From python-dev@python.org Thu Jun 1 00:56:48 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 31 May 2000 16:56:48 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist_rpm.py,1.3,1.4 Message-ID: <200005312356.QAA06648@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv6640 Modified Files: bdist_rpm.py Log Message: Regularize options a bit: * help strings start with lowercase * added affirmative version of '--no-clean' and '--no-rpm-opt-flags', which are the default (thus the attributes that correspond to the options are now 'clean' and 'use_rpm_opt_flags') Index: bdist_rpm.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist_rpm.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** bdist_rpm.py 2000/05/27 17:27:23 1.3 --- bdist_rpm.py 2000/05/31 23:56:45 1.4 *************** *** 6,10 **** # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.3 2000/05/27 17:27:23 gward Exp $" import os, string --- 6,10 ---- # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.4 2000/05/31 23:56:45 gward Exp $" import os, string *************** *** 20,37 **** user_options = [ ('spec-only', None, ! "Only regenerate spec file"), ('source-only', None, ! "Only generate source RPM"), ('binary-only', None, ! "Only generate binary RPM"), ('use-bzip2', None, ! "Use bzip2 instead of gzip to create source distribution"), ('no-clean', None, ! "Do not clean RPM build directory"), ('no-rpm-opt-flags', None, ! "Do not pass any RPM CFLAGS to compiler") ! ] def initialize_options (self): self.spec_only = None --- 20,44 ---- user_options = [ ('spec-only', None, ! "only regenerate spec file"), ('source-only', None, ! "only generate source RPM"), ('binary-only', None, ! "only generate binary RPM"), ('use-bzip2', None, ! "use bzip2 instead of gzip to create source distribution"), ! ('clean', None, ! "clean up RPM build directory [default]"), ('no-clean', None, ! "don't clean up RPM build directory"), ! ('use-rpm-opt-flags', None, ! "compile with RPM_OPT_FLAGS when building from source RPM"), ('no-rpm-opt-flags', None, ! "do not pass any RPM CFLAGS to compiler"), ! ] + negative_opt = {'no-clean': 'clean', + 'no-rpm-opt-flags': 'use-rpm-opt-flags'} + def initialize_options (self): self.spec_only = None *************** *** 39,44 **** self.source_only = None self.use_bzip2 = None ! self.no_clean = None ! self.no_rpm_opt_flags = None # initialize_options() --- 46,51 ---- self.source_only = None self.use_bzip2 = None ! self.clean = 1 ! self.use_rpm_opt_flags = 1 # initialize_options() *************** *** 55,59 **** # don't pass CFLAGS to pure python distributions if not self.distribution.has_ext_modules(): ! self.no_rpm_opt_flags = 1 # finalize_options() --- 62,66 ---- # don't pass CFLAGS to pure python distributions if not self.distribution.has_ext_modules(): ! self.use_rpm_opt_flags = 0 # finalize_options() *************** *** 121,125 **** rpm_args.extend(['--define', '_topdir ' + os.getcwd() + '/build/rpm',]) ! if not self.no_clean: rpm_args.append('--clean') rpm_args.append(spec_path) --- 128,132 ---- rpm_args.extend(['--define', '_topdir ' + os.getcwd() + '/build/rpm',]) ! if self.clean: rpm_args.append('--clean') rpm_args.append(spec_path) *************** *** 169,173 **** self.postun = self._check_string('postun') self.prep = self._check_string('prep', '%setup') ! if not self.no_rpm_opt_flags: self.build = (self._check_string( 'build', --- 176,180 ---- self.postun = self._check_string('postun') self.prep = self._check_string('prep', '%setup') ! if self.use_rpm_opt_flags: self.build = (self._check_string( 'build', From python-dev@python.org Thu Jun 1 01:40:27 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 31 May 2000 17:40:27 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist_rpm.py,1.4,1.5 Message-ID: <200006010040.RAA14660@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv14400 Modified Files: bdist_rpm.py Log Message: More tweaking to make this command act like other Distutils commands: * added "--bdist-base" option to parameterize where we build the RPM (comes from "bdist" by default: "build/bdist.") * simplified/cleaned up some code in 'run()' in the process of removing (most) hard-coded directory names * if "--spec-only", drop spec file in "dist" rather than "redhat" (directory name still hard-coded, though) * use 'reinitialize_command()' to fetch the "sdist" object to tweak before running "sdist" command * use 'self.copy_file()' method rather than 'copy_file()' function * cosmetic tweaks to comments, error messages Index: bdist_rpm.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist_rpm.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** bdist_rpm.py 2000/05/31 23:56:45 1.4 --- bdist_rpm.py 2000/06/01 00:40:25 1.5 *************** *** 6,15 **** # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.4 2000/05/31 23:56:45 gward Exp $" import os, string from types import * from distutils.core import Command ! from distutils.util import mkpath, write_file, copy_file from distutils.errors import * --- 6,15 ---- # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.5 2000/06/01 00:40:25 gward Exp $" import os, string from types import * from distutils.core import Command ! from distutils.util import get_platform, write_file from distutils.errors import * *************** *** 19,22 **** --- 19,24 ---- user_options = [ + ('bdist-base', None, + "base directory for creating built distributions"), ('spec-only', None, "only regenerate spec file"), *************** *** 42,45 **** --- 44,48 ---- def initialize_options (self): + self.bdist_base = None self.spec_only = None self.binary_only = None *************** *** 53,56 **** --- 56,60 ---- def finalize_options (self): + self.set_undefined_options('bdist', ('bdist_base', 'bdist_base')) if os.name != 'posix': raise DistutilsPlatformError, \ *************** *** 59,63 **** if self.binary_only and self.source_only: raise DistutilsOptionsError, \ ! "Cannot supply both '--source-only' and '--binary-only'" # don't pass CFLAGS to pure python distributions if not self.distribution.has_ext_modules(): --- 63,67 ---- if self.binary_only and self.source_only: raise DistutilsOptionsError, \ ! "cannot supply both '--source-only' and '--binary-only'" # don't pass CFLAGS to pure python distributions if not self.distribution.has_ext_modules(): *************** *** 70,99 **** self._get_package_data() # get packaging info - # make directories if self.spec_only: ! self.mkpath('redhat') else: for d in ('SOURCES', 'SPECS', 'BUILD', 'RPMS', 'SRPMS'): ! self.mkpath(os.path.join('build/rpm', d)) ! ! # spec file goes into .redhat directory if '--spec-only specified', ! # into build/rpm/spec otherwise ! if self.spec_only: ! spec_path = 'redhat/%s.spec' % self.distribution.get_name() ! else: ! spec_path = ('build/rpm/SPECS/%s.spec' % ! self.distribution.get_name()) self.execute(write_file, (spec_path, self._make_spec_file()), ! 'Writing .spec file') if self.spec_only: # stop if requested return ! # make a source distribution and copy to SOURCES directory with ! # optional icon ! sdist = self.get_finalized_command ('sdist') if self.use_bzip2: sdist.formats = ['bztar'] --- 74,104 ---- self._get_package_data() # get packaging info # make directories if self.spec_only: ! spec_dir = "dist" ! self.mkpath(spec_dir) # XXX should be configurable else: + rpm_base = os.path.join(self.bdist_base, "rpm") + rpm_dir = {} for d in ('SOURCES', 'SPECS', 'BUILD', 'RPMS', 'SRPMS'): ! rpm_dir[d] = os.path.join(rpm_base, d) ! self.mkpath(rpm_dir[d]) ! spec_dir = rpm_dir['SPECS'] ! ! # Spec file goes into 'dist' directory if '--spec-only specified', ! # into build/rpm. otherwise. ! spec_path = os.path.join(spec_dir, ! "%s.spec" % self.distribution.get_name()) self.execute(write_file, (spec_path, self._make_spec_file()), ! "writing '%s'" % spec_path) if self.spec_only: # stop if requested return ! # Make a source distribution and copy to SOURCES directory with ! # optional icon. ! sdist = self.reinitialize_command ('sdist') if self.use_bzip2: sdist.formats = ['bztar'] *************** *** 101,117 **** sdist.formats = ['gztar'] self.run_command('sdist') ! if self.use_bzip2: ! source = self.distribution.get_fullname() + '.tar.bz2' ! else: ! source = self.distribution.get_fullname() + '.tar.gz' ! self.execute(copy_file, (source, 'build/rpm/SOURCES'), ! 'Copying source distribution to SOURCES') if self.icon: if os.path.exists(self.icon): ! self.execute(copy_file, (self.icon, 'build/rpm/SOURCES'), ! 'Copying icon to SOURCES') else: raise DistutilsFileError, \ ! "Unable to find icon file '%s'" % self.icon --- 106,120 ---- sdist.formats = ['gztar'] self.run_command('sdist') ! ! source = sdist.get_archive_files()[0] ! source_dir = rpm_dir['SOURCES'] ! self.copy_file(source, source_dir) ! if self.icon: if os.path.exists(self.icon): ! self.copy_file(self.icon, source_dir) else: raise DistutilsFileError, \ ! "icon file '%s' does not exist" % self.icon From python-dev@python.org Thu Jun 1 02:08:01 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 31 May 2000 18:08:01 -0700 Subject: [Python-checkins] CVS: distutils/distutils archive_util.py,1.4,1.5 Message-ID: <200006010108.SAA21289@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv21279 Modified Files: archive_util.py Log Message: Ensure that 'make_archive()' returns the name of the new archive file. Index: archive_util.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/archive_util.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** archive_util.py 2000/05/31 02:17:19 1.4 --- archive_util.py 2000/06/01 01:07:55 1.5 *************** *** 6,10 **** # created 2000/04/03, Greg Ward (extracted from util.py) ! __revision__ = "$Id: archive_util.py,v 1.4 2000/05/31 02:17:19 gward Exp $" import os --- 6,10 ---- # created 2000/04/03, Greg Ward (extracted from util.py) ! __revision__ = "$Id: archive_util.py,v 1.5 2000/06/01 01:07:55 gward Exp $" import os *************** *** 128,132 **** root_dir=None, base_dir=None, verbose=0, dry_run=0): - """Create an archive file (eg. zip or tar). 'base_name' is the name of the file to create, minus any format-specific extension; 'format' --- 128,131 ---- *************** *** 137,142 **** ie. 'base_dir' will be the common prefix of all files and directories in the archive. 'root_dir' and 'base_dir' both default ! to the current directory.""" ! save_cwd = os.getcwd() if root_dir is not None: --- 136,141 ---- ie. 'base_dir' will be the common prefix of all files and directories in the archive. 'root_dir' and 'base_dir' both default ! to the current directory. Returns the name of the archive file. ! """ save_cwd = os.getcwd() if root_dir is not None: *************** *** 161,165 **** for (arg,val) in format_info[1]: kwargs[arg] = val ! apply (func, (base_name, base_dir), kwargs) if root_dir is not None: --- 160,164 ---- for (arg,val) in format_info[1]: kwargs[arg] = val ! filename = apply (func, (base_name, base_dir), kwargs) if root_dir is not None: *************** *** 167,170 **** --- 166,171 ---- print "changing back to '%s'" % save_cwd os.chdir (save_cwd) + + return filename # make_archive () From python-dev@python.org Thu Jun 1 02:08:54 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 31 May 2000 18:08:54 -0700 Subject: [Python-checkins] CVS: distutils/distutils cmd.py,1.14,1.15 Message-ID: <200006010108.SAA21322@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv21312 Modified Files: cmd.py Log Message: Added 'reinitialize_command()' method -- delegated to Distribution instance. Ensure 'make_archive()' method returns archive filename. Index: cmd.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/cmd.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** cmd.py 2000/05/28 23:54:00 1.14 --- cmd.py 2000/06/01 01:08:52 1.15 *************** *** 7,11 **** # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: cmd.py,v 1.14 2000/05/28 23:54:00 gward Exp $" import sys, os, string --- 7,11 ---- # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: cmd.py,v 1.15 2000/06/01 01:08:52 gward Exp $" import sys, os, string *************** *** 216,219 **** --- 216,223 ---- return cmd_obj + # XXX rename to 'get_reinitialized_command()'? (should do the + # same in dist.py, if so) + def reinitialize_command (self, command): + return self.distribution.reinitialize_command(command) def run_command (self, command): *************** *** 307,312 **** def make_archive (self, base_name, format, root_dir=None, base_dir=None): ! util.make_archive (base_name, format, root_dir, base_dir, ! self.verbose, self.dry_run) --- 311,316 ---- def make_archive (self, base_name, format, root_dir=None, base_dir=None): ! return util.make_archive (base_name, format, root_dir, base_dir, ! self.verbose, self.dry_run) From python-dev@python.org Thu Jun 1 02:09:49 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 31 May 2000 18:09:49 -0700 Subject: [Python-checkins] CVS: distutils/distutils dist.py,1.21,1.22 Message-ID: <200006010109.SAA21376@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv21367 Modified Files: dist.py Log Message: Oops, 'reinitialize_command()' forgot to return the command object if didn't need to be reinitialized -- fixed. Index: dist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/dist.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -r1.21 -r1.22 *** dist.py 2000/05/28 23:53:06 1.21 --- dist.py 2000/06/01 01:09:47 1.22 *************** *** 7,11 **** # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: dist.py,v 1.21 2000/05/28 23:53:06 gward Exp $" import sys, os, string, re --- 7,11 ---- # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: dist.py,v 1.22 2000/06/01 01:09:47 gward Exp $" import sys, os, string, re *************** *** 712,716 **** if not command.finalized: ! return command.initialize_options() command.finalized = 0 --- 712,716 ---- if not command.finalized: ! return command command.initialize_options() command.finalized = 0 From python-dev@python.org Thu Jun 1 02:10:59 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 31 May 2000 18:10:59 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command sdist.py,1.22,1.23 Message-ID: <200006010110.SAA21571@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv21561/command Modified Files: sdist.py Log Message: Remember the list of archive files created in 'make_distribution()'. Added 'get_archive_files()' so outsiders can get their hands on that list. Index: sdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/sdist.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** sdist.py 2000/05/31 02:32:10 1.22 --- sdist.py 2000/06/01 01:10:56 1.23 *************** *** 5,9 **** # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.22 2000/05/31 02:32:10 gward Exp $" import sys, os, string, re --- 5,9 ---- # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.23 2000/06/01 01:10:56 gward Exp $" import sys, os, string, re *************** *** 65,69 **** --- 65,71 ---- self.keep_tree = 0 + self.archive_files = None + def finalize_options (self): if self.manifest is None: *************** *** 521,529 **** self.make_release_tree (base_dir, self.files) for fmt in self.formats: ! self.make_archive (base_dir, fmt, base_dir=base_dir) if not self.keep_tree: remove_tree (base_dir, self.verbose, self.dry_run) # class sdist --- 523,541 ---- self.make_release_tree (base_dir, self.files) + archive_files = [] # remember names of files we create for fmt in self.formats: ! file = self.make_archive (base_dir, fmt, base_dir=base_dir) ! archive_files.append(file) ! ! self.archive_files = archive_files if not self.keep_tree: remove_tree (base_dir, self.verbose, self.dry_run) + + def get_archive_files (self): + """Return the list of archive files created when the command + was run, or None if the command hasn't run yet. + """ + return self.archive_files # class sdist From python-dev@python.org Thu Jun 1 02:17:20 2000 From: python-dev@python.org (Jeremy Hylton) Date: Wed, 31 May 2000 18:17:20 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib threading.py,1.7,1.8 Message-ID: <200006010117.SAA21927@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv21902 Modified Files: threading.py Log Message: patch from Charles Waldman-- define ThreadError (== thread.error); docs should be updated, too Index: threading.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/threading.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** threading.py 2000/02/29 00:10:24 1.7 --- threading.py 2000/06/01 01:17:17 1.8 *************** *** 19,22 **** --- 19,23 ---- _allocate_lock = thread.allocate_lock _get_ident = thread.get_ident + ThreadError = thread.error del thread From python-dev@python.org Thu Jun 1 03:02:54 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 31 May 2000 19:02:54 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules arraymodule.c,2.39,2.40 posixmodule.c,2.134,2.135 structmodule.c,2.30,2.31 Message-ID: <200006010202.TAA29774@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv29510 Modified Files: arraymodule.c posixmodule.c structmodule.c Log Message: Michael Hudson : Removed PyErr_BadArgument() calls and replaced them with more useful error messages. Index: arraymodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/arraymodule.c,v retrieving revision 2.39 retrieving revision 2.40 diff -C2 -r2.39 -r2.40 *** arraymodule.c 2000/05/03 23:44:31 2.39 --- arraymodule.c 2000/06/01 02:02:46 2.40 *************** *** 541,545 **** arrayobject *np; if (!is_arrayobject(bb)) { ! PyErr_BadArgument(); return NULL; } --- 541,547 ---- arrayobject *np; if (!is_arrayobject(bb)) { ! PyErr_Format(PyExc_TypeError, ! "can only append array (not \"%.200s\") to array", ! bb->ob_type->tp_name); return NULL; } *************** *** 614,618 **** } else { ! PyErr_BadArgument(); return -1; } --- 616,622 ---- } else { ! PyErr_Format(PyExc_TypeError, ! "can only assign array (not \"%.200s\") to array slice", ! v->ob_type->tp_name); return -1; } *************** *** 822,826 **** if (args != NULL) { ! PyErr_BadArgument(); return NULL; } --- 826,831 ---- if (args != NULL) { ! PyErr_SetString(PyExc_TypeError, ! ".reverse requires exactly 0 arguments"); return NULL; } Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.134 retrieving revision 2.135 diff -C2 -r2.134 -r2.135 *** posixmodule.c 2000/05/03 02:44:55 2.134 --- posixmodule.c 2000/06/01 02:02:46 2.135 *************** *** 1563,1568 **** } else { ! badarg: ! PyErr_BadArgument(); return NULL; } --- 1563,1567 ---- } else { ! PyErr_SetString(PyExc_TypeError, "argv must be tuple or list"); return NULL; } *************** *** 1574,1578 **** if (!PyArg_Parse((*getitem)(argv, i), "s", &argvlist[i])) { PyMem_DEL(argvlist); ! goto badarg; } } --- 1573,1579 ---- if (!PyArg_Parse((*getitem)(argv, i), "s", &argvlist[i])) { PyMem_DEL(argvlist); ! PyErr_SetString(PyExc_TypeError, ! "all arguments must be strings"); ! return NULL; } } Index: structmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/structmodule.c,v retrieving revision 2.30 retrieving revision 2.31 diff -C2 -r2.30 -r2.31 *** structmodule.c 2000/02/29 13:59:24 2.30 --- structmodule.c 2000/06/01 02:02:46 2.31 *************** *** 1129,1133 **** (n = PyTuple_Size(args)) < 1) { ! PyErr_BadArgument(); return NULL; } --- 1129,1134 ---- (n = PyTuple_Size(args)) < 1) { ! PyErr_SetString(PyExc_TypeError, ! "struct.pack requires at least one argument"); return NULL; } From python-dev@python.org Thu Jun 1 04:02:50 2000 From: python-dev@python.org (A.M. Kuchling) Date: Wed, 31 May 2000 20:02:50 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules pypcre.c,2.17,2.18 Message-ID: <200006010302.UAA10389@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv4871 Modified Files: pypcre.c Log Message: Fix bug reported by atkins@gweep.net; re.compile(r"[\100-\410]") dumps core. Solution: fix check_escape() to match its comment and use only the low 8 bits of the octal number. Index: pypcre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/pypcre.c,v retrieving revision 2.17 retrieving revision 2.18 diff -C2 -r2.17 -r2.18 *** pypcre.c 2000/02/18 19:16:45 2.17 --- pypcre.c 2000/06/01 03:02:48 2.18 *************** *** 1065,1069 **** while(i++ < 2 && (pcre_ctypes[ptr[1]] & ctype_digit) != 0 && ptr[1] != '8' && ptr[1] != '9') ! c = c * 8 + *(++ptr) - '0'; break; --- 1065,1069 ---- while(i++ < 2 && (pcre_ctypes[ptr[1]] & ctype_digit) != 0 && ptr[1] != '8' && ptr[1] != '9') ! c = (c * 8 + *(++ptr) - '0') & 255; break; From python-dev@python.org Thu Jun 1 04:12:15 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 31 May 2000 20:12:15 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects listobject.c,2.69,2.70 stringobject.c,2.65,2.66 tupleobject.c,2.33,2.34 Message-ID: <200006010312.UAA10844@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv10833 Modified Files: listobject.c stringobject.c tupleobject.c Log Message: Michael Hudson : Removed PyErr_BadArgument() calls and replaced them with more useful error messages. Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.69 retrieving revision 2.70 diff -C2 -r2.69 -r2.70 *** listobject.c 2000/05/03 23:44:35 2.69 --- listobject.c 2000/06/01 03:12:13 2.70 *************** *** 389,393 **** PyListObject *np; if (!PyList_Check(bb)) { ! PyErr_BadArgument(); return NULL; } --- 389,395 ---- PyListObject *np; if (!PyList_Check(bb)) { ! PyErr_Format(PyExc_TypeError, ! "can only append list (not \"%.200s\") to list", ! bb->ob_type->tp_name); return NULL; } *************** *** 470,474 **** } else { ! PyErr_BadArgument(); return -1; } --- 472,478 ---- } else { ! PyErr_Format(PyExc_TypeError, ! "must assign list (not \"%.200s\") to slice", ! v->ob_type->tp_name); return -1; } Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.65 retrieving revision 2.66 diff -C2 -r2.65 -r2.66 *** stringobject.c 2000/05/08 14:08:05 2.65 --- stringobject.c 2000/06/01 03:12:13 2.66 *************** *** 294,298 **** if (PyUnicode_Check(bb)) return PyUnicode_Concat((PyObject *)a, bb); ! PyErr_BadArgument(); return NULL; } --- 294,300 ---- if (PyUnicode_Check(bb)) return PyUnicode_Concat((PyObject *)a, bb); ! PyErr_Format(PyExc_TypeError, ! "cannot add type \"%.200s\" to string", ! bb->ob_type->tp_name); return NULL; } Index: tupleobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/tupleobject.c,v retrieving revision 2.33 retrieving revision 2.34 diff -C2 -r2.33 -r2.34 *** tupleobject.c 2000/05/03 23:44:36 2.33 --- tupleobject.c 2000/06/01 03:12:13 2.34 *************** *** 362,366 **** PyTupleObject *np; if (!PyTuple_Check(bb)) { ! PyErr_BadArgument(); return NULL; } --- 362,368 ---- PyTupleObject *np; if (!PyTuple_Check(bb)) { ! PyErr_Format(PyExc_TypeError, ! "can only append tuple (not \"%.200s\") to tuple", ! bb->ob_type->tp_name); return NULL; } From python-dev@python.org Thu Jun 1 15:31:06 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 1 Jun 2000 07:31:06 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects listobject.c,2.70,2.71 Message-ID: <200006011431.HAA30110@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv30101 Modified Files: listobject.c Log Message: Improve TypeError exception message for list catenation. Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.70 retrieving revision 2.71 diff -C2 -r2.70 -r2.71 *** listobject.c 2000/06/01 03:12:13 2.70 --- listobject.c 2000/06/01 14:31:03 2.71 *************** *** 390,395 **** if (!PyList_Check(bb)) { PyErr_Format(PyExc_TypeError, ! "can only append list (not \"%.200s\") to list", ! bb->ob_type->tp_name); return NULL; } --- 390,395 ---- if (!PyList_Check(bb)) { PyErr_Format(PyExc_TypeError, ! "can only concatenate list (not \"%.200s\") to list", ! bb->ob_type->tp_name); return NULL; } From python-dev@python.org Thu Jun 1 16:47:11 2000 From: python-dev@python.org (Jeremy Hylton) Date: Thu, 1 Jun 2000 08:47:11 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild python16.dsp,1.3,1.4 Message-ID: <200006011547.IAA07995@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv7948 Modified Files: python16.dsp Log Message: add new Python/exceptions.c to python16 project (courtesy Trent Mick) Index: python16.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/python16.dsp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** python16.dsp 2000/04/21 21:26:07 1.3 --- python16.dsp 2000/06/01 15:47:08 1.4 *************** *** 541,544 **** --- 541,559 ---- # Begin Source File + SOURCE=..\python\exceptions.c + + !if "$(cfg)" == "python16 - win32 release" + + !elseif "$(cfg)" == "python16 - win32 debug" + + !elseif "$(cfg)" == "python16 - win32 alpha debug" + + !elseif "$(cfg)" == "python16 - win32 alpha release" + + !endif + + # end source file + # begin source file + SOURCE=..\Objects\fileobject.c From python-dev@python.org Thu Jun 1 18:34:22 2000 From: python-dev@python.org (Jeremy Hylton) Date: Thu, 1 Jun 2000 10:34:22 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.3,2.4 sre.h,2.2,2.3 sre_constants.h,2.2,2.3 Message-ID: <200006011734.KAA26103@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv25984 Modified Files: _sre.c sre.h sre_constants.h Log Message: Fredrik Lundh: here's the 96.6% version of SRE Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.3 retrieving revision 2.4 diff -C2 -r2.3 -r2.4 *** _sre.c 2000/05/03 23:44:30 2.3 --- _sre.c 2000/06/01 17:34:20 2.4 *************** *** 2,11 **** * * Secret Labs' Regular Expression Engine ! * $Id: _sre.c,v 2.3 2000/05/03 23:44:30 guido Exp $ * * simple regular expression matching engine * * partial history: ! * 99-10-24 fl created (bits and pieces from the template matcher) * 99-11-13 fl added categories, branching, and more (0.2) * 99-11-16 fl some tweaks to compile on non-Windows platforms [...1449 lines suppressed...] + 0, /*tp_print*/ + (getattrfunc)_cursor_getattr, /*tp_getattr*/ + }; + static PyMethodDef _functions[] = { {"compile", _compile, 1}, *************** *** 1446,1450 **** { /* Patch object types */ ! Pattern_Type.ob_type = Match_Type.ob_type = &PyType_Type; Py_InitModule("_sre", _functions); --- 1705,1710 ---- { /* Patch object types */ ! Pattern_Type.ob_type = Match_Type.ob_type = ! Cursor_Type.ob_type = &PyType_Type; Py_InitModule("_sre", _functions); Index: sre.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/sre.h,v retrieving revision 2.2 retrieving revision 2.3 diff -C2 -r2.2 -r2.3 *** sre.h 2000/04/10 17:07:24 2.2 --- sre.h 2000/06/01 17:34:20 2.3 *************** *** 1,5 **** /* * Secret Labs' Regular Expression Engine ! * $Id: sre.h,v 2.2 2000/04/10 17:07:24 guido Exp $ * * simple regular expression matching engine --- 1,5 ---- /* * Secret Labs' Regular Expression Engine ! * $Id: sre.h,v 2.3 2000/06/01 17:34:20 jhylton Exp $ * * simple regular expression matching engine *************** *** 15,29 **** #include "sre_constants.h" - /* Python objects */ - typedef struct { PyObject_HEAD PyObject* code; /* link to the code string object */ - PyObject* pattern; /* link to the pattern source (or None) */ int groups; PyObject* groupindex; } PatternObject; ! #define PatternObject_GetCode(o) ((void*) PyString_AS_STRING((o)->code)) typedef struct { --- 15,30 ---- #include "sre_constants.h" typedef struct { PyObject_HEAD PyObject* code; /* link to the code string object */ int groups; PyObject* groupindex; + /* compatibility */ + PyObject* pattern; /* pattern source (or None) */ + int flags; /* flags used when compiling pattern source */ } PatternObject; ! #define PatternObject_GetCode(o)\ ! ((void*) PyString_AS_STRING(((PatternObject*)(o))->code)) typedef struct { *************** *** 35,38 **** } MatchObject; ! #endif --- 36,62 ---- } MatchObject; ! typedef struct { ! /* string pointers */ ! void* ptr; /* current position (also end of current slice) */ ! void* beginning; /* start of original string */ ! void* start; /* start of current slice */ ! void* end; /* end of original string */ ! /* character size */ ! int charsize; ! /* registers */ ! int marks; ! void* mark[64]; /* FIXME: should be dynamically allocated! */ ! /* backtracking stack */ ! void** stack; ! int stacksize; ! int stackbase; ! } SRE_STATE; + typedef struct { + PyObject_HEAD + PyObject* pattern; + PyObject* string; + SRE_STATE state; + } CursorObject; + + #endif Index: sre_constants.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/sre_constants.h,v retrieving revision 2.2 retrieving revision 2.3 diff -C2 -r2.2 -r2.3 *** sre_constants.h 2000/04/10 17:07:24 2.2 --- sre_constants.h 2000/06/01 17:34:20 2.3 *************** *** 1,3 **** ! /* generated by sre_constants.py */ #define SRE_OP_FAILURE 0 #define SRE_OP_SUCCESS 1 --- 1,3 ---- ! /* generated from sre_constants.py */ #define SRE_OP_FAILURE 0 #define SRE_OP_SUCCESS 1 *************** *** 26,27 **** --- 26,49 ---- #define SRE_OP_RANGE 24 #define SRE_OP_REPEAT 25 + #define SRE_AT_BEGINNING 0 + #define SRE_AT_BEGINNING_LINE 1 + #define SRE_AT_BOUNDARY 2 + #define SRE_AT_NON_BOUNDARY 3 + #define SRE_AT_END 4 + #define SRE_AT_END_LINE 5 + #define SRE_CATEGORY_DIGIT 0 + #define SRE_CATEGORY_NOT_DIGIT 1 + #define SRE_CATEGORY_SPACE 2 + #define SRE_CATEGORY_NOT_SPACE 3 + #define SRE_CATEGORY_WORD 4 + #define SRE_CATEGORY_NOT_WORD 5 + #define SRE_CATEGORY_LINEBREAK 6 + #define SRE_CATEGORY_NOT_LINEBREAK 7 + #define SRE_CATEGORY_LOC_DIGIT 8 + #define SRE_CATEGORY_LOC_NOT_DIGIT 9 + #define SRE_CATEGORY_LOC_SPACE 10 + #define SRE_CATEGORY_LOC_NOT_SPACE 11 + #define SRE_CATEGORY_LOC_WORD 12 + #define SRE_CATEGORY_LOC_NOT_WORD 13 + #define SRE_CATEGORY_LOC_LINEBREAK 14 + #define SRE_CATEGORY_LOC_NOT_LINEBREAK 15 From python-dev@python.org Thu Jun 1 18:39:14 2000 From: python-dev@python.org (Jeremy Hylton) Date: Thu, 1 Jun 2000 10:39:14 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre.py,1.4,1.5 sre_compile.py,1.3,1.4 sre_constants.py,1.3,1.4 Message-ID: <200006011739.KAA26462@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv26344 Modified Files: sre.py sre_compile.py sre_constants.py Log Message: Fredrik Lundh: here's the 96.6% version of SRE Index: sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** sre.py 2000/05/02 15:52:33 1.4 --- sre.py 2000/06/01 17:39:12 1.5 *************** *** 1,6 **** - # -*- Mode: Python; tab-width: 4 -*- # # Secret Labs' Regular Expression Engine ! # $Id: sre.py,v 1.4 2000/05/02 15:52:33 guido Exp $ # # re-compatible interface for the sre matching engine --- 1,5 ---- # # Secret Labs' Regular Expression Engine ! # $Id: sre.py,v 1.5 2000/06/01 17:39:12 jhylton Exp $ # # re-compatible interface for the sre matching engine *************** *** 8,14 **** # Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. # - # This code can only be used for 1.6 alpha testing. All other use - # require explicit permission from Secret Labs AB. - # # Portions of this engine have been developed in cooperation with # CNRI. Hewlett-Packard provided funding for 1.6 integration and --- 7,10 ---- *************** *** 16,45 **** # - """ - this is a long string - """ - import sre_compile # -------------------------------------------------------------------- # public interface ! def compile(pattern, flags=0): ! return sre_compile.compile(pattern, _fixflags(flags)) def match(pattern, string, flags=0): ! return compile(pattern, _fixflags(flags)).match(string) def search(pattern, string, flags=0): ! return compile(pattern, _fixflags(flags)).search(string) ! # FIXME: etc # -------------------------------------------------------------------- ! # helpers ! def _fixflags(flags): ! # convert flag bitmask to sequence ! assert not flags ! return () --- 12,132 ---- # import sre_compile + # flags + I = IGNORECASE = sre_compile.SRE_FLAG_IGNORECASE + L = LOCALE = sre_compile.SRE_FLAG_LOCALE + M = MULTILINE = sre_compile.SRE_FLAG_MULTILINE + S = DOTALL = sre_compile.SRE_FLAG_DOTALL + X = VERBOSE = sre_compile.SRE_FLAG_VERBOSE + # -------------------------------------------------------------------- # public interface ! # FIXME: add docstrings def match(pattern, string, flags=0): ! return _compile(pattern, flags).match(string) def search(pattern, string, flags=0): ! return _compile(pattern, flags).search(string) ! ! def sub(pattern, repl, string, count=0): ! return _compile(pattern).sub(repl, string, count) ! ! def subn(pattern, repl, string, count=0): ! return _compile(pattern).subn(repl, string, count) ! ! def split(pattern, string, maxsplit=0): ! return _compile(pattern).split(string, maxsplit) ! ! def findall(pattern, string, maxsplit=0): ! return _compile(pattern).findall(string, maxsplit) ! ! def compile(pattern, flags=0): ! return _compile(pattern, flags) ! def escape(pattern): ! s = list(pattern) ! for i in range(len(pattern)): ! c = pattern[i] ! if not ("a" <= c <= "z" or "A" <= c <= "Z" or "0" <= c <= "9"): ! if c == "\000": ! s[i] = "\\000" ! else: ! s[i] = "\\" + c ! return pattern[:0].join(s) # -------------------------------------------------------------------- ! # internals ! _cache = {} ! _MAXCACHE = 100 + def _compile(pattern, flags=0): + # internal: compile pattern + tp = type(pattern) + if tp not in (type(""), type(u"")): + return pattern + key = (tp, pattern, flags) + try: + return _cache[key] + except KeyError: + pass + p = sre_compile.compile(pattern, flags) + if len(_cache) >= _MAXCACHE: + _cache.clear() + _cache[key] = p + return p + + def _sub(pattern, template, string, count=0): + # internal: pattern.sub implementation hook + return _subn(pattern, template, string, count)[0] + + def _expand(match, template): + # internal: expand template + return template # FIXME + + def _subn(pattern, template, string, count=0): + # internal: pattern.subn implementation hook + if callable(template): + filter = callable + else: + # FIXME: prepare template + def filter(match, template=template): + return _expand(match, template) + n = i = 0 + s = [] + append = s.append + c = pattern.cursor(string) + while not count or n < count: + m = c.search() + if not m: + break + j = m.start() + if j > i: + append(string[i:j]) + append(filter(m)) + i = m.end() + n = n + 1 + if i < len(string): + append(string[i:]) + return string[:0].join(s), n + + def _split(pattern, string, maxsplit=0): + # internal: pattern.split implementation hook + n = i = 0 + s = [] + append = s.append + c = pattern.cursor(string) + while not maxsplit or n < maxsplit: + m = c.search() + if not m: + break + j = m.start() + append(string[i:j]) + i = m.end() + n = n + 1 + if i < len(string): + append(string[i:]) + return s Index: sre_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** sre_compile.py 2000/04/10 17:10:48 1.3 --- sre_compile.py 2000/06/01 17:39:12 1.4 *************** *** 1,5 **** # # Secret Labs' Regular Expression Engine ! # $Id: sre_compile.py,v 1.3 2000/04/10 17:10:48 guido Exp $ # # convert template to internal format --- 1,5 ---- # # Secret Labs' Regular Expression Engine ! # $Id: sre_compile.py,v 1.4 2000/06/01 17:39:12 jhylton Exp $ # # convert template to internal format *************** *** 15,21 **** # - # FIXME: formalize (objectify?) and document the compiler code - # format, so that other frontends can use this compiler - import array, string, sys --- 15,18 ---- *************** *** 46,76 **** def todata(self): # print self.data ! return array.array(WORDSIZE, self.data).tostring() ! ! def _lower(literal): ! # return _sre._lower(literal) # FIXME ! return string.lower(literal) ! def _compile(code, pattern, flags): append = code.append for op, av in pattern: if op is ANY: ! if "s" in flags: ! append(CODES[op]) # any character at all! else: ! append(CODES[NOT_LITERAL]) ! append(10) elif op in (SUCCESS, FAILURE): ! append(CODES[op]) elif op is AT: ! append(CODES[op]) ! append(POSITIONS[av]) elif op is BRANCH: ! append(CODES[op]) tail = [] for av in av[1]: skip = len(code); append(0) ! _compile(code, av, flags) ! append(CODES[JUMP]) tail.append(len(code)); append(0) code[skip] = len(code) - skip --- 43,76 ---- def todata(self): # print self.data ! try: ! return array.array(WORDSIZE, self.data).tostring() ! except OverflowError: ! print self.data ! raise ! def _compile(code, pattern, flags, level=0): append = code.append for op, av in pattern: if op is ANY: ! if flags & SRE_FLAG_DOTALL: ! append(OPCODES[op]) # any character at all! else: ! append(OPCODES[CATEGORY]) ! append(CHCODES[CATEGORY_NOT_LINEBREAK]) elif op in (SUCCESS, FAILURE): ! append(OPCODES[op]) elif op is AT: ! append(OPCODES[op]) ! if flags & SRE_FLAG_MULTILINE: ! append(ATCODES[AT_MULTILINE[av]]) ! else: ! append(ATCODES[av]) elif op is BRANCH: ! append(OPCODES[op]) tail = [] for av in av[1]: skip = len(code); append(0) ! _compile(code, av, flags, level) ! append(OPCODES[JUMP]) tail.append(len(code)); append(0) code[skip] = len(code) - skip *************** *** 79,107 **** code[tail] = len(code) - tail elif op is CALL: ! append(CODES[op]) skip = len(code); append(0) ! _compile(code, av, flags) ! append(CODES[SUCCESS]) code[skip] = len(code) - skip elif op is CATEGORY: # not used by current parser ! append(CODES[op]) ! append(CATEGORIES[av]) elif op is GROUP: ! if "i" in flags: ! append(CODES[MAP_IGNORE[op]]) else: ! append(CODES[op]) ! append(av) elif op is IN: ! if "i" in flags: ! append(CODES[MAP_IGNORE[op]]) def fixup(literal): ! return ord(_lower(literal)) else: ! append(CODES[op]) fixup = ord skip = len(code); append(0) for op, av in av: ! append(CODES[op]) if op is NEGATE: pass --- 79,110 ---- code[tail] = len(code) - tail elif op is CALL: ! append(OPCODES[op]) skip = len(code); append(0) ! _compile(code, av, flags, level+1) ! append(OPCODES[SUCCESS]) code[skip] = len(code) - skip elif op is CATEGORY: # not used by current parser ! append(OPCODES[op]) ! if flags & SRE_FLAG_LOCALE: ! append(CH_LOCALE[CHCODES[av]]) ! else: ! append(CHCODES[av]) elif op is GROUP: ! if flags & SRE_FLAG_IGNORECASE: ! append(OPCODES[OP_IGNORE[op]]) else: ! append(OPCODES[op]) ! append(av-1) elif op is IN: ! if flags & SRE_FLAG_IGNORECASE: ! append(OPCODES[OP_IGNORE[op]]) def fixup(literal): ! return ord(literal.lower()) else: ! append(OPCODES[op]) fixup = ord skip = len(code); append(0) for op, av in av: ! append(OPCODES[op]) if op is NEGATE: pass *************** *** 112,129 **** append(fixup(av[1])) elif op is CATEGORY: ! append(CATEGORIES[av]) else: raise ValueError, "unsupported set operator" ! append(CODES[FAILURE]) code[skip] = len(code) - skip elif op in (LITERAL, NOT_LITERAL): ! if "i" in flags: ! append(CODES[MAP_IGNORE[op]]) ! append(ord(_lower(av))) else: ! append(CODES[op]) append(ord(av)) elif op is MARK: ! append(CODES[op]) append(av) elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): --- 115,135 ---- append(fixup(av[1])) elif op is CATEGORY: ! if flags & SRE_FLAG_LOCALE: ! append(CH_LOCALE[CHCODES[av]]) ! else: ! append(CHCODES[av]) else: raise ValueError, "unsupported set operator" ! append(OPCODES[FAILURE]) code[skip] = len(code) - skip elif op in (LITERAL, NOT_LITERAL): ! if flags & SRE_FLAG_IGNORECASE: ! append(OPCODES[OP_IGNORE[op]]) ! append(ord(av.lower())) else: ! append(OPCODES[op]) append(ord(av)) elif op is MARK: ! append(OPCODES[op]) append(av) elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): *************** *** 132,167 **** raise SyntaxError, "cannot repeat zero-width items" if lo == hi == 1 and op is MAX_REPEAT: ! append(CODES[MAX_REPEAT_ONE]) skip = len(code); append(0) append(av[0]) append(av[1]) ! _compile(code, av[2], flags) ! append(CODES[SUCCESS]) code[skip] = len(code) - skip else: ! append(CODES[op]) skip = len(code); append(0) append(av[0]) append(av[1]) ! _compile(code, av[2], flags) if op is MIN_REPEAT: ! append(CODES[MIN_UNTIL]) else: ! # FIXME: MAX_REPEAT PROBABLY DOESN'T WORK (?) ! append(CODES[MAX_UNTIL]) code[skip] = len(code) - skip elif op is SUBPATTERN: ! ## group = av[0] ! ## if group: ! ## append(CODES[MARK]) ! ## append((group-1)*2) ! _compile(code, av[1], flags) ! ## if group: ! ## append(CODES[MARK]) ! ## append((group-1)*2+1) else: raise ValueError, ("unsupported operand type", op) ! def compile(p, flags=()): # convert pattern list to internal format if type(p) in (type(""), type(u"")): --- 138,172 ---- raise SyntaxError, "cannot repeat zero-width items" if lo == hi == 1 and op is MAX_REPEAT: ! append(OPCODES[MAX_REPEAT_ONE]) skip = len(code); append(0) append(av[0]) append(av[1]) ! _compile(code, av[2], flags, level+1) ! append(OPCODES[SUCCESS]) code[skip] = len(code) - skip else: ! append(OPCODES[op]) skip = len(code); append(0) append(av[0]) append(av[1]) ! _compile(code, av[2], flags, level+1) if op is MIN_REPEAT: ! append(OPCODES[MIN_UNTIL]) else: ! append(OPCODES[MAX_UNTIL]) code[skip] = len(code) - skip elif op is SUBPATTERN: ! group = av[0] ! if group: ! append(OPCODES[MARK]) ! append((group-1)*2) ! _compile(code, av[1], flags, level+1) ! if group: ! append(OPCODES[MARK]) ! append((group-1)*2+1) else: raise ValueError, ("unsupported operand type", op) ! def compile(p, flags=0): # convert pattern list to internal format if type(p) in (type(""), type(u"")): *************** *** 171,180 **** else: pattern = None ! # print p.getwidth() ! # print p code = Code() ! _compile(code, p.data, p.pattern.flags) ! code.append(CODES[SUCCESS]) ! # print list(code.data) data = code.todata() if 0: # debugging --- 176,183 ---- else: pattern = None ! flags = p.pattern.flags | flags code = Code() ! _compile(code, p.data, flags) ! code.append(OPCODES[SUCCESS]) data = code.todata() if 0: # debugging *************** *** 184,187 **** sre_disasm.disasm(data) print "-" * 68 ! # print len(data), p.pattern.groups, len(p.pattern.groupdict) ! return _sre.compile(pattern, data, p.pattern.groups-1, p.pattern.groupdict) --- 187,193 ---- sre_disasm.disasm(data) print "-" * 68 ! return _sre.compile( ! pattern, flags, ! data, ! p.pattern.groups-1, p.pattern.groupdict ! ) Index: sre_constants.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_constants.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** sre_constants.py 2000/04/10 17:10:48 1.3 --- sre_constants.py 2000/06/01 17:39:12 1.4 *************** *** 1,5 **** # # Secret Labs' Regular Expression Engine ! # $Id: sre_constants.py,v 1.3 2000/04/10 17:10:48 guido Exp $ # # various symbols used by the regular expression engine. --- 1,5 ---- # # Secret Labs' Regular Expression Engine ! # $Id: sre_constants.py,v 1.4 2000/06/01 17:39:12 jhylton Exp $ # # various symbols used by the regular expression engine. *************** *** 49,58 **** # positions AT_BEGINNING = "at_beginning" AT_BOUNDARY = "at_boundary" AT_NON_BOUNDARY = "at_non_boundary" AT_END = "at_end" # categories - CATEGORY_DIGIT = "category_digit" CATEGORY_NOT_DIGIT = "category_not_digit" --- 49,59 ---- # positions AT_BEGINNING = "at_beginning" + AT_BEGINNING_LINE = "at_beginning_line" AT_BOUNDARY = "at_boundary" AT_NON_BOUNDARY = "at_non_boundary" AT_END = "at_end" + AT_END_LINE = "at_end_line" # categories CATEGORY_DIGIT = "category_digit" CATEGORY_NOT_DIGIT = "category_not_digit" *************** *** 61,66 **** CATEGORY_WORD = "category_word" CATEGORY_NOT_WORD = "category_not_word" ! CODES = [ # failure=0 success=1 (just because it looks better that way :-) --- 62,77 ---- CATEGORY_WORD = "category_word" CATEGORY_NOT_WORD = "category_not_word" + CATEGORY_LINEBREAK = "category_linebreak" + CATEGORY_NOT_LINEBREAK = "category_not_linebreak" + CATEGORY_LOC_DIGIT = "category_loc_digit" + CATEGORY_LOC_NOT_DIGIT = "category_loc_not_digit" + CATEGORY_LOC_SPACE = "category_loc_space" + CATEGORY_LOC_NOT_SPACE = "category_loc_not_space" + CATEGORY_LOC_WORD = "category_loc_word" + CATEGORY_LOC_NOT_WORD = "category_loc_not_word" + CATEGORY_LOC_LINEBREAK = "category_loc_linebreak" + CATEGORY_LOC_NOT_LINEBREAK = "category_loc_not_linebreak" ! OPCODES = [ # failure=0 success=1 (just because it looks better that way :-) *************** *** 87,101 **** ] ! # convert to dictionary ! c = {} ! i = 0 ! for code in CODES: ! c[code] = i ! i = i + 1 ! CODES = c # replacement operations for "ignore case" mode ! MAP_IGNORE = { GROUP: GROUP_IGNORE, IN: IN_IGNORE, --- 98,130 ---- ] + + ATCODES = [ + AT_BEGINNING, AT_BEGINNING_LINE, AT_BOUNDARY, + AT_NON_BOUNDARY, AT_END, AT_END_LINE + ] ! CHCODES = [ ! CATEGORY_DIGIT, CATEGORY_NOT_DIGIT, CATEGORY_SPACE, ! CATEGORY_NOT_SPACE, CATEGORY_WORD, CATEGORY_NOT_WORD, ! CATEGORY_LINEBREAK, CATEGORY_NOT_LINEBREAK, CATEGORY_LOC_DIGIT, ! CATEGORY_LOC_NOT_DIGIT, CATEGORY_LOC_SPACE, ! CATEGORY_LOC_NOT_SPACE, CATEGORY_LOC_WORD, CATEGORY_LOC_NOT_WORD, ! CATEGORY_LOC_LINEBREAK, CATEGORY_LOC_NOT_LINEBREAK ! ] ! ! def makedict(list): ! d = {} ! i = 0 ! for item in list: ! d[item] = i ! i = i + 1 ! return d ! ! OPCODES = makedict(OPCODES) ! ATCODES = makedict(ATCODES) ! CHCODES = makedict(CHCODES) # replacement operations for "ignore case" mode ! OP_IGNORE = { GROUP: GROUP_IGNORE, IN: IN_IGNORE, *************** *** 104,131 **** } ! POSITIONS = { ! AT_BEGINNING: ord("a"), ! AT_BOUNDARY: ord("b"), ! AT_NON_BOUNDARY: ord("B"), ! AT_END: ord("z"), } ! CATEGORIES = { ! CATEGORY_DIGIT: ord("d"), ! CATEGORY_NOT_DIGIT: ord("D"), ! CATEGORY_SPACE: ord("s"), ! CATEGORY_NOT_SPACE: ord("S"), ! CATEGORY_WORD: ord("w"), ! CATEGORY_NOT_WORD: ord("W"), } if __name__ == "__main__": import string ! items = CODES.items() ! items.sort(lambda a, b: cmp(a[1], b[1])) f = open("sre_constants.h", "w") ! f.write("/* generated by sre_constants.py */\n") ! for k, v in items: ! f.write("#define SRE_OP_" + string.upper(k) + " " + str(v) + "\n") f.close() print "done" --- 133,172 ---- } ! AT_MULTILINE = { ! AT_BEGINNING: AT_BEGINNING_LINE, ! AT_END: AT_END_LINE } ! CH_LOCALE = { ! CATEGORY_DIGIT: CATEGORY_LOC_DIGIT, ! CATEGORY_NOT_DIGIT: CATEGORY_LOC_NOT_DIGIT, ! CATEGORY_SPACE: CATEGORY_LOC_SPACE, ! CATEGORY_NOT_SPACE: CATEGORY_LOC_NOT_SPACE, ! CATEGORY_WORD: CATEGORY_LOC_WORD, ! CATEGORY_NOT_WORD: CATEGORY_LOC_NOT_WORD, ! CATEGORY_LINEBREAK: CATEGORY_LOC_LINEBREAK, ! CATEGORY_NOT_LINEBREAK: CATEGORY_LOC_NOT_LINEBREAK } + # flags + SRE_FLAG_TEMPLATE = 1 # NYI + SRE_FLAG_IGNORECASE = 2 + SRE_FLAG_LOCALE = 4 + SRE_FLAG_MULTILINE = 8 + SRE_FLAG_DOTALL = 16 + SRE_FLAG_VERBOSE = 32 + if __name__ == "__main__": import string ! def dump(f, d, prefix): ! items = d.items() ! items.sort(lambda a, b: cmp(a[1], b[1])) ! for k, v in items: ! f.write("#define %s_%s %s\n" % (prefix, string.upper(k), v)) f = open("sre_constants.h", "w") ! f.write("/* generated from sre_constants.py */\n") ! dump(f, OPCODES, "SRE_OP") ! dump(f, ATCODES, "SRE") ! dump(f, CHCODES, "SRE") f.close() print "done" From python-dev@python.org Thu Jun 1 18:59:19 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 1 Jun 2000 10:59:19 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_math.py,1.3,1.4 Message-ID: <200006011759.KAA28240@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv28145 Modified Files: test_math.py Log Message: Trent Mick : Fix test of the "math" module so it does not break on platforms that do not offer rint(); just skip that portion of the test in that case. Index: test_math.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_math.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** test_math.py 2000/05/11 18:19:41 1.3 --- test_math.py 2000/06/01 17:59:17 1.4 *************** *** 131,138 **** print 'rint' ! testit('rint(0.7)', math.rint(0.7), 1) ! testit('rint(-0.3)', math.rint(-0.3), 0) ! testit('rint(2.5)', math.rint(2.5), 2) ! testit('rint(3.5)', math.rint(3.5), 4) print 'sin' --- 131,144 ---- print 'rint' ! try: ! math.rint ! except AttributeError: ! # this platform does not have rint, that is fine, skip the test ! pass ! else: ! testit('rint(0.7)', math.rint(0.7), 1) ! testit('rint(-0.3)', math.rint(-0.3), 0) ! testit('rint(2.5)', math.rint(2.5), 2) ! testit('rint(3.5)', math.rint(3.5), 4) print 'sin' From python-dev@python.org Thu Jun 1 19:37:38 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 1 Jun 2000 11:37:38 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects longobject.c,1.57,1.58 Message-ID: <200006011837.LAA03494@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv3484 Modified Files: longobject.c Log Message: Trent Mick : This patch correct bounds checking in PyLong_FromLongLong. Currently, it does not check properly for negative values when checking to see if the incoming value fits in a long or unsigned long. This results in possible silent truncation of the value for very large negative values. Index: longobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/longobject.c,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -r1.57 -r1.58 *** longobject.c 2000/05/03 23:44:35 1.57 --- longobject.c 2000/06/01 18:37:36 1.58 *************** *** 356,363 **** return PyLong_FromLong( (long)ival ); #else ! if( ival <= (LONG_LONG)LONG_MAX ) { return PyLong_FromLong( (long)ival ); } ! else if( ival <= (unsigned LONG_LONG)ULONG_MAX ) { return PyLong_FromUnsignedLong( (unsigned long)ival ); } --- 356,363 ---- return PyLong_FromLong( (long)ival ); #else ! if ((LONG_LONG)LONG_MIN <= ival && ival <= (LONG_LONG)LONG_MAX) { return PyLong_FromLong( (long)ival ); } ! else if (0 <= ival && ival <= (unsigned LONG_LONG)ULONG_MAX) { return PyLong_FromUnsignedLong( (unsigned long)ival ); } From python-dev@python.org Fri Jun 2 01:44:55 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 1 Jun 2000 17:44:55 -0700 Subject: [Python-checkins] CVS: distutils/distutils dist.py,1.22,1.23 cmd.py,1.15,1.16 core.py,1.38,1.39 Message-ID: <200006020044.RAA27038@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv27024 Modified Files: dist.py cmd.py core.py Log Message: Reformatted and updated many docstrings. Index: dist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/dist.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** dist.py 2000/06/01 01:09:47 1.22 --- dist.py 2000/06/02 00:44:53 1.23 *************** *** 2,11 **** Provides the Distribution class, which represents the module distribution ! being built/installed/distributed.""" # created 2000/04/03, Greg Ward # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: dist.py,v 1.22 2000/06/01 01:09:47 gward Exp $" import sys, os, string, re --- 2,12 ---- Provides the Distribution class, which represents the module distribution ! being built/installed/distributed. ! """ # created 2000/04/03, Greg Ward # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: dist.py,v 1.23 2000/06/02 00:44:53 gward Exp $" import sys, os, string, re *************** *** 26,43 **** class Distribution: ! """The core of the Distutils. Most of the work hiding behind ! 'setup' is really done within a Distribution instance, which ! farms the work out to the Distutils commands specified on the ! command line. ! ! Clients will almost never instantiate Distribution directly, ! unless the 'setup' function is totally inadequate to their needs. ! However, it is conceivable that a client might wish to subclass ! Distribution for some specialized purpose, and then pass the ! subclass to 'setup' as the 'distclass' keyword argument. If so, ! it is necessary to respect the expectations that 'setup' has of ! Distribution: it must have a constructor and methods ! 'parse_command_line()' and 'run_commands()' with signatures like ! those described below.""" --- 27,42 ---- class Distribution: ! """The core of the Distutils. Most of the work hiding behind 'setup' ! is really done within a Distribution instance, which farms the work out ! to the Distutils commands specified on the command line. ! ! Setup scripts will almost never instantiate Distribution directly, ! unless the 'setup()' function is totally inadequate to their needs. ! However, it is conceivable that a setup script might wish to subclass ! Distribution for some specialized purpose, and then pass the subclass ! to 'setup()' as the 'distclass' keyword argument. If so, it is ! necessary to respect the expectations that 'setup' has of Distribution. ! See the code for 'setup()', in core.py, for details. ! """ *************** *** 99,110 **** def __init__ (self, attrs=None): """Construct a new Distribution instance: initialize all the ! attributes of a Distribution, and then uses 'attrs' (a ! dictionary mapping attribute names to values) to assign ! some of those attributes their "real" values. (Any attributes ! not mentioned in 'attrs' will be assigned to some null ! value: 0, None, an empty list or dictionary, etc.) Most ! importantly, initialize the 'command_obj' attribute ! to the empty dictionary; this will be filled in with real ! command objects by 'parse_command_line()'.""" # Default values for our command-line options --- 98,109 ---- def __init__ (self, attrs=None): """Construct a new Distribution instance: initialize all the ! attributes of a Distribution, and then use 'attrs' (a dictionary ! mapping attribute names to values) to assign some of those ! attributes their "real" values. (Any attributes not mentioned in ! 'attrs' will be assigned to some null value: 0, None, an empty list ! or dictionary, etc.) Most importantly, initialize the ! 'command_obj' attribute to the empty dictionary; this will be ! filled in with real command objects by 'parse_command_line()'. ! """ # Default values for our command-line options *************** *** 388,392 **** def _parse_command_opts (self, parser, args): - """Parse the command-line options for a single command. 'parser' must be a FancyGetopt instance; 'args' must be the list --- 387,390 ---- *************** *** 667,671 **** def _set_command_options (self, command_obj, option_dict=None): - """Set the options for 'command_obj' from 'option_dict'. Basically this means copying elements of a dictionary ('option_dict') to --- 665,668 ---- Index: cmd.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/cmd.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** cmd.py 2000/06/01 01:08:52 1.15 --- cmd.py 2000/06/02 00:44:53 1.16 *************** *** 2,11 **** Provides the Command class, the base class for the command classes ! in the distutils.command package.""" # created 2000/04/03, Greg Ward # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: cmd.py,v 1.15 2000/06/01 01:08:52 gward Exp $" import sys, os, string --- 2,12 ---- Provides the Command class, the base class for the command classes ! in the distutils.command package. ! """ # created 2000/04/03, Greg Ward # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: cmd.py,v 1.16 2000/06/02 00:44:53 gward Exp $" import sys, os, string *************** *** 17,33 **** class Command: """Abstract base class for defining command classes, the "worker bees" ! of the Distutils. A useful analogy for command classes is to ! think of them as subroutines with local variables called ! "options". The options are "declared" in 'initialize_options()' ! and "defined" (given their final values, aka "finalized") in ! 'finalize_options()', both of which must be defined by every ! command class. The distinction between the two is necessary ! because option values might come from the outside world (command ! line, option file, ...), and any options dependent on other ! options must be computed *after* these outside influences have ! been processed -- hence 'finalize_options()'. The "body" of the ! subroutine, where it does all its work based on the values of its ! options, is the 'run()' method, which must also be implemented by ! every command class.""" # -- Creation/initialization methods ------------------------------- --- 18,34 ---- class Command: """Abstract base class for defining command classes, the "worker bees" ! of the Distutils. A useful analogy for command classes is to think of ! them as subroutines with local variables called "options". The options ! are "declared" in 'initialize_options()' and "defined" (given their ! final values, aka "finalized") in 'finalize_options()', both of which ! must be defined by every command class. The distinction between the ! two is necessary because option values might come from the outside ! world (command line, config file, ...), and any options dependent on ! other options must be computed *after* these outside influences have ! been processed -- hence 'finalize_options()'. The "body" of the ! subroutine, where it does all its work based on the values of its ! options, is the 'run()' method, which must also be implemented by every ! command class. ! """ # -- Creation/initialization methods ------------------------------- *************** *** 35,42 **** def __init__ (self, dist): """Create and initialize a new Command object. Most importantly, ! invokes the 'initialize_options()' method, which is the ! real initializer and depends on the actual command being ! instantiated.""" ! # late import because of mutual dependence between these classes from distutils.dist import Distribution --- 36,43 ---- def __init__ (self, dist): """Create and initialize a new Command object. Most importantly, ! invokes the 'initialize_options()' method, which is the real ! initializer and depends on the actual command being ! instantiated. ! """ # late import because of mutual dependence between these classes from distutils.dist import Distribution *************** *** 98,104 **** # Subclasses must define: # initialize_options() ! # provide default values for all options; may be overridden ! # by Distutils client, by command-line options, or by options ! # from option file # finalize_options() # decide on the final values for all options; this is called --- 99,105 ---- # Subclasses must define: # initialize_options() ! # provide default values for all options; may be customized by ! # setup script, by options from config file(s), or by command-line ! # options # finalize_options() # decide on the final values for all options; this is called *************** *** 111,136 **** def initialize_options (self): """Set default values for all the options that this command ! supports. Note that these defaults may be overridden ! by the command-line supplied by the user; thus, this is ! not the place to code dependencies between options; generally, ! 'initialize_options()' implementations are just a bunch ! of "self.foo = None" assignments. ! ! This method must be implemented by all command classes.""" raise RuntimeError, \ "abstract method -- subclass %s must override" % self.__class__ def finalize_options (self): ! """Set final values for all the options that this command ! supports. This is always called as late as possible, ie. ! after any option assignments from the command-line or from ! other commands have been done. Thus, this is the place to to ! code option dependencies: if 'foo' depends on 'bar', then it ! is safe to set 'foo' from 'bar' as long as 'foo' still has ! the same value it was assigned in 'initialize_options()'. ! This method must be implemented by all command classes.""" ! raise RuntimeError, \ "abstract method -- subclass %s must override" % self.__class__ --- 112,137 ---- def initialize_options (self): """Set default values for all the options that this command ! supports. Note that these defaults may be overridden by other ! commands, by the setup script, by config files, or by the ! command-line. Thus, this is not the place to code dependencies ! between options; generally, 'initialize_options()' implementations ! are just a bunch of "self.foo = None" assignments. + This method must be implemented by all command classes. + """ raise RuntimeError, \ "abstract method -- subclass %s must override" % self.__class__ def finalize_options (self): ! """Set final values for all the options that this command supports. ! This is always called as late as possible, ie. after any option ! assignments from the command-line or from other commands have been ! done. Thus, this is the place to to code option dependencies: if ! 'foo' depends on 'bar', then it is safe to set 'foo' from 'bar' as ! long as 'foo' still has the same value it was assigned in ! 'initialize_options()'. ! This method must be implemented by all command classes. ! """ raise RuntimeError, \ "abstract method -- subclass %s must override" % self.__class__ *************** *** 152,163 **** def run (self): ! """A command's raison d'etre: carry out the action it exists ! to perform, controlled by the options initialized in ! 'initialize_options()', customized by the user and other ! commands, and finalized in 'finalize_options()'. All ! terminal output and filesystem interaction should be done by ! 'run()'. ! This method must be implemented by all command classes.""" raise RuntimeError, \ --- 153,165 ---- def run (self): ! """A command's raison d'etre: carry out the action it exists to ! perform, controlled by the options initialized in ! 'initialize_options()', customized by other commands, the setup ! script, the command-line, and config files, and finalized in ! 'finalize_options()'. All terminal output and filesystem ! interaction should be done by 'run()'. ! This method must be implemented by all command classes. ! """ raise RuntimeError, \ *************** *** 165,172 **** def announce (self, msg, level=1): ! """If the Distribution instance to which this command belongs ! has a verbosity level of greater than or equal to 'level' ! print 'msg' to stdout.""" ! if self.verbose >= level: print msg --- 167,173 ---- def announce (self, msg, level=1): ! """If the current verbosity level is of greater than or equal to ! 'level' print 'msg' to stdout. ! """ if self.verbose >= level: print msg *************** *** 184,199 **** def set_undefined_options (self, src_cmd, *option_pairs): """Set the values of any "undefined" options from corresponding ! option values in some other command object. "Undefined" here ! means "is None", which is the convention used to indicate ! that an option has not been changed between ! 'set_initial_values()' and 'set_final_values()'. Usually ! called from 'set_final_values()' for options that depend on ! some other command rather than another option of the same ! command. 'src_cmd' is the other command from which option ! values will be taken (a command object will be created for it ! if necessary); the remaining arguments are ! '(src_option,dst_option)' tuples which mean "take the value ! of 'src_option' in the 'src_cmd' command object, and copy it ! to 'dst_option' in the current command object".""" # Option_pairs: list of (src_option, dst_option) tuples --- 185,200 ---- def set_undefined_options (self, src_cmd, *option_pairs): """Set the values of any "undefined" options from corresponding ! option values in some other command object. "Undefined" here means ! "is None", which is the convention used to indicate that an option ! has not been changed between 'initialize_options()' and ! 'finalize_options()'. Usually called from 'finalize_options()' for ! options that depend on some other command rather than another ! option of the same command. 'src_cmd' is the other command from ! which option values will be taken (a command object will be created ! for it if necessary); the remaining arguments are ! '(src_option,dst_option)' tuples which mean "take the value of ! 'src_option' in the 'src_cmd' command object, and copy it to ! 'dst_option' in the current command object". ! """ # Option_pairs: list of (src_option, dst_option) tuples *************** *** 208,215 **** def get_finalized_command (self, command, create=1): ! """Wrapper around Distribution's 'get_command_obj()' method: ! find (create if necessary and 'create' is true) the command ! object for 'command'..""" ! cmd_obj = self.distribution.get_command_obj (command, create) cmd_obj.ensure_finalized () --- 209,217 ---- def get_finalized_command (self, command, create=1): ! """Wrapper around Distribution's 'get_command_obj()' method: find ! (create if necessary and 'create' is true) the command object for ! 'command', call its 'ensure_finalized()' method, and return the ! finalized command object. ! """ cmd_obj = self.distribution.get_command_obj (command, create) cmd_obj.ensure_finalized () *************** *** 223,229 **** def run_command (self, command): """Run some other command: uses the 'run_command()' method of ! Distribution, which creates the command object if necessary ! and then invokes its 'run()' method.""" ! self.distribution.run_command (command) --- 225,231 ---- def run_command (self, command): """Run some other command: uses the 'run_command()' method of ! Distribution, which creates and finalizes the command object if ! necessary and then invokes its 'run()' method. ! """ self.distribution.run_command (command) *************** *** 237,249 **** def execute (self, func, args, msg=None, level=1): ! """Perform some action that affects the outside world (eg. ! by writing to the filesystem). Such actions are special because ! they should be disabled by the "dry run" flag, and should ! announce themselves if the current verbosity level is high ! enough. This method takes care of all that bureaucracy for you; ! all you have to do is supply the funtion to call and an argument ! tuple for it (to embody the "external action" being performed), ! a message to print if the verbosity level is high enough, and an ! optional verbosity threshold.""" # Generate a message if we weren't passed one --- 239,252 ---- def execute (self, func, args, msg=None, level=1): ! """Perform some action that affects the outside world (eg. by ! writing to the filesystem). Such actions are special because they ! should be disabled by the "dry run" flag, and should announce ! themselves if the current verbosity level is high enough. This ! method takes care of all that bureaucracy for you; all you have to ! do is supply the funtion to call and an argument tuple for it (to ! embody the "external action" being performed), a message to print ! if the verbosity level is high enough, and an optional verbosity ! threshold. ! """ # Generate a message if we weren't passed one *************** *** 286,291 **** level=1): """Copy an entire directory tree respecting verbose, dry-run, ! and force flags.""" ! return util.copy_tree (infile, outfile, preserve_mode,preserve_times,preserve_symlinks, --- 289,294 ---- level=1): """Copy an entire directory tree respecting verbose, dry-run, ! and force flags. ! """ return util.copy_tree (infile, outfile, preserve_mode,preserve_times,preserve_symlinks, *************** *** 303,306 **** --- 306,310 ---- def spawn (self, cmd, search_path=1, level=1): + """Spawn an external command respecting verbose and dry-run flags.""" from distutils.spawn import spawn spawn (cmd, search_path, *************** *** 317,321 **** def make_file (self, infiles, outfile, func, args, exec_msg=None, skip_msg=None, level=1): - """Special case of 'execute()' for operations that process one or more input files and generate one output file. Works just like --- 321,324 ---- *************** *** 324,330 **** files listed in 'infiles'. If the command defined 'self.force', and it is true, then the command is unconditionally run -- does no ! timestamp checks.""" ! ! if exec_msg is None: exec_msg = "generating %s from %s" % \ --- 327,332 ---- files listed in 'infiles'. If the command defined 'self.force', and it is true, then the command is unconditionally run -- does no ! timestamp checks. ! """ if exec_msg is None: exec_msg = "generating %s from %s" % \ Index: core.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/core.py,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -r1.38 -r1.39 *** core.py 2000/05/31 01:11:20 1.38 --- core.py 2000/06/02 00:44:53 1.39 *************** *** 4,12 **** the 'setup' function (which is to be called from the setup script). Also indirectly provides the Distribution and Command classes, although they are ! really defined in distutils.dist and distutils.cmd.""" # created 1999/03/01, Greg Ward ! __revision__ = "$Id: core.py,v 1.38 2000/05/31 01:11:20 gward Exp $" import sys, os --- 4,13 ---- the 'setup' function (which is to be called from the setup script). Also indirectly provides the Distribution and Command classes, although they are ! really defined in distutils.dist and distutils.cmd. ! """ # created 1999/03/01, Greg Ward ! __revision__ = "$Id: core.py,v 1.39 2000/06/02 00:44:53 gward Exp $" import sys, os *************** *** 38,71 **** def setup (**attrs): ! """The gateway to the Distutils: do everything your setup script ! needs to do, in a highly flexible and user-driven way. Briefly: ! create a Distribution instance; parse the command-line, creating ! and customizing instances of the command class for each command ! found on the command-line; run each of those commands. ! ! The Distribution instance might be an instance of a class ! supplied via the 'distclass' keyword argument to 'setup'; if no ! such class is supplied, then the 'Distribution' class (also in ! this module) is instantiated. All other arguments to 'setup' ! (except for 'cmdclass') are used to set attributes of the ! Distribution instance. ! ! The 'cmdclass' argument, if supplied, is a dictionary mapping ! command names to command classes. Each command encountered on ! the command line will be turned into a command class, which is in ! turn instantiated; any class found in 'cmdclass' is used in place ! of the default, which is (for command 'foo_bar') class 'foo_bar' ! in module 'distutils.command.foo_bar'. The command class must ! provide a 'user_options' attribute which is a list of option ! specifiers for 'distutils.fancy_getopt'. Any command-line ! options between the current and the next command are used to set ! attributes of the current command object. ! ! When the entire command-line has been successfully parsed, calls ! the 'run()' method on each command object in turn. This method ! will be driven entirely by the Distribution object (which each ! command object has a reference to, thanks to its constructor), ! and the command-specific options that became attributes of each ! command object.""" from pprint import pprint # for debugging output --- 39,73 ---- def setup (**attrs): ! """The gateway to the Distutils: do everything your setup script needs ! to do, in a highly flexible and user-driven way. Briefly: create a ! Distribution instance; find and parse config files; parse the command ! line; run each of those commands using the options supplied to ! 'setup()' (as keyword arguments), in config files, and on the command ! line. ! ! The Distribution instance might be an instance of a class supplied via ! the 'distclass' keyword argument to 'setup'; if no such class is ! supplied, then the Distribution class (in dist.py) is instantiated. ! All other arguments to 'setup' (except for 'cmdclass') are used to set ! attributes of the Distribution instance. ! ! The 'cmdclass' argument, if supplied, is a dictionary mapping command ! names to command classes. Each command encountered on the command line ! will be turned into a command class, which is in turn instantiated; any ! class found in 'cmdclass' is used in place of the default, which is ! (for command 'foo_bar') class 'foo_bar' in module ! 'distutils.command.foo_bar'. The command class must provide a ! 'user_options' attribute which is a list of option specifiers for ! 'distutils.fancy_getopt'. Any command-line options between the current ! and the next command are used to set attributes of the current command ! object. ! ! When the entire command-line has been successfully parsed, calls the ! 'run()' method on each command object in turn. This method will be ! driven entirely by the Distribution object (which each command object ! has a reference to, thanks to its constructor), and the ! command-specific options that became attributes of each command ! object. ! """ from pprint import pprint # for debugging output From python-dev@python.org Fri Jun 2 02:50:01 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 1 Jun 2000 18:50:01 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist_rpm.py,1.5,1.6 Message-ID: <200006020150.SAA02834@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv2562/command Modified Files: bdist_rpm.py Log Message: Fairly massive overhaul to support getting RPM inputs (extra meta-data, prep/build/etc. scripts, doc files, dependency info) from a config file rather than the dedicated "package_info" file. (The idea is that developers will provide RPM-specific info in the "[bdist_rpm]" section of setup.cfg, but of course it could also be supplied in the other config files, on the command line, or in the setup script -- or any mix of the above.) Major changes: * added a boatload of options to 'user_options' and 'initialize_options()': 'distribution_name', 'group', 'release', ... * added 'finalize_package_data()', which takes the place of '_get_package_data()' -- except it's called from 'finalize_options()', not 'run()', so we have everything figured out before we actually run the command * added 'ensure_string()', 'ensure_string_list()', 'ensure_filename()'; these take the place of '_check_string()' and friends. (These actually look like really useful type-checking methods that could come in handy all over the Distutils; should consider moving them up to Command and using them in other command classes' 'finalize_options()' method for error-checking). * various cleanup, commentary, and adaptation to the new way of storing RPM info in '_make_spec_file()' Index: bdist_rpm.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist_rpm.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** bdist_rpm.py 2000/06/01 00:40:25 1.5 --- bdist_rpm.py 2000/06/02 01:49:58 1.6 *************** *** 6,12 **** # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.5 2000/06/01 00:40:25 gward Exp $" ! import os, string from types import * from distutils.core import Command --- 6,12 ---- # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.6 2000/06/02 01:49:58 gward Exp $" ! import os, string, re from types import * from distutils.core import Command *************** *** 29,32 **** --- 29,89 ---- ('use-bzip2', None, "use bzip2 instead of gzip to create source distribution"), + + # More meta-data: too RPM-specific to put in the setup script, + # but needs to go in the .spec file -- so we make these options + # to "bdist_rpm". The idea is that packagers would put this + # info in setup.cfg, although they are of course free to + # supply it on the command line. + ('distribution-name', None, + "name of the (Linux) distribution name to which this " + "RPM applies (*not* the name of the module distribution!)"), + ('group', None, + "package classification [default: \"Development/Libraries\"]"), + ('release', None, + "RPM release number"), + ('serial', None, + "???"), + ('vendor', None, + "RPM \"vendor\" (eg. \"Joe Blow \") " + "[default: maintainer or author from setup script]"), + ('packager', None, + "RPM packager (eg. \"Jane Doe \")" + "[default: vendor]"), + ('doc-files', None, + "list of documentation files (space or comma-separated)"), + ('changelog', None, + "RPM changelog"), + ('icon', None, + "name of icon file"), + + ('prep-cmd', None, + "?? pre-build command(s) ??"), + ('build-cmd', None, + "?? build command(s) ??"), + ('install-cmd', None, + "?? installation command(s) ??"), + ('clean-cmd', None, + "?? clean command(s) ??"), + ('pre-install', None, + "pre-install script (Bourne shell code)"), + ('post-install', None, + "post-install script (Bourne shell code)"), + ('pre-uninstall', None, + "pre-uninstall script (Bourne shell code)"), + ('post-uninstall', None, + "post-uninstall script (Bourne shell code)"), + + ('provides', None, + "???"), + ('requires', None, + "???"), + ('conflicts', None, + "???"), + ('build-requires', None, + "???"), + ('obsoletes', None, + "???"), + + # Actions to take when building RPM ('clean', None, "clean up RPM build directory [default]"), *************** *** 49,52 **** --- 106,135 ---- self.source_only = None self.use_bzip2 = None + + self.distribution_name = None + self.group = None + self.release = None + self.serial = None + self.vendor = None + self.packager = None + self.doc_files = None + self.changelog = None + self.icon = None + + self.prep_cmd = None + self.build_cmd = None + self.install_cmd = None + self.clean_cmd = None + self.pre_install = None + self.post_install = None + self.pre_uninstall = None + self.post_uninstall = None + self.prep = None + self.provides = None + self.requires = None + self.conflicts = None + self.build_requires = None + self.obsoletes = None + self.clean = 1 self.use_rpm_opt_flags = 1 *************** *** 64,76 **** raise DistutilsOptionsError, \ "cannot supply both '--source-only' and '--binary-only'" # don't pass CFLAGS to pure python distributions if not self.distribution.has_ext_modules(): self.use_rpm_opt_flags = 0 # finalize_options() def run (self): ! self._get_package_data() # get packaging info # make directories --- 147,256 ---- raise DistutilsOptionsError, \ "cannot supply both '--source-only' and '--binary-only'" + # don't pass CFLAGS to pure python distributions if not self.distribution.has_ext_modules(): self.use_rpm_opt_flags = 0 + self.finalize_package_data() + # finalize_options() + def finalize_package_data (self): + self.ensure_string('group', "Development/Libraries") + self.ensure_string('vendor', + "%s <%s>" % (self.distribution.get_contact(), + self.distribution.get_contact_email())) + self.ensure_string('packager', self.vendor) # or nothing? + self.ensure_string_list('doc_files') + if type(self.doc_files) is ListType: + for readme in ('README', 'README.txt'): + if os.path.exists(readme) and readme not in self.doc_files: + self.doc.append(readme) + + self.ensure_string('release', "1") # should it be an int? + self.ensure_string('serial') # should it be an int? + + self.ensure_string('icon') + self.ensure_string('distribution_name') + self.ensure_string('prep_cmd', "%setup") # string or filename? + + if self.use_rpm_opt_flags: + def_build = 'env CFLAGS="$RPM_OPT_FLAGS" python setup.py build' + else: + def_build = 'python setup.py build' + self.ensure_string('build_cmd', def_build) + self.ensure_string('install_cmd', + "python setup.py install --root=$RPM_BUILD_ROOT " + "--record=INSTALLED_FILES") + self.ensure_string('clean_cmd', + "rm -rf $RPM_BUILD_ROOT") + self.ensure_filename('pre_install') + self.ensure_filename('post_install') + self.ensure_filename('pre_uninstall') + self.ensure_filename('post_uninstall') + + # XXX don't forget we punted on summaries and descriptions -- they + # should be handled here eventually! + + # Now *this* is some meta-data that belongs in the setup script... + self.ensure_string_list('provides') + self.ensure_string_list('requires') + self.ensure_string_list('conflicts') + self.ensure_string_list('build_requires') + self.ensure_string_list('obsoletes') + + # finalize_package_data () + + + # XXX these look awfully handy: should probably move them + # up to Command and use more widely. + def _ensure_stringlike (self, option, what, default=None): + val = getattr(self, option) + if val is None: + setattr(self, option, default) + return default + elif type(val) is not StringType: + raise DistutilsOptionError, \ + "'%s' must be a %s (got `%s`)" % (option, what, val) + return val + + def ensure_string (self, option, default=None): + self._ensure_stringlike(option, "string", default) + + def ensure_string_list (self, option): + val = getattr(self, option) + if val is None: + return + elif type(val) is StringType: + setattr(self, option, re.split(r',\s*|\s+', val)) + else: + if type(val) is ListType: + types = map(type, val) + ok = (types == [StringType] * len(val)) + else: + ok = 0 + + if not ok: + raise DistutilsOptionError, \ + "'%s' must be a list of strings (got %s)" % \ + (option, `val`) + + def ensure_filename (self, option, default=None): + val = self._ensure_stringlike(option, "filename", None) + if val is not None and not os.path.exists(val): + raise DistutilsOptionError, \ + "error in '%s' option: file '%s' does not exist" % \ + (option, val) + + + def run (self): ! ! print "before _get_package_data():" ! print "vendor =", self.vendor ! print "packager =", self.packager ! print "doc_files =", self.doc_files ! print "changelog =", self.changelog # make directories *************** *** 207,213 **** def _make_spec_file(self): ! ''' Generate an RPM spec file ''' ! ! # definitons and headers spec_file = [ '%define name ' + self.distribution.get_name(), --- 387,394 ---- def _make_spec_file(self): ! """Generate the text of an RPM spec file and return it as a ! list of strings (one per line). ! """ ! # definitions and headers spec_file = [ '%define name ' + self.distribution.get_name(), *************** *** 219,225 **** # put locale summaries into spec file ! for locale in self.summaries.keys(): ! spec_file.append('Summary(%s): %s' % (locale, ! self.summaries[locale])) spec_file.extend([ --- 400,408 ---- # put locale summaries into spec file ! # XXX not supported for now (hard to put a dictionary ! # in a config file -- arg!) ! #for locale in self.summaries.keys(): ! # spec_file.append('Summary(%s): %s' % (locale, ! # self.summaries[locale])) spec_file.extend([ *************** *** 227,234 **** --- 410,422 ---- 'Version: %{version}', 'Release: %{release}',]) + + # XXX yuck! this filename is available from the "sdist" command, + # but only after it has run: and we create the spec file before + # running "sdist", in case of --spec-only. if self.use_bzip2: spec_file.append('Source0: %{name}-%{version}.tar.bz2') else: spec_file.append('Source0: %{name}-%{version}.tar.gz') + spec_file.extend([ 'Copyright: ' + self.distribution.get_licence(), *************** *** 248,254 **** 'Obsoletes', ): ! if getattr(self, string.lower(field)): ! spec_file.append('%s: %s' % ! (field, getattr(self, string.lower(field)))) if self.distribution.get_url() != 'UNKNOWN': --- 436,445 ---- 'Obsoletes', ): ! val = getattr(self, string.lower(field)) ! if type(val) is ListType: ! spec_file.append('%s: %s' % (field, string.join(val))) ! elif val is not None: ! spec_file.append('%s: %s' % (field, val)) ! if self.distribution.get_url() != 'UNKNOWN': *************** *** 259,263 **** if self.build_requires: ! spec_file.append('BuildRequires: ' + self.build_requires) if self.icon: --- 450,455 ---- if self.build_requires: ! spec_file.append('BuildRequires: ' + ! string.join(self.build_requires)) if self.icon: *************** *** 271,296 **** # put locale descriptions into spec file ! for locale in self.descriptions.keys(): ! spec_file.extend([ ! '', ! '%description -l ' + locale, ! self.descriptions[locale], ! ]) # rpm scripts ! for script in ('prep', ! 'build', ! 'install', ! 'clean', ! 'pre', ! 'post', ! 'preun', ! 'postun', ! ): ! if getattr(self, script): spec_file.extend([ '', ! '%' + script, ! getattr(self, script), ]) --- 463,494 ---- # put locale descriptions into spec file ! # XXX again, suppressed because config file syntax doesn't ! # easily support this ;-( ! #for locale in self.descriptions.keys(): ! # spec_file.extend([ ! # '', ! # '%description -l ' + locale, ! # self.descriptions[locale], ! # ]) # rpm scripts ! for (rpm_opt, attr) in (('prep', 'prep_cmd'), ! ('build', 'build_cmd'), ! ('install', 'install_cmd'), ! ('clean', 'clean_cmd'), ! ('pre', 'pre_install'), ! ('post', 'post_install'), ! ('preun', 'pre_uninstall'), ! ('postun', 'post_uninstall')): ! # XXX oops, this doesn't distinguish between "raw code" ! # options and "script filename" options -- well, we probably ! # should settle on one or the other, and not make the ! # distinction! ! val = getattr(self, attr) ! if val: spec_file.extend([ '', ! '%' + rpm_opt, ! val ]) *************** *** 303,308 **** ]) ! if self.doc: ! spec_file.append('%doc ' + self.doc) if self.changelog: --- 501,506 ---- ]) ! if self.doc_files: ! spec_file.append('%doc ' + string.join(self.doc_files)) if self.changelog: From python-dev@python.org Fri Jun 2 02:52:06 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 1 Jun 2000 18:52:06 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist_rpm.py,1.6,1.7 Message-ID: <200006020152.SAA03020@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv3008/command Modified Files: bdist_rpm.py Log Message: Ditched the obsolete '_get_package_data()' method and its '_check_*()' helpers. Index: bdist_rpm.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist_rpm.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** bdist_rpm.py 2000/06/02 01:49:58 1.6 --- bdist_rpm.py 2000/06/02 01:52:04 1.7 *************** *** 6,10 **** # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.6 2000/06/02 01:49:58 gward Exp $" import os, string, re --- 6,10 ---- # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.7 2000/06/02 01:52:04 gward Exp $" import os, string, re *************** *** 319,389 **** - def _get_package_data(self): - ''' Get data needed to generate spec file, first from the - DistributionMetadata class, then from the package_data file, which is - Python code read with execfile() ''' - - from string import join - - package_type = 'rpm' - - # read in package data, if any - if os.path.exists('package_data'): - try: - exec(open('package_data')) - except: - raise DistutilsOptionError, 'Unable to parse package data file' - - # set instance variables, supplying default value if not provided in - # package data file - self.package_data = locals() - - # the following variables must be {string (len() = 2): string} - self.summaries = self._check_string_dict('summaries') - self.descriptions = self._check_string_dict('descriptions') - - # The following variable must be an ordinary number or a string - self.release = self._check_number_or_string('release', '1') - self.serial = self._check_number_or_string('serial') - - # The following variables must be strings - self.group = self._check_string('group', 'Development/Libraries') - self.vendor = self._check_string('vendor') - self.packager = self._check_string('packager') - self.changelog = self._check_string('changelog') - self.icon = self._check_string('icon') - self.distribution_name = self._check_string('distribution_name') - self.pre = self._check_string('pre') - self.post = self._check_string('post') - self.preun = self._check_string('preun') - self.postun = self._check_string('postun') - self.prep = self._check_string('prep', '%setup') - if self.use_rpm_opt_flags: - self.build = (self._check_string( - 'build', - 'env CFLAGS="$RPM_OPT_FLAGS" python setup.py build')) - else: - self.build = (self._check_string('build', 'python setup.py build')) - self.install = self._check_string( - 'install', - 'python setup.py install --root=$RPM_BUILD_ROOT --record') - self.clean = self._check_string( - 'clean', - 'rm -rf $RPM_BUILD_ROOT') - - # The following variables must be a list or tuple of strings, or a - # string - self.doc = self._check_string_list('doc') - if type(self.doc) == ListType: - for readme in ('README', 'README.txt'): - if os.path.exists(readme) and readme not in self.doc: - self.doc.append(readme) - self.doc = join(self.doc) - self.provides = join(self._check_string_list('provides')) - self.requires = join(self._check_string_list('requires')) - self.conflicts = join(self._check_string_list('conflicts')) - self.build_requires = join(self._check_string_list('build_requires')) - self.obsoletes = join(self._check_string_list('obsoletes')) - def _make_spec_file(self): """Generate the text of an RPM spec file and return it as a --- 319,322 ---- *************** *** 512,589 **** return spec_file - - def _check_string_dict(self, var_name, default_value = {}): - ''' Tests a wariable to determine if it is {string: string}, - var_name is the name of the wariable. Return the value if it is valid, - returns default_value if the variable does not exist, raises - DistutilsOptionError if the variable is not valid''' - if self.package_data.has_key(var_name): - pass_test = 1 # set to 0 if fails test - value = self.package_data[var_name] - if type(value) == DictType: - for locale in value.keys(): - if (type(locale) != StringType) or (type(value[locale]) != - StringType): - pass_test = 0 - break - if pass_test: - return test_me - raise DistutilsOptionError, \ - ("Error in package_data: '%s' must be dictionary: " - '{string: string}' % var_name) - else: - return default_value - - def _check_string(self, var_name, default_value = None): - ''' Tests a variable in package_data to determine if it is a string, - var_name is the name of the wariable. Return the value if it is a - string, returns default_value if the variable does not exist, raises - DistutilsOptionError if the variable is not a string''' - if self.package_data.has_key(var_name): - if type(self.package_data[var_name]) == StringType: - return self.package_data[var_name] - else: - raise DistutilsOptionError, \ - "Error in package_data: '%s' must be a string" % var_name - else: - return default_value ! def _check_number_or_string(self, var_name, default_value = None): ! ''' Tests a variable in package_data to determine if it is a number or ! a string, var_name is the name of the wariable. Return the value if it ! is valid, returns default_value if the variable does not exist, raises ! DistutilsOptionError if the variable is not valid''' ! if self.package_data.has_key(var_name): ! if type(self.package_data[var_name]) in (StringType, LongType, ! IntType, FloatType): ! return str(self.package_data[var_name]) ! else: ! raise DistutilsOptionError, \ ! ("Error in package_data: '%s' must be a string or a " ! 'number' % var_name) ! else: ! return default_value ! def _check_string_list(self, var_name, default_value = []): ! ''' Tests a variable in package_data to determine if it is a string or ! a list or tuple of strings, var_name is the name of the wariable. ! Return the value as a string or a list if it is valid, returns ! default_value if the variable does not exist, raises ! DistutilsOptionError if the variable is not valid''' ! if self.package_data.has_key(var_name): ! value = self.package_data[var_name] ! pass_test = 1 ! if type(value) == StringType: ! return value ! elif type(value) in (ListType, TupleType): ! for item in value: ! if type(item) != StringType: ! pass_test = 0 ! break ! if pass_test: ! return list(value) ! raise DistutilsOptionError, \ ! ("Error in package_data: '%s' must be a string or a " ! 'list or tuple of strings' % var_name) ! else: ! return default_value --- 445,450 ---- return spec_file ! # _make_spec_file () ! # class bdist_rpm From python-dev@python.org Fri Jun 2 02:55:38 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 1 Jun 2000 18:55:38 -0700 Subject: [Python-checkins] CVS: distutils/distutils core.py,1.39,1.40 Message-ID: <200006020155.SAA03135@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv3126 Modified Files: core.py Log Message: Use Distribution method 'dump_option_dicts()' for debugging output, and only do so if DEBUG is true. Index: core.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/core.py,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -r1.39 -r1.40 *** core.py 2000/06/02 00:44:53 1.39 --- core.py 2000/06/02 01:55:36 1.40 *************** *** 9,13 **** # created 1999/03/01, Greg Ward ! __revision__ = "$Id: core.py,v 1.39 2000/06/02 00:44:53 gward Exp $" import sys, os --- 9,13 ---- # created 1999/03/01, Greg Ward ! __revision__ = "$Id: core.py,v 1.40 2000/06/02 01:55:36 gward Exp $" import sys, os *************** *** 71,76 **** """ - from pprint import pprint # for debugging output - # Determine the distribution class -- either caller-supplied or # our Distribution (see below). --- 71,74 ---- *************** *** 89,94 **** dist.parse_config_files() ! print "options (after parsing config files):" ! pprint (dist.command_options) # Parse the command line; any command-line errors are the end user's --- 87,93 ---- dist.parse_config_files() ! if DEBUG: ! print "options (after parsing config files):" ! dist.dump_option_dicts() # Parse the command line; any command-line errors are the end user's *************** *** 100,105 **** raise SystemExit, "error: %s" % msg ! print "options (after parsing command line):" ! pprint (dist.command_options) # And finally, run all the commands found on the command line. --- 99,105 ---- raise SystemExit, "error: %s" % msg ! if DEBUG: ! print "options (after parsing command line):" ! dist.dump_option_dicts() # And finally, run all the commands found on the command line. From python-dev@python.org Fri Jun 2 02:59:35 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 1 Jun 2000 18:59:35 -0700 Subject: [Python-checkins] CVS: distutils/distutils dist.py,1.23,1.24 Message-ID: <200006020159.SAA03331@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv3323 Modified Files: dist.py Log Message: Only print debugging output if DEBUG true (and deleted some of the more extraneous debug prints). Index: dist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/dist.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -r1.23 -r1.24 *** dist.py 2000/06/02 00:44:53 1.23 --- dist.py 2000/06/02 01:59:33 1.24 *************** *** 8,12 **** # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: dist.py,v 1.23 2000/06/02 00:44:53 gward Exp $" import sys, os, string, re --- 8,12 ---- # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: dist.py,v 1.24 2000/06/02 01:59:33 gward Exp $" import sys, os, string, re *************** *** 295,307 **** from ConfigParser import ConfigParser if filenames is None: filenames = self.find_config_files() ! print "Distribution.parse_config_files():" parser = ConfigParser() for filename in filenames: ! print " reading", filename parser.read(filename) for section in parser.sections(): --- 295,308 ---- from ConfigParser import ConfigParser + from distutils.core import DEBUG if filenames is None: filenames = self.find_config_files() ! if DEBUG: print "Distribution.parse_config_files():" parser = ConfigParser() for filename in filenames: ! if DEBUG: print " reading", filename parser.read(filename) for section in parser.sections(): *************** *** 371,375 **** # each command listed on the command line. if self.help: - print "showing 'global' help; commands=", self.commands self._show_help(parser, display_options=len(self.commands) == 0, --- 372,375 ---- *************** *** 441,445 **** (args, opts) = parser.getopt (args[1:]) if hasattr(opts, 'help') and opts.help: - print "showing help for command", cmd_class self._show_help(parser, display_options=0, commands=[cmd_class]) return --- 441,444 ---- *************** *** 644,651 **** return it (if 'create' is true) or return None. """ cmd_obj = self.command_obj.get(command) if not cmd_obj and create: ! print "Distribution.get_command_obj(): " \ ! "creating '%s' command object" % command klass = self.get_command_class(command) --- 643,652 ---- return it (if 'create' is true) or return None. """ + from distutils.core import DEBUG cmd_obj = self.command_obj.get(command) if not cmd_obj and create: ! if DEBUG: ! print "Distribution.get_command_obj(): " \ ! "creating '%s' command object" % command klass = self.get_command_class(command) From python-dev@python.org Fri Jun 2 03:01:54 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 1 Jun 2000 19:01:54 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist_rpm.py,1.7,1.8 Message-ID: <200006020201.TAA06811@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv6759/command Modified Files: bdist_rpm.py Log Message: Only print debugging output if DEBUG true. Index: bdist_rpm.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist_rpm.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** bdist_rpm.py 2000/06/02 01:52:04 1.7 --- bdist_rpm.py 2000/06/02 02:01:51 1.8 *************** *** 6,14 **** # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.7 2000/06/02 01:52:04 gward Exp $" import os, string, re from types import * ! from distutils.core import Command from distutils.util import get_platform, write_file from distutils.errors import * --- 6,14 ---- # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.8 2000/06/02 02:01:51 gward Exp $" import os, string, re from types import * ! from distutils.core import Command, DEBUG from distutils.util import get_platform, write_file from distutils.errors import * *************** *** 248,256 **** def run (self): ! print "before _get_package_data():" ! print "vendor =", self.vendor ! print "packager =", self.packager ! print "doc_files =", self.doc_files ! print "changelog =", self.changelog # make directories --- 248,257 ---- def run (self): ! if DEBUG: ! print "before _get_package_data():" ! print "vendor =", self.vendor ! print "packager =", self.packager ! print "doc_files =", self.doc_files ! print "changelog =", self.changelog # make directories From python-dev@python.org Fri Jun 2 03:03:33 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 1 Jun 2000 19:03:33 -0700 Subject: [Python-checkins] CVS: distutils package_data,1.1,NONE Message-ID: <200006020203.TAA09070@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv9055 Removed Files: package_data Log Message: Removed -- thanks to recent heavy renovations in the "bdist_rpm" command, the contents of this file can all live in setup.cfg. From python-dev@python.org Fri Jun 2 03:07:46 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 1 Jun 2000 19:07:46 -0700 Subject: [Python-checkins] CVS: distutils setup.cfg,NONE,1.1 Message-ID: <200006020207.TAA09378@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv9364 Added Files: setup.cfg Log Message: The Distutils config file. Just as with the Distutils setup script, this has the dual purpose of being used to distribute the Distutils and serving as an example of some of the things you can do with Distutils config files. Currently, this is only useful for me (assuming I'm the only person who creates Distutils source and RPM distributions), but you could add build and installation preferences here, too. (Although those sorts of things are probably best handled on a site-wide or per-user basis, rather than in the config file for each module distribution.) From python-dev@python.org Fri Jun 2 03:09:56 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 1 Jun 2000 19:09:56 -0700 Subject: [Python-checkins] CVS: distutils TODO,1.1,1.2 Message-ID: <200006020209.TAA10096@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv9978 Modified Files: TODO Log Message: Recently revived the to-do list after months of hibernation -- lots of additions and a few deletions. Index: TODO =================================================================== RCS file: /cvsroot/python/distutils/TODO,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** TODO 1999/12/16 01:13:05 1.1 --- TODO 2000/06/02 02:09:53 1.2 *************** *** 2,14 **** ------- - * how to commands communicate non-option data amongst themselves? - eg. 'install_py' might want to ask 'build_py' which .py files - to install and compile -- how should that be handled (NB. - implies that 'build' must be run before 'install' is run, - can't just go by what's in the filesystem) - -> currently done by commands just knowing about each others' - options and methods; this seems to work, and I don't see - a need for further bureaucracy here - * I think fancy_getopt needs to get fancier to properly support the -I, -D, -l, -L, etc. options of "build_ext": need to be able --- 2,5 ---- *************** *** 17,33 **** repetitions of the same option will accumulate or replace, etc. BUILD/INSTALL ------------- - * "site" vs "std" install directories need to be more symmetrical. - Perhaps: - 'install_std_lib' and 'install_std_platlib' - vs - 'install_site_lib' and 'install_site_platlib' - and when we know the installation scheme ('std' or 'site'), we pick - one of these pairs as 'install_lib' and 'install_platlib'. Then - the install_* commands need only refer to 'install_lib' and - 'install_platlib', and not worry about the installation scheme. --- 8,93 ---- repetitions of the same option will accumulate or replace, etc. + * do the above options even work at all? seem to recall hearing + reports of dismal failure, but I never looked into it + [knowing how FancyGetopt works, there's no way these options + can work: damn] + + * think about how to support distribution-specific "configure" commands -- + eg. how can they push option values (include/library directories, that + sort of thing) onto the "build_ext" command? + + * should/can the 'finalize_options()' methods be made more robust, so + you can sensibly call them multiple times? this might be all that's + necessary to enable option-pushing... + [no: added reinitialize_command(), which *is* what's needed to enable + option-pushing] + + * inconsistent use of -f (sdist vs bdist) -- force or format? + + * fix UnixCCompiler so it doesn't depend on sysconfig (ie. cc must + be passed in) + + * allow user to supply cc (compiler executable) in addition to + compiler type + + * ?? add pre-processor interface to CCompiler ?? (needed to support + Autoconf-style 'try_cpp', 'search_cpp', 'search_headers' in config + commands) + + * radically simplify CCompiler method signatures: drop most of the + per-invocation customization, and just use the instance + attributes for eg. include_dirs, libraries, ... + + * need a good, general-purpose, portable-if-you-want-it, unportable-if- + you-need-control, way for the builder/installer to specify compiler + and linker flags (lots of people expect CFLAGS and LDFLAGS to work, + so they probably should; but options to either command and/or + build are the right way, so those should be preferred) + + + HELP + ---- + + * interface for "help about some option" -- eg. --help-compiler to + build_ext would list available compilers; --help-formats to "sdist" + or "bdist" would list available distribution formats; ... + [delegated to Rene Liebscher] + + DOCS + ---- + + * write write write + + * standard blurb for README files + + + BUILD/INSTALL ------------- + + * if Distutils installs the first third-party modules in an installation + (and creates site-packages), then "install" needlessly warns about + having installed to a location not on sys.path -- presumably because + site-packages isn't in sys.path at startup, since it doesn't exist + until we create it! (I think this is only a problem with 1.5.2, + since site-packages is now created when Python is installed -- check!) + + * write a class Extension (name?) to hold all the information needed + to describe a single extension -- ie. replace the (ext_name, build_info) + tuple (particularly build_info!) + [done 2000/05/30 GPW] + + * need a mechanism for specifying pre-install and post-install hooks, + which will be run when installing from a smart built distribution + (RPM, wininst, etc.); also, "install" needs to run these hooks + *except* for "fake" installs done solely to create a built distribution + + * extension building on AIX + + * bdist_dumb should grow a little intelligence: let packager choose whether + to make archive relative to prefix or the root (prefix is essential + for proper Windows support ) *************** *** 35,42 **** --- 95,121 ---- ------------------ + * review and integrate cygwin patch from Rene Liebscher + + DISTRIBUTIONS + ------------- + + * review/tweak bdist_rpm code from Harry Gebel (minor style issues, fix + hardcoded directories) + [done 2000/06/01 GPW, but in need of serious testing!] + + * figure out why bdist_rpm doesn't work with RPM 2.x, and make it work if + possible + + * make "bdist" take multiple formats (both for convenience + and consistency with "sdist"); should be doable now that we can + reinitialize, refinalize, and (presumably) rerun commands + + EXTERNAL DEPENDENCIES --------------------- + * ??? do we need to implement autoconf in Python (shudder) ??? + * if not, how to handle the case of "if Tk present, build with it" in PIL, or "define HAVE_STRFTIME if we have strftime()" in mxDateTime"? From python-dev@python.org Fri Jun 2 03:22:08 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 1 Jun 2000 19:22:08 -0700 Subject: [Python-checkins] CVS: distutils README.txt,1.14,1.15 Message-ID: <200006020222.TAA14899@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv14885 Modified Files: README.txt Log Message: Started updating for forthcoming 0.9 release. Index: README.txt =================================================================== RCS file: /cvsroot/python/distutils/README.txt,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** README.txt 2000/04/25 03:05:16 1.14 --- README.txt 2000/06/02 02:22:06 1.15 *************** *** 1,5 **** ! Python Distutils ! release 0.8.2 ! April 24, 2000 --- 1,5 ---- ! Python Distribution Utilities ! release 0.9 (pre) ! June ??, 2000 *************** *** 42,48 **** ------------ ! Release 0.8.2 of the Distutils requires Python 1.5.2 or later. ! (Compatibility with Python 1.5.1 is forthcoming, as soon as I merge the ! 1.5.1 compatibility changes from Distutils 0.1.4 and 0.1.5 forward.) To use the Distutils under Unix, you must have a *complete* Python --- 42,50 ---- ------------ ! Release 0.9 of the Distutils requires Python 1.5.2 or later. (If you ! absolutely must Python 1.5.1, Distutils 0.1.5 is backwards compatible. ! However, I have dropped plans to port the current Distutils code back to ! Python 1.5.1, as I have received exactly zero complaints about requiring ! Python 1.5.2 since releasing Distutils 0.8 in April.) To use the Distutils under Unix, you must have a *complete* Python *************** *** 74,78 **** fine. (Python 1.6 includes the winreg module for this purpose, which the Distutils will use if available.) If not, the Distutils might not ! be able to find the Visual C++ executables. --- 76,81 ---- fine. (Python 1.6 includes the winreg module for this purpose, which the Distutils will use if available.) If not, the Distutils might not ! be able to find the Visual C++ executables, in which case it will die ! horribly when you attempt to build any Python extensions. *************** *** 105,111 **** The Distutils are included with Python 1.6, so there's generally no need ! to install it under Python 1.6. However, Distutils 0.8.2 is more recent than the code included with Python 1.6a2, so if you really like life on ! the bleeding edge, you might want to install this Distutils release into your Python 1.6a2 library. --- 108,114 ---- The Distutils are included with Python 1.6, so there's generally no need ! to install it under Python 1.6. However, this release is more recent than the code included with Python 1.6a2, so if you really like life on ! the bleeding edge, you might want to install this Distutils release into your Python 1.6a2 library. *************** *** 132,140 **** The Distutils is intended to have three user communities: developers, ! packagers, and installers. This release caters mainly to developers and ! installers (system administrators, users of Python modules and ! applications); there is currently a little support for generating ! "built" (binary) distributions, so would-be packagers can at least start ! playing with the Distutils. Documentation for the Distutils is under construction in the form of two --- 135,144 ---- The Distutils is intended to have three user communities: developers, ! packagers, and installers. Distutils 0.9 is the first release that ! seriously caters to all three communities: developers can use it to ! build and install their modules, as well as create source distributions; ! packagers can use it to create RPMs and (soon!) executable installers ! for Windows; and of course installers can build and install modules from ! source (or just use an installer created by some kind packager). Documentation for the Distutils is under construction in the form of two *************** *** 142,148 **** Python Modules" (for developers and packagers). I've included the LaTeX source for these two manuals in the "doc" subdirectory; if you know your ! way around LaTeX and the Python documentation tools, you can probably ! get something out of these. Otherwise, you're better off getting the ! latest documentation from the Distutils documentation page: http://www.python.org/sigs/distutils-sig/doc/ --- 146,154 ---- Python Modules" (for developers and packagers). I've included the LaTeX source for these two manuals in the "doc" subdirectory; if you know your ! way around LaTeX, the Python documentation tools, and Unix, you might be ! able to get something out of these. Realistically, though, the ! documentation is just provided in the distributio so you can send me doc ! patches; if you want to read it, you're better off getting the latest ! documentation from the Distutils documentation page: http://www.python.org/sigs/distutils-sig/doc/ *************** *** 153,162 **** If you are an installer (system administrator or end-user) and you'd like to try out the Distutils, you've already done so by installing the ! Distutils themselves (thanks!). Additionally, at least two major module ! distributions (Numerical Python and PyXML) use the Distutils for ! installation; if you have installed the Distutils just to get another ! distributions up-and-running, follow the instructions included with that ! distribution. For any "distutil-ized" distribution, though, this should ! always work: python setup.py install --- 159,167 ---- If you are an installer (system administrator or end-user) and you'd like to try out the Distutils, you've already done so by installing the ! Distutils themselves (thanks!). Additionally, a number of module ! distributions now use the Distutils for installation; if you have ! installed the Distutils just to get another distribution up-and-running, ! follow the instructions included with that distribution. For any ! "distutil-ized" distribution, though, this should always work: python setup.py install *************** *** 342,348 **** * Bastian Kleineidam: the "clean" command, and a pile of patches, bug-fixes, and ideas, large and small ! * Lyle Johnson: bug-spotting and -fixing * Harry Henry Gebel: bug-spotting and -fixing; the "bztar" archive ! format [spiritual, in roughly chronological order since the birth of the project] --- 347,356 ---- * Bastian Kleineidam: the "clean" command, and a pile of patches, bug-fixes, and ideas, large and small ! * Lyle Johnson: bug-spotting and -fixing; (forthcoming) support ! for Borland's C/C++ compiler * Harry Henry Gebel: bug-spotting and -fixing; the "bztar" archive ! format; the "bdist_rpm" command ! * Rene Liebscher: smarter extension-building; (forthcoming?) ! Cygwin/Mingw32 support [spiritual, in roughly chronological order since the birth of the project] *************** *** 364,366 **** the CPAN archive (Jarkko), and the CPAN module (Andreas) ! $Id: README.txt,v 1.14 2000/04/25 03:05:16 gward Exp $ --- 372,374 ---- the CPAN archive (Jarkko), and the CPAN module (Andreas) ! $Id: README.txt,v 1.15 2000/06/02 02:22:06 gward Exp $ From python-dev@python.org Fri Jun 2 03:22:18 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 1 Jun 2000 19:22:18 -0700 Subject: [Python-checkins] CVS: distutils MANIFEST.in,1.5,1.6 Message-ID: <200006020222.TAA14916@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv14906 Modified Files: MANIFEST.in Log Message: Ditch 'package_data' file. Index: MANIFEST.in =================================================================== RCS file: /cvsroot/python/distutils/MANIFEST.in,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** MANIFEST.in 2000/05/13 03:39:06 1.5 --- MANIFEST.in 2000/06/02 02:22:16 1.6 *************** *** 6,14 **** # created 2000/02/14, Greg Ward # ! # $Id: MANIFEST.in,v 1.5 2000/05/13 03:39:06 greg Exp $ # include *.txt - include package_data include MANIFEST.in recursive-include examples *.txt *.py --- 6,13 ---- # created 2000/02/14, Greg Ward # ! # $Id: MANIFEST.in,v 1.6 2000/06/02 02:22:16 gward Exp $ # include *.txt include MANIFEST.in recursive-include examples *.txt *.py From python-dev@python.org Fri Jun 2 03:23:44 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 1 Jun 2000 19:23:44 -0700 Subject: [Python-checkins] CVS: distutils setup.py,1.15,1.16 Message-ID: <200006020223.TAA14968@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv14958 Modified Files: setup.py Log Message: Bumped version number to 0.9pre (there will be a couple of code snapshots before the real release, but I want to make it clear that a major new release is on the way). Index: setup.py =================================================================== RCS file: /cvsroot/python/distutils/setup.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** setup.py 2000/04/26 02:27:47 1.15 --- setup.py 2000/06/02 02:23:42 1.16 *************** *** 7,16 **** # created 1999/03 Greg Ward ! __revision__ = "$Id: setup.py,v 1.15 2000/04/26 02:27:47 gward Exp $" from distutils.core import setup setup (name = "Distutils", ! version = "0.8.2", description = "Python Distribution Utilities", author = "Greg Ward", --- 7,16 ---- # created 1999/03 Greg Ward ! __revision__ = "$Id: setup.py,v 1.16 2000/06/02 02:23:42 gward Exp $" from distutils.core import setup setup (name = "Distutils", ! version = "0.9pre", description = "Python Distribution Utilities", author = "Greg Ward", From python-dev@python.org Fri Jun 2 03:23:44 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 1 Jun 2000 19:23:44 -0700 Subject: [Python-checkins] CVS: distutils/distutils __init__.py,1.6,1.7 Message-ID: <200006020223.TAA14972@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv14958/distutils Modified Files: __init__.py Log Message: Bumped version number to 0.9pre (there will be a couple of code snapshots before the real release, but I want to make it clear that a major new release is on the way). Index: __init__.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/__init__.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** __init__.py 2000/04/25 01:55:58 1.6 --- __init__.py 2000/06/02 02:23:42 1.7 *************** *** 9,13 **** """ ! __revision__ = "$Id: __init__.py,v 1.6 2000/04/25 01:55:58 gward Exp $" ! __version__ = "0.8.2" --- 9,13 ---- """ ! __revision__ = "$Id: __init__.py,v 1.7 2000/06/02 02:23:42 gward Exp $" ! __version__ = "0.9pre" From python-dev@python.org Fri Jun 2 03:41:53 2000 From: python-dev@python.org (Jeremy Hylton) Date: Thu, 1 Jun 2000 19:41:53 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild python16.dsp,1.4,1.5 Message-ID: <200006020241.TAA15967@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv15940 Modified Files: python16.dsp Log Message: make sure the case is correct (damned case-sensitive languages :-) Index: python16.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/python16.dsp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** python16.dsp 2000/06/01 15:47:08 1.4 --- python16.dsp 2000/06/02 02:41:47 1.5 *************** *** 543,558 **** SOURCE=..\python\exceptions.c ! !if "$(cfg)" == "python16 - win32 release" ! !elseif "$(cfg)" == "python16 - win32 debug" ! !elseif "$(cfg)" == "python16 - win32 alpha debug" ! !elseif "$(cfg)" == "python16 - win32 alpha release" ! !endif ! # end source file ! # begin source file SOURCE=..\Objects\fileobject.c --- 543,558 ---- SOURCE=..\python\exceptions.c ! !IF "$(cfg)" == "python16 - Win32 Release" ! !ELSEIF "$(cfg)" == "python16 - Win32 Debug" ! !ELSEIF "$(cfg)" == "python16 - Win32 Alpha Debug" ! !ELSEIF "$(cfg)" == "python16 - Win32 Alpha Release" ! !ENDIF ! # End Source File ! # Begin Source File SOURCE=..\Objects\fileobject.c From python-dev@python.org Sat Jun 3 01:44:33 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 2 Jun 2000 17:44:33 -0700 Subject: [Python-checkins] CVS: distutils/distutils sysconfig.py,1.18,1.19 Message-ID: <200006030044.RAA00322@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv310 Modified Files: sysconfig.py Log Message: Added a bunch of new globals in '_init_mac()' -- these will be needed to support the forthcoming Cygwin/Mingw32 GCC-on-Windows patch. Standardized CVS id line. Index: sysconfig.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/sysconfig.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** sysconfig.py 2000/05/23 23:14:00 1.18 --- sysconfig.py 2000/06/03 00:44:30 1.19 *************** *** 7,11 **** """ ! __version__ = "$Revision: 1.18 $" import os --- 7,11 ---- """ ! __revision__ = "$Id: sysconfig.py,v 1.19 2000/06/03 00:44:30 gward Exp $" import os *************** *** 255,258 **** --- 255,272 ---- g['SO'] = '.pyd' g['exec_prefix'] = EXEC_PREFIX + + # These are needed for the CygwinCCompiler and Mingw32CCompiler + # classes, which are just UnixCCompiler classes that happen to work on + # Windows. UnixCCompiler expects to find these values in sysconfig, so + # here they are. The fact that other Windows compilers don't need + # these values is pure luck (hmmm). + g['CC'] = "cc" # not gcc? + g['RANLIB'] = "ranlib" + g['AR'] = "ar" + g['OPT'] = "-O2" + g['SO'] = ".pyd" + g['LDSHARED'] = "ld" + g['CCSHARED'] = "" + g['EXE'] = ".exe" From python-dev@python.org Sat Jun 3 02:02:09 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 2 Jun 2000 18:02:09 -0700 Subject: [Python-checkins] CVS: distutils/distutils core.py,1.40,1.41 Message-ID: <200006030102.SAA06524@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv6513 Modified Files: core.py Log Message: Catch DistutilSetupError from the Distribution constructor. Index: core.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/core.py,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -r1.40 -r1.41 *** core.py 2000/06/02 01:55:36 1.40 --- core.py 2000/06/03 01:02:06 1.41 *************** *** 9,13 **** # created 1999/03/01, Greg Ward ! __revision__ = "$Id: core.py,v 1.40 2000/06/02 01:55:36 gward Exp $" import sys, os --- 9,13 ---- # created 1999/03/01, Greg Ward ! __revision__ = "$Id: core.py,v 1.41 2000/06/03 01:02:06 gward Exp $" import sys, os *************** *** 81,85 **** # Create the Distribution instance, using the remaining arguments # (ie. everything except distclass) to initialize it ! dist = klass (attrs) # Find and parse the config file(s): they will override options from --- 81,88 ---- # Create the Distribution instance, using the remaining arguments # (ie. everything except distclass) to initialize it ! try: ! dist = klass (attrs) ! except DistutilsSetupError, msg: ! raise SystemExit, "error in setup script: %s" % msg # Find and parse the config file(s): they will override options from From python-dev@python.org Sat Jun 3 02:03:58 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 2 Jun 2000 18:03:58 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist_rpm.py,1.8,1.9 Message-ID: <200006030103.SAA06693@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv6683/command Modified Files: bdist_rpm.py Log Message: Patch from Harry Henry Gebel: fixes a bit of code that slipped by my overhaul last night. Index: bdist_rpm.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist_rpm.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** bdist_rpm.py 2000/06/02 02:01:51 1.8 --- bdist_rpm.py 2000/06/03 01:03:55 1.9 *************** *** 6,10 **** # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.8 2000/06/02 02:01:51 gward Exp $" import os, string, re --- 6,10 ---- # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.9 2000/06/03 01:03:55 gward Exp $" import os, string, re *************** *** 309,315 **** else: rpm_args.append('-ba') - topdir = os.getcwd() + 'build/rpm' rpm_args.extend(['--define', ! '_topdir ' + os.getcwd() + '/build/rpm',]) if self.clean: rpm_args.append('--clean') --- 309,314 ---- else: rpm_args.append('-ba') rpm_args.extend(['--define', ! '_topdir %s/%s' % (os.getcwd(), rpm_base),]) if self.clean: rpm_args.append('--clean') From python-dev@python.org Sat Jun 3 20:41:44 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 3 Jun 2000 12:41:44 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules mmapmodule.c,2.8,2.9 Message-ID: <200006031941.MAA21418@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv21410 Modified Files: mmapmodule.c Log Message: Add missing PyArg_NoArgs() calls to methods that didn't take arguments (Pointed out by Moshe Zadka) Index: mmapmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/mmapmodule.c,v retrieving revision 2.8 retrieving revision 2.9 diff -C2 -r2.8 -r2.9 *** mmapmodule.c 2000/05/03 23:44:32 2.8 --- mmapmodule.c 2000/06/03 19:41:42 2.9 *************** *** 2,6 **** / Author: Sam Rushing / Hacked for Unix by A.M. Kuchling ! / $Id: mmapmodule.c,v 2.8 2000/05/03 23:44:32 guido Exp $ / mmapmodule.cpp -- map a view of a file into memory --- 2,6 ---- / Author: Sam Rushing / Hacked for Unix by A.M. Kuchling ! / $Id: mmapmodule.c,v 2.9 2000/06/03 19:41:42 akuchling Exp $ / mmapmodule.cpp -- map a view of a file into memory *************** *** 76,79 **** --- 76,81 ---- mmap_close_method (mmap_object * self, PyObject * args) { + if (!PyArg_NoArgs(args)) + return NULL; #ifdef MS_WIN32 UnmapViewOfFile (self->data); *************** *** 119,122 **** --- 121,126 ---- char * where; CHECK_VALID(NULL); + if (!PyArg_NoArgs(args)) + return NULL; if (self->pos >= 0 && self->pos < self->size) { where = self->data + self->pos; *************** *** 132,136 **** static PyObject * mmap_read_line_method (mmap_object * self, ! PyObject * args) { char * start = self->data+self->pos; --- 136,140 ---- static PyObject * mmap_read_line_method (mmap_object * self, ! PyObject * args) { char * start = self->data+self->pos; *************** *** 140,143 **** --- 144,149 ---- CHECK_VALID(NULL); + if (!PyArg_NoArgs(args)) + return NULL; eol = memchr(start, '\n', self->size - self->pos); *************** *** 154,158 **** static PyObject * mmap_read_method (mmap_object * self, ! PyObject * args) { long num_bytes; --- 160,164 ---- static PyObject * mmap_read_method (mmap_object * self, ! PyObject * args) { long num_bytes; *************** *** 226,230 **** static PyObject * mmap_write_byte_method (mmap_object * self, ! PyObject * args) { char value; --- 232,236 ---- static PyObject * mmap_write_byte_method (mmap_object * self, ! PyObject * args) { char value; *************** *** 242,248 **** static PyObject * mmap_size_method (mmap_object * self, ! PyObject * args) { CHECK_VALID(NULL); #ifdef MS_WIN32 --- 248,256 ---- static PyObject * mmap_size_method (mmap_object * self, ! PyObject * args) { CHECK_VALID(NULL); + if (!PyArg_NoArgs(args)) + return NULL; #ifdef MS_WIN32 *************** *** 347,350 **** --- 355,360 ---- { CHECK_VALID(NULL); + if (!PyArg_NoArgs(args)) + return NULL; return (Py_BuildValue ("l", self->pos) ); } *************** *** 463,470 **** static int ! mmap_buffer_getreadbuf(self, index, ptr) ! mmap_object *self; ! int index; ! const void **ptr; { CHECK_VALID(-1); --- 473,477 ---- static int ! mmap_buffer_getreadbuf(mmap_object *self, int index, const void **ptr) { CHECK_VALID(-1); *************** *** 868,869 **** --- 875,877 ---- } + From python-dev@python.org Sat Jun 3 21:43:46 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 3 Jun 2000 13:43:46 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules mmapmodule.c,2.9,2.10 Message-ID: <200006032043.NAA02637@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv2626 Modified Files: mmapmodule.c Log Message: Use PyArg_ParseTuple and specify the method names, following a suggestion from Greg Stein Index: mmapmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/mmapmodule.c,v retrieving revision 2.9 retrieving revision 2.10 diff -C2 -r2.9 -r2.10 *** mmapmodule.c 2000/06/03 19:41:42 2.9 --- mmapmodule.c 2000/06/03 20:43:43 2.10 *************** *** 2,6 **** / Author: Sam Rushing / Hacked for Unix by A.M. Kuchling ! / $Id: mmapmodule.c,v 2.9 2000/06/03 19:41:42 akuchling Exp $ / mmapmodule.cpp -- map a view of a file into memory --- 2,6 ---- / Author: Sam Rushing / Hacked for Unix by A.M. Kuchling ! / $Id: mmapmodule.c,v 2.10 2000/06/03 20:43:43 akuchling Exp $ / mmapmodule.cpp -- map a view of a file into memory *************** *** 76,80 **** mmap_close_method (mmap_object * self, PyObject * args) { ! if (!PyArg_NoArgs(args)) return NULL; #ifdef MS_WIN32 --- 76,80 ---- mmap_close_method (mmap_object * self, PyObject * args) { ! if (!PyArg_ParseTuple(args, ":close")) return NULL; #ifdef MS_WIN32 *************** *** 121,125 **** char * where; CHECK_VALID(NULL); ! if (!PyArg_NoArgs(args)) return NULL; if (self->pos >= 0 && self->pos < self->size) { --- 121,125 ---- char * where; CHECK_VALID(NULL); ! if (!PyArg_ParseTuple(args, ":read_byte")) return NULL; if (self->pos >= 0 && self->pos < self->size) { *************** *** 144,148 **** CHECK_VALID(NULL); ! if (!PyArg_NoArgs(args)) return NULL; --- 144,148 ---- CHECK_VALID(NULL); ! if (!PyArg_ParseTuple(args, ":readline")) return NULL; *************** *** 251,255 **** { CHECK_VALID(NULL); ! if (!PyArg_NoArgs(args)) return NULL; --- 251,255 ---- { CHECK_VALID(NULL); ! if (!PyArg_ParseTuple(args, ":size")) return NULL; *************** *** 355,359 **** { CHECK_VALID(NULL); ! if (!PyArg_NoArgs(args)) return NULL; return (Py_BuildValue ("l", self->pos) ); --- 355,359 ---- { CHECK_VALID(NULL); ! if (!PyArg_ParseTuple(args, ":tell")) return NULL; return (Py_BuildValue ("l", self->pos) ); From python-dev@python.org Sun Jun 4 14:42:55 2000 From: python-dev@python.org (Greg Ward) Date: Sun, 4 Jun 2000 06:42:55 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command build_py.py,1.25,1.26 Message-ID: <200006041342.GAA31624@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv31616 Modified Files: build_py.py Log Message: Renamed 'modules' option to 'py_modules', for consistency with Distribution (and in order to generate a more sensible error message cleanly). Index: build_py.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build_py.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -r1.25 -r1.26 *** build_py.py 2000/05/26 00:44:06 1.25 --- build_py.py 2000/06/04 13:42:52 1.26 *************** *** 5,9 **** # created 1999/03/08, Greg Ward ! __revision__ = "$Id: build_py.py,v 1.25 2000/05/26 00:44:06 gward Exp $" import sys, string, os --- 5,9 ---- # created 1999/03/08, Greg Ward ! __revision__ = "$Id: build_py.py,v 1.26 2000/06/04 13:42:52 gward Exp $" import sys, string, os *************** *** 27,31 **** def initialize_options (self): self.build_lib = None ! self.modules = None self.package = None self.package_dir = None --- 27,31 ---- def initialize_options (self): self.build_lib = None ! self.py_modules = None self.package = None self.package_dir = None *************** *** 40,44 **** # options -- list of packages and list of modules. self.packages = self.distribution.packages ! self.modules = self.distribution.py_modules self.package_dir = self.distribution.package_dir --- 40,44 ---- # options -- list of packages and list of modules. self.packages = self.distribution.packages ! self.py_modules = self.distribution.py_modules self.package_dir = self.distribution.package_dir *************** *** 63,67 **** # Two options control which modules will be installed: 'packages' ! # and 'modules'. The former lets us work with whole packages, not # specifying individual modules at all; the latter is for # specifying modules one-at-a-time. Currently they are mutually --- 63,67 ---- # Two options control which modules will be installed: 'packages' ! # and 'py_modules'. The former lets us work with whole packages, not # specifying individual modules at all; the latter is for # specifying modules one-at-a-time. Currently they are mutually *************** *** 71,85 **** # Dispose of the two "unusual" cases first: no pure Python modules # at all (no problem, just return silently), and over-specified ! # 'packages' and 'modules' options. ! if not self.modules and not self.packages: return ! if self.modules and self.packages: raise DistutilsOptionError, \ ! "build_py: supplying both 'packages' and 'modules' " + \ "options is not allowed" ! # Now we're down to two cases: 'modules' only and 'packages' only. ! if self.modules: self.build_modules () else: --- 71,85 ---- # Dispose of the two "unusual" cases first: no pure Python modules # at all (no problem, just return silently), and over-specified ! # 'packages' and 'py_modules' options. ! if not self.py_modules and not self.packages: return ! if self.py_modules and self.packages: raise DistutilsOptionError, \ ! "build_py: supplying both 'packages' and 'py_modules' " + \ "options is not allowed" ! # Now we're down to two cases: 'py_modules' only and 'packages' only. ! if self.py_modules: self.build_modules () else: *************** *** 195,199 **** def find_modules (self): """Finds individually-specified Python modules, ie. those listed by ! module name in 'self.modules'. Returns a list of tuples (package, module_base, filename): 'package' is a tuple of the path through package-space to the module; 'module_base' is the bare (no --- 195,199 ---- def find_modules (self): """Finds individually-specified Python modules, ie. those listed by ! module name in 'self.py_modules'. Returns a list of tuples (package, module_base, filename): 'package' is a tuple of the path through package-space to the module; 'module_base' is the bare (no *************** *** 219,223 **** # - don't check for __init__.py in directory for empty package ! for module in self.modules: path = string.split (module, '.') package = tuple (path[0:-1]) --- 219,223 ---- # - don't check for __init__.py in directory for empty package ! for module in self.py_modules: path = string.split (module, '.') package = tuple (path[0:-1]) *************** *** 252,261 **** def find_all_modules (self): """Compute the list of all modules that will be built, whether ! they are specified one-module-at-a-time ('self.modules') or by whole packages ('self.packages'). Return a list of tuples (package, module, module_file), just like 'find_modules()' and 'find_package_modules()' do.""" ! if self.modules: modules = self.find_modules () else: --- 252,261 ---- def find_all_modules (self): """Compute the list of all modules that will be built, whether ! they are specified one-module-at-a-time ('self.py_modules') or by whole packages ('self.packages'). Return a list of tuples (package, module, module_file), just like 'find_modules()' and 'find_package_modules()' do.""" ! if self.py_modules: modules = self.find_modules () else: From python-dev@python.org Sun Jun 4 14:44:06 2000 From: python-dev@python.org (Greg Ward) Date: Sun, 4 Jun 2000 06:44:06 -0700 Subject: [Python-checkins] CVS: distutils/test test_spawn.py,1.1,1.2 Message-ID: <200006041344.GAA31658@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv31650 Modified Files: test_spawn.py Log Message: [from 2000/04/23] Hopeless attempt to make this test script for the 'spawn' module more useful, reliable, and portable. I have since abandoned hope of testing 'spawn' portably -- perhaps I'll write a Unix version, and just hope that someone out there writes a Windows version. ;-( Index: test_spawn.py =================================================================== RCS file: /cvsroot/python/distutils/test/test_spawn.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** test_spawn.py 1999/09/29 13:10:23 1.1 --- test_spawn.py 2000/06/04 13:44:03 1.2 *************** *** 2,16 **** # test_spawn.py # ! # test suite for distutils.util.spawn() (currently Unix-only) # # GPW 1999/07/20 # ! # $Id: test_spawn.py,v 1.1 1999/09/29 13:10:23 gward Exp $ # ! import sys from distutils.spawn import spawn from distutils.errors import * from util import try_it spawn (["/bin/ls"]) --- 2,222 ---- # test_spawn.py # ! # test script for distutils.spawn module # # GPW 1999/07/20 # ! # $Id: test_spawn.py,v 1.2 2000/06/04 13:44:03 gward Exp $ # ! import sys, os, string ! from tempfile import mktemp from distutils.spawn import spawn + from distutils.util import abspath from distutils.errors import * + from unittest import TestScenario, parse_args, run_scenarios from util import try_it + + class SpawnTest (TestScenario): + + def setup (self): + self.python = os.path.normpath (abspath (sys.executable)) + + self.cmd_trivial = self.gen_cmd ('1') + self.cmd_trivial_s = string.join (self.cmd_trivial) + self.cmd_print = self.gen_cmd ('print "hello"') + self.cmd_print_s = string.join (self.cmd_print) + self.cmd_err = self.gen_cmd ('import sys; sys.stderr.write("foo\\n")') + self.cmd_err_s = string.join (self.cmd_err) + self.cmd_mixed = self.gen_cmd ("import sys; " + "sys.stdout.write('out'); " + "sys.stderr.write('err'); " + "sys.stdout.write('put'); " + "sys.stderr.write('or')") + + + def shutdown (self): + pass + + + def capture_output (self): + """Temporarily redirect stdout and stderr to files, the + contents of which will be returned by 'stop_capture()'.""" + self.out_filename = mktemp() + self.err_filename = mktemp() + self.out_file = open(self.out_filename, 'w') + self.err_file = open(self.err_filename, 'w') + self.save_stdout = os.dup(1) + self.save_stderr = os.dup(2) + os.close(1) + if os.dup(self.out_file.fileno()) != 1: + raise RuntimeError, "couldn't redirect stdout - dup() error" + os.close(2) + if os.dup(self.err_file.fileno()) != 2: + raise RuntimeError, "couldn't redirect stderr - dup() error" + + def stop_capture (self): + os.close(1) + os.dup(self.save_stdout) + os.close(2) + os.dup(self.save_stderr) + + self.out_file.close() + self.err_file.close() + + out_file = open(self.out_filename) + output = out_file.read() + out_file.close() + os.unlink (self.out_filename) + + err_file = open(self.err_filename) + error = err_file.read() + err_file.close() + os.unlink (self.err_filename) + + return (output, error) + + + #def capture_test_1 (self, test_method, args): + # """Run a + + + def test_out (self, code, output, error): + # XXX I have no idea how to do this in a portable way! + + from unittest import get_caller_env + (globals, locals) = get_caller_env () + + if os.name == 'posix': + p2cread, p2cwrite = os.pipe() + c2pread, c2pwrite = os.pipe() + err_read, err_write = os.pipe() + + pid = os.fork() + if pid == 0: # in the child + os.close(0) # close stdin + os.close(1) # and stdout + os.close(2) # and stderr + + if os.dup(p2cread) != 0: + raise os.error, "dup stdin (read) != 0" + if os.dup(c2pwrite) != 1: + raise os.error, "dup stdout (write) != 1" + if os.dup(err_write) != 2: + raise os.error, "dup stderr (write) != 2" + + eval (code, globals, locals) + os._exit (0) + + # in the parent + os.close(p2cread) + child_stdin = os.fdopen (p2cwrite, 'w') + os.close(c2pwrite) + child_stdout = os.fdopen (c2pread, 'r') + os.close(err_write) + child_stderr = os.fdopen (err_read, 'r') + + child_out = child_stdout.read() + child_err = child_stderr.read() + + child_stdin.close() + child_stdout.close() + child_stderr.close() + os.waitpid (pid, 0) + + self.tests_run = self.tests_run + 1 + + if output == child_out and error == child_err: + self.report_pass ( + code + "\n" + + " wrote %s to stdout\n" % `child_out` + + " and %s to stderr" % `child_err`) + elif output != child_out and error == child_err: + self.report_fail ( + code + "\n" + + " did not write %s to stdout (wrote %s)\n" % + (`output`, `child_out`) + + " but wrote %s to stderr" % child_err) + elif output == child_out and error != child_err: + self.report_fail ( + code + "\n" + + " wrote %s to stdout" % `child_out` + + " but did not write %s to stderr (wrote %s)" % + (`error`, `child_err`)) + else: + self.report_fail ( + code + "\n" + + " did not write %s to stdout (wrote %s)\n" % + (`output`, `child_out`) + + " and did not write %s to stderr (wrote %s)" % + (`error`, `child_err`)) + + else: + raise RuntimeError, \ + "don't know how to capture stdout/stderr on platform '%s'"%\ + os.name + + # test_out () + + + + def gen_cmd (self, script): + """Generate a Python command line to run 'script' as a list + for use by 'spawn()'. Eg. if 'script' is "print 'hello'", + returns the list ["python", "-c", "print 'hello'"] -- except + the full path to the executable is used.""" + return [self.python, "-c", str(script)] + + + test_cases = ['simple', 'output', 'verbose', 'dryrun'] + + + def check_simple (self): + "Simple spawns (success and failure): 6" + + self.test_stmt ("spawn (%s)" % self.cmd_mixed) + self.test_stmt ("spawn (%s)" % self.gen_cmd("import sys;sys.exit(0)")) + self.test_exc ("spawn (%s)" % self.gen_cmd("import sys;sys.exit(42)"), + DistutilsExecError) + + self.capture_output() + self.test_exc ("spawn (['vjwe9ghwe09fnkwef098vdsjn3209'])", + DistutilsExecError) + (output, error) = self.stop_capture() + exp_error = "unable to execute vjwe9ghwe09fnkwef098vdsjn3209:" + self.test_val ("output", "") + self.test_val ("error[0:%d]" % len(exp_error), exp_error) + + def check_output (self): + "Spawn commands with output and error output: 3" + + self.test_out ("spawn (%s)" % self.cmd_print, + "hello\n", "") + self.test_out ("spawn (%s)" % self.cmd_err, + "", "foo\n") + self.test_out ("spawn (%s)" % self.cmd_mixed, + "output", "error") + + def check_verbose (self): + "Verbose reporting of command executed: 2" + + self.test_out ("spawn (%s, verbose=1)" % self.cmd_trivial, + self.cmd_trivial_s + "\n", "") + self.test_out ("spawn (%s, verbose=1)" % self.cmd_print, + self.cmd_print_s + "\n" + "hello\n", + "") + + def check_dryrun (self): + "Spawn commands in dry-run mode (ie. don't actually do anything): " + self.test_out ("spawn (%s, dry_run=1)" % self.cmd_print, + "", "") + self.test_out ("spawn (%s, dry_run=1, verbose=1)" % self.cmd_print, + "%s -c %s\n" % (self.python, self.cmd_print_s), + "") + + + if __name__ == "__main__": + (scenarios, options) = parse_args() + run_scenarios (scenarios, options) + sys.exit() spawn (["/bin/ls"]) From python-dev@python.org Sun Jun 4 14:45:28 2000 From: python-dev@python.org (Greg Ward) Date: Sun, 4 Jun 2000 06:45:28 -0700 Subject: [Python-checkins] CVS: distutils mksnap,1.4,1.5 Message-ID: <200006041345.GAA31689@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv31681 Modified Files: mksnap Log Message: Tweaked to run at home instead of work, now that I can't update python.org easily at work. ;-( Soon to be obsolete. Index: mksnap =================================================================== RCS file: /cvsroot/python/distutils/mksnap,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** mksnap 2000/04/12 01:45:04 1.4 --- mksnap 2000/06/04 13:45:25 1.5 *************** *** 7,11 **** # command! # ! # $Id: mksnap,v 1.4 2000/04/12 01:45:04 gward Exp $ # --- 7,11 ---- # command! # ! # $Id: mksnap,v 1.5 2000/06/04 13:45:25 gward Exp $ # *************** *** 15,20 **** use POSIX ('strftime'); ! my $tar = '/depot/gnu/plat/bin/gnutar'; # MUST be gnutar! ! #my $tar = '/bin/tar'; die "don't know where to find gnutar" unless -x $tar; --- 15,20 ---- use POSIX ('strftime'); ! #my $tar = '/depot/gnu/plat/bin/gnutar'; # MUST be gnutar! ! my $tar = '/bin/tar'; die "don't know where to find gnutar" unless -x $tar; From python-dev@python.org Sun Jun 4 14:46:22 2000 From: python-dev@python.org (Greg Ward) Date: Sun, 4 Jun 2000 06:46:22 -0700 Subject: [Python-checkins] CVS: distutils README.txt,1.15,1.16 Message-ID: <200006041346.GAA31833@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv31819 Modified Files: README.txt Log Message: Tweaked credits list. Index: README.txt =================================================================== RCS file: /cvsroot/python/distutils/README.txt,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** README.txt 2000/06/02 02:22:06 1.15 --- README.txt 2000/06/04 13:46:19 1.16 *************** *** 347,356 **** * Bastian Kleineidam: the "clean" command, and a pile of patches, bug-fixes, and ideas, large and small ! * Lyle Johnson: bug-spotting and -fixing; (forthcoming) support ! for Borland's C/C++ compiler * Harry Henry Gebel: bug-spotting and -fixing; the "bztar" archive format; the "bdist_rpm" command ! * Rene Liebscher: smarter extension-building; (forthcoming?) ! Cygwin/Mingw32 support [spiritual, in roughly chronological order since the birth of the project] --- 347,356 ---- * Bastian Kleineidam: the "clean" command, and a pile of patches, bug-fixes, and ideas, large and small ! * Lyle Johnson: bug-spotting and -fixing; support for Borland's C/C++ ! compiler (forthcoming) * Harry Henry Gebel: bug-spotting and -fixing; the "bztar" archive format; the "bdist_rpm" command ! * Rene Liebscher: smarter extension-building; Cygwin/Mingw32 support ! (forthcoming) [spiritual, in roughly chronological order since the birth of the project] *************** *** 372,374 **** the CPAN archive (Jarkko), and the CPAN module (Andreas) ! $Id: README.txt,v 1.15 2000/06/02 02:22:06 gward Exp $ --- 372,374 ---- the CPAN archive (Jarkko), and the CPAN module (Andreas) ! $Id: README.txt,v 1.16 2000/06/04 13:46:19 gward Exp $ From python-dev@python.org Sun Jun 4 15:21:00 2000 From: python-dev@python.org (Greg Ward) Date: Sun, 4 Jun 2000 07:21:00 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist_rpm.py,1.9,1.10 Message-ID: <200006041421.HAA11488@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv11480 Modified Files: bdist_rpm.py Log Message: Removed the 'ensure_*' methods -- they're just too handy too keep in one command class, so they're now in the Command base class. Index: bdist_rpm.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist_rpm.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** bdist_rpm.py 2000/06/03 01:03:55 1.9 --- bdist_rpm.py 2000/06/04 14:20:57 1.10 *************** *** 6,12 **** # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.9 2000/06/03 01:03:55 gward Exp $" ! import os, string, re from types import * from distutils.core import Command, DEBUG --- 6,12 ---- # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.10 2000/06/04 14:20:57 gward Exp $" ! import os, string from types import * from distutils.core import Command, DEBUG *************** *** 202,247 **** # finalize_package_data () - - - # XXX these look awfully handy: should probably move them - # up to Command and use more widely. - def _ensure_stringlike (self, option, what, default=None): - val = getattr(self, option) - if val is None: - setattr(self, option, default) - return default - elif type(val) is not StringType: - raise DistutilsOptionError, \ - "'%s' must be a %s (got `%s`)" % (option, what, val) - return val - - def ensure_string (self, option, default=None): - self._ensure_stringlike(option, "string", default) - - def ensure_string_list (self, option): - val = getattr(self, option) - if val is None: - return - elif type(val) is StringType: - setattr(self, option, re.split(r',\s*|\s+', val)) - else: - if type(val) is ListType: - types = map(type, val) - ok = (types == [StringType] * len(val)) - else: - ok = 0 - - if not ok: - raise DistutilsOptionError, \ - "'%s' must be a list of strings (got %s)" % \ - (option, `val`) - - def ensure_filename (self, option, default=None): - val = self._ensure_stringlike(option, "filename", None) - if val is not None and not os.path.exists(val): - raise DistutilsOptionError, \ - "error in '%s' option: file '%s' does not exist" % \ - (option, val) - --- 202,205 ---- From python-dev@python.org Sun Jun 4 15:21:30 2000 From: python-dev@python.org (Greg Ward) Date: Sun, 4 Jun 2000 07:21:30 -0700 Subject: [Python-checkins] CVS: distutils/distutils cmd.py,1.16,1.17 Message-ID: <200006041421.HAA11505@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv11496 Modified Files: cmd.py Log Message: Added the 'ensure_*' methods from bdist_rpm; refactored 'ensure_filename()' and added 'ensure_dirname()'. Index: cmd.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/cmd.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** cmd.py 2000/06/02 00:44:53 1.16 --- cmd.py 2000/06/04 14:21:28 1.17 *************** *** 8,14 **** # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: cmd.py,v 1.16 2000/06/02 00:44:53 gward Exp $" ! import sys, os, string from types import * from distutils.errors import * --- 8,14 ---- # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: cmd.py,v 1.17 2000/06/04 14:21:28 gward Exp $" ! import sys, os, string, re from types import * from distutils.errors import * *************** *** 172,175 **** --- 172,246 ---- if self.verbose >= level: print msg + + + # -- Option validation methods ------------------------------------- + # (these are very handy in writing the 'finalize_options()' method) + # + # NB. the general philosophy here is to ensure that a particular option + # value meets certain type and value constraints. If not, we try to + # force it into conformance (eg. if we expect a list but have a string, + # split the string on comma and/or whitespace). If we can't force the + # option into conformance, raise DistutilsOptionError. Thus, command + # classes need do nothing more than (eg.) + # self.ensure_string_list('foo') + # and they can be guaranteed that thereafter, self.foo will be + # a list of strings. + + def _ensure_stringlike (self, option, what, default=None): + val = getattr(self, option) + if val is None: + setattr(self, option, default) + return default + elif type(val) is not StringType: + raise DistutilsOptionError, \ + "'%s' must be a %s (got `%s`)" % (option, what, val) + return val + + def ensure_string (self, option, default=None): + """Ensure that 'option' is a string; if not defined, set it to + 'default'. + """ + self._ensure_stringlike(option, "string", default) + + def ensure_string_list (self, option): + """Ensure that 'option' is a list of strings. If 'option' is + currently a string, we split it either on /,\s*/ or /\s+/, so + "foo bar baz", "foo,bar,baz", and "foo, bar baz" all become + ["foo", "bar", "baz"]. + """ + val = getattr(self, option) + if val is None: + return + elif type(val) is StringType: + setattr(self, option, re.split(r',\s*|\s+', val)) + else: + if type(val) is ListType: + types = map(type, val) + ok = (types == [StringType] * len(val)) + else: + ok = 0 + + if not ok: + raise DistutilsOptionError, \ + "'%s' must be a list of strings (got %s)" % \ + (option, `val`) + + def _ensure_tested_string (self, option, tester, + what, error_fmt, default=None): + val = self._ensure_stringlike(option, what, default) + if val is not None and not tester(val): + raise DistutilsOptionError, \ + ("error in '%s' option: " + error_fmt) % (option, val) + + def ensure_filename (self, option): + """Ensure that 'option' is the name of an existing file.""" + self._ensure_tested_string(option, os.path.isfile, + "filename", + "'%s' does not exist or is not a file") + + def ensure_dirname (self, option): + self._ensure_tested_string(option, os.path.isdir, + "directory name", + "'%s' does not exist or is not a directory") From python-dev@python.org Sun Jun 4 16:00:37 2000 From: python-dev@python.org (Greg Ward) Date: Sun, 4 Jun 2000 08:00:37 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist_rpm.py,1.10,1.11 Message-ID: <200006041500.IAA15510@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv13785 Modified Files: bdist_rpm.py Log Message: Patch from Harry Henry Gebel: Fills in question marks in help Reads scripts in from files rather than strings Adds RPM 2 compatibility mode (untested). Use of this mode requires that --bdist-base be specified because bdist_rpm has no way of detecting where RPM wants to find spec files and source files. An unmodified RedHat 5.0 system would require '--bdist-base=/usr/src/RedHat'. (You would also have to be root.) If the rpmrc file has been modified to allow RPMs to be built by normal users then --build-base would need to be changed accordingly. Formats the changelog. GPW: tweaked formatting, added some editorial comments. Index: bdist_rpm.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist_rpm.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** bdist_rpm.py 2000/06/04 14:20:57 1.10 --- bdist_rpm.py 2000/06/04 15:00:34 1.11 *************** *** 6,10 **** # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.10 2000/06/04 14:20:57 gward Exp $" import os, string --- 6,10 ---- # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.11 2000/06/04 15:00:34 gward Exp $" import os, string *************** *** 43,47 **** "RPM release number"), ('serial', None, ! "???"), ('vendor', None, "RPM \"vendor\" (eg. \"Joe Blow \") " --- 43,47 ---- "RPM release number"), ('serial', None, ! "RPM serial number"), ('vendor', None, "RPM \"vendor\" (eg. \"Joe Blow \") " *************** *** 53,68 **** "list of documentation files (space or comma-separated)"), ('changelog', None, ! "RPM changelog"), ('icon', None, "name of icon file"), ! ! ('prep-cmd', None, ! "?? pre-build command(s) ??"), ! ('build-cmd', None, ! "?? build command(s) ??"), ! ('install-cmd', None, ! "?? installation command(s) ??"), ! ('clean-cmd', None, ! "?? clean command(s) ??"), ('pre-install', None, "pre-install script (Bourne shell code)"), --- 53,67 ---- "list of documentation files (space or comma-separated)"), ('changelog', None, ! "path to RPM changelog"), ('icon', None, "name of icon file"), ! ('prep-script', None, ! "pre-build script (Bourne shell code)"), ! ('build-script', None, ! "build script (Bourne shell code)"), ! ('install-script', None, ! "installation script (Bourne shell code)"), ! ('clean-script', None, ! "clean script (Bourne shell code)"), ('pre-install', None, "pre-install script (Bourne shell code)"), *************** *** 73,87 **** ('post-uninstall', None, "post-uninstall script (Bourne shell code)"), - ('provides', None, ! "???"), ('requires', None, ! "???"), ('conflicts', None, ! "???"), ('build-requires', None, ! "???"), ('obsoletes', None, ! "???"), # Actions to take when building RPM --- 72,85 ---- ('post-uninstall', None, "post-uninstall script (Bourne shell code)"), ('provides', None, ! "capabilities provided by this package"), ('requires', None, ! "capabilities required by this package"), ('conflicts', None, ! "capabilities which conflict with this package"), ('build-requires', None, ! "capabilities required to build this package"), ('obsoletes', None, ! "capabilities made obsolete by this package"), # Actions to take when building RPM *************** *** 94,101 **** ('no-rpm-opt-flags', None, "do not pass any RPM CFLAGS to compiler"), ] negative_opt = {'no-clean': 'clean', ! 'no-rpm-opt-flags': 'use-rpm-opt-flags'} --- 92,104 ---- ('no-rpm-opt-flags', None, "do not pass any RPM CFLAGS to compiler"), + ('rpm3-mode', None, + "RPM 3 compatibility mode (default)"), + ('rpm2-mode', None, + "RPM 2 compatibility mode"), ] negative_opt = {'no-clean': 'clean', ! 'no-rpm-opt-flags': 'use-rpm-opt-flags', ! 'rpm2-mode': 'rpm3-mode'} *************** *** 117,124 **** self.icon = None ! self.prep_cmd = None ! self.build_cmd = None ! self.install_cmd = None ! self.clean_cmd = None self.pre_install = None self.post_install = None --- 120,127 ---- self.icon = None ! self.prep_script = None ! self.build_script = None ! self.install_script = None ! self.clean_script = None self.pre_install = None self.post_install = None *************** *** 134,137 **** --- 137,141 ---- self.clean = 1 self.use_rpm_opt_flags = 1 + self.rpm3_mode = 1 # initialize_options() *************** *** 161,165 **** "%s <%s>" % (self.distribution.get_contact(), self.distribution.get_contact_email())) ! self.ensure_string('packager', self.vendor) # or nothing? self.ensure_string_list('doc_files') if type(self.doc_files) is ListType: --- 165,169 ---- "%s <%s>" % (self.distribution.get_contact(), self.distribution.get_contact_email())) ! self.ensure_string('packager') self.ensure_string_list('doc_files') if type(self.doc_files) is ListType: *************** *** 168,189 **** self.doc.append(readme) ! self.ensure_string('release', "1") # should it be an int? self.ensure_string('serial') # should it be an int? - self.ensure_string('icon') self.ensure_string('distribution_name') ! self.ensure_string('prep_cmd', "%setup") # string or filename? ! if self.use_rpm_opt_flags: ! def_build = 'env CFLAGS="$RPM_OPT_FLAGS" python setup.py build' ! else: ! def_build = 'python setup.py build' ! self.ensure_string('build_cmd', def_build) ! self.ensure_string('install_cmd', ! "python setup.py install --root=$RPM_BUILD_ROOT " ! "--record=INSTALLED_FILES") ! self.ensure_string('clean_cmd', ! "rm -rf $RPM_BUILD_ROOT") self.ensure_filename('pre_install') self.ensure_filename('post_install') --- 172,190 ---- self.doc.append(readme) ! self.ensure_string('release', "1") self.ensure_string('serial') # should it be an int? self.ensure_string('distribution_name') ! self.ensure_string('changelog') ! # Format changelog correctly ! self.changelog = self._format_changelog(self.changelog) ! self.ensure_filename('icon') ! ! self.ensure_filename('prep_script') ! self.ensure_filename('build_script') ! self.ensure_filename('install_script') ! self.ensure_filename('clean_script') self.ensure_filename('pre_install') self.ensure_filename('post_install') *************** *** 218,222 **** self.mkpath(spec_dir) # XXX should be configurable else: ! rpm_base = os.path.join(self.bdist_base, "rpm") rpm_dir = {} for d in ('SOURCES', 'SPECS', 'BUILD', 'RPMS', 'SRPMS'): --- 219,227 ---- self.mkpath(spec_dir) # XXX should be configurable else: ! if self.rpm3_mode: ! rpm_base = os.path.join(self.bdist_base, "rpm") ! else: ! # complete path must be specified in RPM 2 mode ! rpm_base = self.bdist_base rpm_dir = {} for d in ('SOURCES', 'SPECS', 'BUILD', 'RPMS', 'SRPMS'): *************** *** 267,272 **** else: rpm_args.append('-ba') ! rpm_args.extend(['--define', ! '_topdir %s/%s' % (os.getcwd(), rpm_base),]) if self.clean: rpm_args.append('--clean') --- 272,278 ---- else: rpm_args.append('-ba') ! if self.rpm3_mode: ! rpm_args.extend(['--define', ! '_topdir %s/%s' % (os.getcwd(), rpm_base),]) if self.clean: rpm_args.append('--clean') *************** *** 364,388 **** # rpm scripts ! for (rpm_opt, attr) in (('prep', 'prep_cmd'), ! ('build', 'build_cmd'), ! ('install', 'install_cmd'), ! ('clean', 'clean_cmd'), ! ('pre', 'pre_install'), ! ('post', 'post_install'), ! ('preun', 'pre_uninstall'), ! ('postun', 'post_uninstall')): ! # XXX oops, this doesn't distinguish between "raw code" ! # options and "script filename" options -- well, we probably ! # should settle on one or the other, and not make the ! # distinction! val = getattr(self, attr) ! if val: spec_file.extend([ '', ! '%' + rpm_opt, ! val ! ]) ! # files section spec_file.extend([ --- 370,412 ---- # rpm scripts ! # figure out default build script ! if self.use_rpm_opt_flags: ! def_build = 'env CFLAGS="$RPM_OPT_FLAGS" python setup.py build' ! else: ! def_build = 'python setup.py build' ! # insert contents of files ! ! # XXX this is kind of misleading: user-supplied options are files ! # that we open and interpolate into the spec file, but the defaults ! # are just text that we drop in as-is. Hmmm. ! ! script_options = [ ! ('prep', 'prep_script', "%setup"), ! ('build', 'build_script', def_build), ! ('install', 'install_script', ! "python setup.py install " ! "--root=$RPM_BUILD_ROOT " ! "--record=INSTALLED_FILES"), ! ('clean', 'clean_script', "rm -rf $RPM_BUILD_ROOT"), ! ('pre', 'pre_install', None), ! ('post', 'post_install', None), ! ('preun', 'pre_uninstall', None), ! ('postun', 'post_uninstall', None)) ! ] ! ! for (rpm_opt, attr, default) in script_options: ! # Insert contents of file refered to, if no file is refered to ! # use 'default' as contents of script val = getattr(self, attr) ! if val or default: spec_file.extend([ '', ! '%' + rpm_opt,]) ! if val: ! spec_file.extend(string.split(open(val, 'r').read(), '\n')) ! else: ! spec_file.append(default) ! # files section spec_file.extend([ *************** *** 398,408 **** spec_file.extend([ '', ! '%changelog', ! self.changelog ! ]) return spec_file # _make_spec_file () # class bdist_rpm --- 422,452 ---- spec_file.extend([ '', ! '%changelog',]) ! spec_file.extend(self.changelog) return spec_file # _make_spec_file () + + def _format_changelog(self, changelog): + """Format the changelog correctly and convert it to a list of strings + """ + new_changelog = [] + for line in string.split(string.strip(changelog), '\n'): + line = string.strip(line) + if line[0] == '*': + new_changelog.extend(['', line]) + elif line[0] == '-': + new_changelog.append(line) + else: + new_changelog.append(' ' + line) + + # strip trailing newline inserted by first changelog entry + if not new_changelog[0]: + del new_changelog[0] + + return new_changelog + + # _format_changelog() # class bdist_rpm From python-dev@python.org Sun Jun 4 16:12:53 2000 From: python-dev@python.org (Greg Ward) Date: Sun, 4 Jun 2000 08:12:53 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command sdist.py,1.23,1.24 Message-ID: <200006041512.IAA19491@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv19483 Modified Files: sdist.py Log Message: Use 'ensure_string_list()' for 'formats' option, so that it can be spelled sensibly in a config file. Index: sdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/sdist.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -r1.23 -r1.24 *** sdist.py 2000/06/01 01:10:56 1.23 --- sdist.py 2000/06/04 15:12:51 1.24 *************** *** 5,9 **** # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.23 2000/06/01 01:10:56 gward Exp $" import sys, os, string, re --- 5,9 ---- # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.24 2000/06/04 15:12:51 gward Exp $" import sys, os, string, re *************** *** 74,77 **** --- 74,78 ---- self.template = "MANIFEST.in" + self.ensure_string_list('formats') if self.formats is None: try: *************** *** 81,86 **** "don't know how to create source distributions " + \ "on platform %s" % os.name - elif type (self.formats) is StringType: - self.formats = string.split (self.formats, ',') bad_format = check_archive_formats (self.formats) --- 82,85 ---- From python-dev@python.org Sun Jun 4 16:30:37 2000 From: python-dev@python.org (Greg Ward) Date: Sun, 4 Jun 2000 08:30:37 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist_rpm.py,1.11,1.12 Message-ID: <200006041530.IAA20449@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv20334 Modified Files: bdist_rpm.py Log Message: Fixed syntax error. Half-fixed RPM 2 compatibility:added 'rpm_base' option, which must be set (to eg. /usr/src/redhat on a stock Red Hat system) if rpm2_mode is on. Still not quite working, though. Index: bdist_rpm.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist_rpm.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** bdist_rpm.py 2000/06/04 15:00:34 1.11 --- bdist_rpm.py 2000/06/04 15:30:35 1.12 *************** *** 6,10 **** # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.11 2000/06/04 15:00:34 gward Exp $" import os, string --- 6,10 ---- # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.12 2000/06/04 15:30:35 gward Exp $" import os, string *************** *** 19,24 **** user_options = [ ! ('bdist-base', None, "base directory for creating built distributions"), ('spec-only', None, "only regenerate spec file"), --- 19,27 ---- user_options = [ ! ('bdist-base=', None, "base directory for creating built distributions"), + ('rpm-base=', None, + "base directory for creating RPMs (defaults to \"rpm\" under " + "--bdist-base; must be specified for RPM 2)"), ('spec-only', None, "only regenerate spec file"), *************** *** 105,108 **** --- 108,112 ---- def initialize_options (self): self.bdist_base = None + self.rpm_base = None self.spec_only = None self.binary_only = None *************** *** 144,147 **** --- 148,157 ---- def finalize_options (self): self.set_undefined_options('bdist', ('bdist_base', 'bdist_base')) + if self.rpm_base is None: + if not self.rpm3_mode: + raise DistutilsOptionError, \ + "you must specify --rpm-base in RPM 2 mode" + self.rpm_base = os.path.join(self.bdist_base, "rpm") + if os.name != 'posix': raise DistutilsPlatformError, \ *************** *** 219,230 **** self.mkpath(spec_dir) # XXX should be configurable else: - if self.rpm3_mode: - rpm_base = os.path.join(self.bdist_base, "rpm") - else: - # complete path must be specified in RPM 2 mode - rpm_base = self.bdist_base rpm_dir = {} for d in ('SOURCES', 'SPECS', 'BUILD', 'RPMS', 'SRPMS'): ! rpm_dir[d] = os.path.join(rpm_base, d) self.mkpath(rpm_dir[d]) spec_dir = rpm_dir['SPECS'] --- 229,235 ---- self.mkpath(spec_dir) # XXX should be configurable else: rpm_dir = {} for d in ('SOURCES', 'SPECS', 'BUILD', 'RPMS', 'SRPMS'): ! rpm_dir[d] = os.path.join(self.rpm_base, d) self.mkpath(rpm_dir[d]) spec_dir = rpm_dir['SPECS'] *************** *** 274,278 **** if self.rpm3_mode: rpm_args.extend(['--define', ! '_topdir %s/%s' % (os.getcwd(), rpm_base),]) if self.clean: rpm_args.append('--clean') --- 279,283 ---- if self.rpm3_mode: rpm_args.extend(['--define', ! '_topdir %s/%s' % (os.getcwd(), self.rpm_base),]) if self.clean: rpm_args.append('--clean') *************** *** 392,396 **** ('post', 'post_install', None), ('preun', 'pre_uninstall', None), ! ('postun', 'post_uninstall', None)) ] --- 397,401 ---- ('post', 'post_install', None), ('preun', 'pre_uninstall', None), ! ('postun', 'post_uninstall', None), ] From python-dev@python.org Tue Jun 6 03:18:16 2000 From: python-dev@python.org (Greg Ward) Date: Mon, 5 Jun 2000 19:18:16 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command install_data.py,1.7,1.8 Message-ID: <200006060218.TAA25313@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv25303 Modified Files: install_data.py Log Message: 'get_outputs()' now returns an empty list instead of None. Index: install_data.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/install_data.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** install_data.py 2000/05/25 02:14:26 1.7 --- install_data.py 2000/06/06 02:18:13 1.8 *************** *** 6,10 **** # contributed by Bastian Kleineidam ! __revision__ = "$Id: install_data.py,v 1.7 2000/05/25 02:14:26 gward Exp $" import os --- 6,10 ---- # contributed by Bastian Kleineidam ! __revision__ = "$Id: install_data.py,v 1.8 2000/06/06 02:18:13 gward Exp $" import os *************** *** 57,59 **** def get_outputs (self): ! return self.outfiles --- 57,59 ---- def get_outputs (self): ! return self.outfiles or [] From python-dev@python.org Tue Jun 6 03:51:40 2000 From: python-dev@python.org (Greg Ward) Date: Mon, 5 Jun 2000 19:51:40 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist.py,1.9,1.10 Message-ID: <200006060251.TAA26971@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv26962/command Modified Files: bdist.py Log Message: Support for multiple distribution formats in one run. Index: bdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** bdist.py 2000/05/27 17:27:23 1.9 --- bdist.py 2000/06/06 02:51:38 1.10 *************** *** 6,10 **** # created 2000/03/29, Greg Ward ! __revision__ = "$Id: bdist.py,v 1.9 2000/05/27 17:27:23 gward Exp $" import os, string --- 6,10 ---- # created 2000/03/29, Greg Ward ! __revision__ = "$Id: bdist.py,v 1.10 2000/06/06 02:51:38 gward Exp $" import os, string *************** *** 21,27 **** user_options = [('bdist-base=', 'b', "temporary directory for creating built distributions"), ! ('format=', 'f', ! "format for distribution " + ! "(tar, ztar, gztar, bztar, zip, ... )"), ] --- 21,27 ---- user_options = [('bdist-base=', 'b', "temporary directory for creating built distributions"), ! ('formats=', None, ! "formats for distribution " + ! "(gztar, bztar, zip, rpm, ... )"), ] *************** *** 44,48 **** def initialize_options (self): self.bdist_base = None ! self.format = None # initialize_options() --- 44,48 ---- def initialize_options (self): self.bdist_base = None ! self.formats = None # initialize_options() *************** *** 58,70 **** self.bdist_base = os.path.join (build_base, 'bdist.' + plat) ! if self.format is None: try: ! self.format = self.default_format[os.name] except KeyError: raise DistutilsPlatformError, \ "don't know how to create built distributions " + \ "on platform %s" % os.name - #elif type (self.format) is StringType: - # self.format = string.split (self.format, ',') # finalize_options() --- 58,69 ---- self.bdist_base = os.path.join (build_base, 'bdist.' + plat) ! self.ensure_string_list('formats') ! if self.formats is None: try: ! self.formats = [self.default_format[os.name]] except KeyError: raise DistutilsPlatformError, \ "don't know how to create built distributions " + \ "on platform %s" % os.name # finalize_options() *************** *** 73,86 **** def run (self): ! try: ! cmd_name = self.format_command[self.format] ! except KeyError: ! raise DistutilsOptionError, \ ! "invalid archive format '%s'" % self.format ! ! if cmd_name not in self.no_format_option: ! sub_cmd = self.get_finalized_command (cmd_name) ! sub_cmd.format = self.format ! self.run_command (cmd_name) # run() --- 72,87 ---- def run (self): ! for format in self.formats: ! ! try: ! cmd_name = self.format_command[self.format] ! except KeyError: ! raise DistutilsOptionError, \ ! "invalid format '%s'" % self.format ! ! sub_cmd = self.reinitialize_command(cmd_name) ! if cmd_name not in self.no_format_option: ! sub_cmd.format = self.format ! self.run_command (cmd_name) # run() From python-dev@python.org Tue Jun 6 03:52:38 2000 From: python-dev@python.org (Greg Ward) Date: Mon, 5 Jun 2000 19:52:38 -0700 Subject: [Python-checkins] CVS: distutils/distutils dist.py,1.24,1.25 Message-ID: <200006060252.TAA27112@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv27015 Modified Files: dist.py Log Message: Fix 'reinitialize_command()' so it resets the 'have_run' flag for the command being reinitialized to false. Index: dist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/dist.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -r1.24 -r1.25 *** dist.py 2000/06/02 01:59:33 1.24 --- dist.py 2000/06/06 02:52:36 1.25 *************** *** 8,12 **** # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: dist.py,v 1.24 2000/06/02 01:59:33 gward Exp $" import sys, os, string, re --- 8,12 ---- # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: dist.py,v 1.25 2000/06/06 02:52:36 gward Exp $" import sys, os, string, re *************** *** 713,716 **** --- 713,717 ---- command.initialize_options() command.finalized = 0 + self.have_run[command_name] = 0 self._set_command_options(command) return command From python-dev@python.org Tue Jun 6 03:57:10 2000 From: python-dev@python.org (Greg Ward) Date: Mon, 5 Jun 2000 19:57:10 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command config.py,NONE,1.1 Message-ID: <200006060257.TAA27243@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv27120/command Added Files: config.py Log Message: First crack at the Distutils "config" command. Unlike other commands, this one doesn't *do* anything by default; it's just there as a conduit for data (eg. include dirs, libraries) from the user to the "build" commands. However, it provides a couple of Autoconf-ish methods ('try_compile()', 'try_link()', 'try_run()') that derived, per-distribution "config" commands can use to poke around the target system and see what's available. Initial experimenst with mxDateTime indicate that higher-level methods are necessary: analogs of Autoconf's AC_CHECK_HEADER, AC_CHECK_LIB will be needed too (and that's just to probe the C/C++ system: how to probe the Python system is wide open, and someday we'll have to worry about probing a Java system too). From python-dev@python.org Tue Jun 6 21:52:20 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 6 Jun 2000 13:52:20 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules posixmodule.c,2.135,2.136 Message-ID: <200006062052.NAA24475@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv24342 Modified Files: posixmodule.c Log Message: Patch from Trent Mick: Fix a small bug in posixmodule.c where a char* is being dereferenced where it should not be. Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.135 retrieving revision 2.136 diff -C2 -r2.135 -r2.136 *** posixmodule.c 2000/06/01 02:02:46 2.135 --- posixmodule.c 2000/06/06 20:52:17 2.136 *************** *** 892,896 **** if (FindClose(hFindFile) == FALSE) { errno = GetLastError(); ! return posix_error_with_filename(&name); } --- 892,896 ---- if (FindClose(hFindFile) == FALSE) { errno = GetLastError(); ! return posix_error_with_filename(name); } From python-dev@python.org Wed Jun 7 10:04:08 2000 From: python-dev@python.org (Marc-Andre Lemburg) Date: Wed, 7 Jun 2000 02:04:08 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/encodings undefined.py,NONE,1.1 Message-ID: <200006070904.CAA14879@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/encodings In directory slayer.i.sourceforge.net:/tmp/cvs-serv14834/Lib/encodings Added Files: undefined.py Log Message: New codec which always raises an exception when used. This codec can be used to effectively switch off string coercion to Unicode. From python-dev@python.org Wed Jun 7 10:11:43 2000 From: python-dev@python.org (Marc-Andre Lemburg) Date: Wed, 7 Jun 2000 02:11:43 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib locale.py,1.4,1.5 Message-ID: <200006070911.CAA17368@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv17332/Lib Modified Files: locale.py Log Message: Marc-Andre Lemburg : Added a new locale name aliasing engine which also supports locale encodings, a feature which is used by the new default encoding support in site.py. Index: locale.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/locale.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** locale.py 2000/02/04 15:39:29 1.4 --- locale.py 2000/06/07 09:11:40 1.5 *************** *** 1,9 **** ! """Support for number formatting using the current locale settings.""" ! # Author: Martin von Loewis ! from _locale import * import string #perform the grouping from right to left def _group(s): --- 1,25 ---- ! """ Locale support. ! The module provides low-level access to the C lib's locale APIs ! and adds high level number formatting APIs as well as a locale ! aliasing engine to complement these. ! The aliasing engine includes support for many commonly used locale ! names and maps them to values suitable for passing to the C lib's ! setlocale() function. It also includes default encodings for all ! supported locale names. ! ! """ ! import string + ### C lib locale APIs + + from _locale import * + + ### Number formatting APIs + + # Author: Martin von Loewis + #perform the grouping from right to left def _group(s): *************** *** 26,30 **** result=s[-group:] s=s[:-group] ! if s and result: result=s+conv['thousands_sep']+result return result --- 42,48 ---- result=s[-group:] s=s[:-group] ! if not result: ! return s ! if s: result=s+conv['thousands_sep']+result return result *************** *** 35,39 **** Grouping is applied if the third parameter is true.""" result = f % val ! fields = string.splitfields(result,".") if grouping: fields[0]=_group(fields[0]) --- 53,57 ---- Grouping is applied if the third parameter is true.""" result = f % val ! fields = string.split(result, ".") if grouping: fields[0]=_group(fields[0]) *************** *** 52,60 **** "Parses a string as a float according to the locale settings." #First, get rid of the grouping ! s=string.splitfields(str,localeconv()['thousands_sep']) ! str=string.join(s,"") #next, replace the decimal point with a dot ! s=string.splitfields(str,localeconv()['decimal_point']) ! str=string.join(s,'.') #finally, parse the string return func(str) --- 70,82 ---- "Parses a string as a float according to the locale settings." #First, get rid of the grouping ! ts = localeconv()['thousands_sep'] ! if ts: ! s=string.split(str,ts) ! str=string.join(s, "") #next, replace the decimal point with a dot ! dd = localeconv()['decimal_point'] ! if dd: ! s=string.split(str,dd) ! str=string.join(s,'.') #finally, parse the string return func(str) *************** *** 64,68 **** return atof(str,string.atoi) ! def test(): setlocale(LC_ALL,"") #do grouping --- 86,90 ---- return atof(str,string.atoi) ! def _test(): setlocale(LC_ALL,"") #do grouping *************** *** 72,77 **** s1=str(3.14) print s1,"is",atof(s1) if __name__=='__main__': ! test() --- 94,571 ---- s1=str(3.14) print s1,"is",atof(s1) + + ### Locale name aliasing engine + + # Author: Marc-Andre Lemburg, mal@lemburg.com + + def normalize(localename): + + """ Returns a normalized locale code for the given locale + name. + + The returned locale code is formatted for use with + setlocale(). + + If normalization fails, the original name is returned + unchanged. + + If the given encoding is not known, the function defaults to + the default encoding for the locale code just like setlocale() + does. + + """ + # Normalize the locale name and extract the encoding + fullname = string.lower(localename) + if ':' in fullname: + # ':' is sometimes used as encoding delimiter. + fullname = string.replace(fullname, ':', '.') + if '.' in fullname: + langname, encoding = string.split(fullname, '.')[:2] + fullname = langname + '.' + encoding + else: + langname = fullname + encoding = '' + + # First lookup: fullname (possibly with encoding) + code = locale_alias.get(fullname, None) + if code is not None: + return code + + # Second try: langname (without encoding) + code = locale_alias.get(langname, None) + if code is not None: + if '.' in code: + langname, defenc = string.split(code, '.') + else: + langname = code + defenc = '' + if encoding: + encoding = encoding_alias.get(encoding, encoding) + else: + encoding = defenc + if encoding: + return langname + '.' + encoding + else: + return langname + + else: + return localename + + def _parse_localename(localename): + + """ Parses the locale code for localename and returns the + result as tuple (language code, encoding). + + The localename is normalized and passed through the locale + alias engine. A ValueError is raised in case the locale name + cannot be parsed. + + The language code corresponds to RFC 1766. code and encoding + can be None in case the values cannot be determined or are + unkown to this implementation. + + """ + code = normalize(localename) + if '.' in code: + return string.split(code, '.')[:2] + elif code == 'C': + return None, None + else: + raise ValueError,'unkown locale: %s' % localename + return l + + def _build_localename(localetuple): + + """ Builds a locale code from the given tuple (language code, + encoding). + + No aliasing or normalizing takes place. + + """ + language, encoding = localetuple + if language is None: + language = 'C' + if encoding is None: + return language + else: + return language + '.' + encoding + + def get_default(envvars=('LANGUAGE', 'LC_ALL', 'LC_CTYPE', 'LANG')): + + """ Tries to determine the default locale settings and returns + them as tuple (language code, encoding). + + According to POSIX, a program which has not called + setlocale(LC_ALL,"") runs using the portable 'C' locale. + Calling setlocale(LC_ALL,"") lets it use the default locale as + defined by the LANG variable. Since we don't want to interfere + with the current locale setting we thus emulate the behaviour + in the way described above. + + To maintain compatibility with other platforms, not only the + LANG variable is tested, but a list of variables given as + envvars parameter. The first found to be defined will be + used. envvars defaults to the search path used in GNU gettext; + it must always contain the variable name 'LANG'. + + Except for the code 'C', the language code corresponds to RFC + 1766. code and encoding can be None in case the values cannot + be determined. + + """ + import os + lookup = os.environ.get + for variable in envvars: + localename = lookup(variable,None) + if localename is not None: + break + else: + localename = 'C' + return _parse_localename(localename) + + def get_locale(category=LC_CTYPE): + + """ Returns the current setting for the given locale category as + tuple (language code, encoding). + + category may be one of the LC_* value except LC_ALL. It + defaults to LC_CTYPE. + + Except for the code 'C', the language code corresponds to RFC + 1766. code and encoding can be None in case the values cannot + be determined. + + """ + localename = setlocale(category) + if category == LC_ALL and ';' in localename: + raise TypeError,'category LC_ALL is not supported' + return _parse_localename(localename) + + def set_locale(localetuple, category=LC_ALL): + + """ Set the locale according to the localetuple (language code, + encoding) as returned by get_locale() and get_default(). + + The given codes are passed through the locale aliasing engine + before being given to setlocale() for processing. + + category may be given as one of the LC_* values. It defaults + to LC_ALL. + + """ + setlocale(category, normalize(_build_localename(localetuple))) + + def set_to_default(category=LC_ALL): + + """ Sets the locale for category to the default setting. + + The default setting is determined by calling + get_default(). category defaults to LC_ALL. + + """ + setlocale(category, _build_localename(get_default())) + + ### Database + # + # The following data was extracted from the locale.alias file which + # comes with X11 and then hand edited removing the explicit encoding + # definitions and adding some more aliases. The file is usually + # available as /usr/lib/X11/locale/locale.alias. + # + + # + # The encoding_alias table maps lowercase encoding alias names to C + # locale encoding names (case-sensitive). + # + encoding_alias = { + '437': 'C', + 'c': 'C', + 'iso8859': 'ISO8859-1', + '8859': 'ISO8859-1', + '88591': 'ISO8859-1', + 'ascii': 'ISO8859-1', + 'en': 'ISO8859-1', + 'iso88591': 'ISO8859-1', + 'iso_8859-1': 'ISO8859-1', + '885915': 'ISO8859-15', + 'iso885915': 'ISO8859-15', + 'iso_8859-15': 'ISO8859-15', + 'iso8859-2': 'ISO8859-2', + 'iso88592': 'ISO8859-2', + 'iso_8859-2': 'ISO8859-2', + 'iso88595': 'ISO8859-5', + 'iso88596': 'ISO8859-6', + 'iso88597': 'ISO8859-7', + 'iso88598': 'ISO8859-8', + 'iso88599': 'ISO8859-9', + 'iso-2022-jp': 'JIS7', + 'jis': 'JIS7', + 'jis7': 'JIS7', + 'sjis': 'SJIS', + 'tis620': 'TACTIS', + 'ajec': 'eucJP', + 'eucjp': 'eucJP', + 'ujis': 'eucJP', + 'utf-8': 'utf', + 'utf8': 'utf', + 'utf8@ucs4': 'utf', + } + + # + # The locale_alias table maps lowercase alias names to C locale names + # (case-sensitive). Encodings are always separated from the locale + # name using a dot ('.'); they should only be given in case the + # language name is needed to interpret the given encoding alias + # correctly (CJK codes often have this need). + # + locale_alias = { + 'american': 'en_US.ISO8859-1', + 'ar': 'ar_AA.ISO8859-6', + 'ar_aa': 'ar_AA.ISO8859-6', + 'ar_sa': 'ar_SA.ISO8859-6', + 'arabic': 'ar_AA.ISO8859-6', + 'bg': 'bg_BG.ISO8859-5', + 'bg_bg': 'bg_BG.ISO8859-5', + 'bulgarian': 'bg_BG.ISO8859-5', + 'c-french': 'fr_CA.ISO8859-1', + 'c': 'C', + 'c_c': 'C', + 'cextend': 'en_US.ISO8859-1', + 'chinese-s': 'zh_CN.eucCN', + 'chinese-t': 'zh_TW.eucTW', + 'croatian': 'hr_HR.ISO8859-2', + 'cs': 'cs_CZ.ISO8859-2', + 'cs_cs': 'cs_CZ.ISO8859-2', + 'cs_cz': 'cs_CZ.ISO8859-2', + 'cz': 'cz_CZ.ISO8859-2', + 'cz_cz': 'cz_CZ.ISO8859-2', + 'czech': 'cs_CS.ISO8859-2', + 'da': 'da_DK.ISO8859-1', + 'da_dk': 'da_DK.ISO8859-1', + 'danish': 'da_DK.ISO8859-1', + 'de': 'de_DE.ISO8859-1', + 'de_at': 'de_AT.ISO8859-1', + 'de_ch': 'de_CH.ISO8859-1', + 'de_de': 'de_DE.ISO8859-1', + 'dutch': 'nl_BE.ISO8859-1', + 'ee': 'ee_EE.ISO8859-4', + 'el': 'el_GR.ISO8859-7', + 'el_gr': 'el_GR.ISO8859-7', + 'en': 'en_US.ISO8859-1', + 'en_au': 'en_AU.ISO8859-1', + 'en_ca': 'en_CA.ISO8859-1', + 'en_gb': 'en_GB.ISO8859-1', + 'en_ie': 'en_IE.ISO8859-1', + 'en_nz': 'en_NZ.ISO8859-1', + 'en_uk': 'en_GB.ISO8859-1', + 'en_us': 'en_US.ISO8859-1', + 'eng_gb': 'en_GB.ISO8859-1', + 'english': 'en_EN.ISO8859-1', + 'english_uk': 'en_GB.ISO8859-1', + 'english_united-states': 'en_US.ISO8859-1', + 'english_us': 'en_US.ISO8859-1', + 'es': 'es_ES.ISO8859-1', + 'es_ar': 'es_AR.ISO8859-1', + 'es_bo': 'es_BO.ISO8859-1', + 'es_cl': 'es_CL.ISO8859-1', + 'es_co': 'es_CO.ISO8859-1', + 'es_cr': 'es_CR.ISO8859-1', + 'es_ec': 'es_EC.ISO8859-1', + 'es_es': 'es_ES.ISO8859-1', + 'es_gt': 'es_GT.ISO8859-1', + 'es_mx': 'es_MX.ISO8859-1', + 'es_ni': 'es_NI.ISO8859-1', + 'es_pa': 'es_PA.ISO8859-1', + 'es_pe': 'es_PE.ISO8859-1', + 'es_py': 'es_PY.ISO8859-1', + 'es_sv': 'es_SV.ISO8859-1', + 'es_uy': 'es_UY.ISO8859-1', + 'es_ve': 'es_VE.ISO8859-1', + 'et': 'et_EE.ISO8859-4', + 'et_ee': 'et_EE.ISO8859-4', + 'fi': 'fi_FI.ISO8859-1', + 'fi_fi': 'fi_FI.ISO8859-1', + 'finnish': 'fi_FI.ISO8859-1', + 'fr': 'fr_FR.ISO8859-1', + 'fr_be': 'fr_BE.ISO8859-1', + 'fr_ca': 'fr_CA.ISO8859-1', + 'fr_ch': 'fr_CH.ISO8859-1', + 'fr_fr': 'fr_FR.ISO8859-1', + 'fre_fr': 'fr_FR.ISO8859-1', + 'french': 'fr_FR.ISO8859-1', + 'french_france': 'fr_FR.ISO8859-1', + 'ger_de': 'de_DE.ISO8859-1', + 'german': 'de_DE.ISO8859-1', + 'german_germany': 'de_DE.ISO8859-1', + 'greek': 'el_GR.ISO8859-7', + 'hebrew': 'iw_IL.ISO8859-8', + 'hr': 'hr_HR.ISO8859-2', + 'hr_hr': 'hr_HR.ISO8859-2', + 'hu': 'hu_HU.ISO8859-2', + 'hu_hu': 'hu_HU.ISO8859-2', + 'hungarian': 'hu_HU.ISO8859-2', + 'icelandic': 'is_IS.ISO8859-1', + 'id': 'id_ID.ISO8859-1', + 'id_id': 'id_ID.ISO8859-1', + 'is': 'is_IS.ISO8859-1', + 'is_is': 'is_IS.ISO8859-1', + 'iso-8859-1': 'en_US.ISO8859-1', + 'iso-8859-15': 'en_US.ISO8859-15', + 'iso8859-1': 'en_US.ISO8859-1', + 'iso8859-15': 'en_US.ISO8859-15', + 'iso_8859_1': 'en_US.ISO8859-1', + 'iso_8859_15': 'en_US.ISO8859-15', + 'it': 'it_IT.ISO8859-1', + 'it_ch': 'it_CH.ISO8859-1', + 'it_it': 'it_IT.ISO8859-1', + 'italian': 'it_IT.ISO8859-1', + 'iw': 'iw_IL.ISO8859-8', + 'iw_il': 'iw_IL.ISO8859-8', + 'ja': 'ja_JP.eucJP', + 'ja.jis': 'ja_JP.JIS7', + 'ja.sjis': 'ja_JP.SJIS', + 'ja_jp': 'ja_JP.eucJP', + 'ja_jp.ajec': 'ja_JP.eucJP', + 'ja_jp.euc': 'ja_JP.eucJP', + 'ja_jp.eucjp': 'ja_JP.eucJP', + 'ja_jp.iso-2022-jp': 'ja_JP.JIS7', + 'ja_jp.jis': 'ja_JP.JIS7', + 'ja_jp.jis7': 'ja_JP.JIS7', + 'ja_jp.mscode': 'ja_JP.SJIS', + 'ja_jp.sjis': 'ja_JP.SJIS', + 'ja_jp.ujis': 'ja_JP.eucJP', + 'japan': 'ja_JP.eucJP', + 'japanese': 'ja_JP.SJIS', + 'japanese-euc': 'ja_JP.eucJP', + 'japanese.euc': 'ja_JP.eucJP', + 'jp_jp': 'ja_JP.eucJP', + 'ko': 'ko_KR.eucKR', + 'ko_kr': 'ko_KR.eucKR', + 'ko_kr.euc': 'ko_KR.eucKR', + 'korean': 'ko_KR.eucKR', + 'lt': 'lt_LT.ISO8859-4', + 'lv': 'lv_LV.ISO8859-4', + 'mk': 'mk_MK.ISO8859-5', + 'mk_mk': 'mk_MK.ISO8859-5', + 'nl': 'nl_NL.ISO8859-1', + 'nl_be': 'nl_BE.ISO8859-1', + 'nl_nl': 'nl_NL.ISO8859-1', + 'no': 'no_NO.ISO8859-1', + 'no_no': 'no_NO.ISO8859-1', + 'norwegian': 'no_NO.ISO8859-1', + 'pl': 'pl_PL.ISO8859-2', + 'pl_pl': 'pl_PL.ISO8859-2', + 'polish': 'pl_PL.ISO8859-2', + 'portuguese': 'pt_PT.ISO8859-1', + 'portuguese_brazil': 'pt_BR.ISO8859-1', + 'posix': 'C', + 'posix-utf2': 'C', + 'pt': 'pt_PT.ISO8859-1', + 'pt_br': 'pt_BR.ISO8859-1', + 'pt_pt': 'pt_PT.ISO8859-1', + 'ro': 'ro_RO.ISO8859-2', + 'ro_ro': 'ro_RO.ISO8859-2', + 'ru': 'ru_RU.ISO8859-5', + 'ru_ru': 'ru_RU.ISO8859-5', + 'rumanian': 'ro_RO.ISO8859-2', + 'russian': 'ru_RU.ISO8859-5', + 'serbocroatian': 'sh_YU.ISO8859-2', + 'sh': 'sh_YU.ISO8859-2', + 'sh_hr': 'sh_HR.ISO8859-2', + 'sh_sp': 'sh_YU.ISO8859-2', + 'sh_yu': 'sh_YU.ISO8859-2', + 'sk': 'sk_SK.ISO8859-2', + 'sk_sk': 'sk_SK.ISO8859-2', + 'sl': 'sl_CS.ISO8859-2', + 'sl_cs': 'sl_CS.ISO8859-2', + 'sl_si': 'sl_SI.ISO8859-2', + 'slovak': 'sk_SK.ISO8859-2', + 'slovene': 'sl_CS.ISO8859-2', + 'sp': 'sp_YU.ISO8859-5', + 'sp_yu': 'sp_YU.ISO8859-5', + 'spanish': 'es_ES.ISO8859-1', + 'spanish_spain': 'es_ES.ISO8859-1', + 'sr_sp': 'sr_SP.ISO8859-2', + 'sv': 'sv_SE.ISO8859-1', + 'sv_se': 'sv_SE.ISO8859-1', + 'swedish': 'sv_SE.ISO8859-1', + 'th_th': 'th_TH.TACTIS', + 'tr': 'tr_TR.ISO8859-9', + 'tr_tr': 'tr_TR.ISO8859-9', + 'turkish': 'tr_TR.ISO8859-9', + 'univ': 'en_US.utf', + 'universal': 'en_US.utf', + 'zh': 'zh_CN.eucCN', + 'zh_cn': 'zh_CN.eucCN', + 'zh_cn.big5': 'zh_TW.eucTW', + 'zh_cn.euc': 'zh_CN.eucCN', + 'zh_tw': 'zh_TW.eucTW', + 'zh_tw.euc': 'zh_TW.eucTW', + } + + def _print_locale(): + + """ Test function. + """ + categories = {} + def _init_categories(categories=categories): + for k,v in globals().items(): + if k[:3] == 'LC_': + categories[k] = v + _init_categories() + del categories['LC_ALL'] + + print 'Locale defaults as determined by get_default():' + print '-'*72 + lang, enc = get_default() + print 'Language: ', lang or '(undefined)' + print 'Encoding: ', enc or '(undefined)' + print + + print 'Locale settings on startup:' + print '-'*72 + for name,category in categories.items(): + print name,'...' + lang, enc = get_locale(category) + print ' Language: ', lang or '(undefined)' + print ' Encoding: ', enc or '(undefined)' + print + + set_to_default() + print + print 'Locale settings after calling set_to_default():' + print '-'*72 + for name,category in categories.items(): + print name,'...' + lang, enc = get_locale(category) + print ' Language: ', lang or '(undefined)' + print ' Encoding: ', enc or '(undefined)' + print + + try: + setlocale(LC_ALL,"") + except: + print 'NOTE:' + print 'setlocale(LC_ALL,"") does not support the default locale' + print 'given in the OS environment variables.' + else: + print + print 'Locale settings after calling setlocale(LC_ALL,""):' + print '-'*72 + for name,category in categories.items(): + print name,'...' + lang, enc = get_locale(category) + print ' Language: ', lang or '(undefined)' + print ' Encoding: ', enc or '(undefined)' + print + ### if __name__=='__main__': ! print 'Locale aliasing:' ! print ! _print_locale() ! print ! print 'Number formatting:' ! print ! _test() From python-dev@python.org Wed Jun 7 10:12:12 2000 From: python-dev@python.org (Marc-Andre Lemburg) Date: Wed, 7 Jun 2000 02:12:12 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib site.py,1.10,1.11 Message-ID: <200006070912.CAA17624@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv17610/Lib Modified Files: site.py Log Message: Marc-Andre Lemburg : Added support to set the default encoding of strings at startup time to the values defined by the C locale. The sys.setdefaultencoding() API is deleted after having set up the encoding, so that user code cannot subsequentely change the setting. This effectively means that only site.py may alter the default setting. Index: site.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/site.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** site.py 1998/11/25 15:57:47 1.10 --- site.py 2000/06/07 09:12:09 1.11 *************** *** 120,127 **** del exit try: ! import sitecustomize # Run arbitrary site specific code except ImportError: ! pass # No site customization module def _test(): --- 120,162 ---- del exit + # + # Set the string encoding used by the Unicode implementation to the + # encoding used by the default locale of this system. If the default + # encoding cannot be determined or is unkown, it defaults to 'ascii'. + # + def locale_aware_defaultencoding(): + import locale + code, encoding = locale.get_default() + if encoding is None: + encoding = 'ascii' + try: + sys.setdefaultencoding(encoding) + except LookupError: + sys.setdefaultencoding('ascii') + + if 1: + # Enable to support locale aware default string encodings. + locale_aware_defaultencoding() + elif 0: + # Enable to switch off string to Unicode coercion and implicit + # Unicode to string conversion. + sys.setdefaultencoding('undefined') + elif 0: + # Enable to hard-code a site specific default string encoding. + sys.setdefaultencoding('ascii') + + # + # Run custom site specific code, if available. + # try: ! import sitecustomize except ImportError: ! pass ! ! # ! # Remove sys.setdefaultencoding() so that users cannot change the ! # encoding after initialization. ! # ! del sys.setdefaultencoding def _test(): From python-dev@python.org Wed Jun 7 10:12:33 2000 From: python-dev@python.org (Marc-Andre Lemburg) Date: Wed, 7 Jun 2000 02:12:33 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/encodings aliases.py,1.3,1.4 Message-ID: <200006070912.CAA17730@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/encodings In directory slayer.i.sourceforge.net:/tmp/cvs-serv17691/Lib/encodings Modified Files: aliases.py Log Message: Marc-Andre Lemburg : Added some more codec aliases. Some of them are needed by the new locale.py encoding support. Index: aliases.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/aliases.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** aliases.py 2000/04/05 20:11:18 1.3 --- aliases.py 2000/06/07 09:12:30 1.4 *************** *** 19,22 **** --- 19,24 ---- 'utf8': 'utf_8', 'u8': 'utf_8', + 'utf8@ucs2': 'utf_8', + 'utf8@ucs4': 'utf_8', # UTF-16 *************** *** 32,35 **** --- 34,39 ---- # ISO + '8859': 'latin_1', + 'iso8859': 'latin_1', 'iso8859_1': 'latin_1', 'iso_8859_1': 'latin_1', *************** *** 48,51 **** --- 52,56 ---- # Mac + 'maclatin2': 'mac_latin2', 'maccentraleurope': 'mac_latin2', 'maccyrillic': 'mac_cyrillic', *************** *** 57,60 **** --- 62,82 ---- # MBCS 'dbcs': 'mbcs', + + # Code pages + '437': 'cp437', + + # CJK + # + # The codecs for these encodings are not distributed with the + # Python core, but are included here for reference, since the + # locale module relies on having these aliases available. + # + 'jis_7': 'jis_7', + 'iso_2022_jp': 'jis_7', + 'ujis': 'euc_jp', + 'ajec': 'euc_jp', + 'eucjp': 'euc_jp', + 'tis260': 'tactis', + 'sjis': 'shift_jis', } From python-dev@python.org Wed Jun 7 10:12:56 2000 From: python-dev@python.org (Marc-Andre Lemburg) Date: Wed, 7 Jun 2000 02:12:56 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules Setup.in,1.100,1.101 Message-ID: <200006070912.CAA17814@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv17795/Modules Modified Files: Setup.in Log Message: Marc-Andre Lemburg : The locale module is turned on per default. Index: Setup.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Setup.in,v retrieving revision 1.100 retrieving revision 1.101 diff -C2 -r1.100 -r1.101 *** Setup.in 2000/05/26 19:02:42 1.100 --- Setup.in 2000/06/07 09:12:54 1.101 *************** *** 141,145 **** # static Unicode character database ! #_locale _localemodule.c # access to ISO C locale support --- 141,145 ---- # static Unicode character database ! _locale _localemodule.c # access to ISO C locale support From python-dev@python.org Wed Jun 7 10:13:24 2000 From: python-dev@python.org (Marc-Andre Lemburg) Date: Wed, 7 Jun 2000 02:13:24 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.21,2.22 Message-ID: <200006070913.CAA18060@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv17917/Objects Modified Files: unicodeobject.c Log Message: Marc-Andre Lemburg : Change the default encoding to 'ascii' (it was previously defined as UTF-8). Note: The implementation still uses UTF-8 to implement the buffer protocol, so C APIs will still see UTF-8. This is on purpose: rather than fixing the Unicode implementation, the C APIs should be made Unicode aware. Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.21 retrieving revision 2.22 diff -C2 -r2.21 -r2.22 *** unicodeobject.c 2000/05/09 19:54:43 2.21 --- unicodeobject.c 2000/06/07 09:13:21 2.22 *************** *** 4711,4715 **** /* Init the implementation */ unicode_empty = _PyUnicode_New(0); ! strcpy(unicode_default_encoding, "utf-8"); } --- 4711,4715 ---- /* Init the implementation */ unicode_empty = _PyUnicode_New(0); ! strcpy(unicode_default_encoding, "ascii"); } From python-dev@python.org Wed Jun 7 10:13:44 2000 From: python-dev@python.org (Marc-Andre Lemburg) Date: Wed, 7 Jun 2000 02:13:44 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python sysmodule.c,2.63,2.64 Message-ID: <200006070913.CAA18216@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv18159/Python Modified Files: sysmodule.c Log Message: Marc-Andre Lemburg : Changed the API names for setting the default encoding. These are now in line with the other hooks API names (no underscores). Index: sysmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v retrieving revision 2.63 retrieving revision 2.64 diff -C2 -r2.63 -r2.64 *** sysmodule.c 2000/05/09 19:57:01 2.63 --- sysmodule.c 2000/06/07 09:13:41 2.64 *************** *** 144,158 **** static PyObject * ! sys_get_string_encoding(self, args) PyObject *self; PyObject *args; { ! if (!PyArg_ParseTuple(args, ":get_string_encoding")) return NULL; return PyString_FromString(PyUnicode_GetDefaultEncoding()); } ! static char get_string_encoding_doc[] = ! "get_string_encoding() -> string\n\ \n\ Return the current default string encoding used by the Unicode \n\ --- 144,158 ---- static PyObject * ! sys_getdefaultencoding(self, args) PyObject *self; PyObject *args; { ! if (!PyArg_ParseTuple(args, ":getdefaultencoding")) return NULL; return PyString_FromString(PyUnicode_GetDefaultEncoding()); } ! static char getdefaultencoding_doc[] = ! "getdefaultencoding() -> string\n\ \n\ Return the current default string encoding used by the Unicode \n\ *************** *** 160,169 **** static PyObject * ! sys_set_string_encoding(self, args) PyObject *self; PyObject *args; { char *encoding; ! if (!PyArg_ParseTuple(args, "s:set_string_encoding", &encoding)) return NULL; if (PyUnicode_SetDefaultEncoding(encoding)) --- 160,169 ---- static PyObject * ! sys_setdefaultencoding(self, args) PyObject *self; PyObject *args; { char *encoding; ! if (!PyArg_ParseTuple(args, "s:setdefaultencoding", &encoding)) return NULL; if (PyUnicode_SetDefaultEncoding(encoding)) *************** *** 173,178 **** } ! static char set_string_encoding_doc[] = ! "set_string_encoding(encoding)\n\ \n\ Set the current default string encoding used by the Unicode implementation."; --- 173,178 ---- } ! static char setdefaultencoding_doc[] = ! "setdefaultencoding(encoding)\n\ \n\ Set the current default string encoding used by the Unicode implementation."; *************** *** 302,306 **** {"exc_info", sys_exc_info, 1, exc_info_doc}, {"exit", sys_exit, 0, exit_doc}, ! {"get_string_encoding", sys_get_string_encoding, 1, get_string_encoding_doc}, #ifdef COUNT_ALLOCS {"getcounts", sys_getcounts, 1}, --- 302,306 ---- {"exc_info", sys_exc_info, 1, exc_info_doc}, {"exit", sys_exit, 0, exit_doc}, ! {"getdefaultencoding", sys_getdefaultencoding, 1, getdefaultencoding_doc}, #ifdef COUNT_ALLOCS {"getcounts", sys_getcounts, 1}, *************** *** 316,320 **** {"mdebug", sys_mdebug, 1}, #endif ! {"set_string_encoding", sys_set_string_encoding, 1, set_string_encoding_doc}, {"setcheckinterval", sys_setcheckinterval, 1, setcheckinterval_doc}, {"setprofile", sys_setprofile, 0, setprofile_doc}, --- 316,320 ---- {"mdebug", sys_mdebug, 1}, #endif ! {"setdefaultencoding", sys_setdefaultencoding, 1, setdefaultencoding_doc}, {"setcheckinterval", sys_setcheckinterval, 1, setcheckinterval_doc}, {"setprofile", sys_setprofile, 0, setprofile_doc}, From python-dev@python.org Thu Jun 8 01:02:39 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 7 Jun 2000 17:02:39 -0700 Subject: [Python-checkins] CVS: distutils/distutils cmd.py,1.17,1.18 Message-ID: <200006080002.RAA15620@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv15602 Modified Files: cmd.py Log Message: Added 'debug_print()' method (driven by DEBUG global from distutils.core). Index: cmd.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/cmd.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** cmd.py 2000/06/04 14:21:28 1.17 --- cmd.py 2000/06/08 00:02:36 1.18 *************** *** 8,12 **** # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: cmd.py,v 1.17 2000/06/04 14:21:28 gward Exp $" import sys, os, string, re --- 8,12 ---- # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: cmd.py,v 1.18 2000/06/08 00:02:36 gward Exp $" import sys, os, string, re *************** *** 172,175 **** --- 172,184 ---- if self.verbose >= level: print msg + + def debug_print (self, msg): + """Print 'msg' to stdout if the global DEBUG (taken from the + DISTUTILS_DEBUG environment variable) flag is true. + """ + from distutils.core import DEBUG + if DEBUG: + print msg + From python-dev@python.org Thu Jun 8 01:08:17 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 7 Jun 2000 17:08:17 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command sdist.py,1.25,1.26 Message-ID: <200006080008.RAA15980@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv15881 Modified Files: sdist.py Log Message: Made all debug output go through the 'debug_print()' method instead of directly printing to stdout. This was a bit more work than it sounds like it should have been: * turned 'select_pattern()' and 'exclude_pattern()' from functions into methods, so they can refer to 'self' to access the method * commented out the *other* 'exclude_pattern()' method, which appears to be vestigial code that was never cleaned up when the 'exclude_pattern()' function was created * changed the one use of the old 'exclude_pattern()' method to use the new 'exclude_pattern()' (same behaviour, slightly different args) * some code and docstring reformatting * and, of course, changed all the debugging prints to 'debug_print()' calls Added/tweaked some regular ('self.announce()') output for better runtime feedback. Index: sdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/sdist.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -r1.25 -r1.26 *** sdist.py 2000/06/07 03:00:06 1.25 --- sdist.py 2000/06/08 00:08:14 1.26 *************** *** 5,9 **** # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.25 2000/06/07 03:00:06 gward Exp $" import sys, os, string, re --- 5,9 ---- # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.26 2000/06/08 00:08:14 gward Exp $" import sys, os, string, re *************** *** 273,284 **** ! def exclude_pattern (self, pattern): ! """Remove filenames from 'self.files' that match 'pattern'.""" ! print "exclude_pattern: pattern=%s" % pattern ! pattern_re = translate_pattern (pattern) ! for i in range (len (self.files)-1, -1, -1): ! if pattern_re.match (self.files[i]): ! print "removing %s" % self.files[i] ! del self.files[i] --- 273,284 ---- ! # def exclude_pattern (self, pattern): ! # """Remove filenames from 'self.files' that match 'pattern'.""" ! # self.debug_print("exclude_pattern: pattern=%s" % pattern) ! # pattern_re = translate_pattern (pattern) ! # for i in range (len (self.files)-1, -1, -1): ! # if pattern_re.match (self.files[i]): ! # self.debug_print("removing %s" % self.files[i]) ! # del self.files[i] *************** *** 287,291 **** and whose basenames match 'pattern'.""" ! print "recursive_exclude_pattern: dir=%s, pattern=%s" % (dir, pattern) if pattern is None: pattern_re = None --- 287,292 ---- and whose basenames match 'pattern'.""" ! self.debug_print("recursive_exclude_pattern: dir=%s, pattern=%s" % ! (dir, pattern)) if pattern is None: pattern_re = None *************** *** 297,301 **** if (cur_dir == dir and (pattern_re is None or pattern_re.match (cur_base))): ! print "removing %s" % self.files[i] del self.files[i] --- 298,302 ---- if (cur_dir == dir and (pattern_re is None or pattern_re.match (cur_base))): ! self.debug_print("removing %s" % self.files[i]) del self.files[i] *************** *** 308,311 **** --- 309,313 ---- assert self.files is not None and type (self.files) is ListType + self.announce("reading manifest template '%s'" % self.template) template = TextFile (self.template, *************** *** 375,390 **** if action == 'include': ! print "include", string.join(pattern_list) for pattern in pattern_list: ! files = select_pattern (all_files, pattern, anchor=1) if not files: ! template.warn ("no files found matching '%s'" % pattern) else: self.files.extend (files) elif action == 'exclude': ! print "exclude", string.join(pattern_list) for pattern in pattern_list: ! num = exclude_pattern (self.files, pattern, anchor=1) if num == 0: template.warn ( --- 377,393 ---- if action == 'include': ! self.debug_print("include " + string.join(pattern_list)) for pattern in pattern_list: ! files = self.select_pattern (all_files, pattern, anchor=1) if not files: ! template.warn ("no files found matching '%s'" % ! pattern) else: self.files.extend (files) elif action == 'exclude': ! self.debug_print("exclude " + string.join(pattern_list)) for pattern in pattern_list: ! num = self.exclude_pattern (self.files, pattern, anchor=1) if num == 0: template.warn ( *************** *** 393,399 **** elif action == 'global-include': ! print "global-include", string.join(pattern_list) for pattern in pattern_list: ! files = select_pattern (all_files, pattern, anchor=0) if not files: template.warn (("no files found matching '%s' " + --- 396,402 ---- elif action == 'global-include': ! self.debug_print("global-include " + string.join(pattern_list)) for pattern in pattern_list: ! files = self.select_pattern (all_files, pattern, anchor=0) if not files: template.warn (("no files found matching '%s' " + *************** *** 404,410 **** elif action == 'global-exclude': ! print "global-exclude", string.join(pattern_list) for pattern in pattern_list: ! num = exclude_pattern (self.files, pattern, anchor=0) if num == 0: template.warn \ --- 407,413 ---- elif action == 'global-exclude': ! self.debug_print("global-exclude " + string.join(pattern_list)) for pattern in pattern_list: ! num = self.exclude_pattern (self.files, pattern, anchor=0) if num == 0: template.warn \ *************** *** 414,420 **** elif action == 'recursive-include': ! print "recursive-include", dir, string.join(pattern_list) for pattern in pattern_list: ! files = select_pattern (all_files, pattern, prefix=dir) if not files: template.warn (("no files found matching '%s' " + --- 417,425 ---- elif action == 'recursive-include': ! self.debug_print("recursive-include %s %s" % ! (dir, string.join(pattern_list))) for pattern in pattern_list: ! files = self.select_pattern ( ! all_files, pattern, prefix=dir) if not files: template.warn (("no files found matching '%s' " + *************** *** 425,431 **** elif action == 'recursive-exclude': ! print "recursive-exclude", dir, string.join(pattern_list) for pattern in pattern_list: ! num = exclude_pattern (self.files, pattern, prefix=dir) if num == 0: template.warn \ --- 430,438 ---- elif action == 'recursive-exclude': ! self.debug_print("recursive-exclude %s %s" % ! (dir, string.join(pattern_list))) for pattern in pattern_list: ! num = self.exclude_pattern( ! self.files, pattern, prefix=dir) if num == 0: template.warn \ *************** *** 435,440 **** elif action == 'graft': ! print "graft", dir_pattern ! files = select_pattern (all_files, None, prefix=dir_pattern) if not files: template.warn ("no directories found matching '%s'" % --- 442,448 ---- elif action == 'graft': ! self.debug_print("graft " + dir_pattern) ! files = self.select_pattern( ! all_files, None, prefix=dir_pattern) if not files: template.warn ("no directories found matching '%s'" % *************** *** 444,449 **** elif action == 'prune': ! print "prune", dir_pattern ! num = exclude_pattern (self.files, None, prefix=dir_pattern) if num == 0: template.warn \ --- 452,458 ---- elif action == 'prune': ! self.debug_print("prune " + dir_pattern) ! num = self.exclude_pattern( ! self.files, None, prefix=dir_pattern) if num == 0: template.warn \ *************** *** 459,470 **** # Prune away the build and source distribution directories build = self.get_finalized_command ('build') ! exclude_pattern (self.files, None, prefix=build.build_base) base_dir = self.distribution.get_fullname() ! exclude_pattern (self.files, None, prefix=base_dir) # read_template () def write_manifest (self): """Write the file list in 'self.files' (presumably as filled in --- 468,528 ---- # Prune away the build and source distribution directories build = self.get_finalized_command ('build') ! self.exclude_pattern (self.files, None, prefix=build.build_base) base_dir = self.distribution.get_fullname() ! self.exclude_pattern (self.files, None, prefix=base_dir) # read_template () + def select_pattern (self, files, pattern, anchor=1, prefix=None): + """Select strings (presumably filenames) from 'files' that match + 'pattern', a Unix-style wildcard (glob) pattern. Patterns are not + quite the same as implemented by the 'fnmatch' module: '*' and '?' + match non-special characters, where "special" is platform-dependent: + slash on Unix, colon, slash, and backslash on DOS/Windows, and colon on + Mac OS. + + If 'anchor' is true (the default), then the pattern match is more + stringent: "*.py" will match "foo.py" but not "foo/bar.py". If + 'anchor' is false, both of these will match. + + If 'prefix' is supplied, then only filenames starting with 'prefix' + (itself a pattern) and ending with 'pattern', with anything in between + them, will match. 'anchor' is ignored in this case. + + Return the list of matching strings, possibly empty. + """ + matches = [] + pattern_re = translate_pattern (pattern, anchor, prefix) + self.debug_print("select_pattern: applying regex r'%s'" % + pattern_re.pattern) + for name in files: + if pattern_re.search (name): + matches.append (name) + self.debug_print(" adding " + name) + + return matches + + # select_pattern () + + + def exclude_pattern (self, files, pattern, anchor=1, prefix=None): + """Remove strings (presumably filenames) from 'files' that match + 'pattern'. 'pattern', 'anchor', 'and 'prefix' are the same + as for 'select_pattern()', above. The list 'files' is modified + in place. + """ + pattern_re = translate_pattern (pattern, anchor, prefix) + self.debug_print("exclude_pattern: applying regex r'%s'" % + pattern_re.pattern) + for i in range (len(files)-1, -1, -1): + if pattern_re.search (files[i]): + self.debug_print(" removing " + files[i]) + del files[i] + + # exclude_pattern () + + def write_manifest (self): """Write the file list in 'self.files' (presumably as filled in *************** *** 474,478 **** self.execute(write_file, (self.manifest, self.files), ! "writing manifest file") # write_manifest () --- 532,536 ---- self.execute(write_file, (self.manifest, self.files), ! "writing manifest file '%s'" % self.manifest) # write_manifest () *************** *** 484,487 **** --- 542,546 ---- in the source distribution.""" + self.announce("reading manifest file '%s'" % self.manifest) manifest = open (self.manifest) while 1: *************** *** 496,500 **** - def make_release_tree (self, base_dir, files): --- 555,558 ---- *************** *** 534,538 **** # Remove any files that match "base_dir" from the fileset -- we # don't want to go distributing the distribution inside itself! ! self.exclude_pattern (base_dir + "*") self.make_release_tree (base_dir, self.files) --- 592,596 ---- # Remove any files that match "base_dir" from the fileset -- we # don't want to go distributing the distribution inside itself! ! self.exclude_pattern (self.files, base_dir + "*") self.make_release_tree (base_dir, self.files) *************** *** 582,628 **** return list - - - def select_pattern (files, pattern, anchor=1, prefix=None): - """Select strings (presumably filenames) from 'files' that match - 'pattern', a Unix-style wildcard (glob) pattern. Patterns are not - quite the same as implemented by the 'fnmatch' module: '*' and '?' - match non-special characters, where "special" is platform-dependent: - slash on Unix, colon, slash, and backslash on DOS/Windows, and colon - on Mac OS. - - If 'anchor' is true (the default), then the pattern match is more - stringent: "*.py" will match "foo.py" but not "foo/bar.py". If - 'anchor' is false, both of these will match. - - If 'prefix' is supplied, then only filenames starting with 'prefix' - (itself a pattern) and ending with 'pattern', with anything in - between them, will match. 'anchor' is ignored in this case. - - Return the list of matching strings, possibly empty.""" - - matches = [] - pattern_re = translate_pattern (pattern, anchor, prefix) - print "select_pattern: applying re %s" % pattern_re.pattern - for name in files: - if pattern_re.search (name): - matches.append (name) - print " adding", name - - return matches - - # select_pattern () - - - def exclude_pattern (files, pattern, anchor=1, prefix=None): - - pattern_re = translate_pattern (pattern, anchor, prefix) - print "exclude_pattern: applying re %s" % pattern_re.pattern - for i in range (len(files)-1, -1, -1): - if pattern_re.search (files[i]): - print " removing", files[i] - del files[i] - - # exclude_pattern () --- 640,643 ---- From python-dev@python.org Thu Jun 8 01:14:20 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 7 Jun 2000 17:14:20 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command sdist.py,1.26,1.27 Message-ID: <200006080014.RAA16266@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv16257 Modified Files: sdist.py Log Message: Cosmetic tweaks to imports, the 'show_formats()' function, and the 'help_options' list; also added an editorial comment. Index: sdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/sdist.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -r1.26 -r1.27 *** sdist.py 2000/06/08 00:08:14 1.26 --- sdist.py 2000/06/08 00:14:18 1.27 *************** *** 5,9 **** # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.26 2000/06/08 00:08:14 gward Exp $" import sys, os, string, re --- 5,9 ---- # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.27 2000/06/08 00:14:18 gward Exp $" import sys, os, string, re *************** *** 12,18 **** from glob import glob from distutils.core import Command ! from distutils.util import newer, create_tree, remove_tree, convert_path, \ ! write_file ! from distutils.archive_util import check_archive_formats,ARCHIVE_FORMATS from distutils.text_file import TextFile from distutils.errors import DistutilsExecError, DistutilsOptionError --- 12,18 ---- from glob import glob from distutils.core import Command ! from distutils.util import \ ! convert_path, create_tree, remove_tree, newer, write_file, \ ! check_archive_formats, ARCHIVE_FORMATS from distutils.text_file import TextFile from distutils.errors import DistutilsExecError, DistutilsOptionError *************** *** 41,57 **** "archive file(s)"), ] ! # prints all possible arguments to --formats ! def show_formats(): from distutils.fancy_getopt import FancyGetopt ! list_of_formats=[] for format in ARCHIVE_FORMATS.keys(): ! list_of_formats.append(("formats="+format,None,ARCHIVE_FORMATS[format][2])) ! list_of_formats.sort() ! pretty_printer=FancyGetopt(list_of_formats) ! pretty_printer.print_help("List of available distribution formats:") help_options = [ ('help-formats', None, ! "lists available distribution formats",show_formats), ] --- 41,65 ---- "archive file(s)"), ] ! ! ! # XXX ugh: this has to precede the 'help_options' list, because ! # it is mentioned there -- also, this is not a method, even though ! # it's defined in a class: double-ugh! ! def show_formats (): ! """Print all possible values for the 'formats' option -- used by ! the "--help-formats" command-line option. ! """ from distutils.fancy_getopt import FancyGetopt ! formats=[] for format in ARCHIVE_FORMATS.keys(): ! formats.append(("formats="+format,None,ARCHIVE_FORMATS[format][2])) ! formats.sort() ! pretty_printer = FancyGetopt(formats) ! pretty_printer.print_help( ! "List of available source distribution formats:") help_options = [ ('help-formats', None, ! "lists available distribution formats", show_formats), ] From python-dev@python.org Thu Jun 8 01:24:03 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 7 Jun 2000 17:24:03 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command sdist.py,1.27,1.28 Message-ID: <200006080024.RAA16692@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv16683 Modified Files: sdist.py Log Message: Docstring reformatting binge. Index: sdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/sdist.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -r1.27 -r1.28 *** sdist.py 2000/06/08 00:14:18 1.27 --- sdist.py 2000/06/08 00:24:01 1.28 *************** *** 5,9 **** # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.27 2000/06/08 00:14:18 gward Exp $" import sys, os, string, re --- 5,9 ---- # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.28 2000/06/08 00:24:01 gward Exp $" import sys, os, string, re *************** *** 69,75 **** 'nt': 'zip' } - exclude_re = re.compile (r'\s*!\s*(\S+)') # for manifest lines - def initialize_options (self): # 'template' and 'manifest' are, respectively, the names of --- 69,73 ---- *************** *** 166,176 **** def get_file_list (self): """Figure out the list of files to include in the source ! distribution, and put it in 'self.files'. This might ! involve reading the manifest template (and writing the ! manifest), or just reading the manifest, or just using ! the default file set -- it all depends on the user's ! options and the state of the filesystem.""" ! ! template_exists = os.path.isfile (self.template) if template_exists: --- 164,172 ---- def get_file_list (self): """Figure out the list of files to include in the source ! distribution, and put it in 'self.files'. This might involve ! reading the manifest template (and writing the manifest), or just ! reading the manifest, or just using the default file set -- it all ! depends on the user's options and the state of the filesystem. ! """ template_exists = os.path.isfile (self.template) if template_exists: *************** *** 262,269 **** def search_dir (self, dir, pattern=None): """Recursively find files under 'dir' matching 'pattern' (a string ! containing a Unix-style glob pattern). If 'pattern' is None, ! find all files under 'dir'. Return the list of found ! filenames.""" ! allfiles = findall (dir) if pattern is None: --- 258,264 ---- def search_dir (self, dir, pattern=None): """Recursively find files under 'dir' matching 'pattern' (a string ! containing a Unix-style glob pattern). If 'pattern' is None, find ! all files under 'dir'. Return the list of found filenames. ! """ allfiles = findall (dir) if pattern is None: *************** *** 292,298 **** def recursive_exclude_pattern (self, dir, pattern=None): ! """Remove filenames from 'self.files' that are under 'dir' ! and whose basenames match 'pattern'.""" ! self.debug_print("recursive_exclude_pattern: dir=%s, pattern=%s" % (dir, pattern)) --- 287,293 ---- def recursive_exclude_pattern (self, dir, pattern=None): ! """Remove filenames from 'self.files' that are under 'dir' and ! whose basenames match 'pattern'. ! """ self.debug_print("recursive_exclude_pattern: dir=%s, pattern=%s" % (dir, pattern)) *************** *** 312,319 **** def read_template (self): """Read and parse the manifest template file named by ! 'self.template' (usually "MANIFEST.in"). Process all file ! specifications (include and exclude) in the manifest template ! and add the resulting filenames to 'self.files'.""" ! assert self.files is not None and type (self.files) is ListType self.announce("reading manifest template '%s'" % self.template) --- 307,314 ---- def read_template (self): """Read and parse the manifest template file named by ! 'self.template' (usually "MANIFEST.in"). Process all file ! specifications (include and exclude) in the manifest template and ! add the resulting filenames to 'self.files'. ! """ assert self.files is not None and type (self.files) is ListType self.announce("reading manifest template '%s'" % self.template) *************** *** 534,541 **** def write_manifest (self): ! """Write the file list in 'self.files' (presumably as filled in ! by 'find_defaults()' and 'read_template()') to the manifest file ! named by 'self.manifest'.""" ! self.execute(write_file, (self.manifest, self.files), --- 529,536 ---- def write_manifest (self): ! """Write the file list in 'self.files' (presumably as filled in by ! 'find_defaults()' and 'read_template()') to the manifest file named ! by 'self.manifest'. ! """ self.execute(write_file, (self.manifest, self.files), *************** *** 546,553 **** def read_manifest (self): ! """Read the manifest file (named by 'self.manifest') and use ! it to fill in 'self.files', the list of files to include ! in the source distribution.""" ! self.announce("reading manifest file '%s'" % self.manifest) manifest = open (self.manifest) --- 541,548 ---- def read_manifest (self): ! """Read the manifest file (named by 'self.manifest') and use it to ! fill in 'self.files', the list of files to include in the source ! distribution. ! """ self.announce("reading manifest file '%s'" % self.manifest) manifest = open (self.manifest) From python-dev@python.org Thu Jun 8 01:35:35 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 7 Jun 2000 17:35:35 -0700 Subject: [Python-checkins] CVS: distutils/distutils fancy_getopt.py,1.13,1.14 Message-ID: <200006080035.RAA17196@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv17185 Modified Files: fancy_getopt.py Log Message: Fixed so we print more than just the first line of help for options with a short form and text that wraps onto multiple lines. Index: fancy_getopt.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/fancy_getopt.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** fancy_getopt.py 2000/05/23 03:53:10 1.13 --- fancy_getopt.py 2000/06/08 00:35:33 1.14 *************** *** 11,15 **** # created 1999/03/03, Greg Ward ! __revision__ = "$Id: fancy_getopt.py,v 1.13 2000/05/23 03:53:10 gward Exp $" import sys, string, re --- 11,15 ---- # created 1999/03/03, Greg Ward ! __revision__ = "$Id: fancy_getopt.py,v 1.14 2000/06/08 00:35:33 gward Exp $" import sys, string, re *************** *** 370,376 **** lines.append (" --%-*s " % (max_opt, long)) - for l in text[1:]: - lines.append (big_indent + l) - # Case 2: we have a short option, so we have to include it # just after the long option --- 370,373 ---- *************** *** 382,385 **** --- 379,385 ---- else: lines.append (" --%-*s" % opt_names) + + for l in text[1:]: + lines.append (big_indent + l) # for self.option_table From python-dev@python.org Thu Jun 8 01:46:48 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 7 Jun 2000 17:46:48 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command sdist.py,1.28,1.29 Message-ID: <200006080046.RAA17696@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv17687 Modified Files: sdist.py Log Message: Docstring addition binge. Index: sdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/sdist.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -r1.28 -r1.29 *** sdist.py 2000/06/08 00:24:01 1.28 --- sdist.py 2000/06/08 00:46:45 1.29 *************** *** 5,9 **** # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.28 2000/06/08 00:24:01 gward Exp $" import sys, os, string, re --- 5,9 ---- # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.29 2000/06/08 00:46:45 gward Exp $" import sys, os, string, re *************** *** 32,36 **** "[default; disable with --no-defaults]"), ('manifest-only', 'o', ! "just regenerate the manifest and then stop"), ('force-manifest', 'f', "forcibly regenerate the manifest and carry on as usual"), --- 32,37 ---- "[default; disable with --no-defaults]"), ('manifest-only', 'o', ! "just regenerate the manifest and then stop " ! "(implies --force-manifest)"), ('force-manifest', 'f', "forcibly regenerate the manifest and carry on as usual"), *************** *** 134,138 **** def check_metadata (self): ! metadata = self.distribution.metadata --- 135,143 ---- def check_metadata (self): ! """Ensure that all required elements of meta-data (name, version, ! URL, (author and author_email) or (maintainer and ! maintainer_email)) are supplied by the Distribution object; warn if ! any are missing. ! """ metadata = self.distribution.metadata *************** *** 216,220 **** def find_defaults (self): ! standards = [('README', 'README.txt'), 'setup.py'] for fn in standards: --- 221,234 ---- def find_defaults (self): ! """Add all the default files to self.files: ! - README or README.txt ! - setup.py ! - test/test*.py ! - all pure Python modules mentioned in setup script ! - all C sources listed as part of extensions or C libraries ! in the setup script (doesn't catch C headers!) ! Warns if (README or README.txt) or setup.py are missing; everything ! else is optional. ! """ standards = [('README', 'README.txt'), 'setup.py'] for fn in standards: *************** *** 309,313 **** 'self.template' (usually "MANIFEST.in"). Process all file specifications (include and exclude) in the manifest template and ! add the resulting filenames to 'self.files'. """ assert self.files is not None and type (self.files) is ListType --- 323,328 ---- 'self.template' (usually "MANIFEST.in"). Process all file specifications (include and exclude) in the manifest template and ! update 'self.files' accordingly (filenames may be added to ! or removed from 'self.files' based on the manifest template). """ assert self.files is not None and type (self.files) is ListType *************** *** 559,563 **** def make_release_tree (self, base_dir, files): ! # Create all the directories under 'base_dir' necessary to # put 'files' there. --- 574,585 ---- def make_release_tree (self, base_dir, files): ! """Create the directory tree that will become the source ! distribution archive. All directories implied by the filenames in ! 'files' are created under 'base_dir', and then we hard link or copy ! (if hard linking is unavailable) those files into place. ! Essentially, this duplicates the developer's source tree, but in a ! directory named after the distribution, containing only the files ! to be distributed. ! """ # Create all the directories under 'base_dir' necessary to # put 'files' there. *************** *** 588,592 **** def make_distribution (self): ! # Don't warn about missing meta-data here -- should be (and is!) # done elsewhere. --- 610,620 ---- def make_distribution (self): ! """Create the source distribution(s). First, we create the release ! tree with 'make_release_tree()'; then, we create all required ! archive files (according to 'self.formats') from the release tree. ! Finally, we clean up by blowing away the release tree (unless ! 'self.keep_tree' is true). The list of archive files created is ! stored so it can be retrieved later by 'get_archive_files()'. ! """ # Don't warn about missing meta-data here -- should be (and is!) # done elsewhere. *************** *** 621,627 **** def findall (dir = os.curdir): ! """Find all files under 'dir' and return the list of full ! filenames (relative to 'dir').""" ! list = [] stack = [dir] --- 649,655 ---- def findall (dir = os.curdir): ! """Find all files under 'dir' and return the list of full filenames ! (relative to 'dir'). ! """ list = [] stack = [dir] *************** *** 646,653 **** def glob_to_re (pattern): ! """Translate a shell-like glob pattern to a regular expression; ! return a string containing the regex. Differs from ! 'fnmatch.translate()' in that '*' does not match "special ! characters" (which are platform-specific).""" pattern_re = fnmatch.translate (pattern) --- 674,682 ---- def glob_to_re (pattern): ! """Translate a shell-like glob pattern to a regular expression; return ! a string containing the regex. Differs from 'fnmatch.translate()' in ! that '*' does not match "special characters" (which are ! platform-specific). ! """ pattern_re = fnmatch.translate (pattern) *************** *** 667,672 **** def translate_pattern (pattern, anchor=1, prefix=None): """Translate a shell-like wildcard pattern to a compiled regular ! expression. Return the compiled regex.""" ! if pattern: pattern_re = glob_to_re (pattern) --- 696,701 ---- def translate_pattern (pattern, anchor=1, prefix=None): """Translate a shell-like wildcard pattern to a compiled regular ! expression. Return the compiled regex. ! """ if pattern: pattern_re = glob_to_re (pattern) From python-dev@python.org Thu Jun 8 01:52:55 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 7 Jun 2000 17:52:55 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command sdist.py,1.29,1.30 Message-ID: <200006080052.RAA17913@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv17904 Modified Files: sdist.py Log Message: Renamed 'find_defaults()' to 'add_defaults()'. Deleted old, commented-out 'exclude_pattern()' method. Index: sdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/sdist.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -r1.29 -r1.30 *** sdist.py 2000/06/08 00:46:45 1.29 --- sdist.py 2000/06/08 00:52:52 1.30 *************** *** 5,9 **** # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.29 2000/06/08 00:46:45 gward Exp $" import sys, os, string, re --- 5,9 ---- # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.30 2000/06/08 00:52:52 gward Exp $" import sys, os, string, re *************** *** 190,194 **** # Add default file set to 'files' if self.use_defaults: ! self.find_defaults () # Read manifest template if it exists --- 190,194 ---- # Add default file set to 'files' if self.use_defaults: ! self.add_defaults () # Read manifest template if it exists *************** *** 220,224 **** ! def find_defaults (self): """Add all the default files to self.files: - README or README.txt --- 220,224 ---- ! def add_defaults (self): """Add all the default files to self.files: - README or README.txt *************** *** 269,272 **** --- 269,274 ---- self.files.extend (build_clib.get_source_files ()) + # add_defaults () + def search_dir (self, dir, pattern=None): *************** *** 290,303 **** - # def exclude_pattern (self, pattern): - # """Remove filenames from 'self.files' that match 'pattern'.""" - # self.debug_print("exclude_pattern: pattern=%s" % pattern) - # pattern_re = translate_pattern (pattern) - # for i in range (len (self.files)-1, -1, -1): - # if pattern_re.match (self.files[i]): - # self.debug_print("removing %s" % self.files[i]) - # del self.files[i] - - def recursive_exclude_pattern (self, dir, pattern=None): """Remove filenames from 'self.files' that are under 'dir' and --- 292,295 ---- *************** *** 545,549 **** def write_manifest (self): """Write the file list in 'self.files' (presumably as filled in by ! 'find_defaults()' and 'read_template()') to the manifest file named by 'self.manifest'. """ --- 537,541 ---- def write_manifest (self): """Write the file list in 'self.files' (presumably as filled in by ! 'add_defaults()' and 'read_template()') to the manifest file named by 'self.manifest'. """ From python-dev@python.org Thu Jun 8 02:06:05 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 7 Jun 2000 18:06:05 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command sdist.py,1.30,1.31 Message-ID: <200006080106.SAA24066@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv23972 Modified Files: sdist.py Log Message: Moved the code that prunes the file list after reading the manifest template into a new method 'prune_file_list()', called from 'get_file_list()' rather than 'read_manifest()' -- this keeps 'read_manifest()' more general. Deleted the redundant call to 'exclude_pattern()' in 'make_distribution()' -- this had the same intention as 'prune_file_list()', but was incomplete (only pruned the release tree, not the build tree) and in the wrong place (the prune wouldn't be reflected in the manifest file). Index: sdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/sdist.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -r1.30 -r1.31 *** sdist.py 2000/06/08 00:52:52 1.30 --- sdist.py 2000/06/08 01:06:02 1.31 *************** *** 5,9 **** # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.30 2000/06/08 00:52:52 gward Exp $" import sys, os, string, re --- 5,9 ---- # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.31 2000/06/08 01:06:02 gward Exp $" import sys, os, string, re *************** *** 196,199 **** --- 196,202 ---- self.read_template () + # Prune away the build and source distribution directories + self.prune_file_list() + # File list now complete -- sort it so that higher-level files # come first *************** *** 476,488 **** # while loop over lines of template file ! # Prune away the build and source distribution directories ! build = self.get_finalized_command ('build') ! self.exclude_pattern (self.files, None, prefix=build.build_base) base_dir = self.distribution.get_fullname() self.exclude_pattern (self.files, None, prefix=base_dir) - # read_template () - def select_pattern (self, files, pattern, anchor=1, prefix=None): --- 479,497 ---- # while loop over lines of template file ! # read_template () ! + def prune_file_list (self): + """Prune off branches that might slip into the file list as created + by 'read_template()', but really don't belong there: specifically, + the build tree (typically "build") and the release tree itself + (only an issue if we ran "sdist" previously with --keep-tree, or it + aborted). + """ + build = self.get_finalized_command('build') base_dir = self.distribution.get_fullname() + self.exclude_pattern (self.files, None, prefix=build.build_base) self.exclude_pattern (self.files, None, prefix=base_dir) def select_pattern (self, files, pattern, anchor=1, prefix=None): *************** *** 613,620 **** base_dir = self.distribution.get_fullname() - # Remove any files that match "base_dir" from the fileset -- we - # don't want to go distributing the distribution inside itself! - self.exclude_pattern (self.files, base_dir + "*") - self.make_release_tree (base_dir, self.files) archive_files = [] # remember names of files we create --- 622,625 ---- From python-dev@python.org Thu Jun 8 02:17:35 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 7 Jun 2000 18:17:35 -0700 Subject: [Python-checkins] CVS: distutils MINIFEST.in,NONE,1.1 Message-ID: <200006080117.SAA24669@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv24661 Added Files: MINIFEST.in Log Message: Specialized manifest template for generating code snapshots: includes just the code and example setup scripts, no documentation or tests. From python-dev@python.org Thu Jun 8 02:18:38 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 7 Jun 2000 18:18:38 -0700 Subject: [Python-checkins] CVS: distutils snapshot_setup.py,NONE,1.1 Message-ID: <200006080118.SAA24789@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv24781 Added Files: snapshot_setup.py Log Message: Specialized setup script for generating code snapshots: uses current date instead of a version number, and ensures that the "sdist" command (which is all we really use this setup script for) reads/writes MINIFEST.in and MINIFEST instead of the usual MANIFEST.in/MANIFEST. From python-dev@python.org Thu Jun 8 02:19:20 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 7 Jun 2000 18:19:20 -0700 Subject: [Python-checkins] CVS: distutils mksnap,1.5,1.6 Message-ID: <200006080119.SAA24815@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv24804 Modified Files: mksnap Log Message: Blew away the old Perl script for generating code snapshots; now it's a trivial shell script thanks to the new specialized setup script and manifest template. Index: mksnap =================================================================== RCS file: /cvsroot/python/distutils/mksnap,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** mksnap 2000/06/04 13:45:25 1.5 --- mksnap 2000/06/08 01:19:18 1.6 *************** *** 1,45 **** ! #!/usr/local/bin/perl -w ! ! # ! # mksnap ! # ! # make a Distutils snapshot -- should go away once we have a 'dist' ! # command! ! # ! # $Id: mksnap,v 1.5 2000/06/04 13:45:25 gward Exp $ ! # ! ! use strict; ! use File::Find; ! use File::Copy ('move'); ! use POSIX ('strftime'); ! ! #my $tar = '/depot/gnu/plat/bin/gnutar'; # MUST be gnutar! ! my $tar = '/bin/tar'; ! die "don't know where to find gnutar" unless -x $tar; ! ! # gather up all filenames in the source directories (distutils, test, ...?) ! my @files; ! sub finder ! { ! $File::Find::prune = 1, return if /^(build|dd|www|CVS)$/; ! push @files, $File::Find::name if /.py$/; ! } ! ! chdir ".."; ! find (\&finder, 'distutils'); ! ! # and make a "snapshot" tarball named after today's date ! my $datestamp = strftime ('%Y%m%d', localtime time); ! my $snapname = "distutils-$datestamp.tar.gz"; ! print "creating $snapname\n"; ! open (TAR, "|$tar -cz -T - -f $snapname") ! || die "couldn't open pipe to $tar: $!\n"; ! print TAR join ("\n", @files) . "\n"; ! close (TAR); ! die "$tar failed" unless $? == 0; ! ! # and move the snapshot into the distutils web directory ! print "moving $snapname\n"; ! move ($snapname, "distutils/www/download") ! || die "couldn't move $snapname to distutils/www: $!\n"; --- 1,3 ---- ! #!/bin/sh ! ./snapshot_setup.py sdist ! mv distutils-*.{tar,zip}* www/download From python-dev@python.org Thu Jun 8 02:20:25 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 7 Jun 2000 18:20:25 -0700 Subject: [Python-checkins] CVS: distutils MANIFEST.in,1.6,1.7 Message-ID: <200006080120.SAA24940@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv24931 Modified Files: MANIFEST.in Log Message: 'examples/sample*' instead of 'examples/sample?' (the number of samples is growing...). Index: MANIFEST.in =================================================================== RCS file: /cvsroot/python/distutils/MANIFEST.in,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** MANIFEST.in 2000/06/02 02:22:16 1.6 --- MANIFEST.in 2000/06/08 01:20:23 1.7 *************** *** 6,10 **** # created 2000/02/14, Greg Ward # ! # $Id: MANIFEST.in,v 1.6 2000/06/02 02:22:16 gward Exp $ # --- 6,10 ---- # created 2000/02/14, Greg Ward # ! # $Id: MANIFEST.in,v 1.7 2000/06/08 01:20:23 gward Exp $ # *************** *** 12,15 **** include MANIFEST.in recursive-include examples *.txt *.py ! prune examples/sample?/build recursive-include doc *.sty *.tex --- 12,15 ---- include MANIFEST.in recursive-include examples *.txt *.py ! prune examples/sample*/build recursive-include doc *.sty *.tex From python-dev@python.org Thu Jun 8 02:21:34 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 7 Jun 2000 18:21:34 -0700 Subject: [Python-checkins] CVS: distutils setup.cfg,1.1,1.2 Message-ID: <200006080121.SAA24998@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv24989 Modified Files: setup.cfg Log Message: Changelog/release Update from Harry Gebel (slipped by when checking in his latest patch, I think). Index: setup.cfg =================================================================== RCS file: /cvsroot/python/distutils/setup.cfg,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** setup.cfg 2000/06/02 02:07:43 1.1 --- setup.cfg 2000/06/08 01:21:31 1.2 *************** *** 13,17 **** # created 2000/05/31, Greg Ward # ! # $Id: setup.cfg,v 1.1 2000/06/02 02:07:43 gward Exp $ # --- 13,17 ---- # created 2000/05/31, Greg Ward # ! # $Id: setup.cfg,v 1.2 2000/06/08 01:21:31 gward Exp $ # *************** *** 20,24 **** [bdist_rpm] ! release = 3 packager = Harry Henry Gebel doc_files = CHANGES.txt --- 20,24 ---- [bdist_rpm] ! release = 1 packager = Harry Henry Gebel doc_files = CHANGES.txt *************** *** 29,32 **** --- 29,36 ---- changelog = + * Sun Jun 04 2000 Harry Henry Gebel 0.9pre-1 + - Made sure scripts are file names, filled in some help strings, formatted + changelog correctly + * Wed May 31 2000 Greg Ward 0.8.3pre-1 - Hacked up bdist_rpm.py, moved meta-data into setup.cfg From python-dev@python.org Thu Jun 8 02:22:51 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 7 Jun 2000 18:22:51 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command sdist.py,1.31,1.32 Message-ID: <200006080122.SAA25099@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv25088 Modified Files: sdist.py Log Message: Include setup.cfg in the list of default files to distribute. Index: sdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/sdist.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -r1.31 -r1.32 *** sdist.py 2000/06/08 01:06:02 1.31 --- sdist.py 2000/06/08 01:22:48 1.32 *************** *** 5,9 **** # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.31 2000/06/08 01:06:02 gward Exp $" import sys, os, string, re --- 5,9 ---- # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.32 2000/06/08 01:22:48 gward Exp $" import sys, os, string, re *************** *** 234,237 **** --- 234,241 ---- else is optional. """ + + # XXX name of setup script and config file should be taken + # programmatically from the Distribution object (except + # it doesn't have that capability... yet!) standards = [('README', 'README.txt'), 'setup.py'] for fn in standards: *************** *** 254,258 **** self.warn ("standard file '%s' not found" % fn) ! optional = ['test/test*.py'] for pattern in optional: files = filter (os.path.isfile, glob (pattern)) --- 258,262 ---- self.warn ("standard file '%s' not found" % fn) ! optional = ['test/test*.py', 'setup.cfg'] for pattern in optional: files = filter (os.path.isfile, glob (pattern)) From python-dev@python.org Thu Jun 8 15:21:26 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 8 Jun 2000 07:21:26 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist_rpm.py,1.12,1.13 Message-ID: <200006081421.HAA11116@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv11106 Modified Files: bdist_rpm.py Log Message: Harry Henry Gebel: fix '_format_changelog()' so it doesn't bomb if passed None. Index: bdist_rpm.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist_rpm.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** bdist_rpm.py 2000/06/04 15:30:35 1.12 --- bdist_rpm.py 2000/06/08 14:21:23 1.13 *************** *** 437,440 **** --- 437,442 ---- """Format the changelog correctly and convert it to a list of strings """ + if not changelog: + return changelog new_changelog = [] for line in string.split(string.strip(changelog), '\n'): From python-dev@python.org Thu Jun 8 18:49:43 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Thu, 8 Jun 2000 10:49:43 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib locale.py,1.5,1.6 Message-ID: <200006081749.KAA08366@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv8358/Lib Modified Files: locale.py Log Message: Marc-Andre Lemburg : Added emulations of the C APIs in _locale to be used when the _locale module is not enabled. They return the correct values assuming the 'C' locale. Index: locale.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/locale.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** locale.py 2000/06/07 09:11:40 1.5 --- locale.py 2000/06/08 17:49:41 1.6 *************** *** 14,20 **** import string ! ### C lib locale APIs ! from _locale import * ### Number formatting APIs --- 14,78 ---- import string ! ### Load C lib locale APIs or use an emulation ! try: ! from _locale import * ! ! except ImportError: ! ! CHAR_MAX = 127 ! LC_ALL = 6 ! LC_COLLATE = 3 ! LC_CTYPE = 0 ! LC_MESSAGES = 5 ! LC_MONETARY = 4 ! LC_NUMERIC = 1 ! LC_TIME = 2 ! Error = ValueError ! ! def localeconv(): ! """ localeconv() -> dict. ! Returns numeric and monetary locale-specific parameters. ! """ ! # 'C' locale default values ! return {'grouping': [127], ! 'currency_symbol': '', ! 'n_sign_posn': 127, ! 'p_cs_precedes': 127, ! 'n_cs_precedes': 127, ! 'mon_grouping': [], ! 'n_sep_by_space': 127, ! 'decimal_point': '.', ! 'negative_sign': '', ! 'positive_sign': '', ! 'p_sep_by_space': 127, ! 'int_curr_symbol': '', ! 'p_sign_posn': 127, ! 'thousands_sep': '', ! 'mon_thousands_sep': '', ! 'frac_digits': 127, ! 'mon_decimal_point': '', ! 'int_frac_digits': 127} ! ! def setlocale(category, value=None): ! """ setlocale(integer,string=None) -> string. ! Activates/queries locale processing. ! """ ! if value is not None and \ ! value is not 'C': ! raise Error,'_locale emulation only supports "C" locale' ! return 'C' ! ! def strcoll(a,b): ! """ strcoll(string,string) -> int. ! Compares two strings according to the locale. ! """ ! return cmp(a,b) ! ! def strxfrm(s): ! """ strxfrm(string) -> string. ! Returns a string that behaves for cmp locale-aware. ! """ ! return s ### Number formatting APIs From python-dev@python.org Thu Jun 8 18:50:57 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Thu, 8 Jun 2000 10:50:57 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_unicode.py,1.11,1.12 Message-ID: <200006081750.KAA08463@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv8451/Lib/test Modified Files: test_unicode.py Log Message: Marc-Andre Lemburg : Updated to the fix in %c formatting: it now always checks for a one character argument. Index: test_unicode.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** test_unicode.py 2000/05/09 19:57:46 1.11 --- test_unicode.py 2000/06/08 17:50:55 1.12 *************** *** 248,253 **** assert u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", -1, -2, 3.57) == u'abc, abc, -1, -2.000000, 3.57' assert u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", -1, -2, 1003.57) == u'abc, abc, -1, -2.000000, 1003.57' ! assert u"%c" % (u"abc",) == u'a' ! assert u"%c" % ("abc",) == u'a' assert u"%c" % (34,) == u'"' assert u"%c" % (36,) == u'$' --- 248,253 ---- assert u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", -1, -2, 3.57) == u'abc, abc, -1, -2.000000, 3.57' assert u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", -1, -2, 1003.57) == u'abc, abc, -1, -2.000000, 1003.57' ! assert u"%c" % (u"a",) == u'a' ! assert u"%c" % ("a",) == u'a' assert u"%c" % (34,) == u'"' assert u"%c" % (36,) == u'$' From python-dev@python.org Thu Jun 8 18:51:35 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Thu, 8 Jun 2000 10:51:35 -0700 Subject: [Python-checkins] CVS: python/dist/src/Misc unicode.txt,3.7,3.8 Message-ID: <200006081751.KAA08508@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Misc In directory slayer.i.sourceforge.net:/tmp/cvs-serv8496/Misc Modified Files: unicode.txt Log Message: Marc-Andre Lemburg : Updated to version 1.5. Includes typo fixes by Andrew Kuchling and a new section on the default encoding. Index: unicode.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/unicode.txt,v retrieving revision 3.7 retrieving revision 3.8 diff -C2 -r3.7 -r3.8 *** unicode.txt 2000/05/09 19:58:19 3.7 --- unicode.txt 2000/06/08 17:51:33 3.8 *************** *** 20,28 **** The latest version of this document is always available at: ! http://starship.skyport.net/~lemburg/unicode-proposal.txt Older versions are available as: ! http://starship.skyport.net/~lemburg/unicode-proposal-X.X.txt --- 20,28 ---- The latest version of this document is always available at: ! http://starship.python.net/~lemburg/unicode-proposal.txt Older versions are available as: ! http://starship.python.net/~lemburg/unicode-proposal-X.X.txt *************** *** 102,106 **** needed, but if you include Latin-1 characters not defined in ASCII, it may well be worthwhile including a hint since people in other ! countries will want to be able to read you source strings too. --- 102,106 ---- needed, but if you include Latin-1 characters not defined in ASCII, it may well be worthwhile including a hint since people in other ! countries will want to be able to read your source strings too. *************** *** 170,174 **** In containment tests ('a' in u'abc' and u'a' in 'abc') both sides ! should be coerced to Unicode before applying the test. Errors occuring during coercion (e.g. None in u'abc') should not be masked. --- 170,174 ---- In containment tests ('a' in u'abc' and u'a' in 'abc') both sides ! should be coerced to Unicode before applying the test. Errors occurring during coercion (e.g. None in u'abc') should not be masked. *************** *** 185,189 **** All string methods should delegate the call to an equivalent Unicode ! object method call by converting all envolved strings to Unicode and then applying the arguments to the Unicode method of the same name, e.g. --- 185,189 ---- All string methods should delegate the call to an equivalent Unicode ! object method call by converting all involved strings to Unicode and then applying the arguments to the Unicode method of the same name, e.g. *************** *** 200,204 **** ----------- ! UnicodeError is defined in the exceptions module as subclass of ValueError. It is available at the C level via PyExc_UnicodeError. All exceptions related to Unicode encoding/decoding should be --- 200,204 ---- ----------- ! UnicodeError is defined in the exceptions module as a subclass of ValueError. It is available at the C level via PyExc_UnicodeError. All exceptions related to Unicode encoding/decoding should be *************** *** 269,273 **** 'utf-8': 8-bit variable length encoding ! 'utf-16': 16-bit variable length encoding (litte/big endian) 'utf-16-le': utf-16 but explicitly little endian 'utf-16-be': utf-16 but explicitly big endian --- 269,273 ---- 'utf-8': 8-bit variable length encoding ! 'utf-16': 16-bit variable length encoding (little/big endian) 'utf-16-le': utf-16 but explicitly little endian 'utf-16-be': utf-16 but explicitly big endian *************** *** 285,289 **** All other encodings such as the CJK ones to support Asian scripts ! should be implemented in seperate packages which do not get included in the core Python distribution and are not a part of this proposal. --- 285,289 ---- All other encodings such as the CJK ones to support Asian scripts ! should be implemented in separate packages which do not get included in the core Python distribution and are not a part of this proposal. *************** *** 325,329 **** def encode(self,input,errors='strict'): ! """ Encodes the object intput and returns a tuple (output object, length consumed). --- 325,329 ---- def encode(self,input,errors='strict'): ! """ Encodes the object input and returns a tuple (output object, length consumed). *************** *** 332,336 **** The method may not store state in the Codec instance. Use ! SteamCodec for codecs which have to keep state in order to make encoding/decoding efficient. --- 332,336 ---- The method may not store state in the Codec instance. Use ! StreamCodec for codecs which have to keep state in order to make encoding/decoding efficient. *************** *** 351,355 **** The method may not store state in the Codec instance. Use ! SteamCodec for codecs which have to keep state in order to make encoding/decoding efficient. --- 351,355 ---- The method may not store state in the Codec instance. Use ! StreamCodec for codecs which have to keep state in order to make encoding/decoding efficient. *************** *** 491,495 **** .readline() method -- there is currently no support for line breaking using the codec decoder due to lack of line ! buffering. Sublcasses should however, if possible, try to implement this method using their own knowledge of line breaking. --- 491,495 ---- .readline() method -- there is currently no support for line breaking using the codec decoder due to lack of line ! buffering. Subclasses should however, if possible, try to implement this method using their own knowledge of line breaking. *************** *** 528,532 **** Note that no stream repositioning should take place. ! This method is primarely intended to be able to recover from decoding errors. --- 528,532 ---- Note that no stream repositioning should take place. ! This method is primarily intended to be able to recover from decoding errors. *************** *** 554,558 **** It is not required by the Unicode implementation to use these base classes, only the interfaces must match; this allows writing Codecs as ! extensions types. As guideline, large mapping tables should be implemented using static --- 554,558 ---- It is not required by the Unicode implementation to use these base classes, only the interfaces must match; this allows writing Codecs as ! extension types. As guideline, large mapping tables should be implemented using static *************** *** 629,634 **** Support for these is left to user land Codecs and not explicitly ! intergrated into the core. Note that due to the Internal Format being ! implemented, only the area between \uE000 and \uF8FF is useable for private encodings. --- 629,634 ---- Support for these is left to user land Codecs and not explicitly ! integrated into the core. Note that due to the Internal Format being ! implemented, only the area between \uE000 and \uF8FF is usable for private encodings. *************** *** 650,654 **** It is the Codec's responsibility to ensure that the data they pass to ! the Unicode object constructor repects this assumption. The constructor does not check the data for Unicode compliance or use of surrogates. --- 650,654 ---- It is the Codec's responsibility to ensure that the data they pass to ! the Unicode object constructor respects this assumption. The constructor does not check the data for Unicode compliance or use of surrogates. *************** *** 657,661 **** set of all UTF-16 addressable characters (around 1M characters). ! The Unicode API should provide inteface routines from to the compiler's wchar_t which can be 16 or 32 bit depending on the compiler/libc/platform being used. --- 657,661 ---- set of all UTF-16 addressable characters (around 1M characters). ! The Unicode API should provide interface routines from to the compiler's wchar_t which can be 16 or 32 bit depending on the compiler/libc/platform being used. From python-dev@python.org Thu Jun 8 18:54:03 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Thu, 8 Jun 2000 10:54:03 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.22,2.23 Message-ID: <200006081754.KAA08775@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv8762/Objects Modified Files: unicodeobject.c Log Message: Marc-Andre Lemburg : Fixed %c formatting to check for one character arguments. Thanks to Finn Bock for finding this bug. Added a fix for bug PR#348 which originated from not resetting the globals correctly in _PyUnicode_Fini(). Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.22 retrieving revision 2.23 diff -C2 -r2.22 -r2.23 *** unicodeobject.c 2000/06/07 09:13:21 2.22 --- unicodeobject.c 2000/06/08 17:54:00 2.23 *************** *** 109,120 **** #endif ! /* --- Globals ------------------------------------------------------------ */ /* The empty Unicode object */ ! static PyUnicodeObject *unicode_empty = NULL; /* Free list for Unicode objects */ ! static PyUnicodeObject *unicode_freelist = NULL; ! static int unicode_freelist_size = 0; /* Default encoding to use and assume when NULL is passed as encoding --- 109,125 ---- #endif ! /* --- Globals ------------------------------------------------------------ + The globals are initialized by the _PyUnicode_Init() API and should + not be used before calling that API. + + */ + /* The empty Unicode object */ ! static PyUnicodeObject *unicode_empty; /* Free list for Unicode objects */ ! static PyUnicodeObject *unicode_freelist; ! static int unicode_freelist_size; /* Default encoding to use and assume when NULL is passed as encoding *************** *** 4263,4271 **** PyObject *v) { ! if (PyUnicode_Check(v)) buf[0] = PyUnicode_AS_UNICODE(v)[0]; ! else if (PyString_Check(v)) ! buf[0] = (Py_UNICODE) PyString_AS_STRING(v)[0]; else { --- 4268,4282 ---- PyObject *v) { ! if (PyUnicode_Check(v)) { ! if (PyUnicode_GET_SIZE(v) != 1) ! goto onError; buf[0] = PyUnicode_AS_UNICODE(v)[0]; + } ! else if (PyString_Check(v)) { ! if (PyString_GET_SIZE(v) != 1) ! goto onError; ! buf[0] = (Py_UNICODE)PyString_AS_STRING(v)[0]; ! } else { *************** *** 4274,4282 **** x = PyInt_AsLong(v); if (x == -1 && PyErr_Occurred()) ! return -1; buf[0] = (char) x; } buf[1] = '\0'; return 1; } --- 4285,4298 ---- x = PyInt_AsLong(v); if (x == -1 && PyErr_Occurred()) ! goto onError; buf[0] = (char) x; } buf[1] = '\0'; return 1; + + onError: + PyErr_SetString(PyExc_TypeError, + "%c requires int or char"); + return -1; } *************** *** 4710,4713 **** --- 4726,4731 ---- /* Init the implementation */ + unicode_freelist = NULL; + unicode_freelist_size = 0; unicode_empty = _PyUnicode_New(0); strcpy(unicode_default_encoding, "ascii"); *************** *** 4729,4732 **** --- 4747,4753 ---- PyObject_DEL(v); } + unicode_freelist = NULL; + unicode_freelist_size = 0; Py_XDECREF(unicode_empty); + unicode_empty = NULL; } From python-dev@python.org Fri Jun 9 07:01:50 2000 From: python-dev@python.org (Mark Hammond) Date: Thu, 8 Jun 2000 23:01:50 -0700 Subject: [Python-checkins] CVS: python/dist/src/PC winreg.c,1.2,1.3 Message-ID: <200006090601.XAA27098@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv26869 Modified Files: winreg.c Log Message: Cleanup a few docstrings. Index: winreg.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/winreg.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** winreg.c 2000/05/03 23:44:37 1.2 --- winreg.c 2000/06/09 06:01:47 1.3 *************** *** 89,93 **** "\n" "The return value is the handle of the opened key.\n" ! "If the function fails, an exception is raised."; static char CreateKey_doc[] = --- 89,93 ---- "\n" "The return value is the handle of the opened key.\n" ! "If the function fails, an EnvironmentError exception is raised."; static char CreateKey_doc[] = *************** *** 114,118 **** "\n" "If the method succeeds, the entire key, including all of its values,\n" ! "is removed. If the method fails, and exception is raised."; static char DeleteValue_doc[] = --- 114,118 ---- "\n" "If the method succeeds, the entire key, including all of its values,\n" ! "is removed. If the method fails, an EnvironmentError exception is raised."; static char DeleteValue_doc[] = *************** *** 129,134 **** "\n" "The function retrieves the name of one subkey each time it is called.\n" ! "It is typically called repeatedly until an exception is raised, indicating\n" ! "no more values are available.\n"; static char EnumValue_doc[] = --- 129,134 ---- "\n" "The function retrieves the name of one subkey each time it is called.\n" ! "It is typically called repeatedly until an EnvironmentError exception is\n" ! "raised, indicating no more values are available.\n"; static char EnumValue_doc[] = *************** *** 138,143 **** "\n" "The function retrieves the name of one subkey each time it is called.\n" ! "It is typically called repeatedly, until an exception is raised,\n" ! "indicating no more values.\n" "\n" "The result is a tuple of 3 items:\n" --- 138,143 ---- "\n" "The function retrieves the name of one subkey each time it is called.\n" ! "It is typically called repeatedly, until an EnvironmentError exception\n" ! "is raised, indicating no more values.\n" "\n" "The result is a tuple of 3 items:\n" *************** *** 161,165 **** static char LoadKey_doc[] = ! "RegLoadKey(key, sub_key, file_name) - Creates a subkey under the specified key.\n" "and stores registration information from a specified file into that subkey.\n" "\n" --- 161,165 ---- static char LoadKey_doc[] = ! "LoadKey(key, sub_key, file_name) - Creates a subkey under the specified key\n" "and stores registration information from a specified file into that subkey.\n" "\n" *************** *** 189,193 **** "\n" "The result is a new handle to the specified key\n" ! "If the function fails, an exception is raised.\n"; static char OpenKeyEx_doc[] = --- 189,193 ---- "\n" "The result is a new handle to the specified key\n" ! "If the function fails, an EnvironmentError exception is raised.\n"; static char OpenKeyEx_doc[] = *************** *** 209,213 **** "\n" "key is an already open key, or any one of the predefined HKEY_* constants.\n" ! "sub_key is a string that holds The name of the subkey with which the value\n" " is associated. If this parameter is None or empty, the function retrieves\n" " the value set by the SetValue() method for the key identified by key." --- 209,213 ---- "\n" "key is an already open key, or any one of the predefined HKEY_* constants.\n" ! "sub_key is a string that holds the name of the subkey with which the value\n" " is associated. If this parameter is None or empty, the function retrieves\n" " the value set by the SetValue() method for the key identified by key." *************** *** 269,274 **** " to environment variables (for example, %PATH%).\n" " REG_LINK -- A Unicode symbolic link.\n" ! " REG_MULTI_SZ -- An array of null-terminated strings, terminated by\n" ! " two null characters.\n" " REG_NONE -- No defined value type.\n" " REG_RESOURCE_LIST -- A device-driver resource list.\n" --- 269,275 ---- " to environment variables (for example, %PATH%).\n" " REG_LINK -- A Unicode symbolic link.\n" ! " REG_MULTI_SZ -- An sequence of null-terminated strings, terminated by\n" ! " two null characters. Note that Python handles this\n" ! " termination automatically.\n" " REG_NONE -- No defined value type.\n" " REG_RESOURCE_LIST -- A device-driver resource list.\n" *************** *** 291,295 **** "PyHKEY Object - A Python object, representing a win32 registry key.\n" "\n" ! "This object wraps a win32 HANDLE object, automatically closing it when\n" "the object is destroyed. To guarantee cleanup, you can call either\n" "the Close() method on the PyHKEY, or the CloseKey() method.\n" --- 292,296 ---- "PyHKEY Object - A Python object, representing a win32 registry key.\n" "\n" ! "This object wraps a Windows HKEY object, automatically closing it when\n" "the object is destroyed. To guarantee cleanup, you can call either\n" "the Close() method on the PyHKEY, or the CloseKey() method.\n" *************** *** 312,321 **** static char PyHKEY_Close_doc[] = ! "key.Close() - Closes the underlying Win32 handle.\n" "\n" "If the handle is already closed, no error is raised."; static char PyHKEY_Detach_doc[] = ! "int = key.Detach() - Detaches the Win32 handle from the handle object.\n" "\n" "The result is the value of the handle before it is detached. If the\n" --- 313,322 ---- static char PyHKEY_Close_doc[] = ! "key.Close() - Closes the underlying Windows handle.\n" "\n" "If the handle is already closed, no error is raised."; static char PyHKEY_Detach_doc[] = ! "int = key.Detach() - Detaches the Windows handle from the handle object.\n" "\n" "The result is the value of the handle before it is detached. If the\n" *************** *** 325,329 **** "but the handle is not closed. You would call this function when you\n" "need the underlying win32 handle to exist beyond the lifetime of the\n" ! "handle object."; --- 326,331 ---- "but the handle is not closed. You would call this function when you\n" "need the underlying win32 handle to exist beyond the lifetime of the\n" ! "handle object.\n" ! "On 64 bit windows, the result of this function is a long integer\n"; From python-dev@python.org Fri Jun 9 15:04:55 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 9 Jun 2000 07:04:55 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects stringobject.c,2.66,2.67 unicodeobject.c,2.23,2.24 Message-ID: <200006091404.HAA19419@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv19379 Modified Files: stringobject.c unicodeobject.c Log Message: Patch from Michael Hudson: improve unclear error message Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.66 retrieving revision 2.67 diff -C2 -r2.66 -r2.67 *** stringobject.c 2000/06/01 03:12:13 2.66 --- stringobject.c 2000/06/09 14:04:53 2.67 *************** *** 394,398 **** if (!PyString_Check(el) || PyString_Size(el) != 1) { PyErr_SetString(PyExc_TypeError, ! "string member test needs char left operand"); return -1; } --- 394,398 ---- if (!PyString_Check(el) || PyString_Size(el) != 1) { PyErr_SetString(PyExc_TypeError, ! "'in ' requires character as left operand"); return -1; } Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.23 retrieving revision 2.24 diff -C2 -r2.23 -r2.24 *** unicodeobject.c 2000/06/08 17:54:00 2.23 --- unicodeobject.c 2000/06/09 14:04:53 2.24 *************** *** 2997,3001 **** if (PyUnicode_GET_SIZE(v) != 1) { PyErr_SetString(PyExc_TypeError, ! "string member test needs char left operand"); goto onError; } --- 2997,3001 ---- if (PyUnicode_GET_SIZE(v) != 1) { PyErr_SetString(PyExc_TypeError, ! "'in ' requires character as left operand"); goto onError; } From python-dev@python.org Fri Jun 9 15:08:11 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 9 Jun 2000 07:08:11 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre_parse.py,1.3,1.4 Message-ID: <200006091408.HAA19679@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv19644 Modified Files: sre_parse.py Log Message: Patch from /F: this patch brings the CVS version of SRE in sync with the latest public snapshot."" Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** sre_parse.py 2000/04/10 17:10:48 1.3 --- sre_parse.py 2000/06/09 14:08:07 1.4 *************** *** 3,9 **** # $Id$ # ! # convert re-style regular expression to SRE template. the current ! # implementation is somewhat incomplete, and not very fast. should ! # definitely be rewritten before Python 1.6 goes beta. # # Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. --- 3,7 ---- # $Id$ # ! # convert re-style regular expression to sre pattern # # Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. *************** *** 17,27 **** # - # FIXME: comments marked with the FIXME tag are open issues. all such - # issues should be closed before the final beta. - import string, sys from sre_constants import * SPECIAL_CHARS = ".\\[{()*+?^$|" REPEAT_CHARS = "*+?{" --- 15,28 ---- # import string, sys + import _sre + from sre_constants import * + # FIXME: should be 65535, but the array module currently chokes on + # unsigned integers larger than 32767... + MAXREPEAT = int(2L**(_sre.getcodesize()*8-1))-1 + SPECIAL_CHARS = ".\\[{()*+?^$|" REPEAT_CHARS = "*+?{" *************** *** 33,36 **** --- 34,39 ---- HEXDIGITS = tuple("0123456789abcdefABCDEF") + WHITESPACE = tuple(string.whitespace) + ESCAPES = { "\\a": (LITERAL, chr(7)), *************** *** 56,63 **** } ! class Pattern: ! # FIXME: rename class, and store flags in here too! def __init__(self): ! self.flags = [] self.groups = 1 self.groupdict = {} --- 59,74 ---- } ! FLAGS = { ! "i": SRE_FLAG_IGNORECASE, ! "L": SRE_FLAG_LOCALE, ! "m": SRE_FLAG_MULTILINE, ! "s": SRE_FLAG_DOTALL, ! "t": SRE_FLAG_TEMPLATE, ! "x": SRE_FLAG_VERBOSE, ! } ! ! class State: def __init__(self): ! self.flags = 0 self.groups = 1 self.groupdict = {} *************** *** 68,74 **** self.groupdict[name] = gid return gid - def setflag(self, flag): - if flag in self.flags: - self.flags.append(flag) class SubPattern: --- 79,82 ---- *************** *** 79,83 **** data = [] self.data = data - self.flags = [] self.width = None def __repr__(self): --- 87,90 ---- *************** *** 122,127 **** elif op in (MIN_REPEAT, MAX_REPEAT): i, j = av[2].getwidth() ! lo = lo + i * av[0] ! hi = hi + j * av[1] elif op in (ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY): lo = lo + 1 --- 129,134 ---- elif op in (MIN_REPEAT, MAX_REPEAT): i, j = av[2].getwidth() ! lo = lo + long(i) * av[0] ! hi = hi + long(j) * av[1] elif op in (ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY): lo = lo + 1 *************** *** 131,175 **** self.width = int(min(lo, sys.maxint)), int(min(hi, sys.maxint)) return self.width - def set(self, flag): - if not flag in self.flags: - self.flags.append(flag) - def reset(self, flag): - if flag in self.flags: - self.flags.remove(flag) class Tokenizer: def __init__(self, string): ! self.string = list(string) self.next = self.__next() def __next(self): ! if not self.string: return None ! char = self.string[0] if char[0] == "\\": try: ! c = self.string[1] except IndexError: raise SyntaxError, "bogus escape" char = char + c ! try: ! if c == "x": ! # hexadecimal constant ! for i in xrange(2, sys.maxint): ! c = self.string[i] ! if str(c) not in HEXDIGITS: ! break ! char = char + c ! elif str(c) in DIGITS: ! # decimal (or octal) number ! for i in xrange(2, sys.maxint): ! c = self.string[i] ! # FIXME: if larger than current number of ! # groups, interpret as an octal number ! if str(c) not in DIGITS: ! break ! char = char + c ! except IndexError: ! pass # use what we've got this far ! del self.string[0:len(char)] return char def match(self, char): --- 138,158 ---- self.width = int(min(lo, sys.maxint)), int(min(hi, sys.maxint)) return self.width class Tokenizer: def __init__(self, string): ! self.index = 0 ! self.string = string self.next = self.__next() def __next(self): ! if self.index >= len(self.string): return None ! char = self.string[self.index] if char[0] == "\\": try: ! c = self.string[self.index + 1] except IndexError: raise SyntaxError, "bogus escape" char = char + c ! self.index = self.index + len(char) return char def match(self, char): *************** *** 188,221 **** return this ! def _fixescape(escape, character_class=0): ! # convert escape to (type, value) ! if character_class: ! # inside a character class, we'll look in the character ! # escapes dictionary first ! code = ESCAPES.get(escape) ! if code: ! return code ! code = CATEGORIES.get(escape) ! else: ! code = CATEGORIES.get(escape) ! if code: ! return code ! code = ESCAPES.get(escape) if code: return code - if not character_class: - try: - group = int(escape[1:]) - # FIXME: only valid if group <= current number of groups - return GROUP, group - except ValueError: - pass try: if escape[1:2] == "x": escape = escape[2:] ! return LITERAL, chr(int(escape[-2:], 16) & 0xff) elif str(escape[1:2]) in DIGITS: ! return LITERAL, chr(int(escape[1:], 8) & 0xff) ! elif len(escape) == 2: return LITERAL, escape[1] except ValueError: --- 171,242 ---- return this ! def _group(escape, state): ! # check if the escape string represents a valid group ! try: ! group = int(escape[1:]) ! if group and group < state.groups: ! return group ! except ValueError: ! pass ! return None # not a valid group ! ! def _class_escape(source, escape): ! # handle escape code inside character class ! code = ESCAPES.get(escape) ! if code: ! return code ! code = CATEGORIES.get(escape) ! if code: ! return code ! try: ! if escape[1:2] == "x": ! while source.next in HEXDIGITS: ! escape = escape + source.get() ! escape = escape[2:] ! # FIXME: support unicode characters! ! return LITERAL, chr(int(escape[-4:], 16) & 0xff) ! elif str(escape[1:2]) in OCTDIGITS: ! while source.next in OCTDIGITS: ! escape = escape + source.get() ! escape = escape[1:] ! # FIXME: support unicode characters! ! return LITERAL, chr(int(escape[-6:], 8) & 0xff) ! if len(escape) == 2: ! return LITERAL, escape[1] ! except ValueError: ! pass ! raise SyntaxError, "bogus escape: %s" % repr(escape) ! ! def _escape(source, escape, state): ! # handle escape code in expression ! code = CATEGORIES.get(escape) ! if code: ! return code ! code = ESCAPES.get(escape) if code: return code try: if escape[1:2] == "x": + while source.next in HEXDIGITS: + escape = escape + source.get() escape = escape[2:] ! # FIXME: support unicode characters! ! return LITERAL, chr(int(escape[-4:], 16) & 0xff) elif str(escape[1:2]) in DIGITS: ! while 1: ! group = _group(escape, state) ! if group: ! if (not source.next or ! not _group(escape + source.next, state)): ! return GROUP, group ! escape = escape + source.get() ! elif source.next in OCTDIGITS: ! escape = escape + source.get() ! else: ! break ! escape = escape[1:] ! # FIXME: support unicode characters! ! return LITERAL, chr(int(escape[-6:], 8) & 0xff) ! if len(escape) == 2: return LITERAL, escape[1] except ValueError: *************** *** 223,231 **** raise SyntaxError, "bogus escape: %s" % repr(escape) - def _branch(subpattern, items): # form a branch operator from a set of items (FIXME: move this # optimization to the compiler module!) # check if all items share a common prefix while 1: --- 244,255 ---- raise SyntaxError, "bogus escape: %s" % repr(escape) + def _branch(pattern, items): + # form a branch operator from a set of items (FIXME: move this # optimization to the compiler module!) + subpattern = SubPattern(pattern) + # check if all items share a common prefix while 1: *************** *** 258,272 **** set.append(item[0]) subpattern.append((IN, set)) ! return subpattern.append((BRANCH, (None, items))) ! def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. - - subpattern = SubPattern(pattern) ! this = None while 1: --- 282,295 ---- set.append(item[0]) subpattern.append((IN, set)) ! return subpattern subpattern.append((BRANCH, (None, items))) + return subpattern ! def _parse(source, state, flags=0): # parse regular expression pattern into an operator list. ! subpattern = SubPattern(state) while 1: *************** *** 278,281 **** --- 301,315 ---- break # end of pattern + if state.flags & SRE_FLAG_VERBOSE: + # skip whitespace and comments + if this in WHITESPACE: + continue + if this == "#": + while 1: + this = source.get() + if this in (None, "\n"): + break + continue + if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) *************** *** 295,299 **** break elif this and this[0] == "\\": ! code1 = _fixescape(this, 1) elif this: code1 = LITERAL, this --- 329,333 ---- break elif this and this[0] == "\\": ! code1 = _class_escape(source, this) elif this: code1 = LITERAL, this *************** *** 309,313 **** else: if this[0] == "\\": ! code2 = _fixescape(this, 1) else: code2 = LITERAL, this --- 343,347 ---- else: if this[0] == "\\": ! code2 = _class_escape(source, this) else: code2 = LITERAL, this *************** *** 322,326 **** set.append(code1) ! # FIXME: move set optimization to support function if len(set)==1 and set[0][0] is LITERAL: subpattern.append(set[0]) # optimization --- 356,360 ---- set.append(code1) ! # FIXME: move set optimization to compiler! if len(set)==1 and set[0][0] is LITERAL: subpattern.append(set[0]) # optimization *************** *** 336,344 **** min, max = 0, 1 elif this == "*": ! min, max = 0, sys.maxint elif this == "+": ! min, max = 1, sys.maxint elif this == "{": ! min, max = 0, sys.maxint lo = hi = "" while str(source.next) in DIGITS: --- 370,378 ---- min, max = 0, 1 elif this == "*": ! min, max = 0, MAXREPEAT elif this == "+": ! min, max = 1, MAXREPEAT elif this == "{": ! min, max = 0, MAXREPEAT lo = hi = "" while str(source.next) in DIGITS: *************** *** 359,376 **** raise SyntaxError, "not supported" # figure out which item to repeat - # FIXME: should back up to the right mark, right? if subpattern: ! index = len(subpattern)-1 ! while subpattern[index][0] is MARK: ! index = index - 1 ! item = subpattern[index:index+1] else: raise SyntaxError, "nothing to repeat" if source.match("?"): ! subpattern[index] = (MIN_REPEAT, (min, max, item)) else: ! subpattern[index] = (MAX_REPEAT, (min, max, item)) elif this == ".": subpattern.append((ANY, None)) elif this == "(": group = 1 --- 393,408 ---- raise SyntaxError, "not supported" # figure out which item to repeat if subpattern: ! item = subpattern[-1:] else: raise SyntaxError, "nothing to repeat" if source.match("?"): ! subpattern[-1] = (MIN_REPEAT, (min, max, item)) else: ! subpattern[-1] = (MAX_REPEAT, (min, max, item)) ! elif this == ".": subpattern.append((ANY, None)) + elif this == "(": group = 1 *************** *** 380,405 **** # options if source.match("P"): ! # named group: skip forward to end of name if source.match("<"): name = "" while 1: char = source.get() ! if char is None or char == ">": break name = name + char group = 1 elif source.match(":"): # non-capturing group group = 2 ! elif source.match_set("iI"): ! pattern.setflag("i") ! elif source.match_set("lL"): ! pattern.setflag("l") ! elif source.match_set("mM"): ! pattern.setflag("m") ! elif source.match_set("sS"): ! pattern.setflag("s") ! elif source.match_set("xX"): ! pattern.setflag("x") if group: # parse group contents --- 412,450 ---- # options if source.match("P"): ! # python extensions if source.match("<"): + # named group: skip forward to end of name name = "" while 1: char = source.get() ! if char is None: ! raise SyntaxError, "unterminated name" ! if char == ">": break + # FIXME: check for valid character name = name + char group = 1 + elif source.match("="): + # named backreference + raise SyntaxError, "not yet implemented" + + else: + char = source.get() + if char is None: + raise SyntaxError, "unexpected end of pattern" + raise SyntaxError, "unknown specifier: ?P%s" % char elif source.match(":"): # non-capturing group group = 2 ! elif source.match("#"): ! # comment ! while 1: ! char = source.get() ! if char is None or char == ")": ! break ! else: ! # flags ! while FLAGS.has_key(source.next): ! state.flags = state.flags | FLAGS[source.get()] if group: # parse group contents *************** *** 409,423 **** group = None else: ! group = pattern.getgroup(name) ! if group: ! subpattern.append((MARK, (group-1)*2)) while 1: ! p = _parse(source, pattern, flags) if source.match(")"): if b: b.append(p) ! _branch(subpattern, b) ! else: ! subpattern.append((SUBPATTERN, (group, p))) break elif source.match("|"): --- 454,465 ---- group = None else: ! group = state.getgroup(name) while 1: ! p = _parse(source, state, flags) if source.match(")"): if b: b.append(p) ! p = _branch(state, b) ! subpattern.append((SUBPATTERN, (group, p))) break elif source.match("|"): *************** *** 425,436 **** else: raise SyntaxError, "group not properly closed" - if group: - subpattern.append((MARK, (group-1)*2+1)) else: - # FIXME: should this really be a while loop? while 1: char = source.get() if char is None or char == ")": break elif this == "^": --- 467,476 ---- else: raise SyntaxError, "group not properly closed" else: while 1: char = source.get() if char is None or char == ")": break + # FIXME: skip characters? elif this == "^": *************** *** 441,445 **** elif this and this[0] == "\\": ! code =_fixescape(this) subpattern.append(code) --- 481,485 ---- elif this and this[0] == "\\": ! code = _escape(source, this, state) subpattern.append(code) *************** *** 449,459 **** return subpattern ! def parse(source, flags=()): ! s = Tokenizer(source) ! g = Pattern() b = [] while 1: ! p = _parse(s, g, flags) ! tail = s.get() if tail == "|": b.append(p) --- 489,500 ---- return subpattern ! def parse(pattern, flags=0): ! # parse 're' pattern into list of (opcode, argument) tuples ! source = Tokenizer(pattern) ! state = State() b = [] while 1: ! p = _parse(source, state, flags) ! tail = source.get() if tail == "|": b.append(p) *************** *** 463,471 **** if b: b.append(p) ! p = SubPattern(g) ! _branch(p, b) break else: raise SyntaxError, "bogus characters at end of regular expression" return p --- 504,531 ---- if b: b.append(p) ! p = _branch(state, b) break else: raise SyntaxError, "bogus characters at end of regular expression" + return p + + def parse_replacement(source, pattern): + # parse 're' replacement string into list of literals and + # group references + s = Tokenizer(source) + p = [] + a = p.append + while 1: + this = s.get() + if this is None: + break # end of replacement string + if this and this[0] == "\\": + try: + a(LITERAL, ESCAPES[this]) + except KeyError: + for char in this: + a(LITERAL, char) + else: + a(LITERAL, this) return p From python-dev@python.org Fri Jun 9 17:20:42 2000 From: python-dev@python.org (Jeremy Hylton) Date: Fri, 9 Jun 2000 09:20:42 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects object.c,2.70,2.71 Message-ID: <200006091620.JAA12616@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv12563 Modified Files: object.c Log Message: the PyDict_SetItem does not borrow a reference, so we need to decref reported by Mark Hammon Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.70 retrieving revision 2.71 diff -C2 -r2.70 -r2.71 *** object.c 2000/05/03 23:44:35 2.70 --- object.c 2000/06/09 16:20:39 2.71 *************** *** 352,355 **** --- 352,356 ---- return NULL; } + Py_DECREF(inprogress); } return inprogress; From python-dev@python.org Sat Jun 10 02:41:51 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 9 Jun 2000 18:41:51 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib urllib.py,1.94,1.95 Message-ID: <200006100141.SAA09634@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv9465 Modified Files: urllib.py Log Message: Comment out an apparent debug print Index: urllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib.py,v retrieving revision 1.94 retrieving revision 1.95 diff -C2 -r1.94 -r1.95 *** urllib.py 2000/05/24 13:21:46 1.94 --- urllib.py 2000/06/10 01:41:48 1.95 *************** *** 314,318 **** if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) ! print "proxy via https:", host, selector if not host: raise IOError, ('https error', 'no host given') if user_passwd: --- 314,318 ---- if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) ! #print "proxy via https:", host, selector if not host: raise IOError, ('https error', 'no host given') if user_passwd: From python-dev@python.org Sat Jun 10 05:22:59 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 9 Jun 2000 21:22:59 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_linuxaudiodev,NONE,1.1 Message-ID: <200006100422.VAA06594@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv6583/output Added Files: test_linuxaudiodev Log Message: Added test for linnuxaudiodev module; directly adapted from sunaudiodev test. Someone with more Linux audio knowledge should at least take a brief look at it. --- NEW FILE --- test_linuxaudiodev From python-dev@python.org Sat Jun 10 05:22:59 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 9 Jun 2000 21:22:59 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_linuxaudiodev.py,NONE,1.1 Message-ID: <200006100422.VAA06591@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv6583 Added Files: test_linuxaudiodev.py Log Message: Added test for linnuxaudiodev module; directly adapted from sunaudiodev test. Someone with more Linux audio knowledge should at least take a brief look at it. --- NEW FILE --- from test_support import verbose, findfile, TestFailed import linuxaudiodev import os def play_sound_file(path): fp = open(path, 'r') data = fp.read() fp.close() try: a = linuxaudiodev.open('w') except linuxaudiodev.error, msg: raise TestFailed, msg else: a.write(data) a.close() def test(): play_sound_file(findfile('audiotest.au')) test() From python-dev@python.org Sat Jun 10 10:32:54 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Sat, 10 Jun 2000 02:32:54 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.24,2.25 Message-ID: <200006100932.CAA17757@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv17744/Objects Modified Files: unicodeobject.c Log Message: Marc-Andre Lemburg : Fixed a typo and removed a debug printf(). Thanks to Finn Bock for finding these. Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.24 retrieving revision 2.25 diff -C2 -r2.24 -r2.25 *** unicodeobject.c 2000/06/09 14:04:53 2.24 --- unicodeobject.c 2000/06/10 09:32:51 2.25 *************** *** 733,737 **** bytes which the Python implementation currently does not support. */ - printf("code range problem: U+%04x\n", ch); if (utf8_encoding_error(&s, &p, errors, "unsupported code range")) --- 733,736 ---- *************** *** 1735,1739 **** if (value < 0 || value > 65535) { PyErr_SetString(PyExc_TypeError, ! "character mapping must be in range(65336)"); Py_DECREF(x); goto onError; --- 1734,1738 ---- if (value < 0 || value > 65535) { PyErr_SetString(PyExc_TypeError, ! "character mapping must be in range(65536)"); Py_DECREF(x); goto onError; From python-dev@python.org Sun Jun 11 00:02:59 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 10 Jun 2000 16:02:59 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/curses - New directory Message-ID: <200006102302.QAA17598@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/curses In directory slayer.i.sourceforge.net:/tmp/cvs-serv17416/curses Log Message: Directory /cvsroot/python/python/dist/src/Lib/curses added to the repository ***** Bogus filespec: - ***** Bogus filespec: New ***** Bogus filespec: directory From python-dev@python.org Sun Jun 11 00:06:55 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 10 Jun 2000 16:06:55 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/curses __init__.py,NONE,1.1 wrapper.py,NONE,1.1 Message-ID: <200006102306.QAA18088@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/curses In directory slayer.i.sourceforge.net:/tmp/cvs-serv18069 Added Files: __init__.py wrapper.py Log Message: Add contents of curses package ***** Error reading new file(2, 'No such file or directory') --- NEW FILE --- """curses.wrapper Contains one function, wrapper(), which runs another function which should be the rest of your curses-based application. If the application raises an exception, wrapper() will restore the terminal to a sane state so you can read the resulting traceback. """ import sys, curses def wrapper(func, *rest): """Wrapper function that initializes curses and calls another function, restoring normal keyboard/screen behavior on error. The callable object 'func' is then passed the main window 'stdscr' as its first argument, followed by any other arguments passed to wrapper(). """ res = None try: # Initialize curses stdscr=curses.initscr() # Turn off echoing of keys, and enter cbreak mode, # where no buffering is performed on keyboard input curses.noecho() ; curses.cbreak() # In keypad mode, escape sequences for special keys # (like the cursor keys) will be interpreted and # a special value like curses.KEY_LEFT will be returned stdscr.keypad(1) res = apply(func, (stdscr,) + rest) except: # In the event of an error, restore the terminal # to a sane state. stdscr.keypad(0) curses.echo() ; curses.nocbreak() curses.endwin() # Pass the exception upwards (exc_type, exc_value, exc_traceback) = sys.exc_info() raise exc_type, exc_value, exc_traceback else: # Set everything back to normal stdscr.keypad(0) curses.echo() ; curses.nocbreak() curses.endwin() # Terminate curses return res From python-dev@python.org Sun Jun 11 00:08:24 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 10 Jun 2000 16:08:24 -0700 Subject: [Python-checkins] CVS: python/dist/src Makefile.in,1.86,1.87 Message-ID: <200006102308.QAA18139@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv18130 Modified Files: Makefile.in Log Message: Install the contents of the Lib/curses directory Index: Makefile.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.in,v retrieving revision 1.86 retrieving revision 1.87 diff -C2 -r1.86 -r1.87 *** Makefile.in 2000/04/24 14:57:21 1.86 --- Makefile.in 2000/06/10 23:08:21 1.87 *************** *** 291,295 **** MACHDEPS= $(PLATDIR) LIBSUBDIRS= lib-old lib-tk site-packages test test/output encodings \ ! distutils distutils/command $(MACHDEPS) libinstall: python $(srcdir)/Lib/$(PLATDIR) @for i in $(SCRIPTDIR) $(LIBDEST); \ --- 291,295 ---- MACHDEPS= $(PLATDIR) LIBSUBDIRS= lib-old lib-tk site-packages test test/output encodings \ ! distutils distutils/command curses $(MACHDEPS) libinstall: python $(srcdir)/Lib/$(PLATDIR) @for i in $(SCRIPTDIR) $(LIBDEST); \ From python-dev@python.org Sun Jun 11 00:12:34 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 10 Jun 2000 16:12:34 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules cursesmodule.c,2.22,2.23 Setup.in,1.101,1.102 Message-ID: <200006102312.QAA18393@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv18349 Modified Files: cursesmodule.c Setup.in Log Message: Renamed the C extension for ncurses support from 'curses' to '_curses'. (The SourceForge admins have been asked to rename the ,v file.) Index: cursesmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cursesmodule.c,v retrieving revision 2.22 retrieving revision 2.23 diff -C2 -r2.22 -r2.23 *** cursesmodule.c 2000/05/23 16:24:54 2.22 --- cursesmodule.c 2000/06/10 23:12:32 2.23 *************** *** 2164,2173 **** void ! initcurses() { PyObject *m, *d, *v; /* Create the module and add the functions */ ! m = Py_InitModule("curses", PyCurses_methods); /* Add some symbolic constants to the module */ --- 2164,2173 ---- void ! init_curses() { PyObject *m, *d, *v; /* Create the module and add the functions */ ! m = Py_InitModule("_curses", PyCurses_methods); /* Add some symbolic constants to the module */ *************** *** 2176,2180 **** /* For exception curses.error */ ! PyCursesError = PyString_FromString("curses.error"); PyDict_SetItemString(d, "error", PyCursesError); --- 2176,2180 ---- /* For exception curses.error */ ! PyCursesError = PyString_FromString("_curses.error"); PyDict_SetItemString(d, "error", PyCursesError); *************** *** 2252,2255 **** /* Check for errors */ if (PyErr_Occurred()) ! Py_FatalError("can't initialize module curses"); } --- 2252,2255 ---- /* Check for errors */ if (PyErr_Occurred()) ! Py_FatalError("can't initialize module _curses"); } Index: Setup.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Setup.in,v retrieving revision 1.101 retrieving revision 1.102 diff -C2 -r1.101 -r1.102 *** Setup.in 2000/06/07 09:12:54 1.101 --- Setup.in 2000/06/10 23:12:32 1.102 *************** *** 315,324 **** ! # Lance's curses module. This requires the System V version of ! # curses, sometimes known as ncurses (e.g. on Linux, link with ! # -lncurses instead of -lcurses; on SunOS 4.1.3, insert -I/usr/5include # -L/usr/5lib before -lcurses). ! #curses cursesmodule.c -lcurses -ltermcap --- 315,324 ---- ! # Curses support, requring the System V version of curses, often ! # provided by the ncurses library. e.g. on Linux, link with -lncurses ! # instead of -lcurses; on SunOS 4.1.3, insert -I/usr/5include # -L/usr/5lib before -lcurses). ! #_curses _cursesmodule.c -lcurses -ltermcap From python-dev@python.org Sun Jun 11 00:39:07 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 10 Jun 2000 16:39:07 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/curses wrapper.py,1.1,1.2 Message-ID: <200006102339.QAA19661@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/curses In directory slayer.i.sourceforge.net:/tmp/cvs-serv19653 Modified Files: wrapper.py Log Message: Applied simplifications suggested by Greg Stein. Index: wrapper.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/curses/wrapper.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** wrapper.py 2000/06/10 23:06:53 1.1 --- wrapper.py 2000/06/10 23:39:05 1.2 *************** *** 18,22 **** """ - res = None try: # Initialize curses --- 18,21 ---- *************** *** 31,50 **** stdscr.keypad(1) ! res = apply(func, (stdscr,) + rest) ! except: ! # In the event of an error, restore the terminal ! # to a sane state. stdscr.keypad(0) curses.echo() ; curses.nocbreak() curses.endwin() - # Pass the exception upwards - (exc_type, exc_value, exc_traceback) = sys.exc_info() - raise exc_type, exc_value, exc_traceback - else: - # Set everything back to normal - stdscr.keypad(0) - curses.echo() ; curses.nocbreak() - curses.endwin() # Terminate curses - - return res --- 30,39 ---- stdscr.keypad(1) ! return apply(func, (stdscr,) + rest) ! ! finally: ! # Restore the terminal to a sane state on the way out. stdscr.keypad(0) curses.echo() ; curses.nocbreak() curses.endwin() From python-dev@python.org Sun Jun 11 03:42:10 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 10 Jun 2000 19:42:10 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libpyexpat.tex,NONE,1.1 Message-ID: <200006110242.TAA18090@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv18075 Added Files: libpyexpat.tex Log Message: Documentation for the pyexpat module. --- NEW FILE --- \section{\module{pyexpat} --- Fast XML parsing using the Expat C library} \declaremodule{builtin}{pyexpat} \modulesynopsis{An interface to the Expat XML parser.} \moduleauthor{Paul Prescod}{paul@prescod.net} \sectionauthor{A.M. Kuchling}{amk1@bigfoot.com} The \module{pyexpat} module is a Python interface to the Expat non-validating XML parser. The module provides a single extension type, \class{xmlparser}, that represents the current state of an XML parser. After an \class{xmlparser} object has been created, various attributes of the object can be set to handler functions. When an XML document is then fed to the parser, the handler functions are called for the character data and markup in the XML document. The \module{pyexpat} module contains two functions: \begin{funcdesc}{ErrorString}{errno} Returns an explanatory string for a given error number \var{errno}. \end{funcdesc} \begin{funcdesc}{ParserCreate}{\optional{encoding, namespace_separator}} Creates and returns a new \class{xmlparser} object. \var{encoding}, if specified, must be a string naming the encoding used by the XML data. Expat doesn't support as many encodings as Python does, and its repertoire of encodings can't be extended; it supports UTF-8, UTF-16, ISO-8859-1 (Latin1), and ASCII. % XXX pyexpat.c should only allow a 1-char string for this parameter Expat can optionally do XML namespace processing for you, enabled by providing a value for \var{namespace_separator}. When namespace processing is enabled, element type names and attribute names that belong to a namespace will be expanded. The element name passed to the element handlers \function{StartElementHandler()} and \function{EndElementHandler()} will be the concatenation of the namespace URI, the namespace separator character, and the local part of the name. If the namespace separator is a zero byte (\code{chr(0)}) then the namespace URI and the local part will be concatenated without any separator. For example, if \var{namespace_separator} is set to \samp{ }, and the following document is parsed: \begin{verbatim} \end{verbatim} \function{StartElementHandler()} will receive the following strings for each element: \begin{verbatim} http://default-namespace.org/ root http://www.python.org/ns/ elem1 elem2 \end{verbatim} \end{funcdesc} \class{xmlparser} objects have the following methods: \begin{methoddesc}{Parse}{data \optional{, isfinal}} Parses the contents of the string \var{data}, calling the appropriate handler functions to process the parsed data. \var{isfinal} must be true on the final call to this method. \var{data} can be the empty string at any time. \end{methoddesc} \begin{methoddesc}{ParseFile}{file} Parse XML data reading from the object \var{file}. \var{file} only needs to provide the \method{read(\var{nbytes})} method, returning the empty string when there's no more data. \end{methoddesc} \begin{methoddesc}{SetBase}{base} Sets the base to be used for resolving relative URIs in system identifiers in declarations. Resolving relative identifiers is left to the application: this value will be passed through as the base argument to the \function{ExternalEntityRefHandler}, \function{NotationDeclHandler}, and \function{UnparsedEntityDeclHandler} functions. \end{methoddesc} \begin{methoddesc}{GetBase}{} Returns a string containing the base set by a previous call to \method{SetBase()}, or \code{None} if \method{SetBase()} hasn't been called. \end{methoddesc} \class{xmlparser} objects have the following attributes, containing values relating to the most recent error encountered by an \class{xmlparser} object. These attributes will only have correct values once a call to \method{Parse()} or \method{ParseFile()} has raised a \exception{pyexpat.error} exception. \begin{datadesc}{ErrorByteIndex} Byte index at which an error occurred. \end{datadesc} \begin{datadesc}{ErrorCode} Numeric code specifying the problem. This value can be passed to the \function{ErrorString()} function, or compared to one of the constants defined in the \module{pyexpat.errors} submodule. \end{datadesc} \begin{datadesc}{ErrorColumnNumber} Column number at which an error occurred. \end{datadesc} \begin{datadesc}{ErrorLineNumber} Line number at which an error occurred. \end{datadesc} Here is the list of handlers that can be set. To set a handler on an \class{xmlparser} object \var{o}, use \code{\var{o}.\var{handlername} = \var{func}}. \var{handlername} must be taken from the following list, and \var{func} must be a callable object accepting the correct number of arguments. The arguments are all strings, unless otherwise stated. \begin{methoddesc}{StartElementHandler}{name, attributes} Called for the start of every element. \var{name} is a string containing the element name, and \var{attributes} is a dictionary mapping attribute names to their values. \end{methoddesc} \begin{methoddesc}{EndElementHandler}{name} Called for the end of every element. \end{methoddesc} \begin{methoddesc}{ProcessingInstructionHandler}{target, data} Called for every processing instruction. \end{methoddesc} \begin{methoddesc}{CharacterDataHandler}{\var{data}} Called for character data. \end{methoddesc} \begin{methoddesc}{UnparsedEntityDeclHandler}{entityName, base, systemId, publicId, notationName} Called for unparsed (NDATA) entity declarations. \end{methoddesc} \begin{methoddesc}{NotationDeclHandler}{notationName, base, systemId, publicId} Called for notation declarations. \end{methoddesc} \begin{methoddesc}{StartNamespaceDeclHandler}{prefix, uri} Called when an element contains a namespace declaration. \end{methoddesc} \begin{methoddesc}{EndNamespaceDeclHandler}{prefix} Called when the closing tag is reached for an element that contained a namespace declaration. \end{methoddesc} \begin{methoddesc}{CommentHandler}{data} Called for comments. \end{methoddesc} \begin{methoddesc}{StartCdataSectionHandler}{} Called at the start of a CDATA section. \end{methoddesc} \begin{methoddesc}{EndCdataSectionHandler}{} Called at the end of a CDATA section. \end{methoddesc} \begin{methoddesc}{DefaultHandler}{data} Called for any characters in the XML document for which no applicable handler has been specified. This means characters that are part of a construct which could be reported, but for which no handler has been supplied. \end{methoddesc} \begin{methoddesc}{DefaultHandlerExpand}{data} This is the same as the \function{DefaultHandler}, but doesn't inhibit expansion of internal entities. The entity reference will not be passed to the default handler. \end{methoddesc} \begin{methoddesc}{NotStandaloneHandler}{} Called if the XML document hasn't been declared as being a standalone document. \end{methoddesc} \begin{methoddesc}{ExternalEntityRefHandler}{context, base, systemId, publicId} Called for references to external entities. \end{methoddesc} \subsection{\module{pyexpat.errors} -- Error constants} The following table lists the error constants in the \module{pyexpat.errors} submodule, available once the \module{pyexpat} module has been imported. \begin{tableii}{l|l}{code}{Constants}{}{} \lineii {XML_ERROR_ASYNC_ENTITY} {XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF} \lineii {XML_ERROR_BAD_CHAR_REF} {XML_ERROR_BINARY_ENTITY_REF} \lineii {XML_ERROR_DUPLICATE_ATTRIBUTE} {XML_ERROR_INCORRECT_ENCODING} \lineii {XML_ERROR_INVALID_TOKEN} {XML_ERROR_JUNK_AFTER_DOC_ELEMENT} \lineii {XML_ERROR_MISPLACED_XML_PI} {XML_ERROR_NO_ELEMENTS} \lineii {XML_ERROR_NO_MEMORY} {XML_ERROR_PARAM_ENTITY_REF} \lineii {XML_ERROR_PARTIAL_CHAR} {XML_ERROR_RECURSIVE_ENTITY_REF} \lineii {XML_ERROR_SYNTAX} {XML_ERROR_TAG_MISMATCH} \lineii {XML_ERROR_UNCLOSED_TOKEN} {XML_ERROR_UNDEFINED_ENTITY} \lineii {XML_ERROR_UNKNOWN_ENCODING}{} \end{tableii} \subsection{Example} The following program defines 3 handlers that just print out their arguments. \begin{verbatim} import pyexpat # 3 handler functions def start_element(name, attrs): print 'Start element:', name, attrs def end_element(name): print 'End element:', name def char_data(data): print 'Character data:', repr(data) p=pyexpat.ParserCreate() p.StartElementHandler = start_element p.EndElementHandler = end_element p.CharacterDataHandler= char_data p.Parse(""" Text goes here More text """) \end{verbatim} The output from this program is: \begin{verbatim} Start element: parent {'id': 'top'} Start element: child1 {'name': 'paul'} Character data: 'Text goes here' End element: child1 Character data: '\012' Start element: child2 {'name': 'fred'} Character data: 'More text' End element: child2 Character data: '\012' End element: parent \end{verbatim} From python-dev@python.org Tue Jun 13 13:04:07 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Tue, 13 Jun 2000 05:04:07 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/encodings __init__.py,1.3,1.4 Message-ID: <200006131204.FAA10206@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/encodings In directory slayer.i.sourceforge.net:/tmp/cvs-serv10145/Lib/encodings Modified Files: __init__.py Log Message: Marc-Andre Lemburg : Removed import of string module -- use string methods directly. Thanks to Finn Bock. Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/__init__.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** __init__.py 2000/04/05 20:11:18 1.3 --- __init__.py 2000/06/13 12:04:05 1.4 *************** *** 28,32 **** """#" ! import string,codecs,aliases _cache = {} --- 28,32 ---- """#" ! import codecs,aliases _cache = {} *************** *** 41,45 **** # Import the module ! modname = string.replace(encoding, '-', '_') modname = aliases.aliases.get(modname,modname) try: --- 41,45 ---- # Import the module ! modname = encoding.replace('-', '_') modname = aliases.aliases.get(modname,modname) try: From python-dev@python.org Tue Jun 13 13:05:39 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Tue, 13 Jun 2000 05:05:39 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_unicode.py,1.12,1.13 Message-ID: <200006131205.FAA11587@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv11480/Lib/test Modified Files: test_unicode.py Log Message: Marc-Andre Lemburg : Fixed some tests to not cause the script to fail, but rather output a warning (which then is caught by regrtest.py as wrong output). This is needed to make test_unicode.py run through on JPython. Thanks to Finn Bock. Index: test_unicode.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** test_unicode.py 2000/06/08 17:50:55 1.12 --- test_unicode.py 2000/06/13 12:05:36 1.13 *************** *** 252,258 **** assert u"%c" % (34,) == u'"' assert u"%c" % (36,) == u'$' ! assert u"%r, %r" % (u"abc", "abc") == u"u'abc', 'abc'" assert u"%(x)s, %(y)s" % {'x':u"abc", 'y':"def"} == u'abc, def' ! assert u"%(x)s, %(ä)s" % {'x':u"abc", u'ä'.encode('utf-8'):"def"} == u'abc, def' # formatting jobs delegated from the string implementation: assert '...%(foo)s...' % {'foo':u"abc"} == u'...abc...' --- 252,267 ---- assert u"%c" % (34,) == u'"' assert u"%c" % (36,) == u'$' ! value = u"%r, %r" % (u"abc", "abc") ! if value != u"u'abc', 'abc'": ! print '*** formatting failed for "%s"' % 'u"%r, %r" % (u"abc", "abc")' ! assert u"%(x)s, %(y)s" % {'x':u"abc", 'y':"def"} == u'abc, def' ! try: ! value = u"%(x)s, %(ä)s" % {'x':u"abc", u'ä'.encode('utf-8'):"def"} ! except KeyError: ! print '*** formatting failed for "%s"' % "u'abc, def'" ! else: ! assert value == u'abc, def' ! # formatting jobs delegated from the string implementation: assert '...%(foo)s...' % {'foo':u"abc"} == u'...abc...' *************** *** 269,273 **** pass else: ! raise AssertionError, "'...%s...äöü...' % u'abc' failed to raise an exception" print 'done.' --- 278,282 ---- pass else: ! print "*** formatting failed ...%s...äöü...' % u'abc' failed to raise an exception" print 'done.' From python-dev@python.org Tue Jun 13 19:49:56 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 13 Jun 2000 11:49:56 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib zipfile.py,1.1,1.2 Message-ID: <200006131849.LAA16627@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv16620 Modified Files: zipfile.py Log Message: James C. Ahlstron : Thanks to Hubert Hoegl for finding this bug. Index: zipfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/zipfile.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** zipfile.py 2000/03/31 17:30:02 1.1 --- zipfile.py 2000/06/13 18:49:53 1.2 *************** *** 167,171 **** # Convert date/time code to (year, month, day, hour, min, sec) x.date_time = ( (d>>9)+1980, (d>>5)&0xF, d&0x1F, ! t>>11, (t>>5)&0x3F, t&0x1F * 2 ) self.filelist.append(x) self.NameToInfo[x.filename] = x --- 167,171 ---- # Convert date/time code to (year, month, day, hour, min, sec) x.date_time = ( (d>>9)+1980, (d>>5)&0xF, d&0x1F, ! t>>11, (t>>5)&0x3F, (t&0x1F) * 2 ) self.filelist.append(x) self.NameToInfo[x.filename] = x From python-dev@python.org Tue Jun 13 21:50:53 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 13 Jun 2000 13:50:53 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libunicodedata.tex,NONE,1.1 Message-ID: <200006132050.NAA04900@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv4892/lib Added Files: libunicodedata.tex Log Message: Marc-Andre Lemburg : Documentation for the unicodedata module (massaged by Fred for minor consistency issues). --- NEW FILE --- \section{\module{unicodedata} --- Unicode Database} \declaremodule{standard}{unicodedata} \modulesynopsis{Access the Unicode Database.} \moduleauthor{Marc-Andre Lemburg}{mal@lemburg.com} \sectionauthor{Marc-Andre Lemburg}{mal@lemburg.com} \index{Unicode} \index{character} \indexii{Unicode}{database} This module provides access to the Unicode Character Database which defines character properties for all Unicode characters. The data in this database is based on the \file{UnicodeData.txt} file version 3.0.0 which is publically available from \url{ftp://ftp.unicode.org/}. The module uses the same names and symbols as defined by the UnicodeData File Format 3.0.0 (see \url{ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.html}). It defines the following functions: \begin{funcdesc}{decimal}{unichr\optional{, default}} Returns the decimal value assigned to the Unicode character \var{unichr} as integer. If no such value is defined, \var{default} is returned, or, if not given, \exception{ValueError} is raised. \end{funcdesc} \begin{funcdesc}{digit}{unichr\optional{, default}} Returns the digit value assigned to the Unicode character \var{unichr} as integer. If no such value is defined, \var{default} is returned, or, if not given, \exception{ValueError} is raised. \end{funcdesc} \begin{funcdesc}{numeric}{unichr\optional{, default}} Returns the numeric value assigned to the Unicode character \var{unichr} as float. If no such value is defined, \var{default} is returned, or, if not given, \exception{ValueError} is raised. \end{funcdesc} \begin{funcdesc}{category}{unichr} Returns the general category assigned to the Unicode character \var{unichr} as string. \end{funcdesc} \begin{funcdesc}{bidirectional}{unichr} Returns the bidirectional category assigned to the Unicode character \var{unichr} as string. If no such value is defined, an empty string is returned. \end{funcdesc} \begin{funcdesc}{combining}{unichr} Returns the canonical combining class assigned to the Unicode character \var{unichr} as integer. Returns \code{0} if no combining class is defined. \end{funcdesc} \begin{funcdesc}{mirrored}{unichr} Returns the mirrored property of assigned to the Unicode character \var{unichr} as integer. Returns \code{1} if the character has been identified as a ``mirrored'' character in bidirectional text, \code{0} otherwise. \end{funcdesc} \begin{funcdesc}{decomposition}{unichr} Returns the character decomposition mapping assigned to the Unicode character \var{unichr} as string. An empty string is returned in case no such mapping is defined. \end{funcdesc} From python-dev@python.org Tue Jun 13 21:51:31 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 13 Jun 2000 13:51:31 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib lib.tex,1.151,1.152 Message-ID: <200006132051.NAA04961@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv4948/lib Modified Files: lib.tex Log Message: Hook in the documentation for the unicodedata module. Index: lib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/lib.tex,v retrieving revision 1.151 retrieving revision 1.152 diff -C2 -r1.151 -r1.152 *** lib.tex 2000/06/07 04:07:48 1.151 --- lib.tex 2000/06/13 20:51:29 1.152 *************** *** 115,118 **** --- 115,119 ---- \input{libstringio} \input{libcodecs} + \input{libunicodedata} %\input{libsoundex} From python-dev@python.org Tue Jun 13 21:51:31 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 13 Jun 2000 13:51:31 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc Makefile.deps,1.31,1.32 Message-ID: <200006132051.NAA04957@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc In directory slayer.i.sourceforge.net:/tmp/cvs-serv4948 Modified Files: Makefile.deps Log Message: Hook in the documentation for the unicodedata module. Index: Makefile.deps =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile.deps,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -r1.31 -r1.32 *** Makefile.deps 2000/06/07 04:07:48 1.31 --- Makefile.deps 2000/06/13 20:51:29 1.32 *************** *** 62,65 **** --- 62,66 ---- ../lib/libstring.tex \ ../lib/libcodecs.tex \ + ../lib/libunicodedata.tex \ ../lib/libregex.tex \ ../lib/libregsub.tex \ From python-dev@python.org Wed Jun 14 10:17:27 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 14 Jun 2000 02:17:27 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_unicode.py,1.13,1.14 Message-ID: <200006140917.CAA03479@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv3463/Lib/test Modified Files: test_unicode.py Log Message: Marc-Andre Lemburg : Removed a test which can fail when the default locale setting uses a Latin-1 encoding. The test case is not applicable anymore. Index: test_unicode.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** test_unicode.py 2000/06/13 12:05:36 1.13 --- test_unicode.py 2000/06/14 09:17:25 1.14 *************** *** 273,282 **** assert '...%s...%s...%s...%s...' % (1,2,3,u"abc") == u'...1...2...3...abc...' assert '...%s...' % u"abc" == u'...abc...' - try: - '...%s...äöü...' % u"abc" - except ValueError: - pass - else: - print "*** formatting failed ...%s...äöü...' % u'abc' failed to raise an exception" print 'done.' --- 273,276 ---- From python-dev@python.org Wed Jun 14 10:18:11 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 14 Jun 2000 02:18:11 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects stringobject.c,2.67,2.68 Message-ID: <200006140918.CAA03749@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv3664/Objects Modified Files: stringobject.c Log Message: Marc-Andre Lemburg : Added code so that .isXXX() testing returns 0 for emtpy strings. Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.67 retrieving revision 2.68 diff -C2 -r2.67 -r2.68 *** stringobject.c 2000/06/09 14:04:53 2.67 --- stringobject.c 2000/06/14 09:18:09 2.68 *************** *** 1928,1931 **** --- 1928,1935 ---- return PyInt_FromLong(1); + /* Special case for empty strings */ + if (PyString_GET_SIZE(self) == 0) + return PyInt_FromLong(0); + e = p + PyString_GET_SIZE(self); for (; p < e; p++) { *************** *** 1957,1960 **** --- 1961,1968 ---- return PyInt_FromLong(1); + /* Special case for empty strings */ + if (PyString_GET_SIZE(self) == 0) + return PyInt_FromLong(0); + e = p + PyString_GET_SIZE(self); for (; p < e; p++) { *************** *** 1986,1989 **** --- 1994,2001 ---- return PyInt_FromLong(islower(*p) != 0); + /* Special case for empty strings */ + if (PyString_GET_SIZE(self) == 0) + return PyInt_FromLong(0); + e = p + PyString_GET_SIZE(self); cased = 0; *************** *** 2018,2021 **** --- 2030,2037 ---- return PyInt_FromLong(isupper(*p) != 0); + /* Special case for empty strings */ + if (PyString_GET_SIZE(self) == 0) + return PyInt_FromLong(0); + e = p + PyString_GET_SIZE(self); cased = 0; *************** *** 2050,2053 **** --- 2066,2073 ---- if (PyString_GET_SIZE(self) == 1) return PyInt_FromLong(isupper(*p) != 0); + + /* Special case for empty strings */ + if (PyString_GET_SIZE(self) == 0) + return PyInt_FromLong(0); e = p + PyString_GET_SIZE(self); From python-dev@python.org Wed Jun 14 10:18:35 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 14 Jun 2000 02:18:35 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.25,2.26 Message-ID: <200006140918.CAA04049@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv3975/Objects Modified Files: unicodeobject.c Log Message: Marc-Andre Lemburg : Added code so that .isXXX() testing returns 0 for emtpy strings. Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.25 retrieving revision 2.26 diff -C2 -r2.25 -r2.26 *** unicodeobject.c 2000/06/10 09:32:51 2.25 --- unicodeobject.c 2000/06/14 09:18:32 2.26 *************** *** 3307,3310 **** --- 3307,3314 ---- return PyInt_FromLong(Py_UNICODE_ISLOWER(*p) != 0); + /* Special case for empty strings */ + if (PyString_GET_SIZE(self) == 0) + return PyInt_FromLong(0); + e = p + PyUnicode_GET_SIZE(self); cased = 0; *************** *** 3340,3343 **** --- 3344,3351 ---- return PyInt_FromLong(Py_UNICODE_ISUPPER(*p) != 0); + /* Special case for empty strings */ + if (PyString_GET_SIZE(self) == 0) + return PyInt_FromLong(0); + e = p + PyUnicode_GET_SIZE(self); cased = 0; *************** *** 3375,3378 **** --- 3383,3390 ---- (Py_UNICODE_ISUPPER(*p) != 0)); + /* Special case for empty strings */ + if (PyString_GET_SIZE(self) == 0) + return PyInt_FromLong(0); + e = p + PyUnicode_GET_SIZE(self); cased = 0; *************** *** 3419,3422 **** --- 3431,3438 ---- return PyInt_FromLong(1); + /* Special case for empty strings */ + if (PyString_GET_SIZE(self) == 0) + return PyInt_FromLong(0); + e = p + PyUnicode_GET_SIZE(self); for (; p < e; p++) { *************** *** 3447,3450 **** --- 3463,3470 ---- return PyInt_FromLong(1); + /* Special case for empty strings */ + if (PyString_GET_SIZE(self) == 0) + return PyInt_FromLong(0); + e = p + PyUnicode_GET_SIZE(self); for (; p < e; p++) { *************** *** 3475,3478 **** --- 3495,3502 ---- return PyInt_FromLong(1); + /* Special case for empty strings */ + if (PyString_GET_SIZE(self) == 0) + return PyInt_FromLong(0); + e = p + PyUnicode_GET_SIZE(self); for (; p < e; p++) { *************** *** 3502,3505 **** --- 3526,3533 ---- Py_UNICODE_ISNUMERIC(*p)) return PyInt_FromLong(1); + + /* Special case for empty strings */ + if (PyString_GET_SIZE(self) == 0) + return PyInt_FromLong(0); e = p + PyUnicode_GET_SIZE(self); From python-dev@python.org Thu Jun 15 15:50:23 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 15 Jun 2000 07:50:23 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects listobject.c,2.71,2.72 rangeobject.c,2.12,2.13 tupleobject.c,2.34,2.35 Message-ID: <200006151450.HAA28440@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv28425 Modified Files: listobject.c rangeobject.c tupleobject.c Log Message: Thomas Wouters : The following patch adds "sq_contains" support to rangeobject, and enables the already-written support for sq_contains in listobject and tupleobject. The rangeobject "contains" code should be a bit more efficient than the current default "in" implementation ;-) It might not get used much, but it's not that much to add. listobject.c and tupleobject.c already had code for sq_contains, and the proper struct member was set, but the PyType structure was not extended to include tp_flags, so the object-specific code was not getting called (Go ahead, test it ;-). I also did this for the immutable_list_type in listobject.c, eventhough it is probably never used. Symmetry and all that. Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.71 retrieving revision 2.72 diff -C2 -r2.71 -r2.72 *** listobject.c 2000/06/01 14:31:03 2.71 --- listobject.c 2000/06/15 14:50:20 2.72 *************** *** 1490,1493 **** --- 1490,1500 ---- &list_as_sequence, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ }; *************** *** 1541,1544 **** --- 1548,1552 ---- (intobjargproc)immutable_list_ass, /*sq_ass_item*/ (intintobjargproc)immutable_list_ass, /*sq_ass_slice*/ + (objobjproc)list_contains, /*sq_contains*/ }; *************** *** 1558,1561 **** --- 1566,1576 ---- &immutable_list_as_sequence, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ }; Index: rangeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/rangeobject.c,v retrieving revision 2.12 retrieving revision 2.13 diff -C2 -r2.12 -r2.13 *** rangeobject.c 2000/05/03 23:44:35 2.12 --- rangeobject.c 2000/06/15 14:50:20 2.13 *************** *** 238,241 **** --- 238,258 ---- } + static int + range_contains(r, obj) + rangeobject * r; + PyObject * obj; + { + long num = PyInt_AsLong(obj); + + if (num < 0 && PyErr_Occurred()) + return -1; + + if (num < r->start || (num - r->start) % r->step) + return 0; + if (num > (r->start + (r->len * r->step))) + return 0; + return 1; + } + static PySequenceMethods range_as_sequence = { (inquiry)range_length, /*sq_length*/ *************** *** 246,249 **** --- 263,267 ---- 0, /*sq_ass_item*/ 0, /*sq_ass_slice*/ + (objobjproc)range_contains, /*sq_contains*/ }; *************** *** 263,265 **** --- 281,290 ---- &range_as_sequence, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ }; Index: tupleobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/tupleobject.c,v retrieving revision 2.34 retrieving revision 2.35 diff -C2 -r2.34 -r2.35 *** tupleobject.c 2000/06/01 03:12:13 2.34 --- tupleobject.c 2000/06/15 14:50:20 2.35 *************** *** 448,451 **** --- 448,457 ---- 0, /*tp_as_mapping*/ (hashfunc)tuplehash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ }; From python-dev@python.org Thu Jun 15 19:44:35 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 15 Jun 2000 11:44:35 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libdis.tex,1.18,1.19 Message-ID: <200006151844.LAA01311@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv1301/lib Modified Files: libdis.tex Log Message: Michael Hudson : This patch corrects a little glitch and two outright errors. (Including one reported earlier by Thomas Wouters.) Index: libdis.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdis.tex,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** libdis.tex 1999/05/17 20:57:07 1.18 --- libdis.tex 2000/06/15 18:44:30 1.19 *************** *** 155,159 **** \begin{opcodedesc}{UNARY_INVERT}{} ! Implements \code{TOS = \~TOS}. \end{opcodedesc} --- 155,159 ---- \begin{opcodedesc}{UNARY_INVERT}{} ! Implements \code{TOS = \~{}TOS}. \end{opcodedesc} *************** *** 175,179 **** \begin{opcodedesc}{BINARY_MODULO}{} ! Implements \code{TOS = TOS1 \% TOS}. \end{opcodedesc} --- 175,179 ---- \begin{opcodedesc}{BINARY_MODULO}{} ! Implements \code{TOS = TOS1 \%{} TOS}. \end{opcodedesc} *************** *** 199,203 **** \begin{opcodedesc}{BINARY_AND}{} ! Implements \code{TOS = TOS1 and TOS}. \end{opcodedesc} --- 199,203 ---- \begin{opcodedesc}{BINARY_AND}{} ! Implements \code{TOS = TOS1 \&\ TOS}. \end{opcodedesc} *************** *** 207,211 **** \begin{opcodedesc}{BINARY_OR}{} ! Implements \code{TOS = TOS1 or TOS}. \end{opcodedesc} --- 207,211 ---- \begin{opcodedesc}{BINARY_OR}{} ! Implements \code{TOS = TOS1 | TOS}. \end{opcodedesc} From python-dev@python.org Thu Jun 15 21:07:27 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 15 Jun 2000 13:07:27 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/ref ref3.tex,1.42,1.43 Message-ID: <200006152007.NAA16232@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/ref In directory slayer.i.sourceforge.net:/tmp/cvs-serv16223 Modified Files: ref3.tex Log Message: Fix markup error that hid a tilde character; reported long ago by Carl Feynman . Index: ref3.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref3.tex,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -r1.42 -r1.43 *** ref3.tex 2000/04/06 14:00:14 1.42 --- ref3.tex 2000/06/15 20:07:25 1.43 *************** *** 934,937 **** --- 934,948 ---- \end{methoddesc} + \begin{methoddesc}[object]{__rcmp__}{self, other} + Called by all comparison operations. Should return a negative integer if + \code{self < other}, zero if \code{self == other}, a positive integer if + \code{self > other}. If no \method{__cmp__()} operation is defined, class + instances are compared by object identity (``address''). + (Note: the restriction that exceptions are not propagated by + \method{__cmp__()} has been removed in Python 1.5.) + \bifuncindex{cmp} + \index{comparisons} + \end{methoddesc} + \begin{methoddesc}[object]{__hash__}{self} Called for the key object for dictionary\obindex{dictionary} *************** *** 1202,1206 **** \methodline[numeric object]{__invert__}{self} Called to implement the unary arithmetic operations (\code{-}, \code{+}, ! \function{abs()}\bifuncindex{abs} and \code{~}). \end{methoddesc} --- 1213,1217 ---- \methodline[numeric object]{__invert__}{self} Called to implement the unary arithmetic operations (\code{-}, \code{+}, ! \function{abs()}\bifuncindex{abs} and \code{\~{}}). \end{methoddesc} From python-dev@python.org Thu Jun 15 23:41:51 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 15 Jun 2000 15:41:51 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/perl python.perl,1.75,1.76 Message-ID: <200006152241.PAA08164@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/perl In directory slayer.i.sourceforge.net:/tmp/cvs-serv8153/perl Modified Files: python.perl Log Message: do_cmd_textasciitilde(): New function. Index: python.perl =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/perl/python.perl,v retrieving revision 1.75 retrieving revision 1.76 diff -C2 -r1.75 -r1.76 *** python.perl 2000/05/09 16:17:51 1.75 --- python.perl 2000/06/15 22:41:48 1.76 *************** *** 53,56 **** --- 53,61 ---- + # the older version of LaTeX2HTML we use doesn't support this, but we use it: + + sub do_cmd_textasciitilde{ '~' . @_[0]; } + + # words typeset in a special way (not in HTML though) From python-dev@python.org Fri Jun 16 18:06:00 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Fri, 16 Jun 2000 10:06:00 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects tupleobject.c,2.35,2.36 Message-ID: <200006161706.KAA08640@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv8633/Objects Modified Files: tupleobject.c Log Message: Michael Hudson : The error message refers to "append", yet the operation in question is "concat". Index: tupleobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/tupleobject.c,v retrieving revision 2.35 retrieving revision 2.36 diff -C2 -r2.35 -r2.36 *** tupleobject.c 2000/06/15 14:50:20 2.35 --- tupleobject.c 2000/06/16 17:05:57 2.36 *************** *** 363,367 **** if (!PyTuple_Check(bb)) { PyErr_Format(PyExc_TypeError, ! "can only append tuple (not \"%.200s\") to tuple", bb->ob_type->tp_name); return NULL; --- 363,367 ---- if (!PyTuple_Check(bb)) { PyErr_Format(PyExc_TypeError, ! "can only concatenate tuple (not \"%.200s\") to tuple", bb->ob_type->tp_name); return NULL; From python-dev@python.org Fri Jun 16 20:58:45 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 16 Jun 2000 12:58:45 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/api api.tex,1.65,1.66 Message-ID: <200006161958.MAA30426@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/api In directory slayer.i.sourceforge.net:/tmp/cvs-serv30416 Modified Files: api.tex Log Message: Documented PySequence_List() and PySequence_Tuple(). Added a bit more documentation in the chapter on building extension types, including Py_FindMethod() documentation. Several minor consistency nits were fixed. Index: api.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/api.tex,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -r1.65 -r1.66 *** api.tex 2000/04/10 18:50:14 1.65 --- api.tex 2000/06/16 19:58:42 1.66 *************** *** 211,215 **** Nothing needs to be done for a borrowed reference. ! Conversely, when calling a function passes it a reference to an object, there are two possibilities: the function \emph{steals} a reference to the object, or it does not. Few functions steal --- 211,215 ---- Nothing needs to be done for a borrowed reference. ! Conversely, when a calling function passes it a reference to an object, there are two possibilities: the function \emph{steals} a reference to the object, or it does not. Few functions steal *************** *** 603,607 **** value of \cfunction{PyRun_InteractiveLoop()}, otherwise return the result of \cfunction{PyRun_SimpleFile()}. If \var{filename} is ! \NULL{}, this function uses \code{"???"} as the filename. \end{cfuncdesc} --- 603,607 ---- value of \cfunction{PyRun_InteractiveLoop()}, otherwise return the result of \cfunction{PyRun_SimpleFile()}. If \var{filename} is ! \NULL{}, this function uses \code{'???'} as the filename. \end{cfuncdesc} *************** *** 1025,1029 **** \cdata{Py_InteractiveFlag} is true, this function also returns true if the \var{name} pointer is \NULL{} or if the name is equal to one of ! the strings \code{""} or \code{"???"}. \end{cfuncdesc} --- 1025,1029 ---- \cdata{Py_InteractiveFlag} is true, this function also returns true if the \var{name} pointer is \NULL{} or if the name is equal to one of ! the strings \code{''} or \code{'???'}. \end{cfuncdesc} *************** *** 1664,1668 **** --- 1664,1679 ---- \end{cfuncdesc} + \begin{cfuncdesc}{PyObject*}{PySequence_List}{PyObject *o} + Return a list object with the same contents as the arbitrary sequence + \var{o}. The returned list is guaranteed to be new. + \end{cfuncdesc} + + \begin{cfuncdesc}{PyObject*}{PySequence_Tuple}{PyObject *o} + Return a tuple object with the same contents as the arbitrary sequence + \var{o}. If \var{o} is a tuple, a new reference will be returned, + otherwise a tuple will be constructed with the appropriate contents. + \end{cfuncdesc} + \section{Mapping Protocol \label{mapping}} *************** *** 2232,2236 **** Unicode data in \var{s}. ! If \var{byteorder} is not 0, output is written according to the following byte order: --- 2243,2247 ---- Unicode data in \var{s}. ! If \var{byteorder} is not \code{0}, output is written according to the following byte order: *************** *** 2241,2245 **** \end{verbatim} ! If byteorder is 0, the output string will always start with the Unicode BOM mark (U+FEFF). In the other two modes, no BOM mark is prepended. --- 2252,2256 ---- \end{verbatim} ! If byteorder is \code{0}, the output string will always start with the Unicode BOM mark (U+FEFF). In the other two modes, no BOM mark is prepended. *************** *** 2253,2257 **** \begin{cfuncdesc}{PyObject*}{PyUnicode_AsUTF16String}{PyObject *unicode} - Returns a Python string using the UTF-16 encoding in native byte order. The string always starts with a BOM mark. Error handling is --- 2264,2267 ---- *************** *** 3603,3607 **** used by \cfunction{Py_GetPath()}\ttindex{Py_GetPath()} and some other functions below to find the Python run-time libraries relative to the ! interpreter executable. The default value is \code{"python"}. The argument should point to a zero-terminated character string in static storage whose contents will not change for the duration of the --- 3613,3617 ---- used by \cfunction{Py_GetPath()}\ttindex{Py_GetPath()} and some other functions below to find the Python run-time libraries relative to the ! interpreter executable. The default value is \code{'python'}. The argument should point to a zero-terminated character string in static storage whose contents will not change for the duration of the *************** *** 3621,3629 **** is derived through a number of complicated rules from the program name set with \cfunction{Py_SetProgramName()} and some environment variables; ! for example, if the program name is \code{"/usr/local/bin/python"}, ! the prefix is \code{"/usr/local"}. The returned string points into static storage; the caller should not modify its value. This corresponds to the \makevar{prefix} variable in the top-level ! \file{Makefile} and the \programopt{-}\programopt{-prefix} argument to the \program{configure} script at build time. The value is available to Python code as \code{sys.prefix}. It is only useful on \UNIX{}. See --- 3631,3639 ---- is derived through a number of complicated rules from the program name set with \cfunction{Py_SetProgramName()} and some environment variables; ! for example, if the program name is \code{'/usr/local/bin/python'}, ! the prefix is \code{'/usr/local'}. The returned string points into static storage; the caller should not modify its value. This corresponds to the \makevar{prefix} variable in the top-level ! \file{Makefile} and the \longprogramopt{prefix} argument to the \program{configure} script at build time. The value is available to Python code as \code{sys.prefix}. It is only useful on \UNIX{}. See *************** *** 3636,3644 **** program name set with \cfunction{Py_SetProgramName()} and some environment variables; for example, if the program name is ! \code{"/usr/local/bin/python"}, the exec-prefix is ! \code{"/usr/local"}. The returned string points into static storage; the caller should not modify its value. This corresponds to the \makevar{exec_prefix} variable in the top-level \file{Makefile} and the ! \programopt{-}\programopt{-exec_prefix} argument to the \program{configure} script at build time. The value is available to Python code as \code{sys.exec_prefix}. It is only useful on \UNIX{}. --- 3646,3654 ---- program name set with \cfunction{Py_SetProgramName()} and some environment variables; for example, if the program name is ! \code{'/usr/local/bin/python'}, the exec-prefix is ! \code{'/usr/local'}. The returned string points into static storage; the caller should not modify its value. This corresponds to the \makevar{exec_prefix} variable in the top-level \file{Makefile} and the ! \longprogramopt{exec-prefix} argument to the \program{configure} script at build time. The value is available to Python code as \code{sys.exec_prefix}. It is only useful on \UNIX{}. *************** *** 3648,3653 **** installed in a different directory tree. In a typical installation, platform dependent files may be installed in the ! \code{"/usr/local/plat"} subtree while platform independent may be ! installed in \code{"/usr/local"}. Generally speaking, a platform is a combination of hardware and --- 3658,3663 ---- installed in a different directory tree. In a typical installation, platform dependent files may be installed in the ! \file{/usr/local/plat} subtree while platform independent may be ! installed in \file{/usr/local}. Generally speaking, a platform is a combination of hardware and *************** *** 3664,3669 **** System administrators will know how to configure the \program{mount} or ! \program{automount} programs to share \code{"/usr/local"} between platforms ! while having \code{"/usr/local/plat"} be a different filesystem for each platform. \end{cfuncdesc} --- 3674,3679 ---- System administrators will know how to configure the \program{mount} or ! \program{automount} programs to share \file{/usr/local} between platforms ! while having \file{/usr/local/plat} be a different filesystem for each platform. \end{cfuncdesc} *************** *** 3718,3723 **** converted to lower case, followed by the major revision number; e.g., for Solaris 2.x, which is also known as SunOS 5.x, the value is ! \code{"sunos5"}. On Macintosh, it is \code{"mac"}. On Windows, it ! is \code{"win"}. The returned string points into static storage; the caller should not modify its value. The value is available to Python code as \code{sys.platform}. --- 3728,3733 ---- converted to lower case, followed by the major revision number; e.g., for Solaris 2.x, which is also known as SunOS 5.x, the value is ! \code{'sunos5'}. On Macintosh, it is \code{'mac'}. On Windows, it ! is \code{'win'}. The returned string points into static storage; the caller should not modify its value. The value is available to Python code as \code{sys.platform}. *************** *** 3729,3733 **** for example ! \code{"Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam"} The returned string points into static storage; the caller should not --- 3739,3743 ---- for example ! \code{'Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam'} The returned string points into static storage; the caller should not *************** *** 4376,4379 **** --- 4386,4413 ---- destructor, printfunc, getattrfunc, getattrofunc, setattrfunc, setattrofunc, cmpfunc, reprfunc, hashfunc + + \begin{ctypedesc}{PyCFunction} + Type of the functions used to implement most Python callables in C. + \end{ctypedesc} + + \begin{ctypedesc}{PyMethodDef} + Structure used to describe a method of an extension type. This + structure has four fields: + + \begin{tableiii}{l|l|l}{member}{Field}{C Type}{Meaning} + \lineiii{ml_name}{char *}{name of the method} + \lineiii{ml_meth}{PyCFunction}{pointer to the C implementation} + \lineiii{ml_flags}{int}{flag bits indicating how the call should be + constructed} + \lineiii{ml_doc}{char *}{points to the contents of the docstring} + \end{tableiii} + \end{ctypedesc} + + \begin{cfuncdesc}{PyObject*}{Py_FindMethod}{PyMethodDef[] table, + PyObject *ob, char *name} + Return a bound method object for an extension type implemented in C. + This function also handles the special attribute \member{__methods__}, + returning a list of all the method names defined in \var{table}. + \end{cfuncdesc} From python-dev@python.org Fri Jun 16 21:00:06 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 16 Jun 2000 13:00:06 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/api refcounts.dat,1.8,1.9 Message-ID: <200006162000.NAA30761@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/api In directory slayer.i.sourceforge.net:/tmp/cvs-serv30602 Modified Files: refcounts.dat Log Message: Added reference count information for PySequence_List(). Index: refcounts.dat =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/refcounts.dat,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** refcounts.dat 2000/04/10 19:38:24 1.8 --- refcounts.dat 2000/06/16 20:00:04 1.9 *************** *** 727,730 **** --- 727,733 ---- PySequence_SetSlice:PyObject*:v:+1: + PySequence_List:PyObject*::+1: + PySequence_List:PyObject*:o:0: + PySequence_Tuple:PyObject*::+1: PySequence_Tuple:PyObject*:o:0: From python-dev@python.org Fri Jun 16 22:04:17 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 16 Jun 2000 14:04:17 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/api api.tex,1.66,1.67 refcounts.dat,1.9,1.10 Message-ID: <200006162104.OAA13827@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/api In directory slayer.i.sourceforge.net:/tmp/cvs-serv13811 Modified Files: api.tex refcounts.dat Log Message: Updates from Marc-Andre Lemburg for the Unicode support. Index: api.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/api.tex,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -r1.66 -r1.67 *** api.tex 2000/06/16 19:58:42 1.66 --- api.tex 2000/06/16 21:04:15 1.67 *************** *** 1967,1976 **** \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyUnicode_AS_UNICODE}{PyObject *o} Returns a pointer to the internal Py_UNICODE buffer of the object. o has to be a PyUnicodeObject (not checked). \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyUnicode_AS_DATA}{PyObject *o} Returns a (const char *) pointer to the internal buffer of the object. o has to be a PyUnicodeObject (not checked). --- 1967,1976 ---- \end{cfuncdesc} ! \begin{cfuncdesc}{Py_UNICODE*}{PyUnicode_AS_UNICODE}{PyObject *o} Returns a pointer to the internal Py_UNICODE buffer of the object. o has to be a PyUnicodeObject (not checked). \end{cfuncdesc} ! \begin{cfuncdesc}{const char*}{PyUnicode_AS_DATA}{PyObject *o} Returns a (const char *) pointer to the internal buffer of the object. o has to be a PyUnicodeObject (not checked). Index: refcounts.dat =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/refcounts.dat,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** refcounts.dat 2000/06/16 20:00:04 1.9 --- refcounts.dat 2000/06/16 21:04:15 1.10 *************** *** 823,826 **** --- 823,1097 ---- PyTuple_Size:PyTupleObject*:p:0: + PyUnicode_Check:int::: + PyUnicode_Check:PyObject*:o:0: + + PyUnicode_GET_SIZE:int::: + PyUnicode_GET_SIZE:PyObject*:o:0: + + PyUnicode_GET_DATA_SIZE:int::: + PyUnicode_GET_DATA_SIZE:PyObject*:o:0: + + PyUnicode_AS_UNICODE:Py_UNICODE*::: + PyUnicode_AS_UNICODE:PyObject*:o:0: + + PyUnicode_AS_DATA:const char*::: + PyUnicode_AS_DATA:PyObject*:o:0: + + Py_UNICODE_ISSPACE:int::: + Py_UNICODE_ISSPACE:Py_UNICODE:ch:: + + Py_UNICODE_ISLOWER:int::: + Py_UNICODE_ISLOWER:Py_UNICODE:ch:: + + Py_UNICODE_ISUPPER:int::: + Py_UNICODE_ISUPPER:Py_UNICODE:ch:: + + Py_UNICODE_ISTITLE:int::: + Py_UNICODE_ISTITLE:Py_UNICODE:ch:: + + Py_UNICODE_ISLINEBREAK:int::: + Py_UNICODE_ISLINEBREAK:Py_UNICODE:ch:: + + Py_UNICODE_ISDECIMAL:int::: + Py_UNICODE_ISDECIMAL:Py_UNICODE:ch:: + + Py_UNICODE_ISDIGIT:int::: + Py_UNICODE_ISDIGIT:Py_UNICODE:ch:: + + Py_UNICODE_ISNUMERIC:int::: + Py_UNICODE_ISNUMERIC:Py_UNICODE:ch:: + + Py_UNICODE_TOLOWER:Py_UNICODE::: + Py_UNICODE_TOLOWER:Py_UNICODE:ch:: + + Py_UNICODE_TOUPPER:Py_UNICODE::: + Py_UNICODE_TOUPPER:Py_UNICODE:ch:: + + Py_UNICODE_TOTITLE:Py_UNICODE::: + Py_UNICODE_TOTITLE:Py_UNICODE:ch:: + + Py_UNICODE_TODECIMAL:int::: + Py_UNICODE_TODECIMAL:Py_UNICODE:ch:: + + Py_UNICODE_TODIGIT:int::: + Py_UNICODE_TODIGIT:Py_UNICODE:ch:: + + Py_UNICODE_TONUMERIC:double::: + Py_UNICODE_TONUMERIC:Py_UNICODE:ch:: + + PyUnicode_FromUnicode:PyObject*::+1: + PyUnicode_FromUnicode:const Py_UNICODE *:u:: + PyUnicode_FromUnicode:int:size:: + + PyUnicode_AsUnicode:Py_UNICODE*::: + PyUnicode_AsUnicode:PyObject :*unicode:0: + + PyUnicode_GetSize:int::: + PyUnicode_GetSize:PyObject :*unicode:0: + + PyUnicode_FromObject:PyObject*::+1: + PyUnicode_FromObject:PyObject :*obj:0: + + PyUnicode_FromWideChar:PyObject*::+1: + PyUnicode_FromWideChar:const wchar_t *:w:: + PyUnicode_FromWideChar:int:size:: + + PyUnicode_AsWideChar:int::: + PyUnicode_AsWideChar:PyObject :*unicode:0: + PyUnicode_AsWideChar:wchar_t *:w:: + PyUnicode_AsWideChar:int:size:: + + PyUnicode_Decode:PyObject*::+1: + PyUnicode_Decode:const char *:s:: + PyUnicode_Decode:int:size:: + PyUnicode_Decode:const char *:encoding:: + PyUnicode_Decode:const char *:errors:: + + PyUnicode_Encode:PyObject*::+1: + PyUnicode_Encode:const Py_UNICODE *:s:: + PyUnicode_Encode:int:size:: + PyUnicode_Encode:const char *:encoding:: + PyUnicode_Encode:const char *:errors:: + + PyUnicode_AsEncodedString:PyObject*::+1: + PyUnicode_AsEncodedString:PyObject *:unicode:: + PyUnicode_AsEncodedString:const char *:encoding:: + PyUnicode_AsEncodedString:const char *:errors:: + + PyUnicode_DecodeUTF8:PyObject*::+1: + PyUnicode_DecodeUTF8:const char *:s:: + PyUnicode_DecodeUTF8:int:size:: + PyUnicode_DecodeUTF8:const char *:errors:: + + PyUnicode_EncodeUTF8:PyObject*::+1: + PyUnicode_EncodeUTF8:const Py_UNICODE *:s:: + PyUnicode_EncodeUTF8:int:size:: + PyUnicode_EncodeUTF8:const char *:errors:: + + PyUnicode_AsUTF8String:PyObject*::+1: + PyUnicode_AsUTF8String:PyObject *:unicode:: + + PyUnicode_DecodeUTF16:PyObject*::+1: + PyUnicode_DecodeUTF16:const char *:s:: + PyUnicode_DecodeUTF16:int:size:: + PyUnicode_DecodeUTF16:const char *:errors:: + PyUnicode_DecodeUTF16:int*:byteorder:: + + PyUnicode_EncodeUTF16:PyObject*::+1: + PyUnicode_EncodeUTF16:const Py_UNICODE *:s:: + PyUnicode_EncodeUTF16:int:size:: + PyUnicode_EncodeUTF16:const char *:errors:: + PyUnicode_EncodeUTF16:int:byteorder:: + + PyUnicode_AsUTF16String:PyObject*::+1: + PyUnicode_AsUTF16String:PyObject *:unicode:: + + PyUnicode_DecodeUnicodeEscape:PyObject*::+1: + PyUnicode_DecodeUnicodeEscape:const char *:s:: + PyUnicode_DecodeUnicodeEscape:int:size:: + PyUnicode_DecodeUnicodeEscape:const char *:errors:: + + PyUnicode_EncodeUnicodeEscape:PyObject*::+1: + PyUnicode_EncodeUnicodeEscape:const Py_UNICODE *:s:: + PyUnicode_EncodeUnicodeEscape:int:size:: + PyUnicode_EncodeUnicodeEscape:const char *:errors:: + + PyUnicode_AsUnicodeEscapeString:PyObject*::+1: + PyUnicode_AsUnicodeEscapeString:PyObject *:unicode:: + + PyUnicode_DecodeRawUnicodeEscape:PyObject*::+1: + PyUnicode_DecodeRawUnicodeEscape:const char *:s:: + PyUnicode_DecodeRawUnicodeEscape:int:size:: + PyUnicode_DecodeRawUnicodeEscape:const char *:errors:: + + PyUnicode_EncodeRawUnicodeEscape:PyObject*::+1: + PyUnicode_EncodeRawUnicodeEscape:const Py_UNICODE *:s:: + PyUnicode_EncodeRawUnicodeEscape:int:size:: + PyUnicode_EncodeRawUnicodeEscape:const char *:errors:: + + PyUnicode_AsRawUnicodeEscapeString:PyObject*::+1: + PyUnicode_AsRawUnicodeEscapeString:PyObject *:unicode:: + + PyUnicode_DecodeLatin1:PyObject*::+1: + PyUnicode_DecodeLatin1:const char *:s:: + PyUnicode_DecodeLatin1:int:size:: + PyUnicode_DecodeLatin1:const char *:errors:: + + PyUnicode_EncodeLatin1:PyObject*::+1: + PyUnicode_EncodeLatin1:const Py_UNICODE *:s:: + PyUnicode_EncodeLatin1:int:size:: + PyUnicode_EncodeLatin1:const char *:errors:: + + PyUnicode_AsLatin1String:PyObject*::+1: + PyUnicode_AsLatin1String:PyObject *:unicode:: + + PyUnicode_DecodeASCII:PyObject*::+1: + PyUnicode_DecodeASCII:const char *:s:: + PyUnicode_DecodeASCII:int:size:: + PyUnicode_DecodeASCII:const char *:errors:: + + PyUnicode_EncodeASCII:PyObject*::+1: + PyUnicode_EncodeASCII:const Py_UNICODE *:s:: + PyUnicode_EncodeASCII:int:size:: + PyUnicode_EncodeASCII:const char *:errors:: + + PyUnicode_AsASCIIString:PyObject*::+1: + PyUnicode_AsASCIIString:PyObject *:unicode:: + + PyUnicode_DecodeCharmap:PyObject*::+1: + PyUnicode_DecodeCharmap:const char *:s:: + PyUnicode_DecodeCharmap:int:size:: + PyUnicode_DecodeCharmap:PyObject*:mapping:0: + PyUnicode_DecodeCharmap:const char *:errors:: + + PyUnicode_EncodeCharmap:PyObject*::+1: + PyUnicode_EncodeCharmap:const Py_UNICODE *:s:: + PyUnicode_EncodeCharmap:int:size:: + PyUnicode_EncodeCharmap:PyObject*:mapping:0: + PyUnicode_EncodeCharmap:const char *:errors:: + + PyUnicode_AsCharmapString:PyObject*::+1: + PyUnicode_AsCharmapString:PyObject*:unicode:0: + PyUnicode_AsCharmapString:PyObject*:mapping:0: + + PyUnicode_TranslateCharmap:PyObject*::+1: + PyUnicode_TranslateCharmap:const Py_UNICODE *:s:: + PyUnicode_TranslateCharmap:int:size:: + PyUnicode_TranslateCharmap:PyObject*:table:0: + PyUnicode_TranslateCharmap:const char *:errors:: + + PyUnicode_DecodeMBCS:PyObject*::+1: + PyUnicode_DecodeMBCS:const char *:s:: + PyUnicode_DecodeMBCS:int:size:: + PyUnicode_DecodeMBCS:const char *:errors:: + + PyUnicode_EncodeMBCS:PyObject*::+1: + PyUnicode_EncodeMBCS:const Py_UNICODE *:s:: + PyUnicode_EncodeMBCS:int:size:: + PyUnicode_EncodeMBCS:const char *:errors:: + + PyUnicode_AsMBCSString:PyObject*::+1: + PyUnicode_AsMBCSString:PyObject *:unicode:: + + PyUnicode_Concat:PyObject*::+1: + PyUnicode_Concat:PyObject*:left:0: + PyUnicode_Concat:PyObject*:right:0: + + PyUnicode_Split:PyObject*::+1: + PyUnicode_Split:PyObject*:left:0: + PyUnicode_Split:PyObject*:right:0: + PyUnicode_Split:int:maxsplit:: + + PyUnicode_Splitlines:PyObject*::+1: + PyUnicode_Splitlines:PyObject*:s:0: + PyUnicode_Splitlines:int:maxsplit:: + + PyUnicode_Translate:PyObject*::+1: + PyUnicode_Translate:PyObject*:str:0: + PyUnicode_Translate:PyObject*:table:0: + PyUnicode_Translate:const char *:errors:: + + PyUnicode_Join:PyObject*::+1: + PyUnicode_Join:PyObject*:separator:0: + PyUnicode_Join:PyObject*:seq:0: + + PyUnicode_Tailmatch:PyObject*::+1: + PyUnicode_Tailmatch:PyObject*:str:0: + PyUnicode_Tailmatch:PyObject*:substr:0: + PyUnicode_Tailmatch:int:start:: + PyUnicode_Tailmatch:int:end:: + PyUnicode_Tailmatch:int:direction:: + + PyUnicode_Find:PyObject*::+1: + PyUnicode_Find:PyObject*:str:0: + PyUnicode_Find:PyObject*:substr:0: + PyUnicode_Find:int:start:: + PyUnicode_Find:int:end:: + PyUnicode_Find:int:direction:: + + PyUnicode_Count:PyObject*::+1: + PyUnicode_Count:PyObject*:str:0: + PyUnicode_Count:PyObject*:substr:0: + PyUnicode_Count:int:start:: + PyUnicode_Count:int:end:: + + PyUnicode_Replace:PyObject*::+1: + PyUnicode_Replace:PyObject*:str:0: + PyUnicode_Replace:PyObject*:substr:0: + PyUnicode_Replace:PyObject*:replstr:0: + PyUnicode_Replace:int:maxcount:: + + PyUnicode_Compare:int::: + PyUnicode_Compare:PyObject*:left:0: + PyUnicode_Compare:PyObject*:right:0: + + PyUnicode_Format:PyObject*::+1: + PyUnicode_Format:PyObject*:format:0: + PyUnicode_Format:PyObject*:args:0: + + PyUnicode_Contains:int::: + PyUnicode_Contains:PyObject*:container:0: + PyUnicode_Contains:PyObject*:element:0: + Py_AtExit:int::: Py_AtExit:void (*)():func:: From python-dev@python.org Sat Jun 17 02:34:47 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 16 Jun 2000 18:34:47 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command install.py,1.36,1.37 Message-ID: <200006170134.SAA20203@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv20191 Modified Files: install.py Log Message: Fixed install directory for header files on Unix. Index: install.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/install.py,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -r1.36 -r1.37 *** install.py 2000/05/31 02:32:10 1.36 --- install.py 2000/06/17 01:34:45 1.37 *************** *** 19,23 **** 'purelib': '$base/lib/python$py_version_short/site-packages', 'platlib': '$platbase/lib/python$py_version_short/site-packages', ! 'headers': '$base/include/python/$py_version_short/$dist_name', 'scripts': '$base/bin', 'data' : '$base/share', --- 19,23 ---- 'purelib': '$base/lib/python$py_version_short/site-packages', 'platlib': '$platbase/lib/python$py_version_short/site-packages', ! 'headers': '$base/include/python$py_version_short/$dist_name', 'scripts': '$base/bin', 'data' : '$base/share', From python-dev@python.org Sat Jun 17 02:58:17 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 16 Jun 2000 18:58:17 -0700 Subject: [Python-checkins] CVS: distutils/distutils dir_util.py,1.2,1.3 Message-ID: <200006170158.SAA21066@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv21031 Modified Files: dir_util.py Log Message: Bastian Kleineidam: added 'remove_tree()' function. Needed so that 'remove_tree()' can cooperate with 'mkpath()' in the maintenance of the PATH_CREATED cache: specifically, if a directory is created with 'mkpath()', later removed with 'remove_tree()', and 'mkpath()' is again requested to create it, then it would erroneously think the directory already existed, because it was in the PATH_CREATED cache. The patch (slightly tweaked by me) fixes that. Index: dir_util.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/dir_util.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** dir_util.py 2000/05/27 01:35:27 1.2 --- dir_util.py 2000/06/17 01:58:14 1.3 *************** *** 181,202 **** # copy_tree () def remove_tree (directory, verbose=0, dry_run=0): """Recursively remove an entire directory tree. Any errors are ignored (apart from being reported to stdout if 'verbose' is true).""" - - from shutil import rmtree if verbose: print "removing '%s' (and everything under it)" % directory if dry_run: return ! try: ! rmtree(directory,1) ! except (IOError, OSError), exc: ! if verbose: ! if exc.filename: ! print "error removing %s: %s (%s)" % \ (directory, exc.strerror, exc.filename) ! else: ! print "error removing %s: %s" % (directory, exc.strerror) --- 181,217 ---- # copy_tree () + # Helper for remove_tree() + def _build_cmdtuple(path, cmdtuples): + for f in os.listdir(path): + real_f = os.path.join(path,f) + if os.path.isdir(real_f) and not os.path.islink(real_f): + _build_cmdtuple(real_f, cmdtuples) + else: + cmdtuples.append((os.remove, real_f)) + cmdtuples.append((os.rmdir, path)) + def remove_tree (directory, verbose=0, dry_run=0): """Recursively remove an entire directory tree. Any errors are ignored (apart from being reported to stdout if 'verbose' is true).""" + global PATH_CREATED if verbose: print "removing '%s' (and everything under it)" % directory if dry_run: return ! cmdtuples = [] ! _build_cmdtuple(directory, cmdtuples) ! for cmd in cmdtuples: ! try: ! apply(cmd[0], (cmd[1],)) ! # remove dir from cache if it's already there ! if PATH_CREATED.has_key(cmd[1]): ! del PATH_CREATED[cmd[1]] ! except (IOError, OSError), exc: ! if verbose: ! if exc.filename: ! print "error removing %s: %s (%s)" % \ (directory, exc.strerror, exc.filename) ! else: ! print "error removing %s: %s" % (directory, exc.strerror) From python-dev@python.org Sat Jun 17 03:16:49 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 16 Jun 2000 19:16:49 -0700 Subject: [Python-checkins] CVS: distutils/distutils util.py,1.34,1.35 Message-ID: <200006170216.TAA27797@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv27784 Modified Files: util.py Log Message: Added 'grok_environment_error()' function to deal with the various forms that IOError and OSError can take (taken from core.py). Index: util.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/util.py,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -r1.34 -r1.35 *** util.py 2000/05/31 02:32:10 1.34 --- util.py 2000/06/17 02:16:46 1.35 *************** *** 155,156 **** --- 155,176 ---- + def grok_environment_error (exc, prefix="error: "): + """Generate a useful error message from an EnvironmentError (IOError or + OSError) exception object. Handles Python 1.5.1 and 1.5.2 styles, and + does what it can to deal with exception objects that don't have a + filename (which happens when the error is due to a two-file operation, + such as 'rename()' or 'link()'. Returns the error message as a string + prefixed with 'prefix'. + """ + # check for Python 1.5.2-style {IO,OS}Error exception objects + if hasattr (exc, 'filename') and hasattr (exc, 'strerror'): + if exc.filename: + error = prefix + "%s: %s" % (exc.filename, exc.strerror) + else: + # two-argument functions in posix module don't + # include the filename in the exception object! + error = prefix + "%s" % exc.strerror + else: + error = prefix + str(exc[-1]) + + return error From python-dev@python.org Sat Jun 17 03:17:47 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 16 Jun 2000 19:17:47 -0700 Subject: [Python-checkins] CVS: distutils/distutils core.py,1.41,1.42 Message-ID: <200006170217.TAA27912@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv27893 Modified Files: core.py Log Message: Changed to use the new 'grok_environment_error()' function instead of muddling through IOError and OSError exception objects right here. Index: core.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/core.py,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -r1.41 -r1.42 *** core.py 2000/06/03 01:02:06 1.41 --- core.py 2000/06/17 02:17:45 1.42 *************** *** 113,126 **** raise SystemExit, "interrupted" except (IOError, os.error), exc: ! # check for Python 1.5.2-style {IO,OS}Error exception objects ! if hasattr (exc, 'filename') and hasattr (exc, 'strerror'): ! if exc.filename: ! error = "error: %s: %s" % (exc.filename, exc.strerror) ! else: ! # two-argument functions in posix module don't ! # include the filename in the exception object! ! error = "error: %s" % exc.strerror ! else: ! error = "error: " + str(exc[-1]) if DEBUG: --- 113,117 ---- raise SystemExit, "interrupted" except (IOError, os.error), exc: ! error = grok_environment_error(exc) if DEBUG: From python-dev@python.org Sat Jun 17 03:18:22 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 16 Jun 2000 19:18:22 -0700 Subject: [Python-checkins] CVS: distutils/distutils dir_util.py,1.3,1.4 Message-ID: <200006170218.TAA27986@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv27970 Modified Files: dir_util.py Log Message: Changed 'remove_tree()' to use the new 'grok_environment_error()' function instead of muddling through IOError and OSError exception objects itself. Index: dir_util.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/dir_util.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** dir_util.py 2000/06/17 01:58:14 1.3 --- dir_util.py 2000/06/17 02:18:19 1.4 *************** *** 194,200 **** def remove_tree (directory, verbose=0, dry_run=0): """Recursively remove an entire directory tree. Any errors are ignored ! (apart from being reported to stdout if 'verbose' is true).""" ! global PATH_CREATED if verbose: print "removing '%s' (and everything under it)" % directory --- 194,202 ---- def remove_tree (directory, verbose=0, dry_run=0): """Recursively remove an entire directory tree. Any errors are ignored ! (apart from being reported to stdout if 'verbose' is true). ! """ ! from distutils.util import grok_environment_error global PATH_CREATED + if verbose: print "removing '%s' (and everything under it)" % directory *************** *** 211,217 **** except (IOError, OSError), exc: if verbose: ! if exc.filename: ! print "error removing %s: %s (%s)" % \ ! (directory, exc.strerror, exc.filename) ! else: ! print "error removing %s: %s" % (directory, exc.strerror) --- 213,216 ---- except (IOError, OSError), exc: if verbose: ! print grok_environment_error( ! exc, "error removing %s: " % directory) From python-dev@python.org Sat Jun 17 03:19:32 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 16 Jun 2000 19:19:32 -0700 Subject: [Python-checkins] CVS: distutils/distutils dir_util.py,1.4,1.5 Message-ID: <200006170219.TAA28047@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv28030 Modified Files: dir_util.py Log Message: Renamed PATH_CREATED to _path_created, on the grounds that it's private and mutable, rather than public and constant. Index: dir_util.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/dir_util.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** dir_util.py 2000/06/17 02:18:19 1.4 --- dir_util.py 2000/06/17 02:19:30 1.5 *************** *** 14,18 **** # cache for by mkpath() -- in addition to cheapening redundant calls, # eliminates redundant "creating /foo/bar/baz" messages in dry-run mode ! PATH_CREATED = {} # I don't use os.makedirs because a) it's new to Python 1.5.2, and --- 14,18 ---- # cache for by mkpath() -- in addition to cheapening redundant calls, # eliminates redundant "creating /foo/bar/baz" messages in dry-run mode ! _path_created = {} # I don't use os.makedirs because a) it's new to Python 1.5.2, and *************** *** 29,33 **** actually created.""" ! global PATH_CREATED # Detect a common bug -- name is None --- 29,33 ---- actually created.""" ! global _path_created # Detect a common bug -- name is None *************** *** 45,49 **** if os.path.isdir (name) or name == '': return created_dirs ! if PATH_CREATED.get (name): return created_dirs --- 45,49 ---- if os.path.isdir (name) or name == '': return created_dirs ! if _path_created.get (name): return created_dirs *************** *** 65,69 **** #print "head = %s, d = %s: " % (head, d), head = os.path.join (head, d) ! if PATH_CREATED.get (head): continue --- 65,69 ---- #print "head = %s, d = %s: " % (head, d), head = os.path.join (head, d) ! if _path_created.get (head): continue *************** *** 79,83 **** "could not create '%s': %s" % (head, exc[-1]) ! PATH_CREATED[head] = 1 return created_dirs --- 79,83 ---- "could not create '%s': %s" % (head, exc[-1]) ! _path_created[head] = 1 return created_dirs *************** *** 197,201 **** """ from distutils.util import grok_environment_error ! global PATH_CREATED if verbose: --- 197,201 ---- """ from distutils.util import grok_environment_error ! global _path_created if verbose: *************** *** 209,214 **** apply(cmd[0], (cmd[1],)) # remove dir from cache if it's already there ! if PATH_CREATED.has_key(cmd[1]): ! del PATH_CREATED[cmd[1]] except (IOError, OSError), exc: if verbose: --- 209,214 ---- apply(cmd[0], (cmd[1],)) # remove dir from cache if it's already there ! if _path_created.has_key(cmd[1]): ! del _path_created[cmd[1]] except (IOError, OSError), exc: if verbose: From python-dev@python.org Sat Jun 17 21:31:19 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Sat, 17 Jun 2000 13:31:19 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.26,2.27 Message-ID: <200006172031.NAA17184@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv17084 Modified Files: unicodeobject.c Log Message: Vladimir MARANGOZOV : This patch fixes an optimisation mystery in _PyUnicodeNew causing segfaults on AIX when the interpreter is compiled with -O. Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.26 retrieving revision 2.27 diff -C2 -r2.26 -r2.27 *** unicodeobject.c 2000/06/14 09:18:32 2.26 --- unicodeobject.c 2000/06/17 20:31:17 2.27 *************** *** 214,220 **** if (unicode_freelist) { unicode = unicode_freelist; ! unicode_freelist = *(PyUnicodeObject **)unicode_freelist; unicode_freelist_size--; - PyObject_INIT(unicode, &PyUnicode_Type); if (unicode->str) { /* Keep-Alive optimization: we only upsize the buffer, --- 214,219 ---- if (unicode_freelist) { unicode = unicode_freelist; ! unicode_freelist = *(PyUnicodeObject **)unicode; unicode_freelist_size--; if (unicode->str) { /* Keep-Alive optimization: we only upsize the buffer, *************** *** 226,231 **** } } ! else unicode->str = PyMem_NEW(Py_UNICODE, length + 1); } else { --- 225,232 ---- } } ! else { unicode->str = PyMem_NEW(Py_UNICODE, length + 1); + } + PyObject_INIT(unicode, &PyUnicode_Type); } else { From python-dev@python.org Sat Jun 17 23:39:08 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 17 Jun 2000 15:39:08 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libmmap.tex,NONE,1.1 Message-ID: <200006172239.PAA01994@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv1983 Added Files: libmmap.tex Log Message: Documentation for the mmap module: proofreaders welcomed --- NEW FILE --- \section{\module{mmap} --- Memory-mapped file support} \declaremodule{builtin}{mmap} \modulesynopsis{Interface to memory-mapped files for Unix and Windows.} Memory-mapped file objects behave like both mutable strings and like file objects. You can use mmap objects in most places where strings are expected; for example, you can use the \module{re} module to search through a memory-mapped file. Since they're mutable, you can change a single character by doing \code{obj[ \var{index} ] = 'a'}, or change a substring by assigning to a slice: \code{obj[ \var{i1}:\var{i2} ] = '...'}. You can also read and write data starting at the current file position, and \method{seek()} through the file to different positions. A memory-mapped file is created by the following function, which is different on Unix and on Windows. \begin{funcdesc}{mmap}{fileno, length \optional{, tagname} } (Windows version) Maps \var{length} bytes from the file specified by the file handle \var{fileno}, and returns a mmap object. If you have a Python file object, its \method{fileno()} method returns the file's handle, which is just an integer. \var{tagname}, if specified, is a string giving a tag name for the mapping. XXX what is the purpose of the tag name? \end{funcdesc} \begin{funcdesc}{mmap}{file, size \optional{, flags, prot}} (Unix version) Maps \var{length} bytes from the file specified by the file handle \var{fileno}, and returns a mmap object. If you have a Python file object, its \method{fileno()} method returns the file's handle, which is just an integer. \var{flags} specifies the nature of the mapping. \code{MAP_PRIVATE} creates a private copy-on-write mapping, so changes to the contents of the mmap object will be private to this process, and \code{MAP_SHARED} creates a mapping that's shared with all other processes mapping the same areas of the file. The default value is \code{MAP_SHARED}. \var{prot}, if specified, gives the desired memory protection; the two most useful values are \code{PROT_READ} and \code{PROT_WRITE}, to specify that the pages may be read or written. \var{prot} defaults to \code{PROT_READ | PROT_WRITE}. \end{funcdesc} Memory-mapped file objects support the following methods: \begin{methoddesc}{close}{} Close the file. Subsequent calls to other methods of the object will result in an exception being raised. \end{methoddesc} \begin{methoddesc}{find}{\var{string} \optional{, \var{start}}} Returns the lowest index in the object where the substring \var{string} is found. Returns \code{-1} on failure. \var{start} is the index at which the search begins, and defaults to zero. \end{methoddesc} \begin{methoddesc}{flush}{\optional{\var{offset}, \var{size}}} Flushes changes made to the in-memory copy of a file back to disk. Without use of this call there is no guarantee that changes are written back before the object is destroyed. If \var{offset} and \var{size} are specified, only changes to the given range of bytes will be flushed to disk; otherwise, the whole extent of the mapping is flushed. \end{methoddesc} \begin{methoddesc}{move}{\var{dest}, \var{src}, \var{count}} Copy the \var{count} bytes starting at offset \var{src} to the destination index \var{dest}. \end{methoddesc} \begin{methoddesc}{read}{\var{num}} Return a string containing up to \var{num} bytes taken from the current file position; the file position is updated to point after the bytes that were returned. \end{methoddesc} \begin{methoddesc}{read_byte}{} Returns the character at the current file position, and advancing the file position by 1. \end{methoddesc} \begin{methoddesc}{readline}{} Returns a single line, starting at the current file position and up to the next newline. \end{methoddesc} \begin{methoddesc}{resize}{\var{newsize}} \end{methoddesc} \begin{methoddesc}{seek}{\var{pos} \optional{, \var{whence}}} Set the file's current position. \var{whence} argument is optional and defaults to \code{0} (absolute file positioning); other values are \code{1} (seek relative to the current position) and \code{2} (seek relative to the file's end). \end{methoddesc} \begin{methoddesc}{size}{} Return the length of the file, which can be larger than the size of the memory-mapped area. \end{methoddesc} \begin{methoddesc}{tell}{} Returns the current position of the file pointer. \end{methoddesc} \begin{methoddesc}{write}{\var{string}} Write the bytes in \var{string} into memory at the current position of the file pointer; the file position is updated to point after the bytes that were written. \end{methoddesc} \begin{methoddesc}{write_byte}{\var{byte}} Write \var{byte} into memory at the current position of the file pointer; the file position is advanced by 1. \end{methoddesc} From python-dev@python.org Sat Jun 17 23:41:24 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 17 Jun 2000 15:41:24 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules mmapmodule.c,2.10,2.11 Message-ID: <200006172241.PAA02080@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv2060 Modified Files: mmapmodule.c Log Message: Fix the size() method to return the size of the file on Unix, not the size of the mapped area. This seems to be what the Windows version does. This change requires keeping around the fd of the mapped file. Index: mmapmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/mmapmodule.c,v retrieving revision 2.10 retrieving revision 2.11 diff -C2 -r2.10 -r2.11 *** mmapmodule.c 2000/06/03 20:43:43 2.10 --- mmapmodule.c 2000/06/17 22:41:22 2.11 *************** *** 30,33 **** --- 30,34 ---- #include #include + #include #endif *************** *** 50,54 **** #ifdef UNIX ! /* No Unix-specific information at this point in time */ #endif } mmap_object; --- 51,55 ---- #ifdef UNIX ! int fd; #endif } mmap_object; *************** *** 211,215 **** static PyObject * mmap_write_method (mmap_object * self, ! PyObject * args) { long length; --- 212,216 ---- static PyObject * mmap_write_method (mmap_object * self, ! PyObject * args) { long length; *************** *** 265,269 **** #ifdef UNIX ! return (Py_BuildValue ("l", self->size) ); #endif /* UNIX */ } --- 266,277 ---- #ifdef UNIX ! { ! struct stat buf; ! if (-1 == fstat(self->fd, &buf)) { ! PyErr_SetFromErrno(mmap_module_error); ! return NULL; ! } ! return (Py_BuildValue ("l", buf.st_size) ); ! } #endif /* UNIX */ } *************** *** 718,721 **** --- 726,730 ---- m_obj->size = (size_t) map_size; m_obj->pos = (size_t) 0; + m_obj->fd = fd; m_obj->data = mmap(NULL, map_size, prot, flags, From python-dev@python.org Sun Jun 18 00:04:33 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 17 Jun 2000 16:04:33 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command build_ext.py,1.42,1.43 Message-ID: <200006172304.QAA09038@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv9028 Modified Files: build_ext.py Log Message: Pulled the MSVC++-specific hackery out to a new method, 'prelink_hook()', and added (empty) 'precompile_hook()' for symmetry. One can envision a much more elaborate hook mechanism, but this looks like it'll do for now. Index: build_ext.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build_ext.py,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -r1.42 -r1.43 *** build_ext.py 2000/06/07 03:00:06 1.42 --- build_ext.py 2000/06/17 23:04:31 1.43 *************** *** 161,165 **** # 'self.extensions', as supplied by setup.py, is a list of # Extension instances. See the documentation for Extension (in ! # distutils.core) for details. # # For backwards compatibility with Distutils 0.8.2 and earlier, we --- 161,165 ---- # 'self.extensions', as supplied by setup.py, is a list of # Extension instances. See the documentation for Extension (in ! # distutils.extension) for details. # # For backwards compatibility with Distutils 0.8.2 and earlier, we *************** *** 396,399 **** --- 396,404 ---- extra_args.extend(string.split(os.environ['CFLAGS'])) + # Run any platform/compiler-specific hooks needed before + # compiling (currently none, but any hypothetical subclasses + # might find it useful to override this). + self.precompile_hook() + objects = self.compiler.compile (sources, output_dir=self.build_temp, *************** *** 410,448 **** extra_args = ext.extra_link_args ! # XXX this is a kludge! Knowledge of specific compilers or ! # platforms really doesn't belong here; in an ideal world, the ! # CCompiler interface would provide access to everything in a ! # compiler/linker system needs to build Python extensions, and ! # we would just do everything nicely and cleanly through that ! # interface. However, this is a not an ideal world and the ! # CCompiler interface doesn't handle absolutely everything. ! # Thus, kludges like this slip in occasionally. (This is no ! # excuse for committing more platform- and compiler-specific ! # kludges; they are to be avoided if possible!) ! if self.compiler.compiler_type == 'msvc': ! def_file = ext.export_symbol_file ! if def_file is None: ! source_dir = os.path.dirname (sources[0]) ! ext_base = (string.split (ext.name, '.'))[-1] ! def_file = os.path.join (source_dir, "%s.def" % ext_base) ! if not os.path.exists (def_file): ! def_file = None ! ! if def_file is not None: ! extra_args.append ('/DEF:' + def_file) ! else: ! modname = string.split (ext.name, '.')[-1] ! extra_args.append('/export:init%s'%modname) ! ! # The MSVC linker generates unneeded .lib and .exp files, ! # which cannot be suppressed by any linker switches. So ! # make sure they are generated in the temporary build ! # directory. ! implib_file = os.path.join ( ! self.build_temp, ! self.get_ext_libname (ext.name)) ! extra_args.append ('/IMPLIB:' + implib_file) ! self.mkpath (os.path.dirname (implib_file)) ! # if MSVC self.compiler.link_shared_object ( --- 415,421 ---- extra_args = ext.extra_link_args ! # Run any platform/compiler-specific hooks needed between ! # compiling and linking (currently needed only on Windows). ! self.prelink_hook() self.compiler.link_shared_object ( *************** *** 457,460 **** --- 430,482 ---- + # -- Hooks --------------------------------------------------------- + + def precompile_hook (self): + pass + + def prelink_hook (self): + + # XXX this is a kludge! Knowledge of specific compilers or + # platforms really doesn't belong here; in an ideal world, the + # CCompiler interface would provide access to everything in a + # compiler/linker system needs to build Python extensions, and + # we would just do everything nicely and cleanly through that + # interface. However, this is a not an ideal world and the + # CCompiler interface doesn't handle absolutely everything. + # Thus, kludges like this slip in occasionally. (This is no + # excuse for committing more platform- and compiler-specific + # kludges; they are to be avoided if possible!) + if self.compiler.compiler_type == 'msvc': + def_file = ext.export_symbol_file + if def_file is None: + source_dir = os.path.dirname (sources[0]) + ext_base = (string.split (ext.name, '.'))[-1] + def_file = os.path.join (source_dir, "%s.def" % ext_base) + if not os.path.exists (def_file): + def_file = None + + if def_file is not None: + extra_args.append ('/DEF:' + def_file) + else: + modname = string.split (ext.name, '.')[-1] + extra_args.append('/export:init%s'%modname) + + # The MSVC linker generates unneeded .lib and .exp files, + # which cannot be suppressed by any linker switches. So + # make sure they are generated in the temporary build + # directory. + implib_file = os.path.join ( + self.build_temp, + self.get_ext_libname (ext.name)) + extra_args.append ('/IMPLIB:' + implib_file) + self.mkpath (os.path.dirname (implib_file)) + # if MSVC + + # prelink_hook () + + + # -- Name generators ----------------------------------------------- + # (extension names, filenames, whatever) + def get_ext_fullname (self, ext_name): if self.package is None: *************** *** 464,467 **** --- 486,494 ---- def get_ext_filename (self, ext_name): + """Convert the name of an extension (eg. "foo.bar") into the name + of the file from which it will be loaded (eg. "foo/bar.so", or + "foo\bar.pyd"). + """ + from distutils import sysconfig ext_path = string.split (ext_name, '.') From python-dev@python.org Sun Jun 18 01:50:51 2000 From: python-dev@python.org (Vladimir Marangozov) Date: Sun, 18 Jun 2000 02:50:51 +0200 (CEST) Subject: [Python-checkins] CVS: python/dist/src/Modules mmapmodule.c,2.10,2.11 In-Reply-To: <200006172241.PAA02080@slayer.i.sourceforge.net> from "A.M. Kuchling" at Jun 17, 2000 03:41:24 PM Message-ID: <200006180050.CAA07547@python.inrialpes.fr> A.M. Kuchling wrote: > > Update of /cvsroot/python/python/dist/src/Modules > In directory slayer.i.sourceforge.net:/tmp/cvs-serv2060 > > Modified Files: > mmapmodule.c > Log Message: > Fix the size() method to return the size of the file on Unix, not the > size of the mapped area. This seems to be what the Windows version does. > This change requires keeping around the fd of the mapped file. On AIX, the test_mmap fails with errno=EINVAL on the m.flush() method. It works okay without the MS_INVALIDATE flag though, so I'd suggest removing it from msync in the flush and dealloc methods. Also, it would probably be a good idea to allow optional flags for flush, as it's done in new_mmap_object, the default being only MS_SYNC. Given that this module is enabled by default, I think that it needs some more stress-testing in test_mmap.py. I'll try to add a couple of tests shortly. -- Vladimir MARANGOZOV | Vladimir.Marangozov@inrialpes.fr http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252 From python-dev@python.org Sun Jun 18 05:17:40 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 17 Jun 2000 21:17:40 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libmmap.tex,1.1,1.2 Message-ID: <200006180417.VAA24245@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv24238 Modified Files: libmmap.tex Log Message: Make changes and clarifications suggested by Mark Hammond Index: libmmap.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libmmap.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** libmmap.tex 2000/06/17 22:39:05 1.1 --- libmmap.tex 2000/06/18 04:17:38 1.2 *************** *** 20,34 **** \begin{funcdesc}{mmap}{fileno, length \optional{, tagname} } (Windows version) Maps \var{length} bytes from the file specified by ! the file handle \var{fileno}, and returns a mmap object. If you have ! a Python file object, its ! \method{fileno()} method returns the file's handle, which is just an integer. ! \var{tagname}, if specified, is a string giving a tag name for the mapping. XXX what is the purpose of the tag name? \end{funcdesc} ! \begin{funcdesc}{mmap}{file, size \optional{, flags, prot}} (Unix version) Maps \var{length} bytes from the file specified by the ! file handle \var{fileno}, and returns a mmap object. If you have a ! Python file object, its \method{fileno()} method returns the file's ! handle, which is just an integer. \var{flags} specifies the nature of the mapping. --- 20,41 ---- \begin{funcdesc}{mmap}{fileno, length \optional{, tagname} } (Windows version) Maps \var{length} bytes from the file specified by ! the file handle \var{fileno}, and returns a mmap object. If you wish ! to map an existing Python file object, use its \method{fileno()} ! method to obtain the correct value for the \var{fileno} parameter. ! ! \var{tagname}, if specified, is a string giving a tag name for the mapping. ! Windows allows you to have many different mappings against the same ! file. If you specify the name of an existing tag, that tag is opened, ! otherwise a new tag of this name is created. If this parameter is ! None, the mapping is created without a name. Avoiding the use of the ! tag parameter will assist in keeping your code portable between Unix ! and Windows. \end{funcdesc} ! \begin{funcdesc}{mmap}{fileno, size \optional{, flags, prot}} (Unix version) Maps \var{length} bytes from the file specified by the ! file handle \var{fileno}, and returns a mmap object. If you wish to ! map an existing Python file object, use its \method{fileno()} method ! to obtain the correct value for the \var{fileno} parameter. \var{flags} specifies the nature of the mapping. *************** *** 62,67 **** Flushes changes made to the in-memory copy of a file back to disk. Without use of this call there is no guarantee that changes are ! written back before the object is destroyed. If \var{offset} ! and \var{size} are specified, only changes to the given range of bytes will be flushed to disk; otherwise, the whole extent of the mapping is flushed. \end{methoddesc} --- 69,76 ---- Flushes changes made to the in-memory copy of a file back to disk. Without use of this call there is no guarantee that changes are ! written back before the object is destroyed. If \var{offset} and ! \var{size} are specified, only changes to the given range of bytes ! will be flushed to disk; otherwise, the whole extent of the mapping is ! flushed. \end{methoddesc} *************** *** 72,76 **** \begin{methoddesc}{read}{\var{num}} ! Return a string containing up to \var{num} bytes taken from the current file position; the file position is updated to point after the bytes that were returned. --- 81,85 ---- \begin{methoddesc}{read}{\var{num}} ! Return a string containing up to \var{num} bytes starting from the current file position; the file position is updated to point after the bytes that were returned. *************** *** 78,83 **** \begin{methoddesc}{read_byte}{} ! Returns the character at the current file position, and advancing ! the file position by 1. \end{methoddesc} --- 87,92 ---- \begin{methoddesc}{read_byte}{} ! Returns a string of length 1 containing the character at the current ! file position, and advances the file position by 1. \end{methoddesc} *************** *** 114,118 **** \begin{methoddesc}{write_byte}{\var{byte}} ! Write \var{byte} into memory at the current position of the file pointer; the file position is advanced by 1. \end{methoddesc} --- 123,127 ---- \begin{methoddesc}{write_byte}{\var{byte}} ! Write the single-character string \var{byte} into memory at the current position of the file pointer; the file position is advanced by 1. \end{methoddesc} From python-dev@python.org Sun Jun 18 05:25:10 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 17 Jun 2000 21:25:10 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules mmapmodule.c,2.11,2.12 Message-ID: <200006180425.VAA24502@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv24493 Modified Files: mmapmodule.c Log Message: Removed MS_INVALIDATE flags Index: mmapmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/mmapmodule.c,v retrieving revision 2.11 retrieving revision 2.12 diff -C2 -r2.11 -r2.12 *** mmapmodule.c 2000/06/17 22:41:22 2.11 --- mmapmodule.c 2000/06/18 04:25:08 2.12 *************** *** 66,70 **** #ifdef UNIX if (m_obj->data!=NULL) { ! msync(m_obj->data, m_obj->size, MS_SYNC | MS_INVALIDATE); munmap(m_obj->data, m_obj->size); } --- 66,70 ---- #ifdef UNIX if (m_obj->data!=NULL) { ! msync(m_obj->data, m_obj->size, MS_SYNC); munmap(m_obj->data, m_obj->size); } *************** *** 389,393 **** /* XXX flags for msync? */ if (-1 == msync(self->data + offset, size, ! MS_SYNC | MS_INVALIDATE)) { PyErr_SetFromErrno(mmap_module_error); --- 389,393 ---- /* XXX flags for msync? */ if (-1 == msync(self->data + offset, size, ! MS_SYNC)) { PyErr_SetFromErrno(mmap_module_error); From python-dev@python.org Sun Jun 18 05:45:16 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 17 Jun 2000 21:45:16 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules mmapmodule.c,2.12,2.13 Message-ID: <200006180445.VAA25429@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv25421 Modified Files: mmapmodule.c Log Message: Patch from Trent Mick: The seek() method is broken for any 'whence' value (seek from start, current, orend) other than the default. I have a patch that fixes that as well as gets mmap'd files working on Linux64 and Win64. Index: mmapmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/mmapmodule.c,v retrieving revision 2.12 retrieving revision 2.13 diff -C2 -r2.12 -r2.13 *** mmapmodule.c 2000/06/18 04:25:08 2.12 --- mmapmodule.c 2000/06/18 04:45:14 2.13 *************** *** 46,50 **** #ifdef MS_WIN32 HANDLE map_handle; ! HFILE file_handle; char * tagname; #endif --- 46,50 ---- #ifdef MS_WIN32 HANDLE map_handle; ! INT_PTR file_handle; char * tagname; #endif *************** *** 124,128 **** if (!PyArg_ParseTuple(args, ":read_byte")) return NULL; ! if (self->pos >= 0 && self->pos < self->size) { where = self->data + self->pos; value = (char) *(where); --- 124,128 ---- if (!PyArg_ParseTuple(args, ":read_byte")) return NULL; ! if (self->pos < self->size) { where = self->data + self->pos; value = (char) *(where); *************** *** 154,158 **** ++eol; /* we're interested in the position after the newline. */ ! result = PyString_FromStringAndSize(start, (long) (eol - start)); self->pos += (eol - start); return (result); --- 154,158 ---- ++eol; /* we're interested in the position after the newline. */ ! result = PyString_FromStringAndSize(start, (eol - start)); self->pos += (eol - start); return (result); *************** *** 183,192 **** PyObject *args) { ! long start = self->pos; char * needle; int len; CHECK_VALID(NULL); ! if (!PyArg_ParseTuple (args, "s#|l", &needle, &len, &start)) { return NULL; } else { --- 183,192 ---- PyObject *args) { ! int start = self->pos; char * needle; int len; CHECK_VALID(NULL); ! if (!PyArg_ParseTuple (args, "s#|i", &needle, &len, &start)) { return NULL; } else { *************** *** 201,206 **** if (!*n) { return Py_BuildValue ( ! "l", ! (long) (p - (self->data + start))); } p++; --- 201,206 ---- if (!*n) { return Py_BuildValue ( ! "i", ! (int) (p - (self->data + start))); } p++; *************** *** 256,260 **** #ifdef MS_WIN32 ! if (self->file_handle != (HFILE) 0xFFFFFFFF) { return (Py_BuildValue ( "l", --- 256,260 ---- #ifdef MS_WIN32 ! if (self->file_handle != (INT_PTR) -1) { return (Py_BuildValue ( "l", *************** *** 402,422 **** mmap_seek_method (mmap_object * self, PyObject * args) { ! /* ptrdiff_t dist; */ ! long dist; int how=0; CHECK_VALID(NULL); ! if (!PyArg_ParseTuple (args, "l|i", &dist, &how)) { return(NULL); } else { ! unsigned long where; switch (how) { ! case 0: where = dist; break; ! case 1: where = self->pos + dist; break; ! case 2: ! where = self->size - dist; break; default: --- 402,427 ---- mmap_seek_method (mmap_object * self, PyObject * args) { ! int dist; int how=0; CHECK_VALID(NULL); ! if (!PyArg_ParseTuple (args, "i|i", &dist, &how)) { return(NULL); } else { ! size_t where; switch (how) { ! case 0: /* relative to start */ ! if (dist < 0) ! goto onoutofrange; where = dist; break; ! case 1: /* relative to current position */ ! if ((int)self->pos + dist < 0) ! goto onoutofrange; where = self->pos + dist; break; ! case 2: /* relative to end */ ! if ((int)self->size + dist < 0) ! goto onoutofrange; ! where = self->size + dist; break; default: *************** *** 425,438 **** return NULL; } ! if ((where >= 0) && (where < (self->size))) { ! self->pos = where; ! Py_INCREF (Py_None); ! return (Py_None); ! } else { ! PyErr_SetString (PyExc_ValueError, ! "seek out of range"); ! return NULL; ! } } } --- 430,443 ---- return NULL; } ! if (where > self->size) ! goto onoutofrange; ! self->pos = where; ! Py_INCREF (Py_None); ! return (Py_None); } + + onoutofrange: + PyErr_SetString (PyExc_ValueError, "seek out of range"); + return NULL; } *************** *** 705,708 **** --- 710,770 ---- }; + + /* extract the map size from the given PyObject + + The map size is restricted to [0, INT_MAX] because this is the current + Python limitation on object sizes. Although the mmap object *could* handle + a larger map size, there is no point because all the useful operations + (len(), slicing(), sequence indexing) are limited by a C int. + + Returns -1 on error, with an apprpriate Python exception raised. On + success, the map size is returned. */ + static int + _GetMapSize(o) + PyObject *o; + { + if (PyInt_Check(o)) { + long i = PyInt_AsLong(o); + if (PyErr_Occurred()) + return -1; + if (i < 0) + goto onnegoverflow; + if (i > INT_MAX) + goto onposoverflow; + return (int)i; + } + else if (PyLong_Check(o)) { + long i = PyLong_AsLong(o); + if (PyErr_Occurred()) { + /* yes negative overflow is mistaken for positive overflow + but not worth the trouble to check sign of 'i' */ + if (PyErr_ExceptionMatches(PyExc_OverflowError)) + goto onposoverflow; + else + return -1; + } + if (i < 0) + goto onnegoverflow; + if (i > INT_MAX) + goto onposoverflow; + return (int)i; + } + else { + PyErr_SetString(PyExc_TypeError, + "map size must be an integral value"); + return -1; + } + + onnegoverflow: + PyErr_SetString(PyExc_OverflowError, + "memory mapped size must be positive"); + return -1; + + onposoverflow: + PyErr_SetString(PyExc_OverflowError, + "memory mapped size is too large (limited by C int)"); + return -1; + } + #ifdef UNIX static PyObject * *************** *** 710,714 **** { mmap_object * m_obj; ! unsigned long map_size; int fd, flags = MAP_SHARED, prot = PROT_WRITE | PROT_READ; char * filename; --- 772,777 ---- { mmap_object * m_obj; ! PyObject *map_size_obj = NULL; ! int map_size; int fd, flags = MAP_SHARED, prot = PROT_WRITE | PROT_READ; char * filename; *************** *** 717,725 **** if (!PyArg_ParseTupleAndKeywords(args, kwdict, ! "il|ii", keywords, ! &fd, &map_size, &flags, &prot) ) return NULL; ! m_obj = PyObject_New (mmap_object, &mmap_object_type); if (m_obj == NULL) {return NULL;} --- 780,791 ---- if (!PyArg_ParseTupleAndKeywords(args, kwdict, ! "iO|ii", keywords, ! &fd, &map_size_obj, &flags, &prot) ) return NULL; ! map_size = _GetMapSize(map_size_obj); ! if (map_size < 0) ! return NULL; ! m_obj = PyObject_New (mmap_object, &mmap_object_type); if (m_obj == NULL) {return NULL;} *************** *** 745,754 **** { mmap_object * m_obj; ! unsigned long map_size; char * tagname = ""; DWORD dwErr = 0; int fileno; ! HFILE fh = 0; /* Patch the object type */ --- 811,821 ---- { mmap_object * m_obj; ! PyObject *map_size_obj = NULL; ! int map_size; char * tagname = ""; DWORD dwErr = 0; int fileno; ! INT_PTR fh = 0; /* Patch the object type */ *************** *** 756,766 **** if (!PyArg_ParseTuple(args, ! "il|z", &fileno, ! &map_size, &tagname) ) return NULL; /* if an actual filename has been specified */ if (fileno != 0) { --- 823,837 ---- if (!PyArg_ParseTuple(args, ! "iO|z", &fileno, ! &map_size_obj, &tagname) ) return NULL; + map_size = _GetMapSize(map_size_obj); + if (map_size < 0) + return NULL; + /* if an actual filename has been specified */ if (fileno != 0) { *************** *** 785,789 **** } else { ! m_obj->file_handle = (HFILE) 0xFFFFFFFF; m_obj->size = map_size; } --- 856,860 ---- } else { ! m_obj->file_handle = (INT_PTR) -1; m_obj->size = map_size; } From python-dev@python.org Sun Jun 18 05:47:10 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 17 Jun 2000 21:47:10 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_mmap,1.1,1.2 Message-ID: <200006180447.VAA25478@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv25459/output Modified Files: test_mmap Log Message: Additional tests for seek() method, written by Trent Mick Index: test_mmap =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_mmap,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 Binary files /tmp/cvsjNOmbW and /tmp/cvsWRnnXH differ From python-dev@python.org Sun Jun 18 05:47:10 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 17 Jun 2000 21:47:10 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_mmap.py,1.4,1.5 Message-ID: <200006180447.VAA25474@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv25459 Modified Files: test_mmap.py Log Message: Additional tests for seek() method, written by Trent Mick Index: test_mmap.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_mmap.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** test_mmap.py 2000/04/05 14:17:11 1.4 --- test_mmap.py 2000/06/18 04:47:08 1.5 *************** *** 59,63 **** assert start == PAGESIZE assert end == PAGESIZE + 6 ! m.close() os.unlink("foo") --- 59,98 ---- assert start == PAGESIZE assert end == PAGESIZE + 6 ! ! # test seeking around (try to overflow the seek implementation) ! m.seek(0,0) ! print ' Seek to zeroth byte' ! assert m.tell() == 0 ! m.seek(42,1) ! print ' Seek to 42nd byte' ! assert m.tell() == 42 ! m.seek(0,2) ! print ' Seek to last byte' ! assert m.tell() == len(m) ! ! print ' Try to seek to negative position...' ! try: ! m.seek(-1) ! except ValueError: ! pass ! else: ! assert 0, 'expected a ValueError but did not get it' ! ! print ' Try to seek beyond end of mmap...' ! try: ! m.seek(1,2) ! except ValueError: ! pass ! else: ! assert 0, 'expected a ValueError but did not get it' ! ! print ' Try to seek to negative position...' ! try: ! m.seek(-len(m)-1,2) ! except ValueError: ! pass ! else: ! assert 0, 'expected a ValueError but did not get it' ! m.close() os.unlink("foo") From python-dev@python.org Sun Jun 18 06:21:23 2000 From: python-dev@python.org (Fred L. Drake) Date: Sat, 17 Jun 2000 22:21:23 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/api api.tex,1.67,1.68 Message-ID: <200006180521.WAA32625@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/api In directory slayer.i.sourceforge.net:/tmp/cvs-serv32618/Doc/api Modified Files: api.tex Log Message: Markup consistency nits. Index: api.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/api.tex,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -r1.67 -r1.68 *** api.tex 2000/06/16 21:04:15 1.67 --- api.tex 2000/06/18 05:21:21 1.68 *************** *** 1176,1184 **** \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyImport_ImportFrozenModule}{char *} ! Load a frozen module. Return \code{1} for success, \code{0} if the ! module is not found, and \code{-1} with an exception set if the ! initialization failed. To access the imported module on a successful ! load, use \cfunction{PyImport_ImportModule()}. (Note the misnomer --- this function would reload the module if it was already imported.) --- 1176,1184 ---- \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyImport_ImportFrozenModule}{char *name} ! Load a frozen module named \var{name}. Return \code{1} for success, ! \code{0} if the module is not found, and \code{-1} with an exception ! set if the initialization failed. To access the imported module on a ! successful load, use \cfunction{PyImport_ImportModule()}. (Note the misnomer --- this function would reload the module if it was already imported.) *************** *** 2058,2062 **** \end{cfuncdesc} ! \begin{cfuncdesc}{Py_UNICODE *}{PyUnicode_AsUnicode}{PyObject *unicode} Return a read-only pointer to the Unicode object's internal \ctype{Py_UNICODE} buffer. --- 2058,2062 ---- \end{cfuncdesc} ! \begin{cfuncdesc}{Py_UNICODE*}{PyUnicode_AsUnicode}{PyObject *unicode} Return a read-only pointer to the Unicode object's internal \ctype{Py_UNICODE} buffer. *************** *** 2103,2107 **** wchar_t *w, int size} - Copies the Unicode Object contents into the \ctype{whcar_t} buffer \var{w}. At most \var{size} \ctype{whcar_t} characters are copied. --- 2103,2106 ---- *************** *** 2139,2143 **** const char *encoding, const char *errors} - Create a Unicode object by decoding \var{size} bytes of the encoded string \var{s}. \var{encoding} and \var{errors} have the same meaning --- 2138,2141 ---- *************** *** 2152,2156 **** const char *encoding, const char *errors} - Encodes the \ctype{Py_UNICODE} buffer of the given size and returns a Python string object. \var{encoding} and \var{errors} have the same --- 2150,2153 ---- *************** *** 2164,2168 **** const char *encoding, const char *errors} - Encodes a Unicode object and returns the result as Python string object. \var{encoding} and \var{errors} have the same meaning as the --- 2161,2164 ---- *************** *** 2179,2183 **** int size, const char *errors} - Creates a Unicode object by decoding \var{size} bytes of the UTF-8 encoded string \var{s}. Returns \NULL{} in case an exception was --- 2175,2178 ---- *************** *** 2188,2192 **** int size, const char *errors} - Encodes the \ctype{Py_UNICODE} buffer of the given size using UTF-8 and returns a Python string object. Returns \NULL{} in case an --- 2183,2186 ---- *************** *** 2195,2199 **** \begin{cfuncdesc}{PyObject*}{PyUnicode_AsUTF8String}{PyObject *unicode} - Encodes a Unicode objects using UTF-8 and returns the result as Python string object. Error handling is ``strict''. Returns --- 2189,2192 ---- *************** *** 2209,2213 **** const char *errors, int *byteorder} - Decodes \var{length} bytes from a UTF-16 encoded buffer string and returns the corresponding Unicode object. --- 2202,2205 ---- *************** *** 2239,2243 **** const char *errors, int byteorder} - Returns a Python string object holding the UTF-16 encoded value of the Unicode data in \var{s}. --- 2231,2234 ---- *************** *** 2277,2281 **** int size, const char *errors} - Creates a Unicode object by decoding \var{size} bytes of the Unicode-Esacpe encoded string \var{s}. Returns \NULL{} in case an exception was --- 2268,2271 ---- *************** *** 2286,2290 **** int size, const char *errors} - Encodes the \ctype{Py_UNICODE} buffer of the given size using Unicode-Escape and returns a Python string object. Returns \NULL{} in case an --- 2276,2279 ---- *************** *** 2293,2297 **** \begin{cfuncdesc}{PyObject*}{PyUnicode_AsUnicodeEscapeString}{PyObject *unicode} - Encodes a Unicode objects using Unicode-Escape and returns the result as Python string object. Error handling is ``strict''. Returns --- 2282,2285 ---- *************** *** 2306,2310 **** int size, const char *errors} - Creates a Unicode object by decoding \var{size} bytes of the Raw-Unicode-Esacpe encoded string \var{s}. Returns \NULL{} in case an exception was --- 2294,2297 ---- *************** *** 2315,2319 **** int size, const char *errors} - Encodes the \ctype{Py_UNICODE} buffer of the given size using Raw-Unicode-Escape and returns a Python string object. Returns \NULL{} in case an --- 2302,2305 ---- *************** *** 2322,2326 **** \begin{cfuncdesc}{PyObject*}{PyUnicode_AsRawUnicodeEscapeString}{PyObject *unicode} - Encodes a Unicode objects using Raw-Unicode-Escape and returns the result as Python string object. Error handling is ``strict''. Returns --- 2308,2311 ---- *************** *** 2336,2342 **** \begin{cfuncdesc}{PyObject*}{PyUnicode_DecodeLatin1}{const char *s, ! int size, ! const char *errors} ! Creates a Unicode object by decoding \var{size} bytes of the Latin-1 encoded string \var{s}. Returns \NULL{} in case an exception was --- 2321,2326 ---- \begin{cfuncdesc}{PyObject*}{PyUnicode_DecodeLatin1}{const char *s, ! int size, ! const char *errors} Creates a Unicode object by decoding \var{size} bytes of the Latin-1 encoded string \var{s}. Returns \NULL{} in case an exception was *************** *** 2345,2351 **** \begin{cfuncdesc}{PyObject*}{PyUnicode_EncodeLatin1}{const Py_UNICODE *s, ! int size, ! const char *errors} ! Encodes the \ctype{Py_UNICODE} buffer of the given size using Latin-1 and returns a Python string object. Returns \NULL{} in case an --- 2329,2334 ---- \begin{cfuncdesc}{PyObject*}{PyUnicode_EncodeLatin1}{const Py_UNICODE *s, ! int size, ! const char *errors} Encodes the \ctype{Py_UNICODE} buffer of the given size using Latin-1 and returns a Python string object. Returns \NULL{} in case an *************** *** 2354,2358 **** \begin{cfuncdesc}{PyObject*}{PyUnicode_AsLatin1String}{PyObject *unicode} - Encodes a Unicode objects using Latin-1 and returns the result as Python string object. Error handling is ``strict''. Returns --- 2337,2340 ---- *************** *** 2362,2390 **** % --- ASCII Codecs ------------------------------------------------------- ! These are the ASCII codec APIs: - Only 7-bit ASCII data is excepted. All other codes generate errors. - \begin{cfuncdesc}{PyObject*}{PyUnicode_DecodeASCII}{const char *s, ! int size, ! const char *errors} ! ! Creates a Unicode object by decoding \var{size} bytes of the ASCII ! encoded string \var{s}. Returns \NULL{} in case an exception was ! raised by the codec. \end{cfuncdesc} \begin{cfuncdesc}{PyObject*}{PyUnicode_EncodeASCII}{const Py_UNICODE *s, ! int size, ! const char *errors} ! ! Encodes the \ctype{Py_UNICODE} buffer of the given size using ASCII ! and returns a Python string object. Returns \NULL{} in case an ! exception was raised by the codec. \end{cfuncdesc} \begin{cfuncdesc}{PyObject*}{PyUnicode_AsASCIIString}{PyObject *unicode} ! ! Encodes a Unicode objects using ASCII and returns the result as Python string object. Error handling is ``strict''. Returns \NULL{} in case an exception was raised by the codec. --- 2344,2368 ---- % --- ASCII Codecs ------------------------------------------------------- ! These are the \ASCII{} codec APIs. Only 7-bit \ASCII{} data is ! accepted. All other codes generate errors. \begin{cfuncdesc}{PyObject*}{PyUnicode_DecodeASCII}{const char *s, ! int size, ! const char *errors} ! Creates a Unicode object by decoding \var{size} bytes of the ! \ASCII{} encoded string \var{s}. Returns \NULL{} in case an exception ! was raised by the codec. \end{cfuncdesc} \begin{cfuncdesc}{PyObject*}{PyUnicode_EncodeASCII}{const Py_UNICODE *s, ! int size, ! const char *errors} ! Encodes the \ctype{Py_UNICODE} buffer of the given size using ! \ASCII{} and returns a Python string object. Returns \NULL{} in case ! an exception was raised by the codec. \end{cfuncdesc} \begin{cfuncdesc}{PyObject*}{PyUnicode_AsASCIIString}{PyObject *unicode} ! Encodes a Unicode objects using \ASCII{} and returns the result as Python string object. Error handling is ``strict''. Returns \NULL{} in case an exception was raised by the codec. *************** *** 2421,2425 **** PyObject *mapping, const char *errors} - Creates a Unicode object by decoding \var{size} bytes of the encoded string \var{s} using the given \var{mapping} object. Returns \NULL{} --- 2399,2402 ---- *************** *** 2431,2435 **** PyObject *mapping, const char *errors} - Encodes the \ctype{Py_UNICODE} buffer of the given size using the given \var{mapping} object and returns a Python string object. --- 2408,2411 ---- *************** *** 2439,2443 **** \begin{cfuncdesc}{PyObject*}{PyUnicode_AsCharmapString}{PyObject *unicode, PyObject *mapping} - Encodes a Unicode objects using the given \var{mapping} object and returns the result as Python string object. Error handling is --- 2415,2418 ---- *************** *** 2452,2459 **** PyObject *table, const char *errors} - Translates a \ctype{Py_UNICODE} buffer of the given length by applying a character mapping \var{table} to it and returns the resulting ! Unicode object. The \var{mapping} table must map Unicode ordinal integers to Unicode --- 2427,2434 ---- PyObject *table, const char *errors} Translates a \ctype{Py_UNICODE} buffer of the given length by applying a character mapping \var{table} to it and returns the resulting ! Unicode object. Returns \NULL{} when an exception was raised by the ! codec. The \var{mapping} table must map Unicode ordinal integers to Unicode *************** *** 2463,2486 **** e.g. dictionaries or sequences. Unmapped character ordinals (ones which cause a LookupError) are left untouched and are copied as-is. - - Returns \NULL{} in case an exception was raised by the codec. \end{cfuncdesc} % --- MBCS codecs for Windows -------------------------------------------- ! These are the MBCS codec APIs. They are currently only available Windows and use the Win32 MBCS converters to implement the ! conversions. ! ! Note that MBCS (or DBCS) is a class of encodings, not just one. The ! target encoding is defined by the user settings on the machine running ! the codec. \begin{cfuncdesc}{PyObject*}{PyUnicode_DecodeMBCS}{const char *s, int size, const char *errors} - Creates a Unicode object by decoding \var{size} bytes of the MBCS ! encoded string \var{s}. Returns \NULL{} in case an exception was raised by the codec. \end{cfuncdesc} --- 2438,2456 ---- e.g. dictionaries or sequences. Unmapped character ordinals (ones which cause a LookupError) are left untouched and are copied as-is. \end{cfuncdesc} % --- MBCS codecs for Windows -------------------------------------------- ! These are the MBCS codec APIs. They are currently only available on Windows and use the Win32 MBCS converters to implement the ! conversions. Note that MBCS (or DBCS) is a class of encodings, not ! just one. The target encoding is defined by the user settings on the ! machine running the codec. \begin{cfuncdesc}{PyObject*}{PyUnicode_DecodeMBCS}{const char *s, int size, const char *errors} Creates a Unicode object by decoding \var{size} bytes of the MBCS ! encoded string \var{s}. Returns \NULL{} in case an exception was raised by the codec. \end{cfuncdesc} *************** *** 2489,2493 **** int size, const char *errors} - Encodes the \ctype{Py_UNICODE} buffer of the given size using MBCS and returns a Python string object. Returns \NULL{} in case an --- 2459,2462 ---- *************** *** 2496,2503 **** \begin{cfuncdesc}{PyObject*}{PyUnicode_AsMBCSString}{PyObject *unicode} - Encodes a Unicode objects using MBCS and returns the result as Python ! string object. Error handling is ``strict''. Returns ! \NULL{} in case an exception was raised by the codec. \end{cfuncdesc} --- 2465,2471 ---- \begin{cfuncdesc}{PyObject*}{PyUnicode_AsMBCSString}{PyObject *unicode} Encodes a Unicode objects using MBCS and returns the result as Python ! string object. Error handling is ``strict''. Returns \NULL{} in case ! an exception was raised by the codec. \end{cfuncdesc} *************** *** 2514,2518 **** \begin{cfuncdesc}{PyObject*}{PyUnicode_Concat}{PyObject *left, PyObject *right} - Concat two strings giving a new Unicode string. \end{cfuncdesc} --- 2482,2485 ---- *************** *** 2521,2525 **** PyObject *sep, int maxsplit} - Split a string giving a list of Unicode strings. --- 2488,2491 ---- *************** *** 2534,2542 **** \begin{cfuncdesc}{PyObject*}{PyUnicode_Splitlines}{PyObject *s, int maxsplit} ! ! Dito, but split at line breaks. ! ! CRLF is considered to be one line break. Line breaks are not ! included in the resulting list. \end{cfuncdesc} --- 2500,2506 ---- \begin{cfuncdesc}{PyObject*}{PyUnicode_Splitlines}{PyObject *s, int maxsplit} ! Split a Unicode string at line breaks, returning a list of Unicode ! strings. CRLF is considered to be one line break. The Line break ! characters are not included in the resulting strings. \end{cfuncdesc} *************** *** 2544,2548 **** PyObject *table, const char *errors} - Translate a string by applying a character mapping table to it and return the resulting Unicode object. --- 2508,2511 ---- *************** *** 2557,2566 **** \var{errors} has the usual meaning for codecs. It may be \NULL{} which indicates to use the default error handling. - \end{cfuncdesc} \begin{cfuncdesc}{PyObject*}{PyUnicode_Join}{PyObject *separator, PyObject *seq} - Join a sequence of strings using the given separator and return the resulting Unicode string. --- 2520,2527 ---- *************** *** 2572,2576 **** int end, int direction} - Return 1 if \var{substr} matches \var{str}[\var{start}:\var{end}] at the given tail end (\var{direction} == -1 means to do a prefix match, --- 2533,2536 ---- *************** *** 2583,2587 **** int end, int direction} - Return the first position of \var{substr} in \var{str}[\var{start}:\var{end}] using the given \var{direction} --- 2543,2546 ---- *************** *** 2594,2598 **** int start, int end} - Count the number of occurrences of \var{substr} in \var{str}[\var{start}:\var{end}] --- 2553,2556 ---- *************** *** 2603,2615 **** PyObject *replstr, int maxcount} - Replace at most \var{maxcount} occurrences of \var{substr} in \var{str} with \var{replstr} and return the resulting Unicode object. \var{maxcount} == -1 means: replace all occurrences. \end{cfuncdesc} - - \begin{cfuncdesc}{int}{PyUnicode_Compare}{PyObject *left, - PyObject *right} Compare two strings and return -1, 0, 1 for less than, equal, greater than resp. --- 2561,2570 ---- PyObject *replstr, int maxcount} Replace at most \var{maxcount} occurrences of \var{substr} in \var{str} with \var{replstr} and return the resulting Unicode object. \var{maxcount} == -1 means: replace all occurrences. \end{cfuncdesc} + \begin{cfuncdesc}{int}{PyUnicode_Compare}{PyObject *left, PyObject *right} Compare two strings and return -1, 0, 1 for less than, equal, greater than resp. *************** *** 2618,2633 **** \begin{cfuncdesc}{PyObject*}{PyUnicode_Format}{PyObject *format, PyObject *args} ! Returns a new string object from \var{format} and \var{args}. Analogous ! to \code{\var{format} \% \var{args}}. The \var{args} argument must be ! a tuple. \end{cfuncdesc} \begin{cfuncdesc}{int}{PyUnicode_Contains}{PyObject *container, PyObject *element} - Checks whether \var{element} is contained in \var{container} and ! returns 1/0 accordingly. ! \var{element} has to coerce to an one element Unicode string. -1 is returned in case of an error. \end{cfuncdesc} --- 2573,2587 ---- \begin{cfuncdesc}{PyObject*}{PyUnicode_Format}{PyObject *format, PyObject *args} ! Returns a new string object from \var{format} and \var{args}; this is ! analogous to \code{\var{format} \%\ \var{args}}. The ! \var{args} argument must be a tuple. \end{cfuncdesc} \begin{cfuncdesc}{int}{PyUnicode_Contains}{PyObject *container, PyObject *element} Checks whether \var{element} is contained in \var{container} and ! returns true or false accordingly. ! \var{element} has to coerce to a one element Unicode string. \code{-1} is returned in case of an error. \end{cfuncdesc} *************** *** 2971,2975 **** PyObject *val} Inserts \var{value} into the dictionary using \var{key} ! as a key. \var{key} should be a \ctype{char *}. The key object is created using \code{PyString_FromString(\var{key})}. \ttindex{PyString_FromString()} --- 2925,2929 ---- PyObject *val} Inserts \var{value} into the dictionary using \var{key} ! as a key. \var{key} should be a \ctype{char*}. The key object is created using \code{PyString_FromString(\var{key})}. \ttindex{PyString_FromString()} *************** *** 3448,3452 **** \begin{cfuncdesc}{PyObject*}{PyCObject_FromVoidPtr}{void* cobj, void (*destr)(void *)} ! Creates a \ctype{PyCObject} from the \code{void *} \var{cobj}. The \var{destr} function will be called when the object is reclaimed, unless it is \NULL. --- 3402,3406 ---- \begin{cfuncdesc}{PyObject*}{PyCObject_FromVoidPtr}{void* cobj, void (*destr)(void *)} ! Creates a \ctype{PyCObject} from the \code{void *}\var{cobj}. The \var{destr} function will be called when the object is reclaimed, unless it is \NULL. From python-dev@python.org Sun Jun 18 15:51:24 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sun, 18 Jun 2000 07:51:24 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules mmapmodule.c,2.13,2.14 Message-ID: <200006181451.HAA07070@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv7045 Modified Files: mmapmodule.c Log Message: Support resizing the mapping depending on whether HAVE_MREMAP is defined Remove two unused variables Index: mmapmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/mmapmodule.c,v retrieving revision 2.13 retrieving revision 2.14 diff -C2 -r2.13 -r2.14 *** mmapmodule.c 2000/06/18 04:45:14 2.13 --- mmapmodule.c 2000/06/18 14:51:21 2.14 *************** *** 335,339 **** #ifdef UNIX ! #ifndef MREMAP_MAYMOVE } else { PyErr_SetString(PyExc_SystemError, --- 335,339 ---- #ifdef UNIX ! #ifndef HAVE_MREMAP } else { PyErr_SetString(PyExc_SystemError, *************** *** 344,348 **** --- 344,352 ---- void *newmap; + #ifdef MREMAP_MAYMOVE newmap = mremap(self->data, self->size, new_size, MREMAP_MAYMOVE); + #else + newmap = mremap(self->data, self->size, new_size, 0); + #endif if (newmap == (void *)-1) { *************** *** 354,358 **** Py_INCREF(Py_None); return Py_None; ! #endif /* MREMAP_MAYMOVE */ #endif /* UNIX */ } --- 358,362 ---- Py_INCREF(Py_None); return Py_None; ! #endif /* HAVE_MREMAP */ #endif /* UNIX */ } *************** *** 775,780 **** int map_size; int fd, flags = MAP_SHARED, prot = PROT_WRITE | PROT_READ; - char * filename; - int namelen; char *keywords[] = {"file", "size", "flags", "prot", NULL}; --- 779,782 ---- From python-dev@python.org Sun Jun 18 15:54:16 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sun, 18 Jun 2000 07:54:16 -0700 Subject: [Python-checkins] CVS: python/dist/src configure.in,1.124,1.125 Message-ID: <200006181454.HAA07218@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv7191 Modified Files: configure.in Log Message: Check for existence of mremap() Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.124 retrieving revision 1.125 diff -C2 -r1.124 -r1.125 *** configure.in 2000/05/26 12:22:54 1.124 --- configure.in 2000/06/18 14:54:13 1.125 *************** *** 764,768 **** flock fork fsync fdatasync fpathconf ftime ftruncate \ getgroups getlogin getpeername getpgrp getpid getpwent gettimeofday getwd \ ! kill link lstat mkfifo mktime nice pathconf pause plock pthread_init \ putenv readlink \ select setgid setlocale setuid setsid setpgid setpgrp setvbuf \ --- 764,769 ---- flock fork fsync fdatasync fpathconf ftime ftruncate \ getgroups getlogin getpeername getpgrp getpid getpwent gettimeofday getwd \ ! kill link lstat mkfifo mktime mremap \ ! nice pathconf pause plock pthread_init \ putenv readlink \ select setgid setlocale setuid setsid setpgid setpgrp setvbuf \ From python-dev@python.org Sun Jun 18 16:07:42 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sun, 18 Jun 2000 08:07:42 -0700 Subject: [Python-checkins] CVS: python/dist/src configure,1.116,1.117 config.h.in,2.55,2.56 Message-ID: <200006181507.IAA13927@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv13868 Modified Files: configure config.h.in Log Message: Regenerated autoconf files. There's an extra change to config.h.in beyond the mremap() change I made; did someone modify configure.in previously without recreating these files? Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.116 retrieving revision 1.117 diff -C2 -r1.116 -r1.117 *** configure 2000/05/26 12:22:54 1.116 --- configure 2000/06/18 15:07:39 1.117 *************** *** 1,5 **** #! /bin/sh ! # From configure.in Revision: 1.123 # Guess values for system-dependent variables and create Makefiles. --- 1,5 ---- #! /bin/sh ! # From configure.in Revision: 1.125 [...1463 lines suppressed...] echo $ac_n "checking for socklen_t""... $ac_c" 1>&6 ! echo "configure:5326: checking for socklen_t" >&5 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 < --- 5324,5333 ---- EOF echo $ac_n "checking for socklen_t""... $ac_c" 1>&6 ! echo "configure:5327: checking for socklen_t" >&5 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 < Index: config.h.in =================================================================== RCS file: /cvsroot/python/python/dist/src/config.h.in,v retrieving revision 2.55 retrieving revision 2.56 diff -C2 -r2.55 -r2.56 *** config.h.in 2000/05/11 18:41:31 2.55 --- config.h.in 2000/06/18 15:07:40 2.56 *************** *** 361,364 **** --- 361,367 ---- #undef HAVE_MKTIME + /* Define if you have the mremap function. */ + #undef HAVE_MREMAP + /* Define if you have the nice function. */ #undef HAVE_NICE *************** *** 528,531 **** --- 531,537 ---- /* Define if you have the header file. */ #undef HAVE_SYS_SELECT_H + + /* Define if you have the header file. */ + #undef HAVE_SYS_SOCKET_H /* Define if you have the header file. */ From python-dev@python.org Sun Jun 18 16:45:58 2000 From: python-dev@python.org (Greg Ward) Date: Sun, 18 Jun 2000 08:45:58 -0700 Subject: [Python-checkins] CVS: distutils/distutils util.py,1.35,1.36 Message-ID: <200006181545.IAA15436@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv15428 Modified Files: util.py Log Message: 'get_platform()' now just returns 'sys.platform' on all platforms. Index: util.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/util.py,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -r1.35 -r1.36 *** util.py 2000/06/17 02:16:46 1.35 --- util.py 2000/06/18 15:45:55 1.36 *************** *** 45,60 **** def get_platform (): """Return a string (suitable for tacking onto directory names) that ! identifies the current platform. Under Unix, identifies both the OS ! and hardware architecture, e.g. "linux-i586", "solaris-sparc", ! "irix-mips". For Windows and Mac OS, just returns 'sys.platform' -- ! i.e. "???" or "???".""" ! ! if os.name == 'posix': ! (OS, _, rel, _, arch) = os.uname() ! return "%s%c-%s" % (string.lower (OS), rel[0], string.lower (arch)) ! else: ! return sys.platform ! ! # get_platform() --- 45,52 ---- def get_platform (): """Return a string (suitable for tacking onto directory names) that ! identifies the current platform. Currently, this is just ! 'sys.platform'. ! """ ! return sys.platform From python-dev@python.org Sun Jun 18 19:43:16 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sun, 18 Jun 2000 11:43:16 -0700 Subject: [Python-checkins] CVS: python/dist/src/Include abstract.h,2.17,2.18 Message-ID: <200006181843.LAA10009@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Include In directory slayer.i.sourceforge.net:/tmp/cvs-serv9974/Include Modified Files: abstract.h Log Message: Patch from /F: this patch introduces PySequence_Fast and PySequence_Fast_GET_ITEM, and modifies the list.extend method to accept any kind of sequence. Index: abstract.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/abstract.h,v retrieving revision 2.17 retrieving revision 2.18 diff -C2 -r2.17 -r2.18 *** abstract.h 2000/03/10 22:35:06 2.17 --- abstract.h 2000/06/18 18:43:13 2.18 *************** *** 732,736 **** Return the ith element of o, or NULL on failure. This is the equivalent of the Python expression: o[i]. - */ --- 732,735 ---- *************** *** 784,787 **** --- 783,787 ---- */ + DL_IMPORT(PyObject *) PySequence_List Py_PROTO((PyObject *o)); *************** *** 789,792 **** --- 789,811 ---- Returns the sequence, o, as a list on success, and NULL on failure. This is equivalent to the Python expression: list(o) + */ + + DL_IMPORT(PyObject *) PySequence_Fast Py_PROTO((PyObject *o, const char* m)); + + /* + Returns the sequence, o, as a tuple, unless it's already a + tuple or list. Use PySequence_Fast_GET_ITEM to access the + members of this list. + + Returns NULL on failure. If the object is not a sequence, + raises a TypeError exception with m as the message text. + */ + + #define PySequence_Fast_GET_ITEM(o, i)\ + (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i)) + + /* + Return the ith element of o, assuming that o was returned by + PySequence_Fast, and that i is within bounds. */ From python-dev@python.org Sun Jun 18 19:43:16 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sun, 18 Jun 2000 11:43:16 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects abstract.c,2.34,2.35 listobject.c,2.72,2.73 Message-ID: <200006181843.LAA10014@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv9974/Objects Modified Files: abstract.c listobject.c Log Message: Patch from /F: this patch introduces PySequence_Fast and PySequence_Fast_GET_ITEM, and modifies the list.extend method to accept any kind of sequence. Index: abstract.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/abstract.c,v retrieving revision 2.34 retrieving revision 2.35 diff -C2 -r2.34 -r2.35 *** abstract.c 2000/04/05 20:11:20 2.34 --- abstract.c 2000/06/18 18:43:14 2.35 *************** *** 1208,1211 **** --- 1208,1231 ---- } + PyObject * + PySequence_Fast(v, m) + PyObject *v; + const char* m; + { + if (v == NULL) + return null_error(); + + if (PyList_Check(v) || PyTuple_Check(v)) { + Py_INCREF(v); + return v; + } + + v = PySequence_Tuple(v); + if (v == NULL && PyErr_ExceptionMatches(PyExc_TypeError)) + return type_error(m); + + return v; + } + int PySequence_Count(s, o) Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.72 retrieving revision 2.73 diff -C2 -r2.72 -r2.73 *** listobject.c 2000/06/15 14:50:20 2.72 --- listobject.c 2000/06/18 18:43:14 2.73 *************** *** 628,641 **** return NULL; ! if (!PyList_Check(b)) { ! PyErr_SetString(PyExc_TypeError, ! "list.extend() argument must be a list"); return NULL; ! } ! if (PyList_GET_SIZE(b) == 0) { /* short circuit when b is empty */ ! Py_INCREF(Py_None); ! return Py_None; ! } if (self == (PyListObject*)b) { /* as in list_ass_slice() we must special case the --- 628,639 ---- return NULL; ! b = PySequence_Fast(b, "list.extend() argument must be a sequence"); ! if (!b) return NULL; ! ! if (PyObject_Length(b) == 0) /* short circuit when b is empty */ ! goto ok; ! if (self == (PyListObject*)b) { /* as in list_ass_slice() we must special case the *************** *** 645,648 **** --- 643,647 ---- * list_slice() the way list_ass_slice() does. */ + Py_DECREF(b); b = PyList_New(selflen); if (!b) *************** *** 654,684 **** } } ! else ! /* we want b to have the same refcount semantics for the ! * Py_XDECREF() in the finally clause regardless of which ! * branch in the above conditional we took. ! */ ! Py_INCREF(b); - blen = PyList_GET_SIZE(b); /* resize a using idiom */ items = self->ob_item; NRESIZE(items, PyObject*, selflen + blen); ! if (items == NULL ) { PyErr_NoMemory(); ! goto finally; } self->ob_item = items; ! /* populate the end self with b's items */ for (i = 0; i < blen; i++) { ! PyObject *o = PyList_GET_ITEM(b, i); Py_INCREF(o); PyList_SET_ITEM(self, self->ob_size++, o); } res = Py_None; Py_INCREF(res); ! finally: ! Py_XDECREF(b); return res; } --- 653,679 ---- } } ! ! blen = PyObject_Length(b); /* resize a using idiom */ items = self->ob_item; NRESIZE(items, PyObject*, selflen + blen); ! if (items == NULL) { PyErr_NoMemory(); ! goto failed; } self->ob_item = items; ! /* populate the end of self with b's items */ for (i = 0; i < blen; i++) { ! PyObject *o = PySequence_Fast_GET_ITEM(b, i); Py_INCREF(o); PyList_SET_ITEM(self, self->ob_size++, o); } + ok: res = Py_None; Py_INCREF(res); ! failed: ! Py_DECREF(b); return res; } From python-dev@python.org Sun Jun 18 19:45:52 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sun, 18 Jun 2000 11:45:52 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _tkinter.c,1.99,1.100 Message-ID: <200006181845.LAA10182@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv10064/Modules Modified Files: _tkinter.c Log Message: Patch from /F: this patch adds a fast _flatten function to the _tkinter module, and imports it from Tkinter.py (if available). this speeds up canvas operations like create_line and create_polygon. for example, a create_line with 5000 vertices runs about 50 times faster with this patch in place. Index: _tkinter.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_tkinter.c,v retrieving revision 1.99 retrieving revision 1.100 diff -C2 -r1.99 -r1.100 *** _tkinter.c 2000/05/04 15:55:17 1.99 --- _tkinter.c 2000/06/18 18:45:50 1.100 *************** *** 1979,1982 **** --- 1979,2081 ---- /**** Tkinter Module ****/ + typedef struct { + PyObject* tuple; + int size; /* current size */ + int maxsize; /* allocated size */ + } FlattenContext; + + static int + _bump(FlattenContext* context, int size) + { + /* expand tuple to hold (at least) size new items. return true if + successful, false if an exception was raised*/ + + int maxsize = context->maxsize * 2; + + if (maxsize < context->size + size) + maxsize = context->size + size; + + context->maxsize = maxsize; + + return _PyTuple_Resize(&context->tuple, maxsize, 0) >= 0; + } + + static int + _flatten1(FlattenContext* context, PyObject* item) + { + /* add tuple or list to argument tuple (recursively) */ + + int i, size; + + if (PyList_Check(item)) { + size = PyList_GET_SIZE(item); + /* preallocate (assume no nesting) */ + if (context->size + size > context->maxsize && !_bump(context, size)) + return 0; + /* copy items to output tuple */ + for (i = 0; i < size; i++) { + PyObject *o = PyList_GET_ITEM(item, i); + if (PyList_Check(o) || PyTuple_Check(o)) { + if (!_flatten1(context, o)) + return 0; + } else if (o != Py_None) { + if (context->size + 1 > context->maxsize && !_bump(context, 1)) + return 0; + Py_INCREF(o); + PyTuple_SET_ITEM(context->tuple, context->size++, o); + } + } + } else if (PyTuple_Check(item)) { + /* same, for tuples */ + size = PyTuple_GET_SIZE(item); + if (context->size + size > context->maxsize && !_bump(context, size)) + return 0; + for (i = 0; i < size; i++) { + PyObject *o = PyTuple_GET_ITEM(item, i); + if (PyList_Check(o) || PyTuple_Check(o)) { + if (!_flatten1(context, o)) + return 0; + } else if (o != Py_None) { + if (context->size + 1 > context->maxsize && !_bump(context, 1)) + return 0; + Py_INCREF(o); + PyTuple_SET_ITEM(context->tuple, context->size++, o); + } + } + } else { + PyErr_SetString(PyExc_TypeError, "argument must be sequence"); + return 0; + } + return 1; + } + + static PyObject * + Tkinter_Flatten(PyObject* self, PyObject* args) + { + FlattenContext context; + PyObject* item; + + if (!PyArg_ParseTuple(args, "O:_flatten", &item)) + return NULL; + + context.maxsize = PySequence_Length(item); + if (context.maxsize <= 0) + return PyTuple_New(0); + + context.tuple = PyTuple_New(context.maxsize); + if (!context.tuple) + return NULL; + + context.size = 0; + + if (!_flatten1(&context, item)) + return NULL; + + if (_PyTuple_Resize(&context.tuple, context.size, 0)) + return NULL; + + return context.tuple; + } + static PyObject * Tkinter_Create(self, args) *************** *** 2007,2010 **** --- 2106,2110 ---- static PyMethodDef moduleMethods[] = { + {"_flatten", Tkinter_Flatten, 1}, {"create", Tkinter_Create, 1}, #ifdef HAVE_CREATEFILEHANDLER From python-dev@python.org Sun Jun 18 19:45:52 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sun, 18 Jun 2000 11:45:52 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/lib-tk Tkinter.py,1.137,1.138 Message-ID: <200006181845.LAA10188@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/lib-tk In directory slayer.i.sourceforge.net:/tmp/cvs-serv10064/Lib/lib-tk Modified Files: Tkinter.py Log Message: Patch from /F: this patch adds a fast _flatten function to the _tkinter module, and imports it from Tkinter.py (if available). this speeds up canvas operations like create_line and create_polygon. for example, a create_line with 5000 vertices runs about 50 times faster with this patch in place. Index: Tkinter.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/Tkinter.py,v retrieving revision 1.137 retrieving revision 1.138 diff -C2 -r1.137 -r1.138 *** Tkinter.py 2000/03/30 23:19:44 1.137 --- Tkinter.py 2000/06/18 18:45:50 1.138 *************** *** 40,43 **** --- 40,46 ---- return res + try: _flatten = _tkinter._flatten + except AttributeError: pass + def _cnfmerge(cnfs): if type(cnfs) is DictionaryType: *************** *** 55,58 **** --- 58,64 ---- cnf[k] = v return cnf + + try: _cnfmerge = _tkinter._cnfmerge + except AttributeError: pass class Event: From python-dev@python.org Sun Jun 18 20:06:51 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sun, 18 Jun 2000 12:06:51 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules mmapmodule.c,2.14,2.15 Message-ID: <200006181906.MAA17436@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv17425 Modified Files: mmapmodule.c Log Message: Patch from Lorenzo M. Catucci: I discovered the [MREMAP_MAYMOVE] symbol is only defined when _GNU_SOURCE is defined; therefore, here is the change: if we are compiling for linux, define _GNU_SOURCE before including mman.h, and all is done. Index: mmapmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/mmapmodule.c,v retrieving revision 2.14 retrieving revision 2.15 diff -C2 -r2.14 -r2.15 *** mmapmodule.c 2000/06/18 14:51:21 2.14 --- mmapmodule.c 2000/06/18 19:06:49 2.15 *************** *** 17,20 **** --- 17,25 ---- */ + #ifdef __linux__ + #define _GNU_SOURCE /* So we can get MREMAP_MAYMOVE defined when + sys/mman.h is included */ + #endif + #include From python-dev@python.org Sun Jun 18 21:27:12 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sun, 18 Jun 2000 13:27:12 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre.py,1.5,1.6 Message-ID: <200006182027.NAA00829@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv817 Modified Files: sre.py Log Message: Fix bug when the replacement template is a callable object Index: sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** sre.py 2000/06/01 17:39:12 1.5 --- sre.py 2000/06/18 20:27:10 1.6 *************** *** 91,95 **** # internal: pattern.subn implementation hook if callable(template): ! filter = callable else: # FIXME: prepare template --- 91,95 ---- # internal: pattern.subn implementation hook if callable(template): ! filter = template else: # FIXME: prepare template From python-dev@python.org Sun Jun 18 23:22:29 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Sun, 18 Jun 2000 15:22:29 -0700 Subject: [Python-checkins] CVS: python/dist/src/Include unicodeobject.h,2.9,2.10 Message-ID: <200006182222.PAA19408@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Include In directory slayer.i.sourceforge.net:/tmp/cvs-serv19395/Include Modified Files: unicodeobject.h Log Message: Marc-Andre Lemburg : Added optimization proposed by Andrew Kuchling to the Unicode matching macro. Index: unicodeobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/unicodeobject.h,v retrieving revision 2.9 retrieving revision 2.10 diff -C2 -r2.9 -r2.10 *** unicodeobject.h 2000/05/09 19:51:53 2.9 --- unicodeobject.h 2000/06/18 22:22:27 2.10 *************** *** 169,173 **** #define Py_UNICODE_MATCH(string, offset, substring)\ ! (!memcmp((string)->str + (offset), (substring)->str,\ (substring)->length*sizeof(Py_UNICODE))) --- 169,174 ---- #define Py_UNICODE_MATCH(string, offset, substring)\ ! ((*((string)->str + (offset)) == *((substring)->str)) &&\ ! !memcmp((string)->str + (offset), (substring)->str,\ (substring)->length*sizeof(Py_UNICODE))) From python-dev@python.org Sun Jun 18 23:25:24 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Sun, 18 Jun 2000 15:25:24 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.27,2.28 Message-ID: <200006182225.PAA19484@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv19475/Objects Modified Files: unicodeobject.c Log Message: Marc-Andre Lemburg : Fixed a bug in PyUnicode_Count() which would have caused a core dump in case of substring coercion failure. Synchronized .count() with the string method of the same name to return len(s)+1 for s.count(''). Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.27 retrieving revision 2.28 diff -C2 -r2.27 -r2.28 *** unicodeobject.c 2000/06/17 20:31:17 2.27 --- unicodeobject.c 2000/06/18 22:25:22 2.28 *************** *** 2107,2110 **** --- 2107,2113 ---- int count = 0; + if (substring->length == 0) + return (end - start + 1); + end -= substring->length; *************** *** 2131,2135 **** substr = PyUnicode_FromObject(substr); if (substr == NULL) { ! Py_DECREF(substr); return -1; } --- 2134,2138 ---- substr = PyUnicode_FromObject(substr); if (substr == NULL) { ! Py_DECREF(str); return -1; } *************** *** 3087,3095 **** return NULL; - if (substring->length == 0) { - Py_DECREF(substring); - return PyInt_FromLong((long) 0); - } - if (start < 0) start += self->length; --- 3090,3093 ---- From python-dev@python.org Sun Jun 18 23:33:10 2000 From: python-dev@python.org (Fredrik Lundh) Date: Mon, 19 Jun 2000 00:33:10 +0200 Subject: [Python-checkins] CVS: python/dist/src/Include unicodeobject.h,2.9,2.10 References: <200006182222.PAA19408@slayer.i.sourceforge.net> Message-ID: <00c601bfd975$358d0aa0$f2a6b5d4@hagrid> mal wrote: > =20 > #define Py_UNICODE_MATCH(string, offset, substring)\ > ! ((*((string)->str + (offset)) =3D=3D *((substring)->str)) &&\ > ! !memcmp((string)->str + (offset), (substring)->str,\ > (substring)->length*sizeof(Py_UNICODE))) > =20 I completely forgot that this has different semantics if the substring happens to be empty. (substrings are null terminated, but "\0" isn't the same thing as ""...) don't have time to screen unicodeobject.c right now, but maybe someone else can do it? if not, maybe amk's patch was a better idea after all... From python-dev@python.org Mon Jun 19 00:15:25 2000 From: python-dev@python.org (Michael Hudson) Date: 19 Jun 2000 00:15:25 +0100 Subject: [Python-checkins] CVS: python/dist/src/Modules _tkinter.c,1.99,1.100 In-Reply-To: "A.M. Kuchling"'s message of "Sun, 18 Jun 2000 11:45:52 -0700" References: <200006181845.LAA10182@slayer.i.sourceforge.net> Message-ID: "A.M. Kuchling" writes: > Update of /cvsroot/python/python/dist/src/Modules > In directory slayer.i.sourceforge.net:/tmp/cvs-serv10064/Modules > > Modified Files: > _tkinter.c > Log Message: > Patch from /F: > this patch adds a fast _flatten function to the _tkinter > module, and imports it from Tkinter.py (if available). > > this speeds up canvas operations like create_line and > create_polygon. for example, a create_line with 5000 > vertices runs about 50 times faster with this patch in > place. Unfortunately this introduces another Way To Make Python Core: [mwh21@atrus build]$ ./python Python 1.6a2 (#4, Jun 18 2000, 23:57:36) [GCC 2.95.1 19990816/Linux (release)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam Copyright 1995-2000 Corporation for National Research Initiatives (CNRI) >>> import Tkinter >>> l = [] >>> l.append(l) >>> Tkinter._flatten(l) Segmentation fault (core dumped) Here's a simple solution: Index: _tkinter.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_tkinter.c,v retrieving revision 1.100 diff -u -r1.100 _tkinter.c --- _tkinter.c 2000/06/18 18:45:50 1.100 +++ _tkinter.c 2000/06/18 23:13:22 @@ -2001,13 +2001,16 @@ } static int -_flatten1(FlattenContext* context, PyObject* item) +_flatten1(FlattenContext* context, PyObject* item, int depth) { /* add tuple or list to argument tuple (recursively) */ int i, size; - if (PyList_Check(item)) { + if (depth > 1000) { + PyErr_SetString(PyExc_ValueError,"nesting too deep in _flatten"); + return 0; + } else if (PyList_Check(item)) { size = PyList_GET_SIZE(item); /* preallocate (assume no nesting) */ if (context->size + size > context->maxsize && !_bump(context, size)) @@ -2016,7 +2019,7 @@ for (i = 0; i < size; i++) { PyObject *o = PyList_GET_ITEM(item, i); if (PyList_Check(o) || PyTuple_Check(o)) { - if (!_flatten1(context, o)) + if (!_flatten1(context, o, depth + 1)) return 0; } else if (o != Py_None) { if (context->size + 1 > context->maxsize && !_bump(context, 1)) @@ -2033,7 +2036,7 @@ for (i = 0; i < size; i++) { PyObject *o = PyTuple_GET_ITEM(item, i); if (PyList_Check(o) || PyTuple_Check(o)) { - if (!_flatten1(context, o)) + if (!_flatten1(context, o, depth + 1)) return 0; } else if (o != Py_None) { if (context->size + 1 > context->maxsize && !_bump(context, 1)) @@ -2068,7 +2071,7 @@ context.size = 0; - if (!_flatten1(&context, item)) + if (!_flatten1(&context, item,0)) return NULL; if (_PyTuple_Resize(&context.tuple, context.size, 0)) "seems to work"; I've not tested it for performance, but I can't believe this is too hard a hit. Cheers, M. From python-dev@python.org Mon Jun 19 00:20:27 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Mon, 19 Jun 2000 01:20:27 +0200 Subject: [Python-checkins] CVS: python/dist/src/Include unicodeobject.h,2.9,2.10 References: <200006182222.PAA19408@slayer.i.sourceforge.net> <00c601bfd975$358d0aa0$f2a6b5d4@hagrid> Message-ID: <394D593B.DD4804E6@lemburg.com> Fredrik Lundh wrote: > > mal wrote: > > > > #define Py_UNICODE_MATCH(string, offset, substring)\ > > ! ((*((string)->str + (offset)) == *((substring)->str)) &&\ > > ! !memcmp((string)->str + (offset), (substring)->str,\ > > (substring)->length*sizeof(Py_UNICODE))) > > > > I completely forgot that this has different semantics if the > substring happens to be empty. > > (substrings are null terminated, but "\0" isn't the same > thing as ""...) > > don't have time to screen unicodeobject.c right now, but > maybe someone else can do it? if not, maybe amk's patch > was a better idea after all... I've checked the places where this macro is used: all except the in .count() method showed the same behaviour as for 8-bit strings. The Unicode .count() method now also returns the same value for empty substrings as the 8-bit strings. -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From python-dev@python.org Mon Jun 19 01:55:12 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sun, 18 Jun 2000 17:55:12 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _tkinter.c,1.100,1.101 Message-ID: <200006190055.RAA06711@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv6640 Modified Files: _tkinter.c Log Message: Patch from Michael Hudson to fix flatten recursive data structures: [mwh21@atrus build]$ ./python >>> import Tkinter >>> l = [] >>> l.append(l) >>> Tkinter._flatten(l) Segmentation fault (core dumped) Index: _tkinter.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_tkinter.c,v retrieving revision 1.100 retrieving revision 1.101 diff -C2 -r1.100 -r1.101 *** _tkinter.c 2000/06/18 18:45:50 1.100 --- _tkinter.c 2000/06/19 00:55:09 1.101 *************** *** 2002,2006 **** static int ! _flatten1(FlattenContext* context, PyObject* item) { /* add tuple or list to argument tuple (recursively) */ --- 2002,2006 ---- static int ! _flatten1(FlattenContext* context, PyObject* item, int depth) { /* add tuple or list to argument tuple (recursively) */ *************** *** 2008,2012 **** int i, size; ! if (PyList_Check(item)) { size = PyList_GET_SIZE(item); /* preallocate (assume no nesting) */ --- 2008,2015 ---- int i, size; ! if (depth > 1000) { ! PyErr_SetString(PyExc_ValueError,"nesting too deep in _flatten"); ! return 0; ! } else if (PyList_Check(item)) { size = PyList_GET_SIZE(item); /* preallocate (assume no nesting) */ *************** *** 2017,2021 **** PyObject *o = PyList_GET_ITEM(item, i); if (PyList_Check(o) || PyTuple_Check(o)) { ! if (!_flatten1(context, o)) return 0; } else if (o != Py_None) { --- 2020,2024 ---- PyObject *o = PyList_GET_ITEM(item, i); if (PyList_Check(o) || PyTuple_Check(o)) { ! if (!_flatten1(context, o, depth + 1)) return 0; } else if (o != Py_None) { *************** *** 2034,2038 **** PyObject *o = PyTuple_GET_ITEM(item, i); if (PyList_Check(o) || PyTuple_Check(o)) { ! if (!_flatten1(context, o)) return 0; } else if (o != Py_None) { --- 2037,2041 ---- PyObject *o = PyTuple_GET_ITEM(item, i); if (PyList_Check(o) || PyTuple_Check(o)) { ! if (!_flatten1(context, o, depth + 1)) return 0; } else if (o != Py_None) { *************** *** 2069,2073 **** context.size = 0; ! if (!_flatten1(&context, item)) return NULL; --- 2072,2076 ---- context.size = 0; ! if (!_flatten1(&context, item,0)) return NULL; From python-dev@python.org Mon Jun 19 14:17:44 2000 From: python-dev@python.org (Fred L. Drake) Date: Mon, 19 Jun 2000 06:17:44 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules cStringIO.c,2.20,2.21 Message-ID: <200006191317.GAA17808@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv17801 Modified Files: cStringIO.c Log Message: Fixed docstring typo, reported by Skip Montanaro . Index: cStringIO.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cStringIO.c,v retrieving revision 2.20 retrieving revision 2.21 diff -C2 -r2.20 -r2.21 *** cStringIO.c 2000/05/03 23:44:31 2.20 --- cStringIO.c 2000/06/19 13:17:41 2.21 *************** *** 57,61 **** "This module provides a simple useful replacement for\n" "the StringIO module that is written in C. It does not provide the\n" ! "full generality if StringIO, but it provides enough for most\n" "applications and is especially useful in conjuction with the\n" "pickle module.\n" --- 57,61 ---- "This module provides a simple useful replacement for\n" "the StringIO module that is written in C. It does not provide the\n" ! "full generality of StringIO, but it provides enough for most\n" "applications and is especially useful in conjuction with the\n" "pickle module.\n" From python-dev@python.org Mon Jun 19 14:41:56 2000 From: python-dev@python.org (Fred L. Drake) Date: Mon, 19 Jun 2000 06:41:56 -0700 Subject: [Python-checkins] CVS: python/dist/src/PC config.h,1.35,1.36 Message-ID: <200006191341.GAA19157@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv19143 Modified Files: config.h Log Message: Patch from Rene Liebscher , slightly modified and commented by Fred Drake, to prevent usage of sufficiently broken GCC versions. Index: config.h =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/config.h,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -r1.35 -r1.36 *** config.h 2000/05/10 13:25:32 1.35 --- config.h 2000/06/19 13:41:54 1.36 *************** *** 27,30 **** --- 27,38 ---- */ + /* Suggested by Rene Liebscher to avoid a GCC 2.91.* + bug that requires structure imports. More recent versions of the + compiler don't exhibit this bug. + */ + #if (__GNUC__==2) && (__GNUC_MINOR__<=91) + #error "Please use an up-to-date version of gcc" + #endif + /* Some systems require special declarations for data items imported From python-dev@python.org Tue Jun 20 05:54:22 2000 From: python-dev@python.org (Fred L. Drake) Date: Mon, 19 Jun 2000 21:54:22 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.161,2.162 Message-ID: <200006200454.VAA07148@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv7137 Modified Files: bltinmodule.c Log Message: Christopher Fandrich : Fix memory leak in initializing __debug__. Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.161 retrieving revision 2.162 diff -C2 -r2.161 -r2.162 *** bltinmodule.c 2000/05/25 23:15:05 2.161 --- bltinmodule.c 2000/06/20 04:54:19 2.162 *************** *** 2365,2369 **** _PyBuiltin_Init() { ! PyObject *mod, *dict; mod = Py_InitModule4("__builtin__", builtin_methods, builtin_doc, (PyObject *)NULL, --- 2365,2369 ---- _PyBuiltin_Init() { ! PyObject *mod, *dict, *debug; mod = Py_InitModule4("__builtin__", builtin_methods, builtin_doc, (PyObject *)NULL, *************** *** 2376,2382 **** if (PyDict_SetItemString(dict, "Ellipsis", Py_Ellipsis) < 0) return NULL; ! if (PyDict_SetItemString(dict, "__debug__", ! PyInt_FromLong(Py_OptimizeFlag == 0)) < 0) return NULL; return mod; --- 2376,2385 ---- if (PyDict_SetItemString(dict, "Ellipsis", Py_Ellipsis) < 0) return NULL; ! debug = PyInt_FromLong(Py_OptimizeFlag == 0); ! if (PyDict_SetItemString(dict, "__debug__", debug) < 0) { ! Py_XDECREF(debug); return NULL; + } + Py_XDECREF(debug); return mod; From python-dev@python.org Tue Jun 20 09:12:50 2000 From: python-dev@python.org (Mark Hammond) Date: Tue, 20 Jun 2000 01:12:50 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python sysmodule.c,2.64,2.65 Message-ID: <200006200812.BAA07068@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv7059 Modified Files: sysmodule.c Log Message: Added a new debug method sys.gettotalrefcount(), which returns the total number of references on all Python objects. This is only enabled when Py_TRACE_REFS is defined (which includes default debug builds under Windows). Also removed a redundant cast from sys.getrefcount(), as discussed on the patches list. Index: sysmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v retrieving revision 2.64 retrieving revision 2.65 diff -C2 -r2.64 -r2.65 *** sysmodule.c 2000/06/07 09:13:41 2.64 --- sysmodule.c 2000/06/20 08:12:48 2.65 *************** *** 266,272 **** if (!PyArg_ParseTuple(args, "O:getrefcount", &arg)) return NULL; ! return PyInt_FromLong((long) arg->ob_refcnt); } static char getrefcount_doc[] = "getrefcount(object) -> integer\n\ --- 266,284 ---- if (!PyArg_ParseTuple(args, "O:getrefcount", &arg)) return NULL; ! return PyInt_FromLong(arg->ob_refcnt); } + #ifdef Py_TRACE_REFS + static PyObject * + sys_gettotalrefcount(PyObject *self, PyObject *args) + { + extern long _Py_RefTotal; + if (!PyArg_ParseTuple(args, ":gettotalrefcount")) + return NULL; + return PyInt_FromLong(_Py_RefTotal); + } + + #endif /* Py_TRACE_REFS */ + static char getrefcount_doc[] = "getrefcount(object) -> integer\n\ *************** *** 311,314 **** --- 323,327 ---- #ifdef Py_TRACE_REFS {"getobjects", _Py_GetObjects, 1}, + {"gettotalrefcount", sys_gettotalrefcount, 1}, #endif {"getrefcount", sys_getrefcount, 1, getrefcount_doc}, From python-dev@python.org Tue Jun 20 16:47:56 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 20 Jun 2000 08:47:56 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects stringobject.c,2.68,2.69 Message-ID: <200006201547.IAA26926@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv26919 Modified Files: stringobject.c Log Message: Fredrik Lundh : Simplify find code; this is a performance improvement on at least some platforms. Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.68 retrieving revision 2.69 diff -C2 -r2.68 -r2.69 *** stringobject.c 2000/06/14 09:18:09 2.68 --- stringobject.c 2000/06/20 15:47:54 2.69 *************** *** 652,656 **** i = j = 0; while (i+n <= len) { ! if (s[i] == sub[0] && (n == 1 || memcmp(s+i, sub, n) == 0)) { if (maxsplit-- <= 0) break; --- 652,656 ---- i = j = 0; while (i+n <= len) { ! if (s[i] == sub[0] && memcmp(s+i, sub, n) == 0) { if (maxsplit-- <= 0) break; *************** *** 853,858 **** last -= n; for (; i <= last; ++i) ! if (s[i] == sub[0] && ! (n == 1 || memcmp(&s[i+1], &sub[1], n-1) == 0)) return (long)i; } --- 853,857 ---- last -= n; for (; i <= last; ++i) ! if (s[i] == sub[0] && memcmp(&s[i], sub, n) == 0) return (long)i; } *************** *** 863,868 **** return (long)last; for (j = last-n; j >= i; --j) ! if (s[j] == sub[0] && ! (n == 1 || memcmp(&s[j+1], &sub[1], n-1) == 0)) return (long)j; } --- 862,866 ---- return (long)last; for (j = last-n; j >= i; --j) ! if (s[j] == sub[0] && memcmp(&s[j], sub, n) == 0) return (long)j; } *************** *** 1416,1422 **** for (ii = 0; ii <= len; ii++) { ! if (mem[ii] == pat[0] && ! (pat_len == 1 || ! memcmp(&mem[ii+1], &pat[1], pat_len-1) == 0)) { return ii; } --- 1414,1418 ---- for (ii = 0; ii <= len; ii++) { ! if (mem[ii] == pat[0] && memcmp(&mem[ii], pat, pat_len) == 0) { return ii; } From python-dev@python.org Tue Jun 20 19:32:19 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 20 Jun 2000 11:32:19 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib urlparse.py,1.24,1.25 Message-ID: <200006201832.LAA24163@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv24155 Modified Files: urlparse.py Log Message: Pekka Pessi : Patch to add support for sip: (Session Initiation Protocol, RFC2543) URLs. Index: urlparse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urlparse.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -r1.24 -r1.25 *** urlparse.py 2000/04/14 14:01:34 1.24 --- urlparse.py 2000/06/20 18:32:16 1.25 *************** *** 18,29 **** 'prospero', 'rtsp', 'rtspu', ''] non_hierarchical = ['gopher', 'hdl', 'mailto', 'news', 'telnet', 'wais', ! 'snews', ] uses_params = ['ftp', 'hdl', 'prospero', 'http', ! 'https', 'shttp', 'rtsp', 'rtspu', ''] uses_query = ['http', 'wais', 'https', 'shttp', ! 'gopher', 'rtsp', 'rtspu', ''] uses_fragment = ['ftp', 'hdl', 'http', 'gopher', 'news', 'nntp', 'wais', --- 18,29 ---- 'prospero', 'rtsp', 'rtspu', ''] non_hierarchical = ['gopher', 'hdl', 'mailto', 'news', 'telnet', 'wais', ! 'snews', 'sip', ] uses_params = ['ftp', 'hdl', 'prospero', 'http', ! 'https', 'shttp', 'rtsp', 'rtspu', 'sip', ''] uses_query = ['http', 'wais', 'https', 'shttp', ! 'gopher', 'rtsp', 'rtspu', 'sip', ''] uses_fragment = ['ftp', 'hdl', 'http', 'gopher', 'news', 'nntp', 'wais', From python-dev@python.org Tue Jun 20 19:36:29 2000 From: python-dev@python.org (Jeremy Hylton) Date: Tue, 20 Jun 2000 11:36:29 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python exceptions.c,1.1,1.2 Message-ID: <200006201836.LAA24482@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv24307 Modified Files: exceptions.c Log Message: mark SyntaxError__str__ as METH_VARARGS Index: exceptions.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/exceptions.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** exceptions.c 2000/05/26 19:05:16 1.1 --- exceptions.c 2000/06/20 18:36:26 1.2 *************** *** 728,732 **** PyMethodDef SyntaxError_methods[] = { {"__init__", SyntaxError__init__, 1}, ! {"__str__", SyntaxError__str__,}, {NULL, NULL} }; --- 728,732 ---- PyMethodDef SyntaxError_methods[] = { {"__init__", SyntaxError__init__, 1}, ! {"__str__", SyntaxError__str__, 1}, {NULL, NULL} }; From python-dev@python.org Tue Jun 20 19:53:00 2000 From: python-dev@python.org (Jeremy Hylton) Date: Tue, 20 Jun 2000 11:53:00 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_exceptions.py,1.6,1.7 Message-ID: <200006201853.LAA25802@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv25768 Modified Files: test_exceptions.py Log Message: add minimal test of exception use. verify that each exception can be raised, caught, and converted to a string. Index: test_exceptions.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_exceptions.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** test_exceptions.py 2000/05/25 23:16:34 1.6 --- test_exceptions.py 2000/06/20 18:52:57 1.7 *************** *** 7,11 **** --- 7,23 ---- # XXX This is not really enough, each *operation* should be tested! + def test_raise_catch(exc): + try: + raise exc, "spam" + except exc, err: + buf = str(err) + try: + raise exc("spam") + except exc, err: + buf = str(err) + print buf + def r(thing): + test_raise_catch(thing) if type(thing) == ClassType: print thing.__name__ From python-dev@python.org Tue Jun 20 20:10:47 2000 From: python-dev@python.org (Jeremy Hylton) Date: Tue, 20 Jun 2000 12:10:47 -0700 Subject: [Python-checkins] CVS: python/dist/src/Include errcode.h,2.8,2.9 node.h,2.12,2.13 Message-ID: <200006201910.MAA00549@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Include In directory slayer.i.sourceforge.net:/tmp/cvs-serv509/Include Modified Files: errcode.h node.h Log Message: Add new parser error code, E_OVERFLOW. This error is returned when the number of children of a node exceeds the max possible value for the short that is used to count them. The Python runtime converts this parser error into the SyntaxError "expression too long." Index: errcode.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/errcode.h,v retrieving revision 2.8 retrieving revision 2.9 diff -C2 -r2.8 -r2.9 *** errcode.h 1998/04/09 21:37:20 2.8 --- errcode.h 2000/06/20 19:10:44 2.9 *************** *** 53,56 **** --- 53,57 ---- #define E_ERROR 17 /* Execution error */ #define E_INDENT 18 /* Invalid indentation detected */ + #define E_OVERFLOW 19 /* Node had too many children */ #ifdef __cplusplus Index: node.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/node.h,v retrieving revision 2.12 retrieving revision 2.13 diff -C2 -r2.12 -r2.13 *** node.h 1998/12/04 18:48:11 2.12 --- node.h 2000/06/20 19:10:44 2.13 *************** *** 47,51 **** extern DL_IMPORT(node *) PyNode_New Py_PROTO((int type)); ! extern DL_IMPORT(node *) PyNode_AddChild Py_PROTO((node *n, int type, char *str, int lineno)); extern DL_IMPORT(void) PyNode_Free Py_PROTO((node *n)); --- 47,51 ---- extern DL_IMPORT(node *) PyNode_New Py_PROTO((int type)); ! extern DL_IMPORT(int) PyNode_AddChild Py_PROTO((node *n, int type, char *str, int lineno)); extern DL_IMPORT(void) PyNode_Free Py_PROTO((node *n)); From python-dev@python.org Tue Jun 20 20:10:47 2000 From: python-dev@python.org (Jeremy Hylton) Date: Tue, 20 Jun 2000 12:10:47 -0700 Subject: [Python-checkins] CVS: python/dist/src/Parser node.c,2.7,2.8 parser.c,2.10,2.11 Message-ID: <200006201910.MAA00558@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Parser In directory slayer.i.sourceforge.net:/tmp/cvs-serv509/Parser Modified Files: node.c parser.c Log Message: Add new parser error code, E_OVERFLOW. This error is returned when the number of children of a node exceeds the max possible value for the short that is used to count them. The Python runtime converts this parser error into the SyntaxError "expression too long." Index: node.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/node.c,v retrieving revision 2.7 retrieving revision 2.8 diff -C2 -r2.7 -r2.8 *** node.c 1997/04/29 21:02:42 2.7 --- node.c 2000/06/20 19:10:44 2.8 *************** *** 30,37 **** --- 30,40 ---- ******************************************************************/ + #include + /* Parse tree node implementation */ #include "pgenheaders.h" #include "node.h" + #include "errcode.h" node * *************** *** 53,57 **** #define XXXROUNDUP(n) ((n) == 1 ? 1 : ((n) + XXX - 1) / XXX * XXX) ! node * PyNode_AddChild(n1, type, str, lineno) register node *n1; --- 56,60 ---- #define XXXROUNDUP(n) ((n) == 1 ? 1 : ((n) + XXX - 1) / XXX * XXX) ! int PyNode_AddChild(n1, type, str, lineno) register node *n1; *************** *** 63,66 **** --- 66,71 ---- register int nch1 = nch+1; register node *n; + if (nch == SHRT_MAX || nch < 0) + return E_OVERFLOW; if (XXXROUNDUP(nch) < nch1) { n = n1->n_child; *************** *** 68,72 **** PyMem_RESIZE(n, node, nch1); if (n == NULL) ! return NULL; n1->n_child = n; } --- 73,77 ---- PyMem_RESIZE(n, node, nch1); if (n == NULL) ! return E_NOMEM; n1->n_child = n; } *************** *** 77,81 **** n->n_nchildren = 0; n->n_child = NULL; ! return n; } --- 82,86 ---- n->n_nchildren = 0; n->n_child = NULL; ! return 0; } Index: parser.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/parser.c,v retrieving revision 2.10 retrieving revision 2.11 diff -C2 -r2.10 -r2.11 *** parser.c 1997/04/29 21:02:45 2.10 --- parser.c 2000/06/20 19:10:44 2.11 *************** *** 154,162 **** int lineno; { assert(!s_empty(s)); ! if (PyNode_AddChild(s->s_top->s_parent, type, str, lineno) == NULL) { ! fprintf(stderr, "shift: no mem in addchild\n"); ! return -1; ! } s->s_top->s_state = newstate; return 0; --- 154,162 ---- int lineno; { + int err; assert(!s_empty(s)); ! err = PyNode_AddChild(s->s_top->s_parent, type, str, lineno); ! if (err) ! return err; s->s_top->s_state = newstate; return 0; *************** *** 173,183 **** int lineno; { register node *n; n = s->s_top->s_parent; assert(!s_empty(s)); ! if (PyNode_AddChild(n, type, (char *)NULL, lineno) == NULL) { ! fprintf(stderr, "push: no mem in addchild\n"); ! return -1; ! } s->s_top->s_state = newstate; return s_push(s, d, CHILD(n, NCH(n)-1)); --- 173,183 ---- int lineno; { + int err; register node *n; n = s->s_top->s_parent; assert(!s_empty(s)); ! err = PyNode_AddChild(n, type, (char *)NULL, lineno); ! if (err) ! return err; s->s_top->s_state = newstate; return s_push(s, d, CHILD(n, NCH(n)-1)); *************** *** 234,237 **** --- 234,238 ---- { register int ilabel; + int err; D(printf("Token %s/'%s' ... ", _PyParser_TokenNames[type], str)); *************** *** 261,268 **** dfa *d1 = PyGrammar_FindDFA( ps->p_grammar, nt); ! if (push(&ps->p_stack, nt, d1, ! arrow, lineno) < 0) { D(printf(" MemError: push\n")); ! return E_NOMEM; } D(printf(" Push ...\n")); --- 262,269 ---- dfa *d1 = PyGrammar_FindDFA( ps->p_grammar, nt); ! if ((err = push(&ps->p_stack, nt, d1, ! arrow, lineno)) > 0) { D(printf(" MemError: push\n")); ! return err; } D(printf(" Push ...\n")); *************** *** 271,278 **** /* Shift the token */ ! if (shift(&ps->p_stack, type, str, ! x, lineno) < 0) { D(printf(" MemError: shift.\n")); ! return E_NOMEM; } D(printf(" Shift.\n")); --- 272,279 ---- /* Shift the token */ ! if ((err = shift(&ps->p_stack, type, str, ! x, lineno)) > 0) { D(printf(" MemError: shift.\n")); ! return err; } D(printf(" Shift.\n")); From python-dev@python.org Tue Jun 20 20:10:47 2000 From: python-dev@python.org (Jeremy Hylton) Date: Tue, 20 Jun 2000 12:10:47 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python pythonrun.c,2.97,2.98 Message-ID: <200006201910.MAA00557@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv509/Python Modified Files: pythonrun.c Log Message: Add new parser error code, E_OVERFLOW. This error is returned when the number of children of a node exceeds the max possible value for the short that is used to count them. The Python runtime converts this parser error into the SyntaxError "expression too long." Index: pythonrun.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v retrieving revision 2.97 retrieving revision 2.98 diff -C2 -r2.97 -r2.98 *** pythonrun.c 2000/05/25 23:09:49 2.97 --- pythonrun.c 2000/06/20 19:10:44 2.98 *************** *** 1034,1037 **** --- 1034,1040 ---- msg = "inconsistent use of tabs and spaces in indentation"; break; + case E_OVERFLOW: + msg = "expression too long"; + break; default: fprintf(stderr, "error=%d\n", err->error); From python-dev@python.org Tue Jun 20 20:13:30 2000 From: python-dev@python.org (Jeremy Hylton) Date: Tue, 20 Jun 2000 12:13:30 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_longexp.py,NONE,1.1 Message-ID: <200006201913.MAA00770@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv656 Added Files: test_longexp.py Log Message: verify that Python raises SyntaxError for long and deeply-nested expressions --- NEW FILE --- REPS = 8192 try: eval("2+2+" * REPS + "+3.14159265") except SyntaxError, msg: print "Caught SyntaxError for long expression:", msg else: print "Long expression did not raise SyntaxError" ## This test prints "s_push: parser stack overflow" on stderr, ## which seems to confuse the test harness ##try: ## eval("(2+" * REPS + "0" + ")" * REPS) ##except SyntaxError: ## pass ##else: ## print "Deeply nested expression did not raised SyntaxError" From python-dev@python.org Tue Jun 20 20:13:30 2000 From: python-dev@python.org (Jeremy Hylton) Date: Tue, 20 Jun 2000 12:13:30 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_longexp,NONE,1.1 Message-ID: <200006201913.MAA00775@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv656/output Added Files: test_longexp Log Message: verify that Python raises SyntaxError for long and deeply-nested expressions --- NEW FILE --- test_longexp Caught SyntaxError for long expression: expression too long From python-dev@python.org Wed Jun 21 02:41:51 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 20 Jun 2000 18:41:51 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _cursesmodule.c,2.23,2.24 Message-ID: <200006210141.SAA00795@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv761 Modified Files: _cursesmodule.c Log Message: Added .timeout() method and .typeahead() function Index: _cursesmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_cursesmodule.c,v retrieving revision 2.23 retrieving revision 2.24 diff -C2 -r2.23 -r2.24 *** _cursesmodule.c 2000/06/10 23:12:32 2.23 --- _cursesmodule.c 2000/06/21 01:41:48 2.24 *************** *** 227,230 **** --- 227,231 ---- Window_OneArgNoReturnVoidFunction(idcok, int, "i;True(1) or False(0)") Window_OneArgNoReturnVoidFunction(immedok, int, "i;True(1) or False(0)") + Window_OneArgNoReturnVoidFunction(wtimeout, int, "i;delay") Window_NoArg2TupleReturnFunction(getyx, int, "(ii)") *************** *** 1287,1290 **** --- 1288,1292 ---- {"syncok", (PyCFunction)PyCursesWindow_syncok}, {"syncup", (PyCFunction)PyCursesWindow_wsyncup}, + {"timeout", (PyCFunction)PyCursesWindow_wtimeout}, {"touchline", (PyCFunction)PyCursesWindow_TouchLine}, {"touchwin", (PyCFunction)PyCursesWindow_touchwin}, *************** *** 2028,2031 **** --- 2030,2049 ---- static PyObject * + PyCurses_TypeAhead(self,arg) + PyObject * self; + PyObject * arg; + { + int fd, err; + + PyCursesInitialised + + if (!PyArg_Parse(arg,"i;fd",&fd)) return NULL; + + PyCursesCheckERR(typeahead( fd ), "typeahead"); + Py_INCREF(Py_None); + return Py_None; + } + + static PyObject * PyCurses_UnCtrl(self,arg) PyObject * self; *************** *** 2155,2158 **** --- 2173,2177 ---- {"termattrs", (PyCFunction)PyCurses_termattrs}, {"termname", (PyCFunction)PyCurses_termname}, + {"typeahead", (PyCFunction)PyCurses_TypeAhead}, {"unctrl", (PyCFunction)PyCurses_UnCtrl}, {"ungetch", (PyCFunction)PyCurses_UngetCh}, From python-dev@python.org Wed Jun 21 02:42:53 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 20 Jun 2000 18:42:53 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libcurses.tex,1.4,1.5 Message-ID: <200006210142.SAA00816@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv808 Modified Files: libcurses.tex Log Message: Document .timeout() method and .typeahead() function Index: libcurses.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcurses.tex,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** libcurses.tex 2000/05/23 16:46:04 1.4 --- libcurses.tex 2000/06/21 01:42:51 1.5 *************** *** 343,346 **** --- 343,358 ---- \end{funcdesc} + \begin{funcdesc}{typeahead}{fd} + Specifies that the file descriptor \var{fd} be used for typeahead + checking. If \var{fd} is -1, then no typeahead checking is done. + + The curses library does ``line-breakout optimization'' by looking for + typeahead periodically while updating the screen. If input is found, + and it is coming from a tty, the current update is postponed until + refresh or doupdate is called again, allowing faster response to + commands typed in advance. This function allows specifying a different + file descriptor for typeahead checking. + \end{funcdesc} + \begin{funcdesc}{unctrl}{ch} Returns a string which is a printable representation of the character *************** *** 779,782 **** --- 791,804 ---- Touches all locations in ancestors of the window that have been changed in the window. + \end{methoddesc} + + \begin{methoddesc}{timeout}{delay} + Sets blocking or non-blocking read behaviour for the window. If + \var{delay} is negative, blocking read is used, which will wait + indefinitely for input). If \var{delay} is zero, then non-blocking + read is used, and -1 will be returned by \method{getch()} if no input + is waiting. If \var{delay} is positive, then \method{getch()} will + block for \var{delay} milliseconds, and return -1 if there is still no + input at the end of that time. \end{methoddesc} From python-dev@python.org Wed Jun 21 02:48:55 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 20 Jun 2000 18:48:55 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libstring.tex,1.36,1.37 Message-ID: <200006210148.SAA01061@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv1013 Modified Files: libstring.tex Log Message: Minor grammatical fix Index: libstring.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstring.tex,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -r1.36 -r1.37 *** libstring.tex 2000/04/10 18:35:49 1.36 --- libstring.tex 2000/06/21 01:48:46 1.37 *************** *** 143,147 **** \var{sub} in string \code{\var{s}[\var{start}:\var{end}]}. Defaults for \var{start} and \var{end} and interpretation of ! negative values is the same as for slices. \end{funcdesc} --- 143,147 ---- \var{sub} in string \code{\var{s}[\var{start}:\var{end}]}. Defaults for \var{start} and \var{end} and interpretation of ! negative values are the same as for slices. \end{funcdesc} From python-dev@python.org Wed Jun 21 03:58:49 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 20 Jun 2000 19:58:49 -0700 Subject: [Python-checkins] CVS: distutils/distutils ccompiler.py,1.22,1.23 unixccompiler.py,1.25,1.26 Message-ID: <200006210258.TAA14638@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv14626 Modified Files: ccompiler.py unixccompiler.py Log Message: Added 'preprocess()' method to CCompiler interface, and implemented it in UnixCCompiler. Still needs to be implemented in MSVCCompiler (and whatever other compiler classes are lurking out there, waiting to be checked in). Index: ccompiler.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/ccompiler.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** ccompiler.py 2000/06/07 03:00:05 1.22 --- ccompiler.py 2000/06/21 02:58:46 1.23 *************** *** 415,418 **** --- 415,434 ---- # (must be implemented by subclasses) + def preprocess (self, + source, + output_file=None, + macros=None, + include_dirs=None, + extra_preargs=None, + extra_postargs=None): + """Preprocess a single C/C++ source file, named in 'source'. + Output will be written to file named 'output_file', or stdout if + 'output_file' not supplied. 'macros' is a list of macro + definitions as for 'compile()', which will augment the macros set + with 'define_macro()' and 'undefine_macro()'. 'include_dirs' is a + list of directory names that will be added to the default list. + """ + pass + def compile (self, sources, Index: unixccompiler.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/unixccompiler.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -r1.25 -r1.26 *** unixccompiler.py 2000/05/30 02:02:49 1.25 --- unixccompiler.py 2000/06/21 02:58:46 1.26 *************** *** 22,25 **** --- 22,26 ---- from copy import copy from distutils import sysconfig + from distutils.dep_util import newer from distutils.ccompiler import \ CCompiler, gen_preprocess_options, gen_lib_options *************** *** 103,106 **** --- 104,138 ---- # __init__ () + + + def preprocess (self, + source, + output_file=None, + macros=None, + include_dirs=None, + extra_preargs=None, + extra_postargs=None): + + (_, macros, include_dirs) = \ + self._fix_compile_args (None, macros, include_dirs) + pp_opts = gen_preprocess_options (macros, include_dirs) + cc_args = ['-E'] + pp_opts + if output_file: + cc_args.extend(['-o', output_file]) + if extra_preargs: + cc_args[:0] = extra_preargs + if extra_postargs: + extra_postargs.extend(extra_postargs) + + # We need to preprocess: either we're being forced to, or the + # source file is newer than the target (or the target doesn't + # exist). + if self.force or (output_file and newer(source, output_file)): + if output_file: + self.mkpath(os.path.dirname(output_file)) + try: + self.spawn ([self.cc] + cc_args) + except DistutilsExecError, msg: + raise CompileError, msg From python-dev@python.org Wed Jun 21 03:59:17 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 20 Jun 2000 19:59:17 -0700 Subject: [Python-checkins] CVS: distutils/distutils core.py,1.42,1.43 Message-ID: <200006210259.TAA14669@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv14656 Modified Files: core.py Log Message: Oops, import 'grok_environment_error()'. Index: core.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/core.py,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -r1.42 -r1.43 *** core.py 2000/06/17 02:17:45 1.42 --- core.py 2000/06/21 02:59:14 1.43 *************** *** 14,17 **** --- 14,18 ---- from types import * from distutils.errors import * + from distutils.util import grok_environment_error # Mainly import these so setup scripts can "from distutils.core import" them. From python-dev@python.org Wed Jun 21 04:00:53 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 20 Jun 2000 20:00:53 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command config.py,1.1,1.2 Message-ID: <200006210300.UAA17427@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv17164 Modified Files: config.py Log Message: Fleshed out and added a bunch of useful stuff, notably 'check_func()', 'try_cpp()', 'search_cpp()', and 'check_header()'. This is enough that the base config is actually useful for implementing a real config command, specifically one for mxDateTime. Index: config.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/config.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** config.py 2000/06/06 02:57:07 1.1 --- config.py 2000/06/21 03:00:50 1.2 *************** *** 14,18 **** __revision__ = "$Id$" ! import os, string from distutils.core import Command from distutils.errors import DistutilsExecError --- 14,18 ---- __revision__ = "$Id$" ! import sys, os, string, re from distutils.core import Command from distutils.errors import DistutilsExecError *************** *** 41,44 **** --- 41,49 ---- ('library-dirs=', 'L', "directories to search for external C libraries"), + + ('noisy', None, + "show every action (compile, link, run, ...) taken"), + ('dump-source', None, + "dump generated source files before attempting to compile them"), ] *************** *** 56,59 **** --- 61,72 ---- self.library_dirs = None + # maximal output for now + self.noisy = 1 + self.dump_source = 1 + + # list of temporary files generated along-the-way that we have + # to clean at some point + self.temp_files = [] + def finalize_options (self): pass *************** *** 76,80 **** if not isinstance(self.compiler, CCompiler): self.compiler = new_compiler (compiler=self.compiler, ! verbose=self.verbose, # for now dry_run=self.dry_run, force=1) --- 89,93 ---- if not isinstance(self.compiler, CCompiler): self.compiler = new_compiler (compiler=self.compiler, ! verbose=self.noisy, dry_run=self.dry_run, force=1) *************** *** 87,109 **** ! def _gen_temp_sourcefile (self, body, lang): filename = "_configtest" + LANG_EXT[lang] file = open(filename, "w") file.write(body) file.close() return filename ! def _compile (self, body, lang): ! src = self._gen_temp_sourcefile(body, lang) ! (obj,) = self.compiler.compile([src]) return (src, obj) ! def _link (self, body, lang): ! (src, obj) = self._compile(body, lang) ! exe = os.path.splitext(os.path.basename(src))[0] ! self.compiler.link_executable([obj], exe) ! return (src, obj, exe) def _clean (self, *filenames): self.announce("removing: " + string.join(filenames)) for filename in filenames: --- 100,145 ---- ! def _gen_temp_sourcefile (self, body, headers, lang): filename = "_configtest" + LANG_EXT[lang] file = open(filename, "w") + if headers: + for header in headers: + file.write("#include <%s>\n" % header) + file.write("\n") file.write(body) + if body[-1] != "\n": + file.write("\n") file.close() return filename ! def _preprocess (self, body, headers, lang): ! src = self._gen_temp_sourcefile(body, headers, lang) ! out = "_configtest.i" ! self.temp_files.extend([src, out]) ! self.compiler.preprocess(src, out) ! return (src, out) ! ! def _compile (self, body, headers, lang): ! src = self._gen_temp_sourcefile(body, headers, lang) ! if self.dump_source: ! dump_file(src, "compiling '%s':" % src) ! (obj,) = self.compiler.object_filenames([src]) ! self.temp_files.extend([src, obj]) ! self.compiler.compile([src]) return (src, obj) ! def _link (self, body, headers, libraries, library_dirs, lang): ! (src, obj) = self._compile(body, headers, lang) ! prog = os.path.splitext(os.path.basename(src))[0] ! self.temp_files.append(prog) # XXX should be prog + exe_ext ! self.compiler.link_executable([obj], prog, ! libraries=libraries, ! library_dirs=library_dirs) ! return (src, obj, prog) def _clean (self, *filenames): + if not filenames: + filenames = self.temp_files + self.temp_files = [] self.announce("removing: " + string.join(filenames)) for filename in filenames: *************** *** 114,121 **** - # XXX no 'try_cpp()' or 'search_cpp()' since the CCompiler interface - # does not provide access to the preprocessor. This is an oversight - # that should be fixed. - # XXX these ignore the dry-run flag: what to do, what to do? even if # you want a dry-run build, you still need some sort of configuration --- 150,153 ---- *************** *** 126,138 **** # which is correct. ! def try_compile (self, body, lang="c"): ! """Try to compile a source file that consists of the text in 'body' ! (a multi-line string). Return true on success, false ! otherwise. """ from distutils.ccompiler import CompileError self._check_compiler() try: ! (src, obj) = self._compile(body, lang) ok = 1 except CompileError: --- 158,218 ---- # which is correct. ! # XXX need access to the header search path and maybe default macros. ! ! def try_cpp (self, body=None, headers=None, lang="c"): ! """Construct a source file from 'body' (a string containing lines ! of C/C++ code) and 'headers' (a list of header files to include) ! and run it through the preprocessor. Return true if the ! preprocessor succeeded, false if there were any errors. ! ('body' probably isn't of much use, but what the heck.) ! """ ! from distutils.ccompiler import CompileError ! self._check_compiler() ! ok = 1 ! try: ! self._preprocess(body, headers, lang) ! except CompileError: ! ok = 0 ! ! self._clean() ! return ok ! ! def search_cpp (self, pattern, body=None, headers=None, lang="c"): ! """Construct a source file (just like 'try_cpp()'), run it through ! the preprocessor, and return true if any line of the output matches ! 'pattern'. 'pattern' should either be a compiled regex object or a ! string containing a regex. If both 'body' and 'headers' are None, ! preprocesses an empty file -- which can be useful to determine the ! symbols the preprocessor and compiler set by default. ! """ ! ! self._check_compiler() ! (src, out) = self._preprocess(body, headers, lang) ! ! if type(pattern) is StringType: ! pattern = re.compile(pattern) ! ! file = open(out) ! match = 0 ! while 1: ! line = file.readline() ! if line == '': ! break ! if pattern.search(pattern): ! match = 1 ! break ! ! file.close() ! self._clean() ! return match ! ! def try_compile (self, body, headers=None, lang="c"): ! """Try to compile a source file built from 'body' and 'headers'. ! Return true on success, false otherwise. """ from distutils.ccompiler import CompileError self._check_compiler() try: ! self._compile(body, headers, lang) ok = 1 except CompileError: *************** *** 140,155 **** self.announce(ok and "success!" or "failure.") ! self._clean(src, obj) return ok ! def try_link (self, body, lang="c"): ! """Try to compile and link a source file (to an executable) that ! consists of the text in 'body' (a multi-line string). Return true ! on success, false otherwise. """ from distutils.ccompiler import CompileError, LinkError self._check_compiler() try: ! (src, obj, exe) = self._link(body, lang) ok = 1 except (CompileError, LinkError): --- 220,238 ---- self.announce(ok and "success!" or "failure.") ! self._clean() return ok ! def try_link (self, ! body, headers=None, ! libraries=None, library_dirs=None, ! lang="c"): ! """Try to compile and link a source file, built from 'body' and ! 'headers', to executable form. Return true on success, false ! otherwise. """ from distutils.ccompiler import CompileError, LinkError self._check_compiler() try: ! self._link(body, headers, libraries, library_dirs, lang) ok = 1 except (CompileError, LinkError): *************** *** 157,166 **** self.announce(ok and "success!" or "failure.") ! self._clean(src, obj, exe) return ok ! def try_run (self, body, lang="c"): ! """Try to compile, link to an executable, and run a program that ! consists of the text in 'body'. Return true on success, false otherwise. """ --- 240,252 ---- self.announce(ok and "success!" or "failure.") ! self._clean() return ok ! def try_run (self, ! body, headers=None, ! libraries=None, library_dirs=None, ! lang="c"): ! """Try to compile, link to an executable, and run a program ! built from 'body' and 'headers'. Return true on success, false otherwise. """ *************** *** 168,172 **** self._check_compiler() try: ! (src, obj, exe) = self._link(body, lang) self.spawn([exe]) ok = 1 --- 254,258 ---- self._check_compiler() try: ! self._link(body, headers, libraries, library_dirs, lang) self.spawn([exe]) ok = 1 *************** *** 175,180 **** self.announce(ok and "success!" or "failure.") ! self._clean(src, obj, exe) return ok # class config --- 261,324 ---- self.announce(ok and "success!" or "failure.") ! self._clean() return ok + + # -- High-level methods -------------------------------------------- + # (these are the ones that are actually likely to be useful + # when implementing a real-world config command!) + + def check_func (self, func, headers=None, + libraries=None, library_dirs=None, + decl=0, call=0): + + """Determine if function 'func' is available by constructing a + source file that refers to 'func', and compiles and links it. + If everything succeeds, returns true; otherwise returns false. + + The constructed source file starts out by including the header + files listed in 'headers'. If 'decl' is true, it then declares + 'func' (as "int func()"); you probably shouldn't supply 'headers' + and set 'decl' true in the same call, or you might get errors about + a conflicting declarations for 'func'. Finally, the constructed + 'main()' function either references 'func' or (if 'call' is true) + calls it. 'libraries' and 'library_dirs' are used when + linking. + """ + + self._check_compiler() + body = [] + if decl: + body.append("int %s ();" % func) + body.append("int main () {") + if call: + body.append(" %s();" % func) + else: + body.append(" %s;" % func) + body.append("}") + body = string.join(body, "\n") + "\n" + + return self.try_link(body, headers, libraries, library_dirs) + + # check_func () + + def check_header (self, header, lang="c"): + """Determine if the system header file named by 'header_file' + exists and can be found by the preprocessor; return true if so, + false otherwise. + """ + return self.try_cpp(headers=[header]) + + # class config + + + def dump_file (filename, head=None): + if head is None: + print filename + ":" + else: + print head + + file = open(filename) + sys.stdout.write(file.read()) + file.close() From python-dev@python.org Wed Jun 21 04:09:05 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 20 Jun 2000 20:09:05 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command install.py,1.37,1.38 Message-ID: <200006210309.UAA20997@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv20983 Modified Files: install.py Log Message: Rene Liebscher: when fixing up directories with an alternate root, include 'install_headers'. Index: install.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/install.py,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -r1.37 -r1.38 *** install.py 2000/06/17 01:34:45 1.37 --- install.py 2000/06/21 03:09:02 1.38 *************** *** 273,277 **** # dirs relative to it. if self.root is not None: ! for name in ('lib', 'purelib', 'platlib', 'scripts', 'data'): attr = "install_" + name new_val = change_root (self.root, getattr (self, attr)) --- 273,278 ---- # dirs relative to it. if self.root is not None: ! for name in ('lib', 'purelib', 'platlib', ! 'scripts', 'data', 'headers'): attr = "install_" + name new_val = change_root (self.root, getattr (self, attr)) From python-dev@python.org Wed Jun 21 04:12:09 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 20 Jun 2000 20:12:09 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command install_data.py,1.8,1.9 Message-ID: <200006210312.UAA21107@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv21094 Modified Files: install_data.py Log Message: Build the 'outfiles' list so 'get_outputs()' has something to return. (Bug spotted and originally fixed by Rene Liebscher; fix redone by me.) Index: install_data.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/install_data.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** install_data.py 2000/06/06 02:18:13 1.8 --- install_data.py 2000/06/21 03:12:07 1.9 *************** *** 26,30 **** def initialize_options (self): self.install_dir = None ! self.outfiles = None self.root = None self.data_files = self.distribution.data_files --- 26,30 ---- def initialize_options (self): self.install_dir = None ! self.outfiles = [] self.root = None self.data_files = self.distribution.data_files *************** *** 41,45 **** if type(f) == StringType: # its a simple file, so copy it ! self.copy_file(f, self.install_dir) else: # its a tuple with path to install to and a list of files --- 41,46 ---- if type(f) == StringType: # its a simple file, so copy it ! out = self.copy_file(f, self.install_dir) ! self.outfiles.append(out) else: # its a tuple with path to install to and a list of files *************** *** 51,55 **** self.mkpath(dir) for data in f[1]: ! self.copy_file(data, dir) def get_inputs (self): --- 52,57 ---- self.mkpath(dir) for data in f[1]: ! out = self.copy_file(data, dir) ! self.outfiles.append(out) def get_inputs (self): *************** *** 57,59 **** def get_outputs (self): ! return self.outfiles or [] --- 59,61 ---- def get_outputs (self): ! return self.outfiles From python-dev@python.org Wed Jun 21 04:13:54 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 20 Jun 2000 20:13:54 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command install_headers.py,1.1,1.2 Message-ID: <200006210313.UAA21152@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv21126 Modified Files: install_headers.py Log Message: Build the 'outfiles' list so 'get_outputs()' has something to return. (Bug spotted and originally fixed by Rene Liebscher; fix redone by me.) Index: install_headers.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/install_headers.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** install_headers.py 2000/05/27 01:25:16 1.1 --- install_headers.py 2000/06/21 03:13:51 1.2 *************** *** 8,11 **** --- 8,12 ---- __revision__ = "$Id$" + import os from distutils.core import Command *************** *** 22,25 **** --- 23,27 ---- def initialize_options (self): self.install_dir = None + self.outfiles = [] def finalize_options (self): *************** *** 34,39 **** self.mkpath(self.install_dir) for header in headers: ! self.copy_file(header, self.install_dir) # run() --- 36,47 ---- self.mkpath(self.install_dir) for header in headers: ! out = self.copy_file(header, self.install_dir) ! self.outfiles.append(out) + def get_inputs (self): + return self.distribution.headers or [] + + def get_outputs (self): + return self.outfiles # run() From python-dev@python.org Wed Jun 21 04:14:29 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 20 Jun 2000 20:14:29 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command install_headers.py,1.2,1.3 Message-ID: <200006210314.UAA21185@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv21177 Modified Files: install_headers.py Log Message: Delete spurious comment. Index: install_headers.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/install_headers.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** install_headers.py 2000/06/21 03:13:51 1.2 --- install_headers.py 2000/06/21 03:14:27 1.3 *************** *** 44,48 **** def get_outputs (self): return self.outfiles - # run() # class install_headers --- 44,47 ---- From python-dev@python.org Wed Jun 21 04:29:59 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 20 Jun 2000 20:29:59 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command sdist.py,1.32,1.33 Message-ID: <200006210329.UAA21852@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv21805 Modified Files: sdist.py Log Message: Fix inspired by Rene Liebscher: if setup script is newer than the manifest, regenerate the manifest. Index: sdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/sdist.py,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -r1.32 -r1.33 *** sdist.py 2000/06/08 01:22:48 1.32 --- sdist.py 2000/06/21 03:29:57 1.33 *************** *** 174,185 **** depends on the user's options and the state of the filesystem. """ template_exists = os.path.isfile (self.template) if template_exists: template_newer = newer (self.template, self.manifest) # Regenerate the manifest if necessary (or if explicitly told to) ! if ((template_exists and template_newer) or ! self.force_manifest or ! self.manifest_only): if not template_exists: --- 174,208 ---- depends on the user's options and the state of the filesystem. """ + + # If we have a manifest template, see if it's newer than the + # manifest; if so, we'll regenerate the manifest. template_exists = os.path.isfile (self.template) if template_exists: template_newer = newer (self.template, self.manifest) + # The contents of the manifest file almost certainly depend on the + # setup script as well as the manifest template -- so if the setup + # script is newer than the manifest, we'll regenerate the manifest + # from the template. (Well, not quite: if we already have a + # manifest, but there's no template -- which will happen if the + # developer elects to generate a manifest some other way -- then we + # can't regenerate the manifest, so we don't.) + setup_newer = newer(sys.argv[0], self.manifest) + + # cases: + # 1) no manifest, template exists: generate manifest + # (covered by 2a: no manifest == template newer) + # 2) manifest & template exist: + # 2a) template or setup script newer than manifest: + # regenerate manifest + # 2b) manifest newer than both: + # do nothing (unless --force or --manifest-only) + # 3) manifest exists, no template: + # do nothing (unless --force or --manifest-only) + # 4) no manifest, no template: generate w/ warning ("defaults only") + # Regenerate the manifest if necessary (or if explicitly told to) ! if ((template_exists and (template_newer or setup_newer)) or ! self.force_manifest or self.manifest_only): if not template_exists: From python-dev@python.org Wed Jun 21 04:33:05 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 20 Jun 2000 20:33:05 -0700 Subject: [Python-checkins] CVS: distutils/distutils cygwinccompiler.py,NONE,1.1 Message-ID: <200006210333.UAA22040@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv22033 Added Files: cygwinccompiler.py Log Message: Implementation of the CCompiler class for Cygwin and Mingw32, ie. the two major ports of GCC to Windows. Contributed by Rene Liebscher, and quite untested by me. Apparently requires tweaking Python's installed config.h and adding a libpython.a to build extensions. ***** Error reading new file(2, 'No such file or directory') From python-dev@python.org Wed Jun 21 21:01:13 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 21 Jun 2000 13:01:13 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib xmllib.py,1.17,1.18 Message-ID: <200006212001.NAA00381@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv311 Modified Files: xmllib.py Log Message: Sjoerd Mullender: These two fixes were approved by me. Peter Kropf: There's a problem with the xmllib module when used with JPython. Specifically, the JPython re module has trouble with the () characters in strings passed into re.compile. Spiros Papadimitriou: I just downloaded xmllib.py ver. 0.3 from python.org and there seems to be a slight typo: Line 654 ("tag = self.stack[-1][0]" in parse_endtag), is indented one level more than it should be. I just thought I'd let you know... Index: xmllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xmllib.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** xmllib.py 2000/02/04 15:39:30 1.17 --- xmllib.py 2000/06/21 20:01:10 1.18 *************** *** 28,32 **** _S + '(?P' + _Name + ')' '(' + _opS + '=' + _opS + ! '(?P'+_QStr+'|[-a-zA-Z0-9.:+*%?!()_#=~]+))?') starttagopen = re.compile('<' + _Name) starttagend = re.compile(_opS + '(?P/?)>') --- 28,32 ---- _S + '(?P' + _Name + ')' '(' + _opS + '=' + _opS + ! '(?P'+_QStr+'|[-a-zA-Z0-9.:+*%?!\(\)_#=~]+))?') starttagopen = re.compile('<' + _Name) starttagend = re.compile(_opS + '(?P/?)>') *************** *** 44,49 **** # PUBLIC PubidLiteral SystemLiteral _SystemLiteral = '(?P<%s>'+_QStr+')' ! _PublicLiteral = '(?P<%s>"[-\'()+,./:=?;!*#@$_%% \n\ra-zA-Z0-9]*"|' \ ! "'[-()+,./:=?;!*#@$_%% \n\ra-zA-Z0-9]*')" _ExternalId = '(?:SYSTEM|' \ 'PUBLIC'+_S+_PublicLiteral%'pubid'+ \ --- 44,49 ---- # PUBLIC PubidLiteral SystemLiteral _SystemLiteral = '(?P<%s>'+_QStr+')' ! _PublicLiteral = '(?P<%s>"[-\'\(\)+,./:=?;!*#@$_%% \n\ra-zA-Z0-9]*"|' \ ! "'[-\(\)+,./:=?;!*#@$_%% \n\ra-zA-Z0-9]*')" _ExternalId = '(?:SYSTEM|' \ 'PUBLIC'+_S+_PublicLiteral%'pubid'+ \ *************** *** 653,657 **** if not self.__accept_missing_endtag_name: self.syntax_error('no name specified in end tag') ! tag = self.stack[-1][0] k = i+2 else: --- 653,657 ---- if not self.__accept_missing_endtag_name: self.syntax_error('no name specified in end tag') ! tag = self.stack[-1][0] k = i+2 else: From python-dev@python.org Wed Jun 21 22:21:07 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 21 Jun 2000 14:21:07 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib codecs.py,1.9,1.10 Message-ID: <200006212121.OAA14836@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv14827/Lib Modified Files: codecs.py Log Message: Marc-Andre Lemburg : Made codecs.open() default to 'rb' as file mode. Index: codecs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/codecs.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** codecs.py 2000/05/01 16:17:32 1.9 --- codecs.py 2000/06/21 21:21:04 1.10 *************** *** 459,463 **** ### Shortcuts ! def open(filename, mode, encoding=None, errors='strict', buffering=1): """ Open an encoded file using the given mode and return --- 459,463 ---- ### Shortcuts ! def open(filename, mode='rb', encoding=None, errors='strict', buffering=1): """ Open an encoded file using the given mode and return *************** *** 468,471 **** --- 468,476 ---- codecs. Output is also codec dependent and will usually by Unicode as well. + + Files are always opened in binary mode, even if no binary mode + was specified. Thisis done to avoid data loss due to encodings + using 8-bit values. The default file mode is 'rb' meaning to + open the file in binary read mode. encoding specifies the encoding which is to be used for the From python-dev@python.org Fri Jun 23 02:36:24 2000 From: python-dev@python.org (A.M. Kuchling) Date: Thu, 22 Jun 2000 18:36:24 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _cursesmodule.c,2.24,2.25 Message-ID: <200006230136.SAA21509@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv21471 Modified Files: _cursesmodule.c Log Message: Release the global interpreter lock around the most important functions that might block or pause Index: _cursesmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_cursesmodule.c,v retrieving revision 2.24 retrieving revision 2.25 diff -C2 -r2.24 -r2.25 *** _cursesmodule.c 2000/06/21 01:41:48 2.24 --- _cursesmodule.c 2000/06/23 01:36:21 2.25 *************** *** 634,643 **** --- 634,647 ---- switch (ARG_COUNT(arg)) { case 0: + Py_BEGIN_ALLOW_THREADS rtn = wgetch(self->win); + Py_END_ALLOW_THREADS break; case 2: if (!PyArg_Parse(arg,"(ii);y,x",&y,&x)) return NULL; + Py_BEGIN_ALLOW_THREADS rtn = mvwgetch(self->win,y,x); + Py_END_ALLOW_THREADS break; default: *************** *** 658,667 **** --- 662,675 ---- switch (ARG_COUNT(arg)) { case 0: + Py_BEGIN_ALLOW_THREADS rtn = wgetch(self->win); + Py_END_ALLOW_THREADS break; case 2: if (!PyArg_Parse(arg,"(ii);y,x",&y,&x)) return NULL; + Py_BEGIN_ALLOW_THREADS rtn = mvwgetch(self->win,y,x); + Py_END_ALLOW_THREADS break; default: *************** *** 686,700 **** --- 694,714 ---- switch (ARG_COUNT(arg)) { case 0: + Py_BEGIN_ALLOW_THREADS rtn2 = wgetstr(self->win,rtn); + Py_END_ALLOW_THREADS break; case 1: if (!PyArg_Parse(arg,"i;n", &n)) return NULL; + Py_BEGIN_ALLOW_THREADS rtn2 = wgetnstr(self->win,rtn,n); + Py_END_ALLOW_THREADS break; case 2: if (!PyArg_Parse(arg,"(ii);y,x",&y,&x)) return NULL; + Py_BEGIN_ALLOW_THREADS rtn2 = mvwgetstr(self->win,y,x,rtn); + Py_END_ALLOW_THREADS break; case 3: *************** *** 703,710 **** --- 717,728 ---- #if defined(__sgi__) || defined(__sun__) /* Untested */ + Py_BEGIN_ALLOW_THREADS rtn2 = wmove(self->win,y,x)==ERR ? ERR : wgetnstr(self->win, rtn, n); + Py_END_ALLOW_THREADS #else + Py_BEGIN_ALLOW_THREADS rtn2 = mvwgetnstr(self->win, y, x, rtn, n); + Py_END_ALLOW_THREADS #endif break; *************** *** 997,1000 **** --- 1015,1019 ---- { int pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol; + int rtn; if (self->win->_flags & _ISPAD) { *************** *** 1007,1017 **** &smincol, &smaxrow, &smaxcol)) return NULL; ! return PyCursesCheckERR(pnoutrefresh(self->win, ! pminrow, pmincol, sminrow, ! smincol, smaxrow, smaxcol), ! "pnoutrefresh"); default: PyErr_SetString(PyCursesError, ! "noutrefresh was called for a pad;" \ "requires 6 arguments"); return NULL; --- 1026,1038 ---- &smincol, &smaxrow, &smaxcol)) return NULL; ! Py_BEGIN_ALLOW_THREADS ! rtn = pnoutrefresh(self->win, ! pminrow, pmincol, sminrow, ! smincol, smaxrow, smaxcol), ! Py_END_ALLOW_THREADS ! return PyCursesCheckERR(rtn, "pnoutrefresh"); default: PyErr_SetString(PyCursesError, ! "noutrefresh() called for a pad " "requires 6 arguments"); return NULL; *************** *** 1020,1024 **** if (!PyArg_NoArgs(arg)) return NULL; ! return PyCursesCheckERR(wnoutrefresh(self->win), "wnoutrefresh"); } } --- 1041,1049 ---- if (!PyArg_NoArgs(arg)) return NULL; ! ! Py_BEGIN_ALLOW_THREADS ! rtn = wnoutrefresh(self->win); ! Py_END_ALLOW_THREADS ! return PyCursesCheckERR(rtn, "wnoutrefresh"); } } *************** *** 1058,1061 **** --- 1083,1087 ---- { int pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol; + int rtn; if (self->win->_flags & _ISPAD) { *************** *** 1068,1078 **** &smincol, &smaxrow, &smaxcol)) return NULL; ! return PyCursesCheckERR(prefresh(self->win, ! pminrow, pmincol, sminrow, ! smincol, smaxrow, smaxcol), ! "prefresh"); default: PyErr_SetString(PyCursesError, ! "refresh was called for a pad; requires 6 arguments"); return NULL; } --- 1094,1108 ---- &smincol, &smaxrow, &smaxcol)) return NULL; ! ! Py_BEGIN_ALLOW_THREADS ! rtn = prefresh(self->win, ! pminrow, pmincol, sminrow, ! smincol, smaxrow, smaxcol), ! ! Py_END_ALLOW_THREADS ! return PyCursesCheckERR(rtn, "prefresh"); default: PyErr_SetString(PyCursesError, ! "refresh() for a pad requires 6 arguments"); return NULL; } *************** *** 1080,1084 **** if (!PyArg_NoArgs(arg)) return NULL; ! return PyCursesCheckERR(wrefresh(self->win), "wrefresh"); } } --- 1110,1117 ---- if (!PyArg_NoArgs(arg)) return NULL; ! Py_BEGIN_ALLOW_THREADS ! rtn = wrefresh(self->win); ! Py_END_ALLOW_THREADS ! return PyCursesCheckERR(rtn); } } From python-dev@python.org Fri Jun 23 02:42:43 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 22 Jun 2000 18:42:43 -0700 Subject: [Python-checkins] CVS: distutils/distutils file_util.py,1.3,1.4 Message-ID: <200006230142.SAA21988@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv21979 Modified Files: file_util.py Log Message: Bastian Kleineidam: 'copy_file()' now returns the output filename, rather than a boolean indicating whether it did the copy. Index: file_util.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/file_util.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** file_util.py 2000/05/20 16:05:34 1.3 --- file_util.py 2000/06/23 01:42:40 1.4 *************** *** 97,103 **** contents. ! Return true if the file was copied (or would have been copied), ! false otherwise (ie. 'update' was true and the destination is ! up-to-date).""" # XXX if the destination file already exists, we clobber it if --- 97,102 ---- contents. ! Return the name of the destination file, whether it was actually ! copied or not.""" # XXX if the destination file already exists, we clobber it if *************** *** 124,128 **** if verbose: print "not copying %s (output up-to-date)" % src ! return 0 try: --- 123,127 ---- if verbose: print "not copying %s (output up-to-date)" % src ! return dst try: *************** *** 138,142 **** if dry_run: ! return 1 # On a Mac, use the native file copy routine --- 137,141 ---- if dry_run: ! return dst # On a Mac, use the native file copy routine *************** *** 172,176 **** os.chmod (dst, S_IMODE (st[ST_MODE])) ! return 1 # copy_file () --- 171,175 ---- os.chmod (dst, S_IMODE (st[ST_MODE])) ! return dst # copy_file () From python-dev@python.org Fri Jun 23 15:18:13 2000 From: python-dev@python.org (Jeremy Hylton) Date: Fri, 23 Jun 2000 07:18:13 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects classobject.c,2.86,2.87 dictobject.c,2.52,2.53 funcobject.c,2.20,2.21 listobject.c,2.73,2.74 tupleobject.c,2.36,2.37 Message-ID: <200006231418.HAA02869@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv2798/Objects Modified Files: classobject.c dictobject.c funcobject.c listobject.c tupleobject.c Log Message: Round 1 of Neil Schemenauer's GC patches: This patch adds the type methods traverse and clear necessary for GC implementation. Index: classobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v retrieving revision 2.86 retrieving revision 2.87 diff -C2 -r2.86 -r2.87 *** classobject.c 2000/05/03 23:44:34 2.86 --- classobject.c 2000/06/23 14:18:11 2.87 *************** *** 388,391 **** --- 388,428 ---- } + static int + class_traverse(PyClassObject *o, visitproc visit, void *arg) + { + int err; + if (o->cl_bases) { + err = visit(o->cl_bases, arg); + if (err) + return err; + } + if (o->cl_dict) { + err = visit(o->cl_dict, arg); + if (err) + return err; + } + if (o->cl_name) { + err = visit(o->cl_name, arg); + if (err) + return err; + } + if (o->cl_getattr) { + err = visit(o->cl_getattr, arg); + if (err) + return err; + } + if (o->cl_setattr) { + err = visit(o->cl_setattr, arg); + if (err) + return err; + } + if (o->cl_delattr) { + err = visit(o->cl_delattr, arg); + if (err) + return err; + } + return 0; + } + PyTypeObject PyClass_Type = { PyObject_HEAD_INIT(&PyType_Type) *************** *** 408,411 **** --- 445,452 ---- (getattrofunc)class_getattr, /*tp_getattro*/ (setattrofunc)class_setattr, /*tp_setattro*/ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + 0, /* tp_doc */ + (traverseproc)class_traverse, /* tp_traverse */ }; *************** *** 850,853 **** --- 891,911 ---- } + static int + instance_traverse(PyInstanceObject *o, visitproc visit, void *arg) + { + int err; + if (o->in_class) { + err = visit((PyObject *)(o->in_class), arg); + if (err) + return err; + } + if (o->in_dict) { + err = visit(o->in_dict, arg); + if (err) + return err; + } + return 1; + } + static PyObject *getitemstr, *setitemstr, *delitemstr, *lenstr; *************** *** 1473,1477 **** (setattrofunc)instance_setattr, /*tp_setattro*/ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT, /*tp_flags */ }; --- 1531,1537 ---- (setattrofunc)instance_setattr, /*tp_setattro*/ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT, /*tp_flags*/ ! 0, /* tp_doc */ ! (traverseproc)instance_traverse, /* tp_traverse */ }; *************** *** 1663,1666 **** --- 1723,1748 ---- } + static int + instancemethod_traverse(PyMethodObject *im, visitproc visit, void *arg) + { + int err; + if (im->im_func) { + err = visit(im->im_func, arg); + if (err) + return err; + } + if (im->im_self) { + err = visit(im->im_self, arg); + if (err) + return err; + } + if (im->im_class) { + err = visit(im->im_class, arg); + if (err) + return err; + } + return 1; + } + PyTypeObject PyMethod_Type = { PyObject_HEAD_INIT(&PyType_Type) *************** *** 1683,1686 **** --- 1765,1772 ---- (getattrofunc)instancemethod_getattr, /*tp_getattro*/ 0, /*tp_setattro*/ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + 0, /* tp_doc */ + (traverseproc)instancemethod_traverse, /* tp_traverse */ }; Index: dictobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/dictobject.c,v retrieving revision 2.52 retrieving revision 2.53 diff -C2 -r2.52 -r2.53 *** dictobject.c 2000/05/03 23:44:34 2.52 --- dictobject.c 2000/06/23 14:18:11 2.53 *************** *** 1039,1042 **** --- 1039,1067 ---- } + static int + dict_traverse(PyObject *op, visitproc visit, void *arg) + { + int i = 0, err; + PyObject *pk; + PyObject *pv; + + while (PyDict_Next(op, &i, &pk, &pv)) { + err = visit(pk, arg); + if (err) + return err; + err = visit(pv, arg); + if (err) + return err; + } + return 0; + } + + static int + dict_tp_clear(PyObject *op) + { + PyDict_Clear(op); + return 0; + } + static PyMethodDef mapp_methods[] = { {"has_key", (PyCFunction)dict_has_key, METH_VARARGS}, *************** *** 1074,1077 **** --- 1099,1112 ---- 0, /*tp_as_sequence*/ &dict_as_mapping, /*tp_as_mapping*/ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + 0, /* tp_doc */ + (traverseproc)dict_traverse, /* tp_traverse */ + (inquiry)dict_tp_clear, /* tp_clear */ }; Index: funcobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/funcobject.c,v retrieving revision 2.20 retrieving revision 2.21 diff -C2 -r2.20 -r2.21 *** funcobject.c 2000/05/03 23:44:35 2.20 --- funcobject.c 2000/06/23 14:18:11 2.21 *************** *** 240,243 **** --- 240,275 ---- } + static int + func_traverse(PyFunctionObject *f, visitproc visit, void *arg) + { + int err; + if (f->func_code) { + err = visit(f->func_code, arg); + if (err) + return err; + } + if (f->func_globals) { + err = visit(f->func_globals, arg); + if (err) + return err; + } + if (f->func_defaults) { + err = visit(f->func_defaults, arg); + if (err) + return err; + } + if (f->func_doc) { + err = visit(f->func_doc, arg); + if (err) + return err; + } + if (f->func_name) { + err = visit(f->func_name, arg); + if (err) + return err; + } + return 0; + } + PyTypeObject PyFunction_Type = { PyObject_HEAD_INIT(&PyType_Type) *************** *** 256,258 **** --- 288,298 ---- 0, /*tp_as_mapping*/ (hashfunc)func_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + 0, /* tp_doc */ + (traverseproc)func_traverse, /* tp_traverse */ }; Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.73 retrieving revision 2.74 diff -C2 -r2.73 -r2.74 *** listobject.c 2000/06/18 18:43:14 2.73 --- listobject.c 2000/06/23 14:18:11 2.74 *************** *** 1419,1422 **** --- 1419,1446 ---- } + static int + list_traverse(PyListObject *o, visitproc visit, void *arg) + { + int i, err; + PyObject *x; + + for (i = o->ob_size; --i >= 0; ) { + x = o->ob_item[i]; + if (x != NULL) { + err = visit(x, arg); + if (err) + return err; + } + } + return 0; + } + + static int + list_clear(PyListObject *lp) + { + (void) PyList_SetSlice((PyObject *)lp, 0, lp->ob_size, 0); + return 0; + } + static char append_doc[] = "L.append(object) -- append object to end"; *************** *** 1492,1495 **** --- 1516,1522 ---- 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT, /*tp_flags*/ + 0, /* tp_doc */ + (traverseproc)list_traverse, /* tp_traverse */ + (inquiry)list_clear, /* tp_clear */ }; *************** *** 1568,1571 **** --- 1595,1600 ---- 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT, /*tp_flags*/ + 0, /* tp_doc */ + (traverseproc)list_traverse, /* tp_traverse */ }; Index: tupleobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/tupleobject.c,v retrieving revision 2.36 retrieving revision 2.37 diff -C2 -r2.36 -r2.37 *** tupleobject.c 2000/06/16 17:05:57 2.36 --- tupleobject.c 2000/06/23 14:18:11 2.37 *************** *** 421,424 **** --- 421,441 ---- } + static int + tupletraverse(PyTupleObject *o, visitproc visit, void *arg) + { + int i, err; + PyObject *x; + + for (i = o->ob_size; --i >= 0; ) { + x = o->ob_item[i]; + if (x != NULL) { + err = visit(x, arg); + if (err) + return err; + } + } + return 0; + } + static PySequenceMethods tuple_as_sequence = { (inquiry)tuplelength, /*sq_length*/ *************** *** 454,457 **** --- 471,476 ---- 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT, /*tp_flags*/ + 0, /*tp_doc*/ + (traverseproc)tupletraverse, /* tp_traverse */ }; From python-dev@python.org Fri Jun 23 15:18:13 2000 From: python-dev@python.org (Jeremy Hylton) Date: Fri, 23 Jun 2000 07:18:13 -0700 Subject: [Python-checkins] CVS: python/dist/src/Include object.h,2.54,2.55 Message-ID: <200006231418.HAA02861@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Include In directory slayer.i.sourceforge.net:/tmp/cvs-serv2798/Include Modified Files: object.h Log Message: Round 1 of Neil Schemenauer's GC patches: This patch adds the type methods traverse and clear necessary for GC implementation. Index: object.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/object.h,v retrieving revision 2.54 retrieving revision 2.55 diff -C2 -r2.54 -r2.55 *** object.h 2000/04/24 15:40:45 2.54 --- object.h 2000/06/23 14:18:10 2.55 *************** *** 146,149 **** --- 146,151 ---- typedef int (*getcharbufferproc) Py_PROTO((PyObject *, int, const char **)); typedef int (*objobjproc) Py_PROTO((PyObject *, PyObject *)); + typedef int (*visitproc) Py_PROTO((PyObject *, void *)); + typedef int (*traverseproc) Py_PROTO((PyObject *, visitproc, void *)); typedef struct { *************** *** 244,250 **** char *tp_doc; /* Documentation string */ /* More spares */ - long tp_xxx5; - long tp_xxx6; long tp_xxx7; long tp_xxx8; --- 246,256 ---- char *tp_doc; /* Documentation string */ + /* call function for all accessible objects */ + traverseproc tp_traverse; + + /* delete references to contained objects */ + inquiry tp_clear; + /* More spares */ long tp_xxx7; long tp_xxx8; From python-dev@python.org Fri Jun 23 15:36:35 2000 From: python-dev@python.org (Jeremy Hylton) Date: Fri, 23 Jun 2000 07:36:35 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects object.c,2.71,2.72 Message-ID: <200006231436.HAA04287@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv4239/Objects Modified Files: object.c Log Message: raise TypeError when PyObject_Get/SetAttr called with non-string name Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.71 retrieving revision 2.72 diff -C2 -r2.71 -r2.72 *** object.c 2000/06/09 16:20:39 2.71 --- object.c 2000/06/23 14:36:32 2.72 *************** *** 601,606 **** if (v->ob_type->tp_getattro != NULL) return (*v->ob_type->tp_getattro)(v, name); ! else ! return PyObject_GetAttrString(v, PyString_AsString(name)); } --- 601,611 ---- if (v->ob_type->tp_getattro != NULL) return (*v->ob_type->tp_getattro)(v, name); ! ! if (!PyString_Check(name)) { ! PyErr_SetString(PyExc_TypeError, ! "attribute name must be string"); ! return NULL; ! } ! return PyObject_GetAttrString(v, PyString_AS_STRING(name)); } *************** *** 627,636 **** int err; Py_INCREF(name); ! PyString_InternInPlace(&name); if (v->ob_type->tp_setattro != NULL) err = (*v->ob_type->tp_setattro)(v, name, value); ! else err = PyObject_SetAttrString( ! v, PyString_AsString(name), value); Py_DECREF(name); return err; --- 632,648 ---- int err; Py_INCREF(name); ! if (PyString_Check(name)) ! PyString_InternInPlace(&name); if (v->ob_type->tp_setattro != NULL) err = (*v->ob_type->tp_setattro)(v, name, value); ! else if (PyString_Check(name)) { err = PyObject_SetAttrString( ! v, PyString_AS_STRING(name), value); ! } ! else { ! PyErr_SetString(PyExc_TypeError, ! "attribute name must be string"); ! err = -1; ! } Py_DECREF(name); return err; From python-dev@python.org Fri Jun 23 18:14:59 2000 From: python-dev@python.org (Jeremy Hylton) Date: Fri, 23 Jun 2000 10:14:59 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects classobject.c,2.87,2.88 Message-ID: <200006231714.KAA31555@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv31543 Modified Files: classobject.c Log Message: traverse functions should return 0 on success Index: classobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v retrieving revision 2.87 retrieving revision 2.88 diff -C2 -r2.87 -r2.88 *** classobject.c 2000/06/23 14:18:11 2.87 --- classobject.c 2000/06/23 17:14:56 2.88 *************** *** 905,909 **** return err; } ! return 1; } --- 905,909 ---- return err; } ! return 0; } *************** *** 1742,1746 **** return err; } ! return 1; } --- 1742,1746 ---- return err; } ! return 0; } From python-dev@python.org Fri Jun 23 20:37:04 2000 From: python-dev@python.org (Jeremy Hylton) Date: Fri, 23 Jun 2000 12:37:04 -0700 Subject: [Python-checkins] CVS: python/dist/src/Include object.h,2.55,2.56 objimpl.h,2.15,2.16 Message-ID: <200006231937.MAA19761@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Include In directory slayer.i.sourceforge.net:/tmp/cvs-serv19626/Include Modified Files: object.h objimpl.h Log Message: part 2 of Neil Schemenauer's GC patches: This patch modifies the type structures of objects that participate in GC. The object's tp_basicsize is increased when GC is enabled. GC information is prefixed to the object to maintain binary compatibility. GC objects also define the tp_flag Py_TPFLAGS_GC. Index: object.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/object.h,v retrieving revision 2.55 retrieving revision 2.56 diff -C2 -r2.55 -r2.56 *** object.h 2000/06/23 14:18:10 2.55 --- object.h 2000/06/23 19:37:01 2.56 *************** *** 326,329 **** --- 326,336 ---- #define Py_TPFLAGS_HAVE_SEQUENCE_IN (1L<<1) + /* Objects which participate in garbage collection (see objimp.h) */ + #ifdef WITH_CYCLE_GC + #define Py_TPFLAGS_GC (1L<<2) + #else + #define Py_TPFLAGS_GC 0 + #endif + #define Py_TPFLAGS_DEFAULT (Py_TPFLAGS_HAVE_GETCHARBUFFER | \ Py_TPFLAGS_HAVE_SEQUENCE_IN) Index: objimpl.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/objimpl.h,v retrieving revision 2.15 retrieving revision 2.16 diff -C2 -r2.15 -r2.16 *** objimpl.h 2000/05/03 23:44:23 2.15 --- objimpl.h 2000/06/23 19:37:01 2.16 *************** *** 235,238 **** --- 235,244 ---- constructor you would start directly with PyObject_Init/InitVar. */ + + + #ifndef WITH_CYCLE_GC + #define PyGC_INFO_SIZE 0 + #endif + #ifdef __cplusplus } From python-dev@python.org Fri Jun 23 20:37:04 2000 From: python-dev@python.org (Jeremy Hylton) Date: Fri, 23 Jun 2000 12:37:04 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects classobject.c,2.88,2.89 dictobject.c,2.53,2.54 funcobject.c,2.21,2.22 listobject.c,2.74,2.75 tupleobject.c,2.37,2.38 Message-ID: <200006231937.MAA19769@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv19626/Objects Modified Files: classobject.c dictobject.c funcobject.c listobject.c tupleobject.c Log Message: part 2 of Neil Schemenauer's GC patches: This patch modifies the type structures of objects that participate in GC. The object's tp_basicsize is increased when GC is enabled. GC information is prefixed to the object to maintain binary compatibility. GC objects also define the tp_flag Py_TPFLAGS_GC. Index: classobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v retrieving revision 2.88 retrieving revision 2.89 diff -C2 -r2.88 -r2.89 *** classobject.c 2000/06/23 17:14:56 2.88 --- classobject.c 2000/06/23 19:37:01 2.89 *************** *** 429,433 **** 0, "class", ! sizeof(PyClassObject), 0, (destructor)class_dealloc, /*tp_dealloc*/ --- 429,433 ---- 0, "class", ! sizeof(PyClassObject) + PyGC_INFO_SIZE, 0, (destructor)class_dealloc, /*tp_dealloc*/ *************** *** 446,450 **** (setattrofunc)class_setattr, /*tp_setattro*/ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT, /*tp_flags*/ 0, /* tp_doc */ (traverseproc)class_traverse, /* tp_traverse */ --- 446,450 ---- (setattrofunc)class_setattr, /*tp_setattro*/ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC, /*tp_flags*/ 0, /* tp_doc */ (traverseproc)class_traverse, /* tp_traverse */ *************** *** 1514,1518 **** 0, "instance", ! sizeof(PyInstanceObject), 0, (destructor)instance_dealloc, /*tp_dealloc*/ --- 1514,1518 ---- 0, "instance", ! sizeof(PyInstanceObject) + PyGC_INFO_SIZE, 0, (destructor)instance_dealloc, /*tp_dealloc*/ *************** *** 1531,1535 **** (setattrofunc)instance_setattr, /*tp_setattro*/ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT, /*tp_flags*/ 0, /* tp_doc */ (traverseproc)instance_traverse, /* tp_traverse */ --- 1531,1535 ---- (setattrofunc)instance_setattr, /*tp_setattro*/ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC, /*tp_flags*/ 0, /* tp_doc */ (traverseproc)instance_traverse, /* tp_traverse */ *************** *** 1749,1753 **** 0, "instance method", ! sizeof(PyMethodObject), 0, (destructor)instancemethod_dealloc, /*tp_dealloc*/ --- 1749,1753 ---- 0, "instance method", ! sizeof(PyMethodObject) + PyGC_INFO_SIZE, 0, (destructor)instancemethod_dealloc, /*tp_dealloc*/ *************** *** 1766,1770 **** 0, /*tp_setattro*/ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT, /*tp_flags*/ 0, /* tp_doc */ (traverseproc)instancemethod_traverse, /* tp_traverse */ --- 1766,1770 ---- 0, /*tp_setattro*/ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC, /*tp_flags*/ 0, /* tp_doc */ (traverseproc)instancemethod_traverse, /* tp_traverse */ Index: dictobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/dictobject.c,v retrieving revision 2.53 retrieving revision 2.54 diff -C2 -r2.53 -r2.54 *** dictobject.c 2000/06/23 14:18:11 2.53 --- dictobject.c 2000/06/23 19:37:01 2.54 *************** *** 1088,1092 **** 0, "dictionary", ! sizeof(dictobject), 0, (destructor)dict_dealloc, /*tp_dealloc*/ --- 1088,1092 ---- 0, "dictionary", ! sizeof(dictobject) + PyGC_INFO_SIZE, 0, (destructor)dict_dealloc, /*tp_dealloc*/ *************** *** 1105,1109 **** 0, /* tp_setattro */ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT, /*tp_flags*/ 0, /* tp_doc */ (traverseproc)dict_traverse, /* tp_traverse */ --- 1105,1109 ---- 0, /* tp_setattro */ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC, /*tp_flags*/ 0, /* tp_doc */ (traverseproc)dict_traverse, /* tp_traverse */ Index: funcobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/funcobject.c,v retrieving revision 2.21 retrieving revision 2.22 diff -C2 -r2.21 -r2.22 *** funcobject.c 2000/06/23 14:18:11 2.21 --- funcobject.c 2000/06/23 19:37:01 2.22 *************** *** 276,280 **** 0, "function", ! sizeof(PyFunctionObject), 0, (destructor)func_dealloc, /*tp_dealloc*/ --- 276,280 ---- 0, "function", ! sizeof(PyFunctionObject) + PyGC_INFO_SIZE, 0, (destructor)func_dealloc, /*tp_dealloc*/ *************** *** 293,297 **** 0, /*tp_setattro*/ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT, /*tp_flags*/ 0, /* tp_doc */ (traverseproc)func_traverse, /* tp_traverse */ --- 293,297 ---- 0, /*tp_setattro*/ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC, /*tp_flags*/ 0, /* tp_doc */ (traverseproc)func_traverse, /* tp_traverse */ Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.74 retrieving revision 2.75 diff -C2 -r2.74 -r2.75 *** listobject.c 2000/06/23 14:18:11 2.74 --- listobject.c 2000/06/23 19:37:01 2.75 *************** *** 72,76 **** } /* PyObject_NewVar is inlined */ ! op = (PyListObject *) PyObject_MALLOC(sizeof(PyListObject)); if (op == NULL) { return PyErr_NoMemory(); --- 72,77 ---- } /* PyObject_NewVar is inlined */ ! op = (PyListObject *) PyObject_MALLOC(sizeof(PyListObject) ! + PyGC_INFO_SIZE); if (op == NULL) { return PyErr_NoMemory(); *************** *** 1498,1502 **** 0, "list", ! sizeof(PyListObject), 0, (destructor)list_dealloc, /*tp_dealloc*/ --- 1499,1503 ---- 0, "list", ! sizeof(PyListObject) + PyGC_INFO_SIZE, 0, (destructor)list_dealloc, /*tp_dealloc*/ *************** *** 1515,1519 **** 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ ! Py_TPFLAGS_DEFAULT, /*tp_flags*/ 0, /* tp_doc */ (traverseproc)list_traverse, /* tp_traverse */ --- 1516,1520 ---- 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC, /*tp_flags*/ 0, /* tp_doc */ (traverseproc)list_traverse, /* tp_traverse */ *************** *** 1577,1581 **** 0, "list (immutable, during sort)", ! sizeof(PyListObject), 0, 0, /*tp_dealloc*/ /* Cannot happen */ --- 1578,1582 ---- 0, "list (immutable, during sort)", ! sizeof(PyListObject) + PyGC_INFO_SIZE, 0, 0, /*tp_dealloc*/ /* Cannot happen */ *************** *** 1594,1598 **** 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ ! Py_TPFLAGS_DEFAULT, /*tp_flags*/ 0, /* tp_doc */ (traverseproc)list_traverse, /* tp_traverse */ --- 1595,1599 ---- 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC, /*tp_flags*/ 0, /* tp_doc */ (traverseproc)list_traverse, /* tp_traverse */ Index: tupleobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/tupleobject.c,v retrieving revision 2.37 retrieving revision 2.38 diff -C2 -r2.37 -r2.38 *** tupleobject.c 2000/06/23 14:18:11 2.37 --- tupleobject.c 2000/06/23 19:37:02 2.38 *************** *** 94,98 **** /* Check for overflow */ if (nbytes / sizeof(PyObject *) != (size_t)size || ! (nbytes += sizeof(PyTupleObject) - sizeof(PyObject *)) <= 0) { --- 94,99 ---- /* Check for overflow */ if (nbytes / sizeof(PyObject *) != (size_t)size || ! (nbytes += sizeof(PyTupleObject) - sizeof(PyObject *) ! + PyGC_INFO_SIZE) <= 0) { *************** *** 453,457 **** 0, "tuple", ! sizeof(PyTupleObject) - sizeof(PyObject *), sizeof(PyObject *), (destructor)tupledealloc, /*tp_dealloc*/ --- 454,458 ---- 0, "tuple", ! sizeof(PyTupleObject) - sizeof(PyObject *) + PyGC_INFO_SIZE, sizeof(PyObject *), (destructor)tupledealloc, /*tp_dealloc*/ *************** *** 470,474 **** 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ ! Py_TPFLAGS_DEFAULT, /*tp_flags*/ 0, /*tp_doc*/ (traverseproc)tupletraverse, /* tp_traverse */ --- 471,475 ---- 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC, /*tp_flags*/ 0, /*tp_doc*/ (traverseproc)tupletraverse, /* tp_traverse */ *************** *** 558,563 **** { sv = (PyTupleObject *) ! PyObject_REALLOC((char *)v, ! sizeof(PyTupleObject) + newsize * sizeof(PyObject *)); *pv = (PyObject *) sv; if (sv == NULL) { --- 559,565 ---- { sv = (PyTupleObject *) ! PyObject_REALLOC((char *)v, sizeof(PyTupleObject) ! + PyGC_INFO_SIZE ! + newsize * sizeof(PyObject *)); *pv = (PyObject *) sv; if (sv == NULL) { From python-dev@python.org Fri Jun 23 21:24:28 2000 From: python-dev@python.org (Barry Warsaw) Date: Fri, 23 Jun 2000 13:24:28 -0700 Subject: [Python-checkins] CVS: python/dist/src/Misc python-mode.el,3.106,3.107 Message-ID: <200006232024.NAA28420@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Misc In directory slayer.i.sourceforge.net:/tmp/cvs-serv28410 Modified Files: python-mode.el Log Message: (py-execute-region): Make sure the new temporary buffer is current for the insertion of the text. Index: python-mode.el =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/python-mode.el,v retrieving revision 3.106 retrieving revision 3.107 diff -C2 -r3.106 -r3.107 *** python-mode.el 2000/05/23 05:47:43 3.106 --- python-mode.el 2000/06/23 20:24:25 3.107 *************** *** 1285,1292 **** (save-excursion (goto-char start) ! (when (/= (py-point 'bol) (py-point 'boi)) (set-buffer buf) ! (insert "if 1:\n")) ! (insert-buffer-substring cur start end)) (cond ;; always run the code in its own asynchronous subprocess --- 1285,1293 ---- (save-excursion (goto-char start) ! (let ((needs-if (/= (py-point 'bol) (py-point 'boi)))) (set-buffer buf) ! (when needs-if ! (insert "if 1:\n")) ! (insert-buffer-substring cur start end))) (cond ;; always run the code in its own asynchronous subprocess From python-dev@python.org Sat Jun 24 01:18:26 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 23 Jun 2000 17:18:26 -0700 Subject: [Python-checkins] CVS: distutils/distutils extension.py,1.1,1.2 Message-ID: <200006240018.RAA00586@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv577 Modified Files: extension.py Log Message: Revised docstring so 'sources' isn't necessarily all C/C++ files (to accomodate SWIG interface files, resource files, etc.). Index: extension.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/extension.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** extension.py 2000/05/31 01:05:35 1.1 --- extension.py 2000/06/24 00:18:24 1.2 *************** *** 32,38 **** *not* a filename or pathname, but Python dotted name sources : [string] ! list of C/C++ source filenames, relative to the distribution ! root (where the setup script lives), in Unix form ! (slash-separated) for portability include_dirs : [string] list of directories to search for C/C++ header files (in Unix --- 32,40 ---- *not* a filename or pathname, but Python dotted name sources : [string] ! list of source filenames, relative to the distribution root ! (where the setup script lives), in Unix form (slash-separated) ! for portability. Source files may be C, C++, SWIG (.i), ! platform-specific resource files, or whatever else is recognized ! by the "build_ext" command as source for a Python extension. include_dirs : [string] list of directories to search for C/C++ header files (in Unix From python-dev@python.org Sat Jun 24 01:19:37 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 23 Jun 2000 17:19:37 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command build_ext.py,1.43,1.44 Message-ID: <200006240019.RAA00740@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv729 Modified Files: build_ext.py Log Message: Experimental, completely untested SWIG support. Index: build_ext.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build_ext.py,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -r1.43 -r1.44 *** build_ext.py 2000/06/17 23:04:31 1.43 --- build_ext.py 2000/06/24 00:19:35 1.44 *************** *** 368,377 **** self.announce ("building '%s' extension" % ext.name) ! # First step: compile the source code to object files. This ! # drops the object files in the current directory, regardless ! # of where the source is (may be a bad thing, but that's how a ! # Makefile.pre.in-based system does it, so at least there's a ! # precedent!) # XXX not honouring 'define_macros' or 'undef_macros' -- the # CCompiler API needs to change to accomodate this, and I --- 368,378 ---- self.announce ("building '%s' extension" % ext.name) ! # First, scan the sources for SWIG definition files (.i), run ! # SWIG on 'em to create .c files, and modify the sources list ! # accordingly. ! sources = self.swig_sources(sources) + # Next, compile the source code to object files. + # XXX not honouring 'define_macros' or 'undef_macros' -- the # CCompiler API needs to change to accomodate this, and I *************** *** 429,432 **** --- 430,501 ---- # build_extensions () + + def swig_sources (self, sources): + + """Walk the list of source files in 'sources', looking for SWIG + interface (.i) files. Run SWIG on all that are found, and + return a modified 'sources' list with SWIG source files replaced + by the generated C (or C++) files. + """ + + new_sources = [] + swig_sources = [] + swig_targets = {} + + # XXX this drops generated C files into the source tree, which + # is fine for developers who want to distribute the generated + # source -- but there should be an option to put SWIG output in + # the temp dir. + + for source in sources: + (base, ext) = os.path.splitext(source) + if ext in self.swig_ext(): + new_sources.append(base + ".c") # umm, what if it's C++? + swig_files.append(source) + swig_targets[source] = new_sources[-1] + else: + new_sources.append(source) + + if not swig_files: + return new_sources + + swig = self.find_swig() + swig_cmd = [swig, "-python", "-dnone", "-ISWIG"] # again, C++?!? + + for source in swig_sources: + self.announce ("swigging %s to %s" % (src, obj)) + self.spawn(swig_cmd + ["-o", swig_targets[source], source]) + + return new_sources + + # swig_sources () + + def find_swig (self): + """Return the name of the SWIG executable. On Unix, this is + just "swig" -- it should be in the PATH. Tries a bit harder on + Windows. + """ + + if os.name == "posix": + return "swig" + elif os.name == "nt": + + # Look for SWIG in its standard installation directory on + # Windows (or so I presume!). If we find it there, great; + # if not, act like Unix and assume it's in the PATH. + for vers in ("1.3", "1.2", "1.1"): + fn = os.path.join("c:\\swig%s" % vers, "swig.exe") + if os.path.isfile (fn): + return fn + else: + return "swig.exe" + + else: + raise DistutilsPlatformError, \ + ("I don't know how to find (much less run) SWIG " + "on platform '%s'") % os.name + + # find_swig () + # -- Hooks --------------------------------------------------------- From python-dev@python.org Sat Jun 24 01:23:22 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 23 Jun 2000 17:23:22 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist.py,1.11,1.12 build.py,1.23,1.24 build_clib.py,1.16,1.17 sdist.py,1.33,1.34 Message-ID: <200006240023.RAA00912@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv877/command Modified Files: bdist.py build.py build_clib.py sdist.py Log Message: Stylistic/formatting changes to Rene Liebscher's '--help-xxx' patch. Index: bdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** bdist.py 2000/06/07 03:00:06 1.11 --- bdist.py 2000/06/24 00:23:20 1.12 *************** *** 22,26 **** "temporary directory for creating built distributions"), ('formats=', None, ! "formats for distribution"), ] --- 22,26 ---- "temporary directory for creating built distributions"), ('formats=', None, ! "formats for distribution (comma-separated list)"), ] *************** *** 33,52 **** 'nt': 'zip', } ! format_command = { 'gztar': ('bdist_dumb',"gzipped tar-file"), ! 'bztar': ('bdist_dumb',"bzip2-ed tar-file"), ! 'ztar': ('bdist_dumb',"compressed tar-file"), ! 'tar': ('bdist_dumb',"tar-file"), ! 'rpm': ('bdist_rpm',"rpm distribution"), ! 'zip': ('bdist_dumb',"zip-file"), } ! # prints all possible arguments to --format ! def show_formats(): from distutils.fancy_getopt import FancyGetopt ! list_of_formats=[] for format in bdist.format_command.keys(): ! list_of_formats.append(("formats="+format,None,bdist.format_command[format][1])) ! list_of_formats.sort() ! pretty_printer=FancyGetopt(list_of_formats) pretty_printer.print_help("List of available distribution formats:") --- 33,54 ---- 'nt': 'zip', } ! format_command = { 'rpm': ('bdist_rpm', "RPM distribution"), ! 'gztar': ('bdist_dumb', "gzip'ed tar file"), ! 'bztar': ('bdist_dumb', "bzip2'ed tar file"), ! 'ztar': ('bdist_dumb', "compressed tar file"), ! 'tar': ('bdist_dumb', "tar file"), ! 'zip': ('bdist_dumb', "ZIP file"), } ! def show_formats (): ! """Print list of available formats (arguments to "--format" option). ! """ from distutils.fancy_getopt import FancyGetopt ! formats=[] for format in bdist.format_command.keys(): ! formats.append(("formats="+format, None, ! bdist.format_command[format][1])) ! formats.sort() ! pretty_printer = FancyGetopt(formats) pretty_printer.print_help("List of available distribution formats:") *************** *** 88,92 **** for format in self.formats: - try: cmd_name = self.format_command[format][0] --- 90,93 ---- Index: build.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -r1.23 -r1.24 *** build.py 2000/06/07 03:00:06 1.23 --- build.py 2000/06/24 00:23:20 1.24 *************** *** 37,43 **** "forcibly build everything (ignore file timestamps)"), ] help_options = [ ('help-compiler', None, ! "lists available compilers",show_compilers), ] --- 37,44 ---- "forcibly build everything (ignore file timestamps)"), ] + help_options = [ ('help-compiler', None, ! "list available compilers", show_compilers), ] Index: build_clib.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build_clib.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** build_clib.py 2000/06/07 03:00:06 1.16 --- build_clib.py 2000/06/24 00:23:20 1.17 *************** *** 43,49 **** "specify the compiler type"), ] help_options = [ ('help-compiler', None, ! "lists available compilers",show_compilers), ] --- 43,50 ---- "specify the compiler type"), ] + help_options = [ ('help-compiler', None, ! "list available compilers", show_compilers), ] Index: sdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/sdist.py,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -r1.33 -r1.34 *** sdist.py 2000/06/21 03:29:57 1.33 --- sdist.py 2000/06/24 00:23:20 1.34 *************** *** 37,41 **** "forcibly regenerate the manifest and carry on as usual"), ('formats=', None, ! "formats for source distribution"), ('keep-tree', 'k', "keep the distribution tree around after creating " + --- 37,41 ---- "forcibly regenerate the manifest and carry on as usual"), ('formats=', None, ! "formats for source distribution (comma-separated list)"), ('keep-tree', 'k', "keep the distribution tree around after creating " + *************** *** 62,66 **** help_options = [ ('help-formats', None, ! "lists available distribution formats", show_formats), ] --- 62,66 ---- help_options = [ ('help-formats', None, ! "list available distribution formats", show_formats), ] From python-dev@python.org Sat Jun 24 01:23:22 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 23 Jun 2000 17:23:22 -0700 Subject: [Python-checkins] CVS: distutils/distutils archive_util.py,1.6,1.7 ccompiler.py,1.23,1.24 dist.py,1.28,1.29 Message-ID: <200006240023.RAA00905@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv877 Modified Files: archive_util.py ccompiler.py dist.py Log Message: Stylistic/formatting changes to Rene Liebscher's '--help-xxx' patch. Index: archive_util.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/archive_util.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** archive_util.py 2000/06/07 03:00:05 1.6 --- archive_util.py 2000/06/24 00:23:20 1.7 *************** *** 111,118 **** ARCHIVE_FORMATS = { ! 'gztar': (make_tarball, [('compress', 'gzip')],"gzipped tar-file"), ! 'bztar': (make_tarball, [('compress', 'bzip2')],"bzip2-ed tar-file"), ! 'ztar': (make_tarball, [('compress', 'compress')],"compressed tar-file"), ! 'tar': (make_tarball, [('compress', None)],"uncompressed tar-file"), 'zip': (make_zipfile, [],"zip-file") } --- 111,118 ---- ARCHIVE_FORMATS = { ! 'gztar': (make_tarball, [('compress', 'gzip')], "gzip'ed tar-file"), ! 'bztar': (make_tarball, [('compress', 'bzip2')], "bzip2'ed tar-file"), ! 'ztar': (make_tarball, [('compress', 'compress')], "compressed tar file"), ! 'tar': (make_tarball, [('compress', None)], "uncompressed tar file"), 'zip': (make_zipfile, [],"zip-file") } Index: ccompiler.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/ccompiler.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -r1.23 -r1.24 *** ccompiler.py 2000/06/21 02:58:46 1.23 --- ccompiler.py 2000/06/24 00:23:20 1.24 *************** *** 743,760 **** # find the code that implements an interface to this compiler. (The module # is assumed to be in the 'distutils' package.) ! compiler_class = { 'unix': ('unixccompiler', 'UnixCCompiler',"standard UNIX-style compiler"), ! 'msvc': ('msvccompiler', 'MSVCCompiler',"Microsoft Visual C++"), ! 'cygwin': ('cygwinccompiler', 'CygwinCCompiler',"Cygwin-Gnu-Win32-C-Compiler"), ! 'mingw32': ('cygwinccompiler', 'Mingw32CCompiler',"MinGW32-C-Compiler (or cygwin in this mode)"), } - # prints all possible arguments to --compiler def show_compilers(): from distutils.fancy_getopt import FancyGetopt ! list_of_compilers=[] for compiler in compiler_class.keys(): ! list_of_compilers.append(("compiler="+compiler,None,compiler_class[compiler][2])) ! list_of_compilers.sort() ! pretty_printer=FancyGetopt(list_of_compilers) pretty_printer.print_help("List of available compilers:") --- 743,770 ---- # find the code that implements an interface to this compiler. (The module # is assumed to be in the 'distutils' package.) ! compiler_class = { 'unix': ('unixccompiler', 'UnixCCompiler', ! "standard UNIX-style compiler"), ! 'msvc': ('msvccompiler', 'MSVCCompiler', ! "Microsoft Visual C++"), ! 'cygwin': ('cygwinccompiler', 'CygwinCCompiler', ! "Cygwin port of GNU C Compiler for Win32"), ! 'mingw32': ('cygwinccompiler', 'Mingw32CCompiler', ! "Mingw32 port of GNU C Compiler for Win32"), } def show_compilers(): + """Print list of available compilers (used by the "--help-compiler" + options to "build", "build_ext", "build_clib"). + """ + # XXX this "knows" that the compiler option it's describing is + # "--compiler", which just happens to be the case for the three + # commands that use it. from distutils.fancy_getopt import FancyGetopt ! compilers = [] for compiler in compiler_class.keys(): ! compilers.append(("compiler="+compiler, None, ! compiler_class[compiler][2])) ! compilers.sort() ! pretty_printer = FancyGetopt(compilers) pretty_printer.print_help("List of available compilers:") *************** *** 784,788 **** compiler = default_compiler[plat] ! (module_name, class_name,long_description) = compiler_class[compiler] except KeyError: msg = "don't know how to compile C/C++ code on platform '%s'" % plat --- 794,798 ---- compiler = default_compiler[plat] ! (module_name, class_name, long_description) = compiler_class[compiler] except KeyError: msg = "don't know how to compile C/C++ code on platform '%s'" % plat Index: dist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/dist.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -r1.28 -r1.29 *** dist.py 2000/06/07 03:00:05 1.28 --- dist.py 2000/06/24 00:23:20 1.29 *************** *** 438,446 **** negative_opt.update (cmd_class.negative_opt) ! # Check for help_options in command class ! # They have a different format (tuple of four) so we need to preprocess them here ! help_options = [] ! if hasattr(cmd_class,"help_options") and type (cmd_class.help_options) is ListType: ! help_options = map(lambda x:(x[0],x[1],x[2]),cmd_class.help_options) # All commands support the global options too, just by adding --- 438,449 ---- negative_opt.update (cmd_class.negative_opt) ! # Check for help_options in command class. They have a different ! # format (tuple of four) so we need to preprocess them here. ! if (hasattr(cmd_class, 'help_options') and ! type (cmd_class.help_options) is ListType): ! help_options = fix_help_options(cmd_class.help_options) ! else: ! help_optiosn = [] ! # All commands support the global options too, just by adding *************** *** 454,463 **** return ! if hasattr(cmd_class,"help_options") and type (cmd_class.help_options) is ListType: help_option_found=0 for help_option in cmd_class.help_options: if hasattr(opts, parser.get_attr_name(help_option[0])): help_option_found=1 ! #print "showing help for option %s of command %s" % (help_option[0],cmd_class) if callable(help_option[3]): help_option[3]() --- 457,468 ---- return ! if (hasattr(cmd_class, 'help_options') and ! type (cmd_class.help_options) is ListType): help_option_found=0 for help_option in cmd_class.help_options: if hasattr(opts, parser.get_attr_name(help_option[0])): help_option_found=1 ! #print "showing help for option %s of command %s" % \ ! # (help_option[0],cmd_class) if callable(help_option[3]): help_option[3]() *************** *** 519,525 **** else: klass = self.get_command_class (command) ! if hasattr(klass,"help_options") and type (klass.help_options) is ListType: ! parser.set_option_table (klass.user_options+ ! map(lambda x:(x[0],x[1],x[2]),klass.help_options)) else: parser.set_option_table (klass.user_options) --- 524,531 ---- else: klass = self.get_command_class (command) ! if (hasattr(klass, 'help_options') and ! type (klass.help_options) is ListType): ! parser.set_option_table (klass.user_options + ! fix_help_options(klass.help_options)) else: parser.set_option_table (klass.user_options) *************** *** 890,893 **** --- 896,910 ---- # class DistributionMetadata + + + def fix_help_options (options): + """Convert a 4-tuple 'help_options' list as found in various command + classes to the 3-tuple form required by FancyGetopt. + """ + new_options = [] + for help_tuple in options: + new_options.append(help_tuple[0:3]) + return new_options + if __name__ == "__main__": From python-dev@python.org Sat Jun 24 02:22:43 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 23 Jun 2000 18:22:43 -0700 Subject: [Python-checkins] CVS: distutils/distutils dist.py,1.29,1.30 Message-ID: <200006240122.SAA09839@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv9823 Modified Files: dist.py Log Message: More stylistic tweaks to the generic '--help-xxx' code. Index: dist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/dist.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -r1.29 -r1.30 *** dist.py 2000/06/24 00:23:20 1.29 --- dist.py 2000/06/24 01:22:41 1.30 *************** *** 444,448 **** help_options = fix_help_options(cmd_class.help_options) else: ! help_optiosn = [] --- 444,448 ---- help_options = fix_help_options(cmd_class.help_options) else: ! help_options = [] *************** *** 450,454 **** # in 'global_options'. parser.set_option_table (self.global_options + ! cmd_class.user_options + help_options) parser.set_negative_aliases (negative_opt) (args, opts) = parser.getopt (args[1:]) --- 450,455 ---- # in 'global_options'. parser.set_option_table (self.global_options + ! cmd_class.user_options + ! help_options) parser.set_negative_aliases (negative_opt) (args, opts) = parser.getopt (args[1:]) *************** *** 460,476 **** type (cmd_class.help_options) is ListType): help_option_found=0 ! for help_option in cmd_class.help_options: ! if hasattr(opts, parser.get_attr_name(help_option[0])): help_option_found=1 #print "showing help for option %s of command %s" % \ # (help_option[0],cmd_class) ! if callable(help_option[3]): ! help_option[3]() ! else: ! raise DistutilsClassError, \ ! ("command class %s must provide " + ! "a callable object for help_option '%s'") % \ ! (cmd_class,help_option[0]) ! if help_option_found: return --- 461,479 ---- type (cmd_class.help_options) is ListType): help_option_found=0 ! for (help_option, short, desc, func) in cmd_class.help_options: ! if hasattr(opts, parser.get_attr_name(help_option)): help_option_found=1 #print "showing help for option %s of command %s" % \ # (help_option[0],cmd_class) ! ! if callable(func): ! func() ! else: ! raise DistutilsClassError, \ ! ("invalid help function %s for help option '%s': " ! "must be a callable object (function, etc.)") % \ ! (`func`, help_option) ! ! if help_option_found: return From python-dev@python.org Sat Jun 24 02:23:40 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 23 Jun 2000 18:23:40 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist.py,1.12,1.13 build.py,1.24,1.25 build_clib.py,1.17,1.18 build_ext.py,1.44,1.45 sdist.py,1.34,1.35 Message-ID: <200006240123.SAA09865@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv9830 Modified Files: bdist.py build.py build_clib.py build_ext.py sdist.py Log Message: Changed so all the help-generating functions are defined, at module-level, in the module of the command classes that have command-specific help options. This lets us keep the principle of lazily importing the ccompiler module, and also gets away from defining non-methods at class level. Index: bdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** bdist.py 2000/06/24 00:23:20 1.12 --- bdist.py 2000/06/24 01:23:37 1.13 *************** *** 15,18 **** --- 15,30 ---- + def show_formats (): + """Print list of available formats (arguments to "--format" option). + """ + from distutils.fancy_getopt import FancyGetopt + formats=[] + for format in bdist.format_commands: + formats.append(("formats=" + format, None, + bdist.format_command[format][1])) + pretty_printer = FancyGetopt(formats) + pretty_printer.print_help("List of available distribution formats:") + + class bdist (Command): *************** *** 25,28 **** --- 37,45 ---- ] + help_options = [ + ('help-formats', None, + "lists available distribution formats", show_formats), + ] + # The following commands do not take a format option from bdist no_format_option = ('bdist_rpm',) *************** *** 39,60 **** 'tar': ('bdist_dumb', "tar file"), 'zip': ('bdist_dumb', "ZIP file"), ! } ! ! def show_formats (): ! """Print list of available formats (arguments to "--format" option). ! """ ! from distutils.fancy_getopt import FancyGetopt ! formats=[] ! for format in bdist.format_command.keys(): ! formats.append(("formats="+format, None, ! bdist.format_command[format][1])) ! formats.sort() ! pretty_printer = FancyGetopt(formats) ! pretty_printer.print_help("List of available distribution formats:") ! ! help_options = [ ! ('help-formats', None, ! "lists available distribution formats",show_formats), ! ] --- 56,62 ---- 'tar': ('bdist_dumb', "tar file"), 'zip': ('bdist_dumb', "ZIP file"), ! } ! # establish the preferred order ! format_commands = ['rpm', 'gztar', 'bztar', 'ztar', 'tar', 'zip'] Index: build.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -r1.24 -r1.25 *** build.py 2000/06/24 00:23:20 1.24 --- build.py 2000/06/24 01:23:37 1.25 *************** *** 10,14 **** from distutils.core import Command from distutils.util import get_platform ! from distutils.ccompiler import show_compilers class build (Command): --- 10,19 ---- from distutils.core import Command from distutils.util import get_platform ! ! ! def show_compilers (): ! from distutils.ccompiler import show_compilers ! show_compilers() ! class build (Command): Index: build_clib.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build_clib.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** build_clib.py 2000/06/24 00:23:20 1.17 --- build_clib.py 2000/06/24 01:23:37 1.18 *************** *** 24,30 **** from distutils.core import Command from distutils.errors import * - from distutils.ccompiler import new_compiler,show_compilers class build_clib (Command): --- 24,34 ---- from distutils.core import Command from distutils.errors import * + def show_compilers (): + from distutils.ccompiler import show_compilers + show_compilers() + + class build_clib (Command): *************** *** 103,106 **** --- 107,111 ---- # Yech -- this is cut 'n pasted from build_ext.py! + from distutils.ccompiler import new_compiler self.compiler = new_compiler (compiler=self.compiler, verbose=self.verbose, Index: build_ext.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build_ext.py,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -r1.44 -r1.45 *** build_ext.py 2000/06/24 00:19:35 1.44 --- build_ext.py 2000/06/24 01:23:37 1.45 *************** *** 15,19 **** from distutils.dep_util import newer_group from distutils.extension import Extension - from distutils.ccompiler import show_compilers # An extension name is just a dot-separated list of Python NAMEs (ie. --- 15,18 ---- *************** *** 23,26 **** --- 22,30 ---- + def show_compilers (): + from distutils.ccompiler import show_compilers + show_compilers() + + class build_ext (Command): *************** *** 74,82 **** "specify the compiler type"), ] help_options = [ ('help-compiler', None, ! "lists available compilers",show_compilers), ] - def initialize_options (self): --- 78,86 ---- "specify the compiler type"), ] + help_options = [ ('help-compiler', None, ! "list available compilers", show_compilers), ] def initialize_options (self): Index: sdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/sdist.py,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -r1.34 -r1.35 *** sdist.py 2000/06/24 00:23:20 1.34 --- sdist.py 2000/06/24 01:23:37 1.35 *************** *** 14,22 **** from distutils.util import \ convert_path, create_tree, remove_tree, newer, write_file, \ ! check_archive_formats, ARCHIVE_FORMATS from distutils.text_file import TextFile from distutils.errors import DistutilsExecError, DistutilsOptionError class sdist (Command): --- 14,38 ---- from distutils.util import \ convert_path, create_tree, remove_tree, newer, write_file, \ ! check_archive_formats from distutils.text_file import TextFile from distutils.errors import DistutilsExecError, DistutilsOptionError + def show_formats (): + """Print all possible values for the 'formats' option (used by + the "--help-formats" command-line option). + """ + from distutils.fancy_getopt import FancyGetopt + from distutils.archive_util import ARCHIVE_FORMATS + formats=[] + for format in ARCHIVE_FORMATS.keys(): + formats.append(("formats=" + format, None, + ARCHIVE_FORMATS[format][2])) + formats.sort() + pretty_printer = FancyGetopt(formats) + pretty_printer.print_help( + "List of available source distribution formats:") + + class sdist (Command): *************** *** 44,63 **** - # XXX ugh: this has to precede the 'help_options' list, because - # it is mentioned there -- also, this is not a method, even though - # it's defined in a class: double-ugh! - def show_formats (): - """Print all possible values for the 'formats' option -- used by - the "--help-formats" command-line option. - """ - from distutils.fancy_getopt import FancyGetopt - formats=[] - for format in ARCHIVE_FORMATS.keys(): - formats.append(("formats="+format,None,ARCHIVE_FORMATS[format][2])) - formats.sort() - pretty_printer = FancyGetopt(formats) - pretty_printer.print_help( - "List of available source distribution formats:") - help_options = [ ('help-formats', None, --- 60,63 ---- *************** *** 69,73 **** default_format = { 'posix': 'gztar', 'nt': 'zip' } - def initialize_options (self): --- 69,72 ---- From python-dev@python.org Sat Jun 24 02:27:28 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 23 Jun 2000 18:27:28 -0700 Subject: [Python-checkins] CVS: distutils TODO,1.3,1.4 Message-ID: <200006240127.SAA09999@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv9988 Modified Files: TODO Log Message: Couple o' small changes. Index: TODO =================================================================== RCS file: /cvsroot/python/distutils/TODO,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** TODO 2000/06/07 03:11:17 1.3 --- TODO 2000/06/24 01:27:26 1.4 *************** *** 42,48 **** --- 42,51 ---- other people to try it out and I don't have time to review it right now (and he fixed a stupid bug in bdist.py for me) + [done 2000/06/23 GPW] + * review Rene Liebscher's cygwinccompiler.py contribution + COMMAND-LINE PARSING -------------------- *************** *** 107,110 **** --- 110,118 ---- * support for PyFort (lower priority than SWIG!) + + * OSF/1 problem: ld command has "*" in it, which is appropriate when + a shell is involved, but there isn't one here, so we need to + strip the quotes (and, ideally, put them back on again when + spawn() prints out the command run!) From python-dev@python.org Sat Jun 24 02:33:18 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 23 Jun 2000 18:33:18 -0700 Subject: [Python-checkins] CVS: distutils/doc/inst inst.tex,1.14,1.15 Message-ID: <200006240133.SAA10280@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/doc/inst In directory slayer.i.sourceforge.net:/tmp/cvs-serv10257/inst Modified Files: inst.tex Log Message: Fixed a grab-bag of typos spotted by Detlef Lannert. Index: inst.tex =================================================================== RCS file: /cvsroot/python/distutils/doc/inst/inst.tex,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** inst.tex 2000/05/30 03:00:43 1.14 --- inst.tex 2000/06/24 01:33:16 1.15 *************** *** 98,104 **** If you download a module source distribution, you can tell pretty ! quickly if was packaged and distributed in the standard way, i.e. using ! the Distutils. First, the distribution's name and version number will ! be featured prominently in the name of the downloaded archive, e.g. \file{foo-1.0.tar.gz} or \file{widget-0.9.7.zip}. Next, the archive will unpack into a similarly-named directory: \file{foo-1.0} or --- 98,104 ---- If you download a module source distribution, you can tell pretty ! quickly if it was packaged and distributed in the standard way, i.e. ! using the Distutils. First, the distribution's name and version number ! will be featured prominently in the name of the downloaded archive, e.g. \file{foo-1.0.tar.gz} or \file{widget-0.9.7.zip}. Next, the archive will unpack into a similarly-named directory: \file{foo-1.0} or *************** *** 127,131 **** be made is, ``Read the module's own installation instructions.'' ! However, if such instructions exists at all, they are often woefully inadequate and targeted at experienced Python developers. Such users are already familiar with how the Python library is laid out on their --- 127,131 ---- be made is, ``Read the module's own installation instructions.'' ! However, if such instructions exist at all, they are often woefully inadequate and targeted at experienced Python developers. Such users are already familiar with how the Python library is laid out on their *************** *** 422,426 **** known cases where the prefix scheme will be useful. ! First, consider that many Linux distribution put Python in \file{/usr}, rather than the more traditional \file{/usr/local}. This is entirely appropriate, since in those cases Python is part of ``the system'' --- 422,426 ---- known cases where the prefix scheme will be useful. ! First, consider that many Linux distributions put Python in \file{/usr}, rather than the more traditional \file{/usr/local}. This is entirely appropriate, since in those cases Python is part of ``the system'' *************** *** 559,563 **** the installation base directory (your home directory, in this case): \begin{verbatim} ! python setup.py install --home --install-scripts=scripts \end{verbatim} --- 559,563 ---- the installation base directory (your home directory, in this case): \begin{verbatim} ! python setup.py install --home=~ --install-scripts=scripts \end{verbatim} *************** *** 607,611 **** python setup.py install --home=~/python \ --install-purelib=lib \ ! --install-platlib=lib.$PLAT \ --install-scripts=scripts --install-data=data --- 607,611 ---- python setup.py install --home=~/python \ --install-purelib=lib \ ! --install-platlib='lib.$PLAT' \ --install-scripts=scripts --install-data=data From python-dev@python.org Sat Jun 24 02:33:18 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 23 Jun 2000 18:33:18 -0700 Subject: [Python-checkins] CVS: distutils/doc/dist dist.tex,1.14,1.15 Message-ID: <200006240133.SAA10274@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/doc/dist In directory slayer.i.sourceforge.net:/tmp/cvs-serv10257/dist Modified Files: dist.tex Log Message: Fixed a grab-bag of typos spotted by Detlef Lannert. Index: dist.tex =================================================================== RCS file: /cvsroot/python/distutils/doc/dist/dist.tex,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** dist.tex 2000/05/26 02:24:28 1.14 --- dist.tex 2000/06/24 01:33:14 1.15 *************** *** 56,66 **** it's not always feasible to expect them to create a multitude of built distributions. It is hoped that a class of intermediaries, called ! \emph{packagers}, will arise to take address this need. Packagers will ! take source distributions released by module developers, build them on ! one or more platforms, and release the resulting built distributions. ! Thus, users on the most popular platforms will be able to install most ! popular Python module distributions in the most natural way for their ! platform, without having to run a single setup script or compile a line ! of code. --- 56,65 ---- it's not always feasible to expect them to create a multitude of built distributions. It is hoped that a class of intermediaries, called ! \emph{packagers}, will arise to address this need. Packagers will take ! source distributions released by module developers, build them on one or ! more platforms, and release the resulting built distributions. Thus, ! users on the most popular platforms will be able to install most popular ! Python module distributions in the most natural way for their platform, ! without having to run a single setup script or compile a line of code. *************** *** 374,379 **** python setup.py sdist \end{verbatim} ! (assuming you haven't specified any \command{sdist} options in the setup ! script or config file), \command{sdist} creates the the archive of the default format for the current platform. The default formats are: \begin{tableii}{ll}{textrm}% --- 373,378 ---- python setup.py sdist \end{verbatim} ! (assuming you haven't specified any \command{sdist} options in the setup ! script or config file), \command{sdist} creates the archive of the default format for the current platform. The default formats are: \begin{tableii}{ll}{textrm}% *************** *** 540,544 **** specialty---writing code and creating source distributions---while an intermediary species of \emph{packager} springs up to turn source ! distributions into build distributions for as many platforms as there are packagers. --- 539,543 ---- specialty---writing code and creating source distributions---while an intermediary species of \emph{packager} springs up to turn source ! distributions into built distributions for as many platforms as there are packagers. From python-dev@python.org Sat Jun 24 02:45:49 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 23 Jun 2000 18:45:49 -0700 Subject: [Python-checkins] CVS: distutils/doc/dist dist.tex,1.15,1.16 Message-ID: <200006240145.SAA10895@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/doc/dist In directory slayer.i.sourceforge.net:/tmp/cvs-serv10880 Modified Files: dist.tex Log Message: Some clarifications to the 'A simple example' section. Index: dist.tex =================================================================== RCS file: /cvsroot/python/distutils/doc/dist/dist.tex,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** dist.tex 2000/06/24 01:33:14 1.15 --- dist.tex 2000/06/24 01:45:47 1.16 *************** *** 70,74 **** Python, there are no arbitrary limits to what you can do. If all you want to do is distribute a module called \module{foo}, contained in a ! file \file{foo.py}, then you can get away with as little as this: \begin{verbatim} from distutils.core import setup --- 70,74 ---- Python, there are no arbitrary limits to what you can do. If all you want to do is distribute a module called \module{foo}, contained in a ! file \file{foo.py}, then your setup script can be as little as this: \begin{verbatim} from distutils.core import setup *************** *** 77,87 **** py_modules = ["foo"]) \end{verbatim} Some observations: \begin{itemize} ! \item all information that you supply to the Distutils is supplied as keyword arguments to the \function{setup()} function \item those keyword arguments fall into two categories: package meta-data (name, version number) and information about what's in the ! package (list of pure modules, in this case) \item modules are specified by module name, not filename (the same will hold true for packages and extensions) --- 77,88 ---- py_modules = ["foo"]) \end{verbatim} + Some observations: \begin{itemize} ! \item most information that you supply to the Distutils is supplied as keyword arguments to the \function{setup()} function \item those keyword arguments fall into two categories: package meta-data (name, version number) and information about what's in the ! package (a list of pure Python modules, in this case) \item modules are specified by module name, not filename (the same will hold true for packages and extensions) *************** *** 90,94 **** \end{itemize} ! To create a source distribution for this module, you would run \begin{verbatim} python setup.py sdist --- 91,96 ---- \end{itemize} ! To create a source distribution for this module, you would create a ! setup script, \file{setup.py}, containing the above code, and run: \begin{verbatim} python setup.py sdist *************** *** 137,142 **** zip file with a minimal user interface, which is enough for small- to medium-sized module collections. You'll need to have version XXX of ! Wise installed on your system for the \command{bdist\_wise} to work; ! it's available from \url{http://foo/bar/baz}.) Other \command{bdist} commands exist for other platforms: for example, --- 139,144 ---- zip file with a minimal user interface, which is enough for small- to medium-sized module collections. You'll need to have version XXX of ! Wise installed on your system for the \command{bdist\_wise} command to ! work; it's available from \url{http://foo/bar/baz}.) Other \command{bdist} commands exist for other platforms: for example, From python-dev@python.org Sat Jun 24 03:22:52 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 23 Jun 2000 19:22:52 -0700 Subject: [Python-checkins] CVS: distutils/distutils ccompiler.py,1.24,1.25 Message-ID: <200006240222.TAA18390@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv18373 Modified Files: ccompiler.py Log Message: Changed 'object_filenames()' to raise exception instead of silently carrying on if it sees a filename with unknown extension. Index: ccompiler.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/ccompiler.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -r1.24 -r1.25 *** ccompiler.py 2000/06/24 00:23:20 1.24 --- ccompiler.py 2000/06/24 02:22:49 1.25 *************** *** 672,676 **** (base, ext) = os.path.splitext (src_name) if ext not in self.src_extensions: ! continue if strip_dir: base = os.path.basename (base) --- 672,678 ---- (base, ext) = os.path.splitext (src_name) if ext not in self.src_extensions: ! raise UnknownFileError, \ ! "unknown file type '%s' (from '%s')" % \ ! (ext, src_name) if strip_dir: base = os.path.basename (base) From python-dev@python.org Sat Jun 24 18:22:42 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 10:22:42 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command install.py,1.38,1.39 Message-ID: <200006241722.KAA32544@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv32529/command Modified Files: install.py Log Message: Changed the default installation directory for data files (used by the "install_data" command to the installation base, which is usually just sys.prefix. (Any setup scripts out there that specify data files will have to set the installation directory, relative to the base, explicitly.) Index: install.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/install.py,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -r1.38 -r1.39 *** install.py 2000/06/21 03:09:02 1.38 --- install.py 2000/06/24 17:22:39 1.39 *************** *** 21,25 **** 'headers': '$base/include/python$py_version_short/$dist_name', 'scripts': '$base/bin', ! 'data' : '$base/share', }, 'unix_home': { --- 21,25 ---- 'headers': '$base/include/python$py_version_short/$dist_name', 'scripts': '$base/bin', ! 'data' : '$base', }, 'unix_home': { *************** *** 28,32 **** 'headers': '$base/include/python/$dist_name', 'scripts': '$base/bin', ! 'data' : '$base/share', }, 'nt': { --- 28,32 ---- 'headers': '$base/include/python/$dist_name', 'scripts': '$base/bin', ! 'data' : '$base', }, 'nt': { *************** *** 35,39 **** 'headers': '$base\\Include\\$dist_name', 'scripts': '$base\\Scripts', ! 'data' : '$base\\Data', }, 'mac': { --- 35,39 ---- 'headers': '$base\\Include\\$dist_name', 'scripts': '$base\\Scripts', ! 'data' : '$base', }, 'mac': { *************** *** 42,46 **** 'headers': '$base:Include:$dist_name', 'scripts': '$base:Scripts', ! 'data' : '$base:Data', } } --- 42,46 ---- 'headers': '$base:Include:$dist_name', 'scripts': '$base:Scripts', ! 'data' : '$base', } } From python-dev@python.org Sat Jun 24 18:36:26 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 10:36:26 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command install_data.py,1.9,1.10 Message-ID: <200006241736.KAA00747@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv732 Modified Files: install_data.py Log Message: Print a warning if we install a data file right in install_dir. Tweaked help text. Index: install_data.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/install_data.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** install_data.py 2000/06/21 03:12:07 1.9 --- install_data.py 2000/06/24 17:36:24 1.10 *************** *** 19,23 **** user_options = [ ('install-dir=', 'd', ! "directory to install the files to"), ('root=', None, "install everything relative to this alternate root directory"), --- 19,24 ---- user_options = [ ('install-dir=', 'd', ! "base directory for installating data files " ! "(default: installation base dir)"), ('root=', None, "install everything relative to this alternate root directory"), *************** *** 40,48 **** for f in self.data_files: if type(f) == StringType: ! # its a simple file, so copy it out = self.copy_file(f, self.install_dir) self.outfiles.append(out) else: ! # its a tuple with path to install to and a list of files dir = f[0] if not os.path.isabs(dir): --- 41,52 ---- for f in self.data_files: if type(f) == StringType: ! # it's a simple file, so copy it ! self.warn("setup script did not provide a directory for " ! "'%s' -- installing right in '%s'" % ! (f, self.install_dir)) out = self.copy_file(f, self.install_dir) self.outfiles.append(out) else: ! # it's a tuple with path to install to and a list of files dir = f[0] if not os.path.isabs(dir): From python-dev@python.org Sat Jun 24 19:10:51 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 11:10:51 -0700 Subject: [Python-checkins] CVS: distutils/distutils ccompiler.py,1.25,1.26 Message-ID: <200006241810.LAA08731@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv8721 Modified Files: ccompiler.py Log Message: Docstring reformatting/tweaking binge. Fixed a few comments. Index: ccompiler.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/ccompiler.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -r1.25 -r1.26 *** ccompiler.py 2000/06/24 02:22:49 1.25 --- ccompiler.py 2000/06/24 18:10:48 1.26 *************** *** 18,34 **** class CCompiler: """Abstract base class to define the interface that must be implemented ! by real compiler abstraction classes. Might have some use as a ! place for shared code, but it's not yet clear what code can be ! shared between compiler abstraction models for different platforms. ! ! The basic idea behind a compiler abstraction class is that each ! instance can be used for all the compile/link steps in building ! a single project. Thus, attributes common to all of those compile ! and link steps -- include directories, macros to define, libraries ! to link against, etc. -- are attributes of the compiler instance. ! To allow for variability in how individual files are treated, ! most (all?) of those attributes may be varied on a per-compilation ! or per-link basis.""" # 'compiler_type' is a class attribute that identifies this class. It # keeps code that wants to know what kind of compiler it's dealing with --- 18,33 ---- class CCompiler: """Abstract base class to define the interface that must be implemented ! by real compiler classes. Also has some utility methods used by ! several compiler classes. + The basic idea behind a compiler abstraction class is that each + instance can be used for all the compile/link steps in building a + single project. Thus, attributes common to all of those compile and + link steps -- include directories, macros to define, libraries to link + against, etc. -- are attributes of the compiler instance. To allow for + variability in how individual files are treated, most of those + attributes may be varied on a per-compilation or per-link basis. + """ + # 'compiler_type' is a class attribute that identifies this class. It # keeps code that wants to know what kind of compiler it's dealing with *************** *** 47,54 **** # (UnixCCompiler, MSVCCompiler, etc.) -- or perhaps the base # class should have methods for the common ones. - # * can't put output files (object files, libraries, whatever) - # into a separate directory from their inputs. Should this be - # handled by an 'output_dir' attribute of the whole object, or a - # parameter to the compile/link_* methods, or both? # * can't completely override the include or library searchg # path, ie. no "cc -I -Idir1 -Idir2" or "cc -L -Ldir1 -Ldir2". --- 46,49 ---- *************** *** 130,137 **** def _check_macro_definitions (self, definitions): """Ensures that every element of 'definitions' is a valid macro ! definition, ie. either (name,value) 2-tuple or a (name,) ! tuple. Do nothing if all definitions are OK, raise ! TypeError otherwise.""" ! for defn in definitions: if not (type (defn) is TupleType and --- 125,131 ---- def _check_macro_definitions (self, definitions): """Ensures that every element of 'definitions' is a valid macro ! definition, ie. either (name,value) 2-tuple or a (name,) tuple. Do ! nothing if all definitions are OK, raise TypeError otherwise. ! """ for defn in definitions: if not (type (defn) is TupleType and *************** *** 149,158 **** def define_macro (self, name, value=None): ! """Define a preprocessor macro for all compilations driven by ! this compiler object. The optional parameter 'value' should be ! a string; if it is not supplied, then the macro will be defined ! without an explicit value and the exact outcome depends on the ! compiler used (XXX true? does ANSI say anything about this?)""" ! # Delete from the list of macro definitions/undefinitions if # already there (so that this one will take precedence). --- 143,152 ---- def define_macro (self, name, value=None): ! """Define a preprocessor macro for all compilations driven by this ! compiler object. The optional parameter 'value' should be a ! string; if it is not supplied, then the macro will be defined ! without an explicit value and the exact outcome depends on the ! compiler used (XXX true? does ANSI say anything about this?) ! """ # Delete from the list of macro definitions/undefinitions if # already there (so that this one will take precedence). *************** *** 167,177 **** def undefine_macro (self, name): """Undefine a preprocessor macro for all compilations driven by ! this compiler object. If the same macro is defined by ! 'define_macro()' and undefined by 'undefine_macro()' the last ! call takes precedence (including multiple redefinitions or ! undefinitions). If the macro is redefined/undefined on a ! per-compilation basis (ie. in the call to 'compile()'), then ! that takes precedence.""" ! # Delete from the list of macro definitions/undefinitions if # already there (so that this one will take precedence). --- 161,171 ---- def undefine_macro (self, name): """Undefine a preprocessor macro for all compilations driven by ! this compiler object. If the same macro is defined by ! 'define_macro()' and undefined by 'undefine_macro()' the last call ! takes precedence (including multiple redefinitions or ! undefinitions). If the macro is redefined/undefined on a ! per-compilation basis (ie. in the call to 'compile()'), then that ! takes precedence. ! """ # Delete from the list of macro definitions/undefinitions if # already there (so that this one will take precedence). *************** *** 185,225 **** def add_include_dir (self, dir): ! """Add 'dir' to the list of directories that will be searched ! for header files. The compiler is instructed to search ! directories in the order in which they are supplied by ! successive calls to 'add_include_dir()'.""" self.include_dirs.append (dir) def set_include_dirs (self, dirs): ! """Set the list of directories that will be searched to 'dirs' ! (a list of strings). Overrides any preceding calls to ! 'add_include_dir()'; subsequence calls to 'add_include_dir()' ! add to the list passed to 'set_include_dirs()'. This does ! not affect any list of standard include directories that ! the compiler may search by default.""" self.include_dirs = copy (dirs) def add_library (self, libname): ! """Add 'libname' to the list of libraries that will be included ! in all links driven by this compiler object. Note that ! 'libname' should *not* be the name of a file containing a ! library, but the name of the library itself: the actual filename ! will be inferred by the linker, the compiler, or the compiler ! abstraction class (depending on the platform). ! ! The linker will be instructed to link against libraries in the ! order they were supplied to 'add_library()' and/or ! 'set_libraries()'. It is perfectly valid to duplicate library ! names; the linker will be instructed to link against libraries ! as many times as they are mentioned.""" self.libraries.append (libname) def set_libraries (self, libnames): ! """Set the list of libraries to be included in all links driven ! by this compiler object to 'libnames' (a list of strings). ! This does not affect any standard system libraries that the ! linker may include by default.""" ! self.libraries = copy (libnames) --- 179,222 ---- def add_include_dir (self, dir): ! """Add 'dir' to the list of directories that will be searched for ! header files. The compiler is instructed to search directories in ! the order in which they are supplied by successive calls to ! 'add_include_dir()'. ! """ self.include_dirs.append (dir) def set_include_dirs (self, dirs): ! """Set the list of directories that will be searched to 'dirs' (a ! list of strings). Overrides any preceding calls to ! 'add_include_dir()'; subsequence calls to 'add_include_dir()' add ! to the list passed to 'set_include_dirs()'. This does not affect ! any list of standard include directories that the compiler may ! search by default. ! """ self.include_dirs = copy (dirs) def add_library (self, libname): ! """Add 'libname' to the list of libraries that will be included in ! all links driven by this compiler object. Note that 'libname' ! should *not* be the name of a file containing a library, but the ! name of the library itself: the actual filename will be inferred by ! the linker, the compiler, or the compiler class (depending on the ! platform). ! ! The linker will be instructed to link against libraries in the ! order they were supplied to 'add_library()' and/or ! 'set_libraries()'. It is perfectly valid to duplicate library ! names; the linker will be instructed to link against libraries as ! many times as they are mentioned. ! """ self.libraries.append (libname) def set_libraries (self, libnames): ! """Set the list of libraries to be included in all links driven by ! this compiler object to 'libnames' (a list of strings). This does ! not affect any standard system libraries that the linker may ! include by default. ! """ self.libraries = copy (libnames) *************** *** 227,240 **** def add_library_dir (self, dir): """Add 'dir' to the list of directories that will be searched for ! libraries specified to 'add_library()' and 'set_libraries()'. ! The linker will be instructed to search for libraries in the ! order they are supplied to 'add_library_dir()' and/or ! 'set_library_dirs()'.""" self.library_dirs.append (dir) def set_library_dirs (self, dirs): ! """Set the list of library search directories to 'dirs' (a list ! of strings). This does not affect any standard library ! search path that the linker may search by default.""" self.library_dirs = copy (dirs) --- 224,238 ---- def add_library_dir (self, dir): """Add 'dir' to the list of directories that will be searched for ! libraries specified to 'add_library()' and 'set_libraries()'. The ! linker will be instructed to search for libraries in the order they ! are supplied to 'add_library_dir()' and/or 'set_library_dirs()'. ! """ self.library_dirs.append (dir) def set_library_dirs (self, dirs): ! """Set the list of library search directories to 'dirs' (a list of ! strings). This does not affect any standard library search path ! that the linker may search by default. ! """ self.library_dirs = copy (dirs) *************** *** 242,268 **** def add_runtime_library_dir (self, dir): """Add 'dir' to the list of directories that will be searched for ! shared libraries at runtime.""" self.runtime_library_dirs.append (dir) def set_runtime_library_dirs (self, dirs): ! """Set the list of directories to search for shared libraries ! at runtime to 'dirs' (a list of strings). This does not affect ! any standard search path that the runtime linker may search by ! default.""" self.runtime_library_dirs = copy (dirs) def add_link_object (self, object): ! """Add 'object' to the list of object files (or analogues, such ! as explictly named library files or the output of "resource ! compilers") to be included in every link driven by this ! compiler object.""" self.objects.append (object) def set_link_objects (self, objects): ! """Set the list of object files (or analogues) to be included ! in every link to 'objects'. This does not affect any ! standard object files that the linker may include by default ! (such as system libraries).""" self.objects = copy (objects) --- 240,270 ---- def add_runtime_library_dir (self, dir): """Add 'dir' to the list of directories that will be searched for ! shared libraries at runtime. ! """ self.runtime_library_dirs.append (dir) def set_runtime_library_dirs (self, dirs): ! """Set the list of directories to search for shared libraries at ! runtime to 'dirs' (a list of strings). This does not affect any ! standard search path that the runtime linker may search by ! default. ! """ self.runtime_library_dirs = copy (dirs) def add_link_object (self, object): ! """Add 'object' to the list of object files (or analogues, such as ! explictly named library files or the output of "resource ! compilers") to be included in every link driven by this compiler ! object. ! """ self.objects.append (object) def set_link_objects (self, objects): ! """Set the list of object files (or analogues) to be included in ! every link to 'objects'. This does not affect any standard object ! files that the linker may include by default (such as system ! libraries). ! """ self.objects = copy (objects) *************** *** 272,284 **** def _fix_compile_args (self, output_dir, macros, include_dirs): ! """Typecheck and fix-up some of the arguments to the 'compile()' method, ! and return fixed-up values. Specifically: if 'output_dir' is ! None, replaces it with 'self.output_dir'; ensures that 'macros' ! is a list, and augments it with 'self.macros'; ensures that ! 'include_dirs' is a list, and augments it with ! 'self.include_dirs'. Guarantees that the returned values are of ! the correct type, i.e. for 'output_dir' either string or None, ! and for 'macros' and 'include_dirs' either list or None.""" ! if output_dir is None: output_dir = self.output_dir --- 274,286 ---- def _fix_compile_args (self, output_dir, macros, include_dirs): ! """Typecheck and fix-up some of the arguments to the 'compile()' ! method, and return fixed-up values. Specifically: if 'output_dir' ! is None, replaces it with 'self.output_dir'; ensures that 'macros' ! is a list, and augments it with 'self.macros'; ensures that ! 'include_dirs' is a list, and augments it with 'self.include_dirs'. ! Guarantees that the returned values are of the correct type, ! i.e. for 'output_dir' either string or None, and for 'macros' and ! 'include_dirs' either list or None. ! """ if output_dir is None: output_dir = self.output_dir *************** *** 308,316 **** def _prep_compile (self, sources, output_dir): ! """Determine the list of object files corresponding to 'sources', and ! figure out which ones really need to be recompiled. Return a list ! of all object files and a dictionary telling which source files can ! be skipped.""" ! # Get the list of expected output (object) files objects = self.object_filenames (sources, --- 310,318 ---- def _prep_compile (self, sources, output_dir): ! """Determine the list of object files corresponding to 'sources', ! and figure out which ones really need to be recompiled. Return a ! list of all object files and a dictionary telling which source ! files can be skipped. ! """ # Get the list of expected output (object) files objects = self.object_filenames (sources, *************** *** 331,336 **** (n_sources, n_objects) = newer_pairwise (sources, objects) ! for source in n_sources: # no really, only rebuild what's out-of-date ! skip_source[source] = 0 return (objects, skip_source) --- 333,338 ---- (n_sources, n_objects) = newer_pairwise (sources, objects) ! for source in n_sources: # no really, only rebuild what's ! skip_source[source] = 0 # out-of-date return (objects, skip_source) *************** *** 340,348 **** def _fix_object_args (self, objects, output_dir): ! """Typecheck and fix up some arguments supplied to various ! methods. Specifically: ensure that 'objects' is a list; if ! output_dir is None, replace with self.output_dir. Return fixed ! versions of 'objects' and 'output_dir'.""" ! if type (objects) not in (ListType, TupleType): raise TypeError, \ --- 342,350 ---- def _fix_object_args (self, objects, output_dir): ! """Typecheck and fix up some arguments supplied to various methods. ! Specifically: ensure that 'objects' is a list; if output_dir is ! None, replace with self.output_dir. Return fixed versions of ! 'objects' and 'output_dir'. ! """ if type (objects) not in (ListType, TupleType): raise TypeError, \ *************** *** 360,368 **** def _fix_lib_args (self, libraries, library_dirs, runtime_library_dirs): """Typecheck and fix up some of the arguments supplied to the ! 'link_*' methods. Specifically: ensure that all arguments are ! lists, and augment them with their permanent versions ! (eg. 'self.libraries' augments 'libraries'). Return a tuple ! with fixed versions of all arguments.""" ! if libraries is None: libraries = self.libraries --- 362,370 ---- def _fix_lib_args (self, libraries, library_dirs, runtime_library_dirs): """Typecheck and fix up some of the arguments supplied to the ! 'link_*' methods. Specifically: ensure that all arguments are ! lists, and augment them with their permanent versions ! (eg. 'self.libraries' augments 'libraries'). Return a tuple with ! fixed versions of all arguments. ! """ if libraries is None: libraries = self.libraries *************** *** 397,403 **** def _need_link (self, objects, output_file): ! """Return true if we need to relink the files listed in 'objects' to ! recreate 'output_file'.""" ! if self.force: return 1 --- 399,405 ---- def _need_link (self, objects, output_file): ! """Return true if we need to relink the files listed in 'objects' ! to recreate 'output_file'. ! """ if self.force: return 1 *************** *** 439,480 **** extra_preargs=None, extra_postargs=None): ! """Compile one or more C/C++ source files. 'sources' must be ! a list of strings, each one the name of a C/C++ source ! file. Return a list of object filenames, one per source ! filename in 'sources'. Depending on the implementation, ! not all source files will necessarily be compiled, but ! all corresponding object filenames will be returned. ! ! If 'output_dir' is given, object files will be put under it, ! while retaining their original path component. That is, ! "foo/bar.c" normally compiles to "foo/bar.o" (for a Unix ! implementation); if 'output_dir' is "build", then it would ! compile to "build/foo/bar.o". ! ! 'macros', if given, must be a list of macro definitions. A ! macro definition is either a (name, value) 2-tuple or a (name,) ! 1-tuple. The former defines a macro; if the value is None, the ! macro is defined without an explicit value. The 1-tuple case ! undefines a macro. Later definitions/redefinitions/ ! undefinitions take precedence. ! ! 'include_dirs', if given, must be a list of strings, the ! directories to add to the default include file search path for ! this compilation only. ! ! 'debug' is a boolean; if true, the compiler will be instructed ! to output debug symbols in (or alongside) the object file(s). ! ! 'extra_preargs' and 'extra_postargs' are implementation- ! dependent. On platforms that have the notion of a command-line ! (e.g. Unix, DOS/Windows), they are most likely lists of strings: ! extra command-line arguments to prepand/append to the compiler ! command line. On other platforms, consult the implementation ! class documentation. In any event, they are intended as an ! escape hatch for those occasions when the abstract compiler ! framework doesn't cut the mustard. ! Raises CompileError on failure.""" ! pass --- 441,482 ---- extra_preargs=None, extra_postargs=None): ! """Compile one or more C/C++ source files. 'sources' must be a ! list of strings, each one the name of a C/C++ source file. Return ! a list of object filenames, one per source filename in 'sources'. ! Depending on the implementation, not all source files will ! necessarily be compiled, but all corresponding object filenames ! will be returned. ! ! If 'output_dir' is given, object files will be put under it, while ! retaining their original path component. That is, "foo/bar.c" ! normally compiles to "foo/bar.o" (for a Unix implementation); if ! 'output_dir' is "build", then it would compile to ! "build/foo/bar.o". ! ! 'macros', if given, must be a list of macro definitions. A macro ! definition is either a (name, value) 2-tuple or a (name,) 1-tuple. ! The former defines a macro; if the value is None, the macro is ! defined without an explicit value. The 1-tuple case undefines a ! macro. Later definitions/redefinitions/ undefinitions take ! precedence. ! ! 'include_dirs', if given, must be a list of strings, the ! directories to add to the default include file search path for this ! compilation only. ! ! 'debug' is a boolean; if true, the compiler will be instructed to ! output debug symbols in (or alongside) the object file(s). ! ! 'extra_preargs' and 'extra_postargs' are implementation- dependent. ! On platforms that have the notion of a command-line (e.g. Unix, ! DOS/Windows), they are most likely lists of strings: extra ! command-line arguments to prepand/append to the compiler command ! line. On other platforms, consult the implementation class ! documentation. In any event, they are intended as an escape hatch ! for those occasions when the abstract compiler framework doesn't ! cut the mustard. ! Raises CompileError on failure. ! """ pass *************** *** 485,507 **** output_dir=None, debug=0): ! """Link a bunch of stuff together to create a static library ! file. The "bunch of stuff" consists of the list of object ! files supplied as 'objects', the extra object files supplied ! to 'add_link_object()' and/or 'set_link_objects()', the ! libraries supplied to 'add_library()' and/or ! 'set_libraries()', and the libraries supplied as 'libraries' ! (if any). ! ! 'output_libname' should be a library name, not a filename; the ! filename will be inferred from the library name. 'output_dir' ! is the directory where the library file will be put. ! ! 'debug' is a boolean; if true, debugging information will be ! included in the library (note that on most platforms, it is the ! compile step where this matters: the 'debug' flag is included ! here just for consistency). ! ! Raises LibError on failure.""" pass --- 487,508 ---- output_dir=None, debug=0): ! """Link a bunch of stuff together to create a static library file. ! The "bunch of stuff" consists of the list of object files supplied ! as 'objects', the extra object files supplied to ! 'add_link_object()' and/or 'set_link_objects()', the libraries ! supplied to 'add_library()' and/or 'set_libraries()', and the ! libraries supplied as 'libraries' (if any). ! ! 'output_libname' should be a library name, not a filename; the ! filename will be inferred from the library name. 'output_dir' is ! the directory where the library file will be put. ! ! 'debug' is a boolean; if true, debugging information will be ! included in the library (note that on most platforms, it is the ! compile step where this matters: the 'debug' flag is included here ! just for consistency). + Raises LibError on failure. + """ pass *************** *** 518,559 **** extra_preargs=None, extra_postargs=None): - """Link a bunch of stuff together to create a shared library - file. Similar semantics to 'create_static_lib()', with the - addition of other libraries to link against and directories to - search for them. Also, of course, the type and name of - the generated file will almost certainly be different, as will - the program used to create it. - - 'libraries' is a list of libraries to link against. These are - library names, not filenames, since they're translated into - filenames in a platform-specific way (eg. "foo" becomes - "libfoo.a" on Unix and "foo.lib" on DOS/Windows). However, they - can include a directory component, which means the linker will - look in that specific directory rather than searching all the - normal locations. - - 'library_dirs', if supplied, should be a list of directories to - search for libraries that were specified as bare library names - (ie. no directory component). These are on top of the system - default and those supplied to 'add_library_dir()' and/or - 'set_library_dirs()'. 'runtime_library_dirs' is a list of - directories that will be embedded into the shared library and - used to search for other shared libraries that *it* depends on - at run-time. (This may only be relevant on Unix.) - - 'export_symbols' is a list of symbols that the shared library - will export. (This appears to be relevant only on Windows.) - - 'debug' is as for 'compile()' and 'create_static_lib()', with the - slight distinction that it actually matters on most platforms - (as opposed to 'create_static_lib()', which includes a 'debug' - flag mostly for form's sake). - - 'extra_preargs' and 'extra_postargs' are as for 'compile()' - (except of course that they supply command-line arguments - for the particular linker being used). ! Raises LinkError on failure.""" pass --- 519,560 ---- extra_preargs=None, extra_postargs=None): ! """Link a bunch of stuff together to create a shared library file. ! Similar semantics to 'create_static_lib()', with the addition of ! other libraries to link against and directories to search for them. ! Also, of course, the type and name of the generated file will ! almost certainly be different, as will the program used to create ! it. ! ! 'libraries' is a list of libraries to link against. These are ! library names, not filenames, since they're translated into ! filenames in a platform-specific way (eg. "foo" becomes "libfoo.a" ! on Unix and "foo.lib" on DOS/Windows). However, they can include a ! directory component, which means the linker will look in that ! specific directory rather than searching all the normal locations. ! ! 'library_dirs', if supplied, should be a list of directories to ! search for libraries that were specified as bare library names ! (ie. no directory component). These are on top of the system ! default and those supplied to 'add_library_dir()' and/or ! 'set_library_dirs()'. 'runtime_library_dirs' is a list of ! directories that will be embedded into the shared library and used ! to search for other shared libraries that *it* depends on at ! run-time. (This may only be relevant on Unix.) ! ! 'export_symbols' is a list of symbols that the shared library will ! export. (This appears to be relevant only on Windows.) ! ! 'debug' is as for 'compile()' and 'create_static_lib()', with the ! slight distinction that it actually matters on most platforms (as ! opposed to 'create_static_lib()', which includes a 'debug' flag ! mostly for form's sake). ! ! 'extra_preargs' and 'extra_postargs' are as for 'compile()' (except ! of course that they supply command-line arguments for the ! particular linker being used). + Raises LinkError on failure. + """ pass *************** *** 570,581 **** extra_preargs=None, extra_postargs=None): ! """Link a bunch of stuff together to create a shared object ! file. Much like 'link_shared_lib()', except the output filename ! is explicitly supplied as 'output_filename'. If 'output_dir' is ! supplied, 'output_filename' is relative to it ! (i.e. 'output_filename' can provide directory components if ! needed). ! Raises LinkError on failure.""" pass --- 571,583 ---- extra_preargs=None, extra_postargs=None): ! """Link a bunch of stuff together to create a shared object file. ! Much like 'link_shared_lib()', except the output filename is ! explicitly supplied as 'output_filename'. If 'output_dir' is ! supplied, 'output_filename' is relative to it ! (i.e. 'output_filename' can provide directory components if ! needed). ! Raises LinkError on failure. ! """ pass *************** *** 592,601 **** extra_postargs=None): """Link a bunch of stuff together to create a binary executable ! file. The "bunch of stuff" is as for 'link_shared_lib()'. ! 'output_progname' should be the base name of the executable ! program--e.g. on Unix the same as the output filename, but ! on DOS/Windows ".exe" will be appended. ! Raises LinkError on failure.""" pass --- 594,604 ---- extra_postargs=None): """Link a bunch of stuff together to create a binary executable ! file. The "bunch of stuff" is as for 'link_shared_lib()'. ! 'output_progname' should be the base name of the executable ! program--e.g. on Unix the same as the output filename, but on ! DOS/Windows ".exe" will be appended. ! Raises LinkError on failure. ! """ pass *************** *** 608,629 **** def library_dir_option (self, dir): ! """Return the compiler option to add 'dir' to the list of directories ! searched for libraries.""" raise NotImplementedError def runtime_library_dir_option (self, dir): ! """Return the compiler option to add 'dir' to the list of directories ! searched for runtime libraries.""" raise NotImplementedError def library_option (self, lib): """Return the compiler option to add 'dir' to the list of libraries ! linked into the shared library or executable.""" raise NotImplementedError def find_library_file (self, dirs, lib): """Search the specified list of directories for a static or shared ! library file 'lib' and return the full path to that file. Return ! None if it wasn't found in any of the specified directories.""" raise NotImplementedError --- 611,636 ---- def library_dir_option (self, dir): ! """Return the compiler option to add 'dir' to the list of ! directories searched for libraries. ! """ raise NotImplementedError def runtime_library_dir_option (self, dir): ! """Return the compiler option to add 'dir' to the list of ! directories searched for runtime libraries. ! """ raise NotImplementedError def library_option (self, lib): """Return the compiler option to add 'dir' to the list of libraries ! linked into the shared library or executable. ! """ raise NotImplementedError def find_library_file (self, dirs, lib): """Search the specified list of directories for a static or shared ! library file 'lib' and return the full path to that file. Return ! None if it wasn't found in any of the specified directories. ! """ raise NotImplementedError *************** *** 777,792 **** dry_run=0, force=0): - """Generate an instance of some CCompiler subclass for the supplied ! platform/compiler combination. 'plat' defaults to 'os.name' ! (eg. 'posix', 'nt'), and 'compiler' defaults to the default ! compiler for that platform. Currently only 'posix' and 'nt' ! are supported, and the default compilers are "traditional Unix ! interface" (UnixCCompiler class) and Visual C++ (MSVCCompiler ! class). Note that it's perfectly possible to ask for a Unix ! compiler object under Windows, and a Microsoft compiler object ! under Unix -- if you supply a value for 'compiler', 'plat' ! is ignored.""" ! if plat is None: plat = os.name --- 784,797 ---- dry_run=0, force=0): """Generate an instance of some CCompiler subclass for the supplied ! platform/compiler combination. 'plat' defaults to 'os.name' ! (eg. 'posix', 'nt'), and 'compiler' defaults to the default compiler ! for that platform. Currently only 'posix' and 'nt' are supported, and ! the default compilers are "traditional Unix interface" (UnixCCompiler ! class) and Visual C++ (MSVCCompiler class). Note that it's perfectly ! possible to ask for a Unix compiler object under Windows, and a ! Microsoft compiler object under Unix -- if you supply a value for ! 'compiler', 'plat' is ignored. ! """ if plat is None: plat = os.name *************** *** 821,833 **** def gen_preprocess_options (macros, include_dirs): ! """Generate C pre-processor options (-D, -U, -I) as used by at ! least two types of compilers: the typical Unix compiler and Visual ! C++. 'macros' is the usual thing, a list of 1- or 2-tuples, where ! (name,) means undefine (-U) macro 'name', and (name,value) means ! define (-D) macro 'name' to 'value'. 'include_dirs' is just a list of ! directory names to be added to the header file search path (-I). ! Returns a list of command-line options suitable for either ! Unix compilers or Visual C++.""" ! # XXX it would be nice (mainly aesthetic, and so we don't generate # stupid-looking command lines) to go over 'macros' and eliminate --- 826,838 ---- def gen_preprocess_options (macros, include_dirs): ! """Generate C pre-processor options (-D, -U, -I) as used by at least ! two types of compilers: the typical Unix compiler and Visual C++. ! 'macros' is the usual thing, a list of 1- or 2-tuples, where (name,) ! means undefine (-U) macro 'name', and (name,value) means define (-D) ! macro 'name' to 'value'. 'include_dirs' is just a list of directory ! names to be added to the header file search path (-I). Returns a list ! of command-line options suitable for either Unix compilers or Visual ! C++. ! """ # XXX it would be nice (mainly aesthetic, and so we don't generate # stupid-looking command lines) to go over 'macros' and eliminate *************** *** 873,882 **** def gen_lib_options (compiler, library_dirs, runtime_library_dirs, libraries): """Generate linker options for searching library directories and ! linking with specific libraries. 'libraries' and 'library_dirs' ! are, respectively, lists of library names (not filenames!) and ! search directories. Returns a list of command-line options suitable ! for use with some compiler (depending on the two format strings ! passed in).""" ! lib_opts = [] --- 878,886 ---- def gen_lib_options (compiler, library_dirs, runtime_library_dirs, libraries): """Generate linker options for searching library directories and ! linking with specific libraries. 'libraries' and 'library_dirs' are, ! respectively, lists of library names (not filenames!) and search ! directories. Returns a list of command-line options suitable for use ! with some compiler (depending on the two format strings passed in). ! """ lib_opts = [] From python-dev@python.org Sat Jun 24 21:40:05 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 13:40:05 -0700 Subject: [Python-checkins] CVS: distutils/distutils util.py,1.36,1.37 Message-ID: <200006242040.NAA28315@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv28287 Modified Files: util.py Log Message: Added 'split_quoted()' function to deal with strings that are quoted in Unix shell-like syntax (eg. in Python's Makefile, for one thing -- now that I have this function, I'll probably allow quoted strings in config files too. Index: util.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/util.py,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -r1.36 -r1.37 *** util.py 2000/06/18 15:45:55 1.36 --- util.py 2000/06/24 20:40:02 1.37 *************** *** 167,168 **** --- 167,235 ---- return error + + + # Needed by 'split_quoted()' + _wordchars_re = re.compile(r'[^\\\'\"\ ]*') + _squote_re = re.compile(r"'(?:[^'\\]|\\.)*'") + _dquote_re = re.compile(r'"(?:[^"\\]|\\.)*"') + + def split_quoted (s): + """Split a string up according to Unix shell-like rules for quotes and + backslashes. In short: words are delimited by spaces, as long as those + spaces are not escaped by a backslash, or inside a quoted string. + Single and double quotes are equivalent, and the quote characters can + be backslash-escaped. The backslash is stripped from any two-character + escape sequence, leaving only the escaped character. The quote + characters are stripped from any quoted string. Returns a list of + words. + """ + + # This is a nice algorithm for splitting up a single string, since it + # doesn't require character-by-character examination. It was a little + # bit of a brain-bender to get it working right, though... + + s = string.strip(s) + words = [] + pos = 0 + + while s: + m = _wordchars_re.match(s, pos) + end = m.end() + if end == len(s): + words.append(s[:end]) + break + + if s[end] == ' ': # unescaped, unquoted space: now + words.append(s[:end]) # we definitely have a word delimiter + s = string.lstrip(s[end:]) + pos = 0 + + elif s[end] == '\\': # preserve whatever is being escaped; + # will become part of the current word + s = s[:end] + s[end+1:] + pos = end+1 + + else: + if s[end] == "'": # slurp singly-quoted string + m = _squote_re.match(s, end) + elif s[end] == '"': # slurp doubly-quoted string + m = _dquote_re.match(s, end) + else: + raise RuntimeError, \ + "this can't happen (bad char '%c')" % s[end] + + if m is None: + raise ValueError, \ + "bad string (mismatched %s quotes?)" % s[end] + + (beg, end) = m.span() + s = s[:beg] + s[beg+1:end-1] + s[end:] + pos = m.end() - 2 + + if pos >= len(s): + words.append(s) + break + + return words + + # split_quoted () From python-dev@python.org Sat Jun 24 21:41:13 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 13:41:13 -0700 Subject: [Python-checkins] CVS: distutils/test test_split.py,NONE,1.1 Message-ID: <200006242041.NAA28382@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv28374 Added Files: test_split.py Log Message: Test script for the 'split_quoted()' function. --- NEW FILE --- #!/usr/bin/env python import string, re from distutils.util import split_quoted strings = [("foo bar baz", ['foo', 'bar', 'baz']), (" foo bar", ['foo', 'bar']), ("foo bar ", ['foo', 'bar']), ("foo bar", ['foo', 'bar']), ("\\ foo", [' foo']), ("foo \\ bar", ['foo', ' bar']), ("foo \\ bar", ['foo', ' ', 'bar']), ("foo", ['foo']), ("foo\\ bar", ['foo bar']), ("'foo bar'", ['foo bar']), ("foo 'bar baz'", ['foo', 'bar baz']), ('"foo bar" baz', ['foo bar', 'baz']), ('"hello there" "*"', ['hello there', '*']), ('ding" dong" dang', ['ding dong', 'dang']), ('foo""bar', ['foobar']), ('foo" "bar', ['foo bar']), ('foo\\" bar', ['foo\"', 'bar']), ('foo \\"bar', ['foo', '\"bar']), ('foo\\ \\"bar', ['foo \"bar']), ] bad_strings = ["foo bar'", "'foo bar", "foo 'bar", 'foo "bar', ] for (s, words) in strings: got_split = split_quoted(s) if got_split == words: print "ok: %s -> %s" % (s, got_split) else: print "not ok: %s (expected %s, got %s)" % (s, words, got_split) #print "string to split: " + s #print "expect:", words #print "result:", split(s) #print "expect:", string.join(map(str, words), ", ") #print "result:", string.join(map(str, split(s)), ", ") #print for s in bad_strings: try: words = split_quoted(s) except ValueError, msg: print "ok: %s raised ValueError: %s" % (s, msg) else: print "not ok: %s -> %s (expected ValueError)" % (s, words) From python-dev@python.org Sun Jun 25 03:05:31 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 19:05:31 -0700 Subject: [Python-checkins] CVS: distutils/distutils unixccompiler.py,1.26,1.27 Message-ID: <200006250205.TAA15014@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv15000 Modified Files: unixccompiler.py Log Message: Got rid of direct dependence on the sysconfig module. Mainly, this meant playing along with the new "dictionary of executables" scheme added to CCompiler by adding the 'executables' class attribute, and changing all the compile/link/etc. methods to use the new attributes (which encapsulate both the program to run and its standard arguments, so it was a *little* bit more than just changing some names). Index: unixccompiler.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/unixccompiler.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -r1.26 -r1.27 *** unixccompiler.py 2000/06/21 02:58:46 1.26 --- unixccompiler.py 2000/06/25 02:05:29 1.27 *************** *** 21,25 **** from types import * from copy import copy - from distutils import sysconfig from distutils.dep_util import newer from distutils.ccompiler import \ --- 21,24 ---- *************** *** 46,76 **** class UnixCCompiler (CCompiler): - # XXX perhaps there should really be *three* kinds of include - # directories: those built in to the preprocessor, those from Python's - # Makefiles, and those supplied to {add,set}_include_dirs(). Currently - # we make no distinction between the latter two at this point; it's all - # up to the client class to select the include directories to use above - # and beyond the compiler's defaults. That is, both the Python include - # directories and any module- or package-specific include directories - # are specified via {add,set}_include_dirs(), and there's no way to - # distinguish them. This might be a bug. - compiler_type = 'unix' - # Needed for the filename generation methods provided by the - # base class, CCompiler. src_extensions = [".c",".C",".cc",".cxx",".cpp"] obj_extension = ".o" static_lib_extension = ".a" ! shared_lib_extension = sysconfig.SO static_lib_format = shared_lib_format = "lib%s%s" - # Command to create a static library: seems to be pretty consistent - # across the major Unices. Might have to move down into the - # constructor if we need platform-specific guesswork. - archiver = sysconfig.AR - archiver_options = "-cr" - ranlib = sysconfig.RANLIB - def __init__ (self, --- 45,77 ---- class UnixCCompiler (CCompiler): compiler_type = 'unix' + + # These are used by CCompiler in two places: the constructor sets + # instance attributes 'preprocessor', 'compiler', etc. from them, and + # 'set_executable()' allows any of these to be set. The defaults here + # are pretty generic; they will probably have to be set by an outsider + # (eg. using information discovered by the sysconfig about building + # Python extensions). + executables = {'preprocessor' : None, + 'compiler' : ["cc"], + 'compiler_so' : ["cc"], + 'linker_so' : ["cc", "-shared"], + 'linker_exe' : ["cc"], + 'archiver' : ["ar", "-cr"], + 'ranlib' : None, + } + + # Needed for the filename generation methods provided by the base + # class, CCompiler. NB. whoever instantiates/uses a particular + # UnixCCompiler instance should set 'shared_lib_ext' -- we set a + # reasonable common default here, but it's not necessarily used on all + # Unices! src_extensions = [".c",".C",".cc",".cxx",".cpp"] obj_extension = ".o" static_lib_extension = ".a" ! shared_lib_extension = ".so" static_lib_format = shared_lib_format = "lib%s%s" def __init__ (self, *************** *** 78,109 **** dry_run=0, force=0): - CCompiler.__init__ (self, verbose, dry_run, force) - self.preprocess_options = None - self.compile_options = None - - # Munge CC and OPT together in case there are flags stuck in CC. - # Note that using these variables from sysconfig immediately makes - # this module specific to building Python extensions and - # inappropriate as a general-purpose C compiler front-end. So sue - # me. Note also that we use OPT rather than CFLAGS, because CFLAGS - # is the flags used to compile Python itself -- not only are there - # -I options in there, they are the *wrong* -I options. We'll - # leave selection of include directories up to the class using - # UnixCCompiler! - - (self.cc, self.ccflags) = \ - _split_command (sysconfig.CC + ' ' + sysconfig.OPT) - self.ccflags_shared = string.split (sysconfig.CCSHARED) - - (self.ld_shared, self.ldflags_shared) = \ - _split_command (sysconfig.LDSHARED) - self.ld_exec = self.cc - - # __init__ () - - def preprocess (self, source, --- 79,85 ---- *************** *** 117,125 **** self._fix_compile_args (None, macros, include_dirs) pp_opts = gen_preprocess_options (macros, include_dirs) ! cc_args = ['-E'] + pp_opts if output_file: ! cc_args.extend(['-o', output_file]) if extra_preargs: ! cc_args[:0] = extra_preargs if extra_postargs: extra_postargs.extend(extra_postargs) --- 93,101 ---- self._fix_compile_args (None, macros, include_dirs) pp_opts = gen_preprocess_options (macros, include_dirs) ! pp_args = self.preprocessor + pp_opts if output_file: ! pp_args.extend(['-o', output_file]) if extra_preargs: ! pp_args[:0] = extra_preargs if extra_postargs: extra_postargs.extend(extra_postargs) *************** *** 132,136 **** self.mkpath(os.path.dirname(output_file)) try: ! self.spawn ([self.cc] + cc_args) except DistutilsExecError, msg: raise CompileError, msg --- 108,112 ---- self.mkpath(os.path.dirname(output_file)) try: ! self.spawn (pp_args) except DistutilsExecError, msg: raise CompileError, msg *************** *** 152,156 **** # Figure out the options for the compiler command line. pp_opts = gen_preprocess_options (macros, include_dirs) ! cc_args = ['-c'] + pp_opts + self.ccflags + self.ccflags_shared if debug: cc_args[:0] = ['-g'] --- 128,132 ---- # Figure out the options for the compiler command line. pp_opts = gen_preprocess_options (macros, include_dirs) ! cc_args = pp_opts + ['-c'] if debug: cc_args[:0] = ['-g'] *************** *** 169,173 **** self.mkpath (os.path.dirname (obj)) try: ! self.spawn ([self.cc] + cc_args + [src, '-o', obj] + extra_postargs) --- 145,149 ---- self.mkpath (os.path.dirname (obj)) try: ! self.spawn (self.compiler_so + cc_args + [src, '-o', obj] + extra_postargs) *************** *** 194,200 **** if self._need_link (objects, output_filename): self.mkpath (os.path.dirname (output_filename)) ! self.spawn ([self.archiver, ! self.archiver_options, ! output_filename] + objects + self.objects) --- 170,175 ---- if self._need_link (objects, output_filename): self.mkpath (os.path.dirname (output_filename)) ! self.spawn (self.archiver + ! [output_filename] + objects + self.objects) *************** *** 204,210 **** # needed -- or maybe Python's configure script took care of # it for us, hence the check for leading colon. ! if self.ranlib[0] != ':': try: ! self.spawn ([self.ranlib, output_filename]) except DistutilsExecError, msg: raise LibError, msg --- 179,185 ---- # needed -- or maybe Python's configure script took care of # it for us, hence the check for leading colon. ! if self.ranlib: try: ! self.spawn (self.ranlib + [output_filename]) except DistutilsExecError, msg: raise LibError, msg *************** *** 264,268 **** if self._need_link (objects, output_filename): ! ld_args = (self.ldflags_shared + objects + self.objects + lib_opts + ['-o', output_filename]) if debug: --- 239,243 ---- if self._need_link (objects, output_filename): ! ld_args = (objects + self.objects + lib_opts + ['-o', output_filename]) if debug: *************** *** 274,278 **** self.mkpath (os.path.dirname (output_filename)) try: ! self.spawn ([self.ld_shared] + ld_args) except DistutilsExecError, msg: raise LinkError, msg --- 249,253 ---- self.mkpath (os.path.dirname (output_filename)) try: ! self.spawn (self.linker_so + ld_args) except DistutilsExecError, msg: raise LinkError, msg *************** *** 315,319 **** self.mkpath (os.path.dirname (output_filename)) try: ! self.spawn ([self.ld_exec] + ld_args) except DistutilsExecError, msg: raise LinkError, msg --- 290,294 ---- self.mkpath (os.path.dirname (output_filename)) try: ! self.spawn (self.linker_exe + ld_args) except DistutilsExecError, msg: raise LinkError, msg *************** *** 360,368 **** # class UnixCCompiler - - - def _split_command (cmd): - """Split a command string up into the progam to run (a string) and - the list of arguments; return them as (cmd, arglist).""" - args = string.split (cmd) - return (args[0], args[1:]) --- 335,336 ---- From python-dev@python.org Sun Jun 25 03:08:20 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 19:08:20 -0700 Subject: [Python-checkins] CVS: distutils/distutils ccompiler.py,1.26,1.27 Message-ID: <200006250208.TAA15063@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv15055 Modified Files: ccompiler.py Log Message: Introduced some bureaucracy for setting and tracking the executables that a particular compiler system depends on. This consists of the 'set_executables()' and 'set_executable()' methods, and a few lines in the constructor that expect implementation classes to provide an 'executables' attribute, which we use to initialize several instance attributes. The default implementation is somewhat biased in favour of a Unix/DOS "command-line" view of the world, but it shouldn't be too hard to override this for operating systems with a more sophisticated way of representing programs-to-execute. Index: ccompiler.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/ccompiler.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -r1.26 -r1.27 *** ccompiler.py 2000/06/24 18:10:48 1.26 --- ccompiler.py 2000/06/25 02:08:18 1.27 *************** *** 13,17 **** from distutils.errors import * from distutils.spawn import spawn ! from distutils.util import move_file, mkpath, newer_pairwise, newer_group --- 13,20 ---- from distutils.errors import * from distutils.spawn import spawn ! from distutils.file_util import move_file ! from distutils.dir_util import mkpath ! from distutils.dep_util import newer_pairwise, newer_group ! from distutils.util import split_quoted *************** *** 110,116 **** --- 113,166 ---- self.objects = [] + for key in self.executables.keys(): + self.set_executable(key, self.executables[key]) + # __init__ () + def set_executables (self, **args): + + """Define the executables (and options for them) that will be run + to perform the various stages of compilation. The exact set of + executables that may be specified here depends on the compiler + class (via the 'executables' class attribute), but most will have: + compiler the C/C++ compiler + linker_so linker used to create shared objects and libraries + linker_exe linker used to create binary executables + archiver static library creator + + On platforms with a command-line (Unix, DOS/Windows), each of these + is a string that will be split into executable name and (optional) + list of arguments. (Splitting the string is done similarly to how + Unix shells operate: words are delimited by spaces, but quotes and + backslashes can override this. See + 'distutils.util.split_quoted()'.) + """ + + # Note that some CCompiler implementation classes will define class + # attributes 'cpp', 'cc', etc. with hard-coded executable names; + # this is appropriate when a compiler class is for exactly one + # compiler/OS combination (eg. MSVCCompiler). Other compiler + # classes (UnixCCompiler, in particular) are driven by information + # discovered at run-time, since there are many different ways to do + # basically the same things with Unix C compilers. + + for key in args.keys(): + if not self.executables.has_key(key): + raise ValueError, \ + "unknown executable '%s' for class %s" % \ + (key, self.__class__.__name__) + self.set_executable(key, args[key]) + + # set_executables () + + def set_executable(self, key, value): + if type(value) is StringType: + setattr(self, key, split_quoted(value)) + else: + setattr(self, key, value) + + + def _find_macro (self, name): i = 0 *************** *** 430,433 **** --- 480,485 ---- with 'define_macro()' and 'undefine_macro()'. 'include_dirs' is a list of directory names that will be added to the default list. + + Raises PreprocessError on failure. """ pass *************** *** 441,446 **** extra_preargs=None, extra_postargs=None): ! """Compile one or more C/C++ source files. 'sources' must be a ! list of strings, each one the name of a C/C++ source file. Return a list of object filenames, one per source filename in 'sources'. Depending on the implementation, not all source files will --- 493,501 ---- extra_preargs=None, extra_postargs=None): ! ! """Compile one or more source files. 'sources' must be a list of ! filenames, most likely C/C++ files, but in reality anything that ! can be handled by a particular compiler and compiler class ! (eg. MSVCCompiler can handle resource files in 'sources'). Return a list of object filenames, one per source filename in 'sources'. Depending on the implementation, not all source files will From python-dev@python.org Sun Jun 25 03:09:16 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 19:09:16 -0700 Subject: [Python-checkins] CVS: distutils/distutils sysconfig.py,1.19,1.20 Message-ID: <200006250209.TAA15089@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv15080 Modified Files: sysconfig.py Log Message: Added the 'customize_compiler()' function, which plugs in the essential information about building Python extensions that we discovered in Python's makefile. Currently only needed on Unix, so does nothing on other systems. Index: sysconfig.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/sysconfig.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -r1.19 -r1.20 *** sysconfig.py 2000/06/03 00:44:30 1.19 --- sysconfig.py 2000/06/25 02:09:14 1.20 *************** *** 98,101 **** --- 98,118 ---- + def customize_compiler (compiler): + """Do any platform-specific customization of the CCompiler instance + 'compiler'. Mainly needed on Unix, so we can plug in the information + that varies across Unices and is stored in Python's Makefile. + """ + if compiler.compiler_type == "unix": + cc_cmd = CC + ' ' + OPT + compiler.set_executables( + preprocessor=CC + " -E", # not always! + compiler=cc_cmd, + compiler_so=cc_cmd + ' ' + CCSHARED, + linker_so=LDSHARED, + linker_exe=CC) + + compiler.shared_lib_extension = SO + + def get_config_h_filename(): """Return full pathname of installed config.h file.""" *************** *** 261,264 **** --- 278,284 ---- # here they are. The fact that other Windows compilers don't need # these values is pure luck (hmmm). + + # XXX I think these are now unnecessary... + g['CC'] = "cc" # not gcc? g['RANLIB'] = "ranlib" From python-dev@python.org Sun Jun 25 03:10:49 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 19:10:49 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command build_ext.py,1.45,1.46 Message-ID: <200006250210.TAA15232@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv15224 Modified Files: build_ext.py Log Message: Fixed a few silly bugs in my SWIG support code. (Hey, I said it was experimental and untested.) Call 'customize_compiler()' after getting CCompiler object. Index: build_ext.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build_ext.py,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -r1.45 -r1.46 *** build_ext.py 2000/06/24 01:23:37 1.45 --- build_ext.py 2000/06/25 02:10:46 1.46 *************** *** 13,16 **** --- 13,17 ---- from distutils.core import Command from distutils.errors import * + from distutils.sysconfig import customize_compiler from distutils.dep_util import newer_group from distutils.extension import Extension *************** *** 192,195 **** --- 193,197 ---- dry_run=self.dry_run, force=self.force) + customize_compiler(self.compiler) # And make sure that any compile/link-related options (which might *************** *** 454,465 **** for source in sources: (base, ext) = os.path.splitext(source) ! if ext in self.swig_ext(): new_sources.append(base + ".c") # umm, what if it's C++? ! swig_files.append(source) swig_targets[source] = new_sources[-1] else: new_sources.append(source) ! if not swig_files: return new_sources --- 456,467 ---- for source in sources: (base, ext) = os.path.splitext(source) ! if ext == ".i": # SWIG interface file new_sources.append(base + ".c") # umm, what if it's C++? ! swig_sources.append(source) swig_targets[source] = new_sources[-1] else: new_sources.append(source) ! if not swig_sources: return new_sources From python-dev@python.org Sun Jun 25 03:11:00 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 19:11:00 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command build_clib.py,1.18,1.19 Message-ID: <200006250211.TAA15246@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv15237/command Modified Files: build_clib.py Log Message: Call 'customize_compiler()' after getting CCompiler object. Index: build_clib.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build_clib.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** build_clib.py 2000/06/24 01:23:37 1.18 --- build_clib.py 2000/06/25 02:10:58 1.19 *************** *** 24,27 **** --- 24,28 ---- from distutils.core import Command from distutils.errors import * + from distutils.sysconfig import customize_compiler *************** *** 112,115 **** --- 113,117 ---- dry_run=self.dry_run, force=self.force) + customize_compiler(self.compiler) if self.include_dirs is not None: From python-dev@python.org Sun Jun 25 03:12:16 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 19:12:16 -0700 Subject: [Python-checkins] CVS: distutils/distutils errors.py,1.8,1.9 Message-ID: <200006250212.TAA15337@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv15328 Modified Files: errors.py Log Message: Added PreprocessError and UnknownFileError (both used by CCompiler). Index: errors.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/errors.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** errors.py 2000/05/30 02:02:14 1.8 --- errors.py 2000/06/25 02:12:14 1.9 *************** *** 79,82 **** --- 79,85 ---- """Some compile/link operation failed.""" + class PreprocessError (CCompilerError): + """Failure to preprocess one or more C/C++ files.""" + class CompileError (CCompilerError): """Failure to compile one or more C/C++ source files.""" *************** *** 89,92 **** """Failure to link one or more C/C++ object files into an executable or shared library file.""" - --- 92,96 ---- """Failure to link one or more C/C++ object files into an executable or shared library file.""" + class UnknownFileError (CCompilerError): + """Attempt to process an unknown file type.""" From python-dev@python.org Sun Jun 25 03:23:13 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 19:23:13 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command build_ext.py,1.46,1.47 Message-ID: <200006250223.TAA15670@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv15662 Modified Files: build_ext.py Log Message: Fixed the "pre-link hook" so it actually works, mainly by renaming it to 'msvc_prelink_hack()', adding the parameters that it actually needs, and only calling it for MSVC compiler objects. Generally gave up on the idea of a general "hook" mechanism: deleted the empty 'precompile_hook()'. Index: build_ext.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build_ext.py,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -r1.46 -r1.47 *** build_ext.py 2000/06/25 02:10:46 1.46 --- build_ext.py 2000/06/25 02:23:11 1.47 *************** *** 189,193 **** # Setup the CCompiler object that we'll use to do all the # compiling and linking ! self.compiler = new_compiler (compiler=self.compiler, verbose=self.verbose, dry_run=self.dry_run, --- 189,194 ---- # Setup the CCompiler object that we'll use to do all the # compiling and linking ! self.compiler = new_compiler (#compiler=self.compiler, ! compiler="msvc", verbose=self.verbose, dry_run=self.dry_run, *************** *** 403,411 **** extra_args.extend(string.split(os.environ['CFLAGS'])) - # Run any platform/compiler-specific hooks needed before - # compiling (currently none, but any hypothetical subclasses - # might find it useful to override this). - self.precompile_hook() - objects = self.compiler.compile (sources, output_dir=self.build_temp, --- 404,407 ---- *************** *** 422,428 **** extra_args = ext.extra_link_args ! # Run any platform/compiler-specific hooks needed between ! # compiling and linking (currently needed only on Windows). ! self.prelink_hook() self.compiler.link_shared_object ( --- 418,424 ---- extra_args = ext.extra_link_args ! # Bunch of fixing-up we have to do for Microsoft's linker. ! if self.compiler.compiler_type == 'msvc': ! self.msvc_prelink_hack(sources, ext, extra_args) self.compiler.link_shared_object ( *************** *** 504,514 **** # find_swig () - - # -- Hooks --------------------------------------------------------- ! def precompile_hook (self): ! pass ! def prelink_hook (self): # XXX this is a kludge! Knowledge of specific compilers or --- 500,507 ---- # find_swig () ! # -- Hooks 'n hacks ------------------------------------------------ ! def msvc_prelink_hack (self, sources, ext, extra_args): # XXX this is a kludge! Knowledge of specific compilers or *************** *** 522,552 **** # excuse for committing more platform- and compiler-specific # kludges; they are to be avoided if possible!) - if self.compiler.compiler_type == 'msvc': - def_file = ext.export_symbol_file - if def_file is None: - source_dir = os.path.dirname (sources[0]) - ext_base = (string.split (ext.name, '.'))[-1] - def_file = os.path.join (source_dir, "%s.def" % ext_base) - if not os.path.exists (def_file): - def_file = None ! if def_file is not None: ! extra_args.append ('/DEF:' + def_file) ! else: ! modname = string.split (ext.name, '.')[-1] ! extra_args.append('/export:init%s'%modname) ! # The MSVC linker generates unneeded .lib and .exp files, ! # which cannot be suppressed by any linker switches. So ! # make sure they are generated in the temporary build ! # directory. ! implib_file = os.path.join ( ! self.build_temp, ! self.get_ext_libname (ext.name)) ! extra_args.append ('/IMPLIB:' + implib_file) ! self.mkpath (os.path.dirname (implib_file)) ! # if MSVC ! # prelink_hook () --- 515,544 ---- # excuse for committing more platform- and compiler-specific # kludges; they are to be avoided if possible!) ! def_file = ext.export_symbol_file ! if def_file is None: ! source_dir = os.path.dirname (sources[0]) ! ext_base = (string.split (ext.name, '.'))[-1] ! def_file = os.path.join (source_dir, "%s.def" % ext_base) ! if not os.path.exists (def_file): ! def_file = None ! ! if def_file is not None: ! extra_args.append ('/DEF:' + def_file) ! else: ! modname = string.split (ext.name, '.')[-1] ! extra_args.append('/export:init%s' % modname) ! # The MSVC linker generates unneeded .lib and .exp files, ! # which cannot be suppressed by any linker switches. So ! # make sure they are generated in the temporary build ! # directory. ! implib_file = os.path.join ( ! self.build_temp, ! self.get_ext_libname (ext.name)) ! extra_args.append ('/IMPLIB:' + implib_file) ! self.mkpath (os.path.dirname (implib_file)) ! # msvc_prelink_hack () From python-dev@python.org Sun Jun 25 03:30:17 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 19:30:17 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command build_ext.py,1.47,1.48 Message-ID: <200006250230.TAA16004@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv15996 Modified Files: build_ext.py Log Message: Removed some debugging code that slipped into the last checkin. Ensure that 'extra_args' (whether compile or link args) is never None. Index: build_ext.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build_ext.py,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -r1.47 -r1.48 *** build_ext.py 2000/06/25 02:23:11 1.47 --- build_ext.py 2000/06/25 02:30:15 1.48 *************** *** 189,194 **** # Setup the CCompiler object that we'll use to do all the # compiling and linking ! self.compiler = new_compiler (#compiler=self.compiler, ! compiler="msvc", verbose=self.verbose, dry_run=self.dry_run, --- 189,193 ---- # Setup the CCompiler object that we'll use to do all the # compiling and linking ! self.compiler = new_compiler (compiler=self.compiler, verbose=self.verbose, dry_run=self.dry_run, *************** *** 394,398 **** # any sensible compiler will give precendence to later # command line args. Hence we combine them in order: ! extra_args = ext.extra_compile_args # XXX and if we support CFLAGS, why not CC (compiler --- 393,397 ---- # any sensible compiler will give precendence to later # command line args. Hence we combine them in order: ! extra_args = ext.extra_compile_args or [] # XXX and if we support CFLAGS, why not CC (compiler *************** *** 416,420 **** if ext.extra_objects: objects.extend (ext.extra_objects) ! extra_args = ext.extra_link_args # Bunch of fixing-up we have to do for Microsoft's linker. --- 415,419 ---- if ext.extra_objects: objects.extend (ext.extra_objects) ! extra_args = ext.extra_link_args or [] # Bunch of fixing-up we have to do for Microsoft's linker. From python-dev@python.org Sun Jun 25 03:31:19 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 19:31:19 -0700 Subject: [Python-checkins] CVS: distutils/distutils msvccompiler.py,1.30,1.31 Message-ID: <200006250231.TAA16029@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv16019 Modified Files: msvccompiler.py Log Message: Define the 'executables' class attribute so the CCompiler constructor doesn't blow up. We don't currently use the 'set_executables()' bureaucracy, although it would be nice to do so for consistency with UnixCCompiler. Index: msvccompiler.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/msvccompiler.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -r1.30 -r1.31 *** msvccompiler.py 2000/05/30 02:02:49 1.30 --- msvccompiler.py 2000/06/25 02:31:16 1.31 *************** *** 168,171 **** --- 168,178 ---- compiler_type = 'msvc' + # Just set this so CCompiler's constructor doesn't barf. We currently + # don't use the 'set_executables()' bureaucracy provided by CCompiler, + # as it really isn't necessary for this sort of single-compiler class. + # Would be nice to have a consistent interface with UnixCCompiler, + # though, so it's worth thinking about. + executables = {} + # Private class data (need to distinguish C from C++ source for compiler) _c_extensions = ['.c'] *************** *** 296,300 **** lib_args.extend (extra_postargs) try: ! self.spawn ([self.link] + ld_args) except DistutilsExecError, msg: raise LibError, msg --- 303,307 ---- lib_args.extend (extra_postargs) try: ! self.spawn ([self.lib] + lib_args) except DistutilsExecError, msg: raise LibError, msg From python-dev@python.org Sun Jun 25 03:37:11 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 19:37:11 -0700 Subject: [Python-checkins] CVS: distutils TODO,1.4,1.5 Message-ID: <200006250237.TAA16181@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv16172 Modified Files: TODO Log Message: Updated status of several items. Index: TODO =================================================================== RCS file: /cvsroot/python/distutils/TODO,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** TODO 2000/06/24 01:27:26 1.4 --- TODO 2000/06/25 02:37:09 1.5 *************** *** 13,22 **** build are the right way, so those should be preferred) ! * install_data should to to $prefix by default, not $prefix/share (and should warn if developer doesn't supply any dir component: installing right to $prefix is almost always the wrong thing to do) - DOCS ---- --- 13,22 ---- build are the right way, so those should be preferred) ! * install_data should install to $prefix by default, not $prefix/share (and should warn if developer doesn't supply any dir component: installing right to $prefix is almost always the wrong thing to do) + [done 2000/06/24 GPW] DOCS ---- *************** *** 45,49 **** * review Rene Liebscher's cygwinccompiler.py contribution ! --- 45,50 ---- * review Rene Liebscher's cygwinccompiler.py contribution ! [started and aborted, 2000/06/24 GPW; asked Rene to resubmit patch ! with stylistic changes] *************** *** 69,78 **** --- 70,82 ---- Autoconf-style 'try_cpp', 'search_cpp', 'search_headers' in config commands) + [done, but only UnixCCompiler implements that interface] * fix UnixCCompiler so it doesn't depend on sysconfig (ie. cc must be passed in) + [done 2000/06/24 GPW] * allow user to supply cc (compiler executable) in addition to compiler type + [done 2000/06/24 GPW] * radically simplify CCompiler method signatures: drop most of the *************** *** 82,85 **** --- 86,93 ---- support until this is done, *if* that is it is the right thing to do...] + [update 2000/06/24: I'm cooling to this idea; it turns out the + extra complex interface that's been there all along is useful + for the "config" command, which has to do lots of little + temporary compile and link steps] * Cygwin/Mingw32 support *************** *** 96,100 **** hacking up the example mxDateTime setup script to take advantage of them ! EXTENSION BUILDING --- 104,109 ---- hacking up the example mxDateTime setup script to take advantage of them ! [partly done: at least enough is there to auto-configure mxDateTime; ! need to work on PIL's auto-configuration next] EXTENSION BUILDING *************** *** 102,105 **** --- 111,116 ---- * extension building on AIX + [update 2000/06/24: Rene Liebscher has a patch for this, which + I have asked him to refine] * support for SWIG -- should just have to specify the .i file and *************** *** 108,111 **** --- 119,125 ---- in source distributions, so builders-from-source don't need to have SWIG installed) + [update 2000/06/24: Thomas Heller and I have gone back and forth + on this a couple times: sounds like Thomas has the right idea, + I'll let him work on it] * support for PyFort (lower priority than SWIG!) *************** *** 143,146 **** --- 157,161 ---- * figure out why bdist_rpm doesn't work with RPM 2.x, and make it work if possible + [punt: I don't care anymore, if anyone else does, let them fix it] * make "bdist" take multiple formats (both for convenience From python-dev@python.org Sun Jun 25 03:44:14 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 19:44:14 -0700 Subject: [Python-checkins] CVS: distutils/examples mxdatetime_setup.py,1.4,1.5 Message-ID: <200006250244.TAA16438@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/examples In directory slayer.i.sourceforge.net:/tmp/cvs-serv16430 Modified Files: mxdatetime_setup.py Log Message: Added the config_mxDateTime class to do auto-configuration. Currently works, but has no effect: determines which functions are available, but there's no way to communicate that to the extension-building machinery. Index: mxdatetime_setup.py =================================================================== RCS file: /cvsroot/python/distutils/examples/mxdatetime_setup.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** mxdatetime_setup.py 2000/03/02 01:49:46 1.4 --- mxdatetime_setup.py 2000/06/25 02:44:11 1.5 *************** *** 8,13 **** --- 8,44 ---- __revision__ = "$Id$" + import string from distutils.core import setup + from distutils.command.config import config + class config_mxDateTime (config): + + def run (self): + have = {} + have['strftime'] = self.check_func('strftime', ['time.h']) + have['strptime'] = self.check_func('strptime', ['time.h']) + have['timegm'] = self.check_func('timegm', ['time.h']) + + define = [] + undef = [] + for name in have.keys(): # ('strftime', 'strptime', 'timegm'): + macro_name = 'HAVE_' + string.upper(name) + if have[name]: + define.append((macro_name, None)) + else: + undef.append(macro_name) + + print "macros to define:", define + print "macros to undefine:", undef + + build = self.distribution.reinitialize_command('build') + build.define = define + build.undef = undef + + # run () + + # class config_mxDateTime + + setup (name = "mxDateTime", version = "1.3.0", *************** *** 17,20 **** --- 48,52 ---- url = "http://starship.python.net/~lemburg/mxDateTime.html", + cmdclass = {'config': config_mxDateTime}, packages = ['DateTime', 'DateTime.Examples', 'DateTime.mxDateTime'], package_dir = {'DateTime': ''}, *************** *** 25,31 **** { 'sources': ['mxDateTime/mxDateTime.c'], 'include_dirs': ['mxDateTime'], ! 'macros': [('HAVE_STRFTIME', None), ! ('HAVE_STRPTIME', None), ! ('HAVE_TIMEGM', None)], } )] ) --- 57,61 ---- { 'sources': ['mxDateTime/mxDateTime.c'], 'include_dirs': ['mxDateTime'], ! } )] ) From python-dev@python.org Sun Jun 25 03:45:31 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 19:45:31 -0700 Subject: [Python-checkins] CVS: distutils/examples mxdatetime_setup.py,1.5,1.6 Message-ID: <200006250245.TAA16567@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/examples In directory slayer.i.sourceforge.net:/tmp/cvs-serv16559 Modified Files: mxdatetime_setup.py Log Message: Define the mxDateTime extension using the Extension class, instead of the old-style list-of-tuples-of-etc. hairy mess. Index: mxdatetime_setup.py =================================================================== RCS file: /cvsroot/python/distutils/examples/mxdatetime_setup.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** mxdatetime_setup.py 2000/06/25 02:44:11 1.5 --- mxdatetime_setup.py 2000/06/25 02:45:29 1.6 *************** *** 54,61 **** # XXX user might have to edit the macro definitions here: yuck! # Probably do need to support 'Setup' file or something similar. ! ext_modules = [('DateTime.mxDateTime.mxDateTime', ! { 'sources': ['mxDateTime/mxDateTime.c'], ! 'include_dirs': ['mxDateTime'], ! } ! )] ) --- 54,60 ---- # XXX user might have to edit the macro definitions here: yuck! # Probably do need to support 'Setup' file or something similar. ! ext_modules = [Extension('DateTime.mxDateTime.mxDateTime', ! ['mxDateTime/mxDateTime.c'], ! include_dirs=['mxDateTime']), ! ] ) From python-dev@python.org Sun Jun 25 03:48:10 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 19:48:10 -0700 Subject: [Python-checkins] CVS: distutils/examples mxdatetime_setup.py,1.6,1.7 Message-ID: <200006250248.TAA16615@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/examples In directory slayer.i.sourceforge.net:/tmp/cvs-serv16605 Modified Files: mxdatetime_setup.py Log Message: Delete obsolete comment. Index: mxdatetime_setup.py =================================================================== RCS file: /cvsroot/python/distutils/examples/mxdatetime_setup.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** mxdatetime_setup.py 2000/06/25 02:45:29 1.6 --- mxdatetime_setup.py 2000/06/25 02:48:08 1.7 *************** *** 52,57 **** package_dir = {'DateTime': ''}, - # XXX user might have to edit the macro definitions here: yuck! - # Probably do need to support 'Setup' file or something similar. ext_modules = [Extension('DateTime.mxDateTime.mxDateTime', ['mxDateTime/mxDateTime.c'], --- 52,55 ---- From python-dev@python.org Sun Jun 25 04:14:16 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 20:14:16 -0700 Subject: [Python-checkins] CVS: distutils/doc/dist dist.tex,1.16,1.17 Message-ID: <200006250314.UAA23529@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/doc/dist In directory slayer.i.sourceforge.net:/tmp/cvs-serv23518 Modified Files: dist.tex Log Message: Minor wording tweaks. Kludged the extra-wide table that summarizes the manifest template language (works with LaTeX, but is an *evil* kludge and could well break LaTeX2HTML or similar...). Index: dist.tex =================================================================== RCS file: /cvsroot/python/distutils/doc/dist/dist.tex,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** dist.tex 2000/06/24 01:45:47 1.16 --- dist.tex 2000/06/25 03:14:13 1.17 *************** *** 169,173 **** file, e.g. a shared object (\file{.so}) file for CPython extensions on Unix, a DLL (given the \file{.pyd} extension) for CPython extensions ! on Windows, or a Java class file for JPython extensions. \item[package] a module that contains other modules; typically contained in a directory in the filesystem and distinguished from other --- 169,174 ---- file, e.g. a shared object (\file{.so}) file for CPython extensions on Unix, a DLL (given the \file{.pyd} extension) for CPython extensions ! on Windows, or a Java class file for JPython extensions. (Note that ! currently, the Distutils only handles C/C++ extensions for CPython.) \item[package] a module that contains other modules; typically contained in a directory in the filesystem and distinguished from other *************** *** 218,223 **** do the right thing. As we saw in section~\ref{simple-example} above, the setup script consists mainly of a call to \function{setup()}, and ! all information supplied to the Distutils is supplied as keyword ! arguments to \function{setup()}. Here's a slightly more involved example, which we'll follow for the next --- 219,224 ---- do the right thing. As we saw in section~\ref{simple-example} above, the setup script consists mainly of a call to \function{setup()}, and ! most information supplied to the Distutils by the module developer is ! supplied as keyword arguments to \function{setup()}. Here's a slightly more involved example, which we'll follow for the next *************** *** 719,726 **** {exclude all files under \var{dir} matching any of the listed patterns} \lineii{global-include \var{pat1} \var{pat2} ...} ! {include all files anywhere in the source tree matching any of the listed patterns} \lineii{global-exclude \var{pat1} \var{pat2} ...} ! {exclude all files anywhere in the source tree matching any of the listed patterns} \lineii{prune \var{dir}}{exclude all files under \var{dir}} --- 720,727 ---- {exclude all files under \var{dir} matching any of the listed patterns} \lineii{global-include \var{pat1} \var{pat2} ...} ! {include all files anywhere in the source tree matching\\& any of the listed patterns} \lineii{global-exclude \var{pat1} \var{pat2} ...} ! {exclude all files anywhere in the source tree matching\\& any of the listed patterns} \lineii{prune \var{dir}}{exclude all files under \var{dir}} From python-dev@python.org Sun Jun 25 11:45:00 2000 From: python-dev@python.org (Jeremy Hylton) Date: Sun, 25 Jun 2000 03:45:00 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_exceptions,1.2,1.3 Message-ID: <200006251045.DAA29933@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv29818/output Modified Files: test_exceptions Log Message: update output file to reflect new test of exception object str-ness Index: test_exceptions =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_exceptions,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** test_exceptions 2000/05/25 23:16:54 1.2 --- test_exceptions 2000/06/25 10:44:57 1.3 *************** *** 1,24 **** --- 1,42 ---- test_exceptions 5. Built-in exceptions + spam AttributeError + spam EOFError + spam IOError + spam ImportError + spam IndexError + spam KeyError + spam KeyboardInterrupt (not testable in a script) + spam MemoryError (not safe to test) + spam NameError + spam OverflowError + spam RuntimeError (not used any more?) + spam SyntaxError + spam SystemError (hard to reproduce) + spam SystemExit + spam TypeError + spam ValueError + spam ZeroDivisionError + spam Exception From python-dev@python.org Sun Jun 25 18:49:44 2000 From: python-dev@python.org (Yisroel Gordon) Date: Sun, 25 Jun 2000 13:49:44 EDT Subject: [Python-checkins] (no subject) Message-ID: <20000625174944.21797.qmail@hotmail.com> Please unsubscribe me from this mailing list Thank You ________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com From python-dev@python.org Mon Jun 26 09:28:04 2000 From: python-dev@python.org (Greg Stein) Date: Mon, 26 Jun 2000 01:28:04 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib httplib.py,1.16,1.17 Message-ID: <200006260828.BAA13864@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv13852 Modified Files: httplib.py Log Message: initial commit of a new HTTP library, supporting HTTP/1.1 and persistent connections. Index: httplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/httplib.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** httplib.py 2000/05/19 23:06:45 1.16 --- httplib.py 2000/06/26 08:28:01 1.17 *************** *** 1,34 **** ! """HTTP client class ! ! See the following URL for a description of the HTTP/1.0 protocol: ! http://www.w3.org/hypertext/WWW/Protocols/ ! (I actually implemented it from a much earlier draft.) ! ! Example: ! ! >>> from httplib import HTTP ! >>> h = HTTP('www.python.org') [...1008 lines suppressed...] --- 759,777 ---- print print h.getfile().read() ! ! if hasattr(socket, 'ssl'): ! host = 'www.c2.net' ! hs = HTTPS() ! hs.connect(host) ! hs.putrequest('GET', selector) ! hs.endheaders() ! status, reason, headers = hs.getreply() ! print 'status =', status ! print 'reason =', reason ! print ! if headers: ! for header in headers.headers: print string.strip(header) ! print ! print hs.getfile().read() From python-dev@python.org Mon Jun 26 15:37:56 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 26 Jun 2000 07:37:56 -0700 Subject: [Python-checkins] CVS: python/dist/src/Include pythonrun.h,2.27,2.28 Message-ID: <200006261437.HAA22462@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Include In directory slayer.i.sourceforge.net:/tmp/cvs-serv22452 Modified Files: pythonrun.h Log Message: Fredrik Lundh: get rid of warning in pythonrun.c Index: pythonrun.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pythonrun.h,v retrieving revision 2.27 retrieving revision 2.28 diff -C2 -r2.27 -r2.28 *** pythonrun.h 2000/05/25 23:05:36 2.27 --- pythonrun.h 2000/06/26 14:37:53 2.28 *************** *** 95,98 **** --- 95,99 ---- /* Various internal finalizers */ DL_IMPORT(void) fini_exceptions Py_PROTO((void)); + DL_IMPORT(void) _PyImport_Fini Py_PROTO((void)); DL_IMPORT(void) PyMethod_Fini Py_PROTO((void)); DL_IMPORT(void) PyFrame_Fini Py_PROTO((void)); From python-dev@python.org Mon Jun 26 18:31:51 2000 From: python-dev@python.org (Greg Stein) Date: Mon, 26 Jun 2000 10:31:51 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib imputil.py,1.12,1.13 Message-ID: <200006261731.KAA20302@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv20271 Modified Files: imputil.py Log Message: now that imputil is in the main Python repository, clean up the header Index: imputil.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/imputil.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** imputil.py 2000/02/19 13:36:23 1.12 --- imputil.py 2000/06/26 17:31:49 1.13 *************** *** 1,20 **** # ! # imputil.py # ! # Written by Greg Stein. Public Domain. ! # No Copyright, no Rights Reserved, and no Warranties. ! # ! # Utilities to help out with custom import mechanisms. ! # ! # Additional modifications were contribed by Marc-Andre Lemburg and ! # Gordon McMillan. ! # ! # This module is maintained by Greg and is available at: ! # http://www.lyra.org/greg/python/ ! # ! # Since this isn't in the Python distribution yet, we'll use the CVS ID ! # for tracking: ! # $Id$ ! # # note: avoid importing non-builtin modules --- 1,7 ---- # ! # imputil.py: import utilities # ! ! ### docco needed here and in Docs/ ... # note: avoid importing non-builtin modules From python-dev@python.org Tue Jun 27 01:37:27 2000 From: python-dev@python.org (A.M. Kuchling) Date: Mon, 26 Jun 2000 17:37:27 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_pyexpat.py,1.2,1.3 Message-ID: <200006270037.RAA25539@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv25501 Modified Files: test_pyexpat.py Log Message: Change pyexpat test suite to exercise the .returns_unicode attribute, parsing the sample data once with 8-bit strings and once with Unicode. Index: test_pyexpat.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pyexpat.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** test_pyexpat.py 2000/04/02 05:15:38 1.2 --- test_pyexpat.py 2000/06/27 00:37:25 1.3 *************** *** 11,18 **** class Outputter: def StartElementHandler(self, name, attrs): ! print 'Start element:\n\t', name, attrs def EndElementHandler(self, name): ! print 'End element:\n\t', name def CharacterDataHandler(self, data): --- 11,18 ---- class Outputter: def StartElementHandler(self, name, attrs): ! print 'Start element:\n\t', repr(name), attrs def EndElementHandler(self, name): ! print 'End element:\n\t', repr(name) def CharacterDataHandler(self, data): *************** *** 23,33 **** def ProcessingInstructionHandler(self, target, data): ! print 'PI:\n\t', target, data def StartNamespaceDeclHandler(self, prefix, uri): ! print 'NS decl:\n\t', prefix, uri def EndNamespaceDeclHandler(self, prefix): ! print 'End of NS decl:\n\t', prefix def StartCdataSectionHandler(self): --- 23,33 ---- def ProcessingInstructionHandler(self, target, data): ! print 'PI:\n\t', repr(target), repr(data) def StartNamespaceDeclHandler(self, prefix, uri): ! print 'NS decl:\n\t', repr(prefix), repr(uri) def EndNamespaceDeclHandler(self, prefix): ! print 'End of NS decl:\n\t', repr(prefix) def StartCdataSectionHandler(self): *************** *** 52,57 **** return 1 ! def ExternalEntityRefHandler(self, context, base, sysId, pubId): ! print 'External entity ref:', context, base, sysId, pubId return 1 --- 52,58 ---- return 1 ! def ExternalEntityRefHandler(self, *args): ! context, base, sysId, pubId = args ! print 'External entity ref:', args return 1 *************** *** 65,69 **** out = Outputter() parser = pyexpat.ParserCreate(namespace_separator='!') ! for name in ['StartElementHandler', 'EndElementHandler', 'CharacterDataHandler', 'ProcessingInstructionHandler', 'UnparsedEntityDeclHandler', 'NotationDeclHandler', --- 66,77 ---- out = Outputter() parser = pyexpat.ParserCreate(namespace_separator='!') ! ! # Test getting/setting returns_unicode ! parser.returns_unicode = 0 ; assert parser.returns_unicode == 0 ! parser.returns_unicode = 1 ; assert parser.returns_unicode == 1 ! parser.returns_unicode = 2 ; assert parser.returns_unicode == 1 ! parser.returns_unicode = 0 ; assert parser.returns_unicode == 0 ! ! HANDLER_NAMES = ['StartElementHandler', 'EndElementHandler', 'CharacterDataHandler', 'ProcessingInstructionHandler', 'UnparsedEntityDeclHandler', 'NotationDeclHandler', *************** *** 74,78 **** #'NotStandaloneHandler', 'ExternalEntityRefHandler' ! ]: setattr(parser, name, getattr(out, name) ) --- 82,87 ---- #'NotStandaloneHandler', 'ExternalEntityRefHandler' ! ] ! for name in HANDLER_NAMES: setattr(parser, name, getattr(out, name) ) *************** *** 89,93 **** ]> ! Contents of subelements --- 98,102 ---- ]> ! Contents of subelements *************** *** 98,103 **** --- 107,144 ---- """ + # Produce UTF-8 output + parser.returns_unicode = 0 try: parser.Parse(data, 1) + except pyexpat.error: + print '** Error', parser.ErrorCode, pyexpat.ErrorString( parser.ErrorCode) + print '** Line', parser.ErrorLineNumber + print '** Column', parser.ErrorColumnNumber + print '** Byte', parser.ErrorByteIndex + + # Try the parse again, this time producing Unicode output + parser = pyexpat.ParserCreate(namespace_separator='!') + parser.returns_unicode = 1 + + for name in HANDLER_NAMES: + setattr(parser, name, getattr(out, name) ) + try: + parser.Parse(data, 1) + except pyexpat.error: + print '** Error', parser.ErrorCode, pyexpat.ErrorString( parser.ErrorCode) + print '** Line', parser.ErrorLineNumber + print '** Column', parser.ErrorColumnNumber + print '** Byte', parser.ErrorByteIndex + + # Try parsing a file + parser = pyexpat.ParserCreate(namespace_separator='!') + parser.returns_unicode = 1 + + for name in HANDLER_NAMES: + setattr(parser, name, getattr(out, name) ) + import StringIO + file = StringIO.StringIO(data) + try: + parser.ParseFile(file) except pyexpat.error: print '** Error', parser.ErrorCode, pyexpat.ErrorString( parser.ErrorCode) From python-dev@python.org Tue Jun 27 01:53:14 2000 From: python-dev@python.org (A.M. Kuchling) Date: Mon, 26 Jun 2000 17:53:14 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/curses textpad.py,1.1,1.2 Message-ID: <200006270053.RAA26341@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/curses In directory slayer.i.sourceforge.net:/tmp/cvs-serv26276 Modified Files: textpad.py Log Message: Sync to ESR's current version Index: textpad.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/curses/textpad.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** textpad.py 2000/06/26 23:55:42 1.1 --- textpad.py 2000/06/27 00:53:12 1.2 *************** *** 16,20 **** win.addch(lry, ulx, curses.ACS_LLCORNER) ! class textbox: """Editing widget using the interior of a window object. Supports the following Emacs-like key bindings: --- 16,20 ---- win.addch(lry, ulx, curses.ACS_LLCORNER) ! class Textbox: """Editing widget using the interior of a window object. Supports the following Emacs-like key bindings: *************** *** 26,29 **** --- 26,30 ---- Ctrl-F Cursor right, wrapping to next line when appropriate. Ctrl-G Terminate, returning the window contents. + Ctrl-H Delete character backward. Ctrl-J Terminate if the window is 1 line, otherwise insert newline. Ctrl-K If line is blank, delete it, otherwise clear to end of line. *************** *** 37,40 **** --- 38,42 ---- KEY_LEFT = Ctrl-B, KEY_RIGHT = Ctrl-F, KEY_UP = Ctrl-P, KEY_DOWN = Ctrl-N + KEY_BACKSPACE = Ctrl-h """ def __init__(self, win): *************** *** 44,62 **** self.maxx = self.maxx - 1 self.stripspaces = 1 win.keypad(1) def firstblank(self, y): "Go to the location of the first blank on the given line." ! (oldy, oldx) = self.win.getyx() ! self.win.move(y, self.maxx-1) ! last = self.maxx-1 while 1: - if last == 0: - break if ascii.ascii(self.win.inch(y, last)) != ascii.SP: last = last + 1 break last = last - 1 - self.win.move(oldy, oldx) return last --- 46,62 ---- self.maxx = self.maxx - 1 self.stripspaces = 1 + self.lastcmd = None win.keypad(1) def firstblank(self, y): "Go to the location of the first blank on the given line." ! last = self.maxx while 1: if ascii.ascii(self.win.inch(y, last)) != ascii.SP: last = last + 1 break + elif last == 0: + break last = last - 1 return last *************** *** 64,67 **** --- 64,68 ---- "Process a single editing command." (y, x) = self.win.getyx() + self.lastcmd = ch if ascii.isprint(ch): if y < self.maxy or x < self.maxx: *************** *** 73,79 **** except ERR: pass ! elif ch == ascii.SOH: # Ctrl-a self.win.move(y, 0) ! elif ch in (ascii.STX, curses.KEY_LEFT): # Ctrl-b if x > 0: self.win.move(y, x-1) --- 74,80 ---- except ERR: pass ! elif ch == ascii.SOH: # ^a self.win.move(y, 0) ! elif ch in (ascii.STX,curses.KEY_LEFT, ascii.BS,curses.KEY_BACKSPACE): if x > 0: self.win.move(y, x-1) *************** *** 84,124 **** else: self.win.move(y-1, self.maxx) ! elif ch == ascii.EOT: # Ctrl-d self.win.delch() ! elif ch == ascii.ENQ: # Ctrl-e if self.stripspaces: self.win.move(y, self.firstblank(y, maxx)) else: self.win.move(y, self.maxx) ! elif ch in (ascii.ACK, curses.KEY_RIGHT): # Ctrl-f if x < self.maxx: self.win.move(y, x+1) ! elif y == self.maxx: pass else: self.win.move(y+1, 0) ! elif ch == ascii.BEL: # Ctrl-g return 0 ! elif ch == ascii.NL: # Ctrl-j if self.maxy == 0: return 0 elif y < self.maxy: self.win.move(y+1, 0) ! elif ch == ascii.VT: # Ctrl-k if x == 0 and self.firstblank(y) == 0: self.win.deleteln() else: self.win.clrtoeol() ! elif ch == ascii.FF: # Ctrl-l self.win.refresh() ! elif ch in (ascii.SO, curses.KEY_DOWN): # Ctrl-n if y < self.maxy: self.win.move(y+1, x) ! elif ch == ascii.SI: # Ctrl-o self.win.insertln() ! elif ch in (ascii.DLE, curses.KEY_UP): # Ctrl-p if y > 0: self.win.move(y-1, x) - self.win.refresh() return 1 --- 85,126 ---- else: self.win.move(y-1, self.maxx) ! if ch in (ascii.BS, curses.KEY_BACKSPACE): ! self.win.delch() ! elif ch == ascii.EOT: # ^d self.win.delch() ! elif ch == ascii.ENQ: # ^e if self.stripspaces: self.win.move(y, self.firstblank(y, maxx)) else: self.win.move(y, self.maxx) ! elif ch in (ascii.ACK, curses.KEY_RIGHT): # ^f if x < self.maxx: self.win.move(y, x+1) ! elif y == self.maxy: pass else: self.win.move(y+1, 0) ! elif ch == ascii.BEL: # ^g return 0 ! elif ch == ascii.NL: # ^j if self.maxy == 0: return 0 elif y < self.maxy: self.win.move(y+1, 0) ! elif ch == ascii.VT: # ^k if x == 0 and self.firstblank(y) == 0: self.win.deleteln() else: self.win.clrtoeol() ! elif ch == ascii.FF: # ^l self.win.refresh() ! elif ch in (ascii.SO, curses.KEY_DOWN): # ^n if y < self.maxy: self.win.move(y+1, x) ! elif ch == ascii.SI: # ^o self.win.insertln() ! elif ch in (ascii.DLE, curses.KEY_UP): # ^p if y > 0: self.win.move(y-1, x) return 1 *************** *** 129,132 **** --- 131,135 ---- self.win.move(y, 0) stop = self.firstblank(y) + #sys.stderr.write("y=%d, firstblank(y)=%d\n" % (y, stop)) if stop == 0 and self.stripspaces: continue *************** *** 145,150 **** --- 148,156 ---- if validate: ch = validate(ch) + if not ch: + continue if not self.do_command(ch): break + self.win.refresh() return self.gather() *************** *** 154,158 **** rectangle(stdscr, 14, 19, 19, 29) stdscr.refresh() ! return textbox(win).edit() str = curses.wrapper(test_editbox) --- 160,164 ---- rectangle(stdscr, 14, 19, 19, 29) stdscr.refresh() ! return Textbox(win).edit() str = curses.wrapper(test_editbox) From python-dev@python.org Tue Jun 27 03:11:05 2000 From: python-dev@python.org (Greg Ward) Date: Mon, 26 Jun 2000 19:11:05 -0700 Subject: [Python-checkins] CVS: distutils/examples pil_setup.py,1.11,1.12 Message-ID: <200006270211.TAA09901@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/examples In directory slayer.i.sourceforge.net:/tmp/cvs-serv9891 Modified Files: pil_setup.py Log Message: Added a config command to determine if Tcl/Tk, libjpeg, and/or zlib are present. Doesn't actually do anything with that knowledge, since the base config command doesn't have any infrastructure for doing that. Still, it's a start. Index: pil_setup.py =================================================================== RCS file: /cvsroot/python/distutils/examples/pil_setup.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** pil_setup.py 2000/03/31 04:47:05 1.11 --- pil_setup.py 2000/06/27 02:11:03 1.12 *************** *** 11,14 **** --- 11,15 ---- from distutils.core import setup from distutils.ccompiler import new_compiler + from distutils.command.config import config from glob import glob *************** *** 57,60 **** --- 58,109 ---- + class config_Imaging (config): + + user_options = config.user_options + [ + ('tcltk-include-dirs=', None, + "directories to search for Tcl/Tk header files"), + ('tcltk-library-dirs=', None, + "directories to search for Tcl/Tk library files"), + ('tcl-version', None, + "version of Tcl library to look for"), + ('tk-version', None, + "version of Tk library to look for"), + ('zlib-include-dirs=', None, + "directories to search for zlib header file"), + ('zlib-library-dirs=', None, + "directories to search for zlib library file"), + ] + + def initialize_options (self): + config.initialize_options(self) + self.tcltk_include_dirs = None + self.tcltk_library_dirs = None + self.tcl_version = None + self.tk_version = None + + self.zlib_include_dirs = None + self.zlib_library_dirs = None + + # No 'finalize_options()' method -- none of our options have default + # values (other than None, that is). + + def run (self): + + have_tcl = self.check_lib("tcl" + (self.tcl_version or ""), + self.tcltk_library_dirs, + ["tcl.h"], self.tcltk_include_dirs) + + have_tk = self.check_lib("tk" + (self.tk_version or ""), + self.tcltk_library_dirs, + ["tk.h"], self.tcltk_include_dirs) + + have_zlib = self.check_lib("z", self.zlib_library_dirs, + ["zlib.h"], self.zlib_include_dirs) + + + print "have tcl? %d have tk? %d have zlib? %d" % \ + (have_tcl, have_tk, have_zlib) + + # ------------------------------------------------------------------------ # You should't have to change anything below this point! *************** *** 94,97 **** --- 143,148 ---- # top-level module in the distribution), but Distutils as yet has no # facilities for installing scripts. + + cmdclass = {'config': config_Imaging}, libraries = [(lib_name, From python-dev@python.org Tue Jun 27 00:54:05 2000 From: python-dev@python.org (A.M. Kuchling) Date: Mon, 26 Jun 2000 16:54:05 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/curses __init__.py,1.1,1.2 Message-ID: <200006262354.QAA17041@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/curses In directory slayer.i.sourceforge.net:/tmp/cvs-serv16914 Modified Files: __init__.py Log Message: Add wrapper for initscr() to copy the ACS_ and LINES,COLS bindings Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/curses/__init__.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** __init__.py 2000/06/10 23:06:53 1.1 --- __init__.py 2000/06/26 23:54:03 1.2 *************** *** 16,18 **** --- 16,34 ---- from curses.wrapper import wrapper + # Some constants, most notably the ACS_* ones, are only added to the C + # _curses module's dictionary after initscr() is called. (Some + # versions of SGI's curses don't define values for those constants + # until initscr() has been called.) This wrapper function calls the + # underlying C initscr(), and then copies the constants from the + # _curses module to the curses package's dictionary. Don't do 'from + # curses import *' if you'll be needing the ACS_* constants. + + def initscr(): + import _curses, curses + stdscr = _curses.initscr() + for key, value in _curses.__dict__.items(): + if key[0:4] == 'ACS_' or key in ('LINES', 'COLS'): + setattr(curses, key, value) + + return stdscr From python-dev@python.org Tue Jun 27 00:55:44 2000 From: python-dev@python.org (A.M. Kuchling) Date: Mon, 26 Jun 2000 16:55:44 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/curses ascii.py,NONE,1.1 textpad.py,NONE,1.1 Message-ID: <200006262355.QAA17089@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/curses In directory slayer.i.sourceforge.net:/tmp/cvs-serv17079 Added Files: ascii.py textpad.py Log Message: Added two modules for ASCII characters and a simple editing form (ESR) --- NEW FILE --- # # ascii.py -- constants and memembership tests for ASCII characters # NUL = 0x00 # ^@ SOH = 0x01 # ^A STX = 0x02 # ^B ETX = 0x03 # ^C EOT = 0x04 # ^D ENQ = 0x05 # ^E ACK = 0x06 # ^F BEL = 0x07 # ^G BS = 0x08 # ^H TAB = 0x09 # ^I HT = 0x09 # ^I LF = 0x0a # ^J NL = 0x0a # ^J VT = 0x0b # ^K FF = 0x0c # ^L CR = 0x0d # ^M SO = 0x0e # ^N SI = 0x0f # ^O DLE = 0x10 # ^P DC1 = 0x11 # ^Q DC2 = 0x12 # ^R DC3 = 0x13 # ^S DC4 = 0x14 # ^T NAK = 0x15 # ^U SYN = 0x16 # ^V ETB = 0x17 # ^W CAN = 0x18 # ^X EM = 0x19 # ^Y SUB = 0x1a # ^Z ESC = 0x1b # ^[ FS = 0x1c # ^\ GS = 0x1d # ^] RS = 0x1e # ^^ US = 0x1f # ^_ SP = 0x20 # space DEL = 0x7f # delete controlnames = [ "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", "BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI", "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US", "SP" ] def _ctoi(c): if type(c) == type(""): return ord(c) else: return c def isalnum(c): return isalpha(c) or isdigit(c) def isalpha(c): return isupper(c) or islower(c) def isascii(c): return _ctoi(c) <= 127 # ? def isblank(c): return _ctoi(c) in (8,32) def iscntrl(c): return _ctoi(c) <= 31 def isdigit(c): return _ctoi(c) >= 48 and _ctoi(c) <= 57 def isgraph(c): return _ctoi(c) >= 33 and _ctoi(c) <= 126 def islower(c): return _ctoi(c) >= 97 and _ctoi(c) <= 122 def isprint(c): return _ctoi(c) >= 32 and _ctoi(c) <= 126 def ispunct(c): return _ctoi(c) != 32 and not isalnum(c) def isspace(c): return _ctoi(c) in (12, 10, 13, 9, 11) def isupper(c): return _ctoi(c) >= 65 and _ctoi(c) <= 90 def isxdigit(c): return isdigit(c) or \ (_ctoi(c) >= 65 and _ctoi(c) <= 70) or (_ctoi(c) >= 97 and _ctoi(c) <= 102) def isctrl(c): return _ctoi(c) < 32 def ismeta(c): return _ctoi(c) > 127 def ascii(c): if type(c) == type(""): return chr(_ctoi(c) & 0x7f) else: return _ctoi(c) & 0x7f def ctrl(c): if type(c) == type(""): return chr(_ctoi(c) & 0x1f) else: return _ctoi(c) & 0x1f def alt(c): if type(c) == type(""): return chr(_ctoi(c) | 0x80) else: return _ctoi(c) | 0x80 def unctrl(c): bits = _ctoi(c) if bits == 0x7f: rep = "^?" elif bits & 0x20: rep = chr((bits & 0x7f) | 0x20) else: rep = "^" + chr(((bits & 0x7f) | 0x20) + 0x20) if bits & 0x80: return "!" + rep return rep --- NEW FILE --- """curses.textpad """ import sys, curses, ascii def rectangle(win, uly, ulx, lry, lrx): "Draw a rectangle." win.vline(uly+1, ulx, curses.ACS_VLINE, lry - uly - 1) win.hline(uly, ulx+1, curses.ACS_HLINE, lrx - ulx - 1) win.hline(lry, ulx+1, curses.ACS_HLINE, lrx - ulx - 1) win.vline(uly+1, lrx, curses.ACS_VLINE, lry - uly - 1) win.addch(uly, ulx, curses.ACS_ULCORNER) win.addch(uly, lrx, curses.ACS_URCORNER) win.addch(lry, lrx, curses.ACS_LRCORNER) win.addch(lry, ulx, curses.ACS_LLCORNER) class textbox: """Editing widget using the interior of a window object. Supports the following Emacs-like key bindings: Ctrl-A Go to left edge of window. Ctrl-B Cursor left, wrapping to previous line if appropriate. Ctrl-D Delete character under cursor. Ctrl-E Go to right edge (nospaces off) or end of line (nospaces on). Ctrl-F Cursor right, wrapping to next line when appropriate. Ctrl-G Terminate, returning the window contents. Ctrl-J Terminate if the window is 1 line, otherwise insert newline. Ctrl-K If line is blank, delete it, otherwise clear to end of line. Ctrl-L Refresh screen Ctrl-N Cursor down; move down one line. Ctrl-O Insert a blank line at cursor location. Ctrl-P Cursor up; move up one line. Move operations do nothing if the cursor is at an edge where the movement is not possible. The following synonyms are supported where possible: KEY_LEFT = Ctrl-B, KEY_RIGHT = Ctrl-F, KEY_UP = Ctrl-P, KEY_DOWN = Ctrl-N """ def __init__(self, win): self.win = win (self.maxy, self.maxx) = win.getmaxyx() self.maxy = self.maxy - 1 self.maxx = self.maxx - 1 self.stripspaces = 1 win.keypad(1) def firstblank(self, y): "Go to the location of the first blank on the given line." (oldy, oldx) = self.win.getyx() self.win.move(y, self.maxx-1) last = self.maxx-1 while 1: if last == 0: break if ascii.ascii(self.win.inch(y, last)) != ascii.SP: last = last + 1 break last = last - 1 self.win.move(oldy, oldx) return last def do_command(self, ch): "Process a single editing command." (y, x) = self.win.getyx() if ascii.isprint(ch): if y < self.maxy or x < self.maxx: # The try-catch ignores the error we trigger from some curses # versions by trying to write into the lowest-rightmost spot # in the self.window. try: self.win.addch(ch) except ERR: pass elif ch == ascii.SOH: # Ctrl-a self.win.move(y, 0) elif ch in (ascii.STX, curses.KEY_LEFT): # Ctrl-b if x > 0: self.win.move(y, x-1) elif y == 0: pass elif self.stripspaces: self.win.move(y-1, self.firstblank(y-1)) else: self.win.move(y-1, self.maxx) elif ch == ascii.EOT: # Ctrl-d self.win.delch() elif ch == ascii.ENQ: # Ctrl-e if self.stripspaces: self.win.move(y, self.firstblank(y, maxx)) else: self.win.move(y, self.maxx) elif ch in (ascii.ACK, curses.KEY_RIGHT): # Ctrl-f if x < self.maxx: self.win.move(y, x+1) elif y == self.maxx: pass else: self.win.move(y+1, 0) elif ch == ascii.BEL: # Ctrl-g return 0 elif ch == ascii.NL: # Ctrl-j if self.maxy == 0: return 0 elif y < self.maxy: self.win.move(y+1, 0) elif ch == ascii.VT: # Ctrl-k if x == 0 and self.firstblank(y) == 0: self.win.deleteln() else: self.win.clrtoeol() elif ch == ascii.FF: # Ctrl-l self.win.refresh() elif ch in (ascii.SO, curses.KEY_DOWN): # Ctrl-n if y < self.maxy: self.win.move(y+1, x) elif ch == ascii.SI: # Ctrl-o self.win.insertln() elif ch in (ascii.DLE, curses.KEY_UP): # Ctrl-p if y > 0: self.win.move(y-1, x) self.win.refresh() return 1 def gather(self): "Collect and return the contents of the window." result = "" for y in range(self.maxy+1): self.win.move(y, 0) stop = self.firstblank(y) if stop == 0 and self.stripspaces: continue for x in range(self.maxx+1): if self.stripspaces and x == stop: break result = result + chr(ascii.ascii(self.win.inch(y, x))) if self.maxy > 0: result = result + "\n" return result def edit(self, validate=None): "Edit in the widget window and collect the results." while 1: ch = self.win.getch() if validate: ch = validate(ch) if not self.do_command(ch): break return self.gather() if __name__ == '__main__': def test_editbox(stdscr): win = curses.newwin(4, 9, 15, 20) rectangle(stdscr, 14, 19, 19, 29) stdscr.refresh() return textbox(win).edit() str = curses.wrapper(test_editbox) print str From python-dev@python.org Tue Jun 27 00:59:27 2000 From: python-dev@python.org (A.M. Kuchling) Date: Mon, 26 Jun 2000 16:59:27 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libascii.tex,NONE,1.1 Message-ID: <200006262359.QAA17285@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv17139 Added Files: libascii.tex Log Message: Dcoumentation for ascii.py. I've changed two references from ascii to curses.ascii. --- NEW FILE --- \section{\module{curses.ascii} --- Constants and set-membership functions for ASCII characters.} \declaremodule{standard}{curses.ascii} \modulesynopsis{Constants and set-membership functions for ASCII characters.} \moduleauthor{Eric S. Raymond}{esr@thyrsus.com} \sectionauthor{Eric S. Raymond}{esr@thyrsus.com} \versionadded{1.6} The \module{curses.ascii} module supplies name constants for ASCII characters and functions to test membership in various ASCII character classes. The constants supplied are names for control characters as follows: NUL, SOH, STX, ETX, EOT, ENQ, ACK, BEL, BS, TAB, HT, LF, NL, VT, FF, CR, SO, SI, DLE, DC1, DC2, DC3, DC4, NAK, SYN, ETB, CAN, EM, SUB, ESC, FS, GS, RS, US, SP, DEL. NL and LF are synonyms; so are HT and TAB. The module also supplies the following functions, patterned on those in the standard C library: \begin{funcdesc}{isalnum}{c} Checks for an ASCII alphanumeric character; it is equivalent to isalpha(c) or isdigit(c)) \end{funcdesc} \begin{funcdesc}{isalpha}{c} Checks for an ASCII alphabetic character; it is equivalent to isupper(c) or islower(c)) \end{funcdesc} \begin{funcdesc}{isascii}{c} Checks for a character value that fits in the 7-bit ASCII set. \end{funcdesc} \begin{funcdesc}{isblank}{c} Checks for an ASCII alphanumeric character; it is equivalent to isalpha(c) or isdigit(c)) \end{funcdesc} \begin{funcdesc}{iscntrl}{c} Checks for an ASCII control character (range 0x00 to 0x1f). \end{funcdesc} \begin{funcdesc}{isdigit}{c} Checks for an ASCII decimal digit, 0 through 9. \end{funcdesc} \begin{funcdesc}{isgraph}{c} Checks for ASCII any printable character except space. \end{funcdesc} \begin{funcdesc}{islower}{c} Checks for an ASCII lower-case character. \end{funcdesc} \begin{funcdesc}{isprint}{c} Checks for any ASCII printable character including space. \end{funcdesc} \begin{funcdesc}{ispunct}{c} Checks for any printable ASCII character which is not a space or an alphanumeric character. \end{funcdesc} \begin{funcdesc}{isspace}{c} Checks for ASCII white-space characters; space, tab, line feed, carriage return, form feed, horizontal tab, vertical tab. \end{funcdesc} \begin{funcdesc}{isupper}{c} Checks for an ASCII uppercase letter. \end{funcdesc} \begin{funcdesc}{isxdigit}{c} Checks for an ASCII hexadecimal digit, i.e. one of 0123456789abcdefABCDEF. \end{funcdesc} \begin{funcdesc}{isctrl}{c} Checks for an ASCII control character, bit values 0 to 31. \end{funcdesc} \begin{funcdesc}{ismeta}{c} Checks for a (non-ASCII) character, bit values 0x80 and above. \end{funcdesc} These functions accept either integers or strings; when the argument is a string, it is first converted using the built-in function ord(). Note that all these functions check ordinal bit values derived from the first character of the string you pass in; they do not actually know anything about the host machine's character encoding. For functions that know about the character encoding (and handle internationalization properly) see the string module. The following two functions take either a single-character string or integer byte value; they return a value of the same type. \begin{funcdesc}{ascii}{c} Return the ASCII value corresponding to the low 7 bits of c. \end{funcdesc} \begin{funcdesc}{ctrl}{c} Return the control character corresponding to the given character (the character bit value is logical-anded with 0x1f). \end{funcdesc} \begin{funcdesc}{alt}{c} Return the 8-bit character corresponding to the given ASCII character (the character bit value is logical-ored with 0x80). \end{funcdesc} The following function takes either a single-character string or integer byte value; it returns a string. \begin{funcdesc}{unctrl}{c} Return a string representation of the ASCII character c. If c is printable, this string is the character itself. If the character is a control character (0x00-0x1f) the string consists of a caret (^) followed by the corresponding uppercase letter. If the character is an ASCII delete (0x7f) the string is "^?". If the character has its meta bit (0x80) set, the meta bit is stripped, the preceding rules applied, and "!" prepended to the result. \end{funcdesc} Finally, the module supplies a 33-element string array called controlnames that contains the ASCII mnemonics for the thirty-two ASCII control characters from 0 (NUL) to 0x1f (US), in order, plus the mnemonic "SP" for space. From python-dev@python.org Tue Jun 27 01:33:33 2000 From: python-dev@python.org (A.M. Kuchling) Date: Mon, 26 Jun 2000 17:33:33 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules pyexpat.c,2.4,2.5 Message-ID: <200006270033.RAA25415@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv25294 Modified Files: pyexpat.c Log Message: Added support for passing Unicode strings to Expat handlers by default. This version still includes #ifdef hackery to compile with 1.5.2. Index: pyexpat.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/pyexpat.c,v retrieving revision 2.4 retrieving revision 2.5 diff -C2 -r2.4 -r2.5 *** pyexpat.c 2000/05/03 23:44:33 2.4 --- pyexpat.c 2000/06/27 00:33:30 2.5 *************** *** 39,57 **** enum HandlerTypes{ ! StartElement, ! EndElement, ! ProcessingInstruction, ! CharacterData, ! UnparsedEntityDecl, ! NotationDecl, ! StartNamespaceDecl, ! EndNamespaceDecl, [...1633 lines suppressed...] ! my_StartCdataSectionHandler}, {"EndCdataSectionHandler", ! pyxml_SetEndCdataSection, ! my_EndCdataSectionHandler}, {"DefaultHandler", ! (xmlhandlersetter)XML_SetDefaultHandler, ! my_DefaultHandler}, {"DefaultHandlerExpand", ! (xmlhandlersetter)XML_SetDefaultHandlerExpand, ! my_DefaultHandlerExpandHandler}, {"NotStandaloneHandler", ! (xmlhandlersetter)XML_SetNotStandaloneHandler, ! my_NotStandaloneHandler}, {"ExternalEntityRefHandler", ! (xmlhandlersetter)XML_SetExternalEntityRefHandler, ! my_ExternalEntityRefHandler }, {NULL, NULL, NULL } /* sentinel */ }; From python-dev@python.org Tue Jun 27 01:37:27 2000 From: python-dev@python.org (A.M. Kuchling) Date: Mon, 26 Jun 2000 17:37:27 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_pyexpat,1.1,1.2 Message-ID: <200006270037.RAA25543@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv25501/output Modified Files: test_pyexpat Log Message: Change pyexpat test suite to exercise the .returns_unicode attribute, parsing the sample data once with 8-bit strings and once with Unicode. Index: test_pyexpat =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_pyexpat,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** test_pyexpat 2000/03/31 15:45:20 1.1 --- test_pyexpat 2000/06/27 00:37:25 1.2 *************** *** 1,5 **** test_pyexpat PI: ! xml-stylesheet href="stylesheet.css" Comment: ' comment data ' --- 1,5 ---- test_pyexpat PI: ! 'xml-stylesheet' 'href="stylesheet.css"' Comment: ' comment data ' *************** *** 8,24 **** ('unparsed_entity', None, 'entity.file', None, 'notation') Start element: ! root {} NS decl: ! myns http://www.python.org/namespace Start element: ! http://www.python.org/namespace!subelement {} Character data: 'Contents of subelements' End element: ! http://www.python.org/namespace!subelement End of NS decl: ! myns Start element: ! sub2 {} Start of CDATA section Character data: --- 8,24 ---- ('unparsed_entity', None, 'entity.file', None, 'notation') Start element: ! 'root' {'attr1': 'value1', 'attr2': 'value2\341\275\200'} NS decl: ! 'myns' 'http://www.python.org/namespace' Start element: ! 'http://www.python.org/namespace!subelement' {} Character data: 'Contents of subelements' End element: ! 'http://www.python.org/namespace!subelement' End of NS decl: ! 'myns' Start element: ! 'sub2' {} Start of CDATA section Character data: *************** *** 26,31 **** End of CDATA section End element: ! sub2 ! External entity ref: http://www.python.org/namespace=http://www.w3.org/XML/1998/namespace external_entity None entity.file None End element: ! root --- 26,91 ---- End of CDATA section End element: ! 'sub2' ! External entity ref: ('http://www.python.org/namespace=http://www.w3.org/XML/1998/namespace\014external_entity', None, 'entity.file', None) End element: ! 'root' ! PI: ! u'xml-stylesheet' u'href="stylesheet.css"' ! Comment: ! u' comment data ' ! Notation declared: (u'notation', None, u'notation.jpeg', None) ! Unparsed entity decl: ! (u'unparsed_entity', None, u'entity.file', None, u'notation') ! Start element: ! u'root' {u'attr1': u'value1', u'attr2': u'value2\u1F40'} ! NS decl: ! u'myns' u'http://www.python.org/namespace' ! Start element: ! u'http://www.python.org/namespace!subelement' {} ! Character data: ! u'Contents of subelements' ! End element: ! u'http://www.python.org/namespace!subelement' ! End of NS decl: ! u'myns' ! Start element: ! u'sub2' {} ! Start of CDATA section ! Character data: ! u'contents of CDATA section' ! End of CDATA section ! End element: ! u'sub2' ! External entity ref: (u'http://www.python.org/namespace=http://www.w3.org/XML/1998/namespace\014external_entity', None, u'entity.file', None) ! End element: ! u'root' ! PI: ! u'xml-stylesheet' u'href="stylesheet.css"' ! Comment: ! u' comment data ' ! Notation declared: (u'notation', None, u'notation.jpeg', None) ! Unparsed entity decl: ! (u'unparsed_entity', None, u'entity.file', None, u'notation') ! Start element: ! u'root' {u'attr1': u'value1', u'attr2': u'value2\u1F40'} ! NS decl: ! u'myns' u'http://www.python.org/namespace' ! Start element: ! u'http://www.python.org/namespace!subelement' {} ! Character data: ! u'Contents of subelements' ! End element: ! u'http://www.python.org/namespace!subelement' ! End of NS decl: ! u'myns' ! Start element: ! u'sub2' {} ! Start of CDATA section ! Character data: ! u'contents of CDATA section' ! End of CDATA section ! End element: ! u'sub2' ! External entity ref: (u'http://www.python.org/namespace=http://www.w3.org/XML/1998/namespace\014external_entity', None, u'entity.file', None) ! End element: ! u'root' From python-dev@python.org Tue Jun 27 01:50:42 2000 From: python-dev@python.org (A.M. Kuchling) Date: Mon, 26 Jun 2000 17:50:42 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/curses wrapper.py,1.2,1.3 Message-ID: <200006270050.RAA26210@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/curses In directory slayer.i.sourceforge.net:/tmp/cvs-serv26153 Modified Files: wrapper.py Log Message: Drop back to old version of wrapper(); ESR reports that it broke things, and I lack the time to track down the cause. Index: wrapper.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/curses/wrapper.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** wrapper.py 2000/06/10 23:39:05 1.2 --- wrapper.py 2000/06/27 00:50:40 1.3 *************** *** 18,24 **** --- 18,26 ---- """ + res = None try: # Initialize curses stdscr=curses.initscr() + # Turn off echoing of keys, and enter cbreak mode, # where no buffering is performed on keyboard input *************** *** 30,39 **** stdscr.keypad(1) ! return apply(func, (stdscr,) + rest) ! ! finally: ! # Restore the terminal to a sane state on the way out. stdscr.keypad(0) curses.echo() ; curses.nocbreak() curses.endwin() --- 32,51 ---- stdscr.keypad(1) ! res = apply(func, (stdscr,) + rest) ! except: ! # In the event of an error, restore the terminal ! # to a sane state. stdscr.keypad(0) curses.echo() ; curses.nocbreak() curses.endwin() + + # Pass the exception upwards + (exc_type, exc_value, exc_traceback) = sys.exc_info() + raise exc_type, exc_value, exc_traceback + else: + # Set everything back to normal + stdscr.keypad(0) + curses.echo() ; curses.nocbreak() + curses.endwin() # Terminate curses + return res From python-dev@python.org Tue Jun 27 02:21:24 2000 From: python-dev@python.org (Greg Ward) Date: Mon, 26 Jun 2000 18:21:24 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command config.py,1.2,1.3 Message-ID: <200006270121.SAA01424@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv1414 Modified Files: config.py Log Message: Added 'include_dirs' parameters all over the place. Added 'check_lib()', which provides a subset of the functionality of 'check_func()' with a simpler interface and implementation. Index: config.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/config.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** config.py 2000/06/21 03:00:50 1.2 --- config.py 2000/06/27 01:21:22 1.3 *************** *** 113,124 **** return filename ! def _preprocess (self, body, headers, lang): src = self._gen_temp_sourcefile(body, headers, lang) out = "_configtest.i" self.temp_files.extend([src, out]) ! self.compiler.preprocess(src, out) return (src, out) ! def _compile (self, body, headers, lang): src = self._gen_temp_sourcefile(body, headers, lang) if self.dump_source: --- 113,124 ---- return filename ! def _preprocess (self, body, headers, include_dirs, lang): src = self._gen_temp_sourcefile(body, headers, lang) out = "_configtest.i" self.temp_files.extend([src, out]) ! self.compiler.preprocess(src, out, include_dirs=include_dirs) return (src, out) ! def _compile (self, body, headers, include_dirs, lang): src = self._gen_temp_sourcefile(body, headers, lang) if self.dump_source: *************** *** 126,134 **** (obj,) = self.compiler.object_filenames([src]) self.temp_files.extend([src, obj]) ! self.compiler.compile([src]) return (src, obj) ! def _link (self, body, headers, libraries, library_dirs, lang): ! (src, obj) = self._compile(body, headers, lang) prog = os.path.splitext(os.path.basename(src))[0] self.temp_files.append(prog) # XXX should be prog + exe_ext --- 126,136 ---- (obj,) = self.compiler.object_filenames([src]) self.temp_files.extend([src, obj]) ! self.compiler.compile([src], include_dirs=include_dirs) return (src, obj) ! def _link (self, body, ! headers, include_dirs, ! libraries, library_dirs, lang): ! (src, obj) = self._compile(body, headers, include_dirs, lang) prog = os.path.splitext(os.path.basename(src))[0] self.temp_files.append(prog) # XXX should be prog + exe_ext *************** *** 160,164 **** # XXX need access to the header search path and maybe default macros. ! def try_cpp (self, body=None, headers=None, lang="c"): """Construct a source file from 'body' (a string containing lines of C/C++ code) and 'headers' (a list of header files to include) --- 162,166 ---- # XXX need access to the header search path and maybe default macros. ! def try_cpp (self, body=None, headers=None, include_dirs=None, lang="c"): """Construct a source file from 'body' (a string containing lines of C/C++ code) and 'headers' (a list of header files to include) *************** *** 178,182 **** return ok ! def search_cpp (self, pattern, body=None, headers=None, lang="c"): """Construct a source file (just like 'try_cpp()'), run it through the preprocessor, and return true if any line of the output matches --- 180,185 ---- return ok ! def search_cpp (self, pattern, body=None, ! headers=None, include_dirs=None, lang="c"): """Construct a source file (just like 'try_cpp()'), run it through the preprocessor, and return true if any line of the output matches *************** *** 207,211 **** return match ! def try_compile (self, body, headers=None, lang="c"): """Try to compile a source file built from 'body' and 'headers'. Return true on success, false otherwise. --- 210,214 ---- return match ! def try_compile (self, body, headers=None, include_dirs=None, lang="c"): """Try to compile a source file built from 'body' and 'headers'. Return true on success, false otherwise. *************** *** 223,228 **** return ok ! def try_link (self, ! body, headers=None, libraries=None, library_dirs=None, lang="c"): --- 226,231 ---- return ok ! def try_link (self, body, ! headers=None, include_dirs=None, libraries=None, library_dirs=None, lang="c"): *************** *** 234,238 **** self._check_compiler() try: ! self._link(body, headers, libraries, library_dirs, lang) ok = 1 except (CompileError, LinkError): --- 237,242 ---- self._check_compiler() try: ! self._link(body, headers, include_dirs, ! libraries, library_dirs, lang) ok = 1 except (CompileError, LinkError): *************** *** 243,248 **** return ok ! def try_run (self, ! body, headers=None, libraries=None, library_dirs=None, lang="c"): --- 247,252 ---- return ok ! def try_run (self, body, ! headers=None, include_dirs=None, libraries=None, library_dirs=None, lang="c"): *************** *** 254,258 **** self._check_compiler() try: ! self._link(body, headers, libraries, library_dirs, lang) self.spawn([exe]) ok = 1 --- 258,263 ---- self._check_compiler() try: ! self._link(body, headers, include_dirs, ! libraries, library_dirs, lang) self.spawn([exe]) ok = 1 *************** *** 269,273 **** # when implementing a real-world config command!) ! def check_func (self, func, headers=None, libraries=None, library_dirs=None, decl=0, call=0): --- 274,279 ---- # when implementing a real-world config command!) ! def check_func (self, func, ! headers=None, include_dirs=None, libraries=None, library_dirs=None, decl=0, call=0): *************** *** 299,312 **** body = string.join(body, "\n") + "\n" ! return self.try_link(body, headers, libraries, library_dirs) # check_func () ! def check_header (self, header, lang="c"): """Determine if the system header file named by 'header_file' exists and can be found by the preprocessor; return true if so, false otherwise. """ ! return self.try_cpp(headers=[header]) --- 305,332 ---- body = string.join(body, "\n") + "\n" ! return self.try_link(body, headers, include_dirs, ! libraries, library_dirs) # check_func () ! def check_lib (self, library, library_dirs=None, ! headers=None, include_dirs=None): ! """Determine if 'library' is available to be linked against, ! without actually checking that any particular symbols are provided ! by it. 'headers' will be used in constructing the source file to ! be compiled, but the only effect of this is to check if all the ! header files listed are available. ! """ ! self._check_compiler() ! return self.try_link("int main (void) { }", ! headers, include_dirs, [library], library_dirs) ! ! def check_header (self, header, include_dirs=None, ! library_dirs=None, lang="c"): """Determine if the system header file named by 'header_file' exists and can be found by the preprocessor; return true if so, false otherwise. """ ! return self.try_cpp(headers=[header], include_dirs=include_dirs) From python-dev@python.org Tue Jun 27 02:24:09 2000 From: python-dev@python.org (Greg Ward) Date: Mon, 26 Jun 2000 18:24:09 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command __init__.py,1.13,1.14 bdist.py,1.13,1.14 Message-ID: <200006270124.SAA01626@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv1613 Modified Files: __init__.py bdist.py Log Message: Infrastructure support for the "bdist_wininst" command. Index: __init__.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/__init__.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** __init__.py 2000/05/28 23:49:03 1.13 --- __init__.py 2000/06/27 01:24:07 1.14 *************** *** 21,23 **** --- 21,24 ---- 'bdist_dumb', 'bdist_rpm', + 'bdist_wininst', ] Index: bdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** bdist.py 2000/06/24 01:23:37 1.13 --- bdist.py 2000/06/27 01:24:07 1.14 *************** *** 56,59 **** --- 56,61 ---- 'tar': ('bdist_dumb', "tar file"), 'zip': ('bdist_dumb', "ZIP file"), + 'wininst': ('bdist_wininst', + "Windows executable installer"), } # establish the preferred order From python-dev@python.org Tue Jun 27 02:24:40 2000 From: python-dev@python.org (Greg Ward) Date: Mon, 26 Jun 2000 18:24:40 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist_wininst.py,NONE,1.1 Message-ID: <200006270124.SAA01647@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv1636 Added Files: bdist_wininst.py Log Message: Thomas Heller's "bdist_wininst" command (unreviewed, untested). ***** Error reading new file(2, 'No such file or directory') From python-dev@python.org Tue Jun 27 02:37:12 2000 From: python-dev@python.org (Greg Ward) Date: Mon, 26 Jun 2000 18:37:12 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command build_ext.py,1.48,1.49 Message-ID: <200006270137.SAA02104@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv2081 Modified Files: build_ext.py Log Message: Thomas Heller: added --swig-cpp option and fixed silly typos in SWIG support. Also supposedly made some change to where .lib files wind up under MSVC++, but I don't understand how to code is doing what Thomas says it's doing. Index: build_ext.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build_ext.py,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -r1.48 -r1.49 *** build_ext.py 2000/06/25 02:30:15 1.48 --- build_ext.py 2000/06/27 01:37:10 1.49 *************** *** 78,81 **** --- 78,83 ---- ('compiler=', 'c', "specify the compiler type"), + ('swig-cpp', None, + "make SWIG create C++ files (default is C)"), ] *************** *** 102,105 **** --- 104,108 ---- self.force = None self.compiler = None + self.swig_cpp = None *************** *** 444,456 **** swig_targets = {} ! # XXX this drops generated C files into the source tree, which # is fine for developers who want to distribute the generated # source -- but there should be an option to put SWIG output in # the temp dir. for source in sources: (base, ext) = os.path.splitext(source) if ext == ".i": # SWIG interface file ! new_sources.append(base + ".c") # umm, what if it's C++? swig_sources.append(source) swig_targets[source] = new_sources[-1] --- 447,464 ---- swig_targets = {} ! # XXX this drops generated C/C++ files into the source tree, which # is fine for developers who want to distribute the generated # source -- but there should be an option to put SWIG output in # the temp dir. + if self.swig_cpp: + target_ext = '.cpp' + else: + target_ext = '.c' + for source in sources: (base, ext) = os.path.splitext(source) if ext == ".i": # SWIG interface file ! new_sources.append(base + target_ext) swig_sources.append(source) swig_targets[source] = new_sources[-1] *************** *** 462,470 **** swig = self.find_swig() ! swig_cmd = [swig, "-python", "-dnone", "-ISWIG"] # again, C++?!? for source in swig_sources: ! self.announce ("swigging %s to %s" % (src, obj)) ! self.spawn(swig_cmd + ["-o", swig_targets[source], source]) return new_sources --- 470,481 ---- swig = self.find_swig() ! swig_cmd = [swig, "-python", "-dnone", "-ISWIG"] ! if self.swig_cpp: ! swig_cmd.append ("-c++") for source in swig_sources: ! target = swig_targets[source] ! self.announce ("swigging %s to %s" % (source, target)) ! self.spawn(swig_cmd + ["-o", target, source]) return new_sources *************** *** 529,536 **** extra_args.append('/export:init%s' % modname) ! # The MSVC linker generates unneeded .lib and .exp files, ! # which cannot be suppressed by any linker switches. So ! # make sure they are generated in the temporary build ! # directory. implib_file = os.path.join ( self.build_temp, --- 540,548 ---- extra_args.append('/export:init%s' % modname) ! # The MSVC linker generates .lib and .exp files, which cannot be ! # suppressed by any linker switches. The .lib files may even be ! # needed! Make sure they are generated in the temporary build ! # directory. Since they have different names for debug and release ! # builds, they can go into the same directory. implib_file = os.path.join ( self.build_temp, From python-dev@python.org Tue Jun 27 02:43:26 2000 From: python-dev@python.org (Greg Ward) Date: Mon, 26 Jun 2000 18:43:26 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command build_ext.py,1.49,1.50 Message-ID: <200006270143.SAA02590@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv2490 Modified Files: build_ext.py Log Message: A-ha! Read Thomas' patch a little more carefully and figured it out: the 'implib_dir' attribute is back (only on NT, of course). Index: build_ext.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build_ext.py,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -r1.49 -r1.50 *** build_ext.py 2000/06/27 01:37:10 1.49 --- build_ext.py 2000/06/27 01:43:24 1.50 *************** *** 156,159 **** --- 156,160 ---- if os.name == 'nt': self.library_dirs.append (os.path.join(sys.exec_prefix, 'libs')) + self.implib_dir = self.build_temp if self.debug: self.build_temp = os.path.join (self.build_temp, "Debug") *************** *** 546,550 **** # builds, they can go into the same directory. implib_file = os.path.join ( ! self.build_temp, self.get_ext_libname (ext.name)) extra_args.append ('/IMPLIB:' + implib_file) --- 547,551 ---- # builds, they can go into the same directory. implib_file = os.path.join ( ! self.implib_dir, self.get_ext_libname (ext.name)) extra_args.append ('/IMPLIB:' + implib_file) From python-dev@python.org Tue Jun 27 02:59:09 2000 From: python-dev@python.org (Greg Ward) Date: Mon, 26 Jun 2000 18:59:09 -0700 Subject: [Python-checkins] CVS: distutils/distutils sysconfig.py,1.20,1.21 Message-ID: <200006270159.SAA03355@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv3347 Modified Files: sysconfig.py Log Message: Fixed LDSHARED for AIX, based on a patch by Rene Liebscher. Ditched my old code that fixed relative paths in the Makefile -- didn't work, doomed to failure, etc. Index: sysconfig.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/sysconfig.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -r1.20 -r1.21 *** sysconfig.py 2000/06/25 02:09:14 1.20 --- sysconfig.py 2000/06/27 01:59:06 1.21 *************** *** 223,241 **** del notdone[name] - # "Fix" all pathnames in the Makefile that are explicitly relative, - # ie. that start with "./". This is a kludge to fix the "./ld_so_aix" - # problem, the nature of which is that Python's installed Makefile - # refers to "./ld_so_aix", but when we are building extensions we are - # far from the directory where Python's Makefile (and ld_so_aix, for - # that matter) is installed. Unfortunately, there are several other - # relative pathnames in the Makefile, and this fix doesn't fix them, - # because the layout of Python's source tree -- which is what the - # Makefile refers to -- is not fully preserved in the Python - # installation. Grumble. - from os.path import normpath, join, dirname - for (name, value) in done.items(): - if value[0:2] == "./": - done[name] = normpath(join(dirname(fp.name), value)) - # save the results in the global dictionary g.update(done) --- 223,226 ---- *************** *** 258,261 **** --- 243,258 ---- parse_makefile(file, g) + + # On AIX, there are wrong paths to the linker scripts in the Makefile + # -- these paths are relative to the Python source, but when installed + # the scripts are in another directory. + if sys.platform: # == 'aix4': # what about AIX 3.x ? + # Linker script is in the config directory, not in Modules as the + # Makefile says. + python_lib = get_python_lib(standard_lib=1) + ld_so_aix = os.path.join(python_lib, 'config', 'ld_so_aix') + python_exp = os.path.join(python_lib, 'config', 'python.exp') + + g['LDSHARED'] = "%s %s -bI:%s" % (ld_so_aix, g['CC'], python_exp) From python-dev@python.org Tue Jun 27 02:59:45 2000 From: python-dev@python.org (Greg Ward) Date: Mon, 26 Jun 2000 18:59:45 -0700 Subject: [Python-checkins] CVS: distutils/distutils sysconfig.py,1.21,1.22 Message-ID: <200006270159.SAA03392@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv3378 Modified Files: sysconfig.py Log Message: Oops, only do that AIX hack on AIX. Index: sysconfig.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/sysconfig.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -r1.21 -r1.22 *** sysconfig.py 2000/06/27 01:59:06 1.21 --- sysconfig.py 2000/06/27 01:59:43 1.22 *************** *** 247,251 **** # -- these paths are relative to the Python source, but when installed # the scripts are in another directory. ! if sys.platform: # == 'aix4': # what about AIX 3.x ? # Linker script is in the config directory, not in Modules as the # Makefile says. --- 247,251 ---- # -- these paths are relative to the Python source, but when installed # the scripts are in another directory. ! if sys.platform == 'aix4': # what about AIX 3.x ? # Linker script is in the config directory, not in Modules as the # Makefile says. From python-dev@python.org Tue Jun 27 04:10:45 2000 From: python-dev@python.org (A.M. Kuchling) Date: Mon, 26 Jun 2000 20:10:45 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _cursesmodule.c,2.25,2.26 Message-ID: <200006270310.UAA19315@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv19289 Modified Files: _cursesmodule.c Log Message: Added support for mouse functions: mousemask(), mouseinterval(), getmouse(), ungetmouse(), and window.enclose(). wmouse_trafo() seems of marginal importance at the moment. Index: _cursesmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_cursesmodule.c,v retrieving revision 2.25 retrieving revision 2.26 diff -C2 -r2.25 -r2.26 *** _cursesmodule.c 2000/06/23 01:36:21 2.25 --- _cursesmodule.c 2000/06/27 03:10:38 2.26 *************** *** 614,618 **** --- 614,632 ---- } + #ifdef NCURSES_MOUSE_VERSION static PyObject * + PyCursesWindow_Enclose(self,arg) + PyCursesWindowObject *self; + PyObject * arg; + { + int x, y; + if (!PyArg_Parse(arg,"(ii);y,x", &y, &x)) + return NULL; + + return PyInt_FromLong( wenclose(self->win,y,x) ); + } + #endif + + static PyObject * PyCursesWindow_GetBkgd(self, arg) PyCursesWindowObject *self; *************** *** 1274,1277 **** --- 1288,1294 ---- {"derwin", (PyCFunction)PyCursesWindow_DerWin}, {"echochar", (PyCFunction)PyCursesWindow_EchoChar}, + #ifdef NCURSES_MOUSE_VERSION + {"enclose", (PyCFunction)PyCursesWindow_Enclose}, + #endif {"erase", (PyCFunction)PyCursesWindow_werase}, {"getbegyx", (PyCFunction)PyCursesWindow_getbegyx}, *************** *** 1595,1599 **** --- 1612,1658 ---- } + #ifdef NCURSES_MOUSE_VERSION static PyObject * + PyCurses_GetMouse(self,arg) + PyObject *self; + PyObject * arg; + { + int rtn; + MEVENT event; + + PyCursesInitialised + if (!PyArg_NoArgs(arg)) return NULL; + + rtn = getmouse( &event ); + if (rtn == ERR) { + PyErr_SetString(PyCursesError, "getmouse() returned ERR"); + return NULL; + } + return Py_BuildValue("(hiiil)", + (short)event.id, + event.x, event.y, event.z, + (long) event.bstate); + } + + static PyObject * + PyCurses_UngetMouse(self,args) + PyObject *self; + PyObject *args; + { + int rtn; + MEVENT event; + + PyCursesInitialised + if (!PyArg_ParseTuple(args, "(hiiil)", + &event.id, + &event.x, &event.y, &event.z, + (int *) &event.bstate)) + return NULL; + + return PyCursesCheckERR(ungetmouse(&event), "ungetmouse"); + } + #endif + + static PyObject * PyCurses_GetWin(self,arg) PyCursesWindowObject *self; *************** *** 1866,1869 **** --- 1925,1958 ---- } + #ifdef NCURSES_MOUSE_VERSION + static PyObject * + PyCurses_MouseInterval(self,arg) + PyObject * self; + PyObject * arg; + { + int interval; + PyCursesInitialised + + if (!PyArg_Parse(arg,"i;interval",&interval)) + return NULL; + return PyCursesCheckERR(mouseinterval(interval), "mouseinterval"); + } + + static PyObject * + PyCurses_MouseMask(self,arg) + PyObject * self; + PyObject * arg; + { + int newmask, rtn; + mmask_t oldmask, availmask; + + PyCursesInitialised + if (!PyArg_Parse(arg,"i;mousemask",&newmask)) + return NULL; + availmask = mousemask(newmask, &oldmask); + return Py_BuildValue("(ll)", (long)availmask, (long)oldmask); + } + #endif + static PyObject * PyCurses_NewPad(self,arg) *************** *** 2169,2172 **** --- 2258,2265 ---- {"flash", (PyCFunction)PyCurses_flash}, {"flushinp", (PyCFunction)PyCurses_flushinp}, + #ifdef NCURSES_MOUSE_VERSION + {"getmouse", (PyCFunction)PyCurses_GetMouse}, + {"ungetmouse", (PyCFunction)PyCurses_UngetMouse, METH_VARARGS}, + #endif {"getsyx", (PyCFunction)PyCurses_getsyx}, {"getwin", (PyCFunction)PyCurses_GetWin}, *************** *** 2187,2190 **** --- 2280,2287 ---- {"longname", (PyCFunction)PyCurses_longname}, {"meta", (PyCFunction)PyCurses_Meta}, + #ifdef NCURSES_MOUSE_VERSION + {"mouseinterval", (PyCFunction)PyCurses_MouseInterval}, + {"mousemask", (PyCFunction)PyCurses_MouseMask}, + #endif {"newpad", (PyCFunction)PyCurses_NewPad}, {"newwin", (PyCFunction)PyCurses_NewWindow}, *************** *** 2270,2273 **** --- 2367,2403 ---- SetDictInt("COLOR_WHITE", COLOR_WHITE); + #ifdef NCURSES_MOUSE_VERSION + /* Mouse-related constants */ + SetDictInt("BUTTON1_PRESSED", BUTTON1_PRESSED); + SetDictInt("BUTTON1_RELEASED", BUTTON1_RELEASED); + SetDictInt("BUTTON1_CLICKED", BUTTON1_CLICKED); + SetDictInt("BUTTON1_DOUBLE_CLICKED", BUTTON1_DOUBLE_CLICKED); + SetDictInt("BUTTON1_TRIPLE_CLICKED", BUTTON1_TRIPLE_CLICKED); + + SetDictInt("BUTTON2_PRESSED", BUTTON2_PRESSED); + SetDictInt("BUTTON2_RELEASED", BUTTON2_RELEASED); + SetDictInt("BUTTON2_CLICKED", BUTTON2_CLICKED); + SetDictInt("BUTTON2_DOUBLE_CLICKED", BUTTON2_DOUBLE_CLICKED); + SetDictInt("BUTTON2_TRIPLE_CLICKED", BUTTON2_TRIPLE_CLICKED); + + SetDictInt("BUTTON3_PRESSED", BUTTON3_PRESSED); + SetDictInt("BUTTON3_RELEASED", BUTTON3_RELEASED); + SetDictInt("BUTTON3_CLICKED", BUTTON3_CLICKED); + SetDictInt("BUTTON3_DOUBLE_CLICKED", BUTTON3_DOUBLE_CLICKED); + SetDictInt("BUTTON3_TRIPLE_CLICKED", BUTTON3_TRIPLE_CLICKED); + + SetDictInt("BUTTON4_PRESSED", BUTTON4_PRESSED); + SetDictInt("BUTTON4_RELEASED", BUTTON4_RELEASED); + SetDictInt("BUTTON4_CLICKED", BUTTON4_CLICKED); + SetDictInt("BUTTON4_DOUBLE_CLICKED", BUTTON4_DOUBLE_CLICKED); + SetDictInt("BUTTON4_TRIPLE_CLICKED", BUTTON4_TRIPLE_CLICKED); + + SetDictInt("BUTTON_SHIFT", BUTTON_SHIFT); + SetDictInt("BUTTON_CTRL", BUTTON_CTRL); + SetDictInt("BUTTON_ALT", BUTTON_ALT); + + SetDictInt("ALL_MOUSE_EVENTS", ALL_MOUSE_EVENTS); + SetDictInt("REPORT_MOUSE_POSITION", REPORT_MOUSE_POSITION); + #endif /* Now set everything up for KEY_ variables */ { From python-dev@python.org Tue Jun 27 04:16:07 2000 From: python-dev@python.org (A.M. Kuchling) Date: Mon, 26 Jun 2000 20:16:07 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libre.tex,1.51,1.52 libcrypto.tex,1.16,1.17 Message-ID: <200006270316.UAA19569@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv19527 Modified Files: libre.tex libcrypto.tex Log Message: Changed obsolete e-mail alias Index: libre.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libre.tex,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -r1.51 -r1.52 *** libre.tex 1999/11/09 20:08:53 1.51 --- libre.tex 2000/06/27 03:16:04 1.52 *************** *** 2,7 **** Perl-style regular expression operations.} \declaremodule{standard}{re} ! \moduleauthor{Andrew M. Kuchling}{akuchling@acm.org} ! \sectionauthor{Andrew M. Kuchling}{akuchling@acm.org} --- 2,7 ---- Perl-style regular expression operations.} \declaremodule{standard}{re} ! \moduleauthor{Andrew M. Kuchling}{amk1@bigfoot.com} ! \sectionauthor{Andrew M. Kuchling}{amk1@bigfoot.com} Index: libcrypto.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcrypto.tex,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** libcrypto.tex 1999/04/29 02:30:03 1.16 --- libcrypto.tex 2000/06/27 03:16:04 1.17 *************** *** 15,19 **** are not distributed with Python but available separately. See the URL \url{http://starship.python.net/crew/amk/python/crypto.html} or ! send email to \email{akuchlin@acm.org} for more information. \index{PGP} \index{Pretty Good Privacy} --- 15,19 ---- are not distributed with Python but available separately. See the URL \url{http://starship.python.net/crew/amk/python/crypto.html} or ! send email to \email{amk1@bigfoot.com} for more information. \index{PGP} \index{Pretty Good Privacy} From python-dev@python.org Tue Jun 27 04:52:59 2000 From: python-dev@python.org (Trent Mick) Date: Mon, 26 Jun 2000 20:52:59 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_pyexpat.py,1.2,1.3 In-Reply-To: <200006270037.RAA25539@slayer.i.sourceforge.net> References: <200006270037.RAA25539@slayer.i.sourceforge.net> Message-ID: <20000626205259.A3866@activestate.com> On Mon, Jun 26, 2000 at 05:37:27PM -0700, A . M . Kuchling wrote: > Update of /cvsroot/python/python/dist/src/Lib/test > In directory slayer.i.sourceforge.net:/tmp/cvs-serv25501 > > Modified Files: > test_pyexpat.py > Log Message: > Change pyexpat test suite to exercise the .returns_unicode attribute, > parsing the sample data once with 8-bit strings and once with Unicode. > Does this require a new Lib/test/output/test_pyexpat? Trent -- Trent Mick trentm@activestate.com From python-dev@python.org Tue Jun 27 15:15:32 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 27 Jun 2000 07:15:32 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/curses ascii.py,1.1,1.2 Message-ID: <200006271415.HAA07414@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/curses In directory slayer.i.sourceforge.net:/tmp/cvs-serv7402 Modified Files: ascii.py Log Message: Fix comment typo noticed by Rob Hooft Index: ascii.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/curses/ascii.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** ascii.py 2000/06/26 23:55:42 1.1 --- ascii.py 2000/06/27 14:15:29 1.2 *************** *** 1,4 **** # ! # ascii.py -- constants and memembership tests for ASCII characters # --- 1,4 ---- # ! # ascii.py -- constants and membership tests for ASCII characters # From python-dev@python.org Tue Jun 27 16:01:13 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 27 Jun 2000 08:01:13 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _cursesmodule.c,2.26,2.27 Message-ID: <200006271501.IAA14137@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv13872 Modified Files: _cursesmodule.c Log Message: Fix two typos (, instead of ;) Index: _cursesmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_cursesmodule.c,v retrieving revision 2.26 retrieving revision 2.27 diff -C2 -r2.26 -r2.27 *** _cursesmodule.c 2000/06/27 03:10:38 2.26 --- _cursesmodule.c 2000/06/27 15:01:10 2.27 *************** *** 1043,1047 **** rtn = pnoutrefresh(self->win, pminrow, pmincol, sminrow, ! smincol, smaxrow, smaxcol), Py_END_ALLOW_THREADS return PyCursesCheckERR(rtn, "pnoutrefresh"); --- 1043,1047 ---- rtn = pnoutrefresh(self->win, pminrow, pmincol, sminrow, ! smincol, smaxrow, smaxcol); Py_END_ALLOW_THREADS return PyCursesCheckERR(rtn, "pnoutrefresh"); *************** *** 1112,1117 **** rtn = prefresh(self->win, pminrow, pmincol, sminrow, ! smincol, smaxrow, smaxcol), ! Py_END_ALLOW_THREADS return PyCursesCheckERR(rtn, "prefresh"); --- 1112,1116 ---- rtn = prefresh(self->win, pminrow, pmincol, sminrow, ! smincol, smaxrow, smaxcol); Py_END_ALLOW_THREADS return PyCursesCheckERR(rtn, "prefresh"); From python-dev@python.org Tue Jun 27 22:49:50 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 27 Jun 2000 14:49:50 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _cursesmodule.c,2.27,2.28 Message-ID: <200006272149.OAA17222@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv17205 Modified Files: _cursesmodule.c Log Message: Fixes for compiling on Tru64. Define a STRICT_SYSV_CURSES macro on SGI, Sun, and Tru64, to mark systems that don't support some features. Index: _cursesmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_cursesmodule.c,v retrieving revision 2.27 retrieving revision 2.28 diff -C2 -r2.27 -r2.28 *** _cursesmodule.c 2000/06/27 15:01:10 2.27 --- _cursesmodule.c 2000/06/27 21:49:47 2.28 *************** *** 42,45 **** --- 42,50 ---- #include "Python.h" + #ifdef __osf__ + #define _XOPEN_SOURCE_EXTENDED /* Define macro for OSF/1 */ + #define STRICT_SYSV_CURSES + #endif + #ifdef HAVE_NCURSES_H #include *************** *** 49,54 **** #if defined(__sgi__) || defined(__sun__) ! /* No attr_t type is available */ ! typedef chtype attr_t; #endif --- 54,59 ---- #if defined(__sgi__) || defined(__sun__) ! #define STRICT_SYSV_CURSES ! typedef chtype attr_t; /* No attr_t type is available */ #endif *************** *** 250,254 **** Window_TwoArgNoReturnFunction(mvderwin, int, "(ii);y,x") Window_TwoArgNoReturnFunction(wmove, int, "(ii);y,x") ! #if !defined(__sgi__) && !defined(__sun__) Window_TwoArgNoReturnFunction(wresize, int, "(ii);lines,columns") #endif --- 255,259 ---- Window_TwoArgNoReturnFunction(mvderwin, int, "(ii);y,x") Window_TwoArgNoReturnFunction(wmove, int, "(ii);y,x") ! #ifndef STRICT_SYSV_CURSES Window_TwoArgNoReturnFunction(wresize, int, "(ii);lines,columns") #endif *************** *** 729,733 **** if (!PyArg_Parse(arg,"(iii);y,x,n", &y, &x, &n)) return NULL; ! #if defined(__sgi__) || defined(__sun__) /* Untested */ Py_BEGIN_ALLOW_THREADS --- 734,738 ---- if (!PyArg_Parse(arg,"(iii);y,x,n", &y, &x, &n)) return NULL; ! #ifdef STRICT_SYSV_CURSES /* Untested */ Py_BEGIN_ALLOW_THREADS *************** *** 1324,1328 **** {"redrawwin", (PyCFunction)PyCursesWindow_redrawwin}, {"refresh", (PyCFunction)PyCursesWindow_Refresh}, ! #if !defined(__sgi__) && !defined(__sun__) {"resize", (PyCFunction)PyCursesWindow_wresize}, #endif --- 1329,1333 ---- {"redrawwin", (PyCFunction)PyCursesWindow_redrawwin}, {"refresh", (PyCFunction)PyCursesWindow_Refresh}, ! #ifndef STRICT_SYSV_CURSES {"resize", (PyCFunction)PyCursesWindow_wresize}, #endif *************** *** 1830,1835 **** SetDictInt("ACS_SBSB", (ACS_VLINE)); SetDictInt("ACS_SSSS", (ACS_PLUS)); ! #if !defined(__sgi__) && !defined(__sun__) ! /* The following are never available on IRIX 5.3 */ SetDictInt("ACS_S3", (ACS_S3)); SetDictInt("ACS_LEQUAL", (ACS_LEQUAL)); --- 1835,1840 ---- SetDictInt("ACS_SBSB", (ACS_VLINE)); SetDictInt("ACS_SSSS", (ACS_PLUS)); ! #ifndef STRICT_SYSV_CURSES ! /* The following are never available with strict SYSV curses */ SetDictInt("ACS_S3", (ACS_S3)); SetDictInt("ACS_LEQUAL", (ACS_LEQUAL)); *************** *** 2348,2352 **** SetDictInt("A_CHARTEXT", A_CHARTEXT); SetDictInt("A_COLOR", A_COLOR); ! #if !defined(__sgi__) && !defined(__sun__) SetDictInt("A_HORIZONTAL", A_HORIZONTAL); SetDictInt("A_LEFT", A_LEFT); --- 2353,2357 ---- SetDictInt("A_CHARTEXT", A_CHARTEXT); SetDictInt("A_COLOR", A_COLOR); ! #ifndef STRICT_SYSV_CURSES SetDictInt("A_HORIZONTAL", A_HORIZONTAL); SetDictInt("A_LEFT", A_LEFT); From python-dev@python.org Wed Jun 28 01:36:43 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 27 Jun 2000 17:36:43 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist_dumb.py,1.7,1.8 Message-ID: <200006280036.RAA12335@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv12327 Modified Files: bdist_dumb.py Log Message: Fixed to use 'reinitialize_command()' to fetch the "install" command object. Index: bdist_dumb.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist_dumb.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** bdist_dumb.py 2000/05/27 17:27:23 1.7 --- bdist_dumb.py 2000/06/28 00:36:40 1.8 *************** *** 59,68 **** self.run_command ('build') ! # XXX don't use 'self.get_finalized_command()', because it always runs ! # 'ensure_finalized()' on the command object; we explictly want a ! # command object that has *not* been finalized, so we can set ! # options on it! (The option we set, 'root', is so that we can do ! # a proper "fake install" using this install command object.) ! install = self.distribution.get_command_obj('install') install.root = self.bdist_dir --- 59,63 ---- self.run_command ('build') ! install = self.reinitialize_command('install') install.root = self.bdist_dir From python-dev@python.org Wed Jun 28 01:56:23 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 27 Jun 2000 17:56:23 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist_wininst.py,1.1,1.2 Message-ID: <200006280056.RAA13336@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv13321 Modified Files: bdist_wininst.py Log Message: Fixed to use 'reinitialize_command()' to fetch "install" and "install_lib" command objects. Various formatting tweaks, typo fixes in comments. Index: bdist_wininst.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist_wininst.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** bdist_wininst.py 2000/06/27 01:24:38 1.1 --- bdist_wininst.py 2000/06/28 00:56:20 1.2 *************** *** 8,12 **** __revision__ = "$Id$" ! import os, sys from distutils.core import Command from distutils.util import get_platform, create_tree, remove_tree --- 8,12 ---- __revision__ = "$Id$" ! import sys, os, string from distutils.core import Command from distutils.util import get_platform, create_tree, remove_tree *************** *** 15,19 **** class bdist_wininst (Command): ! description = "create a \"wininst\" built distribution" user_options = [('bdist-dir=', 'd', --- 15,19 ---- class bdist_wininst (Command): ! description = "create an executable installer for MS Windows" user_options = [('bdist-dir=', 'd', *************** *** 65,84 **** self.run_command ('build') ! # XXX don't use 'self.get_finalized_command()', because it always ! # runs 'ensure_finalized()' on the command object; we explictly ! # want a command object that has *not* been finalized, so we can set ! # options on it! (The option we set, 'root', is so that we can do ! # a proper "fake install" using this install command object.) ! install = self.distribution.get_command_obj('install') install.root = self.bdist_dir ! install_lib = self.distribution.get_command_obj('install_lib') ! install_lib.compile = 0 install_lib.optimize = 0 ! # The packager (correct term in distutils speak?) can choose ! # if pyc and pyo files should be created on the TARGET system ! # instead at the SOURCE system. ## # The compilation can only be done on the SOURCE system --- 65,77 ---- self.run_command ('build') ! install = self.reinitialize_command('install') install.root = self.bdist_dir ! install_lib = self.reinitialize_command('install_lib') install_lib.compile = 0 install_lib.optimize = 0 ! # The packager can choose if .pyc and .pyo files should be created ! # on the TARGET system instead at the SOURCE system. ## # The compilation can only be done on the SOURCE system *************** *** 96,100 **** self.announce ("installing to %s" % self.bdist_dir) install.ensure_finalized() - install.run() --- 89,92 ---- *************** *** 104,111 **** # XXX hack! Our archive MUST be relative to sys.prefix # XXX What about .install_data, .install_scripts, ...? root_dir = install.install_lib arcname = self.make_archive (archive_basename, "zip", ! root_dir=root_dir) ! self.create_exe (arcname) --- 96,107 ---- # XXX hack! Our archive MUST be relative to sys.prefix # XXX What about .install_data, .install_scripts, ...? + # [Perhaps require that all installation dirs be under sys.prefix + # on Windows? this will be acceptable until we start dealing + # with Python applications, at which point we should zip up + # the application directory -- and again everything can be + # under one dir --GPW] root_dir = install.install_lib arcname = self.make_archive (archive_basename, "zip", ! root_dir=root_dir) self.create_exe (arcname) *************** *** 116,139 **** def create_inifile (self): ! # create an inifile containing data describing the installation. # This could be done without creating a real file, but ! # a file is (at least) usefull for debugging bdist_wininst. ! import string metadata = self.distribution.metadata - ini_name = "%s.ini" % self.distribution.get_fullname() - self.announce ("creating %s" % ini_name) - inifile = open (ini_name, "w") ! # write the [metadata] section. values are written with repr()[1:], ! # so they do not contain unprintable characters, and are not ! # surrounded by quote chars inifile.write ("[metadata]\n") ! # 'info' will be displayed in the installers dialog box, ! # describing the items to be installed info = metadata.long_description + '\n' --- 112,132 ---- def create_inifile (self): ! # Create an inifile containing data describing the installation. # This could be done without creating a real file, but ! # a file is (at least) useful for debugging bdist_wininst. metadata = self.distribution.metadata + ini_name = "%s.ini" % metadata.get_fullname() self.announce ("creating %s" % ini_name) inifile = open (ini_name, "w") ! # Write the [metadata] section. Values are written with ! # repr()[1:-1], so they do not contain unprintable characters, and ! # are not surrounded by quote chars. inifile.write ("[metadata]\n") ! # 'info' will be displayed in the installer's dialog box, ! # describing the items to be installed. info = metadata.long_description + '\n' *************** *** 174,178 **** installer_name = "%s.win32.exe" % self.distribution.get_fullname() - self.announce ("creating %s" % installer_name) --- 167,170 ---- From python-dev@python.org Wed Jun 28 02:20:38 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 27 Jun 2000 18:20:38 -0700 Subject: [Python-checkins] CVS: distutils/distutils bcppcompiler.py,NONE,1.1 Message-ID: <200006280120.SAA20707@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv20700 Added Files: bcppcompiler.py Log Message: Lyle Johnson's interface to Borland C++, with a few editorial comments by me. Two major points: * lots of overlap with MSVCCompiler; the common code really should be factored out into a base class, say WindowsCCompiler * it doesn't work: weird problem spawning the linker (see comment for details) ***** Error reading new file(2, 'No such file or directory') From python-dev@python.org Wed Jun 28 02:25:29 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 27 Jun 2000 18:25:29 -0700 Subject: [Python-checkins] CVS: distutils/distutils dist.py,1.30,1.31 Message-ID: <200006280125.SAA20982@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv20962 Modified Files: dist.py Log Message: Typo fix. Index: dist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/dist.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -r1.30 -r1.31 *** dist.py 2000/06/24 01:22:41 1.30 --- dist.py 2000/06/28 01:25:27 1.31 *************** *** 731,735 **** """Reinitializes a command to the state it was in when first returned by 'get_command_obj()': ie., initialized but not yet ! finalized. This gives provides the opportunity to sneak option values in programmatically, overriding or supplementing user-supplied values from the config files and command line. --- 731,735 ---- """Reinitializes a command to the state it was in when first returned by 'get_command_obj()': ie., initialized but not yet ! finalized. This provides the opportunity to sneak option values in programmatically, overriding or supplementing user-supplied values from the config files and command line. From python-dev@python.org Wed Jun 28 02:29:11 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 27 Jun 2000 18:29:11 -0700 Subject: [Python-checkins] CVS: distutils/distutils ccompiler.py,1.27,1.28 msvccompiler.py,1.31,1.32 unixccompiler.py,1.27,1.28 Message-ID: <200006280129.SAA21300@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv21286 Modified Files: ccompiler.py msvccompiler.py unixccompiler.py Log Message: Lyle Johnson: added 'build_temp' parameter to 'link_shared_{lib,object}()' methods (but not 'link_executable()', hmmm). Currently only used by BCPPCompiler; it's a dummy parameter for UnixCCompiler and MSVCCompiler. Also added 'bcpp' to compiler table used by 'new_compiler()'. Index: ccompiler.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/ccompiler.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -r1.27 -r1.28 *** ccompiler.py 2000/06/25 02:08:18 1.27 --- ccompiler.py 2000/06/28 01:29:09 1.28 *************** *** 493,497 **** extra_preargs=None, extra_postargs=None): - """Compile one or more source files. 'sources' must be a list of filenames, most likely C/C++ files, but in reality anything that --- 493,496 ---- *************** *** 573,578 **** debug=0, extra_preargs=None, ! extra_postargs=None): ! """Link a bunch of stuff together to create a shared library file. Similar semantics to 'create_static_lib()', with the addition of --- 572,577 ---- debug=0, extra_preargs=None, ! extra_postargs=None, ! build_temp=None): """Link a bunch of stuff together to create a shared library file. Similar semantics to 'create_static_lib()', with the addition of *************** *** 625,629 **** debug=0, extra_preargs=None, ! extra_postargs=None): """Link a bunch of stuff together to create a shared object file. Much like 'link_shared_lib()', except the output filename is --- 624,629 ---- debug=0, extra_preargs=None, ! extra_postargs=None, ! build_temp=None): """Link a bunch of stuff together to create a shared object file. Much like 'link_shared_lib()', except the output filename is *************** *** 815,818 **** --- 815,820 ---- 'mingw32': ('cygwinccompiler', 'Mingw32CCompiler', "Mingw32 port of GNU C Compiler for Win32"), + 'bcpp': ('bcppcompiler', 'BCPPCompiler', + "Borland C++ Compiler"), } Index: msvccompiler.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/msvccompiler.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -r1.31 -r1.32 *** msvccompiler.py 2000/06/25 02:31:16 1.31 --- msvccompiler.py 2000/06/28 01:29:09 1.32 *************** *** 1,3 **** ! """distutils.ccompiler Contains MSVCCompiler, an implementation of the abstract CCompiler class --- 1,3 ---- ! """distutils.msvccompiler Contains MSVCCompiler, an implementation of the abstract CCompiler class *************** *** 323,327 **** debug=0, extra_preargs=None, ! extra_postargs=None): self.link_shared_object (objects, --- 323,328 ---- debug=0, extra_preargs=None, ! extra_postargs=None, ! build_temp=None): self.link_shared_object (objects, *************** *** 334,338 **** debug=debug, extra_preargs=extra_preargs, ! extra_postargs=extra_postargs) --- 335,340 ---- debug=debug, extra_preargs=extra_preargs, ! extra_postargs=extra_postargs, ! build_temp=build_temp) *************** *** 347,351 **** debug=0, extra_preargs=None, ! extra_postargs=None): (objects, output_dir) = self._fix_object_args (objects, output_dir) --- 349,354 ---- debug=0, extra_preargs=None, ! extra_postargs=None, ! build_temp=None): (objects, output_dir) = self._fix_object_args (objects, output_dir) Index: unixccompiler.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/unixccompiler.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -r1.27 -r1.28 *** unixccompiler.py 2000/06/25 02:05:29 1.27 --- unixccompiler.py 2000/06/28 01:29:09 1.28 *************** *** 75,78 **** --- 75,79 ---- + def __init__ (self, verbose=0, *************** *** 200,204 **** debug=0, extra_preargs=None, ! extra_postargs=None): self.link_shared_object ( objects, --- 201,207 ---- debug=0, extra_preargs=None, ! extra_postargs=None, ! build_temp=None): ! self.link_shared_object ( objects, *************** *** 211,215 **** debug, extra_preargs, ! extra_postargs) --- 214,219 ---- debug, extra_preargs, ! extra_postargs, ! build_temp) *************** *** 224,228 **** debug=0, extra_preargs=None, ! extra_postargs=None): (objects, output_dir) = self._fix_object_args (objects, output_dir) --- 228,233 ---- debug=0, extra_preargs=None, ! extra_postargs=None, ! build_temp=None): (objects, output_dir) = self._fix_object_args (objects, output_dir) From python-dev@python.org Wed Jun 28 02:29:39 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 27 Jun 2000 18:29:39 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command build_ext.py,1.50,1.51 Message-ID: <200006280129.SAA21340@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv21325/command Modified Files: build_ext.py Log Message: Lyle Johnson: pass in temp directory as 'build_temp' argument when calling 'link_shared_object()'. Index: build_ext.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build_ext.py,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -r1.50 -r1.51 *** build_ext.py 2000/06/27 01:43:24 1.50 --- build_ext.py 2000/06/28 01:29:37 1.51 *************** *** 431,435 **** runtime_library_dirs=ext.runtime_library_dirs, extra_postargs=extra_args, ! debug=self.debug) # build_extensions () --- 431,436 ---- runtime_library_dirs=ext.runtime_library_dirs, extra_postargs=extra_args, ! debug=self.debug, ! build_temp=self.build_temp) # build_extensions () From python-dev@python.org Wed Jun 28 02:31:39 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 27 Jun 2000 18:31:39 -0700 Subject: [Python-checkins] CVS: distutils MINIFEST.in,1.1,1.2 MANIFEST.in,1.7,1.8 Message-ID: <200006280131.SAA21503@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv21490 Modified Files: MINIFEST.in MANIFEST.in Log Message: Added 'misc' directory (except for zip files), so we get the source to Thomas Heller's Windows installer. Index: MINIFEST.in =================================================================== RCS file: /cvsroot/python/distutils/MINIFEST.in,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** MINIFEST.in 2000/06/08 01:17:32 1.1 --- MINIFEST.in 2000/06/28 01:31:37 1.2 *************** *** 11,12 **** --- 11,14 ---- prune examples/sample*/build prune test + graft misc + exclude misc/*.zip Index: MANIFEST.in =================================================================== RCS file: /cvsroot/python/distutils/MANIFEST.in,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** MANIFEST.in 2000/06/08 01:20:23 1.7 --- MANIFEST.in 2000/06/28 01:31:37 1.8 *************** *** 14,15 **** --- 14,17 ---- prune examples/sample*/build recursive-include doc *.sty *.tex + graft misc + exclude misc/*.zip From python-dev@python.org Wed Jun 28 03:02:44 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 27 Jun 2000 19:02:44 -0700 Subject: [Python-checkins] CVS: distutils/misc - New directory Message-ID: <200006280202.TAA29192@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/misc In directory slayer.i.sourceforge.net:/tmp/cvs-serv29185/misc Log Message: Directory /cvsroot/python/distutils/misc added to the repository From python-dev@python.org Wed Jun 28 03:04:03 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 27 Jun 2000 19:04:03 -0700 Subject: [Python-checkins] CVS: distutils/misc install.c,NONE,1.1 install.rc,NONE,1.1 resource.h,NONE,1.1 wininst.dsp,NONE,1.1 wininst.dsw,NONE,1.1 Message-ID: <200006280204.TAA29320@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/misc In directory slayer.i.sourceforge.net:/tmp/cvs-serv29313 Added Files: install.c install.rc resource.h wininst.dsp wininst.dsw Log Message: C source (and related files) for the GUI Windows installer used by the "bdist_wininst" command. ***** Error reading new file(2, 'No such file or directory') --- NEW FILE --- //Microsoft Developer Studio generated resource script. // #include "resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // #include "afxres.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // German (Germany) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) #ifdef _WIN32 LANGUAGE LANG_GERMAN, SUBLANG_GERMAN #pragma code_page(1252) #endif //_WIN32 ///////////////////////////////////////////////////////////////////////////// // // Dialog // IDD_DIALOG1 DIALOG DISCARDABLE 0, 0, 276, 223 STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Installation" FONT 8, "MS Sans Serif" BEGIN DEFPUSHBUTTON "Start",IDC_START,84,202,50,14 PUSHBUTTON "Close",IDCANCEL,142,202,50,14 CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER, 28,184,218,14 CTEXT "static",IDC_INFO,7,172,262,8 EDITTEXT IDC_EDIT1,7,7,262,128,ES_MULTILINE | ES_READONLY | WS_VSCROLL | WS_HSCROLL CONTROL "Use Python 1.5",IDC_PYTHON15,"Button", BS_AUTORADIOBUTTON,7,140,65,10 EDITTEXT IDC_PATH,42,154,202,14,ES_AUTOHSCROLL CONTROL "Use Python 1.6",IDC_PYTHON16,"Button", BS_AUTORADIOBUTTON,79,140,65,10 LTEXT "Directory:",IDC_STATIC,7,157,31,8 PUSHBUTTON "...",IDC_BROWSE,248,154,21,14 END ///////////////////////////////////////////////////////////////////////////// // // DESIGNINFO // #ifdef APSTUDIO_INVOKED GUIDELINES DESIGNINFO DISCARDABLE BEGIN IDD_DIALOG1, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 269 TOPMARGIN, 7 BOTTOMMARGIN, 216 END END #endif // APSTUDIO_INVOKED #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // TEXTINCLUDE // 1 TEXTINCLUDE DISCARDABLE BEGIN "resource.h\0" END 2 TEXTINCLUDE DISCARDABLE BEGIN "#include ""afxres.h""\r\n" "\0" END 3 TEXTINCLUDE DISCARDABLE BEGIN "\r\n" "\0" END #endif // APSTUDIO_INVOKED #endif // German (Germany) resources ///////////////////////////////////////////////////////////////////////////// #ifndef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 3 resource. // ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED --- NEW FILE --- //{{NO_DEPENDENCIES}} // Microsoft Developer Studio generated include file. // Used by install.rc // #define IDD_DIALOG1 101 #define IDC_EDIT1 1000 #define IDC_START 1001 #define IDC_PROGRESS 1003 #define IDC_INFO 1004 #define IDC_PYTHON15 1006 #define IDC_PATH 1007 #define IDC_PYTHON16 1008 #define IDC_BROWSE 1010 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 102 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1012 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif --- NEW FILE --- # Microsoft Developer Studio Project File - Name="wininst" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Application" 0x0101 CFG=wininst - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "wininst.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "wininst.mak" CFG="wininst - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "wininst - Win32 Release" (based on "Win32 (x86) Application") !MESSAGE "wininst - Win32 Debug" (based on "Win32 (x86) Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "wininst - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "." # PROP Intermediate_Dir "temp-release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O1 /I "zlib" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x407 /d "NDEBUG" # ADD RSC /l 0x407 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo 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 /machine:I386 # ADD LINK32 ole32.lib zlibstat.lib comctl32.lib kernel32.lib user32.lib gdi32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"LIBC" /libpath:"zlib\static32" !ELSEIF "$(CFG)" == "wininst - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "." # PROP Intermediate_Dir "temp-debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MD /W3 /Z7 /Od /I "zlib" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x407 /d "_DEBUG" # ADD RSC /l 0x407 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo 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 /debug /machine:I386 /pdbtype:sept # ADD LINK32 ole32.lib zlibstat.lib comctl32.lib kernel32.lib user32.lib gdi32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /pdb:none /debug /machine:I386 /nodefaultlib:"LIBC" /out:"./wininst_d.exe" /libpath:"zlib\static32" !ENDIF # Begin Target # Name "wininst - Win32 Release" # Name "wininst - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\install.c # End Source File # Begin Source File SOURCE=.\install.rc # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project --- NEW FILE --- Microsoft Developer Studio Workspace File, Format Version 6.00 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! ############################################################################### Project: "wininst"=.\wininst.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Global: Package=<5> {{{ }}} Package=<3> {{{ }}} ############################################################################### From python-dev@python.org Wed Jun 28 04:51:48 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 27 Jun 2000 20:51:48 -0700 Subject: [Python-checkins] CVS: distutils/doc README.txt,1.1,1.2 Message-ID: <200006280351.UAA08426@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/doc In directory slayer.i.sourceforge.net:/tmp/cvs-serv8418 Modified Files: README.txt Log Message: Remove comment about a "forest of symlinks"; not needed now that distutils.sty is part of the Python documentation tools. Updated URL to information about the Python CVS repository. Index: README.txt =================================================================== RCS file: /cvsroot/python/distutils/doc/README.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** README.txt 2000/05/13 03:45:48 1.1 --- README.txt 2000/06/28 03:51:45 1.2 *************** *** 10,15 **** set, and are tightly integrated with the standard Python documentation tools. That means that you won't be able to process the LaTeX files ! here without 1) downloading the latest Python documentation tools, and ! 2) setting up a fearsome forest of symbolic links to make it all work. Since these two manuals are now included with the Python documentation --- 10,14 ---- set, and are tightly integrated with the standard Python documentation tools. That means that you won't be able to process the LaTeX files ! here without downloading the latest Python documentation tools. Since these two manuals are now included with the Python documentation *************** *** 21,25 **** For information on getting access to the Python source and documentation via CVS, see ! http://www.python.org/download/cvs.html If all you really want to do is *read* the documentation, you don't need --- 20,24 ---- For information on getting access to the Python source and documentation via CVS, see ! https://sourceforge.net/cvs/?group_id=5470 If all you really want to do is *read* the documentation, you don't need From python-dev@python.org Wed Jun 28 04:54:51 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 27 Jun 2000 20:54:51 -0700 Subject: [Python-checkins] CVS: python/dist/src/PC config.h,1.36,1.37 Message-ID: <200006280354.UAA08590@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv8581 Modified Files: config.h Log Message: Changed the #error to a #warning when checking gcc versions, and noted the minimum recommended version in the message. Index: config.h =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/config.h,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -r1.36 -r1.37 *** config.h 2000/06/19 13:41:54 1.36 --- config.h 2000/06/28 03:54:48 1.37 *************** *** 32,36 **** */ #if (__GNUC__==2) && (__GNUC_MINOR__<=91) ! #error "Please use an up-to-date version of gcc" #endif --- 32,36 ---- */ #if (__GNUC__==2) && (__GNUC_MINOR__<=91) ! #warning "Please use an up-to-date version of gcc! (>2.91 recommended)" #endif From python-dev@python.org Wed Jun 28 09:11:50 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 28 Jun 2000 01:11:50 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.28,2.29 Message-ID: <200006280811.BAA18157@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv18141/Objects Modified Files: unicodeobject.c Log Message: Marc-Andre Lemburg : Better error message for "1 in unicodestring". Submitted by Andrew Kuchling. Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.28 retrieving revision 2.29 diff -C2 -r2.28 -r2.29 *** unicodeobject.c 2000/06/18 22:25:22 2.28 --- unicodeobject.c 2000/06/28 08:11:47 2.29 *************** *** 2989,2994 **** /* Coerce the two arguments */ v = (PyUnicodeObject *)PyUnicode_FromObject(element); ! if (v == NULL) goto onError; u = (PyUnicodeObject *)PyUnicode_FromObject(container); if (u == NULL) { --- 2989,2997 ---- /* Coerce the two arguments */ v = (PyUnicodeObject *)PyUnicode_FromObject(element); ! if (v == NULL) { ! PyErr_SetString(PyExc_TypeError, ! "'in ' requires character as left operand"); goto onError; + } u = (PyUnicodeObject *)PyUnicode_FromObject(container); if (u == NULL) { From python-dev@python.org Wed Jun 28 15:44:08 2000 From: python-dev@python.org (Jeremy Hylton) Date: Wed, 28 Jun 2000 07:44:08 -0700 Subject: [Python-checkins] CVS: python/dist/src/Demo/pdist rcslib.py,1.6,1.7 Message-ID: <200006281444.HAA00518@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Demo/pdist In directory slayer.i.sourceforge.net:/tmp/cvs-serv506/Demo/pdist Modified Files: rcslib.py Log Message: typos fixed by Rob Hooft Index: rcslib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/pdist/rcslib.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** rcslib.py 1998/09/14 16:43:57 1.6 --- rcslib.py 2000/06/28 14:44:05 1.7 *************** *** 297,301 **** """INTERNAL: run COMMAND in a subshell. ! Standard input for the command is taken fron /dev/null. Raise IOError when the exit status is not zero. --- 297,301 ---- """INTERNAL: run COMMAND in a subshell. ! Standard input for the command is taken from /dev/null. Raise IOError when the exit status is not zero. From python-dev@python.org Wed Jun 28 15:44:08 2000 From: python-dev@python.org (Jeremy Hylton) Date: Wed, 28 Jun 2000 07:44:08 -0700 Subject: [Python-checkins] CVS: python/dist/src/Demo/sgi/video Vcopy.py,1.7,1.8 Vtime.py,1.4,1.5 Message-ID: <200006281444.HAA00523@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Demo/sgi/video In directory slayer.i.sourceforge.net:/tmp/cvs-serv506/Demo/sgi/video Modified Files: Vcopy.py Vtime.py Log Message: typos fixed by Rob Hooft Index: Vcopy.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/sgi/video/Vcopy.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** Vcopy.py 1996/11/27 19:50:07 1.7 --- Vcopy.py 2000/06/28 14:44:05 1.8 *************** *** 9,13 **** # = resample at a fixed rate # = divide the time codes by a speed factor (to make it go faster/slower) ! # = drop frames that are less than n msec apart (to accomodate slow players) # - Convert to a different format # - Magnify (scale) the image --- 9,13 ---- # = resample at a fixed rate # = divide the time codes by a speed factor (to make it go faster/slower) ! # = drop frames that are less than n msec apart (to accommodate slow players) # - Convert to a different format # - Magnify (scale) the image Index: Vtime.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/sgi/video/Vtime.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** Vtime.py 1996/11/27 19:50:28 1.4 --- Vtime.py 2000/06/28 14:44:05 1.5 *************** *** 8,12 **** # - resample at a fixed rate # - divide the time codes by a speed factor (to make it go faster/slower) ! # - drop frames that are less than n msec apart (to accomodate slow players) --- 8,12 ---- # - resample at a fixed rate # - divide the time codes by a speed factor (to make it go faster/slower) ! # - drop frames that are less than n msec apart (to accommodate slow players) From python-dev@python.org Wed Jun 28 15:48:04 2000 From: python-dev@python.org (Jeremy Hylton) Date: Wed, 28 Jun 2000 07:48:04 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/distutils cmd.py,1.18,1.19 util.py,1.37,1.38 version.py,1.1,1.2 Message-ID: <200006281448.HAA00779@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv723/Lib/distutils Modified Files: cmd.py util.py version.py Log Message: typos fixed by Rob Hooft Index: cmd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/cmd.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** cmd.py 2000/06/08 00:02:36 1.18 --- cmd.py 2000/06/28 14:48:01 1.19 *************** *** 324,328 **** themselves if the current verbosity level is high enough. This method takes care of all that bureaucracy for you; all you have to ! do is supply the funtion to call and an argument tuple for it (to embody the "external action" being performed), a message to print if the verbosity level is high enough, and an optional verbosity --- 324,328 ---- themselves if the current verbosity level is high enough. This method takes care of all that bureaucracy for you; all you have to ! do is supply the function to call and an argument tuple for it (to embody the "external action" being performed), a message to print if the verbosity level is high enough, and an optional verbosity Index: util.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/util.py,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -r1.37 -r1.38 *** util.py 2000/06/24 20:40:02 1.37 --- util.py 2000/06/28 14:48:01 1.38 *************** *** 29,33 **** ! # More backwards compatability hacks def extend (list, new_list): """Appends the list 'new_list' to 'list', just like the 'extend()' --- 29,33 ---- ! # More backwards compatibility hacks def extend (list, new_list): """Appends the list 'new_list' to 'list', just like the 'extend()' Index: version.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/version.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** version.py 1998/12/18 22:00:30 1.1 --- version.py 2000/06/28 14:48:01 1.2 *************** *** 208,212 **** # version numbering scheme to its domination. The free-thinking # anarchists in the lot will never give in, though, and something needs ! # to be done to accomodate them. # # Perhaps a "moderately strict" version class could be implemented that --- 208,212 ---- # version numbering scheme to its domination. The free-thinking # anarchists in the lot will never give in, though, and something needs ! # to be done to accommodate them. # # Perhaps a "moderately strict" version class could be implemented that From python-dev@python.org Wed Jun 28 15:48:04 2000 From: python-dev@python.org (Jeremy Hylton) Date: Wed, 28 Jun 2000 07:48:04 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/distutils/command build_ext.py,1.51,1.52 Message-ID: <200006281448.HAA00783@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv723/Lib/distutils/command Modified Files: build_ext.py Log Message: typos fixed by Rob Hooft Index: build_ext.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/build_ext.py,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -r1.51 -r1.52 *** build_ext.py 2000/06/28 01:29:37 1.51 --- build_ext.py 2000/06/28 14:48:01 1.52 *************** *** 2,6 **** Implements the Distutils 'build_ext' command, for building extension ! modules (currently limited to C extensions, should accomodate C++ extensions ASAP).""" --- 2,6 ---- Implements the Distutils 'build_ext' command, for building extension ! modules (currently limited to C extensions, should accommodate C++ extensions ASAP).""" *************** *** 386,390 **** # XXX not honouring 'define_macros' or 'undef_macros' -- the ! # CCompiler API needs to change to accomodate this, and I # want to do one thing at a time! --- 386,390 ---- # XXX not honouring 'define_macros' or 'undef_macros' -- the ! # CCompiler API needs to change to accommodate this, and I # want to do one thing at a time! From python-dev@python.org Wed Jun 28 15:48:04 2000 From: python-dev@python.org (Jeremy Hylton) Date: Wed, 28 Jun 2000 07:48:04 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-irix6 flp.py,1.4,1.5 panel.py,1.1,1.2 Message-ID: <200006281448.HAA00806@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/plat-irix6 In directory slayer.i.sourceforge.net:/tmp/cvs-serv723/Lib/plat-irix6 Modified Files: flp.py panel.py Log Message: typos fixed by Rob Hooft Index: flp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/flp.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** flp.py 1998/03/26 20:23:01 1.4 --- flp.py 2000/06/28 14:48:01 1.5 *************** *** 204,208 **** # # Internal: parse fd form, or skip if name doesn't match. ! # the special value None means 'allways parse it'. # def _parse_fd_form(file, name): --- 204,208 ---- # # Internal: parse fd form, or skip if name doesn't match. ! # the special value None means 'always parse it'. # def _parse_fd_form(file, name): *************** *** 223,227 **** # ! # Internal class: a convient place to store object info fields # class _newobj: --- 223,227 ---- # ! # Internal class: a convenient place to store object info fields # class _newobj: Index: panel.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/panel.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** panel.py 1997/01/15 19:19:11 1.1 --- panel.py 2000/06/28 14:48:01 1.2 *************** *** 3,7 **** # Support for the Panel library. # Uses built-in module 'pnl'. ! # Applciations should use 'panel.function' instead of 'pnl.function'; # most 'pnl' functions are transparently exported by 'panel', # but dopanel() is overridden and you have to use this version --- 3,7 ---- # Support for the Panel library. # Uses built-in module 'pnl'. ! # Applications should use 'panel.function' instead of 'pnl.function'; # most 'pnl' functions are transparently exported by 'panel', # but dopanel() is overridden and you have to use this version *************** *** 138,142 **** ! # Build a real actuator from an actuator descriptior. # Return a pair (actuator, name). # --- 138,142 ---- ! # Build a real actuator from an actuator description. # Return a pair (actuator, name). # From python-dev@python.org Wed Jun 28 15:48:04 2000 From: python-dev@python.org (Jeremy Hylton) Date: Wed, 28 Jun 2000 07:48:04 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/dos-8x3 posixpat.py,1.10,1.11 queue.py,1.7,1.8 test_win.py,1.1,1.2 Message-ID: <200006281448.HAA00799@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/dos-8x3 In directory slayer.i.sourceforge.net:/tmp/cvs-serv723/Lib/dos-8x3 Modified Files: posixpat.py queue.py test_win.py Log Message: typos fixed by Rob Hooft Index: posixpat.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/posixpat.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** posixpat.py 2000/05/08 17:31:00 1.10 --- posixpat.py 2000/06/28 14:48:01 1.11 *************** *** 25,29 **** ! # Return wheter a path is absolute. # Trivial in Posix, harder on the Mac or MS-DOS. --- 25,29 ---- ! # Return whether a path is absolute. # Trivial in Posix, harder on the Mac or MS-DOS. *************** *** 305,309 **** # Expand paths containing shell variable substitutions. # This expands the forms $variable and ${variable} only. ! # Non-existant variables are left unchanged. _varprog = None --- 305,309 ---- # Expand paths containing shell variable substitutions. # This expands the forms $variable and ${variable} only. ! # Non-existent variables are left unchanged. _varprog = None Index: queue.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/queue.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** queue.py 2000/05/08 17:31:00 1.7 --- queue.py 2000/06/28 14:48:01 1.8 *************** *** 120,124 **** return len(self.queue) ! # Check wheter the queue is empty def _empty(self): return not self.queue --- 120,124 ---- return len(self.queue) ! # Check whether the queue is empty def _empty(self): return not self.queue Index: test_win.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/test_win.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** test_win.py 2000/05/08 17:31:03 1.1 --- test_win.py 2000/06/28 14:48:01 1.2 *************** *** 116,120 **** try: key = OpenKey(root_key, test_key_name) ! assert 0, "Could open the non-existant key" except WindowsError: # Use this error name this time pass --- 116,120 ---- try: key = OpenKey(root_key, test_key_name) ! assert 0, "Could open the non-existent key" except WindowsError: # Use this error name this time pass From python-dev@python.org Wed Jun 28 15:48:04 2000 From: python-dev@python.org (Jeremy Hylton) Date: Wed, 28 Jun 2000 07:48:04 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib Queue.py,1.10,1.11 binhex.py,1.12,1.13 calendar.py,1.15,1.16 fnmatch.py,1.7,1.8 locale.py,1.6,1.7 posixpath.py,1.30,1.31 sgmllib.py,1.19,1.20 site.py,1.11,1.12 urllib2.py,1.3,1.4 xmllib.py,1.18,1.19 Message-ID: <200006281448.HAA00808@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv723/Lib Modified Files: Queue.py binhex.py calendar.py fnmatch.py locale.py posixpath.py sgmllib.py site.py urllib2.py xmllib.py Log Message: typos fixed by Rob Hooft Index: Queue.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/Queue.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** Queue.py 2000/02/02 15:10:14 1.10 --- Queue.py 2000/06/28 14:48:01 1.11 *************** *** 120,124 **** return len(self.queue) ! # Check wheter the queue is empty def _empty(self): return not self.queue --- 120,124 ---- return len(self.queue) ! # Check whether the queue is empty def _empty(self): return not self.queue Index: binhex.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/binhex.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** binhex.py 2000/02/04 15:39:29 1.12 --- binhex.py 2000/06/28 14:48:01 1.13 *************** *** 14,18 **** # We seem to lack a simple character-translate in python. # (we should probably use ISO-Latin-1 on all but the mac platform). ! # XXXX The simeple routines are too simple: they expect to hold the complete # files in-core. Should be fixed. # XXXX It would be nice to handle AppleDouble format on unix --- 14,18 ---- # We seem to lack a simple character-translate in python. # (we should probably use ISO-Latin-1 on all but the mac platform). ! # XXXX The simple routines are too simple: they expect to hold the complete # files in-core. Should be fixed. # XXXX It would be nice to handle AppleDouble format on unix *************** *** 49,53 **** openrf = MacOS.openrf except AttributeError: ! # Backward compatability openrf = open --- 49,53 ---- openrf = MacOS.openrf except AttributeError: ! # Backward compatibility openrf = open Index: calendar.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/calendar.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** calendar.py 2000/02/02 15:10:14 1.15 --- calendar.py 2000/06/28 14:48:01 1.16 *************** *** 1,5 **** """Calendar printing functions""" ! # Revision 2: uses funtions from built-in time module # Import functions and variables from time module --- 1,5 ---- """Calendar printing functions""" ! # Revision 2: uses functions from built-in time module # Import functions and variables from time module Index: fnmatch.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/fnmatch.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** fnmatch.py 1997/10/22 20:57:40 1.7 --- fnmatch.py 2000/06/28 14:48:01 1.8 *************** *** 37,41 **** def fnmatchcase(name, pat): ! """Test wheter FILENAME matches PATTERN, including case. This is a version of fnmatch() which doesn't case-normalize --- 37,41 ---- def fnmatchcase(name, pat): ! """Test whether FILENAME matches PATTERN, including case. This is a version of fnmatch() which doesn't case-normalize Index: locale.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/locale.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** locale.py 2000/06/08 17:49:41 1.6 --- locale.py 2000/06/28 14:48:01 1.7 *************** *** 221,225 **** The language code corresponds to RFC 1766. code and encoding can be None in case the values cannot be determined or are ! unkown to this implementation. """ --- 221,225 ---- The language code corresponds to RFC 1766. code and encoding can be None in case the values cannot be determined or are ! unknown to this implementation. """ *************** *** 230,234 **** return None, None else: ! raise ValueError,'unkown locale: %s' % localename return l --- 230,234 ---- return None, None else: ! raise ValueError,'unknown locale: %s' % localename return l Index: posixpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/posixpath.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -r1.30 -r1.31 *** posixpath.py 2000/02/29 13:31:16 1.30 --- posixpath.py 2000/06/28 14:48:01 1.31 *************** *** 25,29 **** ! # Return wheter a path is absolute. # Trivial in Posix, harder on the Mac or MS-DOS. --- 25,29 ---- ! # Return whether a path is absolute. # Trivial in Posix, harder on the Mac or MS-DOS. *************** *** 305,309 **** # Expand paths containing shell variable substitutions. # This expands the forms $variable and ${variable} only. ! # Non-existant variables are left unchanged. _varprog = None --- 305,309 ---- # Expand paths containing shell variable substitutions. # This expands the forms $variable and ${variable} only. ! # Non-existent variables are left unchanged. _varprog = None Index: sgmllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sgmllib.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -r1.19 -r1.20 *** sgmllib.py 2000/02/04 15:28:40 1.19 --- sgmllib.py 2000/06/28 14:48:01 1.20 *************** *** 48,52 **** # (Tags are converted to lower case for this purpose.) The data # between tags is passed to the parser by calling self.handle_data() ! # with some data as argument (the data may be split up in arbutrary # chunks). Entity references are passed by calling # self.handle_entityref() with the entity reference as argument. --- 48,52 ---- # (Tags are converted to lower case for this purpose.) The data # between tags is passed to the parser by calling self.handle_data() ! # with some data as argument (the data may be split up in arbitrary # chunks). Entity references are passed by calling # self.handle_entityref() with the entity reference as argument. Index: site.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/site.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** site.py 2000/06/07 09:12:09 1.11 --- site.py 2000/06/28 14:48:01 1.12 *************** *** 123,127 **** # Set the string encoding used by the Unicode implementation to the # encoding used by the default locale of this system. If the default ! # encoding cannot be determined or is unkown, it defaults to 'ascii'. # def locale_aware_defaultencoding(): --- 123,127 ---- # Set the string encoding used by the Unicode implementation to the # encoding used by the default locale of this system. If the default ! # encoding cannot be determined or is unknown, it defaults to 'ascii'. # def locale_aware_defaultencoding(): Index: urllib2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib2.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** urllib2.py 2000/02/10 17:17:14 1.3 --- urllib2.py 2000/06/28 14:48:01 1.4 *************** *** 142,146 **** # do these error classes make sense? ! # make sure all of the IOError stuff is overriden. we just want to be # subtypes. --- 142,146 ---- # do these error classes make sense? ! # make sure all of the IOError stuff is overridden. we just want to be # subtypes. Index: xmllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xmllib.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** xmllib.py 2000/06/21 20:01:10 1.18 --- xmllib.py 2000/06/28 14:48:01 1.19 *************** *** 80,84 **** # and , respectively. The data between tags is passed to the # parser by calling self.handle_data() with some data as argument (the ! # data may be split up in arbutrary chunks). class XMLParser: --- 80,84 ---- # and , respectively. The data between tags is passed to the # parser by calling self.handle_data() with some data as argument (the ! # data may be split up in arbitrary chunks). class XMLParser: From python-dev@python.org Wed Jun 28 15:48:04 2000 From: python-dev@python.org (Jeremy Hylton) Date: Wed, 28 Jun 2000 07:48:04 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-irix5 CL_old.py,1.1,1.2 flp.py,1.17,1.18 panel.py,1.4,1.5 Message-ID: <200006281448.HAA00804@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/plat-irix5 In directory slayer.i.sourceforge.net:/tmp/cvs-serv723/Lib/plat-irix5 Modified Files: CL_old.py flp.py panel.py Log Message: typos fixed by Rob Hooft Index: CL_old.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/CL_old.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** CL_old.py 1995/05/17 11:18:22 1.1 --- CL_old.py 2000/06/28 14:48:01 1.2 *************** *** 201,205 **** # ! # SGI Proprietaty Algorithm Header Start Code # HEADER_START_CODE = 0xc1C0DEC --- 201,205 ---- # ! # SGI Proprietary Algorithm Header Start Code # HEADER_START_CODE = 0xc1C0DEC Index: flp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/flp.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** flp.py 1998/03/26 20:22:58 1.17 --- flp.py 2000/06/28 14:48:01 1.18 *************** *** 204,208 **** # # Internal: parse fd form, or skip if name doesn't match. ! # the special value None means 'allways parse it'. # def _parse_fd_form(file, name): --- 204,208 ---- # # Internal: parse fd form, or skip if name doesn't match. ! # the special value None means 'always parse it'. # def _parse_fd_form(file, name): *************** *** 223,227 **** # ! # Internal class: a convient place to store object info fields # class _newobj: --- 223,227 ---- # ! # Internal class: a convenient place to store object info fields # class _newobj: Index: panel.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/panel.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** panel.py 1995/09/18 22:00:37 1.4 --- panel.py 2000/06/28 14:48:01 1.5 *************** *** 3,7 **** # Support for the Panel library. # Uses built-in module 'pnl'. ! # Applciations should use 'panel.function' instead of 'pnl.function'; # most 'pnl' functions are transparently exported by 'panel', # but dopanel() is overridden and you have to use this version --- 3,7 ---- # Support for the Panel library. # Uses built-in module 'pnl'. ! # Applications should use 'panel.function' instead of 'pnl.function'; # most 'pnl' functions are transparently exported by 'panel', # but dopanel() is overridden and you have to use this version *************** *** 138,142 **** ! # Build a real actuator from an actuator descriptior. # Return a pair (actuator, name). # --- 138,142 ---- ! # Build a real actuator from an actuator description. # Return a pair (actuator, name). # From python-dev@python.org Wed Jun 28 15:48:04 2000 From: python-dev@python.org (Jeremy Hylton) Date: Wed, 28 Jun 2000 07:48:04 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_al.py,1.2,1.3 test_b1.py,1.22,1.23 test_cd.py,1.2,1.3 test_cl.py,1.2,1.3 test_pwd.py,1.5,1.6 test_winreg.py,1.2,1.3 test_zlib.py,1.7,1.8 Message-ID: <200006281448.HAA00821@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv723/Lib/test Modified Files: test_al.py test_b1.py test_cd.py test_cl.py test_pwd.py test_winreg.py test_zlib.py Log Message: typos fixed by Rob Hooft Index: test_al.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_al.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** test_al.py 1998/03/26 19:41:38 1.2 --- test_al.py 2000/06/28 14:48:01 1.3 *************** *** 9,13 **** 'newconfig', 'openport', 'queryparams', 'setparams'] ! # This is a very inobstrusive test for the existance of the al module and all it's # attributes. More comprehensive examples can be found in Demo/al --- 9,13 ---- 'newconfig', 'openport', 'queryparams', 'setparams'] ! # This is a very unobtrusive test for the existence of the al module and all it's # attributes. More comprehensive examples can be found in Demo/al Index: test_b1.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_b1.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** test_b1.py 2000/04/14 19:13:22 1.22 --- test_b1.py 2000/06/28 14:48:01 1.23 *************** *** 271,275 **** if int("10",16) <> 16L: raise TestFailed, 'int("10",16)' if int(u"10",16) <> 16L: raise TestFailed, 'int(u"10",16)' ! # Test conversion fron strings and various anomalies L = [ ('0', 0), --- 271,275 ---- if int("10",16) <> 16L: raise TestFailed, 'int("10",16)' if int(u"10",16) <> 16L: raise TestFailed, 'int(u"10",16)' ! # Test conversion from strings and various anomalies L = [ ('0', 0), Index: test_cd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_cd.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** test_cd.py 1998/03/26 19:41:49 1.2 --- test_cd.py 2000/06/28 14:48:01 1.3 *************** *** 11,15 **** ! # This is a very inobstrusive test for the existance of the cd module and all it's # attributes. More comprehensive examples can be found in Demo/cd and # require that you have a CD and a CD ROM drive --- 11,15 ---- ! # This is a very inobtrusive test for the existence of the cd module and all it's # attributes. More comprehensive examples can be found in Demo/cd and # require that you have a CD and a CD ROM drive Index: test_cl.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_cl.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** test_cl.py 1998/03/26 19:41:52 1.2 --- test_cl.py 2000/06/28 14:48:01 1.3 *************** *** 64,68 **** ! # This is a very inobstrusive test for the existance of the cl # module and all it's attributes. --- 64,68 ---- ! # This is a very inobtrusive test for the existence of the cl # module and all it's attributes. Index: test_pwd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pwd.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** test_pwd.py 1998/03/26 19:42:32 1.5 --- test_pwd.py 2000/06/28 14:48:01 1.6 *************** *** 60,64 **** print 'fakename', fakename, 'did not except pwd.getpwnam()' ! # Choose a non-existant uid. fakeuid = 4127 while byuids.has_key(fakeuid): --- 60,64 ---- print 'fakename', fakename, 'did not except pwd.getpwnam()' ! # Choose a non-existent uid. fakeuid = 4127 while byuids.has_key(fakeuid): Index: test_winreg.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_winreg.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** test_winreg.py 2000/04/01 05:25:57 1.2 --- test_winreg.py 2000/06/28 14:48:01 1.3 *************** *** 116,120 **** try: key = OpenKey(root_key, test_key_name) ! assert 0, "Could open the non-existant key" except WindowsError: # Use this error name this time pass --- 116,120 ---- try: key = OpenKey(root_key, test_key_name) ! assert 0, "Could open the non-existent key" except WindowsError: # Use this error name this time pass Index: test_zlib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_zlib.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** test_zlib.py 2000/02/10 15:31:07 1.7 --- test_zlib.py 2000/06/28 14:48:01 1.8 *************** *** 12,16 **** file.close() ! # test the chucksums (hex so the test doesn't break on 64-bit machines) print hex(zlib.crc32('penguin')), hex(zlib.crc32('penguin', 1)) print hex(zlib.adler32('penguin')), hex(zlib.adler32('penguin', 1)) --- 12,16 ---- file.close() ! # test the checksums (hex so the test doesn't break on 64-bit machines) print hex(zlib.crc32('penguin')), hex(zlib.crc32('penguin', 1)) print hex(zlib.adler32('penguin')), hex(zlib.adler32('penguin', 1)) From python-dev@python.org Wed Jun 28 16:07:40 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 08:07:40 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libatexit.tex,NONE,1.1 libsys.tex,1.35,1.36 lib.tex,1.152,1.153 Message-ID: <200006281507.IAA08342@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv8272/Doc/lib Modified Files: libsys.tex lib.tex Added Files: libatexit.tex Log Message: Added the atexit module and documentation from Skip Montanaro . Revisions to the markup to make it pass LaTeX, added an index entry and a reference from the sys.exitfunc documentation. This closes SourceForge patch #100620. --- NEW FILE --- \section{\module{atexit} --- exit handlers} \declaremodule{standard}{atexit} \moduleauthor{Skip Montanaro}{skip@mojam.com} \sectionauthor{Skip Montanaro}{skip@mojam.com} \modulesynopsis{Register and execute cleanup functions.} The \module{atexit} module defines a single function to register cleanup functions. Functions thus registered are automatically executed upon normal interpreter termination. Note: the functions registered via this module are not called when the program is killed by a signal, when a Python fatal internal error is detected, or when \code{os._exit()} is called. This is an alternate interface to the functionality provided by the \code{sys.exitfunc} variable. \withsubitem{(in sys)}{\ttindex{exitfunc}} \begin{funcdesc}{register}{func\optional{, *args\optional{, **kargs}}} Register \var{func} as a function to be executed at termination. Any optional arguments that are to be passed to \var{func} must be passed as arguments to \function{register()}. At normal program termination (for instance, if \function{sys.exit()} is called or the main module's execution completes), all functions registered are called in last in, first out order. The assumption is that lower level modules will normally be imported before higher level modules and thus must be cleaned up later. \end{funcdesc} \subsection{\module{atexit} Example \label{atexit-example}} The following simple example demonstrates how a module can initialize a counter from a file when it is imported and save the counter's updated value automatically when the program terminates without relying on the application making an explicit call into this module at termination. \begin{verbatim} try: _count = int(open("/tmp/counter").read()) except IOError: _count = 0 def incrcounter(n): global _count _count = _count + n def savecounter(): open("/tmp/counter", "w").write("%d" % _count) import atexit atexit.register(savecounter) \end{verbatim} Index: libsys.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsys.tex,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -r1.35 -r1.36 *** libsys.tex 2000/04/13 17:51:58 1.35 --- libsys.tex 2000/06/28 15:07:30 1.36 *************** *** 128,132 **** the user (or by a program) to specify a clean-up action at program exit. When set, it should be a parameterless function. This function ! will be called when the interpreter exits. Note: the exit function is not called when the program is killed by a signal, when a Python fatal internal error is detected, or when \code{os._exit()} is called. --- 128,134 ---- the user (or by a program) to specify a clean-up action at program exit. When set, it should be a parameterless function. This function ! will be called when the interpreter exits. Only one function may be ! installed in this way; to allow multiple functions which will be called ! at termination, use the \refmodule{atexit} module. Note: the exit function is not called when the program is killed by a signal, when a Python fatal internal error is detected, or when \code{os._exit()} is called. Index: lib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/lib.tex,v retrieving revision 1.152 retrieving revision 1.153 diff -C2 -r1.152 -r1.153 *** lib.tex 2000/06/13 20:51:29 1.152 --- lib.tex 2000/06/28 15:07:30 1.153 *************** *** 74,77 **** --- 74,78 ---- \input{libpython} % Python Services \input{libsys} + \input{libatexit} \input{libtypes} \input{libuserdict} From python-dev@python.org Wed Jun 28 16:07:40 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 08:07:40 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_atexit,NONE,1.1 Message-ID: <200006281507.IAA08349@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv8272/Lib/test/output Added Files: test_atexit Log Message: Added the atexit module and documentation from Skip Montanaro . Revisions to the markup to make it pass LaTeX, added an index entry and a reference from the sys.exitfunc documentation. This closes SourceForge patch #100620. --- NEW FILE --- test_atexit handler2 (7,) {'kw': 'abc'} handler2 () {} handler1 From python-dev@python.org Wed Jun 28 16:07:40 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 08:07:40 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_atexit.py,NONE,1.1 Message-ID: <200006281507.IAA08346@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv8272/Lib/test Added Files: test_atexit.py Log Message: Added the atexit module and documentation from Skip Montanaro . Revisions to the markup to make it pass LaTeX, added an index entry and a reference from the sys.exitfunc documentation. This closes SourceForge patch #100620. --- NEW FILE --- # Test the exit module from test_support import verbose import atexit def handler1(): print "handler1" def handler2(*args, **kargs): print "handler2", args, kargs # save any exit functions that may have been registered as part of the # test framework _exithandlers = atexit._exithandlers atexit._exithandlers = [] atexit.register(handler1) atexit.register(handler2) atexit.register(handler2, 7, kw="abc") # simulate exit behavior by calling atexit._run_exitfuncs directly... atexit._run_exitfuncs() # restore exit handlers atexit._exithandlers = _exithandlers From python-dev@python.org Wed Jun 28 16:07:40 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 08:07:40 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc Makefile.deps,1.32,1.33 Message-ID: <200006281507.IAA08340@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc In directory slayer.i.sourceforge.net:/tmp/cvs-serv8272/Doc Modified Files: Makefile.deps Log Message: Added the atexit module and documentation from Skip Montanaro . Revisions to the markup to make it pass LaTeX, added an index entry and a reference from the sys.exitfunc documentation. This closes SourceForge patch #100620. Index: Makefile.deps =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile.deps,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -r1.32 -r1.33 *** Makefile.deps 2000/06/13 20:51:29 1.32 --- Makefile.deps 2000/06/28 15:07:31 1.33 *************** *** 229,232 **** --- 229,233 ---- ../lib/libtty.tex \ ../lib/libasyncore.tex \ + ../lib/libatexit.tex \ ../lib/libcfgparser.tex From python-dev@python.org Wed Jun 28 16:07:40 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 08:07:40 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib atexit.py,NONE,1.1 Message-ID: <200006281507.IAA08343@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv8272/Lib Added Files: atexit.py Log Message: Added the atexit module and documentation from Skip Montanaro . Revisions to the markup to make it pass LaTeX, added an index entry and a reference from the sys.exitfunc documentation. This closes SourceForge patch #100620. --- NEW FILE --- """ atexit.py - allow programmer to define multiple exit functions to be executed upon normal program termination. One public function, register, is defined. """ _exithandlers = [] def _run_exitfuncs(): """run any registered exit functions _exithandlers is traversed in reverse order so functions are executed last in, first out. """ while _exithandlers: func, targs, kargs = _exithandlers[-1] apply(func, targs, kargs) _exithandlers.remove(_exithandlers[-1]) def register(func, *targs, **kargs): """register a function to be executed upon normal program termination func - function to be called at exit targs - optional arguments to pass to func kargs - optional keyword arguments to pass to func """ _exithandlers.append((func, targs, kargs)) import sys try: x = sys.exitfunc except AttributeError: sys.exitfunc = _run_exitfuncs else: # if x isn't our own exit func executive, assume it's another # registered exit function - append it to our list... if x != _run_exitfuncs: register(x) del sys if __name__ == "__main__": def x1(): print "running x1" def x2(n): print "running x2(%s)" % `n` def x3(n, kwd=None): print "running x3(%s, kwd=%s)" % (`n`, `kwd`) register(x1) register(x2, 12) register(x3, 5, "bar") register(x3, "no kwd args") From python-dev@python.org Wed Jun 28 16:32:32 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 08:32:32 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/ext ext.tex,1.75,1.76 Message-ID: <200006281532.IAA10093@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/ext In directory slayer.i.sourceforge.net:/tmp/cvs-serv10086/ext Modified Files: ext.tex Log Message: Added memory-reference information to the description of Py_BuildValue(), based on comments from Frank Stajano . Index: ext.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/ext.tex,v retrieving revision 1.75 retrieving revision 1.76 diff -C2 -r1.75 -r1.76 *** ext.tex 2000/05/10 20:36:34 1.75 --- ext.tex 2000/06/28 15:32:29 1.76 *************** *** 1002,1005 **** --- 1002,1010 ---- parenthesize the format string. + When memory buffers are passed as parameters to supply data to build + objects, as for the \samp{s} and \samp{s\#} formats, the required data + is copied. Buffers provided by the caller are never referenced by the + objects created by \cfunction{Py_BuildValue()}. + In the following description, the quoted form is the format unit; the entry in (round) parentheses is the Python object type that the format *************** *** 1015,1019 **** \item[\samp{s} (string) {[char *]}] Convert a null-terminated C string to a Python object. If the C ! string pointer is \NULL{}, \code{None} is returned. \item[\samp{s\#} (string) {[char *, int]}] --- 1020,1024 ---- \item[\samp{s} (string) {[char *]}] Convert a null-terminated C string to a Python object. If the C ! string pointer is \NULL{}, \code{None} is used. \item[\samp{s\#} (string) {[char *, int]}] From python-dev@python.org Wed Jun 28 16:53:17 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 08:53:17 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/api api.tex,1.68,1.69 Message-ID: <200006281553.IAA11238@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/api In directory slayer.i.sourceforge.net:/tmp/cvs-serv11228/api Modified Files: api.tex Log Message: Added documentation for PyOS_AfterFork(). Index: api.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/api.tex,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -r1.68 -r1.69 *** api.tex 2000/06/18 05:21:21 1.68 --- api.tex 2000/06/28 15:53:13 1.69 *************** *** 1034,1037 **** --- 1034,1044 ---- \end{cfuncdesc} + \begin{cfuncdesc}{void}{PyOS_AfterFork}{} + Function to update some internal state after a process fork; this + should be called in the new process if the Python interpreter will + continue to be used. If a new executable is loaded into the new + process, this function does not need to be called. + \end{cfuncdesc} + \section{Process Control \label{processControl}} From python-dev@python.org Wed Jun 28 17:15:10 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 09:15:10 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/ext ext.tex,1.76,1.77 Message-ID: <200006281615.JAA18538@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/ext In directory slayer.i.sourceforge.net:/tmp/cvs-serv18530/ext Modified Files: ext.tex Log Message: Enhanced memory-reference information in the description of Py_BuildValue(), based on response from Frank Stajano . Index: ext.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/ext.tex,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -r1.76 -r1.77 *** ext.tex 2000/06/28 15:32:29 1.76 --- ext.tex 2000/06/28 16:15:08 1.77 *************** *** 1005,1009 **** objects, as for the \samp{s} and \samp{s\#} formats, the required data is copied. Buffers provided by the caller are never referenced by the ! objects created by \cfunction{Py_BuildValue()}. In the following description, the quoted form is the format unit; the --- 1005,1013 ---- objects, as for the \samp{s} and \samp{s\#} formats, the required data is copied. Buffers provided by the caller are never referenced by the ! objects created by \cfunction{Py_BuildValue()}. In other words, if ! your code invokes \cfunction{malloc()} and passes the allocated memory ! to \cfunction{Py_BuildValue()}, your code is responsible for ! calling \cfunction{free()} for that memory once ! \cfunction{Py_BuildValue()} returns. In the following description, the quoted form is the format unit; the From python-dev@python.org Wed Jun 28 17:37:27 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 28 Jun 2000 09:37:27 -0700 Subject: [Python-checkins] CVS: python/dist/src/Include ucnhash.h,NONE,1.1 Message-ID: <200006281637.JAA20224@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Include In directory slayer.i.sourceforge.net:/tmp/cvs-serv20217/Include Added Files: ucnhash.h Log Message: Marc-Andre Lemburg : Exports the C API of the new ucnhash module. By Bill Tutt. --- NEW FILE --- #include #include /* --- C API ----------------------------------------------------*/ /* C API for usage by other Python modules */ typedef struct _Py_UCNHashAPI { unsigned long cKeys; unsigned long cchMax; unsigned long (*hash)(const char *key, unsigned int cch); const void *(*getValue)(unsigned long iKey); } _Py_UCNHashAPI; typedef struct { const char *pszUCN; unsigned int uiValue; } _Py_UnicodeCharacterName; From python-dev@python.org Wed Jun 28 17:38:58 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 28 Jun 2000 09:38:58 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules ucnhash.c,NONE,1.1 Message-ID: <200006281638.JAA20368@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv20335/Modules Added Files: ucnhash.c Log Message: Marc-Andre Lemburg : New ucnhash module by Bill Tutt. This module contains the hash table needed to map Unicode character names to Unicode ordinals and is loaded on-the-fly by the standard unicode-escape codec. --- NEW FILE --- #include /* * The hash is produced using the algorithm described in * "Optimal algorithms for minimal perfect hashing", * G. Havas, B.S. Majewski. Available as a technical report * from the CS department, University of Queensland * (ftp://ftp.cs.uq.oz.au/). * * Generated using a heavily tweaked version of Andrew Kuchling's * perfect_hash.py: * http://starship.python.net/crew/amk/python/code/perfect-hash.html * * Generated on: Wed Jun 28 03:34:07 2000 */ #define k_cHashElements 18836 #define k_cchMaxKey 83 #define k_cKeys 10538 [...12173 lines suppressed...] { "FULLWIDTH POUND SIGN", 0xffe1 }, { "FULLWIDTH NOT SIGN", 0xffe2 }, { "FULLWIDTH MACRON", 0xffe3 }, { "FULLWIDTH BROKEN BAR", 0xffe4 }, { "FULLWIDTH YEN SIGN", 0xffe5 }, { "FULLWIDTH WON SIGN", 0xffe6 }, { "HALFWIDTH FORMS LIGHT VERTICAL", 0xffe8 }, { "HALFWIDTH LEFTWARDS ARROW", 0xffe9 }, { "HALFWIDTH UPWARDS ARROW", 0xffea }, { "HALFWIDTH RIGHTWARDS ARROW", 0xffeb }, { "HALFWIDTH DOWNWARDS ARROW", 0xffec }, { "HALFWIDTH BLACK SQUARE", 0xffed }, { "HALFWIDTH WHITE CIRCLE", 0xffee }, { "INTERLINEAR ANNOTATION ANCHOR", 0xfff9 }, { "INTERLINEAR ANNOTATION SEPARATOR", 0xfffa }, { "INTERLINEAR ANNOTATION TERMINATOR", 0xfffb }, { "OBJECT REPLACEMENT CHARACTER", 0xfffc }, { "REPLACEMENT CHARACTER", 0xfffd }, }; From python-dev@python.org Wed Jun 28 17:40:12 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 28 Jun 2000 09:40:12 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild ucnhash.dsp,NONE,1.1 Message-ID: <200006281640.JAA20477@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv20468/PCbuild Added Files: ucnhash.dsp Log Message: Marc-Andre Lemburg : MSVC project file for the new module ucnhash. This may have to be added to pcbuild.dsw with an dependancy on python16. By Bill Tutt. --- NEW FILE --- # Microsoft Developer Studio Project File - Name="ucnhash" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=ucnhash - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "ucnhash.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "ucnhash.mak" CFG="ucnhash - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "ucnhash - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "ucnhash - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "ucnhash - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "ucnhash___Win32_Release0" # PROP BASE Intermediate_Dir "ucnhash___Win32_Release0" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "ucnhash___Win32_Release0" # PROP Intermediate_Dir "ucnhash___Win32_Release0" # PROP Target_Dir "" F90=df.exe # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UCNHASH_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UCNHASH_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo 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 /dll /machine:I386 # ADD 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 /dll /machine:I386 !ELSEIF "$(CFG)" == "ucnhash - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "ucnhash___Win32_Debug0" # PROP BASE Intermediate_Dir "ucnhash___Win32_Debug0" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "ucnhash___Win32_Debug0" # PROP Intermediate_Dir "ucnhash___Win32_Debug0" # PROP Target_Dir "" F90=df.exe # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UCNHASH_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UCNHASH_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo 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 /dll /debug /machine:I386 /pdbtype:sept # ADD 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 /dll /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "ucnhash - Win32 Release" # Name "ucnhash - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project From python-dev@python.org Wed Jun 28 17:41:49 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 28 Jun 2000 09:41:49 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_unicode,1.6,1.7 Message-ID: <200006281641.JAA20670@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv20577/Lib/test/output Modified Files: test_unicode Log Message: Marc-Andre Lemburg : Updated test output. Index: test_unicode =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_unicode,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** test_unicode 2000/04/13 14:10:04 1.6 --- test_unicode 2000/06/28 16:41:46 1.7 *************** *** 6,7 **** --- 6,10 ---- Testing standard mapping codecs... 0-127... 128-255... done. Testing Unicode string concatenation... done. + Testing General Unicode Character Name, and case insensitivity... done. + Testing misc. symbols for unicode character name expansion.... done. + Testing unicode character name expansion strict error handling.... done. From python-dev@python.org Wed Jun 28 17:42:16 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 28 Jun 2000 09:42:16 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules Makefile.pre.in,1.61,1.62 Message-ID: <200006281642.JAA20693@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv20682/Modules Modified Files: Makefile.pre.in Log Message: Marc-Andre Lemburg : Added new ucnhash module. Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Makefile.pre.in,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -r1.61 -r1.62 *** Makefile.pre.in 2000/03/10 23:12:33 1.61 --- Makefile.pre.in 2000/06/28 16:42:14 1.62 *************** *** 223,226 **** --- 223,227 ---- unicodedata.o: unicodedata.c unicodedatabase.o unicodedatabase.o: unicodedatabase.c unicodedatabase.h + ucnhash.o: ucnhash.c xxmodule.o: xxmodule.c yuvconvert.o: yuvconvert.c From python-dev@python.org Wed Jun 28 17:42:41 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 28 Jun 2000 09:42:41 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules Setup.in,1.102,1.103 Message-ID: <200006281642.JAA20715@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv20708/Modules Modified Files: Setup.in Log Message: Marc-Andre Lemburg : Added new ucnhash module by Bill Tutt. Index: Setup.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Setup.in,v retrieving revision 1.102 retrieving revision 1.103 diff -C2 -r1.102 -r1.103 *** Setup.in 2000/06/10 23:12:32 1.102 --- Setup.in 2000/06/28 16:42:39 1.103 *************** *** 140,143 **** --- 140,144 ---- unicodedata unicodedata.c unicodedatabase.c # static Unicode character database + ucnhash ucnhash.c # Unicode Character Name expansion hash table _locale _localemodule.c # access to ISO C locale support From python-dev@python.org Wed Jun 28 17:43:37 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 28 Jun 2000 09:43:37 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.29,2.30 Message-ID: <200006281643.JAA20750@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv20739/Objects Modified Files: unicodeobject.c Log Message: Marc-Andre Lemburg : Patch to the standard unicode-escape codec which dynamically loads the Unicode name to ordinal mapping from the module ucnhash. By Bill Tutt. Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.29 retrieving revision 2.30 diff -C2 -r2.29 -r2.30 *** unicodeobject.c 2000/06/28 08:11:47 2.29 --- unicodeobject.c 2000/06/28 16:43:35 2.30 *************** *** 67,70 **** --- 67,71 ---- #include "mymath.h" #include "unicodeobject.h" + #include #if defined(HAVE_LIMITS_H) *************** *** 1021,1024 **** --- 1022,1047 ---- } + static _Py_UCNHashAPI *pucnHash = NULL; + + static + int mystrnicmp(const char *s1, const char *s2, size_t count) + { + char c1, c2; + + if (count) + { + do + { + c1 = tolower(*(s1++)); + c2 = tolower(*(s2++)); + } + while(--count && c1 == c2); + + return c1 - c2; + } + + return 0; + } + PyObject *PyUnicode_DecodeUnicodeEscape(const char *s, int size, *************** *** 1124,1127 **** --- 1147,1248 ---- break; + case 'N': + /* Ok, we need to deal with Unicode Character Names now, + * make sure we've imported the hash table data... + */ + if (pucnHash == NULL) + { + PyObject *mod = 0, *v = 0; + + mod = PyImport_ImportModule("ucnhash"); + if (mod == NULL) + goto onError; + v = PyObject_GetAttrString(mod,"ucnhashAPI"); + Py_DECREF(mod); + if (v == NULL) + { + goto onError; + } + pucnHash = PyCObject_AsVoidPtr(v); + Py_DECREF(v); + if (pucnHash == NULL) + { + goto onError; + } + } + + if (*s == '{') + { + const char *start = s + 1; + const char *endBrace = start; + unsigned int uiValue; + unsigned long j; + + /* look for either the closing brace, or we + * exceed the maximum length of the unicode character names + */ + while (*endBrace != '}' && + (unsigned int)(endBrace - start) <= + pucnHash->cchMax && + endBrace < end) + { + endBrace++; + } + if (endBrace != end && *endBrace == '}') + { + j = pucnHash->hash(start, endBrace - start); + if (j > pucnHash->cKeys || + mystrnicmp( + start, + ((_Py_UnicodeCharacterName *) + (pucnHash->getValue(j)))->pszUCN, + (int)(endBrace - start)) != 0) + { + if (unicodeescape_decoding_error( + &s, &x, errors, + "Invalid Unicode Character Name")) + { + goto onError; + } + goto ucnFallthrough; + } + uiValue = ((_Py_UnicodeCharacterName *) + (pucnHash->getValue(j)))->uiValue; + if (uiValue < 1<<16) + { + /* In UCS-2 range, easy solution.. */ + *p++ = uiValue; + } + else + { + /* Oops, its in UCS-4 space, */ + /* compute and append the two surrogates: */ + /* translate from 10000..10FFFF to 0..FFFFF */ + uiValue -= 0x10000; + + /* high surrogate = top 10 bits added to D800 */ + *p++ = 0xD800 + (uiValue >> 10); + + /* low surrogate = bottom 10 bits added to DC00 */ + *p++ = 0xDC00 + (uiValue & ~0xFC00); + } + s = endBrace + 1; + } + else + { + if (unicodeescape_decoding_error( + &s, &x, errors, + "Unicode name missing closing brace")) + goto onError; + goto ucnFallthrough; + } + break; + } + if (unicodeescape_decoding_error( + &s, &x, errors, + "Missing opening brace for Unicode Character Name escape")) + goto onError; + ucnFallthrough: + /* fall through on purpose */ default: *p++ = '\\'; From python-dev@python.org Wed Jun 28 17:40:40 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 09:40:40 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules posixmodule.c,2.136,2.137 Message-ID: <200006281640.JAA20510@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv20497/Modules Modified Files: posixmodule.c Log Message: Thomas Wouters : This patch adds the openpty() and forkpty() library calls to posixmodule.c, when they are available on the target system. (glibc-2.1-based Linux systems, FreeBSD and BSDI at least, probably the other BSD-based systems as well.) Lib/pty.py is also rewritten to use openpty when available, but falls back to the old SGI method or the "manual" BSD open-a-pty code. Openpty() is necessary to use the Unix98 ptys under Linux 2.2, or when using non-standard tty names under (at least) BSDI, which is why I needed it, myself ;-) forkpty() is included for symmetry. Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.136 retrieving revision 2.137 diff -C2 -r2.136 -r2.137 *** posixmodule.c 2000/06/06 20:52:17 2.136 --- posixmodule.c 2000/06/28 16:40:38 2.137 *************** *** 1732,1735 **** --- 1732,1793 ---- #endif + #if defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) + #ifdef HAVE_PTY_H + #include + #else + #ifdef HAVE_LIBUTIL_H + #include + #else + /* BSDI does not supply a prototype for the 'openpty' and 'forkpty' + functions, eventhough they are included in libutil. */ + #include + extern int openpty(int *, int *, char *, struct termios *, struct winsize *); + extern int forkpty(int *, char *, struct termios *, struct winsize *); + #endif /* HAVE_LIBUTIL_H */ + #endif /* HAVE_PTY_H */ + #endif /* defined(HAVE_OPENPTY) or defined(HAVE_FORKPTY) */ + + #ifdef HAVE_OPENPTY + static char posix_openpty__doc__[] = + "openpty() -> (master_fd, slave_fd)\n\ + Open a pseudo-terminal, returning open fd's for both master and slave end.\n"; + + static PyObject * + posix_openpty(self, args) + PyObject *self; + PyObject *args; + { + int master_fd, slave_fd; + if (!PyArg_ParseTuple(args, ":openpty")) + return NULL; + if (openpty(&master_fd, &slave_fd, NULL, NULL, NULL) != 0) + return posix_error(); + return Py_BuildValue("(ii)", master_fd, slave_fd); + } + #endif + + #ifdef HAVE_FORKPTY + static char posix_forkpty__doc__[] = + "forkpty() -> (pid, master_fd)\n\ + Fork a new process with a new pseudo-terminal as controlling tty.\n\n\ + Like fork(), return 0 as pid to child process, and PID of child to parent.\n\ + To both, return fd of newly opened pseudo-terminal.\n"; + + static PyObject * + posix_forkpty(self, args) + PyObject *self; + PyObject *args; + { + int master_fd, pid; + + if (!PyArg_ParseTuple(args, ":forkpty")) + return NULL; + pid = forkpty(&master_fd, NULL, NULL, NULL); + if (pid == -1) + return posix_error(); + PyOS_AfterFork(); + return Py_BuildValue("(ii)", pid, master_fd); + } + #endif #ifdef HAVE_GETEGID *************** *** 4515,4518 **** --- 4573,4582 ---- {"fork", posix_fork, METH_VARARGS, posix_fork__doc__}, #endif /* HAVE_FORK */ + #ifdef HAVE_OPENPTY + {"openpty", posix_openpty, METH_VARARGS, posix_openpty__doc__}, + #endif /* HAVE_OPENPTY */ + #ifdef HAVE_FORKPTY + {"forkpty", posix_forkpty, METH_VARARGS, posix_forkpty__doc__}, + #endif /* HAVE_FORKPTY */ #ifdef HAVE_GETEGID {"getegid", posix_getegid, METH_VARARGS, posix_getegid__doc__}, From python-dev@python.org Wed Jun 28 17:40:41 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 09:40:41 -0700 Subject: [Python-checkins] CVS: python/dist/src configure,1.117,1.118 configure.in,1.125,1.126 Message-ID: <200006281640.JAA20519@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv20497 Modified Files: configure configure.in Log Message: Thomas Wouters : This patch adds the openpty() and forkpty() library calls to posixmodule.c, when they are available on the target system. (glibc-2.1-based Linux systems, FreeBSD and BSDI at least, probably the other BSD-based systems as well.) Lib/pty.py is also rewritten to use openpty when available, but falls back to the old SGI method or the "manual" BSD open-a-pty code. Openpty() is necessary to use the Unix98 ptys under Linux 2.2, or when using non-standard tty names under (at least) BSDI, which is why I needed it, myself ;-) forkpty() is included for symmetry. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.117 retrieving revision 1.118 diff -C2 -r1.117 -r1.118 *** configure 2000/06/18 15:07:39 1.117 --- configure 2000/06/28 16:40:38 1.118 *************** *** 4,8 **** # Guess values for system-dependent variables and create Makefiles. ! # Generated automatically using autoconf version 2.13 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # --- 4,8 ---- # Guess values for system-dependent variables and create Makefiles. ! # Generated automatically using autoconf version 2.14.1 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. [...3885 lines suppressed...] ! echo "$CONFIG_STATUS generated by autoconf version 2.13" exit 0 ;; -help | --help | --hel | --he | --h) --- 5673,5677 ---- exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) ! echo "$CONFIG_STATUS generated by autoconf version 2.14.1" exit 0 ;; -help | --help | --hel | --he | --h) *************** *** 5746,5749 **** chmod +x $CONFIG_STATUS rm -fr confdefs* $ac_clean_files ! test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 --- 5971,5974 ---- chmod +x $CONFIG_STATUS rm -fr confdefs* $ac_clean_files ! test "$no_create" = yes || $SHELL $CONFIG_STATUS || exit 1 Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.125 retrieving revision 1.126 diff -C2 -r1.125 -r1.126 *** configure.in 2000/06/18 14:54:13 1.125 --- configure.in 2000/06/28 16:40:38 1.126 *************** *** 358,362 **** sys/audioio.h sys/file.h sys/lock.h \ sys/param.h sys/select.h sys/socket.h sys/time.h sys/times.h \ ! sys/un.h sys/utsname.h sys/wait.h) AC_HEADER_DIRENT --- 358,362 ---- sys/audioio.h sys/file.h sys/lock.h \ sys/param.h sys/select.h sys/socket.h sys/time.h sys/times.h \ ! sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h) AC_HEADER_DIRENT *************** *** 771,774 **** --- 771,779 ---- tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \ truncate uname waitpid) + + # check for openpty and forkpty + + AC_CHECK_FUNCS(openpty,, AC_CHECK_LIB(util,openpty, [AC_DEFINE(HAVE_OPENPTY)] [LIBS="$LIBS -lutil"])) + AC_CHECK_FUNCS(forkpty,, AC_CHECK_LIB(util,forkpty, [AC_DEFINE(HAVE_FORKPTY)] [LIBS="$LIBS -lutil"])) # check for long file support functions From python-dev@python.org Wed Jun 28 17:40:47 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 28 Jun 2000 09:40:47 -0700 Subject: [Python-checkins] CVS: python/dist/src/Tools/perfecthash - New directory Message-ID: <200006281640.JAA20543@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Tools/perfecthash In directory slayer.i.sourceforge.net:/tmp/cvs-serv20531/Tools/perfecthash Log Message: Directory /cvsroot/python/python/dist/src/Tools/perfecthash added to the repository From python-dev@python.org Wed Jun 28 17:40:40 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 09:40:40 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib pty.py,1.3,1.4 Message-ID: <200006281640.JAA20514@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv20497/Lib Modified Files: pty.py Log Message: Thomas Wouters : This patch adds the openpty() and forkpty() library calls to posixmodule.c, when they are available on the target system. (glibc-2.1-based Linux systems, FreeBSD and BSDI at least, probably the other BSD-based systems as well.) Lib/pty.py is also rewritten to use openpty when available, but falls back to the old SGI method or the "manual" BSD open-a-pty code. Openpty() is necessary to use the Unix98 ptys under Linux 2.2, or when using non-standard tty names under (at least) BSDI, which is why I needed it, myself ;-) forkpty() is included for symmetry. Index: pty.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pty.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** pty.py 2000/02/04 15:10:34 1.3 --- pty.py 2000/06/28 16:40:38 1.4 *************** *** 17,23 **** CHILD = 0 def master_open(): """Open pty master and return (master_fd, tty_name). ! SGI and Linux/BSD version.""" try: import sgi --- 17,51 ---- CHILD = 0 + def openpty(): + """openpty() -> (master_fd, slave_fd) + Open a pty master/slave pair, using os.openpty() if possible.""" + + try: + return os.openpty() + except (AttributeError, OSError): + pass + master_fd, slave_name = _open_terminal() + slave_fd = _slave_open(slave_name) + return master_fd, slave_fd + def master_open(): + """master_open() -> (master_fd, slave_name) + Open a pty master and return the fd, and the filename of the slave end. + Deprecated, use openpty() instead.""" + + try: + master_fd, slave_fd = os.openpty() + except (AttributeError, OSError): + pass + else: + slave_name = os.ttyname(slave_fd) + os.close(slave_fd) + return master_fd, slave_name + + return _open_terminal() + + def _open_terminal(): """Open pty master and return (master_fd, tty_name). ! SGI and generic BSD version, for when openpty() fails.""" try: import sgi *************** *** 41,60 **** def slave_open(tty_name): ! """Open the pty slave and acquire the controlling terminal. ! Return the file descriptor. Linux version.""" ! # (Should be universal? --Guido) return os.open(tty_name, FCNTL.O_RDWR) def fork(): ! """Fork and make the child a session leader with a controlling terminal. ! Return (pid, master_fd).""" ! master_fd, tty_name = master_open() pid = os.fork() if pid == CHILD: # Establish a new session. os.setsid() - - # Acquire controlling terminal. - slave_fd = slave_open(tty_name) os.close(master_fd) --- 69,101 ---- def slave_open(tty_name): ! """slave_open(tty_name) -> slave_fd ! Open the pty slave and acquire the controlling terminal, returning ! opened filedescriptor. ! Deprecated, use openpty() instead.""" ! return os.open(tty_name, FCNTL.O_RDWR) def fork(): ! """fork() -> (pid, master_fd) ! Fork and make the child a session leader with a controlling terminal.""" ! ! try: ! pid, fd = os.forkpty() ! except (AttributeError, OSError): ! pass ! else: ! if pid == CHILD: ! try: ! os.setsid() ! except OSError: ! # os.forkpty() already set us session leader ! pass ! return pid, fd ! ! master_fd, slave_fd = openpty() pid = os.fork() if pid == CHILD: # Establish a new session. os.setsid() os.close(master_fd) *************** *** 69,73 **** return pid, master_fd ! def writen(fd, data): """Write all the data to a descriptor.""" while data != '': --- 110,114 ---- return pid, master_fd ! def _writen(fd, data): """Write all the data to a descriptor.""" while data != '': *************** *** 75,83 **** data = data[n:] ! def read(fd): """Default read function.""" return os.read(fd, 1024) ! def copy(master_fd, master_read=read, stdin_read=read): """Parent copy loop. Copies --- 116,124 ---- data = data[n:] ! def _read(fd): """Default read function.""" return os.read(fd, 1024) ! def _copy(master_fd, master_read=_read, stdin_read=_read): """Parent copy loop. Copies *************** *** 92,98 **** if STDIN_FILENO in rfds: data = stdin_read(STDIN_FILENO) ! writen(master_fd, data) ! def spawn(argv, master_read=read, stdin_read=read): """Create a spawned process.""" if type(argv) == type(''): --- 133,139 ---- if STDIN_FILENO in rfds: data = stdin_read(STDIN_FILENO) ! _writen(master_fd, data) ! def spawn(argv, master_read=_read, stdin_read=_read): """Create a spawned process.""" if type(argv) == type(''): *************** *** 104,108 **** tty.setraw(STDIN_FILENO) try: ! copy(master_fd, master_read, stdin_read) except: tty.tcsetattr(STDIN_FILENO, tty.TCSAFLUSH, mode) --- 145,149 ---- tty.setraw(STDIN_FILENO) try: ! _copy(master_fd, master_read, stdin_read) except: tty.tcsetattr(STDIN_FILENO, tty.TCSAFLUSH, mode) From python-dev@python.org Wed Jun 28 17:41:25 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 28 Jun 2000 09:41:25 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_unicode.py,1.14,1.15 Message-ID: <200006281641.JAA20571@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv20564/Lib/test Modified Files: test_unicode.py Log Message: Marc-Andre Lemburg : Added tests for the new Unicode character name support in the standard unicode-escape codec. Index: test_unicode.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** test_unicode.py 2000/06/14 09:17:25 1.14 --- test_unicode.py 2000/06/28 16:41:23 1.15 *************** *** 409,410 **** --- 409,485 ---- assert ("abc" "def" u"ghi") == u"abcdefghi" print 'done.' + + print 'Testing General Unicode Character Name, and case insensitivity...', + # General and case insensitivity test: + s = u"\N{LATIN CAPITAL LETTER T}" \ + u"\N{LATIN SMALL LETTER H}" \ + u"\N{LATIN SMALL LETTER E}" \ + u"\N{SPACE}" \ + u"\N{LATIN SMALL LETTER R}" \ + u"\N{LATIN CAPITAL LETTER E}" \ + u"\N{LATIN SMALL LETTER D}" \ + u"\N{SPACE}" \ + u"\N{LATIN SMALL LETTER f}" \ + u"\N{LATIN CAPITAL LeTtEr o}" \ + u"\N{LATIN SMaLl LETTER x}" \ + u"\N{SPACE}" \ + u"\N{LATIN SMALL LETTER A}" \ + u"\N{LATIN SMALL LETTER T}" \ + u"\N{LATIN SMALL LETTER E}" \ + u"\N{SPACE}" \ + u"\N{LATIN SMALL LETTER T}" \ + u"\N{LATIN SMALL LETTER H}" \ + u"\N{LATIN SMALL LETTER E}" \ + u"\N{SpAcE}" \ + u"\N{LATIN SMALL LETTER S}" \ + u"\N{LATIN SMALL LETTER H}" \ + u"\N{LATIN SMALL LETTER E}" \ + u"\N{LATIN SMALL LETTER E}" \ + u"\N{LATIN SMALL LETTER P}" \ + u"\N{FULL STOP}" + assert s == u"The rEd fOx ate the sheep.", s + print "done." + + # misc. symbol testing + print "Testing misc. symbols for unicode character name expansion....", + assert u"\N{PILCROW SIGN}" == u"\u00b6" + assert u"\N{REPLACEMENT CHARACTER}" == u"\uFFFD" + assert u"\N{HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK}" == u"\uFF9F" + assert u"\N{FULLWIDTH LATIN SMALL LETTER A}" == u"\uFF41" + print "done." + + + # strict error testing: + print "Testing unicode character name expansion strict error handling....", + k_cchMaxUnicodeName = 83 + + s = "\N{" + "1" * (k_cchMaxUnicodeName + 2) + "}" + try: + unicode(s, 'unicode-escape', 'strict') + except UnicodeError: + pass + else: + raise AssertionError, "failed to raise an exception when presented " \ + "with a UCN > k_cchMaxUnicodeName" + try: + unicode("\N{blah}", 'unicode-escape', 'strict') + except UnicodeError: + pass + else: + raise AssertionError, "failed to raise an exception when given a bogus character name" + + try: + unicode("\N{SPACE", 'unicode-escape', 'strict') + except UnicodeError: + pass + else: + raise AssertionError, "failed to raise an exception for a missing closing brace." + + try: + unicode("\NSPACE", 'unicode-escape', 'strict') + except UnicodeError: + pass + else: + raise AssertionError, "failed to raise an exception for a missing opening brace." + print "done." + From python-dev@python.org Wed Jun 28 17:48:07 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 28 Jun 2000 09:48:07 -0700 Subject: [Python-checkins] CVS: python/dist/src/Tools/perfecthash perfhash.c,NONE,1.1 Message-ID: <200006281648.JAA20984@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Tools/perfecthash In directory slayer.i.sourceforge.net:/tmp/cvs-serv20978/Tools/perfecthash Added Files: perfhash.c Log Message: Marc-Andre Lemburg : Utility extension module needed by perfect_hash.py By Bill Tutt. --- NEW FILE --- #include static PyObject * hashFunction(PyObject *self, PyObject *args, PyObject *kw) { PyStringObject *a; register int len; register unsigned char *p; register long x; long lSeed; unsigned long cchSeed; if (!PyArg_ParseTuple(args, "iiO:hash", &lSeed, &cchSeed, &a)) return NULL; if (!PyString_Check(a)) { PyErr_SetString(PyExc_TypeError, "arg 3 needs to be a string"); return NULL; } len = a->ob_size; p = (unsigned char *) a->ob_sval; x = lSeed; while (--len >= 0) x = (1000003*x) ^ *p++; x ^= a->ob_size + cchSeed; if (x == -1) x = -2; return PyInt_FromLong(x); } static PyObject * calcSeed(PyObject *self, PyObject *args, PyObject *kw) { PyStringObject *a; register int len; register unsigned char *p; register long x; if (!PyString_Check(args)) { PyErr_SetString(PyExc_TypeError, "arg 1 expected a string, but didn't get it."); return NULL; } a = (PyStringObject *)args; len = a->ob_size; p = (unsigned char *) a->ob_sval; x = *p << 7; while (--len >= 0) x = (1000003*x) ^ *p++; return PyInt_FromLong(x); } static struct PyMethodDef hashMethods[] = { { "calcSeed", calcSeed, 0, NULL }, { "hash", hashFunction, 0, NULL }, { NULL, NULL, 0, NULL } /* sentinel */ }; #ifdef _MSC_VER _declspec(dllexport) #endif void initperfhash() { PyObject *m; m = Py_InitModule4("perfhash", hashMethods, NULL, NULL, PYTHON_API_VERSION); if ( m == NULL ) Py_FatalError("can't initialize module hashModule"); } From python-dev@python.org Wed Jun 28 17:49:32 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 28 Jun 2000 09:49:32 -0700 Subject: [Python-checkins] CVS: python/dist/src/Tools/perfecthash GenUCNHash.py,NONE,1.1 Message-ID: <200006281649.JAA21034@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Tools/perfecthash In directory slayer.i.sourceforge.net:/tmp/cvs-serv21021/Tools/perfecthash Added Files: GenUCNHash.py Log Message: Marc-Andre Lemburg : Generator for the new ucnhash module (ucnhash.h|c). Uses perfect_hash.py to create the ucnhash module. --- NEW FILE --- #! /usr/bin/env python import sys import string import perfect_hash # This is a user of perfect_hash.py # that takes as input the UnicodeData.txt file available from: # ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt # It generates a hash table from Unicode Character Name -> # unicode code space value. # These variables determine which hash function is tried first. # Yields a multiple of 1.7875 for UnicodeData.txt on 2000/06/24/ f1Seed = 1694245428 f2Seed = -1917331657 # Maximum allowed multipler, if this isn't None then instead of continually # increasing C, it resets it back to initC to keep searching for # a solution. minC = 1.7875 # Initial multiplier for trying to find a perfect hash function. initC = 1.7875 moduleName = "ucnhash" dataArrayName = "aucn" dataArrayType = "_Py_UnicodeCharacterName" headerFileName = "ucnhash.h" cFileName = "ucnhash.c" structName = "_Py_UCNHashAPI" keys = [] hashData = {} def generateOutputFiles(perfHash, hashData): header = perfHash.generate_header(structName) header = header + """ typedef struct { const char *pszUCN; unsigned int uiValue; } _Py_UnicodeCharacterName; """ code = perfHash.generate_code(moduleName, dataArrayName, dataArrayType, structName) out = open(headerFileName, "w") out.write(header) out = open(cFileName, "w") out.write("#include <%s>\n" % headerFileName) out.write(code) perfHash.generate_graph(out) out.write(""" static const _Py_UnicodeCharacterName aucn[] = { """) for i in xrange(len(keys)): v = hashData[keys[i][0]] out.write(' { "' + keys[i][0] + '", ' + hex(v) + " }," + "\n") out.write("};\n\n") sys.stderr.write('\nGenerated output files: \n') sys.stderr.write('%s\n%s\n' % (headerFileName, cFileName)) def main(): # Suck in UnicodeData.txt and spit out the generated files. input = open(sys.argv[1], 'r') i = 0 while 1: line = input.readline() if line == "": break fields = string.split(line, ';') if len(fields) < 2: sys.stderr.write('Ill-formated line!\n') sys.stderr.write('line #: %d\n' % (i + 1)) sys.exit() data, key = fields[:2] key = string.strip( key ) # Any name starting with '<' is a control, or start/end character, # so skip it... if key[0] == "<": continue hashcode = i i = i + 1 # force the name to uppercase keys.append( (string.upper(key),hashcode) ) data = string.atoi(data, 16) hashData[key] = data input.close() sys.stderr.write('%i key/hash pairs read\n' % len(keys) ) perfHash = perfect_hash.generate_hash(keys, 1, minC, initC, f1Seed, f2Seed, # increment, tries 0.0025, 50) generateOutputFiles(perfHash, hashData) if __name__ == '__main__': if len(sys.argv) == 1: sys.stdout = sys.stderr print 'Usage: %s ' % sys.argv[0] print ' The input file needs to be UnicodeData.txt' sys.exit() main() From python-dev@python.org Wed Jun 28 17:53:18 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 28 Jun 2000 09:53:18 -0700 Subject: [Python-checkins] CVS: python/dist/src/Tools/perfecthash perfect_hash.py,NONE,1.1 Message-ID: <200006281653.JAA21293@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Tools/perfecthash In directory slayer.i.sourceforge.net:/tmp/cvs-serv21286/Tools/perfecthash Added Files: perfect_hash.py Log Message: Marc-Andre Lemburg : Perfect hash table generator. Outputs a Python extension module which provides access to the hash table (which is stored in static C data) using custom code. This module can currently only generates code for the ucnhash module, but can easily be adapted to produce perfect hash tables for other tasks where fast lookup in large tables is needed. By Bill Tutt. --- NEW FILE --- #!/usr/bin/env/python # perfect_hash.py # # Outputs C code for a minimal perfect hash. # The hash is produced using the algorithm described in # "Optimal algorithms for minimal perfect hashing", # G. Havas, B.S. Majewski. Available as a technical report # from the CS department, University of Queensland # (ftp://ftp.cs.uq.oz.au/). # # This is a modified version of Andrew Kuchling's code # (http://starship.python.net/crew/amk/python/code/perfect-hash.html) # and generates C fragments suitable for compilation as a Python # extension module. # # Difference between this algorithm and gperf: # Gperf will complete in finite time with a successful function, # or by giving up. # This algorithm may never complete, although it is extremely likely # when c >= 2. # The algorithm works like this: # 0) You have K keys, that you want to perfectly hash to a bunch # of hash values. # # 1) Choose a number N larger than K. This is the number of # vertices in a graph G, and also the size of the resulting table. # # 2) Pick two random hash functions f1, f2, that output values from # 0...N-1. # # 3) for key in keys: # h1 = f1(key) ; h2 = f2(key) # Draw an edge between vertices h1 and h2 of the graph. # Associate the desired hash value with that edge. # # 4) Check if G is acyclic; if not, go back to step 1 and pick a bigger N. # # 5) Assign values to each vertex such that, for each edge, you can # add the values for the two vertices and get the desired value # for that edge -- which is the desired hash key. This task is # dead easy, because the graph is acyclic. This is done by # picking a vertex V, and assigning it a value of 0. You then do a # depth-first search, assigning values to new vertices so that # they sum up properly. # # 6) f1, f2, and G now make up your perfect hash function. import sys, whrandom, string import pprint import perfhash import time class Hash: """Random hash function For simplicity and speed, this doesn't implement any byte-level hashing scheme. Instead, a random string is generated and prefixing to str(key), and then Python's hashing function is used.""" def __init__(self, N, caseInsensitive=0): self.N = N junk = "" for i in range(10): junk = junk + whrandom.choice(string.letters + string.digits) self.junk = junk self.caseInsensitive = caseInsensitive self.seed = perfhash.calcSeed(junk) def __call__(self, key): key = str(key) if self.caseInsensitive: key = string.upper(key) x = perfhash.hash(self.seed, len(self.junk), key) % self.N #h = hash(self.junk + key) % self.N #assert x == h return x def generate_code(self): s = """{ register int len; register unsigned char *p; register long x; len = cch; p = (unsigned char *) key; x = %(junkSeed)d; while (--len >= 0) x = (1000003*x) ^ """ % \ { "lenJunk" : len(self.junk), "junkSeed" : self.seed, } if self.caseInsensitive: s = s + "toupper(*(p++));" else: s = s + "*(p++);" s = s + """ x ^= cch + %(lenJunk)d; if (x == -1) x = -2; x %%= k_cHashElements; /* ensure the returned value is positive so we mimic Python's %% operator */ if (x < 0) x += k_cHashElements; return x; } """ % { "lenJunk" : len(self.junk), "junkSeed" : self.seed, } return s WHITE, GREY, BLACK = 0,1,2 class Graph: """Graph class. This class isn't particularly efficient or general, and only has the features I needed to implement this algorithm. num_vertices -- number of vertices edges -- maps 2-tuples of vertex numbers to the value for this edge. If there's an edge between v1 and v2 (v1 vertex2: vertex1, vertex2 = vertex2, vertex1 # if self.edges.has_key( (vertex1, vertex2) ): # raise ValueError, 'Collision: vertices already connected' self.edges[ (vertex1, vertex2) ] = value # Add vertices to each other's reachable list if not self.reachable_list.has_key( vertex1 ): self.reachable_list[ vertex1 ] = [vertex2] else: self.reachable_list[vertex1].append(vertex2) if not self.reachable_list.has_key( vertex2 ): self.reachable_list[ vertex2 ] = [vertex1] else: self.reachable_list[vertex2].append(vertex1) def get_edge_value(self, vertex1, vertex2): """Retrieve the value corresponding to the edge between 'vertex1' and 'vertex2'. Raises KeyError if no such edge""" if vertex1 > vertex2: vertex1, vertex2 = vertex2, vertex1 return self.edges[ (vertex1, vertex2) ] def is_acyclic(self): "Returns true if the graph is acyclic, otherwise false" # This is done by doing a depth-first search of the graph; # painting each vertex grey and then black. If the DFS # ever finds a vertex that isn't white, there's a cycle. colour = {} for i in range(self.num_vertices): colour[i] = WHITE # Loop over all vertices, taking white ones as starting # points for a traversal. for i in range(self.num_vertices): if colour[i] == WHITE: # List of vertices to visit visit_list = [ (None,i) ] # Do a DFS while visit_list: # Colour this vertex grey. parent, vertex = visit_list[0] ; del visit_list[0] colour[vertex] = GREY # Make copy of list of neighbours, removing the vertex # we arrived here from. neighbours = self.reachable_list.get(vertex, []) [:] if parent in neighbours: neighbours.remove( parent ) for neighbour in neighbours: if colour[neighbour] == WHITE: visit_list.insert(0, (vertex, neighbour) ) elif colour[neighbour] != WHITE: # Aha! Already visited this node, # so the graph isn't acyclic. return 0 colour[vertex] = BLACK # We got through, so the graph is acyclic. return 1 def assign_values(self): """Compute values for each vertex, so that they sum up properly to the associated value for each edge.""" # Also done with a DFS; I simply copied the DFS code # from is_acyclic(). (Should generalize the logic so # one function could be used from both methods, # but I couldn't be bothered.) colour = {} for i in range(self.num_vertices): colour[i] = WHITE # Loop over all vertices, taking white ones as starting # points for a traversal. for i in range(self.num_vertices): if colour[i] == WHITE: # Set this vertex's value, arbitrarily, to zero. self.set_vertex_value( i, 0 ) # List of vertices to visit visit_list = [ (None,i) ] # Do a DFS while visit_list: # Colour this vertex grey. parent, vertex = visit_list[0] ; del visit_list[0] colour[vertex] = GREY # Make copy of list of neighbours, removing the vertex # we arrived here from. neighbours = self.reachable_list.get(vertex, []) [:] if parent in neighbours: neighbours.remove( parent ) for neighbour in self.reachable_list.get(vertex, []): edge_value = self.get_edge_value( vertex, neighbour ) if colour[neighbour] == WHITE: visit_list.insert(0, (vertex, neighbour) ) # Set new vertex's value to the desired # edge value, minus the value of the # vertex we came here from. new_val = (edge_value - self.get_vertex_value( vertex ) ) self.set_vertex_value( neighbour, new_val % self.num_vertices) colour[vertex] = BLACK # Returns nothing return def __getitem__(self, index): if index < self.num_vertices: return index raise IndexError def get_vertex_value(self, vertex): "Get value for a vertex" return self.values[ vertex ] def set_vertex_value(self, vertex, value): "Set value for a vertex" self.values[ vertex ] = value def generate_code(self, out, width = 70): "Return nicely formatted table" out.write("{ ") pos = 0 for v in self.values: v=str(v)+', ' out.write(v) pos = pos + len(v) + 1 if pos > width: out.write('\n '); pos = 0 out.write('};\n') class PerfectHash: def __init__(self, cchMax, f1, f2, G, cHashElements, cKeys, maxHashValue): self.cchMax = cchMax self.f1 = f1 self.f2 = f2 self.G = G self.cHashElements = cHashElements self.cKeys = cKeys # determine the necessary type for storing our hash function # helper table: self.type = self.determineType(maxHashValue) def generate_header(self, structName): header = """ #include #include /* --- C API ----------------------------------------------------*/ /* C API for usage by other Python modules */ typedef struct %(structName)s { unsigned long cKeys; unsigned long cchMax; unsigned long (*hash)(const char *key, unsigned int cch); const void *(*getValue)(unsigned long iKey); } %(structName)s; """ % { "structName" : structName } return header def determineType(self, maxHashValue): if maxHashValue <= 255: return "unsigned char" elif maxHashValue <= 65535: return "unsigned short" else: # Take the cheesy way out... return "unsigned long" def generate_code(self, moduleName, dataArrayName, dataArrayType, structName): # Output C code for the hash functions and tables code = """ /* * The hash is produced using the algorithm described in * "Optimal algorithms for minimal perfect hashing", * G. Havas, B.S. Majewski. Available as a technical report * from the CS department, University of Queensland * (ftp://ftp.cs.uq.oz.au/). * * Generated using a heavily tweaked version of Andrew Kuchling's * perfect_hash.py: * http://starship.python.net/crew/amk/python/code/perfect-hash.html * * Generated on: %s */ """ % time.ctime(time.time()) # MSVC SP3 was complaining when I actually used a global constant code = code + """ #define k_cHashElements %i #define k_cchMaxKey %d #define k_cKeys %i """ % (self.cHashElements, self.cchMax, self.cKeys) code = code + """ static const %s G[k_cHashElements]; static const %s %s[k_cKeys]; """ % (self.type, dataArrayType, dataArrayName) code = code + """ static long f1(const char *key, unsigned int cch) """ code = code + self.f1.generate_code() code = code + """ static long f2(const char *key, unsigned int cch) """ code = code + self.f2.generate_code() code = code + """ static unsigned long hash(const char *key, unsigned int cch) { return ((unsigned long)(G[ f1(key, cch) ]) + (unsigned long)(G[ f2(key, cch) ]) ) %% k_cHashElements; } const void *getValue(unsigned long iKey) { return &%(dataArrayName)s[iKey]; } /* Helper for adding objects to dictionaries. Check for errors with PyErr_Occurred() */ static void insobj(PyObject *dict, char *name, PyObject *v) { PyDict_SetItemString(dict, name, v); Py_XDECREF(v); } static const %(structName)s hashAPI = { k_cKeys, k_cchMaxKey, &hash, &getValue, }; static PyMethodDef Module_methods[] = { {NULL, NULL}, }; static char *Module_docstring = "%(moduleName)s hash function module"; /* Error reporting for module init functions */ #define Py_ReportModuleInitError(modname) { \\ PyObject *exc_type, *exc_value, *exc_tb; \\ PyObject *str_type, *str_value; \\ \\ /* Fetch error objects and convert them to strings */ \\ PyErr_Fetch(&exc_type, &exc_value, &exc_tb); \\ if (exc_type && exc_value) { \\ str_type = PyObject_Str(exc_type); \\ str_value = PyObject_Str(exc_value); \\ } \\ else { \\ str_type = NULL; \\ str_value = NULL; \\ } \\ /* Try to format a more informative error message using the \\ original error */ \\ if (str_type && str_value && \\ PyString_Check(str_type) && PyString_Check(str_value)) \\ PyErr_Format( \\ PyExc_ImportError, \\ "initialization of module "modname" failed " \\ "(%%s:%%s)", \\ PyString_AS_STRING(str_type), \\ PyString_AS_STRING(str_value)); \\ else \\ PyErr_SetString( \\ PyExc_ImportError, \\ "initialization of module "modname" failed"); \\ Py_XDECREF(str_type); \\ Py_XDECREF(str_value); \\ Py_XDECREF(exc_type); \\ Py_XDECREF(exc_value); \\ Py_XDECREF(exc_tb); \\ } /* Create PyMethodObjects and register them in the module\'s dict */ DL_EXPORT(void) init%(moduleName)s(void) { PyObject *module, *moddict; /* Create module */ module = Py_InitModule4("%(moduleName)s", /* Module name */ Module_methods, /* Method list */ Module_docstring, /* Module doc-string */ (PyObject *)NULL, /* always pass this as *self */ PYTHON_API_VERSION); /* API Version */ if (module == NULL) goto onError; /* Add some constants to the module\'s dict */ moddict = PyModule_GetDict(module); if (moddict == NULL) goto onError; /* Export C API */ insobj( moddict, "%(moduleName)sAPI", PyCObject_FromVoidPtr((void *)&hashAPI, NULL)); onError: /* Check for errors and report them */ if (PyErr_Occurred()) Py_ReportModuleInitError("%(moduleName)s"); return; } """ % { "moduleName" : moduleName, "dataArrayName" : dataArrayName, "structName" : structName, } return code def generate_graph(self, out): out.write(""" static const unsigned short G[] = """) self.G.generate_code(out) def generate_hash(keys, caseInsensitive=0, minC=None, initC=None, f1Seed=None, f2Seed=None, cIncrement=None, cTries=None): """Print out code for a perfect minimal hash. Input is a list of (key, desired hash value) tuples. """ # K is the number of keys. K = len(keys) # We will be generating graphs of size N, where N = c * K. # The larger C is, the fewer trial graphs will need to be made, but # the resulting table is also larger. Increase this starting value # if you're impatient. After 50 failures, c will be increased by 0.025. if initC is None: initC = 1.5 c = initC if cIncrement is None: cIncrement = 0.0025 if cTries is None: cTries = 50 # Number of trial graphs so far num_graphs = 0 sys.stderr.write('Generating graphs... ') while 1: # N is the number of vertices in the graph G N = int(c*K) num_graphs = num_graphs + 1 if (num_graphs % cTries) == 0: # Enough failures at this multiplier, # increase the multiplier and keep trying.... c = c + cIncrement # Whats good with searching for a better # hash function if we exceed the size # of a function we've generated in the past.... if minC is not None and \ c > minC: c = initC sys.stderr.write(' -- c > minC, resetting c to %0.4f\n' % c) else: sys.stderr.write(' -- increasing c to %0.4f\n' % c) sys.stderr.write('Generating graphs... ') # Output a progress message sys.stderr.write( str(num_graphs) + ' ') sys.stderr.flush() # Create graph w/ N vertices G = Graph(N) # Save the seeds used to generate # the following two hash functions. _seeds = whrandom._inst._seed # Create 2 random hash functions f1 = Hash(N, caseInsensitive) f2 = Hash(N, caseInsensitive) # Set the initial hash function seed values if passed in. # Doing this protects our hash functions from # changes to whrandom's behavior. if f1Seed is not None: f1.seed = f1Seed f1Seed = None fSpecifiedSeeds = 1 if f2Seed is not None: f2.seed = f2Seed f2Seed = None fSpecifiedSeeds = 1 # Connect vertices given by the values of the two hash functions # for each key. Associate the desired hash value with each # edge. for k, v in keys: h1 = f1(k) ; h2 = f2(k) G.connect( h1,h2, v) # Check if the resulting graph is acyclic; if it is, # we're done with step 1. if G.is_acyclic(): break elif fSpecifiedSeeds: sys.stderr.write('\nThe initial f1/f2 seeds you specified didn\'t generate a perfect hash function: \n') sys.stderr.write('f1 seed: %s\n' % f1.seed) sys.stderr.write('f2 seed: %s\n' % f2.seed) sys.stderr.write('multipler: %s\n' % c) sys.stderr.write('Your data has likely changed, or you forgot what your initial multiplier should be.\n') sys.stderr.write('continuing the search for a perfect hash function......\n') fSpecifiedSeeds = 0 # Now we have an acyclic graph, so we assign values to each vertex # such that, for each edge, you can add the values for the two vertices # involved and get the desired value for that edge -- which is the # desired hash key. This task is dead easy, because the graph is acyclic. sys.stderr.write('\nAcyclic graph found; computing vertex values...\n') G.assign_values() sys.stderr.write('Checking uniqueness of hash values...\n') # Sanity check the result by actually verifying that all the keys # hash to the right value. cchMaxKey = 0 maxHashValue = 0 for k, v in keys: hash1 = G.values[ f1(k) ] hash2 = G.values[ f2(k) ] if hash1 > maxHashValue: maxHashValue = hash1 if hash2 > maxHashValue: maxHashValue = hash2 perfecthash = (hash1 + hash2) % N assert perfecthash == v cch = len(k) if cch > cchMaxKey: cchMaxKey = cch sys.stderr.write('Found perfect hash function!\n') sys.stderr.write('\nIn order to regenerate this hash function, \n') sys.stderr.write('you need to pass these following values back in:\n') sys.stderr.write('f1 seed: %s\n' % repr(f1.seed)) sys.stderr.write('f2 seed: %s\n' % repr(f2.seed)) sys.stderr.write('initial multipler: %s\n' % c) return PerfectHash(cchMaxKey, f1, f2, G, N, len(keys), maxHashValue) """ static PyObject *codec_tuple(PyObject *unicode, int len) { PyObject *v,*w; if (unicode == NULL) return NULL; v = PyTuple_New(2); if (v == NULL) { Py_DECREF(unicode); return NULL; } PyTuple_SET_ITEM(v,0,unicode); w = PyInt_FromLong(len); if (w == NULL) { Py_DECREF(v); return NULL; } PyTuple_SET_ITEM(v,1,w); return v; } static PyObject * ucn_decode(PyObject *self, PyObject *args) { const char *data; int size; const char *errors = NULL; PyObject *mapping = NULL; if (!PyArg_ParseTuple(args, "t#|z:ucn_decode", &data, &size, &errors)) return NULL; if (mapping == Py_None) mapping = NULL; return codec_tuple(PyUnicode_DecodeNamedUnicodeEscape(data, size, errors), size); } static PyMethodDef _codecs_functions[] = { { "ucn_decode", ucn_decode, 1 }, }; DL_EXPORT(void) init_ucn() { Py_InitModule("_ucn", _codecs_functions); } """ From python-dev@python.org Wed Jun 28 18:27:51 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 10:27:51 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libos.tex,1.40,1.41 libpty.tex,1.2,1.3 Message-ID: <200006281727.KAA30157@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv30149/lib Modified Files: libos.tex libpty.tex Log Message: Thomas Wouters : Documentation updates related to the addition of openpty() and forkpty(). Index: libos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -r1.40 -r1.41 *** libos.tex 2000/05/02 17:29:35 1.40 --- libos.tex 2000/06/28 17:27:48 1.41 *************** *** 368,371 **** --- 368,379 ---- \end{funcdesc} + \begin{funcdesc}{openpty}{} + Open a new pseudo-terminal pair. Return a pair of file descriptors + \code{(\var{master}, \var{slave})} for the pty and the tty, + respectively. For a (slightly) more portable approach, use the + \refmodule{pty}\refstmodindex{pty} module. + Availability: Some flavors of \UNIX{} + \end{funcdesc} + \begin{funcdesc}{pipe}{} Create a pipe. Return a pair of file descriptors \code{(\var{r}, *************** *** 790,793 **** --- 798,811 ---- process id in the parent. Availability: \UNIX{}. + \end{funcdesc} + + \begin{funcdesc}{forkpty}{} + Fork a child process, using a new pseudo-terminal as the child's + controlling terminal. Return a pair of \code{(\var{pid}, \var{fd})}, + where \var{pid} is \code{0} in the child, the new child's process id + in the parent, and \code{fd} is the file descriptor of the master end + of the pseudo-terminal. For a more portable approach, use the + \refmodule{pty} module. + Availability: Some flavors of \UNIX{} \end{funcdesc} Index: libpty.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpty.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** libpty.tex 2000/04/03 20:13:53 1.2 --- libpty.tex 2000/06/28 17:27:48 1.3 *************** *** 27,30 **** --- 27,37 ---- \end{funcdesc} + \begin{funcdesc}{openpty}{} + Open a new pseudo-terminal pair, using \function{os.openpty()} if + possible, or emulation code for SGI and generic \UNIX{} systems. + Return a pair of file descriptors \code{(\var{master}, \var{slave})}, + for the master and the slave end, respectively. + \end{funcdesc} + \begin{funcdesc}{spawn}{argv\optional{, master_read\optional{, stdin_read}}} Spawn a process, and connect its controlling terminal with the current From python-dev@python.org Wed Jun 28 18:49:32 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 10:49:32 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules arraymodule.c,2.40,2.41 Message-ID: <200006281749.KAA31301@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv31291/Modules Modified Files: arraymodule.c Log Message: Trent Mick : The cause: Relatively recent (last month) patches to getargs.c added overflow checking to the PyArg_Parse*() integral formatters thereby restricting 'b' to unsigned char value and 'h','i', and 'l' to signed integral values (i.e. if the incoming value is outside of the specified bounds you get an OverflowError, previous it silently overflowed). The problem: This broke the array module (as Fredrik pointed out) because *its* formatters relied on the loose allowance of signed and unsigned ranges being able to pass through PyArg_Parse*()'s formatters. The fix: This patch fixes the array module to work with the more strict bounds checking now in PyArg_Parse*(). How: If the type signature of a formatter in the arraymodule exactly matches one in PyArg_Parse*(), then use that directly. If there is no equivalent type signature in PyArg_Parse*() (e.g. there is no unsigned int formatter in PyArg_Parse*()), then use the next one up and do some extra bounds checking in the array module. This partially closes SourceForge patch #100506. Index: arraymodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/arraymodule.c,v retrieving revision 2.40 retrieving revision 2.41 diff -C2 -r2.40 -r2.41 *** arraymodule.c 2000/06/01 02:02:46 2.40 --- arraymodule.c 2000/06/28 17:49:30 2.41 *************** *** 115,123 **** PyObject *v; { ! char x; ! if (!PyArg_Parse(v, "b;array item must be integer", &x)) return -1; if (i >= 0) ! ((char *)ap->ob_item)[i] = x; return 0; } --- 115,136 ---- PyObject *v; { ! short x; ! /* PyArg_Parse's 'b' formatter is for an unsigned char, therefore ! must use the next size up that is signed ('h') and manually do ! the overflow checking */ ! if (!PyArg_Parse(v, "h;array item must be integer", &x)) ! return -1; ! else if (x < CHAR_MIN) { ! PyErr_SetString(PyExc_OverflowError, ! "signed char is less than minimum"); ! return -1; ! } ! else if (x > CHAR_MAX) { ! PyErr_SetString(PyExc_OverflowError, ! "signed char is greater than maximum"); return -1; + } if (i >= 0) ! ((char *)ap->ob_item)[i] = (char)x; return 0; } *************** *** 132,136 **** } ! #define BB_setitem b_setitem static PyObject * --- 145,162 ---- } ! static int ! BB_setitem(ap, i, v) ! arrayobject *ap; ! int i; ! PyObject *v; ! { ! unsigned char x; ! /* 'B' == unsigned char, maps to PyArg_Parse's 'b' formatter */ ! if (!PyArg_Parse(v, "b;array item must be integer", &x)) ! return -1; ! if (i >= 0) ! ((char *)ap->ob_item)[i] = x; ! return 0; ! } static PyObject * *************** *** 149,152 **** --- 175,179 ---- { short x; + /* 'h' == signed short, maps to PyArg_Parse's 'h' formatter */ if (!PyArg_Parse(v, "h;array item must be integer", &x)) return -1; *************** *** 164,168 **** } ! #define HH_setitem h_setitem static PyObject * --- 191,219 ---- } ! static int ! HH_setitem(ap, i, v) ! arrayobject *ap; ! int i; ! PyObject *v; ! { ! int x; ! /* PyArg_Parse's 'h' formatter is for a signed short, therefore ! must use the next size up and manually do the overflow checking */ ! if (!PyArg_Parse(v, "i;array item must be integer", &x)) ! return -1; ! else if (x < 0) { ! PyErr_SetString(PyExc_OverflowError, ! "unsigned short is less than minimum"); ! return -1; ! } ! else if (x > USHRT_MAX) { ! PyErr_SetString(PyExc_OverflowError, ! "unsigned short is greater than maximum"); ! return -1; ! } ! if (i >= 0) ! ((short *)ap->ob_item)[i] = (short)x; ! return 0; ! } static PyObject * *************** *** 181,184 **** --- 232,236 ---- { int x; + /* 'i' == signed int, maps to PyArg_Parse's 'i' formatter */ if (!PyArg_Parse(v, "i;array item must be integer", &x)) return -1; *************** *** 210,218 **** } else { ! if (!PyArg_Parse(v, "l;array item must be integer", &x)) return -1; } if (i >= 0) ! ((unsigned int *)ap->ob_item)[i] = x; return 0; } --- 262,284 ---- } else { ! long y; ! if (!PyArg_Parse(v, "l;array item must be integer", &y)) return -1; + if (y < 0) { + PyErr_SetString(PyExc_OverflowError, + "unsigned int is less than minimum"); + return -1; + } + x = (unsigned long)y; + + } + if (x > UINT_MAX) { + PyErr_SetString(PyExc_OverflowError, + "unsigned int is greater than maximum"); + return -1; } + if (i >= 0) ! ((unsigned int *)ap->ob_item)[i] = (unsigned int)x; return 0; } *************** *** 261,267 **** } else { ! if (!PyArg_Parse(v, "l;array item must be integer", &x)) return -1; } if (i >= 0) ((unsigned long *)ap->ob_item)[i] = x; --- 327,347 ---- } else { ! long y; ! if (!PyArg_Parse(v, "l;array item must be integer", &y)) ! return -1; ! if (y < 0) { ! PyErr_SetString(PyExc_OverflowError, ! "unsigned long is less than minimum"); return -1; + } + x = (unsigned long)y; + + } + if (x > ULONG_MAX) { + PyErr_SetString(PyExc_OverflowError, + "unsigned long is greater than maximum"); + return -1; } + if (i >= 0) ((unsigned long *)ap->ob_item)[i] = x; *************** *** 726,731 **** PyObject *args; { ! return Py_BuildValue("ll", ! (long)(self->ob_item), (long)(self->ob_size)); } --- 806,816 ---- PyObject *args; { ! PyObject* retval = PyTuple_New(2); ! if (!retval) return NULL; ! ! PyTuple_SET_ITEM(retval, 0, PyLong_FromVoidPtr(self->ob_item)); ! PyTuple_SET_ITEM(retval, 1, PyInt_FromLong((long)(self->ob_size))); ! ! return retval; } From python-dev@python.org Wed Jun 28 18:50:53 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 10:50:53 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_array.py,1.6,1.7 Message-ID: <200006281750.KAA31358@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv31348/Lib/test Modified Files: test_array.py Log Message: Trent Mick : Testing: test_array.py was also extended to check that one can set the full range of values for each of the integral signed and unsigned array types. This closes SourceForge patch #100506. Index: test_array.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_array.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** test_array.py 1998/07/16 15:31:43 1.6 --- test_array.py 2000/06/28 17:50:51 1.7 *************** *** 16,19 **** --- 16,57 ---- + def testoverflow(type, lowerLimit, upperLimit): + # should not overflow assigning lower limit + if verbose: + print "overflow test: array(%s, [%s])" % (`type`, `lowerLimit`) + try: + a = array.array(type, [lowerLimit]) + except: + raise TestFailed, "array(%s) overflowed assigning %s" %\ + (`type`, `lowerLimit`) + # should overflow assigning less than lower limit + if verbose: + print "overflow test: array(%s, [%s])" % (`type`, `lowerLimit-1`) + try: + a = array.array(type, [lowerLimit-1]) + raise TestFailed, "array(%s) did not overflow assigning %s" %\ + (`type`, `lowerLimit-1`) + except OverflowError: + pass + # should not overflow assigning upper limit + if verbose: + print "overflow test: array(%s, [%s])" % (`type`, `upperLimit`) + try: + a = array.array(type, [upperLimit]) + except: + raise TestFailed, "array(%s) overflowed assigning %s" %\ + (`type`, `upperLimit`) + # should overflow assigning more than upper limit + if verbose: + print "overflow test: array(%s, [%s])" % (`type`, `upperLimit+1`) + try: + a = array.array(type, [upperLimit+1]) + raise TestFailed, "array(%s) did not overflow assigning %s" %\ + (`type`, `upperLimit+1`) + except OverflowError: + pass + + + def testtype(type, example): *************** *** 82,86 **** raise TestFailed, "array(%s) self-slice-assign (cntr)" % `type` ! main() ! --- 120,138 ---- raise TestFailed, "array(%s) self-slice-assign (cntr)" % `type` ! # test that overflow exceptions are raised as expected for assignment ! # to array of specific integral types ! from math import pow ! if type in ('b', 'h', 'i', 'l'): ! # check signed and unsigned versions ! a = array.array(type) ! signedLowerLimit = -1 * long(pow(2, a.itemsize * 8 - 1)) ! signedUpperLimit = long(pow(2, a.itemsize * 8 - 1)) - 1L ! unsignedLowerLimit = 0 ! unsignedUpperLimit = long(pow(2, a.itemsize * 8)) - 1L ! testoverflow(type, signedLowerLimit, signedUpperLimit) ! testoverflow(type.upper(), unsignedLowerLimit, unsignedUpperLimit) ! ! ! main() ! From python-dev@python.org Wed Jun 28 19:47:59 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 11:47:59 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python marshal.c,1.47,1.48 Message-ID: <200006281847.LAA08850@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv8840 Modified Files: marshal.c Log Message: Michael Hudson : As I really do not have anything better to do at the moment, I have written a patch to Python/marshal.c that prevents Python dumping core when trying to marshal stack bustingly deep (or recursive) data structure. It just throws an exception; even slightly clever handling of recursive data is what pickle is for... [Fred Drake:] Moved magic constant 5000 to a #define. This closes SourceForge patch #100645. Index: marshal.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/marshal.c,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -r1.47 -r1.48 *** marshal.c 2000/05/03 23:44:39 1.47 --- marshal.c 2000/06/28 18:47:56 1.48 *************** *** 40,43 **** --- 40,49 ---- #include "marshal.h" + /* High water mark to determine when the marshalled object is dangerously deep + * and risks coring the interpreter. When the object stack gets this deep, + * raise an exception instead of continuing. + */ + #define MAX_MARSHAL_STACK_DEPTH 5000 + #define TYPE_NULL '0' #define TYPE_NONE 'N' *************** *** 59,62 **** --- 65,69 ---- FILE *fp; int error; + int depth; /* If fp == NULL, the following are valid: */ PyObject *str; *************** *** 145,150 **** int i, n; PyBufferProcs *pb; ! if (v == NULL) { w_byte(TYPE_NULL, p); } --- 152,162 ---- int i, n; PyBufferProcs *pb; + + p->depth++; ! if (p->depth > MAX_MARSHAL_STACK_DEPTH) { ! p->error = 2; ! } ! else if (v == NULL) { w_byte(TYPE_NULL, p); } *************** *** 302,305 **** --- 314,318 ---- wf.fp = fp; wf.error = 0; + wf.depth = 0; w_long(x, &wf); } *************** *** 691,694 **** --- 704,708 ---- wf.end = wf.ptr + PyString_Size(wf.str); wf.error = 0; + wf.depth = 0; w_object(x, &wf); if (wf.str != NULL) *************** *** 698,702 **** if (wf.error) { Py_XDECREF(wf.str); ! PyErr_SetString(PyExc_ValueError, "unmarshallable object"); return NULL; } --- 712,718 ---- if (wf.error) { Py_XDECREF(wf.str); ! PyErr_SetString(PyExc_ValueError, ! (wf.error==1)?"unmarshallable object" ! :"object too deeply nested to marshal"); return NULL; } *************** *** 725,731 **** wf.ptr = wf.end = NULL; wf.error = 0; w_object(x, &wf); if (wf.error) { ! PyErr_SetString(PyExc_ValueError, "unmarshallable object"); return NULL; } --- 741,750 ---- wf.ptr = wf.end = NULL; wf.error = 0; + wf.depth = 0; w_object(x, &wf); if (wf.error) { ! PyErr_SetString(PyExc_ValueError, ! (wf.error==1)?"unmarshallable object" ! :"object too deeply nested to marshal"); return NULL; } From python-dev@python.org Wed Jun 28 21:15:52 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 13:15:52 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/ref ref3.tex,1.43,1.44 Message-ID: <200006282015.NAA26364@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/ref In directory slayer.i.sourceforge.net:/tmp/cvs-serv26351/ref Modified Files: ref3.tex Log Message: Revise the description of when functions retrieved from class instances are and are not turned into bound methods; some confusion was noted by Andrew Dalke. In particular, it has to be noted that functions located on the class instance are not turned into any sort of method, only those which are found via the underlying class. Index: ref3.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref3.tex,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -r1.43 -r1.44 *** ref3.tex 2000/06/15 20:07:25 1.43 --- ref3.tex 2000/06/28 20:15:47 1.44 *************** *** 439,447 **** User-defined method objects are created in two ways: when getting an attribute of a class that is a user-defined function object, or when ! getting an attributes of a class instance that is a user-defined ! function object. In the former case (class attribute), the ! \member{im_self} attribute is \code{None}, and the method object is said ! to be unbound; in the latter case (instance attribute), \method{im_self} ! is the instance, and the method object is said to be bound. For instance, when \class{C} is a class which contains a definition for a function \method{f()}, \code{C.f} does not yield the function object --- 439,448 ---- User-defined method objects are created in two ways: when getting an attribute of a class that is a user-defined function object, or when ! getting an attribute of a class instance that is a user-defined ! function object defined by the class of the instance. In the former ! case (class attribute), the \member{im_self} attribute is \code{None}, ! and the method object is said to be unbound; in the latter case ! (instance attribute), \method{im_self} is the instance, and the method ! object is said to be bound. For instance, when \class{C} is a class which contains a definition for a function \method{f()}, \code{C.f} does not yield the function object *************** *** 453,459 **** \code{m.im_self} is \code{x}. \withsubitem{(method attribute)}{ ! \ttindex{im_class} ! \ttindex{im_func} ! \ttindex{im_self}} When an unbound user-defined method object is called, the underlying --- 454,458 ---- \code{m.im_self} is \code{x}. \withsubitem{(method attribute)}{ ! \ttindex{im_class}\ttindex{im_func}\ttindex{im_self}} When an unbound user-defined method object is called, the underlying *************** *** 475,479 **** Also notice that this transformation only happens for user-defined functions; other callable objects (and all non-callable objects) are ! retrieved without transformation. \item[Built-in functions] --- 474,481 ---- Also notice that this transformation only happens for user-defined functions; other callable objects (and all non-callable objects) are ! retrieved without transformation. It is also important to note that ! user-defined functions which are attributes of a class instance are ! not converted to bound methods; this \emph{only} happens when the ! function is an attribute of the class. \item[Built-in functions] From python-dev@python.org Wed Jun 28 21:53:36 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 13:53:36 -0700 Subject: [Python-checkins] CVS: python/dist/src/Tools/bgen/bgen bgenGenerator.py,1.6,1.7 bgenlocations.py,1.3,1.4 scantools.py,1.16,1.17 Message-ID: <200006282053.NAA28507@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Tools/bgen/bgen In directory slayer.i.sourceforge.net:/tmp/cvs-serv28490 Modified Files: bgenGenerator.py bgenlocations.py scantools.py Log Message: Jack Jansen: Support for conditional inclusion of methods and functions Index: bgenGenerator.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/bgenGenerator.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** bgenGenerator.py 1995/06/18 20:08:28 1.6 --- bgenGenerator.py 2000/06/28 20:53:33 1.7 *************** *** 15,23 **** class BaseFunctionGenerator: ! def __init__(self, name): print "<--", name self.name = name self.prefix = name self.objecttype = "PyObject" # Type of _self argument to function def setprefix(self, prefix): --- 15,24 ---- class BaseFunctionGenerator: ! def __init__(self, name, condition=None): print "<--", name self.name = name self.prefix = name self.objecttype = "PyObject" # Type of _self argument to function + self.condition = condition def setprefix(self, prefix): *************** *** 26,32 **** --- 27,38 ---- def generate(self): print "-->", self.name + if self.condition: + Output() + Output(self.condition) self.functionheader() self.functionbody() self.functiontrailer() + if self.condition: + Output("#endif") def functionheader(self): *************** *** 51,56 **** --- 57,67 ---- name = self.name docstring = self.docstring() + if self.condition: + Output() + Output(self.condition) Output("{\"%s\", (PyCFunction)%s_%s, 1,", name, self.prefix, self.name) Output(" %s},", stringify(docstring)) + if self.condition: + Output("#endif") def docstring(self): *************** *** 74,79 **** class ManualGenerator(BaseFunctionGenerator): ! def __init__(self, name, body): ! BaseFunctionGenerator.__init__(self, name) self.body = body --- 85,90 ---- class ManualGenerator(BaseFunctionGenerator): ! def __init__(self, name, body, condition=None): ! BaseFunctionGenerator.__init__(self, name, condition=condition) self.body = body *************** *** 88,93 **** class FunctionGenerator(BaseFunctionGenerator): ! def __init__(self, returntype, name, *argumentList): ! BaseFunctionGenerator.__init__(self, name) self.returntype = returntype self.argumentList = [] --- 99,104 ---- class FunctionGenerator(BaseFunctionGenerator): ! def __init__(self, returntype, name, *argumentList, **conditionlist): ! BaseFunctionGenerator.__init__(self, name, **conditionlist) self.returntype = returntype self.argumentList = [] Index: bgenlocations.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/bgenlocations.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** bgenlocations.py 1998/02/23 15:30:40 1.3 --- bgenlocations.py 2000/06/28 20:53:33 1.4 *************** *** 4,12 **** # Where to find the Universal Header include files: ! MWERKSDIR="flap:Metrowerks:Metrowerks CodeWarrior:" ! INCLUDEDIR=MWERKSDIR + "MacOS Support:Headers:Universal Headers:" # Where to put the python definitions file: ! TOOLBOXDIR="flap:Jack:Python:Mac:Lib:lib-toolbox:" # Creator for C files: --- 4,12 ---- # Where to find the Universal Header include files: ! MWERKSDIR="Macintosh HD:SWDev:Codewarrior Pro 5:Metrowerks CodeWarrior:" ! INCLUDEDIR=MWERKSDIR + "MacOS Support:Universal:Interfaces:CIncludes:" # Where to put the python definitions file: ! TOOLBOXDIR="Macintosh HD:SWDev:Jack:Python:Mac:Lib:lib-toolbox:" # Creator for C files: Index: scantools.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/scantools.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** scantools.py 2000/01/20 20:49:28 1.16 --- scantools.py 2000/06/28 20:53:33 1.17 *************** *** 100,103 **** --- 100,111 ---- self.blacklistnames = self.makeblacklistnames() self.blacklisttypes = ["unknown", "-"] + self.makeblacklisttypes() + self.greydictnames = self.greylist2dict(self.makegreylist()) + + def greylist2dict(self, list): + rv = {} + for define, namelist in list: + for name in namelist: + rv[name] = define + return rv def makeblacklistnames(self): *************** *** 106,109 **** --- 114,120 ---- def makeblacklisttypes(self): return [] + + def makegreylist(self): + return [] def initrepairinstructions(self): *************** *** 396,399 **** --- 407,411 ---- else: self.defsfile.write("# %s = %s\n" % (name, defn)) + # XXXX No way to handle greylisted names def dofuncspec(self): *************** *** 520,523 **** --- 532,537 ---- self.specfile.write(" (%s, %s, %s),\n" % (atype, `aname`, amode)) + if self.greydictnames.has_key(name): + self.specfile.write(" condition=%s,\n"%`self.greydictnames[name]`) self.specfile.write(")\n") self.specfile.write("%s.append(f)\n\n" % listname) From python-dev@python.org Wed Jun 28 21:54:55 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 13:54:55 -0700 Subject: [Python-checkins] CVS: python/dist/src/Parser parsetok.c,2.16,2.17 Message-ID: <200006282054.NAA28568@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Parser In directory slayer.i.sourceforge.net:/tmp/cvs-serv28542 Modified Files: parsetok.c Log Message: Jack Jansen: Removed Macintosh tab-guessing code Index: parsetok.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/parsetok.c,v retrieving revision 2.16 retrieving revision 2.17 diff -C2 -r2.16 -r2.17 *** parsetok.c 2000/05/03 23:44:37 2.16 --- parsetok.c 2000/06/28 20:54:53 2.17 *************** *** 110,120 **** } - #ifdef macintosh - { - int tabsize = guesstabsize(filename); - if (tabsize > 0) - tok->tabsize = tabsize; - } - #endif return parsetok(tok, g, start, err_ret); --- 110,113 ---- From python-dev@python.org Wed Jun 28 21:55:36 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 13:55:36 -0700 Subject: [Python-checkins] CVS: python/dist/src/Include pgenheaders.h,2.17,2.18 Message-ID: <200006282055.NAA28596@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Include In directory slayer.i.sourceforge.net:/tmp/cvs-serv28589/Include Modified Files: pgenheaders.h Log Message: Jack Jansen: Removed support for long-dead Think C compiler Index: pgenheaders.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pgenheaders.h,v retrieving revision 2.17 retrieving revision 2.18 diff -C2 -r2.17 -r2.18 *** pgenheaders.h 1998/12/04 18:48:15 2.17 --- pgenheaders.h 2000/06/28 20:55:34 2.18 *************** *** 48,56 **** #include - #ifdef THINK_C - #define label label_ - #undef label - #endif - #ifdef HAVE_STDLIB_H #include --- 48,51 ---- From python-dev@python.org Wed Jun 28 21:56:32 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 13:56:32 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules pcre.h,2.7,2.8 Message-ID: <200006282056.NAA28621@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv28614/Modules Modified Files: pcre.h Log Message: Jack Jansen: Mac Carbon: don't include sys/types if we don't have it Index: pcre.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/pcre.h,v retrieving revision 2.7 retrieving revision 2.8 diff -C2 -r2.7 -r2.8 *** pcre.h 1998/05/07 15:32:41 2.7 --- pcre.h 2000/06/28 20:56:30 2.8 *************** *** 15,19 **** --- 15,21 ---- it is needed here for malloc. */ + #ifndef DONT_HAVE_SYS_TYPES_H #include + #endif #include From python-dev@python.org Wed Jun 28 21:57:09 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 13:57:09 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects fileobject.c,2.73,2.74 Message-ID: <200006282057.NAA28650@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv28642/Objects Modified Files: fileobject.c Log Message: Jack Jansen: Moved includes to the top, removed think C support Index: fileobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/fileobject.c,v retrieving revision 2.73 retrieving revision 2.74 diff -C2 -r2.73 -r2.74 *** fileobject.c 2000/05/03 23:44:34 2.73 --- fileobject.c 2000/06/28 20:57:07 2.74 *************** *** 39,42 **** --- 39,62 ---- #endif /* DONT_HAVE_SYS_TYPES_H */ + /* We expect that fstat exists on most systems. + It's confirmed on Unix, Mac and Windows. + If you don't have it, add #define DONT_HAVE_FSTAT to your config.h. */ + #ifndef DONT_HAVE_FSTAT + #define HAVE_FSTAT + + #ifndef DONT_HAVE_SYS_TYPES_H + #include + #endif + + #ifndef DONT_HAVE_SYS_STAT_H + #include + #else + #ifdef HAVE_STAT_H + #include + #endif + #endif + + #endif /* DONT_HAVE_FSTAT */ + #ifdef HAVE_UNISTD_H #include *************** *** 55,61 **** #endif - #ifdef THINK_C - #define HAVE_FOPENRF - #endif #ifdef __MWERKS__ /* Mwerks fopen() doesn't always set errno */ --- 75,78 ---- *************** *** 446,464 **** } - /* We expect that fstat exists on most systems. - It's confirmed on Unix, Mac and Windows. - If you don't have it, add #define DONT_HAVE_FSTAT to your config.h. */ - #ifndef DONT_HAVE_FSTAT - #define HAVE_FSTAT - - #ifndef DONT_HAVE_SYS_TYPES_H - #include - #endif - - #ifndef DONT_HAVE_SYS_STAT_H - #include - #endif - - #endif /* DONT_HAVE_FSTAT */ #if BUFSIZ < 8192 --- 463,466 ---- From python-dev@python.org Wed Jun 28 22:12:28 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 14:12:28 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.162,2.163 Message-ID: <200006282112.OAA03095@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv3006 Modified Files: bltinmodule.c Log Message: Trent Mick: Various small fixes to the builtin module to ensure no buffer overflows. - chunk #1: Proper casting to ensure no truncation, and hence no surprises, in the comparison. - chunk #2: The id() function guarantees a unique return value for different objects. It does this by returning the pointer to the object. By returning a PyInt, on Win64 (sizeof(long) < sizeof(void*)) the pointer is truncated and the guarantee may be proven false. The appropriate return function is PyLong_FromVoidPtr, this returns a PyLong if that is necessary to return the pointer without truncation. [GvR: note that this means that id() can now return a long on Win32 platforms. This *might* break some code...] - chunk #3: Ensure no overflow in raw_input(). Granted the user would have to pass in >2GB of data but it *is* a possible buffer overflow condition. Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.162 retrieving revision 2.163 diff -C2 -r2.162 -r2.163 *** bltinmodule.c 2000/06/20 04:54:19 2.162 --- bltinmodule.c 2000/06/28 21:12:25 2.163 *************** *** 833,837 **** } str = PyString_AsString(cmd); ! if ((int)strlen(str) != PyString_Size(cmd)) { PyErr_SetString(PyExc_ValueError, "embedded '\\0' in string arg"); --- 833,837 ---- } str = PyString_AsString(cmd); ! if (strlen(str) != (size_t)PyString_Size(cmd)) { PyErr_SetString(PyExc_ValueError, "embedded '\\0' in string arg"); *************** *** 986,990 **** if (!PyArg_ParseTuple(args, "O:id", &v)) return NULL; ! return PyInt_FromLong((long)v); } --- 986,990 ---- if (!PyArg_ParseTuple(args, "O:id", &v)) return NULL; ! return PyLong_FromVoidPtr(v); } *************** *** 1874,1878 **** } else { /* strip trailing '\n' */ ! result = PyString_FromStringAndSize(s, strlen(s)-1); } PyMem_FREE(s); --- 1874,1885 ---- } else { /* strip trailing '\n' */ ! size_t len = strlen(s); ! if (len > INT_MAX) { ! PyErr_SetString(PyExc_OverflowError, "input too long"); ! result = NULL; ! } ! else { ! result = PyString_FromStringAndSize(s, (int)(len-1)); ! } } PyMem_FREE(s); From python-dev@python.org Wed Jun 28 22:18:15 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 14:18:15 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules selectmodule.c,2.32,2.33 Message-ID: <200006282118.OAA03485@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv3478 Modified Files: selectmodule.c Log Message: Trent Mick: This patches fixes a possible overflow of the optional timeout parameter for the select() function (selectmodule.c). This timeout is passed in as a double and then truncated to an int. If the double is sufficiently large you can get unexpected results as it overflows. This patch raises an overflow if the given select timeout overflows. [GvR: To my embarrassment, the original code was assuming an int could always hold a million. Note that the overflow check doesn't test for a very large *negative* timeout passed in -- but who in the world would do such a thing?] Index: selectmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/selectmodule.c,v retrieving revision 2.32 retrieving revision 2.33 diff -C2 -r2.32 -r2.33 *** selectmodule.c 2000/05/03 23:44:33 2.32 --- selectmodule.c 2000/06/28 21:18:13 2.33 *************** *** 239,243 **** double timeout; struct timeval tv, *tvp; ! int seconds; int imax, omax, emax, max; int n; --- 239,243 ---- double timeout; struct timeval tv, *tvp; ! long seconds; int imax, omax, emax, max; int n; *************** *** 256,263 **** } else { ! seconds = (int)timeout; timeout = timeout - (double)seconds; tv.tv_sec = seconds; ! tv.tv_usec = (int)(timeout*1000000.0); tvp = &tv; } --- 256,267 ---- } else { ! if (timeout > (double)LONG_MAX) { ! PyErr_SetString(PyExc_OverflowError, "timeout period too long"); ! return NULL; ! } ! seconds = (long)timeout; timeout = timeout - (double)seconds; tv.tv_sec = seconds; ! tv.tv_usec = (long)(timeout*1000000.0); tvp = &tv; } From python-dev@python.org Wed Jun 28 22:23:36 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 14:23:36 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _localemodule.c,2.8,2.9 Message-ID: <200006282123.OAA03699@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv3690 Modified Files: _localemodule.c Log Message: Trent Mick: use size_t instead of int where appropriate (in strxfrm(), to hold strlen() outcome). Index: _localemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_localemodule.c,v retrieving revision 2.8 retrieving revision 2.9 diff -C2 -r2.8 -r2.9 *** _localemodule.c 2000/05/03 22:30:13 2.8 --- _localemodule.c 2000/06/28 21:23:33 2.9 *************** *** 282,286 **** { char *s,*buf; ! int n1,n2; PyObject *result; if(!PyArg_ParseTuple(args,"s:strxfrm",&s)) --- 282,286 ---- { char *s,*buf; ! size_t n1,n2; PyObject *result; if(!PyArg_ParseTuple(args,"s:strxfrm",&s)) From python-dev@python.org Wed Jun 28 22:27:24 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 14:27:24 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules arraymodule.c,2.41,2.42 Message-ID: <200006282127.OAA03807@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv3797 Modified Files: arraymodule.c Log Message: Trent Mick: use size_t instead of int where appropriate (in fromfile(), to hold fread() result.) Index: arraymodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/arraymodule.c,v retrieving revision 2.41 retrieving revision 2.42 diff -C2 -r2.41 -r2.42 *** arraymodule.c 2000/06/28 17:49:30 2.41 --- arraymodule.c 2000/06/28 21:27:21 2.42 *************** *** 1028,1032 **** char *item = self->ob_item; int itemsize = self->ob_descr->itemsize; ! int nread; int newlength; size_t newbytes; --- 1028,1032 ---- char *item = self->ob_item; int itemsize = self->ob_descr->itemsize; ! size_t nread; int newlength; size_t newbytes; *************** *** 1046,1050 **** nread = fread(item + (self->ob_size - n) * itemsize, itemsize, n, fp); ! if (nread < n) { self->ob_size -= (n - nread); PyMem_RESIZE(item, char, self->ob_size*itemsize); --- 1046,1050 ---- nread = fread(item + (self->ob_size - n) * itemsize, itemsize, n, fp); ! if (nread < (size_t)n) { self->ob_size -= (n - nread); PyMem_RESIZE(item, char, self->ob_size*itemsize); From python-dev@python.org Wed Jun 28 22:29:05 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 14:29:05 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules getpath.c,1.22,1.23 Message-ID: <200006282129.OAA03946@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv3939 Modified Files: getpath.c Log Message: Trent Mick: use size_t instead of int where appropriate (various spots). Index: getpath.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/getpath.c,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** getpath.c 2000/05/26 21:49:07 1.22 --- getpath.c 2000/06/28 21:29:03 1.23 *************** *** 164,168 **** char *dir; { ! int i = strlen(dir); while (i > 0 && dir[i] != SEP) --i; --- 164,168 ---- char *dir; { ! size_t i = strlen(dir); while (i > 0 && dir[i] != SEP) --i; *************** *** 242,246 **** char *stuff; { ! int n, k; if (stuff[0] == SEP) n = 0; --- 242,246 ---- char *stuff; { ! size_t n, k; if (stuff[0] == SEP) n = 0; *************** *** 263,267 **** char *home; { ! int n; char *vpath; --- 263,267 ---- char *home; { ! size_t n; char *vpath; *************** *** 332,336 **** char *home; { ! int n; /* If PYTHONHOME is set, we believe it unconditionally */ --- 332,336 ---- char *home; { ! size_t n; /* If PYTHONHOME is set, we believe it unconditionally */ *************** *** 394,399 **** int pfound, efound; /* 1 if found; -1 if found build directory */ char *buf; ! int bufsz; ! int prefixsz; char *defpath = pythonpath; #ifdef WITH_NEXT_FRAMEWORK --- 394,399 ---- int pfound, efound; /* 1 if found; -1 if found build directory */ char *buf; ! size_t bufsz; ! size_t prefixsz; char *defpath = pythonpath; #ifdef WITH_NEXT_FRAMEWORK *************** *** 430,434 **** if (delim) { ! int len = delim - path; strncpy(progpath, path, len); *(progpath + len) = '\0'; --- 430,434 ---- if (delim) { ! size_t len = delim - path; strncpy(progpath, path, len); *(progpath + len) = '\0'; *************** *** 558,563 **** if (delim) { ! int len = delim - defpath + 1; ! int end = strlen(buf) + len; strncat(buf, defpath, len); *(buf + end) = '\0'; --- 558,563 ---- if (delim) { ! size_t len = delim - defpath + 1; ! size_t end = strlen(buf) + len; strncat(buf, defpath, len); *(buf + end) = '\0'; From python-dev@python.org Wed Jun 28 22:29:49 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 14:29:49 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules mpzmodule.c,2.23,2.24 Message-ID: <200006282129.OAA03993@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv3986 Modified Files: mpzmodule.c Log Message: Trent Mick: use size_t instead of int where appropriate (mpz_format()). Index: mpzmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/mpzmodule.c,v retrieving revision 2.23 retrieving revision 2.24 diff -C2 -r2.23 -r2.24 *** mpzmodule.c 2000/05/03 23:44:32 2.23 --- mpzmodule.c 2000/06/28 21:29:47 2.24 *************** *** 144,148 **** mpzobject *mpzp = (mpzobject *)objp; PyStringObject *strobjp; ! int i; int cmpres; int taglong; --- 144,148 ---- mpzobject *mpzp = (mpzobject *)objp; PyStringObject *strobjp; ! size_t i; int cmpres; int taglong; From python-dev@python.org Wed Jun 28 22:30:34 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 14:30:34 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules readline.c,2.17,2.18 Message-ID: <200006282130.OAA04055@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv4047 Modified Files: readline.c Log Message: Trent Mick: use size_t instead of int where appropriate (call_readline()). Index: readline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v retrieving revision 2.17 retrieving revision 2.18 diff -C2 -r2.17 -r2.18 *** readline.c 2000/05/03 23:44:33 2.17 --- readline.c 2000/06/28 21:30:31 2.18 *************** *** 377,381 **** char *prompt; { ! int n; char *p, *q; RETSIGTYPE (*old_inthandler)(); --- 377,381 ---- char *prompt; { ! size_t n; char *p, *q; RETSIGTYPE (*old_inthandler)(); From python-dev@python.org Wed Jun 28 22:31:13 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 14:31:13 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules rotormodule.c,2.23,2.24 Message-ID: <200006282131.OAA04112@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv4104 Modified Files: rotormodule.c Log Message: Trent Mick: use size_t instead of int where appropriate (set_key()). Index: rotormodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/rotormodule.c,v retrieving revision 2.23 retrieving revision 2.24 diff -C2 -r2.23 -r2.24 *** rotormodule.c 2000/05/03 23:44:33 2.23 --- rotormodule.c 2000/06/28 21:31:10 2.24 *************** *** 148,153 **** { unsigned long k1=995, k2=576, k3=767, k4=671, k5=463; ! int i; ! int len = strlen(key); for (i = 0; i < len; i++) { --- 148,153 ---- { unsigned long k1=995, k2=576, k3=767, k4=671, k5=463; ! size_t i; ! size_t len = strlen(key); for (i = 0; i < len; i++) { From python-dev@python.org Wed Jun 28 22:34:02 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 14:34:02 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules timemodule.c,2.83,2.84 Message-ID: <200006282134.OAA04279@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv4272 Modified Files: timemodule.c Log Message: Trent Mick: use size_t instead of int where appropriate (time_strftime()). Index: timemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/timemodule.c,v retrieving revision 2.83 retrieving revision 2.84 diff -C2 -r2.83 -r2.84 *** timemodule.c 2000/05/09 19:52:40 2.83 --- timemodule.c 2000/06/28 21:33:59 2.84 *************** *** 379,385 **** struct tm buf; const char *fmt; ! int fmtlen, buflen; char *outbuf = 0; ! int i; memset((ANY *) &buf, '\0', sizeof(buf)); --- 379,385 ---- struct tm buf; const char *fmt; ! size_t fmtlen, buflen; char *outbuf = 0; ! size_t i; memset((ANY *) &buf, '\0', sizeof(buf)); From python-dev@python.org Wed Jun 28 22:51:46 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 14:51:46 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libhttplib.tex,1.19,1.20 Message-ID: <200006282151.OAA05489@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv5474/lib Modified Files: libhttplib.tex Log Message: Skip Montanaro : Added an example of using an HTTP POST request. Index: libhttplib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libhttplib.tex,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -r1.19 -r1.20 *** libhttplib.tex 1999/04/22 16:47:27 1.19 --- libhttplib.tex 2000/06/28 21:51:43 1.20 *************** *** 115,119 **** \nodename{HTTP Example} ! Here is an example session: \begin{verbatim} --- 115,119 ---- \nodename{HTTP Example} ! Here is an example session that uses the \samp{GET} method: \begin{verbatim} *************** *** 129,131 **** --- 129,148 ---- >>> data = f.read() # Get the raw HTML >>> f.close() + \end{verbatim} + + Here is an example session that shows how to \samp{POST} requests: + + \begin{verbatim} + >>> import httplib, urllib + >>> params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0}) + >>> h = httplib.HTTP("www.musi-cal.com:80") + >>> h.putrequest("POST", "/cgi-bin/query") + >>> h.putheader("Content-length", "%d" % len(params)) + >>> h.putheader('Accept', 'text/plain') + >>> h.putheader('Host', 'www.musi-cal.com') + >>> h.endheaders() + >>> h.send(paramstring) + >>> reply, msg, hdrs = h.getreply() + >>> print errcode # should be 200 + >>> data = h.getfile().read() # get the raw HTML \end{verbatim} From python-dev@python.org Wed Jun 28 22:57:20 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 14:57:20 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects classobject.c,2.89,2.90 object.c,2.72,2.73 Message-ID: <200006282157.OAA05880@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv5838 Modified Files: classobject.c object.c Log Message: Trent Mick: change a few casts for Win64 compatibility. Index: classobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v retrieving revision 2.89 retrieving revision 2.90 diff -C2 -r2.89 -r2.90 *** classobject.c 2000/06/23 19:37:01 2.89 --- classobject.c 2000/06/28 21:57:18 2.90 *************** *** 284,288 **** if (v == NULL || !PyString_Check(v)) return "__name__ must be a string object"; ! if ((long)strlen(PyString_AS_STRING(v)) != PyString_GET_SIZE(v)) return "__name__ must not contain null bytes"; set_slot(&c->cl_name, v); --- 284,288 ---- if (v == NULL || !PyString_Check(v)) return "__name__ must be a string object"; ! if (strlen(PyString_AS_STRING(v)) != (size_t)PyString_GET_SIZE(v)) return "__name__ must not contain null bytes"; set_slot(&c->cl_name, v); Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.72 retrieving revision 2.73 diff -C2 -r2.72 -r2.73 *** object.c 2000/06/23 14:36:32 2.72 --- object.c 2000/06/28 21:57:18 2.73 *************** *** 367,371 **** return NULL; } ! if ((long)v <= (long)w) { PyTuple_SET_ITEM(pair, 0, PyLong_FromVoidPtr((void *)v)); PyTuple_SET_ITEM(pair, 1, PyLong_FromVoidPtr((void *)w)); --- 367,371 ---- return NULL; } ! if (v <= w) { PyTuple_SET_ITEM(pair, 0, PyLong_FromVoidPtr((void *)v)); PyTuple_SET_ITEM(pair, 1, PyLong_FromVoidPtr((void *)w)); From python-dev@python.org Wed Jun 28 23:00:05 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 15:00:05 -0700 Subject: [Python-checkins] CVS: python/dist/src/Parser myreadline.c,2.17,2.18 parsetok.c,2.17,2.18 pgenmain.c,2.16,2.17 tokenizer.c,2.41,2.42 Message-ID: <200006282200.PAA06324@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Parser In directory slayer.i.sourceforge.net:/tmp/cvs-serv6150 Modified Files: myreadline.c parsetok.c pgenmain.c tokenizer.c Log Message: Trent Mick: familiar simple Win64 patches Index: myreadline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/myreadline.c,v retrieving revision 2.17 retrieving revision 2.18 diff -C2 -r2.17 -r2.18 *** myreadline.c 2000/05/03 23:44:37 2.17 --- myreadline.c 2000/06/28 22:00:02 2.18 *************** *** 87,91 **** char *prompt; { ! int n; char *p; n = 100; --- 87,91 ---- char *prompt; { ! size_t n; char *p; n = 100; *************** *** 96,100 **** fprintf(stderr, "%s", prompt); fflush(stderr); ! switch (my_fgets(p, n, stdin)) { case 0: /* Normal case */ break; --- 96,100 ---- fprintf(stderr, "%s", prompt); fflush(stderr); ! switch (my_fgets(p, (int)n, stdin)) { case 0: /* Normal case */ break; *************** *** 117,125 **** n = strlen(p); while (n > 0 && p[n-1] != '\n') { ! int incr = n+2; p = PyMem_REALLOC(p, n + incr); if (p == NULL) return NULL; ! if (my_fgets(p+n, incr, stdin) != 0) break; n += strlen(p+n); --- 117,128 ---- n = strlen(p); while (n > 0 && p[n-1] != '\n') { ! size_t incr = n+2; p = PyMem_REALLOC(p, n + incr); if (p == NULL) return NULL; ! if (incr > INT_MAX) { ! PyErr_SetString(PyExc_OverflowError, "input line too long"); ! } ! if (my_fgets(p+n, (int)incr, stdin) != 0) break; n += strlen(p+n); Index: parsetok.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/parsetok.c,v retrieving revision 2.17 retrieving revision 2.18 diff -C2 -r2.17 -r2.18 *** parsetok.c 2000/06/28 20:54:53 2.17 --- parsetok.c 2000/06/28 22:00:02 2.18 *************** *** 137,141 **** char *a, *b; int type; ! int len; char *str; --- 137,141 ---- char *a, *b; int type; ! size_t len; char *str; *************** *** 185,189 **** err_ret->offset = tok->cur - tok->buf; if (tok->buf != NULL) { ! int len = tok->inp - tok->buf; err_ret->text = PyMem_NEW(char, len + 1); if (err_ret->text != NULL) { --- 185,189 ---- err_ret->offset = tok->cur - tok->buf; if (tok->buf != NULL) { ! size_t len = tok->inp - tok->buf; err_ret->text = PyMem_NEW(char, len + 1); if (err_ret->text != NULL) { Index: pgenmain.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/pgenmain.c,v retrieving revision 2.16 retrieving revision 2.17 diff -C2 -r2.16 -r2.17 *** pgenmain.c 2000/05/03 23:44:37 2.16 --- pgenmain.c 2000/06/28 22:00:02 2.17 *************** *** 128,132 **** err.error, err.lineno); if (err.text != NULL) { ! int i; fprintf(stderr, "%s", err.text); i = strlen(err.text); --- 128,132 ---- err.error, err.lineno); if (err.text != NULL) { ! size_t i; fprintf(stderr, "%s", err.text); i = strlen(err.text); *************** *** 196,200 **** char *prompt; { ! int n = 1000; char *p = PyMem_MALLOC(n); char *q; --- 196,200 ---- char *prompt; { ! size_t n = 1000; char *p = PyMem_MALLOC(n); char *q; Index: tokenizer.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/tokenizer.c,v retrieving revision 2.41 retrieving revision 2.42 diff -C2 -r2.41 -r2.42 *** tokenizer.c 2000/05/03 23:44:37 2.41 --- tokenizer.c 2000/06/28 22:00:02 2.42 *************** *** 224,230 **** } else if (tok->start != NULL) { ! int start = tok->start - tok->buf; ! int oldlen = tok->cur - tok->buf; ! int newlen = oldlen + strlen(new); char *buf = tok->buf; PyMem_RESIZE(buf, char, newlen+1); --- 224,230 ---- } else if (tok->start != NULL) { ! size_t start = tok->start - tok->buf; ! size_t oldlen = tok->cur - tok->buf; ! size_t newlen = oldlen + strlen(new); char *buf = tok->buf; PyMem_RESIZE(buf, char, newlen+1); From python-dev@python.org Wed Jun 28 23:03:31 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 15:03:31 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libascii.tex,1.1,1.2 Message-ID: <200006282203.PAA12652@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv12636/lib Modified Files: libascii.tex Log Message: Added entries for the curses.ascii module. Index: libascii.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libascii.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** libascii.tex 2000/06/26 23:59:24 1.1 --- libascii.tex 2000/06/28 22:03:29 1.2 *************** *** 1,7 **** \section{\module{curses.ascii} --- ! Constants and set-membership functions for ASCII characters.} \declaremodule{standard}{curses.ascii} ! \modulesynopsis{Constants and set-membership functions for ASCII characters.} \moduleauthor{Eric S. Raymond}{esr@thyrsus.com} \sectionauthor{Eric S. Raymond}{esr@thyrsus.com} --- 1,8 ---- \section{\module{curses.ascii} --- ! Utilities for ASCII characters} \declaremodule{standard}{curses.ascii} ! \modulesynopsis{Constants and set-membership functions for ! \ASCII{} characters.} \moduleauthor{Eric S. Raymond}{esr@thyrsus.com} \sectionauthor{Eric S. Raymond}{esr@thyrsus.com} *************** *** 9,90 **** \versionadded{1.6} ! The \module{curses.ascii} module supplies name constants for ASCII characters ! and functions to test membership in various ASCII character classes. ! The constants supplied are names for control characters as follows: ! ! NUL, SOH, STX, ETX, EOT, ENQ, ACK, BEL, BS, TAB, HT, LF, NL, VT, FF, CR, ! SO, SI, DLE, DC1, DC2, DC3, DC4, NAK, SYN, ETB, CAN, EM, SUB, ESC, FS, ! GS, RS, US, SP, DEL. ! NL and LF are synonyms; so are HT and TAB. The module also supplies ! the following functions, patterned on those in the standard C library: \begin{funcdesc}{isalnum}{c} ! Checks for an ASCII alphanumeric character; it is equivalent to ! isalpha(c) or isdigit(c)) \end{funcdesc} \begin{funcdesc}{isalpha}{c} ! Checks for an ASCII alphabetic character; it is equivalent to ! isupper(c) or islower(c)) \end{funcdesc} \begin{funcdesc}{isascii}{c} ! Checks for a character value that fits in the 7-bit ASCII set. \end{funcdesc} \begin{funcdesc}{isblank}{c} ! Checks for an ASCII alphanumeric character; it is equivalent to ! isalpha(c) or isdigit(c)) \end{funcdesc} \begin{funcdesc}{iscntrl}{c} ! Checks for an ASCII control character (range 0x00 to 0x1f). \end{funcdesc} \begin{funcdesc}{isdigit}{c} ! Checks for an ASCII decimal digit, 0 through 9. \end{funcdesc} \begin{funcdesc}{isgraph}{c} ! Checks for ASCII any printable character except space. \end{funcdesc} \begin{funcdesc}{islower}{c} ! Checks for an ASCII lower-case character. \end{funcdesc} \begin{funcdesc}{isprint}{c} ! Checks for any ASCII printable character including space. \end{funcdesc} \begin{funcdesc}{ispunct}{c} ! Checks for any printable ASCII character which is not a space or an alphanumeric character. \end{funcdesc} \begin{funcdesc}{isspace}{c} ! Checks for ASCII white-space characters; space, tab, line feed, carriage return, form feed, horizontal tab, vertical tab. \end{funcdesc} \begin{funcdesc}{isupper}{c} ! Checks for an ASCII uppercase letter. \end{funcdesc} \begin{funcdesc}{isxdigit}{c} ! Checks for an ASCII hexadecimal digit, i.e. one of 0123456789abcdefABCDEF. \end{funcdesc} \begin{funcdesc}{isctrl}{c} ! Checks for an ASCII control character, bit values 0 to 31. \end{funcdesc} \begin{funcdesc}{ismeta}{c} ! Checks for a (non-ASCII) character, bit values 0x80 and above. \end{funcdesc} These functions accept either integers or strings; when the argument ! is a string, it is first converted using the built-in function ord(). Note that all these functions check ordinal bit values derived from the --- 10,132 ---- \versionadded{1.6} ! The \module{curses.ascii} module supplies name constants for ! \ASCII{} characters and functions to test membership in various ! \ASCII{} character classes. The constants supplied are names for ! control characters as follows: ! ! \begin{tableii}{l|l}{constant}{Name}{Meaning} ! \lineii{NUL}{} ! \lineii{SOH}{Start of heading, console interrupt} ! \lineii{STX}{Start of text} ! \lineii{ETX}{Ennd of text} ! \lineii{EOT}{End of transmission} ! \lineii{ENQ}{Enquiry, goes with \constant{ACK} flow control} ! \lineii{ACK}{Acknowledgement} ! \lineii{BEL}{Bell} ! \lineii{BS}{Backspace} ! \lineii{TAB}{Tab} ! \lineii{HT}{Alias for \constant{TAB}: ``Horizontal tab''} ! \lineii{LF}{Line feed} ! \lineii{NL}{Alias for \constant{LF}: ``New line''} ! \lineii{VT}{Vertical tab} ! \lineii{FF}{Form feed} ! \lineii{CR}{Carriage return} ! \lineii{SO}{Shift-out, begin alternate character set} ! \lineii{SI}{Shift-in, resume default character set} ! \lineii{DLE}{Data-link escape} ! \lineii{DC1}{XON, for flow control} ! \lineii{DC2}{Device control 2, block-mode flow control} ! \lineii{DC3}{XOFF, for flow control} ! \lineii{DC4}{Device control 4} ! \lineii{NAK}{Negative acknowledgement} ! \lineii{SYN}{Synchronous idle} ! \lineii{ETB}{End transmission block} ! \lineii{CAN}{Cancel} ! \lineii{EM}{End of medium} ! \lineii{SUB}{Substitute} ! \lineii{ESC}{Escape} ! \lineii{FS}{File separator} ! \lineii{GS}{Group separator} ! \lineii{RS}{Record separator, block-mode terminator} ! \lineii{US}{Unit separator} ! \lineii{SP}{Space} ! \lineii{DEL}{Delete} ! \end{tableii} ! Note that many of these have little practical use in modern usage. + The module supplies the following functions, patterned on those in the + standard C library: + + \begin{funcdesc}{isalnum}{c} ! Checks for an \ASCII{} alphanumeric character; it is equivalent to ! \samp{isalpha(\var{c}) or isdigit(\var{c})}. \end{funcdesc} \begin{funcdesc}{isalpha}{c} ! Checks for an \ASCII{} alphabetic character; it is equivalent to ! \samp{isupper(\var{c}) or islower(\var{c})}. \end{funcdesc} \begin{funcdesc}{isascii}{c} ! Checks for a character value that fits in the 7-bit \ASCII{} set. \end{funcdesc} \begin{funcdesc}{isblank}{c} ! Checks for an \ASCII{} whitespace character. \end{funcdesc} \begin{funcdesc}{iscntrl}{c} ! Checks for an \ASCII{} control character (in the range 0x00 to 0x1f). \end{funcdesc} \begin{funcdesc}{isdigit}{c} ! Checks for an \ASCII{} decimal digit, \character{0} through ! \character{9}. This is equivalent to \samp{\var{c} in string.digits}. \end{funcdesc} \begin{funcdesc}{isgraph}{c} ! Checks for \ASCII{} any printable character except space. \end{funcdesc} \begin{funcdesc}{islower}{c} ! Checks for an \ASCII{} lower-case character. \end{funcdesc} \begin{funcdesc}{isprint}{c} ! Checks for any \ASCII{} printable character including space. \end{funcdesc} \begin{funcdesc}{ispunct}{c} ! Checks for any printable \ASCII{} character which is not a space or an alphanumeric character. \end{funcdesc} \begin{funcdesc}{isspace}{c} ! Checks for \ASCII{} white-space characters; space, tab, line feed, carriage return, form feed, horizontal tab, vertical tab. \end{funcdesc} \begin{funcdesc}{isupper}{c} ! Checks for an \ASCII{} uppercase letter. \end{funcdesc} \begin{funcdesc}{isxdigit}{c} ! Checks for an \ASCII{} hexadecimal digit. This is equivalent to ! \samp{\var{c} in string.hexdigits}. \end{funcdesc} \begin{funcdesc}{isctrl}{c} ! Checks for an \ASCII{} control character (ordinal values 0 to 31). \end{funcdesc} \begin{funcdesc}{ismeta}{c} ! Checks for a non-\ASCII{} character (ordinal values 0x80 and above). \end{funcdesc} These functions accept either integers or strings; when the argument ! is a string, it is first converted using the built-in function ! \function{ord()}. Note that all these functions check ordinal bit values derived from the *************** *** 92,96 **** anything about the host machine's character encoding. For functions that know about the character encoding (and handle ! internationalization properly) see the string module. The following two functions take either a single-character string or --- 134,138 ---- anything about the host machine's character encoding. For functions that know about the character encoding (and handle ! internationalization properly) see the \refmodule{string} module. The following two functions take either a single-character string or *************** *** 98,131 **** \begin{funcdesc}{ascii}{c} ! Return the ASCII value corresponding to the low 7 bits of c. \end{funcdesc} \begin{funcdesc}{ctrl}{c} Return the control character corresponding to the given character ! (the character bit value is logical-anded with 0x1f). \end{funcdesc} \begin{funcdesc}{alt}{c} Return the 8-bit character corresponding to the given ASCII character ! (the character bit value is logical-ored with 0x80). \end{funcdesc} The following function takes either a single-character string or ! integer byte value; it returns a string. \begin{funcdesc}{unctrl}{c} ! Return a string representation of the ASCII character c. If c is ! printable, this string is the character itself. If the character ! is a control character (0x00-0x1f) the string consists of a caret ! (^) followed by the corresponding uppercase letter. If the character ! is an ASCII delete (0x7f) the string is "^?". If the character has ! its meta bit (0x80) set, the meta bit is stripped, the preceding rules ! applied, and "!" prepended to the result. \end{funcdesc} - - Finally, the module supplies a 33-element string array - called controlnames that contains the ASCII mnemonics for the - thirty-two ASCII control characters from 0 (NUL) to 0x1f (US), - in order, plus the mnemonic "SP" for space. ! --- 140,173 ---- \begin{funcdesc}{ascii}{c} ! Return the ASCII value corresponding to the low 7 bits of \var{c}. \end{funcdesc} \begin{funcdesc}{ctrl}{c} Return the control character corresponding to the given character ! (the character bit value is bitwise-anded with 0x1f). \end{funcdesc} \begin{funcdesc}{alt}{c} Return the 8-bit character corresponding to the given ASCII character ! (the character bit value is bitwise-ored with 0x80). \end{funcdesc} The following function takes either a single-character string or ! integer value; it returns a string. \begin{funcdesc}{unctrl}{c} ! Return a string representation of the \ASCII{} character \var{c}. If ! \var{c} is printable, this string is the character itself. If the ! character is a control character (0x00-0x1f) the string consists of a ! caret (\character{\^}) followed by the corresponding uppercase letter. ! If the character is an \ASCII{} delete (0x7f) the string is ! \code{'\^{}?'}. If the character has its meta bit (0x80) set, the meta ! bit is stripped, the preceding rules applied, and ! \character{!} prepended to the result. \end{funcdesc} ! \begin{datadesc}{controlnames} ! A 33-element string array that contains the \ASCII{} mnemonics for the ! thirty-two \ASCII{} control characters from 0 (NUL) to 0x1f (US), in ! order, plus the mnemonic \samp{SP} for the space character. ! \end{datadesc} From python-dev@python.org Wed Jun 28 23:03:31 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 15:03:31 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc Makefile.deps,1.33,1.34 Message-ID: <200006282203.PAA12651@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc In directory slayer.i.sourceforge.net:/tmp/cvs-serv12636 Modified Files: Makefile.deps Log Message: Added entries for the curses.ascii module. Index: Makefile.deps =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile.deps,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -r1.33 -r1.34 *** Makefile.deps 2000/06/28 15:07:31 1.33 --- Makefile.deps 2000/06/28 22:03:28 1.34 *************** *** 219,222 **** --- 219,223 ---- ../lib/libcodeop.tex \ ../lib/libcurses.tex \ + ../lib/libascii.tex \ ../lib/libdl.tex \ ../lib/libmutex.tex \ From python-dev@python.org Wed Jun 28 23:05:47 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 15:05:47 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib lib.tex,1.153,1.154 Message-ID: <200006282205.PAA12797@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv12789/lib Modified Files: lib.tex Log Message: Added entry for the curses.ascii module. Index: lib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/lib.tex,v retrieving revision 1.153 retrieving revision 1.154 diff -C2 -r1.153 -r1.154 *** lib.tex 2000/06/28 15:07:30 1.153 --- lib.tex 2000/06/28 22:05:44 1.154 *************** *** 147,150 **** --- 147,151 ---- \input{libgetpass} \input{libcurses} + \input{libascii} % curses.ascii \input{libgetopt} \input{libtempfile} From python-dev@python.org Wed Jun 28 23:07:38 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 15:07:38 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python ceval.c,2.179,2.180 codecs.c,2.6,2.7 compile.c,2.108,2.109 dynload_win.c,2.2,2.3 getcwd.c,1.9,1.10 modsupport.c,2.42,2.43 sysmodule.c,2.65,2.66 thread_nt.h,2.9,2.10 traceback.c,2.27,2.28 Message-ID: <200006282207.PAA12886@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv12842 Modified Files: ceval.c codecs.c compile.c dynload_win.c getcwd.c modsupport.c sysmodule.c thread_nt.h traceback.c Log Message: Trent Mick's Win64 changes: size_t vs. int or long; also some overflow tests. Index: ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.179 retrieving revision 2.180 diff -C2 -r2.179 -r2.180 *** ceval.c 2000/05/08 14:06:50 2.179 --- ceval.c 2000/06/28 22:07:35 2.180 *************** *** 2877,2881 **** else { char *s = PyString_AsString(prog); ! if ((int)strlen(s) != PyString_Size(prog)) { PyErr_SetString(PyExc_ValueError, "embedded '\\0' in exec string"); --- 2877,2881 ---- else { char *s = PyString_AsString(prog); ! if (strlen(s) != (size_t)PyString_Size(prog)) { PyErr_SetString(PyExc_ValueError, "embedded '\\0' in exec string"); Index: codecs.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/codecs.c,v retrieving revision 2.6 retrieving revision 2.7 diff -C2 -r2.6 -r2.7 *** codecs.c 2000/05/09 19:55:59 2.6 --- codecs.c 2000/06/28 22:07:35 2.7 *************** *** 84,92 **** { register int i; ! int len = strlen(string); char *p; PyObject *v; ! v = PyString_FromStringAndSize(NULL, len); if (v == NULL) return NULL; --- 84,97 ---- { register int i; ! size_t len = strlen(string); char *p; PyObject *v; ! if (len > INT_MAX) { ! PyErr_SetString(PyExc_OverflowError, "string is too large"); ! return NULL; ! } ! ! v = PyString_FromStringAndSize(NULL, (int)len); if (v == NULL) return NULL; Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.108 retrieving revision 2.109 diff -C2 -r2.108 -r2.109 *** compile.c 2000/05/03 23:44:38 2.108 --- compile.c 2000/06/28 22:07:35 2.109 *************** *** 266,271 **** continue; p = PyString_AsString(v); ! if ((int)strspn(p, NAME_CHARS) ! != PyString_Size(v)) continue; PyString_InternInPlace(&PyTuple_GET_ITEM(consts, i)); --- 266,271 ---- continue; p = PyString_AsString(v); ! if (strspn(p, NAME_CHARS) ! != (size_t)PyString_Size(v)) continue; PyString_InternInPlace(&PyTuple_GET_ITEM(consts, i)); *************** *** 341,345 **** char *msg; { ! int n = strlen(msg); PyObject *v; char buffer[30]; --- 341,345 ---- char *msg; { ! size_t n = strlen(msg); PyObject *v; char buffer[30]; *************** *** 721,730 **** char *name; char *buffer; ! int maxlen; { /* Name mangling: __private becomes _classname__private. This is independent from how the name is used. */ char *p; ! int nlen, plen; nlen = strlen(name); if (nlen+2 >= maxlen) --- 721,730 ---- char *name; char *buffer; ! size_t maxlen; { /* Name mangling: __private becomes _classname__private. This is independent from how the name is used. */ char *p; ! size_t nlen, plen; nlen = strlen(name); if (nlen+2 >= maxlen) *************** *** 762,766 **** if (name != NULL && name[0] == '_' && name[1] == '_' && c->c_private != NULL && ! com_mangle(c, name, buffer, (int)sizeof(buffer))) name = buffer; #endif --- 762,766 ---- if (name != NULL && name[0] == '_' && name[1] == '_' && c->c_private != NULL && ! com_mangle(c, name, buffer, sizeof(buffer))) name = buffer; #endif *************** *** 884,888 **** { PyObject *v; ! int len; char *buf; char *p; --- 884,888 ---- { PyObject *v; ! size_t len; char *buf; char *p; *************** *** 909,912 **** --- 909,916 ---- s++; len = strlen(s); + if (len > INT_MAX) { + PyErr_SetString(PyExc_OverflowError, "string to parse is too long"); + return NULL; + } if (s[--len] != quote) { PyErr_BadInternalCall(); *************** *** 2202,2206 **** if (s != NULL && s[0] == '_' && s[1] == '_' && c->c_private != NULL && ! com_mangle(c, s, buffer, (int)sizeof(buffer))) s = buffer; #endif --- 2206,2210 ---- if (s != NULL && s[0] == '_' && s[1] == '_' && c->c_private != NULL && ! com_mangle(c, s, buffer, sizeof(buffer))) s = buffer; #endif Index: dynload_win.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/dynload_win.c,v retrieving revision 2.2 retrieving revision 2.3 diff -C2 -r2.2 -r2.3 *** dynload_win.c 1999/12/22 14:09:35 2.2 --- dynload_win.c 2000/06/28 22:07:35 2.3 *************** *** 105,109 **** errorCode); } else { ! int len; /* For some reason a \r\n is appended to the text */ --- 105,109 ---- errorCode); } else { ! size_t len; /* For some reason a \r\n is appended to the text */ Index: getcwd.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/getcwd.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** getcwd.c 1996/10/25 14:43:14 1.9 --- getcwd.c 2000/06/28 22:07:35 1.10 *************** *** 63,67 **** } ret = getwd(localbuf); ! if (ret != NULL && strlen(localbuf) >= size) { errno = ERANGE; return NULL; --- 63,67 ---- } ret = getwd(localbuf); ! if (ret != NULL && strlen(localbuf) >= (size_t)size) { errno = ERANGE; return NULL; Index: modsupport.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/modsupport.c,v retrieving revision 2.42 retrieving revision 2.43 diff -C2 -r2.42 -r2.43 *** modsupport.c 2000/04/28 14:42:37 2.42 --- modsupport.c 2000/06/28 22:07:35 2.43 *************** *** 356,361 **** } else { ! if (n < 0) ! n = strlen(str); v = PyString_FromStringAndSize(str, n); } --- 356,368 ---- } else { ! if (n < 0) { ! size_t m = strlen(str); ! if (m > INT_MAX) { ! PyErr_SetString(PyExc_OverflowError, ! "string too long for Python string"); ! return NULL; ! } ! n = (int)m; ! } v = PyString_FromStringAndSize(str, n); } Index: sysmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v retrieving revision 2.65 retrieving revision 2.66 diff -C2 -r2.65 -r2.66 *** sysmodule.c 2000/06/20 08:12:48 2.65 --- sysmodule.c 2000/06/28 22:07:35 2.66 *************** *** 505,509 **** #ifdef MS_COREDLL PyDict_SetItemString(sysdict, "dllhandle", ! v = PyInt_FromLong((int)PyWin_DLLhModule)); Py_XDECREF(v); PyDict_SetItemString(sysdict, "winver", --- 505,509 ---- #ifdef MS_COREDLL PyDict_SetItemString(sysdict, "dllhandle", ! v = PyLong_FromVoidPtr(PyWin_DLLhModule)); Py_XDECREF(v); PyDict_SetItemString(sysdict, "winver", Index: thread_nt.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_nt.h,v retrieving revision 2.9 retrieving revision 2.10 diff -C2 -r2.9 -r2.10 *** thread_nt.h 2000/05/11 12:53:51 2.9 --- thread_nt.h 2000/06/28 22:07:35 2.10 *************** *** 102,105 **** --- 102,108 ---- } + #ifdef InterlockedCompareExchange + #undef InterlockedCompareExchange + #endif #define InterlockedCompareExchange(dest,exchange,comperand) (ixchg((dest), (exchange), (comperand))) *************** *** 180,184 **** int PyThread_start_new_thread(void (*func)(void *), void *arg) { ! long rv; int success = 0; --- 183,187 ---- int PyThread_start_new_thread(void (*func)(void *), void *arg) { ! INT_PTR rv; int success = 0; *************** *** 191,195 **** if (rv != -1) { success = 1; ! dprintf(("%ld: PyThread_start_new_thread succeeded: %ld\n", PyThread_get_thread_ident(), rv)); } --- 194,198 ---- if (rv != -1) { success = 1; ! dprintf(("%ld: PyThread_start_new_thread succeeded: %p\n", PyThread_get_thread_ident(), rv)); } Index: traceback.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/traceback.c,v retrieving revision 2.27 retrieving revision 2.28 diff -C2 -r2.27 -r2.28 *** traceback.c 2000/05/03 23:44:39 2.27 --- traceback.c 2000/06/28 22:07:35 2.28 *************** *** 167,171 **** if (path != NULL && PyList_Check(path)) { int npath = PyList_Size(path); ! int taillen = strlen(tail); char namebuf[MAXPATHLEN+1]; for (i = 0; i < npath; i++) { --- 167,171 ---- if (path != NULL && PyList_Check(path)) { int npath = PyList_Size(path); ! size_t taillen = strlen(tail); char namebuf[MAXPATHLEN+1]; for (i = 0; i < npath; i++) { *************** *** 176,185 **** } if (PyString_Check(v)) { ! int len; len = PyString_Size(v); if (len + 1 + taillen >= MAXPATHLEN) continue; /* Too long */ strcpy(namebuf, PyString_AsString(v)); ! if ((int)strlen(namebuf) != len) continue; /* v contains '\0' */ if (len > 0 && namebuf[len-1] != SEP) --- 176,185 ---- } if (PyString_Check(v)) { ! size_t len; len = PyString_Size(v); if (len + 1 + taillen >= MAXPATHLEN) continue; /* Too long */ strcpy(namebuf, PyString_AsString(v)); ! if (strlen(namebuf) != len) continue; /* v contains '\0' */ if (len > 0 && namebuf[len-1] != SEP) From python-dev@python.org Wed Jun 28 23:07:57 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 15:07:57 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libatexit.tex,1.1,1.2 Message-ID: <200006282207.PAA12913@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv12906/lib Modified Files: libatexit.tex Log Message: Added note that the atexit module was added for Python 1.6. Index: libatexit.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libatexit.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** libatexit.tex 2000/06/28 15:07:30 1.1 --- libatexit.tex 2000/06/28 22:07:55 1.2 *************** *** 7,10 **** --- 7,12 ---- \modulesynopsis{Register and execute cleanup functions.} + \versionadded{1.6} + The \module{atexit} module defines a single function to register cleanup functions. Functions thus registered are automatically From python-dev@python.org Wed Jun 28 23:09:23 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 15:09:23 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libhttplib.tex,1.20,1.21 Message-ID: <200006282209.PAA13079@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv13070/lib Modified Files: libhttplib.tex Log Message: Made the title of the Examples subsection plural! Index: libhttplib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libhttplib.tex,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -r1.20 -r1.21 *** libhttplib.tex 2000/06/28 21:51:43 1.20 --- libhttplib.tex 2000/06/28 22:09:20 1.21 *************** *** 112,117 **** \end{methoddesc} ! \subsection{Example} ! \nodename{HTTP Example} Here is an example session that uses the \samp{GET} method: --- 112,117 ---- \end{methoddesc} ! \subsection{Examples} ! \nodename{HTTP Examples} Here is an example session that uses the \samp{GET} method: From python-dev@python.org Wed Jun 28 23:11:42 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 15:11:42 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libcurses.tex,1.5,1.6 Message-ID: <200006282211.PAA13181@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv13169/lib Modified Files: libcurses.tex Log Message: Add a "See also:" link to the curses.ascii module. Index: libcurses.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcurses.tex,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** libcurses.tex 2000/06/21 01:42:51 1.5 --- libcurses.tex 2000/06/28 22:11:40 1.6 *************** *** 16,19 **** --- 16,22 ---- \begin{seealso} + \seemodule{curses.ascii}{Utilities for working with \ASCII{} + characters, regardless of your locale + settings.} \seetext{Tutorial material on using curses with Python is available on the Python Web site as Andrew Kuchling's From python-dev@python.org Wed Jun 28 23:13:09 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 15:13:09 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc TODO,1.26,1.27 Message-ID: <200006282213.PAA13365@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc In directory slayer.i.sourceforge.net:/tmp/cvs-serv13357 Modified Files: TODO Log Message: Give Moshe some work to do. Index: TODO =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/TODO,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -r1.26 -r1.27 *** TODO 1999/12/23 17:22:13 1.26 --- TODO 2000/06/28 22:13:06 1.27 *************** *** 32,35 **** --- 32,37 ---- * Straighten out random/whrandom. + * Update the filecmp documentation (Moshe?). + NOT WORTH THE TROUBLE From python-dev@python.org Wed Jun 28 23:20:09 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 15:20:09 -0700 Subject: [Python-checkins] CVS: python/dist/src/PC getpathp.c,1.14,1.15 import_nt.c,1.11,1.12 Message-ID: <200006282220.PAA13728@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv13719 Modified Files: getpathp.c import_nt.c Log Message: Trent Mick: familiar simple Win64 patches Index: getpathp.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/getpathp.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** getpathp.c 2000/05/26 21:49:07 1.14 --- getpathp.c 2000/06/28 22:20:06 1.15 *************** *** 135,139 **** char *dir; { ! int i = strlen(dir); while (i > 0 && !is_sep(dir[i])) --i; --- 135,139 ---- char *dir; { ! size_t i = strlen(dir); while (i > 0 && !is_sep(dir[i])) --i; *************** *** 173,177 **** char *stuff; { ! int n, k; if (is_sep(stuff[0])) n = 0; --- 173,177 ---- char *stuff; { ! size_t n, k; if (is_sep(stuff[0])) n = 0; *************** *** 208,212 **** char *landmark; { - /* Search from argv0_path, until landmark is found */ strcpy(prefix, argv0_path); --- 208,211 ---- *************** *** 245,249 **** static const TCHAR keyPrefix[] = _T("Software\\Python\\PythonCore\\"); static const TCHAR keySuffix[] = _T("\\PythonPath"); ! int versionLen; DWORD index; TCHAR *keyBuf = NULL; --- 244,248 ---- static const TCHAR keyPrefix[] = _T("Software\\Python\\PythonCore\\"); static const TCHAR keySuffix[] = _T("\\PythonPath"); ! size_t versionLen; DWORD index; TCHAR *keyBuf = NULL; *************** *** 403,407 **** if (delim) { ! int len = delim - path; strncpy(progpath, path, len); *(progpath + len) = '\0'; --- 402,406 ---- if (delim) { ! size_t len = delim - path; strncpy(progpath, path, len); *(progpath + len) = '\0'; *************** *** 430,434 **** char argv0_path[MAXPATHLEN+1]; char *buf; ! int bufsz; char *pythonhome = Py_GetPythonHome(); char *envpath = getenv("PYTHONPATH"); --- 429,433 ---- char argv0_path[MAXPATHLEN+1]; char *buf; ! size_t bufsz; char *pythonhome = Py_GetPythonHome(); char *envpath = getenv("PYTHONPATH"); *************** *** 555,559 **** char *p = PYTHONPATH; char *q; ! int n; for (;;) { q = strchr(p, DELIM); --- 554,558 ---- char *p = PYTHONPATH; char *q; ! size_t n; for (;;) { q = strchr(p, DELIM); Index: import_nt.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/import_nt.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** import_nt.c 2000/04/04 22:48:55 1.11 --- import_nt.c 2000/06/28 22:20:06 1.12 *************** *** 34,38 **** // Calculate the size for the sprintf buffer. // Get the size of the chars only, plus 1 NULL. ! int bufSize = sizeof(keyPrefix)-1 + strlen(PyWin_DLLVersionString) + sizeof(keySuffix) + strlen(moduleName) + sizeof(debugString) - 1; // alloca == no free required, but memory only local to fn, also no heap fragmentation! moduleKey = alloca(bufSize); --- 34,38 ---- // Calculate the size for the sprintf buffer. // Get the size of the chars only, plus 1 NULL. ! size_t bufSize = sizeof(keyPrefix)-1 + strlen(PyWin_DLLVersionString) + sizeof(keySuffix) + strlen(moduleName) + sizeof(debugString) - 1; // alloca == no free required, but memory only local to fn, also no heap fragmentation! moduleKey = alloca(bufSize); *************** *** 45,49 **** // use the file extension to locate the type entry. for (fdp = _PyImport_Filetab; fdp->suffix != NULL; fdp++) { ! int extLen=strlen(fdp->suffix); if (modNameSize>extLen && strnicmp(pathBuf+(modNameSize-extLen-1),fdp->suffix,extLen)==0) break; --- 45,49 ---- // use the file extension to locate the type entry. for (fdp = _PyImport_Filetab; fdp->suffix != NULL; fdp++) { ! size_t extLen = strlen(fdp->suffix); if (modNameSize>extLen && strnicmp(pathBuf+(modNameSize-extLen-1),fdp->suffix,extLen)==0) break; From python-dev@python.org Wed Jun 28 23:23:58 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 15:23:58 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules cPickle.c,2.42,2.43 Message-ID: <200006282223.PAA13940@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv13933 Modified Files: cPickle.c Log Message: Trent Mick: This patch fixes cPickle.c for 64-bit platforms. - The false assumption sizeof(long) == size(void*) exists where PyInt_FromLong is used to represent a pointer. The safe Python call for this is PyLong_FromVoidPtr. (On platforms where the above assumption *is* true a PyInt is returned as before so there is no effective change.) - use size_t instead of int for some variables Index: cPickle.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cPickle.c,v retrieving revision 2.42 retrieving revision 2.43 diff -C2 -r2.42 -r2.43 *** cPickle.c 2000/05/09 18:14:50 2.42 --- cPickle.c 2000/06/28 22:23:56 2.43 *************** *** 657,661 **** long c_value; char s[30]; ! int len; UNLESS (mv = PyDict_GetItem(self->memo, id)) { --- 657,661 ---- long c_value; char s[30]; ! size_t len; UNLESS (mv = PyDict_GetItem(self->memo, id)) { *************** *** 718,722 **** put2(Picklerobject *self, PyObject *ob) { char c_str[30]; ! int p, len, res = -1; PyObject *py_ob_id = 0, *memo_len = 0, *t = 0; --- 718,724 ---- put2(Picklerobject *self, PyObject *ob) { char c_str[30]; ! int p; ! size_t len; ! int res = -1; PyObject *py_ob_id = 0, *memo_len = 0, *t = 0; *************** *** 728,732 **** p++; /* Make sure memo keys are positive! */ ! UNLESS (py_ob_id = PyInt_FromLong((long)ob)) goto finally; --- 730,734 ---- p++; /* Make sure memo keys are positive! */ ! UNLESS (py_ob_id = PyLong_FromVoidPtr(ob)) goto finally; *************** *** 1256,1260 **** } ! UNLESS (py_tuple_id = PyInt_FromLong((long)args)) goto finally; --- 1258,1262 ---- } ! UNLESS (py_tuple_id = PyLong_FromVoidPtr(args)) goto finally; *************** *** 1776,1785 **** if (args->ob_refcnt > 1) { - long ob_id; int has_key; ! ob_id = (long)args; ! ! UNLESS (py_ob_id = PyInt_FromLong(ob_id)) goto finally; --- 1778,1784 ---- if (args->ob_refcnt > 1) { int has_key; ! UNLESS (py_ob_id = PyLong_FromVoidPtr(args)) goto finally; From python-dev@python.org Wed Jun 28 23:26:23 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 15:26:23 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules signalmodule.c,2.39,2.40 Message-ID: <200006282226.PAA14044@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv14036 Modified Files: signalmodule.c Log Message: Trent Mick: Fix warnings on 64-bit build build of signalmodule.c - Though I know that SIG_DFL and SIG_IGN are just small constants, there are cast to function pointers so the appropriate Python call is PyLong_FromVoidPtr so that the pointer value cannot overflow on Win64 where sizeof(long) < sizeof(void*). Index: signalmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/signalmodule.c,v retrieving revision 2.39 retrieving revision 2.40 diff -C2 -r2.39 -r2.40 *** signalmodule.c 1998/12/21 19:32:39 2.39 --- signalmodule.c 2000/06/28 22:26:21 2.40 *************** *** 357,365 **** d = PyModule_GetDict(m); ! x = DefaultHandler = PyInt_FromLong((long)SIG_DFL); if (!x || PyDict_SetItemString(d, "SIG_DFL", x) < 0) goto finally; ! x = IgnoreHandler = PyInt_FromLong((long)SIG_IGN); if (!x || PyDict_SetItemString(d, "SIG_IGN", x) < 0) goto finally; --- 357,365 ---- d = PyModule_GetDict(m); ! x = DefaultHandler = PyLong_FromVoidPtr(SIG_DFL); if (!x || PyDict_SetItemString(d, "SIG_DFL", x) < 0) goto finally; ! x = IgnoreHandler = PyLong_FromVoidPtr(SIG_IGN); if (!x || PyDict_SetItemString(d, "SIG_IGN", x) < 0) goto finally; From python-dev@python.org Wed Jun 28 23:47:25 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 15:47:25 -0700 Subject: [Python-checkins] CVS: python/dist/src/Tools/scripts pindent.py,1.6,1.7 Message-ID: <200006282247.PAA15119@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Tools/scripts In directory slayer.i.sourceforge.net:/tmp/cvs-serv15110 Modified Files: pindent.py Log Message: Peter Schneider-Kamp: Problem: A Python program can be completed and reformatted using Tools/scripts/pindent.py. Unfortunately there is no option for removal of the generated "# end"-tags. Although a few Python commands or a "grep -v '# end '" can do wonders here, there are two drawbacks: - not everyone has grep/time to write a Python script - it is not checked whether the "# end"-tags were used validly Solution: add extra option "-e" (eliminate) to pindent.py Index: pindent.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/pindent.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** pindent.py 1998/06/19 21:39:27 1.6 --- pindent.py 2000/06/28 22:47:22 1.7 *************** *** 1,9 **** #! /usr/bin/env python ! # This file contains a class and a main program that perform two # related (though complimentary) formatting operations on Python ! # programs. When called as "pindend -c", it takes a valid Python # program as input and outputs a version augmented with block-closing ! # comments. When called as "pindent -r" it assumes its input is a # Python program with block-closing comments but with its indentation # messed up, and outputs a properly indented version. --- 1,11 ---- #! /usr/bin/env python ! # This file contains a class and a main program that perform three # related (though complimentary) formatting operations on Python ! # programs. When called as "pindent -c", it takes a valid Python # program as input and outputs a version augmented with block-closing ! # comments. When called as "pindent -e", it assumes its input is a ! # Python program with block-closing comments and outputs a commentless ! # version. When called as "pindent -r" it assumes its input is a # Python program with block-closing comments but with its indentation # messed up, and outputs a properly indented version. *************** *** 35,43 **** # comments). ! # Both operations are idempotent (i.e. applied to their own output # they yield an identical result). Running first "pindent -c" and # then "pindent -r" on a valid Python program produces a program that # is semantically identical to the input (though its indentation may ! # be different). # Other options: --- 37,46 ---- # comments). ! # The operations are idempotent (i.e. applied to their own output # they yield an identical result). Running first "pindent -c" and # then "pindent -r" on a valid Python program produces a program that # is semantically identical to the input (though its indentation may ! # be different). Running "pindent -e" on that output produces a ! # program that only differs from the original in indentation. # Other options: *************** *** 194,197 **** --- 197,228 ---- # end def reformat + def eliminate(self): + begin_counter = 0 + end_counter = 0 + while 1: + line = self.getline() + if not line: break # EOF + # end if + m = self.endprog.match(line) + if m: + end_counter = end_counter + 1 + continue + # end if + m = self.kwprog.match(line) + if m: + kw = m.group('kw') + if kw in start: + begin_counter = begin_counter + 1 + # end if + # end if + self.putline(line) + # end while + if begin_counter - end_counter < 0: + sys.stderr.write('Warning: input contained more end tags than expected\n') + elif begin_counter - end_counter > 0: + sys.stderr.write('Warning: input contained less end tags than expected\n') + # end if + # end def eliminate + def complete(self): self.indentsize = 1 *************** *** 294,298 **** # - xxx_file(filename): process file in place, return true iff changed ! def complete_filter(input= sys.stdin, output = sys.stdout, stepsize = STEPSIZE, tabsize = TABSIZE): pi = PythonIndenter(input, output, stepsize, tabsize) --- 325,329 ---- # - xxx_file(filename): process file in place, return true iff changed ! def complete_filter(input = sys.stdin, output = sys.stdout, stepsize = STEPSIZE, tabsize = TABSIZE): pi = PythonIndenter(input, output, stepsize, tabsize) *************** *** 300,303 **** --- 331,340 ---- # end def complete_filter + def eliminate_filter(input= sys.stdin, output = sys.stdout, + stepsize = STEPSIZE, tabsize = TABSIZE): + pi = PythonIndenter(input, output, stepsize, tabsize) + pi.eliminate() + # end def eliminate_filter + def reformat_filter(input = sys.stdin, output = sys.stdout, stepsize = STEPSIZE, tabsize = TABSIZE): *************** *** 358,361 **** --- 395,406 ---- # end def complete_string + def eliminate_string(source, stepsize = STEPSIZE, tabsize = TABSIZE): + input = StringReader(source) + output = StringWriter() + pi = PythonIndenter(input, output, stepsize, tabsize) + pi.eliminate() + return output.getvalue() + # end def eliminate_string + def reformat_string(source, stepsize = STEPSIZE, tabsize = TABSIZE): input = StringReader(source) *************** *** 381,384 **** --- 426,444 ---- # end def complete_file + def eliminate_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE): + source = open(filename, 'r').read() + result = eliminate_string(source, stepsize, tabsize) + if source == result: return 0 + # end if + import os + try: os.rename(filename, filename + '~') + except os.error: pass + # end try + f = open(filename, 'w') + f.write(result) + f.close() + return 1 + # end def eliminate_file + def reformat_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE): source = open(filename, 'r').read() *************** *** 387,391 **** # end if import os ! os.rename(filename, filename + '~') f = open(filename, 'w') f.write(result) --- 447,453 ---- # end if import os ! try: os.rename(filename, filename + '~') ! except os.error: pass ! # end try f = open(filename, 'w') f.write(result) *************** *** 397,402 **** usage = """ ! usage: pindent (-c|-r) [-s stepsize] [-t tabsize] [file] ... -c : complete a correctly indented program (add #end directives) -r : reformat a completed program (use #end directives) -s stepsize: indentation step (default %(STEPSIZE)d) --- 459,465 ---- usage = """ ! usage: pindent (-c|-e|-r) [-s stepsize] [-t tabsize] [file] ... -c : complete a correctly indented program (add #end directives) + -e : eliminate #end directives -r : reformat a completed program (use #end directives) -s stepsize: indentation step (default %(STEPSIZE)d) *************** *** 410,414 **** import getopt try: ! opts, args = getopt.getopt(sys.argv[1:], 'crs:t:') except getopt.error, msg: sys.stderr.write('Error: %s\n' % msg) --- 473,477 ---- import getopt try: ! opts, args = getopt.getopt(sys.argv[1:], 'cers:t:') except getopt.error, msg: sys.stderr.write('Error: %s\n' % msg) *************** *** 422,425 **** --- 485,490 ---- if o == '-c': action = 'complete' + elif o == '-e': + action = 'eliminate' elif o == '-r': action = 'reformat' *************** *** 432,436 **** if not action: sys.stderr.write( ! 'You must specify -c(omplete) or -r(eformat)\n') sys.stderr.write(usage) sys.exit(2) --- 497,501 ---- if not action: sys.stderr.write( ! 'You must specify -c(omplete), -e(eliminate) or -r(eformat)\n') sys.stderr.write(usage) sys.exit(2) From python-dev@python.org Wed Jun 28 23:55:23 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 15:55:23 -0700 Subject: [Python-checkins] CVS: python/dist/src/Tools/scripts pindent.py,1.7,1.8 Message-ID: <200006282255.PAA15643@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Tools/scripts In directory slayer.i.sourceforge.net:/tmp/cvs-serv15635 Modified Files: pindent.py Log Message: Running the program through itself reveals that one end tag was mislabeled. (Using -c and then -e rearranges some comments, so I won't check that in -- but it's a good test anyway. Note that pindent is not perfect -- e.g. it doesn't know about triple-quoted strings!) Index: pindent.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/pindent.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** pindent.py 2000/06/28 22:47:22 1.7 --- pindent.py 2000/06/28 22:55:20 1.8 *************** *** 341,345 **** pi = PythonIndenter(input, output, stepsize, tabsize) pi.reformat() ! # end def reformat class StringReader: --- 341,345 ---- pi = PythonIndenter(input, output, stepsize, tabsize) pi.reformat() ! # end def reformat_filter class StringReader: From python-dev@python.org Thu Jun 29 00:24:21 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 16:24:21 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python marshal.c,1.48,1.49 Message-ID: <200006282324.QAA23340@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv23333 Modified Files: marshal.c Log Message: Urmpf. Quality control on this patch lapsed a bit. :-( The depth field was never decremented inside w_object(), and it was never initialized in PyMarshal_WriteObjectToFile(). This caused imports from .pyc files to fil mysteriously when the .pyc file was written by the broken code -- w_object() would bail out early, but PyMarshal_WriteObjectToFile() doesn't check the error or return an error code, and apparently the marshalling code doesn't call PyErr_Check() either. (That's a separate patch if I feel like it.) Index: marshal.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/marshal.c,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -r1.48 -r1.49 *** marshal.c 2000/06/28 18:47:56 1.48 --- marshal.c 2000/06/28 23:24:19 1.49 *************** *** 235,240 **** utf8 = PyUnicode_AsUTF8String(v); if (utf8 == NULL) { ! p->error = 1; ! return; } w_byte(TYPE_UNICODE, p); --- 235,241 ---- utf8 = PyUnicode_AsUTF8String(v); if (utf8 == NULL) { ! p->depth--; ! p->error = 1; ! return; } w_byte(TYPE_UNICODE, p); *************** *** 304,307 **** --- 305,310 ---- p->error = 1; } + + p->depth--; } *************** *** 326,329 **** --- 329,333 ---- wf.fp = fp; wf.error = 0; + wf.depth = 0; w_object(x, &wf); } From python-dev@python.org Thu Jun 29 00:46:10 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 16:46:10 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects classobject.c,2.90,2.91 Message-ID: <200006282346.QAA24575@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv24566 Modified Files: classobject.c Log Message: Vladimir Marangozov: Avoid calling the dealloc function, previously triggered with DECREF(inst). This caused a segfault in PyDict_GetItem, called with a NULL dict, whenever inst->in_dict fails under low-memory conditions. Index: classobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v retrieving revision 2.90 retrieving revision 2.91 diff -C2 -r2.90 -r2.91 *** classobject.c 2000/06/28 21:57:18 2.90 --- classobject.c 2000/06/28 23:46:07 2.91 *************** *** 490,500 **** if (inst == NULL) return NULL; - Py_INCREF(class); - inst->in_class = (PyClassObject *)class; inst->in_dict = PyDict_New(); if (inst->in_dict == NULL) { ! Py_DECREF(inst); return NULL; } if (initstr == NULL) initstr = PyString_InternFromString("__init__"); --- 490,500 ---- if (inst == NULL) return NULL; inst->in_dict = PyDict_New(); if (inst->in_dict == NULL) { ! PyObject_DEL(inst); return NULL; } + Py_INCREF(class); + inst->in_class = (PyClassObject *)class; if (initstr == NULL) initstr = PyString_InternFromString("__init__"); From python-dev@python.org Thu Jun 29 00:53:59 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 16:53:59 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python getargs.c,2.33,2.34 Message-ID: <200006282353.QAA25108@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv25100 Modified Files: getargs.c Log Message: Vladimir Marangozov: This patch fixes a problem on AIX with the signed int case code in getargs.c, after Trent Mick's intervention about MIN/MAX overflow checks. The AIX compiler/optimizer generates bogus code with the default flags "-g -O" causing test_builtin to fail: int("10", 16) <> 16L. Swapping the two checks in the signed int code makes the problem go away. Also, make the error messages fit in 80 char lines in the source. Index: getargs.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/getargs.c,v retrieving revision 2.33 retrieving revision 2.34 diff -C2 -r2.33 -r2.34 *** getargs.c 2000/05/09 21:50:00 2.33 --- getargs.c 2000/06/28 23:53:56 2.34 *************** *** 474,483 **** else if (ival < 0) { PyErr_SetString(PyExc_OverflowError, ! "unsigned byte integer is less than minimum"); return "integer"; } else if (ival > UCHAR_MAX) { PyErr_SetString(PyExc_OverflowError, ! "unsigned byte integer is greater than maximum"); return "integer"; } --- 474,483 ---- else if (ival < 0) { PyErr_SetString(PyExc_OverflowError, ! "unsigned byte integer is less than minimum"); return "integer"; } else if (ival > UCHAR_MAX) { PyErr_SetString(PyExc_OverflowError, ! "unsigned byte integer is greater than maximum"); return "integer"; } *************** *** 495,504 **** else if (ival < SHRT_MIN) { PyErr_SetString(PyExc_OverflowError, ! "signed short integer is less than minimum"); return "integer"; } else if (ival > SHRT_MAX) { PyErr_SetString(PyExc_OverflowError, ! "signed short integer is greater than maximum"); return "integer"; } --- 495,504 ---- else if (ival < SHRT_MIN) { PyErr_SetString(PyExc_OverflowError, ! "signed short integer is less than minimum"); return "integer"; } else if (ival > SHRT_MAX) { PyErr_SetString(PyExc_OverflowError, ! "signed short integer is greater than maximum"); return "integer"; } *************** *** 514,525 **** if (ival == -1 && PyErr_Occurred()) return "integer"; ! else if (ival < INT_MIN) { PyErr_SetString(PyExc_OverflowError, ! "signed integer is less than minimum"); return "integer"; } ! else if (ival > INT_MAX) { PyErr_SetString(PyExc_OverflowError, ! "signed integer is greater than maximum"); return "integer"; } --- 514,525 ---- if (ival == -1 && PyErr_Occurred()) return "integer"; ! else if (ival > INT_MAX) { PyErr_SetString(PyExc_OverflowError, ! "signed integer is greater than maximum"); return "integer"; } ! else if (ival < INT_MIN) { PyErr_SetString(PyExc_OverflowError, ! "signed integer is less than minimum"); return "integer"; } From python-dev@python.org Thu Jun 29 01:04:54 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 17:04:54 -0700 Subject: [Python-checkins] CVS: python/dist/src/Misc ACKS,1.56,1.57 Message-ID: <200006290004.RAA31899@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Misc In directory slayer.i.sourceforge.net:/tmp/cvs-serv31891 Modified Files: ACKS Log Message: Some new names (some contributors of patches that haven't even been accepted yet!) Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -r1.56 -r1.57 *** ACKS 2000/05/11 18:20:30 1.56 --- ACKS 2000/06/29 00:04:51 1.57 *************** *** 45,48 **** --- 45,49 ---- Dave Brennan Gary S. Brown + Oleg Broytmann Erik de Bueger Jan-Hein B"uhrman *************** *** 115,118 **** --- 116,120 ---- Fred Gansevles Lars Marius Garshol + Hary Henry Gebel Thomas Gellekum Ben Gertzfield *************** *** 324,327 **** --- 326,330 ---- Dan Stromberg Nathan Sullivan + Kalle Svensson Neale Pickett Dan Pierson From python-dev@python.org Thu Jun 29 01:06:42 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 17:06:42 -0700 Subject: [Python-checkins] CVS: python/dist/src/Include ucnhash.h,1.1,1.2 Message-ID: <200006290006.RAA31961@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Include In directory slayer.i.sourceforge.net:/tmp/cvs-serv31933/Include Modified Files: ucnhash.h Log Message: Jack Jansen: Use include "" instead of <>; and staticforward declarations Index: ucnhash.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/ucnhash.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** ucnhash.h 2000/06/28 16:37:24 1.1 --- ucnhash.h 2000/06/29 00:06:39 1.2 *************** *** 1,4 **** ! #include #include --- 1,4 ---- ! #include "Python.h" #include From python-dev@python.org Thu Jun 29 01:06:41 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 17:06:41 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.30,2.31 Message-ID: <200006290006.RAA31952@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv31933/Objects Modified Files: unicodeobject.c Log Message: Jack Jansen: Use include "" instead of <>; and staticforward declarations Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.30 retrieving revision 2.31 diff -C2 -r2.30 -r2.31 *** unicodeobject.c 2000/06/28 16:43:35 2.30 --- unicodeobject.c 2000/06/29 00:06:39 2.31 *************** *** 67,71 **** #include "mymath.h" #include "unicodeobject.h" ! #include #if defined(HAVE_LIMITS_H) --- 67,71 ---- #include "mymath.h" #include "unicodeobject.h" ! #include "ucnhash.h" #if defined(HAVE_LIMITS_H) From python-dev@python.org Thu Jun 29 01:06:42 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 17:06:42 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules ucnhash.c,1.1,1.2 Message-ID: <200006290006.RAA31962@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv31933/Modules Modified Files: ucnhash.c Log Message: Jack Jansen: Use include "" instead of <>; and staticforward declarations Index: ucnhash.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/ucnhash.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** ucnhash.c 2000/06/28 16:38:56 1.1 --- ucnhash.c 2000/06/29 00:06:39 1.2 *************** *** 1,3 **** ! #include /* --- 1,3 ---- ! #include "ucnhash.h" /* *************** *** 20,25 **** ! static const unsigned short G[k_cHashElements]; ! static const _Py_UnicodeCharacterName aucn[k_cKeys]; static long f1(const char *key, unsigned int cch) --- 20,25 ---- ! staticforward const unsigned short G[k_cHashElements]; ! staticforward const _Py_UnicodeCharacterName aucn[k_cKeys]; static long f1(const char *key, unsigned int cch) From python-dev@python.org Thu Jun 29 02:00:51 2000 From: python-dev@python.org (Greg Stein) Date: Wed, 28 Jun 2000 18:00:51 -0700 Subject: [Python-checkins] CVS: python/dist/src/Demo/imputil - New directory Message-ID: <200006290100.SAA04969@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Demo/imputil In directory slayer.i.sourceforge.net:/tmp/cvs-serv4792/imputil Log Message: Directory /cvsroot/python/python/dist/src/Demo/imputil added to the repository From python-dev@python.org Thu Jun 29 03:06:33 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 28 Jun 2000 19:06:33 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command sdist.py,1.35,1.36 Message-ID: <200006290206.TAA17518@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv17312 Modified Files: sdist.py Log Message: Fixed 'findall()' so it only returns regular files -- no directories. Changed 'prune_file_list()' so it also prunes out RCS and CVS directories. Added 'is_regex' parameter to 'select_pattern()', 'exclude_pattern()', and 'translate_pattern()', so that you don't have to be constrained by the simple shell-glob-like pattern language, and can escape into full-blown regexes when needed. Currently this is only available in code -- it's not exposed in the manifest template mini-language. Added 'prune' option (controlled by --prune and --no-prune) to determine whether we call 'prune_file_list()' or not -- it's true by default. Fixed 'negative_opt' -- it was misnamed and not being seen by dist.py. Added --no-defaults to the option table, so it's seen by FancyGetopt. Index: sdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/sdist.py,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -r1.35 -r1.36 *** sdist.py 2000/06/24 01:23:37 1.35 --- sdist.py 2000/06/29 02:06:29 1.36 *************** *** 47,50 **** --- 47,58 ---- "include the default file set in the manifest " "[default; disable with --no-defaults]"), + ('no-defaults', None, + "don't include the default file set"), + ('prune', None, + "specifically exclude files/directories that should not be " + "distributed (build tree, RCS/CVS dirs, etc.) " + "[default; disable with --no-prune]"), + ('no-prune', None, + "don't automatically exclude anything"), ('manifest-only', 'o', "just regenerate the manifest and then stop " *************** *** 65,69 **** ] ! negative_opts = {'use-defaults': 'no-defaults'} default_format = { 'posix': 'gztar', --- 73,78 ---- ] ! negative_opt = {'no-defaults': 'use-defaults', ! 'no-prune': 'prune' } default_format = { 'posix': 'gztar', *************** *** 79,82 **** --- 88,92 ---- # in the manifest self.use_defaults = 1 + self.prune = 1 self.manifest_only = 0 *************** *** 218,223 **** self.read_template () ! # Prune away the build and source distribution directories ! self.prune_file_list() # File list now complete -- sort it so that higher-level files --- 228,235 ---- self.read_template () ! # Prune away any directories that don't belong in the source ! # distribution ! if self.prune: ! self.prune_file_list() # File list now complete -- sort it so that higher-level files *************** *** 510,517 **** def prune_file_list (self): """Prune off branches that might slip into the file list as created ! by 'read_template()', but really don't belong there: specifically, ! the build tree (typically "build") and the release tree itself ! (only an issue if we ran "sdist" previously with --keep-tree, or it ! aborted). """ build = self.get_finalized_command('build') --- 522,530 ---- def prune_file_list (self): """Prune off branches that might slip into the file list as created ! by 'read_template()', but really don't belong there: ! * the build tree (typically "build") ! * the release tree itself (only an issue if we ran "sdist" ! previously with --keep-tree, or it aborted) ! * any RCS or CVS directories """ build = self.get_finalized_command('build') *************** *** 519,525 **** self.exclude_pattern (self.files, None, prefix=build.build_base) self.exclude_pattern (self.files, None, prefix=base_dir) ! def select_pattern (self, files, pattern, anchor=1, prefix=None): """Select strings (presumably filenames) from 'files' that match 'pattern', a Unix-style wildcard (glob) pattern. Patterns are not --- 532,540 ---- self.exclude_pattern (self.files, None, prefix=build.build_base) self.exclude_pattern (self.files, None, prefix=base_dir) + self.exclude_pattern (self.files, r'/(RCS|CVS)/.*', is_regex=1) ! def select_pattern (self, files, pattern, ! anchor=1, prefix=None, is_regex=0): """Select strings (presumably filenames) from 'files' that match 'pattern', a Unix-style wildcard (glob) pattern. Patterns are not *************** *** 537,544 **** them, will match. 'anchor' is ignored in this case. Return the list of matching strings, possibly empty. """ matches = [] ! pattern_re = translate_pattern (pattern, anchor, prefix) self.debug_print("select_pattern: applying regex r'%s'" % pattern_re.pattern) --- 552,564 ---- them, will match. 'anchor' is ignored in this case. + If 'is_regex' is true, 'anchor' and 'prefix' are ignored, and + 'pattern' is assumed to be either a string containing a regex or a + regex object -- no translation is done, the regex is just compiled + and used as-is. + Return the list of matching strings, possibly empty. """ matches = [] ! pattern_re = translate_pattern (pattern, anchor, prefix, is_regex) self.debug_print("select_pattern: applying regex r'%s'" % pattern_re.pattern) *************** *** 553,563 **** ! def exclude_pattern (self, files, pattern, anchor=1, prefix=None): """Remove strings (presumably filenames) from 'files' that match ! 'pattern'. 'pattern', 'anchor', 'and 'prefix' are the same ! as for 'select_pattern()', above. The list 'files' is modified ! in place. """ ! pattern_re = translate_pattern (pattern, anchor, prefix) self.debug_print("exclude_pattern: applying regex r'%s'" % pattern_re.pattern) --- 573,584 ---- ! def exclude_pattern (self, files, pattern, ! anchor=1, prefix=None, is_regex=0): """Remove strings (presumably filenames) from 'files' that match ! 'pattern'. Other parameters are the same as for ! 'select_pattern()', above. The list 'files' is modified in place. """ ! ! pattern_re = translate_pattern (pattern, anchor, prefix, is_regex) self.debug_print("exclude_pattern: applying regex r'%s'" % pattern_re.pattern) *************** *** 675,678 **** --- 696,701 ---- (relative to 'dir'). """ + from stat import ST_MODE, S_ISREG, S_ISDIR, S_ISLNK + list = [] stack = [dir] *************** *** 689,694 **** else: fullname = name ! list.append (fullname) ! if os.path.isdir (fullname) and not os.path.islink(fullname): push (fullname) --- 712,722 ---- else: fullname = name ! ! # Avoid excess stat calls -- just one will do, thank you! ! stat = os.stat(fullname) ! mode = stat[ST_MODE] ! if S_ISREG(mode): ! list.append (fullname) ! elif S_ISDIR(mode) and not S_ISLNK(mode): push (fullname) *************** *** 717,724 **** ! def translate_pattern (pattern, anchor=1, prefix=None): """Translate a shell-like wildcard pattern to a compiled regular ! expression. Return the compiled regex. """ if pattern: pattern_re = glob_to_re (pattern) --- 745,760 ---- ! def translate_pattern (pattern, anchor=1, prefix=None, is_regex=0): """Translate a shell-like wildcard pattern to a compiled regular ! expression. Return the compiled regex. If 'is_regex' true, ! then 'pattern' is directly compiled to a regex (if it's a string) ! or just returned as-is (assumes it's a regex object). """ + if is_regex: + if type(pattern) is StringType: + return re.compile(pattern) + else: + return pattern + if pattern: pattern_re = glob_to_re (pattern) From python-dev@python.org Thu Jun 29 03:16:26 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 28 Jun 2000 19:16:26 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command build_ext.py,1.52,1.53 Message-ID: <200006290216.TAA18111@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv18102 Modified Files: build_ext.py Log Message: Fixed so 'get_source_files()' calls 'check_extension_list()' -- that way, we can run "sdist" on a distribution with old-style extension structures even if we haven't built it yet. Bug spotted by Harry Gebel. Index: build_ext.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build_ext.py,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -r1.52 -r1.53 *** build_ext.py 2000/06/28 14:48:01 1.52 --- build_ext.py 2000/06/29 02:16:24 1.53 *************** *** 310,314 **** def get_source_files (self): ! filenames = [] --- 310,314 ---- def get_source_files (self): ! self.check_extension_list() filenames = [] From python-dev@python.org Thu Jun 29 03:22:05 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 28 Jun 2000 19:22:05 -0700 Subject: [Python-checkins] CVS: distutils/examples mxdatetime_setup.py,1.7,1.8 pil_setup.py,1.12,1.13 xml_setup.py,1.1,1.2 Message-ID: <200006290222.TAA18872@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/examples In directory slayer.i.sourceforge.net:/tmp/cvs-serv18802/examples Modified Files: mxdatetime_setup.py pil_setup.py xml_setup.py Log Message: Harry Henry Gebel: updated the PIL and XML setup scripts to use new-style extension descriptions and fixes a bug in the mxDateTime setup script (which uses new-style extensions but did not import the Extension class). Index: mxdatetime_setup.py =================================================================== RCS file: /cvsroot/python/distutils/examples/mxdatetime_setup.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** mxdatetime_setup.py 2000/06/25 02:48:08 1.7 --- mxdatetime_setup.py 2000/06/29 02:22:02 1.8 *************** *** 9,13 **** import string ! from distutils.core import setup from distutils.command.config import config --- 9,13 ---- import string ! from distutils.core import setup, Extension from distutils.command.config import config Index: pil_setup.py =================================================================== RCS file: /cvsroot/python/distutils/examples/pil_setup.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** pil_setup.py 2000/06/27 02:11:03 1.12 --- pil_setup.py 2000/06/29 02:22:02 1.13 *************** *** 9,13 **** import os ! from distutils.core import setup from distutils.ccompiler import new_compiler from distutils.command.config import config --- 9,13 ---- import os ! from distutils.core import setup, Extension from distutils.ccompiler import new_compiler from distutils.command.config import config *************** *** 154,177 **** packages = ['PIL'], ! ext_modules = \ ! [('_imaging', ! { 'sources': ['_imaging.c', 'decode.c', 'encode.c', ! 'map.c', 'display.c', 'outline.c', 'path.c'], ! # This must include the directories with the JPEG, ! # zlib, and Tcl/Tk header files (if installed) ! 'include_dirs': include_dirs, ! ! # Keep this for Tcl/Tk support ! 'macros': ext_macros, ! ! # This must include the directories with the JPEG, zlib, ! # and Tcl/Tk libraries (whatever's available) ! 'library_dirs': library_dirs, ! ! # And this, of course, lists which of those external ! # libraries to link against (plus libImaging, which *must* ! # be included!) ! 'libraries': optional_libs ! } ! )] ) --- 154,175 ---- packages = ['PIL'], ! ext_modules = ! [Extension('_imaging', ! ['_imaging.c', 'decode.c', 'encode.c', ! 'map.c', 'display.c', 'outline.c', 'path.c'], ! # This must include the directories with the JPEG, ! # zlib, and Tcl/Tk header files (if installed) ! include_dirs = include_dirs, ! ! # Keep this for Tcl/Tk support ! define_macros = ext_macros, ! ! # This must include the directories with the JPEG, zlib, ! # and Tcl/Tk libraries (whatever's available) ! library_dirs = library_dirs, ! ! # And this, of course, lists which of those external ! # libraries to link against (plus libImaging, which ! # *must* be included!) ! libraries = optional_libs)] ) Index: xml_setup.py =================================================================== RCS file: /cvsroot/python/distutils/examples/xml_setup.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** xml_setup.py 2000/03/09 03:17:59 1.1 --- xml_setup.py 2000/06/29 02:22:02 1.2 *************** *** 12,16 **** import sys, os ! from distutils.core import setup --- 12,16 ---- import sys, os ! from distutils.core import setup, Extension *************** *** 32,55 **** ], ! ext_modules = [('sgmlop', { 'sources' : ['extensions/sgmlop.c'] }), ! ('xml.unicode.wstrop', { 'sources' : ['extensions/wstrop.c'] ! }), ! ('xml.parsers.pyexpat', { 'define': [('XML_NS', None)], ! 'include_dirs': [ 'extensions/expat/xmltok', ! 'extensions/expat/xmlparse' ], ! ! 'sources' : ! [ ! 'extensions/pyexpat.c', ! 'extensions/expat/xmltok/xmltok.c', ! 'extensions/expat/xmltok/xmlrole.c', ! 'extensions/expat/xmlwf/xmlfile.c', ! 'extensions/expat/xmlwf/xmlwf.c', ! 'extensions/expat/xmlwf/codepage.c', ! 'extensions/expat/xmlparse/xmlparse.c', ! 'extensions/expat/xmlparse/hashtable.c', ! FILEMAP_SRC, ! ] }), ] ) - --- 32,53 ---- ], ! ext_modules = [Extension('sgmlop', ! ['extensions/sgmlop.c']), ! Extension('xml.unicode.wstrop', ! ['extensions/wstrop.c']), ! Extension('xml.parsers.pyexpat', ! ['extensions/pyexpat.c', ! 'extensions/expat/xmltok/xmltok.c', ! 'extensions/expat/xmltok/xmlrole.c', ! 'extensions/expat/xmlwf/xmlfile.c', ! 'extensions/expat/xmlwf/xmlwf.c', ! 'extensions/expat/xmlwf/codepage.c', ! 'extensions/expat/xmlparse/xmlparse.c', ! 'extensions/expat/xmlparse/hashtable.c', ! FILEMAP_SRC,], ! define_macros = [('XML_NS', None)], ! include_dirs = [ 'extensions/expat/xmltok', ! 'extensions/expat/xmlparse' ], ! ) ] ) From python-dev@python.org Thu Jun 29 04:33:31 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 20:33:31 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc TODO,1.27,1.28 Message-ID: <200006290333.UAA29239@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc In directory slayer.i.sourceforge.net:/tmp/cvs-serv29230 Modified Files: TODO Log Message: Add update of httplib docs to reflect Greg Stein's recent updates. Greg, this is yours! Index: TODO =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/TODO,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -r1.27 -r1.28 *** TODO 2000/06/28 22:13:06 1.27 --- TODO 2000/06/29 03:33:28 1.28 *************** *** 34,37 **** --- 34,40 ---- * Update the filecmp documentation (Moshe?). + * Update the httplib documentation to match Greg Stein's HTTP/1.1 + support and new classes. (Greg, this is yours!) + NOT WORTH THE TROUBLE From python-dev@python.org Thu Jun 29 04:46:49 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 20:46:49 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libfuncs.tex,1.64,1.65 Message-ID: <200006290346.UAA29830@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv29823/lib Modified Files: libfuncs.tex Log Message: Make it clear that id() can return either a long integer or a plain integer. Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -r1.64 -r1.65 *** libfuncs.tex 2000/04/06 15:06:03 1.64 --- libfuncs.tex 2000/06/29 03:46:46 1.65 *************** *** 303,311 **** \begin{funcdesc}{id}{object} ! Return the `identity' of an object. This is an integer which is ! guaranteed to be unique and constant for this object during its ! lifetime. (Two objects whose lifetimes are disjunct may have the ! same \function{id()} value.) (Implementation note: this is the ! address of the object.) \end{funcdesc} --- 303,311 ---- \begin{funcdesc}{id}{object} ! Return the `identity' of an object. This is an integer (or long ! integer) which is guaranteed to be unique and constant for this ! object during its lifetime. Two objects whose lifetimes are ! disjunct may have the same \function{id()} value. (Implementation ! note: this is the address of the object.) \end{funcdesc} From python-dev@python.org Thu Jun 29 06:06:05 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 22:06:05 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib mhlib.py,1.19,1.20 Message-ID: <200006290506.WAA13205@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv13198 Modified Files: mhlib.py Log Message: Convert to use class-based exceptions. Correct exception information in one docstring. Index: mhlib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mhlib.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -r1.19 -r1.20 *** mhlib.py 2000/02/04 15:10:33 1.19 --- mhlib.py 2000/06/29 05:06:02 1.20 *************** *** 86,90 **** # Exported constants ! Error = 'mhlib.Error' --- 86,91 ---- # Exported constants ! class Error(Exception): ! pass *************** *** 331,335 **** def getcurrent(self): ! """Return the current message. Raise KeyError when there is none.""" seqs = self.getsequences() try: --- 332,336 ---- def getcurrent(self): ! """Return the current message. Raise Error when there is none.""" seqs = self.getsequences() try: From python-dev@python.org Thu Jun 29 06:29:11 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 22:29:11 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules Setup.in,1.103,1.104 Message-ID: <200006290529.WAA14004@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv13996 Modified Files: Setup.in Log Message: Improve explanation of how to build the pyexpat module. Index: Setup.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Setup.in,v retrieving revision 1.103 retrieving revision 1.104 diff -C2 -r1.103 -r1.104 *** Setup.in 2000/06/28 16:42:39 1.103 --- Setup.in 2000/06/29 05:29:08 1.104 *************** *** 417,424 **** # always ftp://ftp.jclark.com/pub/xml/expat.zip. # ! # (Note: the expat build process doesn't yet build a libexpat.a; you can ! # do this manually while we try convince the author to add it.) # ! #EXPAT_DIR=/usr/local/src/expat/ #pyexpat pyexpat.c -I$(EXPAT_DIR)/xmlparse -L$(EXPAT_DIR) -lexpat --- 417,430 ---- # always ftp://ftp.jclark.com/pub/xml/expat.zip. # ! # EXPAT_DIR, below, should point to the expat/ directory created by ! # unpacking the Expat source distribution. # ! # Note: the expat build process doesn't yet build a libexpat.a; you can ! # do this manually while we try convince the author to add it. To do so, ! # cd to EXPAT_DIR, run "make" if you have not done so, then run: ! # ! # ar cr xmltok/*.o xmlparse/*.o ! # ! #EXPAT_DIR=/usr/local/src/expat #pyexpat pyexpat.c -I$(EXPAT_DIR)/xmlparse -L$(EXPAT_DIR) -lexpat From python-dev@python.org Thu Jun 29 08:12:17 2000 From: python-dev@python.org (Moshe Zadka) Date: Thu, 29 Jun 2000 10:12:17 +0300 (IDT) Subject: [Python-checkins] CVS: python/dist/src/Doc TODO,1.26,1.27 In-Reply-To: <200006282213.PAA13365@slayer.i.sourceforge.net> Message-ID: On Wed, 28 Jun 2000, Fred L. Drake wrote: > + * Update the filecmp documentation (Moshe?). I'm waiting for Gordon to check-in his directory comparisons to filecmp. Gordon? -- Moshe Zadka http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From python-dev@python.org Thu Jun 29 09:55:57 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 01:55:57 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules sre.h,2.3,2.4 sre_constants.h,2.3,2.4 Message-ID: <200006290855.BAA11068@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv11005 Modified Files: sre.h sre_constants.h Log Message: towards 1.6b1 Index: sre.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/sre.h,v retrieving revision 2.3 retrieving revision 2.4 diff -C2 -r2.3 -r2.4 *** sre.h 2000/06/01 17:34:20 2.3 --- sre.h 2000/06/29 08:55:54 2.4 *************** *** 15,18 **** --- 15,21 ---- #include "sre_constants.h" + /* size of a code word (must be unsigned short or larger) */ + #define SRE_CODE unsigned short + typedef struct { PyObject_HEAD *************** *** 36,39 **** --- 39,50 ---- } MatchObject; + typedef unsigned int (*SRE_TOLOWER_HOOK)(unsigned int ch); + + typedef struct { + /* stack elements */ + SRE_CODE* pattern; + void* ptr; + } SRE_STACK; + typedef struct { /* string pointers */ *************** *** 45,57 **** int charsize; /* registers */ ! int marks; void* mark[64]; /* FIXME: should be dynamically allocated! */ /* backtracking stack */ ! void** stack; int stacksize; int stackbase; } SRE_STATE; typedef struct { PyObject_HEAD PyObject* pattern; --- 56,71 ---- int charsize; /* registers */ ! int lastmark; void* mark[64]; /* FIXME: should be dynamically allocated! */ /* backtracking stack */ ! SRE_STACK* stack; int stacksize; int stackbase; + /* hooks */ + SRE_TOLOWER_HOOK tolower; } SRE_STATE; typedef struct { + /* search helper */ PyObject_HEAD PyObject* pattern; Index: sre_constants.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/sre_constants.h,v retrieving revision 2.3 retrieving revision 2.4 diff -C2 -r2.3 -r2.4 *** sre_constants.h 2000/06/01 17:34:20 2.3 --- sre_constants.h 2000/06/29 08:55:54 2.4 *************** *** 12,29 **** #define SRE_OP_IN 10 #define SRE_OP_IN_IGNORE 11 ! #define SRE_OP_JUMP 12 ! #define SRE_OP_LITERAL 13 ! #define SRE_OP_LITERAL_IGNORE 14 ! #define SRE_OP_MARK 15 ! #define SRE_OP_MAX_REPEAT 16 ! #define SRE_OP_MAX_UNTIL 17 #define SRE_OP_MAX_REPEAT_ONE 18 #define SRE_OP_MIN_REPEAT 19 ! #define SRE_OP_MIN_UNTIL 20 ! #define SRE_OP_NOT_LITERAL 21 ! #define SRE_OP_NOT_LITERAL_IGNORE 22 ! #define SRE_OP_NEGATE 23 ! #define SRE_OP_RANGE 24 ! #define SRE_OP_REPEAT 25 #define SRE_AT_BEGINNING 0 #define SRE_AT_BEGINNING_LINE 1 --- 12,28 ---- #define SRE_OP_IN 10 #define SRE_OP_IN_IGNORE 11 ! #define SRE_OP_INFO 12 ! #define SRE_OP_JUMP 13 ! #define SRE_OP_LITERAL 14 ! #define SRE_OP_LITERAL_IGNORE 15 ! #define SRE_OP_MARK 16 ! #define SRE_OP_MAX_REPEAT 17 #define SRE_OP_MAX_REPEAT_ONE 18 #define SRE_OP_MIN_REPEAT 19 ! #define SRE_OP_NOT_LITERAL 20 ! #define SRE_OP_NOT_LITERAL_IGNORE 21 ! #define SRE_OP_NEGATE 22 ! #define SRE_OP_RANGE 23 ! #define SRE_OP_REPEAT 24 #define SRE_AT_BEGINNING 0 #define SRE_AT_BEGINNING_LINE 1 *************** *** 40,49 **** #define SRE_CATEGORY_LINEBREAK 6 #define SRE_CATEGORY_NOT_LINEBREAK 7 ! #define SRE_CATEGORY_LOC_DIGIT 8 ! #define SRE_CATEGORY_LOC_NOT_DIGIT 9 ! #define SRE_CATEGORY_LOC_SPACE 10 ! #define SRE_CATEGORY_LOC_NOT_SPACE 11 ! #define SRE_CATEGORY_LOC_WORD 12 ! #define SRE_CATEGORY_LOC_NOT_WORD 13 ! #define SRE_CATEGORY_LOC_LINEBREAK 14 ! #define SRE_CATEGORY_LOC_NOT_LINEBREAK 15 --- 39,57 ---- #define SRE_CATEGORY_LINEBREAK 6 #define SRE_CATEGORY_NOT_LINEBREAK 7 ! #define SRE_CATEGORY_LOC_WORD 8 ! #define SRE_CATEGORY_LOC_NOT_WORD 9 ! #define SRE_CATEGORY_UNI_DIGIT 10 ! #define SRE_CATEGORY_UNI_NOT_DIGIT 11 ! #define SRE_CATEGORY_UNI_SPACE 12 ! #define SRE_CATEGORY_UNI_NOT_SPACE 13 ! #define SRE_CATEGORY_UNI_WORD 14 ! #define SRE_CATEGORY_UNI_NOT_WORD 15 ! #define SRE_CATEGORY_UNI_LINEBREAK 16 ! #define SRE_CATEGORY_UNI_NOT_LINEBREAK 17 ! #define SRE_FLAG_TEMPLATE 1 ! #define SRE_FLAG_IGNORECASE 2 ! #define SRE_FLAG_LOCALE 4 ! #define SRE_FLAG_MULTILINE 8 ! #define SRE_FLAG_DOTALL 16 ! #define SRE_FLAG_UNICODE 32 ! #define SRE_FLAG_VERBOSE 64 From python-dev@python.org Thu Jun 29 09:57:57 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 01:57:57 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.4,2.5 Message-ID: <200006290857.BAA11219@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv11206 Modified Files: _sre.c Log Message: towards 1.6b1 Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.4 retrieving revision 2.5 diff -C2 -r2.4 -r2.5 *** _sre.c 2000/06/01 17:34:20 2.4 --- _sre.c 2000/06/29 08:57:54 2.5 *************** *** 4,20 **** * $Id$ * ! * simple regular expression matching engine * * partial history: ! * 99-10-24 fl created (based on the template matcher) * 99-11-13 fl added categories, branching, and more (0.2) * 99-11-16 fl some tweaks to compile on non-Windows platforms * 99-12-18 fl non-literals, generic maximizing repeat (0.3) ! * 99-02-28 fl tons of changes (not all to the better ;-) (0.4) [...1589 lines suppressed...] void ! #if defined(WIN32) __declspec(dllexport) #endif *************** *** 1708,1713 **** Cursor_Type.ob_type = &PyType_Type; ! Py_InitModule("_sre", _functions); } ! #endif --- 1846,1851 ---- Cursor_Type.ob_type = &PyType_Type; ! Py_InitModule("_" MODULE, _functions); } ! #endif /* !defined(SRE_RECURSIVE) */ From python-dev@python.org Thu Jun 29 09:58:47 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 01:58:47 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre.py,1.6,1.7 sre_compile.py,1.4,1.5 sre_constants.py,1.4,1.5 sre_parse.py,1.4,1.5 Message-ID: <200006290858.BAA11335@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv11309 Modified Files: sre.py sre_compile.py sre_constants.py sre_parse.py Log Message: towards 1.6b1 Index: sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** sre.py 2000/06/18 20:27:10 1.6 --- sre.py 2000/06/29 08:58:44 1.7 *************** *** 13,16 **** --- 13,17 ---- import sre_compile + import sre_parse # flags *************** *** 21,24 **** --- 22,32 ---- X = VERBOSE = sre_compile.SRE_FLAG_VERBOSE + # sre extensions (may or may not be in 1.6 final) + T = TEMPLATE = sre_compile.SRE_FLAG_TEMPLATE + U = UNICODE = sre_compile.SRE_FLAG_UNICODE + + # sre exception + error = sre_parse.error + # -------------------------------------------------------------------- # public interface *************** *** 47,50 **** --- 55,61 ---- return _compile(pattern, flags) + def template(pattern, flags=0): + return _compile(pattern, flags|T) + def escape(pattern): s = list(pattern) *************** *** 84,91 **** return _subn(pattern, template, string, count)[0] - def _expand(match, template): - # internal: expand template - return template # FIXME - def _subn(pattern, template, string, count=0): # internal: pattern.subn implementation hook --- 95,98 ---- *************** *** 93,99 **** filter = template else: ! # FIXME: prepare template def filter(match, template=template): ! return _expand(match, template) n = i = 0 s = [] --- 100,106 ---- filter = template else: ! template = sre_parse.parse_template(template, pattern) def filter(match, template=template): ! return sre_parse.expand_template(template, match) n = i = 0 s = [] *************** *** 109,112 **** --- 116,121 ---- append(filter(m)) i = m.end() + if i <= j: + break n = n + 1 if i < len(string): *************** *** 127,130 **** --- 136,141 ---- append(string[i:j]) i = m.end() + if i <= j: + break n = n + 1 if i < len(string): Index: sre_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** sre_compile.py 2000/06/01 17:39:12 1.4 --- sre_compile.py 2000/06/29 08:58:44 1.5 *************** *** 49,53 **** raise ! def _compile(code, pattern, flags, level=0): append = code.append for op, av in pattern: --- 49,53 ---- raise ! def _compile(code, pattern, flags): append = code.append for op, av in pattern: *************** *** 71,91 **** for av in av[1]: skip = len(code); append(0) ! _compile(code, av, flags, level) ! append(OPCODES[JUMP]) ! tail.append(len(code)); append(0) code[skip] = len(code) - skip append(0) # end of branch ! for tail in tail: code[tail] = len(code) - tail elif op is CALL: append(OPCODES[op]) skip = len(code); append(0) ! _compile(code, av, flags, level+1) append(OPCODES[SUCCESS]) code[skip] = len(code) - skip ! elif op is CATEGORY: # not used by current parser append(OPCODES[op]) if flags & SRE_FLAG_LOCALE: append(CH_LOCALE[CHCODES[av]]) else: append(CHCODES[av]) --- 71,94 ---- for av in av[1]: skip = len(code); append(0) ! _compile(code, av, flags) ! ## append(OPCODES[SUCCESS]) ! append(OPCODES[JUMP]) ! tail.append(len(code)); append(0) code[skip] = len(code) - skip append(0) # end of branch ! for tail in tail: code[tail] = len(code) - tail elif op is CALL: append(OPCODES[op]) skip = len(code); append(0) ! _compile(code, av, flags) append(OPCODES[SUCCESS]) code[skip] = len(code) - skip ! elif op is CATEGORY: append(OPCODES[op]) if flags & SRE_FLAG_LOCALE: append(CH_LOCALE[CHCODES[av]]) + elif flags & SRE_FLAG_UNICODE: + append(CH_UNICODE[CHCODES[av]]) else: append(CHCODES[av]) *************** *** 99,104 **** if flags & SRE_FLAG_IGNORECASE: append(OPCODES[OP_IGNORE[op]]) ! def fixup(literal): ! return ord(literal.lower()) else: append(OPCODES[op]) --- 102,107 ---- if flags & SRE_FLAG_IGNORECASE: append(OPCODES[OP_IGNORE[op]]) ! def fixup(literal, flags=flags): ! return _sre.getlower(ord(literal), flags) else: append(OPCODES[op]) *************** *** 117,120 **** --- 120,125 ---- if flags & SRE_FLAG_LOCALE: append(CH_LOCALE[CHCODES[av]]) + elif flags & SRE_FLAG_UNICODE: + append(CH_UNICODE[CHCODES[av]]) else: append(CHCODES[av]) *************** *** 126,159 **** if flags & SRE_FLAG_IGNORECASE: append(OPCODES[OP_IGNORE[op]]) - append(ord(av.lower())) else: append(OPCODES[op]) ! append(ord(av)) elif op is MARK: append(OPCODES[op]) append(av) elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): ! lo, hi = av[2].getwidth() ! if lo == 0: ! raise SyntaxError, "cannot repeat zero-width items" ! if lo == hi == 1 and op is MAX_REPEAT: ! append(OPCODES[MAX_REPEAT_ONE]) skip = len(code); append(0) append(av[0]) append(av[1]) ! _compile(code, av[2], flags, level+1) append(OPCODES[SUCCESS]) code[skip] = len(code) - skip else: ! append(OPCODES[op]) ! skip = len(code); append(0) ! append(av[0]) ! append(av[1]) ! _compile(code, av[2], flags, level+1) ! if op is MIN_REPEAT: ! append(OPCODES[MIN_UNTIL]) else: ! append(OPCODES[MAX_UNTIL]) ! code[skip] = len(code) - skip elif op is SUBPATTERN: group = av[0] --- 131,171 ---- if flags & SRE_FLAG_IGNORECASE: append(OPCODES[OP_IGNORE[op]]) else: append(OPCODES[op]) ! append(ord(av)) elif op is MARK: append(OPCODES[op]) append(av) elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): ! if flags & SRE_FLAG_TEMPLATE: ! append(OPCODES[REPEAT]) skip = len(code); append(0) append(av[0]) append(av[1]) ! _compile(code, av[2], flags) append(OPCODES[SUCCESS]) code[skip] = len(code) - skip else: ! lo, hi = av[2].getwidth() ! if lo == 0: ! raise error, "nothing to repeat" ! if 0 and lo == hi == 1 and op is MAX_REPEAT: ! # FIXME: need a better way to figure out when ! # it's safe to use this one (in the parser, probably) ! append(OPCODES[MAX_REPEAT_ONE]) ! skip = len(code); append(0) ! append(av[0]) ! append(av[1]) ! _compile(code, av[2], flags) ! append(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip else: ! append(OPCODES[op]) ! skip = len(code); append(0) ! append(av[0]) ! append(av[1]) ! _compile(code, av[2], flags) ! append(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip elif op is SUBPATTERN: group = av[0] *************** *** 161,165 **** append(OPCODES[MARK]) append((group-1)*2) ! _compile(code, av[1], flags, level+1) if group: append(OPCODES[MARK]) --- 173,177 ---- append(OPCODES[MARK]) append((group-1)*2) ! _compile(code, av[1], flags) if group: append(OPCODES[MARK]) Index: sre_constants.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_constants.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** sre_constants.py 2000/06/01 17:39:12 1.4 --- sre_constants.py 2000/06/29 08:58:44 1.5 *************** *** 16,19 **** --- 16,24 ---- # + # should this really be here? + + class error(Exception): + pass + # operators *************** *** 31,34 **** --- 36,40 ---- IN = "in" IN_IGNORE = "in_ignore" + INFO = "info" JUMP = "jump" LITERAL = "literal" *************** *** 37,43 **** MAX_REPEAT = "max_repeat" MAX_REPEAT_ONE = "max_repeat_one" - MAX_UNTIL = "max_until" MIN_REPEAT = "min_repeat" - MIN_UNTIL = "min_until" NEGATE = "negate" NOT_LITERAL = "not_literal" --- 43,47 ---- *************** *** 45,48 **** --- 49,53 ---- RANGE = "range" REPEAT = "repeat" + REPEAT_ONE = "repeat_one" SUBPATTERN = "subpattern" *************** *** 64,75 **** CATEGORY_LINEBREAK = "category_linebreak" CATEGORY_NOT_LINEBREAK = "category_not_linebreak" - CATEGORY_LOC_DIGIT = "category_loc_digit" - CATEGORY_LOC_NOT_DIGIT = "category_loc_not_digit" - CATEGORY_LOC_SPACE = "category_loc_space" - CATEGORY_LOC_NOT_SPACE = "category_loc_not_space" CATEGORY_LOC_WORD = "category_loc_word" CATEGORY_LOC_NOT_WORD = "category_loc_not_word" ! CATEGORY_LOC_LINEBREAK = "category_loc_linebreak" ! CATEGORY_LOC_NOT_LINEBREAK = "category_loc_not_linebreak" OPCODES = [ --- 69,82 ---- CATEGORY_LINEBREAK = "category_linebreak" CATEGORY_NOT_LINEBREAK = "category_not_linebreak" CATEGORY_LOC_WORD = "category_loc_word" CATEGORY_LOC_NOT_WORD = "category_loc_not_word" ! CATEGORY_UNI_DIGIT = "category_uni_digit" ! CATEGORY_UNI_NOT_DIGIT = "category_uni_not_digit" ! CATEGORY_UNI_SPACE = "category_uni_space" ! CATEGORY_UNI_NOT_SPACE = "category_uni_not_space" ! CATEGORY_UNI_WORD = "category_uni_word" ! CATEGORY_UNI_NOT_WORD = "category_uni_not_word" ! CATEGORY_UNI_LINEBREAK = "category_uni_linebreak" ! CATEGORY_UNI_NOT_LINEBREAK = "category_uni_not_linebreak" OPCODES = [ *************** *** 86,95 **** GROUP, GROUP_IGNORE, IN, IN_IGNORE, JUMP, LITERAL, LITERAL_IGNORE, MARK, ! MAX_REPEAT, MAX_UNTIL, MAX_REPEAT_ONE, ! MIN_REPEAT, MIN_UNTIL, NOT_LITERAL, NOT_LITERAL_IGNORE, NEGATE, --- 93,103 ---- GROUP, GROUP_IGNORE, IN, IN_IGNORE, + INFO, JUMP, LITERAL, LITERAL_IGNORE, MARK, ! MAX_REPEAT, MAX_REPEAT_ONE, ! MIN_REPEAT, NOT_LITERAL, NOT_LITERAL_IGNORE, NEGATE, *************** *** 107,114 **** CATEGORY_DIGIT, CATEGORY_NOT_DIGIT, CATEGORY_SPACE, CATEGORY_NOT_SPACE, CATEGORY_WORD, CATEGORY_NOT_WORD, ! CATEGORY_LINEBREAK, CATEGORY_NOT_LINEBREAK, CATEGORY_LOC_DIGIT, ! CATEGORY_LOC_NOT_DIGIT, CATEGORY_LOC_SPACE, ! CATEGORY_LOC_NOT_SPACE, CATEGORY_LOC_WORD, CATEGORY_LOC_NOT_WORD, ! CATEGORY_LOC_LINEBREAK, CATEGORY_LOC_NOT_LINEBREAK ] --- 115,123 ---- CATEGORY_DIGIT, CATEGORY_NOT_DIGIT, CATEGORY_SPACE, CATEGORY_NOT_SPACE, CATEGORY_WORD, CATEGORY_NOT_WORD, ! CATEGORY_LINEBREAK, CATEGORY_NOT_LINEBREAK, CATEGORY_LOC_WORD, ! CATEGORY_LOC_NOT_WORD, CATEGORY_UNI_DIGIT, CATEGORY_UNI_NOT_DIGIT, ! CATEGORY_UNI_SPACE, CATEGORY_UNI_NOT_SPACE, CATEGORY_UNI_WORD, ! CATEGORY_UNI_NOT_WORD, CATEGORY_UNI_LINEBREAK, ! CATEGORY_UNI_NOT_LINEBREAK ] *************** *** 139,159 **** CH_LOCALE = { ! CATEGORY_DIGIT: CATEGORY_LOC_DIGIT, ! CATEGORY_NOT_DIGIT: CATEGORY_LOC_NOT_DIGIT, ! CATEGORY_SPACE: CATEGORY_LOC_SPACE, ! CATEGORY_NOT_SPACE: CATEGORY_LOC_NOT_SPACE, CATEGORY_WORD: CATEGORY_LOC_WORD, CATEGORY_NOT_WORD: CATEGORY_LOC_NOT_WORD, ! CATEGORY_LINEBREAK: CATEGORY_LOC_LINEBREAK, ! CATEGORY_NOT_LINEBREAK: CATEGORY_LOC_NOT_LINEBREAK } # flags ! SRE_FLAG_TEMPLATE = 1 # NYI SRE_FLAG_IGNORECASE = 2 SRE_FLAG_LOCALE = 4 SRE_FLAG_MULTILINE = 8 SRE_FLAG_DOTALL = 16 ! SRE_FLAG_VERBOSE = 32 if __name__ == "__main__": --- 148,180 ---- CH_LOCALE = { ! CATEGORY_DIGIT: CATEGORY_DIGIT, ! CATEGORY_NOT_DIGIT: CATEGORY_NOT_DIGIT, ! CATEGORY_SPACE: CATEGORY_SPACE, ! CATEGORY_NOT_SPACE: CATEGORY_NOT_SPACE, CATEGORY_WORD: CATEGORY_LOC_WORD, CATEGORY_NOT_WORD: CATEGORY_LOC_NOT_WORD, ! CATEGORY_LINEBREAK: CATEGORY_LINEBREAK, ! CATEGORY_NOT_LINEBREAK: CATEGORY_NOT_LINEBREAK ! } ! ! CH_UNICODE = { ! CATEGORY_DIGIT: CATEGORY_UNI_DIGIT, ! CATEGORY_NOT_DIGIT: CATEGORY_UNI_NOT_DIGIT, ! CATEGORY_SPACE: CATEGORY_UNI_SPACE, ! CATEGORY_NOT_SPACE: CATEGORY_UNI_NOT_SPACE, ! CATEGORY_WORD: CATEGORY_UNI_WORD, ! CATEGORY_NOT_WORD: CATEGORY_UNI_NOT_WORD, ! CATEGORY_LINEBREAK: CATEGORY_UNI_LINEBREAK, ! CATEGORY_NOT_LINEBREAK: CATEGORY_UNI_NOT_LINEBREAK } # flags ! SRE_FLAG_TEMPLATE = 1 SRE_FLAG_IGNORECASE = 2 SRE_FLAG_LOCALE = 4 SRE_FLAG_MULTILINE = 8 SRE_FLAG_DOTALL = 16 ! SRE_FLAG_UNICODE = 32 ! SRE_FLAG_VERBOSE = 64 if __name__ == "__main__": *************** *** 169,172 **** --- 190,200 ---- dump(f, ATCODES, "SRE") dump(f, CHCODES, "SRE") + f.write("#define SRE_FLAG_TEMPLATE %d\n" % SRE_FLAG_TEMPLATE) + f.write("#define SRE_FLAG_IGNORECASE %d\n" % SRE_FLAG_IGNORECASE) + f.write("#define SRE_FLAG_LOCALE %d\n" % SRE_FLAG_LOCALE) + f.write("#define SRE_FLAG_MULTILINE %d\n" % SRE_FLAG_MULTILINE) + f.write("#define SRE_FLAG_DOTALL %d\n" % SRE_FLAG_DOTALL) + f.write("#define SRE_FLAG_UNICODE %d\n" % SRE_FLAG_UNICODE) + f.write("#define SRE_FLAG_VERBOSE %d\n" % SRE_FLAG_VERBOSE) f.close() print "done" Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** sre_parse.py 2000/06/09 14:08:07 1.4 --- sre_parse.py 2000/06/29 08:58:44 1.5 *************** *** 21,26 **** from sre_constants import * ! # FIXME: should be 65535, but the array module currently chokes on ! # unsigned integers larger than 32767... MAXREPEAT = int(2L**(_sre.getcodesize()*8-1))-1 --- 21,26 ---- from sre_constants import * ! # FIXME: should be 65535, but the array module currently chokes ! # on unsigned integers larger than 32767 [fixed in 1.6b1?] MAXREPEAT = int(2L**(_sre.getcodesize()*8-1))-1 *************** *** 28,32 **** REPEAT_CHARS = "*+?{" ! # FIXME: string in tuple tests may explode with if char is unicode :-( DIGITS = tuple(string.digits) --- 28,33 ---- REPEAT_CHARS = "*+?{" ! # FIXME: string in tuple tests may explode with if char is ! # unicode [fixed in 1.6b1?] DIGITS = tuple(string.digits) *************** *** 60,69 **** FLAGS = { "i": SRE_FLAG_IGNORECASE, "L": SRE_FLAG_LOCALE, "m": SRE_FLAG_MULTILINE, "s": SRE_FLAG_DOTALL, - "t": SRE_FLAG_TEMPLATE, "x": SRE_FLAG_VERBOSE, } --- 61,73 ---- FLAGS = { + # standard flags "i": SRE_FLAG_IGNORECASE, "L": SRE_FLAG_LOCALE, "m": SRE_FLAG_MULTILINE, "s": SRE_FLAG_DOTALL, "x": SRE_FLAG_VERBOSE, + # extensions + "t": SRE_FLAG_TEMPLATE, + "u": SRE_FLAG_UNICODE, } *************** *** 152,156 **** c = self.string[self.index + 1] except IndexError: ! raise SyntaxError, "bogus escape" char = char + c self.index = self.index + len(char) --- 156,160 ---- c = self.string[self.index + 1] except IndexError: ! raise error, "bogus escape" char = char + c self.index = self.index + len(char) *************** *** 206,210 **** except ValueError: pass ! raise SyntaxError, "bogus escape: %s" % repr(escape) def _escape(source, escape, state): --- 210,214 ---- except ValueError: pass ! raise error, "bogus escape: %s" % repr(escape) def _escape(source, escape, state): *************** *** 242,252 **** except ValueError: pass ! raise SyntaxError, "bogus escape: %s" % repr(escape) def _branch(pattern, items): ! # form a branch operator from a set of items (FIXME: move this ! # optimization to the compiler module!) subpattern = SubPattern(pattern) --- 246,255 ---- except ValueError: pass ! raise error, "bogus escape: %s" % repr(escape) def _branch(pattern, items): ! # form a branch operator from a set of items subpattern = SubPattern(pattern) *************** *** 333,337 **** code1 = LITERAL, this else: ! raise SyntaxError, "unexpected end of regular expression" if source.match("-"): # potential range --- 336,340 ---- code1 = LITERAL, this else: ! raise error, "unexpected end of regular expression" if source.match("-"): # potential range *************** *** 347,353 **** code2 = LITERAL, this if code1[0] != LITERAL or code2[0] != LITERAL: ! raise SyntaxError, "illegal range" if len(code1[1]) != 1 or len(code2[1]) != 1: ! raise SyntaxError, "illegal range" set.append((RANGE, (code1[1], code2[1]))) else: --- 350,356 ---- code2 = LITERAL, this if code1[0] != LITERAL or code2[0] != LITERAL: ! raise error, "illegal range" if len(code1[1]) != 1 or len(code2[1]) != 1: ! raise error, "illegal range" set.append((RANGE, (code1[1], code2[1]))) else: *************** *** 384,388 **** hi = lo if not source.match("}"): ! raise SyntaxError, "bogus range" if lo: min = int(lo) --- 387,391 ---- hi = lo if not source.match("}"): ! raise error, "bogus range" if lo: min = int(lo) *************** *** 391,400 **** # FIXME: check that hi >= lo! else: ! raise SyntaxError, "not supported" # figure out which item to repeat if subpattern: item = subpattern[-1:] else: ! raise SyntaxError, "nothing to repeat" if source.match("?"): subpattern[-1] = (MIN_REPEAT, (min, max, item)) --- 394,403 ---- # FIXME: check that hi >= lo! else: ! raise error, "not supported" # figure out which item to repeat if subpattern: item = subpattern[-1:] else: ! raise error, "nothing to repeat" if source.match("?"): subpattern[-1] = (MIN_REPEAT, (min, max, item)) *************** *** 419,423 **** char = source.get() if char is None: ! raise SyntaxError, "unterminated name" if char == ">": break --- 422,426 ---- char = source.get() if char is None: ! raise error, "unterminated name" if char == ">": break *************** *** 427,437 **** elif source.match("="): # named backreference ! raise SyntaxError, "not yet implemented" ! else: char = source.get() if char is None: ! raise SyntaxError, "unexpected end of pattern" ! raise SyntaxError, "unknown specifier: ?P%s" % char elif source.match(":"): # non-capturing group --- 430,439 ---- elif source.match("="): # named backreference ! raise error, "not yet implemented" else: char = source.get() if char is None: ! raise error, "unexpected end of pattern" ! raise error, "unknown specifier: ?P%s" % char elif source.match(":"): # non-capturing group *************** *** 440,446 **** # comment while 1: ! char = source.get() ! if char is None or char == ")": break else: # flags --- 442,448 ---- # comment while 1: ! if source.next is None or source.next == ")": break + source.get() else: # flags *************** *** 466,470 **** b.append(p) else: ! raise SyntaxError, "group not properly closed" else: while 1: --- 468,472 ---- b.append(p) else: ! raise error, "group not properly closed" else: while 1: *************** *** 472,476 **** if char is None or char == ")": break ! # FIXME: skip characters? elif this == "^": --- 474,478 ---- if char is None or char == ")": break ! raise error, "unknown extension" elif this == "^": *************** *** 485,489 **** else: ! raise SyntaxError, "parser error" return subpattern --- 487,491 ---- else: ! raise error, "parser error" return subpattern *************** *** 500,504 **** b.append(p) elif tail == ")": ! raise SyntaxError, "unbalanced parenthesis" elif tail is None: if b: --- 502,506 ---- b.append(p) elif tail == ")": ! raise error, "unbalanced parenthesis" elif tail is None: if b: *************** *** 507,514 **** break else: ! raise SyntaxError, "bogus characters at end of regular expression" return p ! def parse_replacement(source, pattern): # parse 're' replacement string into list of literals and # group references --- 509,516 ---- break else: ! raise error, "bogus characters at end of regular expression" return p ! def parse_template(source, pattern): # parse 're' replacement string into list of literals and # group references *************** *** 521,533 **** break # end of replacement string if this and this[0] == "\\": ! try: ! a(LITERAL, ESCAPES[this]) ! except KeyError: ! for char in this: ! a(LITERAL, char) else: ! a(LITERAL, this) return p if __name__ == "__main__": from pprint import pprint --- 523,576 ---- break # end of replacement string if this and this[0] == "\\": ! if this == "\\g": ! name = "" ! if s.match("<"): ! while 1: ! char = s.get() ! if char is None: ! raise error, "unterminated index" ! if char == ">": ! break ! # FIXME: check for valid character ! name = name + char ! if not name: ! raise error, "bad index" ! try: ! index = int(name) ! except ValueError: ! try: ! index = pattern.groupindex[name] ! except KeyError: ! raise IndexError, "unknown index" ! a((MARK, index)) ! elif len(this) > 1 and this[1] in DIGITS: ! while s.next in DIGITS: ! this = this + s.get() ! a((MARK, int(this[1:]))) ! else: ! try: ! a(ESCAPES[this]) ! except KeyError: ! for char in this: ! a((LITERAL, char)) else: ! a((LITERAL, this)) return p + def expand_template(template, match): + # FIXME: this is sooooo slow. drop in the slicelist + # code instead + p = [] + a = p.append + for c, s in template: + if c is LITERAL: + a(s) + elif c is MARK: + s = match.group(s) + if s is None: + raise error, "empty group" + a(s) + return match.string[:0].join(p) + if __name__ == "__main__": from pprint import pprint *************** *** 549,553 **** pass a = a + 1 ! except SyntaxError, v: print "**", repr(pattern), v b = b + 1 --- 592,596 ---- pass a = a + 1 ! except error, v: print "**", repr(pattern), v b = b + 1 From python-dev@python.org Thu Jun 29 11:34:58 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 03:34:58 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.5,2.6 sre.h,2.4,2.5 Message-ID: <200006291034.DAA01623@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv1431/Modules Modified Files: _sre.c sre.h Log Message: - removed "alpha only" licensing restriction - removed some hacks that worked around 1.6 alpha bugs - removed bogus test code from sre_parse Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.5 retrieving revision 2.6 diff -C2 -r2.5 -r2.6 *** _sre.c 2000/06/29 08:57:54 2.5 --- _sre.c 2000/06/29 10:34:56 2.6 *************** *** 4,8 **** * $Id$ * ! n * simple regular expression matching engine * * partial history: --- 4,8 ---- * $Id$ * ! * regular expression matching engine * * partial history: *************** *** 23,39 **** * Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. * - * This code can only be used for 1.6 alpha testing. All other use - * require explicit permission from Secret Labs AB. - * * Portions of this engine have been developed in cooperation with * CNRI. Hewlett-Packard provided funding for 1.6 integration and * other compatibility work. */ - - /* - * FIXME: repeated groups don't work (they're usually come out empty) - * FIXME: rename to 're' - * FIXME: enable repeat_one optimization - */ #ifndef SRE_RECURSIVE --- 23,30 ---- Index: sre.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/sre.h,v retrieving revision 2.4 retrieving revision 2.5 diff -C2 -r2.4 -r2.5 From python-dev@python.org Thu Jun 29 11:34:58 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 03:34:58 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre.py,1.7,1.8 sre_compile.py,1.5,1.6 sre_constants.py,1.5,1.6 sre_parse.py,1.5,1.6 Message-ID: <200006291034.DAA01619@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv1431/Lib Modified Files: sre.py sre_compile.py sre_constants.py sre_parse.py Log Message: - removed "alpha only" licensing restriction - removed some hacks that worked around 1.6 alpha bugs - removed bogus test code from sre_parse Index: sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 Index: sre_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** sre_compile.py 2000/06/29 08:58:44 1.5 --- sre_compile.py 2000/06/29 10:34:55 1.6 *************** *** 7,13 **** # Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. # - # This code can only be used for 1.6 alpha testing. All other use - # require explicit permission from Secret Labs AB. - # # Portions of this engine have been developed in cooperation with # CNRI. Hewlett-Packard provided funding for 1.6 integration and --- 7,10 ---- Index: sre_constants.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_constants.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** sre_constants.py 2000/06/29 08:58:44 1.5 --- sre_constants.py 2000/06/29 10:34:55 1.6 *************** *** 8,14 **** # Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. # - # This code can only be used for 1.6 alpha testing. All other use - # require explicit permission from Secret Labs AB. - # # Portions of this engine have been developed in cooperation with # CNRI. Hewlett-Packard provided funding for 1.6 integration and --- 8,11 ---- Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** sre_parse.py 2000/06/29 08:58:44 1.5 --- sre_parse.py 2000/06/29 10:34:55 1.6 *************** *** 7,13 **** # Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. # - # This code can only be used for 1.6 alpha testing. All other use - # require explicit permission from Secret Labs AB. - # # Portions of this engine have been developed in cooperation with # CNRI. Hewlett-Packard provided funding for 1.6 integration and --- 7,10 ---- *************** *** 21,39 **** from sre_constants import * ! # FIXME: should be 65535, but the array module currently chokes ! # on unsigned integers larger than 32767 [fixed in 1.6b1?] ! MAXREPEAT = int(2L**(_sre.getcodesize()*8-1))-1 SPECIAL_CHARS = ".\\[{()*+?^$|" REPEAT_CHARS = "*+?{" ! # FIXME: string in tuple tests may explode with if char is ! # unicode [fixed in 1.6b1?] ! DIGITS = tuple(string.digits) ! OCTDIGITS = tuple("01234567") ! HEXDIGITS = tuple("0123456789abcdefABCDEF") ! WHITESPACE = tuple(string.whitespace) ESCAPES = { --- 18,33 ---- from sre_constants import * ! # FIXME: should be 65535, but the arraymodule is still broken ! MAXREPEAT = 32767 SPECIAL_CHARS = ".\\[{()*+?^$|" REPEAT_CHARS = "*+?{" ! DIGITS = string.digits ! OCTDIGITS = "01234567" ! HEXDIGITS = "0123456789abcdefABCDEF" ! WHITESPACE = string.whitespace ESCAPES = { *************** *** 195,199 **** try: if escape[1:2] == "x": ! while source.next in HEXDIGITS: escape = escape + source.get() escape = escape[2:] --- 189,193 ---- try: if escape[1:2] == "x": ! while source.next and source.next in HEXDIGITS: escape = escape + source.get() escape = escape[2:] *************** *** 201,205 **** return LITERAL, chr(int(escape[-4:], 16) & 0xff) elif str(escape[1:2]) in OCTDIGITS: ! while source.next in OCTDIGITS: escape = escape + source.get() escape = escape[1:] --- 195,199 ---- return LITERAL, chr(int(escape[-4:], 16) & 0xff) elif str(escape[1:2]) in OCTDIGITS: ! while source.next and source.next in OCTDIGITS: escape = escape + source.get() escape = escape[1:] *************** *** 222,226 **** try: if escape[1:2] == "x": ! while source.next in HEXDIGITS: escape = escape + source.get() escape = escape[2:] --- 216,220 ---- try: if escape[1:2] == "x": ! while source.next and source.next in HEXDIGITS: escape = escape + source.get() escape = escape[2:] *************** *** 235,239 **** return GROUP, group escape = escape + source.get() ! elif source.next in OCTDIGITS: escape = escape + source.get() else: --- 229,233 ---- return GROUP, group escape = escape + source.get() ! elif source.next and source.next in OCTDIGITS: escape = escape + source.get() else: *************** *** 298,302 **** while 1: ! if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() --- 292,296 ---- while 1: ! if source.next in ("|", ")"): break # end of subpattern this = source.get() *************** *** 379,386 **** min, max = 0, MAXREPEAT lo = hi = "" ! while str(source.next) in DIGITS: lo = lo + source.get() if source.match(","): ! while str(source.next) in DIGITS: hi = hi + source.get() else: --- 373,380 ---- min, max = 0, MAXREPEAT lo = hi = "" ! while source.next and source.next in DIGITS: lo = lo + source.get() if source.match(","): ! while source.next and source.next in DIGITS: hi = hi + source.get() else: *************** *** 572,600 **** a(s) return match.string[:0].join(p) - - if __name__ == "__main__": - from pprint import pprint - from testpatterns import PATTERNS - a = b = c = 0 - for pattern, flags in PATTERNS: - if flags: - continue - print "-"*68 - try: - p = parse(pattern) - print repr(pattern), "->" - pprint(p.data) - import sre_compile - try: - code = sre_compile.compile(p) - c = c + 1 - except: - pass - a = a + 1 - except error, v: - print "**", repr(pattern), v - b = b + 1 - print "-"*68 - print a, "of", b, "patterns successfully parsed" - print c, "of", b, "patterns successfully compiled" - --- 566,567 ---- From python-dev@python.org Thu Jun 29 12:05:34 2000 From: python-dev@python.org (Greg Stein) Date: Thu, 29 Jun 2000 04:05:34 -0700 Subject: [Python-checkins] CVS: python/dist/src/Demo/imputil importers.py,NONE,1.1 Message-ID: <200006291105.EAA11909@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Demo/imputil In directory slayer.i.sourceforge.net:/tmp/cvs-serv11808 Added Files: importers.py Log Message: demonstration importers --- NEW FILE --- # # importers.py # # Demonstration subclasses of imputil.Importer # # There should be consideration for the imports below if it is desirable # to have "all" modules be imported through the imputil system. # these are C extensions import sys import imp import struct import marshal # these are .py modules import imputil import os ###################################################################### _TupleType = type(()) _StringType = type('') ###################################################################### # byte-compiled file suffic character _suffix_char = __debug__ and 'c' or 'o' # byte-compiled file suffix _suffix = '.py' + _suffix_char # the C_EXTENSION suffixes _c_suffixes = filter(lambda x: x[2] == imp.C_EXTENSION, imp.get_suffixes()) def _timestamp(pathname): "Return the file modification time as a Long." try: s = os.stat(pathname) except OSError: return None return long(s[8]) def _fs_import(dir, modname, fqname): "Fetch a module from the filesystem." pathname = os.path.join(dir, modname) if os.path.isdir(pathname): values = { '__pkgdir__' : pathname, '__path__' : [ pathname ] } ispkg = 1 pathname = os.path.join(pathname, '__init__') else: values = { } ispkg = 0 # look for dynload modules for desc in _c_suffixes: file = pathname + desc[0] try: fp = open(file, desc[1]) except IOError: pass else: module = imp.load_module(fqname, fp, file, desc) values['__file__'] = file return 0, module, values t_py = _timestamp(pathname + '.py') t_pyc = _timestamp(pathname + _suffix) if t_py is None and t_pyc is None: return None code = None if t_py is None or (t_pyc is not None and t_pyc >= t_py): file = pathname + _suffix f = open(file, 'rb') if f.read(4) == imp.get_magic(): t = struct.unpack('., where can be located using a subclass-specific mechanism and the is found in the archive using a subclass-specific mechanism. This class defines two hooks for subclasses: one to locate an archive (and possibly return some context for future subfile lookups), and one to locate subfiles. """ def get_code(self, parent, modname, fqname): if parent: # the Importer._finish_import logic ensures that we handle imports # under the top level module (package / archive). assert parent.__importer__ == self # if a parent "package" is provided, then we are importing a sub-file # from the archive. result = self.get_subfile(parent.__archive__, modname) if result is None: return None if isinstance(result, _TupleType): assert len(result) == 2 return (0,) + result return 0, result, {} # no parent was provided, so the archive should exist somewhere on the # default "path". archive = self.get_archive(modname) if archive is None: return None return 1, "", {'__archive__':archive} def get_archive(self, modname): """Get an archive of modules. This method should locate an archive and return a value which can be used by get_subfile to load modules from it. The value may be a simple pathname, an open file, or a complex object that caches information for future imports. Return None if the archive was not found. """ raise RuntimeError, "get_archive not implemented" def get_subfile(self, archive, modname): """Get code from a subfile in the specified archive. Given the specified archive (as returned by get_archive()), locate and return a code object for the specified module name. A 2-tuple may be returned, consisting of a code object and a dict of name/values to place into the target module. Return None if the subfile was not found. """ raise RuntimeError, "get_subfile not implemented" class PackageArchive(PackageArchiveImporter): "PackageArchiveImporter subclass that refers to a specific archive." def __init__(self, modname, archive_pathname): self.__modname = modname self.__path = archive_pathname def get_archive(self, modname): if modname == self.__modname: return self.__path return None # get_subfile is passed the full pathname of the archive ###################################################################### # # Emulate the standard directory-based import mechanism # class DirectoryImporter(imputil.Importer): "Importer subclass to emulate the standard importer." def __init__(self, dir): self.dir = dir def get_code(self, parent, modname, fqname): if parent: dir = parent.__pkgdir__ else: dir = self.dir # Return the module (and other info) if found in the specified # directory. Otherwise, return None. return _fs_import(dir, modname, fqname) def __repr__(self): return '<%s.%s for "%s" at 0x%x>' % (self.__class__.__module__, self.__class__.__name__, self.dir, id(self)) ###################################################################### # # Emulate the standard path-style import mechanism # class PathImporter(imputil.Importer): def __init__(self, path=sys.path): self.path = path def get_code(self, parent, modname, fqname): if parent: # we are looking for a module inside of a specific package return _fs_import(parent.__pkgdir__, modname, fqname) # scan sys.path, looking for the requested module for dir in self.path: if isinstance(dir, _StringType): result = _fs_import(dir, modname, fqname) if result: return result # not found return None ###################################################################### def _test_dir(): "Debug/test function to create DirectoryImporters from sys.path." imputil.ImportManager().install() path = sys.path[:] path.reverse() for d in path: sys.path.insert(0, DirectoryImporter(d)) sys.path.insert(0, imputil.BuiltinImporter()) def _test_revamp(): "Debug/test function for the revamped import system." imputil.ImportManager().install() sys.path.insert(0, PathImporter()) sys.path.insert(0, imputil.BuiltinImporter()) From python-dev@python.org Thu Jun 29 12:34:30 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 04:34:30 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre.py,1.8,1.9 sre_compile.py,1.6,1.7 sre_constants.py,1.6,1.7 sre_parse.py,1.6,1.7 Message-ID: <200006291134.EAA19309@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv18748/Lib Modified Files: sre.py sre_compile.py sre_constants.py sre_parse.py Log Message: - last patch broke parse_template; fixed by changing some tests in sre_patch back to previous version - fixed return value from findall - renamed a bunch of functions inside _sre (way too many leading underscores...) Index: sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 Index: sre_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 Index: sre_constants.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_constants.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** sre_parse.py 2000/06/29 10:34:55 1.6 --- sre_parse.py 2000/06/29 11:34:27 1.7 *************** *** 24,31 **** REPEAT_CHARS = "*+?{" ! DIGITS = string.digits ! OCTDIGITS = "01234567" ! HEXDIGITS = "0123456789abcdefABCDEF" WHITESPACE = string.whitespace --- 24,31 ---- REPEAT_CHARS = "*+?{" ! DIGITS = tuple(string.digits) ! OCTDIGITS = tuple("01234567") ! HEXDIGITS = tuple("0123456789abcdefABCDEF") WHITESPACE = string.whitespace *************** *** 189,193 **** try: if escape[1:2] == "x": ! while source.next and source.next in HEXDIGITS: escape = escape + source.get() escape = escape[2:] --- 189,193 ---- try: if escape[1:2] == "x": ! while source.next in HEXDIGITS: escape = escape + source.get() escape = escape[2:] *************** *** 195,199 **** return LITERAL, chr(int(escape[-4:], 16) & 0xff) elif str(escape[1:2]) in OCTDIGITS: ! while source.next and source.next in OCTDIGITS: escape = escape + source.get() escape = escape[1:] --- 195,199 ---- return LITERAL, chr(int(escape[-4:], 16) & 0xff) elif str(escape[1:2]) in OCTDIGITS: ! while source.next in OCTDIGITS: escape = escape + source.get() escape = escape[1:] *************** *** 216,225 **** try: if escape[1:2] == "x": ! while source.next and source.next in HEXDIGITS: escape = escape + source.get() escape = escape[2:] # FIXME: support unicode characters! return LITERAL, chr(int(escape[-4:], 16) & 0xff) ! elif str(escape[1:2]) in DIGITS: while 1: group = _group(escape, state) --- 216,225 ---- try: if escape[1:2] == "x": ! while source.next in HEXDIGITS: escape = escape + source.get() escape = escape[2:] # FIXME: support unicode characters! return LITERAL, chr(int(escape[-4:], 16) & 0xff) ! elif escape[1:2] in DIGITS: while 1: group = _group(escape, state) *************** *** 229,233 **** return GROUP, group escape = escape + source.get() ! elif source.next and source.next in OCTDIGITS: escape = escape + source.get() else: --- 229,233 ---- return GROUP, group escape = escape + source.get() ! elif source.next in OCTDIGITS: escape = escape + source.get() else: *************** *** 373,380 **** min, max = 0, MAXREPEAT lo = hi = "" ! while source.next and source.next in DIGITS: lo = lo + source.get() if source.match(","): ! while source.next and source.next in DIGITS: hi = hi + source.get() else: --- 373,380 ---- min, max = 0, MAXREPEAT lo = hi = "" ! while source.next in DIGITS: lo = lo + source.get() if source.match(","): ! while source.next in DIGITS: hi = hi + source.get() else: From python-dev@python.org Thu Jun 29 12:34:30 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 04:34:30 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.6,2.7 sre.h,2.5,2.6 Message-ID: <200006291134.EAA19310@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv18748/Modules Modified Files: _sre.c sre.h Log Message: - last patch broke parse_template; fixed by changing some tests in sre_patch back to previous version - fixed return value from findall - renamed a bunch of functions inside _sre (way too many leading underscores...) Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.6 retrieving revision 2.7 diff -C2 -r2.6 -r2.7 *** _sre.c 2000/06/29 10:34:56 2.6 --- _sre.c 2000/06/29 11:34:28 2.7 *************** *** 200,204 **** LOCAL(int) ! _stack_free(SRE_STATE* state) { if (state->stack) { --- 200,204 ---- LOCAL(int) ! stack_free(SRE_STATE* state) { if (state->stack) { *************** *** 212,216 **** static int /* shouldn't be LOCAL */ ! _stack_extend(SRE_STATE* state, int lo, int hi) { SRE_STACK* stack; --- 212,216 ---- static int /* shouldn't be LOCAL */ ! stack_extend(SRE_STATE* state, int lo, int hi) { SRE_STACK* stack; *************** *** 243,247 **** if (!stack) { ! _stack_free(state); return SRE_ERROR_MEMORY; } --- 243,247 ---- if (!stack) { ! stack_free(state); return SRE_ERROR_MEMORY; } *************** *** 776,780 **** stack */ if (stack >= state->stacksize) { ! i = _stack_extend(state, stack + 1, stackbase + pattern[2]); if (i < 0) --- 776,780 ---- stack */ if (stack >= state->stacksize) { ! i = stack_extend(state, stack + 1, stackbase + pattern[2]); if (i < 0) *************** *** 1017,1021 **** LOCAL(PyObject*) ! _setup(SRE_STATE* state, PatternObject* pattern, PyObject* args) { /* prepare state object */ --- 1017,1021 ---- LOCAL(PyObject*) ! state_init(SRE_STATE* state, PatternObject* pattern, PyObject* args) { /* prepare state object */ *************** *** 1094,1099 **** } static PyObject* ! _pattern_new_match(PatternObject* pattern, SRE_STATE* state, PyObject* string, int status) { --- 1094,1124 ---- } + LOCAL(void) + state_fini(SRE_STATE* state) + { + stack_free(state); + } + + LOCAL(PyObject*) + state_getslice(SRE_STATE* state, int index, PyObject* string) + { + index = (index - 1) * 2; + + if (string == Py_None || !state->mark[index] || !state->mark[index+1]) { + Py_INCREF(Py_None); + return Py_None; + } + + return PySequence_GetSlice( + string, + ((char*)state->mark[index] - (char*)state->beginning) / + state->charsize, + ((char*)state->mark[index+1] - (char*)state->beginning) / + state->charsize + ); + } + static PyObject* ! pattern_new_match(PatternObject* pattern, SRE_STATE* state, PyObject* string, int status) { *************** *** 1152,1156 **** static PyObject* ! _pattern_cursor(PatternObject* pattern, PyObject* args) { /* create search state object */ --- 1177,1181 ---- static PyObject* ! pattern_cursor(PatternObject* pattern, PyObject* args) { /* create search state object */ *************** *** 1164,1168 **** return NULL; ! string = _setup(&self->state, pattern, args); if (!string) { PyObject_DEL(self); --- 1189,1193 ---- return NULL; ! string = state_init(&self->state, pattern, args); if (!string) { PyObject_DEL(self); *************** *** 1180,1184 **** static void ! _pattern_dealloc(PatternObject* self) { Py_XDECREF(self->code); --- 1205,1209 ---- static void ! pattern_dealloc(PatternObject* self) { Py_XDECREF(self->code); *************** *** 1189,1193 **** static PyObject* ! _pattern_match(PatternObject* self, PyObject* args) { SRE_STATE state; --- 1214,1218 ---- static PyObject* ! pattern_match(PatternObject* self, PyObject* args) { SRE_STATE state; *************** *** 1195,1199 **** int status; ! string = _setup(&state, self, args); if (!string) return NULL; --- 1220,1224 ---- int status; ! string = state_init(&state, self, args); if (!string) return NULL; *************** *** 1209,1219 **** } ! _stack_free(&state); ! return _pattern_new_match(self, &state, string, status); } static PyObject* ! _pattern_search(PatternObject* self, PyObject* args) { SRE_STATE state; --- 1234,1244 ---- } ! state_fini(&state); ! return pattern_new_match(self, &state, string, status); } static PyObject* ! pattern_search(PatternObject* self, PyObject* args) { SRE_STATE state; *************** *** 1221,1225 **** int status; ! string = _setup(&state, self, args); if (!string) return NULL; --- 1246,1250 ---- int status; ! string = state_init(&state, self, args); if (!string) return NULL; *************** *** 1233,1239 **** } ! _stack_free(&state); ! return _pattern_new_match(self, &state, string, status); } --- 1258,1264 ---- } ! state_fini(&state); ! return pattern_new_match(self, &state, string, status); } *************** *** 1264,1268 **** static PyObject* ! _pattern_sub(PatternObject* self, PyObject* args) { PyObject* template; --- 1289,1293 ---- static PyObject* ! pattern_sub(PatternObject* self, PyObject* args) { PyObject* template; *************** *** 1277,1281 **** static PyObject* ! _pattern_subn(PatternObject* self, PyObject* args) { PyObject* template; --- 1302,1306 ---- static PyObject* ! pattern_subn(PatternObject* self, PyObject* args) { PyObject* template; *************** *** 1290,1294 **** static PyObject* ! _pattern_split(PatternObject* self, PyObject* args) { PyObject* string; --- 1315,1319 ---- static PyObject* ! pattern_split(PatternObject* self, PyObject* args) { PyObject* string; *************** *** 1302,1306 **** static PyObject* ! _pattern_findall(PatternObject* self, PyObject* args) { SRE_STATE state; --- 1327,1331 ---- static PyObject* ! pattern_findall(PatternObject* self, PyObject* args) { SRE_STATE state; *************** *** 1308,1313 **** PyObject* list; int status; ! string = _setup(&state, self, args); if (!string) return NULL; --- 1333,1339 ---- PyObject* list; int status; + int i; ! string = state_init(&state, self, args); if (!string) return NULL; *************** *** 1331,1342 **** if (status > 0) { ! item = PySequence_GetSlice( ! string, ! ((char*) state.start - (char*) state.beginning) / state.charsize, ! ((char*) state.ptr - (char*) state.beginning) / state.charsize); ! if (!item) ! goto error; ! if (PyList_Append(list, item) < 0) goto error; if (state.ptr == state.start) --- 1357,1396 ---- if (status > 0) { ! /* don't bother to build a match object */ ! switch (self->groups) { ! case 0: ! item = PySequence_GetSlice( ! string, ! ((char*) state.start - (char*) state.beginning) / ! state.charsize, ! ((char*) state.ptr - (char*) state.beginning) / ! state.charsize); ! if (!item) ! goto error; ! break; ! case 1: ! item = state_getslice(&state, 1, string); ! if (!item) ! goto error; ! break; ! default: ! item = PyTuple_New(self->groups); ! if (!item) ! goto error; ! for (i = 0; i < self->groups; i++) { ! PyObject* o = state_getslice(&state, i+1, string); ! if (!o) { ! Py_DECREF(item); ! goto error; ! } ! PyTuple_SET_ITEM(item, i, o); ! } ! break; ! } ! ! if (PyList_Append(list, item) < 0) { ! Py_DECREF(item); goto error; + } if (state.ptr == state.start) *************** *** 1359,1391 **** } } - - _stack_free(&state); return list; error: ! _stack_free(&state); return NULL; } ! static PyMethodDef _pattern_methods[] = { ! {"match", (PyCFunction) _pattern_match, 1}, ! {"search", (PyCFunction) _pattern_search, 1}, ! {"sub", (PyCFunction) _pattern_sub, 1}, ! {"subn", (PyCFunction) _pattern_subn, 1}, ! {"split", (PyCFunction) _pattern_split, 1}, ! {"findall", (PyCFunction) _pattern_findall, 1}, /* experimental */ ! {"cursor", (PyCFunction) _pattern_cursor, 1}, {NULL, NULL} }; static PyObject* ! _pattern_getattr(PatternObject* self, char* name) { PyObject* res; ! res = Py_FindMethod(_pattern_methods, (PyObject*) self, name); if (res) --- 1413,1445 ---- } } + state_fini(&state); return list; error: ! Py_DECREF(list); ! state_fini(&state); return NULL; } ! static PyMethodDef pattern_methods[] = { ! {"match", (PyCFunction) pattern_match, 1}, ! {"search", (PyCFunction) pattern_search, 1}, ! {"sub", (PyCFunction) pattern_sub, 1}, ! {"subn", (PyCFunction) pattern_subn, 1}, ! {"split", (PyCFunction) pattern_split, 1}, ! {"findall", (PyCFunction) pattern_findall, 1}, /* experimental */ ! {"cursor", (PyCFunction) pattern_cursor, 1}, {NULL, NULL} }; static PyObject* ! pattern_getattr(PatternObject* self, char* name) { PyObject* res; ! res = Py_FindMethod(pattern_methods, (PyObject*) self, name); if (res) *************** *** 1415,1421 **** PyObject_HEAD_INIT(NULL) 0, "Pattern", sizeof(PatternObject), 0, ! (destructor)_pattern_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ ! (getattrfunc)_pattern_getattr, /*tp_getattr*/ }; --- 1469,1475 ---- PyObject_HEAD_INIT(NULL) 0, "Pattern", sizeof(PatternObject), 0, ! (destructor)pattern_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ ! (getattrfunc)pattern_getattr, /*tp_getattr*/ }; *************** *** 1424,1428 **** static void ! _match_dealloc(MatchObject* self) { Py_XDECREF(self->string); --- 1478,1482 ---- static void ! match_dealloc(MatchObject* self) { Py_XDECREF(self->string); *************** *** 1432,1436 **** static PyObject* ! getslice_by_index(MatchObject* self, int index) { if (index < 0 || index >= self->groups) { --- 1486,1490 ---- static PyObject* ! match_getslice_by_index(MatchObject* self, int index) { if (index < 0 || index >= self->groups) { *************** *** 1455,1459 **** static int ! getindex(MatchObject* self, PyObject* index) { if (!PyInt_Check(index) && self->pattern->groupindex != NULL) { --- 1509,1513 ---- static int ! match_getindex(MatchObject* self, PyObject* index) { if (!PyInt_Check(index) && self->pattern->groupindex != NULL) { *************** *** 1471,1481 **** static PyObject* ! getslice(MatchObject* self, PyObject* index) { ! return getslice_by_index(self, getindex(self, index)); } static PyObject* ! _match_group(MatchObject* self, PyObject* args) { PyObject* result; --- 1525,1535 ---- static PyObject* ! match_getslice(MatchObject* self, PyObject* index) { ! return match_getslice_by_index(self, match_getindex(self, index)); } static PyObject* ! match_group(MatchObject* self, PyObject* args) { PyObject* result; *************** *** 1486,1493 **** switch (size) { case 0: ! result = getslice(self, Py_False); /* force error */ break; case 1: ! result = getslice(self, PyTuple_GET_ITEM(args, 0)); break; default: --- 1540,1547 ---- switch (size) { case 0: ! result = match_getslice(self, Py_False); break; case 1: ! result = match_getslice(self, PyTuple_GET_ITEM(args, 0)); break; default: *************** *** 1497,1501 **** return NULL; for (i = 0; i < size; i++) { ! PyObject* item = getslice(self, PyTuple_GET_ITEM(args, i)); if (!item) { Py_DECREF(result); --- 1551,1555 ---- return NULL; for (i = 0; i < size; i++) { ! PyObject* item = match_getslice(self, PyTuple_GET_ITEM(args, i)); if (!item) { Py_DECREF(result); *************** *** 1510,1514 **** static PyObject* ! _match_groups(MatchObject* self, PyObject* args) { PyObject* result; --- 1564,1568 ---- static PyObject* ! match_groups(MatchObject* self, PyObject* args) { PyObject* result; *************** *** 1524,1528 **** PyObject* item; /* FIXME: handle default! */ ! item = getslice_by_index(self, index); if (!item) { Py_DECREF(result); --- 1578,1582 ---- PyObject* item; /* FIXME: handle default! */ ! item = match_getslice_by_index(self, index); if (!item) { Py_DECREF(result); *************** *** 1536,1540 **** static PyObject* ! _match_groupdict(MatchObject* self, PyObject* args) { PyObject* result; --- 1590,1594 ---- static PyObject* ! match_groupdict(MatchObject* self, PyObject* args) { PyObject* result; *************** *** 1563,1567 **** return NULL; } ! item = getslice(self, key); if (!item) { Py_DECREF(key); --- 1617,1621 ---- return NULL; } ! item = match_getslice(self, key); if (!item) { Py_DECREF(key); *************** *** 1580,1584 **** static PyObject* ! _match_start(MatchObject* self, PyObject* args) { int index; --- 1634,1638 ---- static PyObject* ! match_start(MatchObject* self, PyObject* args) { int index; *************** *** 1588,1592 **** return NULL; ! index = getindex(self, index_); if (index < 0 || index >= self->groups) { --- 1642,1646 ---- return NULL; ! index = match_getindex(self, index_); if (index < 0 || index >= self->groups) { *************** *** 1607,1611 **** static PyObject* ! _match_end(MatchObject* self, PyObject* args) { int index; --- 1661,1665 ---- static PyObject* ! match_end(MatchObject* self, PyObject* args) { int index; *************** *** 1615,1619 **** return NULL; ! index = getindex(self, index_); if (index < 0 || index >= self->groups) { --- 1669,1673 ---- return NULL; ! index = match_getindex(self, index_); if (index < 0 || index >= self->groups) { *************** *** 1634,1638 **** static PyObject* ! _match_span(MatchObject* self, PyObject* args) { int index; --- 1688,1692 ---- static PyObject* ! match_span(MatchObject* self, PyObject* args) { int index; *************** *** 1642,1646 **** return NULL; ! index = getindex(self, index_); if (index < 0 || index >= self->groups) { --- 1696,1700 ---- return NULL; ! index = match_getindex(self, index_); if (index < 0 || index >= self->groups) { *************** *** 1661,1680 **** } ! static PyMethodDef _match_methods[] = { ! {"group", (PyCFunction) _match_group, 1}, ! {"start", (PyCFunction) _match_start, 1}, ! {"end", (PyCFunction) _match_end, 1}, ! {"span", (PyCFunction) _match_span, 1}, ! {"groups", (PyCFunction) _match_groups, 1}, ! {"groupdict", (PyCFunction) _match_groupdict, 1}, {NULL, NULL} }; static PyObject* ! _match_getattr(MatchObject* self, char* name) { PyObject* res; ! res = Py_FindMethod(_match_methods, (PyObject*) self, name); if (res) return res; --- 1715,1734 ---- } ! static PyMethodDef match_methods[] = { ! {"group", (PyCFunction) match_group, 1}, ! {"start", (PyCFunction) match_start, 1}, ! {"end", (PyCFunction) match_end, 1}, ! {"span", (PyCFunction) match_span, 1}, ! {"groups", (PyCFunction) match_groups, 1}, ! {"groupdict", (PyCFunction) match_groupdict, 1}, {NULL, NULL} }; static PyObject* ! match_getattr(MatchObject* self, char* name) { PyObject* res; ! res = Py_FindMethod(match_methods, (PyObject*) self, name); if (res) return res; *************** *** 1711,1717 **** sizeof(MatchObject), /* size of basic object */ sizeof(int), /* space for group item */ ! (destructor)_match_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ ! (getattrfunc)_match_getattr, /*tp_getattr*/ }; --- 1765,1771 ---- sizeof(MatchObject), /* size of basic object */ sizeof(int), /* space for group item */ ! (destructor)match_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ ! (getattrfunc)match_getattr, /*tp_getattr*/ }; *************** *** 1720,1726 **** static void ! _cursor_dealloc(CursorObject* self) { ! _stack_free(&self->state); Py_DECREF(self->string); Py_DECREF(self->pattern); --- 1774,1780 ---- static void ! cursor_dealloc(CursorObject* self) { ! state_fini(&self->state); Py_DECREF(self->string); Py_DECREF(self->pattern); *************** *** 1729,1733 **** static PyObject* ! _cursor_match(CursorObject* self, PyObject* args) { SRE_STATE* state = &self->state; --- 1783,1787 ---- static PyObject* ! cursor_match(CursorObject* self, PyObject* args) { SRE_STATE* state = &self->state; *************** *** 1745,1749 **** } ! match = _pattern_new_match((PatternObject*) self->pattern, state, self->string, status); --- 1799,1803 ---- } ! match = pattern_new_match((PatternObject*) self->pattern, state, self->string, status); *************** *** 1758,1762 **** static PyObject* ! _cursor_search(CursorObject* self, PyObject* args) { SRE_STATE* state = &self->state; --- 1812,1816 ---- static PyObject* ! cursor_search(CursorObject* self, PyObject* args) { SRE_STATE* state = &self->state; *************** *** 1774,1778 **** } ! match = _pattern_new_match((PatternObject*) self->pattern, state, self->string, status); --- 1828,1832 ---- } ! match = pattern_new_match((PatternObject*) self->pattern, state, self->string, status); *************** *** 1783,1798 **** } ! static PyMethodDef _cursor_methods[] = { ! {"match", (PyCFunction) _cursor_match, 0}, ! {"search", (PyCFunction) _cursor_search, 0}, {NULL, NULL} }; static PyObject* ! _cursor_getattr(CursorObject* self, char* name) { PyObject* res; ! res = Py_FindMethod(_cursor_methods, (PyObject*) self, name); if (res) return res; --- 1837,1852 ---- } ! static PyMethodDef cursor_methods[] = { ! {"match", (PyCFunction) cursor_match, 0}, ! {"search", (PyCFunction) cursor_search, 0}, {NULL, NULL} }; static PyObject* ! cursor_getattr(CursorObject* self, char* name) { PyObject* res; ! res = Py_FindMethod(cursor_methods, (PyObject*) self, name); if (res) return res; *************** *** 1815,1821 **** sizeof(CursorObject), /* size of basic object */ 0, ! (destructor)_cursor_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ ! (getattrfunc)_cursor_getattr, /*tp_getattr*/ }; --- 1869,1875 ---- sizeof(CursorObject), /* size of basic object */ 0, ! (destructor)cursor_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ ! (getattrfunc)cursor_getattr, /*tp_getattr*/ }; Index: sre.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/sre.h,v retrieving revision 2.5 retrieving revision 2.6 diff -C2 -r2.5 -r2.6 From python-dev@python.org Thu Jun 29 13:22:12 2000 From: python-dev@python.org (Gordon McMillan) Date: Thu, 29 Jun 2000 08:22:12 -0400 Subject: [Python-Dev] Re: [Python-checkins] CVS: python/dist/src/Doc TODO,1.26,1.27 In-Reply-To: References: <200006282213.PAA13365@slayer.i.sourceforge.net> Message-ID: <1249841091-43777448@hypernet.com> Moshe wrote: > On Wed, 28 Jun 2000, Fred L. Drake wrote: > > > + * Update the filecmp documentation (Moshe?). > > I'm waiting for Gordon to check-in his directory comparisons to > filecmp. Gordon? Looking at CVS, my stuff was there in filecmp revision 1.2 (+299 -38) and wiped out by 1.3 (+38 -299) which was done the following day. - Gordon From python-dev@python.org Thu Jun 29 13:38:48 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 05:38:48 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre.py,1.9,1.10 sre_compile.py,1.7,1.8 sre_constants.py,1.7,1.8 sre_parse.py,1.7,1.8 Message-ID: <200006291238.FAA01061@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv899/Lib Modified Files: sre.py sre_compile.py sre_constants.py sre_parse.py Log Message: - make sure group names are valid identifiers (closes the "SRE: symbolic reference" bug) Index: sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 Index: sre_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 Index: sre_constants.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_constants.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** sre_parse.py 2000/06/29 11:34:27 1.7 --- sre_parse.py 2000/06/29 12:38:45 1.8 *************** *** 169,172 **** --- 169,190 ---- return this + def isident(char): + return "a" <= char <= "z" or "A" <= char <= "Z" or char == "_" + + def isdigit(char): + return "0" <= char <= "9" + + def isname(name): + # check that group name is a valid string + # FIXME: this code is really lame. should use a regular + # expression instead, but I seem to have certain bootstrapping + # problems here ;-) + if not isident(name[0]): + return 0 + for char in name: + if not isident(char) and not isdigit(char): + return 0 + return 1 + def _group(escape, state): # check if the escape string represents a valid group *************** *** 419,425 **** if char == ">": break - # FIXME: check for valid character name = name + char group = 1 elif source.match("="): # named backreference --- 437,444 ---- if char == ">": break name = name + char group = 1 + if not isname(name): + raise error, "illegal character in group name" elif source.match("="): # named backreference *************** *** 523,540 **** char = s.get() if char is None: ! raise error, "unterminated index" if char == ">": break - # FIXME: check for valid character name = name + char if not name: ! raise error, "bad index" try: index = int(name) except ValueError: try: index = pattern.groupindex[name] except KeyError: ! raise IndexError, "unknown index" a((MARK, index)) elif len(this) > 1 and this[1] in DIGITS: --- 542,560 ---- char = s.get() if char is None: ! raise error, "unterminated group name" if char == ">": break name = name + char if not name: ! raise error, "bad group name" try: index = int(name) except ValueError: + if not isname(name): + raise error, "illegal character in group name" try: index = pattern.groupindex[name] except KeyError: ! raise IndexError, "unknown group name" a((MARK, index)) elif len(this) > 1 and this[1] in DIGITS: From python-dev@python.org Thu Jun 29 13:38:48 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 05:38:48 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.7,2.8 sre.h,2.6,2.7 Message-ID: <200006291238.FAA01060@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv899/Modules Modified Files: _sre.c sre.h Log Message: - make sure group names are valid identifiers (closes the "SRE: symbolic reference" bug) Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.7 retrieving revision 2.8 diff -C2 -r2.7 -r2.8 Index: sre.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/sre.h,v retrieving revision 2.6 retrieving revision 2.7 diff -C2 -r2.6 -r2.7 From python-dev@python.org Thu Jun 29 13:45:52 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 29 Jun 2000 05:45:52 -0700 Subject: [Python-checkins] CVS: python/dist/src/Misc ACKS,1.57,1.58 Message-ID: <200006291245.FAA01387@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Misc In directory slayer.i.sourceforge.net:/tmp/cvs-serv1378/Misc Modified Files: ACKS Log Message: Typo fix. Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -r1.57 -r1.58 *** ACKS 2000/06/29 00:04:51 1.57 --- ACKS 2000/06/29 12:45:50 1.58 *************** *** 116,120 **** Fred Gansevles Lars Marius Garshol ! Hary Henry Gebel Thomas Gellekum Ben Gertzfield --- 116,120 ---- Fred Gansevles Lars Marius Garshol ! Harry Henry Gebel Thomas Gellekum Ben Gertzfield From python-dev@python.org Thu Jun 29 13:48:40 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 05:48:40 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.8,2.9 sre.h,2.7,2.8 Message-ID: <200006291248.FAA01606@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv1507/Modules Modified Files: _sre.c sre.h Log Message: - renamed "tolower" hook (it happened to work with my compiler, but not on guido's box...) Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.8 retrieving revision 2.9 diff -C2 -r2.8 -r2.9 *** _sre.c 2000/06/29 12:38:45 2.8 --- _sre.c 2000/06/29 12:48:37 2.9 *************** *** 95,99 **** 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 0, 0, 0, 0, 0 }; ! static char sre_char_tolower[128] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, --- 95,99 ---- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 0, 0, 0, 0, 0 }; ! static char sre_char_lower[128] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, *************** *** 105,111 **** 120, 121, 122, 123, 124, 125, 126, 127 }; ! static unsigned int sre_tolower(unsigned int ch) { ! return ((ch) < 128 ? sre_char_tolower[ch] : ch); } --- 105,111 ---- 120, 121, 122, 123, 124, 125, 126, 127 }; ! static unsigned int sre_lower(unsigned int ch) { ! return ((ch) < 128 ? sre_char_lower[ch] : ch); } *************** *** 123,127 **** /* locale-specific character predicates */ ! static unsigned int sre_tolower_locale(unsigned int ch) { return ((ch) < 256 ? tolower((ch)) : ch); --- 123,127 ---- /* locale-specific character predicates */ ! static unsigned int sre_lower_locale(unsigned int ch) { return ((ch) < 256 ? tolower((ch)) : ch); *************** *** 136,140 **** #if defined(HAVE_UNICODE) ! static unsigned int sre_tolower_unicode(unsigned int ch) { return (unsigned int) Py_UNICODE_TOLOWER((Py_UNICODE)(ch)); --- 136,140 ---- #if defined(HAVE_UNICODE) ! static unsigned int sre_lower_unicode(unsigned int ch) { return (unsigned int) Py_UNICODE_TOLOWER((Py_UNICODE)(ch)); *************** *** 498,502 **** while (p < e) { if (ptr >= end || ! state->tolower(*ptr) != state->tolower(*p)) goto failure; p++; ptr++; --- 498,502 ---- while (p < e) { if (ptr >= end || ! state->lower(*ptr) != state->lower(*p)) goto failure; p++; ptr++; *************** *** 509,513 **** TRACE(("%8d: literal lower(%c)\n", PTR(ptr), (SRE_CHAR) *pattern)); if (ptr >= end || ! state->tolower(*ptr) != state->tolower(*pattern)) goto failure; pattern++; --- 509,513 ---- TRACE(("%8d: literal lower(%c)\n", PTR(ptr), (SRE_CHAR) *pattern)); if (ptr >= end || ! state->lower(*ptr) != state->lower(*pattern)) goto failure; pattern++; *************** *** 519,523 **** (SRE_CHAR) *pattern)); if (ptr >= end || ! state->tolower(*ptr) == state->tolower(*pattern)) goto failure; pattern++; --- 519,523 ---- (SRE_CHAR) *pattern)); if (ptr >= end || ! state->lower(*ptr) == state->lower(*pattern)) goto failure; pattern++; *************** *** 528,532 **** TRACE(("%8d: set lower(%c)\n", PTR(ptr), *ptr)); if (ptr >= end ! || !SRE_MEMBER(pattern+1, (SRE_CHAR) state->tolower(*ptr))) goto failure; pattern += pattern[0]; --- 528,532 ---- TRACE(("%8d: set lower(%c)\n", PTR(ptr), *ptr)); if (ptr >= end ! || !SRE_MEMBER(pattern+1, (SRE_CHAR) state->lower(*ptr))) goto failure; pattern += pattern[0]; *************** *** 612,616 **** SRE_CHAR chr = (SRE_CHAR) pattern[4]; while (count < (int) pattern[2]) { ! if (ptr >= end || (SRE_CHAR) state->tolower(*ptr) != chr) break; ptr++; --- 612,616 ---- SRE_CHAR chr = (SRE_CHAR) pattern[4]; while (count < (int) pattern[2]) { ! if (ptr >= end || (SRE_CHAR) state->lower(*ptr) != chr) break; ptr++; *************** *** 632,636 **** SRE_CHAR chr = (SRE_CHAR) pattern[4]; while (count < (int) pattern[2]) { ! if (ptr >= end || (SRE_CHAR) state->tolower(*ptr) == chr) break; ptr++; --- 632,636 ---- SRE_CHAR chr = (SRE_CHAR) pattern[4]; while (count < (int) pattern[2]) { ! if (ptr >= end || (SRE_CHAR) state->lower(*ptr) == chr) break; ptr++; *************** *** 1002,1006 **** static PyObject * ! sre_lower(PyObject* self, PyObject* args) { int character, flags; --- 1002,1006 ---- static PyObject * ! sre_getlower(PyObject* self, PyObject* args) { int character, flags; *************** *** 1008,1017 **** return NULL; if (flags & SRE_FLAG_LOCALE) ! return Py_BuildValue("i", sre_tolower_locale(character)); #if defined(HAVE_UNICODE) if (flags & SRE_FLAG_UNICODE) ! return Py_BuildValue("i", sre_tolower_unicode(character)); #endif ! return Py_BuildValue("i", sre_tolower(character)); } --- 1008,1017 ---- return NULL; if (flags & SRE_FLAG_LOCALE) ! return Py_BuildValue("i", sre_lower_locale(character)); #if defined(HAVE_UNICODE) if (flags & SRE_FLAG_UNICODE) ! return Py_BuildValue("i", sre_lower_unicode(character)); #endif ! return Py_BuildValue("i", sre_lower(character)); } *************** *** 1083,1093 **** if (pattern->flags & SRE_FLAG_LOCALE) ! state->tolower = sre_tolower_locale; #if defined(HAVE_UNICODE) else if (pattern->flags & SRE_FLAG_UNICODE) ! state->tolower = sre_tolower_unicode; #endif else ! state->tolower = sre_tolower; return string; --- 1083,1093 ---- if (pattern->flags & SRE_FLAG_LOCALE) ! state->lower = sre_lower_locale; #if defined(HAVE_UNICODE) else if (pattern->flags & SRE_FLAG_UNICODE) ! state->lower = sre_lower_unicode; #endif else ! state->lower = sre_lower; return string; *************** *** 1877,1881 **** {"compile", _compile, 1}, {"getcodesize", sre_codesize, 1}, ! {"getlower", sre_lower, 1}, {NULL, NULL} }; --- 1877,1881 ---- {"compile", _compile, 1}, {"getcodesize", sre_codesize, 1}, ! {"getlower", sre_getlower, 1}, {NULL, NULL} }; Index: sre.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/sre.h,v retrieving revision 2.7 retrieving revision 2.8 diff -C2 -r2.7 -r2.8 *** sre.h 2000/06/29 12:38:45 2.7 --- sre.h 2000/06/29 12:48:37 2.8 *************** *** 63,67 **** int stackbase; /* hooks */ ! SRE_TOLOWER_HOOK tolower; } SRE_STATE; --- 63,67 ---- int stackbase; /* hooks */ ! SRE_TOLOWER_HOOK lower; } SRE_STATE; From python-dev@python.org Thu Jun 29 13:48:40 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 05:48:40 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre.py,1.10,1.11 sre_compile.py,1.8,1.9 sre_constants.py,1.8,1.9 sre_parse.py,1.8,1.9 Message-ID: <200006291248.FAA01607@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv1507/Lib Modified Files: sre.py sre_compile.py sre_constants.py sre_parse.py Log Message: - renamed "tolower" hook (it happened to work with my compiler, but not on guido's box...) Index: sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 Index: sre_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 Index: sre_constants.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_constants.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 From python-dev@python.org Thu Jun 29 14:31:13 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Thu, 29 Jun 2000 06:31:13 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_ucn,NONE,1.1 Message-ID: <200006291331.GAA09886@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv9879/Lib/test/output Added Files: test_ucn Log Message: Marc-Andre Lemburg : New test output --- NEW FILE --- test_ucn Testing General Unicode Character Name, and case insensitivity... done. Testing misc. symbols for unicode character name expansion.... done. Testing unicode character name expansion strict error handling.... done. From python-dev@python.org Thu Jun 29 15:13:31 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 29 Jun 2000 07:13:31 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib filecmp.py,1.4,1.5 Message-ID: <200006291413.HAA18493@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv18485 Modified Files: filecmp.py Log Message: Whoops! We just discovered that Gordon's revamp of this module was accidentally wiped out by Ping's patch (which shouldn't have affected this file at all, had Ping done a cvs update). This checkin restores Gordon's version, with Fredrik's change merged back in. Index: filecmp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/filecmp.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** filecmp.py 2000/03/28 21:42:38 1.4 --- filecmp.py 2000/06/29 14:13:28 1.5 *************** *** 1,68 **** ! """Compare files.""" ! import os, stat, statcache _cache = {} BUFSIZE=8*1024 ! def cmp(f1, f2, shallow=1,use_statcache=0): ! """Compare two files. ! Arguments: ! f1 -- First file name ! f2 -- Second file name ! shallow -- Just check stat signature (do not read the files). ! defaults to 1. ! ! use_statcache -- Do not stat() each file directly: go through ! the statcache module for more efficiency. ! ! Return value: ! ! integer -- 1 if the files are the same, 0 otherwise. ! ! This function uses a cache for past comparisons and the results, ! with a cache invalidation mechanism relying on stale signatures. ! Of course, if 'use_statcache' is true, this mechanism is defeated, ! and the cache will never grow stale. ! ! """ ! if use_statcache: ! stat_function = statcache.stat ! else: ! stat_function = os.stat ! s1 = _sig(stat_function(f1)) ! s2 = _sig(stat_function(f2)) ! if s1[0] != stat.S_IFREG or s2[0] != stat.S_IFREG: ! return 0 ! if shallow and s1 == s2: ! return 1 ! if s1[1] != s2[1]: ! return 0 ! ! result = _cache.get((f1, f2)) ! if result and (s1, s2) == result[:2]: ! return result[2] ! outcome = _do_cmp(f1, f2) ! _cache[f1, f2] = s1, s2, outcome ! return outcome def _sig(st): ! return (stat.S_IFMT(st[stat.ST_MODE]), ! st[stat.ST_SIZE], ! st[stat.ST_MTIME]) def _do_cmp(f1, f2): ! bufsize = BUFSIZE ! fp1 = open(f1, 'rb') ! fp2 = open(f2, 'rb') ! while 1: ! b1 = fp1.read(bufsize) ! b2 = fp2.read(bufsize) ! if b1 != b2: ! return 0 ! if not b1: ! return 1 --- 1,329 ---- ! """Utilities for comparing files and directories. ! Classes: ! dircmp + Functions: + cmp(f1, f2, shallow=1, use_statcache=0) -> int + cmpfiles(a, b, common) -> ([], [], []) + + """ + + import os + import stat + import statcache + _cache = {} BUFSIZE=8*1024 ! def cmp(f1, f2, shallow=1,use_statcache=0): ! """Compare two files. ! Arguments: ! f1 -- First file name ! f2 -- Second file name ! shallow -- Just check stat signature (do not read the files). ! defaults to 1. ! ! use_statcache -- Do not stat() each file directly: go through ! the statcache module for more efficiency. ! ! Return value: ! ! integer -- 1 if the files are the same, 0 otherwise. ! ! This function uses a cache for past comparisons and the results, ! with a cache invalidation mechanism relying on stale signatures. ! Of course, if 'use_statcache' is true, this mechanism is defeated, ! and the cache will never grow stale. ! ! """ ! if use_statcache: ! stat_function = statcache.stat ! else: ! stat_function = os.stat ! s1 = _sig(stat_function(f1)) ! s2 = _sig(stat_function(f2)) ! if s1[0] != stat.S_IFREG or s2[0] != stat.S_IFREG: ! return 0 ! if shallow and s1 == s2: ! return 1 ! if s1[1] != s2[1]: ! return 0 ! ! result = _cache.get((f1, f2)) ! if result and (s1, s2) == result[:2]: ! return result[2] ! outcome = _do_cmp(f1, f2) ! _cache[f1, f2] = s1, s2, outcome ! return outcome def _sig(st): ! return (stat.S_IFMT(st[stat.ST_MODE]), ! st[stat.ST_SIZE], ! st[stat.ST_MTIME]) def _do_cmp(f1, f2): ! bufsize = BUFSIZE ! fp1 = open(f1, 'rb') ! fp2 = open(f2, 'rb') ! while 1: ! b1 = fp1.read(bufsize) ! b2 = fp2.read(bufsize) ! if b1 != b2: ! return 0 ! if not b1: ! return 1 ! ! # Directory comparison class. ! # ! class dircmp: ! """A class that manages the comparison of 2 directories. ! ! dircmp(a,b,ignore=None,hide=None) ! A and B are directories. ! IGNORE is a list of names to ignore, ! defaults to ['RCS', 'CVS', 'tags']. ! HIDE is a list of names to hide, ! defaults to [os.curdir, os.pardir]. ! ! High level usage: ! x = dircmp(dir1, dir2) ! x.report() -> prints a report on the differences between dir1 and dir2 ! or ! x.report_partial_closure() -> prints report on differences between dir1 ! and dir2, and reports on common immediate subdirectories. ! x.report_full_closure() -> like report_partial_closure, ! but fully recursive. ! ! Attributes: ! left_list, right_list: The files in dir1 and dir2, ! filtered by hide and ignore. ! common: a list of names in both dir1 and dir2. ! left_only, right_only: names only in dir1, dir2. ! common_dirs: subdirectories in both dir1 and dir2. ! common_files: files in both dir1 and dir2. ! common_funny: names in both dir1 and dir2 where the type differs between ! dir1 and dir2, or the name is not stat-able. ! same_files: list of identical files. ! diff_files: list of filenames which differ. ! funny_files: list of files which could not be compared. ! subdirs: a dictionary of dircmp objects, keyed by names in common_dirs. ! """ ! ! def __init__(self, a, b, ignore=None, hide=None): # Initialize ! self.left = a ! self.right = b ! if hide is None: ! self.hide = [os.curdir, os.pardir] # Names never to be shown ! else: ! self.hide = hide ! if ignore is None: ! self.ignore = ['RCS', 'CVS', 'tags'] # Names ignored in comparison ! else: ! self.ignore = ignore ! ! def phase0(self): # Compare everything except common subdirectories ! self.left_list = _filter(os.listdir(self.left), ! self.hide+self.ignore) ! self.right_list = _filter(os.listdir(self.right), ! self.hide+self.ignore) ! self.left_list.sort() ! self.right_list.sort() ! ! __p4_attrs = ('subdirs',) ! __p3_attrs = ('same_files', 'diff_files', 'funny_files') ! __p2_attrs = ('common_dirs', 'common_files', 'common_funny') ! __p1_attrs = ('common', 'left_only', 'right_only') ! __p0_attrs = ('left_list', 'right_list') ! ! def __getattr__(self, attr): ! if attr in self.__p4_attrs: ! self.phase4() ! elif attr in self.__p3_attrs: ! self.phase3() ! elif attr in self.__p2_attrs: ! self.phase2() ! elif attr in self.__p1_attrs: ! self.phase1() ! elif attr in self.__p0_attrs: ! self.phase0() ! else: ! raise AttributeError, attr ! return getattr(self, attr) ! ! def phase1(self): # Compute common names ! a_only, b_only = [], [] ! common = {} ! b = {} ! for fnm in self.right_list: ! b[fnm] = 1 ! for x in self.left_list: ! if b.get(x, 0): ! common[x] = 1 ! else: ! a_only.append(x) ! for x in self.right_list: ! if common.get(x, 0): ! pass ! else: ! b_only.append(x) ! self.common = common.keys() ! self.left_only = a_only ! self.right_only = b_only ! ! def phase2(self): # Distinguish files, directories, funnies ! self.common_dirs = [] ! self.common_files = [] ! self.common_funny = [] ! ! for x in self.common: ! a_path = os.path.join(self.left, x) ! b_path = os.path.join(self.right, x) ! ! ok = 1 ! try: ! a_stat = statcache.stat(a_path) ! except os.error, why: ! # print 'Can\'t stat', a_path, ':', why[1] ! ok = 0 ! try: ! b_stat = statcache.stat(b_path) ! except os.error, why: ! # print 'Can\'t stat', b_path, ':', why[1] ! ok = 0 ! ! if ok: ! a_type = stat.S_IFMT(a_stat[stat.ST_MODE]) ! b_type = stat.S_IFMT(b_stat[stat.ST_MODE]) ! if a_type <> b_type: ! self.common_funny.append(x) ! elif stat.S_ISDIR(a_type): ! self.common_dirs.append(x) ! elif stat.S_ISREG(a_type): ! self.common_files.append(x) ! else: ! self.common_funny.append(x) ! else: ! self.common_funny.append(x) ! ! def phase3(self): # Find out differences between common files ! xx = cmpfiles(self.left, self.right, self.common_files) ! self.same_files, self.diff_files, self.funny_files = xx ! ! def phase4(self): # Find out differences between common subdirectories ! # A new dircmp object is created for each common subdirectory, ! # these are stored in a dictionary indexed by filename. ! # The hide and ignore properties are inherited from the parent ! self.subdirs = {} ! for x in self.common_dirs: ! a_x = os.path.join(self.left, x) ! b_x = os.path.join(self.right, x) ! self.subdirs[x] = dircmp(a_x, b_x, self.ignore, self.hide) ! ! def phase4_closure(self): # Recursively call phase4() on subdirectories ! self.phase4() ! for x in self.subdirs.keys(): ! self.subdirs[x].phase4_closure() ! ! def report(self): # Print a report on the differences between a and b ! # Output format is purposely lousy ! print 'diff', self.left, self.right ! if self.left_only: ! self.left_only.sort() ! print 'Only in', self.left, ':', self.left_only ! if self.right_only: ! self.right_only.sort() ! print 'Only in', self.right, ':', self.right_only ! if self.same_files: ! self.same_files.sort() ! print 'Identical files :', self.same_files ! if self.diff_files: ! self.diff_files.sort() ! print 'Differing files :', self.diff_files ! if self.funny_files: ! self.funny_files.sort() ! print 'Trouble with common files :', self.funny_files ! if self.common_dirs: ! self.common_dirs.sort() ! print 'Common subdirectories :', self.common_dirs ! if self.common_funny: ! self.common_funny.sort() ! print 'Common funny cases :', self.common_funny ! ! def report_partial_closure(self): # Print reports on self and on subdirs ! self.report() ! for x in self.subdirs.keys(): ! print ! self.subdirs[x].report() ! ! def report_full_closure(self): # Report on self and subdirs recursively ! self.report() ! for x in self.subdirs.keys(): ! print ! self.subdirs[x].report_full_closure() ! ! ! # Compare common files in two directories. ! # Return: ! # - files that compare equal ! # - files that compare different ! # - funny cases (can't stat etc.) ! # ! def cmpfiles(a, b, common): ! """Compare common files in two directories. ! ! cmpfiles(a,b,common) ! A and B are directory names ! COMMON is a list of file names ! returns a tuple of three lists: ! files that compare equal ! files that are different ! filenames that aren't regular files.""" ! ! res = ([], [], []) ! for x in common: ! res[_cmp(os.path.join(a, x), os.path.join(b, x))].append(x) ! return res ! ! ! # Compare two files. ! # Return: ! # 0 for equal ! # 1 for different ! # 2 for funny cases (can't stat, etc.) ! # ! def _cmp(a, b): ! try: ! return not abs(cmp(a, b)) ! except os.error: ! return 2 ! ! ! # Return a copy with items that occur in skip removed. ! # ! def _filter(list, skip): ! result = [] ! for item in list: ! if item not in skip: result.append(item) ! return result ! ! ! # Demonstration and testing. ! # ! def demo(): ! import sys ! import getopt ! options, args = getopt.getopt(sys.argv[1:], 'r') ! if len(args) <> 2: raise getopt.error, 'need exactly two args' ! dd = dircmp(args[0], args[1]) ! if ('-r', '') in options: ! dd.report_full_closure() ! else: ! dd.report() ! ! if __name__ == '__main__': ! demo() From python-dev@python.org Thu Jun 29 15:40:47 2000 From: python-dev@python.org (Jeremy Hylton) Date: Thu, 29 Jun 2000 07:40:47 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules Setup.in,1.104,1.105 Message-ID: <200006291440.HAA20818@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv20793/Modules Modified Files: Setup.in Log Message: pyexpat notes: add the name of the archive to the ar command Index: Setup.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Setup.in,v retrieving revision 1.104 retrieving revision 1.105 diff -C2 -r1.104 -r1.105 *** Setup.in 2000/06/29 05:29:08 1.104 --- Setup.in 2000/06/29 14:40:45 1.105 *************** *** 424,428 **** # cd to EXPAT_DIR, run "make" if you have not done so, then run: # ! # ar cr xmltok/*.o xmlparse/*.o # #EXPAT_DIR=/usr/local/src/expat --- 424,428 ---- # cd to EXPAT_DIR, run "make" if you have not done so, then run: # ! # ar cr libexpat.a xmltok/*.o xmlparse/*.o # #EXPAT_DIR=/usr/local/src/expat From python-dev@python.org Thu Jun 29 15:50:18 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 29 Jun 2000 07:50:18 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python codecs.c,2.7,2.8 Message-ID: <200006291450.HAA21359@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv21351 Modified Files: codecs.c Log Message: Change the loop index in normalizestring() to size_t too, to avoid a warning on Windows. Index: codecs.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/codecs.c,v retrieving revision 2.7 retrieving revision 2.8 diff -C2 -r2.7 -r2.8 *** codecs.c 2000/06/28 22:07:35 2.7 --- codecs.c 2000/06/29 14:50:15 2.8 *************** *** 83,87 **** PyObject *normalizestring(const char *string) { ! register int i; size_t len = strlen(string); char *p; --- 83,87 ---- PyObject *normalizestring(const char *string) { ! register size_t i; size_t len = strlen(string); char *p; From python-dev@python.org Thu Jun 29 17:08:31 2000 From: python-dev@python.org (Barry Warsaw) Date: Thu, 29 Jun 2000 09:08:31 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules Setup.thread.in,2.1,2.2 Message-ID: <200006291608.JAA01388@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv1379 Modified Files: Setup.thread.in Log Message: Updated the comment in this file to reflect the new defaults. Threads are enabled by default now unless --without-threads is given to configure. Index: Setup.thread.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Setup.thread.in,v retrieving revision 2.1 retrieving revision 2.2 diff -C2 -r2.1 -r2.2 *** Setup.thread.in 1997/12/04 00:48:27 2.1 --- Setup.thread.in 2000/06/29 16:08:28 2.2 *************** *** 1,10 **** # This file is transmogrified into Setup.thread by config.status. ! # Its purpose is to automatically enable the thread module when the ! # --with-thread argument is given to the configure script. # *NOTE*: if the configure script decides it can't support threads, # the thread module will still be enabled and cause compile errors. ! # The solution is not to use --with-thread on platforms that don't # support threads. --- 1,11 ---- # This file is transmogrified into Setup.thread by config.status. ! # Its purpose is to automatically enable the thread module by default ! # unless the the --without-threads argument is given to the configure ! # script. # *NOTE*: if the configure script decides it can't support threads, # the thread module will still be enabled and cause compile errors. ! # The solution is to use --without-threads on platforms that don't # support threads. From python-dev@python.org Thu Jun 29 17:12:03 2000 From: python-dev@python.org (Barry Warsaw) Date: Thu, 29 Jun 2000 09:12:03 -0700 Subject: [Python-checkins] CVS: python/dist/src config.h.in,2.56,2.57 configure,1.118,1.119 configure.in,1.126,1.127 Message-ID: <200006291612.JAA02962@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv2286 Modified Files: config.h.in configure configure.in Log Message: Thread support is turned on my default now. To disable building threads use --without-threads. No extra tests of thread/compiler combinations have been added. --with(out)-thread and --with(out)-threads are completely interchangeable. --with-threads still supports the =DIRECTORY option for specifying where to find thread libraries. Index: config.h.in =================================================================== RCS file: /cvsroot/python/python/dist/src/config.h.in,v retrieving revision 2.56 retrieving revision 2.57 diff -C2 -r2.56 -r2.57 *** config.h.in 2000/06/18 15:07:40 2.56 --- config.h.in 2000/06/29 16:12:00 2.57 *************** *** 286,289 **** --- 286,292 ---- #undef HAVE_FORK + /* Define if you have the forkpty function. */ + #undef HAVE_FORKPTY + /* Define if you have the fpathconf function. */ #undef HAVE_FPATHCONF *************** *** 367,370 **** --- 370,376 ---- #undef HAVE_NICE + /* Define if you have the openpty function. */ + #undef HAVE_OPENPTY + /* Define if you have the pathconf function. */ #undef HAVE_PATHCONF *************** *** 484,487 **** --- 490,496 ---- #undef HAVE_FCNTL_H + /* Define if you have the header file. */ + #undef HAVE_LIBUTIL_H + /* Define if you have the header file. */ #undef HAVE_LIMITS_H *************** *** 498,501 **** --- 507,513 ---- /* Define if you have the header file. */ #undef HAVE_PTHREAD_H + + /* Define if you have the header file. */ + #undef HAVE_PTY_H /* Define if you have the header file. */ Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.118 retrieving revision 1.119 diff -C2 -r1.118 -r1.119 *** configure 2000/06/28 16:40:38 1.118 --- configure 2000/06/29 16:12:00 1.119 *************** *** 1,8 **** #! /bin/sh ! # From configure.in Revision: 1.125 # Guess values for system-dependent variables and create Makefiles. ! # Generated automatically using autoconf version 2.14.1 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # --- 1,8 ---- #! /bin/sh [...4155 lines suppressed...] ! echo "$CONFIG_STATUS generated by autoconf version 2.14.1" exit 0 ;; -help | --help | --hel | --he | --h) --- 5651,5655 ---- exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) ! echo "$CONFIG_STATUS generated by autoconf version 2.13" exit 0 ;; -help | --help | --hel | --he | --h) *************** *** 5971,5974 **** chmod +x $CONFIG_STATUS rm -fr confdefs* $ac_clean_files ! test "$no_create" = yes || $SHELL $CONFIG_STATUS || exit 1 --- 5949,5952 ---- chmod +x $CONFIG_STATUS rm -fr confdefs* $ac_clean_files ! test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.126 retrieving revision 1.127 diff -C2 -r1.126 -r1.127 *** configure.in 2000/06/28 16:40:38 1.126 --- configure.in 2000/06/29 16:12:00 1.127 *************** *** 14,18 **** AC_MSG_CHECKING(for --with-next-archs) AC_ARG_WITH(next-archs, ! [--with-next-archs='arch1 arch2 ..' build MAB binary], [ if test -n "$withval"; then ac_arch_flags=`/usr/lib/arch_tool -archify_list $withval` --- 14,18 ---- AC_MSG_CHECKING(for --with-next-archs) AC_ARG_WITH(next-archs, ! [ --with-next-archs='arch1 arch2 ..' build MAB binary], [ if test -n "$withval"; then ac_arch_flags=`/usr/lib/arch_tool -archify_list $withval` *************** *** 34,40 **** AC_ARG_WITH(next-framework, ! [--with-next-framework Build (OpenStep|Rhapsody|MacOS10) framework],,) ! AC_ARG_WITH(dyld, ! [--with-dyld Use (OpenStep|Rhapsody|MacOS10) dynamic linker],,) # Set name for machine-dependent library files --- 34,40 ---- AC_ARG_WITH(next-framework, ! [ --with-next-framework Build (OpenStep|Rhapsody|MacOSX) framework],,) ! AC_ARG_WITH(dyld, ! [ --with-dyld Use (OpenStep|Rhapsody|MacOSX) dynamic linker],,) # Set name for machine-dependent library files *************** *** 100,104 **** # checks for alternative programs AC_MSG_CHECKING(for --without-gcc) ! AC_ARG_WITH(gcc, [--without-gcc never use gcc], [ case $withval in no) CC=cc --- 100,104 ---- # checks for alternative programs AC_MSG_CHECKING(for --without-gcc) ! AC_ARG_WITH(gcc, [ --without-gcc never use gcc], [ case $withval in no) CC=cc *************** *** 157,161 **** MAINOBJ=python.o AC_MSG_CHECKING(for --with-cxx=) ! AC_ARG_WITH(cxx, [--with-cxx= enable C++ support],[ case $withval in no) CXX= --- 157,161 ---- MAINOBJ=python.o AC_MSG_CHECKING(for --with-cxx=) ! AC_ARG_WITH(cxx, [ --with-cxx= enable C++ support],[ case $withval in no) CXX= *************** *** 613,617 **** AC_MSG_CHECKING(for --with-libs) ! AC_ARG_WITH(libs, [--with-libs='lib1 ...' link against additional libs], [ AC_MSG_RESULT($withval) LIBS="$withval $LIBS" --- 613,618 ---- AC_MSG_CHECKING(for --with-libs) ! AC_ARG_WITH(libs, ! [ --with-libs='lib1 ...' link against additional libs], [ AC_MSG_RESULT($withval) LIBS="$withval $LIBS" *************** *** 620,624 **** AC_MSG_CHECKING(for --with(out)-readline) AC_ARG_WITH(readline, ! [--with(out)-readline obsolete, edit Modules/Setup instead], [AC_MSG_RESULT($withval) AC_ERROR(--with(out)-readline is obsolete, edit Modules/Setup instead)], --- 621,625 ---- AC_MSG_CHECKING(for --with(out)-readline) AC_ARG_WITH(readline, ! [ --with(out)-readline obsolete, edit Modules/Setup instead], [AC_MSG_RESULT($withval) AC_ERROR(--with(out)-readline is obsolete, edit Modules/Setup instead)], *************** *** 626,636 **** AC_SUBST(USE_THREAD_MODULE) ! USE_THREAD_MODULE="#" AC_MSG_CHECKING(for --with-dec-threads) AC_SUBST(LDLAST) AC_ARG_WITH(dec-threads, ! [--with-dec-threads use DEC Alpha/OSF1 thread-safe libraries], ! [AC_MSG_RESULT($withval) LDLAST=-threads if test "${with_thread+set}" != set; then --- 627,637 ---- AC_SUBST(USE_THREAD_MODULE) ! USE_THREAD_MODULE="" AC_MSG_CHECKING(for --with-dec-threads) AC_SUBST(LDLAST) AC_ARG_WITH(dec-threads, ! [ --with-dec-threads use DEC Alpha/OSF1 thread-safe libraries], [ ! AC_MSG_RESULT($withval) LDLAST=-threads if test "${with_thread+set}" != set; then *************** *** 640,700 **** AC_MSG_CHECKING(for --with-threads) ! AC_ARG_WITH(threads, [--with-threads alias for --with-thread], ! [AC_MSG_RESULT($withval) ! if test "${with_thread+set}" != set; then ! with_thread="$withval"; ! fi], ! AC_MSG_RESULT(no)) ! AC_MSG_CHECKING(for --with-thread) ! AC_ARG_WITH(thread, [--with-thread[=DIRECTORY] make interpreter thread-safe], [ ! USE_THREAD_MODULE= ! AC_MSG_RESULT($withval) ! if test -d "$withval" ! then LDFLAGS="$LDFLAGS -L$withval" fi ! AC_DEFINE(_REENTRANT) ! AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(C_THREADS) ! LIBOBJS="$LIBOBJS thread.o"],[ ! AC_CHECK_LIB(pth, pth_init, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(_GNU_PTH) ! LIBS="-lpth $LIBS" ! LIBOBJS="$LIBOBJS thread.o"],[ ! AC_CHECK_LIB(pthread, pthread_create, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(_POSIX_THREADS) ! LIBS="-lpthread $LIBS" ! LIBOBJS="$LIBOBJS thread.o"],[ ! AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(_POSIX_THREADS) ! LIBOBJS="$LIBOBJS thread.o"],[ ! AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(BEOS_THREADS) ! LIBOBJS="$LIBOBJS thread.o"],[ ! AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(_POSIX_THREADS) ! LIBS="$LIBS -lpthreads" ! LIBOBJS="$LIBOBJS thread.o"], [ ! AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(_POSIX_THREADS) ! LIBS="$LIBS -lc_r" ! LIBOBJS="$LIBOBJS thread.o"], [ ! AC_CHECK_LIB(thread, __d6_pthread_create, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(_POSIX_THREADS) ! LIBS="$LIBS -lthread" ! LIBOBJS="$LIBOBJS thread.o"], [ ! AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(_POSIX_THREADS) ! LIBS="$LIBS -lcma" ! LIBOBJS="$LIBOBJS thread.o"]) ! ])])])])])])])]) ! ! AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD) ! LIBS="$LIBS -lmpc" ! LIBOBJS="$LIBOBJS thread.o"]) ! AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD) ! LIBS="$LIBS -lthread" ! LIBOBJS="$LIBOBJS thread.o"]) ! ], AC_MSG_RESULT(no)) # -I${DLINCLDIR} is added to the compile rule for importdl.o --- 641,708 ---- AC_MSG_CHECKING(for --with-threads) ! AC_ARG_WITH(threads, ! [ --with(out)-threads[=DIRECTORY] disable/enable thread support]) ! # --with-thread is deprecated, but check for it anyway ! AC_ARG_WITH(thread,,[with_threads=$with_thread]) ! ! if test -z "$with_threads" ! then with_threads="yes" fi ! AC_MSG_RESULT($with_threads) ! ! if test "$with_threads" = "no" ! then ! USE_THREAD_MODULE="#" ! else ! if test -d "$with_threads" ! then LDFLAGS="$LDFLAGS -L$with_threads" ! fi ! if test -d "$withval" ! then LDFLAGS="$LDFLAGS -L$withval" ! fi ! AC_DEFINE(_REENTRANT) ! AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(C_THREADS) ! LIBOBJS="$LIBOBJS thread.o"],[ ! AC_CHECK_LIB(pth, pth_init, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(_GNU_PTH) ! LIBS="-lpth $LIBS" ! LIBOBJS="$LIBOBJS thread.o"],[ ! AC_CHECK_LIB(pthread, pthread_create, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(_POSIX_THREADS) ! LIBS="-lpthread $LIBS" ! LIBOBJS="$LIBOBJS thread.o"],[ ! AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(_POSIX_THREADS) ! LIBOBJS="$LIBOBJS thread.o"],[ ! AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(BEOS_THREADS) ! LIBOBJS="$LIBOBJS thread.o"],[ ! AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(_POSIX_THREADS) ! LIBS="$LIBS -lpthreads" ! LIBOBJS="$LIBOBJS thread.o"], [ ! AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(_POSIX_THREADS) ! LIBS="$LIBS -lc_r" ! LIBOBJS="$LIBOBJS thread.o"], [ ! AC_CHECK_LIB(thread, __d6_pthread_create, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(_POSIX_THREADS) ! LIBS="$LIBS -lthread" ! LIBOBJS="$LIBOBJS thread.o"], [ ! AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(_POSIX_THREADS) ! LIBS="$LIBS -lcma" ! LIBOBJS="$LIBOBJS thread.o"]) ! ])])])])])])])]) ! ! AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD) ! LIBS="$LIBS -lmpc" ! LIBOBJS="$LIBOBJS thread.o"]) ! AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD) ! LIBS="$LIBS -lthread" ! LIBOBJS="$LIBOBJS thread.o"]) ! fi # -I${DLINCLDIR} is added to the compile rule for importdl.o *************** *** 703,707 **** AC_MSG_CHECKING(for --with-sgi-dl) ! AC_ARG_WITH(sgi-dl, [--with-sgi-dl=DIRECTORY IRIX 4 dynamic linking], [ AC_MSG_RESULT($withval) AC_DEFINE(WITH_SGI_DL) --- 711,716 ---- AC_MSG_CHECKING(for --with-sgi-dl) ! AC_ARG_WITH(sgi-dl, ! [ --with-sgi-dl=DIRECTORY IRIX 4 dynamic linking], [ AC_MSG_RESULT($withval) AC_DEFINE(WITH_SGI_DL) *************** *** 716,720 **** AC_MSG_CHECKING(for --with-dl-dld) ! AC_ARG_WITH(dl-dld, [--with-dl-dld=DL_DIR,DLD_DIR GNU dynamic linking], [ AC_MSG_RESULT($withval) AC_DEFINE(WITH_DL_DLD) --- 725,729 ---- AC_MSG_CHECKING(for --with-dl-dld) ! AC_ARG_WITH(dl-dld, [ --with-dl-dld=DL_DIR,DLD_DIR GNU dynamic linking], [ AC_MSG_RESULT($withval) AC_DEFINE(WITH_DL_DLD) *************** *** 959,963 **** # Check for --with-fpectl AC_MSG_CHECKING(for --with-fpectl) ! AC_ARG_WITH(fpectl, [--with-fpectl enable SIGFPE catching], [ if test "$withval" != no then AC_DEFINE(WANT_SIGFPE_HANDLER) AC_MSG_RESULT(yes) --- 968,973 ---- # Check for --with-fpectl AC_MSG_CHECKING(for --with-fpectl) ! AC_ARG_WITH(fpectl, ! [ --with-fpectl enable SIGFPE catching], [ if test "$withval" != no then AC_DEFINE(WANT_SIGFPE_HANDLER) AC_MSG_RESULT(yes) *************** *** 974,978 **** esac AC_MSG_CHECKING(for --with-libm=STRING) ! AC_ARG_WITH(libm, [--with-libm=STRING math library], [ if test "$withval" = no then LIBM= --- 984,988 ---- esac AC_MSG_CHECKING(for --with-libm=STRING) ! AC_ARG_WITH(libm, [ --with-libm=STRING math library], [ if test "$withval" = no then LIBM= *************** *** 988,992 **** AC_SUBST(LIBC) AC_MSG_CHECKING(for --with-libc=STRING) ! AC_ARG_WITH(libc, [--with-libc=STRING C library], [ if test "$withval" = no then LIBC= --- 998,1002 ---- AC_SUBST(LIBC) AC_MSG_CHECKING(for --with-libc=STRING) ! AC_ARG_WITH(libc, [ --with-libc=STRING C library], [ if test "$withval" = no then LIBC= *************** *** 1083,1087 **** AC_MSG_CHECKING(for --with-wctype-functions) AC_ARG_WITH(wctype-functions, ! [--with-wctype-functions use wctype.h functions], [ if test "$withval" != no then AC_DEFINE(WANT_WCTYPE_FUNCTIONS) AC_MSG_RESULT(yes) --- 1093,1097 ---- AC_MSG_CHECKING(for --with-wctype-functions) AC_ARG_WITH(wctype-functions, ! [ --with-wctype-functions use wctype.h functions], [ if test "$withval" != no then AC_DEFINE(WANT_WCTYPE_FUNCTIONS) AC_MSG_RESULT(yes) From python-dev@python.org Thu Jun 29 17:14:17 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 09:14:17 -0700 Subject: [Python-checkins] CVS: python/dist/src/PC _winreg.c,1.3,1.4 Message-ID: <200006291614.JAA03585@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv3574 Modified Files: _winreg.c Log Message: Update the module name to _winreg, pending checkin of Paul Prescod's OO wrapper for this module. Index: _winreg.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/_winreg.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** _winreg.c 2000/06/09 06:01:47 1.3 --- _winreg.c 2000/06/29 16:14:14 1.4 *************** *** 1,4 **** /* ! winreg.c Windows Registry access module for Python. --- 1,4 ---- /* ! _winreg.c Windows Registry access module for Python. *************** *** 1404,1411 **** #define ADD_KEY(val) inskey(d, #val, val) ! __declspec(dllexport) void initwinreg(void) { PyObject *m, *d; ! m = Py_InitModule3("winreg", winreg_methods, module_doc); d = PyModule_GetDict(m); PyHKEY_Type.ob_type = &PyType_Type; --- 1404,1411 ---- #define ADD_KEY(val) inskey(d, #val, val) ! __declspec(dllexport) void init_winreg(void) { PyObject *m, *d; ! m = Py_InitModule3("_winreg", winreg_methods, module_doc); d = PyModule_GetDict(m); PyHKEY_Type.ob_type = &PyType_Type; From python-dev@python.org Thu Jun 29 17:15:55 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 29 Jun 2000 09:15:55 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib pickle.py,1.37,1.38 Message-ID: <200006291615.JAA03805@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv3794 Modified Files: pickle.py Log Message: Change string exceptions to class exceptions. Index: pickle.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pickle.py,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -r1.37 -r1.38 *** pickle.py 2000/03/10 23:20:09 1.37 --- pickle.py 2000/06/29 16:15:52 1.38 *************** *** 39,44 **** mloads = marshal.loads ! PicklingError = "pickle.PicklingError" ! UnpicklingError = "pickle.UnpicklingError" try: --- 39,45 ---- mloads = marshal.loads ! class PickleError(Exception): pass ! class PicklingError(PickleError): pass ! class UnpicklingError(PickleError): pass try: From python-dev@python.org Thu Jun 29 17:30:53 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 29 Jun 2000 09:30:53 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/lib-tk Tkinter.py,1.138,1.139 Message-ID: <200006291630.JAA07217@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/lib-tk In directory slayer.i.sourceforge.net:/tmp/cvs-serv7209 Modified Files: Tkinter.py Log Message: Nils Fischbeck: added doc strings to everything. Martin von Loewis has reviewed this, too. Index: Tkinter.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/Tkinter.py,v retrieving revision 1.138 retrieving revision 1.139 diff -C2 -r1.138 -r1.139 *** Tkinter.py 2000/06/18 18:45:50 1.138 --- Tkinter.py 2000/06/29 16:30:50 1.139 *************** *** 1,4 **** ! # Tkinter.py -- Tk/Tcl widget wrappers __version__ = "$Revision$" --- 1,31 ---- ! """Wrapper functions for Tcl/Tk. + Tkinter provides classes which allow the display, positioning and + control of widgets. Toplevel widgets are Tk and Toplevel. Other + widgets are Frame, Label, Entry, Text, Canvas, Button, Radiobutton, [...2761 lines suppressed...] args = (self.name, 'write', filename) if format: *************** *** 1934,1938 **** --- 3007,3015 ---- class BitmapImage(Image): + """Widget which can display a bitmap.""" def __init__(self, name=None, cnf={}, master=None, **kw): + """Create a bitmap with NAME. + + Valid resource names: background, data, file, foreground, maskdata, maskfile.""" apply(Image.__init__, (self, 'bitmap', name, cnf, master), kw) *************** *** 1987,1988 **** --- 3064,3066 ---- if __name__ == '__main__': _test() + From python-dev@python.org Thu Jun 29 17:43:51 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 09:43:51 -0700 Subject: [Python-checkins] CVS: python/dist/src/PC winreg.c,1.3,NONE Message-ID: <200006291643.JAA07925@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv7915/PC Removed Files: winreg.c Log Message: Finish converting the winreg extension to _winreg. From python-dev@python.org Thu Jun 29 17:43:51 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 09:43:51 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild winreg.dsp,1.3,1.4 Message-ID: <200006291643.JAA07929@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv7915/PCbuild Modified Files: winreg.dsp Log Message: Finish converting the winreg extension to _winreg. Index: winreg.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/winreg.dsp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** winreg.dsp 2000/03/31 01:33:07 1.3 --- winreg.dsp 2000/06/29 16:43:49 1.4 *************** *** 55,59 **** 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 /dll /machine:I386 ! # ADD 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 /base:"0x1e1C0000" /dll /machine:I386 /out:"winreg.pyd" !ELSEIF "$(CFG)" == "winreg - Win32 Debug" --- 55,59 ---- 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 /dll /machine:I386 ! # ADD 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 /base:"0x1e1C0000" /dll /machine:I386 /out:"_winreg.pyd" !ELSEIF "$(CFG)" == "winreg - Win32 Debug" *************** *** 82,86 **** 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 /dll /debug /machine:I386 /pdbtype:sept ! # ADD 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 /base:"0x1e1C0000" /dll /debug /machine:I386 /out:"winreg_d.pyd" /pdbtype:sept !ENDIF --- 82,86 ---- 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 /dll /debug /machine:I386 /pdbtype:sept ! # ADD 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 /base:"0x1e1C0000" /dll /debug /machine:I386 /out:"_winreg_d.pyd" /pdbtype:sept !ENDIF *************** *** 92,96 **** # Begin Source File ! SOURCE=..\PC\winreg.c !IF "$(CFG)" == "winreg - Win32 Release" --- 92,96 ---- # Begin Source File ! SOURCE=..\PC\_winreg.c !IF "$(CFG)" == "winreg - Win32 Release" From python-dev@python.org Thu Jun 29 17:57:42 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 09:57:42 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre.py,1.11,1.12 sre_compile.py,1.9,1.10 sre_constants.py,1.9,1.10 sre_parse.py,1.9,1.10 Message-ID: <200006291657.JAA08802@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv8292/Lib Modified Files: sre.py sre_compile.py sre_constants.py sre_parse.py Log Message: - fixed split (test_sre still complains about split, but that's caused by the group reset bug, not split itself) - added more mark slots (should be dynamically allocated, but 100 is better than 32. and checking for the upper limit is better than overwriting the memory ;-) - internal: renamed the cursor helper class - internal: removed some bloat from sre_compile Index: sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** sre.py 2000/06/29 12:48:37 1.11 --- sre.py 2000/06/29 16:57:39 1.12 *************** *** 27,31 **** # sre exception ! error = sre_parse.error # -------------------------------------------------------------------- --- 27,31 ---- # sre exception ! error = sre_compile.error # -------------------------------------------------------------------- *************** *** 106,110 **** s = [] append = s.append ! c = pattern.cursor(string) while not count or n < count: m = c.search() --- 106,110 ---- s = [] append = s.append ! c = pattern.scanner(string) while not count or n < count: m = c.search() *************** *** 128,141 **** s = [] append = s.append ! c = pattern.cursor(string) while not maxsplit or n < maxsplit: m = c.search() if not m: break ! j = m.start() ! append(string[i:j]) ! i = m.end() ! if i <= j: ! break n = n + 1 if i < len(string): --- 128,145 ---- s = [] append = s.append ! extend = s.extend ! c = pattern.scanner(string) ! g = c.groups while not maxsplit or n < maxsplit: m = c.search() if not m: break ! b, e = m.span() ! if e == i: ! continue ! append(string[i:b]) ! if g and b != e: ! extend(m.groups()) ! i = e n = n + 1 if i < len(string): Index: sre_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** sre_compile.py 2000/06/29 12:48:37 1.9 --- sre_compile.py 2000/06/29 16:57:39 1.10 *************** *** 12,17 **** # ! import array, string, sys ! import _sre --- 12,16 ---- # ! import array import _sre *************** *** 25,145 **** raise RuntimeError, "cannot find a useable array type" - # FIXME: should move some optimizations from the parser to here! - - class Code: - def __init__(self): - self.data = [] - def __len__(self): - return len(self.data) - def __getitem__(self, index): - return self.data[index] - def __setitem__(self, index, code): - self.data[index] = code - def append(self, code): - self.data.append(code) - def todata(self): - # print self.data - try: - return array.array(WORDSIZE, self.data).tostring() - except OverflowError: - print self.data - raise - def _compile(code, pattern, flags): ! append = code.append for op, av in pattern: if op is ANY: if flags & SRE_FLAG_DOTALL: ! append(OPCODES[op]) # any character at all! else: ! append(OPCODES[CATEGORY]) ! append(CHCODES[CATEGORY_NOT_LINEBREAK]) elif op in (SUCCESS, FAILURE): ! append(OPCODES[op]) elif op is AT: ! append(OPCODES[op]) if flags & SRE_FLAG_MULTILINE: ! append(ATCODES[AT_MULTILINE[av]]) else: ! append(ATCODES[av]) elif op is BRANCH: ! append(OPCODES[op]) tail = [] for av in av[1]: ! skip = len(code); append(0) _compile(code, av, flags) ! ## append(OPCODES[SUCCESS]) ! append(OPCODES[JUMP]) ! tail.append(len(code)); append(0) code[skip] = len(code) - skip ! append(0) # end of branch for tail in tail: code[tail] = len(code) - tail elif op is CALL: ! append(OPCODES[op]) ! skip = len(code); append(0) _compile(code, av, flags) ! append(OPCODES[SUCCESS]) code[skip] = len(code) - skip elif op is CATEGORY: ! append(OPCODES[op]) if flags & SRE_FLAG_LOCALE: ! append(CH_LOCALE[CHCODES[av]]) elif flags & SRE_FLAG_UNICODE: ! append(CH_UNICODE[CHCODES[av]]) else: ! append(CHCODES[av]) elif op is GROUP: if flags & SRE_FLAG_IGNORECASE: ! append(OPCODES[OP_IGNORE[op]]) else: ! append(OPCODES[op]) ! append(av-1) elif op is IN: if flags & SRE_FLAG_IGNORECASE: ! append(OPCODES[OP_IGNORE[op]]) def fixup(literal, flags=flags): return _sre.getlower(ord(literal), flags) else: ! append(OPCODES[op]) fixup = ord ! skip = len(code); append(0) for op, av in av: ! append(OPCODES[op]) if op is NEGATE: pass elif op is LITERAL: ! append(fixup(av)) elif op is RANGE: ! append(fixup(av[0])) ! append(fixup(av[1])) elif op is CATEGORY: if flags & SRE_FLAG_LOCALE: ! append(CH_LOCALE[CHCODES[av]]) elif flags & SRE_FLAG_UNICODE: ! append(CH_UNICODE[CHCODES[av]]) else: ! append(CHCODES[av]) else: ! raise ValueError, "unsupported set operator" ! append(OPCODES[FAILURE]) code[skip] = len(code) - skip elif op in (LITERAL, NOT_LITERAL): if flags & SRE_FLAG_IGNORECASE: ! append(OPCODES[OP_IGNORE[op]]) else: ! append(OPCODES[op]) ! append(ord(av)) elif op is MARK: ! append(OPCODES[op]) ! append(av) elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): if flags & SRE_FLAG_TEMPLATE: ! append(OPCODES[REPEAT]) ! skip = len(code); append(0) ! append(av[0]) ! append(av[1]) _compile(code, av[2], flags) ! append(OPCODES[SUCCESS]) code[skip] = len(code) - skip else: --- 24,122 ---- raise RuntimeError, "cannot find a useable array type" def _compile(code, pattern, flags): ! emit = code.append for op, av in pattern: if op is ANY: if flags & SRE_FLAG_DOTALL: ! emit(OPCODES[op]) else: ! emit(OPCODES[CATEGORY]) ! emit(CHCODES[CATEGORY_NOT_LINEBREAK]) elif op in (SUCCESS, FAILURE): ! emit(OPCODES[op]) elif op is AT: ! emit(OPCODES[op]) if flags & SRE_FLAG_MULTILINE: ! emit(ATCODES[AT_MULTILINE[av]]) else: ! emit(ATCODES[av]) elif op is BRANCH: ! emit(OPCODES[op]) tail = [] for av in av[1]: ! skip = len(code); emit(0) _compile(code, av, flags) ! emit(OPCODES[JUMP]) ! tail.append(len(code)); emit(0) code[skip] = len(code) - skip ! emit(0) # end of branch for tail in tail: code[tail] = len(code) - tail elif op is CALL: ! emit(OPCODES[op]) ! skip = len(code); emit(0) _compile(code, av, flags) ! emit(OPCODES[SUCCESS]) code[skip] = len(code) - skip elif op is CATEGORY: ! emit(OPCODES[op]) if flags & SRE_FLAG_LOCALE: ! emit(CH_LOCALE[CHCODES[av]]) elif flags & SRE_FLAG_UNICODE: ! emit(CH_UNICODE[CHCODES[av]]) else: ! emit(CHCODES[av]) elif op is GROUP: if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) else: ! emit(OPCODES[op]) ! emit(av-1) elif op is IN: if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) def fixup(literal, flags=flags): return _sre.getlower(ord(literal), flags) else: ! emit(OPCODES[op]) fixup = ord ! skip = len(code); emit(0) for op, av in av: ! emit(OPCODES[op]) if op is NEGATE: pass elif op is LITERAL: ! emit(fixup(av)) elif op is RANGE: ! emit(fixup(av[0])) ! emit(fixup(av[1])) elif op is CATEGORY: if flags & SRE_FLAG_LOCALE: ! emit(CH_LOCALE[CHCODES[av]]) elif flags & SRE_FLAG_UNICODE: ! emit(CH_UNICODE[CHCODES[av]]) else: ! emit(CHCODES[av]) else: ! raise error, "internal: unsupported set operator" ! emit(OPCODES[FAILURE]) code[skip] = len(code) - skip elif op in (LITERAL, NOT_LITERAL): if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) else: ! emit(OPCODES[op]) ! emit(ord(av)) elif op is MARK: ! emit(OPCODES[op]) ! emit(av) elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): if flags & SRE_FLAG_TEMPLATE: ! emit(OPCODES[REPEAT]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) code[skip] = len(code) - skip else: *************** *** 150,182 **** # FIXME: need a better way to figure out when # it's safe to use this one (in the parser, probably) ! append(OPCODES[MAX_REPEAT_ONE]) ! skip = len(code); append(0) ! append(av[0]) ! append(av[1]) _compile(code, av[2], flags) ! append(OPCODES[SUCCESS]) code[skip] = len(code) - skip else: ! append(OPCODES[op]) ! skip = len(code); append(0) ! append(av[0]) ! append(av[1]) _compile(code, av[2], flags) ! append(OPCODES[SUCCESS]) code[skip] = len(code) - skip elif op is SUBPATTERN: group = av[0] if group: ! append(OPCODES[MARK]) ! append((group-1)*2) _compile(code, av[1], flags) if group: ! append(OPCODES[MARK]) ! append((group-1)*2+1) else: raise ValueError, ("unsupported operand type", op) def compile(p, flags=0): ! # convert pattern list to internal format if type(p) in (type(""), type(u"")): import sre_parse --- 127,159 ---- # FIXME: need a better way to figure out when # it's safe to use this one (in the parser, probably) ! emit(OPCODES[MAX_REPEAT_ONE]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) code[skip] = len(code) - skip else: ! emit(OPCODES[op]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) code[skip] = len(code) - skip elif op is SUBPATTERN: group = av[0] if group: ! emit(OPCODES[MARK]) ! emit((group-1)*2) _compile(code, av[1], flags) if group: ! emit(OPCODES[MARK]) ! emit((group-1)*2+1) else: raise ValueError, ("unsupported operand type", op) def compile(p, flags=0): ! # internal: convert pattern list to internal format if type(p) in (type(""), type(u"")): import sre_parse *************** *** 186,202 **** pattern = None flags = p.pattern.flags | flags ! code = Code() _compile(code, p.data, flags) code.append(OPCODES[SUCCESS]) ! data = code.todata() ! if 0: # debugging ! print ! print "-" * 68 ! import sre_disasm ! sre_disasm.disasm(data) ! print "-" * 68 return _sre.compile( pattern, flags, ! data, p.pattern.groups-1, p.pattern.groupdict ) --- 163,175 ---- pattern = None flags = p.pattern.flags | flags ! code = [] _compile(code, p.data, flags) code.append(OPCODES[SUCCESS]) ! # FIXME: get rid of this limitation ! assert p.pattern.groups <= 100,\ ! "sorry, but this version only supports 100 named groups" return _sre.compile( pattern, flags, ! array.array(WORDSIZE, code).tostring(), p.pattern.groups-1, p.pattern.groupdict ) Index: sre_constants.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_constants.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 From python-dev@python.org Thu Jun 29 17:57:42 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 09:57:42 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.9,2.10 sre.h,2.8,2.9 Message-ID: <200006291657.JAA08807@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv8292/Modules Modified Files: _sre.c sre.h Log Message: - fixed split (test_sre still complains about split, but that's caused by the group reset bug, not split itself) - added more mark slots (should be dynamically allocated, but 100 is better than 32. and checking for the upper limit is better than overwriting the memory ;-) - internal: renamed the cursor helper class - internal: removed some bloat from sre_compile Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.9 retrieving revision 2.10 diff -C2 -r2.9 -r2.10 *** _sre.c 2000/06/29 12:48:37 2.9 --- _sre.c 2000/06/29 16:57:40 2.10 *************** *** 15,23 **** * 00-03-14 fl removed most compatibility stuff (0.6) * 00-05-10 fl towards third alpha (0.8.2) ! * 00-05-13 fl added experimental cursor stuff (0.8.3) * 00-05-27 fl final bug hunt (0.8.4) * 00-06-21 fl less bugs, more taste (0.8.5) * 00-06-25 fl major changes to better deal with nested repeats (0.9) * 00-06-28 fl fixed findall (0.9.1) * * Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. --- 15,24 ---- * 00-03-14 fl removed most compatibility stuff (0.6) * 00-05-10 fl towards third alpha (0.8.2) ! * 00-05-13 fl added experimental scanner stuff (0.8.3) * 00-05-27 fl final bug hunt (0.8.4) * 00-06-21 fl less bugs, more taste (0.8.5) * 00-06-25 fl major changes to better deal with nested repeats (0.9) * 00-06-28 fl fixed findall (0.9.1) + * 00-06-29 fl fixed split, added more scanner features (0.9.2) * * Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. *************** *** 385,389 **** /* FIXME: this is a hack! */ ! void* mark_copy[64]; void* mark = NULL; --- 386,390 ---- /* FIXME: this is a hack! */ ! void* mark_copy[SRE_MARK_SIZE]; void* mark = NULL; *************** *** 955,959 **** staticforward PyTypeObject Pattern_Type; staticforward PyTypeObject Match_Type; ! staticforward PyTypeObject Cursor_Type; static PyObject * --- 956,960 ---- staticforward PyTypeObject Pattern_Type; staticforward PyTypeObject Match_Type; ! staticforward PyTypeObject Scanner_Type; static PyObject * *************** *** 1075,1079 **** /* FIXME: dynamic! */ ! for (i = 0; i < 64; i++) state->mark[i] = NULL; --- 1076,1080 ---- /* FIXME: dynamic! */ ! for (i = 0; i < SRE_MARK_SIZE; i++) state->mark[i] = NULL; *************** *** 1177,1189 **** static PyObject* ! pattern_cursor(PatternObject* pattern, PyObject* args) { /* create search state object */ ! CursorObject* self; PyObject* string; /* create match object (with room for extra group marks) */ ! self = PyObject_NEW(CursorObject, &Cursor_Type); if (self == NULL) return NULL; --- 1178,1190 ---- static PyObject* ! pattern_scanner(PatternObject* pattern, PyObject* args) { /* create search state object */ ! ScannerObject* self; PyObject* string; /* create match object (with room for extra group marks) */ ! self = PyObject_NEW(ScannerObject, &Scanner_Type); if (self == NULL) return NULL; *************** *** 1432,1436 **** {"findall", (PyCFunction) pattern_findall, 1}, /* experimental */ ! {"cursor", (PyCFunction) pattern_cursor, 1}, {NULL, NULL} }; --- 1433,1437 ---- {"findall", (PyCFunction) pattern_findall, 1}, /* experimental */ ! {"scanner", (PyCFunction) pattern_scanner, 1}, {NULL, NULL} }; *************** *** 1468,1472 **** statichere PyTypeObject Pattern_Type = { PyObject_HEAD_INIT(NULL) ! 0, "Pattern", sizeof(PatternObject), 0, (destructor)pattern_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ --- 1469,1473 ---- statichere PyTypeObject Pattern_Type = { PyObject_HEAD_INIT(NULL) ! 0, "SRE_Pattern", sizeof(PatternObject), 0, (destructor)pattern_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ *************** *** 1762,1766 **** statichere PyTypeObject Match_Type = { PyObject_HEAD_INIT(NULL) ! 0, "Match", sizeof(MatchObject), /* size of basic object */ sizeof(int), /* space for group item */ --- 1763,1767 ---- statichere PyTypeObject Match_Type = { PyObject_HEAD_INIT(NULL) ! 0, "SRE_Match", sizeof(MatchObject), /* size of basic object */ sizeof(int), /* space for group item */ *************** *** 1771,1778 **** /* -------------------------------------------------------------------- */ ! /* cursor methods (experimental) */ static void ! cursor_dealloc(CursorObject* self) { state_fini(&self->state); --- 1772,1779 ---- /* -------------------------------------------------------------------- */ ! /* scanner methods (experimental) */ static void ! scanner_dealloc(ScannerObject* self) { state_fini(&self->state); *************** *** 1783,1787 **** static PyObject* ! cursor_match(CursorObject* self, PyObject* args) { SRE_STATE* state = &self->state; --- 1784,1788 ---- static PyObject* ! scanner_match(ScannerObject* self, PyObject* args) { SRE_STATE* state = &self->state; *************** *** 1812,1816 **** static PyObject* ! cursor_search(CursorObject* self, PyObject* args) { SRE_STATE* state = &self->state; --- 1813,1817 ---- static PyObject* ! scanner_search(ScannerObject* self, PyObject* args) { SRE_STATE* state = &self->state; *************** *** 1831,1835 **** state, self->string, status); ! if (status >= 0) state->start = state->ptr; --- 1832,1838 ---- state, self->string, status); ! if (status == 0 || state->ptr == state->start) ! state->start = (void*) ((char*) state->ptr + state->charsize); ! else state->start = state->ptr; *************** *** 1837,1852 **** } ! static PyMethodDef cursor_methods[] = { ! {"match", (PyCFunction) cursor_match, 0}, ! {"search", (PyCFunction) cursor_search, 0}, {NULL, NULL} }; static PyObject* ! cursor_getattr(CursorObject* self, char* name) { PyObject* res; ! res = Py_FindMethod(cursor_methods, (PyObject*) self, name); if (res) return res; --- 1840,1855 ---- } ! static PyMethodDef scanner_methods[] = { ! {"match", (PyCFunction) scanner_match, 0}, ! {"search", (PyCFunction) scanner_search, 0}, {NULL, NULL} }; static PyObject* ! scanner_getattr(ScannerObject* self, char* name) { PyObject* res; ! res = Py_FindMethod(scanner_methods, (PyObject*) self, name); if (res) return res; *************** *** 1860,1875 **** } PyErr_SetString(PyExc_AttributeError, name); return NULL; } ! statichere PyTypeObject Cursor_Type = { PyObject_HEAD_INIT(NULL) ! 0, "Cursor", ! sizeof(CursorObject), /* size of basic object */ 0, ! (destructor)cursor_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ ! (getattrfunc)cursor_getattr, /*tp_getattr*/ }; --- 1863,1881 ---- } + if (!strcmp(name, "groups")) + return Py_BuildValue("i", ((PatternObject*) self->pattern)->groups); + PyErr_SetString(PyExc_AttributeError, name); return NULL; } ! statichere PyTypeObject Scanner_Type = { PyObject_HEAD_INIT(NULL) ! 0, "SRE_Scanner", ! sizeof(ScannerObject), /* size of basic object */ 0, ! (destructor)scanner_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ ! (getattrfunc)scanner_getattr, /*tp_getattr*/ }; *************** *** 1889,1893 **** /* Patch object types */ Pattern_Type.ob_type = Match_Type.ob_type = ! Cursor_Type.ob_type = &PyType_Type; Py_InitModule("_" MODULE, _functions); --- 1895,1899 ---- /* Patch object types */ Pattern_Type.ob_type = Match_Type.ob_type = ! Scanner_Type.ob_type = &PyType_Type; Py_InitModule("_" MODULE, _functions); Index: sre.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/sre.h,v retrieving revision 2.8 retrieving revision 2.9 diff -C2 -r2.8 -r2.9 *** sre.h 2000/06/29 12:48:37 2.8 --- sre.h 2000/06/29 16:57:40 2.9 *************** *** 47,50 **** --- 47,53 ---- } SRE_STACK; + /* FIXME: shouldn't be a constant, really... */ + #define SRE_MARK_SIZE 200 + typedef struct { /* string pointers */ *************** *** 57,61 **** /* registers */ int lastmark; ! void* mark[64]; /* FIXME: should be dynamically allocated! */ /* backtracking stack */ SRE_STACK* stack; --- 60,64 ---- /* registers */ int lastmark; ! void* mark[SRE_MARK_SIZE]; /* backtracking stack */ SRE_STACK* stack; *************** *** 67,76 **** typedef struct { ! /* search helper */ PyObject_HEAD PyObject* pattern; PyObject* string; SRE_STATE state; ! } CursorObject; #endif --- 70,79 ---- typedef struct { ! /* scanner (internal helper object) */ PyObject_HEAD PyObject* pattern; PyObject* string; SRE_STATE state; ! } ScannerObject; #endif From python-dev@python.org Thu Jun 29 17:53:11 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 09:53:11 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-win winreg.py,NONE,1.1 Message-ID: <200006291653.JAA08586@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/plat-win In directory slayer.i.sourceforge.net:/tmp/cvs-serv8578 Added Files: winreg.py Log Message: Paul Prescod : OO wrapper for _winreg; blessed by Mark Hammond. --- NEW FILE --- import winreg import sys import exceptions import array from types import * import string class RegType: def __init__( self, msname, friendlyname ): self.msname=msname self.friendlyname=friendlyname self.intval=getattr( winreg, msname ) def __repr__( self ): return "" % \ (self.intval, self.msname, self.friendlyname ) _typeConstants={ winreg.REG_NONE: RegType( "REG_NONE", "None" ), winreg.REG_SZ: RegType( "REG_SZ", "String" ), winreg.REG_EXPAND_SZ: RegType("REG_EXPAND_SZ", "Expandable Template String" ), winreg.REG_BINARY: RegType("REG_BINARY", "Binary Data"), winreg.REG_DWORD : RegType("REG_DWORD", "Integer" ), # winreg.REG_DWORD_LITTLE_ENDIAN : # RegType("REG_DWORD_LITTLE_ENDIAN", "Integer"), winreg.REG_DWORD_BIG_ENDIAN : RegType("REG_DWORD_BIG_ENDIAN", "Big Endian Integer"), winreg.REG_LINK : RegType("REG_LINK", "Link"), winreg.REG_MULTI_SZ : RegType("REG_MULTI_SZ", "List of Strings"), winreg.REG_RESOURCE_LIST : RegType("REG_RESOURCE_LIST", "Resource List"), winreg.REG_FULL_RESOURCE_DESCRIPTOR : RegType( "REG_FULL_RESOURCE_DESCRIPTOR", "Full Resource Descriptor" ), winreg.REG_RESOURCE_REQUIREMENTS_LIST: RegType( "REG_RESOURCE_REQUIREMENTS_LIST", "Resource Requirements List" ) } regtypes={} for constant in _typeConstants.values(): regtypes[constant.msname]=constant class _DictBase: def __init__( self, key ): self.key=key def clear( self ): keys=list( self.keys() ) map( self.__delitem__, keys ) def get( self, item, defaultVal=None ): try: return self.__getitem__( item ) except (IndexError, EnvironmentError, WindowsError): return defaultVal def has_key( self, item ): try: self.__getitem__( item ) return 1 except (IndexError, EnvironmentError, WindowsError): return 0 def keys( self ): keys=[] try: for i in xrange( 0, sys.maxint ): keyname = self._nameFromNum( i ) keys.append( keyname ) except (IndexError, EnvironmentError, WindowsError): pass return keys def values( self ): values=[] # map() doesn't use the IndexError semantics... for i in self: values.append( i ) return values def items( self ): return map( None, self.keys(), self.values() ) def __len__( self ): return len( self.keys() ) def _getName( item, nameFromNum ): if type( item ) == IntType: try: keyname = nameFromNum( item ) except (WindowsError, EnvironmentError): raise IndexError, item elif type( item )==StringType: keyname=item else: raise exceptions.TypeError, \ "Requires integer index or string key name" return keyname class RegValuesDict( _DictBase ): def _nameFromNum( self, i ): return self.key._nameFromNum( i ) def __getitem__( self, item ): return self.key.getValueNameDataAndType( item ) def __setitem__( self, name, val): if type( val )==TupleType: data, datatype=val assert isinstance( datatype, RegType ) self.key.setValue( name, data, datatype ) else: self.key.setValue( name, val ) def __delitem__( self, item ): valname=_getName( item, self._nameFromNum ) self.key.deleteValue( valname ) class RegKeysDict( _DictBase ): def _nameFromNum( self, item ): return winreg.EnumKey( self.key.handle, item ) def __getitem__( self, item ): keyname=_getName( item, self._nameFromNum ) return self.key.openSubkey( keyname ) def __delitem__( self, item ): keyname=_getName( item, self._nameFromNum ) self.key.deleteSubkey( keyname ) def openKey( keyname, samFlags=None ): lst=string.split( keyname, "\\", 1 ) if len( lst )==2: hivename,path=lst return hives[hivename].openSubkey( path ) else: hivename=lst[0] return hives[hivename] def createKey( keyname ): lst=string.split( keyname, "\\", 1 ) assert len( lst )==2 hivename,path=lst return hives[hivename].createSubkey( path ) def deleteKey( keyname ): lst=string.split( keyname, "\\", 1 ) assert len( lst )==2 hivename,path=lst return hives[hivename].deleteSubkey( path ) class RegKey: def _nameFromNum( self, item ): (name,data,datatype)=winreg.EnumValue( self.handle, item ) return name def __nonzero__(self): if self.handle: return 1 else: return 0 def __cmp__ (self, other ): if hasattr( other, "handle" ) and hasattr( other, "name" ): return cmp( self.name, other.name ) else: return cmp( self.handle, other ) def __init__( self, name, handle=None ): self.name=name self.handle=handle def __repr__( self ): return ""% self.name def close(self ): return winreg.CloseKey( self.handle ) def getSubkeyNames( self ): return self.getSubkeys().keys() def getValueNames( self ): return self.getValues().keys() def deleteSubkey( self, subkey ): return winreg.DeleteKey( self.handle, subkey ) def deleteValue( self, valname ): return winreg.DeleteValue( self.handle, valname ) def createSubkey( self, keyname ): handle=winreg.CreateKey( self.handle, keyname ) return RegKey( self.name+"\\"+keyname, handle) def openSubkey( self, keyname, samFlags=None ): if samFlags: handle=winreg.OpenKey( self.handle, keyname, 0, samFlags ) else: handle=winreg.OpenKey( self.handle, keyname, 0 ) return RegKey( self.name+"\\"+keyname, handle ) def getSubkeys( self ): return RegKeysDict( self ) def getValues( self ): return RegValuesDict( self ) def getValueNameDataAndType( self, valname ): try: if type( valname )==IntType: (valname,data,datatype)=winreg.EnumValue( self.handle, valname ) else: keyname=_getName( valname, self._nameFromNum ) (data,datatype)=winreg.QueryValueEx( self.handle, keyname ) except (WindowsError, EnvironmentError): raise IndexError, valname if datatype==winreg.REG_BINARY: # use arrays for binary data data=array.array( 'c', data ) return (valname, data, _typeConstants[datatype] ) def getValueData( self, valname ): name, data, type=self.getValueNameDataAndType( valname ) return data def setValue( self, valname, data, regtype=None ): if regtype: typeint=regtype.intval else: if type( data )==StringType: typeint=winreg.REG_SZ elif type( data )==IntType: typeint=winreg.REG_DWORD elif type( data )==array.ArrayType: typeint=winreg.REG_BINARY data=data.tostring() winreg.SetValueEx( self.handle, valname, 0, typeint, data ) def flush(self ): winreg.FlushKey( self.keyobbj ) def save( self, filename ): winreg.SaveKey( self.keyobj, filename ) def load( self, subkey, filename ): return winreg.RegLoadKey( self.handle, subkey, filename ) class RemoteKey( RegKey ): def __init__( self, machine, topLevelKey ): assert topLevelKey in _hivenames self.handle = winreg.ConnectRegistry( machine, parentKey ) self.name=r"\\%s\%s" % (machine, topLevelKey ) _hivenames = ["HKEY_CLASSES_ROOT","HKEY_CURRENT_USER","HKEY_LOCAL_MACHINE", "HKEY_USERS","HKEY_CURRENT_CONFIG","HKEY_DYN_DATA", "HKEY_PERFORMANCE_DATA"] hives={} for name in _hivenames: hives[name]=RegKey( name, getattr( winreg, name ) ) hives["HKLM"]=hives["HKEY_LOCAL_MACHINE"] hives["HKCR"]=hives["HKEY_CLASSES_ROOT"] hives["HKCU"]=hives["HKEY_CURRENT_USER"] _flagnames = ["KEY_ALL_ACCESS","KEY_CREATE_LINK", "KEY_CREATE_SUB_KEY", "KEY_ENUMERATE_SUB_KEYS", "KEY_EXECUTE", "KEY_NOTIFY", "KEY_QUERY_VALUE", "KEY_READ", "KEY_SET_VALUE"] flags={} for name in _flagnames: flags[name]=getattr( winreg, name ) _RegNotifyChangeKeyValueOptions=[ "REG_NOTIFY_CHANGE_ATTRIBUTES", "REG_NOTIFY_CHANGE_SECURITY", "REG_NOTIFY_CHANGE_LAST_SET", "REG_NOTIFY_CHANGE_NAME", "REG_LEGAL_CHANGE_FILTER" ] _RegRestoreKeyOptions=["REG_WHOLE_HIVE_VOLATILE", "REG_NO_LAZY_FLUSH", "REG_OPTION_VOLATILE", "REG_REFRESH_HIVE", "REG_OPTION_NON_VOLATILE", "REG_OPTION_BACKUP_RESTORE" ] _RegCreateKeyExOptions=[ "REG_LEGAL_OPTION", "REG_OPTION_RESERVED", "REG_OPTION_VOLATILE", "REG_OPTION_NON_VOLATILE", "REG_OPTION_BACKUP_RESTORE", "REG_CREATED_NEW_KEY", "REG_OPENED_EXISTING_KEY", "REG_OPTION_CREATE_LINK"] def test(): import testreg #unusednames=_RegNotifyChangeKeyValueOptions+_RegRestoreKeyOptions+_RegCreateKeyExOptions #typeConstantNames=map( lambda x: x.msname, typeConstants.values() ) #allnames=_hivenames+_flagnames+typeConstantNames+unusednames #winregnames=winreg.__dict__.keys() #for name in winregnames: # if name not in allnames: # print name From python-dev@python.org Thu Jun 29 18:00:56 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 29 Jun 2000 10:00:56 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_socket.py,1.13,1.14 Message-ID: <200006291700.KAA09410@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv9400 Modified Files: test_socket.py Log Message: Skip Montanaro: modify test_socket.py to listen/connect using loopback addr Index: test_socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** test_socket.py 2000/03/24 20:54:29 1.13 --- test_socket.py 2000/06/29 17:00:54 1.14 *************** *** 98,102 **** # parent is server s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ! s.bind((hostname, PORT)) s.listen(1) if verbose: --- 98,102 ---- # parent is server s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ! s.bind(("127.0.0.1", PORT)) s.listen(1) if verbose: *************** *** 134,138 **** if verbose: print 'child connecting' ! s.connect((hostname, PORT)) msg = 'socket test' s.send(msg) --- 134,138 ---- if verbose: print 'child connecting' ! s.connect(("127.0.0.1", PORT)) msg = 'socket test' s.send(msg) From python-dev@python.org Thu Jun 29 18:25:33 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 10:25:33 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python thread_nt.h,2.10,2.11 Message-ID: <200006291725.KAA16877@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv16794/Python Modified Files: thread_nt.h Log Message: - workaround to make 1.6 build under MSVC 5.0. hopefully, trent (who broke it in the first place ;-) will come up with a cleaner solution. Index: thread_nt.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_nt.h,v retrieving revision 2.10 retrieving revision 2.11 diff -C2 -r2.10 -r2.11 *** thread_nt.h 2000/06/28 22:07:35 2.10 --- thread_nt.h 2000/06/29 17:25:30 2.11 *************** *** 183,187 **** --- 183,191 ---- int PyThread_start_new_thread(void (*func)(void *), void *arg) { + #if _MSC_VER >= 1200 INT_PTR rv; + #else + unsigned long rv; + #endif int success = 0; From python-dev@python.org Thu Jun 29 19:51:02 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 11:51:02 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sgmllib.py,1.20,1.21 Message-ID: <200006291851.LAA28331@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv28314 Modified Files: sgmllib.py Log Message: [Old patch that hadn't been checked in.] get_starttag_text(): New method. Return the text of the most recently parsed start tag, from the '<' to the '>' or '/'. Not really useful for structure processing, but requested for Web-related use. May also be useful for being able to re-generate the input from the parse events, but there's no equivalent for end tags. attrfind: Be a little more forgiving of unquoted attribute values. Index: sgmllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sgmllib.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -r1.20 -r1.21 *** sgmllib.py 2000/06/28 14:48:01 1.20 --- sgmllib.py 2000/06/29 18:50:59 1.21 *************** *** 38,42 **** '[%s]*([a-zA-Z_][-.a-zA-Z_0-9]*)' % string.whitespace + ('([%s]*=[%s]*' % (string.whitespace, string.whitespace)) ! + r'(\'[^\']*\'|"[^"]*"|[-a-zA-Z0-9./:+*%?!\(\)_#=~]*))?') --- 38,42 ---- '[%s]*([a-zA-Z_][-.a-zA-Z_0-9]*)' % string.whitespace + ('([%s]*=[%s]*' % (string.whitespace, string.whitespace)) ! + r'(\'[^\']*\'|"[^"]*"|[-a-zA-Z0-9./:+*%?!&$\(\)_#=~]*))?') *************** *** 208,214 **** --- 208,220 ---- j = match.end(0) return j-i + + __starttag_text = None + def get_starttag_text(self): + return self.__starttag_text # Internal -- handle starttag, return length or -1 if not terminated def parse_starttag(self, i): + self.__starttag_text = None + start_pos = i rawdata = self.rawdata if shorttagopen.match(rawdata, i): *************** *** 221,227 **** return -1 tag, data = match.group(1, 2) tag = string.lower(tag) - self.finish_shorttag(tag, data) k = match.end(0) return k # XXX The following should skip matching quotes (' or ") --- 227,235 ---- return -1 tag, data = match.group(1, 2) + self.__starttag_text = '<%s/' % tag tag = string.lower(tag) k = match.end(0) + self.finish_shorttag(tag, data) + self.__starttag_text = rawdata[start_pos:match.end(1) + 1] return k # XXX The following should skip matching quotes (' or ") *************** *** 256,259 **** --- 264,268 ---- if rawdata[j] == '>': j = j+1 + self.__starttag_text = rawdata[start_pos:j] self.finish_starttag(tag, attrs) return j From python-dev@python.org Thu Jun 29 20:17:07 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:17:07 -0700 Subject: [Python-checkins] CVS: python/dist/src/PC _winreg.c,1.4,1.5 Message-ID: <200006291917.MAA03866@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv3837/PC Modified Files: _winreg.c Log Message: This patch addresses two main issues: (1) There exist some non-fatal errors in some of the hash algorithms. For exmaple, in float_hash and complex_hash a certain part of the value is not included in the hash calculation. See Tim's, Guido's, and my discussion of this on python-dev in May under the title "fix float_hash and complex_hash for 64-bit *nix" (2) The hash algorithms that use pointers (e.g. func_hash, code_hash) are universally not correct on Win64 (they assume that sizeof(long) == sizeof(void*)) As well, this patch significantly cleans up the hash code. It adds the two function _Py_HashDouble and _PyHash_VoidPtr that the various hashing routine are changed to use. These help maintain the hash function invariant: (a==b) => (hash(a)==hash(b))) I have added Lib/test/test_hash.py and Lib/test/output/test_hash to test this for some cases. Index: _winreg.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/_winreg.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** _winreg.c 2000/06/29 16:14:14 1.4 --- _winreg.c 2000/06/29 19:17:04 1.5 *************** *** 424,428 **** XXX - should we use the handle value? */ ! return (long)ob; } --- 424,428 ---- XXX - should we use the handle value? */ ! return _Py_HashPointer(ob); } From python-dev@python.org Thu Jun 29 20:17:07 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:17:07 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_hash,NONE,1.1 Message-ID: <200006291917.MAA03872@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv3837/Lib/test/output Added Files: test_hash Log Message: This patch addresses two main issues: (1) There exist some non-fatal errors in some of the hash algorithms. For exmaple, in float_hash and complex_hash a certain part of the value is not included in the hash calculation. See Tim's, Guido's, and my discussion of this on python-dev in May under the title "fix float_hash and complex_hash for 64-bit *nix" (2) The hash algorithms that use pointers (e.g. func_hash, code_hash) are universally not correct on Win64 (they assume that sizeof(long) == sizeof(void*)) As well, this patch significantly cleans up the hash code. It adds the two function _Py_HashDouble and _PyHash_VoidPtr that the various hashing routine are changed to use. These help maintain the hash function invariant: (a==b) => (hash(a)==hash(b))) I have added Lib/test/test_hash.py and Lib/test/output/test_hash to test this for some cases. --- NEW FILE --- test_hash From python-dev@python.org Thu Jun 29 20:17:07 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:17:07 -0700 Subject: [Python-checkins] CVS: python/dist/src/Include object.h,2.56,2.57 Message-ID: <200006291917.MAA03859@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Include In directory slayer.i.sourceforge.net:/tmp/cvs-serv3837/Include Modified Files: object.h Log Message: This patch addresses two main issues: (1) There exist some non-fatal errors in some of the hash algorithms. For exmaple, in float_hash and complex_hash a certain part of the value is not included in the hash calculation. See Tim's, Guido's, and my discussion of this on python-dev in May under the title "fix float_hash and complex_hash for 64-bit *nix" (2) The hash algorithms that use pointers (e.g. func_hash, code_hash) are universally not correct on Win64 (they assume that sizeof(long) == sizeof(void*)) As well, this patch significantly cleans up the hash code. It adds the two function _Py_HashDouble and _PyHash_VoidPtr that the various hashing routine are changed to use. These help maintain the hash function invariant: (a==b) => (hash(a)==hash(b))) I have added Lib/test/test_hash.py and Lib/test/output/test_hash to test this for some cases. Index: object.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/object.h,v retrieving revision 2.56 retrieving revision 2.57 diff -C2 -r2.56 -r2.57 *** object.h 2000/06/23 19:37:01 2.56 --- object.h 2000/06/29 19:17:04 2.57 *************** *** 294,297 **** --- 294,301 ---- extern PyObject *_PyCompareState_Key; + /* Helpers for hash functions */ + extern DL_IMPORT(long) _Py_HashDouble Py_PROTO((double)); + extern DL_IMPORT(long) _Py_HashPointer Py_PROTO((void*)); + /* Flag bits for printing: */ #define Py_PRINT_RAW 1 /* No string quotes etc. */ From python-dev@python.org Thu Jun 29 20:17:07 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:17:07 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_hash.py,NONE,1.1 Message-ID: <200006291917.MAA03869@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv3837/Lib/test Added Files: test_hash.py Log Message: This patch addresses two main issues: (1) There exist some non-fatal errors in some of the hash algorithms. For exmaple, in float_hash and complex_hash a certain part of the value is not included in the hash calculation. See Tim's, Guido's, and my discussion of this on python-dev in May under the title "fix float_hash and complex_hash for 64-bit *nix" (2) The hash algorithms that use pointers (e.g. func_hash, code_hash) are universally not correct on Win64 (they assume that sizeof(long) == sizeof(void*)) As well, this patch significantly cleans up the hash code. It adds the two function _Py_HashDouble and _PyHash_VoidPtr that the various hashing routine are changed to use. These help maintain the hash function invariant: (a==b) => (hash(a)==hash(b))) I have added Lib/test/test_hash.py and Lib/test/output/test_hash to test this for some cases. --- NEW FILE --- # test the invariant that # iff a==b then hash(a)==hash(b) # import test_support def same_hash(*objlist): # hash each object given an raise TestFailed if # the hash values are not all the same hashed = map(hash, objlist) for h in hashed[1:]: if h != hashed[0]: raise TestFailed, "hashed values differ: %s" % `objlist` same_hash(1, 1L, 1.0, 1.0+0.0j) same_hash(int(1), long(1), float(1), complex(1)) same_hash(long(1.23e300), float(1.23e300)) same_hash(float(0.5), complex(0.5, 0.0)) From python-dev@python.org Thu Jun 29 20:17:07 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:17:07 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects methodobject.c,2.26,2.27 object.c,2.73,2.74 floatobject.c,2.57,2.58 complexobject.c,2.24,2.25 classobject.c,2.91,2.92 funcobject.c,2.22,2.23 Message-ID: <200006291917.MAA03863@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv3837/Objects Modified Files: methodobject.c object.c floatobject.c complexobject.c classobject.c funcobject.c Log Message: This patch addresses two main issues: (1) There exist some non-fatal errors in some of the hash algorithms. For exmaple, in float_hash and complex_hash a certain part of the value is not included in the hash calculation. See Tim's, Guido's, and my discussion of this on python-dev in May under the title "fix float_hash and complex_hash for 64-bit *nix" (2) The hash algorithms that use pointers (e.g. func_hash, code_hash) are universally not correct on Win64 (they assume that sizeof(long) == sizeof(void*)) As well, this patch significantly cleans up the hash code. It adds the two function _Py_HashDouble and _PyHash_VoidPtr that the various hashing routine are changed to use. These help maintain the hash function invariant: (a==b) => (hash(a)==hash(b))) I have added Lib/test/test_hash.py and Lib/test/output/test_hash to test this for some cases. Index: methodobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/methodobject.c,v retrieving revision 2.26 retrieving revision 2.27 diff -C2 -r2.26 -r2.27 *** methodobject.c 2000/05/03 23:44:35 2.26 --- methodobject.c 2000/06/29 19:17:04 2.27 *************** *** 173,177 **** PyCFunctionObject *a; { ! long x; if (a->m_self == NULL) x = 0; --- 173,177 ---- PyCFunctionObject *a; { ! long x,y; if (a->m_self == NULL) x = 0; *************** *** 181,185 **** return -1; } ! return x ^ (long) a->m_ml->ml_meth; } --- 181,191 ---- return -1; } ! y = _Py_HashPointer(a->m_ml->ml_meth); ! if (y == -1) ! return -1; ! x ^= y; ! if (x == -1) ! x = -2; ! return x; } Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.73 retrieving revision 2.74 diff -C2 -r2.73 -r2.74 *** object.c 2000/06/28 21:57:18 2.73 --- object.c 2000/06/29 19:17:04 2.74 *************** *** 34,37 **** --- 34,39 ---- #include "Python.h" + #include "mymath.h" + /* just for trashcan: */ #include "compile.h" *************** *** 508,512 **** --- 510,570 ---- } + + /* Set of hash utility functions to help maintaining the invariant that + iff a==b then hash(a)==hash(b) + + All the utility functions (_Py_Hash*()) return "-1" to signify an error. + */ + + long + _Py_HashDouble(v) + double v; + { + /* Use frexp to get at the bits in the double. + * Since the VAX D double format has 56 mantissa bits, which is the + * most of any double format in use, each of these parts may have as + * many as (but no more than) 56 significant bits. + * So, assuming sizeof(long) >= 4, each part can be broken into two longs; + * frexp and multiplication are used to do that. + * Also, since the Cray double format has 15 exponent bits, which is the + * most of any double format in use, shifting the exponent field left by + * 15 won't overflow a long (again assuming sizeof(long) >= 4). + */ + int expo; + long hipart; + + v = frexp(v, &expo); + v = v * 2147483648.0; /* 2**31 */ + hipart = (long)v; /* Take the top 32 bits */ + v = (v - (double)hipart) * 2147483648.0; /* Get the next 32 bits */ + + return hipart + (long)v + (expo << 15); /* Combine everything */ + } + long + _Py_HashPointer(p) + void *p; + { + #if SIZEOF_LONG >= SIZEOF_VOID_P + return (long)p; + #else + /* convert to a Python long and hash that */ + PyObject* longobj; + long x; + + if ((longobj = PyLong_FromVoidPtr(p)) == NULL) { + x = -1; + goto finally; + } + x = PyObject_Hash(longobj); + + finally: + Py_XDECREF(longobj); + return x; + #endif + } + + + long PyObject_Hash(v) PyObject *v; *************** *** 515,520 **** if (tp->tp_hash != NULL) return (*tp->tp_hash)(v); ! if (tp->tp_compare == NULL) ! return (long) v; /* Use address as hash value */ /* If there's a cmp but no hash defined, the object can't be hashed */ PyErr_SetString(PyExc_TypeError, "unhashable type"); --- 573,579 ---- if (tp->tp_hash != NULL) return (*tp->tp_hash)(v); ! if (tp->tp_compare == NULL) { ! return _Py_HashPointer(v); /* Use address as hash value */ ! } /* If there's a cmp but no hash defined, the object can't be hashed */ PyErr_SetString(PyExc_TypeError, "unhashable type"); Index: floatobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/floatobject.c,v retrieving revision 2.57 retrieving revision 2.58 diff -C2 -r2.57 -r2.58 *** floatobject.c 2000/05/03 23:44:34 2.57 --- floatobject.c 2000/06/29 19:17:04 2.58 *************** *** 60,64 **** --- 60,70 ---- #ifndef LONG_MAX + #if SIZEOF_LONG == 4 #define LONG_MAX 0X7FFFFFFFL + #elif SIZEOF_LONG == 8 + #define LONG_MAX 0X7FFFFFFFFFFFFFFFL + #else + #error "could not set LONG_MAX" + #endif #endif *************** *** 358,361 **** --- 364,368 ---- } + static long float_hash(v) *************** *** 363,367 **** { double intpart, fractpart; - int expo; long x; /* This is designed so that Python numbers with the same --- 370,373 ---- *************** *** 380,384 **** if (fractpart == 0.0) { ! if (intpart > 0x7fffffffL || -intpart > 0x7fffffffL) { /* Convert to long int and use its hash... */ PyObject *w = PyLong_FromDouble(v->ob_fval); --- 386,390 ---- if (fractpart == 0.0) { ! if (intpart > LONG_MAX || -intpart > LONG_MAX) { /* Convert to long int and use its hash... */ PyObject *w = PyLong_FromDouble(v->ob_fval); *************** *** 394,405 **** /* Note -- if you change this code, also change the copy in complexobject.c */ ! long hipart; ! fractpart = frexp(fractpart, &expo); ! fractpart = fractpart * 2147483648.0; /* 2**31 */ ! hipart = (long)fractpart; /* Take the top 32 bits */ ! fractpart = (fractpart - (double)hipart) * 2147483648.0; ! /* Get the next 32 bits */ ! x = hipart + (long)fractpart + (long)intpart + (expo << 15); ! /* Combine everything */ } if (x == -1) --- 400,406 ---- /* Note -- if you change this code, also change the copy in complexobject.c */ ! x = _Py_HashDouble(v->ob_fval); ! if (x == -1) ! return -1; } if (x == -1) Index: complexobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/complexobject.c,v retrieving revision 2.24 retrieving revision 2.25 diff -C2 -r2.24 -r2.25 *** complexobject.c 2000/05/03 23:44:34 2.24 --- complexobject.c 2000/06/29 19:17:04 2.25 *************** *** 286,291 **** { double intpart, fractpart; ! int expo; ! long hipart, x; /* This is designed so that Python numbers with the same value hash to the same value, otherwise comparisons --- 286,290 ---- { double intpart, fractpart; ! long x; /* This is designed so that Python numbers with the same value hash to the same value, otherwise comparisons *************** *** 303,307 **** if (fractpart == 0.0 && v->cval.imag == 0.0) { ! if (intpart > 0x7fffffffL || -intpart > 0x7fffffffL) { /* Convert to long int and use its hash... */ PyObject *w = PyLong_FromDouble(v->cval.real); --- 302,306 ---- if (fractpart == 0.0 && v->cval.imag == 0.0) { ! if (intpart > LONG_MAX || -intpart > LONG_MAX) { /* Convert to long int and use its hash... */ PyObject *w = PyLong_FromDouble(v->cval.real); *************** *** 315,325 **** } else { ! fractpart = frexp(fractpart, &expo); ! fractpart = fractpart * 2147483648.0; /* 2**31 */ ! hipart = (long)fractpart; /* Take the top 32 bits */ ! fractpart = (fractpart - (double)hipart) * 2147483648.0; ! /* Get the next 32 bits */ ! x = hipart + (long)fractpart + (long)intpart + (expo << 15); ! /* Combine everything */ if (v->cval.imag != 0.0) { /* Hash the imaginary part */ --- 314,320 ---- } else { ! x = _Py_HashDouble(v->cval.real); ! if (x == -1) ! return -1; if (v->cval.imag != 0.0) { /* Hash the imaginary part */ *************** *** 327,348 **** to the same value as complex(y, x). Still better than it used to be :-) */ ! #ifdef MPW ! { ! extended e; ! fractpart = modf(v->cval.imag, &e); ! intpart = e; ! } ! #else ! fractpart = modf(v->cval.imag, &intpart); ! #endif ! fractpart = frexp(fractpart, &expo); ! fractpart = fractpart * 2147483648.0; /* 2**31 */ ! hipart = (long)fractpart; /* Take the top 32 bits */ ! fractpart = ! (fractpart - (double)hipart) * 2147483648.0; ! /* Get the next 32 bits */ ! x ^= hipart + (long)fractpart + ! (long)intpart + (expo << 15); ! /* Combine everything */ } } --- 322,329 ---- to the same value as complex(y, x). Still better than it used to be :-) */ ! long y = _Py_HashDouble(v->cval.imag); ! if (y == -1) ! return -1; ! x += y; } } Index: classobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v retrieving revision 2.91 retrieving revision 2.92 diff -C2 -r2.91 -r2.92 *** classobject.c 2000/06/28 23:46:07 2.91 --- classobject.c 2000/06/29 19:17:04 2.92 *************** *** 865,872 **** if (func == NULL) { PyErr_Clear(); ! outcome = (long)inst; ! if (outcome == -1) ! outcome = -2; ! return outcome; } PyErr_SetString(PyExc_TypeError, "unhashable instance"); --- 865,869 ---- if (func == NULL) { PyErr_Clear(); ! return _Py_HashPointer(inst); } PyErr_SetString(PyExc_TypeError, "unhashable instance"); Index: funcobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/funcobject.c,v retrieving revision 2.22 retrieving revision 2.23 diff -C2 -r2.22 -r2.23 *** funcobject.c 2000/06/23 19:37:01 2.22 --- funcobject.c 2000/06/29 19:17:04 2.23 *************** *** 232,239 **** PyFunctionObject *f; { ! long h; h = PyObject_Hash(f->func_code); if (h == -1) return h; ! h = h ^ (long)f->func_globals; if (h == -1) h = -2; return h; --- 232,241 ---- PyFunctionObject *f; { ! long h,x; h = PyObject_Hash(f->func_code); if (h == -1) return h; ! x = _Py_HashPointer(f->func_globals); ! if (x == -1) return x; ! h ^= x; if (h == -1) h = -2; return h; From python-dev@python.org Thu Jun 29 20:24:40 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:24:40 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml - New directory Message-ID: <200006291924.MAA04382@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/xml In directory slayer.i.sourceforge.net:/tmp/cvs-serv4375/xml Log Message: Directory /cvsroot/python/python/dist/src/Lib/xml added to the repository From python-dev@python.org Thu Jun 29 20:25:55 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:25:55 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml __init__.py,NONE,1.1 Message-ID: <200006291925.MAA04456@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/xml In directory slayer.i.sourceforge.net:/tmp/cvs-serv4450 Added Files: __init__.py Log Message: Package docstring. --- NEW FILE --- """Core XML support for Python. This package contains three sub-packages: dom -- The W3C Document Object Model. This supports DOM Level 1 + Namespaces. parser -- Python wrappers for XML parsers (currently only supports Expat). sax -- The Simple API for XML, developed by XML-Dev, led by David Megginson. This supports the SAX 2 API. """ From python-dev@python.org Thu Jun 29 20:26:16 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:26:16 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/dom - New directory Message-ID: <200006291926.MAA04481@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/xml/dom In directory slayer.i.sourceforge.net:/tmp/cvs-serv4470/dom Log Message: Directory /cvsroot/python/python/dist/src/Lib/xml/dom added to the repository From python-dev@python.org Thu Jun 29 20:26:16 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:26:16 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/sax - New directory Message-ID: <200006291926.MAA04484@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/xml/sax In directory slayer.i.sourceforge.net:/tmp/cvs-serv4470/sax Log Message: Directory /cvsroot/python/python/dist/src/Lib/xml/sax added to the repository From python-dev@python.org Thu Jun 29 20:28:06 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:28:06 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/dom __init__.py,NONE,1.1 Message-ID: <200006291928.MAA04613@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/xml/dom In directory slayer.i.sourceforge.net:/tmp/cvs-serv4606 Added Files: __init__.py Log Message: Package docstring. --- NEW FILE --- """W3C Document Object Model implementation for Python. The Python mapping of the Document Object Model is documented in <...>. This package contains the following modules: minidom -- A simple implementation of the Level 1 DOM with namespace support added (based on the Level 2 specification). """ From python-dev@python.org Thu Jun 29 20:33:45 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:33:45 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/sax __init__.py,NONE,1.1 Message-ID: <200006291933.MAA05055@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/xml/sax In directory slayer.i.sourceforge.net:/tmp/cvs-serv5045 Added Files: __init__.py Log Message: Package docstring and initialization. --- NEW FILE --- """Simple API for XML (SAX) implementation for Python. This module provides an implementation of the SAX 2 interface; information about the Java version of the interface can be found at http://www.megginson.com/SAX/. The Python version of the interface is documented at <...>. This package contains the following modules: saxutils -- Implementation of the convenience functions normally used to work with SAX. saxlib -- Implementation of the shared SAX 2 classes. drv_pyexpat -- Driver that allows use of the Expat parser with the classes defined in saxlib. """ from handler import * from expatreader import * from _exceptions import * from saxutils import * from _exceptions import SAXParseException import xmlreader From python-dev@python.org Thu Jun 29 20:34:56 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:34:56 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/sax _exceptions.py,NONE,1.1 expatreader.py,NONE,1.1 handler.py,NONE,1.1 saxutils.py,NONE,1.1 xmlreader.py,NONE,1.1 Message-ID: <200006291934.MAA05146@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/xml/sax In directory slayer.i.sourceforge.net:/tmp/cvs-serv5139 Added Files: _exceptions.py expatreader.py handler.py saxutils.py xmlreader.py Log Message: Paul Prescod : SAX interfaces for Python. --- NEW FILE --- """Different kinds of SAX Exceptions""" import sys if sys.platform[:4] == "java": from java.lang import Exception # ===== SAXEXCEPTION ===== class SAXException(Exception): """Encapsulate an XML error or warning. This class can contain basic error or warning information from either the XML parser or the application: you can subclass it to provide additional functionality, or to add localization. Note that although you will receive a SAXException as the argument to the handlers in the ErrorHandler interface, you are not actually required to throw the exception; instead, you can simply read the information in it.""" def __init__(self, msg, exception = None): """Creates an exception. The message is required, but the exception is optional.""" self._msg = msg self._exception = exception def getMessage(self): "Return a message for this exception." return self._msg def getException(self): "Return the embedded exception, or None if there was none." return self._exception def __str__(self): "Create a string representation of the exception." return self._msg def __getitem__(self, ix): """Avoids weird error messages if someone does exception[ix] by mistake, since Exception has __getitem__ defined.""" raise NameError("__getitem__") # ===== SAXPARSEEXCEPTION ===== class SAXParseException(SAXException): """Encapsulate an XML parse error or warning. This exception will include information for locating the error in the original XML document. Note that although the application will receive a SAXParseException as the argument to the handlers in the ErrorHandler interface, the application is not actually required to throw the exception; instead, it can simply read the information in it and take a different action. Since this exception is a subclass of SAXException, it inherits the ability to wrap another exception.""" def __init__(self, msg, exception, locator): "Creates the exception. The exception parameter is allowed to be None." SAXException.__init__(self, msg, exception) self._locator = locator def getColumnNumber(self): """The column number of the end of the text where the exception occurred.""" return self._locator.getColumnNumber() def getLineNumber(self): "The line number of the end of the text where the exception occurred." return self._locator.getLineNumber() def getPublicId(self): "Get the public identifier of the entity where the exception occurred." return self._locator.getPublicId() def getSystemId(self): "Get the system identifier of the entity where the exception occurred." return self._locator.getSystemId() def __str__(self): "Create a string representation of the exception." return "%s at %s:%d:%d" % (self._msg, self.getSystemId(), self.getLineNumber(), self.getColumnNumber()) # ===== SAXNOTRECOGNIZEDEXCEPTION ===== class SAXNotRecognizedException(SAXException): """Exception class for an unrecognized identifier. An XMLReader will raise this exception when it is confronted with an unrecognized feature or property. SAX applications and extensions may use this class for similar purposes.""" # ===== SAXNOTSUPPORTEDEXCEPTION ===== class SAXNotSupportedException(SAXException): """Exception class for an unsupported operation. An XMLReader will raise this exception when a service it cannot perform is requested (specifically setting a state or value). SAX applications and extensions may use this class for similar purposes.""" ***** Error reading new file(2, 'No such file or directory') ***** Error reading new file(2, 'No such file or directory') ***** Error reading new file(2, 'No such file or directory') --- NEW FILE --- import handler """An XML Reader is the SAX 2 name for an XML parser. XML Parsers should be based on this code. """ # ===== XMLREADER ===== class XMLReader: def __init__(self): self._cont_handler = handler.ContentHandler() #self._dtd_handler = handler.DTDHandler() #self._ent_handler = handler.EntityResolver() self._err_handler = handler.ErrorHandler() def parse(self, source): "Parse an XML document from a system identifier or an InputSource." raise NotImplementedError("This method must be implemented!") def getContentHandler(self): "Returns the current ContentHandler." return self._cont_handler def setContentHandler(self, handler): "Registers a new object to receive document content events." self._cont_handler = handler def getDTDHandler(self): "Returns the current DTD handler." return self._dtd_handler def setDTDHandler(self, handler): "Register an object to receive basic DTD-related events." self._dtd_handler = handler def getEntityResolver(self): "Returns the current EntityResolver." return self._ent_handler def setEntityResolver(self, resolver): "Register an object to resolve external entities." self._ent_handler = resolver def getErrorHandler(self): "Returns the current ErrorHandler." return self._err_handler def setErrorHandler(self, handler): "Register an object to receive error-message events." self._err_handler = handler def setLocale(self, locale): """Allow an application to set the locale for errors and warnings. SAX parsers are not required to provide localisation for errors and warnings; if they cannot support the requested locale, however, they must throw a SAX exception. Applications may request a locale change in the middle of a parse.""" raise SAXNotSupportedException("Locale support not implemented") def getFeature(self, name): "Looks up and returns the state of a SAX2 feature." raise SAXNotRecognizedException("Feature '%s' not recognized" % name) def setFeature(self, name, state): "Sets the state of a SAX2 feature." raise SAXNotRecognizedException("Feature '%s' not recognized" % name) def getProperty(self, name): "Looks up and returns the value of a SAX2 property." raise SAXNotRecognizedException("Property '%s' not recognized" % name) def setProperty(self, name, value): "Sets the value of a SAX2 property." raise SAXNotRecognizedException("Property '%s' not recognized" % name) class IncrementalParser(XMLReader): """This interface adds three extra methods to the XMLReader interface that allow XML parsers to support incremental parsing. Support for this interface is optional, since not all underlying XML parsers support this functionality. When the parser is instantiated it is ready to begin accepting data from the feed method immediately. After parsing has been finished with a call to close the reset method must be called to make the parser ready to accept new data, either from feed or using the parse method. Note that these methods must _not_ be called during parsing, that is, after parse has been called and before it returns. By default, the class also implements the parse method of the XMLReader interface using the feed, close and reset methods of the IncrementalParser interface as a convenience to SAX 2.0 driver writers.""" def __init__(self, bufsize=2**16 ): self._bufsize=bufsize XMLReader.__init__( self ) def parse(self, source): self.prepareParser(source) #FIXME: do some type checking: could be already stream, URL or # filename inf=open( source ) buffer = inf.read(self._bufsize) while buffer != "": self.feed(buffer) buffer = inf.read(self._bufsize) self.close() self.reset() def feed(self, data): """This method gives the raw XML data in the data parameter to the parser and makes it parse the data, emitting the corresponding events. It is allowed for XML constructs to be split across several calls to feed. feed may raise SAXException.""" raise NotImplementedError("This method must be implemented!") def prepareParser(self, source): """This method is called by the parse implementation to allow the SAX 2.0 driver to prepare itself for parsing.""" raise NotImplementedError("prepareParser must be overridden!") def close(self): """This method is called when the entire XML document has been passed to the parser through the feed method, to notify the parser that there are no more data. This allows the parser to do the final checks on the document and empty the internal data buffer. The parser will not be ready to parse another document until the reset method has been called. close may raise SAXException.""" raise NotImplementedError("This method must be implemented!") def reset(self): """This method is called after close has been called to reset the parser so that it is ready to parse new documents. The results of calling parse or feed after close without calling reset are undefined.""" raise NotImplementedError("This method must be implemented!") # ===== LOCATOR ===== class Locator: """Interface for associating a SAX event with a document location. A locator object will return valid results only during calls to DocumentHandler methods; at any other time, the results are unpredictable.""" def getColumnNumber(self): "Return the column number where the current event ends." return -1 def getLineNumber(self): "Return the line number where the current event ends." return -1 def getPublicId(self): "Return the public identifier for the current event." return None def getSystemId(self): "Return the system identifier for the current event." return None # --- AttributesImpl class AttributesImpl: def __init__(self, attrs, rawnames): self._attrs = attrs self._rawnames = rawnames def getLength(self): return len(self._attrs) def getType(self, name): return "CDATA" def getValue(self, name): return self._attrs[name] def getValueByQName(self, name): return self._attrs[self._rawnames[name]] def getNameByQName(self, name): return self._rawnames[name] def getNames(self): return self._attrs.keys() def getQNames(self): return self._rawnames.keys() def __len__(self): return len(self._attrs) def __getitem__(self, name): return self._attrs[name] def keys(self): return self._attrs.keys() def has_key(self, name): return self._attrs.has_key(name) def get(self, name, alternative=None): return self._attrs.get(name, alternative) def copy(self): return self.__class__(self._attrs, self._rawnames) def items(self): return self._attrs.items() def values(self): return self._attrs.values() def _test(): XMLReader() IncrementalParser() Locator() AttributesImpl() if __name__=="__main__": _test() From python-dev@python.org Thu Jun 29 20:35:32 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 29 Jun 2000 12:35:32 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/dos-8x3 test_ate.py,NONE,1.1 test_lin.py,NONE,1.1 basehttp.py,1.5,1.6 configpa.py,1.6,1.7 nturl2pa.py,1.4,1.5 reconver.py,1.2,1.3 rlcomple.py,1.5,1.6 simpleht.py,1.5,1.6 socketse.py,1.9,1.10 sre_comp.py,1.1,1.2 sre_cons.py,1.1,1.2 sre_pars.py,1.1,1.2 test_arr.py,1.6,1.7 test_bin.py,1.3,1.4 test_exc.py,1.3,1.4 test_mat.py,1.2,1.3 test_mma.py,1.1,1.2 test_ope.py,1.3,1.4 test_pye.py,1.1,1.2 test_soc.py,1.6,1.7 test_str.py,1.8,1.9 test_tim.py,1.5,1.6 test_uni.py,1.1,1.2 test_use.py,1.1,1.2 test_win.py,1.2,1.3 test_zli.py,1.5,1.6 threadin.py,1.2,1.3 Message-ID: <200006291935.MAA05215@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/dos-8x3 In directory slayer.i.sourceforge.net:/tmp/cvs-serv5180 Modified Files: basehttp.py configpa.py nturl2pa.py reconver.py rlcomple.py simpleht.py socketse.py sre_comp.py sre_cons.py sre_pars.py test_arr.py test_bin.py test_exc.py test_mat.py test_mma.py test_ope.py test_pye.py test_soc.py test_str.py test_tim.py test_uni.py test_use.py test_win.py test_zli.py threadin.py Added Files: test_ate.py test_lin.py Log Message: The usual :) --- NEW FILE --- # Test the exit module from test_support import verbose import atexit def handler1(): print "handler1" def handler2(*args, **kargs): print "handler2", args, kargs # save any exit functions that may have been registered as part of the # test framework _exithandlers = atexit._exithandlers atexit._exithandlers = [] atexit.register(handler1) atexit.register(handler2) atexit.register(handler2, 7, kw="abc") # simulate exit behavior by calling atexit._run_exitfuncs directly... atexit._run_exitfuncs() # restore exit handlers atexit._exithandlers = _exithandlers --- NEW FILE --- from test_support import verbose, findfile, TestFailed import linuxaudiodev import os def play_sound_file(path): fp = open(path, 'r') data = fp.read() fp.close() try: a = linuxaudiodev.open('w') except linuxaudiodev.error, msg: raise TestFailed, msg else: a.write(data) a.close() def test(): play_sound_file(findfile('audiotest.au')) test() Index: basehttp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/basehttp.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** basehttp.py 2000/05/08 17:30:59 1.5 --- basehttp.py 2000/06/29 19:35:29 1.6 *************** *** 88,91 **** --- 88,93 ---- class HTTPServer(SocketServer.TCPServer): + allow_reuse_address = 1 # Seems to make sense in testing environment + def server_bind(self): """Override server_bind to store the server name.""" Index: configpa.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/configpa.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** configpa.py 2000/05/08 17:30:59 1.6 --- configpa.py 2000/06/29 19:35:29 1.7 *************** *** 198,202 **** filename may also be given. """ ! if type(filenames) is type(''): filenames = [filenames] for filename in filenames: --- 198,202 ---- filename may also be given. """ ! if type(filenames) in [type(''), type(u'')]: filenames = [filenames] for filename in filenames: Index: nturl2pa.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/nturl2pa.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** nturl2pa.py 2000/05/08 17:31:00 1.4 --- nturl2pa.py 2000/06/29 19:35:29 1.5 *************** *** 2,6 **** def url2pathname(url): ! """ Convert a URL to a DOS path... ///C|/foo/bar/spam.foo --- 2,7 ---- def url2pathname(url): ! r"""Convert a URL to a DOS path. ! ///C|/foo/bar/spam.foo *************** *** 33,37 **** def pathname2url(p): ! """ Convert a DOS path name to a file url... C:\foo\bar\spam.foo --- 34,39 ---- def pathname2url(p): ! r"""Convert a DOS path name to a file url. ! C:\foo\bar\spam.foo Index: reconver.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/reconver.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** reconver.py 1998/03/26 22:13:26 1.2 --- reconver.py 2000/06/29 19:35:29 1.3 *************** *** 1,5 **** #! /usr/bin/env python1.5 ! """Convert old ("regex") regular expressions to new syntax ("re"). When imported as a module, there are two functions, with their own --- 1,5 ---- #! /usr/bin/env python1.5 ! r"""Convert old ("regex") regular expressions to new syntax ("re"). When imported as a module, there are two functions, with their own Index: rlcomple.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/rlcomple.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** rlcomple.py 2000/05/08 17:31:01 1.5 --- rlcomple.py 2000/06/29 19:35:29 1.6 *************** *** 77,81 **** __main__.__dict__.keys()]: for word in list: ! if word[:n] == text: matches.append(word) return matches --- 77,81 ---- __main__.__dict__.keys()]: for word in list: ! if word[:n] == text and word != "__builtins__": matches.append(word) return matches *************** *** 107,111 **** n = len(attr) for word in words: ! if word[:n] == attr: matches.append("%s.%s" % (expr, word)) return matches --- 107,111 ---- n = len(attr) for word in words: ! if word[:n] == attr and word != "__builtins__": matches.append("%s.%s" % (expr, word)) return matches Index: simpleht.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/simpleht.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** simpleht.py 2000/05/08 17:31:01 1.5 --- simpleht.py 2000/06/29 19:35:29 1.6 *************** *** 7,11 **** ! __version__ = "0.3" --- 7,11 ---- ! __version__ = "0.4" *************** *** 15,18 **** --- 15,20 ---- import BaseHTTPServer import urllib + import cgi + from StringIO import StringIO *************** *** 58,71 **** """ path = self.translate_path(self.path) if os.path.isdir(path): ! self.send_error(403, "Directory listing not supported") ! return None try: ! f = open(path, 'rb') except IOError: self.send_error(404, "File not found") return None self.send_response(200) ! self.send_header("Content-type", self.guess_type(path)) self.end_headers() return f --- 60,119 ---- """ path = self.translate_path(self.path) + f = None if os.path.isdir(path): ! for index in "index.html", "index.htm": ! index = os.path.join(path, index) ! if os.path.exists(index): ! path = index ! break ! else: ! return self.list_directory(path) ! ctype = self.guess_type(path) ! if ctype.startswith('text/'): ! mode = 'r' ! else: ! mode = 'rb' try: ! f = open(path, mode) except IOError: self.send_error(404, "File not found") return None + self.send_response(200) + self.send_header("Content-type", ctype) + self.end_headers() + return f + + def list_directory(self, path): + """Helper to produce a directory listing (absent index.html). + + Return value is either a file object, or None (indicating an + error). In either case, the headers are sent, making the + interface the same as for send_head(). + + """ + try: + list = os.listdir(path) + except os.error: + self.send_error(404, "No permission to list directory"); + return None + list.sort(lambda a, b: cmp(a.lower(), b.lower())) + f = StringIO() + f.write("

Directory listing for %s

\n" % self.path) + f.write("
\n
    \n") + for name in list: + fullname = os.path.join(path, name) + displayname = linkname = name = cgi.escape(name) + # Append / for directories or @ for symbolic links + if os.path.isdir(fullname): + displayname = name + "/" + linkname = name + os.sep + if os.path.islink(fullname): + displayname = name + "@" + # Note: a link to a directory displays with @ and links with / + f.write('
  • %s\n' % (linkname, displayname)) + f.write("
\n
\n") + f.seek(0) self.send_response(200) ! self.send_header("Content-type", "text/html") self.end_headers() return f Index: socketse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/socketse.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** socketse.py 2000/05/08 17:31:01 1.9 --- socketse.py 2000/06/29 19:35:29 1.10 *************** *** 142,145 **** --- 142,146 ---- - socket_type - request_queue_size (only for stream sockets) + - reuse_address Instance variables: *************** *** 157,160 **** --- 158,163 ---- request_queue_size = 5 + allow_reuse_address = 0 + def __init__(self, server_address, RequestHandlerClass): """Constructor. May be extended, do not override.""" *************** *** 172,175 **** --- 175,180 ---- """ + if self.allow_reuse_address: + self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self.socket.bind(self.server_address) Index: sre_comp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/sre_comp.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** sre_comp.py 2000/05/08 17:31:01 1.1 --- sre_comp.py 2000/06/29 19:35:29 1.2 *************** *** 1,5 **** # # Secret Labs' Regular Expression Engine - # $Id$ # # convert template to internal format --- 1,4 ---- *************** *** 7,23 **** # Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. # - # This code can only be used for 1.6 alpha testing. All other use - # require explicit permission from Secret Labs AB. - # # Portions of this engine have been developed in cooperation with # CNRI. Hewlett-Packard provided funding for 1.6 integration and # other compatibility work. # - - # FIXME: formalize (objectify?) and document the compiler code - # format, so that other frontends can use this compiler - - import array, string, sys import _sre --- 6,15 ---- # Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. # # Portions of this engine have been developed in cooperation with # CNRI. Hewlett-Packard provided funding for 1.6 integration and # other compatibility work. # + import array import _sre *************** *** 31,168 **** raise RuntimeError, "cannot find a useable array type" - # FIXME: should move some optimizations from the parser to here! - - class Code: - def __init__(self): - self.data = [] - def __len__(self): - return len(self.data) - def __getitem__(self, index): - return self.data[index] - def __setitem__(self, index, code): - self.data[index] = code - def append(self, code): - self.data.append(code) - def todata(self): - # print self.data - return array.array(WORDSIZE, self.data).tostring() - - def _lower(literal): - # return _sre._lower(literal) # FIXME - return string.lower(literal) - def _compile(code, pattern, flags): ! append = code.append for op, av in pattern: if op is ANY: ! if "s" in flags: ! append(CODES[op]) # any character at all! else: ! append(CODES[NOT_LITERAL]) ! append(10) elif op in (SUCCESS, FAILURE): ! append(CODES[op]) elif op is AT: ! append(CODES[op]) ! append(POSITIONS[av]) elif op is BRANCH: ! append(CODES[op]) tail = [] for av in av[1]: ! skip = len(code); append(0) _compile(code, av, flags) ! append(CODES[JUMP]) ! tail.append(len(code)); append(0) code[skip] = len(code) - skip ! append(0) # end of branch ! for tail in tail: code[tail] = len(code) - tail elif op is CALL: ! append(CODES[op]) ! skip = len(code); append(0) _compile(code, av, flags) ! append(CODES[SUCCESS]) code[skip] = len(code) - skip ! elif op is CATEGORY: # not used by current parser ! append(CODES[op]) ! append(CATEGORIES[av]) elif op is GROUP: ! if "i" in flags: ! append(CODES[MAP_IGNORE[op]]) else: ! append(CODES[op]) ! append(av) elif op is IN: ! if "i" in flags: ! append(CODES[MAP_IGNORE[op]]) ! def fixup(literal): ! return ord(_lower(literal)) else: ! append(CODES[op]) fixup = ord ! skip = len(code); append(0) for op, av in av: ! append(CODES[op]) if op is NEGATE: pass elif op is LITERAL: ! append(fixup(av)) elif op is RANGE: ! append(fixup(av[0])) ! append(fixup(av[1])) elif op is CATEGORY: ! append(CATEGORIES[av]) else: ! raise ValueError, "unsupported set operator" ! append(CODES[FAILURE]) code[skip] = len(code) - skip elif op in (LITERAL, NOT_LITERAL): ! if "i" in flags: ! append(CODES[MAP_IGNORE[op]]) ! append(ord(_lower(av))) else: ! append(CODES[op]) ! append(ord(av)) elif op is MARK: ! append(CODES[op]) ! append(av) elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): ! lo, hi = av[2].getwidth() ! if lo == 0: ! raise SyntaxError, "cannot repeat zero-width items" ! if lo == hi == 1 and op is MAX_REPEAT: ! append(CODES[MAX_REPEAT_ONE]) ! skip = len(code); append(0) ! append(av[0]) ! append(av[1]) _compile(code, av[2], flags) ! append(CODES[SUCCESS]) code[skip] = len(code) - skip else: ! append(CODES[op]) ! skip = len(code); append(0) ! append(av[0]) ! append(av[1]) ! _compile(code, av[2], flags) ! if op is MIN_REPEAT: ! append(CODES[MIN_UNTIL]) else: ! # FIXME: MAX_REPEAT PROBABLY DOESN'T WORK (?) ! append(CODES[MAX_UNTIL]) ! code[skip] = len(code) - skip elif op is SUBPATTERN: ! ## group = av[0] ! ## if group: ! ## append(CODES[MARK]) ! ## append((group-1)*2) _compile(code, av[1], flags) ! ## if group: ! ## append(CODES[MARK]) ! ## append((group-1)*2+1) else: raise ValueError, ("unsupported operand type", op) ! def compile(p, flags=()): ! # convert pattern list to internal format if type(p) in (type(""), type(u"")): import sre_parse --- 23,158 ---- raise RuntimeError, "cannot find a useable array type" def _compile(code, pattern, flags): ! emit = code.append for op, av in pattern: if op is ANY: ! if flags & SRE_FLAG_DOTALL: ! emit(OPCODES[op]) else: ! emit(OPCODES[CATEGORY]) ! emit(CHCODES[CATEGORY_NOT_LINEBREAK]) elif op in (SUCCESS, FAILURE): ! emit(OPCODES[op]) elif op is AT: ! emit(OPCODES[op]) ! if flags & SRE_FLAG_MULTILINE: ! emit(ATCODES[AT_MULTILINE[av]]) ! else: ! emit(ATCODES[av]) elif op is BRANCH: ! emit(OPCODES[op]) tail = [] for av in av[1]: ! skip = len(code); emit(0) _compile(code, av, flags) ! emit(OPCODES[JUMP]) ! tail.append(len(code)); emit(0) code[skip] = len(code) - skip ! emit(0) # end of branch ! for tail in tail: code[tail] = len(code) - tail elif op is CALL: ! emit(OPCODES[op]) ! skip = len(code); emit(0) _compile(code, av, flags) ! emit(OPCODES[SUCCESS]) code[skip] = len(code) - skip ! elif op is CATEGORY: ! emit(OPCODES[op]) ! if flags & SRE_FLAG_LOCALE: ! emit(CH_LOCALE[CHCODES[av]]) ! elif flags & SRE_FLAG_UNICODE: ! emit(CH_UNICODE[CHCODES[av]]) ! else: ! emit(CHCODES[av]) elif op is GROUP: ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) else: ! emit(OPCODES[op]) ! emit(av-1) elif op is IN: ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) ! def fixup(literal, flags=flags): ! return _sre.getlower(ord(literal), flags) else: ! emit(OPCODES[op]) fixup = ord ! skip = len(code); emit(0) for op, av in av: ! emit(OPCODES[op]) if op is NEGATE: pass elif op is LITERAL: ! emit(fixup(av)) elif op is RANGE: ! emit(fixup(av[0])) ! emit(fixup(av[1])) elif op is CATEGORY: ! if flags & SRE_FLAG_LOCALE: ! emit(CH_LOCALE[CHCODES[av]]) ! elif flags & SRE_FLAG_UNICODE: ! emit(CH_UNICODE[CHCODES[av]]) ! else: ! emit(CHCODES[av]) else: ! raise error, "internal: unsupported set operator" ! emit(OPCODES[FAILURE]) code[skip] = len(code) - skip elif op in (LITERAL, NOT_LITERAL): ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) else: ! emit(OPCODES[op]) ! emit(ord(av)) elif op is MARK: ! emit(OPCODES[op]) ! emit(av) elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): ! if flags & SRE_FLAG_TEMPLATE: ! emit(OPCODES[REPEAT]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) code[skip] = len(code) - skip else: ! lo, hi = av[2].getwidth() ! if lo == 0: ! raise error, "nothing to repeat" ! if 0 and lo == hi == 1 and op is MAX_REPEAT: ! # FIXME: need a better way to figure out when ! # it's safe to use this one (in the parser, probably) ! emit(OPCODES[MAX_REPEAT_ONE]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) ! _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip else: ! emit(OPCODES[op]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) ! _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip elif op is SUBPATTERN: ! group = av[0] ! if group: ! emit(OPCODES[MARK]) ! emit((group-1)*2) _compile(code, av[1], flags) ! if group: ! emit(OPCODES[MARK]) ! emit((group-1)*2+1) else: raise ValueError, ("unsupported operand type", op) ! def compile(p, flags=0): ! # internal: convert pattern list to internal format if type(p) in (type(""), type(u"")): import sre_parse *************** *** 171,187 **** else: pattern = None ! # print p.getwidth() ! # print p ! code = Code() ! _compile(code, p.data, p.pattern.flags) ! code.append(CODES[SUCCESS]) ! # print list(code.data) ! data = code.todata() ! if 0: # debugging ! print ! print "-" * 68 ! import sre_disasm ! sre_disasm.disasm(data) ! print "-" * 68 ! # print len(data), p.pattern.groups, len(p.pattern.groupdict) ! return _sre.compile(pattern, data, p.pattern.groups-1, p.pattern.groupdict) --- 161,174 ---- else: pattern = None ! flags = p.pattern.flags | flags ! code = [] ! _compile(code, p.data, flags) ! code.append(OPCODES[SUCCESS]) ! # FIXME: get rid of this limitation ! assert p.pattern.groups <= 100,\ ! "sorry, but this version only supports 100 named groups" ! return _sre.compile( ! pattern, flags, ! array.array(WORDSIZE, code).tostring(), ! p.pattern.groups-1, p.pattern.groupdict ! ) Index: sre_cons.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/sre_cons.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** sre_cons.py 2000/05/08 17:31:01 1.1 --- sre_cons.py 2000/06/29 19:35:29 1.2 *************** *** 1,5 **** # # Secret Labs' Regular Expression Engine - # $Id$ # # various symbols used by the regular expression engine. --- 1,4 ---- *************** *** 8,14 **** # Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. # - # This code can only be used for 1.6 alpha testing. All other use - # require explicit permission from Secret Labs AB. - # # Portions of this engine have been developed in cooperation with # CNRI. Hewlett-Packard provided funding for 1.6 integration and --- 7,10 ---- *************** *** 16,19 **** --- 12,20 ---- # + # should this really be here? + + class error(Exception): + pass + # operators *************** *** 31,34 **** --- 32,36 ---- IN = "in" IN_IGNORE = "in_ignore" + INFO = "info" JUMP = "jump" LITERAL = "literal" *************** *** 37,43 **** MAX_REPEAT = "max_repeat" MAX_REPEAT_ONE = "max_repeat_one" - MAX_UNTIL = "max_until" MIN_REPEAT = "min_repeat" - MIN_UNTIL = "min_until" NEGATE = "negate" NOT_LITERAL = "not_literal" --- 39,43 ---- *************** *** 45,58 **** RANGE = "range" REPEAT = "repeat" SUBPATTERN = "subpattern" # positions AT_BEGINNING = "at_beginning" AT_BOUNDARY = "at_boundary" AT_NON_BOUNDARY = "at_non_boundary" AT_END = "at_end" # categories - CATEGORY_DIGIT = "category_digit" CATEGORY_NOT_DIGIT = "category_not_digit" --- 45,60 ---- RANGE = "range" REPEAT = "repeat" + REPEAT_ONE = "repeat_one" SUBPATTERN = "subpattern" # positions AT_BEGINNING = "at_beginning" + AT_BEGINNING_LINE = "at_beginning_line" AT_BOUNDARY = "at_boundary" AT_NON_BOUNDARY = "at_non_boundary" AT_END = "at_end" + AT_END_LINE = "at_end_line" # categories CATEGORY_DIGIT = "category_digit" CATEGORY_NOT_DIGIT = "category_not_digit" *************** *** 61,66 **** CATEGORY_WORD = "category_word" CATEGORY_NOT_WORD = "category_not_word" ! CODES = [ # failure=0 success=1 (just because it looks better that way :-) --- 63,80 ---- CATEGORY_WORD = "category_word" CATEGORY_NOT_WORD = "category_not_word" + CATEGORY_LINEBREAK = "category_linebreak" + CATEGORY_NOT_LINEBREAK = "category_not_linebreak" + CATEGORY_LOC_WORD = "category_loc_word" + CATEGORY_LOC_NOT_WORD = "category_loc_not_word" + CATEGORY_UNI_DIGIT = "category_uni_digit" + CATEGORY_UNI_NOT_DIGIT = "category_uni_not_digit" + CATEGORY_UNI_SPACE = "category_uni_space" + CATEGORY_UNI_NOT_SPACE = "category_uni_not_space" + CATEGORY_UNI_WORD = "category_uni_word" + CATEGORY_UNI_NOT_WORD = "category_uni_not_word" + CATEGORY_UNI_LINEBREAK = "category_uni_linebreak" + CATEGORY_UNI_NOT_LINEBREAK = "category_uni_not_linebreak" ! OPCODES = [ # failure=0 success=1 (just because it looks better that way :-) *************** *** 75,84 **** GROUP, GROUP_IGNORE, IN, IN_IGNORE, JUMP, LITERAL, LITERAL_IGNORE, MARK, ! MAX_REPEAT, MAX_UNTIL, MAX_REPEAT_ONE, ! MIN_REPEAT, MIN_UNTIL, NOT_LITERAL, NOT_LITERAL_IGNORE, NEGATE, --- 89,99 ---- GROUP, GROUP_IGNORE, IN, IN_IGNORE, + INFO, JUMP, LITERAL, LITERAL_IGNORE, MARK, ! MAX_REPEAT, MAX_REPEAT_ONE, ! MIN_REPEAT, NOT_LITERAL, NOT_LITERAL_IGNORE, NEGATE, *************** *** 88,101 **** ] ! # convert to dictionary ! c = {} ! i = 0 ! for code in CODES: ! c[code] = i ! i = i + 1 ! CODES = c # replacement operations for "ignore case" mode ! MAP_IGNORE = { GROUP: GROUP_IGNORE, IN: IN_IGNORE, --- 103,135 ---- ] ! ATCODES = [ ! AT_BEGINNING, AT_BEGINNING_LINE, AT_BOUNDARY, ! AT_NON_BOUNDARY, AT_END, AT_END_LINE ! ] + CHCODES = [ + CATEGORY_DIGIT, CATEGORY_NOT_DIGIT, CATEGORY_SPACE, + CATEGORY_NOT_SPACE, CATEGORY_WORD, CATEGORY_NOT_WORD, + CATEGORY_LINEBREAK, CATEGORY_NOT_LINEBREAK, CATEGORY_LOC_WORD, + CATEGORY_LOC_NOT_WORD, CATEGORY_UNI_DIGIT, CATEGORY_UNI_NOT_DIGIT, + CATEGORY_UNI_SPACE, CATEGORY_UNI_NOT_SPACE, CATEGORY_UNI_WORD, + CATEGORY_UNI_NOT_WORD, CATEGORY_UNI_LINEBREAK, + CATEGORY_UNI_NOT_LINEBREAK + ] + + def makedict(list): + d = {} + i = 0 + for item in list: + d[item] = i + i = i + 1 + return d + + OPCODES = makedict(OPCODES) + ATCODES = makedict(ATCODES) + CHCODES = makedict(CHCODES) + # replacement operations for "ignore case" mode ! OP_IGNORE = { GROUP: GROUP_IGNORE, IN: IN_IGNORE, *************** *** 104,131 **** } ! POSITIONS = { ! AT_BEGINNING: ord("a"), ! AT_BOUNDARY: ord("b"), ! AT_NON_BOUNDARY: ord("B"), ! AT_END: ord("z"), } ! CATEGORIES = { ! CATEGORY_DIGIT: ord("d"), ! CATEGORY_NOT_DIGIT: ord("D"), ! CATEGORY_SPACE: ord("s"), ! CATEGORY_NOT_SPACE: ord("S"), ! CATEGORY_WORD: ord("w"), ! CATEGORY_NOT_WORD: ord("W"), } if __name__ == "__main__": import string ! items = CODES.items() ! items.sort(lambda a, b: cmp(a[1], b[1])) f = open("sre_constants.h", "w") ! f.write("/* generated by sre_constants.py */\n") ! for k, v in items: ! f.write("#define SRE_OP_" + string.upper(k) + " " + str(v) + "\n") f.close() print "done" --- 138,196 ---- } ! AT_MULTILINE = { ! AT_BEGINNING: AT_BEGINNING_LINE, ! AT_END: AT_END_LINE } ! CH_LOCALE = { ! CATEGORY_DIGIT: CATEGORY_DIGIT, ! CATEGORY_NOT_DIGIT: CATEGORY_NOT_DIGIT, ! CATEGORY_SPACE: CATEGORY_SPACE, ! CATEGORY_NOT_SPACE: CATEGORY_NOT_SPACE, ! CATEGORY_WORD: CATEGORY_LOC_WORD, ! CATEGORY_NOT_WORD: CATEGORY_LOC_NOT_WORD, ! CATEGORY_LINEBREAK: CATEGORY_LINEBREAK, ! CATEGORY_NOT_LINEBREAK: CATEGORY_NOT_LINEBREAK } + CH_UNICODE = { + CATEGORY_DIGIT: CATEGORY_UNI_DIGIT, + CATEGORY_NOT_DIGIT: CATEGORY_UNI_NOT_DIGIT, + CATEGORY_SPACE: CATEGORY_UNI_SPACE, + CATEGORY_NOT_SPACE: CATEGORY_UNI_NOT_SPACE, + CATEGORY_WORD: CATEGORY_UNI_WORD, + CATEGORY_NOT_WORD: CATEGORY_UNI_NOT_WORD, + CATEGORY_LINEBREAK: CATEGORY_UNI_LINEBREAK, + CATEGORY_NOT_LINEBREAK: CATEGORY_UNI_NOT_LINEBREAK + } + + # flags + SRE_FLAG_TEMPLATE = 1 + SRE_FLAG_IGNORECASE = 2 + SRE_FLAG_LOCALE = 4 + SRE_FLAG_MULTILINE = 8 + SRE_FLAG_DOTALL = 16 + SRE_FLAG_UNICODE = 32 + SRE_FLAG_VERBOSE = 64 + if __name__ == "__main__": import string ! def dump(f, d, prefix): ! items = d.items() ! items.sort(lambda a, b: cmp(a[1], b[1])) ! for k, v in items: ! f.write("#define %s_%s %s\n" % (prefix, string.upper(k), v)) f = open("sre_constants.h", "w") ! f.write("/* generated from sre_constants.py */\n") ! dump(f, OPCODES, "SRE_OP") ! dump(f, ATCODES, "SRE") ! dump(f, CHCODES, "SRE") ! f.write("#define SRE_FLAG_TEMPLATE %d\n" % SRE_FLAG_TEMPLATE) ! f.write("#define SRE_FLAG_IGNORECASE %d\n" % SRE_FLAG_IGNORECASE) ! f.write("#define SRE_FLAG_LOCALE %d\n" % SRE_FLAG_LOCALE) ! f.write("#define SRE_FLAG_MULTILINE %d\n" % SRE_FLAG_MULTILINE) ! f.write("#define SRE_FLAG_DOTALL %d\n" % SRE_FLAG_DOTALL) ! f.write("#define SRE_FLAG_UNICODE %d\n" % SRE_FLAG_UNICODE) ! f.write("#define SRE_FLAG_VERBOSE %d\n" % SRE_FLAG_VERBOSE) f.close() print "done" Index: sre_pars.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/sre_pars.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** sre_pars.py 2000/05/08 17:31:01 1.1 --- sre_pars.py 2000/06/29 19:35:29 1.2 *************** *** 1,15 **** # # Secret Labs' Regular Expression Engine - # $Id$ # ! # convert re-style regular expression to SRE template. the current ! # implementation is somewhat incomplete, and not very fast. should ! # definitely be rewritten before Python 1.6 goes beta. # # Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. # - # This code can only be used for 1.6 alpha testing. All other use - # require explicit permission from Secret Labs AB. - # # Portions of this engine have been developed in cooperation with # CNRI. Hewlett-Packard provided funding for 1.6 integration and --- 1,9 ---- # # Secret Labs' Regular Expression Engine # ! # convert re-style regular expression to sre pattern # # Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. # # Portions of this engine have been developed in cooperation with # CNRI. Hewlett-Packard provided funding for 1.6 integration and *************** *** 17,31 **** # - # FIXME: comments marked with the FIXME tag are open issues. all such - # issues should be closed before the final beta. - import string, sys from sre_constants import * SPECIAL_CHARS = ".\\[{()*+?^$|" REPEAT_CHARS = "*+?{" - # FIXME: string in tuple tests may explode with if char is unicode :-( DIGITS = tuple(string.digits) --- 11,26 ---- # import string, sys + import _sre + from sre_constants import * + # FIXME: should be 65535, but the arraymodule is still broken + MAXREPEAT = 32767 + SPECIAL_CHARS = ".\\[{()*+?^$|" REPEAT_CHARS = "*+?{" DIGITS = tuple(string.digits) *************** *** 33,36 **** --- 28,33 ---- HEXDIGITS = tuple("0123456789abcdefABCDEF") + WHITESPACE = string.whitespace + ESCAPES = { "\\a": (LITERAL, chr(7)), *************** *** 55,63 **** "\\Z": (AT, AT_END), # end of string } ! class Pattern: ! # FIXME: rename class, and store flags in here too! def __init__(self): ! self.flags = [] self.groups = 1 self.groupdict = {} --- 52,71 ---- "\\Z": (AT, AT_END), # end of string } + + FLAGS = { + # standard flags + "i": SRE_FLAG_IGNORECASE, + "L": SRE_FLAG_LOCALE, + "m": SRE_FLAG_MULTILINE, + "s": SRE_FLAG_DOTALL, + "x": SRE_FLAG_VERBOSE, + # extensions + "t": SRE_FLAG_TEMPLATE, + "u": SRE_FLAG_UNICODE, + } ! class State: def __init__(self): ! self.flags = 0 self.groups = 1 self.groupdict = {} *************** *** 68,74 **** self.groupdict[name] = gid return gid - def setflag(self, flag): - if flag in self.flags: - self.flags.append(flag) class SubPattern: --- 76,79 ---- *************** *** 79,83 **** data = [] self.data = data - self.flags = [] self.width = None def __repr__(self): --- 84,87 ---- *************** *** 122,127 **** elif op in (MIN_REPEAT, MAX_REPEAT): i, j = av[2].getwidth() ! lo = lo + i * av[0] ! hi = hi + j * av[1] elif op in (ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY): lo = lo + 1 --- 126,131 ---- elif op in (MIN_REPEAT, MAX_REPEAT): i, j = av[2].getwidth() ! lo = lo + long(i) * av[0] ! hi = hi + long(j) * av[1] elif op in (ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY): lo = lo + 1 *************** *** 131,175 **** self.width = int(min(lo, sys.maxint)), int(min(hi, sys.maxint)) return self.width - def set(self, flag): - if not flag in self.flags: - self.flags.append(flag) - def reset(self, flag): - if flag in self.flags: - self.flags.remove(flag) class Tokenizer: def __init__(self, string): ! self.string = list(string) self.next = self.__next() def __next(self): ! if not self.string: return None ! char = self.string[0] if char[0] == "\\": try: ! c = self.string[1] except IndexError: ! raise SyntaxError, "bogus escape" char = char + c ! try: ! if c == "x": ! # hexadecimal constant ! for i in xrange(2, sys.maxint): ! c = self.string[i] ! if str(c) not in HEXDIGITS: ! break ! char = char + c ! elif str(c) in DIGITS: ! # decimal (or octal) number ! for i in xrange(2, sys.maxint): ! c = self.string[i] ! # FIXME: if larger than current number of ! # groups, interpret as an octal number ! if str(c) not in DIGITS: ! break ! char = char + c ! except IndexError: ! pass # use what we've got this far ! del self.string[0:len(char)] return char def match(self, char): --- 135,155 ---- self.width = int(min(lo, sys.maxint)), int(min(hi, sys.maxint)) return self.width class Tokenizer: def __init__(self, string): ! self.index = 0 ! self.string = string self.next = self.__next() def __next(self): ! if self.index >= len(self.string): return None ! char = self.string[self.index] if char[0] == "\\": try: ! c = self.string[self.index + 1] except IndexError: ! raise error, "bogus escape" char = char + c ! self.index = self.index + len(char) return char def match(self, char): *************** *** 188,230 **** return this ! def _fixescape(escape, character_class=0): ! # convert escape to (type, value) ! if character_class: ! # inside a character class, we'll look in the character ! # escapes dictionary first ! code = ESCAPES.get(escape) ! if code: ! return code ! code = CATEGORIES.get(escape) ! else: ! code = CATEGORIES.get(escape) ! if code: ! return code ! code = ESCAPES.get(escape) if code: return code ! if not character_class: ! try: ! group = int(escape[1:]) ! # FIXME: only valid if group <= current number of groups ! return GROUP, group ! except ValueError: ! pass try: if escape[1:2] == "x": escape = escape[2:] ! return LITERAL, chr(int(escape[-2:], 16) & 0xff) ! elif str(escape[1:2]) in DIGITS: ! return LITERAL, chr(int(escape[1:], 8) & 0xff) ! elif len(escape) == 2: return LITERAL, escape[1] except ValueError: pass ! raise SyntaxError, "bogus escape: %s" % repr(escape) ! def _branch(subpattern, items): ! # form a branch operator from a set of items (FIXME: move this ! # optimization to the compiler module!) # check if all items share a common prefix --- 168,268 ---- return this ! def isident(char): ! return "a" <= char <= "z" or "A" <= char <= "Z" or char == "_" ! ! def isdigit(char): ! return "0" <= char <= "9" ! ! def isname(name): ! # check that group name is a valid string ! # FIXME: this code is really lame. should use a regular ! # expression instead, but I seem to have certain bootstrapping ! # problems here ;-) ! if not isident(name[0]): ! return 0 ! for char in name: ! if not isident(char) and not isdigit(char): ! return 0 ! return 1 ! ! def _group(escape, state): ! # check if the escape string represents a valid group ! try: ! group = int(escape[1:]) ! if group and group < state.groups: ! return group ! except ValueError: ! pass ! return None # not a valid group ! ! def _class_escape(source, escape): ! # handle escape code inside character class ! code = ESCAPES.get(escape) if code: return code ! code = CATEGORIES.get(escape) ! if code: ! return code try: if escape[1:2] == "x": + while source.next in HEXDIGITS: + escape = escape + source.get() escape = escape[2:] ! # FIXME: support unicode characters! ! return LITERAL, chr(int(escape[-4:], 16) & 0xff) ! elif str(escape[1:2]) in OCTDIGITS: ! while source.next in OCTDIGITS: ! escape = escape + source.get() ! escape = escape[1:] ! # FIXME: support unicode characters! ! return LITERAL, chr(int(escape[-6:], 8) & 0xff) ! if len(escape) == 2: return LITERAL, escape[1] except ValueError: pass ! raise error, "bogus escape: %s" % repr(escape) ! def _escape(source, escape, state): ! # handle escape code in expression ! code = CATEGORIES.get(escape) ! if code: ! return code ! code = ESCAPES.get(escape) ! if code: ! return code ! try: ! if escape[1:2] == "x": ! while source.next in HEXDIGITS: ! escape = escape + source.get() ! escape = escape[2:] ! # FIXME: support unicode characters! ! return LITERAL, chr(int(escape[-4:], 16) & 0xff) ! elif escape[1:2] in DIGITS: ! while 1: ! group = _group(escape, state) ! if group: ! if (not source.next or ! not _group(escape + source.next, state)): ! return GROUP, group ! escape = escape + source.get() ! elif source.next in OCTDIGITS: ! escape = escape + source.get() ! else: ! break ! escape = escape[1:] ! # FIXME: support unicode characters! ! return LITERAL, chr(int(escape[-6:], 8) & 0xff) ! if len(escape) == 2: ! return LITERAL, escape[1] ! except ValueError: ! pass ! raise error, "bogus escape: %s" % repr(escape) ! ! def _branch(pattern, items): ! ! # form a branch operator from a set of items ! ! subpattern = SubPattern(pattern) # check if all items share a common prefix *************** *** 258,276 **** set.append(item[0]) subpattern.append((IN, set)) ! return subpattern.append((BRANCH, (None, items))) ! def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. - - subpattern = SubPattern(pattern) ! this = None while 1: ! if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() --- 296,313 ---- set.append(item[0]) subpattern.append((IN, set)) ! return subpattern subpattern.append((BRANCH, (None, items))) + return subpattern ! def _parse(source, state, flags=0): # parse regular expression pattern into an operator list. ! subpattern = SubPattern(state) while 1: ! if source.next in ("|", ")"): break # end of subpattern this = source.get() *************** *** 278,281 **** --- 315,329 ---- break # end of pattern + if state.flags & SRE_FLAG_VERBOSE: + # skip whitespace and comments + if this in WHITESPACE: + continue + if this == "#": + while 1: + this = source.get() + if this in (None, "\n"): + break + continue + if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) *************** *** 295,303 **** break elif this and this[0] == "\\": ! code1 = _fixescape(this, 1) elif this: code1 = LITERAL, this else: ! raise SyntaxError, "unexpected end of regular expression" if source.match("-"): # potential range --- 343,351 ---- break elif this and this[0] == "\\": ! code1 = _class_escape(source, this) elif this: code1 = LITERAL, this else: ! raise error, "unexpected end of regular expression" if source.match("-"): # potential range *************** *** 309,319 **** else: if this[0] == "\\": ! code2 = _fixescape(this, 1) else: code2 = LITERAL, this if code1[0] != LITERAL or code2[0] != LITERAL: ! raise SyntaxError, "illegal range" if len(code1[1]) != 1 or len(code2[1]) != 1: ! raise SyntaxError, "illegal range" set.append((RANGE, (code1[1], code2[1]))) else: --- 357,367 ---- else: if this[0] == "\\": ! code2 = _class_escape(source, this) else: code2 = LITERAL, this if code1[0] != LITERAL or code2[0] != LITERAL: ! raise error, "illegal range" if len(code1[1]) != 1 or len(code2[1]) != 1: ! raise error, "illegal range" set.append((RANGE, (code1[1], code2[1]))) else: *************** *** 322,326 **** set.append(code1) ! # FIXME: move set optimization to support function if len(set)==1 and set[0][0] is LITERAL: subpattern.append(set[0]) # optimization --- 370,374 ---- set.append(code1) ! # FIXME: move set optimization to compiler! if len(set)==1 and set[0][0] is LITERAL: subpattern.append(set[0]) # optimization *************** *** 336,354 **** min, max = 0, 1 elif this == "*": ! min, max = 0, sys.maxint elif this == "+": ! min, max = 1, sys.maxint elif this == "{": ! min, max = 0, sys.maxint lo = hi = "" ! while str(source.next) in DIGITS: lo = lo + source.get() if source.match(","): ! while str(source.next) in DIGITS: hi = hi + source.get() else: hi = lo if not source.match("}"): ! raise SyntaxError, "bogus range" if lo: min = int(lo) --- 384,402 ---- min, max = 0, 1 elif this == "*": ! min, max = 0, MAXREPEAT elif this == "+": ! min, max = 1, MAXREPEAT elif this == "{": ! min, max = 0, MAXREPEAT lo = hi = "" ! while source.next in DIGITS: lo = lo + source.get() if source.match(","): ! while source.next in DIGITS: hi = hi + source.get() else: hi = lo if not source.match("}"): ! raise error, "bogus range" if lo: min = int(lo) *************** *** 357,376 **** # FIXME: check that hi >= lo! else: ! raise SyntaxError, "not supported" # figure out which item to repeat - # FIXME: should back up to the right mark, right? if subpattern: ! index = len(subpattern)-1 ! while subpattern[index][0] is MARK: ! index = index - 1 ! item = subpattern[index:index+1] else: ! raise SyntaxError, "nothing to repeat" if source.match("?"): ! subpattern[index] = (MIN_REPEAT, (min, max, item)) else: ! subpattern[index] = (MAX_REPEAT, (min, max, item)) elif this == ".": subpattern.append((ANY, None)) elif this == "(": group = 1 --- 405,422 ---- # FIXME: check that hi >= lo! else: ! raise error, "not supported" # figure out which item to repeat if subpattern: ! item = subpattern[-1:] else: ! raise error, "nothing to repeat" if source.match("?"): ! subpattern[-1] = (MIN_REPEAT, (min, max, item)) else: ! subpattern[-1] = (MAX_REPEAT, (min, max, item)) ! elif this == ".": subpattern.append((ANY, None)) + elif this == "(": group = 1 *************** *** 380,405 **** # options if source.match("P"): ! # named group: skip forward to end of name if source.match("<"): name = "" while 1: char = source.get() ! if char is None or char == ">": break name = name + char group = 1 elif source.match(":"): # non-capturing group group = 2 ! elif source.match_set("iI"): ! pattern.setflag("i") ! elif source.match_set("lL"): ! pattern.setflag("l") ! elif source.match_set("mM"): ! pattern.setflag("m") ! elif source.match_set("sS"): ! pattern.setflag("s") ! elif source.match_set("xX"): ! pattern.setflag("x") if group: # parse group contents --- 426,464 ---- # options if source.match("P"): ! # python extensions if source.match("<"): + # named group: skip forward to end of name name = "" while 1: char = source.get() ! if char is None: ! raise error, "unterminated name" ! if char == ">": break name = name + char group = 1 + if not isname(name): + raise error, "illegal character in group name" + elif source.match("="): + # named backreference + raise error, "not yet implemented" + else: + char = source.get() + if char is None: + raise error, "unexpected end of pattern" + raise error, "unknown specifier: ?P%s" % char elif source.match(":"): # non-capturing group group = 2 ! elif source.match("#"): ! # comment ! while 1: ! if source.next is None or source.next == ")": ! break ! source.get() ! else: ! # flags ! while FLAGS.has_key(source.next): ! state.flags = state.flags | FLAGS[source.get()] if group: # parse group contents *************** *** 409,436 **** group = None else: ! group = pattern.getgroup(name) ! if group: ! subpattern.append((MARK, (group-1)*2)) while 1: ! p = _parse(source, pattern, flags) if source.match(")"): if b: b.append(p) ! _branch(subpattern, b) ! else: ! subpattern.append((SUBPATTERN, (group, p))) break elif source.match("|"): b.append(p) else: ! raise SyntaxError, "group not properly closed" ! if group: ! subpattern.append((MARK, (group-1)*2+1)) else: - # FIXME: should this really be a while loop? while 1: char = source.get() if char is None or char == ")": break elif this == "^": --- 468,490 ---- group = None else: ! group = state.getgroup(name) while 1: ! p = _parse(source, state, flags) if source.match(")"): if b: b.append(p) ! p = _branch(state, b) ! subpattern.append((SUBPATTERN, (group, p))) break elif source.match("|"): b.append(p) else: ! raise error, "group not properly closed" else: while 1: char = source.get() if char is None or char == ")": break + raise error, "unknown extension" elif this == "^": *************** *** 441,497 **** elif this and this[0] == "\\": ! code =_fixescape(this) subpattern.append(code) else: ! raise SyntaxError, "parser error" return subpattern ! def parse(source, flags=()): ! s = Tokenizer(source) ! g = Pattern() b = [] while 1: ! p = _parse(s, g, flags) ! tail = s.get() if tail == "|": b.append(p) elif tail == ")": ! raise SyntaxError, "unbalanced parenthesis" elif tail is None: if b: b.append(p) ! p = SubPattern(g) ! _branch(p, b) break else: ! raise SyntaxError, "bogus characters at end of regular expression" return p ! if __name__ == "__main__": ! from pprint import pprint ! from testpatterns import PATTERNS ! a = b = c = 0 ! for pattern, flags in PATTERNS: ! if flags: ! continue ! print "-"*68 ! try: ! p = parse(pattern) ! print repr(pattern), "->" ! pprint(p.data) ! import sre_compile ! try: ! code = sre_compile.compile(p) ! c = c + 1 ! except: ! pass ! a = a + 1 ! except SyntaxError, v: ! print "**", repr(pattern), v ! b = b + 1 ! print "-"*68 ! print a, "of", b, "patterns successfully parsed" ! print c, "of", b, "patterns successfully compiled" --- 495,586 ---- elif this and this[0] == "\\": ! code = _escape(source, this, state) subpattern.append(code) else: ! raise error, "parser error" return subpattern ! def parse(pattern, flags=0): ! # parse 're' pattern into list of (opcode, argument) tuples ! source = Tokenizer(pattern) ! state = State() b = [] while 1: ! p = _parse(source, state, flags) ! tail = source.get() if tail == "|": b.append(p) elif tail == ")": ! raise error, "unbalanced parenthesis" elif tail is None: if b: b.append(p) ! p = _branch(state, b) break else: ! raise error, "bogus characters at end of regular expression" return p ! def parse_template(source, pattern): ! # parse 're' replacement string into list of literals and ! # group references ! s = Tokenizer(source) ! p = [] ! a = p.append ! while 1: ! this = s.get() ! if this is None: ! break # end of replacement string ! if this and this[0] == "\\": ! if this == "\\g": ! name = "" ! if s.match("<"): ! while 1: ! char = s.get() ! if char is None: ! raise error, "unterminated group name" ! if char == ">": ! break ! name = name + char ! if not name: ! raise error, "bad group name" ! try: ! index = int(name) ! except ValueError: ! if not isname(name): ! raise error, "illegal character in group name" ! try: ! index = pattern.groupindex[name] ! except KeyError: ! raise IndexError, "unknown group name" ! a((MARK, index)) ! elif len(this) > 1 and this[1] in DIGITS: ! while s.next in DIGITS: ! this = this + s.get() ! a((MARK, int(this[1:]))) ! else: ! try: ! a(ESCAPES[this]) ! except KeyError: ! for char in this: ! a((LITERAL, char)) ! else: ! a((LITERAL, this)) ! return p + def expand_template(template, match): + # FIXME: this is sooooo slow. drop in the slicelist + # code instead + p = [] + a = p.append + for c, s in template: + if c is LITERAL: + a(s) + elif c is MARK: + s = match.group(s) + if s is None: + raise error, "empty group" + a(s) + return match.string[:0].join(p) Index: test_arr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/test_arr.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** test_arr.py 1998/08/12 02:38:01 1.6 --- test_arr.py 2000/06/29 19:35:29 1.7 *************** *** 16,19 **** --- 16,57 ---- + def testoverflow(type, lowerLimit, upperLimit): + # should not overflow assigning lower limit + if verbose: + print "overflow test: array(%s, [%s])" % (`type`, `lowerLimit`) + try: + a = array.array(type, [lowerLimit]) + except: + raise TestFailed, "array(%s) overflowed assigning %s" %\ + (`type`, `lowerLimit`) + # should overflow assigning less than lower limit + if verbose: + print "overflow test: array(%s, [%s])" % (`type`, `lowerLimit-1`) + try: + a = array.array(type, [lowerLimit-1]) + raise TestFailed, "array(%s) did not overflow assigning %s" %\ + (`type`, `lowerLimit-1`) + except OverflowError: + pass + # should not overflow assigning upper limit + if verbose: + print "overflow test: array(%s, [%s])" % (`type`, `upperLimit`) + try: + a = array.array(type, [upperLimit]) + except: + raise TestFailed, "array(%s) overflowed assigning %s" %\ + (`type`, `upperLimit`) + # should overflow assigning more than upper limit + if verbose: + print "overflow test: array(%s, [%s])" % (`type`, `upperLimit+1`) + try: + a = array.array(type, [upperLimit+1]) + raise TestFailed, "array(%s) did not overflow assigning %s" %\ + (`type`, `upperLimit+1`) + except OverflowError: + pass + + + def testtype(type, example): *************** *** 82,86 **** raise TestFailed, "array(%s) self-slice-assign (cntr)" % `type` ! main() ! --- 120,138 ---- raise TestFailed, "array(%s) self-slice-assign (cntr)" % `type` ! # test that overflow exceptions are raised as expected for assignment ! # to array of specific integral types ! from math import pow ! if type in ('b', 'h', 'i', 'l'): ! # check signed and unsigned versions ! a = array.array(type) ! signedLowerLimit = -1 * long(pow(2, a.itemsize * 8 - 1)) ! signedUpperLimit = long(pow(2, a.itemsize * 8 - 1)) - 1L ! unsignedLowerLimit = 0 ! unsignedUpperLimit = long(pow(2, a.itemsize * 8)) - 1L ! testoverflow(type, signedLowerLimit, signedUpperLimit) ! testoverflow(type.upper(), unsignedLowerLimit, unsignedUpperLimit) ! ! ! main() ! Index: test_bin.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/test_bin.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** test_bin.py 2000/05/08 17:31:02 1.3 --- test_bin.py 2000/06/29 19:35:29 1.4 *************** *** 1,93 **** ! """Test the binascii C module.""" from test_support import verbose - import binascii ! # Show module doc string ! print binascii.__doc__ ! # Show module exceptions ! print binascii.Error ! print binascii.Incomplete ! ! # Check presence and display doc strings of all functions ! funcs = [] ! for suffix in "base64", "hqx", "uu": ! prefixes = ["a2b_", "b2a_"] ! if suffix == "hqx": ! prefixes.extend(["crc_", "rlecode_", "rledecode_"]) ! for prefix in prefixes: ! name = prefix + suffix ! funcs.append(getattr(binascii, name)) ! for func in funcs: ! print "%-15s: %s" % (func.__name__, func.__doc__) ! ! # Create binary test data ! testdata = "The quick brown fox jumps over the lazy dog.\r\n" ! for i in range(256): ! # Be slow so we don't depend on other modules ! testdata = testdata + chr(i) ! testdata = testdata + "\r\nHello world.\n" ! ! # Test base64 with valid data ! print "base64 test" ! MAX_BASE64 = 57 ! lines = [] ! for i in range(0, len(testdata), MAX_BASE64): ! b = testdata[i:i+MAX_BASE64] ! a = binascii.b2a_base64(b) ! lines.append(a) ! print a, ! res = "" ! for line in lines: ! b = binascii.a2b_base64(line) ! res = res + b ! assert res == testdata ! ! # Test base64 with random invalid characters sprinkled throughout ! # (This requires a new version of binascii.) ! fillers = "" ! valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/" ! for i in range(256): ! c = chr(i) ! if c not in valid: ! fillers = fillers + c ! def addnoise(line): ! noise = fillers ! ratio = len(line) / len(noise) ! res = "" ! while line and noise: ! if len(line) / len(noise) > ratio: ! c, line = line[0], line[1:] ! else: ! c, noise = noise[0], noise[1:] ! res = res + c ! return res + noise + line ! res = "" ! for line in map(addnoise, lines): ! b = binascii.a2b_base64(line) ! res = res + b ! assert res == testdata ! ! # Test uu ! print "uu test" ! MAX_UU = 45 ! lines = [] ! for i in range(0, len(testdata), MAX_UU): ! b = testdata[i:i+MAX_UU] ! a = binascii.b2a_uu(b) ! lines.append(a) ! print a, ! res = "" ! for line in lines: ! b = binascii.a2b_uu(line) ! res = res + b ! assert res == testdata ! ! # Test crc32() ! crc = binascii.crc32("Test the CRC-32 of") ! crc = binascii.crc32(" this string.", crc) ! if crc != 1571220330: ! print "binascii.crc32() failed." ! ! # The hqx test is in test_binhex.py --- 1,46 ---- ! #! /usr/bin/env python ! """Test script for the binhex C module + Uses the mechanism of the python binhex module + Roger E. Masse + """ + import binhex + import tempfile from test_support import verbose ! def test(): ! try: ! fname1 = tempfile.mktemp() ! fname2 = tempfile.mktemp() ! f = open(fname1, 'w') ! except: ! raise ImportError, "Cannot test binhex without a temp file" ! ! start = 'Jack is my hero' ! f.write(start) ! f.close() ! ! binhex.binhex(fname1, fname2) ! if verbose: ! print 'binhex' ! ! binhex.hexbin(fname2, fname1) ! if verbose: ! print 'hexbin' ! ! f = open(fname1, 'r') ! finish = f.readline() ! ! if start <> finish: ! print 'Error: binhex <> hexbin' ! elif verbose: ! print 'binhex == hexbin' ! ! try: ! import os ! os.unlink(fname1) ! os.unlink(fname2) ! except: ! pass ! test() Index: test_exc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/test_exc.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** test_exc.py 1998/03/26 22:13:49 1.3 --- test_exc.py 2000/06/29 19:35:29 1.4 *************** *** 7,11 **** --- 7,23 ---- # XXX This is not really enough, each *operation* should be tested! + def test_raise_catch(exc): + try: + raise exc, "spam" + except exc, err: + buf = str(err) + try: + raise exc("spam") + except exc, err: + buf = str(err) + print buf + def r(thing): + test_raise_catch(thing) if type(thing) == ClassType: print thing.__name__ *************** *** 94,97 **** --- 106,113 ---- try: x = 1/0 except ZeroDivisionError: pass + + r(Exception) + try: x = 1/0 + except Exception, e: pass unlink(TESTFN) Index: test_mat.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/test_mat.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** test_mat.py 1996/09/11 19:07:43 1.2 --- test_mat.py 2000/06/29 19:35:29 1.3 *************** *** 130,133 **** --- 130,145 ---- testit('pow(2,-1)', math.pow(2,-1), 0.5) + print 'rint' + try: + math.rint + except AttributeError: + # this platform does not have rint, that is fine, skip the test + pass + else: + testit('rint(0.7)', math.rint(0.7), 1) + testit('rint(-0.3)', math.rint(-0.3), 0) + testit('rint(2.5)', math.rint(2.5), 2) + testit('rint(3.5)', math.rint(3.5), 4) + print 'sin' testit('sin(0)', math.sin(0), 0) Index: test_mma.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/test_mma.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** test_mma.py 2000/05/08 17:31:03 1.1 --- test_mma.py 2000/06/29 19:35:29 1.2 *************** *** 59,63 **** assert start == PAGESIZE assert end == PAGESIZE + 6 ! m.close() os.unlink("foo") --- 59,98 ---- assert start == PAGESIZE assert end == PAGESIZE + 6 ! ! # test seeking around (try to overflow the seek implementation) ! m.seek(0,0) ! print ' Seek to zeroth byte' ! assert m.tell() == 0 ! m.seek(42,1) ! print ' Seek to 42nd byte' ! assert m.tell() == 42 ! m.seek(0,2) ! print ' Seek to last byte' ! assert m.tell() == len(m) ! ! print ' Try to seek to negative position...' ! try: ! m.seek(-1) ! except ValueError: ! pass ! else: ! assert 0, 'expected a ValueError but did not get it' ! ! print ' Try to seek beyond end of mmap...' ! try: ! m.seek(1,2) ! except ValueError: ! pass ! else: ! assert 0, 'expected a ValueError but did not get it' ! ! print ' Try to seek to negative position...' ! try: ! m.seek(-len(m)-1,2) ! except ValueError: ! pass ! else: ! assert 0, 'expected a ValueError but did not get it' ! m.close() os.unlink("foo") Index: test_ope.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/test_ope.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** test_ope.py 1997/05/22 20:47:55 1.3 --- test_ope.py 2000/06/29 19:35:29 1.4 *************** *** 1,5 **** ! # Python test set -- part 3, built-in operations. ! print '3. Operations' ! print 'XXX Not yet implemented' --- 1,77 ---- ! import operator ! import sys + def test(name, input, output, *args): + print 'testing:', name + f = getattr(operator, name) + params = (input,) + args + try: + val = apply(f, params) + except: + val = sys.exc_type + if val <> output: + print '%s%s = %s: %s expected' % (f.__name__, params, `val`, `output`) ! test('abs', -1, 1) ! test('add', 3, 7, 4) ! test('and_', 0xf, 0xa, 0xa) ! test('concat', 'py', 'python', 'thon') ! ! test('countOf', [1, 2, 1, 3, 1, 4], 1, 3) ! ! a = [4, 3, 2, 1] ! test('delitem', a, None, 1) ! if a <> [4, 2, 1]: ! print 'delitem() failed' ! ! a = range(10) ! test('delslice', a, None, 2, 8) ! if a <> [0, 1, 8, 9]: ! print 'delslice() failed' ! ! a = range(10) ! test('div', 5, 2, 2) ! test('getitem', a, 2, 2) ! test('getslice', a, [4, 5], 4, 6) ! test('indexOf', [4, 3, 2, 1], 1, 3) ! test('inv', 4, -5) ! test('isCallable', 4, 0) ! test('isCallable', operator.isCallable, 1) ! test('isMappingType', operator.isMappingType, 0) ! test('isMappingType', operator.__dict__, 1) ! test('isNumberType', 8.3, 1) ! test('isNumberType', dir(), 0) ! test('isSequenceType', dir(), 1) ! test('isSequenceType', 'yeahbuddy', 1) ! test('isSequenceType', 3, 0) ! test('lshift', 5, 10, 1) ! test('mod', 5, 1, 2) ! test('mul', 5, 10, 2) ! test('neg', 5, -5) ! test('or_', 0xa, 0xf, 0x5) ! test('pos', -5, -5) ! ! a = range(3) ! test('repeat', a, a+a, 2) ! test('rshift', 5, 2, 1) ! ! test('sequenceIncludes', range(4), 1, 2) ! test('sequenceIncludes', range(4), 0, 5) ! ! test('setitem', a, None, 0, 2) ! if a <> [2, 1, 2]: ! print 'setitem() failed' ! ! a = range(4) ! test('setslice', a, None, 1, 3, [2, 1]) ! if a <> [0, 2, 1, 3]: ! print 'setslice() failed:', a ! ! test('sub', 5, 2, 3) ! test('truth', 5, 1) ! test('truth', [], 0) ! test('xor', 0xb, 0x7, 0xc) ! ! ! # some negative tests ! test('indexOf', [4, 3, 2, 1], ValueError, 9) Index: test_pye.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/test_pye.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** test_pye.py 2000/05/08 17:31:03 1.1 --- test_pye.py 2000/06/29 19:35:29 1.2 *************** *** 11,18 **** class Outputter: def StartElementHandler(self, name, attrs): ! print 'Start element:\n\t', name, attrs def EndElementHandler(self, name): ! print 'End element:\n\t', name def CharacterDataHandler(self, data): --- 11,18 ---- class Outputter: def StartElementHandler(self, name, attrs): ! print 'Start element:\n\t', repr(name), attrs def EndElementHandler(self, name): ! print 'End element:\n\t', repr(name) def CharacterDataHandler(self, data): *************** *** 23,33 **** def ProcessingInstructionHandler(self, target, data): ! print 'PI:\n\t', target, data def StartNamespaceDeclHandler(self, prefix, uri): ! print 'NS decl:\n\t', prefix, uri def EndNamespaceDeclHandler(self, prefix): ! print 'End of NS decl:\n\t', prefix def StartCdataSectionHandler(self): --- 23,33 ---- def ProcessingInstructionHandler(self, target, data): ! print 'PI:\n\t', repr(target), repr(data) def StartNamespaceDeclHandler(self, prefix, uri): ! print 'NS decl:\n\t', repr(prefix), repr(uri) def EndNamespaceDeclHandler(self, prefix): ! print 'End of NS decl:\n\t', repr(prefix) def StartCdataSectionHandler(self): *************** *** 52,57 **** return 1 ! def ExternalEntityRefHandler(self, context, base, sysId, pubId): ! print 'External entity ref:', context, base, sysId, pubId return 1 --- 52,58 ---- return 1 ! def ExternalEntityRefHandler(self, *args): ! context, base, sysId, pubId = args ! print 'External entity ref:', args return 1 *************** *** 65,69 **** out = Outputter() parser = pyexpat.ParserCreate(namespace_separator='!') ! for name in ['StartElementHandler', 'EndElementHandler', 'CharacterDataHandler', 'ProcessingInstructionHandler', 'UnparsedEntityDeclHandler', 'NotationDeclHandler', --- 66,77 ---- out = Outputter() parser = pyexpat.ParserCreate(namespace_separator='!') ! ! # Test getting/setting returns_unicode ! parser.returns_unicode = 0 ; assert parser.returns_unicode == 0 ! parser.returns_unicode = 1 ; assert parser.returns_unicode == 1 ! parser.returns_unicode = 2 ; assert parser.returns_unicode == 1 ! parser.returns_unicode = 0 ; assert parser.returns_unicode == 0 ! ! HANDLER_NAMES = ['StartElementHandler', 'EndElementHandler', 'CharacterDataHandler', 'ProcessingInstructionHandler', 'UnparsedEntityDeclHandler', 'NotationDeclHandler', *************** *** 74,78 **** #'NotStandaloneHandler', 'ExternalEntityRefHandler' ! ]: setattr(parser, name, getattr(out, name) ) --- 82,87 ---- #'NotStandaloneHandler', 'ExternalEntityRefHandler' ! ] ! for name in HANDLER_NAMES: setattr(parser, name, getattr(out, name) ) *************** *** 89,93 **** ]> ! Contents of subelements --- 98,102 ---- ]> ! Contents of subelements *************** *** 98,103 **** --- 107,144 ---- """ + # Produce UTF-8 output + parser.returns_unicode = 0 try: parser.Parse(data, 1) + except pyexpat.error: + print '** Error', parser.ErrorCode, pyexpat.ErrorString( parser.ErrorCode) + print '** Line', parser.ErrorLineNumber + print '** Column', parser.ErrorColumnNumber + print '** Byte', parser.ErrorByteIndex + + # Try the parse again, this time producing Unicode output + parser = pyexpat.ParserCreate(namespace_separator='!') + parser.returns_unicode = 1 + + for name in HANDLER_NAMES: + setattr(parser, name, getattr(out, name) ) + try: + parser.Parse(data, 1) + except pyexpat.error: + print '** Error', parser.ErrorCode, pyexpat.ErrorString( parser.ErrorCode) + print '** Line', parser.ErrorLineNumber + print '** Column', parser.ErrorColumnNumber + print '** Byte', parser.ErrorByteIndex + + # Try parsing a file + parser = pyexpat.ParserCreate(namespace_separator='!') + parser.returns_unicode = 1 + + for name in HANDLER_NAMES: + setattr(parser, name, getattr(out, name) ) + import StringIO + file = StringIO.StringIO(data) + try: + parser.ParseFile(file) except pyexpat.error: print '** Error', parser.ErrorCode, pyexpat.ErrorString( parser.ErrorCode) Index: test_soc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/test_soc.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** test_soc.py 2000/05/08 17:31:03 1.6 --- test_soc.py 2000/06/29 19:35:29 1.7 *************** *** 98,102 **** # parent is server s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ! s.bind((hostname, PORT)) s.listen(1) if verbose: --- 98,102 ---- # parent is server s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ! s.bind(("127.0.0.1", PORT)) s.listen(1) if verbose: *************** *** 134,138 **** if verbose: print 'child connecting' ! s.connect((hostname, PORT)) msg = 'socket test' s.send(msg) --- 134,138 ---- if verbose: print 'child connecting' ! s.connect(("127.0.0.1", PORT)) msg = 'socket test' s.send(msg) Index: test_str.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/test_str.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** test_str.py 1998/03/26 22:14:05 1.8 --- test_str.py 2000/06/29 19:35:29 1.9 *************** *** 1,11 **** from test_support import verbose ! import strop, sys def test(name, input, output, *args): if verbose: print 'string.%s%s =? %s... ' % (name, (input,) + args, output), - f = getattr(strop, name) try: ! value = apply(f, (input,) + args) except: value = sys.exc_type --- 1,22 ---- from test_support import verbose ! import string, sys + # XXX: kludge... short circuit if strings don't have methods + try: + ''.join + except AttributeError: + raise ImportError + def test(name, input, output, *args): if verbose: print 'string.%s%s =? %s... ' % (name, (input,) + args, output), try: ! # Prefer string methods over string module functions ! try: ! f = getattr(input, name) ! value = apply(f, args) ! except AttributeError: ! f = getattr(string, name) ! value = apply(f, (input,) + args) except: value = sys.exc_type *************** *** 35,39 **** --- 46,95 ---- test('rfind', 'abcdefghiabc', 9, 'abc') test('lower', 'HeLLo', 'hello') + test('lower', 'hello', 'hello') test('upper', 'HeLLo', 'HELLO') + test('upper', 'HELLO', 'HELLO') + + test('title', ' hello ', ' Hello ') + test('title', 'hello ', 'Hello ') + test('title', "fOrMaT thIs aS titLe String", 'Format This As Title String') + test('title', "fOrMaT,thIs-aS*titLe;String", 'Format,This-As*Title;String') + test('title', "getInt", 'Getint') + + test('expandtabs', 'abc\rab\tdef\ng\thi', 'abc\rab def\ng hi') + test('expandtabs', 'abc\rab\tdef\ng\thi', 'abc\rab def\ng hi', 8) + test('expandtabs', 'abc\rab\tdef\ng\thi', 'abc\rab def\ng hi', 4) + test('expandtabs', 'abc\r\nab\tdef\ng\thi', 'abc\r\nab def\ng hi', 4) + + test('islower', 'a', 1) + test('islower', 'A', 0) + test('islower', '\n', 0) + test('islower', 'abc', 1) + test('islower', 'aBc', 0) + test('islower', 'abc\n', 1) + + test('isupper', 'a', 0) + test('isupper', 'A', 1) + test('isupper', '\n', 0) + test('isupper', 'ABC', 1) + test('isupper', 'AbC', 0) + test('isupper', 'ABC\n', 1) + + test('istitle', 'a', 0) + test('istitle', 'A', 1) + test('istitle', '\n', 0) + test('istitle', 'A Titlecased Line', 1) + test('istitle', 'A\nTitlecased Line', 1) + test('istitle', 'A Titlecased, Line', 1) + test('istitle', 'Not a capitalized String', 0) + test('istitle', 'Not\ta Titlecase String', 0) + test('istitle', 'Not--a Titlecase String', 0) + + test('splitlines', "abc\ndef\n\rghi", ['abc', 'def', '', 'ghi']) + test('splitlines', "abc\ndef\n\r\nghi", ['abc', 'def', '', 'ghi']) + test('splitlines', "abc\ndef\r\nghi", ['abc', 'def', 'ghi']) + test('splitlines', "abc\ndef\r\nghi\n", ['abc', 'def', 'ghi']) + test('splitlines', "abc\ndef\r\nghi\n\r", ['abc', 'def', 'ghi', '']) + test('splitlines', "\nabc\ndef\r\nghi\n\r", ['', 'abc', 'def', 'ghi', '']) + test('splitlines', "\nabc\ndef\r\nghi\n\r", ['\n', 'abc\n', 'def\r\n', 'ghi\n', '\r'], 1) transtable = '\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037 !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`xyzdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377' *************** *** 50,55 **** test('split', 'a b c d', ['a', 'b', 'c', 'd'], None, 3) test('split', 'a b c d', ['a', 'b', 'c', 'd'], None, 4) ! test('split', 'a b c d', ['a', 'b', 'c', 'd'], None, 0) test('split', 'a b c d', ['a', 'b', 'c d'], None, 2) # join now works with any sequence type --- 106,112 ---- test('split', 'a b c d', ['a', 'b', 'c', 'd'], None, 3) test('split', 'a b c d', ['a', 'b', 'c', 'd'], None, 4) ! test('split', 'a b c d', ['a b c d'], None, 0) test('split', 'a b c d', ['a', 'b', 'c d'], None, 2) + test('split', 'a b c d ', ['a', 'b', 'c', 'd']) # join now works with any sequence type *************** *** 62,87 **** test('join', ('a', 'b', 'c', 'd'), 'abcd', '') test('join', Sequence(), 'w x y z') # try a few long ones ! print strop.join(['x' * 100] * 100, ':') ! print strop.join(('x' * 100,) * 100, ':') test('strip', ' hello ', 'hello') test('lstrip', ' hello ', 'hello ') test('rstrip', ' hello ', ' hello') test('swapcase', 'HeLLo cOmpUteRs', 'hEllO CoMPuTErS') test('translate', 'xyzabcdef', 'xyzxyz', transtable, 'def') test('replace', 'one!two!three!', 'one@two!three!', '!', '@', 1) test('replace', 'one!two!three!', 'one@two@three!', '!', '@', 2) test('replace', 'one!two!three!', 'one@two@three@', '!', '@', 3) test('replace', 'one!two!three!', 'one@two@three@', '!', '@', 4) ! test('replace', 'one!two!three!', 'one@two@three@', '!', '@', 0) test('replace', 'one!two!three!', 'one@two@three@', '!', '@') test('replace', 'one!two!three!', 'one!two!three!', 'x', '@') test('replace', 'one!two!three!', 'one!two!three!', 'x', '@', 2) ! strop.whitespace ! strop.lowercase ! strop.uppercase --- 119,185 ---- test('join', ('a', 'b', 'c', 'd'), 'abcd', '') test('join', Sequence(), 'w x y z') + test('join', 7, TypeError) + + class BadSeq(Sequence): + def __init__(self): self.seq = [7, 'hello', 123L] + test('join', BadSeq(), TypeError) + # try a few long ones ! print string.join(['x' * 100] * 100, ':') ! print string.join(('x' * 100,) * 100, ':') test('strip', ' hello ', 'hello') test('lstrip', ' hello ', 'hello ') test('rstrip', ' hello ', ' hello') + test('strip', 'hello', 'hello') test('swapcase', 'HeLLo cOmpUteRs', 'hEllO CoMPuTErS') test('translate', 'xyzabcdef', 'xyzxyz', transtable, 'def') + table = string.maketrans('a', 'A') + test('translate', 'abc', 'Abc', table) + test('translate', 'xyz', 'xyz', table) + test('replace', 'one!two!three!', 'one@two!three!', '!', '@', 1) + test('replace', 'one!two!three!', 'onetwothree', '!', '') test('replace', 'one!two!three!', 'one@two@three!', '!', '@', 2) test('replace', 'one!two!three!', 'one@two@three@', '!', '@', 3) test('replace', 'one!two!three!', 'one@two@three@', '!', '@', 4) ! test('replace', 'one!two!three!', 'one!two!three!', '!', '@', 0) test('replace', 'one!two!three!', 'one@two@three@', '!', '@') test('replace', 'one!two!three!', 'one!two!three!', 'x', '@') test('replace', 'one!two!three!', 'one!two!three!', 'x', '@', 2) ! test('startswith', 'hello', 1, 'he') ! test('startswith', 'hello', 1, 'hello') ! test('startswith', 'hello', 0, 'hello world') ! test('startswith', 'hello', 1, '') ! test('startswith', 'hello', 0, 'ello') ! test('startswith', 'hello', 1, 'ello', 1) ! test('startswith', 'hello', 1, 'o', 4) ! test('startswith', 'hello', 0, 'o', 5) ! test('startswith', 'hello', 1, '', 5) ! test('startswith', 'hello', 0, 'lo', 6) ! test('startswith', 'helloworld', 1, 'lowo', 3) ! test('startswith', 'helloworld', 1, 'lowo', 3, 7) ! test('startswith', 'helloworld', 0, 'lowo', 3, 6) ! ! test('endswith', 'hello', 1, 'lo') ! test('endswith', 'hello', 0, 'he') ! test('endswith', 'hello', 1, '') ! test('endswith', 'hello', 0, 'hello world') ! test('endswith', 'helloworld', 0, 'worl') ! test('endswith', 'helloworld', 1, 'worl', 3, 9) ! test('endswith', 'helloworld', 1, 'world', 3, 12) ! test('endswith', 'helloworld', 1, 'lowo', 1, 7) ! test('endswith', 'helloworld', 1, 'lowo', 2, 7) ! test('endswith', 'helloworld', 1, 'lowo', 3, 7) ! test('endswith', 'helloworld', 0, 'lowo', 4, 7) ! test('endswith', 'helloworld', 0, 'lowo', 3, 8) ! test('endswith', 'ab', 0, 'ab', 0, 1) ! test('endswith', 'ab', 0, 'ab', 0, 0) ! ! string.whitespace ! string.lowercase ! string.uppercase Index: test_tim.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/test_tim.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** test_tim.py 1998/03/26 22:14:09 1.5 --- test_tim.py 2000/06/29 19:35:29 1.6 *************** *** 1,39 **** ! import time ! time.altzone ! time.clock() ! t = time.time() ! time.asctime(time.gmtime(t)) ! if time.ctime(t) <> time.asctime(time.localtime(t)): ! print 'time.ctime(t) <> time.asctime(time.localtime(t))' ! ! time.daylight ! if long(time.mktime(time.localtime(t))) <> long(t): ! print 'time.mktime(time.localtime(t)) <> t' ! ! time.sleep(1.2) ! tt = time.gmtime(t) ! for directive in ('a', 'A', 'b', 'B', 'c', 'd', 'H', 'I', ! 'j', 'm', 'M', 'p', 'S', ! 'U', 'w', 'W', 'x', 'X', 'y', 'Y', 'Z', '%'): ! format = ' %' + directive ! try: ! time.strftime(format, tt) ! except ValueError: ! print 'conversion specifier:', format, ' failed.' ! ! time.timezone ! time.tzname ! ! # expected errors ! try: ! time.asctime(0) ! except TypeError: ! pass ! ! try: ! time.mktime((999999, 999999, 999999, 999999, ! 999999, 999999, 999999, 999999, ! 999999)) ! except OverflowError: pass --- 1,21 ---- ! from test_support import verbose ! import timing ! r = range(100000) ! if verbose: ! print 'starting...' ! timing.start() ! for i in r: pass + timing.finish() + if verbose: + print 'finished' + + secs = timing.seconds() + milli = timing.milli() + micro = timing.micro() + + if verbose: + print 'seconds:', secs + print 'milli :', milli + print 'micro :', micro Index: test_uni.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/test_uni.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** test_uni.py 2000/05/08 17:31:03 1.1 --- test_uni.py 2000/06/29 19:35:29 1.2 *************** *** 1,3 **** ! """ Test script for the Unicode implementation. Written by Marc-Andre Lemburg (mal@lemburg.com). --- 1,3 ---- ! """ Test script for the unicodedata module. Written by Marc-Andre Lemburg (mal@lemburg.com). *************** *** 5,401 **** (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. ! """ from test_support import verbose import sys ! def test(method, input, output, *args): ! if verbose: ! print '%s.%s%s =? %s... ' % (repr(input), method, args, output), ! try: ! f = getattr(input, method) ! value = apply(f, args) ! except: ! value = sys.exc_type ! exc = sys.exc_info()[:2] ! else: ! exc = None ! if value != output: ! if verbose: ! print 'no' ! print '*',f, `input`, `output`, `value` ! if exc: ! print ' value == %s: %s' % (exc) ! else: ! if verbose: ! print 'yes' ! ! test('capitalize', u' hello ', u' hello ') ! test('capitalize', u'hello ', u'Hello ') ! ! test('title', u' hello ', u' Hello ') ! test('title', u'hello ', u'Hello ') ! test('title', u"fOrMaT thIs aS titLe String", u'Format This As Title String') ! test('title', u"fOrMaT,thIs-aS*titLe;String", u'Format,This-As*Title;String') ! test('title', u"getInt", u'Getint') ! ! test('find', u'abcdefghiabc', 0, u'abc') ! test('find', u'abcdefghiabc', 9, u'abc', 1) ! test('find', u'abcdefghiabc', -1, u'def', 4) ! ! test('rfind', u'abcdefghiabc', 9, u'abc') ! ! test('lower', u'HeLLo', u'hello') ! test('lower', u'hello', u'hello') ! ! test('upper', u'HeLLo', u'HELLO') ! test('upper', u'HELLO', u'HELLO') ! ! if 0: ! transtable = '\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037 !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`xyzdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377' ! ! test('maketrans', u'abc', transtable, u'xyz') ! test('maketrans', u'abc', ValueError, u'xyzq') ! ! test('split', u'this is the split function', ! [u'this', u'is', u'the', u'split', u'function']) ! test('split', u'a|b|c|d', [u'a', u'b', u'c', u'd'], u'|') ! test('split', u'a|b|c|d', [u'a', u'b', u'c|d'], u'|', 2) ! test('split', u'a b c d', [u'a', u'b c d'], None, 1) ! test('split', u'a b c d', [u'a', u'b', u'c d'], None, 2) ! test('split', u'a b c d', [u'a', u'b', u'c', u'd'], None, 3) ! test('split', u'a b c d', [u'a', u'b', u'c', u'd'], None, 4) ! test('split', u'a b c d', [u'a b c d'], None, 0) ! test('split', u'a b c d', [u'a', u'b', u'c d'], None, 2) ! test('split', u'a b c d ', [u'a', u'b', u'c', u'd']) ! ! # join now works with any sequence type ! class Sequence: ! def __init__(self): self.seq = 'wxyz' ! def __len__(self): return len(self.seq) ! def __getitem__(self, i): return self.seq[i] ! ! test('join', u' ', u'a b c d', [u'a', u'b', u'c', u'd']) ! test('join', u'', u'abcd', (u'a', u'b', u'c', u'd')) ! test('join', u' ', u'w x y z', Sequence()) ! test('join', u' ', TypeError, 7) ! ! class BadSeq(Sequence): ! def __init__(self): self.seq = [7, u'hello', 123L] ! ! test('join', u' ', TypeError, BadSeq()) ! ! result = u'' ! for i in range(10): ! if i > 0: ! result = result + u':' ! result = result + u'x'*10 ! test('join', u':', result, [u'x' * 10] * 10) ! test('join', u':', result, (u'x' * 10,) * 10) ! ! test('strip', u' hello ', u'hello') ! test('lstrip', u' hello ', u'hello ') ! test('rstrip', u' hello ', u' hello') ! test('strip', u'hello', u'hello') ! ! test('swapcase', u'HeLLo cOmpUteRs', u'hEllO CoMPuTErS') ! ! if 0: ! test('translate', u'xyzabcdef', u'xyzxyz', transtable, u'def') ! ! table = string.maketrans('a', u'A') ! test('translate', u'abc', u'Abc', table) ! test('translate', u'xyz', u'xyz', table) ! ! test('replace', u'one!two!three!', u'one@two!three!', u'!', u'@', 1) ! test('replace', u'one!two!three!', u'onetwothree', '!', '') ! test('replace', u'one!two!three!', u'one@two@three!', u'!', u'@', 2) ! test('replace', u'one!two!three!', u'one@two@three@', u'!', u'@', 3) ! test('replace', u'one!two!three!', u'one@two@three@', u'!', u'@', 4) ! test('replace', u'one!two!three!', u'one!two!three!', u'!', u'@', 0) ! test('replace', u'one!two!three!', u'one@two@three@', u'!', u'@') ! test('replace', u'one!two!three!', u'one!two!three!', u'x', u'@') ! test('replace', u'one!two!three!', u'one!two!three!', u'x', u'@', 2) ! ! test('startswith', u'hello', 1, u'he') ! test('startswith', u'hello', 1, u'hello') ! test('startswith', u'hello', 0, u'hello world') ! test('startswith', u'hello', 1, u'') ! test('startswith', u'hello', 0, u'ello') ! test('startswith', u'hello', 1, u'ello', 1) ! test('startswith', u'hello', 1, u'o', 4) ! test('startswith', u'hello', 0, u'o', 5) ! test('startswith', u'hello', 1, u'', 5) ! test('startswith', u'hello', 0, u'lo', 6) ! test('startswith', u'helloworld', 1, u'lowo', 3) ! test('startswith', u'helloworld', 1, u'lowo', 3, 7) ! test('startswith', u'helloworld', 0, u'lowo', 3, 6) ! ! test('endswith', u'hello', 1, u'lo') ! test('endswith', u'hello', 0, u'he') ! test('endswith', u'hello', 1, u'') ! test('endswith', u'hello', 0, u'hello world') ! test('endswith', u'helloworld', 0, u'worl') ! test('endswith', u'helloworld', 1, u'worl', 3, 9) ! test('endswith', u'helloworld', 1, u'world', 3, 12) ! test('endswith', u'helloworld', 1, u'lowo', 1, 7) ! test('endswith', u'helloworld', 1, u'lowo', 2, 7) ! test('endswith', u'helloworld', 1, u'lowo', 3, 7) ! test('endswith', u'helloworld', 0, u'lowo', 4, 7) ! test('endswith', u'helloworld', 0, u'lowo', 3, 8) ! test('endswith', u'ab', 0, u'ab', 0, 1) ! test('endswith', u'ab', 0, u'ab', 0, 0) ! ! test('expandtabs', u'abc\rab\tdef\ng\thi', u'abc\rab def\ng hi') ! test('expandtabs', u'abc\rab\tdef\ng\thi', u'abc\rab def\ng hi', 8) ! test('expandtabs', u'abc\rab\tdef\ng\thi', u'abc\rab def\ng hi', 4) ! test('expandtabs', u'abc\r\nab\tdef\ng\thi', u'abc\r\nab def\ng hi', 4) ! ! if 0: ! test('capwords', u'abc def ghi', u'Abc Def Ghi') ! test('capwords', u'abc\tdef\nghi', u'Abc Def Ghi') ! test('capwords', u'abc\t def \nghi', u'Abc Def Ghi') ! ! # Comparisons: ! print 'Testing Unicode comparisons...', ! assert u'abc' == 'abc' ! assert 'abc' == u'abc' ! assert u'abc' == u'abc' ! assert u'abcd' > 'abc' ! assert 'abcd' > u'abc' ! assert u'abcd' > u'abc' ! assert u'abc' < 'abcd' ! assert 'abc' < u'abcd' ! assert u'abc' < u'abcd' ! print 'done.' ! ! test('ljust', u'abc', u'abc ', 10) ! test('rjust', u'abc', u' abc', 10) ! test('center', u'abc', u' abc ', 10) ! test('ljust', u'abc', u'abc ', 6) ! test('rjust', u'abc', u' abc', 6) ! test('center', u'abc', u' abc ', 6) ! test('ljust', u'abc', u'abc', 2) ! test('rjust', u'abc', u'abc', 2) ! test('center', u'abc', u'abc', 2) ! ! test('islower', u'a', 1) ! test('islower', u'A', 0) ! test('islower', u'\n', 0) ! test('islower', u'\u1FFc', 0) ! test('islower', u'abc', 1) ! test('islower', u'aBc', 0) ! test('islower', u'abc\n', 1) ! ! test('isupper', u'a', 0) ! test('isupper', u'A', 1) ! test('isupper', u'\n', 0) ! test('isupper', u'\u1FFc', 0) ! test('isupper', u'ABC', 1) ! test('isupper', u'AbC', 0) ! test('isupper', u'ABC\n', 1) ! ! test('istitle', u'a', 0) ! test('istitle', u'A', 1) ! test('istitle', u'\n', 0) ! test('istitle', u'\u1FFc', 1) ! test('istitle', u'A Titlecased Line', 1) ! test('istitle', u'A\nTitlecased Line', 1) ! test('istitle', u'A Titlecased, Line', 1) ! test('istitle', u'Greek \u1FFcitlecases ...', 1) ! test('istitle', u'Not a capitalized String', 0) ! test('istitle', u'Not\ta Titlecase String', 0) ! test('istitle', u'Not--a Titlecase String', 0) ! ! test('splitlines', u"abc\ndef\n\rghi", [u'abc', u'def', u'', u'ghi']) ! test('splitlines', u"abc\ndef\n\r\nghi", [u'abc', u'def', u'', u'ghi']) ! test('splitlines', u"abc\ndef\r\nghi", [u'abc', u'def', u'ghi']) ! test('splitlines', u"abc\ndef\r\nghi\n", [u'abc', u'def', u'ghi']) ! test('splitlines', u"abc\ndef\r\nghi\n\r", [u'abc', u'def', u'ghi', u'']) ! test('splitlines', u"\nabc\ndef\r\nghi\n\r", [u'', u'abc', u'def', u'ghi', u'']) ! test('splitlines', u"\nabc\ndef\r\nghi\n\r", [u'\n', u'abc\n', u'def\r\n', u'ghi\n', u'\r'], 1) ! ! test('translate', u"abababc", u'bbbc', {ord('a'):None}) ! test('translate', u"abababc", u'iiic', {ord('a'):None, ord('b'):ord('i')}) ! test('translate', u"abababc", u'iiix', {ord('a'):None, ord('b'):ord('i'), ord('c'):u'x'}) ! ! # Contains: ! print 'Testing Unicode contains method...', ! assert ('a' in u'abdb') == 1 ! assert ('a' in u'bdab') == 1 ! assert ('a' in u'bdaba') == 1 ! assert ('a' in u'bdba') == 1 ! assert ('a' in u'bdba') == 1 ! assert (u'a' in u'bdba') == 1 ! assert (u'a' in u'bdb') == 0 ! assert (u'a' in 'bdb') == 0 ! assert (u'a' in 'bdba') == 1 ! assert (u'a' in ('a',1,None)) == 1 ! assert (u'a' in (1,None,'a')) == 1 ! assert (u'a' in (1,None,u'a')) == 1 ! assert ('a' in ('a',1,None)) == 1 ! assert ('a' in (1,None,'a')) == 1 ! assert ('a' in (1,None,u'a')) == 1 ! assert ('a' in ('x',1,u'y')) == 0 ! assert ('a' in ('x',1,None)) == 0 ! print 'done.' ! ! # Formatting: ! print 'Testing Unicode formatting strings...', ! assert u"%s, %s" % (u"abc", "abc") == u'abc, abc' ! assert u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", 1, 2, 3) == u'abc, abc, 1, 2.000000, 3.00' ! assert u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", 1, -2, 3) == u'abc, abc, 1, -2.000000, 3.00' ! assert u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", -1, -2, 3.5) == u'abc, abc, -1, -2.000000, 3.50' ! assert u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", -1, -2, 3.57) == u'abc, abc, -1, -2.000000, 3.57' ! assert u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", -1, -2, 1003.57) == u'abc, abc, -1, -2.000000, 1003.57' ! assert u"%c" % (u"abc",) == u'a' ! assert u"%c" % ("abc",) == u'a' ! assert u"%c" % (34,) == u'"' ! assert u"%c" % (36,) == u'$' ! assert u"%r, %r" % (u"abc", "abc") == u"u'abc', 'abc'" ! assert u"%(x)s, %(y)s" % {'x':u"abc", 'y':"def"} == u'abc, def' ! assert u"%(x)s, %(ä)s" % {'x':u"abc", u'ä'.encode('utf-8'):"def"} == u'abc, def' ! # formatting jobs delegated from the string implementation: ! assert '...%(foo)s...' % {'foo':u"abc"} == u'...abc...' ! assert '...%(foo)s...' % {'foo':"abc"} == '...abc...' ! assert '...%(foo)s...' % {u'foo':"abc"} == '...abc...' ! assert '...%(foo)s...' % {u'foo':u"abc"} == u'...abc...' ! assert '...%(foo)s...' % {u'foo':u"abc",'def':123} == u'...abc...' ! assert '...%(foo)s...' % {u'foo':u"abc",u'def':123} == u'...abc...' ! assert '...%s...%s...%s...%s...' % (1,2,3,u"abc") == u'...1...2...3...abc...' ! assert '...%s...' % u"abc" == u'...abc...' ! print 'done.' ! ! # Test builtin codecs ! print 'Testing builtin codecs...', ! ! assert unicode('hello','ascii') == u'hello' ! assert unicode('hello','utf-8') == u'hello' ! assert unicode('hello','utf8') == u'hello' ! assert unicode('hello','latin-1') == u'hello' ! ! try: ! u'Andr\202 x'.encode('ascii') ! u'Andr\202 x'.encode('ascii','strict') ! except ValueError: ! pass ! else: ! raise AssertionError, "u'Andr\202'.encode('ascii') failed to raise an exception" ! assert u'Andr\202 x'.encode('ascii','ignore') == "Andr x" ! assert u'Andr\202 x'.encode('ascii','replace') == "Andr? x" ! ! try: ! unicode('Andr\202 x','ascii') ! unicode('Andr\202 x','ascii','strict') ! except ValueError: ! pass ! else: ! raise AssertionError, "unicode('Andr\202') failed to raise an exception" ! assert unicode('Andr\202 x','ascii','ignore') == u"Andr x" ! assert unicode('Andr\202 x','ascii','replace') == u'Andr\uFFFD x' ! ! assert u'hello'.encode('ascii') == 'hello' ! assert u'hello'.encode('utf-8') == 'hello' ! assert u'hello'.encode('utf8') == 'hello' ! assert u'hello'.encode('utf-16-le') == 'h\000e\000l\000l\000o\000' ! assert u'hello'.encode('utf-16-be') == '\000h\000e\000l\000l\000o' ! assert u'hello'.encode('latin-1') == 'hello' ! ! u = u''.join(map(unichr, range(1024))) ! for encoding in ('utf-8', 'utf-16', 'utf-16-le', 'utf-16-be', ! 'raw_unicode_escape', 'unicode_escape', 'unicode_internal'): ! assert unicode(u.encode(encoding),encoding) == u ! ! u = u''.join(map(unichr, range(256))) ! for encoding in ( ! 'latin-1', ! ): ! try: ! assert unicode(u.encode(encoding),encoding) == u ! except AssertionError: ! print '*** codec "%s" failed round-trip' % encoding ! except ValueError,why: ! print '*** codec for "%s" failed: %s' % (encoding, why) ! ! u = u''.join(map(unichr, range(128))) ! for encoding in ( ! 'ascii', ! ): ! try: ! assert unicode(u.encode(encoding),encoding) == u ! except AssertionError: ! print '*** codec "%s" failed round-trip' % encoding ! except ValueError,why: ! print '*** codec for "%s" failed: %s' % (encoding, why) ! ! print 'done.' ! ! print 'Testing standard mapping codecs...', ! ! print '0-127...', ! s = ''.join(map(chr, range(128))) ! for encoding in ( ! 'cp037', 'cp1026', ! 'cp437', 'cp500', 'cp737', 'cp775', 'cp850', ! 'cp852', 'cp855', 'cp860', 'cp861', 'cp862', ! 'cp863', 'cp865', 'cp866', ! 'iso8859_10', 'iso8859_13', 'iso8859_14', 'iso8859_15', ! 'iso8859_2', 'iso8859_3', 'iso8859_4', 'iso8859_5', 'iso8859_6', ! 'iso8859_7', 'iso8859_9', 'koi8_r', 'latin_1', ! 'mac_cyrillic', 'mac_latin2', ! ! 'cp1250', 'cp1251', 'cp1252', 'cp1253', 'cp1254', 'cp1255', ! 'cp1256', 'cp1257', 'cp1258', ! 'cp856', 'cp857', 'cp864', 'cp869', 'cp874', ! ! 'mac_greek', 'mac_iceland','mac_roman', 'mac_turkish', ! 'cp1006', 'cp875', 'iso8859_8', ! ! ### These have undefined mappings: ! #'cp424', ! ! ): ! try: ! assert unicode(s,encoding).encode(encoding) == s ! except AssertionError: ! print '*** codec "%s" failed round-trip' % encoding ! except ValueError,why: ! print '*** codec for "%s" failed: %s' % (encoding, why) ! ! print '128-255...', ! s = ''.join(map(chr, range(128,256))) ! for encoding in ( ! 'cp037', 'cp1026', ! 'cp437', 'cp500', 'cp737', 'cp775', 'cp850', ! 'cp852', 'cp855', 'cp860', 'cp861', 'cp862', ! 'cp863', 'cp865', 'cp866', ! 'iso8859_10', 'iso8859_13', 'iso8859_14', 'iso8859_15', ! 'iso8859_2', 'iso8859_3', 'iso8859_4', 'iso8859_5', 'iso8859_6', ! 'iso8859_7', 'iso8859_9', 'koi8_r', 'latin_1', ! 'mac_cyrillic', 'mac_latin2', ! ! ### These have undefined mappings: ! #'cp1250', 'cp1251', 'cp1252', 'cp1253', 'cp1254', 'cp1255', ! #'cp1256', 'cp1257', 'cp1258', ! #'cp424', 'cp856', 'cp857', 'cp864', 'cp869', 'cp874', ! #'mac_greek', 'mac_iceland','mac_roman', 'mac_turkish', ! ! ### These fail the round-trip: ! #'cp1006', 'cp875', 'iso8859_8', ! ! ): ! try: ! assert unicode(s,encoding).encode(encoding) == s ! except AssertionError: ! print '*** codec "%s" failed round-trip' % encoding ! except ValueError,why: ! print '*** codec for "%s" failed: %s' % (encoding, why) ! ! print 'done.' ! ! print 'Testing Unicode string concatenation...', ! assert (u"abc" u"def") == u"abcdef" ! assert ("abc" u"def") == u"abcdef" ! assert (u"abc" "def") == u"abcdef" ! assert (u"abc" u"def" "ghi") == u"abcdefghi" ! assert ("abc" "def" u"ghi") == u"abcdefghi" print 'done.' --- 5,50 ---- (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. ! """#" from test_support import verbose import sys ! # Test Unicode database APIs ! import unicodedata ! ! print 'Testing unicodedata module...', ! ! assert unicodedata.digit(u'A',None) is None ! assert unicodedata.digit(u'9') == 9 ! assert unicodedata.digit(u'\u215b',None) is None ! assert unicodedata.digit(u'\u2468') == 9 ! ! assert unicodedata.numeric(u'A',None) is None ! assert unicodedata.numeric(u'9') == 9 ! assert unicodedata.numeric(u'\u215b') == 0.125 ! assert unicodedata.numeric(u'\u2468') == 9.0 ! ! assert unicodedata.decimal(u'A',None) is None ! assert unicodedata.decimal(u'9') == 9 ! assert unicodedata.decimal(u'\u215b',None) is None ! assert unicodedata.decimal(u'\u2468',None) is None ! ! assert unicodedata.category(u'\uFFFE') == 'Cn' ! assert unicodedata.category(u'a') == 'Ll' ! assert unicodedata.category(u'A') == 'Lu' ! ! assert unicodedata.bidirectional(u'\uFFFE') == '' ! assert unicodedata.bidirectional(u' ') == 'WS' ! assert unicodedata.bidirectional(u'A') == 'L' ! ! assert unicodedata.decomposition(u'\uFFFE') == '' ! assert unicodedata.decomposition(u'\u00bc') == ' 0031 2044 0034' ! ! assert unicodedata.mirrored(u'\uFFFE') == 0 ! assert unicodedata.mirrored(u'a') == 0 ! assert unicodedata.mirrored(u'\u2201') == 1 ! ! assert unicodedata.combining(u'\uFFFE') == 0 ! assert unicodedata.combining(u'a') == 0 ! assert unicodedata.combining(u'\u20e1') == 230 ! print 'done.' Index: test_use.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/test_use.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** test_use.py 1999/04/08 20:27:52 1.1 --- test_use.py 2000/06/29 19:35:29 1.2 *************** *** 1,101 **** ! # Check every path through every method of UserDict ! ! from UserDict import UserDict ! ! d0 = {} ! d1 = {"one": 1} ! d2 = {"one": 1, "two": 2} ! ! # Test constructors ! ! u = UserDict() ! u0 = UserDict(d0) ! u1 = UserDict(d1) ! u2 = UserDict(d2) ! ! uu = UserDict(u) ! uu0 = UserDict(u0) ! uu1 = UserDict(u1) ! uu2 = UserDict(u2) ! ! # Test __repr__ ! ! assert str(u0) == str(d0) ! assert repr(u1) == repr(d1) ! assert `u2` == `d2` ! ! # Test __cmp__ and __len__ ! ! all = [d0, d1, d2, u, u0, u1, u2, uu, uu0, uu1, uu2] ! for a in all: ! for b in all: ! assert cmp(a, b) == cmp(len(a), len(b)) ! ! # Test __getitem__ ! ! assert u2["one"] == 1 ! try: ! u1["two"] ! except KeyError: ! pass ! else: ! assert 0, "u1['two'] shouldn't exist" ! ! # Test __setitem__ ! ! u3 = UserDict(u2) ! u3["two"] = 2 ! u3["three"] = 3 ! ! # Test __delitem__ ! ! del u3["three"] ! try: ! del u3["three"] ! except KeyError: ! pass ! else: ! assert 0, "u3['three'] shouldn't exist" ! ! # Test clear ! ! u3.clear() ! assert u3 == {} ! ! # Test copy() ! ! u2a = u2.copy() ! assert u2a == u2 ! ! class MyUserDict(UserDict): ! def display(self): print self ! ! m2 = MyUserDict(u2) ! m2a = m2.copy() ! assert m2a == m2 ! ! # Test keys, items, values ! ! assert u2.keys() == d2.keys() ! assert u2.items() == d2.items() ! assert u2.values() == d2.values() ! ! # Test has_key ! ! for i in u2.keys(): ! assert u2.has_key(i) == 1 ! assert u1.has_key(i) == d1.has_key(i) ! assert u0.has_key(i) == d0.has_key(i) ! ! # Test update ! ! t = UserDict() ! t.update(u2) ! assert t == u2 ! ! # Test get ! ! for i in u2.keys(): ! assert u2.get(i) == u2[i] ! assert u1.get(i) == d1.get(i) ! assert u0.get(i) == d0.get(i) --- 1,227 ---- ! #!/usr/bin/env python ! import sys, string ! from test_support import verbose ! # UserString is a wrapper around the native builtin string type. ! # UserString instances should behave similar to builtin string objects. ! # The test cases were in part derived from 'test_string.py'. ! from UserString import UserString ! ! if __name__ == "__main__": ! verbose = 0 ! ! tested_methods = {} ! ! def test(methodname, input, *args): ! global tested_methods ! tested_methods[methodname] = 1 ! if verbose: ! print '%s.%s(%s) ' % (input, methodname, args), ! u = UserString(input) ! objects = [input, u, UserString(u)] ! res = [""] * 3 ! for i in range(3): ! object = objects[i] ! try: ! f = getattr(object, methodname) ! res[i] = apply(f, args) ! except: ! res[i] = sys.exc_type ! if res[0] != res[1]: ! if verbose: ! print 'no' ! print `input`, f, `res[0]`, "<>", `res[1]` ! else: ! if verbose: ! print 'yes' ! if res[1] != res[2]: ! if verbose: ! print 'no' ! print `input`, f, `res[1]`, "<>", `res[2]` ! else: ! if verbose: ! print 'yes' ! ! test('capitalize', ' hello ') ! test('capitalize', 'hello ') ! ! test('center', 'foo', 0) ! test('center', 'foo', 3) ! test('center', 'foo', 16) ! ! test('ljust', 'foo', 0) ! test('ljust', 'foo', 3) ! test('ljust', 'foo', 16) ! ! test('rjust', 'foo', 0) ! test('rjust', 'foo', 3) ! test('rjust', 'foo', 16) ! ! test('count', 'abcabcabc', 'abc') ! test('count', 'abcabcabc', 'abc', 1) ! test('count', 'abcabcabc', 'abc', -1) ! test('count', 'abcabcabc', 'abc', 7) ! test('count', 'abcabcabc', 'abc', 0, 3) ! test('count', 'abcabcabc', 'abc', 0, 333) ! ! test('find', 'abcdefghiabc', 'abc') ! test('find', 'abcdefghiabc', 'abc', 1) ! test('find', 'abcdefghiabc', 'def', 4) ! test('rfind', 'abcdefghiabc', 'abc') ! ! test('index', 'abcabcabc', 'abc') ! test('index', 'abcabcabc', 'abc', 1) ! test('index', 'abcabcabc', 'abc', -1) ! test('index', 'abcabcabc', 'abc', 7) ! test('index', 'abcabcabc', 'abc', 0, 3) ! test('index', 'abcabcabc', 'abc', 0, 333) ! ! test('rindex', 'abcabcabc', 'abc') ! test('rindex', 'abcabcabc', 'abc', 1) ! test('rindex', 'abcabcabc', 'abc', -1) ! test('rindex', 'abcabcabc', 'abc', 7) ! test('rindex', 'abcabcabc', 'abc', 0, 3) ! test('rindex', 'abcabcabc', 'abc', 0, 333) ! ! ! test('lower', 'HeLLo') ! test('lower', 'hello') ! test('upper', 'HeLLo') ! test('upper', 'HELLO') ! ! test('title', ' hello ') ! test('title', 'hello ') ! test('title', "fOrMaT thIs aS titLe String") ! test('title', "fOrMaT,thIs-aS*titLe;String") ! test('title', "getInt") ! ! test('expandtabs', 'abc\rab\tdef\ng\thi') ! test('expandtabs', 'abc\rab\tdef\ng\thi', 8) ! test('expandtabs', 'abc\rab\tdef\ng\thi', 4) ! test('expandtabs', 'abc\r\nab\tdef\ng\thi', 4) ! ! test('islower', 'a') ! test('islower', 'A') ! test('islower', '\n') ! test('islower', 'abc') ! test('islower', 'aBc') ! test('islower', 'abc\n') ! ! test('isupper', 'a') ! test('isupper', 'A') ! test('isupper', '\n') ! test('isupper', 'ABC') ! test('isupper', 'AbC') ! test('isupper', 'ABC\n') ! ! test('isdigit', ' 0123456789') ! test('isdigit', '56789') ! test('isdigit', '567.89') ! test('isdigit', '0123456789abc') ! ! test('isspace', '') ! test('isspace', ' ') ! test('isspace', ' \t') ! test('isspace', ' \t\f\n') ! ! test('istitle', 'a') ! test('istitle', 'A') ! test('istitle', '\n') ! test('istitle', 'A Titlecased Line') ! test('istitle', 'A\nTitlecased Line') ! test('istitle', 'A Titlecased, Line') ! test('istitle', 'Not a capitalized String') ! test('istitle', 'Not\ta Titlecase String') ! test('istitle', 'Not--a Titlecase String') ! ! test('splitlines', "abc\ndef\n\rghi") ! test('splitlines', "abc\ndef\n\r\nghi") ! test('splitlines', "abc\ndef\r\nghi") ! test('splitlines', "abc\ndef\r\nghi\n") ! test('splitlines', "abc\ndef\r\nghi\n\r") ! test('splitlines', "\nabc\ndef\r\nghi\n\r") ! test('splitlines', "\nabc\ndef\r\nghi\n\r") ! test('splitlines', "\nabc\ndef\r\nghi\n\r") ! ! test('split', 'this is the split function') ! test('split', 'a|b|c|d', '|') ! test('split', 'a|b|c|d', '|', 2) ! test('split', 'a b c d', None, 1) ! test('split', 'a b c d', None, 2) ! test('split', 'a b c d', None, 3) ! test('split', 'a b c d', None, 4) ! test('split', 'a b c d', None, 0) ! test('split', 'a b c d', None, 2) ! test('split', 'a b c d ') ! ! # join now works with any sequence type ! class Sequence: ! def __init__(self): self.seq = 'wxyz' ! def __len__(self): return len(self.seq) ! def __getitem__(self, i): return self.seq[i] ! ! test('join', '', ('a', 'b', 'c', 'd')) ! test('join', '', Sequence()) ! test('join', '', 7) ! ! class BadSeq(Sequence): ! def __init__(self): self.seq = [7, 'hello', 123L] ! ! test('join', '', BadSeq()) ! ! test('strip', ' hello ') ! test('lstrip', ' hello ') ! test('rstrip', ' hello ') ! test('strip', 'hello') ! ! test('swapcase', 'HeLLo cOmpUteRs') ! transtable = string.maketrans("abc", "xyz") ! test('translate', 'xyzabcdef', transtable, 'def') ! ! transtable = string.maketrans('a', 'A') ! test('translate', 'abc', transtable) ! test('translate', 'xyz', transtable) ! ! test('replace', 'one!two!three!', '!', '@', 1) ! test('replace', 'one!two!three!', '!', '') ! test('replace', 'one!two!three!', '!', '@', 2) ! test('replace', 'one!two!three!', '!', '@', 3) ! test('replace', 'one!two!three!', '!', '@', 4) ! test('replace', 'one!two!three!', '!', '@', 0) ! test('replace', 'one!two!three!', '!', '@') ! test('replace', 'one!two!three!', 'x', '@') ! test('replace', 'one!two!three!', 'x', '@', 2) ! ! test('startswith', 'hello', 'he') ! test('startswith', 'hello', 'hello') ! test('startswith', 'hello', 'hello world') ! test('startswith', 'hello', '') ! test('startswith', 'hello', 'ello') ! test('startswith', 'hello', 'ello', 1) ! test('startswith', 'hello', 'o', 4) ! test('startswith', 'hello', 'o', 5) ! test('startswith', 'hello', '', 5) ! test('startswith', 'hello', 'lo', 6) ! test('startswith', 'helloworld', 'lowo', 3) ! test('startswith', 'helloworld', 'lowo', 3, 7) ! test('startswith', 'helloworld', 'lowo', 3, 6) ! ! test('endswith', 'hello', 'lo') ! test('endswith', 'hello', 'he') ! test('endswith', 'hello', '') ! test('endswith', 'hello', 'hello world') ! test('endswith', 'helloworld', 'worl') ! test('endswith', 'helloworld', 'worl', 3, 9) ! test('endswith', 'helloworld', 'world', 3, 12) ! test('endswith', 'helloworld', 'lowo', 1, 7) ! test('endswith', 'helloworld', 'lowo', 2, 7) ! test('endswith', 'helloworld', 'lowo', 3, 7) ! test('endswith', 'helloworld', 'lowo', 4, 7) ! test('endswith', 'helloworld', 'lowo', 3, 8) ! test('endswith', 'ab', 'ab', 0, 1) ! test('endswith', 'ab', 'ab', 0, 0) ! ! # TODO: test cases for: int, long, float, complex, +, * and cmp ! s = "" ! for builtin_method in dir(s): ! if not tested_methods.has_key(builtin_method): ! print "no regression test case for method '"+builtin_method+"'" Index: test_win.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/test_win.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** test_win.py 2000/06/28 14:48:01 1.2 --- test_win.py 2000/06/29 19:35:29 1.3 *************** *** 1,147 **** ! # Test the windows specific win32reg module. ! # Only win32reg functions not hit here: FlushKey, LoadKey and SaveKey ! from winreg import * ! import os, sys ! ! test_key_name = "SOFTWARE\\Python Registry Test Key - Delete Me" ! ! test_data = [ ! ("Int Value", 45, REG_DWORD), ! ("String Val", "A string value", REG_SZ,), ! (u"Unicode Val", u"A Unicode value", REG_SZ,), ! ("StringExpand", "The path is %path%", REG_EXPAND_SZ), ! ("UnicodeExpand", u"The path is %path%", REG_EXPAND_SZ), ! ("Multi-string", ["Lots", "of", "string", "values"], REG_MULTI_SZ), ! ("Multi-unicode", [u"Lots", u"of", u"unicode", u"values"], REG_MULTI_SZ), ! ("Multi-mixed", [u"Unicode", u"and", "string", "values"],REG_MULTI_SZ), ! ("Raw Data", ("binary"+chr(0)+"data"), REG_BINARY), ! ] ! ! def WriteTestData(root_key): ! # Set the default value for this key. ! SetValue(root_key, test_key_name, REG_SZ, "Default value") ! key = CreateKey(root_key, test_key_name) ! # Create a sub-key ! sub_key = CreateKey(key, "sub_key") ! # Give the sub-key some named values ! ! for value_name, value_data, value_type in test_data: ! SetValueEx(sub_key, value_name, 0, value_type, value_data) ! ! # Check we wrote as many items as we thought. ! nkeys, nvalues, since_mod = QueryInfoKey(key) ! assert nkeys==1, "Not the correct number of sub keys" ! assert nvalues==1, "Not the correct number of values" ! nkeys, nvalues, since_mod = QueryInfoKey(sub_key) ! assert nkeys==0, "Not the correct number of sub keys" ! assert nvalues==len(test_data), "Not the correct number of values" ! # Close this key this way... ! # (but before we do, copy the key as an integer - this allows ! # us to test that the key really gets closed). ! int_sub_key = int(sub_key) ! CloseKey(sub_key) ! try: ! QueryInfoKey(int_sub_key) ! raise RuntimeError, "It appears the CloseKey() function does not close the actual key!" ! except EnvironmentError: ! pass ! # ... and close that key that way :-) ! int_key = int(key) ! key.Close() ! try: ! QueryInfoKey(int_key) ! raise RuntimeError, "It appears the key.Close() function does not close the actual key!" ! except EnvironmentError: ! pass ! ! def ReadTestData(root_key): ! # Check we can get default value for this key. ! val = QueryValue(root_key, test_key_name) ! assert val=="Default value", "Registry didnt give back the correct value" ! ! key = OpenKey(root_key, test_key_name) ! # Read the sub-keys ! sub_key = OpenKey(key, "sub_key") ! # Check I can enumerate over the values. ! index = 0 ! while 1: ! try: ! data = EnumValue(sub_key, index) ! except EnvironmentError: ! break ! assert data in test_data, "didnt read back the correct test data." ! index = index + 1 ! assert index==len(test_data), "Didnt read the correct number of items" ! # Check I can directly access each item ! for value_name, value_data, value_type in test_data: ! read_val, read_typ = QueryValueEx(sub_key, value_name) ! assert read_val==value_data and read_typ == value_type, \ ! "Could not directly read the value" ! sub_key.Close() ! # Enumerate our main key. ! read_val = EnumKey(key, 0) ! assert read_val == "sub_key", "Read subkey value wrong" ! try: ! EnumKey(key, 1) ! assert 0, "Was able to get a second key when I only have one!" ! except EnvironmentError: ! pass ! ! key.Close() ! ! def DeleteTestData(root_key): ! key = OpenKey(root_key, test_key_name, 0, KEY_ALL_ACCESS) ! sub_key = OpenKey(key, "sub_key", 0, KEY_ALL_ACCESS) ! # It is not necessary to delete the values before deleting ! # the key (although subkeys must not exist). We delete them ! # manually just to prove we can :-) ! for value_name, value_data, value_type in test_data: ! DeleteValue(sub_key, value_name) ! ! nkeys, nvalues, since_mod = QueryInfoKey(sub_key) ! assert nkeys==0 and nvalues==0, "subkey not empty before delete" ! sub_key.Close() ! DeleteKey(key, "sub_key") ! ! try: ! # Shouldnt be able to delete it twice! ! DeleteKey(key, "sub_key") ! assert 0, "Deleting the key twice succeeded" ! except EnvironmentError: ! pass ! key.Close() ! DeleteKey(root_key, test_key_name) ! # Opening should now fail! ! try: ! key = OpenKey(root_key, test_key_name) ! assert 0, "Could open the non-existent key" ! except WindowsError: # Use this error name this time ! pass ! ! def TestAll(root_key): ! WriteTestData(root_key) ! ReadTestData(root_key) ! DeleteTestData(root_key) ! ! # Test on my local machine. ! TestAll(HKEY_CURRENT_USER) ! print "Local registry tests worked" ! try: ! remote_name = sys.argv[sys.argv.index("--remote")+1] ! except (IndexError, ValueError): ! remote_name = None ! ! if remote_name is not None: ! try: ! remote_key = ConnectRegistry(remote_name, HKEY_CURRENT_USER) ! except EnvironmentError, exc: ! print "Could not connect to the remote machine -", exc.strerror ! remote_key = None ! if remote_key is not None: ! TestAll(remote_key) ! print "Remote registry tests worked" ! else: ! print "Remote registry calls can be tested using", ! print "'test_winreg.py --remote \\\\machine_name'" --- 1,7 ---- ! # Ridiculously simple test of the winsound module for Windows. ! import winsound ! for i in range(100, 2000, 100): ! winsound.Beep(i, 75) ! print "Hopefully you heard some sounds increasing in frequency!" Index: test_zli.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/test_zli.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** test_zli.py 2000/05/08 17:31:03 1.5 --- test_zli.py 2000/06/29 19:35:29 1.6 *************** *** 12,16 **** file.close() ! # test the chucksums (hex so the test doesn't break on 64-bit machines) print hex(zlib.crc32('penguin')), hex(zlib.crc32('penguin', 1)) print hex(zlib.adler32('penguin')), hex(zlib.adler32('penguin', 1)) --- 12,16 ---- file.close() ! # test the checksums (hex so the test doesn't break on 64-bit machines) print hex(zlib.crc32('penguin')), hex(zlib.crc32('penguin', 1)) print hex(zlib.adler32('penguin')), hex(zlib.adler32('penguin', 1)) Index: threadin.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/threadin.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** threadin.py 2000/05/08 17:31:03 1.2 --- threadin.py 2000/06/29 19:35:29 1.3 *************** *** 19,22 **** --- 19,23 ---- _allocate_lock = thread.allocate_lock _get_ident = thread.get_ident + ThreadError = thread.error del thread From python-dev@python.org Thu Jun 29 20:35:48 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:35:48 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/parser - New directory Message-ID: <200006291935.MAA05240@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/xml/parser In directory slayer.i.sourceforge.net:/tmp/cvs-serv5232/parser Log Message: Directory /cvsroot/python/python/dist/src/Lib/xml/parser added to the repository From python-dev@python.org Thu Jun 29 20:36:30 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:36:30 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/parser __init__.py,NONE,1.1 Message-ID: <200006291936.MAA05289@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/xml/parser In directory slayer.i.sourceforge.net:/tmp/cvs-serv5279/parser Added Files: __init__.py Log Message: Package docstring. --- NEW FILE --- """Python interfaces to XML parsers. This package contains on module: expat -- Python wrapper for James Clark's Expat parser, with namespace support. """ From python-dev@python.org Thu Jun 29 20:39:59 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:39:59 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/dom minidom.py,NONE,1.1 pulldom.py,NONE,1.1 Message-ID: <200006291939.MAA05611@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/xml/dom In directory slayer.i.sourceforge.net:/tmp/cvs-serv5599 Added Files: minidom.py pulldom.py Log Message: Paul Prescod : W3C DOM implementation for Python. --- NEW FILE --- import pulldom import string from StringIO import StringIO import types """ minidom.py -- a lightweight DOM implementation based on SAX. Todo: ===== * convenience methods for getting elements and text. * more testing * bring some of the writer and linearizer code into conformance with this interface * SAX 2 namespaces """ class Node: ELEMENT_NODE = 1 ATTRIBUTE_NODE = 2 TEXT_NODE = 3 CDATA_SECTION_NODE = 4 ENTITY_REFERENCE_NODE = 5 ENTITY_NODE = 6 PROCESSING_INSTRUCTION_NODE = 7 COMMENT_NODE = 8 DOCUMENT_NODE = 9 DOCUMENT_TYPE_NODE = 10 DOCUMENT_FRAGMENT_NODE = 11 NOTATION_NODE = 12 allnodes=[] def __init__( self ): self.childNodes=[] Node.allnodes.append( repr( id( self ))+repr( self.__class__ )) def __getattr__( self, key ): if key[0:2]=="__": raise AttributeError # getattr should never call getattr! if self.__dict__.has_key("inGetAttr"): del self.inGetAttr raise AttributeError, key prefix,attrname=key[:5],key[5:] if prefix=="_get_": self.inGetAttr=1 if hasattr( self, attrname ): del self.inGetAttr return (lambda self=self, attrname=attrname: getattr( self, attrname )) else: del self.inGetAttr raise AttributeError, key else: self.inGetAttr=1 try: func = getattr( self, "_get_"+key ) except AttributeError: raise AttributeError, key del self.inGetAttr return func() def __nonzero__(self): return 1 def toxml( self ): writer=StringIO() self.writexml( writer ) return writer.getvalue() def hasChildNodes( self ): if self.childNodes: return 1 else: return 0 def insertBefore( self, newChild, refChild): index=self.childNodes.index( refChild ) self.childNodes.insert( index, newChild ) def appendChild( self, node ): self.childNodes.append( node ) def unlink( self ): self.parentNode=None while self.childNodes: self.childNodes[-1].unlink() del self.childNodes[-1] # probably not most efficient! self.childNodes=None if self.attributes: for attr in self.attributes.values(): attr.unlink() self.attributes=None index=Node.allnodes.index( repr( id( self ))+repr( self.__class__ )) del Node.allnodes[index] def _write_data( writer, data): "Writes datachars to writer." data=string.replace(data,"&","&") data=string.replace(data,"<","<") data=string.replace(data,"\"",""") data=string.replace(data,">",">") writer.write(data) def _closeElement( element ): del element.parentNode for node in element.elements: _closeElement( node ) def _getElementsByTagNameHelper( parent, name, rc ): for node in parent.childNodes: if node.nodeType==Node.ELEMENT_NODE and\ (name=="*" or node.tagName==name): rc.append( node ) _getElementsByTagNameHelper( node, name, rc ) return rc def _getElementsByTagNameNSHelper( parent, nsURI, localName, rc ): for node in parent.childNodes: if (node.nodeType==Node.ELEMENT_NODE ): if ((localName=="*" or node.tagName==localName) and (nsURI=="*" or node.namespaceURI==nsURI)): rc.append( node ) _getElementsByTagNameNSHelper( node, name, rc ) class Attr(Node): nodeType=Node.ATTRIBUTE_NODE def __init__( self, qName, namespaceURI="", prefix="", localName=None ): Node.__init__( self ) assert qName # skip setattr for performance self.__dict__["nodeName"] = self.__dict__["name"] = qName self.__dict__["localName"]=localName or qName self.__dict__["prefix"]=prefix self.__dict__["namespaceURI"]=namespaceURI # nodeValue and value are set elsewhere self.attributes=None def __setattr__( self, name, value ): if name in ("value", "nodeValue" ): self.__dict__["value"]=self.__dict__["nodeValue"]=value else: self.__dict__[name]=value class AttributeList: # the attribute list is a transient interface to the underlying dictionaries # mutations here will change the underlying element's dictionary def __init__( self, attrs, attrsNS ): self.__attrs=attrs self.__attrsNS=attrs self.length=len( self.__attrs.keys() ) def item( self, index ): try: return self[self.keys()[index]] except IndexError: return None def items( self ): return map( lambda node: (node.tagName, node.value), self.__attrs.values() ) def itemsNS( self ): return map( lambda node: ((node.URI, node.localName), node.value), self.__attrs.values() ) def keys( self ): return self.__attrs.keys() def keysNS( self ): return self.__attrsNS.keys() def values( self ): return self.__attrs.values() def __len__( self ): return self.length def __cmp__( self, other ): if self.__attrs is other.__attrs: return 0 else: return cmp( id( self ), id( other ) ) #FIXME: is it appropriate to return .value? def __getitem__( self, attname_or_tuple ): if type( attname_or_tuple ) == type( (1,2) ): return self.__attrsNS[attname_or_tuple].value else: return self.__attrs[attname_or_tuple].value def __setitem__( self, attname ): raise TypeError, "object does not support item assignment" class Element( Node ): nodeType=Node.ELEMENT_NODE def __init__( self, tagName, namespaceURI="", prefix="", localName=None ): Node.__init__( self ) self.tagName = self.nodeName = tagName self.localName=localName or tagName self.prefix=prefix self.namespaceURI=namespaceURI self.nodeValue=None self.__attrs={} # attributes are double-indexed: self.__attrsNS={}# tagName -> Attribute # URI,localName -> Attribute # in the future: consider lazy generation of attribute objects # this is too tricky for now because of headaches # with namespaces. def getAttribute( self, attname ): return self.__attrs[attname].value def getAttributeNS( self, namespaceURI, localName ): return self.__attrsNS[(namespaceURI, localName)].value def setAttribute( self, attname, value ): attr=Attr( attname ) # for performance attr.__dict__["value"]=attr.__dict__["nodeValue"]=value self.setAttributeNode( attr ) def setAttributeNS( self, namespaceURI, qualifiedName, value ): attr=createAttributeNS( namespaceURI, qualifiedName ) # for performance attr.__dict__["value"]=attr.__dict__["nodeValue"]=value self.setAttributeNode( attr ) def setAttributeNode( self, attr ): self.__attrs[attr.name]=attr self.__attrsNS[(attr.namespaceURI,attr.localName)]=attr def removeAttribute( self, name ): attr = self.__attrs[name] self.removeAttributeNode( attr ) def removeAttributeNS( self, namespaceURI, localName ): attr = self.__attrsNS[(uri, localName)] self.removeAttributeNode( attr ) def removeAttributeNode( self, node ): del self.__attrs[node.name] del self.__attrsNS[(node.namespaceURI, node.localName)] def getElementsByTagName( self, name ): return _getElementsByTagNameHelper( self, name, [] ) def getElementsByTagNameNS(self,namespaceURI,localName): _getElementsByTagNameNSHelper( self, namespaceURI, localName, [] ) def __repr__( self ): return "" def writexml(self, writer): writer.write("<"+self.tagName) a_names=self._get_attributes().keys() a_names.sort() for a_name in a_names: writer.write(" "+a_name+"=\"") _write_data(writer, self._get_attributes()[a_name]) writer.write("\"") if self.childNodes: writer.write(">") for node in self.childNodes: node.writexml( writer ) writer.write("") else: writer.write("/>") def _get_attributes( self ): return AttributeList( self.__attrs, self.__attrsNS ) class Comment( Node ): nodeType=Node.COMMENT_NODE def __init__(self, data ): Node.__init__( self ) self.data=self.nodeValue=data self.nodeName="#comment" self.attributes=None def writexml( self, writer ): writer.write( "" ) class ProcessingInstruction( Node ): nodeType=Node.PROCESSING_INSTRUCTION_NODE def __init__(self, target, data ): Node.__init__( self ) self.target = self.nodeName = target self.data = self.nodeValue = data self.attributes=None def writexml( self, writer ): writer.write( "" ) class Text( Node ): nodeType=Node.TEXT_NODE nodeName="#text" def __init__(self, data ): Node.__init__( self ) self.data = self.nodeValue = data self.attributes=None def __repr__(self): if len( self.data )> 10: dotdotdot="..." else: dotdotdot="" return "" def writexml( self, writer ): _write_data( writer, self.data ) class Document( Node ): nodeType=Node.DOCUMENT_NODE def __init__( self ): Node.__init__( self ) self.documentElement=None self.attributes=None self.nodeName="#document" self.nodeValue=None createElement=Element createTextNode=Text createComment=Comment createProcessingInstruction=ProcessingInstruction createAttribute=Attr def createElementNS(self, namespaceURI, qualifiedName): fields = string.split(qualifiedName, ':') if len(fields) == 2: prefix = fields[0] localName = fields[1] elif len(fields) == 1: prefix = '' localName = fields[0] return Element(self, qualifiedName, namespaceURI, prefix, localName) def createAttributeNS(self, namespaceURI, qualifiedName): fields = string.split(qualifiedName,':') if len(fields) == 2: localName = fields[1] prefix = fields[0] elif len(fields) == 1: localName = fields[0] prefix = None return Attr(qualifiedName, namespaceURI, prefix, localName) def getElementsByTagNameNS(self,namespaceURI,localName): _getElementsByTagNameNSHelper( self, namespaceURI, localName ) def close( self ): for node in self.elements: _closeElement( node ) def unlink( self ): self.documentElement=None Node.unlink( self ) def getElementsByTagName( self, name ): rc=[] _getElementsByTagNameHelper( self, name, rc ) return rc def writexml( self, writer ): for node in self.childNodes: node.writexml( writer ) def _doparse( func, args, kwargs ): events=apply( func, args, kwargs ) (toktype, rootNode)=events.getEvent() events.expandNode( rootNode ) return rootNode def parse( *args, **kwargs ): return _doparse( pulldom.parse, args, kwargs ) def parseString( *args, **kwargs ): return _doparse( pulldom.parseString, args, kwargs ) --- NEW FILE --- import minidom import types import string import sys import pyexpat from xml.sax import ExpatParser #todo: SAX2/namespace handling START_ELEMENT="START_ELEMENT" END_ELEMENT="END_ELEMENT" COMMENT="COMMENT" START_DOCUMENT="START_DOCUMENT" END_DOCUMENT="END_DOCUMENT" PROCESSING_INSTRUCTION="PROCESSING_INSTRUCTION" IGNORABLE_WHITESPACE="IGNORABLE_WHITESPACE" CHARACTERS="CHARACTERS" class PullDOM: def __init__( self ): self.firstEvent=[None,None] self.lastEvent=self.firstEvent def setDocumentLocator( self, locator ): pass def startElement( self, tagName , attrs ): if not hasattr( self, "curNode" ): # FIXME: hack! self.startDocument( ) node = self.document.createElement( tagName ) #FIXME namespaces! for attr in attrs.keys(): node.setAttribute( attr, attrs[attr] ) parent=self.curNode node.parentNode = parent if parent.childNodes: node.previousSibling=parent.childNodes[-1] node.previousSibling.nextSibling=node self.curNode = node # FIXME: do I have to screen namespace attributes self.lastEvent[1]=[(START_ELEMENT, node), None ] self.lastEvent=self.lastEvent[1] #self.events.append( (START_ELEMENT, node) ) def endElement( self, name ): node = self.curNode self.lastEvent[1]=[(END_ELEMENT, node), None ] self.lastEvent=self.lastEvent[1] #self.events.append( (END_ELEMENT, node )) self.curNode = node.parentNode def comment( self, s): node = self.document.createComment ( s ) parent=self.curNode node.parentNode=parent if parent.childNodes: node.previousSibling=parent.childNodes[-1] node.previousSibling.nextSibling=node self.lastEvent[1]=[(COMMENT, node), None ] self.lastEvent=self.lastEvent[1] #self.events.append( (COMMENT, node )) def processingInstruction( self, target, data ): node = self.document.createProcessingInstruction( target, data ) #self.appendChild( node ) parent=self.curNode node.parentNode=parent if parent.childNodes: node.previousSibling=parent.childNodes[-1] node.previousSibling.nextSibling=node self.lastEvent[1]=[(PROCESSING_INSTRUCTION, node), None ] self.lastEvent=self.lastEvent[1] #self.events.append( (PROCESSING_INSTRUCTION, node) ) def ignorableWhitespace( self, chars ): node = self.document.createTextNode( chars[start:start+length] ) parent=self.curNode node.parentNode=parent if parent.childNodes: node.previousSibling=parent.childNodes[-1] node.previousSibling.nextSibling=node self.lastEvent[1]=[(IGNORABLE_WHITESPACE, node), None ] self.lastEvent=self.lastEvent[1] #self.events.append( (IGNORABLE_WHITESPACE, node)) def characters( self, chars ): node = self.document.createTextNode( chars ) node.parentNode=self.curNode self.lastEvent[1]=[(CHARACTERS, node), None ] self.lastEvent=self.lastEvent[1] def startDocument( self ): node = self.curNode = self.document = minidom.Document() node.parentNode=None self.lastEvent[1]=[(START_DOCUMENT, node), None ] self.lastEvent=self.lastEvent[1] #self.events.append( (START_DOCUMENT, node) ) def endDocument( self ): assert( not self.curNode.parentNode ) for node in self.curNode.childNodes: if node.nodeType==node.ELEMENT_NODE: self.document.documentElement = node #if not self.document.documentElement: # raise Error, "No document element" self.lastEvent[1]=[(END_DOCUMENT, node), None ] #self.events.append( (END_DOCUMENT, self.curNode) ) class ErrorHandler: def warning( self, exception ): print exception def error( self, exception ): raise exception def fatalError( self, exception ): raise exception class DOMEventStream: def __init__( self, stream, parser, bufsize ): self.stream=stream self.parser=parser self.bufsize=bufsize self.reset() def reset( self ): self.pulldom = PullDOM() self.parser.setContentHandler( self.pulldom ) def __getitem__( self, pos ): rc=self.getEvent() if rc: return rc raise IndexError def expandNode( self, node ): event=self.getEvent() while event: token,cur_node=event if cur_node is node: return if token !=END_ELEMENT: cur_node.parentNode.childNodes.append( cur_node ) event=self.getEvent() if node.nodeType==minidom.Node.DOCUMENT_NODE: for child in node.childNodes: if child.nodeType==minidom.Node.ELEMENT_NODE: node.documentElement=child def getEvent( self ): if not self.pulldom.firstEvent[1]: self.pulldom.lastEvent=self.pulldom.firstEvent while not self.pulldom.firstEvent[1]: buf=self.stream.read( self.bufsize ) if not buf: #FIXME: why doesn't Expat close work? #self.parser.close() return None self.parser.feed( buf ) rc=self.pulldom.firstEvent[1][0] self.pulldom.firstEvent[1]=self.pulldom.firstEvent[1][1] return rc # FIXME: sax2 #def _getParser( ): # from xml.sax.saxexts import make_parser # expat doesn't report errors properly! Figure it out # return make_parser() # return make_parser("xml.sax.drivers.drv_xmllib") def _getParser(): return ExpatParser() default_bufsize=(2**14)-20 # FIXME: move into sax package for common usage def parse( stream_or_string, parser=None, bufsize=default_bufsize ): if type( stream_or_string ) == type( "" ): stream=open( stream_or_string ) else: stream=stream_or_string if not parser: parser=_getParser() return DOMEventStream( stream, parser, bufsize ) def parseString( string, parser=None ): try: import cStringIO stringio=cStringIO.StringIO except ImportError: import StringIO stringio=StringIO.StringIO bufsize=len( string ) stringio( string ) parser=_getParser() return DOMEventStream( buf, parser, bufsize ) #FIXME: Use Lars' instead!!! class SAX_expat: "SAX driver for the Pyexpat C module." def __init__(self): self.parser=pyexpat.ParserCreate() self.started=0 def setDocumentHandler( self, handler ): self.parser.StartElementHandler = handler.startElement self.parser.EndElementHandler = handler.endElement self.parser.CharacterDataHandler = handler.datachars self.parser.ProcessingInstructionHandler = handler.processingInstruction self.doc_handler=handler def setErrorHandler( self, handler ): self.err_handler=handler # --- Locator methods. Only usable after errors. def getLineNumber(self): return self.parser.ErrorLineNumber def getColumnNumber(self): return self.parser.ErrorColumnNumber # --- Internal def __report_error(self): msg=pyexpat.ErrorString(self.parser.ErrorCode) self.err_handler.fatalError(msg) # --- EXPERIMENTAL PYTHON SAX EXTENSIONS def get_parser_name(self): return "pyexpat" def get_parser_version(self): return "Unknown" def get_driver_version(self): return version def is_validating(self): return 0 def is_dtd_reading(self): return 0 def reset(self): self.parser=pyexpat.ParserCreate() self.parser.StartElementHandler = self.startElement self.parser.EndElementHandler = self.endElement self.parser.CharacterDataHandler = self.characters self.parser.ProcessingInstructionHandler = self.processingInstruction def feed(self,data): if not self.started: self.doc_handler.startDocument() self.started=1 if not self.parser.Parse(data): self.__report_error() def close(self): if not self.parser.Parse("",1): self.__report_error() self.doc_handler.endDocument() self.parser = None From python-dev@python.org Thu Jun 29 20:42:02 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:42:02 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_winreg.py,1.3,1.4 Message-ID: <200006291942.MAA05814@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv5802 Modified Files: test_winreg.py Log Message: The low-level interface is now in _winreg; update the import here. Index: test_winreg.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_winreg.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** test_winreg.py 2000/06/28 14:48:01 1.3 --- test_winreg.py 2000/06/29 19:42:00 1.4 *************** *** 2,6 **** # Only win32reg functions not hit here: FlushKey, LoadKey and SaveKey ! from winreg import * import os, sys --- 2,6 ---- # Only win32reg functions not hit here: FlushKey, LoadKey and SaveKey ! from _winreg import * import os, sys From python-dev@python.org Thu Jun 29 21:02:41 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 13:02:41 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/parser __init__.py,1.1,1.2 Message-ID: <200006292002.NAA08546@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/xml/parser In directory slayer.i.sourceforge.net:/tmp/cvs-serv8507 Modified Files: __init__.py Log Message: Typo. Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/parser/__init__.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** __init__.py 2000/06/29 19:36:27 1.1 --- __init__.py 2000/06/29 20:02:38 1.2 *************** *** 1,5 **** """Python interfaces to XML parsers. ! This package contains on module: expat -- Python wrapper for James Clark's Expat parser, with namespace --- 1,5 ---- """Python interfaces to XML parsers. ! This package contains one module: expat -- Python wrapper for James Clark's Expat parser, with namespace From python-dev@python.org Thu Jun 29 21:15:17 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 13:15:17 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/api api.tex,1.69,1.70 Message-ID: <200006292015.NAA14253@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/api In directory slayer.i.sourceforge.net:/tmp/cvs-serv14245 Modified Files: api.tex Log Message: Update comments relating to the removal of the -X option and of string exceptions in the interpreter and standard library. Index: api.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/api.tex,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -r1.69 -r1.70 *** api.tex 2000/06/28 15:53:13 1.69 --- api.tex 2000/06/29 20:15:14 1.70 *************** *** 939,952 **** \var{name} argument must be the name of the new exception, a C string of the form \code{module.class}. The \var{base} and ! \var{dict} arguments are normally \NULL{}. Normally, this creates a class object derived from the root for all exceptions, the built-in name \exception{Exception} (accessible in C as ! \cdata{PyExc_Exception}). In this case the \member{__module__} ! attribute of the new class is set to the first part (up to the last ! dot) of the \var{name} argument, and the class name is set to the last ! part (after the last dot). The ! \var{base} argument can be used to specify an alternate base class. ! The \var{dict} argument can be used to specify a dictionary of class ! variables and methods. \end{cfuncdesc} --- 939,951 ---- \var{name} argument must be the name of the new exception, a C string of the form \code{module.class}. The \var{base} and ! \var{dict} arguments are normally \NULL{}. This creates a class object derived from the root for all exceptions, the built-in name \exception{Exception} (accessible in C as ! \cdata{PyExc_Exception}). The \member{__module__} attribute of the ! new class is set to the first part (up to the last dot) of the ! \var{name} argument, and the class name is set to the last part (after ! the last dot). The \var{base} argument can be used to specify an ! alternate base class. The \var{dict} argument can be used to specify ! a dictionary of class variables and methods. \end{cfuncdesc} *************** *** 992,999 **** \begin{description} \item[(1)] ! This is a base class for other standard exceptions. If the ! \code{-X} interpreter option is used, these will be tuples ! containing the string exceptions which would have otherwise been ! subclasses. \end{description} --- 991,995 ---- \begin{description} \item[(1)] ! This is a base class for other standard exceptions. \end{description} *************** *** 1001,1010 **** \section{Deprecation of String Exceptions} ! The \code{-X} command-line option will be removed in Python 1.6. All ! exceptions built into Python or provided in the standard library will \withsubitem{(built-in exception)}{\ttindex{Exception}} - be classes derived from \exception{Exception}. ! String exceptions will still be supported in the interpreter to allow existing code to run unmodified, but this will also change in a future release. --- 997,1005 ---- \section{Deprecation of String Exceptions} ! All exceptions built into Python or provided in the standard library ! are derived from \exception{Exception}. \withsubitem{(built-in exception)}{\ttindex{Exception}} ! String exceptions are still supported in the interpreter to allow existing code to run unmodified, but this will also change in a future release. From python-dev@python.org Thu Jun 29 21:44:49 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 13:44:49 -0700 Subject: [Python-checkins] CVS: python/dist/src/PC config.h,1.37,1.38 Message-ID: <200006292044.NAA16854@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv16828/PC Modified Files: config.h Log Message: This patch extends PC/config.h and configure.in as appropriate for 64-bit readiness (the config values are needed for patches that I will be submitting later today. The changes are as follows: - add SIZEOF_OFF_T #define's to PC/config.h (it was already in configure.in) - add SIZEOF_TIME_T #define to PC/config.h and configure Needed for some buffer overflow checking because sizeof(time_t) is different on Win64. - add SIZEOF_FPOS_T #define Needed for the Win64 large file support implementation. - add SIZEOF_HKEY in PC/config.h only Needed for proper Win32 vs. Win64 handling in PC/winreg.c - #define HAVE_LARGEFILE_SUPPORT for Win64 - typedef long intptr_t; for all Windows except Win64 (which defines it itself) This is a new ANSI (I think) type that is useful (and used by me) for proper handling in msvcrtmodule.c and posixmodule.c - indent the nested #ifdef's and #defines in PC/config.h This is *so* much more readable. There cannot be a compiler compatibilty issue here can there? Perl uses indented #defines and it compiles with everything. Index: config.h =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/config.h,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -r1.37 -r1.38 *** config.h 2000/06/28 03:54:48 1.37 --- config.h 2000/06/29 20:44:47 1.38 *************** *** 242,262 **** /* End of compilers - finish up */ #if defined(MS_WIN64) /* maintain "win32" sys.platform for backward compatibility of Python code, the Win64 API should be close enough to the Win32 API to make this preferable */ ! #define PLATFORM "win32" ! #define SIZEOF_VOID_P 8 #elif defined(MS_WIN32) ! #define PLATFORM "win32" ! #ifdef _M_ALPHA ! #define SIZEOF_VOID_P 8 ! #else ! #define SIZEOF_VOID_P 4 ! #endif #elif defined(MS_WIN16) ! #define PLATFORM "win16" #else ! #define PLATFORM "dos" #endif --- 242,284 ---- /* End of compilers - finish up */ + /* define the ANSI intptr_t type for portable use of a pointer sized + integer */ + #include + #if defined(MS_WINDOWS) && !defined(MS_WIN64) + typedef long intptr_t; + #endif + #if defined(MS_WIN64) /* maintain "win32" sys.platform for backward compatibility of Python code, the Win64 API should be close enough to the Win32 API to make this preferable */ ! # define PLATFORM "win32" ! # define SIZEOF_VOID_P 8 ! # define SIZEOF_TIME_T 8 ! # define SIZEOF_OFF_T 4 ! # define SIZEOF_FPOS_T 8 ! # define SIZEOF_HKEY 8 ! /* configure.in defines HAVE_LARGEFILE_SUPPORT iff HAVE_LONG_LONG, ! sizeof(off_t) > sizeof(long), and sizeof(LONG_LONG) >= sizeof(off_t). ! On Win64 the second condition is not true, but if fpos_t replaces off_t ! then this is true. The uses of HAVE_LARGEFILE_SUPPORT imply that Win64 ! should define this. */ ! # define HAVE_LARGEFILE_SUPPORT #elif defined(MS_WIN32) ! # define PLATFORM "win32" ! # ifdef _M_ALPHA ! # define SIZEOF_VOID_P 8 ! # define SIZEOF_TIME_T 8 ! # else ! # define SIZEOF_VOID_P 4 ! # define SIZEOF_TIME_T 4 ! # define SIZEOF_OFF_T 4 ! # define SIZEOF_FPOS_T 8 ! # define SIZEOF_HKEY 4 ! # endif #elif defined(MS_WIN16) ! # define PLATFORM "win16" #else ! # define PLATFORM "dos" #endif From python-dev@python.org Thu Jun 29 21:44:49 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 13:44:49 -0700 Subject: [Python-checkins] CVS: python/dist/src acconfig.h,1.29,1.30 config.h.in,2.57,2.58 configure.in,1.127,1.128 Message-ID: <200006292044.NAA16852@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv16828 Modified Files: acconfig.h config.h.in configure.in Log Message: This patch extends PC/config.h and configure.in as appropriate for 64-bit readiness (the config values are needed for patches that I will be submitting later today. The changes are as follows: - add SIZEOF_OFF_T #define's to PC/config.h (it was already in configure.in) - add SIZEOF_TIME_T #define to PC/config.h and configure Needed for some buffer overflow checking because sizeof(time_t) is different on Win64. - add SIZEOF_FPOS_T #define Needed for the Win64 large file support implementation. - add SIZEOF_HKEY in PC/config.h only Needed for proper Win32 vs. Win64 handling in PC/winreg.c - #define HAVE_LARGEFILE_SUPPORT for Win64 - typedef long intptr_t; for all Windows except Win64 (which defines it itself) This is a new ANSI (I think) type that is useful (and used by me) for proper handling in msvcrtmodule.c and posixmodule.c - indent the nested #ifdef's and #defines in PC/config.h This is *so* much more readable. There cannot be a compiler compatibilty issue here can there? Perl uses indented #defines and it compiles with everything. Index: acconfig.h =================================================================== RCS file: /cvsroot/python/python/dist/src/acconfig.h,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -r1.29 -r1.30 *** acconfig.h 2000/05/08 13:41:37 1.29 --- acconfig.h 2000/06/29 20:44:46 1.30 *************** *** 152,155 **** --- 152,158 ---- #undef SIZEOF_OFF_T + /* The number of bytes in a time_t. */ + #undef SIZEOF_TIME_T + /* Defined to enable large file support when an off_t is bigger than a long and long long is available and at least as big as an off_t. You may need Index: config.h.in =================================================================== RCS file: /cvsroot/python/python/dist/src/config.h.in,v retrieving revision 2.57 retrieving revision 2.58 diff -C2 -r2.57 -r2.58 *** config.h.in 2000/06/29 16:12:00 2.57 --- config.h.in 2000/06/29 20:44:46 2.58 *************** *** 214,217 **** --- 214,220 ---- #undef SIZEOF_OFF_T + /* The number of bytes in a time_t. */ + #undef SIZEOF_TIME_T + /* Defined to enable large file support when an off_t is bigger than a long and long long is available and at least as big as an off_t. You may need *************** *** 235,238 **** --- 238,244 ---- #undef SIZEOF_FLOAT + /* The number of bytes in a fpos_t. */ + #undef SIZEOF_FPOS_T + /* The number of bytes in a int. */ #undef SIZEOF_INT *************** *** 543,546 **** --- 549,555 ---- /* Define if you have the header file. */ #undef HAVE_SYS_SELECT_H + + /* Define if you have the header file. */ + #undef HAVE_SYS_SOCKET_H /* Define if you have the header file. */ Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.127 retrieving revision 1.128 diff -C2 -r1.127 -r1.128 *** configure.in 2000/06/29 16:12:00 1.127 --- configure.in 2000/06/29 20:44:46 1.128 *************** *** 390,393 **** --- 390,394 ---- AC_CHECK_SIZEOF(float) AC_CHECK_SIZEOF(double) + AC_CHECK_SIZEOF(fpos_t) AC_MSG_CHECKING(for long long support) *************** *** 424,427 **** --- 425,444 ---- AC_MSG_RESULT(no) fi + + # AC_CHECK_SIZEOF() doesn't include . + AC_MSG_CHECKING(size of time_t) + AC_CACHE_VAL(ac_cv_sizeof_time_t, + [AC_TRY_RUN([#include + #include + main() + { + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", sizeof(time_t)); + exit(0); + }], ac_cv_sizeof_time_t=`cat conftestval`, ac_cv_sizeof_time_t=0) + ]) + AC_MSG_RESULT($ac_cv_sizeof_time_t) + AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t) From python-dev@python.org Thu Jun 29 21:56:32 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 13:56:32 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules timemodule.c,2.84,2.85 Message-ID: <200006292056.NAA17660@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv17653/Modules Modified Files: timemodule.c Log Message: Trent Mick : Mark Hammond provided (a long time ago) a better Win32 specific time_clock implementation in timemodule.c. The library for this implementation does not exist on Win64 (yet, at least). This patch makes Win64 fall back on the system's clock() function for time_clock(). This closes SourceForge patch #100512. Index: timemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/timemodule.c,v retrieving revision 2.84 retrieving revision 2.85 diff -C2 -r2.84 -r2.85 *** timemodule.c 2000/06/28 21:33:59 2.84 --- timemodule.c 2000/06/29 20:56:28 2.85 *************** *** 90,98 **** #endif /* !__WATCOMC__ || __QNX__ */ ! #ifdef MS_WIN32 ! /* Win32 has better clock replacement */ #include #undef HAVE_CLOCK /* We have our own version down below */ ! #endif /* MS_WIN32 */ #if defined(PYCC_VACPP) --- 90,99 ---- #endif /* !__WATCOMC__ || __QNX__ */ ! #if defined(MS_WIN32) && !defined(MS_WIN64) ! /* Win32 has better clock replacement ! XXX Win64 does not yet, but might when the platform matures. */ #include #undef HAVE_CLOCK /* We have our own version down below */ ! #endif /* MS_WIN32 && !MS_WIN64 */ #if defined(PYCC_VACPP) *************** *** 191,195 **** #endif /* HAVE_CLOCK */ ! #ifdef MS_WIN32 /* Due to Mark Hammond */ static PyObject * --- 192,196 ---- #endif /* HAVE_CLOCK */ ! #if defined(MS_WIN32) && !defined(MS_WIN64) /* Due to Mark Hammond */ static PyObject * *************** *** 227,231 **** #define HAVE_CLOCK /* So it gets included in the methods */ ! #endif /* MS_WIN32 */ #ifdef HAVE_CLOCK --- 228,232 ---- #define HAVE_CLOCK /* So it gets included in the methods */ ! #endif /* MS_WIN32 && !MS_WIN64 */ #ifdef HAVE_CLOCK From python-dev@python.org Thu Jun 29 22:12:48 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 14:12:48 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules posixmodule.c,2.137,2.138 Message-ID: <200006292112.OAA24946@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv24938/Modules Modified Files: posixmodule.c Log Message: Trent Mick : This patch fixes the posix module for large file support mainly on Win64, although some general cleanup is done as well. The changes are: - abstract stat->STAT, fstat->FSTAT, and struct stat->STRUCT_STAT This is because stat() etc. are not the correct functions to use on Win64 (nor maybe on other platforms?, if not then it is now trivial to select the appropriate one). On Win64 the appropriate system functions are _stati64(), etc. - add _pystat_fromstructstat(), it builds the return tuple for the fstat system call. This functionality was being duplicated. As well the construction of the tuple was modified to ensure no overflow of the time_t elements (sizeof(time_t) > sizeof(long) on Win64). - add overflow protection for the return values of posix_spawnv and posix_spawnve - use the proper 64-bit capable lseek() on Win64 - use intptr_t instead of long where appropriate from Win32/64 blocks (sizeof(void*) > sizeof(long) on Win64) This closes SourceForge patch #100513. Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.137 retrieving revision 2.138 diff -C2 -r2.137 -r2.138 *** posixmodule.c 2000/06/28 16:40:38 2.137 --- posixmodule.c 2000/06/29 21:12:41 2.138 *************** *** 285,288 **** --- 285,300 ---- #endif + /* choose the appropriate stat and fstat functions and return structs */ + #ifdef MS_WIN64 + # define STAT _stati64 + # define FSTAT _fstati64 + # define STRUCT_STAT struct _stati64 + #else + # define STAT stat + # define FSTAT fstat + # define STRUCT_STAT struct stat + #endif + + /* Return a dictionary corresponding to the POSIX environment table */ *************** *** 540,543 **** --- 552,605 ---- } + + + /* pack a system stat C structure into the Python stat tuple + (used by posix_stat() and posix_fstat()) */ + static PyObject* + _pystat_fromstructstat(st) + STRUCT_STAT st; + { + PyObject *v = PyTuple_New(10); + if (v == NULL) + return NULL; + + PyTuple_SetItem(v, 0, PyInt_FromLong((long)st.st_mode)); + #ifdef HAVE_LARGEFILE_SUPPORT + PyTuple_SetItem(v, 1, PyLong_FromLongLong((LONG_LONG)st.st_ino)); + #else + PyTuple_SetItem(v, 1, PyInt_FromLong((long)st.st_ino)); + #endif + #if defined(HAVE_LONG_LONG) && !defined(MS_WINDOWS) + PyTuple_SetItem(v, 2, PyLong_FromLongLong((LONG_LONG)st.st_dev)); + #else + PyTuple_SetItem(v, 2, PyInt_FromLong((long)st.st_dev)); + #endif + PyTuple_SetItem(v, 3, PyInt_FromLong((long)st.st_nlink)); + PyTuple_SetItem(v, 4, PyInt_FromLong((long)st.st_uid)); + PyTuple_SetItem(v, 5, PyInt_FromLong((long)st.st_gid)); + #ifdef HAVE_LARGEFILE_SUPPORT + PyTuple_SetItem(v, 6, PyLong_FromLongLong((LONG_LONG)st.st_size)); + #else + PyTuple_SetItem(v, 6, PyInt_FromLong(st.st_size)); + #endif + #if SIZEOF_TIME_T > SIZEOF_LONG + PyTuple_SetItem(v, 7, PyLong_FromLongLong((LONG_LONG)st.st_atime)); + PyTuple_SetItem(v, 8, PyLong_FromLongLong((LONG_LONG)st.st_mtime)); + PyTuple_SetItem(v, 9, PyLong_FromLongLong((LONG_LONG)st.st_ctime)); + #else + PyTuple_SetItem(v, 7, PyInt_FromLong((long)st.st_atime)); + PyTuple_SetItem(v, 8, PyInt_FromLong((long)st.st_mtime)); + PyTuple_SetItem(v, 9, PyInt_FromLong((long)st.st_ctime)); + #endif + + if (PyErr_Occurred()) { + Py_DECREF(v); + return NULL; + } + + return v; + } + + static PyObject * posix_do_stat(self, args, format, statfunc) *************** *** 545,551 **** PyObject *args; char *format; ! int (*statfunc) Py_FPROTO((const char *, struct stat *)); { ! struct stat st; char *path; int res; --- 607,613 ---- PyObject *args; char *format; ! int (*statfunc) Py_FPROTO((const char *, STRUCT_STAT *)); { ! STRUCT_STAT st; char *path; int res; *************** *** 586,614 **** if (res != 0) return posix_error_with_filename(path); ! #if !defined(HAVE_LARGEFILE_SUPPORT) ! return Py_BuildValue("(llllllllll)", ! (long)st.st_mode, ! (long)st.st_ino, ! (long)st.st_dev, ! (long)st.st_nlink, ! (long)st.st_uid, ! (long)st.st_gid, ! (long)st.st_size, ! (long)st.st_atime, ! (long)st.st_mtime, ! (long)st.st_ctime); ! #else ! return Py_BuildValue("(lLllllLlll)", ! (long)st.st_mode, ! (LONG_LONG)st.st_ino, ! (long)st.st_dev, ! (long)st.st_nlink, ! (long)st.st_uid, ! (long)st.st_gid, ! (LONG_LONG)st.st_size, ! (long)st.st_atime, ! (long)st.st_mtime, ! (long)st.st_ctime); ! #endif } --- 648,653 ---- if (res != 0) return posix_error_with_filename(path); ! ! return _pystat_fromstructstat(st); } *************** *** 1159,1163 **** PyObject *args; { ! return posix_do_stat(self, args, "s:stat", stat); } --- 1198,1202 ---- PyObject *args; { ! return posix_do_stat(self, args, "s:stat", STAT); } *************** *** 1547,1550 **** --- 1586,1590 ---- char **argvlist; int mode, i, argc; + intptr_t spawnval; PyObject *(*getitem) Py_PROTO((PyObject *, int)); *************** *** 1582,1593 **** if (mode == _OLD_P_OVERLAY) mode = _P_OVERLAY; ! i = _spawnv(mode, path, argvlist); PyMem_DEL(argvlist); ! if (i == -1) return posix_error(); else ! return Py_BuildValue("i", i); } --- 1622,1637 ---- if (mode == _OLD_P_OVERLAY) mode = _P_OVERLAY; ! spawnval = _spawnv(mode, path, argvlist); PyMem_DEL(argvlist); ! if (spawnval == -1) return posix_error(); else ! #if SIZEOF_LONG == SIZE_VOID_P ! return Py_BuildValue("l", spawnval); ! #else ! return Py_BuildValue("L", spawnval); ! #endif } *************** *** 1613,1616 **** --- 1657,1661 ---- PyObject *key, *val, *keys=NULL, *vals=NULL, *res=NULL; int mode, i, pos, argc, envc; + intptr_t spawnval; PyObject *(*getitem) Py_PROTO((PyObject *, int)); *************** *** 1690,1698 **** if (mode == _OLD_P_OVERLAY) mode = _P_OVERLAY; ! i = _spawnve(mode, path, argvlist, envlist); ! if (i == -1) (void) posix_error(); else ! res = Py_BuildValue("i", i); fail_2: --- 1735,1747 ---- if (mode == _OLD_P_OVERLAY) mode = _P_OVERLAY; ! spawnval = _spawnve(mode, path, argvlist, envlist); ! if (spawnval == -1) (void) posix_error(); else ! #if SIZEOF_LONG == SIZE_VOID_P ! res = Py_BuildValue("l", spawnval); ! #else ! res = Py_BuildValue("L", spawnval); ! #endif fail_2: *************** *** 2329,2333 **** return posix_do_stat(self, args, "s:lstat", lstat); #else /* !HAVE_LSTAT */ ! return posix_do_stat(self, args, "s:lstat", stat); #endif /* !HAVE_LSTAT */ } --- 2378,2382 ---- return posix_do_stat(self, args, "s:lstat", lstat); #else /* !HAVE_LSTAT */ ! return posix_do_stat(self, args, "s:lstat", STAT); #endif /* !HAVE_LSTAT */ } *************** *** 2653,2657 **** --- 2702,2710 ---- { int fd, how; + #ifdef MS_WIN64 + LONG_LONG pos, res; + #else off_t pos, res; + #endif PyObject *posobj; if (!PyArg_ParseTuple(args, "iOi:lseek", &fd, &posobj, &how)) *************** *** 2676,2680 **** --- 2729,2737 ---- Py_BEGIN_ALLOW_THREADS + #ifdef MS_WIN64 + res = _lseeki64(fd, pos, how); + #else res = lseek(fd, pos, how); + #endif Py_END_ALLOW_THREADS if (res < 0) *************** *** 2750,2787 **** { int fd; ! struct stat st; int res; if (!PyArg_ParseTuple(args, "i:fstat", &fd)) return NULL; Py_BEGIN_ALLOW_THREADS ! res = fstat(fd, &st); Py_END_ALLOW_THREADS if (res != 0) return posix_error(); ! #if !defined(HAVE_LARGEFILE_SUPPORT) ! return Py_BuildValue("(llllllllll)", ! (long)st.st_mode, ! (long)st.st_ino, ! (long)st.st_dev, ! (long)st.st_nlink, ! (long)st.st_uid, ! (long)st.st_gid, ! (long)st.st_size, ! (long)st.st_atime, ! (long)st.st_mtime, ! (long)st.st_ctime); ! #else ! return Py_BuildValue("(lLllllLlll)", ! (long)st.st_mode, ! (LONG_LONG)st.st_ino, ! (long)st.st_dev, ! (long)st.st_nlink, ! (long)st.st_uid, ! (long)st.st_gid, ! (LONG_LONG)st.st_size, ! (long)st.st_atime, ! (long)st.st_mtime, ! (long)st.st_ctime); ! #endif } --- 2807,2821 ---- { int fd; ! STRUCT_STAT st; int res; if (!PyArg_ParseTuple(args, "i:fstat", &fd)) return NULL; Py_BEGIN_ALLOW_THREADS ! res = FSTAT(fd, &st); Py_END_ALLOW_THREADS if (res != 0) return posix_error(); ! ! return _pystat_fromstructstat(st); } *************** *** 2864,2869 **** if (!ok) return posix_error(); ! read_fd = _open_osfhandle((long)read, 0); ! write_fd = _open_osfhandle((long)write, 1); return Py_BuildValue("(ii)", read_fd, write_fd); #endif /* MS_WIN32 */ --- 2898,2903 ---- if (!ok) return posix_error(); ! read_fd = _open_osfhandle((intptr_t)read, 0); ! write_fd = _open_osfhandle((intptr_t)write, 1); return Py_BuildValue("(ii)", read_fd, write_fd); #endif /* MS_WIN32 */ *************** *** 3527,3533 **** if (PyString_Check(arg)) { /* look up the value in the table using a binary search */ ! int lo = 0; ! int hi = tablesize; ! int cmp, mid; char *confname = PyString_AS_STRING(arg); while (lo < hi) { --- 3561,3568 ---- if (PyString_Check(arg)) { /* look up the value in the table using a binary search */ ! size_t lo = 0; ! size_t mid; ! size_t hi = tablesize; ! int cmp; char *confname = PyString_AS_STRING(arg); while (lo < hi) { From python-dev@python.org Thu Jun 29 22:31:05 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 14:31:05 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules timemodule.c,2.85,2.86 Message-ID: <200006292131.OAA26110@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv26103/Modules Modified Files: timemodule.c Log Message: Trent Mick : This patch fixes a possible overflow in the Sleep system call on Win32/64 in the time_sleep() function in the time module. For very large values of the give time to sleep the number of milliseconds can overflow and give unexpected sleep intervals. THis patch raises an OverflowError if the value overflows. Closes SourceForge patch #100514. Index: timemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/timemodule.c,v retrieving revision 2.85 retrieving revision 2.86 diff -C2 -r2.85 -r2.86 *** timemodule.c 2000/06/29 20:56:28 2.85 --- timemodule.c 2000/06/29 21:31:02 2.86 *************** *** 836,843 **** #else /* !MSDOS */ #ifdef MS_WIN32 ! /* XXX Can't interrupt this sleep */ ! Py_BEGIN_ALLOW_THREADS ! Sleep((int)(secs*1000)); ! Py_END_ALLOW_THREADS #else /* !MS_WIN32 */ #ifdef PYOS_OS2 --- 836,850 ---- #else /* !MSDOS */ #ifdef MS_WIN32 ! { ! double millisecs = secs * 1000.0; ! if (millisecs > (double)ULONG_MAX) { ! PyErr_SetString(PyExc_OverflowError, "sleep length is too large"); ! return -1; ! } ! /* XXX Can't interrupt this sleep */ ! Py_BEGIN_ALLOW_THREADS ! Sleep((unsigned long)millisecs); ! Py_END_ALLOW_THREADS ! } #else /* !MS_WIN32 */ #ifdef PYOS_OS2 From python-dev@python.org Thu Jun 29 23:28:46 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 29 Jun 2000 15:28:46 -0700 Subject: [Python-checkins] CVS: python/dist/src README,1.85,1.86 Message-ID: <200006292228.PAA03569@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv3562 Modified Files: README Log Message: Tentative 2.0 and BeOpen upgrade. Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/README,v retrieving revision 1.85 retrieving revision 1.86 diff -C2 -r1.85 -r1.86 *** README 2000/04/11 17:11:09 1.85 --- README 2000/06/29 22:28:44 1.86 *************** *** 1,8 **** ! This is Python version 1.6 ========================== ! There are various alpha and beta versions -- these are distinguishable ! through Include/patchlevel.h or by the name of the top-level directory ! and the tar file. --- 1,8 ---- ! This is Python version 2.0 ========================== ! There are various beta versions -- these are distinguishable through ! Include/patchlevel.h or by the name of the top-level directory and the ! tar file. *************** *** 10,16 **** --------------------------- ! See http://www.python.org/1.6/. If you don't read instructions ------------------------------ --- 10,32 ---- --------------------------- ! See http://www.pythonlabs.com/. + Why is it called version 2.0? + ----------------------------- + + While Pythoneers have grown fond of Python's exceedingly slow version + incrementing, that same quality makes parts of the rest of the world + think that Python is barely out of its first alpha test. Especially + enterprise customers are often fearful of anything that's version 1.x! + The new version number also clearly marks departure of Python's core + development teal from CNRI to join BeOpen.com. + + Previously, the version number 2.0 was associated with a mythical and + elusive incompatible future release. That release (still ways off, + and not as incompatible as people fear!) is now referred to as Python + 3000. + + If you don't read instructions ------------------------------ *************** *** 68,71 **** --- 84,88 ---- + Build instructions ================== *************** *** 106,110 **** If you run into other trouble, see section 3 of the FAQ ! (http://grail.cnri.reston.va.us/cgi-bin/faqw.py or http://www.python.org/doc/FAQ.html) for hints on what can go wrong, and how to fix it. --- 123,127 ---- If you run into other trouble, see section 3 of the FAQ ! (http://www.python.org/cgi-bin/faqw.py or http://www.python.org/doc/FAQ.html) for hints on what can go wrong, and how to fix it. *************** *** 468,477 **** All subdirectories created will have Python's version number in their name, e.g. the library modules are installed in ! "/usr/local/lib/python1.6/" by default. The Python binary is ! installed as "python1.6" and a hard link named "python" is created. The only file not installed with a version number in its name is the manual page, installed as "/usr/local/man/man1/python.1" by default. ! If you have a previous installation of a pre-1.6 Python that you don't want to replace yet, use --- 485,494 ---- All subdirectories created will have Python's version number in their name, e.g. the library modules are installed in ! "/usr/local/lib/python2.0/" by default. The Python binary is ! installed as "python2.0" and a hard link named "python" is created. The only file not installed with a version number in its name is the manual page, installed as "/usr/local/man/man1/python.1" by default. ! If you have a previous installation of a pre-2.0 Python that you don't want to replace yet, use *************** *** 479,483 **** This installs the same set of files as "make install" except it ! doesn't create the hard link to "python1.6" named "python" and it doesn't install the manual page at all. --- 496,500 ---- This installs the same set of files as "make install" except it ! doesn't create the hard link to "python2.0" named "python" and it doesn't install the manual page at all. *************** *** 680,684 **** Misc/python-mode.el. Originally written by the famous Tim Peters, it is now maintained by the equally famous Barry Warsaw ! . The latest version, along with various other contributed Python-related Emacs goodies, is online at . And if you are planning to --- 697,701 ---- Misc/python-mode.el. Originally written by the famous Tim Peters, it is now maintained by the equally famous Barry Warsaw ! . The latest version, along with various other contributed Python-related Emacs goodies, is online at . And if you are planning to *************** *** 832,850 **** config.log Log from last configure run config.status Status from last run of configure script ! libpython1.6.a The library archive python The executable interpreter tags, TAGS Tags files for vi and Emacs ! Author's address ! ================ Guido van Rossum ! CNRI ! 1895 Preston White Drive ! Reston, VA 20191 ! USA ! E-mail: guido@cnri.reston.va.us or guido@python.org --- 849,867 ---- config.log Log from last configure run config.status Status from last run of configure script ! libpython2.0.a The library archive python The executable interpreter tags, TAGS Tags files for vi and Emacs ! ! How to reach the author ! ======================= Guido van Rossum ! BeOpen.com ! 160 Saratoga Avenue, Suite 46 ! Santa Clara, CA 95051 ! E-mail: guido@beopen.com or guido@python.org *************** *** 854,888 **** The Python source is copyrighted, but you can freely use and copy it ! as long as you don't change or remove the copyright notice: ! ! ---------------------------------------------------------------------- ! Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, ! The Netherlands. ! ! All Rights Reserved ! ! Permission to use, copy, modify, and distribute this software and its ! documentation for any purpose and without fee is hereby granted, ! provided that the above copyright notice appear in all copies and that ! both that copyright notice and this permission notice appear in ! supporting documentation, and that the names of Stichting Mathematisch ! Centrum or CWI or Corporation for National Research Initiatives or ! CNRI not be used in advertising or publicity pertaining to ! distribution of the software without specific, written prior ! permission. ! ! While CWI is the initial source for this software, a modified version ! is made available by the Corporation for National Research Initiatives ! (CNRI) at the Internet address ftp://ftp.python.org. ! ! STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH ! REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF ! MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH ! CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL ! DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR ! PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER ! TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR ! PERFORMANCE OF THIS SOFTWARE. ! ---------------------------------------------------------------------- --- 871,876 ---- The Python source is copyrighted, but you can freely use and copy it ! as long as you don't change or remove the copyright notice. The ! copyright notice is found in the Misc/COPYRIGHT file. From python-dev@python.org Thu Jun 29 23:29:26 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 29 Jun 2000 15:29:26 -0700 Subject: [Python-checkins] CVS: python/dist/src/Include patchlevel.h,2.35,2.36 Message-ID: <200006292229.PAA03595@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Include In directory slayer.i.sourceforge.net:/tmp/cvs-serv3588 Modified Files: patchlevel.h Log Message: Bump version to 2.0b1. Index: patchlevel.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/patchlevel.h,v retrieving revision 2.35 retrieving revision 2.36 diff -C2 -r2.35 -r2.36 *** patchlevel.h 2000/04/06 15:01:30 2.35 --- patchlevel.h 2000/06/29 22:29:24 2.36 *************** *** 50,64 **** /* Version parsed out into numeric values */ ! #define PY_MAJOR_VERSION 1 ! #define PY_MINOR_VERSION 6 #define PY_MICRO_VERSION 0 ! #define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_ALPHA ! #define PY_RELEASE_SERIAL 2 /* Version as a string */ ! #define PY_VERSION "1.6a2" /* Historic */ ! #define PATCHLEVEL "1.6a2" /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. --- 50,64 ---- /* Version parsed out into numeric values */ ! #define PY_MAJOR_VERSION 2 ! #define PY_MINOR_VERSION 0 #define PY_MICRO_VERSION 0 ! #define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_BETA ! #define PY_RELEASE_SERIAL 1 /* Version as a string */ ! #define PY_VERSION "2.0b1" /* Historic */ ! #define PATCHLEVEL "2.0b1" /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. From python-dev@python.org Thu Jun 29 23:30:39 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 29 Jun 2000 15:30:39 -0700 Subject: [Python-checkins] CVS: python/dist/src/PC python_nt.rc,1.9,1.10 Message-ID: <200006292230.PAA03748@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv3737 Modified Files: python_nt.rc Log Message: Bump version to 2.0b1. Change copyright to BeOpen, CNRI, SMC. Index: python_nt.rc =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/python_nt.rc,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** python_nt.rc 2000/03/30 22:59:09 1.9 --- python_nt.rc 2000/06/29 22:30:37 1.10 *************** *** 9,18 **** #include "patchlevel.h" ! #define MS_DLL_ID "1.6" #define PYTHON_VERSION MS_DLL_ID "." PYTHON_API_STRING "\0" #ifndef PYTHON_DLL_NAME ! #define PYTHON_DLL_NAME "Python16.dll" #endif --- 9,18 ---- #include "patchlevel.h" ! #define MS_DLL_ID "2.0" #define PYTHON_VERSION MS_DLL_ID "." PYTHON_API_STRING "\0" #ifndef PYTHON_DLL_NAME ! #define PYTHON_DLL_NAME "Python20.dll" #endif *************** *** 45,53 **** BLOCK "000004b0" BEGIN ! VALUE "CompanyName", "Corporation for National Research Initatives\0" VALUE "FileDescription", "Python Core\0" VALUE "FileVersion", PYTHON_VERSION VALUE "InternalName", "Python DLL\0" ! VALUE "LegalCopyright", "Copyright © 1991-1995 Stichting Mathematisch Centrum, Amsterdam\0" VALUE "OriginalFilename", PYTHON_DLL_NAME "\0" VALUE "ProductName", "Python\0" --- 45,53 ---- BLOCK "000004b0" BEGIN ! VALUE "CompanyName", "BeOpen.com\0" VALUE "FileDescription", "Python Core\0" VALUE "FileVersion", PYTHON_VERSION VALUE "InternalName", "Python DLL\0" ! VALUE "LegalCopyright", "Copyright (c) 2000 BeOpen.com. Copyright (c) 1995-2000 CNRI. Copyright (c) 1990-1995 SMC.\0" VALUE "OriginalFilename", PYTHON_DLL_NAME "\0" VALUE "ProductName", "Python\0" From python-dev@python.org Thu Jun 29 23:31:30 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 29 Jun 2000 15:31:30 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild python20.dsp,NONE,1.1 Message-ID: <200006292231.PAA03796@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv3789 Added Files: python20.dsp Log Message: Bump version to 2.0. --- NEW FILE --- # Microsoft Developer Studio Project File - Name="python20" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 # TARGTYPE "Win32 (ALPHA) Dynamic-Link Library" 0x0602 CFG=python20 - Win32 Alpha Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "python20.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "python20.mak" CFG="python20 - Win32 Alpha Debug" !MESSAGE !MESSAGE Possible choices for configuration are: [...1636 lines suppressed...] !ENDIF # End Source File # Begin Source File SOURCE=..\Modules\yuvconvert.c !IF "$(CFG)" == "python20 - Win32 Release" !ELSEIF "$(CFG)" == "python20 - Win32 Debug" !ELSEIF "$(CFG)" == "python20 - Win32 Alpha Debug" !ELSEIF "$(CFG)" == "python20 - Win32 Alpha Release" !ENDIF # End Source File # End Target # End Project From python-dev@python.org Thu Jun 29 23:32:10 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 29 Jun 2000 15:32:10 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild python20.wse,NONE,1.1 Message-ID: <200006292232.PAA03838@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv3830 Added Files: python20.wse Log Message: Bump version to 2.0. --- NEW FILE --- Document Type: WSE item: Global Version=5.0 Title=Python 2.0 alpha 2 Flags=00010100 Languages=65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Japanese Font Name=MS Gothic Japanese Font Size=10 Start Gradient=0 0 255 End Gradient=0 0 0 Windows Flags=00000100000000010010110100001000 Log Pathname=%MAINDIR%\INSTALL.LOG Message Font=MS Sans Serif Font Size=8 Disk Filename=SETUP Patch Flags=0000000000000001 Patch Threshold=85 Patch Memory=4000 Variable Name1=_SYS_ [...1206 lines suppressed...] Text=%APPTITLE% has been successfully installed. Text= Text=Press the Finish button to exit this installation. Text French=%APPTITLE% est maintenant installé. Text French= Text French=Cliquez sur le bouton Fin pour quitter l'installation. Text German=%APPTITLE% wurde erfolgreich installiert. Text German= Text German=Klicken Sie auf "Weiter", um die Installation zu beenden. Text Spanish=%APPTITLE% se ha instalado con éxito. Text Spanish= Text Spanish=Presione el botón Terminar para salir de esta instalación. Text Italian=L'installazione %APPTITLE% è stata portata a termine con successo. Text Italian= Text Italian=Premere il pulsante Fine per uscire dall'installazione. end end end item: End Block end From python-dev@python.org Thu Jun 29 23:57:58 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 29 Jun 2000 15:57:58 -0700 Subject: [Python-checkins] CVS: distutils/distutils cygwinccompiler.py,1.1,1.2 Message-ID: <200006292257.PAA05236@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv5227 Modified Files: cygwinccompiler.py Log Message: Cleaned up and reformatted by Rene Liebscher. More reformatting by me. Also added some editorial comments. Index: cygwinccompiler.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/cygwinccompiler.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** cygwinccompiler.py 2000/06/21 03:33:03 1.1 --- cygwinccompiler.py 2000/06/29 22:57:55 1.2 *************** *** 1,9 **** """distutils.cygwinccompiler ! Contains the CygwinCCompiler class, a subclass of UnixCCompiler that handles ! the Gnu Win32 C compiler. ! It also contains the Mingw32CCompiler class which handles the mingw32 compiler ! (same as cygwin in no-cygwin mode.) ! """ --- 1,8 ---- """distutils.cygwinccompiler ! Provides the CygwinCCompiler class, a subclass of UnixCCompiler that ! handles the Cygwin port of the GNU C compiler to Windows. It also contains ! the Mingw32CCompiler class which handles the mingw32 port of GCC (same as ! cygwin in no-cygwin mode). """ *************** *** 12,47 **** __revision__ = "$Id$" ! import os,sys,string,tempfile from distutils import sysconfig from distutils.unixccompiler import UnixCCompiler ! # Because these compilers aren't configured in Python's config.h file by default ! # we should at least warn the user if he used this unmodified version. ! def check_if_config_h_is_gcc_ready(): ! """ checks, if the gcc-compiler is mentioned in config.h ! if it is not, compiling probably doesn't work """ ! from distutils import sysconfig ! import string,sys try: ! # It would probably better to read single lines to search. ! # But we do this only once, and it is fast enough ! f=open(sysconfig.get_config_h_filename()) ! s=f.read() ! f.close() ! try: ! string.index(s,"__GNUC__") # is somewhere a #ifdef __GNUC__ or something similar ! except: ! sys.stderr.write ("warning: Python's config.h doesn't seem to support your compiler.\n") ! except: # unspecific error => ignore ! pass # This is called when the module is imported, so we make this check only once ! check_if_config_h_is_gcc_ready() - # XXX Things not currently handled: - # * see UnixCCompiler - class CygwinCCompiler (UnixCCompiler): --- 11,54 ---- __revision__ = "$Id$" ! import os,sys,string from distutils import sysconfig from distutils.unixccompiler import UnixCCompiler ! # Because these compilers aren't configured in Python's config.h file by ! # default we should at least warn the user if he is using a unmodified ! # version. ! ! def check_config_h(): ! """Checks if the GCC compiler is mentioned in config.h. If it is not, ! compiling probably doesn't work, so print a warning to stderr. ! """ ! ! # XXX the result of the check should be returned! ! ! from distutils import sysconfig ! import string,sys ! try: ! # It would probably better to read single lines to search. ! # But we do this only once, and it is fast enough ! f=open(sysconfig.get_config_h_filename()) ! s=f.read() ! f.close() try: ! # is somewhere a #ifdef __GNUC__ or something similar ! string.index(s,"__GNUC__") ! except ValueError: ! sys.stderr.write ("warning: "+ ! "Python's config.h doesn't seem to support your compiler.\n") ! except IOError: ! # if we can't read this file, we cannot say it is wrong ! # the compiler will complain later about this file as missing ! pass # This is called when the module is imported, so we make this check only once ! # XXX why not make it only when the compiler is needed? ! check_config_h() class CygwinCCompiler (UnixCCompiler): *************** *** 55,73 **** UnixCCompiler.__init__ (self, verbose, dry_run, force) ! # our compiler uses other names ! self.cc='gcc' ! self.ld_shared='dllwrap' ! self.ldflags_shared=[] ! ! # some variables to manage the differences between cygwin and mingw32 ! self.dllwrap_options=["--target=i386-cygwin32"] ! # specification of entry point is not necessary ! ! self.dll_additional_libraries=[ ! # cygwin shouldn't need msvcrt, but without the dll's will crash ! # perhaps something about initialization (Python uses it, too) # mingw32 needs it in all cases ! "msvcrt" ! ] # __init__ () --- 62,81 ---- UnixCCompiler.__init__ (self, verbose, dry_run, force) ! # Hard-code GCC because that's what this is all about. ! # XXX optimization, warnings etc. should be customizable. ! self.set_executables(compiler='gcc -O -Wall', ! compiler_so='gcc -O -Wall', ! linker_exe='gcc', ! linker_so='dllwrap --target=i386-cygwin32') ! ! # cygwin and mingw32 need different sets of libraries ! self.dll_libraries=[ ! # cygwin shouldn't need msvcrt, ! # but without the dll's will crash ! # ( gcc version 2.91.57 ) ! # perhaps something about initialization # mingw32 needs it in all cases ! "msvcrt" ! ] # __init__ () *************** *** 81,139 **** runtime_library_dirs=None, export_symbols=None, ! debug=0, extra_preargs=None, ! extra_postargs=None): ! ! if libraries==None: ! libraries=[] ! python_library=["python"+str(sys.hexversion>>24)+str((sys.hexversion>>16)&0xff)] ! libraries=libraries+python_library+self.dll_additional_libraries ! # if you don't need the def-file afterwards, it is ! # better to use for it tempfile.mktemp() as its name ! # (unix-style compilers don't like backslashes in filenames) ! win_dll_def_file=string.replace(tempfile.mktemp(),"\\","/") ! #win_dll_def_file=output_filename[:-len(self.shared_lib_extension)]+".def" ! #win_dll_exp_file=output_filename[:-len(self.shared_lib_extension)]+".exp" ! #win_dll_lib_file=output_filename[:-len(self.shared_lib_extension)]+".a" # Make .def file ! # (It would probably better to check if we really need this, but for this we had to ! # insert some unchanged parts of UnixCCompiler, and this is not what I want.) ! f=open(win_dll_def_file,"w") f.write("EXPORTS\n") # intro ! # always export a function "init"+module_name ! if not debug: ! f.write("init"+os.path.basename(output_filename)[:-len(self.shared_lib_extension)]+"\n") ! else: # in debug mode outfile_name is something like XXXXX_d.pyd ! f.write("init"+os.path.basename(output_filename)[:-(len(self.shared_lib_extension)+2)]+"\n") ! # if there are more symbols to export ! # insert code here to write them in f ! if export_symbols!=None: for sym in export_symbols: ! f.write(sym+"\n") f.close() ! if extra_preargs==None: ! extra_preargs=[] ! extra_preargs=extra_preargs+[ #"--verbose", ! #"--output-exp",win_dll_exp_file, ! #"--output-lib",win_dll_lib_file, ! "--def",win_dll_def_file ! ]+ self.dllwrap_options ! # who wants symbols and a many times greater output file # should explicitely switch the debug mode on ! # otherwise we let dllwrap strip the outputfile ! # (On my machine unstripped_file=stripped_file+254KB # 10KB < stripped_file < ??100KB ) if not debug: ! extra_preargs=extra_preargs+["-s"] ! ! try: ! UnixCCompiler.link_shared_object(self, objects, output_filename, --- 89,157 ---- runtime_library_dirs=None, export_symbols=None, ! debug=0, extra_preargs=None, ! extra_postargs=None, ! build_temp=None): ! if libraries == None: ! libraries = [] ! # Additional libraries: the python library is always needed on ! # Windows we need the python version without the dot, eg. '15' ! ! pythonlib = ("python%d%d" % ! (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff)) ! libraries.append(pythonlib) ! libraries.extend(self.dll_libraries) ! ! # name of extension ! ! # XXX WRONG WRONG WRONG ! # this is NOT the place to make guesses about Python namespaces; ! # that MUST be done in build_ext.py ! ! if not debug: ! ext_name = os.path.basename(output_filename)[:-len(".pyd")] ! else: ! ext_name = os.path.basename(output_filename)[:-len("_d.pyd")] ! ! def_file = os.path.join(build_temp, ext_name + ".def") ! #exp_file = os.path.join(build_temp, ext_name + ".exp") ! #lib_file = os.path.join(build_temp, 'lib' + ext_name + ".a") # Make .def file ! # (It would probably better to check if we really need this, ! # but for this we had to insert some unchanged parts of ! # UnixCCompiler, and this is not what we want.) ! f = open(def_file,"w") f.write("EXPORTS\n") # intro ! if export_symbols == None: ! # export a function "init" + ext_name ! f.write("init" + ext_name + "\n") ! else: ! # if there are more symbols to export write them into f for sym in export_symbols: ! f.write(sym+"\n") f.close() ! if extra_preargs == None: ! extra_preargs = [] ! extra_preargs = extra_preargs + [ #"--verbose", ! #"--output-exp",exp_file, ! #"--output-lib",lib_file, ! "--def",def_file ! ] ! # who wants symbols and a many times larger output file # should explicitely switch the debug mode on ! # otherwise we let dllwrap strip the output file ! # (On my machine unstripped_file = stripped_file + 254KB # 10KB < stripped_file < ??100KB ) if not debug: ! extra_preargs = extra_preargs + ["-s"] ! ! UnixCCompiler.link_shared_object(self, objects, output_filename, *************** *** 142,152 **** library_dirs, runtime_library_dirs, ! None, # export_symbols, we do this with our def-file debug, extra_preargs, ! extra_postargs) ! finally: ! # we don't need the def-file anymore ! os.remove(win_dll_def_file) # link_shared_object () --- 160,168 ---- library_dirs, runtime_library_dirs, ! None, # export_symbols, we do this with our def-file debug, extra_preargs, ! extra_postargs, ! build_temp) # link_shared_object () *************** *** 154,157 **** --- 170,174 ---- # class CygwinCCompiler + # the same as cygwin plus some additional parameters class Mingw32CCompiler (CygwinCCompiler): *************** *** 165,177 **** CygwinCCompiler.__init__ (self, verbose, dry_run, force) - self.ccflags = self.ccflags + ["-mno-cygwin"] - self.dllwrap_options=[ - # mingw32 doesn't really need 'target' - # and cygwin too (it seems, it is enough - # to specify a different entry point) - #"--target=i386-mingw32", - "--entry","_DllMain@12" - ] # no additional libraries need # (only msvcrt, which is already added by CygwinCCompiler) --- 182,195 ---- CygwinCCompiler.__init__ (self, verbose, dry_run, force) + + self.set_executables(compiler='gcc -mno-cygwin -O -Wall', + compiler_so='gcc -mno-cygwin -O -Wall', + linker_exe='gcc -mno-cygwin', + linker_so='dllwrap' + + ' --target=i386-mingw32' + + ' --entry _DllMain@12') + # mingw32 doesn't really need 'target' and cygwin too (it seems, + # it is enough to specify a different entry point) # no additional libraries need # (only msvcrt, which is already added by CygwinCCompiler) From python-dev@python.org Thu Jun 29 23:59:13 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 29 Jun 2000 15:59:13 -0700 Subject: [Python-checkins] CVS: distutils/distutils msvccompiler.py,1.32,1.33 Message-ID: <200006292259.PAA05290@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv5280 Modified Files: msvccompiler.py Log Message: Changed to use _winreg module instead of winreg. Index: msvccompiler.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/msvccompiler.py,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -r1.32 -r1.33 *** msvccompiler.py 2000/06/28 01:29:09 1.32 --- msvccompiler.py 2000/06/29 22:59:10 1.33 *************** *** 21,32 **** _can_read_reg = 0 try: ! import winreg _can_read_reg = 1 ! hkey_mod = winreg ! RegOpenKeyEx = winreg.OpenKeyEx ! RegEnumKey = winreg.EnumKey ! RegEnumValue = winreg.EnumValue ! RegError = winreg.error except ImportError: --- 21,32 ---- _can_read_reg = 0 try: ! import _winreg _can_read_reg = 1 ! hkey_mod = _winreg ! RegOpenKeyEx = _winreg.OpenKeyEx ! RegEnumKey = _winreg.EnumKey ! RegEnumValue = _winreg.EnumValue ! RegError = _winreg.error except ImportError: From python-dev@python.org Fri Jun 30 00:01:43 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 16:01:43 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/tools mkhowto,1.8,1.9 Message-ID: <200006292301.QAA09700@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/tools In directory slayer.i.sourceforge.net:/tmp/cvs-serv9587 Modified Files: mkhowto Log Message: Removed --l2h-config option; it introduced unnecessary complexity and is not needed anywhere. Index: mkhowto =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tools/mkhowto,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** mkhowto 2000/04/03 04:19:14 1.8 --- mkhowto 2000/06/29 23:01:40 1.9 *************** *** 95,99 **** def __init__(self): - self.config_files = [] self.formats = [] --- 95,98 ---- *************** *** 108,112 **** opts, args = getopt.getopt(args, "Hi:a:s:lDkqr:", ["all", "postscript", "help", "iconserver=", ! "address=", "a4", "l2h-config=", "letter", "link=", "split=", "logging", "debugging", "keep", "quiet", "runs=", "image-type=", --- 107,111 ---- opts, args = getopt.getopt(args, "Hi:a:s:lDkqr:", ["all", "postscript", "help", "iconserver=", ! "address=", "a4", "letter", "link=", "split=", "logging", "debugging", "keep", "quiet", "runs=", "image-type=", *************** *** 127,132 **** elif opt == "--letter": self.paper = "letter" - elif opt == "--l2h-config": - self.config_files.append(arg) elif opt == "--link": self.max_link_depth = int(arg) --- 126,129 ---- *************** *** 371,380 **** ) options = self.options - for fn in options.config_files: - fp.write(open(fn).read()) - fp.write("\n" - "\n" - 'print "\nInitializing from file: %s\";\n\n' - % string_to_perl(fn)) l2hoption(fp, "ABOUT_FILE", options.about_file) l2hoption(fp, "ICONSERVER", options.icon_server) --- 368,371 ---- From python-dev@python.org Fri Jun 30 00:05:01 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 29 Jun 2000 16:05:01 -0700 Subject: [Python-checkins] CVS: distutils/distutils msvccompiler.py,1.33,1.34 Message-ID: <200006292305.QAA11929@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv11914 Modified Files: msvccompiler.py Log Message: On second thought, first try for _winreg, and then winreg. Only if both fail do we try for win32api/win32con. If *those* both fail, then we don't have registry access. Phew! Index: msvccompiler.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/msvccompiler.py,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -r1.33 -r1.34 *** msvccompiler.py 2000/06/29 22:59:10 1.33 --- msvccompiler.py 2000/06/29 23:04:59 1.34 *************** *** 21,25 **** _can_read_reg = 0 try: ! import _winreg _can_read_reg = 1 hkey_mod = _winreg --- 21,29 ---- _can_read_reg = 0 try: ! try: ! import _winreg ! except ImportError: ! import winreg # for pre-2000/06/29 CVS Python ! _can_read_reg = 1 hkey_mod = _winreg From python-dev@python.org Fri Jun 30 00:09:23 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 29 Jun 2000 16:09:23 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command build_ext.py,1.53,1.54 Message-ID: <200006292309.QAA12142@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv12132/command Modified Files: build_ext.py Log Message: Don't try to guess the name of a .def file -- if one is supplied, use it, otherwise just generate an '/export:' option. Index: build_ext.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build_ext.py,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -r1.53 -r1.54 *** build_ext.py 2000/06/29 02:16:24 1.53 --- build_ext.py 2000/06/29 23:09:20 1.54 *************** *** 529,538 **** def_file = ext.export_symbol_file - if def_file is None: - source_dir = os.path.dirname (sources[0]) - ext_base = (string.split (ext.name, '.'))[-1] - def_file = os.path.join (source_dir, "%s.def" % ext_base) - if not os.path.exists (def_file): - def_file = None if def_file is not None: --- 529,532 ---- From python-dev@python.org Fri Jun 30 00:33:14 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 16:33:14 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre_compile.py,1.11,1.12 Message-ID: <200006292333.QAA13565@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv12640/Lib Modified Files: sre_compile.py Log Message: still trying to figure out how to fix the remaining group reset problem. in the meantime, I added some optimizations: - added "inline" directive to LOCAL (this assumes that AC_C_INLINE does what it's supposed to do). to compile SRE on a non-unix platform that doesn't support inline, you have to add a "#define inline" somewhere... - added code to generate a SRE_OP_INFO primitive - added code to do fast prefix search (enabled by the USE_FAST_SEARCH define; default is on, in this release) Index: sre_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** sre_compile.py 2000/06/29 18:03:25 1.11 --- sre_compile.py 2000/06/29 23:33:11 1.12 *************** *** 24,27 **** --- 24,28 ---- def _compile(code, pattern, flags): + # internal: compile a (sub)pattern emit = code.append for op, av in pattern: *************** *** 153,158 **** --- 154,204 ---- raise ValueError, ("unsupported operand type", op) + def _compile_info(code, pattern, flags): + # internal: compile an info block. in the current version, + # this contains min/max pattern width and a literal prefix, + # if any + lo, hi = pattern.getwidth() + if lo == 0: + return # not worth it + # look for a literal prefix + prefix = [] + if not (flags & SRE_FLAG_IGNORECASE): + for op, av in pattern.data: + if op is LITERAL: + prefix.append(ord(av)) + else: + break + # add an info block + emit = code.append + emit(OPCODES[INFO]) + skip = len(code); emit(0) + # literal flag + mask = 0 + if len(prefix) == len(pattern.data): + mask = 1 + emit(mask) + # pattern length + emit(lo) + if hi < 32768: + emit(hi) + else: + emit(0) + # add literal prefix + emit(len(prefix)) + if prefix: + code.extend(prefix) + # generate overlap table + table = [-1] + ([0]*len(prefix)) + for i in range(len(prefix)): + table[i+1] = table[i]+1 + while table[i+1] > 0 and prefix[i] != prefix[table[i+1]-1]: + table[i+1] = table[table[i+1]-1]+1 + code.extend(table[1:]) # don't store first entry + code[skip] = len(code) - skip + def compile(p, flags=0): # internal: convert pattern list to internal format + + # compile, as necessary if type(p) in (type(""), type(u"")): import sre_parse *************** *** 161,171 **** else: pattern = None flags = p.pattern.flags | flags code = [] _compile(code, p.data, flags) code.append(OPCODES[SUCCESS]) ! # FIXME: get rid of this limitation assert p.pattern.groups <= 100,\ "sorry, but this version only supports 100 named groups" return _sre.compile( pattern, flags, --- 207,226 ---- else: pattern = None + flags = p.pattern.flags | flags code = [] + + # compile info block + _compile_info(code, p, flags) + + # compile the pattern _compile(code, p.data, flags) + code.append(OPCODES[SUCCESS]) ! ! # FIXME: get rid of this limitation! assert p.pattern.groups <= 100,\ "sorry, but this version only supports 100 named groups" + return _sre.compile( pattern, flags, From python-dev@python.org Fri Jun 30 00:33:14 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 16:33:14 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.11,2.12 Message-ID: <200006292333.QAA13569@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv12640/Modules Modified Files: _sre.c Log Message: still trying to figure out how to fix the remaining group reset problem. in the meantime, I added some optimizations: - added "inline" directive to LOCAL (this assumes that AC_C_INLINE does what it's supposed to do). to compile SRE on a non-unix platform that doesn't support inline, you have to add a "#define inline" somewhere... - added code to generate a SRE_OP_INFO primitive - added code to do fast prefix search (enabled by the USE_FAST_SEARCH define; default is on, in this release) Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.11 retrieving revision 2.12 diff -C2 -r2.11 -r2.12 *** _sre.c 2000/06/29 18:03:25 2.11 --- _sre.c 2000/06/29 23:33:12 2.12 *************** *** 20,23 **** --- 20,24 ---- * 00-06-28 fl fixed findall (0.9.1) * 00-06-29 fl fixed split, added more scanner features (0.9.2) + * 00-06-30 fl tuning, fast search (0.9.3) * * Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. *************** *** 30,35 **** #ifndef SRE_RECURSIVE ! static char ! copyright[] = " SRE 0.9.2 Copyright (c) 1997-2000 by Secret Labs AB "; #include "Python.h" --- 31,35 ---- #ifndef SRE_RECURSIVE ! char copyright[] = " SRE 0.9.3 Copyright (c) 1997-2000 by Secret Labs AB "; #include "Python.h" *************** *** 56,59 **** --- 56,62 ---- #endif + /* optional features */ + #define USE_FAST_SEARCH + #if defined(_MSC_VER) #pragma optimize("agtw", on) /* doesn't seem to make much difference... */ *************** *** 61,65 **** #define LOCAL(type) static __inline type __fastcall #else ! #define LOCAL(type) static type #endif --- 64,68 ---- #define LOCAL(type) static __inline type __fastcall #else ! #define LOCAL(type) static inline type #endif *************** *** 397,400 **** --- 400,414 ---- TRACE(("%8d: enter\n", PTR(ptr))); + if (pattern[0] == SRE_OP_INFO) { + /* optimization info block */ + /* args: <1=skip> <2=flags> <3=min> ... */ + if (pattern[3] && (end - ptr) < pattern[3]) { + TRACE(("reject (got %d chars, need %d)\n", + (end - ptr), pattern[3])); + return 0; + } + pattern += pattern[1] + 1; + } + stackbase = stack = state->stackbase; lastmark = state->lastmark; *************** *** 918,935 **** int status = 0; int prefix_len = 0; ! SRE_CODE* prefix = NULL; if (pattern[0] == SRE_OP_INFO) { ! /* args: */ ! end -= pattern[2]; ! prefix_len = pattern[4]; ! prefix = pattern + 5; ! pattern += pattern[1]; } ! /* if (prefix_len > 0) ... */ if (pattern[0] == SRE_OP_LITERAL) { ! /* pattern starts with a literal */ SRE_CHAR chr = (SRE_CHAR) pattern[1]; for (;;) { --- 932,1001 ---- int status = 0; int prefix_len = 0; ! SRE_CODE* prefix; ! SRE_CODE* overlap; ! int literal = 0; if (pattern[0] == SRE_OP_INFO) { ! /* optimization info block */ ! /* args: <1=skip> <2=flags> <3=min> <4=max> <5=prefix> <6=data...> */ ! ! if (pattern[3] > 0) { ! /* adjust end point (but make sure we leave at least one ! character in there) */ ! end -= pattern[3]-1; ! if (end <= ptr) ! end = ptr+1; ! } ! ! literal = pattern[2]; ! ! prefix = pattern + 6; ! prefix_len = pattern[5]; ! ! overlap = prefix + prefix_len - 1; ! ! pattern += 1 + pattern[1]; } ! #if defined(USE_FAST_SEARCH) ! if (prefix_len > 1) { ! /* pattern starts with a known prefix. use the overlap ! table to skip forward as fast as we possibly can */ ! int i = 0; ! end = state->end; ! while (ptr < end) { ! for (;;) { ! if (*ptr != (SRE_CHAR) prefix[i]) { ! if (!i) ! break; ! else ! i = overlap[i]; ! } else { ! if (++i == prefix_len) { ! /* found a potential match */ ! TRACE(("%8d: === SEARCH === hit\n", PTR(ptr))); ! state->start = ptr - prefix_len + 1; ! state->ptr = ptr + 1; ! if (literal) ! return 1; /* all of it */ ! status = SRE_MATCH(state, pattern + 2*prefix_len); ! if (status != 0) ! return status; ! /* close but no cigar -- try again */ ! i = overlap[i]; ! } ! break; ! } ! ! } ! ptr++; ! } ! return 0; ! } ! #endif if (pattern[0] == SRE_OP_LITERAL) { ! /* pattern starts with a literal character. this is used for ! short prefixes, and if fast search is disabled*/ SRE_CHAR chr = (SRE_CHAR) pattern[1]; for (;;) { *************** *** 945,950 **** break; } - } else while (ptr <= end) { TRACE(("%8d: === SEARCH ===\n", PTR(ptr))); --- 1011,1016 ---- break; } } else + /* general case */ while (ptr <= end) { TRACE(("%8d: === SEARCH ===\n", PTR(ptr))); From python-dev@python.org Fri Jun 30 00:50:22 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 29 Jun 2000 16:50:22 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist_wininst.py,1.2,1.3 Message-ID: <200006292350.QAA14433@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv14417/command Modified Files: bdist_wininst.py Log Message: Allow 2.0 on the list of target versions. NB. this isn't enough: the GUI part, misc/install.c, still needs to be updated, and it looks like a non-trivial change. Index: bdist_wininst.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist_wininst.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** bdist_wininst.py 2000/06/28 00:56:20 1.2 --- bdist_wininst.py 2000/06/29 23:50:19 1.3 *************** *** 28,32 **** ('target-version=', 'v', "require a specific python version" + ! " on the target system (1.5 or 1.6)"), ] --- 28,32 ---- ('target-version=', 'v', "require a specific python version" + ! " on the target system (1.5 or 1.6/2.0)"), ] *************** *** 48,54 **** self.target_version = "" else: ! if not self.target_version in ("1.5", "1.6"): raise DistutilsOptionError ( ! "target version must be 1.5 or 1.6") if self.distribution.has_ext_modules(): short_version = sys.version[:3] --- 48,54 ---- self.target_version = "" else: ! if not self.target_version in ("1.5", "1.6", "2.0"): raise DistutilsOptionError ( ! "target version must be 1.5, 1.6, or 2.0") if self.distribution.has_ext_modules(): short_version = sys.version[:3] *************** *** 75,80 **** # on the TARGET system instead at the SOURCE system. ! ## # The compilation can only be done on the SOURCE system ! ## # for one python version (assuming 1.6 and 1.5 have incompatible ## # byte-codes). ## short_version = sys.version[:3] --- 75,80 ---- # on the TARGET system instead at the SOURCE system. ! ## # The compilation can only be done on the SOURCE system for one ! ## # python version (assuming 1.6/2.0 and 1.5 have incompatible ## # byte-codes). ## short_version = sys.version[:3] From python-dev@python.org Fri Jun 30 01:27:48 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 17:27:48 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.12,2.13 Message-ID: <200006300027.RAA22644@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv22449/Modules Modified Files: _sre.c Log Message: - fixed split behaviour on empty matches - fixed compiler problems when using locale/unicode flags - fixed group/octal code parsing in sub/subn templates Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.12 retrieving revision 2.13 diff -C2 -r2.12 -r2.13 *** _sre.c 2000/06/29 23:33:12 2.12 --- _sre.c 2000/06/30 00:27:46 2.13 *************** *** 1535,1538 **** --- 1535,1541 ---- return Py_BuildValue("i", self->flags); + if (!strcmp(name, "groups")) + return Py_BuildValue("i", self->groups); + if (!strcmp(name, "groupindex") && self->groupindex) { Py_INCREF(self->groupindex); *************** *** 1939,1945 **** return self->pattern; } - - if (!strcmp(name, "groups")) - return Py_BuildValue("i", ((PatternObject*) self->pattern)->groups); PyErr_SetString(PyExc_AttributeError, name); --- 1942,1945 ---- From python-dev@python.org Fri Jun 30 01:27:48 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 17:27:48 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre.py,1.13,1.14 sre_compile.py,1.12,1.13 sre_parse.py,1.11,1.12 Message-ID: <200006300027.RAA22643@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv22449/Lib Modified Files: sre.py sre_compile.py sre_parse.py Log Message: - fixed split behaviour on empty matches - fixed compiler problems when using locale/unicode flags - fixed group/octal code parsing in sub/subn templates Index: sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** sre.py 2000/06/29 18:03:25 1.13 --- sre.py 2000/06/30 00:27:45 1.14 *************** *** 110,123 **** if not m: break ! j = m.start() ! if j > i: ! append(string[i:j]) append(filter(m)) ! i = m.end() ! if i <= j: ! break n = n + 1 ! if i < len(string): ! append(string[i:]) return string[:0].join(s), n --- 110,120 ---- if not m: break ! b, e = m.span() ! if i < b: ! append(string[i:b]) append(filter(m)) ! i = e n = n + 1 ! append(string[i:]) return string[:0].join(s), n *************** *** 129,133 **** extend = s.extend c = pattern.scanner(string) ! g = c.groups while not maxsplit or n < maxsplit: m = c.search() --- 126,130 ---- extend = s.extend c = pattern.scanner(string) ! g = pattern.groups while not maxsplit or n < maxsplit: m = c.search() Index: sre_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** sre_compile.py 2000/06/29 23:33:11 1.12 --- sre_compile.py 2000/06/30 00:27:45 1.13 *************** *** 62,68 **** emit(OPCODES[op]) if flags & SRE_FLAG_LOCALE: ! emit(CH_LOCALE[CHCODES[av]]) elif flags & SRE_FLAG_UNICODE: ! emit(CH_UNICODE[CHCODES[av]]) else: emit(CHCODES[av]) --- 62,68 ---- emit(OPCODES[op]) if flags & SRE_FLAG_LOCALE: ! emit(CHCODES[CH_LOCALE[av]]) elif flags & SRE_FLAG_UNICODE: ! emit(CHCODES[CH_UNICODE[av]]) else: emit(CHCODES[av]) *************** *** 93,99 **** elif op is CATEGORY: if flags & SRE_FLAG_LOCALE: ! emit(CH_LOCALE[CHCODES[av]]) elif flags & SRE_FLAG_UNICODE: ! emit(CH_UNICODE[CHCODES[av]]) else: emit(CHCODES[av]) --- 93,99 ---- elif op is CATEGORY: if flags & SRE_FLAG_LOCALE: ! emit(CHCODES[CH_LOCALE[av]]) elif flags & SRE_FLAG_UNICODE: ! emit(CHCODES[CH_UNICODE[av]]) else: emit(CHCODES[av]) Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** sre_parse.py 2000/06/29 18:03:25 1.11 --- sre_parse.py 2000/06/30 00:27:45 1.12 *************** *** 31,54 **** ESCAPES = { ! "\\a": (LITERAL, chr(7)), ! "\\b": (LITERAL, chr(8)), ! "\\f": (LITERAL, chr(12)), ! "\\n": (LITERAL, chr(10)), ! "\\r": (LITERAL, chr(13)), ! "\\t": (LITERAL, chr(9)), ! "\\v": (LITERAL, chr(11)) } CATEGORIES = { ! "\\A": (AT, AT_BEGINNING), # start of string ! "\\b": (AT, AT_BOUNDARY), ! "\\B": (AT, AT_NON_BOUNDARY), ! "\\d": (IN, [(CATEGORY, CATEGORY_DIGIT)]), ! "\\D": (IN, [(CATEGORY, CATEGORY_NOT_DIGIT)]), ! "\\s": (IN, [(CATEGORY, CATEGORY_SPACE)]), ! "\\S": (IN, [(CATEGORY, CATEGORY_NOT_SPACE)]), ! "\\w": (IN, [(CATEGORY, CATEGORY_WORD)]), ! "\\W": (IN, [(CATEGORY, CATEGORY_NOT_WORD)]), ! "\\Z": (AT, AT_END), # end of string } --- 31,55 ---- ESCAPES = { ! r"\a": (LITERAL, chr(7)), ! r"\b": (LITERAL, chr(8)), ! r"\f": (LITERAL, chr(12)), ! r"\n": (LITERAL, chr(10)), ! r"\r": (LITERAL, chr(13)), ! r"\t": (LITERAL, chr(9)), ! r"\v": (LITERAL, chr(11)), ! r"\\": (LITERAL, "\\") } CATEGORIES = { ! r"\A": (AT, AT_BEGINNING), # start of string ! r"\b": (AT, AT_BOUNDARY), ! r"\B": (AT, AT_NON_BOUNDARY), ! r"\d": (IN, [(CATEGORY, CATEGORY_DIGIT)]), ! r"\D": (IN, [(CATEGORY, CATEGORY_NOT_DIGIT)]), ! r"\s": (IN, [(CATEGORY, CATEGORY_SPACE)]), ! r"\S": (IN, [(CATEGORY, CATEGORY_NOT_SPACE)]), ! r"\w": (IN, [(CATEGORY, CATEGORY_WORD)]), ! r"\W": (IN, [(CATEGORY, CATEGORY_NOT_WORD)]), ! r"\Z": (AT, AT_END), # end of string } *************** *** 186,194 **** return 1 ! def _group(escape, state): # check if the escape string represents a valid group try: group = int(escape[1:]) ! if group and group < state.groups: return group except ValueError: --- 187,195 ---- return 1 ! def _group(escape, groups): # check if the escape string represents a valid group try: group = int(escape[1:]) ! if group and group < groups: return group except ValueError: *************** *** 240,247 **** elif escape[1:2] in DIGITS: while 1: ! group = _group(escape, state) if group: if (not source.next or ! not _group(escape + source.next, state)): return GROUP, group escape = escape + source.get() --- 241,248 ---- elif escape[1:2] in DIGITS: while 1: ! group = _group(escape, state.groups) if group: if (not source.next or ! not _group(escape + source.next, state.groups)): return GROUP, group escape = escape + source.get() *************** *** 535,538 **** --- 536,540 ---- break # end of replacement string if this and this[0] == "\\": + # group if this == "\\g": name = "" *************** *** 558,570 **** a((MARK, index)) elif len(this) > 1 and this[1] in DIGITS: ! while s.next in DIGITS: ! this = this + s.get() ! a((MARK, int(this[1:]))) else: try: a(ESCAPES[this]) except KeyError: ! for char in this: ! a((LITERAL, char)) else: a((LITERAL, this)) --- 560,586 ---- a((MARK, index)) elif len(this) > 1 and this[1] in DIGITS: ! code = None ! while 1: ! group = _group(this, pattern.groups+1) ! if group: ! if (not s.next or ! not _group(this + s.next, pattern.groups+1)): ! code = MARK, int(group) ! break ! elif s.next in OCTDIGITS: ! this = this + s.get() ! else: ! break ! if not code: ! this = this[1:] ! # FIXME: support unicode characters! ! code = LITERAL, chr(int(this[-6:], 8) & 0xff) ! a(code) else: try: a(ESCAPES[this]) except KeyError: ! for c in this: ! a((LITERAL, c)) else: a((LITERAL, this)) From python-dev@python.org Fri Jun 30 02:05:42 2000 From: python-dev@python.org (A.M. Kuchling) Date: Thu, 29 Jun 2000 18:05:42 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libcurses.tex,1.6,1.7 Message-ID: <200006300105.SAA30792@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv30763 Modified Files: libcurses.tex Log Message: Document recently-added mouse-related functions Index: libcurses.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcurses.tex,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** libcurses.tex 2000/06/28 22:11:40 1.6 --- libcurses.tex 2000/06/30 01:05:39 1.7 *************** *** 131,134 **** --- 131,155 ---- \end{funcdesc} + \begin{funcdesc}{getmouse}{} + After \method{getch()} returns \constant{KEY_MOUSE} to signal a mouse + event, this method should be call to retrieve the queued mouse event, + represented as a 5-tuple + \code{(\var{id}, \var{x}, \var{y}, \var{z}, \var{bstate})}. + \var{id} is an ID value used to distinguish multiple devices, + and \var{x}, \var{y}, \var{z} are the event's coordinates. (\var{z} + is currently unused.). \var{bstate} is an integer value whose bits + will be set to indicate the type of event, and will be the bitwise OR + of one or more of the following constants, where \var{n} is the button + number from 1 to 4: + \constant{BUTTON\var{n}_PRESSED}, + \constant{BUTTON\var{n}_RELEASED}, + \constant{BUTTON\var{n}_CLICKED}, + \constant{BUTTON\var{n}_DOUBLE_CLICKED}, + \constant{BUTTON\var{n}_TRIPLE_CLICKED}, + \constant{BUTTON_SHIFT}, + \constant{BUTTON_CTRL}, + \constant{BUTTON_ALT}. + \end{funcdesc} + \begin{funcdesc}{getsyx}{} Returns the current coordinates of the virtual screen cursor in y and *************** *** 222,225 **** --- 243,263 ---- \end{funcdesc} + \begin{funcdesc}{mouseinterval}{interval} + Sets the maximum time in millisecondsthat can elapse between press and + release events in order for them to be recognized as a click, and + returns the previous interval value. The default value is 200 msec, + or one fifth of a second. + \end{funcdesc} + + \begin{funcdesc}{mousemask}{mousemask} + Sets the mouse events to be reported, and returns a tuple + \code{(\var{availmask}, \var{oldmask})}. + \var{availmask} indicates which of the + specified mouse events can be reported; on complete failure it returns + 0. \var{oldmask} is the previous value of the given window's mouse + event mask. If this function is never called, no mouse events are + ever reported. + \end{funcdesc} + \begin{funcdesc}{newpad}{nlines, ncols} Creates and returns a pointer to a new pad data structure with the *************** *** 371,374 **** --- 409,417 ---- \end{funcdesc} + \begin{funcdesc}{ungetmouse}{id, x, y, z, bstate} + Push a \constant{KEY_MOUSE} event onto the input queue, associating + the given state data with it. + \end{funcdesc} + \begin{funcdesc}{use_env}{flag} If used, this function should be called before \function{initscr} or *************** *** 521,524 **** --- 564,574 ---- Add character \var{ch} with attribute \var{attr}, and immediately call \method{refresh}. + \end{methoddesc} + + \begin{methoddesc}{enclose}{y, x} + Tests whether the given pair of screen-relative character-cell + coordinates are enclosed by the given window, returning true or + false. It is useful for determining what subset of the screen + windows enclose the location of a mouse event. \end{methoddesc} From python-dev@python.org Fri Jun 30 03:29:24 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 29 Jun 2000 19:29:24 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules cmathmodule.c,2.12,2.13 Message-ID: <200006300229.TAA09177@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv9169 Modified Files: cmathmodule.c Log Message: Patch by Nadav Horesh to make acosh and asinh better. Tim posted a long comment to python-dev (subject: "Controversial patch (cmath)"; date: 6/29/00). The conclusion is that this whole module stinks and this patch isn't perfect, but it's better than the acosh and asinh we had, so let's check it in. Index: cmathmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cmathmodule.c,v retrieving revision 2.12 retrieving revision 2.13 diff -C2 -r2.12 -r2.13 *** cmathmodule.c 1999/03/16 14:17:48 2.12 --- cmathmodule.c 2000/06/30 02:29:22 2.13 *************** *** 58,63 **** Py_complex x; { ! return c_log(c_sum(x,c_prod(c_i, ! c_sqrt(c_diff(c_1,c_prod(x,x)))))); } --- 58,66 ---- Py_complex x; { ! Py_complex z; ! z = c_sqrt(c_half); ! z = c_log(c_prod(z, c_sum(c_sqrt(c_sum(x,c_1)), ! c_sqrt(c_diff(x,c_1))))); ! return c_sum(z, z); } *************** *** 71,76 **** Py_complex x; { ! return c_neg(c_prodi(c_log(c_sum(c_prod(c_i,x), ! c_sqrt(c_diff(c_1,c_prod(x,x))))))); } --- 74,82 ---- Py_complex x; { ! Py_complex z; ! z = c_sqrt(c_half); ! z = c_log(c_prod(z, c_sum(c_sqrt(c_sum(x,c_i)), ! c_sqrt(c_diff(x,c_i))))); ! return c_sum(z, z); } *************** *** 86,92 **** /* Break up long expression for WATCOM */ Py_complex z; ! z = c_sum(c_1,c_prod(x,x)); ! z = c_diff(c_sqrt(z),x); ! return c_neg(c_log(z)); } --- 92,97 ---- /* Break up long expression for WATCOM */ Py_complex z; ! z = c_sum(c_1,c_prod(x, x)); ! return c_log(c_sum(c_sqrt(z), x)); } From python-dev@python.org Fri Jun 30 03:44:44 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 29 Jun 2000 19:44:44 -0700 Subject: [Python-checkins] CVS: python/dist/src config.h.in,2.58,2.59 Message-ID: <200006300244.TAA10445@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv10433 Modified Files: config.h.in Log Message: Somehow this had HAVE_SYS_SOCKET_H twice. Once is enough. Rerunning autoheader revealed this. Index: config.h.in =================================================================== RCS file: /cvsroot/python/python/dist/src/config.h.in,v retrieving revision 2.58 retrieving revision 2.59 diff -C2 -r2.58 -r2.59 *** config.h.in 2000/06/29 20:44:46 2.58 --- config.h.in 2000/06/30 02:44:41 2.59 *************** *** 553,559 **** #undef HAVE_SYS_SOCKET_H - /* Define if you have the header file. */ - #undef HAVE_SYS_SOCKET_H - /* Define if you have the header file. */ #undef HAVE_SYS_TIME_H --- 553,556 ---- From python-dev@python.org Fri Jun 30 03:46:09 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 19:46:09 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules socketmodule.c,1.108,1.109 Message-ID: <200006300246.TAA10573@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv10484/Modules Modified Files: socketmodule.c Log Message: Trent Mick : This patch fixes possible overflows in the socket module for 64-bit platforms (mainly Win64). The changes are: - abstract the socket type to SOCKET_T (this is SOCKET on Windows, int on Un*x), this is necessary because sizeof(SOCKET) > sizeof(int) on Win64 - use INVALID_SOCKET on Win32/64 for an error return value for accept() - ensure no overflow of the socket variable for: (1) a PyObject return value (use PyLong_FromLongLong if necessary); and (2) printf formatting in repr(). Closes SourceForge patch #100516. Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.108 retrieving revision 1.109 diff -C2 -r1.108 -r1.109 *** socketmodule.c 2000/05/16 13:30:12 1.108 --- socketmodule.c 2000/06/30 02:46:07 1.109 *************** *** 222,225 **** --- 222,239 ---- #endif + /* abstract the socket file descriptor type */ + #ifdef MS_WINDOWS + typedef SOCKET SOCKET_T; + # ifdef MS_WIN64 + # define SIZEOF_SOCKET_T 8 + # else + # define SIZEOF_SOCKET_T 4 + # endif + #else + typedef int SOCKET_T; + # define SIZEOF_SOCKET_T SIZEOF_INT + #endif + + #if defined(PYOS_OS2) #define SOCKETCLOSE soclose *************** *** 338,342 **** typedef struct { PyObject_HEAD ! int sock_fd; /* Socket file descriptor */ int sock_family; /* Address family, e.g., AF_INET */ int sock_type; /* Socket type, e.g., SOCK_STREAM */ --- 352,356 ---- typedef struct { PyObject_HEAD ! SOCKET_T sock_fd; /* Socket file descriptor */ int sock_family; /* Address family, e.g., AF_INET */ int sock_type; /* Socket type, e.g., SOCK_STREAM */ *************** *** 388,392 **** static PySocketSockObject * ! BUILD_FUNC_DEF_4(PySocketSock_New,int,fd, int,family, int,type, int,proto) { PySocketSockObject *s; --- 402,406 ---- static PySocketSockObject * ! BUILD_FUNC_DEF_4(PySocketSock_New,SOCKET_T,fd, int,family, int,type, int,proto) { PySocketSockObject *s; *************** *** 667,671 **** { char addrbuf[256]; ! int newfd; socklen_t addrlen; PyObject *sock = NULL; --- 681,685 ---- { char addrbuf[256]; ! SOCKET_T newfd; socklen_t addrlen; PyObject *sock = NULL; *************** *** 680,684 **** --- 694,702 ---- newfd = accept(s->sock_fd, (struct sockaddr *) addrbuf, &addrlen); Py_END_ALLOW_THREADS + #ifdef MS_WINDOWS + if (newfd == INVALID_SOCKET) + #else if (newfd < 0) + #endif return PySocket_Err(); *************** *** 969,973 **** --- 987,995 ---- if (!PyArg_ParseTuple(args, ":fileno")) return NULL; + #if SIZEOF_SOCKET_T <= SIZEOF_LONG return PyInt_FromLong((long) s->sock_fd); + #else + return PyLong_FromLongLong((LONG_LONG)s->sock_fd); + #endif } *************** *** 984,988 **** BUILD_FUNC_DEF_2(PySocketSock_dup,PySocketSockObject *,s, PyObject *,args) { ! int newfd; PyObject *sock; if (!PyArg_ParseTuple(args, ":dup")) --- 1006,1010 ---- BUILD_FUNC_DEF_2(PySocketSock_dup,PySocketSockObject *,s, PyObject *,args) { ! SOCKET_T newfd; PyObject *sock; if (!PyArg_ParseTuple(args, ":dup")) *************** *** 1110,1114 **** --- 1132,1140 ---- char *mode = "r"; int bufsize = -1; + #ifdef MS_WIN32 + intptr_t fd; + #else int fd; + #endif FILE *fp; PyObject *f; *************** *** 1388,1394 **** { char buf[512]; sprintf(buf, ! "", ! s->sock_fd, s->sock_family, s->sock_type, s->sock_proto); return PyString_FromString(buf); } --- 1414,1430 ---- { char buf[512]; + #if SIZEOF_SOCKET_T > SIZEOF_LONG + if (s->sock_fd > LONG_MAX) { + /* this can occur on Win64, and actually there is a special + ugly printf formatter for decimal pointer length integer + printing, only bother if necessary*/ + PyErr_SetString(PyExc_OverflowError, + "no printf formatter to display the socket descriptor in decimal"); + return NULL; + } + #endif sprintf(buf, ! "", ! (long)s->sock_fd, s->sock_family, s->sock_type, s->sock_proto); return PyString_FromString(buf); } *************** *** 1717,1725 **** { PySocketSockObject *s; ! #ifdef MS_WINDOWS ! SOCKET fd; ! #else ! int fd; ! #endif int family, type, proto = 0; if (!PyArg_ParseTuple(args, "ii|i:socket", &family, &type, &proto)) --- 1753,1757 ---- { PySocketSockObject *s; ! SOCKET_T fd; int family, type, proto = 0; if (!PyArg_ParseTuple(args, "ii|i:socket", &family, &type, &proto)) *************** *** 1767,1771 **** { PySocketSockObject *s; ! int fd, family, type, proto = 0; if (!PyArg_ParseTuple(args, "iii|i:fromfd", &fd, &family, &type, &proto)) --- 1799,1804 ---- { PySocketSockObject *s; ! SOCKET_T fd; ! int family, type, proto = 0; if (!PyArg_ParseTuple(args, "iii|i:fromfd", &fd, &family, &type, &proto)) *************** *** 2114,2118 **** { char *data; ! int len = 0; if (!PyArg_ParseTuple(args, "s|i:write", &data, &len)) --- 2147,2151 ---- { char *data; ! size_t len = 0; if (!PyArg_ParseTuple(args, "s|i:write", &data, &len)) From python-dev@python.org Fri Jun 30 03:48:56 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 29 Jun 2000 19:48:56 -0700 Subject: [Python-checkins] CVS: python/dist/src configure,1.119,1.120 configure.in,1.128,1.129 Message-ID: <200006300248.TAA10665@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv10638 Modified Files: configure configure.in Log Message: Bump version to 2.0. Note that configure hadn't been checked in a few times so it has more changes, catching up with the last few changes to congifure.in as well. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.119 retrieving revision 1.120 diff -C2 -r1.119 -r1.120 *** configure 2000/06/29 16:12:00 1.119 --- configure 2000/06/30 02:48:53 1.120 *************** *** 1,5 **** #! /bin/sh ! # From configure.in Revision: 1.126 # Guess values for system-dependent variables and create Makefiles. --- 1,5 ---- #! /bin/sh ! # From configure.in Revision: 1.129 [...2672 lines suppressed...] echo $ac_n "checking for socklen_t""... $ac_c" 1>&6 ! echo "configure:5530: checking for socklen_t" >&5 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 < --- 5609,5618 ---- EOF echo $ac_n "checking for socklen_t""... $ac_c" 1>&6 ! echo "configure:5612: checking for socklen_t" >&5 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 < Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.128 retrieving revision 1.129 diff -C2 -r1.128 -r1.129 *** configure.in 2000/06/29 20:44:46 1.128 --- configure.in 2000/06/30 02:48:53 1.129 *************** *** 7,11 **** # Set VERSION so we only need to edit in one place (i.e., here) AC_SUBST(VERSION) ! VERSION=1.6 # NEXTSTEP stuff --- 7,11 ---- # Set VERSION so we only need to edit in one place (i.e., here) AC_SUBST(VERSION) ! VERSION=2.0 # NEXTSTEP stuff From python-dev@python.org Fri Jun 30 03:54:02 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 29 Jun 2000 19:54:02 -0700 Subject: [Python-checkins] CVS: distutils README.txt,1.16,1.17 CHANGES.txt,1.10,1.11 Message-ID: <200006300254.TAA10865@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv10850 Modified Files: README.txt CHANGES.txt Log Message: Update for Distutils 0.9. Index: README.txt =================================================================== RCS file: /cvsroot/python/distutils/README.txt,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** README.txt 2000/06/04 13:46:19 1.16 --- README.txt 2000/06/30 02:54:00 1.17 *************** *** 1,5 **** Python Distribution Utilities ! release 0.9 (pre) ! June ??, 2000 --- 1,5 ---- Python Distribution Utilities ! release 0.9 ! June 29, 2000 *************** *** 11,20 **** installation of Python modules. (It is intended that ultimately the Distutils will grow up into a system for distributing and installing ! whole Python applications, but for now their scope is limited to module distributions.) ! The Distutils are a standard part of Python 1.6; if you are running 1.6, ! you don't need to install the Distutils separately. This release is ! primarily so that you can add the Distutils to a Python 1.5.2 installation -- you will then be able to install modules that require the Distutils, or use the Distutils to distribute your own modules. --- 11,20 ---- installation of Python modules. (It is intended that ultimately the Distutils will grow up into a system for distributing and installing ! whole Python applications, but for now their scope is primarily module distributions.) ! The Distutils are a standard part of Python 1.6/2.0; if you are running ! 1.6/2.0, you don't need to install the Distutils separately. This ! release is primarily so that you can add the Distutils to a Python 1.5.2 installation -- you will then be able to install modules that require the Distutils, or use the Distutils to distribute your own modules. *************** *** 43,50 **** Release 0.9 of the Distutils requires Python 1.5.2 or later. (If you ! absolutely must Python 1.5.1, Distutils 0.1.5 is backwards compatible. ! However, I have dropped plans to port the current Distutils code back to ! Python 1.5.1, as I have received exactly zero complaints about requiring ! Python 1.5.2 since releasing Distutils 0.8 in April.) To use the Distutils under Unix, you must have a *complete* Python --- 43,50 ---- Release 0.9 of the Distutils requires Python 1.5.2 or later. (If you ! absolutely must use Python 1.5.1, Distutils 0.1.5 is backwards ! compatible. However, I have dropped plans to port the current Distutils ! code back to Python 1.5.1, as I have received exactly zero complaints ! about requiring Python 1.5.2 since releasing Distutils 0.8 in April.) To use the Distutils under Unix, you must have a *complete* Python *************** *** 71,81 **** extensions works or not. ! To build extensions on Windows, you need Microsoft Visual C++ 5.0 or ! 6.0. It also helps to have access to the Windows registry from Python; ! if you have the Win32 extensions (win32api, win32con) installed, you're ! fine. (Python 1.6 includes the winreg module for this purpose, which ! the Distutils will use if available.) If not, the Distutils might not ! be able to find the Visual C++ executables, in which case it will die ! horribly when you attempt to build any Python extensions. --- 71,85 ---- extensions works or not. ! Building extensions on Windows works best with Microsoft Visual C++ 5.0 ! or 6.0. It also helps to have access to the Windows registry from ! Python; if you have the Win32 extensions (win32api, win32con) installed, ! you're fine. (Python 2.0 includes the winreg module for this purpose, ! which the Distutils will use if available.) If not, the Distutils might ! not be able to find the Visual C++ executables, in which case it will ! die horribly when you attempt to build any Python extensions. ! ! There is also experimental support for building extensions under Windows ! using Borland C++ or GCC (Cygwin or Mingw32 ports). Come join the ! Distutils SIG to learn about using these compilers. *************** *** 104,115 **** ! INSTALLATION UNDER PYTHON 1.6 ! ------------------------------- ! The Distutils are included with Python 1.6, so there's generally no need ! to install it under Python 1.6. However, this release is more recent ! than the code included with Python 1.6a2, so if you really like life on the bleeding edge, you might want to install this Distutils release into ! your Python 1.6a2 library. To do this, you'll need to hide the original Distutils package directory --- 108,121 ---- ! INSTALLATION UNDER PYTHON 1.6/2.0 ! --------------------------------- ! The Distutils have been included with Python since 1.6a1, and Distutils ! 0.9 is approximately the code that will be included with Python 2.0b1 ! (modulo bug fixes). Thus, there's generally no need to install the ! Distutils under Python 1.6/2.0. However, Distutils releases may ! occasionally get ahead of Python releases, so if you really like life on the bleeding edge, you might want to install this Distutils release into ! your Python 1.6/2.0 library. To do this, you'll need to hide the original Distutils package directory *************** *** 119,127 **** follows: ! cd /usr/local/lib/python1.6 mv distutils distutils-orig On Windows, the stock Distutils installation is "Lib\distutils" under ! the Python directory ("C:\Python" by default for Python 1.6a2 and later). Again, you should just rename this directory, eg. to "distutils-orig", so that Python won't find it. --- 125,133 ---- follows: ! cd /usr/local/lib/python1.6 # or 2.0 mv distutils distutils-orig On Windows, the stock Distutils installation is "Lib\distutils" under ! the Python directory ("C:\Python" by default with Python 1.6a2 and later). Again, you should just rename this directory, eg. to "distutils-orig", so that Python won't find it. *************** *** 138,143 **** seriously caters to all three communities: developers can use it to build and install their modules, as well as create source distributions; ! packagers can use it to create RPMs and (soon!) executable installers ! for Windows; and of course installers can build and install modules from source (or just use an installer created by some kind packager). --- 144,149 ---- seriously caters to all three communities: developers can use it to build and install their modules, as well as create source distributions; ! packagers can use it to create RPMs and executable installers for ! Windows; and of course installers can build and install modules from source (or just use an installer created by some kind packager). *************** *** 148,154 **** way around LaTeX, the Python documentation tools, and Unix, you might be able to get something out of these. Realistically, though, the ! documentation is just provided in the distributio so you can send me doc ! patches; if you want to read it, you're better off getting the latest ! documentation from the Distutils documentation page: http://www.python.org/sigs/distutils-sig/doc/ --- 154,160 ---- way around LaTeX, the Python documentation tools, and Unix, you might be able to get something out of these. Realistically, though, the ! documentation is just provided in the distribution so you can send me ! doc patches; if you want to read it, you're better off getting the ! latest documentation from the Distutils documentation page: http://www.python.org/sigs/distutils-sig/doc/ *************** *** 171,190 **** ------------------------------ ! There are a couple of small incompatibilities between Distutils 0.1.x ! and 0.8.x that affect setup scripts. Unfortunately, two of the major ! module distributions currently using the Distutils -- Numerical Python and ! PyXML -- stumble across these incompatibilities. If you need to build ! and install either of these (or, in theory, any module distribution that ! used Distutils 0.1.x -- although most will not be affected), you have ! two options: * stick with Distutils 0.1.x (to be avoided, especially if you are ! running Python 1.6) * replace the setup script provided by the module distribution with ! the Distutils 0.8-compatibile version provided here (recommended) ! For example, if you want to build Numerical Python 15.2 using ! Distutils 0.8.x, you would: * rename the setup.py provided with Numerical Python 15.2, eg. to --- 177,196 ---- ------------------------------ ! There were a couple of small incompatibilities introduced with Distutils ! 0.8 (the previous major release) that affected setup scripts. ! Unfortunately, two of the major module distributions currently using the ! Distutils -- Numerical Python and PyXML -- stumble across these ! incompatibilities. If you need to build and install either of these ! (or, in theory, any module distribution that used Distutils 0.1.x -- ! although most will not be affected), you have two options: * stick with Distutils 0.1.x (to be avoided, especially if you are ! running Python 1.6/2.0) * replace the setup script provided by the module distribution with ! the Distutils 0.8-compatible version provided here (recommended) ! For example, if you want to build Numerical Python 15.2 using Distutils ! 0.8.x or 0.9, you would: * rename the setup.py provided with Numerical Python 15.2, eg. to *************** *** 268,278 **** there are a few outstanding problems: - * Distutils 0.8.x doesn't yet work with Python 1.5.1 - * not well tested with Python 1.6 * problems with specifying relative directories in an installation scheme - * "bdist_dumb" command untested on Windows * Mac OS support only partially included ! * no test suite (hmm, is this testing thing a common theme?) * doesn't check to see if you're clobbering an existing module installation --- 274,281 ---- there are a few outstanding problems: * problems with specifying relative directories in an installation scheme * Mac OS support only partially included ! * no test suite * doesn't check to see if you're clobbering an existing module installation *************** *** 280,287 **** There are some major features that still need to be added: - * no configuration file mechanism (although it's talked about - in the documentation) - * no support for probing the target system for either C- or Python- - level dependencies * no knowledge of whether you have installed some module distribution before --- 283,286 ---- *************** *** 296,309 **** http://www.python.org/mailman/listinfo/distutils-sig FUTURE PLANS ------------ - Distutils 0.9 will include support for configuration files and building - extensions on Mac OS (definitely with the MPW compiler, possibly with - CodeWarrior as well). - Distutils 1.0 will, if all goes well, be the version included with ! Python 1.6 (final). (If all does not go well, that version will be 1.0.1 or 1.0.2 or so.) --- 295,307 ---- http://www.python.org/mailman/listinfo/distutils-sig + Also, take a look through the TODO file to see a more recent/complete + version of the Distutils to-do list. + FUTURE PLANS ------------ Distutils 1.0 will, if all goes well, be the version included with ! Python 2.0 (final). (If all does not go well, that version will be 1.0.1 or 1.0.2 or so.) *************** *** 339,343 **** * Thomas Heller: more work on the registry support, several bug fixes in the Windows support, and just generally improving ! the code for compiling extensions on Windows * Eric Tiedemann: bug fixes * Fred Drake and Guido van Rossum: helping to figure out the --- 337,342 ---- * Thomas Heller: more work on the registry support, several bug fixes in the Windows support, and just generally improving ! the code for compiling extensions on Windows; also, the ! "bdist_wininst" command (and associated C code) * Eric Tiedemann: bug fixes * Fred Drake and Guido van Rossum: helping to figure out the *************** *** 345,356 **** * Joe Van Andel: tweaks to the sysconfig module, misc. bug fixes * Corran Webster: Mac OS support in general ! * Bastian Kleineidam: the "clean" command, and a pile of ! patches, bug-fixes, and ideas, large and small * Lyle Johnson: bug-spotting and -fixing; support for Borland's C/C++ ! compiler (forthcoming) * Harry Henry Gebel: bug-spotting and -fixing; the "bztar" archive format; the "bdist_rpm" command ! * Rene Liebscher: smarter extension-building; Cygwin/Mingw32 support ! (forthcoming) [spiritual, in roughly chronological order since the birth of the project] --- 344,356 ---- * Joe Van Andel: tweaks to the sysconfig module, misc. bug fixes * Corran Webster: Mac OS support in general ! * Bastian Kleineidam: a bunch of small but vital commands: clean, ! install_scripts, install_data, build_scripts; a pile of patches, ! bug-fixes, and good ideas, large and small * Lyle Johnson: bug-spotting and -fixing; support for Borland's C/C++ ! compiler * Harry Henry Gebel: bug-spotting and -fixing; the "bztar" archive format; the "bdist_rpm" command ! * Rene Liebscher: smarter extension-building; Cygwin/Mingw32 support; ! more help options [spiritual, in roughly chronological order since the birth of the project] Index: CHANGES.txt =================================================================== RCS file: /cvsroot/python/distutils/CHANGES.txt,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** CHANGES.txt 2000/04/25 03:05:17 1.10 --- CHANGES.txt 2000/06/30 02:54:00 1.11 *************** *** 1,2 **** --- 1,89 ---- + Release 0.9 (29 June, 2000): + ---------------------------- + * added config file mechanism + + * added "bdist_rpm" command: create an RPM built distribution (thanks to + Harry Henry Gebel) + + * added "bdist_wininst" command: create an executable Windows installer + (self-extracting ZIP file with a small GUI) (thanks to Thomas + Heller) + + * added extra help options to list the available C/C++ compilers + ("build_ext", "build_clib" commands), archive formats for source + distributions ("sdist"), and formats for built distributions + ("bdist") (thanks to Rene Liebscher) + + * added "install_data" and "install_scripts" commands to install, + respectively, arbitrary data files and scripts (thanks to Bastian + Kleineidam) + + * added the "build_scripts" command, mainly to fix the "#!" line + of Python scripts to point to the current Python interpreter + (Bastian Kleineidam again) + + * added "install_headers" command to install C/C++ header files + (to the include/python directory by default) + + * added a new, much simpler way to describe extensions in the setup + script (no more hairy list-of-tuples-of-dicts: just call the + Extension constructor to create an Extension object that describes + your extension) + + * modified all the example setup scripts to use the new way of + describing extensions (thanks to Harry Henry Gebel for help) + + * added another bit of meta-data: the "long description" (Harry Henry + Gebel) + + * added the ability to compile and link in resource files with + Visual C++ on Windows (Thomas Heller) + + * extension building now works on AIX (actually tested this time) + (thanks to Rene Liebscher for the initial patch, and Vladimir + Marangozov for testing) + + * extension building now works on OSF/1 (aka Digital Unix, aka Tru64 + Unix) (thanks to Mark Favas for testing) + + * experimental support for auto-configuration, via the "config" command + (think "Autoconf in Python") + + * modified example setup scripts for PIL and mxDateTime to do some + auto-configuration (only partially implemented -- no support for + actually using the information discovered during the build process) + + * experimental interface to Borland C++ for building extensions on + Windows (thanks to Lyle Johnson) + + * experimental interface to Cygwin and Mingw32 ports of GCC for building + extensions on Windows (thanks to Rene Liebscher) + + * added ability to select which compiler to use as an option to "build", + "build_ext", and/or "build_clib" + + * experimental support for building extensions from SWIG interface files + + * added more ways to sneak compiler and/or linker options in through + the back door ('extra_link_args', 'extra_compile_args' when + constructing an Extension object, for now) + + * fixed a bunch of silly bugs in "sdist"; most importantly, it will now + exclude directories from the source distribution that really shouldn't + be there (like the build tree, the temporary tree that is used to + build the source distribution archive, CVS and RCS directories, ...) + + * added a minimal debugging framework (set environment variable + DISTUTILS_DEBUG to 1 and you get a *lot* more feedback!) + + * added the notion of "list of symbols to export" to CCompiler interface + + * added preprocessor interface to CCompiler (only implemented in + UnixCCompiler, so far) + + * better separation of responsibilities between the UnixCCompiler class + and the build_ext command + + Release 0.8.2 (24 April, 2000): ------------------------------- From python-dev@python.org Fri Jun 30 03:54:38 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 29 Jun 2000 19:54:38 -0700 Subject: [Python-checkins] CVS: distutils setup.py,1.16,1.17 Message-ID: <200006300254.TAA10890@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv10877 Modified Files: setup.py Log Message: Bump version to 0.9. Index: setup.py =================================================================== RCS file: /cvsroot/python/distutils/setup.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** setup.py 2000/06/02 02:23:42 1.16 --- setup.py 2000/06/30 02:54:36 1.17 *************** *** 12,16 **** setup (name = "Distutils", ! version = "0.9pre", description = "Python Distribution Utilities", author = "Greg Ward", --- 12,16 ---- setup (name = "Distutils", ! version = "0.9", description = "Python Distribution Utilities", author = "Greg Ward", From python-dev@python.org Fri Jun 30 03:54:38 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 29 Jun 2000 19:54:38 -0700 Subject: [Python-checkins] CVS: distutils/distutils __init__.py,1.7,1.8 Message-ID: <200006300254.TAA10894@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv10877/distutils Modified Files: __init__.py Log Message: Bump version to 0.9. Index: __init__.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/__init__.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** __init__.py 2000/06/02 02:23:42 1.7 --- __init__.py 2000/06/30 02:54:36 1.8 *************** *** 11,13 **** __revision__ = "$Id$" ! __version__ = "0.9pre" --- 11,13 ---- __revision__ = "$Id$" ! __version__ = "0.9" From python-dev@python.org Fri Jun 30 04:36:44 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 20:36:44 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/inst inst.tex,1.15,1.16 Message-ID: <200006300336.UAA19153@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/inst In directory slayer.i.sourceforge.net:/tmp/cvs-serv19140/inst Modified Files: inst.tex Log Message: Update Python version numbers from 1.6 to 2.0 where appropriate. Make some references between the distutils documents hyperlinks using the \citetitle markup. Index: inst.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/inst/inst.tex,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** inst.tex 2000/06/24 01:33:16 1.15 --- inst.tex 2000/06/30 03:36:41 1.16 *************** *** 49,53 **** In the past, there has been little support for adding third-party modules to an existing Python installation. With the introduction of ! the Python Distribution Utilities (Distutils for short) in Python 1.6, this is starting to change. Not everything will change overnight, though, so while this document concentrates on installing module --- 49,53 ---- In the past, there has been little support for adding third-party modules to an existing Python installation. With the introduction of ! the Python Distribution Utilities (Distutils for short) in Python 2.0, this is starting to change. Not everything will change overnight, though, so while this document concentrates on installing module *************** *** 63,67 **** installation, but that's it. If you're looking for information on how to distribute your own Python modules so that others may use them, see ! the ``Distributing Python Modules'' manual. --- 63,67 ---- installation, but that's it. If you're looking for information on how to distribute your own Python modules so that others may use them, see ! the \citetitle[../dist/dist.html]{Distributing Python Modules} manual. *************** *** 275,284 **** {Platform}{Standard installation location}{Default value}{Notes} \lineiv{Unix (pure)} ! {\filenq{\filevar{prefix}/lib/python1.6/site-packages}} ! {\filenq{/usr/local/lib/python1.6/site-packages}} {(1)} \lineiv{Unix (non-pure)} ! {\filenq{\filevar{exec-prefix}/lib/python1.6/site-packages}} ! {\filenq{/usr/local/lib/python1.6/site-packages}} {(1)} \lineiv{Windows} --- 275,284 ---- {Platform}{Standard installation location}{Default value}{Notes} \lineiv{Unix (pure)} ! {\filenq{\filevar{prefix}/lib/python2.0/site-packages}} ! {\filenq{/usr/local/lib/python2.0/site-packages}} {(1)} \lineiv{Unix (non-pure)} ! {\filenq{\filevar{exec-prefix}/lib/python2.0/site-packages}} ! {\filenq{/usr/local/lib/python2.0/site-packages}} {(1)} \lineiv{Windows} *************** *** 315,323 **** running Python in interactive mode and typing a few simple commands. Under Unix, just type \code{python} at the shell prompt; under Windows, ! run ``Python 1.6 (interpreter)'' \XXX{right?}; under Mac~OS, \XXX{???}. ! Once the interpreter is started, you type Python code at the \code{>>>} ! prompt. For example, on my Linux system, I type the three Python ! statements shown below, and get the output as shown, to find out my ! \filevar{prefix} and \filevar{exec-prefix}: \begin{verbatim} Python 1.5.2 (#1, Apr 18 1999, 16:03:16) [GCC pgcc-2.91.60 19981201 (egcs-1.1.1 on linux2 --- 315,324 ---- running Python in interactive mode and typing a few simple commands. Under Unix, just type \code{python} at the shell prompt; under Windows, ! run ``Python 2.0 (interpreter)'' \XXX{right?}; under Mac~OS, \XXX{???}. ! Once the interpreter is started, you type Python code at the ! \samp{>>> } prompt. For example, on my Linux system, I type the three ! Python statements shown below, and get the output as shown, to find ! out my \filevar{prefix} and \filevar{exec-prefix}: ! \begin{verbatim} Python 1.5.2 (#1, Apr 18 1999, 16:03:16) [GCC pgcc-2.91.60 19981201 (egcs-1.1.1 on linux2 From python-dev@python.org Fri Jun 30 04:36:44 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 20:36:44 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/dist dist.tex,1.17,1.18 Message-ID: <200006300336.UAA19149@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/dist In directory slayer.i.sourceforge.net:/tmp/cvs-serv19140/dist Modified Files: dist.tex Log Message: Update Python version numbers from 1.6 to 2.0 where appropriate. Make some references between the distutils documents hyperlinks using the \citetitle markup. Index: dist.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/dist/dist.tex,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** dist.tex 2000/06/25 03:14:13 1.17 --- dist.tex 2000/06/30 03:36:41 1.18 *************** *** 22,39 **** for installing and maintaining third-party modules. With the introduction of the Python Distribution Utilities (Distutils for short) ! in Python 1.6, this situation should start to improve. This document only covers using the Distutils to distribute your Python ! modules. Using the Distutils does not tie you to Python 1.6, though: the Distutils work just fine with Python 1.5, and it is reasonable (and expected to become commonplace) to expect users of Python 1.5 to download and install the Distutils separately before they can install ! your modules. Python 1.6 users, of course, won't have to add anything to their Python installation in order to use the Distutils to install third-party modules. This document concentrates on the role of developer/distributor: if ! you're looking for information on installing Python modules, you should ! refer to the ``Installing Python Modules'' manual. --- 22,40 ---- for installing and maintaining third-party modules. With the introduction of the Python Distribution Utilities (Distutils for short) ! in Python 2.0, this situation should start to improve. This document only covers using the Distutils to distribute your Python ! modules. Using the Distutils does not tie you to Python 2.0, though: the Distutils work just fine with Python 1.5, and it is reasonable (and expected to become commonplace) to expect users of Python 1.5 to download and install the Distutils separately before they can install ! your modules. Python 2.0 users, of course, won't have to add anything to their Python installation in order to use the Distutils to install third-party modules. This document concentrates on the role of developer/distributor: if ! you're looking for information on installing Python modules, you ! should refer to the \citetitle[../inst/inst.html]{Installing Python ! Modules} manual. *************** *** 224,228 **** Here's a slightly more involved example, which we'll follow for the next couple of sections: the Distutils' own setup script. (Keep in mind that ! although the Distutils are included with Python 1.6, they also have an independent existence so that Python 1.5 users can use them to install other module distributions. The Distutils' own setup script is used to --- 225,229 ---- Here's a slightly more involved example, which we'll follow for the next couple of sections: the Distutils' own setup script. (Keep in mind that ! although the Distutils are included with Python 2.0, they also have an independent existence so that Python 1.5 users can use them to install other module distributions. The Distutils' own setup script is used to From python-dev@python.org Fri Jun 30 04:43:55 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 29 Jun 2000 20:43:55 -0700 Subject: [Python-checkins] CVS: distutils MANIFEST.in,1.8,1.9 Message-ID: <200006300343.UAA19471@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv19463 Modified Files: MANIFEST.in Log Message: Add TODO file. Add doc files conservatively, to avoid diving into my forest of symlinks. Index: MANIFEST.in =================================================================== RCS file: /cvsroot/python/distutils/MANIFEST.in,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** MANIFEST.in 2000/06/28 01:31:37 1.8 --- MANIFEST.in 2000/06/30 03:43:53 1.9 *************** *** 9,17 **** # ! include *.txt include MANIFEST.in recursive-include examples *.txt *.py prune examples/sample*/build ! recursive-include doc *.sty *.tex graft misc exclude misc/*.zip --- 9,17 ---- # ! include *.txt TODO include MANIFEST.in recursive-include examples *.txt *.py prune examples/sample*/build ! include doc/dist/*.tex doc/inst/*.tex graft misc exclude misc/*.zip From python-dev@python.org Fri Jun 30 04:45:10 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 29 Jun 2000 20:45:10 -0700 Subject: [Python-checkins] CVS: distutils TODO,1.5,1.6 Message-ID: <200006300345.UAA19523@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv19507 Modified Files: TODO Log Message: Added notes on a couple of quirks ("not's not a bug -- that's a quirk!") noticed while testing/packaging 0.9. Index: TODO =================================================================== RCS file: /cvsroot/python/distutils/TODO,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** TODO 2000/06/25 02:37:09 1.5 --- TODO 2000/06/30 03:45:08 1.6 *************** *** 150,155 **** --- 150,160 ---- for proper Windows support ) + * should be able to turn off byte-compilation (and optimized version too) + * need to test --compile, --optimize! (--optimize doesn't work, that's + for sure) + + DISTRIBUTION FORMATS -------------------- *************** *** 159,162 **** --- 164,170 ---- [punt: I don't care anymore, if anyone else does, let them fix it] + * bdist_rpm ignores the Python you ran it with, and just puts + "python setup.py ..." into the setup script + * make "bdist" take multiple formats (both for convenience and consistency with "sdist"); should be doable now that we can *************** *** 172,175 **** --- 180,193 ---- * Wise installer for Windows ("bdist_wise") [Thomas Heller said he will work on this when "bdist_wininst" is done] + + * should certainly put tarballs and zip files (sdist, bdist_dumb) in + "dist" directory -- maybe RPMs, Windows installers too + + + MISC + ---- + + * sdist tends to blow up when making hardlinks in the distribution + tree if a previous run blew up and left stuff already there From python-dev@python.org Fri Jun 30 04:45:42 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 20:45:42 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libwinreg.tex,1.1,1.2 Message-ID: <200006300345.UAA19551@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv19536 Modified Files: libwinreg.tex Log Message: Reflect the name change to _winreg; we still need documentation for the new winreg module. Index: libwinreg.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libwinreg.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** libwinreg.tex 2000/06/07 04:07:48 1.1 --- libwinreg.tex 2000/06/30 03:45:40 1.2 *************** *** 1,6 **** ! \section{\module{winreg} -- Windows registry access} ! \declaremodule{extension}{winreg} \platform{Windows} \modulesynopsis{Routines and objects for manipulating the Windows registry.} --- 1,6 ---- ! \section{\module{_winreg} -- Windows registry access} ! \declaremodule[-winreg]{extension}{_winreg} \platform{Windows} \modulesynopsis{Routines and objects for manipulating the Windows registry.} *************** *** 11,14 **** --- 11,18 ---- that the handles are closed correctly, even if the programmer neglects to explicitly close them. + + This module exposes a very low-level interface to the Windows + registry; for a more object-oriented interface, use the + \module{winreg} module. From python-dev@python.org Fri Jun 30 04:45:47 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 29 Jun 2000 20:45:47 -0700 Subject: [Python-checkins] CVS: distutils setup.cfg,1.2,1.3 Message-ID: <200006300345.UAA19562@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv19554 Modified Files: setup.cfg Log Message: Made myself the RPM packager; added a changelog entry. Index: setup.cfg =================================================================== RCS file: /cvsroot/python/distutils/setup.cfg,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** setup.cfg 2000/06/08 01:21:31 1.2 --- setup.cfg 2000/06/30 03:45:44 1.3 *************** *** 21,25 **** [bdist_rpm] release = 1 ! packager = Harry Henry Gebel doc_files = CHANGES.txt README.txt --- 21,25 ---- [bdist_rpm] release = 1 ! packager = Greg Ward doc_files = CHANGES.txt README.txt *************** *** 29,32 **** --- 29,35 ---- changelog = + * Thu Jun 29 2000 Greg Ward 0.9 + - Made myself the packager, since I can now create the RPM on my own + * Sun Jun 04 2000 Harry Henry Gebel 0.9pre-1 - Made sure scripts are file names, filled in some help strings, formatted From python-dev@python.org Fri Jun 30 04:46:31 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 29 Jun 2000 20:46:31 -0700 Subject: [Python-checkins] CVS: distutils/examples mxdatetime_setup.py,1.8,1.9 pil_setup.py,1.13,1.14 Message-ID: <200006300346.UAA19700@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/examples In directory slayer.i.sourceforge.net:/tmp/cvs-serv19687/examples Modified Files: mxdatetime_setup.py pil_setup.py Log Message: Added comment to explain that auto-configuration isn't done yet. Index: mxdatetime_setup.py =================================================================== RCS file: /cvsroot/python/distutils/examples/mxdatetime_setup.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** mxdatetime_setup.py 2000/06/29 02:22:02 1.8 --- mxdatetime_setup.py 2000/06/30 03:46:28 1.9 *************** *** 12,15 **** --- 12,21 ---- from distutils.command.config import config + # Auto-configuration: this will obsolete manual editing of the setup script + # soon, but not yet. The problem is that there's no way to communicate + # what the "config" command finds out to the "build_clib" and "build_ext" + # commands. Thus, it's fun to play with auto-configuration, but it's not + # ready for prime-time yet. + class config_mxDateTime (config): Index: pil_setup.py =================================================================== RCS file: /cvsroot/python/distutils/examples/pil_setup.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** pil_setup.py 2000/06/29 02:22:02 1.13 --- pil_setup.py 2000/06/30 03:46:28 1.14 *************** *** 58,61 **** --- 58,68 ---- + + # Auto-configuration: this will obsolete the above manual editing soon, but + # not yet. The problem is that there's no way to communicate what the + # "config" command finds out to the "build_clib" and "build_ext" commands. + # Thus, it's fun to play with auto-configuration, but it's not ready for + # prime-time yet. + class config_Imaging (config): From python-dev@python.org Fri Jun 30 04:50:13 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 20:50:13 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libwinreg.tex,1.2,1.3 Message-ID: <200006300350.UAA19860@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv19842 Modified Files: libwinreg.tex Log Message: Make sure to note that this module was added for Python 2.0! Index: libwinreg.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libwinreg.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** libwinreg.tex 2000/06/30 03:45:40 1.2 --- libwinreg.tex 2000/06/30 03:50:06 1.3 *************** *** 7,10 **** --- 7,12 ---- \sectionauthor{Mark Hammond}{MarkH@ActiveState.com} + \versionadded{2.0} + These functions exposes the Windows registry API to Python. Instead of using an integer as the registry handle, a handle object is used to ensure From python-dev@python.org Fri Jun 30 05:17:13 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 21:17:13 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules bsddbmodule.c,1.18,1.19 Message-ID: <200006300417.VAA27365@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv27358 Modified Files: bsddbmodule.c Log Message: Add a comment about needing to change a #include if using a version of Berkeley DB 2.0 or newer; most Linux distros will include a more recent version than 1.85. Index: bsddbmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/bsddbmodule.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** bsddbmodule.c 2000/05/03 23:44:31 1.18 --- bsddbmodule.c 2000/06/30 04:17:11 1.19 *************** *** 52,55 **** --- 52,56 ---- #include #include + /* If using Berkeley DB 2.0 or newer, change this include to : */ #include /* Please don't include internal header files of the Berkeley db package From python-dev@python.org Fri Jun 30 05:21:43 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 21:21:43 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libsocket.tex,1.44,1.45 Message-ID: <200006300421.VAA27708@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv27698 Modified Files: libsocket.tex Log Message: Say "manual page", not "man page", when referring to the Unix manual. Index: libsocket.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsocket.tex,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -r1.44 -r1.45 *** libsocket.tex 2000/05/03 19:40:32 1.44 --- libsocket.tex 2000/06/30 04:21:41 1.45 *************** *** 373,377 **** \begin{methoddesc}[socket]{setsockopt}{level, optname, value} ! Set the value of the given socket option (see the \UNIX{} man page \manpage{setsockopt}{2}). The needed symbolic constants are defined in the \module{socket} module (\code{SO_*} etc.). The value can be an --- 373,377 ---- \begin{methoddesc}[socket]{setsockopt}{level, optname, value} ! Set the value of the given socket option (see the \UNIX{} manual page \manpage{setsockopt}{2}). The needed symbolic constants are defined in the \module{socket} module (\code{SO_*} etc.). The value can be an From python-dev@python.org Fri Jun 30 05:24:54 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 21:24:54 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libtime.tex,1.30,1.31 Message-ID: <200006300424.VAA27832@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv27822 Modified Files: libtime.tex Log Message: Change description of altzone to not refer to the "0th meridian". Index: libtime.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libtime.tex,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -r1.30 -r1.31 *** libtime.tex 2000/04/05 15:06:03 1.30 --- libtime.tex 2000/06/30 04:24:52 1.31 *************** *** 112,117 **** \begin{datadesc}{altzone} The offset of the local DST timezone, in seconds west of UTC, if one ! is defined. Negative if the local DST timezone is east of the 0th ! meridian (as in Western Europe, including the UK). Only use this if \code{daylight} is nonzero. \end{datadesc} --- 112,117 ---- \begin{datadesc}{altzone} The offset of the local DST timezone, in seconds west of UTC, if one ! is defined. This is negative if the local DST timezone is east of UTC ! (as in Western Europe, including the UK). Only use this if \code{daylight} is nonzero. \end{datadesc} From python-dev@python.org Fri Jun 30 05:36:31 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 29 Jun 2000 21:36:31 -0700 Subject: [Python-checkins] CVS: distutils ANNOUNCE-0.9,NONE,1.1 ANNOUNCE-0.1,1.1,NONE ANNOUNCE-0.8,1.1,NONE Message-ID: <200006300436.VAA28170@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv28160 Added Files: ANNOUNCE-0.9 Removed Files: ANNOUNCE-0.1 ANNOUNCE-0.8 Log Message: Ditched the old announcements, and preserve the 0.9 announcement for posterity. --- NEW FILE --- Python Distribution Utilities release 0.9 June 29, 2000 The Python Distribution Utilities, or Distutils for short, are a collection of modules that aid in the development, distribution, and installation of Python modules. (It is intended that ultimately the Distutils will grow up into a system for distributing and installing whole Python applications, but for now their scope is limited to module distributions.) The Distutils are a standard part of Python 2.0; if you are running 2.0 (or one of the 1.6 alpha releases that preceded it), you don't need to install the Distutils separately. This release is primarily so that you can add the Distutils to a Python 1.5.2 installation -- you will then be able to install modules that require the Distutils, or use the Distutils to distribute your own modules. More information is available at the Distutils web page: http://www.python.org/sigs/distutils-sig/ and in the README.txt included in the Distutils source distribution. You can download the Distutils from http://www.python.org/sigs/distutils-sig/download.html Trivial patches can be sent to me (Greg Ward) at gward@python.net. Larger patches should be discussed on the Distutils mailing list: distutils-sig@python.org. From python-dev@python.org Fri Jun 30 05:57:57 2000 From: python-dev@python.org (Jeremy Hylton) Date: Thu, 29 Jun 2000 21:57:57 -0700 Subject: [Python-checkins] CVS: python/dist/src config.h.in,2.59,2.60 configure.in,1.129,1.130 configure,1.120,1.121 Message-ID: <200006300457.VAA29127@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv29090 Modified Files: config.h.in configure.in configure Log Message: penultimate phase of Neil Schemenauer's GC patches update configure files (turn --with-cycle-gc on for beta release?) Index: config.h.in =================================================================== RCS file: /cvsroot/python/python/dist/src/config.h.in,v retrieving revision 2.59 retrieving revision 2.60 diff -C2 -r2.59 -r2.60 *** config.h.in 2000/06/30 02:44:41 2.59 --- config.h.in 2000/06/30 04:57:55 2.60 *************** *** 211,214 **** --- 211,217 ---- #undef WITH_NEXT_FRAMEWORK + /* Define if you want cycle garbage collection */ + #undef WITH_CYCLE_GC + /* The number of bytes in an off_t. */ #undef SIZEOF_OFF_T Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.129 retrieving revision 1.130 diff -C2 -r1.129 -r1.130 *** configure.in 2000/06/30 02:48:53 1.129 --- configure.in 2000/06/30 04:57:55 1.130 *************** *** 1117,1120 **** --- 1117,1131 ---- [AC_MSG_RESULT(no)]) + # Check for GC support + AC_SUBST(USE_GC_MODULE) + USE_GC_MODULE="#" + AC_MSG_CHECKING(for --with-cycle-gc) + AC_ARG_WITH(cycle-gc, [--with-cycle-gc enable garbage collection], [ + AC_MSG_RESULT($withval) + AC_DEFINE(WITH_CYCLE_GC) + USE_GC_MODULE= + ], + AC_MSG_RESULT(no)) + # THIS MUST BE LAST, IT CAN BREAK OTHER TESTS! # Add sys/socket.h to confdefs.h Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.120 retrieving revision 1.121 diff -C2 -r1.120 -r1.121 *** configure 2000/06/30 02:48:53 1.120 --- configure 2000/06/30 04:57:55 1.121 *************** *** 46,49 **** --- 46,51 ---- ac_help="$ac_help --with-wctype-functions use wctype.h functions" + ac_help="$ac_help + --with-cycle-gc enable garbage collection" # Initialize some variables set by options. *************** *** 566,570 **** [...3819 lines suppressed...] #include --- 5632,5641 ---- EOF echo $ac_n "checking for socklen_t""... $ac_c" 1>&6 ! echo "configure:5635: checking for socklen_t" >&5 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 < *************** *** 5814,5817 **** --- 5837,5841 ---- s%@LIBM@%$LIBM%g s%@LIBC@%$LIBC%g + s%@USE_GC_MODULE@%$USE_GC_MODULE%g CEOF From python-dev@python.org Fri Jun 30 05:59:19 2000 From: python-dev@python.org (Jeremy Hylton) Date: Thu, 29 Jun 2000 21:59:19 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python import.c,2.134,2.135 Message-ID: <200006300459.VAA29186@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv29167/Python Modified Files: import.c Log Message: another typo caught by Rob Hooft Index: import.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/import.c,v retrieving revision 2.134 retrieving revision 2.135 diff -C2 -r2.134 -r2.135 *** import.c 2000/05/03 23:44:39 2.134 --- import.c 2000/06/30 04:59:17 2.135 *************** *** 88,92 **** /* Magic word as global; note that _PyImport_Init() can change the ! value of this global to accomodate for alterations of how the compiler works which are enabled by command line switches. */ static long pyc_magic = MAGIC; --- 88,92 ---- /* Magic word as global; note that _PyImport_Init() can change the ! value of this global to accommodate for alterations of how the compiler works which are enabled by command line switches. */ static long pyc_magic = MAGIC; From python-dev@python.org Fri Jun 30 06:00:06 2000 From: python-dev@python.org (Jeremy Hylton) Date: Thu, 29 Jun 2000 22:00:06 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python exceptions.c,1.2,1.3 Message-ID: <200006300500.WAA29289@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv29201/Python Modified Files: exceptions.c Log Message: replace constant 1 with symbolic constant METH_VARARGS another typo caught by Rob Hooft Index: exceptions.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/exceptions.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** exceptions.c 2000/06/20 18:36:26 1.2 --- exceptions.c 2000/06/30 04:59:59 1.3 *************** *** 190,194 **** * First thing we create is the base class for all exceptions, called * appropriately enough: Exception. Creation of this class makes no ! * assumptions about the existance of any other exception class -- except * for TypeError, which can conditionally exist. * --- 190,194 ---- * First thing we create is the base class for all exceptions, called * appropriately enough: Exception. Creation of this class makes no ! * assumptions about the existence of any other exception class -- except * for TypeError, which can conditionally exist. * *************** *** 283,289 **** Exception_methods[] = { /* methods for the Exception class */ ! { "__getitem__", Exception__getitem__, 1}, ! { "__str__", Exception__str__, 1}, ! { "__init__", Exception__init__, 1}, { NULL, NULL } }; --- 283,289 ---- Exception_methods[] = { /* methods for the Exception class */ ! { "__getitem__", Exception__getitem__, METH_VARARGS}, ! { "__str__", Exception__str__, METH_VARARGS}, ! { "__init__", Exception__init__, METH_VARARGS}, { NULL, NULL } }; *************** *** 397,401 **** PyMethodDef SystemExit_methods[] = { ! { "__init__", SystemExit__init__, 1}, {NULL, NULL} }; --- 397,401 ---- PyMethodDef SystemExit_methods[] = { ! { "__init__", SystemExit__init__, METH_VARARGS}, {NULL, NULL} }; *************** *** 577,582 **** static PyMethodDef EnvironmentError_methods[] = { ! {"__init__", EnvironmentError__init__, 1}, ! {"__str__", EnvironmentError__str__, 1}, {NULL, NULL} }; --- 577,582 ---- static PyMethodDef EnvironmentError_methods[] = { ! {"__init__", EnvironmentError__init__, METH_VARARGS}, ! {"__str__", EnvironmentError__str__, METH_VARARGS}, {NULL, NULL} }; *************** *** 727,732 **** PyMethodDef SyntaxError_methods[] = { ! {"__init__", SyntaxError__init__, 1}, ! {"__str__", SyntaxError__str__, 1}, {NULL, NULL} }; --- 727,732 ---- PyMethodDef SyntaxError_methods[] = { ! {"__init__", SyntaxError__init__, METH_VARARGS}, ! {"__str__", SyntaxError__str__, METH_VARARGS}, {NULL, NULL} }; From python-dev@python.org Fri Jun 30 06:02:55 2000 From: python-dev@python.org (Jeremy Hylton) Date: Thu, 29 Jun 2000 22:02:55 -0700 Subject: [Python-checkins] CVS: python/dist/src/Include objimpl.h,2.16,2.17 Message-ID: <200006300502.WAA03256@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Include In directory slayer.i.sourceforge.net:/tmp/cvs-serv3220/Include Modified Files: objimpl.h Log Message: final patches from Neil Schemenauer for garbage collection Index: objimpl.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/objimpl.h,v retrieving revision 2.16 retrieving revision 2.17 diff -C2 -r2.16 -r2.17 *** objimpl.h 2000/06/23 19:37:01 2.16 --- objimpl.h 2000/06/30 05:02:52 2.17 *************** *** 204,208 **** (PyVarObject *) PyObject_MALLOC( _PyObject_VAR_SIZE((typeobj),(n)) ),\ (typeobj), (n)) ) - #define PyObject_DEL(op) PyObject_FREE(op) /* This example code implements an object constructor with a custom --- 204,207 ---- *************** *** 234,243 **** the 1st step is performed automatically for you, so in a C++ class constructor you would start directly with PyObject_Init/InitVar. */ - #ifndef WITH_CYCLE_GC ! #define PyGC_INFO_SIZE 0 ! #endif #ifdef __cplusplus --- 233,298 ---- the 1st step is performed automatically for you, so in a C++ class constructor you would start directly with PyObject_Init/InitVar. */ + /* + * Garbage Collection Support + * ========================== + */ + + /* To make a new object participate in garbage collection use + PyObject_{New, VarNew, Del} to manage the memory. Set the type flag + Py_TPFLAGS_GC and define the type method tp_recurse. You should also + add the method tp_clear if your object is mutable. Include + PyGC_INFO_SIZE in the calculation of tp_basicsize. Call + PyObject_GC_Init after the pointers followed by tp_recurse become + valid (usually just before returning the object from the allocation + method. Call PyObject_GC_Fini before those pointers become invalid + (usually at the top of the deallocation method). */ #ifndef WITH_CYCLE_GC ! ! #define PyGC_HEAD_SIZE 0 ! #define PyObject_GC_Init(op) ! #define PyObject_GC_Fini(op) ! #define PyObject_AS_GC(op) (op) ! #define PyObject_FROM_GC(op) (op) ! #define PyObject_DEL(op) PyObject_FREE(op) ! ! #else ! ! /* Add the object into the container set */ ! extern DL_IMPORT(void) _PyGC_Insert Py_PROTO((PyObject *)); ! ! /* Remove the object from the container set */ ! extern DL_IMPORT(void) _PyGC_Remove Py_PROTO((PyObject *)); ! ! #define PyObject_GC_Init(op) _PyGC_Insert((PyObject *)op) ! #define PyObject_GC_Fini(op) _PyGC_Remove((PyObject *)op) ! ! /* Structure *prefixed* to container objects participating in GC */ ! typedef struct _gc_head { ! struct _gc_head *gc_next; ! struct _gc_head *gc_prev; ! int gc_refs; ! } PyGC_Head; ! ! #define PyGC_HEAD_SIZE sizeof(PyGC_Head) ! ! /* Test if a type has a GC head */ ! #define PyType_IS_GC(t) PyType_HasFeature((t), Py_TPFLAGS_GC) ! ! /* Test if an object has a GC head */ ! #define PyObject_IS_GC(o) PyType_IS_GC((o)->ob_type) ! ! /* Get an object's GC head */ ! #define PyObject_AS_GC(o) ((PyGC_Head *)(o)-1) ! ! /* Get the object given the PyGC_Head */ ! #define PyObject_FROM_GC(g) ((PyObject *)(((PyGC_Head *)g)+1)) ! ! #define PyObject_DEL(op) PyObject_FREE( PyObject_IS_GC(op) ? \ ! (ANY *)PyObject_AS_GC(op) : \ ! (ANY *)(op) ) ! ! #endif /* WITH_CYCLE_GC */ #ifdef __cplusplus From python-dev@python.org Fri Jun 30 06:02:55 2000 From: python-dev@python.org (Jeremy Hylton) Date: Thu, 29 Jun 2000 22:02:55 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild python16.dsp,1.6,1.7 Message-ID: <200006300502.WAA03275@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv3220/PCbuild Modified Files: python16.dsp Log Message: final patches from Neil Schemenauer for garbage collection Index: python16.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/python16.dsp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** python16.dsp 2000/06/06 23:29:09 1.6 --- python16.dsp 2000/06/30 05:02:53 1.7 *************** *** 660,663 **** --- 660,677 ---- # End Source File # Begin Source File + SOURCE=..\Modules\gcmodule.c + + !IF "$(CFG)" == "python16 - Win32 Release" + + !ELSEIF "$(CFG)" == "python16 - Win32 Debug" + + !ELSEIF "$(CFG)" == "python16 - Win32 Alpha Debug" + + !ELSEIF "$(CFG)" == "python16 - Win32 Alpha Release" + + !ENDIF + + # End Source File + # Begin Source File SOURCE=..\Python\getargs.c From python-dev@python.org Fri Jun 30 06:02:55 2000 From: python-dev@python.org (Jeremy Hylton) Date: Thu, 29 Jun 2000 22:02:55 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules gcmodule.c,NONE,2.1 Setup.thread.in,2.2,2.3 cPickle.c,2.43,2.44 newmodule.c,2.20,2.21 Message-ID: <200006300502.WAA03262@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv3220/Modules Modified Files: Setup.thread.in cPickle.c newmodule.c Added Files: gcmodule.c Log Message: final patches from Neil Schemenauer for garbage collection --- NEW FILE --- /* Reference Cycle Garbage Collection ================================== Neil Schemenauer Based on a post on the python-dev list. Ideas from Guido van Rossum, Eric Tiedemann, and various others. http://www.enme.calgary.ca/~nascheme/python/gc.html http://www.python.org/pipermail/python-dev/2000-March/003869.html http://www.python.org/pipermail/python-dev/2000-March/004010.html http://www.python.org/pipermail/python-dev/2000-March/004022.html For a highlevel view of the collection process, read the collect function. TODO: use a different interface for set_debug() (keywords)? tune parameters */ #include "Python.h" #ifdef WITH_CYCLE_GC /* magic gc_refs value */ #define GC_MOVED -1 /*** Global GC state ***/ /* linked lists of container objects */ static PyGC_Head generation0 = {&generation0, &generation0, 0}; static PyGC_Head generation1 = {&generation1, &generation1, 0}; static PyGC_Head generation2 = {&generation2, &generation2, 0}; static int generation = 0; /* current generation being collected */ /* collection frequencies, XXX tune these */ static int threshold0 = 100; /* net new containers before collection */ static int threshold1 = 10; /* generation0 collections before collecting 1 */ static int threshold2 = 10; /* generation1 collections before collecting 2 */ /* net new objects allocated since last collection */ static int allocated; /* set for debugging information */ #define DEBUG_STATS (1<<0) /* print collection statistics */ #define DEBUG_COLLECTABLE (1<<1) /* print collectable objects */ #define DEBUG_UNCOLLECTABLE (1<<2) /* print uncollectable objects */ #define DEBUG_INSTANCES (1<<3) /* print instances */ #define DEBUG_OBJECTS (1<<4) /* print other objects */ #define DEBUG_LEAK DEBUG_COLLECTABLE | \ DEBUG_UNCOLLECTABLE | \ DEBUG_INSTANCES | \ DEBUG_OBJECTS static int debug; /* list of uncollectable objects */ static PyObject *garbage; /*** list functions ***/ static void gc_list_init(PyGC_Head *list) { list->gc_prev = list; list->gc_next = list; } static void gc_list_append(PyGC_Head *node, PyGC_Head *list) { node->gc_next = list; node->gc_prev = list->gc_prev; node->gc_prev->gc_next = node; list->gc_prev = node; } static void 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 } static void gc_list_move(PyGC_Head *from, PyGC_Head *to) { if (from->gc_next == from) { /* empty from list */ gc_list_init(to); } else { to->gc_next = from->gc_next; to->gc_next->gc_prev = to; to->gc_prev = from->gc_prev; to->gc_prev->gc_next = to; } gc_list_init(from); } /* append a list onto another list, from becomes an empty list */ static void gc_list_merge(PyGC_Head *from, PyGC_Head *to) { PyGC_Head *tail; if (from->gc_next != from) { tail = to->gc_prev; tail->gc_next = from->gc_next; tail->gc_next->gc_prev = tail; to->gc_prev = from->gc_prev; to->gc_prev->gc_next = to; } gc_list_init(from); } static long gc_list_size(PyGC_Head *list) { PyGC_Head *gc; long n = 0; for (gc = list->gc_next; gc != list; gc = gc->gc_next) { n++; } return n; } /*** end of list stuff ***/ /* Set all gc_refs = ob_refcnt */ static void update_refs(PyGC_Head *containers) { PyGC_Head *gc = containers->gc_next; for (; gc != containers; gc=gc->gc_next) { gc->gc_refs = PyObject_FROM_GC(gc)->ob_refcnt; } } static int visit_decref(PyObject *op, void *data) { if (op && PyObject_IS_GC(op)) { PyObject_AS_GC(op)->gc_refs--; } return 0; } /* Subtract internal references from gc_refs */ static void subtract_refs(PyGC_Head *containers) { traverseproc traverse; PyGC_Head *gc = containers->gc_next; for (; gc != containers; gc=gc->gc_next) { traverse = PyObject_FROM_GC(gc)->ob_type->tp_traverse; (void) traverse(PyObject_FROM_GC(gc), (visitproc)visit_decref, NULL); } } /* Append objects with gc_refs > 0 to roots list */ static void move_roots(PyGC_Head *containers, PyGC_Head *roots) { PyGC_Head *next; PyGC_Head *gc = containers->gc_next; while (gc != containers) { next = gc->gc_next; if (gc->gc_refs > 0) { gc_list_remove(gc); gc_list_append(gc, roots); gc->gc_refs = GC_MOVED; } gc = next; } } static int visit_reachable(PyObject *op, PyGC_Head *roots) { if (PyObject_IS_GC(op)) { PyGC_Head *gc = PyObject_AS_GC(op); if (gc && gc->gc_refs != GC_MOVED) { gc_list_remove(gc); gc_list_append(gc, roots); gc->gc_refs = GC_MOVED; } } return 0; } /* Move objects referenced from reachable to reachable set. */ static void move_root_reachable(PyGC_Head *reachable) { traverseproc traverse; PyGC_Head *gc = reachable->gc_next; for (; gc != reachable; gc=gc->gc_next) { /* careful, reachable list is growing here */ PyObject *op = PyObject_FROM_GC(gc); traverse = op->ob_type->tp_traverse; (void) traverse(op, (visitproc)visit_reachable, (void *)reachable); } } /* move all objects with finalizers (instances with __del__) */ static void move_finalizers(PyGC_Head *unreachable, PyGC_Head *finalizers) { PyGC_Head *next; PyGC_Head *gc = unreachable->gc_next; static PyObject *delstr; if (delstr == NULL) { delstr = PyString_InternFromString("__del__"); } for (; gc != unreachable; gc=next) { PyObject *op = PyObject_FROM_GC(gc); next = gc->gc_next; if (PyInstance_Check(op) && PyObject_HasAttr(op, delstr)) { gc_list_remove(gc); gc_list_append(gc, finalizers); } } } /* called by tp_traverse */ static int visit_finalizer_reachable(PyObject *op, PyGC_Head *finalizers) { if (PyObject_IS_GC(op)) { PyGC_Head *gc = PyObject_AS_GC(op); if (gc && gc->gc_refs != GC_MOVED) { gc_list_remove(gc); gc_list_append(gc, finalizers); gc->gc_refs = GC_MOVED; } } return 0; } /* Move objects referenced from roots to roots */ static void move_finalizer_reachable(PyGC_Head *finalizers) { traverseproc traverse; PyGC_Head *gc = finalizers->gc_next; for (; gc != finalizers; gc=gc->gc_next) { /* careful, finalizers list is growing here */ traverse = PyObject_FROM_GC(gc)->ob_type->tp_traverse; (void) traverse(PyObject_FROM_GC(gc), (visitproc)visit_finalizer_reachable, (void *)finalizers); } } static void debug_instance(PyObject *output, char *msg, PyInstanceObject *inst) { char buf[200]; char *cname; /* be careful not to create new dictionaries */ PyObject *classname = inst->in_class->cl_name; if (classname != NULL && PyString_Check(classname)) cname = PyString_AsString(classname); else cname = "?"; sprintf(buf, "gc: %s<%.100s instance at %lx>\n", msg, cname, (long)inst); PyFile_WriteString(buf, output); } static void debug_cycle(PyObject *output, char *msg, PyObject *op) { if ((debug & DEBUG_INSTANCES) && PyInstance_Check(op)) { debug_instance(output, msg, (PyInstanceObject *)op); } else if (debug & DEBUG_OBJECTS) { char buf[200]; sprintf(buf, "gc: %s<%s 0x%x>\n", msg, op->ob_type->tp_name, (long)op); PyFile_WriteString(buf, output); } } /* Handle uncollectable garbage (cycles with finalizers). */ static void handle_finalizers(PyGC_Head *finalizers, PyGC_Head *old) { PyGC_Head *gc; if (garbage == NULL) { garbage = PyList_New(0); } for (gc = finalizers->gc_next; gc != finalizers; gc = finalizers->gc_next) { PyObject *op = PyObject_FROM_GC(gc); /* Add all instances to a Python accessible list of garbage */ if (PyInstance_Check(op)) { PyList_Append(garbage, op); } /* We assume that all objects in finalizers are reachable from * instances. Once we add the instances to the garbage list * everything is reachable from Python again. */ gc_list_remove(gc); gc_list_append(gc, old); } } /* Break reference cycles by clearing the containers involved. This is * tricky business as the lists can be changing and we don't know which * objects may be freed. It is possible I screwed something up here. */ static void delete_garbage(PyGC_Head *unreachable, PyGC_Head *old) { inquiry clear; while (unreachable->gc_next != unreachable) { PyGC_Head *gc = unreachable->gc_next; PyObject *op = PyObject_FROM_GC(gc); /* PyList_Append(garbage, op); */ if ((clear = op->ob_type->tp_clear) != NULL) { Py_INCREF(op); clear((PyObject *)op); Py_DECREF(op); } /* only try to call tp_clear once for each object */ if (unreachable->gc_next == gc) { /* still alive, move it, it may die later */ gc_list_remove(gc); gc_list_append(gc, old); } } } /* This is the main function. Read this to understand how the * collection process works. */ static long collect(PyGC_Head *young, PyGC_Head *old) { long n = 0; long m = 0; PyGC_Head reachable; PyGC_Head unreachable; PyGC_Head finalizers; PyGC_Head *gc; PyObject *output = NULL; if (debug) { output = PySys_GetObject("stderr"); } if (debug & DEBUG_STATS) { char buf[100]; sprintf(buf, "gc: collecting generation %d...\n", generation); PyFile_WriteString(buf,output); sprintf(buf, "gc: objects in each generation: %d %d %d\n", gc_list_size(&generation0), gc_list_size(&generation1), gc_list_size(&generation2)); PyFile_WriteString(buf,output); } /* Using ob_refcnt and gc_refs, calculate which objects in the * container set are reachable from outside the set (ie. have a * refcount greater than 0 when all the references within the * set are taken into account */ update_refs(young); subtract_refs(young); /* Move everything reachable from outside the set into the * reachable set (ie. gc_refs > 0). Next, move everything * reachable from objects in the reachable set. */ gc_list_init(&reachable); move_roots(young, &reachable); move_root_reachable(&reachable); /* move unreachable objects to a temporary list, new objects can be * allocated after this point */ gc_list_init(&unreachable); gc_list_move(young, &unreachable); /* move reachable objects to next generation */ gc_list_merge(&reachable, old); /* Move objects reachable from finalizers, we can't safely delete * them. Python programmers should take care not to create such * things. For Python finalizers means instance objects with * __del__ methods. */ gc_list_init(&finalizers); move_finalizers(&unreachable, &finalizers); move_finalizer_reachable(&finalizers); /* Collect statistics on collectable objects found and print * debugging information. */ for (gc = unreachable.gc_next; gc != &unreachable; gc = gc->gc_next) { m++; if (output != NULL && (debug & DEBUG_COLLECTABLE)) { debug_cycle(output, "collectable ", PyObject_FROM_GC(gc)); } } /* call tp_clear on objects in the collectable set. This will cause * the reference cycles to be broken. It may also cause some objects in * finalizers to be freed */ delete_garbage(&unreachable, old); /* Collect statistics on uncollectable objects found and print * debugging information. */ for (gc = finalizers.gc_next; gc != &finalizers; gc = gc->gc_next) { n++; if (output != NULL && (debug & DEBUG_UNCOLLECTABLE)) { debug_cycle(output, "uncollectable ", PyObject_FROM_GC(gc)); } } if (output != NULL && (debug & DEBUG_STATS)) { if (m == 0 && n == 0) { PyFile_WriteString("gc: done.\n", output); } else { char buf[200]; sprintf(buf, "gc: done, %d unreachable, %d uncollectable.\n", n+m, n); PyFile_WriteString(buf, output); } } /* Append instances in the uncollectable set to a Python * reachable list of garbage. The programmer has to deal with * this if they insist on creating this type of structure. */ handle_finalizers(&finalizers, old); allocated = 0; PyErr_Clear(); /* in case writing to sys.stderr failed */ return n+m; } static long collect_generations(void) { static long collections0 = 0; static long collections1 = 0; long n; if (collections1 > threshold2) { generation = 2; gc_list_merge(&generation0, &generation2); gc_list_merge(&generation1, &generation2); if (generation2.gc_next != &generation2) { n = collect(&generation2, &generation2); } collections1 = 0; } else if (collections0 > threshold1) { generation = 1; collections1++; gc_list_merge(&generation0, &generation1); if (generation1.gc_next != &generation1) { n = collect(&generation1, &generation2); } collections0 = 0; } else { generation = 0; collections0++; if (generation0.gc_next != &generation0) { n = collect(&generation0, &generation1); } } return n; } void _PyGC_Insert(PyObject *op) { /* collection lock since collecting may cause allocations */ static int collecting = 0; #ifdef Py_DEBUG if (!PyObject_IS_GC(op)) { abort(); } #endif if (threshold0 && allocated > threshold0 && !collecting) { collecting++; collect_generations(); collecting--; } allocated++; gc_list_append(PyObject_AS_GC(op), &generation0); } void _PyGC_Remove(PyObject *op) { PyGC_Head *g = PyObject_AS_GC(op); #ifdef Py_DEBUG if (!PyObject_IS_GC(op)) { abort(); } #endif gc_list_remove(g); if (allocated > 0) { allocated--; } } static char collect__doc__[] = "collect() -> n\n" "\n" "Run a full collection. The number of unreachable objects is returned.\n" ; static PyObject * Py_collect(self, args) PyObject *self; PyObject *args; { long n; if(!PyArg_ParseTuple(args, "")) /* check no args */ return NULL; generation = 2; gc_list_merge(&generation0, &generation2); gc_list_merge(&generation1, &generation2); n = collect(&generation2, &generation2); return Py_BuildValue("i", n); } static char set_debug__doc__[] = "set_debug(flags) -> None\n" "\n" "Set the garbage collection debugging flags. Debugging information is\n" "written to sys.stderr.\n" "\n" "flags is an integer and can have the following bits turned on:\n" "\n" " DEBUG_STATS - Print statistics during collection.\n" " DEBUG_COLLECTABLE - Print collectable objects found.\n" " DEBUG_UNCOLLECTABLE - Print unreachable but uncollectable objects found.\n" " DEBUG_INSTANCES - Print instance objects.\n" " DEBUG_OBJECTS - Print objects other than instances.\n" " DEBUG_LEAK - Debug leaking programs (everything but STATS).\n" ; static PyObject * Py_set_debug(self, args) PyObject *self; PyObject *args; { if (!PyArg_ParseTuple(args, "l", &debug)) return NULL; Py_INCREF(Py_None); return Py_None; } static char get_debug__doc__[] = "get_debug() -> flags\n" "\n" "Get the garbage collection debugging flags.\n" ; static PyObject * Py_get_debug(self, args) PyObject *self; PyObject *args; { if(!PyArg_ParseTuple(args, "")) /* no args */ return NULL; return Py_BuildValue("i", debug); } static char set_thresh__doc__[] = "set_threshold(threshold0, [threhold1, threshold2]) -> None\n" "\n" "Sets the collection thresholds. Setting threshold0 to zero disables\n" "collection.\n" ; static PyObject * Py_set_thresh(self, args) PyObject *self; PyObject *args; { if (!PyArg_ParseTuple(args, "i|ii", &threshold0, &threshold1, &threshold2)) return NULL; Py_INCREF(Py_None); return Py_None; } static char get_thresh__doc__[] = "get_threshold() -> (threshold0, threshold1, threshold2)\n" "\n" "Return the current collection thresholds\n" ; static PyObject * Py_get_thresh(self, args) PyObject *self; PyObject *args; { if(!PyArg_ParseTuple(args, "")) /* no args */ return NULL; return Py_BuildValue("(iii)", threshold0, threshold1, threshold2); } static char gc__doc__ [] = "This module provides access to the garbage collector for reference cycles.\n" "\n" "collect() -- Do a full collection right now.\n" "set_debug() -- Set debugging flags.\n" "get_debug() -- Get debugging flags.\n" "set_threshold() -- Set the collection thresholds.\n" "get_threshold() -- Return the current the collection thresholds.\n" ; static PyMethodDef GcMethods[] = { {"set_debug", Py_set_debug, METH_VARARGS, set_debug__doc__}, {"get_debug", Py_get_debug, METH_VARARGS, get_debug__doc__}, {"set_threshold", Py_set_thresh, METH_VARARGS, set_thresh__doc__}, {"get_threshold", Py_get_thresh, METH_VARARGS, get_thresh__doc__}, {"collect", Py_collect, METH_VARARGS, collect__doc__}, {NULL, NULL} /* Sentinel */ }; void initgc(void) { PyObject *m; PyObject *d; m = Py_InitModule4("gc", GcMethods, gc__doc__, NULL, PYTHON_API_VERSION); d = PyModule_GetDict(m); if (garbage == NULL) { garbage = PyList_New(0); } PyDict_SetItemString(d, "garbage", garbage); PyDict_SetItemString(d, "DEBUG_STATS", PyInt_FromLong(DEBUG_STATS)); PyDict_SetItemString(d, "DEBUG_COLLECTABLE", PyInt_FromLong(DEBUG_COLLECTABLE)); PyDict_SetItemString(d, "DEBUG_UNCOLLECTABLE", PyInt_FromLong(DEBUG_UNCOLLECTABLE)); PyDict_SetItemString(d, "DEBUG_INSTANCES", PyInt_FromLong(DEBUG_INSTANCES)); PyDict_SetItemString(d, "DEBUG_OBJECTS", PyInt_FromLong(DEBUG_OBJECTS)); PyDict_SetItemString(d, "DEBUG_LEAK", PyInt_FromLong(DEBUG_LEAK)); } #endif /* WITH_CYCLE_GC */ Index: Setup.thread.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Setup.thread.in,v retrieving revision 2.2 retrieving revision 2.3 diff -C2 -r2.2 -r2.3 *** Setup.thread.in 2000/06/29 16:08:28 2.2 --- Setup.thread.in 2000/06/30 05:02:53 2.3 *************** *** 11,12 **** --- 11,15 ---- @USE_THREAD_MODULE@thread threadmodule.c + + # Garbage collection enabled with --with-cycle-gc + @USE_GC_MODULE@gc gcmodule.c Index: cPickle.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cPickle.c,v retrieving revision 2.43 retrieving revision 2.44 diff -C2 -r2.43 -r2.44 *** cPickle.c 2000/06/28 22:23:56 2.43 --- cPickle.c 2000/06/30 05:02:53 2.44 *************** *** 2893,2897 **** goto err; } ! return (PyObject *)inst; } --- 2893,2897 ---- goto err; } ! PyObject_GC_Init(inst); return (PyObject *)inst; } Index: newmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/newmodule.c,v retrieving revision 2.20 retrieving revision 2.21 diff -C2 -r2.20 -r2.21 *** newmodule.c 2000/05/03 23:44:32 2.20 --- newmodule.c 2000/06/30 05:02:53 2.21 *************** *** 57,60 **** --- 57,61 ---- inst->in_class = (PyClassObject *)klass; inst->in_dict = dict; + PyObject_GC_Init(inst); return (PyObject *)inst; } From python-dev@python.org Fri Jun 30 06:02:56 2000 From: python-dev@python.org (Jeremy Hylton) Date: Thu, 29 Jun 2000 22:02:56 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_gc.py,NONE,1.1 Message-ID: <200006300502.WAA03281@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv3220/Lib/test Added Files: test_gc.py Log Message: final patches from Neil Schemenauer for garbage collection --- NEW FILE --- import gc def test_list(): l = [] l.append(l) print 'list 0x%x' % id(l) gc.collect() del l assert gc.collect() == 1 def test_dict(): d = {} d[1] = d print 'dict 0x%x' % id(d) gc.collect() del d assert gc.collect() == 1 def test_tuple(): l = [] t = (l,) l.append(t) print 'list 0x%x' % id(l) print 'tuple 0x%x' % id(t) gc.collect() del t del l assert gc.collect() == 2 def test_class(): class A: pass A.a = A print 'class 0x%x' % id(A) gc.collect() del A assert gc.collect() > 0 def test_instance(): class A: pass a = A() a.a = a print repr(a) gc.collect() del a assert gc.collect() > 0 def test_method(): class A: def __init__(self): self.init = self.__init__ a = A() gc.collect() del a assert gc.collect() > 0 def test_finalizer(): class A: def __del__(self): pass class B: pass a = A() a.a = a id_a = id(a) b = B() b.b = b print 'a', repr(a) print 'b', repr(b) gc.collect() gc.garbage[:] = [] del a del b assert gc.collect() > 0 assert id(gc.garbage[0]) == id_a def test_function(): d = {} exec("def f(): pass\n") in d print 'dict 0x%x' % id(d) print 'func 0x%x' % id(d['f']) gc.collect() del d assert gc.collect() == 2 def test_all(): debug = gc.get_debug() gc.set_debug(gc.DEBUG_LEAK | gc.DEBUG_STATS) test_list() test_dict() test_tuple() test_class() test_instance() test_method() test_finalizer() test_function() gc.set_debug(debug) test_all() From python-dev@python.org Fri Jun 30 06:02:56 2000 From: python-dev@python.org (Jeremy Hylton) Date: Thu, 29 Jun 2000 22:02:56 -0700 Subject: [Python-checkins] CVS: python/dist/src/PC config.c,1.22,1.23 config.h,1.38,1.39 Message-ID: <200006300502.WAA03280@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv3220/PC Modified Files: config.c config.h Log Message: final patches from Neil Schemenauer for garbage collection Index: config.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/config.c,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** config.c 2000/05/08 14:15:19 1.22 --- config.c 2000/06/30 05:02:53 1.23 *************** *** 44,47 **** --- 44,50 ---- extern void initcmath(); extern void initerrno(); + #ifdef WITH_CYCLE_GC + extern void initgc(); + #endif #ifndef MS_WIN64 extern void initimageop(); *************** *** 90,93 **** --- 93,99 ---- {"cmath", initcmath}, {"errno", initerrno}, + #ifdef WITH_CYCLE_GC + {"gc", initgc}, + #endif #ifndef MS_WIN64 {"imageop", initimageop}, Index: config.h =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/config.h,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -r1.38 -r1.39 *** config.h 2000/06/29 20:44:47 1.38 --- config.h 2000/06/30 05:02:53 1.39 *************** *** 452,455 **** --- 452,458 ---- /* #define WITH_READLINE 1 */ + /* Define if you want cycle garbage collection */ + /* #define WITH_CYCLE_GC 1 */ + /* Define if you have clock. */ /* #define HAVE_CLOCK */ From python-dev@python.org Fri Jun 30 06:02:56 2000 From: python-dev@python.org (Jeremy Hylton) Date: Thu, 29 Jun 2000 22:02:56 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_gc,NONE,1.1 Message-ID: <200006300502.WAA03286@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv3220/Lib/test/output Added Files: test_gc Log Message: final patches from Neil Schemenauer for garbage collection --- NEW FILE --- test_gc list 0x831a754 dict 0x831a754 list 0x831a754 tuple 0x831a734 class 0x831a794 a b dict 0x831a9bc func 0x831d9e4 From python-dev@python.org Fri Jun 30 06:02:56 2000 From: python-dev@python.org (Jeremy Hylton) Date: Thu, 29 Jun 2000 22:02:56 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects classobject.c,2.92,2.93 dictobject.c,2.54,2.55 funcobject.c,2.23,2.24 listobject.c,2.75,2.76 object.c,2.74,2.75 tupleobject.c,2.38,2.39 Message-ID: <200006300502.WAA03295@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv3220/Objects Modified Files: classobject.c dictobject.c funcobject.c listobject.c object.c tupleobject.c Log Message: final patches from Neil Schemenauer for garbage collection Index: classobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v retrieving revision 2.92 retrieving revision 2.93 diff -C2 -r2.92 -r2.93 *** classobject.c 2000/06/29 19:17:04 2.92 --- classobject.c 2000/06/30 05:02:53 2.93 *************** *** 133,136 **** --- 133,137 ---- Py_XINCREF(op->cl_setattr); Py_XINCREF(op->cl_delattr); + PyObject_GC_Init(op); return (PyObject *) op; } *************** *** 142,145 **** --- 143,147 ---- PyClassObject *op; { + PyObject_GC_Fini(op); Py_DECREF(op->cl_bases); Py_DECREF(op->cl_dict); *************** *** 429,433 **** 0, "class", ! sizeof(PyClassObject) + PyGC_INFO_SIZE, 0, (destructor)class_dealloc, /*tp_dealloc*/ --- 431,435 ---- 0, "class", ! sizeof(PyClassObject) + PyGC_HEAD_SIZE, 0, (destructor)class_dealloc, /*tp_dealloc*/ *************** *** 491,494 **** --- 493,497 ---- return NULL; inst->in_dict = PyDict_New(); + PyObject_GC_Init(inst); if (inst->in_dict == NULL) { PyObject_DEL(inst); *************** *** 540,548 **** PyObject *del; static PyObject *delstr; /* Call the __del__ method if it exists. First temporarily revive the object and save the current exception, if any. */ #ifdef Py_TRACE_REFS /* much too complicated if Py_TRACE_REFS defined */ - extern long _Py_RefTotal; inst->ob_type = &PyInstance_Type; _Py_NewReference((PyObject *)inst); --- 543,552 ---- PyObject *del; static PyObject *delstr; + extern long _Py_RefTotal; + PyObject_GC_Fini(inst); /* Call the __del__ method if it exists. First temporarily revive the object and save the current exception, if any. */ #ifdef Py_TRACE_REFS /* much too complicated if Py_TRACE_REFS defined */ inst->ob_type = &PyInstance_Type; _Py_NewReference((PyObject *)inst); *************** *** 592,595 **** --- 596,600 ---- inst->ob_type->tp_free--; #endif + PyObject_GC_Init((PyObject *)inst); return; /* __del__ added a reference; don't delete now */ } *************** *** 599,603 **** --- 604,610 ---- #endif _Py_ForgetReference((PyObject *)inst); + #ifndef WITH_CYCLE_GC inst->ob_type = NULL; + #endif #endif /* Py_TRACE_REFS */ Py_DECREF(inst->in_class); *************** *** 1511,1515 **** 0, "instance", ! sizeof(PyInstanceObject) + PyGC_INFO_SIZE, 0, (destructor)instance_dealloc, /*tp_dealloc*/ --- 1518,1522 ---- 0, "instance", ! sizeof(PyInstanceObject) + PyGC_HEAD_SIZE, 0, (destructor)instance_dealloc, /*tp_dealloc*/ *************** *** 1569,1572 **** --- 1576,1580 ---- Py_INCREF(class); im->im_class = class; + PyObject_GC_Init(im); return (PyObject *)im; } *************** *** 1644,1647 **** --- 1652,1656 ---- register PyMethodObject *im; { + PyObject_GC_Fini(im); Py_DECREF(im->im_func); Py_XDECREF(im->im_self); *************** *** 1746,1750 **** 0, "instance method", ! sizeof(PyMethodObject) + PyGC_INFO_SIZE, 0, (destructor)instancemethod_dealloc, /*tp_dealloc*/ --- 1755,1759 ---- 0, "instance method", ! sizeof(PyMethodObject) + PyGC_HEAD_SIZE, 0, (destructor)instancemethod_dealloc, /*tp_dealloc*/ Index: dictobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/dictobject.c,v retrieving revision 2.54 retrieving revision 2.55 diff -C2 -r2.54 -r2.55 *** dictobject.c 2000/06/23 19:37:01 2.54 --- dictobject.c 2000/06/30 05:02:53 2.55 *************** *** 130,133 **** --- 130,134 ---- mp->ma_fill = 0; mp->ma_used = 0; + PyObject_GC_Init(mp); return (PyObject *)mp; } *************** *** 482,485 **** --- 483,487 ---- 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) { *************** *** 1088,1092 **** 0, "dictionary", ! sizeof(dictobject) + PyGC_INFO_SIZE, 0, (destructor)dict_dealloc, /*tp_dealloc*/ --- 1090,1094 ---- 0, "dictionary", ! sizeof(dictobject) + PyGC_HEAD_SIZE, 0, (destructor)dict_dealloc, /*tp_dealloc*/ Index: funcobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/funcobject.c,v retrieving revision 2.23 retrieving revision 2.24 diff -C2 -r2.23 -r2.24 *** funcobject.c 2000/06/29 19:17:04 2.23 --- funcobject.c 2000/06/30 05:02:53 2.24 *************** *** 64,67 **** --- 64,68 ---- op->func_doc = doc; } + PyObject_GC_Init(op); return (PyObject *)op; } *************** *** 187,190 **** --- 188,192 ---- PyFunctionObject *op; { + PyObject_GC_Fini(op); Py_DECREF(op->func_code); Py_DECREF(op->func_globals); *************** *** 278,282 **** 0, "function", ! sizeof(PyFunctionObject) + PyGC_INFO_SIZE, 0, (destructor)func_dealloc, /*tp_dealloc*/ --- 280,284 ---- 0, "function", ! sizeof(PyFunctionObject) + PyGC_HEAD_SIZE, 0, (destructor)func_dealloc, /*tp_dealloc*/ Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.75 retrieving revision 2.76 diff -C2 -r2.75 -r2.76 *** listobject.c 2000/06/23 19:37:01 2.75 --- listobject.c 2000/06/30 05:02:53 2.76 *************** *** 73,80 **** /* PyObject_NewVar is inlined */ op = (PyListObject *) PyObject_MALLOC(sizeof(PyListObject) ! + PyGC_INFO_SIZE); if (op == NULL) { return PyErr_NoMemory(); } if (size <= 0) { op->ob_item = NULL; --- 73,81 ---- /* PyObject_NewVar is inlined */ op = (PyListObject *) PyObject_MALLOC(sizeof(PyListObject) ! + PyGC_HEAD_SIZE); if (op == NULL) { return PyErr_NoMemory(); } + op = (PyListObject *) PyObject_FROM_GC(op); if (size <= 0) { op->ob_item = NULL; *************** *** 90,93 **** --- 91,95 ---- for (i = 0; i < size; i++) op->ob_item[i] = NULL; + PyObject_GC_Init(op); return (PyObject *) op; } *************** *** 217,220 **** --- 219,223 ---- int i; Py_TRASHCAN_SAFE_BEGIN(op) + PyObject_GC_Fini(op); if (op->ob_item != NULL) { /* Do it backwards, for Christian Tismer. *************** *** 1499,1503 **** 0, "list", ! sizeof(PyListObject) + PyGC_INFO_SIZE, 0, (destructor)list_dealloc, /*tp_dealloc*/ --- 1502,1506 ---- 0, "list", ! sizeof(PyListObject) + PyGC_HEAD_SIZE, 0, (destructor)list_dealloc, /*tp_dealloc*/ *************** *** 1578,1582 **** 0, "list (immutable, during sort)", ! sizeof(PyListObject) + PyGC_INFO_SIZE, 0, 0, /*tp_dealloc*/ /* Cannot happen */ --- 1581,1585 ---- 0, "list (immutable, during sort)", ! sizeof(PyListObject) + PyGC_HEAD_SIZE, 0, 0, /*tp_dealloc*/ /* Cannot happen */ Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.74 retrieving revision 2.75 diff -C2 -r2.74 -r2.75 *** object.c 2000/06/29 19:17:04 2.74 --- object.c 2000/06/30 05:02:53 2.75 *************** *** 125,128 **** --- 125,132 ---- return op; } + #ifdef WITH_CYCLE_GC + if (PyType_IS_GC(tp)) + op = (PyObject *) PyObject_FROM_GC(op); + #endif /* Any changes should be reflected in PyObject_INIT (objimpl.h) */ op->ob_type = tp; *************** *** 142,145 **** --- 146,153 ---- return op; } + #ifdef WITH_CYCLE_GC + if (PyType_IS_GC(tp)) + op = (PyVarObject *) PyObject_FROM_GC(op); + #endif /* Any changes should be reflected in PyObject_INIT_VAR */ op->ob_size = size; *************** *** 157,160 **** --- 165,172 ---- if (op == NULL) return PyErr_NoMemory(); + #ifdef WITH_CYCLE_GC + if (PyType_IS_GC(tp)) + op = (PyObject *) PyObject_FROM_GC(op); + #endif return PyObject_INIT(op, tp); } *************** *** 169,172 **** --- 181,188 ---- if (op == NULL) return (PyVarObject *)PyErr_NoMemory(); + #ifdef WITH_CYCLE_GC + if (PyType_IS_GC(tp)) + op = (PyVarObject *) PyObject_FROM_GC(op); + #endif return PyObject_INIT_VAR(op, tp, size); } *************** *** 176,182 **** PyObject *op; { ! PyObject_FREE(op); } int PyObject_Print(op, fp, flags) --- 192,212 ---- PyObject *op; { ! #ifdef WITH_CYCLE_GC ! if (PyType_IS_GC(op->ob_type)) { ! PyGC_Head *g = PyObject_AS_GC(op); ! PyObject_FREE(g); ! } else ! #endif ! { ! PyObject_FREE(op); ! } } + #ifndef WITH_CYCLE_GC + /* extension modules might need these */ + void _PyGC_Insert(PyObject *op) { } + void _PyGC_Remove(PyObject *op) { } + #endif + int PyObject_Print(op, fp, flags) *************** *** 918,923 **** --- 948,955 ---- destructor dealloc = op->ob_type->tp_dealloc; _Py_ForgetReference(op); + #ifndef WITH_CYCLE_GC if (_PyTrash_delete_nesting < PyTrash_UNWIND_LEVEL-1) op->ob_type = NULL; + #endif (*dealloc)(op); } Index: tupleobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/tupleobject.c,v retrieving revision 2.38 retrieving revision 2.39 diff -C2 -r2.38 -r2.39 *** tupleobject.c 2000/06/23 19:37:02 2.38 --- tupleobject.c 2000/06/30 05:02:53 2.39 *************** *** 95,99 **** if (nbytes / sizeof(PyObject *) != (size_t)size || (nbytes += sizeof(PyTupleObject) - sizeof(PyObject *) ! + PyGC_INFO_SIZE) <= 0) { --- 95,99 ---- if (nbytes / sizeof(PyObject *) != (size_t)size || (nbytes += sizeof(PyTupleObject) - sizeof(PyObject *) ! + PyGC_HEAD_SIZE) <= 0) { *************** *** 104,108 **** if (op == NULL) return PyErr_NoMemory(); ! PyObject_INIT_VAR(op, &PyTuple_Type, size); } --- 104,108 ---- if (op == NULL) return PyErr_NoMemory(); ! op = (PyTupleObject *) PyObject_FROM_GC(op); PyObject_INIT_VAR(op, &PyTuple_Type, size); } *************** *** 116,119 **** --- 116,120 ---- } #endif + PyObject_GC_Init(op); return (PyObject *) op; } *************** *** 182,185 **** --- 183,187 ---- register int len = op->ob_size; Py_TRASHCAN_SAFE_BEGIN(op) + PyObject_GC_Fini(op); if (len > 0) { i = len; *************** *** 454,458 **** 0, "tuple", ! sizeof(PyTupleObject) - sizeof(PyObject *) + PyGC_INFO_SIZE, sizeof(PyObject *), (destructor)tupledealloc, /*tp_dealloc*/ --- 456,460 ---- 0, "tuple", ! sizeof(PyTupleObject) - sizeof(PyObject *) + PyGC_HEAD_SIZE, sizeof(PyObject *), (destructor)tupledealloc, /*tp_dealloc*/ *************** *** 558,567 **** #endif { sv = (PyTupleObject *) PyObject_REALLOC((char *)v, sizeof(PyTupleObject) ! + PyGC_INFO_SIZE + newsize * sizeof(PyObject *)); *pv = (PyObject *) sv; if (sv == NULL) { PyObject_DEL(v); PyErr_NoMemory(); --- 560,584 ---- #endif { + #ifdef WITH_CYCLE_GC + PyGC_Head *g = PyObject_AS_GC((PyObject *)v); + PyObject_GC_Fini((PyObject *)v); sv = (PyTupleObject *) + PyObject_REALLOC((char *)g, sizeof(PyTupleObject) + + PyGC_HEAD_SIZE + + newsize * sizeof(PyObject *)); + if (g == NULL) { + sv = NULL; + } else { + sv = (PyTupleObject *)PyObject_FROM_GC(g); + } + #else + sv = (PyTupleObject *) PyObject_REALLOC((char *)v, sizeof(PyTupleObject) ! + PyGC_HEAD_SIZE + newsize * sizeof(PyObject *)); + #endif *pv = (PyObject *) sv; if (sv == NULL) { + PyObject_GC_Init((PyObject *)v); PyObject_DEL(v); PyErr_NoMemory(); *************** *** 579,582 **** --- 596,600 ---- } } + PyObject_GC_Init(sv); sv->ob_size = newsize; return 0; From python-dev@python.org Fri Jun 30 07:05:50 2000 From: python-dev@python.org (Trent Mick) Date: Thu, 29 Jun 2000 23:05:50 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild python16.dsp,1.6,1.7 In-Reply-To: <200006300502.WAA03275@slayer.i.sourceforge.net> References: <200006300502.WAA03275@slayer.i.sourceforge.net> Message-ID: <20000629230550.A24811@activestate.com> On Thu, Jun 29, 2000 at 10:02:55PM -0700, Jeremy Hylton wrote: > Update of /cvsroot/python/python/dist/src/PCbuild > In directory slayer.i.sourceforge.net:/tmp/cvs-serv3220/PCbuild > > Modified Files: > python16.dsp > Log Message: > final patches from Neil Schemenauer for garbage collection > > > Index: python16.dsp > =================================================================== > RCS file: /cvsroot/python/python/dist/src/PCbuild/python16.dsp,v > retrieving revision 1.6 > retrieving revision 1.7 > diff -C2 -r1.6 -r1.7 > *** python16.dsp 2000/06/06 23:29:09 1.6 > --- python16.dsp 2000/06/30 05:02:53 1.7 > *************** > *** 660,663 **** > --- 660,677 ---- > # End Source File > # Begin Source File > + SOURCE=..\Modules\gcmodule.c > + > + !IF "$(CFG)" == "python16 - Win32 Release" > + > + !ELSEIF "$(CFG)" == "python16 - Win32 Debug" > + > + !ELSEIF "$(CFG)" == "python16 - Win32 Alpha Debug" > + > + !ELSEIF "$(CFG)" == "python16 - Win32 Alpha Release" > + > + !ENDIF > + > + # End Source File > + # Begin Source File > > SOURCE=..\Python\getargs.c > Pardon me if I am wrong (I have not actually checked the repository) but is this correct now that the version number is 2.0? Trent -- Trent Mick trentm@activestate.com From python-dev@python.org Fri Jun 30 07:08:38 2000 From: python-dev@python.org (Skip Montanaro) Date: Thu, 29 Jun 2000 23:08:38 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test README,NONE,1.1 Message-ID: <200006300608.XAA13124@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv13116 Added Files: README Log Message: Describe a bit about writing test cases for Python... --- NEW FILE --- Writing Python Test Cases ------------------------- Skip Montanaro If you add a new module to Python or modify the functionality of an existing module, it is your responsibility to write one or more test cases to test that new functionality. The mechanics of the test system are fairly straightforward. If you are writing test cases for module zyzzyx, you need to create a file in .../Lib/test named test_zyzzyx.py and an expected output file in .../Lib/test/output named test_zyzzyx ("..." represents the top-level directory in the Python source tree, the directory containing the configure script). Generate the initial version of the test output file by executing: cd .../Lib/test python regrtest.py -g test_zyzzyx.py Any time you modify test_zyzzyx.py you need to generate a new expected output file. Don't forget to desk check the generated output to make sure it's really what you expected to find! To run a single test after modifying a module, simply run regrtest.py without the -g flag: cd .../Lib/test python regrtest.py test_zyzzyx.py To run the entire test suite, make the "test" target at the top level: cd ... make test Test cases generate output based upon computed values and branches taken in the code. When executed, regrtest.py compares the actual output generated by executing the test case with the expected output and reports success or failure. It stands to reason that if the actual and expected outputs are to match, they must not contain any machine dependencies. This means your test cases should not print out absolute machine addresses or floating point numbers with large numbers of significant digits. Writing good test cases is a skilled task and is too complex to discuss in detail in this short document. Many books have been written on the subject. I'll show my age by suggesting that Glenford Myers' "The Art of Software Testing", published in 1979, is still the best introduction to the subject available. It is short (177 pages), easy to read, and discusses the major elements of software testing, though its publication predates the object-oriented software revolution, so doesn't cover that subject at all. Unfortunately, it is very expensive (about $100 new). If you can borrow it or find it used (around $20), I strongly urge you to pick up a copy. As an author of at least part of a module, you will be writing unit tests (isolated tests of functions and objects defined by the module) using white box techniques. (Unlike black box testing, where you only have the external interfaces to guide your test case writing, in white box testing you can see the code being tested and tailor your test cases to exercise it more completely). The most important goal when writing test cases is to break things. A test case that doesn't uncover a bug is less valuable than one that does. In designing test cases you should pay attention to the following: 1. Your test cases should exercise all the functions and objects defined in the module, not just the ones meant to be called by users of your module. This may require you to write test code that uses the module in ways you don't expect (explicitly calling internal functions, for example - see test_atexit.py). 2. You should consider any boundary values that may tickle exceptional conditions (e.g. if you were testing a division module you might well want to generate tests with numerators and denominators at the limits of floating point and integer numbers on the machine performing the tests as well as a denominator of zero). 3. You should exercise as many paths through the code as possible. This may not always be possible, but is a goal to strive for. In particular, when considering if statements (or their equivalent), you want to create test cases that exercise both the true and false branches. For while and for statements, you should create test cases that exercise the loop zero, one and multiple times. From python-dev@python.org Fri Jun 30 07:39:12 2000 From: python-dev@python.org (Tim Peters) Date: Fri, 30 Jun 2000 02:39:12 -0400 Subject: [Python-Dev] Re: [Python-checkins] CVS: python/dist/src/PCbuild python16.dsp,1.6,1.7 In-Reply-To: <20000629230550.A24811@activestate.com> Message-ID: [Trent Mick, on Guido's late-night (for him ) checkin of python16.dsp] > Pardon me if I am wrong (I have not actually checked the > repository) but is this correct now that the version number is 2.0? No, it is not, and the Windows build is slightly damaged now. I've already yelled at Guido about this, but I suspect he's asleep. I'm sure it will get sorted out in the morning. From python-dev@python.org Fri Jun 30 08:05:50 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 00:05:50 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre.py,1.14,1.15 Message-ID: <200006300705.AAA22019@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv21938/Lib Modified Files: sre.py Log Message: - fixed default value handling in group/groupdict - added test suite Index: sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** sre.py 2000/06/30 00:27:45 1.14 --- sre.py 2000/06/30 07:05:47 1.15 *************** *** 21,25 **** X = VERBOSE = sre_compile.SRE_FLAG_VERBOSE ! # sre extensions (may or may not be in 1.6 final) T = TEMPLATE = sre_compile.SRE_FLAG_TEMPLATE U = UNICODE = sre_compile.SRE_FLAG_UNICODE --- 21,25 ---- X = VERBOSE = sre_compile.SRE_FLAG_VERBOSE ! # sre extensions (may or may not be in 2.0 final) T = TEMPLATE = sre_compile.SRE_FLAG_TEMPLATE U = UNICODE = sre_compile.SRE_FLAG_UNICODE From python-dev@python.org Fri Jun 30 08:05:50 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 00:05:50 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.13,2.14 Message-ID: <200006300705.AAA22023@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv21938/Modules Modified Files: _sre.c Log Message: - fixed default value handling in group/groupdict - added test suite Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.13 retrieving revision 2.14 diff -C2 -r2.13 -r2.14 *** _sre.c 2000/06/30 00:27:46 2.13 --- _sre.c 2000/06/30 07:05:48 2.14 *************** *** 1567,1571 **** static PyObject* ! match_getslice_by_index(MatchObject* self, int index) { if (index < 0 || index >= self->groups) { --- 1567,1571 ---- static PyObject* ! match_getslice_by_index(MatchObject* self, int index, PyObject* def) { if (index < 0 || index >= self->groups) { *************** *** 1579,1585 **** if (self->string == Py_None || self->mark[index+index] < 0) { ! /* return None if the string or group is undefined */ ! Py_INCREF(Py_None); ! return Py_None; } --- 1579,1585 ---- if (self->string == Py_None || self->mark[index+index] < 0) { ! /* return default value if the string or group is undefined */ ! Py_INCREF(def); ! return def; } *************** *** 1606,1612 **** static PyObject* ! match_getslice(MatchObject* self, PyObject* index) { ! return match_getslice_by_index(self, match_getindex(self, index)); } --- 1606,1612 ---- static PyObject* ! match_getslice(MatchObject* self, PyObject* index, PyObject* def) { ! return match_getslice_by_index(self, match_getindex(self, index), def); } *************** *** 1621,1628 **** switch (size) { case 0: ! result = match_getslice(self, Py_False); break; case 1: ! result = match_getslice(self, PyTuple_GET_ITEM(args, 0)); break; default: --- 1621,1628 ---- switch (size) { case 0: ! result = match_getslice(self, Py_False, Py_None); break; case 1: ! result = match_getslice(self, PyTuple_GET_ITEM(args, 0), Py_None); break; default: *************** *** 1632,1636 **** return NULL; for (i = 0; i < size; i++) { ! PyObject* item = match_getslice(self, PyTuple_GET_ITEM(args, i)); if (!item) { Py_DECREF(result); --- 1632,1638 ---- return NULL; for (i = 0; i < size; i++) { ! PyObject* item = match_getslice( ! self, PyTuple_GET_ITEM(args, i), Py_None ! ); if (!item) { Py_DECREF(result); *************** *** 1650,1654 **** int index; ! /* FIXME: handle default value! */ result = PyTuple_New(self->groups-1); --- 1652,1658 ---- int index; ! PyObject* def = Py_None; ! if (!PyArg_ParseTuple(args, "|O", &def)) ! return NULL; result = PyTuple_New(self->groups-1); *************** *** 1658,1663 **** for (index = 1; index < self->groups; index++) { PyObject* item; ! /* FIXME: handle default! */ ! item = match_getslice_by_index(self, index); if (!item) { Py_DECREF(result); --- 1662,1666 ---- for (index = 1; index < self->groups; index++) { PyObject* item; ! item = match_getslice_by_index(self, index, def); if (!item) { Py_DECREF(result); *************** *** 1677,1691 **** int index; ! /* FIXME: handle default value! */ result = PyDict_New(); ! if (!result) ! return NULL; ! if (!self->pattern->groupindex) return result; keys = PyMapping_Keys(self->pattern->groupindex); ! if (!keys) return NULL; for (index = 0; index < PyList_GET_SIZE(keys); index++) { --- 1680,1696 ---- int index; ! PyObject* def = Py_None; ! if (!PyArg_ParseTuple(args, "|O", &def)) ! return NULL; result = PyDict_New(); ! if (!result || !self->pattern->groupindex) return result; keys = PyMapping_Keys(self->pattern->groupindex); ! if (!keys) { ! Py_DECREF(result); return NULL; + } for (index = 0; index < PyList_GET_SIZE(keys); index++) { *************** *** 1698,1702 **** return NULL; } ! item = match_getslice(self, key); if (!item) { Py_DECREF(key); --- 1703,1707 ---- return NULL; } ! item = match_getslice(self, key, def); if (!item) { Py_DECREF(key); From python-dev@python.org Fri Jun 30 08:08:22 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 00:08:22 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_sre,NONE,1.1 Message-ID: <200006300708.AAA22167@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv22149/Lib/test/output Added Files: test_sre Log Message: - fixed default value handling in group/groupdict - added test suite --- NEW FILE --- test_sre test_support -- test failed re module pickle test_support -- test failed re module cPickle === Syntax error: ('(?Pa)(?P=foo_123)', 'aa', 0, 'g1', 'a') === Failed incorrectly ('^(.+)?B', 'AB', 0, 'g1', 'A') === Failed incorrectly ('(a+)+\\1', 'aa', 0, 'found+"-"+g1', 'aa-a') === grouping error ('([^/]*/)*sub1/', 'd:msgs/tdir/sub1/trial/away.cpp', 0, 'found+"-"+g1', 'd:msgs/tdir/sub1/-tdir/') 'd:msgs/tdir/sub1/-trial/' should be 'd:msgs/tdir/sub1/-tdir/' === Syntax error: ('(?Paa)(?P=id)', 'aaaa', 0, 'found+"-"+id', 'aaaa-aa') === grouping error ('([abc])*bcd', 'abcd', 0, 'found+"-"+g1', 'abcd-a') 'abcd-c' should be 'abcd-a' === grouping error ('(?i)([abc])*bcd', 'ABCD', 0, 'found+"-"+g1', 'ABCD-A') 'ABCD-C' should be 'ABCD-A' === Syntax error: ('a(?!b).', 'abad', 0, 'found', 'ad') === Syntax error: ('a(?=d).', 'abad', 0, 'found', 'ad') === Syntax error: ('a(?=c|d).', 'abad', 0, 'found', 'ad') === Failed incorrectly ('^(.+)?B', 'AB', 0, 'g1', 'A') From python-dev@python.org Fri Jun 30 08:08:22 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 00:08:22 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_sre.py,NONE,1.1 Message-ID: <200006300708.AAA22164@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv22149/Lib/test Added Files: test_sre.py Log Message: - fixed default value handling in group/groupdict - added test suite --- NEW FILE --- # FIXME: this is basically test_re.py, with a few import sys sys.path=['.']+sys.path from test_support import verbose, TestFailed import sre import sys, os, string, traceback # Misc tests from Tim Peters' re.doc if verbose: print 'Running tests on sre.search and sre.match' try: assert sre.search('x*', 'axx').span(0) == (0, 0) assert sre.search('x*', 'axx').span() == (0, 0) assert sre.search('x+', 'axx').span(0) == (1, 3) assert sre.search('x+', 'axx').span() == (1, 3) assert sre.search('x', 'aaa') == None except: raise TestFailed, "sre.search" try: assert sre.match('a*', 'xxx').span(0) == (0, 0) assert sre.match('a*', 'xxx').span() == (0, 0) assert sre.match('x*', 'xxxa').span(0) == (0, 3) assert sre.match('x*', 'xxxa').span() == (0, 3) assert sre.match('a+', 'xxx') == None except: raise TestFailed, "sre.search" if verbose: print 'Running tests on sre.sub' try: assert sre.sub("(?i)b+", "x", "bbbb BBBB") == 'x x' def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) assert sre.sub(r'\d+', bump_num, '08.2 -2 23x99y') == '9.3 -3 24x100y' assert sre.sub(r'\d+', bump_num, '08.2 -2 23x99y', 3) == '9.3 -3 23x99y' assert sre.sub('.', lambda m: r"\n", 'x') == '\\n' assert sre.sub('.', r"\n", 'x') == '\n' s = r"\1\1" assert sre.sub('(.)', s, 'x') == 'xx' assert sre.sub('(.)', sre.escape(s), 'x') == s assert sre.sub('(.)', lambda m: s, 'x') == s assert sre.sub('(?Px)', '\g\g', 'xx') == 'xxxx' assert sre.sub('(?Px)', '\g\g<1>', 'xx') == 'xxxx' assert sre.sub('(?Px)', '\g\g', 'xx') == 'xxxx' assert sre.sub('(?Px)', '\g<1>\g<1>', 'xx') == 'xxxx' assert sre.sub('a', r'\t\n\v\r\f\a\b\B\Z\a\A\w\W\s\S\d\D', 'a') == '\t\n\v\r\f\a\b\\B\\Z\a\\A\\w\\W\\s\\S\\d\\D' assert sre.sub('a', '\t\n\v\r\f\a', 'a') == '\t\n\v\r\f\a' assert sre.sub('a', '\t\n\v\r\f\a', 'a') == (chr(9)+chr(10)+chr(11)+chr(13)+chr(12)+chr(7)) assert sre.sub('^\s*', 'X', 'test') == 'Xtest' except AssertionError: raise TestFailed, "sre.sub" try: assert sre.sub('a', 'b', 'aaaaa') == 'bbbbb' assert sre.sub('a', 'b', 'aaaaa', 1) == 'baaaa' except AssertionError: raise TestFailed, "qualified sre.sub" if verbose: print 'Running tests on symbolic references' try: sre.sub('(?Px)', '\gx)', '\g<', 'xx') except sre.error, reason: pass else: raise TestFailed, "symbolic reference" try: sre.sub('(?Px)', '\g', 'xx') except sre.error, reason: pass else: raise TestFailed, "symbolic reference" try: sre.sub('(?Px)', '\g', 'xx') except sre.error, reason: pass else: raise TestFailed, "symbolic reference" try: sre.sub('(?Px)', '\g<1a1>', 'xx') except sre.error, reason: pass else: raise TestFailed, "symbolic reference" try: sre.sub('(?Px)', '\g', 'xx') except IndexError, reason: pass else: raise TestFailed, "symbolic reference" try: sre.sub('(?Px)|(?Py)', '\g', 'xx') except sre.error, reason: pass else: raise TestFailed, "symbolic reference" try: sre.sub('(?Px)|(?Py)', '\\2', 'xx') except sre.error, reason: pass else: raise TestFailed, "symbolic reference" if verbose: print 'Running tests on sre.subn' try: assert sre.subn("(?i)b+", "x", "bbbb BBBB") == ('x x', 2) assert sre.subn("b+", "x", "bbbb BBBB") == ('x BBBB', 1) assert sre.subn("b+", "x", "xyz") == ('xyz', 0) assert sre.subn("b*", "x", "xyz") == ('xxxyxzx', 4) assert sre.subn("b*", "x", "xyz", 2) == ('xxxyz', 2) except AssertionError: raise TestFailed, "sre.subn" if verbose: print 'Running tests on sre.split' try: assert sre.split(":", ":a:b::c") == ['', 'a', 'b', '', 'c'] assert sre.split(":*", ":a:b::c") == ['', 'a', 'b', 'c'] assert sre.split("(:*)", ":a:b::c") == ['', ':', 'a', ':', 'b', '::', 'c'] assert sre.split("(?::*)", ":a:b::c") == ['', 'a', 'b', 'c'] assert sre.split("(:)*", ":a:b::c") == ['', ':', 'a', ':', 'b', ':', 'c'] assert sre.split("([b:]+)", ":a:b::c") == ['', ':', 'a', ':b::', 'c'] # FIXME: group problem # assert sre.split("(b)|(:+)", ":a:b::c") == \ # ['', None, ':', 'a', None, ':', '', 'b', None, '', None, '::', 'c'] assert sre.split("(?:b)|(?::+)", ":a:b::c") == ['', 'a', '', '', 'c'] except AssertionError: raise TestFailed, "sre.split" try: assert sre.split(":", ":a:b::c", 2) == ['', 'a', 'b::c'] assert sre.split(':', 'a:b:c:d', 2) == ['a', 'b', 'c:d'] assert sre.split("(:)", ":a:b::c", 2) == ['', ':', 'a', ':', 'b::c'] assert sre.split("(:*)", ":a:b::c", 2) == ['', ':', 'a', ':', 'b::c'] except AssertionError: raise TestFailed, "qualified sre.split" if verbose: print "Running tests on sre.findall" try: assert sre.findall(":+", "abc") == [] assert sre.findall(":+", "a:b::c:::d") == [":", "::", ":::"] assert sre.findall("(:+)", "a:b::c:::d") == [":", "::", ":::"] assert sre.findall("(:)(:*)", "a:b::c:::d") == [(":", ""), (":", ":"), (":", "::")] except AssertionError: raise TestFailed, "sre.findall" if verbose: print "Running tests on sre.match" try: # No groups at all m = sre.match('a', 'a') ; assert m.groups() == () # A single group m = sre.match('(a)', 'a') ; assert m.groups() == ('a',) pat = sre.compile('((a)|(b))(c)?') assert pat.match('a').groups() == ('a', 'a', None, None) assert pat.match('b').groups() == ('b', None, 'b', None) assert pat.match('ac').groups() == ('a', 'a', None, 'c') assert pat.match('bc').groups() == ('b', None, 'b', 'c') assert pat.match('bc').groups("") == ('b', "", 'b', 'c') except AssertionError: raise TestFailed, "match .groups() method" try: # A single group m = sre.match('(a)', 'a') assert m.group(0) == 'a' ; assert m.group(0) == 'a' assert m.group(1) == 'a' ; assert m.group(1, 1) == ('a', 'a') pat = sre.compile('(?:(?Pa)|(?Pb))(?Pc)?') assert pat.match('a').group(1, 2, 3) == ('a', None, None) assert pat.match('b').group('a1', 'b2', 'c3') == (None, 'b', None) assert pat.match('ac').group(1, 'b2', 3) == ('a', None, 'c') except AssertionError: raise TestFailed, "match .group() method" if verbose: print "Running tests on sre.escape" try: p="" for i in range(0, 256): p = p + chr(i) assert sre.match(sre.escape(chr(i)), chr(i)) != None assert sre.match(sre.escape(chr(i)), chr(i)).span() == (0,1) pat=sre.compile( sre.escape(p) ) assert pat.match(p) != None assert pat.match(p).span() == (0,256) except AssertionError: raise TestFailed, "sre.escape" if verbose: print 'Pickling a SRE_Pattern instance' try: import pickle pat = sre.compile('a(?:b|(c|e){1,2}?|d)+?(.)') s = pickle.dumps(pat) pat = pickle.loads(s) except: print TestFailed, 're module pickle' # expected try: import cPickle pat = sre.compile('a(?:b|(c|e){1,2}?|d)+?(.)') s = cPickle.dumps(pat) pat = cPickle.loads(s) except: print TestFailed, 're module cPickle' # expected try: assert sre.I == sre.IGNORECASE assert sre.L == sre.LOCALE assert sre.M == sre.MULTILINE assert sre.S == sre.DOTALL assert sre.X == sre.VERBOSE assert sre.T == sre.TEMPLATE assert sre.U == sre.UNICODE except AssertionError: raise TestFailed, 're module constants' for flags in [sre.I, sre.M, sre.X, sre.S, sre.L, sre.T, sre.U]: try: r = sre.compile('^pattern$', flags) except: print 'Exception raised on flag', flags from re_tests import * if verbose: print 'Running re_tests test suite' else: # To save time, only run the first and last 10 tests #tests = tests[:10] + tests[-10:] pass for t in tests: sys.stdout.flush() pattern=s=outcome=repl=expected=None if len(t)==5: pattern, s, outcome, repl, expected = t elif len(t)==3: pattern, s, outcome = t else: raise ValueError, ('Test tuples should have 3 or 5 fields',t) try: obj=sre.compile(pattern) except sre.error: if outcome==SYNTAX_ERROR: pass # Expected a syntax error else: print '=== Syntax error:', t except KeyboardInterrupt: raise KeyboardInterrupt except: print '*** Unexpected error ***', t if verbose: traceback.print_exc(file=sys.stdout) else: try: result=obj.search(s) except (sre.error), msg: print '=== Unexpected exception', t, repr(msg) if outcome==SYNTAX_ERROR: # This should have been a syntax error; forget it. pass elif outcome==FAIL: if result is None: pass # No match, as expected else: print '=== Succeeded incorrectly', t elif outcome==SUCCEED: if result is not None: # Matched, as expected, so now we compute the # result string and compare it to our expected result. start, end = result.span(0) vardict={'found': result.group(0), 'groups': result.group(), 'flags': result.re.flags} for i in range(1, 100): try: gi = result.group(i) # Special hack because else the string concat fails: if gi is None: gi = "None" except IndexError: gi = "Error" vardict['g%d' % i] = gi for i in result.re.groupindex.keys(): try: gi = result.group(i) if gi is None: gi = "None" except IndexError: gi = "Error" vardict[i] = gi repl=eval(repl, vardict) if repl!=expected: print '=== grouping error', t, print repr(repl)+' should be '+repr(expected) else: print '=== Failed incorrectly', t continue # Try the match on a unicode string, and check that it # still succeeds. result=obj.search(unicode(s, "latin-1")) if result==None: print '=== Fails on unicode match', t # Try the match on a unicode pattern, and check that it # still succeeds. obj=sre.compile(unicode(pattern, "latin-1")) result=obj.search(s) if result==None: print '=== Fails on unicode pattern match', t # Try the match with the search area limited to the extent # of the match and see if it still succeeds. \B will # break (because it won't match at the end or start of a # string), so we'll ignore patterns that feature it. if pattern[:2]!='\\B' and pattern[-2:]!='\\B': obj=sre.compile(pattern) result=obj.search(s, result.start(0), result.end(0)+1) if result==None: print '=== Failed on range-limited match', t # Try the match with IGNORECASE enabled, and check that it # still succeeds. obj=sre.compile(pattern, sre.IGNORECASE) result=obj.search(s) if result==None: print '=== Fails on case-insensitive match', t # Try the match with LOCALE enabled, and check that it # still succeeds. obj=sre.compile(pattern, sre.LOCALE) result=obj.search(s) if result==None: print '=== Fails on locale-sensitive match', t # Try the match with UNICODE enabled, and check that it # still succeeds. obj=sre.compile(pattern, sre.UNICODE) result=obj.search(s) if result==None: print '=== Fails on unicode-sensitive match', t From python-dev@python.org Fri Jun 30 08:51:01 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 00:51:01 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_sre.py,1.1,1.2 Message-ID: <200006300751.AAA24038@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv24009/Lib/test Modified Files: test_sre.py Log Message: - pedantic: make sure "python -t" doesn't complain... Index: test_sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_sre.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** test_sre.py 2000/06/30 07:08:20 1.1 --- test_sre.py 2000/06/30 07:50:59 1.2 *************** *** 1,3 **** ! # FIXME: this is basically test_re.py, with a few import sys --- 1,3 ---- ! # FIXME: this is basically test_re.py, with a few minor changes import sys *************** *** 338,342 **** else: print '=== Failed incorrectly', t ! continue # Try the match on a unicode string, and check that it --- 338,342 ---- else: print '=== Failed incorrectly', t ! continue # Try the match on a unicode string, and check that it *************** *** 360,366 **** if pattern[:2]!='\\B' and pattern[-2:]!='\\B': obj=sre.compile(pattern) ! result=obj.search(s, result.start(0), result.end(0)+1) ! if result==None: ! print '=== Failed on range-limited match', t # Try the match with IGNORECASE enabled, and check that it --- 360,366 ---- if pattern[:2]!='\\B' and pattern[-2:]!='\\B': obj=sre.compile(pattern) ! result=obj.search(s, result.start(0), result.end(0)+1) ! if result==None: ! print '=== Failed on range-limited match', t # Try the match with IGNORECASE enabled, and check that it From python-dev@python.org Fri Jun 30 08:51:01 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 00:51:01 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre.py,1.15,1.16 sre_compile.py,1.13,1.14 sre_parse.py,1.12,1.13 Message-ID: <200006300751.AAA24039@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv24009/Lib Modified Files: sre.py sre_compile.py sre_parse.py Log Message: - pedantic: make sure "python -t" doesn't complain... Index: sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** sre.py 2000/06/30 07:05:47 1.15 --- sre.py 2000/06/30 07:50:59 1.16 *************** *** 99,103 **** filter = template else: ! template = sre_parse.parse_template(template, pattern) def filter(match, template=template): return sre_parse.expand_template(template, match) --- 99,103 ---- filter = template else: ! template = sre_parse.parse_template(template, pattern) def filter(match, template=template): return sre_parse.expand_template(template, match) *************** *** 110,118 **** if not m: break ! b, e = m.span() if i < b: append(string[i:b]) append(filter(m)) ! i = e n = n + 1 append(string[i:]) --- 110,118 ---- if not m: break ! b, e = m.span() if i < b: append(string[i:b]) append(filter(m)) ! i = e n = n + 1 append(string[i:]) *************** *** 131,143 **** if not m: break ! b, e = m.span() ! if b == e: ! if i >= len(string): ! break ! continue append(string[i:b]) ! if g and b != e: ! extend(m.groups()) ! i = e n = n + 1 append(string[i:]) --- 131,143 ---- if not m: break ! b, e = m.span() ! if b == e: ! if i >= len(string): ! break ! continue append(string[i:b]) ! if g and b != e: ! extend(m.groups()) ! i = e n = n + 1 append(string[i:]) Index: sre_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** sre_compile.py 2000/06/30 00:27:45 1.13 --- sre_compile.py 2000/06/30 07:50:59 1.14 *************** *** 19,23 **** for WORDSIZE in "BHil": if len(array.array(WORDSIZE, [0]).tostring()) == _sre.getcodesize(): ! break else: raise RuntimeError, "cannot find a useable array type" --- 19,23 ---- for WORDSIZE in "BHil": if len(array.array(WORDSIZE, [0]).tostring()) == _sre.getcodesize(): ! break else: raise RuntimeError, "cannot find a useable array type" *************** *** 27,156 **** emit = code.append for op, av in pattern: ! if op is ANY: ! if flags & SRE_FLAG_DOTALL: ! emit(OPCODES[op]) ! else: ! emit(OPCODES[CATEGORY]) ! emit(CHCODES[CATEGORY_NOT_LINEBREAK]) ! elif op in (SUCCESS, FAILURE): ! emit(OPCODES[op]) ! elif op is AT: ! emit(OPCODES[op]) ! if flags & SRE_FLAG_MULTILINE: ! emit(ATCODES[AT_MULTILINE[av]]) ! else: ! emit(ATCODES[av]) ! elif op is BRANCH: ! emit(OPCODES[op]) ! tail = [] ! for av in av[1]: ! skip = len(code); emit(0) ! _compile(code, av, flags) ! emit(OPCODES[JUMP]) ! tail.append(len(code)); emit(0) ! code[skip] = len(code) - skip ! emit(0) # end of branch ! for tail in tail: ! code[tail] = len(code) - tail ! elif op is CALL: ! emit(OPCODES[op]) ! skip = len(code); emit(0) ! _compile(code, av, flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! elif op is CATEGORY: ! emit(OPCODES[op]) ! if flags & SRE_FLAG_LOCALE: ! emit(CHCODES[CH_LOCALE[av]]) ! elif flags & SRE_FLAG_UNICODE: ! emit(CHCODES[CH_UNICODE[av]]) ! else: ! emit(CHCODES[av]) ! elif op is GROUP: ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) ! else: ! emit(OPCODES[op]) ! emit(av-1) ! elif op is IN: ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) ! def fixup(literal, flags=flags): ! return _sre.getlower(ord(literal), flags) ! else: ! emit(OPCODES[op]) ! fixup = ord ! skip = len(code); emit(0) ! for op, av in av: ! emit(OPCODES[op]) ! if op is NEGATE: ! pass ! elif op is LITERAL: ! emit(fixup(av)) ! elif op is RANGE: ! emit(fixup(av[0])) ! emit(fixup(av[1])) ! elif op is CATEGORY: ! if flags & SRE_FLAG_LOCALE: ! emit(CHCODES[CH_LOCALE[av]]) ! elif flags & SRE_FLAG_UNICODE: ! emit(CHCODES[CH_UNICODE[av]]) ! else: ! emit(CHCODES[av]) ! else: ! raise error, "internal: unsupported set operator" ! emit(OPCODES[FAILURE]) ! code[skip] = len(code) - skip ! elif op in (LITERAL, NOT_LITERAL): ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) ! else: ! emit(OPCODES[op]) ! emit(ord(av)) ! elif op is MARK: ! emit(OPCODES[op]) ! emit(av) ! elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): ! if flags & SRE_FLAG_TEMPLATE: ! emit(OPCODES[REPEAT]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) ! _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! else: ! lo, hi = av[2].getwidth() ! if lo == 0: ! raise error, "nothing to repeat" ! if 0 and lo == hi == 1 and op is MAX_REPEAT: ! # FIXME: need a better way to figure out when ! # it's safe to use this one (in the parser, probably) ! emit(OPCODES[MAX_REPEAT_ONE]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) ! _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! else: ! emit(OPCODES[op]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) ! _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! elif op is SUBPATTERN: ! group = av[0] ! if group: ! emit(OPCODES[MARK]) ! emit((group-1)*2) ! _compile(code, av[1], flags) ! if group: ! emit(OPCODES[MARK]) ! emit((group-1)*2+1) ! else: ! raise ValueError, ("unsupported operand type", op) def _compile_info(code, pattern, flags): --- 27,156 ---- emit = code.append for op, av in pattern: ! if op is ANY: ! if flags & SRE_FLAG_DOTALL: ! emit(OPCODES[op]) ! else: ! emit(OPCODES[CATEGORY]) ! emit(CHCODES[CATEGORY_NOT_LINEBREAK]) ! elif op in (SUCCESS, FAILURE): ! emit(OPCODES[op]) ! elif op is AT: ! emit(OPCODES[op]) ! if flags & SRE_FLAG_MULTILINE: ! emit(ATCODES[AT_MULTILINE[av]]) ! else: ! emit(ATCODES[av]) ! elif op is BRANCH: ! emit(OPCODES[op]) ! tail = [] ! for av in av[1]: ! skip = len(code); emit(0) ! _compile(code, av, flags) ! emit(OPCODES[JUMP]) ! tail.append(len(code)); emit(0) ! code[skip] = len(code) - skip ! emit(0) # end of branch ! for tail in tail: ! code[tail] = len(code) - tail ! elif op is CALL: ! emit(OPCODES[op]) ! skip = len(code); emit(0) ! _compile(code, av, flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! elif op is CATEGORY: ! emit(OPCODES[op]) ! if flags & SRE_FLAG_LOCALE: ! emit(CHCODES[CH_LOCALE[av]]) ! elif flags & SRE_FLAG_UNICODE: ! emit(CHCODES[CH_UNICODE[av]]) ! else: ! emit(CHCODES[av]) ! elif op is GROUP: ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) ! else: ! emit(OPCODES[op]) ! emit(av-1) ! elif op is IN: ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) ! def fixup(literal, flags=flags): ! return _sre.getlower(ord(literal), flags) ! else: ! emit(OPCODES[op]) ! fixup = ord ! skip = len(code); emit(0) ! for op, av in av: ! emit(OPCODES[op]) ! if op is NEGATE: ! pass ! elif op is LITERAL: ! emit(fixup(av)) ! elif op is RANGE: ! emit(fixup(av[0])) ! emit(fixup(av[1])) ! elif op is CATEGORY: ! if flags & SRE_FLAG_LOCALE: ! emit(CHCODES[CH_LOCALE[av]]) ! elif flags & SRE_FLAG_UNICODE: ! emit(CHCODES[CH_UNICODE[av]]) ! else: ! emit(CHCODES[av]) ! else: ! raise error, "internal: unsupported set operator" ! emit(OPCODES[FAILURE]) ! code[skip] = len(code) - skip ! elif op in (LITERAL, NOT_LITERAL): ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) ! else: ! emit(OPCODES[op]) ! emit(ord(av)) ! elif op is MARK: ! emit(OPCODES[op]) ! emit(av) ! elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): ! if flags & SRE_FLAG_TEMPLATE: ! emit(OPCODES[REPEAT]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) ! _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! else: ! lo, hi = av[2].getwidth() ! if lo == 0: ! raise error, "nothing to repeat" ! if 0 and lo == hi == 1 and op is MAX_REPEAT: ! # FIXME: need a better way to figure out when ! # it's safe to use this one (in the parser, probably) ! emit(OPCODES[MAX_REPEAT_ONE]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) ! _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! else: ! emit(OPCODES[op]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) ! _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! elif op is SUBPATTERN: ! group = av[0] ! if group: ! emit(OPCODES[MARK]) ! emit((group-1)*2) ! _compile(code, av[1], flags) ! if group: ! emit(OPCODES[MARK]) ! emit((group-1)*2+1) ! else: ! raise ValueError, ("unsupported operand type", op) def _compile_info(code, pattern, flags): *************** *** 160,172 **** lo, hi = pattern.getwidth() if lo == 0: ! return # not worth it # look for a literal prefix prefix = [] if not (flags & SRE_FLAG_IGNORECASE): ! for op, av in pattern.data: ! if op is LITERAL: ! prefix.append(ord(av)) ! else: ! break # add an info block emit = code.append --- 160,172 ---- lo, hi = pattern.getwidth() if lo == 0: ! return # not worth it # look for a literal prefix prefix = [] if not (flags & SRE_FLAG_IGNORECASE): ! for op, av in pattern.data: ! if op is LITERAL: ! prefix.append(ord(av)) ! else: ! break # add an info block emit = code.append *************** *** 176,198 **** mask = 0 if len(prefix) == len(pattern.data): ! mask = 1 emit(mask) # pattern length emit(lo) if hi < 32768: ! emit(hi) else: ! emit(0) # add literal prefix emit(len(prefix)) if prefix: ! code.extend(prefix) ! # generate overlap table ! table = [-1] + ([0]*len(prefix)) ! for i in range(len(prefix)): ! table[i+1] = table[i]+1 ! while table[i+1] > 0 and prefix[i] != prefix[table[i+1]-1]: ! table[i+1] = table[table[i+1]-1]+1 ! code.extend(table[1:]) # don't store first entry code[skip] = len(code) - skip --- 176,198 ---- mask = 0 if len(prefix) == len(pattern.data): ! mask = 1 emit(mask) # pattern length emit(lo) if hi < 32768: ! emit(hi) else: ! emit(0) # add literal prefix emit(len(prefix)) if prefix: ! code.extend(prefix) ! # generate overlap table ! table = [-1] + ([0]*len(prefix)) ! for i in range(len(prefix)): ! table[i+1] = table[i]+1 ! while table[i+1] > 0 and prefix[i] != prefix[table[i+1]-1]: ! table[i+1] = table[table[i+1]-1]+1 ! code.extend(table[1:]) # don't store first entry code[skip] = len(code) - skip *************** *** 202,210 **** # compile, as necessary if type(p) in (type(""), type(u"")): ! import sre_parse ! pattern = p ! p = sre_parse.parse(p) else: ! pattern = None flags = p.pattern.flags | flags --- 202,210 ---- # compile, as necessary if type(p) in (type(""), type(u"")): ! import sre_parse ! pattern = p ! p = sre_parse.parse(p) else: ! pattern = None flags = p.pattern.flags | flags *************** *** 221,229 **** # FIXME: get rid of this limitation! assert p.pattern.groups <= 100,\ ! "sorry, but this version only supports 100 named groups" return _sre.compile( ! pattern, flags, ! array.array(WORDSIZE, code).tostring(), ! p.pattern.groups-1, p.pattern.groupdict ! ) --- 221,229 ---- # FIXME: get rid of this limitation! assert p.pattern.groups <= 100,\ ! "sorry, but this version only supports 100 named groups" return _sre.compile( ! pattern, flags, ! array.array(WORDSIZE, code).tostring(), ! p.pattern.groups-1, p.pattern.groupdict ! ) Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** sre_parse.py 2000/06/30 00:27:45 1.12 --- sre_parse.py 2000/06/30 07:50:59 1.13 *************** *** 68,171 **** class State: def __init__(self): ! self.flags = 0 ! self.groups = 1 ! self.groupdict = {} def getgroup(self, name=None): ! gid = self.groups ! self.groups = gid + 1 ! if name: ! self.groupdict[name] = gid [...982 lines suppressed...] for c, s in template: ! if c is LITERAL: ! a(s) ! elif c is MARK: ! s = match.group(s) ! if s is None: ! raise error, "empty group" ! a(s) return match.string[:0].join(p) --- 593,602 ---- a = p.append for c, s in template: ! if c is LITERAL: ! a(s) ! elif c is MARK: ! s = match.group(s) ! if s is None: ! raise error, "empty group" ! a(s) return match.string[:0].join(p) From python-dev@python.org Fri Jun 30 10:04:38 2000 From: python-dev@python.org (Tim Peters) Date: Fri, 30 Jun 2000 02:04:38 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild readme.txt,1.5,1.6 Message-ID: <200006300904.CAA04151@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv3903/python/dist/src/PCbuild Modified Files: readme.txt Log Message: Making a tiny change to figure out what I'm going to screw up by trying to use CVS under Windows at all ... Index: readme.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/readme.txt,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** readme.txt 2000/03/29 01:51:37 1.5 --- readme.txt 2000/06/30 09:04:35 1.6 *************** *** 3,7 **** This directory is used to build Python for Win32 platforms, ! e.g. Windows 95, 98 and NT. It requires Microsoft Visual C++ 5.x. (For other Windows platforms and compilers, see ../PC/readme.txt.) --- 3,8 ---- This directory is used to build Python for Win32 platforms, ! e.g. Windows 95, 98 and NT. It requires Microsoft Visual C++ 6.x ! or 5.x. (For other Windows platforms and compilers, see ../PC/readme.txt.) From python-dev@python.org Fri Jun 30 10:13:08 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 02:13:08 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_sre,1.1,1.2 Message-ID: <200006300913.CAA06558@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv5441/Lib/test/output Modified Files: test_sre Log Message: - added support for (?P=name) (closes #3 and #7 from the status report) Index: test_sre =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_sre,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** test_sre 2000/06/30 07:08:20 1.1 --- test_sre 2000/06/30 09:13:06 1.2 *************** *** 2,10 **** test_support -- test failed re module pickle test_support -- test failed re module cPickle - === Syntax error: ('(?Pa)(?P=foo_123)', 'aa', 0, 'g1', 'a') === Failed incorrectly ('^(.+)?B', 'AB', 0, 'g1', 'A') === Failed incorrectly ('(a+)+\\1', 'aa', 0, 'found+"-"+g1', 'aa-a') === grouping error ('([^/]*/)*sub1/', 'd:msgs/tdir/sub1/trial/away.cpp', 0, 'found+"-"+g1', 'd:msgs/tdir/sub1/-tdir/') 'd:msgs/tdir/sub1/-trial/' should be 'd:msgs/tdir/sub1/-tdir/' - === Syntax error: ('(?Paa)(?P=id)', 'aaaa', 0, 'found+"-"+id', 'aaaa-aa') === grouping error ('([abc])*bcd', 'abcd', 0, 'found+"-"+g1', 'abcd-a') 'abcd-c' should be 'abcd-a' === grouping error ('(?i)([abc])*bcd', 'ABCD', 0, 'found+"-"+g1', 'ABCD-A') 'ABCD-C' should be 'ABCD-A' --- 2,8 ---- From python-dev@python.org Fri Jun 30 10:13:08 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 02:13:08 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre_parse.py,1.13,1.14 Message-ID: <200006300913.CAA06559@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv5441/Lib Modified Files: sre_parse.py Log Message: - added support for (?P=name) (closes #3 and #7 from the status report) Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** sre_parse.py 2000/06/30 07:50:59 1.13 --- sre_parse.py 2000/06/30 09:13:05 1.14 *************** *** 190,196 **** # check if the escape string represents a valid group try: ! group = int(escape[1:]) ! if group and group < groups: ! return group except ValueError: pass --- 190,196 ---- # check if the escape string represents a valid group try: ! gid = int(escape[1:]) ! if gid and gid < groups: ! return gid except ValueError: pass *************** *** 443,447 **** elif source.match("="): # named backreference ! raise error, "not yet implemented" else: char = source.get() --- 443,460 ---- elif source.match("="): # named backreference ! name = "" ! while 1: ! char = source.get() ! if char is None: ! raise error, "unterminated name" ! if char == ")": ! break ! name = name + char ! if not isname(name): ! raise error, "illegal character in group name" ! gid = state.groupdict.get(name) ! if gid is None: ! raise error, "unknown group name" ! subpattern.append((GROUP, gid)) else: char = source.get() From python-dev@python.org Fri Jun 30 10:13:37 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Fri, 30 Jun 2000 02:13:37 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_unicode.py,1.15,1.16 Message-ID: <200006300913.CAA06700@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv6675/Lib/test Modified Files: test_unicode.py Log Message: Marc-Andre Lemburg : Moved tests of new Unicode Char Name support to a separate test. Index: test_unicode.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** test_unicode.py 2000/06/28 16:41:23 1.15 --- test_unicode.py 2000/06/30 09:13:35 1.16 *************** *** 410,485 **** print 'done.' - print 'Testing General Unicode Character Name, and case insensitivity...', - # General and case insensitivity test: - s = u"\N{LATIN CAPITAL LETTER T}" \ - u"\N{LATIN SMALL LETTER H}" \ - u"\N{LATIN SMALL LETTER E}" \ - u"\N{SPACE}" \ - u"\N{LATIN SMALL LETTER R}" \ - u"\N{LATIN CAPITAL LETTER E}" \ - u"\N{LATIN SMALL LETTER D}" \ - u"\N{SPACE}" \ - u"\N{LATIN SMALL LETTER f}" \ - u"\N{LATIN CAPITAL LeTtEr o}" \ - u"\N{LATIN SMaLl LETTER x}" \ - u"\N{SPACE}" \ - u"\N{LATIN SMALL LETTER A}" \ - u"\N{LATIN SMALL LETTER T}" \ - u"\N{LATIN SMALL LETTER E}" \ - u"\N{SPACE}" \ - u"\N{LATIN SMALL LETTER T}" \ - u"\N{LATIN SMALL LETTER H}" \ - u"\N{LATIN SMALL LETTER E}" \ - u"\N{SpAcE}" \ - u"\N{LATIN SMALL LETTER S}" \ - u"\N{LATIN SMALL LETTER H}" \ - u"\N{LATIN SMALL LETTER E}" \ - u"\N{LATIN SMALL LETTER E}" \ - u"\N{LATIN SMALL LETTER P}" \ - u"\N{FULL STOP}" - assert s == u"The rEd fOx ate the sheep.", s - print "done." - - # misc. symbol testing - print "Testing misc. symbols for unicode character name expansion....", - assert u"\N{PILCROW SIGN}" == u"\u00b6" - assert u"\N{REPLACEMENT CHARACTER}" == u"\uFFFD" - assert u"\N{HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK}" == u"\uFF9F" - assert u"\N{FULLWIDTH LATIN SMALL LETTER A}" == u"\uFF41" - print "done." - - - # strict error testing: - print "Testing unicode character name expansion strict error handling....", - k_cchMaxUnicodeName = 83 - - s = "\N{" + "1" * (k_cchMaxUnicodeName + 2) + "}" - try: - unicode(s, 'unicode-escape', 'strict') - except UnicodeError: - pass - else: - raise AssertionError, "failed to raise an exception when presented " \ - "with a UCN > k_cchMaxUnicodeName" - try: - unicode("\N{blah}", 'unicode-escape', 'strict') - except UnicodeError: - pass - else: - raise AssertionError, "failed to raise an exception when given a bogus character name" - - try: - unicode("\N{SPACE", 'unicode-escape', 'strict') - except UnicodeError: - pass - else: - raise AssertionError, "failed to raise an exception for a missing closing brace." - - try: - unicode("\NSPACE", 'unicode-escape', 'strict') - except UnicodeError: - pass - else: - raise AssertionError, "failed to raise an exception for a missing opening brace." - print "done." - --- 410,411 ---- From python-dev@python.org Fri Jun 30 10:14:15 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Fri, 30 Jun 2000 02:14:15 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_unicode,1.7,1.8 Message-ID: <200006300914.CAA06914@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv6902/Lib/test/output Modified Files: test_unicode Log Message: Marc-Andre Lemburg : Updated test output (the ucn tests are now in test_ucn). Index: test_unicode =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_unicode,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** test_unicode 2000/06/28 16:41:46 1.7 --- test_unicode 2000/06/30 09:14:13 1.8 *************** *** 6,10 **** Testing standard mapping codecs... 0-127... 128-255... done. Testing Unicode string concatenation... done. - Testing General Unicode Character Name, and case insensitivity... done. - Testing misc. symbols for unicode character name expansion.... done. - Testing unicode character name expansion strict error handling.... done. --- 6,7 ---- From python-dev@python.org Fri Jun 30 10:45:23 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Fri, 30 Jun 2000 02:45:23 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_ucn.py,NONE,1.1 Message-ID: <200006300945.CAA13805@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv13782/Lib/test Added Files: test_ucn.py Log Message: New test for the ucnhash module. --- NEW FILE --- """ Test script for the Unicode implementation. Written by Bill Tutt. (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. """#" print 'Testing General Unicode Character Name, and case insensitivity...', # General and case insensitivity test: s = u"\N{LATIN CAPITAL LETTER T}" \ u"\N{LATIN SMALL LETTER H}" \ u"\N{LATIN SMALL LETTER E}" \ u"\N{SPACE}" \ u"\N{LATIN SMALL LETTER R}" \ u"\N{LATIN CAPITAL LETTER E}" \ u"\N{LATIN SMALL LETTER D}" \ u"\N{SPACE}" \ u"\N{LATIN SMALL LETTER f}" \ u"\N{LATIN CAPITAL LeTtEr o}" \ u"\N{LATIN SMaLl LETTER x}" \ u"\N{SPACE}" \ u"\N{LATIN SMALL LETTER A}" \ u"\N{LATIN SMALL LETTER T}" \ u"\N{LATIN SMALL LETTER E}" \ u"\N{SPACE}" \ u"\N{LATIN SMALL LETTER T}" \ u"\N{LATIN SMALL LETTER H}" \ u"\N{LATIN SMALL LETTER E}" \ u"\N{SpAcE}" \ u"\N{LATIN SMALL LETTER S}" \ u"\N{LATIN SMALL LETTER H}" \ u"\N{LATIN SMALL LETTER E}" \ u"\N{LATIN SMALL LETTER E}" \ u"\N{LATIN SMALL LETTER P}" \ u"\N{FULL STOP}" assert s == u"The rEd fOx ate the sheep.", s print "done." # misc. symbol testing print "Testing misc. symbols for unicode character name expansion....", assert u"\N{PILCROW SIGN}" == u"\u00b6" assert u"\N{REPLACEMENT CHARACTER}" == u"\uFFFD" assert u"\N{HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK}" == u"\uFF9F" assert u"\N{FULLWIDTH LATIN SMALL LETTER A}" == u"\uFF41" print "done." # strict error testing: print "Testing unicode character name expansion strict error handling....", k_cchMaxUnicodeName = 83 s = "\N{" + "1" * (k_cchMaxUnicodeName + 2) + "}" try: unicode(s, 'unicode-escape', 'strict') except UnicodeError: pass else: raise AssertionError, "failed to raise an exception when presented " \ "with a UCN > k_cchMaxUnicodeName" try: unicode("\N{blah}", 'unicode-escape', 'strict') except UnicodeError: pass else: raise AssertionError, "failed to raise an exception when given a bogus character name" try: unicode("\N{SPACE", 'unicode-escape', 'strict') except UnicodeError: pass else: raise AssertionError, "failed to raise an exception for a missing closing brace." try: unicode("\NSPACE", 'unicode-escape', 'strict') except UnicodeError: pass else: raise AssertionError, "failed to raise an exception for a missing opening brace." print "done." From python-dev@python.org Fri Jun 30 10:53:25 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Fri, 30 Jun 2000 02:53:25 -0700 Subject: [Python-checkins] CVS: python/dist/src/Tools/perfecthash GenUCNHash.py,1.1,1.2 Message-ID: <200006300953.CAA14782@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Tools/perfecthash In directory slayer.i.sourceforge.net:/tmp/cvs-serv14766/Tools/perfecthash Modified Files: GenUCNHash.py Log Message: Marc-Andre Lemburg : Include <> -> "". Patch by Bill Tutt. Index: GenUCNHash.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/perfecthash/GenUCNHash.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** GenUCNHash.py 2000/06/28 16:49:29 1.1 --- GenUCNHash.py 2000/06/30 09:53:22 1.2 *************** *** 51,55 **** out.write(header) out = open(cFileName, "w") ! out.write("#include <%s>\n" % headerFileName) out.write(code) perfHash.generate_graph(out) --- 51,55 ---- out.write(header) out = open(cFileName, "w") ! out.write("#include "%s"\n" % headerFileName) out.write(code) perfHash.generate_graph(out) From python-dev@python.org Fri Jun 30 10:56:02 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Fri, 30 Jun 2000 02:56:02 -0700 Subject: [Python-checkins] CVS: python/dist/src/Tools/perfecthash perfect_hash.py,1.1,1.2 Message-ID: <200006300956.CAA15161@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Tools/perfecthash In directory slayer.i.sourceforge.net:/tmp/cvs-serv15153/Tools/perfecthash Modified Files: perfect_hash.py Log Message: Marc-Andre Lemburg : Include <> -> "". Removed some left over code at the end of the file. Patch by Bill Tutt. Index: perfect_hash.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/perfecthash/perfect_hash.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** perfect_hash.py 2000/06/28 16:53:16 1.1 --- perfect_hash.py 2000/06/30 09:56:00 1.2 *************** *** 292,296 **** def generate_header(self, structName): header = """ ! #include #include --- 292,296 ---- def generate_header(self, structName): header = """ ! #include "Python.h" #include *************** *** 604,664 **** return PerfectHash(cchMaxKey, f1, f2, G, N, len(keys), maxHashValue) - - """ - static - PyObject *codec_tuple(PyObject *unicode, - int len) - { - PyObject *v,*w; - - if (unicode == NULL) - return NULL; - v = PyTuple_New(2); - if (v == NULL) { - Py_DECREF(unicode); - return NULL; - } - PyTuple_SET_ITEM(v,0,unicode); - w = PyInt_FromLong(len); - if (w == NULL) { - Py_DECREF(v); - return NULL; - } - PyTuple_SET_ITEM(v,1,w); - return v; - } - - static PyObject * - ucn_decode(PyObject *self, - PyObject *args) - { - const char *data; - int size; - const char *errors = NULL; - PyObject *mapping = NULL; - - if (!PyArg_ParseTuple(args, "t#|z:ucn_decode", - &data, &size, &errors)) - return NULL; - if (mapping == Py_None) - mapping = NULL; - - return codec_tuple(PyUnicode_DecodeNamedUnicodeEscape(data, size, errors), - size); - } - - - static PyMethodDef _codecs_functions[] = { - { "ucn_decode", ucn_decode, 1 }, - }; - - DL_EXPORT(void) - init_ucn() - { - Py_InitModule("_ucn", _codecs_functions); - } - - """ - - - --- 604,605 ---- From python-dev@python.org Fri Jun 30 11:04:00 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 12:04:00 +0200 Subject: [Python-checkins] CVS: python/dist/src/Tools/perfecthash GenUCNHash.py,1.1,1.2 References: <200006300953.CAA14782@slayer.i.sourceforge.net> Message-ID: <00b001bfe27a$845f7880$f2a6b5d4@hagrid> MAL wrote: > out.write(header) > out =3D open(cFileName, "w") > ! out.write("#include "%s"\n" % headerFileName) > out.write(code) > perfHash.generate_graph(out) umm. I suppose you meant: > ! out.write('#include "%s"\n' % headerFileName) or possibly: > ! out.write("#include \"%s\"\n" % headerFileName) From python-dev@python.org Fri Jun 30 11:15:23 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Fri, 30 Jun 2000 12:15:23 +0200 Subject: [Python-Dev] Re: [Python-checkins] CVS: python/dist/src/Tools/perfecthash GenUCNHash.py,1.1,1.2 References: <200006300953.CAA14782@slayer.i.sourceforge.net> <00b001bfe27a$845f7880$f2a6b5d4@hagrid> Message-ID: <395C733B.4E2AFFA3@lemburg.com> Fredrik Lundh wrote: > > MAL wrote: > > out.write(header) > > out = open(cFileName, "w") > > ! out.write("#include "%s"\n" % headerFileName) > > out.write(code) > > perfHash.generate_graph(out) > > umm. I suppose you meant: > > > ! out.write('#include "%s"\n' % headerFileName) > > or possibly: > > > ! out.write("#include \"%s\"\n" % headerFileName) Oops, you're right. Thanks. -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From python-dev@python.org Fri Jun 30 11:26:33 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Fri, 30 Jun 2000 03:26:33 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_format.py,NONE,1.1 Message-ID: <200006301026.DAA24915@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv24905/Lib/test Added Files: test_format.py Log Message: Marc-Andre Lemburg : New test for huge formatting strings (these could cause core dumps in previous versions). By Trent Mick. --- NEW FILE --- from test_support import verbose import string, sys # test string formatting operator (I am not sure if this is being tested # elsewhere but, surely, some of the given cases are *not* tested because # they crash python) # test on unicode strings as well def testformat(formatstr, args, output=None): if verbose: if output: print "%s %% %s =? %s ..." %\ (repr(formatstr), repr(args), repr(output)), else: print "%s %% %s works? ..." % (repr(formatstr), repr(args)), try: result = formatstr % args except OverflowError: if verbose: print 'overflow (this is fine)' else: if output and result != output: if verbose: print 'no' print "%s %% %s == %s != %s" %\ (repr(formatstr), repr(args), repr(result), repr(output)) else: if verbose: print 'yes' def testboth(formatstr, *args): testformat(formatstr, *args) testformat(unicode(formatstr), *args) testboth("%.1d", (1,), "1") testboth("%.*d", (sys.maxint,1)) # expect overflow testboth("%.100d", (1,), '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001') testboth("%#.117x", (1,), '0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001') testboth("%#.118x", (1,), '0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001') testboth("%f", (1.0,), "1.000000") # these are trying to test the limits of the internal magic-number-length # formatting buffer, if that number changes then these tests are less # effective testboth("%#.*g", (109, -1.e+49/3.)) testboth("%#.*g", (110, -1.e+49/3.)) testboth("%#.*g", (110, -1.e+100/3.)) # test some ridiculously large precision, expect overflow testboth('%12.*f', (123456, 1.0)) From python-dev@python.org Fri Jun 30 11:28:35 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Fri, 30 Jun 2000 03:28:35 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_format,NONE,1.1 Message-ID: <200006301028.DAA25304@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv25295/Lib/test/output Added Files: test_format Log Message: Marc-Andre Lemburg : Added test output. --- NEW FILE --- test_format From python-dev@python.org Fri Jun 30 11:29:19 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Fri, 30 Jun 2000 03:29:19 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects stringobject.c,2.69,2.70 Message-ID: <200006301029.DAA25334@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv25322/Objects Modified Files: stringobject.c Log Message: Marc-Andre Lemburg : New buffer overflow checks for formatting strings. By Trent Mick. Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.69 retrieving revision 2.70 diff -C2 -r2.69 -r2.70 *** stringobject.c 2000/06/20 15:47:54 2.69 --- stringobject.c 2000/06/30 10:29:17 2.70 *************** *** 125,130 **** const char *str; { ! register unsigned int size = strlen(str); register PyStringObject *op; #ifndef DONT_SHARE_SHORT_STRINGS if (size == 0 && (op = nullstring) != NULL) { --- 125,135 ---- const char *str; { ! register size_t size = strlen(str); register PyStringObject *op; + if (size > INT_MAX) { + PyErr_SetString(PyExc_OverflowError, + "string is too long for a Python string"); + return NULL; + } #ifndef DONT_SHARE_SHORT_STRINGS if (size == 0 && (op = nullstring) != NULL) { *************** *** 238,244 **** register PyStringObject *op; { ! /* XXX overflow? */ ! int newsize = 2 + 4 * op->ob_size * sizeof(char); ! PyObject *v = PyString_FromStringAndSize((char *)NULL, newsize); if (v == NULL) { return NULL; --- 243,253 ---- register PyStringObject *op; { ! size_t newsize = 2 + 4 * op->ob_size * sizeof(char); ! PyObject *v; ! if (newsize > INT_MAX) { ! PyErr_SetString(PyExc_OverflowError, ! "string is too large to make repr"); ! } ! v = PyString_FromStringAndSize((char *)NULL, newsize); if (v == NULL) { return NULL; *************** *** 2336,2341 **** static int ! formatfloat(buf, flags, prec, type, v) char *buf; int flags; int prec; --- 2345,2351 ---- static int ! formatfloat(buf, buflen, flags, prec, type, v) char *buf; + size_t buflen; int flags; int prec; *************** *** 2343,2346 **** --- 2353,2358 ---- PyObject *v; { + /* fmt = '%#.' + `prec` + `type` + worst case length = 3 + 10 (len of INT_MAX) + 1 = 14 (use 20)*/ char fmt[20]; double x; *************** *** 2349,2357 **** if (prec < 0) prec = 6; - if (prec > 50) - prec = 50; /* Arbitrary limitation */ if (type == 'f' && fabs(x)/1e25 >= 1e25) type = 'g'; sprintf(fmt, "%%%s.%d%c", (flags&F_ALT) ? "#" : "", prec, type); sprintf(buf, fmt, x); return strlen(buf); --- 2361,2379 ---- if (prec < 0) prec = 6; if (type == 'f' && fabs(x)/1e25 >= 1e25) type = 'g'; sprintf(fmt, "%%%s.%d%c", (flags&F_ALT) ? "#" : "", prec, type); + /* worst case length calc to ensure no buffer overrun: + fmt = %#.g + buf = '-' + [0-9]*prec + '.' + 'e+' + (longest exp + for any double rep.) + len = 1 + prec + 1 + 2 + 5 = 9 + prec + If prec=0 the effective precision is 1 (the leading digit is + always given), therefore increase by one to 10+prec. */ + if (buflen <= (size_t)10 + (size_t)prec) { + PyErr_SetString(PyExc_OverflowError, + "formatted float is too long (precision too long?)"); + return -1; + } sprintf(buf, fmt, x); return strlen(buf); *************** *** 2359,2364 **** static int ! formatint(buf, flags, prec, type, v) char *buf; int flags; int prec; --- 2381,2387 ---- static int ! formatint(buf, buflen, flags, prec, type, v) char *buf; + size_t buflen; int flags; int prec; *************** *** 2366,2369 **** --- 2389,2394 ---- PyObject *v; { + /* fmt = '%#.' + `prec` + 'l' + `type` + worst case length = 3 + 10 (len of INT_MAX) + 1 + 1 = 15 (use 20)*/ char fmt[20]; long x; *************** *** 2373,2376 **** --- 2398,2408 ---- prec = 1; sprintf(fmt, "%%%s.%dl%c", (flags&F_ALT) ? "#" : "", prec, type); + /* buf = '+'/'-'/'0'/'0x' + '[0-9]'*max(prec,len(x in octal)) + worst case buf = '0x' + [0-9]*prec, where prec >= 11 */ + if (buflen <= 13 || buflen <= (size_t)2+(size_t)prec) { + PyErr_SetString(PyExc_OverflowError, + "formatted integer is too long (precision too long?)"); + return -1; + } sprintf(buf, fmt, x); return strlen(buf); *************** *** 2378,2385 **** static int ! formatchar(buf, v) char *buf; PyObject *v; { if (PyString_Check(v)) { if (!PyArg_Parse(v, "c;%c requires int or char", &buf[0])) --- 2410,2419 ---- static int ! formatchar(buf, buflen, v) char *buf; + size_t buflen; PyObject *v; { + /* presume that the buffer is at least 2 characters long */ if (PyString_Check(v)) { if (!PyArg_Parse(v, "c;%c requires int or char", &buf[0])) *************** *** 2395,2399 **** ! /* fmt%(v1,v2,...) is roughly equivalent to sprintf(fmt, v1, v2, ...) */ PyObject * --- 2429,2441 ---- ! /* fmt%(v1,v2,...) is roughly equivalent to sprintf(fmt, v1, v2, ...) ! ! FORMATBUFLEN is the length of the buffer in which the floats, ints, & ! chars are formatted. XXX This is a magic number. Each formatting ! routine does bounds checking to ensure no overflow, but a better ! solution may be to malloc a buffer of appropriate size for each ! format. For now, the current solution is sufficient. ! */ ! #define FORMATBUFLEN (size_t)120 PyObject * *************** *** 2452,2459 **** PyObject *v = NULL; PyObject *temp = NULL; ! char *buf; int sign; int len; ! char tmpbuf[120]; /* For format{float,int,char}() */ char *fmt_start = fmt; --- 2494,2501 ---- PyObject *v = NULL; PyObject *temp = NULL; ! char *pbuf; int sign; int len; ! char formatbuf[FORMATBUFLEN]; /* For format{float,int,char}() */ char *fmt_start = fmt; *************** *** 2603,2607 **** switch (c) { case '%': ! buf = "%"; len = 1; break; --- 2645,2649 ---- switch (c) { case '%': ! pbuf = "%"; len = 1; break; *************** *** 2623,2627 **** goto error; } ! buf = PyString_AsString(temp); len = PyString_Size(temp); if (prec >= 0 && len > prec) --- 2665,2669 ---- goto error; } ! pbuf = PyString_AsString(temp); len = PyString_Size(temp); if (prec >= 0 && len > prec) *************** *** 2636,2641 **** if (c == 'i') c = 'd'; ! buf = tmpbuf; ! len = formatint(buf, flags, prec, c, v); if (len < 0) goto error; --- 2678,2683 ---- if (c == 'i') c = 'd'; ! pbuf = formatbuf; ! len = formatint(pbuf, sizeof(formatbuf), flags, prec, c, v); if (len < 0) goto error; *************** *** 2645,2651 **** if ((flags&F_ALT) && (c == 'x' || c == 'X') && ! buf[0] == '0' && buf[1] == c) { ! *res++ = *buf++; ! *res++ = *buf++; rescnt -= 2; len -= 2; --- 2687,2693 ---- if ((flags&F_ALT) && (c == 'x' || c == 'X') && ! pbuf[0] == '0' && pbuf[1] == c) { ! *res++ = *pbuf++; ! *res++ = *pbuf++; rescnt -= 2; len -= 2; *************** *** 2661,2666 **** case 'g': case 'G': ! buf = tmpbuf; ! len = formatfloat(buf, flags, prec, c, v); if (len < 0) goto error; --- 2703,2708 ---- case 'g': case 'G': ! pbuf = formatbuf; ! len = formatfloat(pbuf, sizeof(formatbuf), flags, prec, c, v); if (len < 0) goto error; *************** *** 2670,2675 **** break; case 'c': ! buf = tmpbuf; ! len = formatchar(buf, v); if (len < 0) goto error; --- 2712,2717 ---- break; case 'c': ! pbuf = formatbuf; ! len = formatchar(pbuf, sizeof(formatbuf), v); if (len < 0) goto error; *************** *** 2682,2687 **** } if (sign) { ! if (*buf == '-' || *buf == '+') { ! sign = *buf++; len--; } --- 2724,2729 ---- } if (sign) { ! if (*pbuf == '-' || *pbuf == '+') { ! sign = *pbuf++; len--; } *************** *** 2719,2723 **** if (sign && fill == ' ') *res++ = sign; ! memcpy(res, buf, len); res += len; rescnt -= len; --- 2761,2765 ---- if (sign && fill == ' ') *res++ = sign; ! memcpy(res, pbuf, len); res += len; rescnt -= len; From python-dev@python.org Fri Jun 30 11:29:59 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Fri, 30 Jun 2000 03:29:59 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.31,2.32 Message-ID: <200006301029.DAA25494@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv25442/Objects Modified Files: unicodeobject.c Log Message: Marc-Andre Lemburg : New buffer overflow checks for formatting strings. By Trent Mick. Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.31 retrieving revision 2.32 diff -C2 -r2.31 -r2.32 *** unicodeobject.c 2000/06/29 00:06:39 2.31 --- unicodeobject.c 2000/06/30 10:29:57 2.32 *************** *** 67,71 **** #include "mymath.h" #include "unicodeobject.h" ! #include "ucnhash.h" #if defined(HAVE_LIMITS_H) --- 67,71 ---- #include "mymath.h" #include "unicodeobject.h" ! #include #if defined(HAVE_LIMITS_H) *************** *** 1245,1249 **** ucnFallthrough: /* fall through on purpose */ ! default: *p++ = '\\'; *p++ = (unsigned char)s[-1]; --- 1245,1249 ---- ucnFallthrough: /* fall through on purpose */ ! default: *p++ = '\\'; *p++ = (unsigned char)s[-1]; *************** *** 1252,1256 **** } if (_PyUnicode_Resize(v, (int)(p - buf))) ! goto onError; return (PyObject *)v; --- 1252,1256 ---- } if (_PyUnicode_Resize(v, (int)(p - buf))) ! goto onError; return (PyObject *)v; *************** *** 4374,4377 **** --- 4374,4378 ---- static int formatfloat(Py_UNICODE *buf, + size_t buflen, int flags, int prec, *************** *** 4379,4382 **** --- 4380,4385 ---- PyObject *v) { + /* fmt = '%#.' + `prec` + `type` + worst case length = 3 + 10 (len of INT_MAX) + 1 = 14 (use 20)*/ char fmt[20]; double x; *************** *** 4387,4395 **** if (prec < 0) prec = 6; - if (prec > 50) - prec = 50; /* Arbitrary limitation */ if (type == 'f' && (fabs(x) / 1e25) >= 1e25) type = 'g'; sprintf(fmt, "%%%s.%d%c", (flags & F_ALT) ? "#" : "", prec, type); return usprintf(buf, fmt, x); } --- 4390,4408 ---- if (prec < 0) prec = 6; if (type == 'f' && (fabs(x) / 1e25) >= 1e25) type = 'g'; sprintf(fmt, "%%%s.%d%c", (flags & F_ALT) ? "#" : "", prec, type); + /* worst case length calc to ensure no buffer overrun: + fmt = %#.g + buf = '-' + [0-9]*prec + '.' + 'e+' + (longest exp + for any double rep.) + len = 1 + prec + 1 + 2 + 5 = 9 + prec + If prec=0 the effective precision is 1 (the leading digit is + always given), therefore increase by one to 10+prec. */ + if (buflen <= (size_t)10 + (size_t)prec) { + PyErr_SetString(PyExc_OverflowError, + "formatted float is too long (precision too long?)"); + return -1; + } return usprintf(buf, fmt, x); } *************** *** 4397,4400 **** --- 4410,4414 ---- static int formatint(Py_UNICODE *buf, + size_t buflen, int flags, int prec, *************** *** 4402,4405 **** --- 4416,4421 ---- PyObject *v) { + /* fmt = '%#.' + `prec` + 'l' + `type` + worst case length = 3 + 10 (len of INT_MAX) + 1 + 1 = 15 (use 20)*/ char fmt[20]; long x; *************** *** 4410,4413 **** --- 4426,4436 ---- if (prec < 0) prec = 1; + /* buf = '+'/'-'/'0'/'0x' + '[0-9]'*max(prec,len(x in octal)) + worst case buf = '0x' + [0-9]*prec, where prec >= 11 */ + if (buflen <= 13 || buflen <= (size_t)2+(size_t)prec) { + PyErr_SetString(PyExc_OverflowError, + "formatted integer is too long (precision too long?)"); + return -1; + } sprintf(fmt, "%%%s.%dl%c", (flags & F_ALT) ? "#" : "", prec, type); return usprintf(buf, fmt, x); *************** *** 4416,4421 **** static int formatchar(Py_UNICODE *buf, ! PyObject *v) { if (PyUnicode_Check(v)) { if (PyUnicode_GET_SIZE(v) != 1) --- 4439,4446 ---- static int formatchar(Py_UNICODE *buf, ! size_t buflen, ! PyObject *v) { + /* presume that the buffer is at least 2 characters long */ if (PyUnicode_Check(v)) { if (PyUnicode_GET_SIZE(v) != 1) *************** *** 4447,4450 **** --- 4472,4485 ---- } + /* fmt%(v1,v2,...) is roughly equivalent to sprintf(fmt, v1, v2, ...) + + FORMATBUFLEN is the length of the buffer in which the floats, ints, & + chars are formatted. XXX This is a magic number. Each formatting + routine does bounds checking to ensure no overflow, but a better + solution may be to malloc a buffer of appropriate size for each + format. For now, the current solution is sufficient. + */ + #define FORMATBUFLEN (size_t)120 + PyObject *PyUnicode_Format(PyObject *format, PyObject *args) *************** *** 4506,4513 **** PyObject *v = NULL; PyObject *temp = NULL; ! Py_UNICODE *buf; Py_UNICODE sign; int len; ! Py_UNICODE tmpbuf[120]; /* For format{float,int,char}() */ fmt++; --- 4541,4548 ---- PyObject *v = NULL; PyObject *temp = NULL; ! Py_UNICODE *pbuf; Py_UNICODE sign; int len; ! Py_UNICODE formatbuf[FORMATBUFLEN]; /* For format{float,int,char}() */ fmt++; *************** *** 4659,4664 **** case '%': ! buf = tmpbuf; ! buf[0] = '%'; len = 1; break; --- 4694,4700 ---- case '%': ! pbuf = formatbuf; ! /* presume that buffer length is at least 1 */ ! pbuf[0] = '%'; len = 1; break; *************** *** 4696,4700 **** goto onError; } ! buf = PyUnicode_AS_UNICODE(temp); len = PyUnicode_GET_SIZE(temp); if (prec >= 0 && len > prec) --- 4732,4736 ---- goto onError; } ! pbuf = PyUnicode_AS_UNICODE(temp); len = PyUnicode_GET_SIZE(temp); if (prec >= 0 && len > prec) *************** *** 4710,4715 **** if (c == 'i') c = 'd'; ! buf = tmpbuf; ! len = formatint(buf, flags, prec, c, v); if (len < 0) goto onError; --- 4746,4752 ---- if (c == 'i') c = 'd'; ! pbuf = formatbuf; ! len = formatint(pbuf, sizeof(formatbuf)/sizeof(Py_UNICODE), ! flags, prec, c, v); if (len < 0) goto onError; *************** *** 4719,4725 **** if ((flags&F_ALT) && (c == 'x' || c == 'X') && ! buf[0] == '0' && buf[1] == c) { ! *res++ = *buf++; ! *res++ = *buf++; rescnt -= 2; len -= 2; --- 4756,4762 ---- if ((flags&F_ALT) && (c == 'x' || c == 'X') && ! pbuf[0] == '0' && pbuf[1] == c) { ! *res++ = *pbuf++; ! *res++ = *pbuf++; rescnt -= 2; len -= 2; *************** *** 4736,4741 **** case 'g': case 'G': ! buf = tmpbuf; ! len = formatfloat(buf, flags, prec, c, v); if (len < 0) goto onError; --- 4773,4779 ---- case 'g': case 'G': ! pbuf = formatbuf; ! len = formatfloat(pbuf, sizeof(formatbuf)/sizeof(Py_UNICODE), ! flags, prec, c, v); if (len < 0) goto onError; *************** *** 4746,4751 **** case 'c': ! buf = tmpbuf; ! len = formatchar(buf, v); if (len < 0) goto onError; --- 4784,4789 ---- case 'c': ! pbuf = formatbuf; ! len = formatchar(pbuf, sizeof(formatbuf)/sizeof(Py_UNICODE), v); if (len < 0) goto onError; *************** *** 4759,4764 **** } if (sign) { ! if (*buf == '-' || *buf == '+') { ! sign = *buf++; len--; } --- 4797,4802 ---- } if (sign) { ! if (*pbuf == '-' || *pbuf == '+') { ! sign = *pbuf++; len--; } *************** *** 4796,4800 **** if (sign && fill == ' ') *res++ = sign; ! memcpy(res, buf, len * sizeof(Py_UNICODE)); res += len; rescnt -= len; --- 4834,4838 ---- if (sign && fill == ' ') *res++ = sign; ! memcpy(res, pbuf, len * sizeof(Py_UNICODE)); res += len; rescnt -= len; From python-dev@python.org Fri Jun 30 11:30:37 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Fri, 30 Jun 2000 03:30:37 -0700 Subject: [Python-checkins] CVS: python/dist/src/Tools/perfecthash GenUCNHash.py,1.2,1.3 Message-ID: <200006301030.DAA25564@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Tools/perfecthash In directory slayer.i.sourceforge.net:/tmp/cvs-serv25556/Tools/perfecthash Modified Files: GenUCNHash.py Log Message: Marc-Andre Lemburg : Fixed a quote bug. Thanks to Fredrik Lundh. Index: GenUCNHash.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/perfecthash/GenUCNHash.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** GenUCNHash.py 2000/06/30 09:53:22 1.2 --- GenUCNHash.py 2000/06/30 10:30:35 1.3 *************** *** 51,55 **** out.write(header) out = open(cFileName, "w") ! out.write("#include "%s"\n" % headerFileName) out.write(code) perfHash.generate_graph(out) --- 51,55 ---- out.write(header) out = open(cFileName, "w") ! out.write("#include \"%s\"\n" % headerFileName) out.write(code) perfHash.generate_graph(out) From python-dev@python.org Fri Jun 30 11:41:33 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 03:41:33 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.14,2.15 sre_constants.h,2.4,2.5 Message-ID: <200006301041.DAA26823@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv26572/Modules Modified Files: _sre.c sre_constants.h Log Message: - fixed lookahead assertions (#10, #11, #12) - untabified sre_constants.py Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.14 retrieving revision 2.15 diff -C2 -r2.14 -r2.15 *** _sre.c 2000/06/30 07:05:48 2.14 --- _sre.c 2000/06/30 10:41:31 2.15 *************** *** 21,24 **** --- 21,25 ---- * 00-06-29 fl fixed split, added more scanner features (0.9.2) * 00-06-30 fl tuning, fast search (0.9.3) + * 00-06-30 fl added assert (lookahead) primitives (0.9.4) * * Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. *************** *** 31,35 **** #ifndef SRE_RECURSIVE ! char copyright[] = " SRE 0.9.3 Copyright (c) 1997-2000 by Secret Labs AB "; #include "Python.h" --- 32,36 ---- #ifndef SRE_RECURSIVE ! char copyright[] = " SRE 0.9.4 Copyright (c) 1997-2000 by Secret Labs AB "; #include "Python.h" *************** *** 577,585 **** break; ! #if 0 ! case SRE_OP_CALL: ! /* match subpattern, without backtracking */ /* args: */ ! TRACE(("%8d: subpattern\n", PTR(ptr))); state->ptr = ptr; i = SRE_MATCH(state, pattern + 1); --- 578,585 ---- break; ! case SRE_OP_ASSERT: ! /* assert subpattern */ /* args: */ ! TRACE(("%8d: assert subpattern\n", PTR(ptr))); state->ptr = ptr; i = SRE_MATCH(state, pattern + 1); *************** *** 589,595 **** goto failure; pattern += pattern[0]; - ptr = state->ptr; break; ! #endif #if 0 --- 589,606 ---- goto failure; pattern += pattern[0]; break; ! ! case SRE_OP_ASSERT_NOT: ! /* assert not subpattern */ ! /* args: */ ! TRACE(("%8d: assert not subpattern\n", PTR(ptr))); ! state->ptr = ptr; ! i = SRE_MATCH(state, pattern + 1); ! if (i < 0) ! return i; ! if (i) ! goto failure; ! pattern += pattern[0]; ! break; #if 0 Index: sre_constants.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/sre_constants.h,v retrieving revision 2.4 retrieving revision 2.5 diff -C2 -r2.4 -r2.5 *** sre_constants.h 2000/06/29 08:55:54 2.4 --- sre_constants.h 2000/06/30 10:41:31 2.5 *************** *** 1,28 **** ! /* generated from sre_constants.py */ #define SRE_OP_FAILURE 0 #define SRE_OP_SUCCESS 1 #define SRE_OP_ANY 2 #define SRE_OP_ASSERT 3 ! #define SRE_OP_AT 4 ! #define SRE_OP_BRANCH 5 ! #define SRE_OP_CALL 6 ! #define SRE_OP_CATEGORY 7 ! #define SRE_OP_GROUP 8 ! #define SRE_OP_GROUP_IGNORE 9 ! #define SRE_OP_IN 10 ! #define SRE_OP_IN_IGNORE 11 ! #define SRE_OP_INFO 12 ! #define SRE_OP_JUMP 13 ! #define SRE_OP_LITERAL 14 ! #define SRE_OP_LITERAL_IGNORE 15 ! #define SRE_OP_MARK 16 ! #define SRE_OP_MAX_REPEAT 17 ! #define SRE_OP_MAX_REPEAT_ONE 18 ! #define SRE_OP_MIN_REPEAT 19 ! #define SRE_OP_NOT_LITERAL 20 ! #define SRE_OP_NOT_LITERAL_IGNORE 21 ! #define SRE_OP_NEGATE 22 ! #define SRE_OP_RANGE 23 ! #define SRE_OP_REPEAT 24 #define SRE_AT_BEGINNING 0 #define SRE_AT_BEGINNING_LINE 1 --- 1,41 ---- ! /* ! * Secret Labs' Regular Expression Engine ! * ! * regular expression matching engine ! * ! * NOTE: This file is generated by sre_constants.py. If you need ! * to change anything in here, edit sre_constants.py and run it. ! * ! * Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. ! * ! * See the _sre.c file for information on usage and redistribution. ! */ ! #define SRE_OP_FAILURE 0 #define SRE_OP_SUCCESS 1 #define SRE_OP_ANY 2 #define SRE_OP_ASSERT 3 ! #define SRE_OP_ASSERT_NOT 4 ! #define SRE_OP_AT 5 ! #define SRE_OP_BRANCH 6 ! #define SRE_OP_CALL 7 ! #define SRE_OP_CATEGORY 8 ! #define SRE_OP_GROUP 9 ! #define SRE_OP_GROUP_IGNORE 10 ! #define SRE_OP_IN 11 ! #define SRE_OP_IN_IGNORE 12 ! #define SRE_OP_INFO 13 ! #define SRE_OP_JUMP 14 ! #define SRE_OP_LITERAL 15 ! #define SRE_OP_LITERAL_IGNORE 16 ! #define SRE_OP_MARK 17 ! #define SRE_OP_MAX_REPEAT 18 ! #define SRE_OP_MAX_REPEAT_ONE 19 ! #define SRE_OP_MIN_REPEAT 20 ! #define SRE_OP_NOT_LITERAL 21 ! #define SRE_OP_NOT_LITERAL_IGNORE 22 ! #define SRE_OP_NEGATE 23 ! #define SRE_OP_RANGE 24 ! #define SRE_OP_REPEAT 25 #define SRE_AT_BEGINNING 0 #define SRE_AT_BEGINNING_LINE 1 From python-dev@python.org Fri Jun 30 11:41:33 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 03:41:33 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_sre,1.2,1.3 Message-ID: <200006301041.DAA26826@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv26572/Lib/test/output Modified Files: test_sre Log Message: - fixed lookahead assertions (#10, #11, #12) - untabified sre_constants.py Index: test_sre =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_sre,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** test_sre 2000/06/30 09:13:06 1.2 --- test_sre 2000/06/30 10:41:31 1.3 *************** *** 7,12 **** === grouping error ('([abc])*bcd', 'abcd', 0, 'found+"-"+g1', 'abcd-a') 'abcd-c' should be 'abcd-a' === grouping error ('(?i)([abc])*bcd', 'ABCD', 0, 'found+"-"+g1', 'ABCD-A') 'ABCD-C' should be 'ABCD-A' - === Syntax error: ('a(?!b).', 'abad', 0, 'found', 'ad') - === Syntax error: ('a(?=d).', 'abad', 0, 'found', 'ad') - === Syntax error: ('a(?=c|d).', 'abad', 0, 'found', 'ad') === Failed incorrectly ('^(.+)?B', 'AB', 0, 'g1', 'A') --- 7,9 ---- From python-dev@python.org Fri Jun 30 11:41:33 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 03:41:33 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre_compile.py,1.14,1.15 sre_constants.py,1.11,1.12 sre_parse.py,1.14,1.15 Message-ID: <200006301041.DAA26820@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv26572/Lib Modified Files: sre_compile.py sre_constants.py sre_parse.py Log Message: - fixed lookahead assertions (#10, #11, #12) - untabified sre_constants.py Index: sre_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** sre_compile.py 2000/06/30 07:50:59 1.14 --- sre_compile.py 2000/06/30 10:41:30 1.15 *************** *** 27,76 **** emit = code.append for op, av in pattern: ! if op is ANY: ! if flags & SRE_FLAG_DOTALL: ! emit(OPCODES[op]) ! else: ! emit(OPCODES[CATEGORY]) ! emit(CHCODES[CATEGORY_NOT_LINEBREAK]) ! elif op in (SUCCESS, FAILURE): ! emit(OPCODES[op]) ! elif op is AT: ! emit(OPCODES[op]) ! if flags & SRE_FLAG_MULTILINE: ! emit(ATCODES[AT_MULTILINE[av]]) ! else: ! emit(ATCODES[av]) ! elif op is BRANCH: ! emit(OPCODES[op]) ! tail = [] ! for av in av[1]: ! skip = len(code); emit(0) ! _compile(code, av, flags) ! emit(OPCODES[JUMP]) ! tail.append(len(code)); emit(0) ! code[skip] = len(code) - skip ! emit(0) # end of branch ! for tail in tail: ! code[tail] = len(code) - tail ! elif op is CALL: ! emit(OPCODES[op]) ! skip = len(code); emit(0) ! _compile(code, av, flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! elif op is CATEGORY: ! emit(OPCODES[op]) ! if flags & SRE_FLAG_LOCALE: ! emit(CHCODES[CH_LOCALE[av]]) ! elif flags & SRE_FLAG_UNICODE: ! emit(CHCODES[CH_UNICODE[av]]) ! else: ! emit(CHCODES[av]) ! elif op is GROUP: if flags & SRE_FLAG_IGNORECASE: emit(OPCODES[OP_IGNORE[op]]) else: emit(OPCODES[op]) ! emit(av-1) elif op is IN: if flags & SRE_FLAG_IGNORECASE: --- 27,36 ---- emit = code.append for op, av in pattern: ! if op in (LITERAL, NOT_LITERAL): if flags & SRE_FLAG_IGNORECASE: emit(OPCODES[OP_IGNORE[op]]) else: emit(OPCODES[op]) ! emit(ord(av)) elif op is IN: if flags & SRE_FLAG_IGNORECASE: *************** *** 102,114 **** emit(OPCODES[FAILURE]) code[skip] = len(code) - skip ! elif op in (LITERAL, NOT_LITERAL): ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) ! else: emit(OPCODES[op]) ! emit(ord(av)) ! elif op is MARK: ! emit(OPCODES[op]) ! emit(av) elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): if flags & SRE_FLAG_TEMPLATE: --- 62,71 ---- emit(OPCODES[FAILURE]) code[skip] = len(code) - skip ! elif op is ANY: ! if flags & SRE_FLAG_DOTALL: emit(OPCODES[op]) ! else: ! emit(OPCODES[CATEGORY]) ! emit(CHCODES[CATEGORY_NOT_LINEBREAK]) elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): if flags & SRE_FLAG_TEMPLATE: *************** *** 151,154 **** --- 108,154 ---- emit(OPCODES[MARK]) emit((group-1)*2+1) + elif op in (SUCCESS, FAILURE): + emit(OPCODES[op]) + elif op in (ASSERT, ASSERT_NOT, CALL): + emit(OPCODES[op]) + skip = len(code); emit(0) + _compile(code, av, flags) + emit(OPCODES[SUCCESS]) + code[skip] = len(code) - skip + elif op is AT: + emit(OPCODES[op]) + if flags & SRE_FLAG_MULTILINE: + emit(ATCODES[AT_MULTILINE[av]]) + else: + emit(ATCODES[av]) + elif op is BRANCH: + emit(OPCODES[op]) + tail = [] + for av in av[1]: + skip = len(code); emit(0) + _compile(code, av, flags) + emit(OPCODES[JUMP]) + tail.append(len(code)); emit(0) + code[skip] = len(code) - skip + emit(0) # end of branch + for tail in tail: + code[tail] = len(code) - tail + elif op is CATEGORY: + emit(OPCODES[op]) + if flags & SRE_FLAG_LOCALE: + emit(CHCODES[CH_LOCALE[av]]) + elif flags & SRE_FLAG_UNICODE: + emit(CHCODES[CH_UNICODE[av]]) + else: + emit(CHCODES[av]) + elif op is GROUP: + if flags & SRE_FLAG_IGNORECASE: + emit(OPCODES[OP_IGNORE[op]]) + else: + emit(OPCODES[op]) + emit(av-1) + elif op is MARK: + emit(OPCODES[op]) + emit(av) else: raise ValueError, ("unsupported operand type", op) Index: sre_constants.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_constants.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** sre_constants.py 2000/06/29 18:03:25 1.11 --- sre_constants.py 2000/06/30 10:41:30 1.12 *************** *** 24,27 **** --- 24,28 ---- ANY = "any" ASSERT = "assert" + ASSERT_NOT = "assert_not" AT = "at" BRANCH = "branch" *************** *** 82,86 **** ANY, ! ASSERT, AT, BRANCH, --- 83,87 ---- ANY, ! ASSERT, ASSERT_NOT, AT, BRANCH, *************** *** 122,127 **** i = 0 for item in list: ! d[item] = i ! i = i + 1 return d --- 123,128 ---- i = 0 for item in list: ! d[item] = i ! i = i + 1 return d *************** *** 177,186 **** import string def dump(f, d, prefix): ! items = d.items() ! items.sort(lambda a, b: cmp(a[1], b[1])) ! for k, v in items: ! f.write("#define %s_%s %s\n" % (prefix, string.upper(k), v)) f = open("sre_constants.h", "w") ! f.write("/* generated from sre_constants.py */\n") dump(f, OPCODES, "SRE_OP") dump(f, ATCODES, "SRE") --- 178,202 ---- import string def dump(f, d, prefix): ! items = d.items() ! items.sort(lambda a, b: cmp(a[1], b[1])) ! for k, v in items: ! f.write("#define %s_%s %s\n" % (prefix, string.upper(k), v)) f = open("sre_constants.h", "w") ! f.write("""\ ! /* ! * Secret Labs' Regular Expression Engine ! * ! * regular expression matching engine ! * ! * NOTE: This file is generated by sre_constants.py. If you need ! * to change anything in here, edit sre_constants.py and run it. ! * ! * Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. ! * ! * See the _sre.c file for information on usage and redistribution. ! */ ! ! """) ! dump(f, OPCODES, "SRE_OP") dump(f, ATCODES, "SRE") Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** sre_parse.py 2000/06/30 09:13:05 1.14 --- sre_parse.py 2000/06/30 10:41:30 1.15 *************** *** 471,474 **** --- 471,493 ---- break source.get() + elif source.next in ("=", "!"): + # lookahead assertions + char = source.get() + b = [] + while 1: + p = _parse(source, state, flags) + if source.next == ")": + if b: + b.append(p) + p = _branch(state, b) + if char == "=": + subpattern.append((ASSERT, p)) + else: + subpattern.append((ASSERT_NOT, p)) + break + elif source.match("|"): + b.append(p) + else: + raise error, "pattern not properly closed" else: # flags From python-dev@python.org Fri Jun 30 14:00:35 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 06:00:35 -0700 Subject: [Python-checkins] CVS: python/dist/src/PC readme.txt,1.21,1.22 Message-ID: <200006301300.GAA25808@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv24416 Modified Files: readme.txt Log Message: Trivial commit to test Windows CVS capabilities. Index: readme.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/readme.txt,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -r1.21 -r1.22 *** readme.txt 1999/04/12 14:48:53 1.21 --- readme.txt 2000/06/30 13:00:32 1.22 *************** *** 1,4 **** ! Welcome to the "PC" subdirectory of the Python distribution! ! ************************************************************ *** Note: the project files for MS VC++ 5.0 and 6.0 are now in the --- 1,4 ---- ! Welcome to the "PC" subdirectory of the Python distribution ! *********************************************************** *** Note: the project files for MS VC++ 5.0 and 6.0 are now in the From python-dev@python.org Fri Jun 30 14:55:17 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 06:55:17 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_sre,1.3,1.4 Message-ID: <200006301355.GAA00997@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv350/Lib/test/output Modified Files: test_sre Log Message: the mad patcher strikes again: -- added pickling support (only works if sre is imported) -- fixed wordsize problems in engine (instead of casting literals down to the character size, cast characters up to the literal size (same as the code word size). this prevents false hits when you're matching a unicode pattern against an 8-bit string. (unfortunately, this broke another test, but I think the test should be changed in this case; more on that on python-dev) -- added sre.purge function (unofficial, clears the cache) Index: test_sre =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_sre,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** test_sre 2000/06/30 10:41:31 1.3 --- test_sre 2000/06/30 13:55:15 1.4 *************** *** 1,5 **** test_sre ! test_support -- test failed re module pickle ! test_support -- test failed re module cPickle === Failed incorrectly ('^(.+)?B', 'AB', 0, 'g1', 'A') === Failed incorrectly ('(a+)+\\1', 'aa', 0, 'found+"-"+g1', 'aa-a') --- 1,4 ---- test_sre ! === Failed incorrectly ('\\x00ffffffffffffff', '\377', 0, 'found', '\377') === Failed incorrectly ('^(.+)?B', 'AB', 0, 'g1', 'A') === Failed incorrectly ('(a+)+\\1', 'aa', 0, 'found+"-"+g1', 'aa-a') From python-dev@python.org Fri Jun 30 14:55:17 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 06:55:17 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.15,2.16 Message-ID: <200006301355.GAA00998@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv350/Modules Modified Files: _sre.c Log Message: the mad patcher strikes again: -- added pickling support (only works if sre is imported) -- fixed wordsize problems in engine (instead of casting literals down to the character size, cast characters up to the literal size (same as the code word size). this prevents false hits when you're matching a unicode pattern against an 8-bit string. (unfortunately, this broke another test, but I think the test should be changed in this case; more on that on python-dev) -- added sre.purge function (unofficial, clears the cache) Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.15 retrieving revision 2.16 diff -C2 -r2.15 -r2.16 *** _sre.c 2000/06/30 10:41:31 2.15 --- _sre.c 2000/06/30 13:55:15 2.16 *************** *** 21,25 **** * 00-06-29 fl fixed split, added more scanner features (0.9.2) * 00-06-30 fl tuning, fast search (0.9.3) ! * 00-06-30 fl added assert (lookahead) primitives (0.9.4) * * Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. --- 21,25 ---- * 00-06-29 fl fixed split, added more scanner features (0.9.2) * 00-06-30 fl tuning, fast search (0.9.3) ! * 00-06-30 fl added assert (lookahead) primitives, etc (0.9.4) * * Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. *************** *** 340,344 **** LOCAL(int) ! SRE_MEMBER(SRE_CODE* set, SRE_CHAR ch) { /* check if character is a member of the given set */ --- 340,344 ---- LOCAL(int) ! SRE_MEMBER(SRE_CODE* set, SRE_CODE ch) { /* check if character is a member of the given set */ *************** *** 357,361 **** case SRE_OP_LITERAL: ! if (ch == (SRE_CHAR) set[0]) return ok; set++; --- 357,361 ---- case SRE_OP_LITERAL: ! if (ch == set[0]) return ok; set++; *************** *** 363,367 **** case SRE_OP_RANGE: ! if ((SRE_CHAR) set[0] <= ch && ch <= (SRE_CHAR) set[1]) return ok; set += 2; --- 363,367 ---- case SRE_OP_RANGE: ! if (set[0] <= ch && ch <= set[1]) return ok; set += 2; *************** *** 456,461 **** /* match literal string */ /* args: */ ! TRACE(("%8d: literal %c\n", PTR(ptr), (SRE_CHAR) pattern[0])); ! if (ptr >= end || *ptr != (SRE_CHAR) pattern[0]) goto failure; pattern++; --- 456,461 ---- /* match literal string */ /* args: */ ! TRACE(("%8d: literal %c\n", PTR(ptr), pattern[0])); ! if (ptr >= end || (SRE_CODE) ptr[0] != pattern[0]) goto failure; pattern++; *************** *** 466,471 **** /* match anything that is not literal character */ /* args: */ ! TRACE(("%8d: literal not %c\n", PTR(ptr), (SRE_CHAR) pattern[0])); ! if (ptr >= end || *ptr == (SRE_CHAR) pattern[0]) goto failure; pattern++; --- 466,471 ---- /* match anything that is not literal character */ /* args: */ ! TRACE(("%8d: literal not %c\n", PTR(ptr), pattern[0])); ! if (ptr >= end || (SRE_CODE) ptr[0] == pattern[0]) goto failure; pattern++; *************** *** 529,533 **** case SRE_OP_LITERAL_IGNORE: ! TRACE(("%8d: literal lower(%c)\n", PTR(ptr), (SRE_CHAR) *pattern)); if (ptr >= end || state->lower(*ptr) != state->lower(*pattern)) --- 529,533 ---- case SRE_OP_LITERAL_IGNORE: ! TRACE(("%8d: literal lower(%c)\n", PTR(ptr), pattern[0])); if (ptr >= end || state->lower(*ptr) != state->lower(*pattern)) *************** *** 538,543 **** case SRE_OP_NOT_LITERAL_IGNORE: ! TRACE(("%8d: literal not lower(%c)\n", PTR(ptr), ! (SRE_CHAR) *pattern)); if (ptr >= end || state->lower(*ptr) == state->lower(*pattern)) --- 538,542 ---- case SRE_OP_NOT_LITERAL_IGNORE: ! TRACE(("%8d: literal not lower(%c)\n", PTR(ptr), pattern[0])); if (ptr >= end || state->lower(*ptr) == state->lower(*pattern)) *************** *** 550,554 **** TRACE(("%8d: set lower(%c)\n", PTR(ptr), *ptr)); if (ptr >= end ! || !SRE_MEMBER(pattern+1, (SRE_CHAR) state->lower(*ptr))) goto failure; pattern += pattern[0]; --- 549,553 ---- TRACE(("%8d: set lower(%c)\n", PTR(ptr), *ptr)); if (ptr >= end ! || !SRE_MEMBER(pattern+1, (SRE_CODE) state->lower(*ptr))) goto failure; pattern += pattern[0]; *************** *** 632,638 **** } else if (pattern[3] == SRE_OP_LITERAL) { /* repeated literal */ ! SRE_CHAR chr = (SRE_CHAR) pattern[4]; while (count < (int) pattern[2]) { ! if (ptr >= end || *ptr != chr) break; ptr++; --- 631,637 ---- } else if (pattern[3] == SRE_OP_LITERAL) { /* repeated literal */ ! SRE_CODE chr = pattern[4]; while (count < (int) pattern[2]) { ! if (ptr >= end || (SRE_CODE) ptr[0] != chr) break; ptr++; *************** *** 642,648 **** } else if (pattern[3] == SRE_OP_LITERAL_IGNORE) { /* repeated literal */ ! SRE_CHAR chr = (SRE_CHAR) pattern[4]; while (count < (int) pattern[2]) { ! if (ptr >= end || (SRE_CHAR) state->lower(*ptr) != chr) break; ptr++; --- 641,647 ---- } else if (pattern[3] == SRE_OP_LITERAL_IGNORE) { /* repeated literal */ ! SRE_CODE chr = pattern[4]; while (count < (int) pattern[2]) { ! if (ptr >= end || (SRE_CODE) state->lower(*ptr) != chr) break; ptr++; *************** *** 652,658 **** } else if (pattern[3] == SRE_OP_NOT_LITERAL) { /* repeated non-literal */ ! SRE_CHAR chr = (SRE_CHAR) pattern[4]; while (count < (int) pattern[2]) { ! if (ptr >= end || *ptr == chr) break; ptr++; --- 651,657 ---- } else if (pattern[3] == SRE_OP_NOT_LITERAL) { /* repeated non-literal */ ! SRE_CODE chr = pattern[4]; while (count < (int) pattern[2]) { ! if (ptr >= end || (SRE_CODE) ptr[0] == chr) break; ptr++; *************** *** 662,668 **** } else if (pattern[3] == SRE_OP_NOT_LITERAL_IGNORE) { /* repeated non-literal */ ! SRE_CHAR chr = (SRE_CHAR) pattern[4]; while (count < (int) pattern[2]) { ! if (ptr >= end || (SRE_CHAR) state->lower(*ptr) == chr) break; ptr++; --- 661,667 ---- } else if (pattern[3] == SRE_OP_NOT_LITERAL_IGNORE) { /* repeated non-literal */ ! SRE_CODE chr = pattern[4]; while (count < (int) pattern[2]) { ! if (ptr >= end || (SRE_CODE) state->lower(ptr[0]) == chr) break; ptr++; *************** *** 713,717 **** /* tail starts with a literal. skip positions where the rest of the pattern cannot possibly match */ ! SRE_CHAR chr = (SRE_CHAR) pattern[pattern[0]+1]; TRACE(("%8d: tail is literal %d\n", PTR(ptr), chr)); for (;;) { --- 712,716 ---- /* tail starts with a literal. skip positions where the rest of the pattern cannot possibly match */ ! SRE_CODE chr = pattern[pattern[0]+1]; TRACE(("%8d: tail is literal %d\n", PTR(ptr), chr)); for (;;) { *************** *** 869,873 **** while (*pattern) { if (pattern[1] != SRE_OP_LITERAL || ! (ptr < end && *ptr == (SRE_CHAR) pattern[2])) { TRACE(("%8d: branch check\n", PTR(ptr))); state->ptr = ptr; --- 868,872 ---- while (*pattern) { if (pattern[1] != SRE_OP_LITERAL || ! (ptr < end && (SRE_CODE) ptr[0] == pattern[2])) { TRACE(("%8d: branch check\n", PTR(ptr))); state->ptr = ptr; *************** *** 977,981 **** while (ptr < end) { for (;;) { ! if (*ptr != (SRE_CHAR) prefix[i]) { if (!i) break; --- 976,980 ---- while (ptr < end) { for (;;) { ! if ((SRE_CODE) ptr[0] != prefix[i]) { if (!i) break; *************** *** 1009,1015 **** /* pattern starts with a literal character. this is used for short prefixes, and if fast search is disabled*/ ! SRE_CHAR chr = (SRE_CHAR) pattern[1]; for (;;) { ! while (ptr < end && *ptr != chr) ptr++; if (ptr == end) --- 1008,1014 ---- /* pattern starts with a literal character. this is used for short prefixes, and if fast search is disabled*/ ! SRE_CODE chr = pattern[1]; for (;;) { ! while (ptr < end && (SRE_CODE) ptr[0] != chr) ptr++; if (ptr == end) From python-dev@python.org Fri Jun 30 14:55:17 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 06:55:17 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre.py,1.16,1.17 sre_compile.py,1.15,1.16 sre_parse.py,1.15,1.16 Message-ID: <200006301355.GAA00999@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv350/Lib Modified Files: sre.py sre_compile.py sre_parse.py Log Message: the mad patcher strikes again: -- added pickling support (only works if sre is imported) -- fixed wordsize problems in engine (instead of casting literals down to the character size, cast characters up to the literal size (same as the code word size). this prevents false hits when you're matching a unicode pattern against an 8-bit string. (unfortunately, this broke another test, but I think the test should be changed in this case; more on that on python-dev) -- added sre.purge function (unofficial, clears the cache) Index: sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** sre.py 2000/06/30 07:50:59 1.16 --- sre.py 2000/06/30 13:55:14 1.17 *************** *** 90,93 **** --- 90,97 ---- return p + def purge(): + # clear pattern cache + _cache.clear() + def _sub(pattern, template, string, count=0): # internal: pattern.sub implementation hook *************** *** 143,144 **** --- 147,157 ---- append(string[i:]) return s + + # register myself for pickling + + import copy_reg + + def _pickle(p): + return _compile, (p.pattern, p.flags) + + copy_reg.pickle(type(_compile("")), _pickle, _compile) Index: sre_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** sre_compile.py 2000/06/30 10:41:30 1.15 --- sre_compile.py 2000/06/30 13:55:14 1.16 *************** *** 32,44 **** else: emit(OPCODES[op]) ! emit(ord(av)) elif op is IN: if flags & SRE_FLAG_IGNORECASE: emit(OPCODES[OP_IGNORE[op]]) def fixup(literal, flags=flags): ! return _sre.getlower(ord(literal), flags) else: emit(OPCODES[op]) ! fixup = ord skip = len(code); emit(0) for op, av in av: --- 32,44 ---- else: emit(OPCODES[op]) ! emit(av) elif op is IN: if flags & SRE_FLAG_IGNORECASE: emit(OPCODES[OP_IGNORE[op]]) def fixup(literal, flags=flags): ! return _sre.getlower(literal, flags) else: emit(OPCODES[op]) ! fixup = lambda x: x skip = len(code); emit(0) for op, av in av: *************** *** 166,170 **** for op, av in pattern.data: if op is LITERAL: ! prefix.append(ord(av)) else: break --- 166,170 ---- for op, av in pattern.data: if op is LITERAL: ! prefix.append(av) else: break Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** sre_parse.py 2000/06/30 10:41:30 1.15 --- sre_parse.py 2000/06/30 13:55:14 1.16 *************** *** 20,23 **** --- 20,26 ---- MAXREPEAT = 32767 + # FIXME: same here + CHARMASK = 0x7fff + SPECIAL_CHARS = ".\\[{()*+?^$|" REPEAT_CHARS = "*+?{" *************** *** 31,42 **** ESCAPES = { ! r"\a": (LITERAL, chr(7)), ! r"\b": (LITERAL, chr(8)), ! r"\f": (LITERAL, chr(12)), ! r"\n": (LITERAL, chr(10)), ! r"\r": (LITERAL, chr(13)), ! r"\t": (LITERAL, chr(9)), ! r"\v": (LITERAL, chr(11)), ! r"\\": (LITERAL, "\\") } --- 34,45 ---- ESCAPES = { ! r"\a": (LITERAL, 7), ! r"\b": (LITERAL, 8), ! r"\f": (LITERAL, 12), ! r"\n": (LITERAL, 10), ! r"\r": (LITERAL, 13), ! r"\t": (LITERAL, 9), ! r"\v": (LITERAL, 11), ! r"\\": (LITERAL, ord("\\")) } *************** *** 177,183 **** def isname(name): # check that group name is a valid string - # FIXME: this code is really lame. should use a regular - # expression instead, but I seem to have certain bootstrapping - # problems here ;-) if not isident(name[0]): return 0 --- 180,183 ---- *************** *** 210,223 **** escape = escape + source.get() escape = escape[2:] ! # FIXME: support unicode characters! ! return LITERAL, chr(int(escape[-4:], 16) & 0xff) elif str(escape[1:2]) in OCTDIGITS: while source.next in OCTDIGITS: escape = escape + source.get() escape = escape[1:] ! # FIXME: support unicode characters! ! return LITERAL, chr(int(escape[-6:], 8) & 0xff) if len(escape) == 2: ! return LITERAL, escape[1] except ValueError: pass --- 210,221 ---- escape = escape + source.get() escape = escape[2:] ! return LITERAL, int(escape[-4:], 16) & CHARMASK elif str(escape[1:2]) in OCTDIGITS: while source.next in OCTDIGITS: escape = escape + source.get() escape = escape[1:] ! return LITERAL, int(escape[-6:], 8) & CHARMASK if len(escape) == 2: ! return LITERAL, ord(escape[1]) except ValueError: pass *************** *** 237,242 **** escape = escape + source.get() escape = escape[2:] ! # FIXME: support unicode characters! ! return LITERAL, chr(int(escape[-4:], 16) & 0xff) elif escape[1:2] in DIGITS: while 1: --- 235,239 ---- escape = escape + source.get() escape = escape[2:] ! return LITERAL, int(escape[-4:], 16) & CHARMASK elif escape[1:2] in DIGITS: while 1: *************** *** 252,266 **** break escape = escape[1:] ! # FIXME: support unicode characters! ! return LITERAL, chr(int(escape[-6:], 8) & 0xff) if len(escape) == 2: ! return LITERAL, escape[1] except ValueError: pass raise error, "bogus escape: %s" % repr(escape) - def _branch(pattern, items): - # form a branch operator from a set of items --- 249,260 ---- break escape = escape[1:] ! return LITERAL, int(escape[-6:], 8) & CHARMASK if len(escape) == 2: ! return LITERAL, ord(escape[1]) except ValueError: pass raise error, "bogus escape: %s" % repr(escape) def _branch(pattern, items): # form a branch operator from a set of items *************** *** 328,332 **** if this and this[0] not in SPECIAL_CHARS: ! subpattern.append((LITERAL, this)) elif this == "[": --- 322,326 ---- if this and this[0] not in SPECIAL_CHARS: ! subpattern.append((LITERAL, ord(this))) elif this == "[": *************** *** 346,350 **** code1 = _class_escape(source, this) elif this: ! code1 = LITERAL, this else: raise error, "unexpected end of regular expression" --- 340,344 ---- code1 = _class_escape(source, this) elif this: ! code1 = LITERAL, ord(this) else: raise error, "unexpected end of regular expression" *************** *** 354,358 **** if this == "]": set.append(code1) ! set.append((LITERAL, "-")) break else: --- 348,352 ---- if this == "]": set.append(code1) ! set.append((LITERAL, ord("-"))) break else: *************** *** 360,368 **** code2 = _class_escape(source, this) else: ! code2 = LITERAL, this if code1[0] != LITERAL or code2[0] != LITERAL: raise error, "illegal range" - if len(code1[1]) != 1 or len(code2[1]) != 1: - raise error, "illegal range" set.append((RANGE, (code1[1], code2[1]))) else: --- 354,360 ---- code2 = _class_escape(source, this) else: ! code2 = LITERAL, ord(this) if code1[0] != LITERAL or code2[0] != LITERAL: raise error, "illegal range" set.append((RANGE, (code1[1], code2[1]))) else: *************** *** 606,611 **** if not code: this = this[1:] ! # FIXME: support unicode characters! ! code = LITERAL, chr(int(this[-6:], 8) & 0xff) a(code) else: --- 598,602 ---- if not code: this = this[1:] ! code = LITERAL, int(this[-6:], 8) & CHARMASK a(code) else: *************** *** 614,620 **** except KeyError: for c in this: ! a((LITERAL, c)) else: ! a((LITERAL, this)) return p --- 605,611 ---- except KeyError: for c in this: ! a((LITERAL, ord(c))) else: ! a((LITERAL, ord(this))) return p *************** *** 624,630 **** p = [] a = p.append for c, s in template: if c is LITERAL: ! a(s) elif c is MARK: s = match.group(s) --- 615,626 ---- p = [] a = p.append + sep = match.string[:0] + if type(sep) is type(""): + char = chr + else: + char = unichr for c, s in template: if c is LITERAL: ! a(char(s)) elif c is MARK: s = match.group(s) *************** *** 632,634 **** raise error, "empty group" a(s) ! return match.string[:0].join(p) --- 628,630 ---- raise error, "empty group" a(s) ! return sep.join(p) From python-dev@python.org Fri Jun 30 15:04:13 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 07:04:13 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild pcbuild.dsw,1.16,1.17 python16.dsp,1.7,NONE python16.wse,1.7,NONE Message-ID: <200006301404.HAA04120@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv4059 Modified Files: pcbuild.dsw Removed Files: python16.dsp python16.wse Log Message: More 2.0 stuff -- fix workspace, remove 1.6 files Index: pcbuild.dsw =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pcbuild.dsw,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** pcbuild.dsw 2000/04/25 03:24:06 1.16 --- pcbuild.dsw 2000/06/30 14:04:10 1.17 *************** *** 8,15 **** Package=<5> {{{ - begin source code control - _socket - .. - end source code control }}} --- 8,11 ---- *************** *** 17,21 **** {{{ Begin Project Dependency ! Project_Dep_Name python16 End Project Dependency }}} --- 13,17 ---- {{{ Begin Project Dependency ! Project_Dep_Name python20 End Project Dependency }}} *************** *** 27,34 **** Package=<5> {{{ - begin source code control - _sre - .. - end source code control }}} --- 23,26 ---- *************** *** 36,40 **** {{{ Begin Project Dependency ! Project_Dep_Name python16 End Project Dependency }}} --- 28,32 ---- {{{ Begin Project Dependency ! Project_Dep_Name python20 End Project Dependency }}} *************** *** 46,53 **** Package=<5> {{{ - begin source code control - _tkinter - . - end source code control }}} --- 38,41 ---- *************** *** 55,59 **** {{{ Begin Project Dependency ! Project_Dep_Name python16 End Project Dependency }}} --- 43,47 ---- {{{ Begin Project Dependency ! Project_Dep_Name python20 End Project Dependency }}} *************** *** 65,72 **** Package=<5> {{{ - begin source code control - bsddb - .. - end source code control }}} --- 53,56 ---- *************** *** 74,78 **** {{{ Begin Project Dependency ! Project_Dep_Name python16 End Project Dependency }}} --- 58,62 ---- {{{ Begin Project Dependency ! Project_Dep_Name python20 End Project Dependency }}} *************** *** 84,91 **** Package=<5> {{{ - begin source code control - mmap - .. - end source code control }}} --- 68,71 ---- *************** *** 93,97 **** {{{ Begin Project Dependency ! Project_Dep_Name python16 End Project Dependency }}} --- 73,77 ---- {{{ Begin Project Dependency ! Project_Dep_Name python20 End Project Dependency }}} *************** *** 103,110 **** Package=<5> {{{ - begin source code control - parser - .. - end source code control }}} --- 83,86 ---- *************** *** 112,116 **** {{{ Begin Project Dependency ! Project_Dep_Name python16 End Project Dependency }}} --- 88,92 ---- {{{ Begin Project Dependency ! Project_Dep_Name python20 End Project Dependency }}} *************** *** 122,129 **** Package=<5> {{{ - begin source code control - pyexpat - .. - end source code control }}} --- 98,101 ---- *************** *** 131,135 **** {{{ Begin Project Dependency ! Project_Dep_Name python16 End Project Dependency }}} --- 103,107 ---- {{{ Begin Project Dependency ! Project_Dep_Name python20 End Project Dependency }}} *************** *** 141,148 **** Package=<5> {{{ - begin source code control - python - .. - end source code control }}} --- 113,116 ---- *************** *** 150,154 **** {{{ Begin Project Dependency ! Project_Dep_Name python16 End Project Dependency }}} --- 118,122 ---- {{{ Begin Project Dependency ! Project_Dep_Name python20 End Project Dependency }}} *************** *** 156,167 **** ############################################################################### ! Project: "python16"=".\python16.dsp" - Package Owner=<4> Package=<5> {{{ - begin source code control - python16 - .. - end source code control }}} --- 124,131 ---- ############################################################################### ! Project: "python20"=".\python20.dsp" - Package Owner=<4> Package=<5> {{{ }}} *************** *** 176,183 **** Package=<5> {{{ - begin source code control - pythonw - ..\pc - end source code control }}} --- 140,143 ---- *************** *** 185,189 **** {{{ Begin Project Dependency ! Project_Dep_Name python16 End Project Dependency }}} --- 145,149 ---- {{{ Begin Project Dependency ! Project_Dep_Name python20 End Project Dependency }}} *************** *** 195,202 **** Package=<5> {{{ - begin source code control - select - .. - end source code control }}} --- 155,158 ---- *************** *** 204,208 **** {{{ Begin Project Dependency ! Project_Dep_Name python16 End Project Dependency }}} --- 160,164 ---- {{{ Begin Project Dependency ! Project_Dep_Name python20 End Project Dependency }}} *************** *** 214,221 **** Package=<5> {{{ - begin source code control - unicodedata - .. - end source code control }}} --- 170,173 ---- *************** *** 223,227 **** {{{ Begin Project Dependency ! Project_Dep_Name python16 End Project Dependency }}} --- 175,179 ---- {{{ Begin Project Dependency ! Project_Dep_Name python20 End Project Dependency }}} *************** *** 233,240 **** Package=<5> {{{ - begin source code control - winreg - ..\pc - end source code control }}} --- 185,188 ---- *************** *** 242,246 **** {{{ Begin Project Dependency ! Project_Dep_Name python16 End Project Dependency }}} --- 190,194 ---- {{{ Begin Project Dependency ! Project_Dep_Name python20 End Project Dependency }}} *************** *** 252,259 **** Package=<5> {{{ - begin source code control - winsound - ..\pc - end source code control }}} --- 200,203 ---- *************** *** 261,265 **** {{{ Begin Project Dependency ! Project_Dep_Name python16 End Project Dependency }}} --- 205,209 ---- {{{ Begin Project Dependency ! Project_Dep_Name python20 End Project Dependency }}} *************** *** 271,278 **** Package=<5> {{{ - begin source code control - zlib - .. - end source code control }}} --- 215,218 ---- *************** *** 280,284 **** {{{ Begin Project Dependency ! Project_Dep_Name python16 End Project Dependency }}} --- 220,224 ---- {{{ Begin Project Dependency ! Project_Dep_Name python20 End Project Dependency }}} *************** *** 297,299 **** --- 237,240 ---- ############################################################################### + From python-dev@python.org Fri Jun 30 15:20:22 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 07:20:22 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild python20.wse,1.1,1.2 Message-ID: <200006301420.HAA09411@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv9404 Modified Files: python20.wse Log Message: Poke and hope for Tim... (Change title to beta 1, change a few paths for typical Win98 setup.) Index: python20.wse =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/python20.wse,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** python20.wse 2000/06/29 22:32:08 1.1 --- python20.wse 2000/06/30 14:20:19 1.2 *************** *** 2,6 **** item: Global Version=5.0 ! Title=Python 2.0 alpha 2 Flags=00010100 Languages=65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 --- 2,6 ---- item: Global Version=5.0 ! Title=Python 2.0 beta 1 Flags=00010100 Languages=65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 *************** *** 19,35 **** Variable Name1=_SYS_ Variable Description1=System directory ! Variable Default1=C:\WINNT\SYSTEM32 Variable Flags1=00001001 Variable Name2=_WISE_ Variable Description2=WISE root directory ! Variable Default2=C:\Program Files\Wise Variable Flags2=00001001 Variable Name3=_SRC_ Variable Description3=Python source directory ! Variable Default3=D:\src\Python-2.0 Variable Flags3=00001001 Variable Name4=_DOC_ Variable Description4=HTML documentation tree directory ! Variable Default4=D:\src\Python-2.0\html Variable Flags4=00001001 end --- 19,35 ---- Variable Name1=_SYS_ Variable Description1=System directory ! Variable Default1=C:\Windows\System Variable Flags1=00001001 Variable Name2=_WISE_ Variable Description2=WISE root directory ! Variable Default2=C:\Wise Variable Flags2=00001001 Variable Name3=_SRC_ Variable Description3=Python source directory ! Variable Default3=C:\src\Python-2.0 Variable Flags3=00001001 Variable Name4=_DOC_ Variable Description4=HTML documentation tree directory ! Variable Default4=C:\src\Python-2.0\html Variable Flags4=00001001 end *************** *** 56,60 **** item: Set Variable Variable=APPTITLE ! Value=Python 2.0 alpha 2 end item: Set Variable --- 56,60 ---- item: Set Variable Variable=APPTITLE ! Value=Python 2.0 beta 1 end item: Set Variable From python-dev@python.org Fri Jun 30 15:21:53 2000 From: python-dev@python.org (Sjoerd Mullender) Date: Fri, 30 Jun 2000 16:21:53 +0200 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.31,2.32 In-Reply-To: Your message of Fri, 30 Jun 2000 03:29:59 -0700. <200006301029.DAA25494@slayer.i.sourceforge.net> References: <200006301029.DAA25494@slayer.i.sourceforge.net> Message-ID: <20000630142154.968F831047C@bireme.oratrix.nl> Why was the change that occurred in revision 2.31 reverted? Accident? The change log said: Jack Jansen: Use include "" instead of <>; and staticforward declarations On Fri, Jun 30 2000 "M.-A. Lemburg" wrote: > Update of /cvsroot/python/python/dist/src/Objects > In directory slayer.i.sourceforge.net:/tmp/cvs-serv25442/Objects > > Modified Files: > unicodeobject.c > Log Message: > Marc-Andre Lemburg : > New buffer overflow checks for formatting strings. > > By Trent Mick. > > Index: unicodeobject.c > =================================================================== > RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v > retrieving revision 2.31 > retrieving revision 2.32 > diff -C2 -r2.31 -r2.32 > *** unicodeobject.c 2000/06/29 00:06:39 2.31 > --- unicodeobject.c 2000/06/30 10:29:57 2.32 > *************** > *** 67,71 **** > #include "mymath.h" > #include "unicodeobject.h" > ! #include "ucnhash.h" > > #if defined(HAVE_LIMITS_H) > --- 67,71 ---- > #include "mymath.h" > #include "unicodeobject.h" > ! #include > > #if defined(HAVE_LIMITS_H) > *************** > *** 1245,1249 **** > ucnFallthrough: > /* fall through on purpose */ > ! default: > *p++ = '\\'; > *p++ = (unsigned char)s[-1]; > --- 1245,1249 ---- > ucnFallthrough: > /* fall through on purpose */ > ! default: > *p++ = '\\'; > *p++ = (unsigned char)s[-1]; > *************** > *** 1252,1256 **** > } > if (_PyUnicode_Resize(v, (int)(p - buf))) > ! goto onError; > return (PyObject *)v; > > --- 1252,1256 ---- > } > if (_PyUnicode_Resize(v, (int)(p - buf))) > ! goto onError; > return (PyObject *)v; > > *************** > *** 4374,4377 **** > --- 4374,4378 ---- > static int > formatfloat(Py_UNICODE *buf, > + size_t buflen, > int flags, > int prec, > *************** > *** 4379,4382 **** > --- 4380,4385 ---- > PyObject *v) > { > + /* fmt = '%#.' + `prec` + `type` > + worst case length = 3 + 10 (len of INT_MAX) + 1 = 14 (use 20)*/ > char fmt[20]; > double x; > *************** > *** 4387,4395 **** > if (prec < 0) > prec = 6; > - if (prec > 50) > - prec = 50; /* Arbitrary limitation */ > if (type == 'f' && (fabs(x) / 1e25) >= 1e25) > type = 'g'; > sprintf(fmt, "%%%s.%d%c", (flags & F_ALT) ? "#" : "", prec, type); > return usprintf(buf, fmt, x); > } > --- 4390,4408 ---- > if (prec < 0) > prec = 6; > if (type == 'f' && (fabs(x) / 1e25) >= 1e25) > type = 'g'; > sprintf(fmt, "%%%s.%d%c", (flags & F_ALT) ? "#" : "", prec, type); > + /* worst case length calc to ensure no buffer overrun: > + fmt = %#.g > + buf = '-' + [0-9]*prec + '.' + 'e+' + (longest exp > + for any double rep.) > + len = 1 + prec + 1 + 2 + 5 = 9 + prec > + If prec=0 the effective precision is 1 (the leading digit is > + always given), therefore increase by one to 10+prec. */ > + if (buflen <= (size_t)10 + (size_t)prec) { > + PyErr_SetString(PyExc_OverflowError, > + "formatted float is too long (precision too long?)"); > + return -1; > + } > return usprintf(buf, fmt, x); > } > *************** > *** 4397,4400 **** > --- 4410,4414 ---- > static int > formatint(Py_UNICODE *buf, > + size_t buflen, > int flags, > int prec, > *************** > *** 4402,4405 **** > --- 4416,4421 ---- > PyObject *v) > { > + /* fmt = '%#.' + `prec` + 'l' + `type` > + worst case length = 3 + 10 (len of INT_MAX) + 1 + 1 = 15 (use 20)*/ > char fmt[20]; > long x; > *************** > *** 4410,4413 **** > --- 4426,4436 ---- > if (prec < 0) > prec = 1; > + /* buf = '+'/'-'/'0'/'0x' + '[0-9]'*max(prec,len(x in octal)) > + worst case buf = '0x' + [0-9]*prec, where prec >= 11 */ > + if (buflen <= 13 || buflen <= (size_t)2+(size_t)prec) { > + PyErr_SetString(PyExc_OverflowError, > + "formatted integer is too long (precision too long?)"); > + return -1; > + } > sprintf(fmt, "%%%s.%dl%c", (flags & F_ALT) ? "#" : "", prec, type); > return usprintf(buf, fmt, x); > *************** > *** 4416,4421 **** > static int > formatchar(Py_UNICODE *buf, > ! PyObject *v) > { > if (PyUnicode_Check(v)) { > if (PyUnicode_GET_SIZE(v) != 1) > --- 4439,4446 ---- > static int > formatchar(Py_UNICODE *buf, > ! size_t buflen, > ! PyObject *v) > { > + /* presume that the buffer is at least 2 characters long */ > if (PyUnicode_Check(v)) { > if (PyUnicode_GET_SIZE(v) != 1) > *************** > *** 4447,4450 **** > --- 4472,4485 ---- > } > > + /* fmt%(v1,v2,...) is roughly equivalent to sprintf(fmt, v1, v2, ...) > + > + FORMATBUFLEN is the length of the buffer in which the floats, ints, & > + chars are formatted. XXX This is a magic number. Each formatting > + routine does bounds checking to ensure no overflow, but a better > + solution may be to malloc a buffer of appropriate size for each > + format. For now, the current solution is sufficient. > + */ > + #define FORMATBUFLEN (size_t)120 > + > PyObject *PyUnicode_Format(PyObject *format, > PyObject *args) > *************** > *** 4506,4513 **** > PyObject *v = NULL; > PyObject *temp = NULL; > ! Py_UNICODE *buf; > Py_UNICODE sign; > int len; > ! Py_UNICODE tmpbuf[120]; /* For format{float,int,char}() */ > > fmt++; > --- 4541,4548 ---- > PyObject *v = NULL; > PyObject *temp = NULL; > ! Py_UNICODE *pbuf; > Py_UNICODE sign; > int len; > ! Py_UNICODE formatbuf[FORMATBUFLEN]; /* For format{float,int,char}() */ > > fmt++; > *************** > *** 4659,4664 **** > > case '%': > ! buf = tmpbuf; > ! buf[0] = '%'; > len = 1; > break; > --- 4694,4700 ---- > > case '%': > ! pbuf = formatbuf; > ! /* presume that buffer length is at least 1 */ > ! pbuf[0] = '%'; > len = 1; > break; > *************** > *** 4696,4700 **** > goto onError; > } > ! buf = PyUnicode_AS_UNICODE(temp); > len = PyUnicode_GET_SIZE(temp); > if (prec >= 0 && len > prec) > --- 4732,4736 ---- > goto onError; > } > ! pbuf = PyUnicode_AS_UNICODE(temp); > len = PyUnicode_GET_SIZE(temp); > if (prec >= 0 && len > prec) > *************** > *** 4710,4715 **** > if (c == 'i') > c = 'd'; > ! buf = tmpbuf; > ! len = formatint(buf, flags, prec, c, v); > if (len < 0) > goto onError; > --- 4746,4752 ---- > if (c == 'i') > c = 'd'; > ! pbuf = formatbuf; > ! len = formatint(pbuf, sizeof(formatbuf)/sizeof(Py_UNICODE), > ! flags, prec, c, v); > if (len < 0) > goto onError; > *************** > *** 4719,4725 **** > if ((flags&F_ALT) && > (c == 'x' || c == 'X') && > ! buf[0] == '0' && buf[1] == c) { > ! *res++ = *buf++; > ! *res++ = *buf++; > rescnt -= 2; > len -= 2; > --- 4756,4762 ---- > if ((flags&F_ALT) && > (c == 'x' || c == 'X') && > ! pbuf[0] == '0' && pbuf[1] == c) { > ! *res++ = *pbuf++; > ! *res++ = *pbuf++; > rescnt -= 2; > len -= 2; > *************** > *** 4736,4741 **** > case 'g': > case 'G': > ! buf = tmpbuf; > ! len = formatfloat(buf, flags, prec, c, v); > if (len < 0) > goto onError; > --- 4773,4779 ---- > case 'g': > case 'G': > ! pbuf = formatbuf; > ! len = formatfloat(pbuf, sizeof(formatbuf)/sizeof(Py_UNICODE), > ! flags, prec, c, v); > if (len < 0) > goto onError; > *************** > *** 4746,4751 **** > > case 'c': > ! buf = tmpbuf; > ! len = formatchar(buf, v); > if (len < 0) > goto onError; > --- 4784,4789 ---- > > case 'c': > ! pbuf = formatbuf; > ! len = formatchar(pbuf, sizeof(formatbuf)/sizeof(Py_UNICODE), v); > if (len < 0) > goto onError; > *************** > *** 4759,4764 **** > } > if (sign) { > ! if (*buf == '-' || *buf == '+') { > ! sign = *buf++; > len--; > } > --- 4797,4802 ---- > } > if (sign) { > ! if (*pbuf == '-' || *pbuf == '+') { > ! sign = *pbuf++; len--; > } > *************** > *** 4796,4800 **** > if (sign && fill == ' ') > *res++ = sign; > ! memcpy(res, buf, len * sizeof(Py_UNICODE)); > res += len; > rescnt -= len; > --- 4834,4838 ---- > if (sign && fill == ' ') > *res++ = sign; > ! memcpy(res, pbuf, len * sizeof(Py_UNICODE)); > res += len; > rescnt -= len; > > -- Sjoerd Mullender From python-dev@python.org Fri Jun 30 15:30:31 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 07:30:31 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild python20.wse,1.2,1.3 Message-ID: <200006301430.HAA10113@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv10092 Modified Files: python20.wse Log Message: Move Wise install dir consistently to C:\Wise. Don't use %_WISE_% in include, it doesn't seem to work. Index: python20.wse =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/python20.wse,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** python20.wse 2000/06/30 14:20:19 1.2 --- python20.wse 2000/06/30 14:30:28 1.3 *************** *** 88,92 **** Direction Variable=DIRECTION Display Variable=DISPLAY ! Bitmap Pathname=C:\Program Files\Wise\DIALOGS\TEMPLATE\WIZARD.BMP X Position=9 Y Position=10 --- 88,92 ---- Direction Variable=DIRECTION Display Variable=DISPLAY ! Bitmap Pathname=C:\Wise\DIALOGS\TEMPLATE\WIZARD.BMP X Position=9 Y Position=10 *************** *** 1049,1053 **** end item: Include Script ! Pathname=%_WISE_%\include\uninstal.wse end item: If/While Statement --- 1049,1053 ---- end item: Include Script ! Pathname=C:\Wise\include\uninstal.wse end item: If/While Statement *************** *** 1151,1155 **** Direction Variable=DIRECTION Display Variable=DISPLAY ! Bitmap Pathname=C:\Program Files\Wise\DIALOGS\TEMPLATE\WIZARD.BMP X Position=9 Y Position=10 --- 1151,1155 ---- Direction Variable=DIRECTION Display Variable=DISPLAY ! Bitmap Pathname=C:\Wise\DIALOGS\TEMPLATE\WIZARD.BMP X Position=9 Y Position=10 From python-dev@python.org Fri Jun 30 15:33:50 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 07:33:50 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild _tkinter.dsp,1.14,1.15 Message-ID: <200006301433.HAA10408@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv10364 Modified Files: _tkinter.dsp Log Message: Change the include etc paths to Tcl 8.3.1. Index: _tkinter.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/_tkinter.dsp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** _tkinter.dsp 2000/04/21 21:26:07 1.14 --- _tkinter.dsp 2000/06/30 14:33:47 1.15 *************** *** 110,114 **** CPP=cl.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 "C:\Program Files\Tcl\include" /I "..\Include" /I "..\PC" /I "..\..\tcl8.2\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "WITH_APPINIT" /YX /FD /c MTL=midl.exe # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 --- 110,114 ---- CPP=cl.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 "..\..\tcl\include" /I "..\Include" /I "..\PC" /I "..\..\tcl8.3\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "WITH_APPINIT" /YX /FD /c MTL=midl.exe # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 *************** *** 122,126 **** 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 ..\..\tcl8.2\lib\tk82.lib ..\..\tcl8.2\lib\tcl82.lib odbc32.lib odbccp32.lib user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /base:"0x1e190000" /subsystem:windows /dll /debug /machine:I386 /out:"./_tkinter_d.pyd" /pdbtype:sept /libpath:"C:\Program Files\Tcl\lib" /export:init_tkinter # SUBTRACT LINK32 /pdb:none --- 122,126 ---- 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 ..\..\tcl\lib\tk83.lib ..\..\tcl\lib\tcl83.lib odbc32.lib odbccp32.lib user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /base:"0x1e190000" /subsystem:windows /dll /debug /machine:I386 /out:"./_tkinter_d.pyd" /pdbtype:sept /libpath:"C:\Program Files\Tcl\lib" /export:init_tkinter # SUBTRACT LINK32 /pdb:none *************** *** 141,145 **** CPP=cl.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 "..\..\tcl\include" /I "..\Include" /I "..\PC" /I "..\..\tcl8.2\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "WITH_APPINIT" /YX /FD /c MTL=midl.exe # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 --- 141,145 ---- CPP=cl.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 "..\..\tcl\include" /I "..\Include" /I "..\PC" /I "..\..\tcl8.3\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "WITH_APPINIT" /YX /FD /c MTL=midl.exe # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 *************** *** 153,157 **** 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 ..\..\tcl8.2\lib\tk82.lib ..\..\tcl8.2\lib\tcl82.lib odbc32.lib odbccp32.lib user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /base:"0x1e190000" /subsystem:windows /dll /debug /machine:I386 /out:"./_tkinter.pyd" /libpath:"C:\Program Files\Tcl\lib" /export:init_tkinter # SUBTRACT LINK32 /pdb:none --- 153,157 ---- 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 ..\..\tcl\lib\tk83.lib ..\..\tcl\lib\tcl83.lib odbc32.lib odbccp32.lib user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /base:"0x1e190000" /subsystem:windows /dll /debug /machine:I386 /out:"./_tkinter.pyd" /libpath:"C:\Program Files\Tcl\lib" /export:init_tkinter # SUBTRACT LINK32 /pdb:none From python-dev@python.org Fri Jun 30 15:38:43 2000 From: python-dev@python.org (Jeremy Hylton) Date: Fri, 30 Jun 2000 07:38:43 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild python20.dsp,1.1,1.2 Message-ID: <200006301438.HAA11138@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv11130 Modified Files: python20.dsp Log Message: add gcmodule Index: python20.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/python20.dsp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** python20.dsp 2000/06/29 22:31:28 1.1 --- python20.dsp 2000/06/30 14:38:41 1.2 *************** *** 660,663 **** --- 660,677 ---- # End Source File # Begin Source File + SOURCE=..\Modules\gcmodule.c + + !IF "$(CFG)" == "python20 - Win32 Release" + + !ELSEIF "$(CFG)" == "python20 - Win32 Debug" + + !ELSEIF "$(CFG)" == "python20 - Win32 Alpha Debug" + + !ELSEIF "$(CFG)" == "python20 - Win32 Alpha Release" + + !ENDIF + + # End Source File + # Begin Source File SOURCE=..\Python\getargs.c From python-dev@python.org Fri Jun 30 15:50:54 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 07:50:54 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild python20.wse,1.3,1.4 Message-ID: <200006301450.HAA12146@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv12135 Modified Files: python20.wse Log Message: Poke and hope for Tcl version: now settable through _TCLMINOR_ variable... Index: python20.wse =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/python20.wse,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** python20.wse 2000/06/30 14:30:28 1.3 --- python20.wse 2000/06/30 14:50:52 1.4 *************** *** 33,36 **** --- 33,40 ---- Variable Default4=C:\src\Python-2.0\html Variable Flags4=00001001 + Variable Name5=_TCLMINOR_ + Variable Description5=Tcl/Tk Minor Version (e.g. the "3" in "8.3.1") + Variable Default5=2 + Variable Flags5=00001000 end remarked item: Open/Close INSTALL.LOG *************** *** 1132,1142 **** end item: Install File ! Source=%_SRC_%\..\tcl8.2\bin\tcl82.dll ! Destination=%MAINDIR%\DLLs\tcl82.dll Flags=0000000000000010 end item: Install File ! Source=%_SRC_%\..\tcl8.2\bin\tk82.dll ! Destination=%MAINDIR%\DLLs\tk82.dll Flags=0000000000000010 end --- 1136,1146 ---- end item: Install File ! Source=%_SRC_%\..\tcl\bin\tcl8%_TCLMINOR_%.dll ! Destination=%MAINDIR%\DLLs\tcl8%_TCLMINOR_%.dll Flags=0000000000000010 end item: Install File ! Source=%_SRC_%\..\tcl\bin\tk8%_TCLMINOR_%.dll ! Destination=%MAINDIR%\DLLs\tk8%_TCLMINOR_%.dll Flags=0000000000000010 end From python-dev@python.org Fri Jun 30 15:53:31 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Fri, 30 Jun 2000 16:53:31 +0200 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.31,2.32 References: <200006301029.DAA25494@slayer.i.sourceforge.net> <20000630142154.968F831047C@bireme.oratrix.nl> Message-ID: <395CB46B.34053D3E@lemburg.com> > Why was the change that occurred in revision 2.31 reverted? Accident? > > The change log said: > Jack Jansen: Use include "" instead of <>; and staticforward declarations Accident... I'll revert that change. -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From python-dev@python.org Fri Jun 30 15:55:29 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 07:55:29 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild python20.wse,1.4,1.5 Message-ID: <200006301455.HAA12420@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv12411 Modified Files: python20.wse Log Message: Oops. - The Tcl minor version should be 3 -- we're now using 8.3.1. - Remove the version number from yet another Tcl source file. Note that Tcl should be installed in C:\src\tcl for this to work. Index: python20.wse =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/python20.wse,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** python20.wse 2000/06/30 14:50:52 1.4 --- python20.wse 2000/06/30 14:55:26 1.5 *************** *** 35,39 **** Variable Name5=_TCLMINOR_ Variable Description5=Tcl/Tk Minor Version (e.g. the "3" in "8.3.1") ! Variable Default5=2 Variable Flags5=00001000 end --- 35,39 ---- Variable Name5=_TCLMINOR_ Variable Description5=Tcl/Tk Minor Version (e.g. the "3" in "8.3.1") ! Variable Default5=3 Variable Flags5=00001000 end *************** *** 1146,1150 **** end item: Install File ! Source=%_SRC_%\..\tcl8.2\lib\*.* Destination=%MAINDIR%\tcl Flags=0000000100000010 --- 1146,1150 ---- end item: Install File ! Source=%_SRC_%\..\tcl\lib\*.* Destination=%MAINDIR%\tcl Flags=0000000100000010 From python-dev@python.org Fri Jun 30 15:58:23 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Fri, 30 Jun 2000 07:58:23 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.32,2.33 Message-ID: <200006301458.HAA12572@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv12549/Objects Modified Files: unicodeobject.c Log Message: Marc-Andre Lemburg : A previous patch by Jack Jansen was accidently reverted. Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.32 retrieving revision 2.33 diff -C2 -r2.32 -r2.33 *** unicodeobject.c 2000/06/30 10:29:57 2.32 --- unicodeobject.c 2000/06/30 14:58:20 2.33 *************** *** 67,71 **** #include "mymath.h" #include "unicodeobject.h" ! #include #if defined(HAVE_LIMITS_H) --- 67,71 ---- #include "mymath.h" #include "unicodeobject.h" ! #include "ucnhash.h" #if defined(HAVE_LIMITS_H) From python-dev@python.org Fri Jun 30 16:01:02 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 08:01:02 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python thread_beos.h,2.2,2.3 thread_cthread.h,2.8,2.9 thread_foobar.h,2.6,2.7 thread_lwp.h,2.7,2.8 thread_nt.h,2.11,2.12 thread_os2.h,2.5,2.6 thread_pth.h,2.1,2.2 thread_pthread.h,2.24,2.25 thread_sgi.h,2.9,2.10 thread_solaris.h,2.10,2.11 thread_wince.h,2.1,2.2 Message-ID: <200006301501.IAA13183@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv13110/Python Modified Files: thread_beos.h thread_cthread.h thread_foobar.h thread_lwp.h thread_nt.h thread_os2.h thread_pth.h thread_pthread.h thread_sgi.h thread_solaris.h thread_wince.h Log Message: Trent Mick : The common technique for printing out a pointer has been to cast to a long and use the "%lx" printf modifier. This is incorrect on Win64 where casting to a long truncates the pointer. The "%p" formatter should be used instead. The problem as stated by Tim: > Unfortunately, the C committee refused to define what %p conversion "looks > like" -- they explicitly allowed it to be implementation-defined. Older > versions of Microsoft C even stuck a colon in the middle of the address (in > the days of segment+offset addressing)! The result is that the hex value of a pointer will maybe/maybe not have a 0x prepended to it. Notes on the patch: There are two main classes of changes: - in the various repr() functions that print out pointers - debugging printf's in the various thread_*.h files (these are why the patch is large) Closes SourceForge patch #100505. Index: thread_beos.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_beos.h,v retrieving revision 2.2 retrieving revision 2.3 diff -C2 -r2.2 -r2.3 *** thread_beos.h 1998/12/21 19:32:29 2.2 --- thread_beos.h 2000/06/30 15:01:00 2.3 *************** *** 263,267 **** } ! dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock)); return (PyThread_type_lock) lock; } --- 263,267 ---- } ! dprintf(("PyThread_allocate_lock() -> %p\n", lock)); return (PyThread_type_lock) lock; } *************** *** 271,275 **** status_t retval; ! dprintf(("PyThread_free_lock(%lx) called\n", (long)lock)); retval = benaphore_destroy( (benaphore_t *)lock ); --- 271,275 ---- status_t retval; ! dprintf(("PyThread_free_lock(%p) called\n", lock)); retval = benaphore_destroy( (benaphore_t *)lock ); *************** *** 285,289 **** status_t retval; ! dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag)); if( waitflag ) { --- 285,289 ---- status_t retval; ! dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag)); if( waitflag ) { *************** *** 301,305 **** } ! dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success)); return success; } --- 301,305 ---- } ! dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success)); return success; } *************** *** 309,313 **** status_t retval; ! dprintf(("PyThread_release_lock(%lx) called\n", (long)lock)); retval = benaphore_unlock( (benaphore_t *)lock ); --- 309,313 ---- status_t retval; ! dprintf(("PyThread_release_lock(%p) called\n", lock)); retval = benaphore_unlock( (benaphore_t *)lock ); *************** *** 337,341 **** } ! dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema)); return (PyThread_type_sema) sema; } --- 337,341 ---- } ! dprintf(("PyThread_allocate_sema() -> %p\n", sema)); return (PyThread_type_sema) sema; } *************** *** 345,349 **** status_t retval; ! dprintf(("PyThread_free_sema(%lx) called\n", (long) sema)); retval = delete_sem( (sem_id)sema ); --- 345,349 ---- status_t retval; ! dprintf(("PyThread_free_sema(%p) called\n", sema)); retval = delete_sem( (sem_id)sema ); *************** *** 358,362 **** status_t retval; ! dprintf(("PyThread_down_sema(%lx, %d) called\n", (long) sema, waitflag)); if( waitflag ) { --- 358,362 ---- status_t retval; ! dprintf(("PyThread_down_sema(%p, %d) called\n", sema, waitflag)); if( waitflag ) { *************** *** 371,375 **** } ! dprintf(("PyThread_down_sema(%lx) return\n", (long) sema)); return -1; } --- 371,375 ---- } ! dprintf(("PyThread_down_sema(%p) return\n", sema)); return -1; } *************** *** 379,383 **** status_t retval; ! dprintf(("PyThread_up_sema(%lx)\n", (long) sema)); retval = release_sem( (sem_id)sema ); --- 379,383 ---- status_t retval; ! dprintf(("PyThread_up_sema(%p)\n", sema)); retval = release_sem( (sem_id)sema ); Index: thread_cthread.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_cthread.h,v retrieving revision 2.8 retrieving revision 2.9 diff -C2 -r2.8 -r2.9 *** thread_cthread.h 1998/12/21 19:32:30 2.8 --- thread_cthread.h 2000/06/30 15:01:00 2.9 *************** *** 130,134 **** lock = 0; } ! dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock)); return (PyThread_type_lock) lock; } --- 130,134 ---- lock = 0; } ! dprintf(("PyThread_allocate_lock() -> %p\n", lock)); return (PyThread_type_lock) lock; } *************** *** 136,140 **** void PyThread_free_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_free_lock(%lx) called\n", (long)lock)); mutex_free(lock); } --- 136,140 ---- void PyThread_free_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_free_lock(%p) called\n", lock)); mutex_free(lock); } *************** *** 144,148 **** int success = FALSE; ! dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag)); if (waitflag) { /* blocking */ mutex_lock(lock); --- 144,148 ---- int success = FALSE; ! dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag)); if (waitflag) { /* blocking */ mutex_lock(lock); *************** *** 151,155 **** success = mutex_try_lock(lock); } ! dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success)); return success; } --- 151,155 ---- success = mutex_try_lock(lock); } ! dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success)); return success; } *************** *** 157,161 **** void PyThread_release_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_release_lock(%lx) called\n", (long)lock)); mutex_unlock((mutex_t )lock); } --- 157,161 ---- void PyThread_release_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_release_lock(%p) called\n", lock)); mutex_unlock((mutex_t )lock); } *************** *** 182,186 **** PyThread_init_thread(); ! dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema)); return (PyThread_type_sema) sema; } --- 182,186 ---- PyThread_init_thread(); ! dprintf(("PyThread_allocate_sema() -> %p\n", sema)); return (PyThread_type_sema) sema; } *************** *** 188,198 **** void PyThread_free_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_free_sema(%lx) called\n", (long) sema)); } int PyThread_down_sema _P2(sema, PyThread_type_sema sema, waitflag, int waitflag) { ! dprintf(("PyThread_down_sema(%lx, %d) called\n", (long) sema, waitflag)); ! dprintf(("PyThread_down_sema(%lx) return\n", (long) sema)); return -1; } --- 188,198 ---- void PyThread_free_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_free_sema(%p) called\n", sema)); } int PyThread_down_sema _P2(sema, PyThread_type_sema sema, waitflag, int waitflag) { ! dprintf(("PyThread_down_sema(%p, %d) called\n", sema, waitflag)); ! dprintf(("PyThread_down_sema(%p) return\n", sema)); return -1; } *************** *** 200,203 **** void PyThread_up_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_up_sema(%lx)\n", (long) sema)); } --- 200,203 ---- void PyThread_up_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_up_sema(%p)\n", sema)); } Index: thread_foobar.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_foobar.h,v retrieving revision 2.6 retrieving revision 2.7 diff -C2 -r2.6 -r2.7 *** thread_foobar.h 1998/12/21 19:32:30 2.6 --- thread_foobar.h 2000/06/30 15:01:00 2.7 *************** *** 109,113 **** PyThread_init_thread(); ! dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock)); return (PyThread_type_lock) lock; } --- 109,113 ---- PyThread_init_thread(); ! dprintf(("PyThread_allocate_lock() -> %p\n", lock)); return (PyThread_type_lock) lock; } *************** *** 115,119 **** void PyThread_free_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_free_lock(%lx) called\n", (long)lock)); } --- 115,119 ---- void PyThread_free_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_free_lock(%p) called\n", lock)); } *************** *** 122,127 **** int success; ! dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag)); ! dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success)); return success; } --- 122,127 ---- int success; ! dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag)); ! dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success)); return success; } *************** *** 129,133 **** void PyThread_release_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_release_lock(%lx) called\n", (long)lock)); } --- 129,133 ---- void PyThread_release_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_release_lock(%p) called\n", lock)); } *************** *** 141,145 **** PyThread_init_thread(); ! dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema)); return (PyThread_type_sema) sema; } --- 141,145 ---- PyThread_init_thread(); ! dprintf(("PyThread_allocate_sema() -> %p\n", sema)); return (PyThread_type_sema) sema; } *************** *** 147,157 **** void PyThread_free_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_free_sema(%lx) called\n", (long) sema)); } int PyThread_down_sema _P2(sema, PyThread_type_sema sema, waitflag, int waitflag) { ! dprintf(("PyThread_down_sema(%lx, %d) called\n", (long) sema, waitflag)); ! dprintf(("PyThread_down_sema(%lx) return\n", (long) sema)); return -1; } --- 147,157 ---- void PyThread_free_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_free_sema(%p) called\n", sema)); } int PyThread_down_sema _P2(sema, PyThread_type_sema sema, waitflag, int waitflag) { ! dprintf(("PyThread_down_sema(%p, %d) called\n", sema, waitflag)); ! dprintf(("PyThread_down_sema(%p) return\n", sema)); return -1; } *************** *** 159,162 **** void PyThread_up_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_up_sema(%lx)\n", (long) sema)); } --- 159,162 ---- void PyThread_up_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_up_sema(%p)\n", sema)); } Index: thread_lwp.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_lwp.h,v retrieving revision 2.7 retrieving revision 2.8 diff -C2 -r2.7 -r2.8 *** thread_lwp.h 1998/12/21 19:32:31 2.7 --- thread_lwp.h 2000/06/30 15:01:00 2.8 *************** *** 138,142 **** (void) mon_create(&lock->lock_monitor); (void) cv_create(&lock->lock_condvar, lock->lock_monitor); ! dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock)); return (PyThread_type_lock) lock; } --- 138,142 ---- (void) mon_create(&lock->lock_monitor); (void) cv_create(&lock->lock_condvar, lock->lock_monitor); ! dprintf(("PyThread_allocate_lock() -> %p\n", lock)); return (PyThread_type_lock) lock; } *************** *** 144,148 **** void PyThread_free_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_free_lock(%lx) called\n", (long)lock)); mon_destroy(((struct lock *) lock)->lock_monitor); free((char *) lock); --- 144,148 ---- void PyThread_free_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_free_lock(%p) called\n", lock)); mon_destroy(((struct lock *) lock)->lock_monitor); free((char *) lock); *************** *** 153,157 **** int success; ! dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag)); success = 0; --- 153,157 ---- int success; ! dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag)); success = 0; *************** *** 166,170 **** cv_broadcast(((struct lock *) lock)->lock_condvar); mon_exit(((struct lock *) lock)->lock_monitor); ! dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success)); return success; } --- 166,170 ---- cv_broadcast(((struct lock *) lock)->lock_condvar); mon_exit(((struct lock *) lock)->lock_monitor); ! dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success)); return success; } *************** *** 172,176 **** void PyThread_release_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_release_lock(%lx) called\n", (long)lock)); (void) mon_enter(((struct lock *) lock)->lock_monitor); ((struct lock *) lock)->lock_locked = 0; --- 172,176 ---- void PyThread_release_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_release_lock(%p) called\n", lock)); (void) mon_enter(((struct lock *) lock)->lock_monitor); ((struct lock *) lock)->lock_locked = 0; *************** *** 189,193 **** PyThread_init_thread(); ! dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema)); return (PyThread_type_sema) sema; } --- 189,193 ---- PyThread_init_thread(); ! dprintf(("PyThread_allocate_sema() -> %p\n", sema)); return (PyThread_type_sema) sema; } *************** *** 195,205 **** void PyThread_free_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_free_sema(%lx) called\n", (long) sema)); } int PyThread_down_sema _P2(sema, PyThread_type_sema sema, waitflag, int waitflag) { ! dprintf(("PyThread_down_sema(%lx, %d) called\n", (long) sema, waitflag)); ! dprintf(("PyThread_down_sema(%lx) return\n", (long) sema)); return -1; } --- 195,205 ---- void PyThread_free_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_free_sema(%p) called\n", sema)); } int PyThread_down_sema _P2(sema, PyThread_type_sema sema, waitflag, int waitflag) { ! dprintf(("PyThread_down_sema(%p, %d) called\n", sema, waitflag)); ! dprintf(("PyThread_down_sema(%p) return\n", sema)); return -1; } *************** *** 207,210 **** void PyThread_up_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_up_sema(%lx)\n", (long) sema)); } --- 207,210 ---- void PyThread_up_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_up_sema(%p)\n", sema)); } Index: thread_nt.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_nt.h,v retrieving revision 2.11 retrieving revision 2.12 diff -C2 -r2.11 -r2.12 *** thread_nt.h 2000/06/29 17:25:30 2.11 --- thread_nt.h 2000/06/30 15:01:00 2.12 *************** *** 274,278 **** aLock = AllocNonRecursiveMutex() ; ! dprintf(("%ld: PyThread_allocate_lock() -> %lx\n", PyThread_get_thread_ident(), (long)aLock)); return (PyThread_type_lock) aLock; --- 274,278 ---- aLock = AllocNonRecursiveMutex() ; ! dprintf(("%ld: PyThread_allocate_lock() -> %p\n", PyThread_get_thread_ident(), aLock)); return (PyThread_type_lock) aLock; *************** *** 281,285 **** void PyThread_free_lock(PyThread_type_lock aLock) { ! dprintf(("%ld: PyThread_free_lock(%lx) called\n", PyThread_get_thread_ident(),(long)aLock)); FreeNonRecursiveMutex(aLock) ; --- 281,285 ---- void PyThread_free_lock(PyThread_type_lock aLock) { ! dprintf(("%ld: PyThread_free_lock(%p) called\n", PyThread_get_thread_ident(),aLock)); FreeNonRecursiveMutex(aLock) ; *************** *** 296,304 **** int success ; ! dprintf(("%ld: PyThread_acquire_lock(%lx, %d) called\n", PyThread_get_thread_ident(),(long)aLock, waitflag)); success = aLock && EnterNonRecursiveMutex((PNRMUTEX) aLock, (waitflag == 1 ? INFINITE : 0)) == WAIT_OBJECT_0 ; ! dprintf(("%ld: PyThread_acquire_lock(%lx, %d) -> %d\n", PyThread_get_thread_ident(),(long)aLock, waitflag, success)); return success; --- 296,304 ---- int success ; ! dprintf(("%ld: PyThread_acquire_lock(%p, %d) called\n", PyThread_get_thread_ident(),aLock, waitflag)); success = aLock && EnterNonRecursiveMutex((PNRMUTEX) aLock, (waitflag == 1 ? INFINITE : 0)) == WAIT_OBJECT_0 ; ! dprintf(("%ld: PyThread_acquire_lock(%p, %d) -> %d\n", PyThread_get_thread_ident(),aLock, waitflag, success)); return success; *************** *** 307,314 **** void PyThread_release_lock(PyThread_type_lock aLock) { ! dprintf(("%ld: PyThread_release_lock(%lx) called\n", PyThread_get_thread_ident(),(long)aLock)); if (!(aLock && LeaveNonRecursiveMutex((PNRMUTEX) aLock))) ! dprintf(("%ld: Could not PyThread_release_lock(%lx) error: %l\n", PyThread_get_thread_ident(), (long)aLock, GetLastError())); } --- 307,314 ---- void PyThread_release_lock(PyThread_type_lock aLock) { ! dprintf(("%ld: PyThread_release_lock(%p) called\n", PyThread_get_thread_ident(),aLock)); if (!(aLock && LeaveNonRecursiveMutex((PNRMUTEX) aLock))) ! dprintf(("%ld: Could not PyThread_release_lock(%p) error: %l\n", PyThread_get_thread_ident(), aLock, GetLastError())); } *************** *** 329,333 **** NULL); /* Name of semaphore */ ! dprintf(("%ld: PyThread_allocate_sema() -> %lx\n", PyThread_get_thread_ident(), (long)aSemaphore)); return (PyThread_type_sema) aSemaphore; --- 329,333 ---- NULL); /* Name of semaphore */ ! dprintf(("%ld: PyThread_allocate_sema() -> %p\n", PyThread_get_thread_ident(), aSemaphore)); return (PyThread_type_sema) aSemaphore; *************** *** 336,340 **** void PyThread_free_sema(PyThread_type_sema aSemaphore) { ! dprintf(("%ld: PyThread_free_sema(%lx) called\n", PyThread_get_thread_ident(), (long)aSemaphore)); CloseHandle((HANDLE) aSemaphore); --- 336,340 ---- void PyThread_free_sema(PyThread_type_sema aSemaphore) { ! dprintf(("%ld: PyThread_free_sema(%p) called\n", PyThread_get_thread_ident(), aSemaphore)); CloseHandle((HANDLE) aSemaphore); *************** *** 348,356 **** DWORD waitResult; ! dprintf(("%ld: PyThread_down_sema(%lx) called\n", PyThread_get_thread_ident(), (long)aSemaphore)); waitResult = WaitForSingleObject( (HANDLE) aSemaphore, INFINITE); ! dprintf(("%ld: PyThread_down_sema(%lx) return: %l\n", PyThread_get_thread_ident(),(long) aSemaphore, waitResult)); return 0; } --- 348,356 ---- DWORD waitResult; ! dprintf(("%ld: PyThread_down_sema(%p) called\n", PyThread_get_thread_ident(), aSemaphore)); waitResult = WaitForSingleObject( (HANDLE) aSemaphore, INFINITE); ! dprintf(("%ld: PyThread_down_sema(%p) return: %l\n", PyThread_get_thread_ident(), aSemaphore, waitResult)); return 0; } *************** *** 363,366 **** NULL); /* not interested in previous count */ ! dprintf(("%ld: PyThread_up_sema(%lx)\n", PyThread_get_thread_ident(), (long)aSemaphore)); } --- 363,366 ---- NULL); /* not interested in previous count */ ! dprintf(("%ld: PyThread_up_sema(%p)\n", PyThread_get_thread_ident(), aSemaphore)); } Index: thread_os2.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_os2.h,v retrieving revision 2.5 retrieving revision 2.6 diff -C2 -r2.5 -r2.6 *** thread_os2.h 1998/12/21 19:32:33 2.5 --- thread_os2.h 2000/06/30 15:01:00 2.6 *************** *** 142,146 **** 0); /* initial state */ ! dprintf(("%ld: PyThread_allocate_lock() -> %lx\n", PyThread_get_thread_ident(), (long)aLock)); return (PyThread_type_lock) aLock; --- 142,146 ---- 0); /* initial state */ ! dprintf(("%ld: PyThread_allocate_lock() -> %p\n", PyThread_get_thread_ident(), aLock)); return (PyThread_type_lock) aLock; *************** *** 149,153 **** void PyThread_free_lock(PyThread_type_lock aLock) { ! dprintf(("%ld: PyThread_free_lock(%lx) called\n", PyThread_get_thread_ident(),(long)aLock)); DosCloseMutexSem((HMTX)aLock); --- 149,153 ---- void PyThread_free_lock(PyThread_type_lock aLock) { ! dprintf(("%ld: PyThread_free_lock(%p) called\n", PyThread_get_thread_ident(),aLock)); DosCloseMutexSem((HMTX)aLock); *************** *** 167,172 **** TID tid = 0; ! dprintf(("%ld: PyThread_acquire_lock(%lx, %d) called\n", PyThread_get_thread_ident(), ! (long)aLock, waitflag)); DosQueryMutexSem((HMTX)aLock,&pid,&tid,&count); --- 167,172 ---- TID tid = 0; ! dprintf(("%ld: PyThread_acquire_lock(%p, %d) called\n", PyThread_get_thread_ident(), ! aLock, waitflag)); DosQueryMutexSem((HMTX)aLock,&pid,&tid,&count); *************** *** 182,187 **** } ! dprintf(("%ld: PyThread_acquire_lock(%lx, %d) -> %d\n", ! PyThread_get_thread_ident(),(long)aLock, waitflag, success)); return success; --- 182,187 ---- } ! dprintf(("%ld: PyThread_acquire_lock(%p, %d) -> %d\n", ! PyThread_get_thread_ident(),aLock, waitflag, success)); return success; *************** *** 190,198 **** void PyThread_release_lock(PyThread_type_lock aLock) { ! dprintf(("%ld: PyThread_release_lock(%lx) called\n", PyThread_get_thread_ident(),(long)aLock)); if ( DosReleaseMutexSem( (HMTX) aLock ) != 0 ) { ! dprintf(("%ld: Could not PyThread_release_lock(%lx) error: %l\n", ! PyThread_get_thread_ident(), (long)aLock, GetLastError())); } } --- 190,198 ---- void PyThread_release_lock(PyThread_type_lock aLock) { ! dprintf(("%ld: PyThread_release_lock(%p) called\n", PyThread_get_thread_ident(),aLock)); if ( DosReleaseMutexSem( (HMTX) aLock ) != 0 ) { ! dprintf(("%ld: Could not PyThread_release_lock(%p) error: %l\n", ! PyThread_get_thread_ident(), aLock, GetLastError())); } } *************** *** 218,221 **** void PyThread_up_sema(PyThread_type_sema aSemaphore) { ! dprintf(("%ld: PyThread_up_sema(%lx)\n", PyThread_get_thread_ident(), (long)aSemaphore)); } --- 218,221 ---- void PyThread_up_sema(PyThread_type_sema aSemaphore) { ! dprintf(("%ld: PyThread_up_sema(%p)\n", PyThread_get_thread_ident(), aSemaphore)); } Index: thread_pth.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_pth.h,v retrieving revision 2.1 retrieving revision 2.2 diff -C2 -r2.1 -r2.2 *** thread_pth.h 2000/05/08 13:36:49 2.1 --- thread_pth.h 2000/06/30 15:01:00 2.2 *************** *** 169,173 **** } } ! dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock)); return (PyThread_type_lock) lock; } --- 169,173 ---- } } ! dprintf(("PyThread_allocate_lock() -> %p\n", lock)); return (PyThread_type_lock) lock; } *************** *** 178,182 **** int status, error = 0; ! dprintf(("PyThread_free_lock(%lx) called\n", (long)lock)); free((void *)thelock); --- 178,182 ---- int status, error = 0; ! dprintf(("PyThread_free_lock(%p) called\n", lock)); free((void *)thelock); *************** *** 189,193 **** int status, error = 0; ! dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag)); status = pth_mutex_acquire(&thelock->mut, !waitflag, NULL); --- 189,193 ---- int status, error = 0; ! dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag)); status = pth_mutex_acquire(&thelock->mut, !waitflag, NULL); *************** *** 216,220 **** } if (error) success = 0; ! dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success)); return success; } --- 216,220 ---- } if (error) success = 0; ! dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success)); return success; } *************** *** 225,229 **** int status, error = 0; ! dprintf(("PyThread_release_lock(%lx) called\n", (long)lock)); status = pth_mutex_acquire( &thelock->mut, 0, NULL ); --- 225,229 ---- int status, error = 0; ! dprintf(("PyThread_release_lock(%p) called\n", lock)); status = pth_mutex_acquire( &thelock->mut, 0, NULL ); *************** *** 271,275 **** } } ! dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema)); return (PyThread_type_sema) sema; } --- 271,275 ---- } } ! dprintf(("PyThread_allocate_sema() -> %p\n", sema)); return (PyThread_type_sema) sema; } *************** *** 280,284 **** struct semaphore *thesema = (struct semaphore *) sema; ! dprintf(("PyThread_free_sema(%lx) called\n", (long) sema)); free((void *) thesema); } --- 280,284 ---- struct semaphore *thesema = (struct semaphore *) sema; ! dprintf(("PyThread_free_sema(%p) called\n", sema)); free((void *) thesema); } *************** *** 289,293 **** struct semaphore *thesema = (struct semaphore *) sema; ! dprintf(("PyThread_down_sema(%lx, %d) called\n", (long) sema, waitflag)); status = pth_mutex_acquire(&thesema->mutex, !waitflag, NULL); CHECK_STATUS("pth_mutex_acquire"); --- 289,293 ---- struct semaphore *thesema = (struct semaphore *) sema; ! dprintf(("PyThread_down_sema(%p, %d) called\n", sema, waitflag)); status = pth_mutex_acquire(&thesema->mutex, !waitflag, NULL); CHECK_STATUS("pth_mutex_acquire"); *************** *** 309,313 **** status = pth_mutex_release(&thesema->mutex); CHECK_STATUS("pth_mutex_release"); ! dprintf(("PyThread_down_sema(%lx) return\n", (long) sema)); return success; } --- 309,313 ---- status = pth_mutex_release(&thesema->mutex); CHECK_STATUS("pth_mutex_release"); ! dprintf(("PyThread_down_sema(%p) return\n", sema)); return success; } *************** *** 318,322 **** struct semaphore *thesema = (struct semaphore *) sema; ! dprintf(("PyThread_up_sema(%lx)\n", (long) sema)); status = pth_mutex_acquire(&thesema->mutex, 0, NULL); CHECK_STATUS("pth_mutex_acquire"); --- 318,322 ---- struct semaphore *thesema = (struct semaphore *) sema; ! dprintf(("PyThread_up_sema(%p)\n", sema)); status = pth_mutex_acquire(&thesema->mutex, 0, NULL); CHECK_STATUS("pth_mutex_acquire"); Index: thread_pthread.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_pthread.h,v retrieving revision 2.24 retrieving revision 2.25 diff -C2 -r2.24 -r2.25 *** thread_pthread.h 1999/03/15 20:27:53 2.24 --- thread_pthread.h 2000/06/30 15:01:00 2.25 *************** *** 273,277 **** } ! dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock)); return (PyThread_type_lock) lock; } --- 273,277 ---- } ! dprintf(("PyThread_allocate_lock() -> %p\n", lock)); return (PyThread_type_lock) lock; } *************** *** 282,286 **** int status, error = 0; ! dprintf(("PyThread_free_lock(%lx) called\n", (long)lock)); status = pthread_mutex_destroy( &thelock->mut ); --- 282,286 ---- int status, error = 0; ! dprintf(("PyThread_free_lock(%p) called\n", lock)); status = pthread_mutex_destroy( &thelock->mut ); *************** *** 299,303 **** int status, error = 0; ! dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag)); status = pthread_mutex_lock( &thelock->mut ); --- 299,303 ---- int status, error = 0; ! dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag)); status = pthread_mutex_lock( &thelock->mut ); *************** *** 326,330 **** } if (error) success = 0; ! dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success)); return success; } --- 326,330 ---- } if (error) success = 0; ! dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success)); return success; } *************** *** 335,339 **** int status, error = 0; ! dprintf(("PyThread_release_lock(%lx) called\n", (long)lock)); status = pthread_mutex_lock( &thelock->mut ); --- 335,339 ---- int status, error = 0; ! dprintf(("PyThread_release_lock(%p) called\n", lock)); status = pthread_mutex_lock( &thelock->mut ); *************** *** 383,387 **** } } ! dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema)); return (PyThread_type_sema) sema; } --- 383,387 ---- } } ! dprintf(("PyThread_allocate_sema() -> %p\n", sema)); return (PyThread_type_sema) sema; } *************** *** 392,396 **** struct semaphore *thesema = (struct semaphore *) sema; ! dprintf(("PyThread_free_sema(%lx) called\n", (long) sema)); status = pthread_cond_destroy(&thesema->cond); CHECK_STATUS("pthread_cond_destroy"); --- 392,396 ---- struct semaphore *thesema = (struct semaphore *) sema; ! dprintf(("PyThread_free_sema(%p) called\n", sema)); status = pthread_cond_destroy(&thesema->cond); CHECK_STATUS("pthread_cond_destroy"); *************** *** 405,409 **** struct semaphore *thesema = (struct semaphore *) sema; ! dprintf(("PyThread_down_sema(%lx, %d) called\n", (long) sema, waitflag)); status = pthread_mutex_lock(&thesema->mutex); CHECK_STATUS("pthread_mutex_lock"); --- 405,409 ---- struct semaphore *thesema = (struct semaphore *) sema; ! dprintf(("PyThread_down_sema(%p, %d) called\n", sema, waitflag)); status = pthread_mutex_lock(&thesema->mutex); CHECK_STATUS("pthread_mutex_lock"); *************** *** 425,429 **** status = pthread_mutex_unlock(&thesema->mutex); CHECK_STATUS("pthread_mutex_unlock"); ! dprintf(("PyThread_down_sema(%lx) return\n", (long) sema)); return success; } --- 425,429 ---- status = pthread_mutex_unlock(&thesema->mutex); CHECK_STATUS("pthread_mutex_unlock"); ! dprintf(("PyThread_down_sema(%p) return\n", sema)); return success; } *************** *** 434,438 **** struct semaphore *thesema = (struct semaphore *) sema; ! dprintf(("PyThread_up_sema(%lx)\n", (long) sema)); status = pthread_mutex_lock(&thesema->mutex); CHECK_STATUS("pthread_mutex_lock"); --- 434,438 ---- struct semaphore *thesema = (struct semaphore *) sema; ! dprintf(("PyThread_up_sema(%p)\n", sema)); status = pthread_mutex_lock(&thesema->mutex); CHECK_STATUS("pthread_mutex_lock"); Index: thread_sgi.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_sgi.h,v retrieving revision 2.9 retrieving revision 2.10 diff -C2 -r2.9 -r2.10 *** thread_sgi.h 1998/12/21 19:32:34 2.9 --- thread_sgi.h 2000/06/30 15:01:00 2.10 *************** *** 120,124 **** perror("usconfig - CONF_INITSIZE (reset)"); addr = (long) dl_getrange(size + HDR_SIZE); ! dprintf(("trying to use addr %lx-%lx for shared arena\n", addr, addr+size)); errno = 0; if ((addr = usconfig(CONF_ATTACHADDR, addr)) < 0 && errno != 0) --- 120,124 ---- perror("usconfig - CONF_INITSIZE (reset)"); addr = (long) dl_getrange(size + HDR_SIZE); ! dprintf(("trying to use addr %p-%p for shared arena\n", addr, addr+size)); errno = 0; if ((addr = usconfig(CONF_ATTACHADDR, addr)) < 0 && errno != 0) *************** *** 158,162 **** if ((wait_lock = usnewlock(shared_arena)) == NULL) perror("usnewlock (wait_lock)"); ! dprintf(("arena start: %lx, arena size: %ld\n", (long) shared_arena, (long) usconfig(CONF_GETSIZE, shared_arena))); } --- 158,162 ---- if ((wait_lock = usnewlock(shared_arena)) == NULL) perror("usnewlock (wait_lock)"); ! dprintf(("arena start: %p, arena size: %ld\n", shared_arena, (long) usconfig(CONF_GETSIZE, shared_arena))); } *************** *** 225,229 **** perror("usconfig - CONF_INITSIZE (reset)"); addr = (long) dl_getrange(size + HDR_SIZE); ! dprintf(("trying to use addr %lx-%lx for sproc\n", addr, addr+size)); errno = 0; --- 225,229 ---- perror("usconfig - CONF_INITSIZE (reset)"); addr = (long) dl_getrange(size + HDR_SIZE); ! dprintf(("trying to use addr %p-%p for sproc\n", addr, addr+size)); errno = 0; *************** *** 376,380 **** perror("usnewlock"); (void) usinitlock(lock); ! dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock)); return (PyThread_type_lock) lock; } --- 376,380 ---- perror("usnewlock"); (void) usinitlock(lock); ! dprintf(("PyThread_allocate_lock() -> %p\n", lock)); return (PyThread_type_lock) lock; } *************** *** 382,386 **** void PyThread_free_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_free_lock(%lx) called\n", (long)lock)); usfreelock((ulock_t) lock, shared_arena); } --- 382,386 ---- void PyThread_free_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_free_lock(%p) called\n", lock)); usfreelock((ulock_t) lock, shared_arena); } *************** *** 390,394 **** int success; ! dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag)); errno = 0; /* clear it just in case */ if (waitflag) --- 390,394 ---- int success; ! dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag)); errno = 0; /* clear it just in case */ if (waitflag) *************** *** 398,402 **** if (success < 0) perror(waitflag ? "ussetlock" : "uscsetlock"); ! dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success)); return success; } --- 398,402 ---- if (success < 0) perror(waitflag ? "ussetlock" : "uscsetlock"); ! dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success)); return success; } *************** *** 404,408 **** void PyThread_release_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_release_lock(%lx) called\n", (long)lock)); if (usunsetlock((ulock_t) lock) < 0) perror("usunsetlock"); --- 404,408 ---- void PyThread_release_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_release_lock(%p) called\n", lock)); if (usunsetlock((ulock_t) lock) < 0) perror("usunsetlock"); *************** *** 421,425 **** if ((sema = usnewsema(shared_arena, value)) == NULL) perror("usnewsema"); ! dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema)); return (PyThread_type_sema) sema; } --- 421,425 ---- if ((sema = usnewsema(shared_arena, value)) == NULL) perror("usnewsema"); ! dprintf(("PyThread_allocate_sema() -> %p\n", sema)); return (PyThread_type_sema) sema; } *************** *** 427,431 **** void PyThread_free_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_free_sema(%lx) called\n", (long) sema)); usfreesema((usema_t *) sema, shared_arena); } --- 427,431 ---- void PyThread_free_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_free_sema(%p) called\n", sema)); usfreesema((usema_t *) sema, shared_arena); } *************** *** 435,439 **** int success; ! dprintf(("PyThread_down_sema(%lx) called\n", (long) sema)); if (waitflag) success = uspsema((usema_t *) sema); --- 435,439 ---- int success; ! dprintf(("PyThread_down_sema(%p) called\n", sema)); if (waitflag) success = uspsema((usema_t *) sema); *************** *** 442,446 **** if (success < 0) perror(waitflag ? "uspsema" : "uscpsema"); ! dprintf(("PyThread_down_sema(%lx) return\n", (long) sema)); return success; } --- 442,446 ---- if (success < 0) perror(waitflag ? "uspsema" : "uscpsema"); ! dprintf(("PyThread_down_sema(%p) return\n", sema)); return success; } *************** *** 448,452 **** void PyThread_up_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_up_sema(%lx)\n", (long) sema)); if (usvsema((usema_t *) sema) < 0) perror("usvsema"); --- 448,452 ---- void PyThread_up_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_up_sema(%p)\n", sema)); if (usvsema((usema_t *) sema) < 0) perror("usvsema"); Index: thread_solaris.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_solaris.h,v retrieving revision 2.10 retrieving revision 2.11 diff -C2 -r2.10 -r2.11 *** thread_solaris.h 1999/04/13 14:32:12 2.10 --- thread_solaris.h 2000/06/30 15:01:00 2.11 *************** *** 158,162 **** lock = 0; } ! dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock)); return (PyThread_type_lock) lock; } --- 158,162 ---- lock = 0; } ! dprintf(("PyThread_allocate_lock() -> %p\n", lock)); return (PyThread_type_lock) lock; } *************** *** 164,168 **** void PyThread_free_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_free_lock(%lx) called\n", (long)lock)); mutex_destroy((mutex_t *) lock); free((void *) lock); --- 164,168 ---- void PyThread_free_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_free_lock(%p) called\n", lock)); mutex_destroy((mutex_t *) lock); free((void *) lock); *************** *** 173,177 **** int success; ! dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag)); if (waitflag) success = mutex_lock((mutex_t *) lock); --- 173,177 ---- int success; ! dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag)); if (waitflag) success = mutex_lock((mutex_t *) lock); *************** *** 182,186 **** else success = !success; /* solaris does it the other way round */ ! dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success)); return success; } --- 182,186 ---- else success = !success; /* solaris does it the other way round */ ! dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success)); return success; } *************** *** 188,192 **** void PyThread_release_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_release_lock(%lx) called\n", (long)lock)); if (mutex_unlock((mutex_t *) lock)) perror("mutex_unlock"); --- 188,192 ---- void PyThread_release_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_release_lock(%p) called\n", lock)); if (mutex_unlock((mutex_t *) lock)) perror("mutex_unlock"); *************** *** 209,213 **** sema = 0; } ! dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema)); return (PyThread_type_sema) sema; } --- 209,213 ---- sema = 0; } ! dprintf(("PyThread_allocate_sema() -> %p\n", sema)); return (PyThread_type_sema) sema; } *************** *** 215,219 **** void PyThread_free_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_free_sema(%lx) called\n", (long) sema)); if (sema_destroy((sema_t *) sema)) perror("sema_destroy"); --- 215,219 ---- void PyThread_free_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_free_sema(%p) called\n", sema)); if (sema_destroy((sema_t *) sema)) perror("sema_destroy"); *************** *** 225,229 **** int success; ! dprintf(("PyThread_down_sema(%lx) called\n", (long) sema)); if (waitflag) success = sema_wait((sema_t *) sema); --- 225,229 ---- int success; ! dprintf(("PyThread_down_sema(%p) called\n", sema)); if (waitflag) success = sema_wait((sema_t *) sema); *************** *** 238,242 **** else success = !success; ! dprintf(("PyThread_down_sema(%lx) return %d\n", (long) sema, success)); return success; } --- 238,242 ---- else success = !success; ! dprintf(("PyThread_down_sema(%p) return %d\n", sema, success)); return success; } *************** *** 244,248 **** void PyThread_up_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_up_sema(%lx)\n", (long) sema)); if (sema_post((sema_t *) sema)) perror("sema_post"); --- 244,248 ---- void PyThread_up_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_up_sema(%p)\n", sema)); if (sema_post((sema_t *) sema)) perror("sema_post"); Index: thread_wince.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_wince.h,v retrieving revision 2.1 retrieving revision 2.2 diff -C2 -r2.1 -r2.2 *** thread_wince.h 1999/04/08 13:57:06 2.1 --- thread_wince.h 2000/06/30 15:01:00 2.2 *************** *** 145,149 **** NULL); /* Name of event */ ! dprintf(("%ld: PyThread_allocate_lock() -> %lx\n", PyThread_get_thread_ident(), (long)aLock)); return (PyThread_type_lock) aLock; --- 145,149 ---- NULL); /* Name of event */ ! dprintf(("%ld: PyThread_allocate_lock() -> %p\n", PyThread_get_thread_ident(), aLock)); return (PyThread_type_lock) aLock; *************** *** 152,156 **** void PyThread_free_lock(PyThread_type_lock aLock) { ! dprintf(("%ld: PyThread_free_lock(%lx) called\n", PyThread_get_thread_ident(),(long)aLock)); CloseHandle(aLock); --- 152,156 ---- void PyThread_free_lock(PyThread_type_lock aLock) { ! dprintf(("%ld: PyThread_free_lock(%p) called\n", PyThread_get_thread_ident(),aLock)); CloseHandle(aLock); *************** *** 168,172 **** DWORD waitResult; ! dprintf(("%ld: PyThread_acquire_lock(%lx, %d) called\n", PyThread_get_thread_ident(),(long)aLock, waitflag)); #ifndef DEBUG --- 168,172 ---- DWORD waitResult; ! dprintf(("%ld: PyThread_acquire_lock(%p, %d) called\n", PyThread_get_thread_ident(),aLock, waitflag)); #ifndef DEBUG *************** *** 186,190 **** } ! dprintf(("%ld: PyThread_acquire_lock(%lx, %d) -> %d\n", PyThread_get_thread_ident(),(long)aLock, waitflag, success)); return success; --- 186,190 ---- } ! dprintf(("%ld: PyThread_acquire_lock(%p, %d) -> %d\n", PyThread_get_thread_ident(),aLock, waitflag, success)); return success; *************** *** 193,200 **** void PyThread_release_lock(PyThread_type_lock aLock) { ! dprintf(("%ld: PyThread_release_lock(%lx) called\n", PyThread_get_thread_ident(),(long)aLock)); if (!SetEvent(aLock)) ! dprintf(("%ld: Could not PyThread_release_lock(%lx) error: %l\n", PyThread_get_thread_ident(), (long)aLock, GetLastError())); } --- 193,200 ---- void PyThread_release_lock(PyThread_type_lock aLock) { ! dprintf(("%ld: PyThread_release_lock(%p) called\n", PyThread_get_thread_ident(),aLock)); if (!SetEvent(aLock)) ! dprintf(("%ld: Could not PyThread_release_lock(%p) error: %l\n", PyThread_get_thread_ident(), aLock, GetLastError())); } From python-dev@python.org Fri Jun 30 16:01:02 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 08:01:02 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects bufferobject.c,2.7,2.8 classobject.c,2.93,2.94 fileobject.c,2.74,2.75 floatobject.c,2.58,2.59 funcobject.c,2.24,2.25 intobject.c,2.42,2.43 methodobject.c,2.27,2.28 object.c,2.75,2.76 Message-ID: <200006301501.IAA13197@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv13110/Objects Modified Files: bufferobject.c classobject.c fileobject.c floatobject.c funcobject.c intobject.c methodobject.c object.c Log Message: Trent Mick : The common technique for printing out a pointer has been to cast to a long and use the "%lx" printf modifier. This is incorrect on Win64 where casting to a long truncates the pointer. The "%p" formatter should be used instead. The problem as stated by Tim: > Unfortunately, the C committee refused to define what %p conversion "looks > like" -- they explicitly allowed it to be implementation-defined. Older > versions of Microsoft C even stuck a colon in the middle of the address (in > the days of segment+offset addressing)! The result is that the hex value of a pointer will maybe/maybe not have a 0x prepended to it. Notes on the patch: There are two main classes of changes: - in the various repr() functions that print out pointers - debugging printf's in the various thread_*.h files (these are why the patch is large) Closes SourceForge patch #100505. Index: bufferobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/bufferobject.c,v retrieving revision 2.7 retrieving revision 2.8 diff -C2 -r2.7 -r2.8 *** bufferobject.c 2000/05/03 23:44:34 2.7 --- bufferobject.c 2000/06/30 15:01:00 2.8 *************** *** 242,259 **** if ( self->b_base == NULL ) { ! sprintf(buf, "<%s buffer ptr %lx, size %d at %lx>", status, ! (long)self->b_ptr, self->b_size, ! (long)self); } else { ! sprintf(buf, "<%s buffer for %lx, ptr %lx, size %d at %lx>", status, ! (long)self->b_base, ! (long)self->b_ptr, self->b_size, ! (long)self); } --- 242,259 ---- if ( self->b_base == NULL ) { ! sprintf(buf, "<%s buffer ptr %p, size %d at %p>", status, ! self->b_ptr, self->b_size, ! self); } else { ! sprintf(buf, "<%s buffer for %p, ptr %p, size %d at %p>", status, ! self->b_base, ! self->b_ptr, self->b_size, ! self); } Index: classobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v retrieving revision 2.93 retrieving revision 2.94 diff -C2 -r2.93 -r2.94 *** classobject.c 2000/06/30 05:02:53 2.93 --- classobject.c 2000/06/30 15:01:00 2.94 *************** *** 354,362 **** name = PyString_AsString(op->cl_name); if (mod == NULL || !PyString_Check(mod)) ! sprintf(buf, "", name, (long)op); else ! sprintf(buf, "", PyString_AsString(mod), ! name, (long)op); return PyString_FromString(buf); } --- 354,362 ---- name = PyString_AsString(op->cl_name); if (mod == NULL || !PyString_Check(mod)) ! sprintf(buf, "", name, op); else ! sprintf(buf, "", PyString_AsString(mod), ! name, op); return PyString_FromString(buf); } *************** *** 806,815 **** PyErr_Clear(); if (mod == NULL || !PyString_Check(mod)) ! sprintf(buf, "", ! cname, (long)inst); else ! sprintf(buf, "<%.50s.%.50s instance at %lx>", PyString_AsString(mod), ! cname, (long)inst); return PyString_FromString(buf); } --- 806,815 ---- PyErr_Clear(); if (mod == NULL || !PyString_Check(mod)) ! sprintf(buf, "", ! cname, inst); else ! sprintf(buf, "<%.50s.%.50s instance at %p>", PyString_AsString(mod), ! cname, inst); return PyString_FromString(buf); } *************** *** 1705,1710 **** else icname = "?"; ! sprintf(buf, "", ! fcname, fname, icname, (long)self); } Py_XDECREF(funcname); --- 1705,1710 ---- else icname = "?"; ! sprintf(buf, "", ! fcname, fname, icname, self); } Py_XDECREF(funcname); Index: fileobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/fileobject.c,v retrieving revision 2.74 retrieving revision 2.75 diff -C2 -r2.74 -r2.75 *** fileobject.c 2000/06/28 20:57:07 2.74 --- fileobject.c 2000/06/30 15:01:00 2.75 *************** *** 241,249 **** { char buf[300]; ! sprintf(buf, "<%s file '%.256s', mode '%.10s' at %lx>", f->f_fp == NULL ? "closed" : "open", PyString_AsString(f->f_name), PyString_AsString(f->f_mode), ! (long)f); return PyString_FromString(buf); } --- 241,249 ---- { char buf[300]; ! sprintf(buf, "<%s file '%.256s', mode '%.10s' at %p>", f->f_fp == NULL ? "closed" : "open", PyString_AsString(f->f_name), PyString_AsString(f->f_mode), ! f); return PyString_FromString(buf); } Index: floatobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/floatobject.c,v retrieving revision 2.58 retrieving revision 2.59 diff -C2 -r2.58 -r2.59 *** floatobject.c 2000/06/29 19:17:04 2.58 --- floatobject.c 2000/06/30 15:01:00 2.59 *************** *** 807,812 **** PyFloat_AsString(buf, p); fprintf(stderr, ! "# \n", ! (long)p, p->ob_refcnt, buf); } } --- 807,812 ---- PyFloat_AsString(buf, p); fprintf(stderr, ! "# \n", ! p, p->ob_refcnt, buf); } } Index: funcobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/funcobject.c,v retrieving revision 2.24 retrieving revision 2.25 diff -C2 -r2.24 -r2.25 *** funcobject.c 2000/06/30 05:02:53 2.24 --- funcobject.c 2000/06/30 15:01:00 2.25 *************** *** 203,211 **** char buf[140]; if (op->func_name == Py_None) ! sprintf(buf, "", (long)op); else ! sprintf(buf, "", PyString_AsString(op->func_name), ! (long)op); return PyString_FromString(buf); } --- 203,211 ---- char buf[140]; if (op->func_name == Py_None) ! sprintf(buf, "", op); else ! sprintf(buf, "", PyString_AsString(op->func_name), ! op); return PyString_FromString(buf); } Index: intobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/intobject.c,v retrieving revision 2.42 retrieving revision 2.43 diff -C2 -r2.42 -r2.43 *** intobject.c 2000/05/09 14:27:48 2.42 --- intobject.c 2000/06/30 15:01:00 2.43 *************** *** 958,963 **** if (PyInt_Check(p) && p->ob_refcnt != 0) fprintf(stderr, ! "# \n", ! (long)p, p->ob_refcnt, p->ob_ival); } list = list->next; --- 958,963 ---- if (PyInt_Check(p) && p->ob_refcnt != 0) fprintf(stderr, ! "# \n", ! p, p->ob_refcnt, p->ob_ival); } list = list->next; Index: methodobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/methodobject.c,v retrieving revision 2.27 retrieving revision 2.28 diff -C2 -r2.27 -r2.28 *** methodobject.c 2000/06/29 19:17:04 2.27 --- methodobject.c 2000/06/30 15:01:00 2.28 *************** *** 149,155 **** else sprintf(buf, ! "", m->m_ml->ml_name, m->m_self->ob_type->tp_name, ! (long)m->m_self); return PyString_FromString(buf); } --- 149,155 ---- else sprintf(buf, ! "", m->m_ml->ml_name, m->m_self->ob_type->tp_name, ! m->m_self); return PyString_FromString(buf); } Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.75 retrieving revision 2.76 diff -C2 -r2.75 -r2.76 *** object.c 2000/06/30 05:02:53 2.75 --- object.c 2000/06/30 15:01:00 2.76 *************** *** 230,239 **** else { if (op->ob_refcnt <= 0) ! fprintf(fp, "", ! op->ob_refcnt, (long)op); else if (op->ob_type->tp_print == NULL) { if (op->ob_type->tp_repr == NULL) { ! fprintf(fp, "<%s object at %lx>", ! op->ob_type->tp_name, (long)op); } else { --- 230,239 ---- else { if (op->ob_refcnt <= 0) ! fprintf(fp, "", ! op->ob_refcnt, op); else if (op->ob_type->tp_print == NULL) { if (op->ob_type->tp_repr == NULL) { ! fprintf(fp, "<%s object at %p>", ! op->ob_type->tp_name, op); } else { *************** *** 281,286 **** else if (v->ob_type->tp_repr == NULL) { char buf[120]; ! sprintf(buf, "<%.80s object at %lx>", ! v->ob_type->tp_name, (long)v); return PyString_FromString(buf); } --- 281,286 ---- else if (v->ob_type->tp_repr == NULL) { char buf[120]; ! sprintf(buf, "<%.80s object at %p>", ! v->ob_type->tp_name, v); return PyString_FromString(buf); } From python-dev@python.org Fri Jun 30 16:01:02 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 08:01:02 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _tkinter.c,1.101,1.102 flmodule.c,1.36,1.37 mpzmodule.c,2.24,2.25 Message-ID: <200006301501.IAA13165@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv13110/Modules Modified Files: _tkinter.c flmodule.c mpzmodule.c Log Message: Trent Mick : The common technique for printing out a pointer has been to cast to a long and use the "%lx" printf modifier. This is incorrect on Win64 where casting to a long truncates the pointer. The "%p" formatter should be used instead. The problem as stated by Tim: > Unfortunately, the C committee refused to define what %p conversion "looks > like" -- they explicitly allowed it to be implementation-defined. Older > versions of Microsoft C even stuck a colon in the middle of the address (in > the days of segment+offset addressing)! The result is that the hex value of a pointer will maybe/maybe not have a 0x prepended to it. Notes on the patch: There are two main classes of changes: - in the various repr() functions that print out pointers - debugging printf's in the various thread_*.h files (these are why the patch is large) Closes SourceForge patch #100505. Index: _tkinter.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_tkinter.c,v retrieving revision 1.101 retrieving revision 1.102 diff -C2 -r1.101 -r1.102 *** _tkinter.c 2000/06/19 00:55:09 1.101 --- _tkinter.c 2000/06/30 15:00:59 1.102 *************** *** 1706,1710 **** char buf[100]; ! sprintf(buf, "", (long)v, v->func == NULL ? ", handler deleted" : ""); return PyString_FromString(buf); --- 1706,1710 ---- char buf[100]; ! sprintf(buf, "", v, v->func == NULL ? ", handler deleted" : ""); return PyString_FromString(buf); Index: flmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/flmodule.c,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -r1.36 -r1.37 *** flmodule.c 2000/05/03 23:44:32 1.36 --- flmodule.c 2000/06/30 15:00:59 1.37 *************** *** 436,441 **** { char buf[100]; ! sprintf(buf, "", ! (long)g, g->ob_generic->objclass); return PyString_FromString(buf); } --- 436,441 ---- { char buf[100]; ! sprintf(buf, "", ! g, g->ob_generic->objclass); return PyString_FromString(buf); } *************** *** 1907,1912 **** { char buf[100]; ! sprintf(buf, "", ! (long)f, f->ob_form->window); return PyString_FromString(buf); } --- 1907,1912 ---- { char buf[100]; ! sprintf(buf, "", ! f, f->ob_form->window); return PyString_FromString(buf); } Index: mpzmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/mpzmodule.c,v retrieving revision 2.24 retrieving revision 2.25 diff -C2 -r2.24 -r2.25 *** mpzmodule.c 2000/06/28 21:29:47 2.24 --- mpzmodule.c 2000/06/30 15:00:59 2.25 *************** *** 263,267 **** #ifdef MPZ_DEBUG fprintf(stderr, ! "mpz_format: cp (str end) 0x%x, begin 0x%x, diff %d, i %d\n", cp, PyString_AS_STRING(strobjp), cp - PyString_AS_STRING(strobjp), i); --- 263,267 ---- #ifdef MPZ_DEBUG fprintf(stderr, ! "mpz_format: cp (str end) %p, begin %p, diff %d, i %d\n", cp, PyString_AS_STRING(strobjp), cp - PyString_AS_STRING(strobjp), i); *************** *** 1766,1770 **** #ifdef MPZ_DEBUG ! fprintf(stderr, "mp_allocate : address 0x%08x\n", res); #endif /* def MPZ_DEBUG */ --- 1766,1770 ---- #ifdef MPZ_DEBUG ! fprintf(stderr, "mp_allocate : address %08p\n", res); #endif /* def MPZ_DEBUG */ *************** *** 1783,1787 **** #ifdef MPZ_DEBUG ! fprintf(stderr, "mp_reallocate: old address 0x%08x, old size %ld\n", ptr, old_size); #endif /* def MPZ_DEBUG */ --- 1783,1787 ---- #ifdef MPZ_DEBUG ! fprintf(stderr, "mp_reallocate: old address %08p, old size %ld\n", ptr, old_size); #endif /* def MPZ_DEBUG */ *************** *** 1793,1797 **** #ifdef MPZ_DEBUG ! fprintf(stderr, "mp_reallocate: new address 0x%08x, new size %ld\n", res, new_size); #endif /* def MPZ_DEBUG */ --- 1793,1797 ---- #ifdef MPZ_DEBUG ! fprintf(stderr, "mp_reallocate: new address %08p, new size %ld\n", res, new_size); #endif /* def MPZ_DEBUG */ *************** *** 1809,1813 **** #ifdef MPZ_DEBUG ! fprintf(stderr, "mp_free : old address 0x%08x, old size %ld\n", ptr, size); #endif /* def MPZ_DEBUG */ --- 1809,1813 ---- #ifdef MPZ_DEBUG ! fprintf(stderr, "mp_free : old address %08p, old size %ld\n", ptr, size); #endif /* def MPZ_DEBUG */ From python-dev@python.org Fri Jun 30 16:13:24 2000 From: python-dev@python.org (Jeremy Hylton) Date: Fri, 30 Jun 2000 08:13:24 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_gc,1.1,1.2 Message-ID: <200006301513.IAA19999@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv19979/Lib/test/output Modified Files: test_gc Log Message: remove all prints (since the prints where of memory locations) Index: test_gc =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_gc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** test_gc 2000/06/30 05:02:53 1.1 --- test_gc 2000/06/30 15:13:15 1.2 *************** *** 1,11 **** test_gc - list 0x831a754 - dict 0x831a754 - list 0x831a754 - tuple 0x831a734 - class 0x831a794 - - a - b - dict 0x831a9bc - func 0x831d9e4 --- 1 ---- From python-dev@python.org Fri Jun 30 16:13:24 2000 From: python-dev@python.org (Jeremy Hylton) Date: Fri, 30 Jun 2000 08:13:24 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_gc.py,1.1,1.2 Message-ID: <200006301513.IAA20000@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv19979/Lib/test Modified Files: test_gc.py Log Message: remove all prints (since the prints where of memory locations) Index: test_gc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_gc.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** test_gc.py 2000/06/30 05:02:53 1.1 --- test_gc.py 2000/06/30 15:13:14 1.2 *************** *** 4,8 **** l = [] l.append(l) - print 'list 0x%x' % id(l) gc.collect() del l --- 4,7 ---- *************** *** 12,16 **** d = {} d[1] = d - print 'dict 0x%x' % id(d) gc.collect() del d --- 11,14 ---- *************** *** 21,26 **** t = (l,) l.append(t) - print 'list 0x%x' % id(l) - print 'tuple 0x%x' % id(t) gc.collect() del t --- 19,22 ---- *************** *** 32,36 **** pass A.a = A - print 'class 0x%x' % id(A) gc.collect() del A --- 28,31 ---- *************** *** 42,46 **** a = A() a.a = a - print repr(a) gc.collect() del a --- 37,40 ---- *************** *** 66,71 **** b = B() b.b = b - print 'a', repr(a) - print 'b', repr(b) gc.collect() gc.garbage[:] = [] --- 60,63 ---- *************** *** 78,83 **** d = {} exec("def f(): pass\n") in d - print 'dict 0x%x' % id(d) - print 'func 0x%x' % id(d['f']) gc.collect() del d --- 70,73 ---- *************** *** 86,91 **** def test_all(): - debug = gc.get_debug() - gc.set_debug(gc.DEBUG_LEAK | gc.DEBUG_STATS) test_list() test_dict() --- 76,79 ---- *************** *** 96,100 **** test_finalizer() test_function() - gc.set_debug(debug) test_all() --- 84,87 ---- From python-dev@python.org Fri Jun 30 16:30:35 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 08:30:35 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/html index.html.in,1.6,1.7 Message-ID: <200006301530.IAA21763@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/html In directory slayer.i.sourceforge.net:/tmp/cvs-serv21746/html Modified Files: index.html.in Log Message: Fix an icon width; a "32" became a "3" somehow, and that did not look as nice. ;) Index: index.html.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/html/index.html.in,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** index.html.in 2000/04/28 17:43:12 1.6 --- index.html.in 2000/06/30 15:30:33 1.7 *************** *** 11,15 **** ! !
Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv21882/lib Modified Files: librandom.tex Log Message: Document randrange(). Index: librandom.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/librandom.tex,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** librandom.tex 2000/04/03 20:13:54 1.13 --- librandom.tex 2000/06/30 15:32:31 1.14 *************** *** 114,117 **** --- 114,118 ---- \begin{funcdesc}{randint}{a, b} + \deprecated{2.0}{Use \function{randrange()} instead.} Returns a random integer \var{N} such that \code{\var{a} <= \var{N} <= \var{b}}. *************** *** 121,124 **** --- 122,132 ---- Returns the next random floating point number in the range [0.0 ... 1.0). + \end{funcdesc} + + \begin{funcdesc}{randrange}{\optional{start,} stop\optional{, step}} + Return a randomly selected element from \code{range(\var{start}, + \var{stop}, \var{step})}. This is equivalent to + \code{choice(range(\var{start}, \var{stop}, \var{step}))}. + \versionadded{1.5.2} \end{funcdesc} From python-dev@python.org Fri Jun 30 16:35:18 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 08:35:18 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/texinputs boilerplate.tex,1.40,1.41 Message-ID: <200006301535.IAA22310@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/texinputs In directory slayer.i.sourceforge.net:/tmp/cvs-serv22299/texinputs Modified Files: boilerplate.tex Log Message: Update the release number & date, Guido's employer. Index: boilerplate.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/texinputs/boilerplate.tex,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -r1.40 -r1.41 *** boilerplate.tex 2000/04/03 04:13:48 1.40 --- boilerplate.tex 2000/06/30 15:35:16 1.41 *************** *** 2,10 **** \authoraddress{ ! Corporation for National Research Initiatives \\ ! 1895 Preston White Drive, Reston, VA 20191, USA \\ E-mail: \email{guido@python.org} } ! \date{\today} % XXX update before release! ! \release{1.6} --- 2,9 ---- \authoraddress{ ! BeOpen PythonLabs \\ E-mail: \email{guido@python.org} } ! \date{July 1, 2000} % XXX update before release! ! \release{2.0b1} From python-dev@python.org Fri Jun 30 16:46:10 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 08:46:10 -0700 Subject: [Python-checkins] CVS: python/dist/src Makefile.in,1.87,1.88 Message-ID: <200006301546.IAA23433@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv23418 Modified Files: Makefile.in Log Message: Martin von Löwis : Do not forget to install the xml packages! Index: Makefile.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.in,v retrieving revision 1.87 retrieving revision 1.88 diff -C2 -r1.87 -r1.88 *** Makefile.in 2000/06/10 23:08:21 1.87 --- Makefile.in 2000/06/30 15:46:08 1.88 *************** *** 290,295 **** PLATDIR= plat-$(MACHDEP) MACHDEPS= $(PLATDIR) LIBSUBDIRS= lib-old lib-tk site-packages test test/output encodings \ ! distutils distutils/command curses $(MACHDEPS) libinstall: python $(srcdir)/Lib/$(PLATDIR) @for i in $(SCRIPTDIR) $(LIBDEST); \ --- 290,296 ---- PLATDIR= plat-$(MACHDEP) MACHDEPS= $(PLATDIR) + XMLLIBSUBDIRS= xml xml/dom xml/parser xml/sax LIBSUBDIRS= lib-old lib-tk site-packages test test/output encodings \ ! distutils distutils/command $(XMLLIBSUBDIRS) curses $(MACHDEPS) libinstall: python $(srcdir)/Lib/$(PLATDIR) @for i in $(SCRIPTDIR) $(LIBDEST); \ From python-dev@python.org Fri Jun 30 16:47:04 2000 From: python-dev@python.org (Mark Hammond) Date: Fri, 30 Jun 2000 08:47:04 -0700 Subject: [Python-checkins] CVS: python/dist/src/PC config.h,1.39,1.40 Message-ID: <200006301547.IAA23471@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv23462 Modified Files: config.h Log Message: Python's .lib is now named Python20.lib Index: config.h =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/config.h,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -r1.39 -r1.40 *** config.h 2000/06/30 05:02:53 1.39 --- config.h 2000/06/30 15:47:02 1.40 *************** *** 289,295 **** /* So nobody needs to specify the .lib in their Makefile any more */ #ifdef _DEBUG ! #pragma comment(lib,"python16_d.lib") #else ! #pragma comment(lib,"python16.lib") #endif #endif /* USE_DL_EXPORT */ --- 289,295 ---- /* So nobody needs to specify the .lib in their Makefile any more */ #ifdef _DEBUG ! #pragma comment(lib,"python20_d.lib") #else ! #pragma comment(lib,"python20.lib") #endif #endif /* USE_DL_EXPORT */ From python-dev@python.org Fri Jun 30 16:52:41 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 08:52:41 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/api api.tex,1.70,1.71 Message-ID: <200006301552.IAA23907@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/api In directory slayer.i.sourceforge.net:/tmp/cvs-serv23897 Modified Files: api.tex Log Message: Uncomment some additions from Vladimir pertinent to 2.0 but not 1.5.2. Index: api.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/api.tex,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -r1.70 -r1.71 *** api.tex 2000/06/29 20:15:14 1.70 --- api.tex 2000/06/30 15:52:39 1.71 *************** *** 4293,4304 **** \cfunction{PyObject_NEW_VAR()}\ttindex{PyObject_NEW_VAR()}. ! % XXX use this for Python 1.6: ! % \cfunction{_PyObject_New()}, \cfunction{_PyObject_NewVar()}, ! % \cfunction{_PyObject_Del()}, or with their corresponding macros ! % \cfunction{PyObject_NEW()}, \cfunction{PyObject_NEW_VAR()}, ! % \cfunction{PyObject_DEL()}. ! % These will be explained in the next chapter on defining and ! % implementing new object types in C. --- 4293,4303 ---- \cfunction{PyObject_NEW_VAR()}\ttindex{PyObject_NEW_VAR()}. ! \cfunction{_PyObject_New()}, \cfunction{_PyObject_NewVar()}, ! \cfunction{_PyObject_Del()}, or with their corresponding macros ! \cfunction{PyObject_NEW()}, \cfunction{PyObject_NEW_VAR()}, ! \cfunction{PyObject_DEL()}. ! These will be explained in the next chapter on defining and ! implementing new object types in C. From python-dev@python.org Fri Jun 30 16:54:20 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 08:54:20 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/doc doc.tex,1.20,1.21 Message-ID: <200006301554.IAA23981@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/doc In directory slayer.i.sourceforge.net:/tmp/cvs-serv23974 Modified Files: doc.tex Log Message: Update authors email address and corporate affiliation. Index: doc.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/doc/doc.tex,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -r1.20 -r1.21 *** doc.tex 2000/05/02 17:43:44 1.20 --- doc.tex 2000/06/30 15:54:18 1.21 *************** *** 11,17 **** \author{Fred L. Drake, Jr.} \authoraddress{ ! Corporation for National Research Initiatives (CNRI) \\ ! 1895 Preston White Drive, Reston, Va 20191, USA \\ ! E-mail: \email{fdrake@acm.org} } --- 11,16 ---- \author{Fred L. Drake, Jr.} \authoraddress{ ! BeOpen PythonLabs \\ ! E-mail: \email{fdrake@beopen.com} } From python-dev@python.org Fri Jun 30 17:02:26 2000 From: python-dev@python.org (Barry Warsaw) Date: Fri, 30 Jun 2000 09:02:26 -0700 Subject: [Python-checkins] CVS: python/dist/src acconfig.h,1.30,1.31 Message-ID: <200006301602.JAA26036@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv25996 Modified Files: acconfig.h Log Message: Added #undef of WITH_CYCLE_GC for autoconf's delight. Index: acconfig.h =================================================================== RCS file: /cvsroot/python/python/dist/src/acconfig.h,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -r1.30 -r1.31 *** acconfig.h 2000/06/29 20:44:46 1.30 --- acconfig.h 2000/06/30 16:02:24 1.31 *************** *** 145,148 **** --- 145,151 ---- #undef WITH_THREAD + /* Define if you want to compile in cycle garbage collection */ + #undef WITH_CYCLE_GC + /* Define if you want to produce an OpenStep/Rhapsody framework (shared library plus accessory files). */ From python-dev@python.org Fri Jun 30 17:03:00 2000 From: python-dev@python.org (Barry Warsaw) Date: Fri, 30 Jun 2000 09:03:00 -0700 Subject: [Python-checkins] CVS: python/dist/src config.h.in,2.60,2.61 Message-ID: <200006301603.JAA26426@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv26375 Modified Files: config.h.in Log Message: Added #undef of WITH_CYCLE_GC for autoconf's delight. Index: config.h.in =================================================================== RCS file: /cvsroot/python/python/dist/src/config.h.in,v retrieving revision 2.60 retrieving revision 2.61 diff -C2 -r2.60 -r2.61 *** config.h.in 2000/06/30 04:57:55 2.60 --- config.h.in 2000/06/30 16:02:58 2.61 *************** *** 207,216 **** #undef WITH_THREAD /* Define if you want to produce an OpenStep/Rhapsody framework (shared library plus accessory files). */ #undef WITH_NEXT_FRAMEWORK - - /* Define if you want cycle garbage collection */ - #undef WITH_CYCLE_GC /* The number of bytes in an off_t. */ --- 207,216 ---- #undef WITH_THREAD + /* Define if you want to compile in cycle garbage collection */ + #undef WITH_CYCLE_GC + /* Define if you want to produce an OpenStep/Rhapsody framework (shared library plus accessory files). */ #undef WITH_NEXT_FRAMEWORK /* The number of bytes in an off_t. */ From python-dev@python.org Fri Jun 30 17:03:29 2000 From: python-dev@python.org (Barry Warsaw) Date: Fri, 30 Jun 2000 09:03:29 -0700 Subject: [Python-checkins] CVS: python/dist/src Makefile.in,1.88,1.89 Message-ID: <200006301603.JAA26558@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv26517 Modified Files: Makefile.in Log Message: Setup.thread => Setup.config Index: Makefile.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.in,v retrieving revision 1.88 retrieving revision 1.89 diff -C2 -r1.88 -r1.89 *** Makefile.in 2000/06/30 15:46:08 1.88 --- Makefile.in 2000/06/30 16:03:26 1.89 *************** *** 403,407 **** $(INSTALL_DATA) Modules/Setup $(LIBPL)/Setup $(INSTALL_DATA) Modules/Setup.local $(LIBPL)/Setup.local ! $(INSTALL_DATA) Modules/Setup.thread $(LIBPL)/Setup.thread $(INSTALL_PROGRAM) $(srcdir)/Modules/makesetup $(LIBPL)/makesetup $(INSTALL_PROGRAM) $(srcdir)/install-sh $(LIBPL)/install-sh --- 403,407 ---- $(INSTALL_DATA) Modules/Setup $(LIBPL)/Setup $(INSTALL_DATA) Modules/Setup.local $(LIBPL)/Setup.local ! $(INSTALL_DATA) Modules/Setup.config $(LIBPL)/Setup.config $(INSTALL_PROGRAM) $(srcdir)/Modules/makesetup $(LIBPL)/makesetup $(INSTALL_PROGRAM) $(srcdir)/install-sh $(LIBPL)/install-sh From python-dev@python.org Fri Jun 30 17:03:57 2000 From: python-dev@python.org (Barry Warsaw) Date: Fri, 30 Jun 2000 09:03:57 -0700 Subject: [Python-checkins] CVS: python/dist/src/Misc Makefile.pre.in,1.16,1.17 Message-ID: <200006301603.JAA27164@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Misc In directory slayer.i.sourceforge.net:/tmp/cvs-serv27058 Modified Files: Makefile.pre.in Log Message: Setup.thread => Setup.config Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/Makefile.pre.in,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** Makefile.pre.in 1998/12/09 17:05:33 1.16 --- Makefile.pre.in 2000/06/30 16:03:53 1.17 *************** *** 169,173 **** CONFIGC= $(LIBPL)/config.c CONFIGCIN= $(LIBPL)/config.c.in ! SETUP= $(LIBPL)/Setup.thread $(LIBPL)/Setup.local $(LIBPL)/Setup SYSLIBS= $(LIBM) $(LIBC) --- 169,173 ---- CONFIGC= $(LIBPL)/config.c CONFIGCIN= $(LIBPL)/config.c.in ! SETUP= $(LIBPL)/Setup.config $(LIBPL)/Setup.local $(LIBPL)/Setup SYSLIBS= $(LIBM) $(LIBC) From python-dev@python.org Fri Jun 30 17:04:21 2000 From: python-dev@python.org (Barry Warsaw) Date: Fri, 30 Jun 2000 09:04:21 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules Makefile.pre.in,1.62,1.63 Message-ID: <200006301604.JAA27553@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv27536 Modified Files: Makefile.pre.in Log Message: Setup.thread => Setup.config Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Makefile.pre.in,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -r1.62 -r1.63 *** Makefile.pre.in 2000/06/28 16:42:14 1.62 --- Makefile.pre.in 2000/06/30 16:04:18 1.63 *************** *** 148,155 **** # longer pertinent (but that were in a previous configuration). config.c Makefile: Makefile.pre config.c.in $(MAKESETUP) ! config.c Makefile: Setup.thread Setup Setup.local config.c Makefile: -rm -f $(LIBRARY) ! $(SHELL) $(MAKESETUP) Setup.thread Setup.local Setup hassignal: --- 148,155 ---- # longer pertinent (but that were in a previous configuration). config.c Makefile: Makefile.pre config.c.in $(MAKESETUP) ! config.c Makefile: Setup.config Setup Setup.local config.c Makefile: -rm -f $(LIBRARY) ! $(SHELL) $(MAKESETUP) Setup.config Setup.local Setup hassignal: From python-dev@python.org Fri Jun 30 17:05:24 2000 From: python-dev@python.org (Barry Warsaw) Date: Fri, 30 Jun 2000 09:05:24 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules Setup.in,1.105,1.106 Message-ID: <200006301605.JAA28397@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv28326 Modified Files: Setup.in Log Message: Removed the comment about the thread module. Index: Setup.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Setup.in,v retrieving revision 1.105 retrieving revision 1.106 diff -C2 -r1.105 -r1.106 *** Setup.in 2000/06/29 14:40:45 1.105 --- Setup.in 2000/06/30 16:05:22 1.106 *************** *** 101,106 **** #gl glmodule.c cgensupport.c -I$(srcdir) $(GLHACK) -lgl -lX11 - # The thread module is now automatically enabled, see Setup.thread. - # Pure module. Cannot be linked dynamically. # -DWITH_QUANTIFY, -DWITH_PURIFY, or -DWITH_ALL_PURE --- 101,104 ---- From python-dev@python.org Fri Jun 30 17:06:21 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 09:06:21 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc Makefile,1.195,1.196 Message-ID: <200006301606.JAA28615@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc In directory slayer.i.sourceforge.net:/tmp/cvs-serv28564 Modified Files: Makefile Log Message: Update version numbering from 1.6 to 2.0. Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile,v retrieving revision 1.195 retrieving revision 1.196 diff -C2 -r1.195 -r1.196 *** Makefile 2000/04/28 17:09:17 1.195 --- Makefile 2000/06/30 16:06:19 1.196 *************** *** 62,66 **** # This is the *documentation* release, and is used to construct the file # names of the downloadable tarballs. ! RELEASE=1.6a2 --- 62,66 ---- # This is the *documentation* release, and is used to construct the file # names of the downloadable tarballs. ! RELEASE=2.0b1 From python-dev@python.org Fri Jun 30 17:06:21 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 09:06:21 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libascii.tex,1.2,1.3 libatexit.tex,1.2,1.3 libexcs.tex,1.29,1.30 libfuncs.tex,1.65,1.66 libos.tex,1.41,1.42 libstdtypes.tex,1.22,1.23 libsys.tex,1.36,1.37 libtempfile.tex,1.14,1.15 libundoc.tex,1.73,1.74 Message-ID: <200006301606.JAA28639@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv28564/lib Modified Files: libascii.tex libatexit.tex libexcs.tex libfuncs.tex libos.tex libstdtypes.tex libsys.tex libtempfile.tex libundoc.tex Log Message: Update version numbering from 1.6 to 2.0. Index: libascii.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libascii.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** libascii.tex 2000/06/28 22:03:29 1.2 --- libascii.tex 2000/06/30 16:06:19 1.3 *************** *** 8,12 **** \sectionauthor{Eric S. Raymond}{esr@thyrsus.com} ! \versionadded{1.6} The \module{curses.ascii} module supplies name constants for --- 8,12 ---- \sectionauthor{Eric S. Raymond}{esr@thyrsus.com} ! \versionadded{2.0} The \module{curses.ascii} module supplies name constants for Index: libatexit.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libatexit.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** libatexit.tex 2000/06/28 22:07:55 1.2 --- libatexit.tex 2000/06/30 16:06:19 1.3 *************** *** 7,11 **** \modulesynopsis{Register and execute cleanup functions.} ! \versionadded{1.6} The \module{atexit} module defines a single function to register --- 7,11 ---- \modulesynopsis{Register and execute cleanup functions.} ! \versionadded{2.0} The \module{atexit} module defines a single function to register Index: libexcs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libexcs.tex,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -r1.29 -r1.30 *** libexcs.tex 2000/04/17 17:42:00 1.29 --- libexcs.tex 2000/06/30 16:06:19 1.30 *************** *** 299,303 **** method, but no value has been bound to that variable. This is a subclass of \exception{NameError}. ! \versionadded{1.6} \end{excdesc} --- 299,303 ---- method, but no value has been bound to that variable. This is a subclass of \exception{NameError}. ! \versionadded{2.0} \end{excdesc} *************** *** 305,309 **** Raised when a Unicode-related encoding or decoding error occurs. It is a subclass of \exception{ValueError}. ! \versionadded{1.6} \end{excdesc} --- 305,309 ---- Raised when a Unicode-related encoding or decoding error occurs. It is a subclass of \exception{ValueError}. ! \versionadded{2.0} \end{excdesc} *************** *** 322,326 **** \cfunction{FormatMessage()} functions from the Windows Platform API. This is a subclass of \exception{OSError}. ! \versionadded{1.6} \end{excdesc} --- 322,326 ---- \cfunction{FormatMessage()} functions from the Windows Platform API. This is a subclass of \exception{OSError}. ! \versionadded{2.0} \end{excdesc} Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -r1.65 -r1.66 *** libfuncs.tex 2000/06/29 03:46:46 1.65 --- libfuncs.tex 2000/06/30 16:06:19 1.66 *************** *** 670,674 **** strings. The argument must be in the range [0..65535], inclusive. \exception{ValueError} is raised otherwise. ! \versionadded{1.6} \end{funcdesc} --- 670,674 ---- strings. The argument must be in the range [0..65535], inclusive. \exception{ValueError} is raised otherwise. ! \versionadded{2.0} \end{funcdesc} *************** *** 678,682 **** to decode UTF-8 in strict mode, meaning that encoding errors raise \exception{ValueError}. ! \versionadded{1.6} \end{funcdesc} --- 678,682 ---- to decode UTF-8 in strict mode, meaning that encoding errors raise \exception{ValueError}. ! \versionadded{2.0} \end{funcdesc} Index: libos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -r1.41 -r1.42 *** libos.tex 2000/06/28 17:27:48 1.41 --- libos.tex 2000/06/30 16:06:19 1.42 *************** *** 717,721 **** 2-tuple of numbers, of the form \code{(\var{atime}, \var{mtime})} which is used to set the access and modified times, respectively. ! \versionchanged[added support for \code{None} for \var{times}]{1.6} Availability: Macintosh, \UNIX{}, Windows. \end{funcdesc} --- 717,721 ---- 2-tuple of numbers, of the form \code{(\var{atime}, \var{mtime})} which is used to set the access and modified times, respectively. ! \versionchanged[added support for \code{None} for \var{times}]{2.0} Availability: Macintosh, \UNIX{}, Windows. \end{funcdesc} Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** libstdtypes.tex 2000/04/03 20:13:54 1.22 --- libstdtypes.tex 2000/06/30 16:06:19 1.23 *************** *** 497,501 **** \item[(1)] The C implementation of Python has historically accepted multiple parameters and implicitly joined them into a tuple; this ! will no longer work in Python 1.6. Use of this misfeature has been deprecated since Python 1.4. --- 497,501 ---- \item[(1)] The C implementation of Python has historically accepted multiple parameters and implicitly joined them into a tuple; this ! no longer works in Python 2.0. Use of this misfeature has been deprecated since Python 1.4. Index: libsys.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsys.tex,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -r1.36 -r1.37 *** libsys.tex 2000/06/28 15:07:30 1.36 --- libsys.tex 2000/06/30 16:06:19 1.37 *************** *** 335,341 **** release level is \code{'alpha'}, \code{'beta'}, \code{'candidate'}, or \code{'final'}. The \code{version_info} value ! corresponding to the Python version 1.6 is ! \code{(1, 6, 0, 'final', 0)}. ! \versionadded{1.6} \end{datadesc} --- 335,341 ---- release level is \code{'alpha'}, \code{'beta'}, \code{'candidate'}, or \code{'final'}. The \code{version_info} value ! corresponding to the Python version 2.0 is ! \code{(2, 0, 0, 'final', 0)}. ! \versionadded{2.0} \end{datadesc} Index: libtempfile.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libtempfile.tex,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** libtempfile.tex 2000/05/26 19:32:14 1.14 --- libtempfile.tex 2000/06/30 16:06:19 1.15 *************** *** 64,68 **** \begin{datadesc}{template} ! \deprecated{1.6}{Use \function{gettempprefix()} instead.} When set to a value other than \code{None}, this variable defines the prefix of the final component of the filenames returned by --- 64,68 ---- \begin{datadesc}{template} ! \deprecated{2.0}{Use \function{gettempprefix()} instead.} When set to a value other than \code{None}, this variable defines the prefix of the final component of the filenames returned by Index: libundoc.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libundoc.tex,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -r1.73 -r1.74 *** libundoc.tex 2000/04/03 20:13:54 1.73 --- libundoc.tex 2000/06/30 16:06:19 1.74 *************** *** 41,45 **** \item[\module{dircmp}] --- Class to build directory diff tools on (may become a demo or tool). ! \deprecated{1.6}{The \refmodule{filecmp} module will replace \module{dircmp}.} --- 41,45 ---- \item[\module{dircmp}] --- Class to build directory diff tools on (may become a demo or tool). ! \deprecated{2.0}{The \refmodule{filecmp} module will replace \module{dircmp}.} From python-dev@python.org Fri Jun 30 17:06:21 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 09:06:21 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/tut tut.tex,1.107,1.108 Message-ID: <200006301606.JAA28637@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/tut In directory slayer.i.sourceforge.net:/tmp/cvs-serv28564/tut Modified Files: tut.tex Log Message: Update version numbering from 1.6 to 2.0. Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.107 retrieving revision 1.108 diff -C2 -r1.107 -r1.108 *** tut.tex 2000/04/17 14:56:31 1.107 --- tut.tex 2000/06/30 16:06:19 1.108 *************** *** 738,742 **** \sectionauthor{Marc-Andre Lemburg}{mal@lemburg.com} ! Starting with Python 1.6 a new data type for storing text data is available to the programmer: the Unicode object. It can be used to store and manipulate Unicode data (see \url{http://www.unicode.org}) --- 738,742 ---- \sectionauthor{Marc-Andre Lemburg}{mal@lemburg.com} ! Starting with Python 2.0 a new data type for storing text data is available to the programmer: the Unicode object. It can be used to store and manipulate Unicode data (see \url{http://www.unicode.org}) From python-dev@python.org Fri Jun 30 17:09:04 2000 From: python-dev@python.org (Barry Warsaw) Date: Fri, 30 Jun 2000 09:09:04 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules .cvsignore,2.1,2.2 Message-ID: <200006301609.JAA29933@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv29911 Modified Files: .cvsignore Log Message: Add Setup.config Index: .cvsignore =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/.cvsignore,v retrieving revision 2.1 retrieving revision 2.2 diff -C2 -r2.1 -r2.2 *** .cvsignore 2000/05/02 18:32:34 2.1 --- .cvsignore 2000/06/30 16:09:01 2.2 *************** *** 2,5 **** --- 2,6 ---- Makefile.pre Setup.thread + Setup.config Setup.local hassignal From python-dev@python.org Fri Jun 30 17:12:17 2000 From: python-dev@python.org (Barry Warsaw) Date: Fri, 30 Jun 2000 09:12:17 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules Setup.config.in,NONE,1.1 Setup.thread.in,2.3,NONE Message-ID: <200006301612.JAA31542@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv31260 Added Files: Setup.config.in Removed Files: Setup.thread.in Log Message: Setup.thread.in was misnamed so it has been replaced by Setup.config.in. The latter contains all configure-time selectable modules; currently thread and gc. --- NEW FILE --- # This file is transmogrified into Setup.config by config.status. # The purpose of this file is to conditionally enable certain modules # based on configure-time options. Currently thread support and # garbage collection support are the only two modules so enabled. # *NOTE*: if the configure script decides it can't support threads, # the thread module will still be enabled and cause compile errors. # The solution is to use --without-threads on platforms that don't # support threads. @USE_THREAD_MODULE@thread threadmodule.c # Garbage collection enabled with --with-cycle-gc @USE_GC_MODULE@gc gcmodule.c From python-dev@python.org Fri Jun 30 17:13:40 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 09:13:40 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/dos-8x3 test_has.py,NONE,1.1 sre_comp.py,1.2,1.3 sre_cons.py,1.2,1.3 sre_pars.py,1.2,1.3 Message-ID: <200006301613.JAA31632@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/dos-8x3 In directory slayer.i.sourceforge.net:/tmp/cvs-serv31620 Modified Files: sre_comp.py sre_cons.py sre_pars.py Added Files: test_has.py Log Message: the usual --- NEW FILE --- # test the invariant that # iff a==b then hash(a)==hash(b) # import test_support def same_hash(*objlist): # hash each object given an raise TestFailed if # the hash values are not all the same hashed = map(hash, objlist) for h in hashed[1:]: if h != hashed[0]: raise TestFailed, "hashed values differ: %s" % `objlist` same_hash(1, 1L, 1.0, 1.0+0.0j) same_hash(int(1), long(1), float(1), complex(1)) same_hash(long(1.23e300), float(1.23e300)) same_hash(float(0.5), complex(0.5, 0.0)) Index: sre_comp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/sre_comp.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** sre_comp.py 2000/06/29 19:35:29 1.2 --- sre_comp.py 2000/06/30 16:13:37 1.3 *************** *** 19,174 **** for WORDSIZE in "BHil": if len(array.array(WORDSIZE, [0]).tostring()) == _sre.getcodesize(): ! break else: raise RuntimeError, "cannot find a useable array type" def _compile(code, pattern, flags): emit = code.append for op, av in pattern: ! if op is ANY: ! if flags & SRE_FLAG_DOTALL: ! emit(OPCODES[op]) ! else: ! emit(OPCODES[CATEGORY]) ! emit(CHCODES[CATEGORY_NOT_LINEBREAK]) ! elif op in (SUCCESS, FAILURE): ! emit(OPCODES[op]) ! elif op is AT: ! emit(OPCODES[op]) ! if flags & SRE_FLAG_MULTILINE: ! emit(ATCODES[AT_MULTILINE[av]]) ! else: ! emit(ATCODES[av]) ! elif op is BRANCH: ! emit(OPCODES[op]) ! tail = [] ! for av in av[1]: ! skip = len(code); emit(0) ! _compile(code, av, flags) ! emit(OPCODES[JUMP]) ! tail.append(len(code)); emit(0) ! code[skip] = len(code) - skip ! emit(0) # end of branch ! for tail in tail: ! code[tail] = len(code) - tail ! elif op is CALL: ! emit(OPCODES[op]) ! skip = len(code); emit(0) ! _compile(code, av, flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! elif op is CATEGORY: ! emit(OPCODES[op]) ! if flags & SRE_FLAG_LOCALE: ! emit(CH_LOCALE[CHCODES[av]]) ! elif flags & SRE_FLAG_UNICODE: ! emit(CH_UNICODE[CHCODES[av]]) ! else: ! emit(CHCODES[av]) ! elif op is GROUP: ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) ! else: ! emit(OPCODES[op]) ! emit(av-1) ! elif op is IN: ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) ! def fixup(literal, flags=flags): ! return _sre.getlower(ord(literal), flags) ! else: ! emit(OPCODES[op]) ! fixup = ord ! skip = len(code); emit(0) ! for op, av in av: ! emit(OPCODES[op]) ! if op is NEGATE: ! pass ! elif op is LITERAL: ! emit(fixup(av)) ! elif op is RANGE: ! emit(fixup(av[0])) ! emit(fixup(av[1])) ! elif op is CATEGORY: ! if flags & SRE_FLAG_LOCALE: ! emit(CH_LOCALE[CHCODES[av]]) ! elif flags & SRE_FLAG_UNICODE: ! emit(CH_UNICODE[CHCODES[av]]) ! else: ! emit(CHCODES[av]) ! else: ! raise error, "internal: unsupported set operator" ! emit(OPCODES[FAILURE]) ! code[skip] = len(code) - skip ! elif op in (LITERAL, NOT_LITERAL): ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) ! else: ! emit(OPCODES[op]) ! emit(ord(av)) ! elif op is MARK: ! emit(OPCODES[op]) ! emit(av) ! elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): ! if flags & SRE_FLAG_TEMPLATE: ! emit(OPCODES[REPEAT]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) ! _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! else: ! lo, hi = av[2].getwidth() ! if lo == 0: ! raise error, "nothing to repeat" ! if 0 and lo == hi == 1 and op is MAX_REPEAT: ! # FIXME: need a better way to figure out when ! # it's safe to use this one (in the parser, probably) ! emit(OPCODES[MAX_REPEAT_ONE]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) ! _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! else: ! emit(OPCODES[op]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) ! _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! elif op is SUBPATTERN: ! group = av[0] ! if group: ! emit(OPCODES[MARK]) ! emit((group-1)*2) ! _compile(code, av[1], flags) ! if group: ! emit(OPCODES[MARK]) ! emit((group-1)*2+1) ! else: ! raise ValueError, ("unsupported operand type", op) def compile(p, flags=0): # internal: convert pattern list to internal format if type(p) in (type(""), type(u"")): ! import sre_parse ! pattern = p ! p = sre_parse.parse(p) else: ! pattern = None flags = p.pattern.flags | flags code = [] _compile(code, p.data, flags) code.append(OPCODES[SUCCESS]) ! # FIXME: get rid of this limitation assert p.pattern.groups <= 100,\ ! "sorry, but this version only supports 100 named groups" return _sre.compile( ! pattern, flags, ! array.array(WORDSIZE, code).tostring(), ! p.pattern.groups-1, p.pattern.groupdict ! ) --- 19,229 ---- for WORDSIZE in "BHil": if len(array.array(WORDSIZE, [0]).tostring()) == _sre.getcodesize(): ! break else: raise RuntimeError, "cannot find a useable array type" def _compile(code, pattern, flags): + # internal: compile a (sub)pattern emit = code.append for op, av in pattern: ! if op in (LITERAL, NOT_LITERAL): ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) ! else: ! emit(OPCODES[op]) ! emit(av) ! elif op is IN: ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) ! def fixup(literal, flags=flags): ! return _sre.getlower(literal, flags) ! else: ! emit(OPCODES[op]) ! fixup = lambda x: x ! skip = len(code); emit(0) ! for op, av in av: ! emit(OPCODES[op]) ! if op is NEGATE: ! pass ! elif op is LITERAL: ! emit(fixup(av)) ! elif op is RANGE: ! emit(fixup(av[0])) ! emit(fixup(av[1])) ! elif op is CATEGORY: ! if flags & SRE_FLAG_LOCALE: ! emit(CHCODES[CH_LOCALE[av]]) ! elif flags & SRE_FLAG_UNICODE: ! emit(CHCODES[CH_UNICODE[av]]) ! else: ! emit(CHCODES[av]) ! else: ! raise error, "internal: unsupported set operator" ! emit(OPCODES[FAILURE]) ! code[skip] = len(code) - skip ! elif op is ANY: ! if flags & SRE_FLAG_DOTALL: ! emit(OPCODES[op]) ! else: ! emit(OPCODES[CATEGORY]) ! emit(CHCODES[CATEGORY_NOT_LINEBREAK]) ! elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): ! if flags & SRE_FLAG_TEMPLATE: ! emit(OPCODES[REPEAT]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) ! _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! else: ! lo, hi = av[2].getwidth() ! if lo == 0: ! raise error, "nothing to repeat" ! if 0 and lo == hi == 1 and op is MAX_REPEAT: ! # FIXME: need a better way to figure out when ! # it's safe to use this one (in the parser, probably) ! emit(OPCODES[MAX_REPEAT_ONE]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) ! _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! else: ! emit(OPCODES[op]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) ! _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! elif op is SUBPATTERN: ! group = av[0] ! if group: ! emit(OPCODES[MARK]) ! emit((group-1)*2) ! _compile(code, av[1], flags) ! if group: ! emit(OPCODES[MARK]) ! emit((group-1)*2+1) ! elif op in (SUCCESS, FAILURE): ! emit(OPCODES[op]) ! elif op in (ASSERT, ASSERT_NOT, CALL): ! emit(OPCODES[op]) ! skip = len(code); emit(0) ! _compile(code, av, flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! elif op is AT: ! emit(OPCODES[op]) ! if flags & SRE_FLAG_MULTILINE: ! emit(ATCODES[AT_MULTILINE[av]]) ! else: ! emit(ATCODES[av]) ! elif op is BRANCH: ! emit(OPCODES[op]) ! tail = [] ! for av in av[1]: ! skip = len(code); emit(0) ! _compile(code, av, flags) ! emit(OPCODES[JUMP]) ! tail.append(len(code)); emit(0) ! code[skip] = len(code) - skip ! emit(0) # end of branch ! for tail in tail: ! code[tail] = len(code) - tail ! elif op is CATEGORY: ! emit(OPCODES[op]) ! if flags & SRE_FLAG_LOCALE: ! emit(CHCODES[CH_LOCALE[av]]) ! elif flags & SRE_FLAG_UNICODE: ! emit(CHCODES[CH_UNICODE[av]]) ! else: ! emit(CHCODES[av]) ! elif op is GROUP: ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) ! else: ! emit(OPCODES[op]) ! emit(av-1) ! elif op is MARK: ! emit(OPCODES[op]) ! emit(av) ! else: ! raise ValueError, ("unsupported operand type", op) + def _compile_info(code, pattern, flags): + # internal: compile an info block. in the current version, + # this contains min/max pattern width and a literal prefix, + # if any + lo, hi = pattern.getwidth() + if lo == 0: + return # not worth it + # look for a literal prefix + prefix = [] + if not (flags & SRE_FLAG_IGNORECASE): + for op, av in pattern.data: + if op is LITERAL: + prefix.append(av) + else: + break + # add an info block + emit = code.append + emit(OPCODES[INFO]) + skip = len(code); emit(0) + # literal flag + mask = 0 + if len(prefix) == len(pattern.data): + mask = 1 + emit(mask) + # pattern length + emit(lo) + if hi < 32768: + emit(hi) + else: + emit(0) + # add literal prefix + emit(len(prefix)) + if prefix: + code.extend(prefix) + # generate overlap table + table = [-1] + ([0]*len(prefix)) + for i in range(len(prefix)): + table[i+1] = table[i]+1 + while table[i+1] > 0 and prefix[i] != prefix[table[i+1]-1]: + table[i+1] = table[table[i+1]-1]+1 + code.extend(table[1:]) # don't store first entry + code[skip] = len(code) - skip + def compile(p, flags=0): # internal: convert pattern list to internal format + + # compile, as necessary if type(p) in (type(""), type(u"")): ! import sre_parse ! pattern = p ! p = sre_parse.parse(p) else: ! pattern = None ! flags = p.pattern.flags | flags code = [] + + # compile info block + _compile_info(code, p, flags) + + # compile the pattern _compile(code, p.data, flags) + code.append(OPCODES[SUCCESS]) ! ! # FIXME: get rid of this limitation! assert p.pattern.groups <= 100,\ ! "sorry, but this version only supports 100 named groups" ! return _sre.compile( ! pattern, flags, ! array.array(WORDSIZE, code).tostring(), ! p.pattern.groups-1, p.pattern.groupdict ! ) Index: sre_cons.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/sre_cons.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** sre_cons.py 2000/06/29 19:35:29 1.2 --- sre_cons.py 2000/06/30 16:13:37 1.3 *************** *** 24,27 **** --- 24,28 ---- ANY = "any" ASSERT = "assert" + ASSERT_NOT = "assert_not" AT = "at" BRANCH = "branch" *************** *** 82,86 **** ANY, ! ASSERT, AT, BRANCH, --- 83,87 ---- ANY, ! ASSERT, ASSERT_NOT, AT, BRANCH, *************** *** 122,127 **** i = 0 for item in list: ! d[item] = i ! i = i + 1 return d --- 123,128 ---- i = 0 for item in list: ! d[item] = i ! i = i + 1 return d *************** *** 177,186 **** import string def dump(f, d, prefix): ! items = d.items() ! items.sort(lambda a, b: cmp(a[1], b[1])) ! for k, v in items: ! f.write("#define %s_%s %s\n" % (prefix, string.upper(k), v)) f = open("sre_constants.h", "w") ! f.write("/* generated from sre_constants.py */\n") dump(f, OPCODES, "SRE_OP") dump(f, ATCODES, "SRE") --- 178,202 ---- import string def dump(f, d, prefix): ! items = d.items() ! items.sort(lambda a, b: cmp(a[1], b[1])) ! for k, v in items: ! f.write("#define %s_%s %s\n" % (prefix, string.upper(k), v)) f = open("sre_constants.h", "w") ! f.write("""\ ! /* ! * Secret Labs' Regular Expression Engine ! * ! * regular expression matching engine ! * ! * NOTE: This file is generated by sre_constants.py. If you need ! * to change anything in here, edit sre_constants.py and run it. ! * ! * Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. ! * ! * See the _sre.c file for information on usage and redistribution. ! */ ! ! """) ! dump(f, OPCODES, "SRE_OP") dump(f, ATCODES, "SRE") Index: sre_pars.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/sre_pars.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** sre_pars.py 2000/06/29 19:35:29 1.2 --- sre_pars.py 2000/06/30 16:13:37 1.3 *************** *** 20,23 **** --- 20,26 ---- MAXREPEAT = 32767 + # FIXME: same here + CHARMASK = 0x7fff + SPECIAL_CHARS = ".\\[{()*+?^$|" REPEAT_CHARS = "*+?{" *************** *** 31,54 **** [...1073 lines suppressed...] ! raise error, "empty group" ! a(s) ! return match.string[:0].join(p) --- 615,630 ---- p = [] a = p.append + sep = match.string[:0] + if type(sep) is type(""): + char = chr + else: + char = unichr for c, s in template: ! if c is LITERAL: ! a(char(s)) ! elif c is MARK: ! s = match.group(s) ! if s is None: ! raise error, "empty group" ! a(s) ! return sep.join(p) From python-dev@python.org Fri Jun 30 17:18:59 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 09:18:59 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python getmtime.c,2.9,2.10 import.c,2.135,2.136 Message-ID: <200006301618.JAA31951@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv31939 Modified Files: getmtime.c import.c Log Message: Trent Mick : This patch fixes possible overflow in the use of PyOS_GetLastModificationTime in getmtime.c and Python/import.c. Currently PyOS_GetLastModificationTime returns a C long. This can overflow on Win64 where sizeof(time_t) > sizeof(long). Besides it should logically return a time_t anyway (this patch changes this). As well, import.c uses PyOS_GetLastModificationTime for .pyc timestamping. There has been recent discussion about the .pyc header format on python-dev. This patch adds oveflow checking to import.c so that an exception will be raised if the modification time overflows. There are a few other minor 64-bit readiness changes made to the module as well: - size_t instead of int or long for function-local buffer and string length variables - one buffer overflow check was added (raises an exception on possible overflow, this overflow chance exists on 32-bit platforms as well), no other possible buffer overflows existed (from my analysis anyway) Closes SourceForge patch #100509. Index: getmtime.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/getmtime.c,v retrieving revision 2.9 retrieving revision 2.10 diff -C2 -r2.9 -r2.10 *** getmtime.c 1997/09/05 07:33:15 2.9 --- getmtime.c 2000/06/30 16:18:57 2.10 *************** *** 34,37 **** --- 34,38 ---- /* (A separate file because this may be OS dependent) */ + #include "Python.h" #include "config.h" *************** *** 40,44 **** #include ! long PyOS_GetLastModificationTime(path, fp) char *path; --- 41,45 ---- #include ! time_t PyOS_GetLastModificationTime(path, fp) char *path; Index: import.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/import.c,v retrieving revision 2.135 retrieving revision 2.136 diff -C2 -r2.135 -r2.136 *** import.c 2000/06/30 04:59:17 2.135 --- import.c 2000/06/30 16:18:57 2.136 *************** *** 75,79 **** ! extern long PyOS_GetLastModificationTime(); /* In getmtime.c */ /* Magic word to reject .pyc files generated by other Python versions */ --- 75,79 ---- ! extern time_t PyOS_GetLastModificationTime(); /* In getmtime.c */ /* Magic word to reject .pyc files generated by other Python versions */ *************** *** 550,556 **** char *pathname; char *buf; ! int buflen; { ! int len; len = strlen(pathname); --- 550,556 ---- char *pathname; char *buf; ! size_t buflen; { ! size_t len; len = strlen(pathname); *************** *** 733,737 **** FILE *fp; { ! long mtime; FILE *fpc; char buf[MAXPATHLEN+1]; --- 733,737 ---- FILE *fp; { ! time_t mtime; FILE *fpc; char buf[MAXPATHLEN+1]; *************** *** 741,745 **** mtime = PyOS_GetLastModificationTime(pathname, fp); ! cpathname = make_compiled_pathname(pathname, buf, MAXPATHLEN+1); if (cpathname != NULL && (fpc = check_compiled_module(pathname, mtime, cpathname))) { --- 741,758 ---- mtime = PyOS_GetLastModificationTime(pathname, fp); ! if (mtime == -1) ! return NULL; ! #if SIZEOF_TIME_T > 4 ! /* Python's .pyc timestamp handling presumes that the timestamp fits ! in 4 bytes. This will be fine until sometime in the year 2038, ! when a 4-byte signed time_t will overflow. ! */ ! if (mtime >> 32) { ! PyErr_SetString(PyExc_OverflowError, ! "modification time overflows a 4 bytes"); ! return NULL; ! } ! #endif ! cpathname = make_compiled_pathname(pathname, buf, (size_t)MAXPATHLEN+1); if (cpathname != NULL && (fpc = check_compiled_module(pathname, mtime, cpathname))) { *************** *** 772,776 **** static PyObject *load_module Py_PROTO((char *, FILE *, char *, int)); static struct filedescr *find_module Py_PROTO((char *, PyObject *, ! char *, int, FILE **)); static struct _frozen *find_frozen Py_PROTO((char *name)); --- 785,789 ---- static PyObject *load_module Py_PROTO((char *, FILE *, char *, int)); static struct filedescr *find_module Py_PROTO((char *, PyObject *, ! char *, size_t, FILE **)); static struct _frozen *find_frozen Py_PROTO((char *name)); *************** *** 870,877 **** /* Output parameters: */ char *buf; ! int buflen; FILE **p_fp; { ! int i, npath, len, namelen; struct _frozen *f; struct filedescr *fdp = NULL; --- 883,891 ---- /* Output parameters: */ char *buf; ! size_t buflen; FILE **p_fp; { ! int i, npath; ! size_t len, namelen; struct _frozen *f; struct filedescr *fdp = NULL; *************** *** 883,886 **** --- 897,904 ---- char name[MAXPATHLEN+1]; + if (strlen(realname) > MAXPATHLEN) { + PyErr_SetString(PyExc_OverflowError, "module name is too long"); + return NULL; + } strcpy(name, realname); *************** *** 934,938 **** continue; /* Too long */ strcpy(buf, PyString_AsString(v)); ! if ((int)strlen(buf) != len) continue; /* v contains '\0' */ #ifdef macintosh --- 952,956 ---- continue; /* Too long */ strcpy(buf, PyString_AsString(v)); ! if (strlen(buf) != len) continue; /* v contains '\0' */ #ifdef macintosh *************** *** 1182,1187 **** char *buf; { ! int save_len = strlen(buf); ! int i = save_len; struct stat statbuf; --- 1200,1205 ---- char *buf; { ! size_t save_len = strlen(buf); ! size_t i = save_len; struct stat statbuf; *************** *** 1578,1582 **** char *start = PyString_AS_STRING(modname); char *lastdot = strrchr(start, '.'); ! int len; if (lastdot == NULL) return Py_None; --- 1596,1600 ---- char *start = PyString_AS_STRING(modname); char *lastdot = strrchr(start, '.'); ! size_t len; if (lastdot == NULL) return Py_None; *************** *** 1613,1617 **** char *name = *p_name; char *dot = strchr(name, '.'); ! int len; char *p; PyObject *result; --- 1631,1635 ---- char *name = *p_name; char *dot = strchr(name, '.'); ! size_t len; char *p; PyObject *result; From python-dev@python.org Fri Jun 30 17:20:15 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 09:20:15 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python compile.c,2.109,2.110 Message-ID: <200006301620.JAA32128@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv32117/Python Modified Files: compile.c Log Message: Trent Mick : The common technique for printing out a pointer has been to cast to a long and use the "%lx" printf modifier. This is incorrect on Win64 where casting to a long truncates the pointer. The "%p" formatter should be used instead. The problem as stated by Tim: > Unfortunately, the C committee refused to define what %p conversion "looks > like" -- they explicitly allowed it to be implementation-defined. Older > versions of Microsoft C even stuck a colon in the middle of the address (in > the days of segment+offset addressing)! The result is that the hex value of a pointer will maybe/maybe not have a 0x prepended to it. Notes on the patch: There are two main classes of changes: - in the various repr() functions that print out pointers - debugging printf's in the various thread_*.h files (these are why the patch is large) Closes SourceForge patch #100505. Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.109 retrieving revision 2.110 diff -C2 -r2.109 -r2.110 *** compile.c 2000/06/28 22:07:35 2.109 --- compile.c 2000/06/30 16:20:13 2.110 *************** *** 131,136 **** if (co->co_name && PyString_Check(co->co_name)) name = PyString_AsString(co->co_name); ! sprintf(buf, "", ! name, (long)co, filename, lineno); return PyString_FromString(buf); } --- 131,136 ---- if (co->co_name && PyString_Check(co->co_name)) name = PyString_AsString(co->co_name); ! sprintf(buf, "", ! name, co, filename, lineno); return PyString_FromString(buf); } From python-dev@python.org Fri Jun 30 17:21:06 2000 From: python-dev@python.org (Barry Warsaw) Date: Fri, 30 Jun 2000 09:21:06 -0700 Subject: [Python-checkins] CVS: python/dist/src configure,1.121,1.122 configure.in,1.130,1.131 Message-ID: <200006301621.JAA32190@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv31678 Modified Files: configure configure.in Log Message: Enable the garbage collection module by default. --without-cycle-gc disables it. The gc test is moved to just after the thread test, as is the wctype-functions test. Modules/Setup.config is generated instead of Modules/Setup.thread. Applied SF patch #100684 (loewis) to fix help alignment bug. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.121 retrieving revision 1.122 diff -C2 -r1.121 -r1.122 *** configure 2000/06/30 04:57:55 1.121 --- configure 2000/06/30 16:21:00 1.122 *************** *** 1,5 **** #! /bin/sh ! # From configure.in Revision: 1.129 # Guess values for system-dependent variables and create Makefiles. --- 1,5 ---- #! /bin/sh ! # From configure.in Revision: 1.130 [...1824 lines suppressed...] *** 5837,5841 **** s%@LIBM@%$LIBM%g s%@LIBC@%$LIBC%g - s%@USE_GC_MODULE@%$USE_GC_MODULE%g CEOF --- 5843,5846 ---- *************** *** 5884,5888 **** Python/Makefile \ Modules/Makefile.pre \ ! Modules/Setup.thread"} EOF cat >> $CONFIG_STATUS <<\EOF --- 5889,5893 ---- Python/Makefile \ Modules/Makefile.pre \ ! Modules/Setup.config"} EOF cat >> $CONFIG_STATUS <<\EOF Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.130 retrieving revision 1.131 diff -C2 -r1.130 -r1.131 *** configure.in 2000/06/30 04:57:55 1.130 --- configure.in 2000/06/30 16:21:01 1.131 *************** *** 723,726 **** --- 723,754 ---- fi + # Check for GC support + AC_SUBST(USE_GC_MODULE) + USE_GC_MODULE="" + AC_MSG_CHECKING(for --with-cycle-gc) + AC_ARG_WITH(cycle-gc, + [ --with(out)-cycle-gc disable/enable garbage collection]) + + if test -z "$with_cycle_gc" + then with_cycle_gc="yes" + fi + if test "$with_cycle_gc" = "no" + then + USE_GC_MODULE="#" + else + AC_DEFINE(WITH_CYCLE_GC) + fi + AC_MSG_RESULT($with_cycle_gc) + + # Check for --with-wctype-functions + AC_MSG_CHECKING(for --with-wctype-functions) + AC_ARG_WITH(wctype-functions, + [ --with-wctype-functions use wctype.h functions], [ + if test "$withval" != no + then AC_DEFINE(WANT_WCTYPE_FUNCTIONS) AC_MSG_RESULT(yes) + else AC_MSG_RESULT(no) + fi], + [AC_MSG_RESULT(no)]) + # -I${DLINCLDIR} is added to the compile rule for importdl.o AC_SUBST(DLINCLDIR) *************** *** 1107,1131 **** AC_C_BIGENDIAN - # Check for --with-wctype-functions - AC_MSG_CHECKING(for --with-wctype-functions) - AC_ARG_WITH(wctype-functions, - [ --with-wctype-functions use wctype.h functions], [ - if test "$withval" != no - then AC_DEFINE(WANT_WCTYPE_FUNCTIONS) AC_MSG_RESULT(yes) - else AC_MSG_RESULT(no) - fi], - [AC_MSG_RESULT(no)]) - - # Check for GC support - AC_SUBST(USE_GC_MODULE) - USE_GC_MODULE="#" - AC_MSG_CHECKING(for --with-cycle-gc) - AC_ARG_WITH(cycle-gc, [--with-cycle-gc enable garbage collection], [ - AC_MSG_RESULT($withval) - AC_DEFINE(WITH_CYCLE_GC) - USE_GC_MODULE= - ], - AC_MSG_RESULT(no)) - # THIS MUST BE LAST, IT CAN BREAK OTHER TESTS! # Add sys/socket.h to confdefs.h --- 1135,1138 ---- *************** *** 1143,1145 **** Python/Makefile \ Modules/Makefile.pre \ ! Modules/Setup.thread) --- 1150,1152 ---- Python/Makefile \ Modules/Makefile.pre \ ! Modules/Setup.config) From python-dev@python.org Fri Jun 30 17:25:23 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 09:25:23 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_re.py,1.19,1.20 Message-ID: <200006301625.JAA32505@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv32367/test Modified Files: test_re.py Log Message: Switch to sre for regular expression matching (the new mini-re module is actually by Fredrik Lundh). This will break the re tests -- Fredrik will fix this before the final release. Index: test_re.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_re.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -r1.19 -r1.20 *** test_re.py 1998/07/17 20:05:02 1.19 --- test_re.py 2000/06/30 16:25:20 1.20 *************** *** 151,156 **** assert re.split("(:)*", ":a:b::c") == ['', ':', 'a', ':', 'b', ':', 'c'] assert re.split("([b:]+)", ":a:b::c") == ['', ':', 'a', ':b::', 'c'] ! assert re.split("(b)|(:+)", ":a:b::c") == \ ! ['', None, ':', 'a', None, ':', '', 'b', None, '', None, '::', 'c'] assert re.split("(?:b)|(?::+)", ":a:b::c") == ['', 'a', '', '', 'c'] except AssertionError: --- 151,156 ---- assert re.split("(:)*", ":a:b::c") == ['', ':', 'a', ':', 'b', ':', 'c'] assert re.split("([b:]+)", ":a:b::c") == ['', ':', 'a', ':b::', 'c'] ! ## assert re.split("(b)|(:+)", ":a:b::c") == \ ! ## ['', None, ':', 'a', None, ':', '', 'b', None, '', None, '::', 'c'] assert re.split("(?:b)|(?::+)", ":a:b::c") == ['', 'a', '', '', 'c'] except AssertionError: *************** *** 328,334 **** # string), so we'll ignore patterns that feature it. ! if pattern[:2]!='\\B' and pattern[-2:]!='\\B': obj=re.compile(pattern) ! result=obj.search(s, pos=result.start(0), endpos=result.end(0)+1) if result==None: print '=== Failed on range-limited match', t --- 328,334 ---- # string), so we'll ignore patterns that feature it. ! if pattern[:2]!='\\B' and pattern[-2:]!='\\B' and result!=None: obj=re.compile(pattern) ! result=obj.search(s, result.start(0), result.end(0)+1) if result==None: print '=== Failed on range-limited match', t From python-dev@python.org Fri Jun 30 17:25:23 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 09:25:23 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib pre.py,NONE,1.1 re.py,1.35,1.36 Message-ID: <200006301625.JAA32503@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv32367 Modified Files: re.py Added Files: pre.py Log Message: Switch to sre for regular expression matching (the new mini-re module is actually by Fredrik Lundh). This will break the re tests -- Fredrik will fix this before the final release. --- NEW FILE --- # module 're' -- A collection of regular expression operations """Support for regular expressions (RE). This module provides regular expression matching operations similar to those found in Perl. It's 8-bit clean: the strings being processed may contain both null bytes and characters whose high bit is set. Regular expression pattern strings may not contain null bytes, but can specify the null byte using the \\number notation. Characters with the high bit set may be included. Regular expressions can contain both special and ordinary characters. Most ordinary characters, like "A", "a", or "0", are the simplest regular expressions; they simply match themselves. You can concatenate ordinary characters, so last matches the string 'last'. The special characters are: "." Matches any character except a newline. "^" Matches the start of the string. "$" Matches the end of the string. "*" Matches 0 or more (greedy) repetitions of the preceding RE. Greedy means that it will match as many repetitions as possible. "+" Matches 1 or more (greedy) repetitions of the preceding RE. "?" Matches 0 or 1 (greedy) of the preceding RE. *?,+?,?? Non-greedy versions of the previous three special characters. {m,n} Matches from m to n repetitions of the preceding RE. {m,n}? Non-greedy version of the above. "\\" Either escapes special characters or signals a special sequence. [] Indicates a set of characters. A "^" as the first character indicates a complementing set. "|" A|B, creates an RE that will match either A or B. (...) Matches the RE inside the parentheses. The contents can be retrieved or matched later in the string. (?iLmsx) Set the I, L, M, S, or X flag for the RE. (?:...) Non-grouping version of regular parentheses. (?P...) The substring matched by the group is accessible by name. (?P=name) Matches the text matched earlier by the group named name. (?#...) A comment; ignored. (?=...) Matches if ... matches next, but doesn't consume the string. (?!...) Matches if ... doesn't match next. The special sequences consist of "\\" and a character from the list below. If the ordinary character is not on the list, then the resulting RE will match the second character. \\number Matches the contents of the group of the same number. \\A Matches only at the start of the string. \\Z Matches only at the end of the string. \\b Matches the empty string, but only at the start or end of a word. \\B Matches the empty string, but not at the start or end of a word. \\d Matches any decimal digit; equivalent to the set [0-9]. \\D Matches any non-digit character; equivalent to the set [^0-9]. \\s Matches any whitespace character; equivalent to [ \\t\\n\\r\\f\\v]. \\S Matches any non-whitespace character; equiv. to [^ \\t\\n\\r\\f\\v]. \\w Matches any alphanumeric character; equivalent to [a-zA-Z0-9_]. With LOCALE, it will match the set [0-9_] plus characters defined as letters for the current locale. \\W Matches the complement of \\w. \\\\ Matches a literal backslash. This module exports the following functions: match Match a regular expression pattern to the beginning of a string. search Search a string for the presence of a pattern. sub Substitute occurrences of a pattern found in a string. subn Same as sub, but also return the number of substitutions made. split Split a string by the occurrences of a pattern. findall Find all occurrences of a pattern in a string. compile Compile a pattern into a RegexObject. escape Backslash all non-alphanumerics in a string. This module exports the following classes: RegexObject Holds a compiled regular expression pattern. MatchObject Contains information about pattern matches. Some of the functions in this module takes flags as optional parameters: I IGNORECASE Perform case-insensitive matching. L LOCALE Make \w, \W, \b, \B, dependent on the current locale. M MULTILINE "^" matches the beginning of lines as well as the string. "$" matches the end of lines as well as the string. S DOTALL "." matches any character at all, including the newline. X VERBOSE Ignore whitespaces and comments for nicer looking RE's. This module also defines an exception 'error'. """ import sys import string from pcre import * # # First, the public part of the interface: # # pcre.error and re.error should be the same, since exceptions can be # raised from either module. # compilation flags I = IGNORECASE L = LOCALE M = MULTILINE S = DOTALL X = VERBOSE # # # _cache = {} _MAXCACHE = 20 def _cachecompile(pattern, flags=0): key = (pattern, flags) try: return _cache[key] except KeyError: pass value = compile(pattern, flags) if len(_cache) >= _MAXCACHE: _cache.clear() _cache[key] = value return value def match(pattern, string, flags=0): """match (pattern, string[, flags]) -> MatchObject or None If zero or more characters at the beginning of string match the regular expression pattern, return a corresponding MatchObject instance. Return None if the string does not match the pattern; note that this is different from a zero-length match. Note: If you want to locate a match anywhere in string, use search() instead. """ return _cachecompile(pattern, flags).match(string) def search(pattern, string, flags=0): """search (pattern, string[, flags]) -> MatchObject or None Scan through string looking for a location where the regular expression pattern produces a match, and return a corresponding MatchObject instance. Return None if no position in the string matches the pattern; note that this is different from finding a zero-length match at some point in the string. """ return _cachecompile(pattern, flags).search(string) def sub(pattern, repl, string, count=0): """sub(pattern, repl, string[, count=0]) -> string Return the string obtained by replacing the leftmost non-overlapping occurrences of pattern in string by the replacement repl. If the pattern isn't found, string is returned unchanged. repl can be a string or a function; if a function, it is called for every non-overlapping occurrence of pattern. The function takes a single match object argument, and returns the replacement string. The pattern may be a string or a regex object; if you need to specify regular expression flags, you must use a regex object, or use embedded modifiers in a pattern; e.g. sub("(?i)b+", "x", "bbbb BBBB") returns 'x x'. The optional argument count is the maximum number of pattern occurrences to be replaced; count must be a non-negative integer, and the default value of 0 means to replace all occurrences. """ if type(pattern) == type(''): pattern = _cachecompile(pattern) return pattern.sub(repl, string, count) def subn(pattern, repl, string, count=0): """subn(pattern, repl, string[, count=0]) -> (string, num substitutions) Perform the same operation as sub(), but return a tuple (new_string, number_of_subs_made). """ if type(pattern) == type(''): pattern = _cachecompile(pattern) return pattern.subn(repl, string, count) def split(pattern, string, maxsplit=0): """split(pattern, string[, maxsplit=0]) -> list of strings Split string by the occurrences of pattern. If capturing parentheses are used in pattern, then the text of all groups in the pattern are also returned as part of the resulting list. If maxsplit is nonzero, at most maxsplit splits occur, and the remainder of the string is returned as the final element of the list. """ if type(pattern) == type(''): pattern = _cachecompile(pattern) return pattern.split(string, maxsplit) def findall(pattern, string): """findall(pattern, string) -> list Return a list of all non-overlapping matches of pattern in string. If one or more groups are present in the pattern, return a list of groups; this will be a list of tuples if the pattern has more than one group. Empty matches are included in the result. """ if type(pattern) == type(''): pattern = _cachecompile(pattern) return pattern.findall(string) def escape(pattern): """escape(string) -> string Return string with all non-alphanumerics backslashed; this is useful if you want to match an arbitrary literal string that may have regular expression metacharacters in it. """ result = list(pattern) alphanum=string.letters+'_'+string.digits for i in range(len(pattern)): char = pattern[i] if char not in alphanum: if char=='\000': result[i] = '\\000' else: result[i] = '\\'+char return string.join(result, '') def compile(pattern, flags=0): """compile(pattern[, flags]) -> RegexObject Compile a regular expression pattern into a regular expression object, which can be used for matching using its match() and search() methods. """ groupindex={} code=pcre_compile(pattern, flags, groupindex) return RegexObject(pattern, flags, code, groupindex) # # Class definitions # class RegexObject: """Holds a compiled regular expression pattern. Methods: match Match the pattern to the beginning of a string. search Search a string for the presence of the pattern. sub Substitute occurrences of the pattern found in a string. subn Same as sub, but also return the number of substitutions made. split Split a string by the occurrences of the pattern. findall Find all occurrences of the pattern in a string. """ def __init__(self, pattern, flags, code, groupindex): self.code = code self.flags = flags self.pattern = pattern self.groupindex = groupindex def search(self, string, pos=0, endpos=None): """search(string[, pos][, endpos]) -> MatchObject or None Scan through string looking for a location where this regular expression produces a match, and return a corresponding MatchObject instance. Return None if no position in the string matches the pattern; note that this is different from finding a zero-length match at some point in the string. The optional pos and endpos parameters have the same meaning as for the match() method. """ if endpos is None or endpos>len(string): endpos=len(string) if endpos MatchObject or None If zero or more characters at the beginning of string match this regular expression, return a corresponding MatchObject instance. Return None if the string does not match the pattern; note that this is different from a zero-length match. Note: If you want to locate a match anywhere in string, use search() instead. The optional second parameter pos gives an index in the string where the search is to start; it defaults to 0. This is not completely equivalent to slicing the string; the '' pattern character matches at the real beginning of the string and at positions just after a newline, but not necessarily at the index where the search is to start. The optional parameter endpos limits how far the string will be searched; it will be as if the string is endpos characters long, so only the characters from pos to endpos will be searched for a match. """ if endpos is None or endpos>len(string): endpos=len(string) if endpos string Return the string obtained by replacing the leftmost non-overlapping occurrences of the compiled pattern in string by the replacement repl. If the pattern isn't found, string is returned unchanged. Identical to the sub() function, using the compiled pattern. """ return self.subn(repl, string, count)[0] def subn(self, repl, source, count=0): """subn(repl, string[, count=0]) -> tuple Perform the same operation as sub(), but return a tuple (new_string, number_of_subs_made). """ if count < 0: raise error, "negative substitution count" if count == 0: count = sys.maxint n = 0 # Number of matches pos = 0 # Where to start searching lastmatch = -1 # End of last match results = [] # Substrings making up the result end = len(source) if type(repl) is type(''): # See if repl contains group references try: repl = pcre_expand(_Dummy, repl) except: m = MatchObject(self, source, 0, end, []) repl = lambda m, repl=repl, expand=pcre_expand: expand(m, repl) else: m = None else: m = MatchObject(self, source, 0, end, []) match = self.code.match append = results.append while n < count and pos <= end: regs = match(source, pos, end, 0) if not regs: break self._num_regs = len(regs) i, j = regs[0] if i == j == lastmatch: # Empty match adjacent to previous match pos = pos + 1 append(source[lastmatch:pos]) continue if pos < i: append(source[pos:i]) if m: m.pos = pos m.regs = regs append(repl(m)) else: append(repl) pos = lastmatch = j if i == j: # Last match was empty; don't try here again pos = pos + 1 append(source[lastmatch:pos]) n = n + 1 append(source[pos:]) return (string.join(results, ''), n) def split(self, source, maxsplit=0): """split(source[, maxsplit=0]) -> list of strings Split string by the occurrences of the compiled pattern. If capturing parentheses are used in the pattern, then the text of all groups in the pattern are also returned as part of the resulting list. If maxsplit is nonzero, at most maxsplit splits occur, and the remainder of the string is returned as the final element of the list. """ if maxsplit < 0: raise error, "negative split count" if maxsplit == 0: maxsplit = sys.maxint n = 0 pos = 0 lastmatch = 0 results = [] end = len(source) match = self.code.match append = results.append while n < maxsplit: regs = match(source, pos, end, 0) if not regs: break i, j = regs[0] if i == j: # Empty match if pos >= end: break pos = pos+1 continue append(source[lastmatch:i]) rest = regs[1:] if rest: for a, b in rest: if a == -1 or b == -1: group = None else: group = source[a:b] append(group) pos = lastmatch = j n = n + 1 append(source[lastmatch:]) return results def findall(self, source): """findall(source) -> list Return a list of all non-overlapping matches of the compiled pattern in string. If one or more groups are present in the pattern, return a list of groups; this will be a list of tuples if the pattern has more than one group. Empty matches are included in the result. """ pos = 0 end = len(source) results = [] match = self.code.match append = results.append while pos <= end: regs = match(source, pos, end, 0) if not regs: break i, j = regs[0] rest = regs[1:] if not rest: gr = source[i:j] elif len(rest) == 1: a, b = rest[0] gr = source[a:b] else: gr = [] for (a, b) in rest: gr.append(source[a:b]) gr = tuple(gr) append(gr) pos = max(j, pos+1) return results # The following 3 functions were contributed by Mike Fletcher, and # allow pickling and unpickling of RegexObject instances. def __getinitargs__(self): return (None,None,None,None) # any 4 elements, to work around # problems with the # pickle/cPickle modules not yet # ignoring the __init__ function def __getstate__(self): return self.pattern, self.flags, self.groupindex def __setstate__(self, statetuple): self.pattern = statetuple[0] self.flags = statetuple[1] self.groupindex = statetuple[2] self.code = apply(pcre_compile, statetuple) class _Dummy: # Dummy class used by _subn_string(). Has 'group' to avoid core dump. group = None class MatchObject: """Holds a compiled regular expression pattern. Methods: start Return the index of the start of a matched substring. end Return the index of the end of a matched substring. span Return a tuple of (start, end) of a matched substring. groups Return a tuple of all the subgroups of the match. group Return one or more subgroups of the match. groupdict Return a dictionary of all the named subgroups of the match. """ def __init__(self, re, string, pos, endpos, regs): self.re = re self.string = string self.pos = pos self.endpos = endpos self.regs = regs def start(self, g = 0): """start([group=0]) -> int or None Return the index of the start of the substring matched by group; group defaults to zero (meaning the whole matched substring). Return None if group exists but did not contribute to the match. """ if type(g) == type(''): try: g = self.re.groupindex[g] except (KeyError, TypeError): raise IndexError, 'group %s is undefined' % `g` return self.regs[g][0] def end(self, g = 0): """end([group=0]) -> int or None Return the indices of the end of the substring matched by group; group defaults to zero (meaning the whole matched substring). Return None if group exists but did not contribute to the match. """ if type(g) == type(''): try: g = self.re.groupindex[g] except (KeyError, TypeError): raise IndexError, 'group %s is undefined' % `g` return self.regs[g][1] def span(self, g = 0): """span([group=0]) -> tuple Return the 2-tuple (m.start(group), m.end(group)). Note that if group did not contribute to the match, this is (None, None). Group defaults to zero (meaning the whole matched substring). """ if type(g) == type(''): try: g = self.re.groupindex[g] except (KeyError, TypeError): raise IndexError, 'group %s is undefined' % `g` return self.regs[g] def groups(self, default=None): """groups([default=None]) -> tuple Return a tuple containing all the subgroups of the match, from 1 up to however many groups are in the pattern. The default argument is used for groups that did not participate in the match. """ result = [] for g in range(1, self.re._num_regs): a, b = self.regs[g] if a == -1 or b == -1: result.append(default) else: result.append(self.string[a:b]) return tuple(result) def group(self, *groups): """group([group1, group2, ...]) -> string or tuple Return one or more subgroups of the match. If there is a single argument, the result is a single string; if there are multiple arguments, the result is a tuple with one item per argument. Without arguments, group1 defaults to zero (i.e. the whole match is returned). If a groupN argument is zero, the corresponding return value is the entire matching string; if it is in the inclusive range [1..99], it is the string matching the the corresponding parenthesized group. If a group number is negative or larger than the number of groups defined in the pattern, an IndexError exception is raised. If a group is contained in a part of the pattern that did not match, the corresponding result is None. If a group is contained in a part of the pattern that matched multiple times, the last match is returned. If the regular expression uses the (?P...) syntax, the groupN arguments may also be strings identifying groups by their group name. If a string argument is not used as a group name in the pattern, an IndexError exception is raised. """ if len(groups) == 0: groups = (0,) result = [] for g in groups: if type(g) == type(''): try: g = self.re.groupindex[g] except (KeyError, TypeError): raise IndexError, 'group %s is undefined' % `g` if g >= len(self.regs): raise IndexError, 'group %s is undefined' % `g` a, b = self.regs[g] if a == -1 or b == -1: result.append(None) else: result.append(self.string[a:b]) if len(result) > 1: return tuple(result) elif len(result) == 1: return result[0] else: return () def groupdict(self, default=None): """groupdict([default=None]) -> dictionary Return a dictionary containing all the named subgroups of the match, keyed by the subgroup name. The default argument is used for groups that did not participate in the match. """ dict = {} for name, index in self.re.groupindex.items(): a, b = self.regs[index] if a == -1 or b == -1: dict[name] = default else: dict[name] = self.string[a:b] return dict Index: re.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/re.py,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -r1.35 -r1.36 *** re.py 1999/11/15 14:19:15 1.35 --- re.py 2000/06/30 16:25:20 1.36 *************** *** 1,652 **** ! # module 're' -- A collection of regular expression operations ! """Support for regular expressions (RE). ! This module provides regular expression matching operations similar to ! those found in Perl. It's 8-bit clean: the strings being processed may ! contain both null bytes and characters whose high bit is set. Regular ! expression pattern strings may not contain null bytes, but can specify ! the null byte using the \\number notation. Characters with the high ! bit set may be included. ! ! Regular expressions can contain both special and ordinary ! characters. Most ordinary characters, like "A", "a", or "0", are the ! simplest regular expressions; they simply match themselves. You can ! concatenate ordinary characters, so last matches the string 'last'. ! ! The special characters are: ! "." Matches any character except a newline. ! "^" Matches the start of the string. ! "$" Matches the end of the string. ! "*" Matches 0 or more (greedy) repetitions of the preceding RE. ! Greedy means that it will match as many repetitions as possible. ! "+" Matches 1 or more (greedy) repetitions of the preceding RE. ! "?" Matches 0 or 1 (greedy) of the preceding RE. ! *?,+?,?? Non-greedy versions of the previous three special characters. ! {m,n} Matches from m to n repetitions of the preceding RE. ! {m,n}? Non-greedy version of the above. ! "\\" Either escapes special characters or signals a special sequence. ! [] Indicates a set of characters. ! A "^" as the first character indicates a complementing set. ! "|" A|B, creates an RE that will match either A or B. ! (...) Matches the RE inside the parentheses. ! The contents can be retrieved or matched later in the string. ! (?iLmsx) Set the I, L, M, S, or X flag for the RE. ! (?:...) Non-grouping version of regular parentheses. ! (?P...) The substring matched by the group is accessible by name. ! (?P=name) Matches the text matched earlier by the group named name. ! (?#...) A comment; ignored. ! (?=...) Matches if ... matches next, but doesn't consume the string. ! (?!...) Matches if ... doesn't match next. ! ! The special sequences consist of "\\" and a character from the list ! below. If the ordinary character is not on the list, then the ! resulting RE will match the second character. ! \\number Matches the contents of the group of the same number. ! \\A Matches only at the start of the string. ! \\Z Matches only at the end of the string. ! \\b Matches the empty string, but only at the start or end of a word. ! \\B Matches the empty string, but not at the start or end of a word. ! \\d Matches any decimal digit; equivalent to the set [0-9]. ! \\D Matches any non-digit character; equivalent to the set [^0-9]. ! \\s Matches any whitespace character; equivalent to [ \\t\\n\\r\\f\\v]. ! \\S Matches any non-whitespace character; equiv. to [^ \\t\\n\\r\\f\\v]. ! \\w Matches any alphanumeric character; equivalent to [a-zA-Z0-9_]. ! With LOCALE, it will match the set [0-9_] plus characters defined ! as letters for the current locale. ! \\W Matches the complement of \\w. ! \\\\ Matches a literal backslash. ! ! This module exports the following functions: ! match Match a regular expression pattern to the beginning of a string. ! search Search a string for the presence of a pattern. ! sub Substitute occurrences of a pattern found in a string. ! subn Same as sub, but also return the number of substitutions made. ! split Split a string by the occurrences of a pattern. ! findall Find all occurrences of a pattern in a string. ! compile Compile a pattern into a RegexObject. ! escape Backslash all non-alphanumerics in a string. ! ! This module exports the following classes: ! RegexObject Holds a compiled regular expression pattern. ! MatchObject Contains information about pattern matches. ! ! Some of the functions in this module takes flags as optional parameters: ! I IGNORECASE Perform case-insensitive matching. ! L LOCALE Make \w, \W, \b, \B, dependent on the current locale. ! M MULTILINE "^" matches the beginning of lines as well as the string. ! "$" matches the end of lines as well as the string. ! S DOTALL "." matches any character at all, including the newline. ! X VERBOSE Ignore whitespaces and comments for nicer looking RE's. ! ! This module also defines an exception 'error'. ! ! """ ! ! ! import sys ! import string ! from pcre import * ! ! # ! # First, the public part of the interface: ! # ! ! # pcre.error and re.error should be the same, since exceptions can be ! # raised from either module. ! ! # compilation flags ! ! I = IGNORECASE ! L = LOCALE ! M = MULTILINE ! S = DOTALL ! X = VERBOSE ! ! ! # ! # ! # ! ! _cache = {} ! _MAXCACHE = 20 ! ! def _cachecompile(pattern, flags=0): ! key = (pattern, flags) ! try: ! return _cache[key] ! except KeyError: ! pass ! value = compile(pattern, flags) ! if len(_cache) >= _MAXCACHE: ! _cache.clear() ! _cache[key] = value ! return value ! ! def match(pattern, string, flags=0): ! """match (pattern, string[, flags]) -> MatchObject or None ! ! If zero or more characters at the beginning of string match the ! regular expression pattern, return a corresponding MatchObject ! instance. Return None if the string does not match the pattern; ! note that this is different from a zero-length match. ! ! Note: If you want to locate a match anywhere in string, use ! search() instead. ! ! """ ! ! return _cachecompile(pattern, flags).match(string) ! ! def search(pattern, string, flags=0): ! """search (pattern, string[, flags]) -> MatchObject or None ! ! Scan through string looking for a location where the regular ! expression pattern produces a match, and return a corresponding ! MatchObject instance. Return None if no position in the string ! matches the pattern; note that this is different from finding a ! zero-length match at some point in the string. ! ! """ ! return _cachecompile(pattern, flags).search(string) ! ! def sub(pattern, repl, string, count=0): ! """sub(pattern, repl, string[, count=0]) -> string ! ! Return the string obtained by replacing the leftmost ! non-overlapping occurrences of pattern in string by the ! replacement repl. If the pattern isn't found, string is returned ! unchanged. repl can be a string or a function; if a function, it ! is called for every non-overlapping occurrence of pattern. The ! function takes a single match object argument, and returns the ! replacement string. ! ! The pattern may be a string or a regex object; if you need to ! specify regular expression flags, you must use a regex object, or ! use embedded modifiers in a pattern; e.g. ! sub("(?i)b+", "x", "bbbb BBBB") returns 'x x'. ! ! The optional argument count is the maximum number of pattern ! occurrences to be replaced; count must be a non-negative integer, ! and the default value of 0 means to replace all occurrences. ! ! """ ! if type(pattern) == type(''): ! pattern = _cachecompile(pattern) ! return pattern.sub(repl, string, count) ! ! def subn(pattern, repl, string, count=0): ! """subn(pattern, repl, string[, count=0]) -> (string, num substitutions) ! ! Perform the same operation as sub(), but return a tuple ! (new_string, number_of_subs_made). ! ! """ ! if type(pattern) == type(''): ! pattern = _cachecompile(pattern) ! return pattern.subn(repl, string, count) ! ! def split(pattern, string, maxsplit=0): ! """split(pattern, string[, maxsplit=0]) -> list of strings ! ! Split string by the occurrences of pattern. If capturing ! parentheses are used in pattern, then the text of all groups in ! the pattern are also returned as part of the resulting list. If ! maxsplit is nonzero, at most maxsplit splits occur, and the ! remainder of the string is returned as the final element of the ! list. ! ! """ ! if type(pattern) == type(''): ! pattern = _cachecompile(pattern) ! return pattern.split(string, maxsplit) ! ! def findall(pattern, string): ! """findall(pattern, string) -> list ! ! Return a list of all non-overlapping matches of pattern in ! string. If one or more groups are present in the pattern, return a ! list of groups; this will be a list of tuples if the pattern has ! more than one group. Empty matches are included in the result. ! ! """ ! if type(pattern) == type(''): ! pattern = _cachecompile(pattern) ! return pattern.findall(string) ! ! def escape(pattern): ! """escape(string) -> string ! ! Return string with all non-alphanumerics backslashed; this is ! useful if you want to match an arbitrary literal string that may ! have regular expression metacharacters in it. ! ! """ ! result = list(pattern) ! alphanum=string.letters+'_'+string.digits ! for i in range(len(pattern)): ! char = pattern[i] ! if char not in alphanum: ! if char=='\000': result[i] = '\\000' ! else: result[i] = '\\'+char ! return string.join(result, '') ! ! def compile(pattern, flags=0): ! """compile(pattern[, flags]) -> RegexObject ! ! Compile a regular expression pattern into a regular expression ! object, which can be used for matching using its match() and ! search() methods. ! ! """ ! groupindex={} ! code=pcre_compile(pattern, flags, groupindex) ! return RegexObject(pattern, flags, code, groupindex) ! ! ! # ! # Class definitions ! # ! ! class RegexObject: ! """Holds a compiled regular expression pattern. ! ! Methods: ! match Match the pattern to the beginning of a string. ! search Search a string for the presence of the pattern. ! sub Substitute occurrences of the pattern found in a string. ! subn Same as sub, but also return the number of substitutions made. ! split Split a string by the occurrences of the pattern. ! findall Find all occurrences of the pattern in a string. ! ! """ ! ! def __init__(self, pattern, flags, code, groupindex): ! self.code = code ! self.flags = flags ! self.pattern = pattern ! self.groupindex = groupindex ! ! def search(self, string, pos=0, endpos=None): ! """search(string[, pos][, endpos]) -> MatchObject or None ! ! Scan through string looking for a location where this regular ! expression produces a match, and return a corresponding ! MatchObject instance. Return None if no position in the string ! matches the pattern; note that this is different from finding ! a zero-length match at some point in the string. The optional ! pos and endpos parameters have the same meaning as for the ! match() method. ! ! """ ! if endpos is None or endpos>len(string): ! endpos=len(string) ! if endpos MatchObject or None ! ! If zero or more characters at the beginning of string match ! this regular expression, return a corresponding MatchObject ! instance. Return None if the string does not match the ! pattern; note that this is different from a zero-length match. ! ! Note: If you want to locate a match anywhere in string, use ! search() instead. ! ! The optional second parameter pos gives an index in the string ! where the search is to start; it defaults to 0. This is not ! completely equivalent to slicing the string; the '' pattern ! character matches at the real beginning of the string and at ! positions just after a newline, but not necessarily at the ! index where the search is to start. ! ! The optional parameter endpos limits how far the string will ! be searched; it will be as if the string is endpos characters ! long, so only the characters from pos to endpos will be ! searched for a match. ! ! """ ! if endpos is None or endpos>len(string): ! endpos=len(string) ! if endpos string ! ! Return the string obtained by replacing the leftmost ! non-overlapping occurrences of the compiled pattern in string ! by the replacement repl. If the pattern isn't found, string is ! returned unchanged. ! ! Identical to the sub() function, using the compiled pattern. ! ! """ ! return self.subn(repl, string, count)[0] ! ! def subn(self, repl, source, count=0): ! """subn(repl, string[, count=0]) -> tuple ! ! Perform the same operation as sub(), but return a tuple ! (new_string, number_of_subs_made). ! ! """ ! if count < 0: ! raise error, "negative substitution count" ! if count == 0: ! count = sys.maxint ! n = 0 # Number of matches ! pos = 0 # Where to start searching ! lastmatch = -1 # End of last match ! results = [] # Substrings making up the result ! end = len(source) ! ! if type(repl) is type(''): ! # See if repl contains group references ! try: ! repl = pcre_expand(_Dummy, repl) ! except: ! m = MatchObject(self, source, 0, end, []) ! repl = lambda m, repl=repl, expand=pcre_expand: expand(m, repl) ! else: ! m = None ! else: ! m = MatchObject(self, source, 0, end, []) ! ! match = self.code.match ! append = results.append ! while n < count and pos <= end: ! regs = match(source, pos, end, 0) ! if not regs: ! break ! self._num_regs = len(regs) ! i, j = regs[0] ! if i == j == lastmatch: ! # Empty match adjacent to previous match ! pos = pos + 1 ! append(source[lastmatch:pos]) ! continue ! if pos < i: ! append(source[pos:i]) ! if m: ! m.pos = pos ! m.regs = regs ! append(repl(m)) ! else: ! append(repl) ! pos = lastmatch = j ! if i == j: ! # Last match was empty; don't try here again ! pos = pos + 1 ! append(source[lastmatch:pos]) ! n = n + 1 ! append(source[pos:]) ! return (string.join(results, ''), n) ! ! def split(self, source, maxsplit=0): ! """split(source[, maxsplit=0]) -> list of strings ! ! Split string by the occurrences of the compiled pattern. If ! capturing parentheses are used in the pattern, then the text ! of all groups in the pattern are also returned as part of the ! resulting list. If maxsplit is nonzero, at most maxsplit ! splits occur, and the remainder of the string is returned as ! the final element of the list. ! ! """ ! if maxsplit < 0: ! raise error, "negative split count" ! if maxsplit == 0: ! maxsplit = sys.maxint ! n = 0 ! pos = 0 ! lastmatch = 0 ! results = [] ! end = len(source) ! match = self.code.match ! append = results.append ! while n < maxsplit: ! regs = match(source, pos, end, 0) ! if not regs: ! break ! i, j = regs[0] ! if i == j: ! # Empty match ! if pos >= end: ! break ! pos = pos+1 ! continue ! append(source[lastmatch:i]) ! rest = regs[1:] ! if rest: ! for a, b in rest: ! if a == -1 or b == -1: ! group = None ! else: ! group = source[a:b] ! append(group) ! pos = lastmatch = j ! n = n + 1 ! append(source[lastmatch:]) ! return results ! ! def findall(self, source): ! """findall(source) -> list ! ! Return a list of all non-overlapping matches of the compiled ! pattern in string. If one or more groups are present in the ! pattern, return a list of groups; this will be a list of ! tuples if the pattern has more than one group. Empty matches ! are included in the result. ! ! """ ! pos = 0 ! end = len(source) ! results = [] ! match = self.code.match ! append = results.append ! while pos <= end: ! regs = match(source, pos, end, 0) ! if not regs: ! break ! i, j = regs[0] ! rest = regs[1:] ! if not rest: ! gr = source[i:j] ! elif len(rest) == 1: ! a, b = rest[0] ! gr = source[a:b] ! else: ! gr = [] ! for (a, b) in rest: ! gr.append(source[a:b]) ! gr = tuple(gr) ! append(gr) ! pos = max(j, pos+1) ! return results ! ! # The following 3 functions were contributed by Mike Fletcher, and ! # allow pickling and unpickling of RegexObject instances. ! def __getinitargs__(self): ! return (None,None,None,None) # any 4 elements, to work around ! # problems with the ! # pickle/cPickle modules not yet ! # ignoring the __init__ function ! def __getstate__(self): ! return self.pattern, self.flags, self.groupindex ! def __setstate__(self, statetuple): ! self.pattern = statetuple[0] ! self.flags = statetuple[1] ! self.groupindex = statetuple[2] ! self.code = apply(pcre_compile, statetuple) ! ! class _Dummy: ! # Dummy class used by _subn_string(). Has 'group' to avoid core dump. ! group = None ! ! class MatchObject: ! """Holds a compiled regular expression pattern. ! ! Methods: ! start Return the index of the start of a matched substring. ! end Return the index of the end of a matched substring. ! span Return a tuple of (start, end) of a matched substring. ! groups Return a tuple of all the subgroups of the match. ! group Return one or more subgroups of the match. ! groupdict Return a dictionary of all the named subgroups of the match. ! ! """ ! ! def __init__(self, re, string, pos, endpos, regs): ! self.re = re ! self.string = string ! self.pos = pos ! self.endpos = endpos ! self.regs = regs ! ! def start(self, g = 0): ! """start([group=0]) -> int or None ! ! Return the index of the start of the substring matched by ! group; group defaults to zero (meaning the whole matched ! substring). Return None if group exists but did not contribute ! to the match. ! ! """ ! if type(g) == type(''): ! try: ! g = self.re.groupindex[g] ! except (KeyError, TypeError): ! raise IndexError, 'group %s is undefined' % `g` ! return self.regs[g][0] ! ! def end(self, g = 0): ! """end([group=0]) -> int or None ! ! Return the indices of the end of the substring matched by ! group; group defaults to zero (meaning the whole matched ! substring). Return None if group exists but did not contribute ! to the match. ! ! """ ! if type(g) == type(''): ! try: ! g = self.re.groupindex[g] ! except (KeyError, TypeError): ! raise IndexError, 'group %s is undefined' % `g` ! return self.regs[g][1] ! ! def span(self, g = 0): ! """span([group=0]) -> tuple ! ! Return the 2-tuple (m.start(group), m.end(group)). Note that ! if group did not contribute to the match, this is (None, ! None). Group defaults to zero (meaning the whole matched ! substring). ! ! """ ! if type(g) == type(''): ! try: ! g = self.re.groupindex[g] ! except (KeyError, TypeError): ! raise IndexError, 'group %s is undefined' % `g` ! return self.regs[g] ! ! def groups(self, default=None): ! """groups([default=None]) -> tuple ! ! Return a tuple containing all the subgroups of the match, from ! 1 up to however many groups are in the pattern. The default ! argument is used for groups that did not participate in the ! match. ! ! """ ! result = [] ! for g in range(1, self.re._num_regs): ! a, b = self.regs[g] ! if a == -1 or b == -1: ! result.append(default) ! else: ! result.append(self.string[a:b]) ! return tuple(result) ! ! def group(self, *groups): ! """group([group1, group2, ...]) -> string or tuple ! ! Return one or more subgroups of the match. If there is a ! single argument, the result is a single string; if there are ! multiple arguments, the result is a tuple with one item per ! argument. Without arguments, group1 defaults to zero (i.e. the ! whole match is returned). If a groupN argument is zero, the ! corresponding return value is the entire matching string; if ! it is in the inclusive range [1..99], it is the string ! matching the the corresponding parenthesized group. If a group ! number is negative or larger than the number of groups defined ! in the pattern, an IndexError exception is raised. If a group ! is contained in a part of the pattern that did not match, the ! corresponding result is None. If a group is contained in a ! part of the pattern that matched multiple times, the last ! match is returned. ! ! If the regular expression uses the (?P...) syntax, the ! groupN arguments may also be strings identifying groups by ! their group name. If a string argument is not used as a group ! name in the pattern, an IndexError exception is raised. ! ! """ ! if len(groups) == 0: ! groups = (0,) ! result = [] ! for g in groups: ! if type(g) == type(''): ! try: ! g = self.re.groupindex[g] ! except (KeyError, TypeError): ! raise IndexError, 'group %s is undefined' % `g` ! if g >= len(self.regs): ! raise IndexError, 'group %s is undefined' % `g` ! a, b = self.regs[g] ! if a == -1 or b == -1: ! result.append(None) ! else: ! result.append(self.string[a:b]) ! if len(result) > 1: ! return tuple(result) ! elif len(result) == 1: ! return result[0] ! else: ! return () ! ! def groupdict(self, default=None): ! """groupdict([default=None]) -> dictionary ! ! Return a dictionary containing all the named subgroups of the ! match, keyed by the subgroup name. The default argument is ! used for groups that did not participate in the match. ! ! """ ! dict = {} ! for name, index in self.re.groupindex.items(): ! a, b = self.regs[index] ! if a == -1 or b == -1: ! dict[name] = default ! else: ! dict[name] = self.string[a:b] ! return dict --- 1,11 ---- ! # change this to "pre" if your regexps stopped working. don't ! # forget to send a bug report to ! engine = "sre" ! if engine == "sre": ! # new 2.0 engine ! from sre import * ! else: ! # old 1.5.2 engine. will be removed in 2.0 final. ! from pre import * From python-dev@python.org Fri Jun 30 17:39:29 2000 From: python-dev@python.org (Skip Montanaro) Date: Fri, 30 Jun 2000 09:39:29 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test regrtest.py,1.16,1.17 Message-ID: <200006301639.JAA00851@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv843 Modified Files: regrtest.py Log Message: * added a randomize flag and corresponding -r command line argument that allows the caller to execute the various tests in pseudo-random order - default is still to execute tests in the order returned by findtests(). * moved initialization of the various flag variables to the main() function definition, making it possible to execute regrtest.main() interactively and still override default behavior. Index: regrtest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** regrtest.py 2000/05/05 14:27:39 1.16 --- regrtest.py 2000/06/30 16:39:27 1.17 *************** *** 14,17 **** --- 14,18 ---- -x: exclude -- arguments are tests to *exclude* -s: single -- run only a single test (see below) + -r: random -- randomize test execution order If non-option arguments are present, they are names for tests to run, *************** *** 34,41 **** import getopt import traceback import test_support ! def main(tests=None, testdir=None): """Execute a test suite. --- 35,44 ---- import getopt import traceback + import random import test_support ! def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, ! exclude=0, single=0, randomize=0): """Execute a test suite. *************** *** 53,70 **** command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. ! """ try: ! opts, args = getopt.getopt(sys.argv[1:], 'vgqxs') except getopt.error, msg: print msg print __doc__ return 2 - verbose = 0 - quiet = 0 - generate = 0 - exclude = 0 - single = 0 for o, a in opts: if o == '-v': verbose = verbose+1 --- 56,72 ---- command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. ! ! The other six default arguments (verbose, quiet, generate, exclude, ! single, and randomize) allow programmers calling main() directly to ! set the values that would normally be set by flags on the command ! line. """ try: ! opts, args = getopt.getopt(sys.argv[1:], 'vgqxsr') except getopt.error, msg: print msg print __doc__ return 2 for o, a in opts: if o == '-v': verbose = verbose+1 *************** *** 73,76 **** --- 75,79 ---- if o == '-x': exclude = 1 if o == '-s': single = 1 + if o == '-r': randomize = 1 if generate and verbose: print "-g and -v don't go together!" *************** *** 105,108 **** --- 108,113 ---- if single: tests = tests[:1] + if randomize: + random.shuffle(tests) test_support.verbose = verbose # Tell tests to be moderately quiet save_modules = sys.modules.keys() From python-dev@python.org Fri Jun 30 17:39:37 2000 From: python-dev@python.org (Barry Warsaw) Date: Fri, 30 Jun 2000 09:39:37 -0700 Subject: [Python-checkins] CVS: python/dist/src configure,1.122,1.123 configure.in,1.131,1.132 Message-ID: <200006301639.JAA00863@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv730 Modified Files: configure configure.in Log Message: Document --with-thread as deprecated. This gets rid of the annoying newline in configure --help. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.122 retrieving revision 1.123 diff -C2 -r1.122 -r1.123 *** configure 2000/06/30 16:21:00 1.122 --- configure 2000/06/30 16:39:35 1.123 *************** *** 1,5 **** #! /bin/sh ! # From configure.in Revision: 1.130 # Guess values for system-dependent variables and create Makefiles. --- 1,5 ---- #! /bin/sh ! # From configure.in Revision: 1.131 [...2128 lines suppressed...] echo $ac_n "checking for socklen_t""... $ac_c" 1>&6 ! echo "configure:5640: checking for socklen_t" >&5 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 < --- 5638,5647 ---- EOF echo $ac_n "checking for socklen_t""... $ac_c" 1>&6 ! echo "configure:5641: checking for socklen_t" >&5 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 < Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.131 retrieving revision 1.132 diff -C2 -r1.131 -r1.132 *** configure.in 2000/06/30 16:21:01 1.131 --- configure.in 2000/06/30 16:39:35 1.132 *************** *** 662,666 **** # --with-thread is deprecated, but check for it anyway ! AC_ARG_WITH(thread,,[with_threads=$with_thread]) if test -z "$with_threads" --- 662,668 ---- # --with-thread is deprecated, but check for it anyway ! AC_ARG_WITH(thread, ! [ --with(out)-thread[=DIRECTORY] deprecated; use --with(out)-threads],[ ! with_threads=$with_thread]) if test -z "$with_threads" From python-dev@python.org Fri Jun 30 18:30:21 2000 From: python-dev@python.org (Jeremy Hylton) Date: Fri, 30 Jun 2000 10:30:21 -0700 Subject: [Python-checkins] CVS: python/dist/src README,1.86,1.87 Message-ID: <200006301730.KAA10046@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv9905 Modified Files: README Log Message: add note about what happened to Python 1.6 also, fix type (not caught by Rob Hooft, but could have been :-) Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/README,v retrieving revision 1.86 retrieving revision 1.87 diff -C2 -r1.86 -r1.87 *** README 2000/06/29 22:28:44 1.86 --- README 2000/06/30 17:30:18 1.87 *************** *** 21,25 **** enterprise customers are often fearful of anything that's version 1.x! The new version number also clearly marks departure of Python's core ! development teal from CNRI to join BeOpen.com. Previously, the version number 2.0 was associated with a mythical and --- 21,29 ---- enterprise customers are often fearful of anything that's version 1.x! The new version number also clearly marks departure of Python's core ! development team from CNRI to join BeOpen.com. ! ! What happened to Python 1.6? It was promoted and renamed Python 2.0. ! There were two alpha releases of Python 1.6 before we decided to ! increment the major version number. Previously, the version number 2.0 was associated with a mythical and From python-dev@python.org Fri Jun 30 18:48:54 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 10:48:54 -0700 Subject: [Python-checkins] CVS: python/dist/src/PC msvcrtmodule.c,1.4,1.5 _winreg.c,1.5,1.6 Message-ID: <200006301748.KAA11055@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv11047/PC Modified Files: msvcrtmodule.c _winreg.c Log Message: [*** Not tested as I don't have Windows running right now! ***] Trent Mick : Fix PC/msvcrtmodule.c and PC/winreg.c for Win64. Basically: - sizeof(HKEY) > sizeof(long) on Win64, so use PyLong_FromVoidPtr() instead of PyInt_FromLong() to return HKEY values on Win64 - Check for string overflow of an arbitrary registry value (I know that ensuring that a registry value does not overflow 2**31 characters seems ridiculous but it is *possible*). Closes SourceForge patch #100517. Index: msvcrtmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/msvcrtmodule.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** msvcrtmodule.c 1999/02/16 19:40:02 1.4 --- msvcrtmodule.c 2000/06/30 17:48:51 1.5 *************** *** 91,95 **** { int fd; ! long handle; if (!PyArg_ParseTuple(args,"i:get_osfhandle", &fd)) --- 91,95 ---- { int fd; ! intptr_t handle; if (!PyArg_ParseTuple(args,"i:get_osfhandle", &fd)) *************** *** 100,104 **** return PyErr_SetFromErrno(PyExc_IOError); ! return PyInt_FromLong(handle); } --- 100,107 ---- return PyErr_SetFromErrno(PyExc_IOError); ! /* technically 'handle' is not a pointer, but a integer as ! large as a pointer, Python's *VoidPtr interface is the ! most appropriate here */ ! return PyLong_FromVoidPtr((void*)handle); } Index: _winreg.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/_winreg.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** _winreg.c 2000/06/29 19:17:04 1.5 --- _winreg.c 2000/06/30 17:48:51 1.6 *************** *** 593,597 **** if (PyErr_Occurred()) return FALSE; - *pHANDLE = (HKEY)PyInt_AsLong(ob); } else { --- 593,596 ---- *************** *** 629,632 **** --- 628,632 ---- ok = PyHKEY_Close(obHandle); } + #if SIZEOF_LONG >= SIZEOF_HKEY else if (PyInt_Check(obHandle)) { long rc = RegCloseKey((HKEY)PyInt_AsLong(obHandle)); *************** *** 635,638 **** --- 635,646 ---- PyErr_SetFromWindowsErrWithFunction(rc, "RegCloseKey"); } + #else + else if (PyLong_Check(obHandle)) { + long rc = RegCloseKey((HKEY)PyLong_AsVoidPtr(obHandle)); + ok = (rc == ERROR_SUCCESS); + if (!ok) + PyErr_SetFromWindowsErrWithFunction(rc, "RegCloseKey"); + } + #endif else { PyErr_SetString( *************** *** 881,891 **** fixupMultiSZ(str, retDataBuf, retDataSize); obData = PyList_New(s); for (index = 0; index < s; index++) { PyList_SetItem(obData, index, PyUnicode_DecodeMBCS( (const char *)str[index], ! _mbstrlen(str[index]), NULL) ); --- 889,908 ---- fixupMultiSZ(str, retDataBuf, retDataSize); obData = PyList_New(s); + if (obData == NULL) + return NULL; for (index = 0; index < s; index++) { + size_t len = _mbstrlen(str[index]); + if (len > INT_MAX) { + PyErr_SetString(PyExc_OverflowError, + "registry string is too long for a Python string"); + Py_DECREF(obData); + return NULL; + } PyList_SetItem(obData, index, PyUnicode_DecodeMBCS( (const char *)str[index], ! (int)len, NULL) ); From python-dev@python.org Fri Jun 30 18:57:08 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 10:57:08 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/texinputs python.sty,1.60,1.61 Message-ID: <200006301757.KAA11755@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/texinputs In directory slayer.i.sourceforge.net:/tmp/cvs-serv11742/texinputs Modified Files: python.sty Log Message: Try to make sure \code always uses roman (non-italic) text. Change a 1.6 version number used in a an example in a comment to 2.0. Index: python.sty =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/texinputs/python.sty,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -r1.60 -r1.61 *** python.sty 2000/05/09 16:18:44 1.60 --- python.sty 2000/06/30 17:57:05 1.61 *************** *** 711,715 **** % code is the most difficult one... ! \newcommand{\code}[1]{{\@vobeyspaces\@noligs\def\{{\char`\{}\def\}{\char`\}}\def\~{\char`\~}\def\^{\char`\^}\def\e{\char`\\}\def\${\char`\$}\def\#{\char`\#}\def\&{\char`\&}\def\%{\char`\%}% \texttt{#1}}} --- 711,715 ---- % code is the most difficult one... ! \newcommand{\code}[1]{\textrm{\@vobeyspaces\@noligs\def\{{\char`\{}\def\}{\char`\}}\def\~{\char`\~}\def\^{\char`\^}\def\e{\char`\\}\def\${\char`\$}\def\#{\char`\#}\def\&{\char`\&}\def\%{\char`\%}% \texttt{#1}}} *************** *** 839,843 **** % Example: % \versionadded{1.5.2} ! % \versionchanged[short explanation]{1.6} % \newcommand{\versionadded}[1]{% --- 839,843 ---- % Example: % \versionadded{1.5.2} ! % \versionchanged[short explanation]{2.0} % \newcommand{\versionadded}[1]{% From python-dev@python.org Fri Jun 30 18:58:36 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 10:58:36 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/ext ext.tex,1.77,1.78 Message-ID: <200006301758.KAA11837@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/ext In directory slayer.i.sourceforge.net:/tmp/cvs-serv11830/ext Modified Files: ext.tex Log Message: Small grammatical correction from Frank Stajano. Added comment with suggestion from Frank for an example and further explanation. Index: ext.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/ext.tex,v retrieving revision 1.77 retrieving revision 1.78 diff -C2 -r1.77 -r1.78 *** ext.tex 2000/06/28 16:15:08 1.77 --- ext.tex 2000/06/30 17:58:34 1.78 *************** *** 1399,1403 **** arguments is that functions often pass the objects they receive on to other function --- if each function were to test for \NULL{}, ! there would be a lot of redundant tests and the code would run slower. It is better to test for \NULL{} only at the ``source'', i.e.\ when a --- 1399,1404 ---- arguments is that functions often pass the objects they receive on to other function --- if each function were to test for \NULL{}, ! there would be a lot of redundant tests and the code would run more ! slowly. It is better to test for \NULL{} only at the ``source'', i.e.\ when a *************** *** 1423,1427 **** It is a severe error to ever let a \NULL{} pointer ``escape'' to ! the Python user. --- 1424,1434 ---- It is a severe error to ever let a \NULL{} pointer ``escape'' to ! the Python user. ! ! % Frank Stajano: ! % A pedagogically buggy example, along the lines of the previous listing, ! % would be helpful here -- showing in more concrete terms what sort of ! % actions could cause the problem. I can't very well imagine it from the ! % description. From python-dev@python.org Fri Jun 30 19:39:23 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 11:39:23 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre_compile.py,1.16,1.17 sre_parse.py,1.16,1.17 Message-ID: <200006301839.LAA20318@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv20255/Lib Modified Files: sre_compile.py sre_parse.py Log Message: - reverted to "\x is binary byte" - removed evil tabs from sre_parse and sre_compile Index: sre_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** sre_compile.py 2000/06/30 13:55:14 1.16 --- sre_compile.py 2000/06/30 18:39:20 1.17 *************** *** 40,44 **** else: emit(OPCODES[op]) ! fixup = lambda x: x skip = len(code); emit(0) for op, av in av: --- 40,44 ---- else: emit(OPCODES[op]) ! fixup = lambda x: x skip = len(code); emit(0) for op, av in av: Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** sre_parse.py 2000/06/30 13:55:14 1.16 --- sre_parse.py 2000/06/30 18:39:20 1.17 *************** *** 20,25 **** MAXREPEAT = 32767 ! # FIXME: same here ! CHARMASK = 0x7fff SPECIAL_CHARS = ".\\[{()*+?^$|" --- 20,26 ---- MAXREPEAT = 32767 ! # FIXME: might change in 2.0 final. but for now, this seems ! # to be the best way to be compatible with 1.5.2 ! CHARMASK = 0xff SPECIAL_CHARS = ".\\[{()*+?^$|" *************** *** 617,623 **** sep = match.string[:0] if type(sep) is type(""): ! char = chr else: ! char = unichr for c, s in template: if c is LITERAL: --- 618,624 ---- sep = match.string[:0] if type(sep) is type(""): ! char = chr else: ! char = unichr for c, s in template: if c is LITERAL: From python-dev@python.org Fri Jun 30 19:39:23 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 11:39:23 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_sre,1.4,1.5 Message-ID: <200006301839.LAA20322@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv20255/Lib/test/output Modified Files: test_sre Log Message: - reverted to "\x is binary byte" - removed evil tabs from sre_parse and sre_compile Index: test_sre =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_sre,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** test_sre 2000/06/30 13:55:15 1.4 --- test_sre 2000/06/30 18:39:20 1.5 *************** *** 1,4 **** test_sre - === Failed incorrectly ('\\x00ffffffffffffff', '\377', 0, 'found', '\377') === Failed incorrectly ('^(.+)?B', 'AB', 0, 'g1', 'A') === Failed incorrectly ('(a+)+\\1', 'aa', 0, 'found+"-"+g1', 'aa-a') --- 1,3 ---- From python-dev@python.org Fri Jun 30 19:41:04 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 11:41:04 -0700 Subject: [Python-checkins] CVS: python/dist/src/Misc COPYRIGHT,1.4,1.5 Message-ID: <200006301841.LAA20523@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Misc In directory slayer.i.sourceforge.net:/tmp/cvs-serv20516/Misc Modified Files: COPYRIGHT Log Message: The new copyright / license. Index: COPYRIGHT =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/COPYRIGHT,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** COPYRIGHT 1996/10/25 13:45:43 1.4 --- COPYRIGHT 2000/06/30 18:41:01 1.5 *************** *** 1,27 **** ! Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, ! The Netherlands. ! All Rights Reserved ! Permission to use, copy, modify, and distribute this software and its ! documentation for any purpose and without fee is hereby granted, ! provided that the above copyright notice appear in all copies and that ! both that copyright notice and this permission notice appear in ! supporting documentation, and that the names of Stichting Mathematisch ! Centrum or CWI or Corporation for National Research Initiatives or ! CNRI not be used in advertising or publicity pertaining to ! distribution of the software without specific, written prior ! permission. ! While CWI is the initial source for this software, a modified version ! is made available by the Corporation for National Research Initiatives ! (CNRI) at the Internet address ftp://ftp.python.org. ! STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH ! REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF ! MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH ! CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL ! DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR ! PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER ! TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR ! PERFORMANCE OF THIS SOFTWARE. --- 1,31 ---- ! Copyright (c) 2000, BeOpen.com. ! Copyright (c) 1995-2000, Corporation for National Research Initiatives. ! Copyright (c) 1990-1995, Stichting Mathematisch Centrum. ! All rights reserved. ! Redistribution and use in source and binary forms, with or without ! modification, are permitted provided that the following conditions are ! met: ! - Redistributions of source code must retain the above copyright ! notice, this list of conditions and the following disclaimer. ! - Redistributions in binary form must reproduce the above copyright ! notice, this list of conditions and the following disclaimer in the ! documentation and/or other materials provided with the distribution. ! - Neither names of the copyright holders nor the names of their ! contributors may be used to endorse or promote products derived from ! this software without specific prior written permission. ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ! A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR ! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, ! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR ! PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ! LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ! NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ! SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. From python-dev@python.org Fri Jun 30 18:35:20 2000 From: python-dev@python.org (Skip Montanaro) Date: Fri, 30 Jun 2000 12:35:20 -0500 (CDT) Subject: [Python-checkins] CVS: python/dist/src/Misc COPYRIGHT,1.4,1.5 In-Reply-To: <200006301841.LAA20523@slayer.i.sourceforge.net> References: <200006301841.LAA20523@slayer.i.sourceforge.net> Message-ID: <14684.55896.890339.982232@beluga.mojam.com> Fred> The new copyright / license. ... Fred> ! ... IN NO EVENT SHALL THE REGENTS OR Fred> ! CONTRIBUTORS BE LIABLE FOR ... Who are the "regents" and the "contributors"? Should those terms be defined somewhere? not-a-lawyer-and-never-wanted-to-be-ly y'rs, -- Skip Montanaro, skip@mojam.com, http://www.mojam.com/, http://www.musi-cal.com/ On Phil Jackson's ability to manage multiple Lakers superstars, Shaquille O'Neal said: "He's got the rings. I listen to the man with the rings." From python-dev@python.org Fri Jun 30 20:25:44 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 12:25:44 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/paper-a4 .cvsignore,1.7,1.8 Message-ID: <200006301925.MAA29446@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/paper-a4 In directory slayer.i.sourceforge.net:/tmp/cvs-serv29439/paper-a4 Modified Files: .cvsignore Log Message: Ignore the generated api.tex. Index: .cvsignore =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/paper-a4/.cvsignore,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** .cvsignore 1999/03/16 16:14:51 1.7 --- .cvsignore 2000/06/30 19:25:41 1.8 *************** *** 14,15 **** --- 14,16 ---- *.how README + api.tex From python-dev@python.org Fri Jun 30 20:33:37 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 12:33:37 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib whrandom.py,1.16,1.17 Message-ID: <200006301933.MAA29761@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv29748/Lib Modified Files: whrandom.py Log Message: Line-wrap and properly indent a couple of docstrings. Index: whrandom.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/whrandom.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** whrandom.py 2000/02/28 15:12:25 1.16 --- whrandom.py 2000/06/30 19:33:35 1.17 *************** *** 83,87 **** def randint(self, a, b): ! """Get a random integer in the range [a, b] including both end points. (Deprecated; use randrange below.)""" return self.randrange(a, b+1) --- 83,89 ---- def randint(self, a, b): ! """Get a random integer in the range [a, b] including ! both end points. ! (Deprecated; use randrange below.)""" return self.randrange(a, b+1) *************** *** 92,99 **** def randrange(self, start, stop=None, step=1, int=int, default=None): ! """Choose a random item from range([start,] step[, stop]). This fixes the problem with randint() which includes the endpoint; in Python this is usually not what you want. ! Do not supply the 'int' and 'default' arguments.""" # This code is a bit messy to make it fast for the # common case while still doing adequate error checking --- 94,102 ---- def randrange(self, start, stop=None, step=1, int=int, default=None): ! """Choose a random item from range(start, stop[, step]). ! This fixes the problem with randint() which includes the endpoint; in Python this is usually not what you want. ! Do not supply the 'int' and 'default' arguments.""" # This code is a bit messy to make it fast for the # common case while still doing adequate error checking From python-dev@python.org Fri Jun 30 20:36:25 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 12:36:25 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_winreg2.py,NONE,1.1 Message-ID: <200006301936.MAA29995@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv29987/Lib/test Added Files: test_winreg2.py Log Message: Paul Prescod : Regression test for the new winreg.py module. [Could a Windows person someone please review this?] --- NEW FILE --- from winreg import hives, createKey, openKey, flags, deleteKey, regtypes import sys, traceback import time def testHives(): hivenames = ["HKEY_CLASSES_ROOT","HKEY_CURRENT_USER","HKEY_LOCAL_MACHINE", "HKEY_USERS","HKEY_CURRENT_CONFIG"] #, # for hivename in hivenames: hive = hives[ hivename ] print hive.name assert hive.handle assert hive.getSubkeys() for hivename in ["HKEY_DYN_DATA", "HKEY_PERFORMANCE_DATA"]: hive = hives[ hivename ] print hive.name assert hive.handle assert not hive.getValues() assert not hive.getSubkeys() def testNonZero(): key=hives["HKLM"].openSubkey( "SOFTWARE" ) assert key.openSubkey( "Microsoft" ) assert key key.close() assert not key try: key.openSubkey( "Microsoft" ) assert 0 except EnvironmentError: pass def testCmp(): HKLM=hives["HKLM"] assert (openKey("HKLM\\SOFTWARE")==\ HKLM.openSubkey("SOFTWARE")) assert not HKLM.openSubkey("SYSTEM")!=HKLM.openSubkey("SYSTEM") assert HKLM.openSubkey("SOFTWARE")!=HKLM.openSubkey("SYSTEM") assert not HKLM.openSubkey("SOFTWARE")==HKLM.openSubkey("SYSTEM") assert not HKLM.openSubkey("SOFTWARE")=="spam" assert ((HKLM.openSubkey("SOFTWARE")<"spam") != (HKLM.openSubkey("SOFTWARE")>"spam")) def testClose(): key=hives["HKLM"].openSubkey( "SOFTWARE" ) assert key key.close() assert not key def testOpen(): assert openKey( r"HKLM" ) assert openKey( r"HKLM\HARDWARE" ) assert openKey( r"HKLM\HARDWARE\DESCRIPTION\System" ) def testOpenFailure(): try: print openKey( r"HKCU\Software\Python\A\B\C\D" ) assert 0 # except EnvironmentError: pass def testDeleteKey(): createKey( r"HKCU\Software\Python\A\B\C\D" ) deleteKey( r"HKCU\Software\Python\A\B\C\D" ) deleteKey( r"HKCU\Software\Python\A\B\C" ) deleteKey( r"HKCU\Software\Python\A\B" ) assert "A" in \ openKey(r"HKCU\Software\Python").getSubkeys().keys() openKey( r"HKCU\Software\Python" ).deleteSubkey( r"A" ) assert "A" not in \ openKey(r"HKCU\Software\Python").getSubkeys().keys() def testDeleteValue(): key=createKey( r"HKCU\Software\Python\A" ) key.setValue( "abcde", "fghij" ) assert key.getValueData( "abcde" )=="fghij" assert "abcde" in key.getValues().keys() assert "fghij" in map( lambda x:x[1], key.getValues().values() ) assert "abcde" in key.getValues().keys() key.deleteValue( "abcde" ) assert "abcde" not in key.getValues().keys() assert "fghij" not in map( lambda x:x[1], key.getValues().values() ) deleteKey( r"HKCU\Software\Python\A" ) def testCreateKey(): key=createKey( r"HKCU\Software\Python\A" ) assert openKey( r"HKCU\Software\Python").getSubkeys().has_key( "A" ) deleteKey( r"HKCU\Software\Python\A" ) assert not openKey( r"HKCU\Software\Python").getSubkeys().\ has_key( "A" ) key=openKey( r"HKCU\Software\Python" ).createSubkey( "A" ) def testOpenKeyWithFlags(): assert openKey( r"HKCU\Software\Python", flags["KEY_READ"]) assert openKey( r"HKCU\Software\Python", flags["KEY_ALL_ACCESS"]) def testGetSubkeys(): keys=openKey( r"HKCU\Software" ).getSubkeys() assert keys index=0 for i in keys: index=index+1 assert index==len( keys ) def testGetValueNameDataAndType(): pass def testGetSubkeyNames(): subkeyNames=hives["HKLM"].getSubkeyNames() assert len( subkeyNames )==len(hives["HKLM"].getSubkeys()) for name in subkeyNames: assert type( name )==type("") def testGetValueNames(): valNames=hives["HKLM"].getValueNames() assert len( valNames )==len(hives["HKLM"].getValues()) for name in valNames: assert type( name )==type("") def testRepr(): assert repr(hives["HKCU"])==str(hives["HKCU"]) def testSetStringValue(): hives["HKCU"].setValue( "Blah", "abc" ) assert hives["HKCU"].getValueData( "Blah" )=="abc" assert hives["HKCU"].getValues().has_key( "Blah" ) del hives["HKCU"].getValues()[ "Blah" ] assert not hives["HKCU"].getValues().has_key( "Blah" ) def testDeleteValue(): hives["HKCU"].setValue( "Blah", "abc" ) assert hives["HKCU"].getValues().has_key( "Blah" ) del hives["HKCU"].getValues()[ "Blah" ] assert not hives["HKCU"].getValues().has_key( "Blah" ) hives["HKCU"].setValue( "Blah", "abc" ) hives["HKCU"].deleteValue( "Blah" ) assert not hives["HKCU"].getValues().has_key( "Blah" ) def testKeyDict_ClearKeys(): createKey( "HKLM\\Software\\a\\b\\c\\d\\e" ) createKey( "HKLM\\Software\\a\\b\\c\\d\\f" ) createKey( "HKLM\\Software\\a\\b\\c\\d\\g" ) createKey( "HKLM\\Software\\a\\b\\c\\d\\h" ) createKey( "HKLM\\Software\\a\\b\\c\\d\\i" ) key=openKey( "HKLM\\Software\\a\\b\\c\\d" ) assert key.getSubkeys() key.getSubkeys().clear() assert not key.getSubkeys() assert not openKey( "HKLM\\Software\\a\\b\\c\\d").getSubkeys() deleteKey( "HKLM\\Software\\a\\b\\c\\d" ) deleteKey( "HKLM\\Software\\a\\b\\c" ) deleteKey( "HKLM\\Software\\a\\b" ) deleteKey( "HKLM\\Software\\a" ) def testUnicodeKeyName(): pass def testUnicodeValueName(): pass def testGetValueDataFromEnum(): pass def testGetValueDataFromName(): pass def testGetBinaryData(): pass def testSetIntValue(): key=createKey( "HKLM\\Software\\a\\b") key.setValue( "abcd", 5 ) assert key.getValueData( "abcd" )==5 assert key.getValues()[ "abcd" ][1]==5 key.deleteValue( "abcd" ) key.getValues()["abcd"]=5 assert key.getValues()[ "abcd" ][1]==5 key.deleteValue( "abcd" ) key.getValues()["abcd"]=(5,regtypes["REG_DWORD"]) assert key.getValues()[ "abcd" ][1]==5 key.deleteValue( "abcd" ) key.deleteKey( "HKLM\\Software\\a\\b") key.deleteKey( "HKLM\\Software\\a") def testSetBinaryValue(): key=createKey( "HKLM\\Software\\a\\b") key.setValue( "abcd", array.array( 'c', "PPPPPPPPPPPPPPP") ) key.setValue( "abcde", array.array( 'c', "PPPPPPPPPPPPPPP"), regtypes["REG_BINARY"] ) assert key.getValues()["abcd"]==key.getValues()["abcde"] key.deleteKey( "HKLM\\Software\\a\\b") key.deleteKey( "HKLM\\Software\\a") def testSetNone(): pass def testSetString(): pass def testSetExpandString(): pass def testSetBinaryData(): pass def testSetDword(): pass def testSetDwordBigEndian(): pass def testSetLink(): pass def testSetMultiSz(): pass def testSetResourceList(): pass def testSetFullResourceDescription(): pass def testSetResourceRequirementsList(): pass def testFlush(): pass def testSave(): pass def testLoad(): pass def testNoneType(): pass def testStringType(): pass def testExpandStringType(): pass def testDWordType(): pass def testDWordBigEndianType(): pass def testLinkType(): pass def testMultiStringType(): pass def testResourceLinkType(): pass def testResourceDescriptionType(): pass def testResourceRequirementsListType(): pass def getSubkeysDict(): pass def testKeyDict_Get(): pass def testKeyDict_HasKey(): pass def testKeyDict_Keys(): pass def testKeyDict_Values(): pass def testKeyDict_Items(): pass def testKeyDict_Length(): pass def testKeyDict_Map(): pass def testKeyDict_GetItem(): pass def testKeyDict_DelItem(): pass def testRemote(): pass def testShortcuts(): pass def getValues(): pass def testValueDict_ClearKeys(): pass def testValueDict_Get(): pass def testValueDict_HasKey(): pass def testValueDict_Keys(): pass def testValueDict_Values(): pass def testValueDict_Items(): pass def testValueDict_Length(): pass def testValueDict_Map(): pass def testValueDict_GetItem(): pass def testValueDict_DelItem(): pass for name in globals().keys(): if name[0:4]=="test": func=globals()[ name ] try: func() print "Test Passed: %s" % name except Exception, e: print "Test Failed: %s" % name traceback.print_exc() j=[0]*len( regtypes ) k=0 def test1( basekey ): global k for (name, data, type) in basekey.getValues(): j[type.intval]=j[type.intval]+1 if j[type.intval]==1: pass #print "[[%s]] %s [%s] = %s "% (type.msname, name, basekey, value) keys=basekey.getSubkeys() index=0 k=k+1 if(k%2500)==0: dump() while 1: try: test1( keys[index] ) index=index+1 except IndexError: break print "Done", basekey, index except (WindowsError, EnvironmentError): index=index+1 dumpfile.write( "Skipping %s %s"% (basekey, index)) def dump(dumpfile): for i in range( len( j )): dumpfile.write( "%s %s\n" %( i,j[i] )) def testRecursive(): dumpfile=open( "foo.txt", "w" ) start=time.time() for hive in hives.values(): dumpfile.write( "Hive: %s\n" % hive ) test1( hive ) dump(dumpfile) print time.time()-start From python-dev@python.org Fri Jun 30 20:38:02 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 30 Jun 2000 12:38:02 -0700 Subject: [Python-checkins] CVS: distutils/distutils msvccompiler.py,1.34,1.35 Message-ID: <200006301938.MAA30140@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv30132 Modified Files: msvccompiler.py Log Message: Simplify the registry-module-finding code: _winreg or win32api/win32con. This'll work fine with 2.0 or 1.5.2, but is less than ideal for 1.6a1/a2. But the code to accomodate 1.6a1/a2 was released with Distutils 0.9, so it can go away now. Index: msvccompiler.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/msvccompiler.py,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -r1.34 -r1.35 *** msvccompiler.py 2000/06/29 23:04:59 1.34 --- msvccompiler.py 2000/06/30 19:37:59 1.35 *************** *** 21,28 **** _can_read_reg = 0 try: ! try: ! import _winreg ! except ImportError: ! import winreg # for pre-2000/06/29 CVS Python _can_read_reg = 1 --- 21,25 ---- _can_read_reg = 0 try: ! import _winreg _can_read_reg = 1 From python-dev@python.org Fri Jun 30 20:38:18 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 12:38:18 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_winreg2,NONE,1.1 Message-ID: <200006301938.MAA30170@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv30161/Lib/test/output Added Files: test_winreg2 Log Message: Output for test_winreg2. Someone who knows what they are doing needs to replace this with something that makes sense -- I'm not running Windows right now. --- NEW FILE --- test_winreg2 From python-dev@python.org Fri Jun 30 21:22:39 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 13:22:39 -0700 Subject: [Python-checkins] CVS: python/dist/src/Misc COPYRIGHT,1.5,1.6 Message-ID: <200006302022.NAA06700@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Misc In directory slayer.i.sourceforge.net:/tmp/cvs-serv6688 Modified Files: COPYRIGHT Log Message: s/REGENTS/COPYRIGHT HOLDERS/ followed by paragraph reflow. Index: COPYRIGHT =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/COPYRIGHT,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** COPYRIGHT 2000/06/30 18:41:01 1.5 --- COPYRIGHT 2000/06/30 20:22:36 1.6 *************** *** 22,31 **** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ! A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR ! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, ! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR ! PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ! LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ! NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ! SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- 22,32 ---- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ! A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ! HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ! INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, ! BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS ! OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ! ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE ! USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH ! DAMAGE. From python-dev@python.org Fri Jun 30 22:23:09 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 16:23:09 -0500 Subject: [Python-Dev] Re: [Python-checkins] CVS: python/dist/src/Misc COPYRIGHT,1.4,1.5 In-Reply-To: Your message of "Fri, 30 Jun 2000 12:35:20 EST." <14684.55896.890339.982232@beluga.mojam.com> References: <200006301841.LAA20523@slayer.i.sourceforge.net> <14684.55896.890339.982232@beluga.mojam.com> Message-ID: <200006302123.QAA20537@cj20424-a.reston1.va.home.com> > Fred> The new copyright / license. > ... > Fred> ! ... IN NO EVENT SHALL THE REGENTS OR > Fred> ! CONTRIBUTORS BE LIABLE FOR ... > > Who are the "regents" and the "contributors"? Should those terms be > defined somewhere? Oops. I thought I caught all the regents and replaced them with a more politically correct term. Seems one got away. Fixed now. > not-a-lawyer-and-never-wanted-to-be-ly y'rs, Ditto, --Guido van Rossum (home page: http://www.python.org/~guido/) From python-dev@python.org Fri Jun 30 21:30:05 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 13:30:05 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild python20.dsp,1.2,1.3 Message-ID: <200006302030.NAA07601@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv7578 Modified Files: python20.dsp Log Message: Add back a missing CRLF line ending. Index: python20.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/python20.dsp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** python20.dsp 2000/06/30 14:38:41 1.2 --- python20.dsp 2000/06/30 20:30:03 1.3 *************** *** 672,676 **** !ENDIF ! # End Source File # Begin Source File --- 672,676 ---- !ENDIF ! # End Source File # Begin Source File From python-dev@python.org Fri Jun 30 21:31:41 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 13:31:41 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-win winreg.py,1.1,1.2 Message-ID: <200006302031.NAA07859@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/plat-win In directory slayer.i.sourceforge.net:/tmp/cvs-serv7849/Lib/plat-win Modified Files: winreg.py Log Message: Ooops! I didn't finish all the renaming needed here, so this was attempting a recursive import and causing a fatal error. Index: winreg.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-win/winreg.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** winreg.py 2000/06/29 16:53:06 1.1 --- winreg.py 2000/06/30 20:31:39 1.2 *************** *** 1,3 **** ! import winreg import sys import exceptions --- 1,3 ---- ! import _winreg import sys import exceptions *************** *** 10,14 **** self.msname=msname self.friendlyname=friendlyname ! self.intval=getattr( winreg, msname ) def __repr__( self ): --- 10,14 ---- self.msname=msname self.friendlyname=friendlyname ! self.intval=getattr( _winreg, msname ) def __repr__( self ): *************** *** 17,44 **** _typeConstants={ ! winreg.REG_NONE: RegType( "REG_NONE", "None" ), ! winreg.REG_SZ: RegType( "REG_SZ", "String" ), ! winreg.REG_EXPAND_SZ: RegType("REG_EXPAND_SZ", "Expandable Template String" ), ! winreg.REG_BINARY: RegType("REG_BINARY", "Binary Data"), ! winreg.REG_DWORD : RegType("REG_DWORD", "Integer" ), ! # winreg.REG_DWORD_LITTLE_ENDIAN : # RegType("REG_DWORD_LITTLE_ENDIAN", "Integer"), ! winreg.REG_DWORD_BIG_ENDIAN : RegType("REG_DWORD_BIG_ENDIAN", "Big Endian Integer"), ! winreg.REG_LINK : RegType("REG_LINK", "Link"), ! winreg.REG_MULTI_SZ : RegType("REG_MULTI_SZ", "List of Strings"), ! winreg.REG_RESOURCE_LIST : RegType("REG_RESOURCE_LIST", "Resource List"), ! winreg.REG_FULL_RESOURCE_DESCRIPTOR : RegType( "REG_FULL_RESOURCE_DESCRIPTOR", "Full Resource Descriptor" ), ! winreg.REG_RESOURCE_REQUIREMENTS_LIST: RegType( "REG_RESOURCE_REQUIREMENTS_LIST", "Resource Requirements List" ) --- 17,44 ---- _typeConstants={ ! _winreg.REG_NONE: RegType( "REG_NONE", "None" ), ! _winreg.REG_SZ: RegType( "REG_SZ", "String" ), ! _winreg.REG_EXPAND_SZ: RegType("REG_EXPAND_SZ", "Expandable Template String" ), ! _winreg.REG_BINARY: RegType("REG_BINARY", "Binary Data"), ! _winreg.REG_DWORD : RegType("REG_DWORD", "Integer" ), ! # _winreg.REG_DWORD_LITTLE_ENDIAN : # RegType("REG_DWORD_LITTLE_ENDIAN", "Integer"), ! _winreg.REG_DWORD_BIG_ENDIAN : RegType("REG_DWORD_BIG_ENDIAN", "Big Endian Integer"), ! _winreg.REG_LINK : RegType("REG_LINK", "Link"), ! _winreg.REG_MULTI_SZ : RegType("REG_MULTI_SZ", "List of Strings"), ! _winreg.REG_RESOURCE_LIST : RegType("REG_RESOURCE_LIST", "Resource List"), ! _winreg.REG_FULL_RESOURCE_DESCRIPTOR : RegType( "REG_FULL_RESOURCE_DESCRIPTOR", "Full Resource Descriptor" ), ! _winreg.REG_RESOURCE_REQUIREMENTS_LIST: RegType( "REG_RESOURCE_REQUIREMENTS_LIST", "Resource Requirements List" ) *************** *** 129,133 **** class RegKeysDict( _DictBase ): def _nameFromNum( self, item ): ! return winreg.EnumKey( self.key.handle, item ) def __getitem__( self, item ): --- 129,133 ---- class RegKeysDict( _DictBase ): def _nameFromNum( self, item ): ! return _winreg.EnumKey( self.key.handle, item ) def __getitem__( self, item ): *************** *** 163,167 **** class RegKey: def _nameFromNum( self, item ): ! (name,data,datatype)=winreg.EnumValue( self.handle, item ) return name --- 163,167 ---- class RegKey: def _nameFromNum( self, item ): ! (name,data,datatype)=_winreg.EnumValue( self.handle, item ) return name *************** *** 186,190 **** def close(self ): ! return winreg.CloseKey( self.handle ) def getSubkeyNames( self ): --- 186,190 ---- def close(self ): ! return _winreg.CloseKey( self.handle ) def getSubkeyNames( self ): *************** *** 195,212 **** def deleteSubkey( self, subkey ): ! return winreg.DeleteKey( self.handle, subkey ) def deleteValue( self, valname ): ! return winreg.DeleteValue( self.handle, valname ) def createSubkey( self, keyname ): ! handle=winreg.CreateKey( self.handle, keyname ) return RegKey( self.name+"\\"+keyname, handle) def openSubkey( self, keyname, samFlags=None ): if samFlags: ! handle=winreg.OpenKey( self.handle, keyname, 0, samFlags ) else: ! handle=winreg.OpenKey( self.handle, keyname, 0 ) return RegKey( self.name+"\\"+keyname, handle ) --- 195,212 ---- def deleteSubkey( self, subkey ): ! return _winreg.DeleteKey( self.handle, subkey ) def deleteValue( self, valname ): ! return _winreg.DeleteValue( self.handle, valname ) def createSubkey( self, keyname ): ! handle=_winreg.CreateKey( self.handle, keyname ) return RegKey( self.name+"\\"+keyname, handle) def openSubkey( self, keyname, samFlags=None ): if samFlags: ! handle=_winreg.OpenKey( self.handle, keyname, 0, samFlags ) else: ! handle=_winreg.OpenKey( self.handle, keyname, 0 ) return RegKey( self.name+"\\"+keyname, handle ) *************** *** 220,231 **** try: if type( valname )==IntType: ! (valname,data,datatype)=winreg.EnumValue( self.handle, valname ) else: keyname=_getName( valname, self._nameFromNum ) ! (data,datatype)=winreg.QueryValueEx( self.handle, keyname ) except (WindowsError, EnvironmentError): raise IndexError, valname ! if datatype==winreg.REG_BINARY: # use arrays for binary data data=array.array( 'c', data ) --- 220,231 ---- try: if type( valname )==IntType: ! (valname,data,datatype)=_winreg.EnumValue( self.handle, valname ) else: keyname=_getName( valname, self._nameFromNum ) ! (data,datatype)=_winreg.QueryValueEx( self.handle, keyname ) except (WindowsError, EnvironmentError): raise IndexError, valname ! if datatype==_winreg.REG_BINARY: # use arrays for binary data data=array.array( 'c', data ) *************** *** 242,261 **** else: if type( data )==StringType: ! typeint=winreg.REG_SZ elif type( data )==IntType: ! typeint=winreg.REG_DWORD elif type( data )==array.ArrayType: ! typeint=winreg.REG_BINARY data=data.tostring() ! winreg.SetValueEx( self.handle, valname, 0, typeint, data ) def flush(self ): ! winreg.FlushKey( self.keyobbj ) def save( self, filename ): ! winreg.SaveKey( self.keyobj, filename ) def load( self, subkey, filename ): ! return winreg.RegLoadKey( self.handle, subkey, filename ) --- 242,261 ---- else: if type( data )==StringType: ! typeint=_winreg.REG_SZ elif type( data )==IntType: ! typeint=_winreg.REG_DWORD elif type( data )==array.ArrayType: ! typeint=_winreg.REG_BINARY data=data.tostring() ! _winreg.SetValueEx( self.handle, valname, 0, typeint, data ) def flush(self ): ! _winreg.FlushKey( self.keyobbj ) def save( self, filename ): ! _winreg.SaveKey( self.keyobj, filename ) def load( self, subkey, filename ): ! return _winreg.RegLoadKey( self.handle, subkey, filename ) *************** *** 263,267 **** def __init__( self, machine, topLevelKey ): assert topLevelKey in _hivenames ! self.handle = winreg.ConnectRegistry( machine, parentKey ) self.name=r"\\%s\%s" % (machine, topLevelKey ) --- 263,267 ---- def __init__( self, machine, topLevelKey ): assert topLevelKey in _hivenames ! self.handle = _winreg.ConnectRegistry( machine, parentKey ) self.name=r"\\%s\%s" % (machine, topLevelKey ) *************** *** 271,275 **** hives={} for name in _hivenames: ! hives[name]=RegKey( name, getattr( winreg, name ) ) hives["HKLM"]=hives["HKEY_LOCAL_MACHINE"] hives["HKCR"]=hives["HKEY_CLASSES_ROOT"] --- 271,275 ---- hives={} for name in _hivenames: ! hives[name]=RegKey( name, getattr( _winreg, name ) ) hives["HKLM"]=hives["HKEY_LOCAL_MACHINE"] hives["HKCR"]=hives["HKEY_CLASSES_ROOT"] *************** *** 281,285 **** flags={} for name in _flagnames: ! flags[name]=getattr( winreg, name ) _RegNotifyChangeKeyValueOptions=[ "REG_NOTIFY_CHANGE_ATTRIBUTES", --- 281,285 ---- flags={} for name in _flagnames: ! flags[name]=getattr( _winreg, name ) _RegNotifyChangeKeyValueOptions=[ "REG_NOTIFY_CHANGE_ATTRIBUTES", *************** *** 312,316 **** #allnames=_hivenames+_flagnames+typeConstantNames+unusednames ! #winregnames=winreg.__dict__.keys() #for name in winregnames: # if name not in allnames: --- 312,316 ---- #allnames=_hivenames+_flagnames+typeConstantNames+unusednames ! #winregnames=_winreg.__dict__.keys() #for name in winregnames: # if name not in allnames: From python-dev@python.org Fri Jun 30 21:31:53 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 13:31:53 -0700 Subject: [Python-checkins] CVS: python/dist/src/PC config.h,1.40,1.41 Message-ID: <200006302031.NAA07897@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv7887 Modified Files: config.h Log Message: As Neil Schemenauer points out, WITH_CYCLE_GC should be uncommented if we want to have GC enabled in the beta. Index: config.h =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/config.h,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -r1.40 -r1.41 *** config.h 2000/06/30 15:47:02 1.40 --- config.h 2000/06/30 20:31:50 1.41 *************** *** 453,457 **** /* Define if you want cycle garbage collection */ ! /* #define WITH_CYCLE_GC 1 */ /* Define if you have clock. */ --- 453,457 ---- /* Define if you want cycle garbage collection */ ! #define WITH_CYCLE_GC 1 /* Define if you have clock. */ From python-dev@python.org Fri Jun 30 22:40:23 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 14:40:23 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.16,2.17 Message-ID: <200006302140.OAA19198@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv19117/Modules Modified Files: _sre.c Log Message: -- changed $ to match before a trailing newline, even if the multiline flag isn't given. Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.16 retrieving revision 2.17 diff -C2 -r2.16 -r2.17 *** _sre.c 2000/06/30 13:55:15 2.16 --- _sre.c 2000/06/30 21:40:20 2.17 *************** *** 311,315 **** case SRE_AT_END: ! return ((void*) ptr == state->end); case SRE_AT_END_LINE: --- 311,317 ---- case SRE_AT_END: ! return (((void*) (ptr+1) == state->end && ! SRE_IS_LINEBREAK((int) ptr[0])) || ! ((void*) ptr == state->end)); case SRE_AT_END_LINE: From python-dev@python.org Fri Jun 30 23:01:39 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 15:01:39 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib re.py,1.36,1.37 Message-ID: <200006302201.PAA25279@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv23820/Lib Modified Files: re.py Log Message: replaced with something slightly more suitable. Index: re.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/re.py,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -r1.36 -r1.37 *** re.py 2000/06/30 16:25:20 1.36 --- re.py 2000/06/30 22:01:36 1.37 *************** *** 1,11 **** ! # change this to "pre" if your regexps stopped working. don't ! # forget to send a bug report to engine = "sre" if engine == "sre": ! # new 2.0 engine from sre import * else: ! # old 1.5.2 engine. will be removed in 2.0 final. from pre import * --- 1,32 ---- ! # ! # Minimal "re" compatibility wrapper ! # ! # If your regexps don't work well under 2.0b1, you can switch ! # to the old engine ("pre") down below. ! # ! # To help us fix any remaining bugs in the new engine, please ! # report what went wrong. You can either use the following web ! # page: ! # ! # http://www.python.org/search/search_bugs.html ! # ! # or send a mail to SRE's author: ! # ! # Fredrik Lundh ! # ! # Make sure to include the pattern, the string SRE failed to ! # match, and what result you expected. ! # ! # thanks /F ! # engine = "sre" + # engine = "pre" if engine == "sre": ! # New unicode-aware engine from sre import * else: ! # Old 1.5.2 engine. This one supports 8-bit strings only, ! # and will be removed in 2.0 final. from pre import * From python-dev@python.org Fri Jun 30 23:17:55 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 15:17:55 -0700 Subject: [Python-checkins] CVS: python/dist/src/PC config.h,1.41,1.42 Message-ID: <200006302217.PAA28219@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv28210 Modified Files: config.h Log Message: Only include for VC 6.0 and higher. Index: config.h =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/config.h,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -r1.41 -r1.42 *** config.h 2000/06/30 20:31:50 1.41 --- config.h 2000/06/30 22:17:53 1.42 *************** *** 244,248 **** --- 244,250 ---- /* define the ANSI intptr_t type for portable use of a pointer sized integer */ + #if _MSC_VER >= 1200 /* This file only exists in VC 6.0 or higher */ #include + #endif #if defined(MS_WINDOWS) && !defined(MS_WIN64) typedef long intptr_t; From python-dev@python.org Fri Jun 30 23:37:34 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 15:37:34 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre_compile.py,1.17,1.18 sre_parse.py,1.17,1.18 Message-ID: <200006302237.PAA29565@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv29384/Lib Modified Files: sre_compile.py sre_parse.py Log Message: - fixed code generation error in multiline mode - fixed parser flag propagation (of all stupid bugs...) Index: sre_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** sre_compile.py 2000/06/30 18:39:20 1.17 --- sre_compile.py 2000/06/30 22:37:31 1.18 *************** *** 119,123 **** emit(OPCODES[op]) if flags & SRE_FLAG_MULTILINE: ! emit(ATCODES[AT_MULTILINE[av]]) else: emit(ATCODES[av]) --- 119,123 ---- emit(OPCODES[op]) if flags & SRE_FLAG_MULTILINE: ! emit(ATCODES[AT_MULTILINE.get(av, av)]) else: emit(ATCODES[av]) *************** *** 204,208 **** import sre_parse pattern = p ! p = sre_parse.parse(p) else: pattern = None --- 204,208 ---- import sre_parse pattern = p ! p = sre_parse.parse(p, flags) else: pattern = None Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** sre_parse.py 2000/06/30 18:39:20 1.17 --- sre_parse.py 2000/06/30 22:37:31 1.18 *************** *** 32,36 **** HEXDIGITS = tuple("0123456789abcdefABCDEF") ! WHITESPACE = string.whitespace ESCAPES = { --- 32,36 ---- HEXDIGITS = tuple("0123456789abcdefABCDEF") ! WHITESPACE = tuple(string.whitespace) ESCAPES = { *************** *** 297,301 **** return subpattern ! def _parse(source, state, flags=0): # parse regular expression pattern into an operator list. --- 297,301 ---- return subpattern ! def _parse(source, state): # parse regular expression pattern into an operator list. *************** *** 469,473 **** b = [] while 1: ! p = _parse(source, state, flags) if source.next == ")": if b: --- 469,473 ---- b = [] while 1: ! p = _parse(source, state) if source.next == ")": if b: *************** *** 496,500 **** group = state.getgroup(name) while 1: ! p = _parse(source, state, flags) if source.match(")"): if b: --- 496,500 ---- group = state.getgroup(name) while 1: ! p = _parse(source, state) if source.match(")"): if b: *************** *** 533,539 **** source = Tokenizer(pattern) state = State() b = [] while 1: ! p = _parse(source, state, flags) tail = source.get() if tail == "|": --- 533,540 ---- source = Tokenizer(pattern) state = State() + state.flags = flags b = [] while 1: ! p = _parse(source, state) tail = source.get() if tail == "|": From python-dev@python.org Fri Jun 30 23:45:15 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 15:45:15 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules posixmodule.c,2.138,2.139 Message-ID: <200006302245.PAA29900@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv29892 Modified Files: posixmodule.c Log Message: Crude way to fix a problem on AIX: #undef STAT before defining it. Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.138 retrieving revision 2.139 diff -C2 -r2.138 -r2.139 *** posixmodule.c 2000/06/29 21:12:41 2.138 --- posixmodule.c 2000/06/30 22:45:12 2.139 *************** *** 286,289 **** --- 286,290 ---- /* choose the appropriate stat and fstat functions and return structs */ + #undef STAT #ifdef MS_WIN64 # define STAT _stati64 From python-dev@python.org Fri Jun 30 23:46:07 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 15:46:07 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects methodobject.c,2.28,2.29 Message-ID: <200006302246.PAA29937@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv29930 Modified Files: methodobject.c Log Message: Fix an error on AIX by using a proper cast. Index: methodobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/methodobject.c,v retrieving revision 2.28 retrieving revision 2.29 diff -C2 -r2.28 -r2.29 *** methodobject.c 2000/06/30 15:01:00 2.28 --- methodobject.c 2000/06/30 22:46:04 2.29 *************** *** 181,185 **** return -1; } ! y = _Py_HashPointer(a->m_ml->ml_meth); if (y == -1) return -1; --- 181,185 ---- return -1; } ! y = _Py_HashPointer((void*)(a->m_ml->ml_meth)); if (y == -1) return -1; From python-dev@python.org Thu Jun 1 00:56:48 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 31 May 2000 16:56:48 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist_rpm.py,1.3,1.4 Message-ID: <200005312356.QAA06648@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv6640 Modified Files: bdist_rpm.py Log Message: Regularize options a bit: * help strings start with lowercase * added affirmative version of '--no-clean' and '--no-rpm-opt-flags', which are the default (thus the attributes that correspond to the options are now 'clean' and 'use_rpm_opt_flags') Index: bdist_rpm.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist_rpm.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** bdist_rpm.py 2000/05/27 17:27:23 1.3 --- bdist_rpm.py 2000/05/31 23:56:45 1.4 *************** *** 6,10 **** # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.3 2000/05/27 17:27:23 gward Exp $" import os, string --- 6,10 ---- # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.4 2000/05/31 23:56:45 gward Exp $" import os, string *************** *** 20,37 **** user_options = [ ('spec-only', None, ! "Only regenerate spec file"), ('source-only', None, ! "Only generate source RPM"), ('binary-only', None, ! "Only generate binary RPM"), ('use-bzip2', None, ! "Use bzip2 instead of gzip to create source distribution"), ('no-clean', None, ! "Do not clean RPM build directory"), ('no-rpm-opt-flags', None, ! "Do not pass any RPM CFLAGS to compiler") ! ] def initialize_options (self): self.spec_only = None --- 20,44 ---- user_options = [ ('spec-only', None, ! "only regenerate spec file"), ('source-only', None, ! "only generate source RPM"), ('binary-only', None, ! "only generate binary RPM"), ('use-bzip2', None, ! "use bzip2 instead of gzip to create source distribution"), ! ('clean', None, ! "clean up RPM build directory [default]"), ('no-clean', None, ! "don't clean up RPM build directory"), ! ('use-rpm-opt-flags', None, ! "compile with RPM_OPT_FLAGS when building from source RPM"), ('no-rpm-opt-flags', None, ! "do not pass any RPM CFLAGS to compiler"), ! ] + negative_opt = {'no-clean': 'clean', + 'no-rpm-opt-flags': 'use-rpm-opt-flags'} + def initialize_options (self): self.spec_only = None *************** *** 39,44 **** self.source_only = None self.use_bzip2 = None ! self.no_clean = None ! self.no_rpm_opt_flags = None # initialize_options() --- 46,51 ---- self.source_only = None self.use_bzip2 = None ! self.clean = 1 ! self.use_rpm_opt_flags = 1 # initialize_options() *************** *** 55,59 **** # don't pass CFLAGS to pure python distributions if not self.distribution.has_ext_modules(): ! self.no_rpm_opt_flags = 1 # finalize_options() --- 62,66 ---- # don't pass CFLAGS to pure python distributions if not self.distribution.has_ext_modules(): ! self.use_rpm_opt_flags = 0 # finalize_options() *************** *** 121,125 **** rpm_args.extend(['--define', '_topdir ' + os.getcwd() + '/build/rpm',]) ! if not self.no_clean: rpm_args.append('--clean') rpm_args.append(spec_path) --- 128,132 ---- rpm_args.extend(['--define', '_topdir ' + os.getcwd() + '/build/rpm',]) ! if self.clean: rpm_args.append('--clean') rpm_args.append(spec_path) *************** *** 169,173 **** self.postun = self._check_string('postun') self.prep = self._check_string('prep', '%setup') ! if not self.no_rpm_opt_flags: self.build = (self._check_string( 'build', --- 176,180 ---- self.postun = self._check_string('postun') self.prep = self._check_string('prep', '%setup') ! if self.use_rpm_opt_flags: self.build = (self._check_string( 'build', From python-dev@python.org Thu Jun 1 01:40:27 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 31 May 2000 17:40:27 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist_rpm.py,1.4,1.5 Message-ID: <200006010040.RAA14660@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv14400 Modified Files: bdist_rpm.py Log Message: More tweaking to make this command act like other Distutils commands: * added "--bdist-base" option to parameterize where we build the RPM (comes from "bdist" by default: "build/bdist.") * simplified/cleaned up some code in 'run()' in the process of removing (most) hard-coded directory names * if "--spec-only", drop spec file in "dist" rather than "redhat" (directory name still hard-coded, though) * use 'reinitialize_command()' to fetch the "sdist" object to tweak before running "sdist" command * use 'self.copy_file()' method rather than 'copy_file()' function * cosmetic tweaks to comments, error messages Index: bdist_rpm.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist_rpm.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** bdist_rpm.py 2000/05/31 23:56:45 1.4 --- bdist_rpm.py 2000/06/01 00:40:25 1.5 *************** *** 6,15 **** # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.4 2000/05/31 23:56:45 gward Exp $" import os, string from types import * from distutils.core import Command ! from distutils.util import mkpath, write_file, copy_file from distutils.errors import * --- 6,15 ---- # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.5 2000/06/01 00:40:25 gward Exp $" import os, string from types import * from distutils.core import Command ! from distutils.util import get_platform, write_file from distutils.errors import * *************** *** 19,22 **** --- 19,24 ---- user_options = [ + ('bdist-base', None, + "base directory for creating built distributions"), ('spec-only', None, "only regenerate spec file"), *************** *** 42,45 **** --- 44,48 ---- def initialize_options (self): + self.bdist_base = None self.spec_only = None self.binary_only = None *************** *** 53,56 **** --- 56,60 ---- def finalize_options (self): + self.set_undefined_options('bdist', ('bdist_base', 'bdist_base')) if os.name != 'posix': raise DistutilsPlatformError, \ *************** *** 59,63 **** if self.binary_only and self.source_only: raise DistutilsOptionsError, \ ! "Cannot supply both '--source-only' and '--binary-only'" # don't pass CFLAGS to pure python distributions if not self.distribution.has_ext_modules(): --- 63,67 ---- if self.binary_only and self.source_only: raise DistutilsOptionsError, \ ! "cannot supply both '--source-only' and '--binary-only'" # don't pass CFLAGS to pure python distributions if not self.distribution.has_ext_modules(): *************** *** 70,99 **** self._get_package_data() # get packaging info - # make directories if self.spec_only: ! self.mkpath('redhat') else: for d in ('SOURCES', 'SPECS', 'BUILD', 'RPMS', 'SRPMS'): ! self.mkpath(os.path.join('build/rpm', d)) ! ! # spec file goes into .redhat directory if '--spec-only specified', ! # into build/rpm/spec otherwise ! if self.spec_only: ! spec_path = 'redhat/%s.spec' % self.distribution.get_name() ! else: ! spec_path = ('build/rpm/SPECS/%s.spec' % ! self.distribution.get_name()) self.execute(write_file, (spec_path, self._make_spec_file()), ! 'Writing .spec file') if self.spec_only: # stop if requested return ! # make a source distribution and copy to SOURCES directory with ! # optional icon ! sdist = self.get_finalized_command ('sdist') if self.use_bzip2: sdist.formats = ['bztar'] --- 74,104 ---- self._get_package_data() # get packaging info # make directories if self.spec_only: ! spec_dir = "dist" ! self.mkpath(spec_dir) # XXX should be configurable else: + rpm_base = os.path.join(self.bdist_base, "rpm") + rpm_dir = {} for d in ('SOURCES', 'SPECS', 'BUILD', 'RPMS', 'SRPMS'): ! rpm_dir[d] = os.path.join(rpm_base, d) ! self.mkpath(rpm_dir[d]) ! spec_dir = rpm_dir['SPECS'] ! ! # Spec file goes into 'dist' directory if '--spec-only specified', ! # into build/rpm. otherwise. ! spec_path = os.path.join(spec_dir, ! "%s.spec" % self.distribution.get_name()) self.execute(write_file, (spec_path, self._make_spec_file()), ! "writing '%s'" % spec_path) if self.spec_only: # stop if requested return ! # Make a source distribution and copy to SOURCES directory with ! # optional icon. ! sdist = self.reinitialize_command ('sdist') if self.use_bzip2: sdist.formats = ['bztar'] *************** *** 101,117 **** sdist.formats = ['gztar'] self.run_command('sdist') ! if self.use_bzip2: ! source = self.distribution.get_fullname() + '.tar.bz2' ! else: ! source = self.distribution.get_fullname() + '.tar.gz' ! self.execute(copy_file, (source, 'build/rpm/SOURCES'), ! 'Copying source distribution to SOURCES') if self.icon: if os.path.exists(self.icon): ! self.execute(copy_file, (self.icon, 'build/rpm/SOURCES'), ! 'Copying icon to SOURCES') else: raise DistutilsFileError, \ ! "Unable to find icon file '%s'" % self.icon --- 106,120 ---- sdist.formats = ['gztar'] self.run_command('sdist') ! ! source = sdist.get_archive_files()[0] ! source_dir = rpm_dir['SOURCES'] ! self.copy_file(source, source_dir) ! if self.icon: if os.path.exists(self.icon): ! self.copy_file(self.icon, source_dir) else: raise DistutilsFileError, \ ! "icon file '%s' does not exist" % self.icon From python-dev@python.org Thu Jun 1 02:08:01 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 31 May 2000 18:08:01 -0700 Subject: [Python-checkins] CVS: distutils/distutils archive_util.py,1.4,1.5 Message-ID: <200006010108.SAA21289@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv21279 Modified Files: archive_util.py Log Message: Ensure that 'make_archive()' returns the name of the new archive file. Index: archive_util.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/archive_util.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** archive_util.py 2000/05/31 02:17:19 1.4 --- archive_util.py 2000/06/01 01:07:55 1.5 *************** *** 6,10 **** # created 2000/04/03, Greg Ward (extracted from util.py) ! __revision__ = "$Id: archive_util.py,v 1.4 2000/05/31 02:17:19 gward Exp $" import os --- 6,10 ---- # created 2000/04/03, Greg Ward (extracted from util.py) ! __revision__ = "$Id: archive_util.py,v 1.5 2000/06/01 01:07:55 gward Exp $" import os *************** *** 128,132 **** root_dir=None, base_dir=None, verbose=0, dry_run=0): - """Create an archive file (eg. zip or tar). 'base_name' is the name of the file to create, minus any format-specific extension; 'format' --- 128,131 ---- *************** *** 137,142 **** ie. 'base_dir' will be the common prefix of all files and directories in the archive. 'root_dir' and 'base_dir' both default ! to the current directory.""" ! save_cwd = os.getcwd() if root_dir is not None: --- 136,141 ---- ie. 'base_dir' will be the common prefix of all files and directories in the archive. 'root_dir' and 'base_dir' both default ! to the current directory. Returns the name of the archive file. ! """ save_cwd = os.getcwd() if root_dir is not None: *************** *** 161,165 **** for (arg,val) in format_info[1]: kwargs[arg] = val ! apply (func, (base_name, base_dir), kwargs) if root_dir is not None: --- 160,164 ---- for (arg,val) in format_info[1]: kwargs[arg] = val ! filename = apply (func, (base_name, base_dir), kwargs) if root_dir is not None: *************** *** 167,170 **** --- 166,171 ---- print "changing back to '%s'" % save_cwd os.chdir (save_cwd) + + return filename # make_archive () From python-dev@python.org Thu Jun 1 02:08:54 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 31 May 2000 18:08:54 -0700 Subject: [Python-checkins] CVS: distutils/distutils cmd.py,1.14,1.15 Message-ID: <200006010108.SAA21322@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv21312 Modified Files: cmd.py Log Message: Added 'reinitialize_command()' method -- delegated to Distribution instance. Ensure 'make_archive()' method returns archive filename. Index: cmd.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/cmd.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** cmd.py 2000/05/28 23:54:00 1.14 --- cmd.py 2000/06/01 01:08:52 1.15 *************** *** 7,11 **** # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: cmd.py,v 1.14 2000/05/28 23:54:00 gward Exp $" import sys, os, string --- 7,11 ---- # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: cmd.py,v 1.15 2000/06/01 01:08:52 gward Exp $" import sys, os, string *************** *** 216,219 **** --- 216,223 ---- return cmd_obj + # XXX rename to 'get_reinitialized_command()'? (should do the + # same in dist.py, if so) + def reinitialize_command (self, command): + return self.distribution.reinitialize_command(command) def run_command (self, command): *************** *** 307,312 **** def make_archive (self, base_name, format, root_dir=None, base_dir=None): ! util.make_archive (base_name, format, root_dir, base_dir, ! self.verbose, self.dry_run) --- 311,316 ---- def make_archive (self, base_name, format, root_dir=None, base_dir=None): ! return util.make_archive (base_name, format, root_dir, base_dir, ! self.verbose, self.dry_run) From python-dev@python.org Thu Jun 1 02:09:49 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 31 May 2000 18:09:49 -0700 Subject: [Python-checkins] CVS: distutils/distutils dist.py,1.21,1.22 Message-ID: <200006010109.SAA21376@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv21367 Modified Files: dist.py Log Message: Oops, 'reinitialize_command()' forgot to return the command object if didn't need to be reinitialized -- fixed. Index: dist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/dist.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -r1.21 -r1.22 *** dist.py 2000/05/28 23:53:06 1.21 --- dist.py 2000/06/01 01:09:47 1.22 *************** *** 7,11 **** # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: dist.py,v 1.21 2000/05/28 23:53:06 gward Exp $" import sys, os, string, re --- 7,11 ---- # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: dist.py,v 1.22 2000/06/01 01:09:47 gward Exp $" import sys, os, string, re *************** *** 712,716 **** if not command.finalized: ! return command.initialize_options() command.finalized = 0 --- 712,716 ---- if not command.finalized: ! return command command.initialize_options() command.finalized = 0 From python-dev@python.org Thu Jun 1 02:10:59 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 31 May 2000 18:10:59 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command sdist.py,1.22,1.23 Message-ID: <200006010110.SAA21571@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv21561/command Modified Files: sdist.py Log Message: Remember the list of archive files created in 'make_distribution()'. Added 'get_archive_files()' so outsiders can get their hands on that list. Index: sdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/sdist.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** sdist.py 2000/05/31 02:32:10 1.22 --- sdist.py 2000/06/01 01:10:56 1.23 *************** *** 5,9 **** # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.22 2000/05/31 02:32:10 gward Exp $" import sys, os, string, re --- 5,9 ---- # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.23 2000/06/01 01:10:56 gward Exp $" import sys, os, string, re *************** *** 65,69 **** --- 65,71 ---- self.keep_tree = 0 + self.archive_files = None + def finalize_options (self): if self.manifest is None: *************** *** 521,529 **** self.make_release_tree (base_dir, self.files) for fmt in self.formats: ! self.make_archive (base_dir, fmt, base_dir=base_dir) if not self.keep_tree: remove_tree (base_dir, self.verbose, self.dry_run) # class sdist --- 523,541 ---- self.make_release_tree (base_dir, self.files) + archive_files = [] # remember names of files we create for fmt in self.formats: ! file = self.make_archive (base_dir, fmt, base_dir=base_dir) ! archive_files.append(file) ! ! self.archive_files = archive_files if not self.keep_tree: remove_tree (base_dir, self.verbose, self.dry_run) + + def get_archive_files (self): + """Return the list of archive files created when the command + was run, or None if the command hasn't run yet. + """ + return self.archive_files # class sdist From python-dev@python.org Thu Jun 1 02:17:20 2000 From: python-dev@python.org (Jeremy Hylton) Date: Wed, 31 May 2000 18:17:20 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib threading.py,1.7,1.8 Message-ID: <200006010117.SAA21927@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv21902 Modified Files: threading.py Log Message: patch from Charles Waldman-- define ThreadError (== thread.error); docs should be updated, too Index: threading.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/threading.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** threading.py 2000/02/29 00:10:24 1.7 --- threading.py 2000/06/01 01:17:17 1.8 *************** *** 19,22 **** --- 19,23 ---- _allocate_lock = thread.allocate_lock _get_ident = thread.get_ident + ThreadError = thread.error del thread From python-dev@python.org Thu Jun 1 03:02:54 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 31 May 2000 19:02:54 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules arraymodule.c,2.39,2.40 posixmodule.c,2.134,2.135 structmodule.c,2.30,2.31 Message-ID: <200006010202.TAA29774@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv29510 Modified Files: arraymodule.c posixmodule.c structmodule.c Log Message: Michael Hudson : Removed PyErr_BadArgument() calls and replaced them with more useful error messages. Index: arraymodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/arraymodule.c,v retrieving revision 2.39 retrieving revision 2.40 diff -C2 -r2.39 -r2.40 *** arraymodule.c 2000/05/03 23:44:31 2.39 --- arraymodule.c 2000/06/01 02:02:46 2.40 *************** *** 541,545 **** arrayobject *np; if (!is_arrayobject(bb)) { ! PyErr_BadArgument(); return NULL; } --- 541,547 ---- arrayobject *np; if (!is_arrayobject(bb)) { ! PyErr_Format(PyExc_TypeError, ! "can only append array (not \"%.200s\") to array", ! bb->ob_type->tp_name); return NULL; } *************** *** 614,618 **** } else { ! PyErr_BadArgument(); return -1; } --- 616,622 ---- } else { ! PyErr_Format(PyExc_TypeError, ! "can only assign array (not \"%.200s\") to array slice", ! v->ob_type->tp_name); return -1; } *************** *** 822,826 **** if (args != NULL) { ! PyErr_BadArgument(); return NULL; } --- 826,831 ---- if (args != NULL) { ! PyErr_SetString(PyExc_TypeError, ! ".reverse requires exactly 0 arguments"); return NULL; } Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.134 retrieving revision 2.135 diff -C2 -r2.134 -r2.135 *** posixmodule.c 2000/05/03 02:44:55 2.134 --- posixmodule.c 2000/06/01 02:02:46 2.135 *************** *** 1563,1568 **** } else { ! badarg: ! PyErr_BadArgument(); return NULL; } --- 1563,1567 ---- } else { ! PyErr_SetString(PyExc_TypeError, "argv must be tuple or list"); return NULL; } *************** *** 1574,1578 **** if (!PyArg_Parse((*getitem)(argv, i), "s", &argvlist[i])) { PyMem_DEL(argvlist); ! goto badarg; } } --- 1573,1579 ---- if (!PyArg_Parse((*getitem)(argv, i), "s", &argvlist[i])) { PyMem_DEL(argvlist); ! PyErr_SetString(PyExc_TypeError, ! "all arguments must be strings"); ! return NULL; } } Index: structmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/structmodule.c,v retrieving revision 2.30 retrieving revision 2.31 diff -C2 -r2.30 -r2.31 *** structmodule.c 2000/02/29 13:59:24 2.30 --- structmodule.c 2000/06/01 02:02:46 2.31 *************** *** 1129,1133 **** (n = PyTuple_Size(args)) < 1) { ! PyErr_BadArgument(); return NULL; } --- 1129,1134 ---- (n = PyTuple_Size(args)) < 1) { ! PyErr_SetString(PyExc_TypeError, ! "struct.pack requires at least one argument"); return NULL; } From python-dev@python.org Thu Jun 1 04:02:50 2000 From: python-dev@python.org (A.M. Kuchling) Date: Wed, 31 May 2000 20:02:50 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules pypcre.c,2.17,2.18 Message-ID: <200006010302.UAA10389@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv4871 Modified Files: pypcre.c Log Message: Fix bug reported by atkins@gweep.net; re.compile(r"[\100-\410]") dumps core. Solution: fix check_escape() to match its comment and use only the low 8 bits of the octal number. Index: pypcre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/pypcre.c,v retrieving revision 2.17 retrieving revision 2.18 diff -C2 -r2.17 -r2.18 *** pypcre.c 2000/02/18 19:16:45 2.17 --- pypcre.c 2000/06/01 03:02:48 2.18 *************** *** 1065,1069 **** while(i++ < 2 && (pcre_ctypes[ptr[1]] & ctype_digit) != 0 && ptr[1] != '8' && ptr[1] != '9') ! c = c * 8 + *(++ptr) - '0'; break; --- 1065,1069 ---- while(i++ < 2 && (pcre_ctypes[ptr[1]] & ctype_digit) != 0 && ptr[1] != '8' && ptr[1] != '9') ! c = (c * 8 + *(++ptr) - '0') & 255; break; From python-dev@python.org Thu Jun 1 04:12:15 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 31 May 2000 20:12:15 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects listobject.c,2.69,2.70 stringobject.c,2.65,2.66 tupleobject.c,2.33,2.34 Message-ID: <200006010312.UAA10844@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv10833 Modified Files: listobject.c stringobject.c tupleobject.c Log Message: Michael Hudson : Removed PyErr_BadArgument() calls and replaced them with more useful error messages. Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.69 retrieving revision 2.70 diff -C2 -r2.69 -r2.70 *** listobject.c 2000/05/03 23:44:35 2.69 --- listobject.c 2000/06/01 03:12:13 2.70 *************** *** 389,393 **** PyListObject *np; if (!PyList_Check(bb)) { ! PyErr_BadArgument(); return NULL; } --- 389,395 ---- PyListObject *np; if (!PyList_Check(bb)) { ! PyErr_Format(PyExc_TypeError, ! "can only append list (not \"%.200s\") to list", ! bb->ob_type->tp_name); return NULL; } *************** *** 470,474 **** } else { ! PyErr_BadArgument(); return -1; } --- 472,478 ---- } else { ! PyErr_Format(PyExc_TypeError, ! "must assign list (not \"%.200s\") to slice", ! v->ob_type->tp_name); return -1; } Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.65 retrieving revision 2.66 diff -C2 -r2.65 -r2.66 *** stringobject.c 2000/05/08 14:08:05 2.65 --- stringobject.c 2000/06/01 03:12:13 2.66 *************** *** 294,298 **** if (PyUnicode_Check(bb)) return PyUnicode_Concat((PyObject *)a, bb); ! PyErr_BadArgument(); return NULL; } --- 294,300 ---- if (PyUnicode_Check(bb)) return PyUnicode_Concat((PyObject *)a, bb); ! PyErr_Format(PyExc_TypeError, ! "cannot add type \"%.200s\" to string", ! bb->ob_type->tp_name); return NULL; } Index: tupleobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/tupleobject.c,v retrieving revision 2.33 retrieving revision 2.34 diff -C2 -r2.33 -r2.34 *** tupleobject.c 2000/05/03 23:44:36 2.33 --- tupleobject.c 2000/06/01 03:12:13 2.34 *************** *** 362,366 **** PyTupleObject *np; if (!PyTuple_Check(bb)) { ! PyErr_BadArgument(); return NULL; } --- 362,368 ---- PyTupleObject *np; if (!PyTuple_Check(bb)) { ! PyErr_Format(PyExc_TypeError, ! "can only append tuple (not \"%.200s\") to tuple", ! bb->ob_type->tp_name); return NULL; } From python-dev@python.org Thu Jun 1 15:31:06 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 1 Jun 2000 07:31:06 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects listobject.c,2.70,2.71 Message-ID: <200006011431.HAA30110@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv30101 Modified Files: listobject.c Log Message: Improve TypeError exception message for list catenation. Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.70 retrieving revision 2.71 diff -C2 -r2.70 -r2.71 *** listobject.c 2000/06/01 03:12:13 2.70 --- listobject.c 2000/06/01 14:31:03 2.71 *************** *** 390,395 **** if (!PyList_Check(bb)) { PyErr_Format(PyExc_TypeError, ! "can only append list (not \"%.200s\") to list", ! bb->ob_type->tp_name); return NULL; } --- 390,395 ---- if (!PyList_Check(bb)) { PyErr_Format(PyExc_TypeError, ! "can only concatenate list (not \"%.200s\") to list", ! bb->ob_type->tp_name); return NULL; } From python-dev@python.org Thu Jun 1 16:47:11 2000 From: python-dev@python.org (Jeremy Hylton) Date: Thu, 1 Jun 2000 08:47:11 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild python16.dsp,1.3,1.4 Message-ID: <200006011547.IAA07995@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv7948 Modified Files: python16.dsp Log Message: add new Python/exceptions.c to python16 project (courtesy Trent Mick) Index: python16.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/python16.dsp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** python16.dsp 2000/04/21 21:26:07 1.3 --- python16.dsp 2000/06/01 15:47:08 1.4 *************** *** 541,544 **** --- 541,559 ---- # Begin Source File + SOURCE=..\python\exceptions.c + + !if "$(cfg)" == "python16 - win32 release" + + !elseif "$(cfg)" == "python16 - win32 debug" + + !elseif "$(cfg)" == "python16 - win32 alpha debug" + + !elseif "$(cfg)" == "python16 - win32 alpha release" + + !endif + + # end source file + # begin source file + SOURCE=..\Objects\fileobject.c From python-dev@python.org Thu Jun 1 18:34:22 2000 From: python-dev@python.org (Jeremy Hylton) Date: Thu, 1 Jun 2000 10:34:22 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.3,2.4 sre.h,2.2,2.3 sre_constants.h,2.2,2.3 Message-ID: <200006011734.KAA26103@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv25984 Modified Files: _sre.c sre.h sre_constants.h Log Message: Fredrik Lundh: here's the 96.6% version of SRE Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.3 retrieving revision 2.4 diff -C2 -r2.3 -r2.4 *** _sre.c 2000/05/03 23:44:30 2.3 --- _sre.c 2000/06/01 17:34:20 2.4 *************** *** 2,11 **** * * Secret Labs' Regular Expression Engine ! * $Id: _sre.c,v 2.3 2000/05/03 23:44:30 guido Exp $ * * simple regular expression matching engine * * partial history: ! * 99-10-24 fl created (bits and pieces from the template matcher) * 99-11-13 fl added categories, branching, and more (0.2) * 99-11-16 fl some tweaks to compile on non-Windows platforms [...1449 lines suppressed...] + 0, /*tp_print*/ + (getattrfunc)_cursor_getattr, /*tp_getattr*/ + }; + static PyMethodDef _functions[] = { {"compile", _compile, 1}, *************** *** 1446,1450 **** { /* Patch object types */ ! Pattern_Type.ob_type = Match_Type.ob_type = &PyType_Type; Py_InitModule("_sre", _functions); --- 1705,1710 ---- { /* Patch object types */ ! Pattern_Type.ob_type = Match_Type.ob_type = ! Cursor_Type.ob_type = &PyType_Type; Py_InitModule("_sre", _functions); Index: sre.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/sre.h,v retrieving revision 2.2 retrieving revision 2.3 diff -C2 -r2.2 -r2.3 *** sre.h 2000/04/10 17:07:24 2.2 --- sre.h 2000/06/01 17:34:20 2.3 *************** *** 1,5 **** /* * Secret Labs' Regular Expression Engine ! * $Id: sre.h,v 2.2 2000/04/10 17:07:24 guido Exp $ * * simple regular expression matching engine --- 1,5 ---- /* * Secret Labs' Regular Expression Engine ! * $Id: sre.h,v 2.3 2000/06/01 17:34:20 jhylton Exp $ * * simple regular expression matching engine *************** *** 15,29 **** #include "sre_constants.h" - /* Python objects */ - typedef struct { PyObject_HEAD PyObject* code; /* link to the code string object */ - PyObject* pattern; /* link to the pattern source (or None) */ int groups; PyObject* groupindex; } PatternObject; ! #define PatternObject_GetCode(o) ((void*) PyString_AS_STRING((o)->code)) typedef struct { --- 15,30 ---- #include "sre_constants.h" typedef struct { PyObject_HEAD PyObject* code; /* link to the code string object */ int groups; PyObject* groupindex; + /* compatibility */ + PyObject* pattern; /* pattern source (or None) */ + int flags; /* flags used when compiling pattern source */ } PatternObject; ! #define PatternObject_GetCode(o)\ ! ((void*) PyString_AS_STRING(((PatternObject*)(o))->code)) typedef struct { *************** *** 35,38 **** } MatchObject; ! #endif --- 36,62 ---- } MatchObject; ! typedef struct { ! /* string pointers */ ! void* ptr; /* current position (also end of current slice) */ ! void* beginning; /* start of original string */ ! void* start; /* start of current slice */ ! void* end; /* end of original string */ ! /* character size */ ! int charsize; ! /* registers */ ! int marks; ! void* mark[64]; /* FIXME: should be dynamically allocated! */ ! /* backtracking stack */ ! void** stack; ! int stacksize; ! int stackbase; ! } SRE_STATE; + typedef struct { + PyObject_HEAD + PyObject* pattern; + PyObject* string; + SRE_STATE state; + } CursorObject; + + #endif Index: sre_constants.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/sre_constants.h,v retrieving revision 2.2 retrieving revision 2.3 diff -C2 -r2.2 -r2.3 *** sre_constants.h 2000/04/10 17:07:24 2.2 --- sre_constants.h 2000/06/01 17:34:20 2.3 *************** *** 1,3 **** ! /* generated by sre_constants.py */ #define SRE_OP_FAILURE 0 #define SRE_OP_SUCCESS 1 --- 1,3 ---- ! /* generated from sre_constants.py */ #define SRE_OP_FAILURE 0 #define SRE_OP_SUCCESS 1 *************** *** 26,27 **** --- 26,49 ---- #define SRE_OP_RANGE 24 #define SRE_OP_REPEAT 25 + #define SRE_AT_BEGINNING 0 + #define SRE_AT_BEGINNING_LINE 1 + #define SRE_AT_BOUNDARY 2 + #define SRE_AT_NON_BOUNDARY 3 + #define SRE_AT_END 4 + #define SRE_AT_END_LINE 5 + #define SRE_CATEGORY_DIGIT 0 + #define SRE_CATEGORY_NOT_DIGIT 1 + #define SRE_CATEGORY_SPACE 2 + #define SRE_CATEGORY_NOT_SPACE 3 + #define SRE_CATEGORY_WORD 4 + #define SRE_CATEGORY_NOT_WORD 5 + #define SRE_CATEGORY_LINEBREAK 6 + #define SRE_CATEGORY_NOT_LINEBREAK 7 + #define SRE_CATEGORY_LOC_DIGIT 8 + #define SRE_CATEGORY_LOC_NOT_DIGIT 9 + #define SRE_CATEGORY_LOC_SPACE 10 + #define SRE_CATEGORY_LOC_NOT_SPACE 11 + #define SRE_CATEGORY_LOC_WORD 12 + #define SRE_CATEGORY_LOC_NOT_WORD 13 + #define SRE_CATEGORY_LOC_LINEBREAK 14 + #define SRE_CATEGORY_LOC_NOT_LINEBREAK 15 From python-dev@python.org Thu Jun 1 18:39:14 2000 From: python-dev@python.org (Jeremy Hylton) Date: Thu, 1 Jun 2000 10:39:14 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre.py,1.4,1.5 sre_compile.py,1.3,1.4 sre_constants.py,1.3,1.4 Message-ID: <200006011739.KAA26462@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv26344 Modified Files: sre.py sre_compile.py sre_constants.py Log Message: Fredrik Lundh: here's the 96.6% version of SRE Index: sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** sre.py 2000/05/02 15:52:33 1.4 --- sre.py 2000/06/01 17:39:12 1.5 *************** *** 1,6 **** - # -*- Mode: Python; tab-width: 4 -*- # # Secret Labs' Regular Expression Engine ! # $Id: sre.py,v 1.4 2000/05/02 15:52:33 guido Exp $ # # re-compatible interface for the sre matching engine --- 1,5 ---- # # Secret Labs' Regular Expression Engine ! # $Id: sre.py,v 1.5 2000/06/01 17:39:12 jhylton Exp $ # # re-compatible interface for the sre matching engine *************** *** 8,14 **** # Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. # - # This code can only be used for 1.6 alpha testing. All other use - # require explicit permission from Secret Labs AB. - # # Portions of this engine have been developed in cooperation with # CNRI. Hewlett-Packard provided funding for 1.6 integration and --- 7,10 ---- *************** *** 16,45 **** # - """ - this is a long string - """ - import sre_compile # -------------------------------------------------------------------- # public interface ! def compile(pattern, flags=0): ! return sre_compile.compile(pattern, _fixflags(flags)) def match(pattern, string, flags=0): ! return compile(pattern, _fixflags(flags)).match(string) def search(pattern, string, flags=0): ! return compile(pattern, _fixflags(flags)).search(string) ! # FIXME: etc # -------------------------------------------------------------------- ! # helpers ! def _fixflags(flags): ! # convert flag bitmask to sequence ! assert not flags ! return () --- 12,132 ---- # import sre_compile + # flags + I = IGNORECASE = sre_compile.SRE_FLAG_IGNORECASE + L = LOCALE = sre_compile.SRE_FLAG_LOCALE + M = MULTILINE = sre_compile.SRE_FLAG_MULTILINE + S = DOTALL = sre_compile.SRE_FLAG_DOTALL + X = VERBOSE = sre_compile.SRE_FLAG_VERBOSE + # -------------------------------------------------------------------- # public interface ! # FIXME: add docstrings def match(pattern, string, flags=0): ! return _compile(pattern, flags).match(string) def search(pattern, string, flags=0): ! return _compile(pattern, flags).search(string) ! ! def sub(pattern, repl, string, count=0): ! return _compile(pattern).sub(repl, string, count) ! ! def subn(pattern, repl, string, count=0): ! return _compile(pattern).subn(repl, string, count) ! ! def split(pattern, string, maxsplit=0): ! return _compile(pattern).split(string, maxsplit) ! ! def findall(pattern, string, maxsplit=0): ! return _compile(pattern).findall(string, maxsplit) ! ! def compile(pattern, flags=0): ! return _compile(pattern, flags) ! def escape(pattern): ! s = list(pattern) ! for i in range(len(pattern)): ! c = pattern[i] ! if not ("a" <= c <= "z" or "A" <= c <= "Z" or "0" <= c <= "9"): ! if c == "\000": ! s[i] = "\\000" ! else: ! s[i] = "\\" + c ! return pattern[:0].join(s) # -------------------------------------------------------------------- ! # internals ! _cache = {} ! _MAXCACHE = 100 + def _compile(pattern, flags=0): + # internal: compile pattern + tp = type(pattern) + if tp not in (type(""), type(u"")): + return pattern + key = (tp, pattern, flags) + try: + return _cache[key] + except KeyError: + pass + p = sre_compile.compile(pattern, flags) + if len(_cache) >= _MAXCACHE: + _cache.clear() + _cache[key] = p + return p + + def _sub(pattern, template, string, count=0): + # internal: pattern.sub implementation hook + return _subn(pattern, template, string, count)[0] + + def _expand(match, template): + # internal: expand template + return template # FIXME + + def _subn(pattern, template, string, count=0): + # internal: pattern.subn implementation hook + if callable(template): + filter = callable + else: + # FIXME: prepare template + def filter(match, template=template): + return _expand(match, template) + n = i = 0 + s = [] + append = s.append + c = pattern.cursor(string) + while not count or n < count: + m = c.search() + if not m: + break + j = m.start() + if j > i: + append(string[i:j]) + append(filter(m)) + i = m.end() + n = n + 1 + if i < len(string): + append(string[i:]) + return string[:0].join(s), n + + def _split(pattern, string, maxsplit=0): + # internal: pattern.split implementation hook + n = i = 0 + s = [] + append = s.append + c = pattern.cursor(string) + while not maxsplit or n < maxsplit: + m = c.search() + if not m: + break + j = m.start() + append(string[i:j]) + i = m.end() + n = n + 1 + if i < len(string): + append(string[i:]) + return s Index: sre_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** sre_compile.py 2000/04/10 17:10:48 1.3 --- sre_compile.py 2000/06/01 17:39:12 1.4 *************** *** 1,5 **** # # Secret Labs' Regular Expression Engine ! # $Id: sre_compile.py,v 1.3 2000/04/10 17:10:48 guido Exp $ # # convert template to internal format --- 1,5 ---- # # Secret Labs' Regular Expression Engine ! # $Id: sre_compile.py,v 1.4 2000/06/01 17:39:12 jhylton Exp $ # # convert template to internal format *************** *** 15,21 **** # - # FIXME: formalize (objectify?) and document the compiler code - # format, so that other frontends can use this compiler - import array, string, sys --- 15,18 ---- *************** *** 46,76 **** def todata(self): # print self.data ! return array.array(WORDSIZE, self.data).tostring() ! ! def _lower(literal): ! # return _sre._lower(literal) # FIXME ! return string.lower(literal) ! def _compile(code, pattern, flags): append = code.append for op, av in pattern: if op is ANY: ! if "s" in flags: ! append(CODES[op]) # any character at all! else: ! append(CODES[NOT_LITERAL]) ! append(10) elif op in (SUCCESS, FAILURE): ! append(CODES[op]) elif op is AT: ! append(CODES[op]) ! append(POSITIONS[av]) elif op is BRANCH: ! append(CODES[op]) tail = [] for av in av[1]: skip = len(code); append(0) ! _compile(code, av, flags) ! append(CODES[JUMP]) tail.append(len(code)); append(0) code[skip] = len(code) - skip --- 43,76 ---- def todata(self): # print self.data ! try: ! return array.array(WORDSIZE, self.data).tostring() ! except OverflowError: ! print self.data ! raise ! def _compile(code, pattern, flags, level=0): append = code.append for op, av in pattern: if op is ANY: ! if flags & SRE_FLAG_DOTALL: ! append(OPCODES[op]) # any character at all! else: ! append(OPCODES[CATEGORY]) ! append(CHCODES[CATEGORY_NOT_LINEBREAK]) elif op in (SUCCESS, FAILURE): ! append(OPCODES[op]) elif op is AT: ! append(OPCODES[op]) ! if flags & SRE_FLAG_MULTILINE: ! append(ATCODES[AT_MULTILINE[av]]) ! else: ! append(ATCODES[av]) elif op is BRANCH: ! append(OPCODES[op]) tail = [] for av in av[1]: skip = len(code); append(0) ! _compile(code, av, flags, level) ! append(OPCODES[JUMP]) tail.append(len(code)); append(0) code[skip] = len(code) - skip *************** *** 79,107 **** code[tail] = len(code) - tail elif op is CALL: ! append(CODES[op]) skip = len(code); append(0) ! _compile(code, av, flags) ! append(CODES[SUCCESS]) code[skip] = len(code) - skip elif op is CATEGORY: # not used by current parser ! append(CODES[op]) ! append(CATEGORIES[av]) elif op is GROUP: ! if "i" in flags: ! append(CODES[MAP_IGNORE[op]]) else: ! append(CODES[op]) ! append(av) elif op is IN: ! if "i" in flags: ! append(CODES[MAP_IGNORE[op]]) def fixup(literal): ! return ord(_lower(literal)) else: ! append(CODES[op]) fixup = ord skip = len(code); append(0) for op, av in av: ! append(CODES[op]) if op is NEGATE: pass --- 79,110 ---- code[tail] = len(code) - tail elif op is CALL: ! append(OPCODES[op]) skip = len(code); append(0) ! _compile(code, av, flags, level+1) ! append(OPCODES[SUCCESS]) code[skip] = len(code) - skip elif op is CATEGORY: # not used by current parser ! append(OPCODES[op]) ! if flags & SRE_FLAG_LOCALE: ! append(CH_LOCALE[CHCODES[av]]) ! else: ! append(CHCODES[av]) elif op is GROUP: ! if flags & SRE_FLAG_IGNORECASE: ! append(OPCODES[OP_IGNORE[op]]) else: ! append(OPCODES[op]) ! append(av-1) elif op is IN: ! if flags & SRE_FLAG_IGNORECASE: ! append(OPCODES[OP_IGNORE[op]]) def fixup(literal): ! return ord(literal.lower()) else: ! append(OPCODES[op]) fixup = ord skip = len(code); append(0) for op, av in av: ! append(OPCODES[op]) if op is NEGATE: pass *************** *** 112,129 **** append(fixup(av[1])) elif op is CATEGORY: ! append(CATEGORIES[av]) else: raise ValueError, "unsupported set operator" ! append(CODES[FAILURE]) code[skip] = len(code) - skip elif op in (LITERAL, NOT_LITERAL): ! if "i" in flags: ! append(CODES[MAP_IGNORE[op]]) ! append(ord(_lower(av))) else: ! append(CODES[op]) append(ord(av)) elif op is MARK: ! append(CODES[op]) append(av) elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): --- 115,135 ---- append(fixup(av[1])) elif op is CATEGORY: ! if flags & SRE_FLAG_LOCALE: ! append(CH_LOCALE[CHCODES[av]]) ! else: ! append(CHCODES[av]) else: raise ValueError, "unsupported set operator" ! append(OPCODES[FAILURE]) code[skip] = len(code) - skip elif op in (LITERAL, NOT_LITERAL): ! if flags & SRE_FLAG_IGNORECASE: ! append(OPCODES[OP_IGNORE[op]]) ! append(ord(av.lower())) else: ! append(OPCODES[op]) append(ord(av)) elif op is MARK: ! append(OPCODES[op]) append(av) elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): *************** *** 132,167 **** raise SyntaxError, "cannot repeat zero-width items" if lo == hi == 1 and op is MAX_REPEAT: ! append(CODES[MAX_REPEAT_ONE]) skip = len(code); append(0) append(av[0]) append(av[1]) ! _compile(code, av[2], flags) ! append(CODES[SUCCESS]) code[skip] = len(code) - skip else: ! append(CODES[op]) skip = len(code); append(0) append(av[0]) append(av[1]) ! _compile(code, av[2], flags) if op is MIN_REPEAT: ! append(CODES[MIN_UNTIL]) else: ! # FIXME: MAX_REPEAT PROBABLY DOESN'T WORK (?) ! append(CODES[MAX_UNTIL]) code[skip] = len(code) - skip elif op is SUBPATTERN: ! ## group = av[0] ! ## if group: ! ## append(CODES[MARK]) ! ## append((group-1)*2) ! _compile(code, av[1], flags) ! ## if group: ! ## append(CODES[MARK]) ! ## append((group-1)*2+1) else: raise ValueError, ("unsupported operand type", op) ! def compile(p, flags=()): # convert pattern list to internal format if type(p) in (type(""), type(u"")): --- 138,172 ---- raise SyntaxError, "cannot repeat zero-width items" if lo == hi == 1 and op is MAX_REPEAT: ! append(OPCODES[MAX_REPEAT_ONE]) skip = len(code); append(0) append(av[0]) append(av[1]) ! _compile(code, av[2], flags, level+1) ! append(OPCODES[SUCCESS]) code[skip] = len(code) - skip else: ! append(OPCODES[op]) skip = len(code); append(0) append(av[0]) append(av[1]) ! _compile(code, av[2], flags, level+1) if op is MIN_REPEAT: ! append(OPCODES[MIN_UNTIL]) else: ! append(OPCODES[MAX_UNTIL]) code[skip] = len(code) - skip elif op is SUBPATTERN: ! group = av[0] ! if group: ! append(OPCODES[MARK]) ! append((group-1)*2) ! _compile(code, av[1], flags, level+1) ! if group: ! append(OPCODES[MARK]) ! append((group-1)*2+1) else: raise ValueError, ("unsupported operand type", op) ! def compile(p, flags=0): # convert pattern list to internal format if type(p) in (type(""), type(u"")): *************** *** 171,180 **** else: pattern = None ! # print p.getwidth() ! # print p code = Code() ! _compile(code, p.data, p.pattern.flags) ! code.append(CODES[SUCCESS]) ! # print list(code.data) data = code.todata() if 0: # debugging --- 176,183 ---- else: pattern = None ! flags = p.pattern.flags | flags code = Code() ! _compile(code, p.data, flags) ! code.append(OPCODES[SUCCESS]) data = code.todata() if 0: # debugging *************** *** 184,187 **** sre_disasm.disasm(data) print "-" * 68 ! # print len(data), p.pattern.groups, len(p.pattern.groupdict) ! return _sre.compile(pattern, data, p.pattern.groups-1, p.pattern.groupdict) --- 187,193 ---- sre_disasm.disasm(data) print "-" * 68 ! return _sre.compile( ! pattern, flags, ! data, ! p.pattern.groups-1, p.pattern.groupdict ! ) Index: sre_constants.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_constants.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** sre_constants.py 2000/04/10 17:10:48 1.3 --- sre_constants.py 2000/06/01 17:39:12 1.4 *************** *** 1,5 **** # # Secret Labs' Regular Expression Engine ! # $Id: sre_constants.py,v 1.3 2000/04/10 17:10:48 guido Exp $ # # various symbols used by the regular expression engine. --- 1,5 ---- # # Secret Labs' Regular Expression Engine ! # $Id: sre_constants.py,v 1.4 2000/06/01 17:39:12 jhylton Exp $ # # various symbols used by the regular expression engine. *************** *** 49,58 **** # positions AT_BEGINNING = "at_beginning" AT_BOUNDARY = "at_boundary" AT_NON_BOUNDARY = "at_non_boundary" AT_END = "at_end" # categories - CATEGORY_DIGIT = "category_digit" CATEGORY_NOT_DIGIT = "category_not_digit" --- 49,59 ---- # positions AT_BEGINNING = "at_beginning" + AT_BEGINNING_LINE = "at_beginning_line" AT_BOUNDARY = "at_boundary" AT_NON_BOUNDARY = "at_non_boundary" AT_END = "at_end" + AT_END_LINE = "at_end_line" # categories CATEGORY_DIGIT = "category_digit" CATEGORY_NOT_DIGIT = "category_not_digit" *************** *** 61,66 **** CATEGORY_WORD = "category_word" CATEGORY_NOT_WORD = "category_not_word" ! CODES = [ # failure=0 success=1 (just because it looks better that way :-) --- 62,77 ---- CATEGORY_WORD = "category_word" CATEGORY_NOT_WORD = "category_not_word" + CATEGORY_LINEBREAK = "category_linebreak" + CATEGORY_NOT_LINEBREAK = "category_not_linebreak" + CATEGORY_LOC_DIGIT = "category_loc_digit" + CATEGORY_LOC_NOT_DIGIT = "category_loc_not_digit" + CATEGORY_LOC_SPACE = "category_loc_space" + CATEGORY_LOC_NOT_SPACE = "category_loc_not_space" + CATEGORY_LOC_WORD = "category_loc_word" + CATEGORY_LOC_NOT_WORD = "category_loc_not_word" + CATEGORY_LOC_LINEBREAK = "category_loc_linebreak" + CATEGORY_LOC_NOT_LINEBREAK = "category_loc_not_linebreak" ! OPCODES = [ # failure=0 success=1 (just because it looks better that way :-) *************** *** 87,101 **** ] ! # convert to dictionary ! c = {} ! i = 0 ! for code in CODES: ! c[code] = i ! i = i + 1 ! CODES = c # replacement operations for "ignore case" mode ! MAP_IGNORE = { GROUP: GROUP_IGNORE, IN: IN_IGNORE, --- 98,130 ---- ] + + ATCODES = [ + AT_BEGINNING, AT_BEGINNING_LINE, AT_BOUNDARY, + AT_NON_BOUNDARY, AT_END, AT_END_LINE + ] ! CHCODES = [ ! CATEGORY_DIGIT, CATEGORY_NOT_DIGIT, CATEGORY_SPACE, ! CATEGORY_NOT_SPACE, CATEGORY_WORD, CATEGORY_NOT_WORD, ! CATEGORY_LINEBREAK, CATEGORY_NOT_LINEBREAK, CATEGORY_LOC_DIGIT, ! CATEGORY_LOC_NOT_DIGIT, CATEGORY_LOC_SPACE, ! CATEGORY_LOC_NOT_SPACE, CATEGORY_LOC_WORD, CATEGORY_LOC_NOT_WORD, ! CATEGORY_LOC_LINEBREAK, CATEGORY_LOC_NOT_LINEBREAK ! ] ! ! def makedict(list): ! d = {} ! i = 0 ! for item in list: ! d[item] = i ! i = i + 1 ! return d ! ! OPCODES = makedict(OPCODES) ! ATCODES = makedict(ATCODES) ! CHCODES = makedict(CHCODES) # replacement operations for "ignore case" mode ! OP_IGNORE = { GROUP: GROUP_IGNORE, IN: IN_IGNORE, *************** *** 104,131 **** } ! POSITIONS = { ! AT_BEGINNING: ord("a"), ! AT_BOUNDARY: ord("b"), ! AT_NON_BOUNDARY: ord("B"), ! AT_END: ord("z"), } ! CATEGORIES = { ! CATEGORY_DIGIT: ord("d"), ! CATEGORY_NOT_DIGIT: ord("D"), ! CATEGORY_SPACE: ord("s"), ! CATEGORY_NOT_SPACE: ord("S"), ! CATEGORY_WORD: ord("w"), ! CATEGORY_NOT_WORD: ord("W"), } if __name__ == "__main__": import string ! items = CODES.items() ! items.sort(lambda a, b: cmp(a[1], b[1])) f = open("sre_constants.h", "w") ! f.write("/* generated by sre_constants.py */\n") ! for k, v in items: ! f.write("#define SRE_OP_" + string.upper(k) + " " + str(v) + "\n") f.close() print "done" --- 133,172 ---- } ! AT_MULTILINE = { ! AT_BEGINNING: AT_BEGINNING_LINE, ! AT_END: AT_END_LINE } ! CH_LOCALE = { ! CATEGORY_DIGIT: CATEGORY_LOC_DIGIT, ! CATEGORY_NOT_DIGIT: CATEGORY_LOC_NOT_DIGIT, ! CATEGORY_SPACE: CATEGORY_LOC_SPACE, ! CATEGORY_NOT_SPACE: CATEGORY_LOC_NOT_SPACE, ! CATEGORY_WORD: CATEGORY_LOC_WORD, ! CATEGORY_NOT_WORD: CATEGORY_LOC_NOT_WORD, ! CATEGORY_LINEBREAK: CATEGORY_LOC_LINEBREAK, ! CATEGORY_NOT_LINEBREAK: CATEGORY_LOC_NOT_LINEBREAK } + # flags + SRE_FLAG_TEMPLATE = 1 # NYI + SRE_FLAG_IGNORECASE = 2 + SRE_FLAG_LOCALE = 4 + SRE_FLAG_MULTILINE = 8 + SRE_FLAG_DOTALL = 16 + SRE_FLAG_VERBOSE = 32 + if __name__ == "__main__": import string ! def dump(f, d, prefix): ! items = d.items() ! items.sort(lambda a, b: cmp(a[1], b[1])) ! for k, v in items: ! f.write("#define %s_%s %s\n" % (prefix, string.upper(k), v)) f = open("sre_constants.h", "w") ! f.write("/* generated from sre_constants.py */\n") ! dump(f, OPCODES, "SRE_OP") ! dump(f, ATCODES, "SRE") ! dump(f, CHCODES, "SRE") f.close() print "done" From python-dev@python.org Thu Jun 1 18:59:19 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 1 Jun 2000 10:59:19 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_math.py,1.3,1.4 Message-ID: <200006011759.KAA28240@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv28145 Modified Files: test_math.py Log Message: Trent Mick : Fix test of the "math" module so it does not break on platforms that do not offer rint(); just skip that portion of the test in that case. Index: test_math.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_math.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** test_math.py 2000/05/11 18:19:41 1.3 --- test_math.py 2000/06/01 17:59:17 1.4 *************** *** 131,138 **** print 'rint' ! testit('rint(0.7)', math.rint(0.7), 1) ! testit('rint(-0.3)', math.rint(-0.3), 0) ! testit('rint(2.5)', math.rint(2.5), 2) ! testit('rint(3.5)', math.rint(3.5), 4) print 'sin' --- 131,144 ---- print 'rint' ! try: ! math.rint ! except AttributeError: ! # this platform does not have rint, that is fine, skip the test ! pass ! else: ! testit('rint(0.7)', math.rint(0.7), 1) ! testit('rint(-0.3)', math.rint(-0.3), 0) ! testit('rint(2.5)', math.rint(2.5), 2) ! testit('rint(3.5)', math.rint(3.5), 4) print 'sin' From python-dev@python.org Thu Jun 1 19:37:38 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 1 Jun 2000 11:37:38 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects longobject.c,1.57,1.58 Message-ID: <200006011837.LAA03494@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv3484 Modified Files: longobject.c Log Message: Trent Mick : This patch correct bounds checking in PyLong_FromLongLong. Currently, it does not check properly for negative values when checking to see if the incoming value fits in a long or unsigned long. This results in possible silent truncation of the value for very large negative values. Index: longobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/longobject.c,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -r1.57 -r1.58 *** longobject.c 2000/05/03 23:44:35 1.57 --- longobject.c 2000/06/01 18:37:36 1.58 *************** *** 356,363 **** return PyLong_FromLong( (long)ival ); #else ! if( ival <= (LONG_LONG)LONG_MAX ) { return PyLong_FromLong( (long)ival ); } ! else if( ival <= (unsigned LONG_LONG)ULONG_MAX ) { return PyLong_FromUnsignedLong( (unsigned long)ival ); } --- 356,363 ---- return PyLong_FromLong( (long)ival ); #else ! if ((LONG_LONG)LONG_MIN <= ival && ival <= (LONG_LONG)LONG_MAX) { return PyLong_FromLong( (long)ival ); } ! else if (0 <= ival && ival <= (unsigned LONG_LONG)ULONG_MAX) { return PyLong_FromUnsignedLong( (unsigned long)ival ); } From python-dev@python.org Fri Jun 2 01:44:55 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 1 Jun 2000 17:44:55 -0700 Subject: [Python-checkins] CVS: distutils/distutils dist.py,1.22,1.23 cmd.py,1.15,1.16 core.py,1.38,1.39 Message-ID: <200006020044.RAA27038@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv27024 Modified Files: dist.py cmd.py core.py Log Message: Reformatted and updated many docstrings. Index: dist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/dist.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** dist.py 2000/06/01 01:09:47 1.22 --- dist.py 2000/06/02 00:44:53 1.23 *************** *** 2,11 **** Provides the Distribution class, which represents the module distribution ! being built/installed/distributed.""" # created 2000/04/03, Greg Ward # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: dist.py,v 1.22 2000/06/01 01:09:47 gward Exp $" import sys, os, string, re --- 2,12 ---- Provides the Distribution class, which represents the module distribution ! being built/installed/distributed. ! """ # created 2000/04/03, Greg Ward # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: dist.py,v 1.23 2000/06/02 00:44:53 gward Exp $" import sys, os, string, re *************** *** 26,43 **** class Distribution: ! """The core of the Distutils. Most of the work hiding behind ! 'setup' is really done within a Distribution instance, which ! farms the work out to the Distutils commands specified on the ! command line. ! ! Clients will almost never instantiate Distribution directly, ! unless the 'setup' function is totally inadequate to their needs. ! However, it is conceivable that a client might wish to subclass ! Distribution for some specialized purpose, and then pass the ! subclass to 'setup' as the 'distclass' keyword argument. If so, ! it is necessary to respect the expectations that 'setup' has of ! Distribution: it must have a constructor and methods ! 'parse_command_line()' and 'run_commands()' with signatures like ! those described below.""" --- 27,42 ---- class Distribution: ! """The core of the Distutils. Most of the work hiding behind 'setup' ! is really done within a Distribution instance, which farms the work out ! to the Distutils commands specified on the command line. ! ! Setup scripts will almost never instantiate Distribution directly, ! unless the 'setup()' function is totally inadequate to their needs. ! However, it is conceivable that a setup script might wish to subclass ! Distribution for some specialized purpose, and then pass the subclass ! to 'setup()' as the 'distclass' keyword argument. If so, it is ! necessary to respect the expectations that 'setup' has of Distribution. ! See the code for 'setup()', in core.py, for details. ! """ *************** *** 99,110 **** def __init__ (self, attrs=None): """Construct a new Distribution instance: initialize all the ! attributes of a Distribution, and then uses 'attrs' (a ! dictionary mapping attribute names to values) to assign ! some of those attributes their "real" values. (Any attributes ! not mentioned in 'attrs' will be assigned to some null ! value: 0, None, an empty list or dictionary, etc.) Most ! importantly, initialize the 'command_obj' attribute ! to the empty dictionary; this will be filled in with real ! command objects by 'parse_command_line()'.""" # Default values for our command-line options --- 98,109 ---- def __init__ (self, attrs=None): """Construct a new Distribution instance: initialize all the ! attributes of a Distribution, and then use 'attrs' (a dictionary ! mapping attribute names to values) to assign some of those ! attributes their "real" values. (Any attributes not mentioned in ! 'attrs' will be assigned to some null value: 0, None, an empty list ! or dictionary, etc.) Most importantly, initialize the ! 'command_obj' attribute to the empty dictionary; this will be ! filled in with real command objects by 'parse_command_line()'. ! """ # Default values for our command-line options *************** *** 388,392 **** def _parse_command_opts (self, parser, args): - """Parse the command-line options for a single command. 'parser' must be a FancyGetopt instance; 'args' must be the list --- 387,390 ---- *************** *** 667,671 **** def _set_command_options (self, command_obj, option_dict=None): - """Set the options for 'command_obj' from 'option_dict'. Basically this means copying elements of a dictionary ('option_dict') to --- 665,668 ---- Index: cmd.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/cmd.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** cmd.py 2000/06/01 01:08:52 1.15 --- cmd.py 2000/06/02 00:44:53 1.16 *************** *** 2,11 **** Provides the Command class, the base class for the command classes ! in the distutils.command package.""" # created 2000/04/03, Greg Ward # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: cmd.py,v 1.15 2000/06/01 01:08:52 gward Exp $" import sys, os, string --- 2,12 ---- Provides the Command class, the base class for the command classes ! in the distutils.command package. ! """ # created 2000/04/03, Greg Ward # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: cmd.py,v 1.16 2000/06/02 00:44:53 gward Exp $" import sys, os, string *************** *** 17,33 **** class Command: """Abstract base class for defining command classes, the "worker bees" ! of the Distutils. A useful analogy for command classes is to ! think of them as subroutines with local variables called ! "options". The options are "declared" in 'initialize_options()' ! and "defined" (given their final values, aka "finalized") in ! 'finalize_options()', both of which must be defined by every ! command class. The distinction between the two is necessary ! because option values might come from the outside world (command ! line, option file, ...), and any options dependent on other ! options must be computed *after* these outside influences have ! been processed -- hence 'finalize_options()'. The "body" of the ! subroutine, where it does all its work based on the values of its ! options, is the 'run()' method, which must also be implemented by ! every command class.""" # -- Creation/initialization methods ------------------------------- --- 18,34 ---- class Command: """Abstract base class for defining command classes, the "worker bees" ! of the Distutils. A useful analogy for command classes is to think of ! them as subroutines with local variables called "options". The options ! are "declared" in 'initialize_options()' and "defined" (given their ! final values, aka "finalized") in 'finalize_options()', both of which ! must be defined by every command class. The distinction between the ! two is necessary because option values might come from the outside ! world (command line, config file, ...), and any options dependent on ! other options must be computed *after* these outside influences have ! been processed -- hence 'finalize_options()'. The "body" of the ! subroutine, where it does all its work based on the values of its ! options, is the 'run()' method, which must also be implemented by every ! command class. ! """ # -- Creation/initialization methods ------------------------------- *************** *** 35,42 **** def __init__ (self, dist): """Create and initialize a new Command object. Most importantly, ! invokes the 'initialize_options()' method, which is the ! real initializer and depends on the actual command being ! instantiated.""" ! # late import because of mutual dependence between these classes from distutils.dist import Distribution --- 36,43 ---- def __init__ (self, dist): """Create and initialize a new Command object. Most importantly, ! invokes the 'initialize_options()' method, which is the real ! initializer and depends on the actual command being ! instantiated. ! """ # late import because of mutual dependence between these classes from distutils.dist import Distribution *************** *** 98,104 **** # Subclasses must define: # initialize_options() ! # provide default values for all options; may be overridden ! # by Distutils client, by command-line options, or by options ! # from option file # finalize_options() # decide on the final values for all options; this is called --- 99,105 ---- # Subclasses must define: # initialize_options() ! # provide default values for all options; may be customized by ! # setup script, by options from config file(s), or by command-line ! # options # finalize_options() # decide on the final values for all options; this is called *************** *** 111,136 **** def initialize_options (self): """Set default values for all the options that this command ! supports. Note that these defaults may be overridden ! by the command-line supplied by the user; thus, this is ! not the place to code dependencies between options; generally, ! 'initialize_options()' implementations are just a bunch ! of "self.foo = None" assignments. ! ! This method must be implemented by all command classes.""" raise RuntimeError, \ "abstract method -- subclass %s must override" % self.__class__ def finalize_options (self): ! """Set final values for all the options that this command ! supports. This is always called as late as possible, ie. ! after any option assignments from the command-line or from ! other commands have been done. Thus, this is the place to to ! code option dependencies: if 'foo' depends on 'bar', then it ! is safe to set 'foo' from 'bar' as long as 'foo' still has ! the same value it was assigned in 'initialize_options()'. ! This method must be implemented by all command classes.""" ! raise RuntimeError, \ "abstract method -- subclass %s must override" % self.__class__ --- 112,137 ---- def initialize_options (self): """Set default values for all the options that this command ! supports. Note that these defaults may be overridden by other ! commands, by the setup script, by config files, or by the ! command-line. Thus, this is not the place to code dependencies ! between options; generally, 'initialize_options()' implementations ! are just a bunch of "self.foo = None" assignments. + This method must be implemented by all command classes. + """ raise RuntimeError, \ "abstract method -- subclass %s must override" % self.__class__ def finalize_options (self): ! """Set final values for all the options that this command supports. ! This is always called as late as possible, ie. after any option ! assignments from the command-line or from other commands have been ! done. Thus, this is the place to to code option dependencies: if ! 'foo' depends on 'bar', then it is safe to set 'foo' from 'bar' as ! long as 'foo' still has the same value it was assigned in ! 'initialize_options()'. ! This method must be implemented by all command classes. ! """ raise RuntimeError, \ "abstract method -- subclass %s must override" % self.__class__ *************** *** 152,163 **** def run (self): ! """A command's raison d'etre: carry out the action it exists ! to perform, controlled by the options initialized in ! 'initialize_options()', customized by the user and other ! commands, and finalized in 'finalize_options()'. All ! terminal output and filesystem interaction should be done by ! 'run()'. ! This method must be implemented by all command classes.""" raise RuntimeError, \ --- 153,165 ---- def run (self): ! """A command's raison d'etre: carry out the action it exists to ! perform, controlled by the options initialized in ! 'initialize_options()', customized by other commands, the setup ! script, the command-line, and config files, and finalized in ! 'finalize_options()'. All terminal output and filesystem ! interaction should be done by 'run()'. ! This method must be implemented by all command classes. ! """ raise RuntimeError, \ *************** *** 165,172 **** def announce (self, msg, level=1): ! """If the Distribution instance to which this command belongs ! has a verbosity level of greater than or equal to 'level' ! print 'msg' to stdout.""" ! if self.verbose >= level: print msg --- 167,173 ---- def announce (self, msg, level=1): ! """If the current verbosity level is of greater than or equal to ! 'level' print 'msg' to stdout. ! """ if self.verbose >= level: print msg *************** *** 184,199 **** def set_undefined_options (self, src_cmd, *option_pairs): """Set the values of any "undefined" options from corresponding ! option values in some other command object. "Undefined" here ! means "is None", which is the convention used to indicate ! that an option has not been changed between ! 'set_initial_values()' and 'set_final_values()'. Usually ! called from 'set_final_values()' for options that depend on ! some other command rather than another option of the same ! command. 'src_cmd' is the other command from which option ! values will be taken (a command object will be created for it ! if necessary); the remaining arguments are ! '(src_option,dst_option)' tuples which mean "take the value ! of 'src_option' in the 'src_cmd' command object, and copy it ! to 'dst_option' in the current command object".""" # Option_pairs: list of (src_option, dst_option) tuples --- 185,200 ---- def set_undefined_options (self, src_cmd, *option_pairs): """Set the values of any "undefined" options from corresponding ! option values in some other command object. "Undefined" here means ! "is None", which is the convention used to indicate that an option ! has not been changed between 'initialize_options()' and ! 'finalize_options()'. Usually called from 'finalize_options()' for ! options that depend on some other command rather than another ! option of the same command. 'src_cmd' is the other command from ! which option values will be taken (a command object will be created ! for it if necessary); the remaining arguments are ! '(src_option,dst_option)' tuples which mean "take the value of ! 'src_option' in the 'src_cmd' command object, and copy it to ! 'dst_option' in the current command object". ! """ # Option_pairs: list of (src_option, dst_option) tuples *************** *** 208,215 **** def get_finalized_command (self, command, create=1): ! """Wrapper around Distribution's 'get_command_obj()' method: ! find (create if necessary and 'create' is true) the command ! object for 'command'..""" ! cmd_obj = self.distribution.get_command_obj (command, create) cmd_obj.ensure_finalized () --- 209,217 ---- def get_finalized_command (self, command, create=1): ! """Wrapper around Distribution's 'get_command_obj()' method: find ! (create if necessary and 'create' is true) the command object for ! 'command', call its 'ensure_finalized()' method, and return the ! finalized command object. ! """ cmd_obj = self.distribution.get_command_obj (command, create) cmd_obj.ensure_finalized () *************** *** 223,229 **** def run_command (self, command): """Run some other command: uses the 'run_command()' method of ! Distribution, which creates the command object if necessary ! and then invokes its 'run()' method.""" ! self.distribution.run_command (command) --- 225,231 ---- def run_command (self, command): """Run some other command: uses the 'run_command()' method of ! Distribution, which creates and finalizes the command object if ! necessary and then invokes its 'run()' method. ! """ self.distribution.run_command (command) *************** *** 237,249 **** def execute (self, func, args, msg=None, level=1): ! """Perform some action that affects the outside world (eg. ! by writing to the filesystem). Such actions are special because ! they should be disabled by the "dry run" flag, and should ! announce themselves if the current verbosity level is high ! enough. This method takes care of all that bureaucracy for you; ! all you have to do is supply the funtion to call and an argument ! tuple for it (to embody the "external action" being performed), ! a message to print if the verbosity level is high enough, and an ! optional verbosity threshold.""" # Generate a message if we weren't passed one --- 239,252 ---- def execute (self, func, args, msg=None, level=1): ! """Perform some action that affects the outside world (eg. by ! writing to the filesystem). Such actions are special because they ! should be disabled by the "dry run" flag, and should announce ! themselves if the current verbosity level is high enough. This ! method takes care of all that bureaucracy for you; all you have to ! do is supply the funtion to call and an argument tuple for it (to ! embody the "external action" being performed), a message to print ! if the verbosity level is high enough, and an optional verbosity ! threshold. ! """ # Generate a message if we weren't passed one *************** *** 286,291 **** level=1): """Copy an entire directory tree respecting verbose, dry-run, ! and force flags.""" ! return util.copy_tree (infile, outfile, preserve_mode,preserve_times,preserve_symlinks, --- 289,294 ---- level=1): """Copy an entire directory tree respecting verbose, dry-run, ! and force flags. ! """ return util.copy_tree (infile, outfile, preserve_mode,preserve_times,preserve_symlinks, *************** *** 303,306 **** --- 306,310 ---- def spawn (self, cmd, search_path=1, level=1): + """Spawn an external command respecting verbose and dry-run flags.""" from distutils.spawn import spawn spawn (cmd, search_path, *************** *** 317,321 **** def make_file (self, infiles, outfile, func, args, exec_msg=None, skip_msg=None, level=1): - """Special case of 'execute()' for operations that process one or more input files and generate one output file. Works just like --- 321,324 ---- *************** *** 324,330 **** files listed in 'infiles'. If the command defined 'self.force', and it is true, then the command is unconditionally run -- does no ! timestamp checks.""" ! ! if exec_msg is None: exec_msg = "generating %s from %s" % \ --- 327,332 ---- files listed in 'infiles'. If the command defined 'self.force', and it is true, then the command is unconditionally run -- does no ! timestamp checks. ! """ if exec_msg is None: exec_msg = "generating %s from %s" % \ Index: core.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/core.py,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -r1.38 -r1.39 *** core.py 2000/05/31 01:11:20 1.38 --- core.py 2000/06/02 00:44:53 1.39 *************** *** 4,12 **** the 'setup' function (which is to be called from the setup script). Also indirectly provides the Distribution and Command classes, although they are ! really defined in distutils.dist and distutils.cmd.""" # created 1999/03/01, Greg Ward ! __revision__ = "$Id: core.py,v 1.38 2000/05/31 01:11:20 gward Exp $" import sys, os --- 4,13 ---- the 'setup' function (which is to be called from the setup script). Also indirectly provides the Distribution and Command classes, although they are ! really defined in distutils.dist and distutils.cmd. ! """ # created 1999/03/01, Greg Ward ! __revision__ = "$Id: core.py,v 1.39 2000/06/02 00:44:53 gward Exp $" import sys, os *************** *** 38,71 **** def setup (**attrs): ! """The gateway to the Distutils: do everything your setup script ! needs to do, in a highly flexible and user-driven way. Briefly: ! create a Distribution instance; parse the command-line, creating ! and customizing instances of the command class for each command ! found on the command-line; run each of those commands. ! ! The Distribution instance might be an instance of a class ! supplied via the 'distclass' keyword argument to 'setup'; if no ! such class is supplied, then the 'Distribution' class (also in ! this module) is instantiated. All other arguments to 'setup' ! (except for 'cmdclass') are used to set attributes of the ! Distribution instance. ! ! The 'cmdclass' argument, if supplied, is a dictionary mapping ! command names to command classes. Each command encountered on ! the command line will be turned into a command class, which is in ! turn instantiated; any class found in 'cmdclass' is used in place ! of the default, which is (for command 'foo_bar') class 'foo_bar' ! in module 'distutils.command.foo_bar'. The command class must ! provide a 'user_options' attribute which is a list of option ! specifiers for 'distutils.fancy_getopt'. Any command-line ! options between the current and the next command are used to set ! attributes of the current command object. ! ! When the entire command-line has been successfully parsed, calls ! the 'run()' method on each command object in turn. This method ! will be driven entirely by the Distribution object (which each ! command object has a reference to, thanks to its constructor), ! and the command-specific options that became attributes of each ! command object.""" from pprint import pprint # for debugging output --- 39,73 ---- def setup (**attrs): ! """The gateway to the Distutils: do everything your setup script needs ! to do, in a highly flexible and user-driven way. Briefly: create a ! Distribution instance; find and parse config files; parse the command ! line; run each of those commands using the options supplied to ! 'setup()' (as keyword arguments), in config files, and on the command ! line. ! ! The Distribution instance might be an instance of a class supplied via ! the 'distclass' keyword argument to 'setup'; if no such class is ! supplied, then the Distribution class (in dist.py) is instantiated. ! All other arguments to 'setup' (except for 'cmdclass') are used to set ! attributes of the Distribution instance. ! ! The 'cmdclass' argument, if supplied, is a dictionary mapping command ! names to command classes. Each command encountered on the command line ! will be turned into a command class, which is in turn instantiated; any ! class found in 'cmdclass' is used in place of the default, which is ! (for command 'foo_bar') class 'foo_bar' in module ! 'distutils.command.foo_bar'. The command class must provide a ! 'user_options' attribute which is a list of option specifiers for ! 'distutils.fancy_getopt'. Any command-line options between the current ! and the next command are used to set attributes of the current command ! object. ! ! When the entire command-line has been successfully parsed, calls the ! 'run()' method on each command object in turn. This method will be ! driven entirely by the Distribution object (which each command object ! has a reference to, thanks to its constructor), and the ! command-specific options that became attributes of each command ! object. ! """ from pprint import pprint # for debugging output From python-dev@python.org Fri Jun 2 02:50:01 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 1 Jun 2000 18:50:01 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist_rpm.py,1.5,1.6 Message-ID: <200006020150.SAA02834@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv2562/command Modified Files: bdist_rpm.py Log Message: Fairly massive overhaul to support getting RPM inputs (extra meta-data, prep/build/etc. scripts, doc files, dependency info) from a config file rather than the dedicated "package_info" file. (The idea is that developers will provide RPM-specific info in the "[bdist_rpm]" section of setup.cfg, but of course it could also be supplied in the other config files, on the command line, or in the setup script -- or any mix of the above.) Major changes: * added a boatload of options to 'user_options' and 'initialize_options()': 'distribution_name', 'group', 'release', ... * added 'finalize_package_data()', which takes the place of '_get_package_data()' -- except it's called from 'finalize_options()', not 'run()', so we have everything figured out before we actually run the command * added 'ensure_string()', 'ensure_string_list()', 'ensure_filename()'; these take the place of '_check_string()' and friends. (These actually look like really useful type-checking methods that could come in handy all over the Distutils; should consider moving them up to Command and using them in other command classes' 'finalize_options()' method for error-checking). * various cleanup, commentary, and adaptation to the new way of storing RPM info in '_make_spec_file()' Index: bdist_rpm.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist_rpm.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** bdist_rpm.py 2000/06/01 00:40:25 1.5 --- bdist_rpm.py 2000/06/02 01:49:58 1.6 *************** *** 6,12 **** # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.5 2000/06/01 00:40:25 gward Exp $" ! import os, string from types import * from distutils.core import Command --- 6,12 ---- # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.6 2000/06/02 01:49:58 gward Exp $" ! import os, string, re from types import * from distutils.core import Command *************** *** 29,32 **** --- 29,89 ---- ('use-bzip2', None, "use bzip2 instead of gzip to create source distribution"), + + # More meta-data: too RPM-specific to put in the setup script, + # but needs to go in the .spec file -- so we make these options + # to "bdist_rpm". The idea is that packagers would put this + # info in setup.cfg, although they are of course free to + # supply it on the command line. + ('distribution-name', None, + "name of the (Linux) distribution name to which this " + "RPM applies (*not* the name of the module distribution!)"), + ('group', None, + "package classification [default: \"Development/Libraries\"]"), + ('release', None, + "RPM release number"), + ('serial', None, + "???"), + ('vendor', None, + "RPM \"vendor\" (eg. \"Joe Blow \") " + "[default: maintainer or author from setup script]"), + ('packager', None, + "RPM packager (eg. \"Jane Doe \")" + "[default: vendor]"), + ('doc-files', None, + "list of documentation files (space or comma-separated)"), + ('changelog', None, + "RPM changelog"), + ('icon', None, + "name of icon file"), + + ('prep-cmd', None, + "?? pre-build command(s) ??"), + ('build-cmd', None, + "?? build command(s) ??"), + ('install-cmd', None, + "?? installation command(s) ??"), + ('clean-cmd', None, + "?? clean command(s) ??"), + ('pre-install', None, + "pre-install script (Bourne shell code)"), + ('post-install', None, + "post-install script (Bourne shell code)"), + ('pre-uninstall', None, + "pre-uninstall script (Bourne shell code)"), + ('post-uninstall', None, + "post-uninstall script (Bourne shell code)"), + + ('provides', None, + "???"), + ('requires', None, + "???"), + ('conflicts', None, + "???"), + ('build-requires', None, + "???"), + ('obsoletes', None, + "???"), + + # Actions to take when building RPM ('clean', None, "clean up RPM build directory [default]"), *************** *** 49,52 **** --- 106,135 ---- self.source_only = None self.use_bzip2 = None + + self.distribution_name = None + self.group = None + self.release = None + self.serial = None + self.vendor = None + self.packager = None + self.doc_files = None + self.changelog = None + self.icon = None + + self.prep_cmd = None + self.build_cmd = None + self.install_cmd = None + self.clean_cmd = None + self.pre_install = None + self.post_install = None + self.pre_uninstall = None + self.post_uninstall = None + self.prep = None + self.provides = None + self.requires = None + self.conflicts = None + self.build_requires = None + self.obsoletes = None + self.clean = 1 self.use_rpm_opt_flags = 1 *************** *** 64,76 **** raise DistutilsOptionsError, \ "cannot supply both '--source-only' and '--binary-only'" # don't pass CFLAGS to pure python distributions if not self.distribution.has_ext_modules(): self.use_rpm_opt_flags = 0 # finalize_options() def run (self): ! self._get_package_data() # get packaging info # make directories --- 147,256 ---- raise DistutilsOptionsError, \ "cannot supply both '--source-only' and '--binary-only'" + # don't pass CFLAGS to pure python distributions if not self.distribution.has_ext_modules(): self.use_rpm_opt_flags = 0 + self.finalize_package_data() + # finalize_options() + def finalize_package_data (self): + self.ensure_string('group', "Development/Libraries") + self.ensure_string('vendor', + "%s <%s>" % (self.distribution.get_contact(), + self.distribution.get_contact_email())) + self.ensure_string('packager', self.vendor) # or nothing? + self.ensure_string_list('doc_files') + if type(self.doc_files) is ListType: + for readme in ('README', 'README.txt'): + if os.path.exists(readme) and readme not in self.doc_files: + self.doc.append(readme) + + self.ensure_string('release', "1") # should it be an int? + self.ensure_string('serial') # should it be an int? + + self.ensure_string('icon') + self.ensure_string('distribution_name') + self.ensure_string('prep_cmd', "%setup") # string or filename? + + if self.use_rpm_opt_flags: + def_build = 'env CFLAGS="$RPM_OPT_FLAGS" python setup.py build' + else: + def_build = 'python setup.py build' + self.ensure_string('build_cmd', def_build) + self.ensure_string('install_cmd', + "python setup.py install --root=$RPM_BUILD_ROOT " + "--record=INSTALLED_FILES") + self.ensure_string('clean_cmd', + "rm -rf $RPM_BUILD_ROOT") + self.ensure_filename('pre_install') + self.ensure_filename('post_install') + self.ensure_filename('pre_uninstall') + self.ensure_filename('post_uninstall') + + # XXX don't forget we punted on summaries and descriptions -- they + # should be handled here eventually! + + # Now *this* is some meta-data that belongs in the setup script... + self.ensure_string_list('provides') + self.ensure_string_list('requires') + self.ensure_string_list('conflicts') + self.ensure_string_list('build_requires') + self.ensure_string_list('obsoletes') + + # finalize_package_data () + + + # XXX these look awfully handy: should probably move them + # up to Command and use more widely. + def _ensure_stringlike (self, option, what, default=None): + val = getattr(self, option) + if val is None: + setattr(self, option, default) + return default + elif type(val) is not StringType: + raise DistutilsOptionError, \ + "'%s' must be a %s (got `%s`)" % (option, what, val) + return val + + def ensure_string (self, option, default=None): + self._ensure_stringlike(option, "string", default) + + def ensure_string_list (self, option): + val = getattr(self, option) + if val is None: + return + elif type(val) is StringType: + setattr(self, option, re.split(r',\s*|\s+', val)) + else: + if type(val) is ListType: + types = map(type, val) + ok = (types == [StringType] * len(val)) + else: + ok = 0 + + if not ok: + raise DistutilsOptionError, \ + "'%s' must be a list of strings (got %s)" % \ + (option, `val`) + + def ensure_filename (self, option, default=None): + val = self._ensure_stringlike(option, "filename", None) + if val is not None and not os.path.exists(val): + raise DistutilsOptionError, \ + "error in '%s' option: file '%s' does not exist" % \ + (option, val) + + + def run (self): ! ! print "before _get_package_data():" ! print "vendor =", self.vendor ! print "packager =", self.packager ! print "doc_files =", self.doc_files ! print "changelog =", self.changelog # make directories *************** *** 207,213 **** def _make_spec_file(self): ! ''' Generate an RPM spec file ''' ! ! # definitons and headers spec_file = [ '%define name ' + self.distribution.get_name(), --- 387,394 ---- def _make_spec_file(self): ! """Generate the text of an RPM spec file and return it as a ! list of strings (one per line). ! """ ! # definitions and headers spec_file = [ '%define name ' + self.distribution.get_name(), *************** *** 219,225 **** # put locale summaries into spec file ! for locale in self.summaries.keys(): ! spec_file.append('Summary(%s): %s' % (locale, ! self.summaries[locale])) spec_file.extend([ --- 400,408 ---- # put locale summaries into spec file ! # XXX not supported for now (hard to put a dictionary ! # in a config file -- arg!) ! #for locale in self.summaries.keys(): ! # spec_file.append('Summary(%s): %s' % (locale, ! # self.summaries[locale])) spec_file.extend([ *************** *** 227,234 **** --- 410,422 ---- 'Version: %{version}', 'Release: %{release}',]) + + # XXX yuck! this filename is available from the "sdist" command, + # but only after it has run: and we create the spec file before + # running "sdist", in case of --spec-only. if self.use_bzip2: spec_file.append('Source0: %{name}-%{version}.tar.bz2') else: spec_file.append('Source0: %{name}-%{version}.tar.gz') + spec_file.extend([ 'Copyright: ' + self.distribution.get_licence(), *************** *** 248,254 **** 'Obsoletes', ): ! if getattr(self, string.lower(field)): ! spec_file.append('%s: %s' % ! (field, getattr(self, string.lower(field)))) if self.distribution.get_url() != 'UNKNOWN': --- 436,445 ---- 'Obsoletes', ): ! val = getattr(self, string.lower(field)) ! if type(val) is ListType: ! spec_file.append('%s: %s' % (field, string.join(val))) ! elif val is not None: ! spec_file.append('%s: %s' % (field, val)) ! if self.distribution.get_url() != 'UNKNOWN': *************** *** 259,263 **** if self.build_requires: ! spec_file.append('BuildRequires: ' + self.build_requires) if self.icon: --- 450,455 ---- if self.build_requires: ! spec_file.append('BuildRequires: ' + ! string.join(self.build_requires)) if self.icon: *************** *** 271,296 **** # put locale descriptions into spec file ! for locale in self.descriptions.keys(): ! spec_file.extend([ ! '', ! '%description -l ' + locale, ! self.descriptions[locale], ! ]) # rpm scripts ! for script in ('prep', ! 'build', ! 'install', ! 'clean', ! 'pre', ! 'post', ! 'preun', ! 'postun', ! ): ! if getattr(self, script): spec_file.extend([ '', ! '%' + script, ! getattr(self, script), ]) --- 463,494 ---- # put locale descriptions into spec file ! # XXX again, suppressed because config file syntax doesn't ! # easily support this ;-( ! #for locale in self.descriptions.keys(): ! # spec_file.extend([ ! # '', ! # '%description -l ' + locale, ! # self.descriptions[locale], ! # ]) # rpm scripts ! for (rpm_opt, attr) in (('prep', 'prep_cmd'), ! ('build', 'build_cmd'), ! ('install', 'install_cmd'), ! ('clean', 'clean_cmd'), ! ('pre', 'pre_install'), ! ('post', 'post_install'), ! ('preun', 'pre_uninstall'), ! ('postun', 'post_uninstall')): ! # XXX oops, this doesn't distinguish between "raw code" ! # options and "script filename" options -- well, we probably ! # should settle on one or the other, and not make the ! # distinction! ! val = getattr(self, attr) ! if val: spec_file.extend([ '', ! '%' + rpm_opt, ! val ]) *************** *** 303,308 **** ]) ! if self.doc: ! spec_file.append('%doc ' + self.doc) if self.changelog: --- 501,506 ---- ]) ! if self.doc_files: ! spec_file.append('%doc ' + string.join(self.doc_files)) if self.changelog: From python-dev@python.org Fri Jun 2 02:52:06 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 1 Jun 2000 18:52:06 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist_rpm.py,1.6,1.7 Message-ID: <200006020152.SAA03020@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv3008/command Modified Files: bdist_rpm.py Log Message: Ditched the obsolete '_get_package_data()' method and its '_check_*()' helpers. Index: bdist_rpm.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist_rpm.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** bdist_rpm.py 2000/06/02 01:49:58 1.6 --- bdist_rpm.py 2000/06/02 01:52:04 1.7 *************** *** 6,10 **** # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.6 2000/06/02 01:49:58 gward Exp $" import os, string, re --- 6,10 ---- # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.7 2000/06/02 01:52:04 gward Exp $" import os, string, re *************** *** 319,389 **** - def _get_package_data(self): - ''' Get data needed to generate spec file, first from the - DistributionMetadata class, then from the package_data file, which is - Python code read with execfile() ''' - - from string import join - - package_type = 'rpm' - - # read in package data, if any - if os.path.exists('package_data'): - try: - exec(open('package_data')) - except: - raise DistutilsOptionError, 'Unable to parse package data file' - - # set instance variables, supplying default value if not provided in - # package data file - self.package_data = locals() - - # the following variables must be {string (len() = 2): string} - self.summaries = self._check_string_dict('summaries') - self.descriptions = self._check_string_dict('descriptions') - - # The following variable must be an ordinary number or a string - self.release = self._check_number_or_string('release', '1') - self.serial = self._check_number_or_string('serial') - - # The following variables must be strings - self.group = self._check_string('group', 'Development/Libraries') - self.vendor = self._check_string('vendor') - self.packager = self._check_string('packager') - self.changelog = self._check_string('changelog') - self.icon = self._check_string('icon') - self.distribution_name = self._check_string('distribution_name') - self.pre = self._check_string('pre') - self.post = self._check_string('post') - self.preun = self._check_string('preun') - self.postun = self._check_string('postun') - self.prep = self._check_string('prep', '%setup') - if self.use_rpm_opt_flags: - self.build = (self._check_string( - 'build', - 'env CFLAGS="$RPM_OPT_FLAGS" python setup.py build')) - else: - self.build = (self._check_string('build', 'python setup.py build')) - self.install = self._check_string( - 'install', - 'python setup.py install --root=$RPM_BUILD_ROOT --record') - self.clean = self._check_string( - 'clean', - 'rm -rf $RPM_BUILD_ROOT') - - # The following variables must be a list or tuple of strings, or a - # string - self.doc = self._check_string_list('doc') - if type(self.doc) == ListType: - for readme in ('README', 'README.txt'): - if os.path.exists(readme) and readme not in self.doc: - self.doc.append(readme) - self.doc = join(self.doc) - self.provides = join(self._check_string_list('provides')) - self.requires = join(self._check_string_list('requires')) - self.conflicts = join(self._check_string_list('conflicts')) - self.build_requires = join(self._check_string_list('build_requires')) - self.obsoletes = join(self._check_string_list('obsoletes')) - def _make_spec_file(self): """Generate the text of an RPM spec file and return it as a --- 319,322 ---- *************** *** 512,589 **** return spec_file - - def _check_string_dict(self, var_name, default_value = {}): - ''' Tests a wariable to determine if it is {string: string}, - var_name is the name of the wariable. Return the value if it is valid, - returns default_value if the variable does not exist, raises - DistutilsOptionError if the variable is not valid''' - if self.package_data.has_key(var_name): - pass_test = 1 # set to 0 if fails test - value = self.package_data[var_name] - if type(value) == DictType: - for locale in value.keys(): - if (type(locale) != StringType) or (type(value[locale]) != - StringType): - pass_test = 0 - break - if pass_test: - return test_me - raise DistutilsOptionError, \ - ("Error in package_data: '%s' must be dictionary: " - '{string: string}' % var_name) - else: - return default_value - - def _check_string(self, var_name, default_value = None): - ''' Tests a variable in package_data to determine if it is a string, - var_name is the name of the wariable. Return the value if it is a - string, returns default_value if the variable does not exist, raises - DistutilsOptionError if the variable is not a string''' - if self.package_data.has_key(var_name): - if type(self.package_data[var_name]) == StringType: - return self.package_data[var_name] - else: - raise DistutilsOptionError, \ - "Error in package_data: '%s' must be a string" % var_name - else: - return default_value ! def _check_number_or_string(self, var_name, default_value = None): ! ''' Tests a variable in package_data to determine if it is a number or ! a string, var_name is the name of the wariable. Return the value if it ! is valid, returns default_value if the variable does not exist, raises ! DistutilsOptionError if the variable is not valid''' ! if self.package_data.has_key(var_name): ! if type(self.package_data[var_name]) in (StringType, LongType, ! IntType, FloatType): ! return str(self.package_data[var_name]) ! else: ! raise DistutilsOptionError, \ ! ("Error in package_data: '%s' must be a string or a " ! 'number' % var_name) ! else: ! return default_value ! def _check_string_list(self, var_name, default_value = []): ! ''' Tests a variable in package_data to determine if it is a string or ! a list or tuple of strings, var_name is the name of the wariable. ! Return the value as a string or a list if it is valid, returns ! default_value if the variable does not exist, raises ! DistutilsOptionError if the variable is not valid''' ! if self.package_data.has_key(var_name): ! value = self.package_data[var_name] ! pass_test = 1 ! if type(value) == StringType: ! return value ! elif type(value) in (ListType, TupleType): ! for item in value: ! if type(item) != StringType: ! pass_test = 0 ! break ! if pass_test: ! return list(value) ! raise DistutilsOptionError, \ ! ("Error in package_data: '%s' must be a string or a " ! 'list or tuple of strings' % var_name) ! else: ! return default_value --- 445,450 ---- return spec_file ! # _make_spec_file () ! # class bdist_rpm From python-dev@python.org Fri Jun 2 02:55:38 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 1 Jun 2000 18:55:38 -0700 Subject: [Python-checkins] CVS: distutils/distutils core.py,1.39,1.40 Message-ID: <200006020155.SAA03135@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv3126 Modified Files: core.py Log Message: Use Distribution method 'dump_option_dicts()' for debugging output, and only do so if DEBUG is true. Index: core.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/core.py,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -r1.39 -r1.40 *** core.py 2000/06/02 00:44:53 1.39 --- core.py 2000/06/02 01:55:36 1.40 *************** *** 9,13 **** # created 1999/03/01, Greg Ward ! __revision__ = "$Id: core.py,v 1.39 2000/06/02 00:44:53 gward Exp $" import sys, os --- 9,13 ---- # created 1999/03/01, Greg Ward ! __revision__ = "$Id: core.py,v 1.40 2000/06/02 01:55:36 gward Exp $" import sys, os *************** *** 71,76 **** """ - from pprint import pprint # for debugging output - # Determine the distribution class -- either caller-supplied or # our Distribution (see below). --- 71,74 ---- *************** *** 89,94 **** dist.parse_config_files() ! print "options (after parsing config files):" ! pprint (dist.command_options) # Parse the command line; any command-line errors are the end user's --- 87,93 ---- dist.parse_config_files() ! if DEBUG: ! print "options (after parsing config files):" ! dist.dump_option_dicts() # Parse the command line; any command-line errors are the end user's *************** *** 100,105 **** raise SystemExit, "error: %s" % msg ! print "options (after parsing command line):" ! pprint (dist.command_options) # And finally, run all the commands found on the command line. --- 99,105 ---- raise SystemExit, "error: %s" % msg ! if DEBUG: ! print "options (after parsing command line):" ! dist.dump_option_dicts() # And finally, run all the commands found on the command line. From python-dev@python.org Fri Jun 2 02:59:35 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 1 Jun 2000 18:59:35 -0700 Subject: [Python-checkins] CVS: distutils/distutils dist.py,1.23,1.24 Message-ID: <200006020159.SAA03331@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv3323 Modified Files: dist.py Log Message: Only print debugging output if DEBUG true (and deleted some of the more extraneous debug prints). Index: dist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/dist.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -r1.23 -r1.24 *** dist.py 2000/06/02 00:44:53 1.23 --- dist.py 2000/06/02 01:59:33 1.24 *************** *** 8,12 **** # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: dist.py,v 1.23 2000/06/02 00:44:53 gward Exp $" import sys, os, string, re --- 8,12 ---- # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: dist.py,v 1.24 2000/06/02 01:59:33 gward Exp $" import sys, os, string, re *************** *** 295,307 **** from ConfigParser import ConfigParser if filenames is None: filenames = self.find_config_files() ! print "Distribution.parse_config_files():" parser = ConfigParser() for filename in filenames: ! print " reading", filename parser.read(filename) for section in parser.sections(): --- 295,308 ---- from ConfigParser import ConfigParser + from distutils.core import DEBUG if filenames is None: filenames = self.find_config_files() ! if DEBUG: print "Distribution.parse_config_files():" parser = ConfigParser() for filename in filenames: ! if DEBUG: print " reading", filename parser.read(filename) for section in parser.sections(): *************** *** 371,375 **** # each command listed on the command line. if self.help: - print "showing 'global' help; commands=", self.commands self._show_help(parser, display_options=len(self.commands) == 0, --- 372,375 ---- *************** *** 441,445 **** (args, opts) = parser.getopt (args[1:]) if hasattr(opts, 'help') and opts.help: - print "showing help for command", cmd_class self._show_help(parser, display_options=0, commands=[cmd_class]) return --- 441,444 ---- *************** *** 644,651 **** return it (if 'create' is true) or return None. """ cmd_obj = self.command_obj.get(command) if not cmd_obj and create: ! print "Distribution.get_command_obj(): " \ ! "creating '%s' command object" % command klass = self.get_command_class(command) --- 643,652 ---- return it (if 'create' is true) or return None. """ + from distutils.core import DEBUG cmd_obj = self.command_obj.get(command) if not cmd_obj and create: ! if DEBUG: ! print "Distribution.get_command_obj(): " \ ! "creating '%s' command object" % command klass = self.get_command_class(command) From python-dev@python.org Fri Jun 2 03:01:54 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 1 Jun 2000 19:01:54 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist_rpm.py,1.7,1.8 Message-ID: <200006020201.TAA06811@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv6759/command Modified Files: bdist_rpm.py Log Message: Only print debugging output if DEBUG true. Index: bdist_rpm.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist_rpm.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** bdist_rpm.py 2000/06/02 01:52:04 1.7 --- bdist_rpm.py 2000/06/02 02:01:51 1.8 *************** *** 6,14 **** # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.7 2000/06/02 01:52:04 gward Exp $" import os, string, re from types import * ! from distutils.core import Command from distutils.util import get_platform, write_file from distutils.errors import * --- 6,14 ---- # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.8 2000/06/02 02:01:51 gward Exp $" import os, string, re from types import * ! from distutils.core import Command, DEBUG from distutils.util import get_platform, write_file from distutils.errors import * *************** *** 248,256 **** def run (self): ! print "before _get_package_data():" ! print "vendor =", self.vendor ! print "packager =", self.packager ! print "doc_files =", self.doc_files ! print "changelog =", self.changelog # make directories --- 248,257 ---- def run (self): ! if DEBUG: ! print "before _get_package_data():" ! print "vendor =", self.vendor ! print "packager =", self.packager ! print "doc_files =", self.doc_files ! print "changelog =", self.changelog # make directories From python-dev@python.org Fri Jun 2 03:03:33 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 1 Jun 2000 19:03:33 -0700 Subject: [Python-checkins] CVS: distutils package_data,1.1,NONE Message-ID: <200006020203.TAA09070@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv9055 Removed Files: package_data Log Message: Removed -- thanks to recent heavy renovations in the "bdist_rpm" command, the contents of this file can all live in setup.cfg. From python-dev@python.org Fri Jun 2 03:07:46 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 1 Jun 2000 19:07:46 -0700 Subject: [Python-checkins] CVS: distutils setup.cfg,NONE,1.1 Message-ID: <200006020207.TAA09378@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv9364 Added Files: setup.cfg Log Message: The Distutils config file. Just as with the Distutils setup script, this has the dual purpose of being used to distribute the Distutils and serving as an example of some of the things you can do with Distutils config files. Currently, this is only useful for me (assuming I'm the only person who creates Distutils source and RPM distributions), but you could add build and installation preferences here, too. (Although those sorts of things are probably best handled on a site-wide or per-user basis, rather than in the config file for each module distribution.) From python-dev@python.org Fri Jun 2 03:09:56 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 1 Jun 2000 19:09:56 -0700 Subject: [Python-checkins] CVS: distutils TODO,1.1,1.2 Message-ID: <200006020209.TAA10096@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv9978 Modified Files: TODO Log Message: Recently revived the to-do list after months of hibernation -- lots of additions and a few deletions. Index: TODO =================================================================== RCS file: /cvsroot/python/distutils/TODO,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** TODO 1999/12/16 01:13:05 1.1 --- TODO 2000/06/02 02:09:53 1.2 *************** *** 2,14 **** ------- - * how to commands communicate non-option data amongst themselves? - eg. 'install_py' might want to ask 'build_py' which .py files - to install and compile -- how should that be handled (NB. - implies that 'build' must be run before 'install' is run, - can't just go by what's in the filesystem) - -> currently done by commands just knowing about each others' - options and methods; this seems to work, and I don't see - a need for further bureaucracy here - * I think fancy_getopt needs to get fancier to properly support the -I, -D, -l, -L, etc. options of "build_ext": need to be able --- 2,5 ---- *************** *** 17,33 **** repetitions of the same option will accumulate or replace, etc. BUILD/INSTALL ------------- - * "site" vs "std" install directories need to be more symmetrical. - Perhaps: - 'install_std_lib' and 'install_std_platlib' - vs - 'install_site_lib' and 'install_site_platlib' - and when we know the installation scheme ('std' or 'site'), we pick - one of these pairs as 'install_lib' and 'install_platlib'. Then - the install_* commands need only refer to 'install_lib' and - 'install_platlib', and not worry about the installation scheme. --- 8,93 ---- repetitions of the same option will accumulate or replace, etc. + * do the above options even work at all? seem to recall hearing + reports of dismal failure, but I never looked into it + [knowing how FancyGetopt works, there's no way these options + can work: damn] + + * think about how to support distribution-specific "configure" commands -- + eg. how can they push option values (include/library directories, that + sort of thing) onto the "build_ext" command? + + * should/can the 'finalize_options()' methods be made more robust, so + you can sensibly call them multiple times? this might be all that's + necessary to enable option-pushing... + [no: added reinitialize_command(), which *is* what's needed to enable + option-pushing] + + * inconsistent use of -f (sdist vs bdist) -- force or format? + + * fix UnixCCompiler so it doesn't depend on sysconfig (ie. cc must + be passed in) + + * allow user to supply cc (compiler executable) in addition to + compiler type + + * ?? add pre-processor interface to CCompiler ?? (needed to support + Autoconf-style 'try_cpp', 'search_cpp', 'search_headers' in config + commands) + + * radically simplify CCompiler method signatures: drop most of the + per-invocation customization, and just use the instance + attributes for eg. include_dirs, libraries, ... + + * need a good, general-purpose, portable-if-you-want-it, unportable-if- + you-need-control, way for the builder/installer to specify compiler + and linker flags (lots of people expect CFLAGS and LDFLAGS to work, + so they probably should; but options to either command and/or + build are the right way, so those should be preferred) + + + HELP + ---- + + * interface for "help about some option" -- eg. --help-compiler to + build_ext would list available compilers; --help-formats to "sdist" + or "bdist" would list available distribution formats; ... + [delegated to Rene Liebscher] + + DOCS + ---- + + * write write write + + * standard blurb for README files + + + BUILD/INSTALL ------------- + + * if Distutils installs the first third-party modules in an installation + (and creates site-packages), then "install" needlessly warns about + having installed to a location not on sys.path -- presumably because + site-packages isn't in sys.path at startup, since it doesn't exist + until we create it! (I think this is only a problem with 1.5.2, + since site-packages is now created when Python is installed -- check!) + + * write a class Extension (name?) to hold all the information needed + to describe a single extension -- ie. replace the (ext_name, build_info) + tuple (particularly build_info!) + [done 2000/05/30 GPW] + + * need a mechanism for specifying pre-install and post-install hooks, + which will be run when installing from a smart built distribution + (RPM, wininst, etc.); also, "install" needs to run these hooks + *except* for "fake" installs done solely to create a built distribution + + * extension building on AIX + + * bdist_dumb should grow a little intelligence: let packager choose whether + to make archive relative to prefix or the root (prefix is essential + for proper Windows support ) *************** *** 35,42 **** --- 95,121 ---- ------------------ + * review and integrate cygwin patch from Rene Liebscher + + DISTRIBUTIONS + ------------- + + * review/tweak bdist_rpm code from Harry Gebel (minor style issues, fix + hardcoded directories) + [done 2000/06/01 GPW, but in need of serious testing!] + + * figure out why bdist_rpm doesn't work with RPM 2.x, and make it work if + possible + + * make "bdist" take multiple formats (both for convenience + and consistency with "sdist"); should be doable now that we can + reinitialize, refinalize, and (presumably) rerun commands + + EXTERNAL DEPENDENCIES --------------------- + * ??? do we need to implement autoconf in Python (shudder) ??? + * if not, how to handle the case of "if Tk present, build with it" in PIL, or "define HAVE_STRFTIME if we have strftime()" in mxDateTime"? From python-dev@python.org Fri Jun 2 03:22:08 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 1 Jun 2000 19:22:08 -0700 Subject: [Python-checkins] CVS: distutils README.txt,1.14,1.15 Message-ID: <200006020222.TAA14899@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv14885 Modified Files: README.txt Log Message: Started updating for forthcoming 0.9 release. Index: README.txt =================================================================== RCS file: /cvsroot/python/distutils/README.txt,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** README.txt 2000/04/25 03:05:16 1.14 --- README.txt 2000/06/02 02:22:06 1.15 *************** *** 1,5 **** ! Python Distutils ! release 0.8.2 ! April 24, 2000 --- 1,5 ---- ! Python Distribution Utilities ! release 0.9 (pre) ! June ??, 2000 *************** *** 42,48 **** ------------ ! Release 0.8.2 of the Distutils requires Python 1.5.2 or later. ! (Compatibility with Python 1.5.1 is forthcoming, as soon as I merge the ! 1.5.1 compatibility changes from Distutils 0.1.4 and 0.1.5 forward.) To use the Distutils under Unix, you must have a *complete* Python --- 42,50 ---- ------------ ! Release 0.9 of the Distutils requires Python 1.5.2 or later. (If you ! absolutely must Python 1.5.1, Distutils 0.1.5 is backwards compatible. ! However, I have dropped plans to port the current Distutils code back to ! Python 1.5.1, as I have received exactly zero complaints about requiring ! Python 1.5.2 since releasing Distutils 0.8 in April.) To use the Distutils under Unix, you must have a *complete* Python *************** *** 74,78 **** fine. (Python 1.6 includes the winreg module for this purpose, which the Distutils will use if available.) If not, the Distutils might not ! be able to find the Visual C++ executables. --- 76,81 ---- fine. (Python 1.6 includes the winreg module for this purpose, which the Distutils will use if available.) If not, the Distutils might not ! be able to find the Visual C++ executables, in which case it will die ! horribly when you attempt to build any Python extensions. *************** *** 105,111 **** The Distutils are included with Python 1.6, so there's generally no need ! to install it under Python 1.6. However, Distutils 0.8.2 is more recent than the code included with Python 1.6a2, so if you really like life on ! the bleeding edge, you might want to install this Distutils release into your Python 1.6a2 library. --- 108,114 ---- The Distutils are included with Python 1.6, so there's generally no need ! to install it under Python 1.6. However, this release is more recent than the code included with Python 1.6a2, so if you really like life on ! the bleeding edge, you might want to install this Distutils release into your Python 1.6a2 library. *************** *** 132,140 **** The Distutils is intended to have three user communities: developers, ! packagers, and installers. This release caters mainly to developers and ! installers (system administrators, users of Python modules and ! applications); there is currently a little support for generating ! "built" (binary) distributions, so would-be packagers can at least start ! playing with the Distutils. Documentation for the Distutils is under construction in the form of two --- 135,144 ---- The Distutils is intended to have three user communities: developers, ! packagers, and installers. Distutils 0.9 is the first release that ! seriously caters to all three communities: developers can use it to ! build and install their modules, as well as create source distributions; ! packagers can use it to create RPMs and (soon!) executable installers ! for Windows; and of course installers can build and install modules from ! source (or just use an installer created by some kind packager). Documentation for the Distutils is under construction in the form of two *************** *** 142,148 **** Python Modules" (for developers and packagers). I've included the LaTeX source for these two manuals in the "doc" subdirectory; if you know your ! way around LaTeX and the Python documentation tools, you can probably ! get something out of these. Otherwise, you're better off getting the ! latest documentation from the Distutils documentation page: http://www.python.org/sigs/distutils-sig/doc/ --- 146,154 ---- Python Modules" (for developers and packagers). I've included the LaTeX source for these two manuals in the "doc" subdirectory; if you know your ! way around LaTeX, the Python documentation tools, and Unix, you might be ! able to get something out of these. Realistically, though, the ! documentation is just provided in the distributio so you can send me doc ! patches; if you want to read it, you're better off getting the latest ! documentation from the Distutils documentation page: http://www.python.org/sigs/distutils-sig/doc/ *************** *** 153,162 **** If you are an installer (system administrator or end-user) and you'd like to try out the Distutils, you've already done so by installing the ! Distutils themselves (thanks!). Additionally, at least two major module ! distributions (Numerical Python and PyXML) use the Distutils for ! installation; if you have installed the Distutils just to get another ! distributions up-and-running, follow the instructions included with that ! distribution. For any "distutil-ized" distribution, though, this should ! always work: python setup.py install --- 159,167 ---- If you are an installer (system administrator or end-user) and you'd like to try out the Distutils, you've already done so by installing the ! Distutils themselves (thanks!). Additionally, a number of module ! distributions now use the Distutils for installation; if you have ! installed the Distutils just to get another distribution up-and-running, ! follow the instructions included with that distribution. For any ! "distutil-ized" distribution, though, this should always work: python setup.py install *************** *** 342,348 **** * Bastian Kleineidam: the "clean" command, and a pile of patches, bug-fixes, and ideas, large and small ! * Lyle Johnson: bug-spotting and -fixing * Harry Henry Gebel: bug-spotting and -fixing; the "bztar" archive ! format [spiritual, in roughly chronological order since the birth of the project] --- 347,356 ---- * Bastian Kleineidam: the "clean" command, and a pile of patches, bug-fixes, and ideas, large and small ! * Lyle Johnson: bug-spotting and -fixing; (forthcoming) support ! for Borland's C/C++ compiler * Harry Henry Gebel: bug-spotting and -fixing; the "bztar" archive ! format; the "bdist_rpm" command ! * Rene Liebscher: smarter extension-building; (forthcoming?) ! Cygwin/Mingw32 support [spiritual, in roughly chronological order since the birth of the project] *************** *** 364,366 **** the CPAN archive (Jarkko), and the CPAN module (Andreas) ! $Id: README.txt,v 1.14 2000/04/25 03:05:16 gward Exp $ --- 372,374 ---- the CPAN archive (Jarkko), and the CPAN module (Andreas) ! $Id: README.txt,v 1.15 2000/06/02 02:22:06 gward Exp $ From python-dev@python.org Fri Jun 2 03:22:18 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 1 Jun 2000 19:22:18 -0700 Subject: [Python-checkins] CVS: distutils MANIFEST.in,1.5,1.6 Message-ID: <200006020222.TAA14916@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv14906 Modified Files: MANIFEST.in Log Message: Ditch 'package_data' file. Index: MANIFEST.in =================================================================== RCS file: /cvsroot/python/distutils/MANIFEST.in,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** MANIFEST.in 2000/05/13 03:39:06 1.5 --- MANIFEST.in 2000/06/02 02:22:16 1.6 *************** *** 6,14 **** # created 2000/02/14, Greg Ward # ! # $Id: MANIFEST.in,v 1.5 2000/05/13 03:39:06 greg Exp $ # include *.txt - include package_data include MANIFEST.in recursive-include examples *.txt *.py --- 6,13 ---- # created 2000/02/14, Greg Ward # ! # $Id: MANIFEST.in,v 1.6 2000/06/02 02:22:16 gward Exp $ # include *.txt include MANIFEST.in recursive-include examples *.txt *.py From python-dev@python.org Fri Jun 2 03:23:44 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 1 Jun 2000 19:23:44 -0700 Subject: [Python-checkins] CVS: distutils setup.py,1.15,1.16 Message-ID: <200006020223.TAA14968@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv14958 Modified Files: setup.py Log Message: Bumped version number to 0.9pre (there will be a couple of code snapshots before the real release, but I want to make it clear that a major new release is on the way). Index: setup.py =================================================================== RCS file: /cvsroot/python/distutils/setup.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** setup.py 2000/04/26 02:27:47 1.15 --- setup.py 2000/06/02 02:23:42 1.16 *************** *** 7,16 **** # created 1999/03 Greg Ward ! __revision__ = "$Id: setup.py,v 1.15 2000/04/26 02:27:47 gward Exp $" from distutils.core import setup setup (name = "Distutils", ! version = "0.8.2", description = "Python Distribution Utilities", author = "Greg Ward", --- 7,16 ---- # created 1999/03 Greg Ward ! __revision__ = "$Id: setup.py,v 1.16 2000/06/02 02:23:42 gward Exp $" from distutils.core import setup setup (name = "Distutils", ! version = "0.9pre", description = "Python Distribution Utilities", author = "Greg Ward", From python-dev@python.org Fri Jun 2 03:23:44 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 1 Jun 2000 19:23:44 -0700 Subject: [Python-checkins] CVS: distutils/distutils __init__.py,1.6,1.7 Message-ID: <200006020223.TAA14972@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv14958/distutils Modified Files: __init__.py Log Message: Bumped version number to 0.9pre (there will be a couple of code snapshots before the real release, but I want to make it clear that a major new release is on the way). Index: __init__.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/__init__.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** __init__.py 2000/04/25 01:55:58 1.6 --- __init__.py 2000/06/02 02:23:42 1.7 *************** *** 9,13 **** """ ! __revision__ = "$Id: __init__.py,v 1.6 2000/04/25 01:55:58 gward Exp $" ! __version__ = "0.8.2" --- 9,13 ---- """ ! __revision__ = "$Id: __init__.py,v 1.7 2000/06/02 02:23:42 gward Exp $" ! __version__ = "0.9pre" From python-dev@python.org Fri Jun 2 03:41:53 2000 From: python-dev@python.org (Jeremy Hylton) Date: Thu, 1 Jun 2000 19:41:53 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild python16.dsp,1.4,1.5 Message-ID: <200006020241.TAA15967@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv15940 Modified Files: python16.dsp Log Message: make sure the case is correct (damned case-sensitive languages :-) Index: python16.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/python16.dsp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** python16.dsp 2000/06/01 15:47:08 1.4 --- python16.dsp 2000/06/02 02:41:47 1.5 *************** *** 543,558 **** SOURCE=..\python\exceptions.c ! !if "$(cfg)" == "python16 - win32 release" ! !elseif "$(cfg)" == "python16 - win32 debug" ! !elseif "$(cfg)" == "python16 - win32 alpha debug" ! !elseif "$(cfg)" == "python16 - win32 alpha release" ! !endif ! # end source file ! # begin source file SOURCE=..\Objects\fileobject.c --- 543,558 ---- SOURCE=..\python\exceptions.c ! !IF "$(cfg)" == "python16 - Win32 Release" ! !ELSEIF "$(cfg)" == "python16 - Win32 Debug" ! !ELSEIF "$(cfg)" == "python16 - Win32 Alpha Debug" ! !ELSEIF "$(cfg)" == "python16 - Win32 Alpha Release" ! !ENDIF ! # End Source File ! # Begin Source File SOURCE=..\Objects\fileobject.c From python-dev@python.org Sat Jun 3 01:44:33 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 2 Jun 2000 17:44:33 -0700 Subject: [Python-checkins] CVS: distutils/distutils sysconfig.py,1.18,1.19 Message-ID: <200006030044.RAA00322@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv310 Modified Files: sysconfig.py Log Message: Added a bunch of new globals in '_init_mac()' -- these will be needed to support the forthcoming Cygwin/Mingw32 GCC-on-Windows patch. Standardized CVS id line. Index: sysconfig.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/sysconfig.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** sysconfig.py 2000/05/23 23:14:00 1.18 --- sysconfig.py 2000/06/03 00:44:30 1.19 *************** *** 7,11 **** """ ! __version__ = "$Revision: 1.18 $" import os --- 7,11 ---- """ ! __revision__ = "$Id: sysconfig.py,v 1.19 2000/06/03 00:44:30 gward Exp $" import os *************** *** 255,258 **** --- 255,272 ---- g['SO'] = '.pyd' g['exec_prefix'] = EXEC_PREFIX + + # These are needed for the CygwinCCompiler and Mingw32CCompiler + # classes, which are just UnixCCompiler classes that happen to work on + # Windows. UnixCCompiler expects to find these values in sysconfig, so + # here they are. The fact that other Windows compilers don't need + # these values is pure luck (hmmm). + g['CC'] = "cc" # not gcc? + g['RANLIB'] = "ranlib" + g['AR'] = "ar" + g['OPT'] = "-O2" + g['SO'] = ".pyd" + g['LDSHARED'] = "ld" + g['CCSHARED'] = "" + g['EXE'] = ".exe" From python-dev@python.org Sat Jun 3 02:02:09 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 2 Jun 2000 18:02:09 -0700 Subject: [Python-checkins] CVS: distutils/distutils core.py,1.40,1.41 Message-ID: <200006030102.SAA06524@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv6513 Modified Files: core.py Log Message: Catch DistutilSetupError from the Distribution constructor. Index: core.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/core.py,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -r1.40 -r1.41 *** core.py 2000/06/02 01:55:36 1.40 --- core.py 2000/06/03 01:02:06 1.41 *************** *** 9,13 **** # created 1999/03/01, Greg Ward ! __revision__ = "$Id: core.py,v 1.40 2000/06/02 01:55:36 gward Exp $" import sys, os --- 9,13 ---- # created 1999/03/01, Greg Ward ! __revision__ = "$Id: core.py,v 1.41 2000/06/03 01:02:06 gward Exp $" import sys, os *************** *** 81,85 **** # Create the Distribution instance, using the remaining arguments # (ie. everything except distclass) to initialize it ! dist = klass (attrs) # Find and parse the config file(s): they will override options from --- 81,88 ---- # Create the Distribution instance, using the remaining arguments # (ie. everything except distclass) to initialize it ! try: ! dist = klass (attrs) ! except DistutilsSetupError, msg: ! raise SystemExit, "error in setup script: %s" % msg # Find and parse the config file(s): they will override options from From python-dev@python.org Sat Jun 3 02:03:58 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 2 Jun 2000 18:03:58 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist_rpm.py,1.8,1.9 Message-ID: <200006030103.SAA06693@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv6683/command Modified Files: bdist_rpm.py Log Message: Patch from Harry Henry Gebel: fixes a bit of code that slipped by my overhaul last night. Index: bdist_rpm.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist_rpm.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** bdist_rpm.py 2000/06/02 02:01:51 1.8 --- bdist_rpm.py 2000/06/03 01:03:55 1.9 *************** *** 6,10 **** # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.8 2000/06/02 02:01:51 gward Exp $" import os, string, re --- 6,10 ---- # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.9 2000/06/03 01:03:55 gward Exp $" import os, string, re *************** *** 309,315 **** else: rpm_args.append('-ba') - topdir = os.getcwd() + 'build/rpm' rpm_args.extend(['--define', ! '_topdir ' + os.getcwd() + '/build/rpm',]) if self.clean: rpm_args.append('--clean') --- 309,314 ---- else: rpm_args.append('-ba') rpm_args.extend(['--define', ! '_topdir %s/%s' % (os.getcwd(), rpm_base),]) if self.clean: rpm_args.append('--clean') From python-dev@python.org Sat Jun 3 20:41:44 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 3 Jun 2000 12:41:44 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules mmapmodule.c,2.8,2.9 Message-ID: <200006031941.MAA21418@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv21410 Modified Files: mmapmodule.c Log Message: Add missing PyArg_NoArgs() calls to methods that didn't take arguments (Pointed out by Moshe Zadka) Index: mmapmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/mmapmodule.c,v retrieving revision 2.8 retrieving revision 2.9 diff -C2 -r2.8 -r2.9 *** mmapmodule.c 2000/05/03 23:44:32 2.8 --- mmapmodule.c 2000/06/03 19:41:42 2.9 *************** *** 2,6 **** / Author: Sam Rushing / Hacked for Unix by A.M. Kuchling ! / $Id: mmapmodule.c,v 2.8 2000/05/03 23:44:32 guido Exp $ / mmapmodule.cpp -- map a view of a file into memory --- 2,6 ---- / Author: Sam Rushing / Hacked for Unix by A.M. Kuchling ! / $Id: mmapmodule.c,v 2.9 2000/06/03 19:41:42 akuchling Exp $ / mmapmodule.cpp -- map a view of a file into memory *************** *** 76,79 **** --- 76,81 ---- mmap_close_method (mmap_object * self, PyObject * args) { + if (!PyArg_NoArgs(args)) + return NULL; #ifdef MS_WIN32 UnmapViewOfFile (self->data); *************** *** 119,122 **** --- 121,126 ---- char * where; CHECK_VALID(NULL); + if (!PyArg_NoArgs(args)) + return NULL; if (self->pos >= 0 && self->pos < self->size) { where = self->data + self->pos; *************** *** 132,136 **** static PyObject * mmap_read_line_method (mmap_object * self, ! PyObject * args) { char * start = self->data+self->pos; --- 136,140 ---- static PyObject * mmap_read_line_method (mmap_object * self, ! PyObject * args) { char * start = self->data+self->pos; *************** *** 140,143 **** --- 144,149 ---- CHECK_VALID(NULL); + if (!PyArg_NoArgs(args)) + return NULL; eol = memchr(start, '\n', self->size - self->pos); *************** *** 154,158 **** static PyObject * mmap_read_method (mmap_object * self, ! PyObject * args) { long num_bytes; --- 160,164 ---- static PyObject * mmap_read_method (mmap_object * self, ! PyObject * args) { long num_bytes; *************** *** 226,230 **** static PyObject * mmap_write_byte_method (mmap_object * self, ! PyObject * args) { char value; --- 232,236 ---- static PyObject * mmap_write_byte_method (mmap_object * self, ! PyObject * args) { char value; *************** *** 242,248 **** static PyObject * mmap_size_method (mmap_object * self, ! PyObject * args) { CHECK_VALID(NULL); #ifdef MS_WIN32 --- 248,256 ---- static PyObject * mmap_size_method (mmap_object * self, ! PyObject * args) { CHECK_VALID(NULL); + if (!PyArg_NoArgs(args)) + return NULL; #ifdef MS_WIN32 *************** *** 347,350 **** --- 355,360 ---- { CHECK_VALID(NULL); + if (!PyArg_NoArgs(args)) + return NULL; return (Py_BuildValue ("l", self->pos) ); } *************** *** 463,470 **** static int ! mmap_buffer_getreadbuf(self, index, ptr) ! mmap_object *self; ! int index; ! const void **ptr; { CHECK_VALID(-1); --- 473,477 ---- static int ! mmap_buffer_getreadbuf(mmap_object *self, int index, const void **ptr) { CHECK_VALID(-1); *************** *** 868,869 **** --- 875,877 ---- } + From python-dev@python.org Sat Jun 3 21:43:46 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 3 Jun 2000 13:43:46 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules mmapmodule.c,2.9,2.10 Message-ID: <200006032043.NAA02637@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv2626 Modified Files: mmapmodule.c Log Message: Use PyArg_ParseTuple and specify the method names, following a suggestion from Greg Stein Index: mmapmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/mmapmodule.c,v retrieving revision 2.9 retrieving revision 2.10 diff -C2 -r2.9 -r2.10 *** mmapmodule.c 2000/06/03 19:41:42 2.9 --- mmapmodule.c 2000/06/03 20:43:43 2.10 *************** *** 2,6 **** / Author: Sam Rushing / Hacked for Unix by A.M. Kuchling ! / $Id: mmapmodule.c,v 2.9 2000/06/03 19:41:42 akuchling Exp $ / mmapmodule.cpp -- map a view of a file into memory --- 2,6 ---- / Author: Sam Rushing / Hacked for Unix by A.M. Kuchling ! / $Id: mmapmodule.c,v 2.10 2000/06/03 20:43:43 akuchling Exp $ / mmapmodule.cpp -- map a view of a file into memory *************** *** 76,80 **** mmap_close_method (mmap_object * self, PyObject * args) { ! if (!PyArg_NoArgs(args)) return NULL; #ifdef MS_WIN32 --- 76,80 ---- mmap_close_method (mmap_object * self, PyObject * args) { ! if (!PyArg_ParseTuple(args, ":close")) return NULL; #ifdef MS_WIN32 *************** *** 121,125 **** char * where; CHECK_VALID(NULL); ! if (!PyArg_NoArgs(args)) return NULL; if (self->pos >= 0 && self->pos < self->size) { --- 121,125 ---- char * where; CHECK_VALID(NULL); ! if (!PyArg_ParseTuple(args, ":read_byte")) return NULL; if (self->pos >= 0 && self->pos < self->size) { *************** *** 144,148 **** CHECK_VALID(NULL); ! if (!PyArg_NoArgs(args)) return NULL; --- 144,148 ---- CHECK_VALID(NULL); ! if (!PyArg_ParseTuple(args, ":readline")) return NULL; *************** *** 251,255 **** { CHECK_VALID(NULL); ! if (!PyArg_NoArgs(args)) return NULL; --- 251,255 ---- { CHECK_VALID(NULL); ! if (!PyArg_ParseTuple(args, ":size")) return NULL; *************** *** 355,359 **** { CHECK_VALID(NULL); ! if (!PyArg_NoArgs(args)) return NULL; return (Py_BuildValue ("l", self->pos) ); --- 355,359 ---- { CHECK_VALID(NULL); ! if (!PyArg_ParseTuple(args, ":tell")) return NULL; return (Py_BuildValue ("l", self->pos) ); From python-dev@python.org Sun Jun 4 14:42:55 2000 From: python-dev@python.org (Greg Ward) Date: Sun, 4 Jun 2000 06:42:55 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command build_py.py,1.25,1.26 Message-ID: <200006041342.GAA31624@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv31616 Modified Files: build_py.py Log Message: Renamed 'modules' option to 'py_modules', for consistency with Distribution (and in order to generate a more sensible error message cleanly). Index: build_py.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build_py.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -r1.25 -r1.26 *** build_py.py 2000/05/26 00:44:06 1.25 --- build_py.py 2000/06/04 13:42:52 1.26 *************** *** 5,9 **** # created 1999/03/08, Greg Ward ! __revision__ = "$Id: build_py.py,v 1.25 2000/05/26 00:44:06 gward Exp $" import sys, string, os --- 5,9 ---- # created 1999/03/08, Greg Ward ! __revision__ = "$Id: build_py.py,v 1.26 2000/06/04 13:42:52 gward Exp $" import sys, string, os *************** *** 27,31 **** def initialize_options (self): self.build_lib = None ! self.modules = None self.package = None self.package_dir = None --- 27,31 ---- def initialize_options (self): self.build_lib = None ! self.py_modules = None self.package = None self.package_dir = None *************** *** 40,44 **** # options -- list of packages and list of modules. self.packages = self.distribution.packages ! self.modules = self.distribution.py_modules self.package_dir = self.distribution.package_dir --- 40,44 ---- # options -- list of packages and list of modules. self.packages = self.distribution.packages ! self.py_modules = self.distribution.py_modules self.package_dir = self.distribution.package_dir *************** *** 63,67 **** # Two options control which modules will be installed: 'packages' ! # and 'modules'. The former lets us work with whole packages, not # specifying individual modules at all; the latter is for # specifying modules one-at-a-time. Currently they are mutually --- 63,67 ---- # Two options control which modules will be installed: 'packages' ! # and 'py_modules'. The former lets us work with whole packages, not # specifying individual modules at all; the latter is for # specifying modules one-at-a-time. Currently they are mutually *************** *** 71,85 **** # Dispose of the two "unusual" cases first: no pure Python modules # at all (no problem, just return silently), and over-specified ! # 'packages' and 'modules' options. ! if not self.modules and not self.packages: return ! if self.modules and self.packages: raise DistutilsOptionError, \ ! "build_py: supplying both 'packages' and 'modules' " + \ "options is not allowed" ! # Now we're down to two cases: 'modules' only and 'packages' only. ! if self.modules: self.build_modules () else: --- 71,85 ---- # Dispose of the two "unusual" cases first: no pure Python modules # at all (no problem, just return silently), and over-specified ! # 'packages' and 'py_modules' options. ! if not self.py_modules and not self.packages: return ! if self.py_modules and self.packages: raise DistutilsOptionError, \ ! "build_py: supplying both 'packages' and 'py_modules' " + \ "options is not allowed" ! # Now we're down to two cases: 'py_modules' only and 'packages' only. ! if self.py_modules: self.build_modules () else: *************** *** 195,199 **** def find_modules (self): """Finds individually-specified Python modules, ie. those listed by ! module name in 'self.modules'. Returns a list of tuples (package, module_base, filename): 'package' is a tuple of the path through package-space to the module; 'module_base' is the bare (no --- 195,199 ---- def find_modules (self): """Finds individually-specified Python modules, ie. those listed by ! module name in 'self.py_modules'. Returns a list of tuples (package, module_base, filename): 'package' is a tuple of the path through package-space to the module; 'module_base' is the bare (no *************** *** 219,223 **** # - don't check for __init__.py in directory for empty package ! for module in self.modules: path = string.split (module, '.') package = tuple (path[0:-1]) --- 219,223 ---- # - don't check for __init__.py in directory for empty package ! for module in self.py_modules: path = string.split (module, '.') package = tuple (path[0:-1]) *************** *** 252,261 **** def find_all_modules (self): """Compute the list of all modules that will be built, whether ! they are specified one-module-at-a-time ('self.modules') or by whole packages ('self.packages'). Return a list of tuples (package, module, module_file), just like 'find_modules()' and 'find_package_modules()' do.""" ! if self.modules: modules = self.find_modules () else: --- 252,261 ---- def find_all_modules (self): """Compute the list of all modules that will be built, whether ! they are specified one-module-at-a-time ('self.py_modules') or by whole packages ('self.packages'). Return a list of tuples (package, module, module_file), just like 'find_modules()' and 'find_package_modules()' do.""" ! if self.py_modules: modules = self.find_modules () else: From python-dev@python.org Sun Jun 4 14:44:06 2000 From: python-dev@python.org (Greg Ward) Date: Sun, 4 Jun 2000 06:44:06 -0700 Subject: [Python-checkins] CVS: distutils/test test_spawn.py,1.1,1.2 Message-ID: <200006041344.GAA31658@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv31650 Modified Files: test_spawn.py Log Message: [from 2000/04/23] Hopeless attempt to make this test script for the 'spawn' module more useful, reliable, and portable. I have since abandoned hope of testing 'spawn' portably -- perhaps I'll write a Unix version, and just hope that someone out there writes a Windows version. ;-( Index: test_spawn.py =================================================================== RCS file: /cvsroot/python/distutils/test/test_spawn.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** test_spawn.py 1999/09/29 13:10:23 1.1 --- test_spawn.py 2000/06/04 13:44:03 1.2 *************** *** 2,16 **** # test_spawn.py # ! # test suite for distutils.util.spawn() (currently Unix-only) # # GPW 1999/07/20 # ! # $Id: test_spawn.py,v 1.1 1999/09/29 13:10:23 gward Exp $ # ! import sys from distutils.spawn import spawn from distutils.errors import * from util import try_it spawn (["/bin/ls"]) --- 2,222 ---- # test_spawn.py # ! # test script for distutils.spawn module # # GPW 1999/07/20 # ! # $Id: test_spawn.py,v 1.2 2000/06/04 13:44:03 gward Exp $ # ! import sys, os, string ! from tempfile import mktemp from distutils.spawn import spawn + from distutils.util import abspath from distutils.errors import * + from unittest import TestScenario, parse_args, run_scenarios from util import try_it + + class SpawnTest (TestScenario): + + def setup (self): + self.python = os.path.normpath (abspath (sys.executable)) + + self.cmd_trivial = self.gen_cmd ('1') + self.cmd_trivial_s = string.join (self.cmd_trivial) + self.cmd_print = self.gen_cmd ('print "hello"') + self.cmd_print_s = string.join (self.cmd_print) + self.cmd_err = self.gen_cmd ('import sys; sys.stderr.write("foo\\n")') + self.cmd_err_s = string.join (self.cmd_err) + self.cmd_mixed = self.gen_cmd ("import sys; " + "sys.stdout.write('out'); " + "sys.stderr.write('err'); " + "sys.stdout.write('put'); " + "sys.stderr.write('or')") + + + def shutdown (self): + pass + + + def capture_output (self): + """Temporarily redirect stdout and stderr to files, the + contents of which will be returned by 'stop_capture()'.""" + self.out_filename = mktemp() + self.err_filename = mktemp() + self.out_file = open(self.out_filename, 'w') + self.err_file = open(self.err_filename, 'w') + self.save_stdout = os.dup(1) + self.save_stderr = os.dup(2) + os.close(1) + if os.dup(self.out_file.fileno()) != 1: + raise RuntimeError, "couldn't redirect stdout - dup() error" + os.close(2) + if os.dup(self.err_file.fileno()) != 2: + raise RuntimeError, "couldn't redirect stderr - dup() error" + + def stop_capture (self): + os.close(1) + os.dup(self.save_stdout) + os.close(2) + os.dup(self.save_stderr) + + self.out_file.close() + self.err_file.close() + + out_file = open(self.out_filename) + output = out_file.read() + out_file.close() + os.unlink (self.out_filename) + + err_file = open(self.err_filename) + error = err_file.read() + err_file.close() + os.unlink (self.err_filename) + + return (output, error) + + + #def capture_test_1 (self, test_method, args): + # """Run a + + + def test_out (self, code, output, error): + # XXX I have no idea how to do this in a portable way! + + from unittest import get_caller_env + (globals, locals) = get_caller_env () + + if os.name == 'posix': + p2cread, p2cwrite = os.pipe() + c2pread, c2pwrite = os.pipe() + err_read, err_write = os.pipe() + + pid = os.fork() + if pid == 0: # in the child + os.close(0) # close stdin + os.close(1) # and stdout + os.close(2) # and stderr + + if os.dup(p2cread) != 0: + raise os.error, "dup stdin (read) != 0" + if os.dup(c2pwrite) != 1: + raise os.error, "dup stdout (write) != 1" + if os.dup(err_write) != 2: + raise os.error, "dup stderr (write) != 2" + + eval (code, globals, locals) + os._exit (0) + + # in the parent + os.close(p2cread) + child_stdin = os.fdopen (p2cwrite, 'w') + os.close(c2pwrite) + child_stdout = os.fdopen (c2pread, 'r') + os.close(err_write) + child_stderr = os.fdopen (err_read, 'r') + + child_out = child_stdout.read() + child_err = child_stderr.read() + + child_stdin.close() + child_stdout.close() + child_stderr.close() + os.waitpid (pid, 0) + + self.tests_run = self.tests_run + 1 + + if output == child_out and error == child_err: + self.report_pass ( + code + "\n" + + " wrote %s to stdout\n" % `child_out` + + " and %s to stderr" % `child_err`) + elif output != child_out and error == child_err: + self.report_fail ( + code + "\n" + + " did not write %s to stdout (wrote %s)\n" % + (`output`, `child_out`) + + " but wrote %s to stderr" % child_err) + elif output == child_out and error != child_err: + self.report_fail ( + code + "\n" + + " wrote %s to stdout" % `child_out` + + " but did not write %s to stderr (wrote %s)" % + (`error`, `child_err`)) + else: + self.report_fail ( + code + "\n" + + " did not write %s to stdout (wrote %s)\n" % + (`output`, `child_out`) + + " and did not write %s to stderr (wrote %s)" % + (`error`, `child_err`)) + + else: + raise RuntimeError, \ + "don't know how to capture stdout/stderr on platform '%s'"%\ + os.name + + # test_out () + + + + def gen_cmd (self, script): + """Generate a Python command line to run 'script' as a list + for use by 'spawn()'. Eg. if 'script' is "print 'hello'", + returns the list ["python", "-c", "print 'hello'"] -- except + the full path to the executable is used.""" + return [self.python, "-c", str(script)] + + + test_cases = ['simple', 'output', 'verbose', 'dryrun'] + + + def check_simple (self): + "Simple spawns (success and failure): 6" + + self.test_stmt ("spawn (%s)" % self.cmd_mixed) + self.test_stmt ("spawn (%s)" % self.gen_cmd("import sys;sys.exit(0)")) + self.test_exc ("spawn (%s)" % self.gen_cmd("import sys;sys.exit(42)"), + DistutilsExecError) + + self.capture_output() + self.test_exc ("spawn (['vjwe9ghwe09fnkwef098vdsjn3209'])", + DistutilsExecError) + (output, error) = self.stop_capture() + exp_error = "unable to execute vjwe9ghwe09fnkwef098vdsjn3209:" + self.test_val ("output", "") + self.test_val ("error[0:%d]" % len(exp_error), exp_error) + + def check_output (self): + "Spawn commands with output and error output: 3" + + self.test_out ("spawn (%s)" % self.cmd_print, + "hello\n", "") + self.test_out ("spawn (%s)" % self.cmd_err, + "", "foo\n") + self.test_out ("spawn (%s)" % self.cmd_mixed, + "output", "error") + + def check_verbose (self): + "Verbose reporting of command executed: 2" + + self.test_out ("spawn (%s, verbose=1)" % self.cmd_trivial, + self.cmd_trivial_s + "\n", "") + self.test_out ("spawn (%s, verbose=1)" % self.cmd_print, + self.cmd_print_s + "\n" + "hello\n", + "") + + def check_dryrun (self): + "Spawn commands in dry-run mode (ie. don't actually do anything): " + self.test_out ("spawn (%s, dry_run=1)" % self.cmd_print, + "", "") + self.test_out ("spawn (%s, dry_run=1, verbose=1)" % self.cmd_print, + "%s -c %s\n" % (self.python, self.cmd_print_s), + "") + + + if __name__ == "__main__": + (scenarios, options) = parse_args() + run_scenarios (scenarios, options) + sys.exit() spawn (["/bin/ls"]) From python-dev@python.org Sun Jun 4 14:45:28 2000 From: python-dev@python.org (Greg Ward) Date: Sun, 4 Jun 2000 06:45:28 -0700 Subject: [Python-checkins] CVS: distutils mksnap,1.4,1.5 Message-ID: <200006041345.GAA31689@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv31681 Modified Files: mksnap Log Message: Tweaked to run at home instead of work, now that I can't update python.org easily at work. ;-( Soon to be obsolete. Index: mksnap =================================================================== RCS file: /cvsroot/python/distutils/mksnap,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** mksnap 2000/04/12 01:45:04 1.4 --- mksnap 2000/06/04 13:45:25 1.5 *************** *** 7,11 **** # command! # ! # $Id: mksnap,v 1.4 2000/04/12 01:45:04 gward Exp $ # --- 7,11 ---- # command! # ! # $Id: mksnap,v 1.5 2000/06/04 13:45:25 gward Exp $ # *************** *** 15,20 **** use POSIX ('strftime'); ! my $tar = '/depot/gnu/plat/bin/gnutar'; # MUST be gnutar! ! #my $tar = '/bin/tar'; die "don't know where to find gnutar" unless -x $tar; --- 15,20 ---- use POSIX ('strftime'); ! #my $tar = '/depot/gnu/plat/bin/gnutar'; # MUST be gnutar! ! my $tar = '/bin/tar'; die "don't know where to find gnutar" unless -x $tar; From python-dev@python.org Sun Jun 4 14:46:22 2000 From: python-dev@python.org (Greg Ward) Date: Sun, 4 Jun 2000 06:46:22 -0700 Subject: [Python-checkins] CVS: distutils README.txt,1.15,1.16 Message-ID: <200006041346.GAA31833@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv31819 Modified Files: README.txt Log Message: Tweaked credits list. Index: README.txt =================================================================== RCS file: /cvsroot/python/distutils/README.txt,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** README.txt 2000/06/02 02:22:06 1.15 --- README.txt 2000/06/04 13:46:19 1.16 *************** *** 347,356 **** * Bastian Kleineidam: the "clean" command, and a pile of patches, bug-fixes, and ideas, large and small ! * Lyle Johnson: bug-spotting and -fixing; (forthcoming) support ! for Borland's C/C++ compiler * Harry Henry Gebel: bug-spotting and -fixing; the "bztar" archive format; the "bdist_rpm" command ! * Rene Liebscher: smarter extension-building; (forthcoming?) ! Cygwin/Mingw32 support [spiritual, in roughly chronological order since the birth of the project] --- 347,356 ---- * Bastian Kleineidam: the "clean" command, and a pile of patches, bug-fixes, and ideas, large and small ! * Lyle Johnson: bug-spotting and -fixing; support for Borland's C/C++ ! compiler (forthcoming) * Harry Henry Gebel: bug-spotting and -fixing; the "bztar" archive format; the "bdist_rpm" command ! * Rene Liebscher: smarter extension-building; Cygwin/Mingw32 support ! (forthcoming) [spiritual, in roughly chronological order since the birth of the project] *************** *** 372,374 **** the CPAN archive (Jarkko), and the CPAN module (Andreas) ! $Id: README.txt,v 1.15 2000/06/02 02:22:06 gward Exp $ --- 372,374 ---- the CPAN archive (Jarkko), and the CPAN module (Andreas) ! $Id: README.txt,v 1.16 2000/06/04 13:46:19 gward Exp $ From python-dev@python.org Sun Jun 4 15:21:00 2000 From: python-dev@python.org (Greg Ward) Date: Sun, 4 Jun 2000 07:21:00 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist_rpm.py,1.9,1.10 Message-ID: <200006041421.HAA11488@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv11480 Modified Files: bdist_rpm.py Log Message: Removed the 'ensure_*' methods -- they're just too handy too keep in one command class, so they're now in the Command base class. Index: bdist_rpm.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist_rpm.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** bdist_rpm.py 2000/06/03 01:03:55 1.9 --- bdist_rpm.py 2000/06/04 14:20:57 1.10 *************** *** 6,12 **** # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.9 2000/06/03 01:03:55 gward Exp $" ! import os, string, re from types import * from distutils.core import Command, DEBUG --- 6,12 ---- # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.10 2000/06/04 14:20:57 gward Exp $" ! import os, string from types import * from distutils.core import Command, DEBUG *************** *** 202,247 **** # finalize_package_data () - - - # XXX these look awfully handy: should probably move them - # up to Command and use more widely. - def _ensure_stringlike (self, option, what, default=None): - val = getattr(self, option) - if val is None: - setattr(self, option, default) - return default - elif type(val) is not StringType: - raise DistutilsOptionError, \ - "'%s' must be a %s (got `%s`)" % (option, what, val) - return val - - def ensure_string (self, option, default=None): - self._ensure_stringlike(option, "string", default) - - def ensure_string_list (self, option): - val = getattr(self, option) - if val is None: - return - elif type(val) is StringType: - setattr(self, option, re.split(r',\s*|\s+', val)) - else: - if type(val) is ListType: - types = map(type, val) - ok = (types == [StringType] * len(val)) - else: - ok = 0 - - if not ok: - raise DistutilsOptionError, \ - "'%s' must be a list of strings (got %s)" % \ - (option, `val`) - - def ensure_filename (self, option, default=None): - val = self._ensure_stringlike(option, "filename", None) - if val is not None and not os.path.exists(val): - raise DistutilsOptionError, \ - "error in '%s' option: file '%s' does not exist" % \ - (option, val) - --- 202,205 ---- From python-dev@python.org Sun Jun 4 15:21:30 2000 From: python-dev@python.org (Greg Ward) Date: Sun, 4 Jun 2000 07:21:30 -0700 Subject: [Python-checkins] CVS: distutils/distutils cmd.py,1.16,1.17 Message-ID: <200006041421.HAA11505@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv11496 Modified Files: cmd.py Log Message: Added the 'ensure_*' methods from bdist_rpm; refactored 'ensure_filename()' and added 'ensure_dirname()'. Index: cmd.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/cmd.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** cmd.py 2000/06/02 00:44:53 1.16 --- cmd.py 2000/06/04 14:21:28 1.17 *************** *** 8,14 **** # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: cmd.py,v 1.16 2000/06/02 00:44:53 gward Exp $" ! import sys, os, string from types import * from distutils.errors import * --- 8,14 ---- # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: cmd.py,v 1.17 2000/06/04 14:21:28 gward Exp $" ! import sys, os, string, re from types import * from distutils.errors import * *************** *** 172,175 **** --- 172,246 ---- if self.verbose >= level: print msg + + + # -- Option validation methods ------------------------------------- + # (these are very handy in writing the 'finalize_options()' method) + # + # NB. the general philosophy here is to ensure that a particular option + # value meets certain type and value constraints. If not, we try to + # force it into conformance (eg. if we expect a list but have a string, + # split the string on comma and/or whitespace). If we can't force the + # option into conformance, raise DistutilsOptionError. Thus, command + # classes need do nothing more than (eg.) + # self.ensure_string_list('foo') + # and they can be guaranteed that thereafter, self.foo will be + # a list of strings. + + def _ensure_stringlike (self, option, what, default=None): + val = getattr(self, option) + if val is None: + setattr(self, option, default) + return default + elif type(val) is not StringType: + raise DistutilsOptionError, \ + "'%s' must be a %s (got `%s`)" % (option, what, val) + return val + + def ensure_string (self, option, default=None): + """Ensure that 'option' is a string; if not defined, set it to + 'default'. + """ + self._ensure_stringlike(option, "string", default) + + def ensure_string_list (self, option): + """Ensure that 'option' is a list of strings. If 'option' is + currently a string, we split it either on /,\s*/ or /\s+/, so + "foo bar baz", "foo,bar,baz", and "foo, bar baz" all become + ["foo", "bar", "baz"]. + """ + val = getattr(self, option) + if val is None: + return + elif type(val) is StringType: + setattr(self, option, re.split(r',\s*|\s+', val)) + else: + if type(val) is ListType: + types = map(type, val) + ok = (types == [StringType] * len(val)) + else: + ok = 0 + + if not ok: + raise DistutilsOptionError, \ + "'%s' must be a list of strings (got %s)" % \ + (option, `val`) + + def _ensure_tested_string (self, option, tester, + what, error_fmt, default=None): + val = self._ensure_stringlike(option, what, default) + if val is not None and not tester(val): + raise DistutilsOptionError, \ + ("error in '%s' option: " + error_fmt) % (option, val) + + def ensure_filename (self, option): + """Ensure that 'option' is the name of an existing file.""" + self._ensure_tested_string(option, os.path.isfile, + "filename", + "'%s' does not exist or is not a file") + + def ensure_dirname (self, option): + self._ensure_tested_string(option, os.path.isdir, + "directory name", + "'%s' does not exist or is not a directory") From python-dev@python.org Sun Jun 4 16:00:37 2000 From: python-dev@python.org (Greg Ward) Date: Sun, 4 Jun 2000 08:00:37 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist_rpm.py,1.10,1.11 Message-ID: <200006041500.IAA15510@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv13785 Modified Files: bdist_rpm.py Log Message: Patch from Harry Henry Gebel: Fills in question marks in help Reads scripts in from files rather than strings Adds RPM 2 compatibility mode (untested). Use of this mode requires that --bdist-base be specified because bdist_rpm has no way of detecting where RPM wants to find spec files and source files. An unmodified RedHat 5.0 system would require '--bdist-base=/usr/src/RedHat'. (You would also have to be root.) If the rpmrc file has been modified to allow RPMs to be built by normal users then --build-base would need to be changed accordingly. Formats the changelog. GPW: tweaked formatting, added some editorial comments. Index: bdist_rpm.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist_rpm.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** bdist_rpm.py 2000/06/04 14:20:57 1.10 --- bdist_rpm.py 2000/06/04 15:00:34 1.11 *************** *** 6,10 **** # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.10 2000/06/04 14:20:57 gward Exp $" import os, string --- 6,10 ---- # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.11 2000/06/04 15:00:34 gward Exp $" import os, string *************** *** 43,47 **** "RPM release number"), ('serial', None, ! "???"), ('vendor', None, "RPM \"vendor\" (eg. \"Joe Blow \") " --- 43,47 ---- "RPM release number"), ('serial', None, ! "RPM serial number"), ('vendor', None, "RPM \"vendor\" (eg. \"Joe Blow \") " *************** *** 53,68 **** "list of documentation files (space or comma-separated)"), ('changelog', None, ! "RPM changelog"), ('icon', None, "name of icon file"), ! ! ('prep-cmd', None, ! "?? pre-build command(s) ??"), ! ('build-cmd', None, ! "?? build command(s) ??"), ! ('install-cmd', None, ! "?? installation command(s) ??"), ! ('clean-cmd', None, ! "?? clean command(s) ??"), ('pre-install', None, "pre-install script (Bourne shell code)"), --- 53,67 ---- "list of documentation files (space or comma-separated)"), ('changelog', None, ! "path to RPM changelog"), ('icon', None, "name of icon file"), ! ('prep-script', None, ! "pre-build script (Bourne shell code)"), ! ('build-script', None, ! "build script (Bourne shell code)"), ! ('install-script', None, ! "installation script (Bourne shell code)"), ! ('clean-script', None, ! "clean script (Bourne shell code)"), ('pre-install', None, "pre-install script (Bourne shell code)"), *************** *** 73,87 **** ('post-uninstall', None, "post-uninstall script (Bourne shell code)"), - ('provides', None, ! "???"), ('requires', None, ! "???"), ('conflicts', None, ! "???"), ('build-requires', None, ! "???"), ('obsoletes', None, ! "???"), # Actions to take when building RPM --- 72,85 ---- ('post-uninstall', None, "post-uninstall script (Bourne shell code)"), ('provides', None, ! "capabilities provided by this package"), ('requires', None, ! "capabilities required by this package"), ('conflicts', None, ! "capabilities which conflict with this package"), ('build-requires', None, ! "capabilities required to build this package"), ('obsoletes', None, ! "capabilities made obsolete by this package"), # Actions to take when building RPM *************** *** 94,101 **** ('no-rpm-opt-flags', None, "do not pass any RPM CFLAGS to compiler"), ] negative_opt = {'no-clean': 'clean', ! 'no-rpm-opt-flags': 'use-rpm-opt-flags'} --- 92,104 ---- ('no-rpm-opt-flags', None, "do not pass any RPM CFLAGS to compiler"), + ('rpm3-mode', None, + "RPM 3 compatibility mode (default)"), + ('rpm2-mode', None, + "RPM 2 compatibility mode"), ] negative_opt = {'no-clean': 'clean', ! 'no-rpm-opt-flags': 'use-rpm-opt-flags', ! 'rpm2-mode': 'rpm3-mode'} *************** *** 117,124 **** self.icon = None ! self.prep_cmd = None ! self.build_cmd = None ! self.install_cmd = None ! self.clean_cmd = None self.pre_install = None self.post_install = None --- 120,127 ---- self.icon = None ! self.prep_script = None ! self.build_script = None ! self.install_script = None ! self.clean_script = None self.pre_install = None self.post_install = None *************** *** 134,137 **** --- 137,141 ---- self.clean = 1 self.use_rpm_opt_flags = 1 + self.rpm3_mode = 1 # initialize_options() *************** *** 161,165 **** "%s <%s>" % (self.distribution.get_contact(), self.distribution.get_contact_email())) ! self.ensure_string('packager', self.vendor) # or nothing? self.ensure_string_list('doc_files') if type(self.doc_files) is ListType: --- 165,169 ---- "%s <%s>" % (self.distribution.get_contact(), self.distribution.get_contact_email())) ! self.ensure_string('packager') self.ensure_string_list('doc_files') if type(self.doc_files) is ListType: *************** *** 168,189 **** self.doc.append(readme) ! self.ensure_string('release', "1") # should it be an int? self.ensure_string('serial') # should it be an int? - self.ensure_string('icon') self.ensure_string('distribution_name') ! self.ensure_string('prep_cmd', "%setup") # string or filename? ! if self.use_rpm_opt_flags: ! def_build = 'env CFLAGS="$RPM_OPT_FLAGS" python setup.py build' ! else: ! def_build = 'python setup.py build' ! self.ensure_string('build_cmd', def_build) ! self.ensure_string('install_cmd', ! "python setup.py install --root=$RPM_BUILD_ROOT " ! "--record=INSTALLED_FILES") ! self.ensure_string('clean_cmd', ! "rm -rf $RPM_BUILD_ROOT") self.ensure_filename('pre_install') self.ensure_filename('post_install') --- 172,190 ---- self.doc.append(readme) ! self.ensure_string('release', "1") self.ensure_string('serial') # should it be an int? self.ensure_string('distribution_name') ! self.ensure_string('changelog') ! # Format changelog correctly ! self.changelog = self._format_changelog(self.changelog) ! self.ensure_filename('icon') ! ! self.ensure_filename('prep_script') ! self.ensure_filename('build_script') ! self.ensure_filename('install_script') ! self.ensure_filename('clean_script') self.ensure_filename('pre_install') self.ensure_filename('post_install') *************** *** 218,222 **** self.mkpath(spec_dir) # XXX should be configurable else: ! rpm_base = os.path.join(self.bdist_base, "rpm") rpm_dir = {} for d in ('SOURCES', 'SPECS', 'BUILD', 'RPMS', 'SRPMS'): --- 219,227 ---- self.mkpath(spec_dir) # XXX should be configurable else: ! if self.rpm3_mode: ! rpm_base = os.path.join(self.bdist_base, "rpm") ! else: ! # complete path must be specified in RPM 2 mode ! rpm_base = self.bdist_base rpm_dir = {} for d in ('SOURCES', 'SPECS', 'BUILD', 'RPMS', 'SRPMS'): *************** *** 267,272 **** else: rpm_args.append('-ba') ! rpm_args.extend(['--define', ! '_topdir %s/%s' % (os.getcwd(), rpm_base),]) if self.clean: rpm_args.append('--clean') --- 272,278 ---- else: rpm_args.append('-ba') ! if self.rpm3_mode: ! rpm_args.extend(['--define', ! '_topdir %s/%s' % (os.getcwd(), rpm_base),]) if self.clean: rpm_args.append('--clean') *************** *** 364,388 **** # rpm scripts ! for (rpm_opt, attr) in (('prep', 'prep_cmd'), ! ('build', 'build_cmd'), ! ('install', 'install_cmd'), ! ('clean', 'clean_cmd'), ! ('pre', 'pre_install'), ! ('post', 'post_install'), ! ('preun', 'pre_uninstall'), ! ('postun', 'post_uninstall')): ! # XXX oops, this doesn't distinguish between "raw code" ! # options and "script filename" options -- well, we probably ! # should settle on one or the other, and not make the ! # distinction! val = getattr(self, attr) ! if val: spec_file.extend([ '', ! '%' + rpm_opt, ! val ! ]) ! # files section spec_file.extend([ --- 370,412 ---- # rpm scripts ! # figure out default build script ! if self.use_rpm_opt_flags: ! def_build = 'env CFLAGS="$RPM_OPT_FLAGS" python setup.py build' ! else: ! def_build = 'python setup.py build' ! # insert contents of files ! ! # XXX this is kind of misleading: user-supplied options are files ! # that we open and interpolate into the spec file, but the defaults ! # are just text that we drop in as-is. Hmmm. ! ! script_options = [ ! ('prep', 'prep_script', "%setup"), ! ('build', 'build_script', def_build), ! ('install', 'install_script', ! "python setup.py install " ! "--root=$RPM_BUILD_ROOT " ! "--record=INSTALLED_FILES"), ! ('clean', 'clean_script', "rm -rf $RPM_BUILD_ROOT"), ! ('pre', 'pre_install', None), ! ('post', 'post_install', None), ! ('preun', 'pre_uninstall', None), ! ('postun', 'post_uninstall', None)) ! ] ! ! for (rpm_opt, attr, default) in script_options: ! # Insert contents of file refered to, if no file is refered to ! # use 'default' as contents of script val = getattr(self, attr) ! if val or default: spec_file.extend([ '', ! '%' + rpm_opt,]) ! if val: ! spec_file.extend(string.split(open(val, 'r').read(), '\n')) ! else: ! spec_file.append(default) ! # files section spec_file.extend([ *************** *** 398,408 **** spec_file.extend([ '', ! '%changelog', ! self.changelog ! ]) return spec_file # _make_spec_file () # class bdist_rpm --- 422,452 ---- spec_file.extend([ '', ! '%changelog',]) ! spec_file.extend(self.changelog) return spec_file # _make_spec_file () + + def _format_changelog(self, changelog): + """Format the changelog correctly and convert it to a list of strings + """ + new_changelog = [] + for line in string.split(string.strip(changelog), '\n'): + line = string.strip(line) + if line[0] == '*': + new_changelog.extend(['', line]) + elif line[0] == '-': + new_changelog.append(line) + else: + new_changelog.append(' ' + line) + + # strip trailing newline inserted by first changelog entry + if not new_changelog[0]: + del new_changelog[0] + + return new_changelog + + # _format_changelog() # class bdist_rpm From python-dev@python.org Sun Jun 4 16:12:53 2000 From: python-dev@python.org (Greg Ward) Date: Sun, 4 Jun 2000 08:12:53 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command sdist.py,1.23,1.24 Message-ID: <200006041512.IAA19491@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv19483 Modified Files: sdist.py Log Message: Use 'ensure_string_list()' for 'formats' option, so that it can be spelled sensibly in a config file. Index: sdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/sdist.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -r1.23 -r1.24 *** sdist.py 2000/06/01 01:10:56 1.23 --- sdist.py 2000/06/04 15:12:51 1.24 *************** *** 5,9 **** # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.23 2000/06/01 01:10:56 gward Exp $" import sys, os, string, re --- 5,9 ---- # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.24 2000/06/04 15:12:51 gward Exp $" import sys, os, string, re *************** *** 74,77 **** --- 74,78 ---- self.template = "MANIFEST.in" + self.ensure_string_list('formats') if self.formats is None: try: *************** *** 81,86 **** "don't know how to create source distributions " + \ "on platform %s" % os.name - elif type (self.formats) is StringType: - self.formats = string.split (self.formats, ',') bad_format = check_archive_formats (self.formats) --- 82,85 ---- From python-dev@python.org Sun Jun 4 16:30:37 2000 From: python-dev@python.org (Greg Ward) Date: Sun, 4 Jun 2000 08:30:37 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist_rpm.py,1.11,1.12 Message-ID: <200006041530.IAA20449@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv20334 Modified Files: bdist_rpm.py Log Message: Fixed syntax error. Half-fixed RPM 2 compatibility:added 'rpm_base' option, which must be set (to eg. /usr/src/redhat on a stock Red Hat system) if rpm2_mode is on. Still not quite working, though. Index: bdist_rpm.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist_rpm.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** bdist_rpm.py 2000/06/04 15:00:34 1.11 --- bdist_rpm.py 2000/06/04 15:30:35 1.12 *************** *** 6,10 **** # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.11 2000/06/04 15:00:34 gward Exp $" import os, string --- 6,10 ---- # created 2000/04/25, by Harry Henry Gebel ! __revision__ = "$Id: bdist_rpm.py,v 1.12 2000/06/04 15:30:35 gward Exp $" import os, string *************** *** 19,24 **** user_options = [ ! ('bdist-base', None, "base directory for creating built distributions"), ('spec-only', None, "only regenerate spec file"), --- 19,27 ---- user_options = [ ! ('bdist-base=', None, "base directory for creating built distributions"), + ('rpm-base=', None, + "base directory for creating RPMs (defaults to \"rpm\" under " + "--bdist-base; must be specified for RPM 2)"), ('spec-only', None, "only regenerate spec file"), *************** *** 105,108 **** --- 108,112 ---- def initialize_options (self): self.bdist_base = None + self.rpm_base = None self.spec_only = None self.binary_only = None *************** *** 144,147 **** --- 148,157 ---- def finalize_options (self): self.set_undefined_options('bdist', ('bdist_base', 'bdist_base')) + if self.rpm_base is None: + if not self.rpm3_mode: + raise DistutilsOptionError, \ + "you must specify --rpm-base in RPM 2 mode" + self.rpm_base = os.path.join(self.bdist_base, "rpm") + if os.name != 'posix': raise DistutilsPlatformError, \ *************** *** 219,230 **** self.mkpath(spec_dir) # XXX should be configurable else: - if self.rpm3_mode: - rpm_base = os.path.join(self.bdist_base, "rpm") - else: - # complete path must be specified in RPM 2 mode - rpm_base = self.bdist_base rpm_dir = {} for d in ('SOURCES', 'SPECS', 'BUILD', 'RPMS', 'SRPMS'): ! rpm_dir[d] = os.path.join(rpm_base, d) self.mkpath(rpm_dir[d]) spec_dir = rpm_dir['SPECS'] --- 229,235 ---- self.mkpath(spec_dir) # XXX should be configurable else: rpm_dir = {} for d in ('SOURCES', 'SPECS', 'BUILD', 'RPMS', 'SRPMS'): ! rpm_dir[d] = os.path.join(self.rpm_base, d) self.mkpath(rpm_dir[d]) spec_dir = rpm_dir['SPECS'] *************** *** 274,278 **** if self.rpm3_mode: rpm_args.extend(['--define', ! '_topdir %s/%s' % (os.getcwd(), rpm_base),]) if self.clean: rpm_args.append('--clean') --- 279,283 ---- if self.rpm3_mode: rpm_args.extend(['--define', ! '_topdir %s/%s' % (os.getcwd(), self.rpm_base),]) if self.clean: rpm_args.append('--clean') *************** *** 392,396 **** ('post', 'post_install', None), ('preun', 'pre_uninstall', None), ! ('postun', 'post_uninstall', None)) ] --- 397,401 ---- ('post', 'post_install', None), ('preun', 'pre_uninstall', None), ! ('postun', 'post_uninstall', None), ] From python-dev@python.org Tue Jun 6 03:18:16 2000 From: python-dev@python.org (Greg Ward) Date: Mon, 5 Jun 2000 19:18:16 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command install_data.py,1.7,1.8 Message-ID: <200006060218.TAA25313@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv25303 Modified Files: install_data.py Log Message: 'get_outputs()' now returns an empty list instead of None. Index: install_data.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/install_data.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** install_data.py 2000/05/25 02:14:26 1.7 --- install_data.py 2000/06/06 02:18:13 1.8 *************** *** 6,10 **** # contributed by Bastian Kleineidam ! __revision__ = "$Id: install_data.py,v 1.7 2000/05/25 02:14:26 gward Exp $" import os --- 6,10 ---- # contributed by Bastian Kleineidam ! __revision__ = "$Id: install_data.py,v 1.8 2000/06/06 02:18:13 gward Exp $" import os *************** *** 57,59 **** def get_outputs (self): ! return self.outfiles --- 57,59 ---- def get_outputs (self): ! return self.outfiles or [] From python-dev@python.org Tue Jun 6 03:51:40 2000 From: python-dev@python.org (Greg Ward) Date: Mon, 5 Jun 2000 19:51:40 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist.py,1.9,1.10 Message-ID: <200006060251.TAA26971@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv26962/command Modified Files: bdist.py Log Message: Support for multiple distribution formats in one run. Index: bdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** bdist.py 2000/05/27 17:27:23 1.9 --- bdist.py 2000/06/06 02:51:38 1.10 *************** *** 6,10 **** # created 2000/03/29, Greg Ward ! __revision__ = "$Id: bdist.py,v 1.9 2000/05/27 17:27:23 gward Exp $" import os, string --- 6,10 ---- # created 2000/03/29, Greg Ward ! __revision__ = "$Id: bdist.py,v 1.10 2000/06/06 02:51:38 gward Exp $" import os, string *************** *** 21,27 **** user_options = [('bdist-base=', 'b', "temporary directory for creating built distributions"), ! ('format=', 'f', ! "format for distribution " + ! "(tar, ztar, gztar, bztar, zip, ... )"), ] --- 21,27 ---- user_options = [('bdist-base=', 'b', "temporary directory for creating built distributions"), ! ('formats=', None, ! "formats for distribution " + ! "(gztar, bztar, zip, rpm, ... )"), ] *************** *** 44,48 **** def initialize_options (self): self.bdist_base = None ! self.format = None # initialize_options() --- 44,48 ---- def initialize_options (self): self.bdist_base = None ! self.formats = None # initialize_options() *************** *** 58,70 **** self.bdist_base = os.path.join (build_base, 'bdist.' + plat) ! if self.format is None: try: ! self.format = self.default_format[os.name] except KeyError: raise DistutilsPlatformError, \ "don't know how to create built distributions " + \ "on platform %s" % os.name - #elif type (self.format) is StringType: - # self.format = string.split (self.format, ',') # finalize_options() --- 58,69 ---- self.bdist_base = os.path.join (build_base, 'bdist.' + plat) ! self.ensure_string_list('formats') ! if self.formats is None: try: ! self.formats = [self.default_format[os.name]] except KeyError: raise DistutilsPlatformError, \ "don't know how to create built distributions " + \ "on platform %s" % os.name # finalize_options() *************** *** 73,86 **** def run (self): ! try: ! cmd_name = self.format_command[self.format] ! except KeyError: ! raise DistutilsOptionError, \ ! "invalid archive format '%s'" % self.format ! ! if cmd_name not in self.no_format_option: ! sub_cmd = self.get_finalized_command (cmd_name) ! sub_cmd.format = self.format ! self.run_command (cmd_name) # run() --- 72,87 ---- def run (self): ! for format in self.formats: ! ! try: ! cmd_name = self.format_command[self.format] ! except KeyError: ! raise DistutilsOptionError, \ ! "invalid format '%s'" % self.format ! ! sub_cmd = self.reinitialize_command(cmd_name) ! if cmd_name not in self.no_format_option: ! sub_cmd.format = self.format ! self.run_command (cmd_name) # run() From python-dev@python.org Tue Jun 6 03:52:38 2000 From: python-dev@python.org (Greg Ward) Date: Mon, 5 Jun 2000 19:52:38 -0700 Subject: [Python-checkins] CVS: distutils/distutils dist.py,1.24,1.25 Message-ID: <200006060252.TAA27112@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv27015 Modified Files: dist.py Log Message: Fix 'reinitialize_command()' so it resets the 'have_run' flag for the command being reinitialized to false. Index: dist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/dist.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -r1.24 -r1.25 *** dist.py 2000/06/02 01:59:33 1.24 --- dist.py 2000/06/06 02:52:36 1.25 *************** *** 8,12 **** # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: dist.py,v 1.24 2000/06/02 01:59:33 gward Exp $" import sys, os, string, re --- 8,12 ---- # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: dist.py,v 1.25 2000/06/06 02:52:36 gward Exp $" import sys, os, string, re *************** *** 713,716 **** --- 713,717 ---- command.initialize_options() command.finalized = 0 + self.have_run[command_name] = 0 self._set_command_options(command) return command From python-dev@python.org Tue Jun 6 03:57:10 2000 From: python-dev@python.org (Greg Ward) Date: Mon, 5 Jun 2000 19:57:10 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command config.py,NONE,1.1 Message-ID: <200006060257.TAA27243@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv27120/command Added Files: config.py Log Message: First crack at the Distutils "config" command. Unlike other commands, this one doesn't *do* anything by default; it's just there as a conduit for data (eg. include dirs, libraries) from the user to the "build" commands. However, it provides a couple of Autoconf-ish methods ('try_compile()', 'try_link()', 'try_run()') that derived, per-distribution "config" commands can use to poke around the target system and see what's available. Initial experimenst with mxDateTime indicate that higher-level methods are necessary: analogs of Autoconf's AC_CHECK_HEADER, AC_CHECK_LIB will be needed too (and that's just to probe the C/C++ system: how to probe the Python system is wide open, and someday we'll have to worry about probing a Java system too). From python-dev@python.org Tue Jun 6 21:52:20 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 6 Jun 2000 13:52:20 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules posixmodule.c,2.135,2.136 Message-ID: <200006062052.NAA24475@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv24342 Modified Files: posixmodule.c Log Message: Patch from Trent Mick: Fix a small bug in posixmodule.c where a char* is being dereferenced where it should not be. Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.135 retrieving revision 2.136 diff -C2 -r2.135 -r2.136 *** posixmodule.c 2000/06/01 02:02:46 2.135 --- posixmodule.c 2000/06/06 20:52:17 2.136 *************** *** 892,896 **** if (FindClose(hFindFile) == FALSE) { errno = GetLastError(); ! return posix_error_with_filename(&name); } --- 892,896 ---- if (FindClose(hFindFile) == FALSE) { errno = GetLastError(); ! return posix_error_with_filename(name); } From python-dev@python.org Wed Jun 7 10:04:08 2000 From: python-dev@python.org (Marc-Andre Lemburg) Date: Wed, 7 Jun 2000 02:04:08 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/encodings undefined.py,NONE,1.1 Message-ID: <200006070904.CAA14879@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/encodings In directory slayer.i.sourceforge.net:/tmp/cvs-serv14834/Lib/encodings Added Files: undefined.py Log Message: New codec which always raises an exception when used. This codec can be used to effectively switch off string coercion to Unicode. From python-dev@python.org Wed Jun 7 10:11:43 2000 From: python-dev@python.org (Marc-Andre Lemburg) Date: Wed, 7 Jun 2000 02:11:43 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib locale.py,1.4,1.5 Message-ID: <200006070911.CAA17368@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv17332/Lib Modified Files: locale.py Log Message: Marc-Andre Lemburg : Added a new locale name aliasing engine which also supports locale encodings, a feature which is used by the new default encoding support in site.py. Index: locale.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/locale.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** locale.py 2000/02/04 15:39:29 1.4 --- locale.py 2000/06/07 09:11:40 1.5 *************** *** 1,9 **** ! """Support for number formatting using the current locale settings.""" ! # Author: Martin von Loewis ! from _locale import * import string #perform the grouping from right to left def _group(s): --- 1,25 ---- ! """ Locale support. ! The module provides low-level access to the C lib's locale APIs ! and adds high level number formatting APIs as well as a locale ! aliasing engine to complement these. ! The aliasing engine includes support for many commonly used locale ! names and maps them to values suitable for passing to the C lib's ! setlocale() function. It also includes default encodings for all ! supported locale names. ! ! """ ! import string + ### C lib locale APIs + + from _locale import * + + ### Number formatting APIs + + # Author: Martin von Loewis + #perform the grouping from right to left def _group(s): *************** *** 26,30 **** result=s[-group:] s=s[:-group] ! if s and result: result=s+conv['thousands_sep']+result return result --- 42,48 ---- result=s[-group:] s=s[:-group] ! if not result: ! return s ! if s: result=s+conv['thousands_sep']+result return result *************** *** 35,39 **** Grouping is applied if the third parameter is true.""" result = f % val ! fields = string.splitfields(result,".") if grouping: fields[0]=_group(fields[0]) --- 53,57 ---- Grouping is applied if the third parameter is true.""" result = f % val ! fields = string.split(result, ".") if grouping: fields[0]=_group(fields[0]) *************** *** 52,60 **** "Parses a string as a float according to the locale settings." #First, get rid of the grouping ! s=string.splitfields(str,localeconv()['thousands_sep']) ! str=string.join(s,"") #next, replace the decimal point with a dot ! s=string.splitfields(str,localeconv()['decimal_point']) ! str=string.join(s,'.') #finally, parse the string return func(str) --- 70,82 ---- "Parses a string as a float according to the locale settings." #First, get rid of the grouping ! ts = localeconv()['thousands_sep'] ! if ts: ! s=string.split(str,ts) ! str=string.join(s, "") #next, replace the decimal point with a dot ! dd = localeconv()['decimal_point'] ! if dd: ! s=string.split(str,dd) ! str=string.join(s,'.') #finally, parse the string return func(str) *************** *** 64,68 **** return atof(str,string.atoi) ! def test(): setlocale(LC_ALL,"") #do grouping --- 86,90 ---- return atof(str,string.atoi) ! def _test(): setlocale(LC_ALL,"") #do grouping *************** *** 72,77 **** s1=str(3.14) print s1,"is",atof(s1) if __name__=='__main__': ! test() --- 94,571 ---- s1=str(3.14) print s1,"is",atof(s1) + + ### Locale name aliasing engine + + # Author: Marc-Andre Lemburg, mal@lemburg.com + + def normalize(localename): + + """ Returns a normalized locale code for the given locale + name. + + The returned locale code is formatted for use with + setlocale(). + + If normalization fails, the original name is returned + unchanged. + + If the given encoding is not known, the function defaults to + the default encoding for the locale code just like setlocale() + does. + + """ + # Normalize the locale name and extract the encoding + fullname = string.lower(localename) + if ':' in fullname: + # ':' is sometimes used as encoding delimiter. + fullname = string.replace(fullname, ':', '.') + if '.' in fullname: + langname, encoding = string.split(fullname, '.')[:2] + fullname = langname + '.' + encoding + else: + langname = fullname + encoding = '' + + # First lookup: fullname (possibly with encoding) + code = locale_alias.get(fullname, None) + if code is not None: + return code + + # Second try: langname (without encoding) + code = locale_alias.get(langname, None) + if code is not None: + if '.' in code: + langname, defenc = string.split(code, '.') + else: + langname = code + defenc = '' + if encoding: + encoding = encoding_alias.get(encoding, encoding) + else: + encoding = defenc + if encoding: + return langname + '.' + encoding + else: + return langname + + else: + return localename + + def _parse_localename(localename): + + """ Parses the locale code for localename and returns the + result as tuple (language code, encoding). + + The localename is normalized and passed through the locale + alias engine. A ValueError is raised in case the locale name + cannot be parsed. + + The language code corresponds to RFC 1766. code and encoding + can be None in case the values cannot be determined or are + unkown to this implementation. + + """ + code = normalize(localename) + if '.' in code: + return string.split(code, '.')[:2] + elif code == 'C': + return None, None + else: + raise ValueError,'unkown locale: %s' % localename + return l + + def _build_localename(localetuple): + + """ Builds a locale code from the given tuple (language code, + encoding). + + No aliasing or normalizing takes place. + + """ + language, encoding = localetuple + if language is None: + language = 'C' + if encoding is None: + return language + else: + return language + '.' + encoding + + def get_default(envvars=('LANGUAGE', 'LC_ALL', 'LC_CTYPE', 'LANG')): + + """ Tries to determine the default locale settings and returns + them as tuple (language code, encoding). + + According to POSIX, a program which has not called + setlocale(LC_ALL,"") runs using the portable 'C' locale. + Calling setlocale(LC_ALL,"") lets it use the default locale as + defined by the LANG variable. Since we don't want to interfere + with the current locale setting we thus emulate the behaviour + in the way described above. + + To maintain compatibility with other platforms, not only the + LANG variable is tested, but a list of variables given as + envvars parameter. The first found to be defined will be + used. envvars defaults to the search path used in GNU gettext; + it must always contain the variable name 'LANG'. + + Except for the code 'C', the language code corresponds to RFC + 1766. code and encoding can be None in case the values cannot + be determined. + + """ + import os + lookup = os.environ.get + for variable in envvars: + localename = lookup(variable,None) + if localename is not None: + break + else: + localename = 'C' + return _parse_localename(localename) + + def get_locale(category=LC_CTYPE): + + """ Returns the current setting for the given locale category as + tuple (language code, encoding). + + category may be one of the LC_* value except LC_ALL. It + defaults to LC_CTYPE. + + Except for the code 'C', the language code corresponds to RFC + 1766. code and encoding can be None in case the values cannot + be determined. + + """ + localename = setlocale(category) + if category == LC_ALL and ';' in localename: + raise TypeError,'category LC_ALL is not supported' + return _parse_localename(localename) + + def set_locale(localetuple, category=LC_ALL): + + """ Set the locale according to the localetuple (language code, + encoding) as returned by get_locale() and get_default(). + + The given codes are passed through the locale aliasing engine + before being given to setlocale() for processing. + + category may be given as one of the LC_* values. It defaults + to LC_ALL. + + """ + setlocale(category, normalize(_build_localename(localetuple))) + + def set_to_default(category=LC_ALL): + + """ Sets the locale for category to the default setting. + + The default setting is determined by calling + get_default(). category defaults to LC_ALL. + + """ + setlocale(category, _build_localename(get_default())) + + ### Database + # + # The following data was extracted from the locale.alias file which + # comes with X11 and then hand edited removing the explicit encoding + # definitions and adding some more aliases. The file is usually + # available as /usr/lib/X11/locale/locale.alias. + # + + # + # The encoding_alias table maps lowercase encoding alias names to C + # locale encoding names (case-sensitive). + # + encoding_alias = { + '437': 'C', + 'c': 'C', + 'iso8859': 'ISO8859-1', + '8859': 'ISO8859-1', + '88591': 'ISO8859-1', + 'ascii': 'ISO8859-1', + 'en': 'ISO8859-1', + 'iso88591': 'ISO8859-1', + 'iso_8859-1': 'ISO8859-1', + '885915': 'ISO8859-15', + 'iso885915': 'ISO8859-15', + 'iso_8859-15': 'ISO8859-15', + 'iso8859-2': 'ISO8859-2', + 'iso88592': 'ISO8859-2', + 'iso_8859-2': 'ISO8859-2', + 'iso88595': 'ISO8859-5', + 'iso88596': 'ISO8859-6', + 'iso88597': 'ISO8859-7', + 'iso88598': 'ISO8859-8', + 'iso88599': 'ISO8859-9', + 'iso-2022-jp': 'JIS7', + 'jis': 'JIS7', + 'jis7': 'JIS7', + 'sjis': 'SJIS', + 'tis620': 'TACTIS', + 'ajec': 'eucJP', + 'eucjp': 'eucJP', + 'ujis': 'eucJP', + 'utf-8': 'utf', + 'utf8': 'utf', + 'utf8@ucs4': 'utf', + } + + # + # The locale_alias table maps lowercase alias names to C locale names + # (case-sensitive). Encodings are always separated from the locale + # name using a dot ('.'); they should only be given in case the + # language name is needed to interpret the given encoding alias + # correctly (CJK codes often have this need). + # + locale_alias = { + 'american': 'en_US.ISO8859-1', + 'ar': 'ar_AA.ISO8859-6', + 'ar_aa': 'ar_AA.ISO8859-6', + 'ar_sa': 'ar_SA.ISO8859-6', + 'arabic': 'ar_AA.ISO8859-6', + 'bg': 'bg_BG.ISO8859-5', + 'bg_bg': 'bg_BG.ISO8859-5', + 'bulgarian': 'bg_BG.ISO8859-5', + 'c-french': 'fr_CA.ISO8859-1', + 'c': 'C', + 'c_c': 'C', + 'cextend': 'en_US.ISO8859-1', + 'chinese-s': 'zh_CN.eucCN', + 'chinese-t': 'zh_TW.eucTW', + 'croatian': 'hr_HR.ISO8859-2', + 'cs': 'cs_CZ.ISO8859-2', + 'cs_cs': 'cs_CZ.ISO8859-2', + 'cs_cz': 'cs_CZ.ISO8859-2', + 'cz': 'cz_CZ.ISO8859-2', + 'cz_cz': 'cz_CZ.ISO8859-2', + 'czech': 'cs_CS.ISO8859-2', + 'da': 'da_DK.ISO8859-1', + 'da_dk': 'da_DK.ISO8859-1', + 'danish': 'da_DK.ISO8859-1', + 'de': 'de_DE.ISO8859-1', + 'de_at': 'de_AT.ISO8859-1', + 'de_ch': 'de_CH.ISO8859-1', + 'de_de': 'de_DE.ISO8859-1', + 'dutch': 'nl_BE.ISO8859-1', + 'ee': 'ee_EE.ISO8859-4', + 'el': 'el_GR.ISO8859-7', + 'el_gr': 'el_GR.ISO8859-7', + 'en': 'en_US.ISO8859-1', + 'en_au': 'en_AU.ISO8859-1', + 'en_ca': 'en_CA.ISO8859-1', + 'en_gb': 'en_GB.ISO8859-1', + 'en_ie': 'en_IE.ISO8859-1', + 'en_nz': 'en_NZ.ISO8859-1', + 'en_uk': 'en_GB.ISO8859-1', + 'en_us': 'en_US.ISO8859-1', + 'eng_gb': 'en_GB.ISO8859-1', + 'english': 'en_EN.ISO8859-1', + 'english_uk': 'en_GB.ISO8859-1', + 'english_united-states': 'en_US.ISO8859-1', + 'english_us': 'en_US.ISO8859-1', + 'es': 'es_ES.ISO8859-1', + 'es_ar': 'es_AR.ISO8859-1', + 'es_bo': 'es_BO.ISO8859-1', + 'es_cl': 'es_CL.ISO8859-1', + 'es_co': 'es_CO.ISO8859-1', + 'es_cr': 'es_CR.ISO8859-1', + 'es_ec': 'es_EC.ISO8859-1', + 'es_es': 'es_ES.ISO8859-1', + 'es_gt': 'es_GT.ISO8859-1', + 'es_mx': 'es_MX.ISO8859-1', + 'es_ni': 'es_NI.ISO8859-1', + 'es_pa': 'es_PA.ISO8859-1', + 'es_pe': 'es_PE.ISO8859-1', + 'es_py': 'es_PY.ISO8859-1', + 'es_sv': 'es_SV.ISO8859-1', + 'es_uy': 'es_UY.ISO8859-1', + 'es_ve': 'es_VE.ISO8859-1', + 'et': 'et_EE.ISO8859-4', + 'et_ee': 'et_EE.ISO8859-4', + 'fi': 'fi_FI.ISO8859-1', + 'fi_fi': 'fi_FI.ISO8859-1', + 'finnish': 'fi_FI.ISO8859-1', + 'fr': 'fr_FR.ISO8859-1', + 'fr_be': 'fr_BE.ISO8859-1', + 'fr_ca': 'fr_CA.ISO8859-1', + 'fr_ch': 'fr_CH.ISO8859-1', + 'fr_fr': 'fr_FR.ISO8859-1', + 'fre_fr': 'fr_FR.ISO8859-1', + 'french': 'fr_FR.ISO8859-1', + 'french_france': 'fr_FR.ISO8859-1', + 'ger_de': 'de_DE.ISO8859-1', + 'german': 'de_DE.ISO8859-1', + 'german_germany': 'de_DE.ISO8859-1', + 'greek': 'el_GR.ISO8859-7', + 'hebrew': 'iw_IL.ISO8859-8', + 'hr': 'hr_HR.ISO8859-2', + 'hr_hr': 'hr_HR.ISO8859-2', + 'hu': 'hu_HU.ISO8859-2', + 'hu_hu': 'hu_HU.ISO8859-2', + 'hungarian': 'hu_HU.ISO8859-2', + 'icelandic': 'is_IS.ISO8859-1', + 'id': 'id_ID.ISO8859-1', + 'id_id': 'id_ID.ISO8859-1', + 'is': 'is_IS.ISO8859-1', + 'is_is': 'is_IS.ISO8859-1', + 'iso-8859-1': 'en_US.ISO8859-1', + 'iso-8859-15': 'en_US.ISO8859-15', + 'iso8859-1': 'en_US.ISO8859-1', + 'iso8859-15': 'en_US.ISO8859-15', + 'iso_8859_1': 'en_US.ISO8859-1', + 'iso_8859_15': 'en_US.ISO8859-15', + 'it': 'it_IT.ISO8859-1', + 'it_ch': 'it_CH.ISO8859-1', + 'it_it': 'it_IT.ISO8859-1', + 'italian': 'it_IT.ISO8859-1', + 'iw': 'iw_IL.ISO8859-8', + 'iw_il': 'iw_IL.ISO8859-8', + 'ja': 'ja_JP.eucJP', + 'ja.jis': 'ja_JP.JIS7', + 'ja.sjis': 'ja_JP.SJIS', + 'ja_jp': 'ja_JP.eucJP', + 'ja_jp.ajec': 'ja_JP.eucJP', + 'ja_jp.euc': 'ja_JP.eucJP', + 'ja_jp.eucjp': 'ja_JP.eucJP', + 'ja_jp.iso-2022-jp': 'ja_JP.JIS7', + 'ja_jp.jis': 'ja_JP.JIS7', + 'ja_jp.jis7': 'ja_JP.JIS7', + 'ja_jp.mscode': 'ja_JP.SJIS', + 'ja_jp.sjis': 'ja_JP.SJIS', + 'ja_jp.ujis': 'ja_JP.eucJP', + 'japan': 'ja_JP.eucJP', + 'japanese': 'ja_JP.SJIS', + 'japanese-euc': 'ja_JP.eucJP', + 'japanese.euc': 'ja_JP.eucJP', + 'jp_jp': 'ja_JP.eucJP', + 'ko': 'ko_KR.eucKR', + 'ko_kr': 'ko_KR.eucKR', + 'ko_kr.euc': 'ko_KR.eucKR', + 'korean': 'ko_KR.eucKR', + 'lt': 'lt_LT.ISO8859-4', + 'lv': 'lv_LV.ISO8859-4', + 'mk': 'mk_MK.ISO8859-5', + 'mk_mk': 'mk_MK.ISO8859-5', + 'nl': 'nl_NL.ISO8859-1', + 'nl_be': 'nl_BE.ISO8859-1', + 'nl_nl': 'nl_NL.ISO8859-1', + 'no': 'no_NO.ISO8859-1', + 'no_no': 'no_NO.ISO8859-1', + 'norwegian': 'no_NO.ISO8859-1', + 'pl': 'pl_PL.ISO8859-2', + 'pl_pl': 'pl_PL.ISO8859-2', + 'polish': 'pl_PL.ISO8859-2', + 'portuguese': 'pt_PT.ISO8859-1', + 'portuguese_brazil': 'pt_BR.ISO8859-1', + 'posix': 'C', + 'posix-utf2': 'C', + 'pt': 'pt_PT.ISO8859-1', + 'pt_br': 'pt_BR.ISO8859-1', + 'pt_pt': 'pt_PT.ISO8859-1', + 'ro': 'ro_RO.ISO8859-2', + 'ro_ro': 'ro_RO.ISO8859-2', + 'ru': 'ru_RU.ISO8859-5', + 'ru_ru': 'ru_RU.ISO8859-5', + 'rumanian': 'ro_RO.ISO8859-2', + 'russian': 'ru_RU.ISO8859-5', + 'serbocroatian': 'sh_YU.ISO8859-2', + 'sh': 'sh_YU.ISO8859-2', + 'sh_hr': 'sh_HR.ISO8859-2', + 'sh_sp': 'sh_YU.ISO8859-2', + 'sh_yu': 'sh_YU.ISO8859-2', + 'sk': 'sk_SK.ISO8859-2', + 'sk_sk': 'sk_SK.ISO8859-2', + 'sl': 'sl_CS.ISO8859-2', + 'sl_cs': 'sl_CS.ISO8859-2', + 'sl_si': 'sl_SI.ISO8859-2', + 'slovak': 'sk_SK.ISO8859-2', + 'slovene': 'sl_CS.ISO8859-2', + 'sp': 'sp_YU.ISO8859-5', + 'sp_yu': 'sp_YU.ISO8859-5', + 'spanish': 'es_ES.ISO8859-1', + 'spanish_spain': 'es_ES.ISO8859-1', + 'sr_sp': 'sr_SP.ISO8859-2', + 'sv': 'sv_SE.ISO8859-1', + 'sv_se': 'sv_SE.ISO8859-1', + 'swedish': 'sv_SE.ISO8859-1', + 'th_th': 'th_TH.TACTIS', + 'tr': 'tr_TR.ISO8859-9', + 'tr_tr': 'tr_TR.ISO8859-9', + 'turkish': 'tr_TR.ISO8859-9', + 'univ': 'en_US.utf', + 'universal': 'en_US.utf', + 'zh': 'zh_CN.eucCN', + 'zh_cn': 'zh_CN.eucCN', + 'zh_cn.big5': 'zh_TW.eucTW', + 'zh_cn.euc': 'zh_CN.eucCN', + 'zh_tw': 'zh_TW.eucTW', + 'zh_tw.euc': 'zh_TW.eucTW', + } + + def _print_locale(): + + """ Test function. + """ + categories = {} + def _init_categories(categories=categories): + for k,v in globals().items(): + if k[:3] == 'LC_': + categories[k] = v + _init_categories() + del categories['LC_ALL'] + + print 'Locale defaults as determined by get_default():' + print '-'*72 + lang, enc = get_default() + print 'Language: ', lang or '(undefined)' + print 'Encoding: ', enc or '(undefined)' + print + + print 'Locale settings on startup:' + print '-'*72 + for name,category in categories.items(): + print name,'...' + lang, enc = get_locale(category) + print ' Language: ', lang or '(undefined)' + print ' Encoding: ', enc or '(undefined)' + print + + set_to_default() + print + print 'Locale settings after calling set_to_default():' + print '-'*72 + for name,category in categories.items(): + print name,'...' + lang, enc = get_locale(category) + print ' Language: ', lang or '(undefined)' + print ' Encoding: ', enc or '(undefined)' + print + + try: + setlocale(LC_ALL,"") + except: + print 'NOTE:' + print 'setlocale(LC_ALL,"") does not support the default locale' + print 'given in the OS environment variables.' + else: + print + print 'Locale settings after calling setlocale(LC_ALL,""):' + print '-'*72 + for name,category in categories.items(): + print name,'...' + lang, enc = get_locale(category) + print ' Language: ', lang or '(undefined)' + print ' Encoding: ', enc or '(undefined)' + print + ### if __name__=='__main__': ! print 'Locale aliasing:' ! print ! _print_locale() ! print ! print 'Number formatting:' ! print ! _test() From python-dev@python.org Wed Jun 7 10:12:12 2000 From: python-dev@python.org (Marc-Andre Lemburg) Date: Wed, 7 Jun 2000 02:12:12 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib site.py,1.10,1.11 Message-ID: <200006070912.CAA17624@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv17610/Lib Modified Files: site.py Log Message: Marc-Andre Lemburg : Added support to set the default encoding of strings at startup time to the values defined by the C locale. The sys.setdefaultencoding() API is deleted after having set up the encoding, so that user code cannot subsequentely change the setting. This effectively means that only site.py may alter the default setting. Index: site.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/site.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** site.py 1998/11/25 15:57:47 1.10 --- site.py 2000/06/07 09:12:09 1.11 *************** *** 120,127 **** del exit try: ! import sitecustomize # Run arbitrary site specific code except ImportError: ! pass # No site customization module def _test(): --- 120,162 ---- del exit + # + # Set the string encoding used by the Unicode implementation to the + # encoding used by the default locale of this system. If the default + # encoding cannot be determined or is unkown, it defaults to 'ascii'. + # + def locale_aware_defaultencoding(): + import locale + code, encoding = locale.get_default() + if encoding is None: + encoding = 'ascii' + try: + sys.setdefaultencoding(encoding) + except LookupError: + sys.setdefaultencoding('ascii') + + if 1: + # Enable to support locale aware default string encodings. + locale_aware_defaultencoding() + elif 0: + # Enable to switch off string to Unicode coercion and implicit + # Unicode to string conversion. + sys.setdefaultencoding('undefined') + elif 0: + # Enable to hard-code a site specific default string encoding. + sys.setdefaultencoding('ascii') + + # + # Run custom site specific code, if available. + # try: ! import sitecustomize except ImportError: ! pass ! ! # ! # Remove sys.setdefaultencoding() so that users cannot change the ! # encoding after initialization. ! # ! del sys.setdefaultencoding def _test(): From python-dev@python.org Wed Jun 7 10:12:33 2000 From: python-dev@python.org (Marc-Andre Lemburg) Date: Wed, 7 Jun 2000 02:12:33 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/encodings aliases.py,1.3,1.4 Message-ID: <200006070912.CAA17730@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/encodings In directory slayer.i.sourceforge.net:/tmp/cvs-serv17691/Lib/encodings Modified Files: aliases.py Log Message: Marc-Andre Lemburg : Added some more codec aliases. Some of them are needed by the new locale.py encoding support. Index: aliases.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/aliases.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** aliases.py 2000/04/05 20:11:18 1.3 --- aliases.py 2000/06/07 09:12:30 1.4 *************** *** 19,22 **** --- 19,24 ---- 'utf8': 'utf_8', 'u8': 'utf_8', + 'utf8@ucs2': 'utf_8', + 'utf8@ucs4': 'utf_8', # UTF-16 *************** *** 32,35 **** --- 34,39 ---- # ISO + '8859': 'latin_1', + 'iso8859': 'latin_1', 'iso8859_1': 'latin_1', 'iso_8859_1': 'latin_1', *************** *** 48,51 **** --- 52,56 ---- # Mac + 'maclatin2': 'mac_latin2', 'maccentraleurope': 'mac_latin2', 'maccyrillic': 'mac_cyrillic', *************** *** 57,60 **** --- 62,82 ---- # MBCS 'dbcs': 'mbcs', + + # Code pages + '437': 'cp437', + + # CJK + # + # The codecs for these encodings are not distributed with the + # Python core, but are included here for reference, since the + # locale module relies on having these aliases available. + # + 'jis_7': 'jis_7', + 'iso_2022_jp': 'jis_7', + 'ujis': 'euc_jp', + 'ajec': 'euc_jp', + 'eucjp': 'euc_jp', + 'tis260': 'tactis', + 'sjis': 'shift_jis', } From python-dev@python.org Wed Jun 7 10:12:56 2000 From: python-dev@python.org (Marc-Andre Lemburg) Date: Wed, 7 Jun 2000 02:12:56 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules Setup.in,1.100,1.101 Message-ID: <200006070912.CAA17814@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv17795/Modules Modified Files: Setup.in Log Message: Marc-Andre Lemburg : The locale module is turned on per default. Index: Setup.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Setup.in,v retrieving revision 1.100 retrieving revision 1.101 diff -C2 -r1.100 -r1.101 *** Setup.in 2000/05/26 19:02:42 1.100 --- Setup.in 2000/06/07 09:12:54 1.101 *************** *** 141,145 **** # static Unicode character database ! #_locale _localemodule.c # access to ISO C locale support --- 141,145 ---- # static Unicode character database ! _locale _localemodule.c # access to ISO C locale support From python-dev@python.org Wed Jun 7 10:13:24 2000 From: python-dev@python.org (Marc-Andre Lemburg) Date: Wed, 7 Jun 2000 02:13:24 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.21,2.22 Message-ID: <200006070913.CAA18060@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv17917/Objects Modified Files: unicodeobject.c Log Message: Marc-Andre Lemburg : Change the default encoding to 'ascii' (it was previously defined as UTF-8). Note: The implementation still uses UTF-8 to implement the buffer protocol, so C APIs will still see UTF-8. This is on purpose: rather than fixing the Unicode implementation, the C APIs should be made Unicode aware. Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.21 retrieving revision 2.22 diff -C2 -r2.21 -r2.22 *** unicodeobject.c 2000/05/09 19:54:43 2.21 --- unicodeobject.c 2000/06/07 09:13:21 2.22 *************** *** 4711,4715 **** /* Init the implementation */ unicode_empty = _PyUnicode_New(0); ! strcpy(unicode_default_encoding, "utf-8"); } --- 4711,4715 ---- /* Init the implementation */ unicode_empty = _PyUnicode_New(0); ! strcpy(unicode_default_encoding, "ascii"); } From python-dev@python.org Wed Jun 7 10:13:44 2000 From: python-dev@python.org (Marc-Andre Lemburg) Date: Wed, 7 Jun 2000 02:13:44 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python sysmodule.c,2.63,2.64 Message-ID: <200006070913.CAA18216@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv18159/Python Modified Files: sysmodule.c Log Message: Marc-Andre Lemburg : Changed the API names for setting the default encoding. These are now in line with the other hooks API names (no underscores). Index: sysmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v retrieving revision 2.63 retrieving revision 2.64 diff -C2 -r2.63 -r2.64 *** sysmodule.c 2000/05/09 19:57:01 2.63 --- sysmodule.c 2000/06/07 09:13:41 2.64 *************** *** 144,158 **** static PyObject * ! sys_get_string_encoding(self, args) PyObject *self; PyObject *args; { ! if (!PyArg_ParseTuple(args, ":get_string_encoding")) return NULL; return PyString_FromString(PyUnicode_GetDefaultEncoding()); } ! static char get_string_encoding_doc[] = ! "get_string_encoding() -> string\n\ \n\ Return the current default string encoding used by the Unicode \n\ --- 144,158 ---- static PyObject * ! sys_getdefaultencoding(self, args) PyObject *self; PyObject *args; { ! if (!PyArg_ParseTuple(args, ":getdefaultencoding")) return NULL; return PyString_FromString(PyUnicode_GetDefaultEncoding()); } ! static char getdefaultencoding_doc[] = ! "getdefaultencoding() -> string\n\ \n\ Return the current default string encoding used by the Unicode \n\ *************** *** 160,169 **** static PyObject * ! sys_set_string_encoding(self, args) PyObject *self; PyObject *args; { char *encoding; ! if (!PyArg_ParseTuple(args, "s:set_string_encoding", &encoding)) return NULL; if (PyUnicode_SetDefaultEncoding(encoding)) --- 160,169 ---- static PyObject * ! sys_setdefaultencoding(self, args) PyObject *self; PyObject *args; { char *encoding; ! if (!PyArg_ParseTuple(args, "s:setdefaultencoding", &encoding)) return NULL; if (PyUnicode_SetDefaultEncoding(encoding)) *************** *** 173,178 **** } ! static char set_string_encoding_doc[] = ! "set_string_encoding(encoding)\n\ \n\ Set the current default string encoding used by the Unicode implementation."; --- 173,178 ---- } ! static char setdefaultencoding_doc[] = ! "setdefaultencoding(encoding)\n\ \n\ Set the current default string encoding used by the Unicode implementation."; *************** *** 302,306 **** {"exc_info", sys_exc_info, 1, exc_info_doc}, {"exit", sys_exit, 0, exit_doc}, ! {"get_string_encoding", sys_get_string_encoding, 1, get_string_encoding_doc}, #ifdef COUNT_ALLOCS {"getcounts", sys_getcounts, 1}, --- 302,306 ---- {"exc_info", sys_exc_info, 1, exc_info_doc}, {"exit", sys_exit, 0, exit_doc}, ! {"getdefaultencoding", sys_getdefaultencoding, 1, getdefaultencoding_doc}, #ifdef COUNT_ALLOCS {"getcounts", sys_getcounts, 1}, *************** *** 316,320 **** {"mdebug", sys_mdebug, 1}, #endif ! {"set_string_encoding", sys_set_string_encoding, 1, set_string_encoding_doc}, {"setcheckinterval", sys_setcheckinterval, 1, setcheckinterval_doc}, {"setprofile", sys_setprofile, 0, setprofile_doc}, --- 316,320 ---- {"mdebug", sys_mdebug, 1}, #endif ! {"setdefaultencoding", sys_setdefaultencoding, 1, setdefaultencoding_doc}, {"setcheckinterval", sys_setcheckinterval, 1, setcheckinterval_doc}, {"setprofile", sys_setprofile, 0, setprofile_doc}, From python-dev@python.org Thu Jun 8 01:02:39 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 7 Jun 2000 17:02:39 -0700 Subject: [Python-checkins] CVS: distutils/distutils cmd.py,1.17,1.18 Message-ID: <200006080002.RAA15620@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv15602 Modified Files: cmd.py Log Message: Added 'debug_print()' method (driven by DEBUG global from distutils.core). Index: cmd.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/cmd.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** cmd.py 2000/06/04 14:21:28 1.17 --- cmd.py 2000/06/08 00:02:36 1.18 *************** *** 8,12 **** # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: cmd.py,v 1.17 2000/06/04 14:21:28 gward Exp $" import sys, os, string, re --- 8,12 ---- # (extricated from core.py; actually dates back to the beginning) ! __revision__ = "$Id: cmd.py,v 1.18 2000/06/08 00:02:36 gward Exp $" import sys, os, string, re *************** *** 172,175 **** --- 172,184 ---- if self.verbose >= level: print msg + + def debug_print (self, msg): + """Print 'msg' to stdout if the global DEBUG (taken from the + DISTUTILS_DEBUG environment variable) flag is true. + """ + from distutils.core import DEBUG + if DEBUG: + print msg + From python-dev@python.org Thu Jun 8 01:08:17 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 7 Jun 2000 17:08:17 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command sdist.py,1.25,1.26 Message-ID: <200006080008.RAA15980@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv15881 Modified Files: sdist.py Log Message: Made all debug output go through the 'debug_print()' method instead of directly printing to stdout. This was a bit more work than it sounds like it should have been: * turned 'select_pattern()' and 'exclude_pattern()' from functions into methods, so they can refer to 'self' to access the method * commented out the *other* 'exclude_pattern()' method, which appears to be vestigial code that was never cleaned up when the 'exclude_pattern()' function was created * changed the one use of the old 'exclude_pattern()' method to use the new 'exclude_pattern()' (same behaviour, slightly different args) * some code and docstring reformatting * and, of course, changed all the debugging prints to 'debug_print()' calls Added/tweaked some regular ('self.announce()') output for better runtime feedback. Index: sdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/sdist.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -r1.25 -r1.26 *** sdist.py 2000/06/07 03:00:06 1.25 --- sdist.py 2000/06/08 00:08:14 1.26 *************** *** 5,9 **** # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.25 2000/06/07 03:00:06 gward Exp $" import sys, os, string, re --- 5,9 ---- # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.26 2000/06/08 00:08:14 gward Exp $" import sys, os, string, re *************** *** 273,284 **** ! def exclude_pattern (self, pattern): ! """Remove filenames from 'self.files' that match 'pattern'.""" ! print "exclude_pattern: pattern=%s" % pattern ! pattern_re = translate_pattern (pattern) ! for i in range (len (self.files)-1, -1, -1): ! if pattern_re.match (self.files[i]): ! print "removing %s" % self.files[i] ! del self.files[i] --- 273,284 ---- ! # def exclude_pattern (self, pattern): ! # """Remove filenames from 'self.files' that match 'pattern'.""" ! # self.debug_print("exclude_pattern: pattern=%s" % pattern) ! # pattern_re = translate_pattern (pattern) ! # for i in range (len (self.files)-1, -1, -1): ! # if pattern_re.match (self.files[i]): ! # self.debug_print("removing %s" % self.files[i]) ! # del self.files[i] *************** *** 287,291 **** and whose basenames match 'pattern'.""" ! print "recursive_exclude_pattern: dir=%s, pattern=%s" % (dir, pattern) if pattern is None: pattern_re = None --- 287,292 ---- and whose basenames match 'pattern'.""" ! self.debug_print("recursive_exclude_pattern: dir=%s, pattern=%s" % ! (dir, pattern)) if pattern is None: pattern_re = None *************** *** 297,301 **** if (cur_dir == dir and (pattern_re is None or pattern_re.match (cur_base))): ! print "removing %s" % self.files[i] del self.files[i] --- 298,302 ---- if (cur_dir == dir and (pattern_re is None or pattern_re.match (cur_base))): ! self.debug_print("removing %s" % self.files[i]) del self.files[i] *************** *** 308,311 **** --- 309,313 ---- assert self.files is not None and type (self.files) is ListType + self.announce("reading manifest template '%s'" % self.template) template = TextFile (self.template, *************** *** 375,390 **** if action == 'include': ! print "include", string.join(pattern_list) for pattern in pattern_list: ! files = select_pattern (all_files, pattern, anchor=1) if not files: ! template.warn ("no files found matching '%s'" % pattern) else: self.files.extend (files) elif action == 'exclude': ! print "exclude", string.join(pattern_list) for pattern in pattern_list: ! num = exclude_pattern (self.files, pattern, anchor=1) if num == 0: template.warn ( --- 377,393 ---- if action == 'include': ! self.debug_print("include " + string.join(pattern_list)) for pattern in pattern_list: ! files = self.select_pattern (all_files, pattern, anchor=1) if not files: ! template.warn ("no files found matching '%s'" % ! pattern) else: self.files.extend (files) elif action == 'exclude': ! self.debug_print("exclude " + string.join(pattern_list)) for pattern in pattern_list: ! num = self.exclude_pattern (self.files, pattern, anchor=1) if num == 0: template.warn ( *************** *** 393,399 **** elif action == 'global-include': ! print "global-include", string.join(pattern_list) for pattern in pattern_list: ! files = select_pattern (all_files, pattern, anchor=0) if not files: template.warn (("no files found matching '%s' " + --- 396,402 ---- elif action == 'global-include': ! self.debug_print("global-include " + string.join(pattern_list)) for pattern in pattern_list: ! files = self.select_pattern (all_files, pattern, anchor=0) if not files: template.warn (("no files found matching '%s' " + *************** *** 404,410 **** elif action == 'global-exclude': ! print "global-exclude", string.join(pattern_list) for pattern in pattern_list: ! num = exclude_pattern (self.files, pattern, anchor=0) if num == 0: template.warn \ --- 407,413 ---- elif action == 'global-exclude': ! self.debug_print("global-exclude " + string.join(pattern_list)) for pattern in pattern_list: ! num = self.exclude_pattern (self.files, pattern, anchor=0) if num == 0: template.warn \ *************** *** 414,420 **** elif action == 'recursive-include': ! print "recursive-include", dir, string.join(pattern_list) for pattern in pattern_list: ! files = select_pattern (all_files, pattern, prefix=dir) if not files: template.warn (("no files found matching '%s' " + --- 417,425 ---- elif action == 'recursive-include': ! self.debug_print("recursive-include %s %s" % ! (dir, string.join(pattern_list))) for pattern in pattern_list: ! files = self.select_pattern ( ! all_files, pattern, prefix=dir) if not files: template.warn (("no files found matching '%s' " + *************** *** 425,431 **** elif action == 'recursive-exclude': ! print "recursive-exclude", dir, string.join(pattern_list) for pattern in pattern_list: ! num = exclude_pattern (self.files, pattern, prefix=dir) if num == 0: template.warn \ --- 430,438 ---- elif action == 'recursive-exclude': ! self.debug_print("recursive-exclude %s %s" % ! (dir, string.join(pattern_list))) for pattern in pattern_list: ! num = self.exclude_pattern( ! self.files, pattern, prefix=dir) if num == 0: template.warn \ *************** *** 435,440 **** elif action == 'graft': ! print "graft", dir_pattern ! files = select_pattern (all_files, None, prefix=dir_pattern) if not files: template.warn ("no directories found matching '%s'" % --- 442,448 ---- elif action == 'graft': ! self.debug_print("graft " + dir_pattern) ! files = self.select_pattern( ! all_files, None, prefix=dir_pattern) if not files: template.warn ("no directories found matching '%s'" % *************** *** 444,449 **** elif action == 'prune': ! print "prune", dir_pattern ! num = exclude_pattern (self.files, None, prefix=dir_pattern) if num == 0: template.warn \ --- 452,458 ---- elif action == 'prune': ! self.debug_print("prune " + dir_pattern) ! num = self.exclude_pattern( ! self.files, None, prefix=dir_pattern) if num == 0: template.warn \ *************** *** 459,470 **** # Prune away the build and source distribution directories build = self.get_finalized_command ('build') ! exclude_pattern (self.files, None, prefix=build.build_base) base_dir = self.distribution.get_fullname() ! exclude_pattern (self.files, None, prefix=base_dir) # read_template () def write_manifest (self): """Write the file list in 'self.files' (presumably as filled in --- 468,528 ---- # Prune away the build and source distribution directories build = self.get_finalized_command ('build') ! self.exclude_pattern (self.files, None, prefix=build.build_base) base_dir = self.distribution.get_fullname() ! self.exclude_pattern (self.files, None, prefix=base_dir) # read_template () + def select_pattern (self, files, pattern, anchor=1, prefix=None): + """Select strings (presumably filenames) from 'files' that match + 'pattern', a Unix-style wildcard (glob) pattern. Patterns are not + quite the same as implemented by the 'fnmatch' module: '*' and '?' + match non-special characters, where "special" is platform-dependent: + slash on Unix, colon, slash, and backslash on DOS/Windows, and colon on + Mac OS. + + If 'anchor' is true (the default), then the pattern match is more + stringent: "*.py" will match "foo.py" but not "foo/bar.py". If + 'anchor' is false, both of these will match. + + If 'prefix' is supplied, then only filenames starting with 'prefix' + (itself a pattern) and ending with 'pattern', with anything in between + them, will match. 'anchor' is ignored in this case. + + Return the list of matching strings, possibly empty. + """ + matches = [] + pattern_re = translate_pattern (pattern, anchor, prefix) + self.debug_print("select_pattern: applying regex r'%s'" % + pattern_re.pattern) + for name in files: + if pattern_re.search (name): + matches.append (name) + self.debug_print(" adding " + name) + + return matches + + # select_pattern () + + + def exclude_pattern (self, files, pattern, anchor=1, prefix=None): + """Remove strings (presumably filenames) from 'files' that match + 'pattern'. 'pattern', 'anchor', 'and 'prefix' are the same + as for 'select_pattern()', above. The list 'files' is modified + in place. + """ + pattern_re = translate_pattern (pattern, anchor, prefix) + self.debug_print("exclude_pattern: applying regex r'%s'" % + pattern_re.pattern) + for i in range (len(files)-1, -1, -1): + if pattern_re.search (files[i]): + self.debug_print(" removing " + files[i]) + del files[i] + + # exclude_pattern () + + def write_manifest (self): """Write the file list in 'self.files' (presumably as filled in *************** *** 474,478 **** self.execute(write_file, (self.manifest, self.files), ! "writing manifest file") # write_manifest () --- 532,536 ---- self.execute(write_file, (self.manifest, self.files), ! "writing manifest file '%s'" % self.manifest) # write_manifest () *************** *** 484,487 **** --- 542,546 ---- in the source distribution.""" + self.announce("reading manifest file '%s'" % self.manifest) manifest = open (self.manifest) while 1: *************** *** 496,500 **** - def make_release_tree (self, base_dir, files): --- 555,558 ---- *************** *** 534,538 **** # Remove any files that match "base_dir" from the fileset -- we # don't want to go distributing the distribution inside itself! ! self.exclude_pattern (base_dir + "*") self.make_release_tree (base_dir, self.files) --- 592,596 ---- # Remove any files that match "base_dir" from the fileset -- we # don't want to go distributing the distribution inside itself! ! self.exclude_pattern (self.files, base_dir + "*") self.make_release_tree (base_dir, self.files) *************** *** 582,628 **** return list - - - def select_pattern (files, pattern, anchor=1, prefix=None): - """Select strings (presumably filenames) from 'files' that match - 'pattern', a Unix-style wildcard (glob) pattern. Patterns are not - quite the same as implemented by the 'fnmatch' module: '*' and '?' - match non-special characters, where "special" is platform-dependent: - slash on Unix, colon, slash, and backslash on DOS/Windows, and colon - on Mac OS. - - If 'anchor' is true (the default), then the pattern match is more - stringent: "*.py" will match "foo.py" but not "foo/bar.py". If - 'anchor' is false, both of these will match. - - If 'prefix' is supplied, then only filenames starting with 'prefix' - (itself a pattern) and ending with 'pattern', with anything in - between them, will match. 'anchor' is ignored in this case. - - Return the list of matching strings, possibly empty.""" - - matches = [] - pattern_re = translate_pattern (pattern, anchor, prefix) - print "select_pattern: applying re %s" % pattern_re.pattern - for name in files: - if pattern_re.search (name): - matches.append (name) - print " adding", name - - return matches - - # select_pattern () - - - def exclude_pattern (files, pattern, anchor=1, prefix=None): - - pattern_re = translate_pattern (pattern, anchor, prefix) - print "exclude_pattern: applying re %s" % pattern_re.pattern - for i in range (len(files)-1, -1, -1): - if pattern_re.search (files[i]): - print " removing", files[i] - del files[i] - - # exclude_pattern () --- 640,643 ---- From python-dev@python.org Thu Jun 8 01:14:20 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 7 Jun 2000 17:14:20 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command sdist.py,1.26,1.27 Message-ID: <200006080014.RAA16266@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv16257 Modified Files: sdist.py Log Message: Cosmetic tweaks to imports, the 'show_formats()' function, and the 'help_options' list; also added an editorial comment. Index: sdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/sdist.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -r1.26 -r1.27 *** sdist.py 2000/06/08 00:08:14 1.26 --- sdist.py 2000/06/08 00:14:18 1.27 *************** *** 5,9 **** # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.26 2000/06/08 00:08:14 gward Exp $" import sys, os, string, re --- 5,9 ---- # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.27 2000/06/08 00:14:18 gward Exp $" import sys, os, string, re *************** *** 12,18 **** from glob import glob from distutils.core import Command ! from distutils.util import newer, create_tree, remove_tree, convert_path, \ ! write_file ! from distutils.archive_util import check_archive_formats,ARCHIVE_FORMATS from distutils.text_file import TextFile from distutils.errors import DistutilsExecError, DistutilsOptionError --- 12,18 ---- from glob import glob from distutils.core import Command ! from distutils.util import \ ! convert_path, create_tree, remove_tree, newer, write_file, \ ! check_archive_formats, ARCHIVE_FORMATS from distutils.text_file import TextFile from distutils.errors import DistutilsExecError, DistutilsOptionError *************** *** 41,57 **** "archive file(s)"), ] ! # prints all possible arguments to --formats ! def show_formats(): from distutils.fancy_getopt import FancyGetopt ! list_of_formats=[] for format in ARCHIVE_FORMATS.keys(): ! list_of_formats.append(("formats="+format,None,ARCHIVE_FORMATS[format][2])) ! list_of_formats.sort() ! pretty_printer=FancyGetopt(list_of_formats) ! pretty_printer.print_help("List of available distribution formats:") help_options = [ ('help-formats', None, ! "lists available distribution formats",show_formats), ] --- 41,65 ---- "archive file(s)"), ] ! ! ! # XXX ugh: this has to precede the 'help_options' list, because ! # it is mentioned there -- also, this is not a method, even though ! # it's defined in a class: double-ugh! ! def show_formats (): ! """Print all possible values for the 'formats' option -- used by ! the "--help-formats" command-line option. ! """ from distutils.fancy_getopt import FancyGetopt ! formats=[] for format in ARCHIVE_FORMATS.keys(): ! formats.append(("formats="+format,None,ARCHIVE_FORMATS[format][2])) ! formats.sort() ! pretty_printer = FancyGetopt(formats) ! pretty_printer.print_help( ! "List of available source distribution formats:") help_options = [ ('help-formats', None, ! "lists available distribution formats", show_formats), ] From python-dev@python.org Thu Jun 8 01:24:03 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 7 Jun 2000 17:24:03 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command sdist.py,1.27,1.28 Message-ID: <200006080024.RAA16692@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv16683 Modified Files: sdist.py Log Message: Docstring reformatting binge. Index: sdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/sdist.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -r1.27 -r1.28 *** sdist.py 2000/06/08 00:14:18 1.27 --- sdist.py 2000/06/08 00:24:01 1.28 *************** *** 5,9 **** # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.27 2000/06/08 00:14:18 gward Exp $" import sys, os, string, re --- 5,9 ---- # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.28 2000/06/08 00:24:01 gward Exp $" import sys, os, string, re *************** *** 69,75 **** 'nt': 'zip' } - exclude_re = re.compile (r'\s*!\s*(\S+)') # for manifest lines - def initialize_options (self): # 'template' and 'manifest' are, respectively, the names of --- 69,73 ---- *************** *** 166,176 **** def get_file_list (self): """Figure out the list of files to include in the source ! distribution, and put it in 'self.files'. This might ! involve reading the manifest template (and writing the ! manifest), or just reading the manifest, or just using ! the default file set -- it all depends on the user's ! options and the state of the filesystem.""" ! ! template_exists = os.path.isfile (self.template) if template_exists: --- 164,172 ---- def get_file_list (self): """Figure out the list of files to include in the source ! distribution, and put it in 'self.files'. This might involve ! reading the manifest template (and writing the manifest), or just ! reading the manifest, or just using the default file set -- it all ! depends on the user's options and the state of the filesystem. ! """ template_exists = os.path.isfile (self.template) if template_exists: *************** *** 262,269 **** def search_dir (self, dir, pattern=None): """Recursively find files under 'dir' matching 'pattern' (a string ! containing a Unix-style glob pattern). If 'pattern' is None, ! find all files under 'dir'. Return the list of found ! filenames.""" ! allfiles = findall (dir) if pattern is None: --- 258,264 ---- def search_dir (self, dir, pattern=None): """Recursively find files under 'dir' matching 'pattern' (a string ! containing a Unix-style glob pattern). If 'pattern' is None, find ! all files under 'dir'. Return the list of found filenames. ! """ allfiles = findall (dir) if pattern is None: *************** *** 292,298 **** def recursive_exclude_pattern (self, dir, pattern=None): ! """Remove filenames from 'self.files' that are under 'dir' ! and whose basenames match 'pattern'.""" ! self.debug_print("recursive_exclude_pattern: dir=%s, pattern=%s" % (dir, pattern)) --- 287,293 ---- def recursive_exclude_pattern (self, dir, pattern=None): ! """Remove filenames from 'self.files' that are under 'dir' and ! whose basenames match 'pattern'. ! """ self.debug_print("recursive_exclude_pattern: dir=%s, pattern=%s" % (dir, pattern)) *************** *** 312,319 **** def read_template (self): """Read and parse the manifest template file named by ! 'self.template' (usually "MANIFEST.in"). Process all file ! specifications (include and exclude) in the manifest template ! and add the resulting filenames to 'self.files'.""" ! assert self.files is not None and type (self.files) is ListType self.announce("reading manifest template '%s'" % self.template) --- 307,314 ---- def read_template (self): """Read and parse the manifest template file named by ! 'self.template' (usually "MANIFEST.in"). Process all file ! specifications (include and exclude) in the manifest template and ! add the resulting filenames to 'self.files'. ! """ assert self.files is not None and type (self.files) is ListType self.announce("reading manifest template '%s'" % self.template) *************** *** 534,541 **** def write_manifest (self): ! """Write the file list in 'self.files' (presumably as filled in ! by 'find_defaults()' and 'read_template()') to the manifest file ! named by 'self.manifest'.""" ! self.execute(write_file, (self.manifest, self.files), --- 529,536 ---- def write_manifest (self): ! """Write the file list in 'self.files' (presumably as filled in by ! 'find_defaults()' and 'read_template()') to the manifest file named ! by 'self.manifest'. ! """ self.execute(write_file, (self.manifest, self.files), *************** *** 546,553 **** def read_manifest (self): ! """Read the manifest file (named by 'self.manifest') and use ! it to fill in 'self.files', the list of files to include ! in the source distribution.""" ! self.announce("reading manifest file '%s'" % self.manifest) manifest = open (self.manifest) --- 541,548 ---- def read_manifest (self): ! """Read the manifest file (named by 'self.manifest') and use it to ! fill in 'self.files', the list of files to include in the source ! distribution. ! """ self.announce("reading manifest file '%s'" % self.manifest) manifest = open (self.manifest) From python-dev@python.org Thu Jun 8 01:35:35 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 7 Jun 2000 17:35:35 -0700 Subject: [Python-checkins] CVS: distutils/distutils fancy_getopt.py,1.13,1.14 Message-ID: <200006080035.RAA17196@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv17185 Modified Files: fancy_getopt.py Log Message: Fixed so we print more than just the first line of help for options with a short form and text that wraps onto multiple lines. Index: fancy_getopt.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/fancy_getopt.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** fancy_getopt.py 2000/05/23 03:53:10 1.13 --- fancy_getopt.py 2000/06/08 00:35:33 1.14 *************** *** 11,15 **** # created 1999/03/03, Greg Ward ! __revision__ = "$Id: fancy_getopt.py,v 1.13 2000/05/23 03:53:10 gward Exp $" import sys, string, re --- 11,15 ---- # created 1999/03/03, Greg Ward ! __revision__ = "$Id: fancy_getopt.py,v 1.14 2000/06/08 00:35:33 gward Exp $" import sys, string, re *************** *** 370,376 **** lines.append (" --%-*s " % (max_opt, long)) - for l in text[1:]: - lines.append (big_indent + l) - # Case 2: we have a short option, so we have to include it # just after the long option --- 370,373 ---- *************** *** 382,385 **** --- 379,385 ---- else: lines.append (" --%-*s" % opt_names) + + for l in text[1:]: + lines.append (big_indent + l) # for self.option_table From python-dev@python.org Thu Jun 8 01:46:48 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 7 Jun 2000 17:46:48 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command sdist.py,1.28,1.29 Message-ID: <200006080046.RAA17696@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv17687 Modified Files: sdist.py Log Message: Docstring addition binge. Index: sdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/sdist.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -r1.28 -r1.29 *** sdist.py 2000/06/08 00:24:01 1.28 --- sdist.py 2000/06/08 00:46:45 1.29 *************** *** 5,9 **** # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.28 2000/06/08 00:24:01 gward Exp $" import sys, os, string, re --- 5,9 ---- # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.29 2000/06/08 00:46:45 gward Exp $" import sys, os, string, re *************** *** 32,36 **** "[default; disable with --no-defaults]"), ('manifest-only', 'o', ! "just regenerate the manifest and then stop"), ('force-manifest', 'f', "forcibly regenerate the manifest and carry on as usual"), --- 32,37 ---- "[default; disable with --no-defaults]"), ('manifest-only', 'o', ! "just regenerate the manifest and then stop " ! "(implies --force-manifest)"), ('force-manifest', 'f', "forcibly regenerate the manifest and carry on as usual"), *************** *** 134,138 **** def check_metadata (self): ! metadata = self.distribution.metadata --- 135,143 ---- def check_metadata (self): ! """Ensure that all required elements of meta-data (name, version, ! URL, (author and author_email) or (maintainer and ! maintainer_email)) are supplied by the Distribution object; warn if ! any are missing. ! """ metadata = self.distribution.metadata *************** *** 216,220 **** def find_defaults (self): ! standards = [('README', 'README.txt'), 'setup.py'] for fn in standards: --- 221,234 ---- def find_defaults (self): ! """Add all the default files to self.files: ! - README or README.txt ! - setup.py ! - test/test*.py ! - all pure Python modules mentioned in setup script ! - all C sources listed as part of extensions or C libraries ! in the setup script (doesn't catch C headers!) ! Warns if (README or README.txt) or setup.py are missing; everything ! else is optional. ! """ standards = [('README', 'README.txt'), 'setup.py'] for fn in standards: *************** *** 309,313 **** 'self.template' (usually "MANIFEST.in"). Process all file specifications (include and exclude) in the manifest template and ! add the resulting filenames to 'self.files'. """ assert self.files is not None and type (self.files) is ListType --- 323,328 ---- 'self.template' (usually "MANIFEST.in"). Process all file specifications (include and exclude) in the manifest template and ! update 'self.files' accordingly (filenames may be added to ! or removed from 'self.files' based on the manifest template). """ assert self.files is not None and type (self.files) is ListType *************** *** 559,563 **** def make_release_tree (self, base_dir, files): ! # Create all the directories under 'base_dir' necessary to # put 'files' there. --- 574,585 ---- def make_release_tree (self, base_dir, files): ! """Create the directory tree that will become the source ! distribution archive. All directories implied by the filenames in ! 'files' are created under 'base_dir', and then we hard link or copy ! (if hard linking is unavailable) those files into place. ! Essentially, this duplicates the developer's source tree, but in a ! directory named after the distribution, containing only the files ! to be distributed. ! """ # Create all the directories under 'base_dir' necessary to # put 'files' there. *************** *** 588,592 **** def make_distribution (self): ! # Don't warn about missing meta-data here -- should be (and is!) # done elsewhere. --- 610,620 ---- def make_distribution (self): ! """Create the source distribution(s). First, we create the release ! tree with 'make_release_tree()'; then, we create all required ! archive files (according to 'self.formats') from the release tree. ! Finally, we clean up by blowing away the release tree (unless ! 'self.keep_tree' is true). The list of archive files created is ! stored so it can be retrieved later by 'get_archive_files()'. ! """ # Don't warn about missing meta-data here -- should be (and is!) # done elsewhere. *************** *** 621,627 **** def findall (dir = os.curdir): ! """Find all files under 'dir' and return the list of full ! filenames (relative to 'dir').""" ! list = [] stack = [dir] --- 649,655 ---- def findall (dir = os.curdir): ! """Find all files under 'dir' and return the list of full filenames ! (relative to 'dir'). ! """ list = [] stack = [dir] *************** *** 646,653 **** def glob_to_re (pattern): ! """Translate a shell-like glob pattern to a regular expression; ! return a string containing the regex. Differs from ! 'fnmatch.translate()' in that '*' does not match "special ! characters" (which are platform-specific).""" pattern_re = fnmatch.translate (pattern) --- 674,682 ---- def glob_to_re (pattern): ! """Translate a shell-like glob pattern to a regular expression; return ! a string containing the regex. Differs from 'fnmatch.translate()' in ! that '*' does not match "special characters" (which are ! platform-specific). ! """ pattern_re = fnmatch.translate (pattern) *************** *** 667,672 **** def translate_pattern (pattern, anchor=1, prefix=None): """Translate a shell-like wildcard pattern to a compiled regular ! expression. Return the compiled regex.""" ! if pattern: pattern_re = glob_to_re (pattern) --- 696,701 ---- def translate_pattern (pattern, anchor=1, prefix=None): """Translate a shell-like wildcard pattern to a compiled regular ! expression. Return the compiled regex. ! """ if pattern: pattern_re = glob_to_re (pattern) From python-dev@python.org Thu Jun 8 01:52:55 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 7 Jun 2000 17:52:55 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command sdist.py,1.29,1.30 Message-ID: <200006080052.RAA17913@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv17904 Modified Files: sdist.py Log Message: Renamed 'find_defaults()' to 'add_defaults()'. Deleted old, commented-out 'exclude_pattern()' method. Index: sdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/sdist.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -r1.29 -r1.30 *** sdist.py 2000/06/08 00:46:45 1.29 --- sdist.py 2000/06/08 00:52:52 1.30 *************** *** 5,9 **** # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.29 2000/06/08 00:46:45 gward Exp $" import sys, os, string, re --- 5,9 ---- # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.30 2000/06/08 00:52:52 gward Exp $" import sys, os, string, re *************** *** 190,194 **** # Add default file set to 'files' if self.use_defaults: ! self.find_defaults () # Read manifest template if it exists --- 190,194 ---- # Add default file set to 'files' if self.use_defaults: ! self.add_defaults () # Read manifest template if it exists *************** *** 220,224 **** ! def find_defaults (self): """Add all the default files to self.files: - README or README.txt --- 220,224 ---- ! def add_defaults (self): """Add all the default files to self.files: - README or README.txt *************** *** 269,272 **** --- 269,274 ---- self.files.extend (build_clib.get_source_files ()) + # add_defaults () + def search_dir (self, dir, pattern=None): *************** *** 290,303 **** - # def exclude_pattern (self, pattern): - # """Remove filenames from 'self.files' that match 'pattern'.""" - # self.debug_print("exclude_pattern: pattern=%s" % pattern) - # pattern_re = translate_pattern (pattern) - # for i in range (len (self.files)-1, -1, -1): - # if pattern_re.match (self.files[i]): - # self.debug_print("removing %s" % self.files[i]) - # del self.files[i] - - def recursive_exclude_pattern (self, dir, pattern=None): """Remove filenames from 'self.files' that are under 'dir' and --- 292,295 ---- *************** *** 545,549 **** def write_manifest (self): """Write the file list in 'self.files' (presumably as filled in by ! 'find_defaults()' and 'read_template()') to the manifest file named by 'self.manifest'. """ --- 537,541 ---- def write_manifest (self): """Write the file list in 'self.files' (presumably as filled in by ! 'add_defaults()' and 'read_template()') to the manifest file named by 'self.manifest'. """ From python-dev@python.org Thu Jun 8 02:06:05 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 7 Jun 2000 18:06:05 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command sdist.py,1.30,1.31 Message-ID: <200006080106.SAA24066@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv23972 Modified Files: sdist.py Log Message: Moved the code that prunes the file list after reading the manifest template into a new method 'prune_file_list()', called from 'get_file_list()' rather than 'read_manifest()' -- this keeps 'read_manifest()' more general. Deleted the redundant call to 'exclude_pattern()' in 'make_distribution()' -- this had the same intention as 'prune_file_list()', but was incomplete (only pruned the release tree, not the build tree) and in the wrong place (the prune wouldn't be reflected in the manifest file). Index: sdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/sdist.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -r1.30 -r1.31 *** sdist.py 2000/06/08 00:52:52 1.30 --- sdist.py 2000/06/08 01:06:02 1.31 *************** *** 5,9 **** # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.30 2000/06/08 00:52:52 gward Exp $" import sys, os, string, re --- 5,9 ---- # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.31 2000/06/08 01:06:02 gward Exp $" import sys, os, string, re *************** *** 196,199 **** --- 196,202 ---- self.read_template () + # Prune away the build and source distribution directories + self.prune_file_list() + # File list now complete -- sort it so that higher-level files # come first *************** *** 476,488 **** # while loop over lines of template file ! # Prune away the build and source distribution directories ! build = self.get_finalized_command ('build') ! self.exclude_pattern (self.files, None, prefix=build.build_base) base_dir = self.distribution.get_fullname() self.exclude_pattern (self.files, None, prefix=base_dir) - # read_template () - def select_pattern (self, files, pattern, anchor=1, prefix=None): --- 479,497 ---- # while loop over lines of template file ! # read_template () ! + def prune_file_list (self): + """Prune off branches that might slip into the file list as created + by 'read_template()', but really don't belong there: specifically, + the build tree (typically "build") and the release tree itself + (only an issue if we ran "sdist" previously with --keep-tree, or it + aborted). + """ + build = self.get_finalized_command('build') base_dir = self.distribution.get_fullname() + self.exclude_pattern (self.files, None, prefix=build.build_base) self.exclude_pattern (self.files, None, prefix=base_dir) def select_pattern (self, files, pattern, anchor=1, prefix=None): *************** *** 613,620 **** base_dir = self.distribution.get_fullname() - # Remove any files that match "base_dir" from the fileset -- we - # don't want to go distributing the distribution inside itself! - self.exclude_pattern (self.files, base_dir + "*") - self.make_release_tree (base_dir, self.files) archive_files = [] # remember names of files we create --- 622,625 ---- From python-dev@python.org Thu Jun 8 02:17:35 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 7 Jun 2000 18:17:35 -0700 Subject: [Python-checkins] CVS: distutils MINIFEST.in,NONE,1.1 Message-ID: <200006080117.SAA24669@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv24661 Added Files: MINIFEST.in Log Message: Specialized manifest template for generating code snapshots: includes just the code and example setup scripts, no documentation or tests. From python-dev@python.org Thu Jun 8 02:18:38 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 7 Jun 2000 18:18:38 -0700 Subject: [Python-checkins] CVS: distutils snapshot_setup.py,NONE,1.1 Message-ID: <200006080118.SAA24789@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv24781 Added Files: snapshot_setup.py Log Message: Specialized setup script for generating code snapshots: uses current date instead of a version number, and ensures that the "sdist" command (which is all we really use this setup script for) reads/writes MINIFEST.in and MINIFEST instead of the usual MANIFEST.in/MANIFEST. From python-dev@python.org Thu Jun 8 02:19:20 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 7 Jun 2000 18:19:20 -0700 Subject: [Python-checkins] CVS: distutils mksnap,1.5,1.6 Message-ID: <200006080119.SAA24815@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv24804 Modified Files: mksnap Log Message: Blew away the old Perl script for generating code snapshots; now it's a trivial shell script thanks to the new specialized setup script and manifest template. Index: mksnap =================================================================== RCS file: /cvsroot/python/distutils/mksnap,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** mksnap 2000/06/04 13:45:25 1.5 --- mksnap 2000/06/08 01:19:18 1.6 *************** *** 1,45 **** ! #!/usr/local/bin/perl -w ! ! # ! # mksnap ! # ! # make a Distutils snapshot -- should go away once we have a 'dist' ! # command! ! # ! # $Id: mksnap,v 1.5 2000/06/04 13:45:25 gward Exp $ ! # ! ! use strict; ! use File::Find; ! use File::Copy ('move'); ! use POSIX ('strftime'); ! ! #my $tar = '/depot/gnu/plat/bin/gnutar'; # MUST be gnutar! ! my $tar = '/bin/tar'; ! die "don't know where to find gnutar" unless -x $tar; ! ! # gather up all filenames in the source directories (distutils, test, ...?) ! my @files; ! sub finder ! { ! $File::Find::prune = 1, return if /^(build|dd|www|CVS)$/; ! push @files, $File::Find::name if /.py$/; ! } ! ! chdir ".."; ! find (\&finder, 'distutils'); ! ! # and make a "snapshot" tarball named after today's date ! my $datestamp = strftime ('%Y%m%d', localtime time); ! my $snapname = "distutils-$datestamp.tar.gz"; ! print "creating $snapname\n"; ! open (TAR, "|$tar -cz -T - -f $snapname") ! || die "couldn't open pipe to $tar: $!\n"; ! print TAR join ("\n", @files) . "\n"; ! close (TAR); ! die "$tar failed" unless $? == 0; ! ! # and move the snapshot into the distutils web directory ! print "moving $snapname\n"; ! move ($snapname, "distutils/www/download") ! || die "couldn't move $snapname to distutils/www: $!\n"; --- 1,3 ---- ! #!/bin/sh ! ./snapshot_setup.py sdist ! mv distutils-*.{tar,zip}* www/download From python-dev@python.org Thu Jun 8 02:20:25 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 7 Jun 2000 18:20:25 -0700 Subject: [Python-checkins] CVS: distutils MANIFEST.in,1.6,1.7 Message-ID: <200006080120.SAA24940@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv24931 Modified Files: MANIFEST.in Log Message: 'examples/sample*' instead of 'examples/sample?' (the number of samples is growing...). Index: MANIFEST.in =================================================================== RCS file: /cvsroot/python/distutils/MANIFEST.in,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** MANIFEST.in 2000/06/02 02:22:16 1.6 --- MANIFEST.in 2000/06/08 01:20:23 1.7 *************** *** 6,10 **** # created 2000/02/14, Greg Ward # ! # $Id: MANIFEST.in,v 1.6 2000/06/02 02:22:16 gward Exp $ # --- 6,10 ---- # created 2000/02/14, Greg Ward # ! # $Id: MANIFEST.in,v 1.7 2000/06/08 01:20:23 gward Exp $ # *************** *** 12,15 **** include MANIFEST.in recursive-include examples *.txt *.py ! prune examples/sample?/build recursive-include doc *.sty *.tex --- 12,15 ---- include MANIFEST.in recursive-include examples *.txt *.py ! prune examples/sample*/build recursive-include doc *.sty *.tex From python-dev@python.org Thu Jun 8 02:21:34 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 7 Jun 2000 18:21:34 -0700 Subject: [Python-checkins] CVS: distutils setup.cfg,1.1,1.2 Message-ID: <200006080121.SAA24998@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv24989 Modified Files: setup.cfg Log Message: Changelog/release Update from Harry Gebel (slipped by when checking in his latest patch, I think). Index: setup.cfg =================================================================== RCS file: /cvsroot/python/distutils/setup.cfg,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** setup.cfg 2000/06/02 02:07:43 1.1 --- setup.cfg 2000/06/08 01:21:31 1.2 *************** *** 13,17 **** # created 2000/05/31, Greg Ward # ! # $Id: setup.cfg,v 1.1 2000/06/02 02:07:43 gward Exp $ # --- 13,17 ---- # created 2000/05/31, Greg Ward # ! # $Id: setup.cfg,v 1.2 2000/06/08 01:21:31 gward Exp $ # *************** *** 20,24 **** [bdist_rpm] ! release = 3 packager = Harry Henry Gebel doc_files = CHANGES.txt --- 20,24 ---- [bdist_rpm] ! release = 1 packager = Harry Henry Gebel doc_files = CHANGES.txt *************** *** 29,32 **** --- 29,36 ---- changelog = + * Sun Jun 04 2000 Harry Henry Gebel 0.9pre-1 + - Made sure scripts are file names, filled in some help strings, formatted + changelog correctly + * Wed May 31 2000 Greg Ward 0.8.3pre-1 - Hacked up bdist_rpm.py, moved meta-data into setup.cfg From python-dev@python.org Thu Jun 8 02:22:51 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 7 Jun 2000 18:22:51 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command sdist.py,1.31,1.32 Message-ID: <200006080122.SAA25099@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv25088 Modified Files: sdist.py Log Message: Include setup.cfg in the list of default files to distribute. Index: sdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/sdist.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -r1.31 -r1.32 *** sdist.py 2000/06/08 01:06:02 1.31 --- sdist.py 2000/06/08 01:22:48 1.32 *************** *** 5,9 **** # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.31 2000/06/08 01:06:02 gward Exp $" import sys, os, string, re --- 5,9 ---- # created 1999/09/22, Greg Ward ! __revision__ = "$Id: sdist.py,v 1.32 2000/06/08 01:22:48 gward Exp $" import sys, os, string, re *************** *** 234,237 **** --- 234,241 ---- else is optional. """ + + # XXX name of setup script and config file should be taken + # programmatically from the Distribution object (except + # it doesn't have that capability... yet!) standards = [('README', 'README.txt'), 'setup.py'] for fn in standards: *************** *** 254,258 **** self.warn ("standard file '%s' not found" % fn) ! optional = ['test/test*.py'] for pattern in optional: files = filter (os.path.isfile, glob (pattern)) --- 258,262 ---- self.warn ("standard file '%s' not found" % fn) ! optional = ['test/test*.py', 'setup.cfg'] for pattern in optional: files = filter (os.path.isfile, glob (pattern)) From python-dev@python.org Thu Jun 8 15:21:26 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 8 Jun 2000 07:21:26 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist_rpm.py,1.12,1.13 Message-ID: <200006081421.HAA11116@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv11106 Modified Files: bdist_rpm.py Log Message: Harry Henry Gebel: fix '_format_changelog()' so it doesn't bomb if passed None. Index: bdist_rpm.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist_rpm.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** bdist_rpm.py 2000/06/04 15:30:35 1.12 --- bdist_rpm.py 2000/06/08 14:21:23 1.13 *************** *** 437,440 **** --- 437,442 ---- """Format the changelog correctly and convert it to a list of strings """ + if not changelog: + return changelog new_changelog = [] for line in string.split(string.strip(changelog), '\n'): From python-dev@python.org Thu Jun 8 18:49:43 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Thu, 8 Jun 2000 10:49:43 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib locale.py,1.5,1.6 Message-ID: <200006081749.KAA08366@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv8358/Lib Modified Files: locale.py Log Message: Marc-Andre Lemburg : Added emulations of the C APIs in _locale to be used when the _locale module is not enabled. They return the correct values assuming the 'C' locale. Index: locale.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/locale.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** locale.py 2000/06/07 09:11:40 1.5 --- locale.py 2000/06/08 17:49:41 1.6 *************** *** 14,20 **** import string ! ### C lib locale APIs ! from _locale import * ### Number formatting APIs --- 14,78 ---- import string ! ### Load C lib locale APIs or use an emulation ! try: ! from _locale import * ! ! except ImportError: ! ! CHAR_MAX = 127 ! LC_ALL = 6 ! LC_COLLATE = 3 ! LC_CTYPE = 0 ! LC_MESSAGES = 5 ! LC_MONETARY = 4 ! LC_NUMERIC = 1 ! LC_TIME = 2 ! Error = ValueError ! ! def localeconv(): ! """ localeconv() -> dict. ! Returns numeric and monetary locale-specific parameters. ! """ ! # 'C' locale default values ! return {'grouping': [127], ! 'currency_symbol': '', ! 'n_sign_posn': 127, ! 'p_cs_precedes': 127, ! 'n_cs_precedes': 127, ! 'mon_grouping': [], ! 'n_sep_by_space': 127, ! 'decimal_point': '.', ! 'negative_sign': '', ! 'positive_sign': '', ! 'p_sep_by_space': 127, ! 'int_curr_symbol': '', ! 'p_sign_posn': 127, ! 'thousands_sep': '', ! 'mon_thousands_sep': '', ! 'frac_digits': 127, ! 'mon_decimal_point': '', ! 'int_frac_digits': 127} ! ! def setlocale(category, value=None): ! """ setlocale(integer,string=None) -> string. ! Activates/queries locale processing. ! """ ! if value is not None and \ ! value is not 'C': ! raise Error,'_locale emulation only supports "C" locale' ! return 'C' ! ! def strcoll(a,b): ! """ strcoll(string,string) -> int. ! Compares two strings according to the locale. ! """ ! return cmp(a,b) ! ! def strxfrm(s): ! """ strxfrm(string) -> string. ! Returns a string that behaves for cmp locale-aware. ! """ ! return s ### Number formatting APIs From python-dev@python.org Thu Jun 8 18:50:57 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Thu, 8 Jun 2000 10:50:57 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_unicode.py,1.11,1.12 Message-ID: <200006081750.KAA08463@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv8451/Lib/test Modified Files: test_unicode.py Log Message: Marc-Andre Lemburg : Updated to the fix in %c formatting: it now always checks for a one character argument. Index: test_unicode.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** test_unicode.py 2000/05/09 19:57:46 1.11 --- test_unicode.py 2000/06/08 17:50:55 1.12 *************** *** 248,253 **** assert u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", -1, -2, 3.57) == u'abc, abc, -1, -2.000000, 3.57' assert u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", -1, -2, 1003.57) == u'abc, abc, -1, -2.000000, 1003.57' ! assert u"%c" % (u"abc",) == u'a' ! assert u"%c" % ("abc",) == u'a' assert u"%c" % (34,) == u'"' assert u"%c" % (36,) == u'$' --- 248,253 ---- assert u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", -1, -2, 3.57) == u'abc, abc, -1, -2.000000, 3.57' assert u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", -1, -2, 1003.57) == u'abc, abc, -1, -2.000000, 1003.57' ! assert u"%c" % (u"a",) == u'a' ! assert u"%c" % ("a",) == u'a' assert u"%c" % (34,) == u'"' assert u"%c" % (36,) == u'$' From python-dev@python.org Thu Jun 8 18:51:35 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Thu, 8 Jun 2000 10:51:35 -0700 Subject: [Python-checkins] CVS: python/dist/src/Misc unicode.txt,3.7,3.8 Message-ID: <200006081751.KAA08508@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Misc In directory slayer.i.sourceforge.net:/tmp/cvs-serv8496/Misc Modified Files: unicode.txt Log Message: Marc-Andre Lemburg : Updated to version 1.5. Includes typo fixes by Andrew Kuchling and a new section on the default encoding. Index: unicode.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/unicode.txt,v retrieving revision 3.7 retrieving revision 3.8 diff -C2 -r3.7 -r3.8 *** unicode.txt 2000/05/09 19:58:19 3.7 --- unicode.txt 2000/06/08 17:51:33 3.8 *************** *** 20,28 **** The latest version of this document is always available at: ! http://starship.skyport.net/~lemburg/unicode-proposal.txt Older versions are available as: ! http://starship.skyport.net/~lemburg/unicode-proposal-X.X.txt --- 20,28 ---- The latest version of this document is always available at: ! http://starship.python.net/~lemburg/unicode-proposal.txt Older versions are available as: ! http://starship.python.net/~lemburg/unicode-proposal-X.X.txt *************** *** 102,106 **** needed, but if you include Latin-1 characters not defined in ASCII, it may well be worthwhile including a hint since people in other ! countries will want to be able to read you source strings too. --- 102,106 ---- needed, but if you include Latin-1 characters not defined in ASCII, it may well be worthwhile including a hint since people in other ! countries will want to be able to read your source strings too. *************** *** 170,174 **** In containment tests ('a' in u'abc' and u'a' in 'abc') both sides ! should be coerced to Unicode before applying the test. Errors occuring during coercion (e.g. None in u'abc') should not be masked. --- 170,174 ---- In containment tests ('a' in u'abc' and u'a' in 'abc') both sides ! should be coerced to Unicode before applying the test. Errors occurring during coercion (e.g. None in u'abc') should not be masked. *************** *** 185,189 **** All string methods should delegate the call to an equivalent Unicode ! object method call by converting all envolved strings to Unicode and then applying the arguments to the Unicode method of the same name, e.g. --- 185,189 ---- All string methods should delegate the call to an equivalent Unicode ! object method call by converting all involved strings to Unicode and then applying the arguments to the Unicode method of the same name, e.g. *************** *** 200,204 **** ----------- ! UnicodeError is defined in the exceptions module as subclass of ValueError. It is available at the C level via PyExc_UnicodeError. All exceptions related to Unicode encoding/decoding should be --- 200,204 ---- ----------- ! UnicodeError is defined in the exceptions module as a subclass of ValueError. It is available at the C level via PyExc_UnicodeError. All exceptions related to Unicode encoding/decoding should be *************** *** 269,273 **** 'utf-8': 8-bit variable length encoding ! 'utf-16': 16-bit variable length encoding (litte/big endian) 'utf-16-le': utf-16 but explicitly little endian 'utf-16-be': utf-16 but explicitly big endian --- 269,273 ---- 'utf-8': 8-bit variable length encoding ! 'utf-16': 16-bit variable length encoding (little/big endian) 'utf-16-le': utf-16 but explicitly little endian 'utf-16-be': utf-16 but explicitly big endian *************** *** 285,289 **** All other encodings such as the CJK ones to support Asian scripts ! should be implemented in seperate packages which do not get included in the core Python distribution and are not a part of this proposal. --- 285,289 ---- All other encodings such as the CJK ones to support Asian scripts ! should be implemented in separate packages which do not get included in the core Python distribution and are not a part of this proposal. *************** *** 325,329 **** def encode(self,input,errors='strict'): ! """ Encodes the object intput and returns a tuple (output object, length consumed). --- 325,329 ---- def encode(self,input,errors='strict'): ! """ Encodes the object input and returns a tuple (output object, length consumed). *************** *** 332,336 **** The method may not store state in the Codec instance. Use ! SteamCodec for codecs which have to keep state in order to make encoding/decoding efficient. --- 332,336 ---- The method may not store state in the Codec instance. Use ! StreamCodec for codecs which have to keep state in order to make encoding/decoding efficient. *************** *** 351,355 **** The method may not store state in the Codec instance. Use ! SteamCodec for codecs which have to keep state in order to make encoding/decoding efficient. --- 351,355 ---- The method may not store state in the Codec instance. Use ! StreamCodec for codecs which have to keep state in order to make encoding/decoding efficient. *************** *** 491,495 **** .readline() method -- there is currently no support for line breaking using the codec decoder due to lack of line ! buffering. Sublcasses should however, if possible, try to implement this method using their own knowledge of line breaking. --- 491,495 ---- .readline() method -- there is currently no support for line breaking using the codec decoder due to lack of line ! buffering. Subclasses should however, if possible, try to implement this method using their own knowledge of line breaking. *************** *** 528,532 **** Note that no stream repositioning should take place. ! This method is primarely intended to be able to recover from decoding errors. --- 528,532 ---- Note that no stream repositioning should take place. ! This method is primarily intended to be able to recover from decoding errors. *************** *** 554,558 **** It is not required by the Unicode implementation to use these base classes, only the interfaces must match; this allows writing Codecs as ! extensions types. As guideline, large mapping tables should be implemented using static --- 554,558 ---- It is not required by the Unicode implementation to use these base classes, only the interfaces must match; this allows writing Codecs as ! extension types. As guideline, large mapping tables should be implemented using static *************** *** 629,634 **** Support for these is left to user land Codecs and not explicitly ! intergrated into the core. Note that due to the Internal Format being ! implemented, only the area between \uE000 and \uF8FF is useable for private encodings. --- 629,634 ---- Support for these is left to user land Codecs and not explicitly ! integrated into the core. Note that due to the Internal Format being ! implemented, only the area between \uE000 and \uF8FF is usable for private encodings. *************** *** 650,654 **** It is the Codec's responsibility to ensure that the data they pass to ! the Unicode object constructor repects this assumption. The constructor does not check the data for Unicode compliance or use of surrogates. --- 650,654 ---- It is the Codec's responsibility to ensure that the data they pass to ! the Unicode object constructor respects this assumption. The constructor does not check the data for Unicode compliance or use of surrogates. *************** *** 657,661 **** set of all UTF-16 addressable characters (around 1M characters). ! The Unicode API should provide inteface routines from to the compiler's wchar_t which can be 16 or 32 bit depending on the compiler/libc/platform being used. --- 657,661 ---- set of all UTF-16 addressable characters (around 1M characters). ! The Unicode API should provide interface routines from to the compiler's wchar_t which can be 16 or 32 bit depending on the compiler/libc/platform being used. From python-dev@python.org Thu Jun 8 18:54:03 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Thu, 8 Jun 2000 10:54:03 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.22,2.23 Message-ID: <200006081754.KAA08775@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv8762/Objects Modified Files: unicodeobject.c Log Message: Marc-Andre Lemburg : Fixed %c formatting to check for one character arguments. Thanks to Finn Bock for finding this bug. Added a fix for bug PR#348 which originated from not resetting the globals correctly in _PyUnicode_Fini(). Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.22 retrieving revision 2.23 diff -C2 -r2.22 -r2.23 *** unicodeobject.c 2000/06/07 09:13:21 2.22 --- unicodeobject.c 2000/06/08 17:54:00 2.23 *************** *** 109,120 **** #endif ! /* --- Globals ------------------------------------------------------------ */ /* The empty Unicode object */ ! static PyUnicodeObject *unicode_empty = NULL; /* Free list for Unicode objects */ ! static PyUnicodeObject *unicode_freelist = NULL; ! static int unicode_freelist_size = 0; /* Default encoding to use and assume when NULL is passed as encoding --- 109,125 ---- #endif ! /* --- Globals ------------------------------------------------------------ + The globals are initialized by the _PyUnicode_Init() API and should + not be used before calling that API. + + */ + /* The empty Unicode object */ ! static PyUnicodeObject *unicode_empty; /* Free list for Unicode objects */ ! static PyUnicodeObject *unicode_freelist; ! static int unicode_freelist_size; /* Default encoding to use and assume when NULL is passed as encoding *************** *** 4263,4271 **** PyObject *v) { ! if (PyUnicode_Check(v)) buf[0] = PyUnicode_AS_UNICODE(v)[0]; ! else if (PyString_Check(v)) ! buf[0] = (Py_UNICODE) PyString_AS_STRING(v)[0]; else { --- 4268,4282 ---- PyObject *v) { ! if (PyUnicode_Check(v)) { ! if (PyUnicode_GET_SIZE(v) != 1) ! goto onError; buf[0] = PyUnicode_AS_UNICODE(v)[0]; + } ! else if (PyString_Check(v)) { ! if (PyString_GET_SIZE(v) != 1) ! goto onError; ! buf[0] = (Py_UNICODE)PyString_AS_STRING(v)[0]; ! } else { *************** *** 4274,4282 **** x = PyInt_AsLong(v); if (x == -1 && PyErr_Occurred()) ! return -1; buf[0] = (char) x; } buf[1] = '\0'; return 1; } --- 4285,4298 ---- x = PyInt_AsLong(v); if (x == -1 && PyErr_Occurred()) ! goto onError; buf[0] = (char) x; } buf[1] = '\0'; return 1; + + onError: + PyErr_SetString(PyExc_TypeError, + "%c requires int or char"); + return -1; } *************** *** 4710,4713 **** --- 4726,4731 ---- /* Init the implementation */ + unicode_freelist = NULL; + unicode_freelist_size = 0; unicode_empty = _PyUnicode_New(0); strcpy(unicode_default_encoding, "ascii"); *************** *** 4729,4732 **** --- 4747,4753 ---- PyObject_DEL(v); } + unicode_freelist = NULL; + unicode_freelist_size = 0; Py_XDECREF(unicode_empty); + unicode_empty = NULL; } From python-dev@python.org Fri Jun 9 07:01:50 2000 From: python-dev@python.org (Mark Hammond) Date: Thu, 8 Jun 2000 23:01:50 -0700 Subject: [Python-checkins] CVS: python/dist/src/PC winreg.c,1.2,1.3 Message-ID: <200006090601.XAA27098@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv26869 Modified Files: winreg.c Log Message: Cleanup a few docstrings. Index: winreg.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/winreg.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** winreg.c 2000/05/03 23:44:37 1.2 --- winreg.c 2000/06/09 06:01:47 1.3 *************** *** 89,93 **** "\n" "The return value is the handle of the opened key.\n" ! "If the function fails, an exception is raised."; static char CreateKey_doc[] = --- 89,93 ---- "\n" "The return value is the handle of the opened key.\n" ! "If the function fails, an EnvironmentError exception is raised."; static char CreateKey_doc[] = *************** *** 114,118 **** "\n" "If the method succeeds, the entire key, including all of its values,\n" ! "is removed. If the method fails, and exception is raised."; static char DeleteValue_doc[] = --- 114,118 ---- "\n" "If the method succeeds, the entire key, including all of its values,\n" ! "is removed. If the method fails, an EnvironmentError exception is raised."; static char DeleteValue_doc[] = *************** *** 129,134 **** "\n" "The function retrieves the name of one subkey each time it is called.\n" ! "It is typically called repeatedly until an exception is raised, indicating\n" ! "no more values are available.\n"; static char EnumValue_doc[] = --- 129,134 ---- "\n" "The function retrieves the name of one subkey each time it is called.\n" ! "It is typically called repeatedly until an EnvironmentError exception is\n" ! "raised, indicating no more values are available.\n"; static char EnumValue_doc[] = *************** *** 138,143 **** "\n" "The function retrieves the name of one subkey each time it is called.\n" ! "It is typically called repeatedly, until an exception is raised,\n" ! "indicating no more values.\n" "\n" "The result is a tuple of 3 items:\n" --- 138,143 ---- "\n" "The function retrieves the name of one subkey each time it is called.\n" ! "It is typically called repeatedly, until an EnvironmentError exception\n" ! "is raised, indicating no more values.\n" "\n" "The result is a tuple of 3 items:\n" *************** *** 161,165 **** static char LoadKey_doc[] = ! "RegLoadKey(key, sub_key, file_name) - Creates a subkey under the specified key.\n" "and stores registration information from a specified file into that subkey.\n" "\n" --- 161,165 ---- static char LoadKey_doc[] = ! "LoadKey(key, sub_key, file_name) - Creates a subkey under the specified key\n" "and stores registration information from a specified file into that subkey.\n" "\n" *************** *** 189,193 **** "\n" "The result is a new handle to the specified key\n" ! "If the function fails, an exception is raised.\n"; static char OpenKeyEx_doc[] = --- 189,193 ---- "\n" "The result is a new handle to the specified key\n" ! "If the function fails, an EnvironmentError exception is raised.\n"; static char OpenKeyEx_doc[] = *************** *** 209,213 **** "\n" "key is an already open key, or any one of the predefined HKEY_* constants.\n" ! "sub_key is a string that holds The name of the subkey with which the value\n" " is associated. If this parameter is None or empty, the function retrieves\n" " the value set by the SetValue() method for the key identified by key." --- 209,213 ---- "\n" "key is an already open key, or any one of the predefined HKEY_* constants.\n" ! "sub_key is a string that holds the name of the subkey with which the value\n" " is associated. If this parameter is None or empty, the function retrieves\n" " the value set by the SetValue() method for the key identified by key." *************** *** 269,274 **** " to environment variables (for example, %PATH%).\n" " REG_LINK -- A Unicode symbolic link.\n" ! " REG_MULTI_SZ -- An array of null-terminated strings, terminated by\n" ! " two null characters.\n" " REG_NONE -- No defined value type.\n" " REG_RESOURCE_LIST -- A device-driver resource list.\n" --- 269,275 ---- " to environment variables (for example, %PATH%).\n" " REG_LINK -- A Unicode symbolic link.\n" ! " REG_MULTI_SZ -- An sequence of null-terminated strings, terminated by\n" ! " two null characters. Note that Python handles this\n" ! " termination automatically.\n" " REG_NONE -- No defined value type.\n" " REG_RESOURCE_LIST -- A device-driver resource list.\n" *************** *** 291,295 **** "PyHKEY Object - A Python object, representing a win32 registry key.\n" "\n" ! "This object wraps a win32 HANDLE object, automatically closing it when\n" "the object is destroyed. To guarantee cleanup, you can call either\n" "the Close() method on the PyHKEY, or the CloseKey() method.\n" --- 292,296 ---- "PyHKEY Object - A Python object, representing a win32 registry key.\n" "\n" ! "This object wraps a Windows HKEY object, automatically closing it when\n" "the object is destroyed. To guarantee cleanup, you can call either\n" "the Close() method on the PyHKEY, or the CloseKey() method.\n" *************** *** 312,321 **** static char PyHKEY_Close_doc[] = ! "key.Close() - Closes the underlying Win32 handle.\n" "\n" "If the handle is already closed, no error is raised."; static char PyHKEY_Detach_doc[] = ! "int = key.Detach() - Detaches the Win32 handle from the handle object.\n" "\n" "The result is the value of the handle before it is detached. If the\n" --- 313,322 ---- static char PyHKEY_Close_doc[] = ! "key.Close() - Closes the underlying Windows handle.\n" "\n" "If the handle is already closed, no error is raised."; static char PyHKEY_Detach_doc[] = ! "int = key.Detach() - Detaches the Windows handle from the handle object.\n" "\n" "The result is the value of the handle before it is detached. If the\n" *************** *** 325,329 **** "but the handle is not closed. You would call this function when you\n" "need the underlying win32 handle to exist beyond the lifetime of the\n" ! "handle object."; --- 326,331 ---- "but the handle is not closed. You would call this function when you\n" "need the underlying win32 handle to exist beyond the lifetime of the\n" ! "handle object.\n" ! "On 64 bit windows, the result of this function is a long integer\n"; From python-dev@python.org Fri Jun 9 15:04:55 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 9 Jun 2000 07:04:55 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects stringobject.c,2.66,2.67 unicodeobject.c,2.23,2.24 Message-ID: <200006091404.HAA19419@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv19379 Modified Files: stringobject.c unicodeobject.c Log Message: Patch from Michael Hudson: improve unclear error message Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.66 retrieving revision 2.67 diff -C2 -r2.66 -r2.67 *** stringobject.c 2000/06/01 03:12:13 2.66 --- stringobject.c 2000/06/09 14:04:53 2.67 *************** *** 394,398 **** if (!PyString_Check(el) || PyString_Size(el) != 1) { PyErr_SetString(PyExc_TypeError, ! "string member test needs char left operand"); return -1; } --- 394,398 ---- if (!PyString_Check(el) || PyString_Size(el) != 1) { PyErr_SetString(PyExc_TypeError, ! "'in ' requires character as left operand"); return -1; } Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.23 retrieving revision 2.24 diff -C2 -r2.23 -r2.24 *** unicodeobject.c 2000/06/08 17:54:00 2.23 --- unicodeobject.c 2000/06/09 14:04:53 2.24 *************** *** 2997,3001 **** if (PyUnicode_GET_SIZE(v) != 1) { PyErr_SetString(PyExc_TypeError, ! "string member test needs char left operand"); goto onError; } --- 2997,3001 ---- if (PyUnicode_GET_SIZE(v) != 1) { PyErr_SetString(PyExc_TypeError, ! "'in ' requires character as left operand"); goto onError; } From python-dev@python.org Fri Jun 9 15:08:11 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 9 Jun 2000 07:08:11 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre_parse.py,1.3,1.4 Message-ID: <200006091408.HAA19679@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv19644 Modified Files: sre_parse.py Log Message: Patch from /F: this patch brings the CVS version of SRE in sync with the latest public snapshot."" Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** sre_parse.py 2000/04/10 17:10:48 1.3 --- sre_parse.py 2000/06/09 14:08:07 1.4 *************** *** 3,9 **** # $Id$ # ! # convert re-style regular expression to SRE template. the current ! # implementation is somewhat incomplete, and not very fast. should ! # definitely be rewritten before Python 1.6 goes beta. # # Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. --- 3,7 ---- # $Id$ # ! # convert re-style regular expression to sre pattern # # Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. *************** *** 17,27 **** # - # FIXME: comments marked with the FIXME tag are open issues. all such - # issues should be closed before the final beta. - import string, sys from sre_constants import * SPECIAL_CHARS = ".\\[{()*+?^$|" REPEAT_CHARS = "*+?{" --- 15,28 ---- # import string, sys + import _sre + from sre_constants import * + # FIXME: should be 65535, but the array module currently chokes on + # unsigned integers larger than 32767... + MAXREPEAT = int(2L**(_sre.getcodesize()*8-1))-1 + SPECIAL_CHARS = ".\\[{()*+?^$|" REPEAT_CHARS = "*+?{" *************** *** 33,36 **** --- 34,39 ---- HEXDIGITS = tuple("0123456789abcdefABCDEF") + WHITESPACE = tuple(string.whitespace) + ESCAPES = { "\\a": (LITERAL, chr(7)), *************** *** 56,63 **** } ! class Pattern: ! # FIXME: rename class, and store flags in here too! def __init__(self): ! self.flags = [] self.groups = 1 self.groupdict = {} --- 59,74 ---- } ! FLAGS = { ! "i": SRE_FLAG_IGNORECASE, ! "L": SRE_FLAG_LOCALE, ! "m": SRE_FLAG_MULTILINE, ! "s": SRE_FLAG_DOTALL, ! "t": SRE_FLAG_TEMPLATE, ! "x": SRE_FLAG_VERBOSE, ! } ! ! class State: def __init__(self): ! self.flags = 0 self.groups = 1 self.groupdict = {} *************** *** 68,74 **** self.groupdict[name] = gid return gid - def setflag(self, flag): - if flag in self.flags: - self.flags.append(flag) class SubPattern: --- 79,82 ---- *************** *** 79,83 **** data = [] self.data = data - self.flags = [] self.width = None def __repr__(self): --- 87,90 ---- *************** *** 122,127 **** elif op in (MIN_REPEAT, MAX_REPEAT): i, j = av[2].getwidth() ! lo = lo + i * av[0] ! hi = hi + j * av[1] elif op in (ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY): lo = lo + 1 --- 129,134 ---- elif op in (MIN_REPEAT, MAX_REPEAT): i, j = av[2].getwidth() ! lo = lo + long(i) * av[0] ! hi = hi + long(j) * av[1] elif op in (ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY): lo = lo + 1 *************** *** 131,175 **** self.width = int(min(lo, sys.maxint)), int(min(hi, sys.maxint)) return self.width - def set(self, flag): - if not flag in self.flags: - self.flags.append(flag) - def reset(self, flag): - if flag in self.flags: - self.flags.remove(flag) class Tokenizer: def __init__(self, string): ! self.string = list(string) self.next = self.__next() def __next(self): ! if not self.string: return None ! char = self.string[0] if char[0] == "\\": try: ! c = self.string[1] except IndexError: raise SyntaxError, "bogus escape" char = char + c ! try: ! if c == "x": ! # hexadecimal constant ! for i in xrange(2, sys.maxint): ! c = self.string[i] ! if str(c) not in HEXDIGITS: ! break ! char = char + c ! elif str(c) in DIGITS: ! # decimal (or octal) number ! for i in xrange(2, sys.maxint): ! c = self.string[i] ! # FIXME: if larger than current number of ! # groups, interpret as an octal number ! if str(c) not in DIGITS: ! break ! char = char + c ! except IndexError: ! pass # use what we've got this far ! del self.string[0:len(char)] return char def match(self, char): --- 138,158 ---- self.width = int(min(lo, sys.maxint)), int(min(hi, sys.maxint)) return self.width class Tokenizer: def __init__(self, string): ! self.index = 0 ! self.string = string self.next = self.__next() def __next(self): ! if self.index >= len(self.string): return None ! char = self.string[self.index] if char[0] == "\\": try: ! c = self.string[self.index + 1] except IndexError: raise SyntaxError, "bogus escape" char = char + c ! self.index = self.index + len(char) return char def match(self, char): *************** *** 188,221 **** return this ! def _fixescape(escape, character_class=0): ! # convert escape to (type, value) ! if character_class: ! # inside a character class, we'll look in the character ! # escapes dictionary first ! code = ESCAPES.get(escape) ! if code: ! return code ! code = CATEGORIES.get(escape) ! else: ! code = CATEGORIES.get(escape) ! if code: ! return code ! code = ESCAPES.get(escape) if code: return code - if not character_class: - try: - group = int(escape[1:]) - # FIXME: only valid if group <= current number of groups - return GROUP, group - except ValueError: - pass try: if escape[1:2] == "x": escape = escape[2:] ! return LITERAL, chr(int(escape[-2:], 16) & 0xff) elif str(escape[1:2]) in DIGITS: ! return LITERAL, chr(int(escape[1:], 8) & 0xff) ! elif len(escape) == 2: return LITERAL, escape[1] except ValueError: --- 171,242 ---- return this ! def _group(escape, state): ! # check if the escape string represents a valid group ! try: ! group = int(escape[1:]) ! if group and group < state.groups: ! return group ! except ValueError: ! pass ! return None # not a valid group ! ! def _class_escape(source, escape): ! # handle escape code inside character class ! code = ESCAPES.get(escape) ! if code: ! return code ! code = CATEGORIES.get(escape) ! if code: ! return code ! try: ! if escape[1:2] == "x": ! while source.next in HEXDIGITS: ! escape = escape + source.get() ! escape = escape[2:] ! # FIXME: support unicode characters! ! return LITERAL, chr(int(escape[-4:], 16) & 0xff) ! elif str(escape[1:2]) in OCTDIGITS: ! while source.next in OCTDIGITS: ! escape = escape + source.get() ! escape = escape[1:] ! # FIXME: support unicode characters! ! return LITERAL, chr(int(escape[-6:], 8) & 0xff) ! if len(escape) == 2: ! return LITERAL, escape[1] ! except ValueError: ! pass ! raise SyntaxError, "bogus escape: %s" % repr(escape) ! ! def _escape(source, escape, state): ! # handle escape code in expression ! code = CATEGORIES.get(escape) ! if code: ! return code ! code = ESCAPES.get(escape) if code: return code try: if escape[1:2] == "x": + while source.next in HEXDIGITS: + escape = escape + source.get() escape = escape[2:] ! # FIXME: support unicode characters! ! return LITERAL, chr(int(escape[-4:], 16) & 0xff) elif str(escape[1:2]) in DIGITS: ! while 1: ! group = _group(escape, state) ! if group: ! if (not source.next or ! not _group(escape + source.next, state)): ! return GROUP, group ! escape = escape + source.get() ! elif source.next in OCTDIGITS: ! escape = escape + source.get() ! else: ! break ! escape = escape[1:] ! # FIXME: support unicode characters! ! return LITERAL, chr(int(escape[-6:], 8) & 0xff) ! if len(escape) == 2: return LITERAL, escape[1] except ValueError: *************** *** 223,231 **** raise SyntaxError, "bogus escape: %s" % repr(escape) - def _branch(subpattern, items): # form a branch operator from a set of items (FIXME: move this # optimization to the compiler module!) # check if all items share a common prefix while 1: --- 244,255 ---- raise SyntaxError, "bogus escape: %s" % repr(escape) + def _branch(pattern, items): + # form a branch operator from a set of items (FIXME: move this # optimization to the compiler module!) + subpattern = SubPattern(pattern) + # check if all items share a common prefix while 1: *************** *** 258,272 **** set.append(item[0]) subpattern.append((IN, set)) ! return subpattern.append((BRANCH, (None, items))) ! def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. - - subpattern = SubPattern(pattern) ! this = None while 1: --- 282,295 ---- set.append(item[0]) subpattern.append((IN, set)) ! return subpattern subpattern.append((BRANCH, (None, items))) + return subpattern ! def _parse(source, state, flags=0): # parse regular expression pattern into an operator list. ! subpattern = SubPattern(state) while 1: *************** *** 278,281 **** --- 301,315 ---- break # end of pattern + if state.flags & SRE_FLAG_VERBOSE: + # skip whitespace and comments + if this in WHITESPACE: + continue + if this == "#": + while 1: + this = source.get() + if this in (None, "\n"): + break + continue + if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) *************** *** 295,299 **** break elif this and this[0] == "\\": ! code1 = _fixescape(this, 1) elif this: code1 = LITERAL, this --- 329,333 ---- break elif this and this[0] == "\\": ! code1 = _class_escape(source, this) elif this: code1 = LITERAL, this *************** *** 309,313 **** else: if this[0] == "\\": ! code2 = _fixescape(this, 1) else: code2 = LITERAL, this --- 343,347 ---- else: if this[0] == "\\": ! code2 = _class_escape(source, this) else: code2 = LITERAL, this *************** *** 322,326 **** set.append(code1) ! # FIXME: move set optimization to support function if len(set)==1 and set[0][0] is LITERAL: subpattern.append(set[0]) # optimization --- 356,360 ---- set.append(code1) ! # FIXME: move set optimization to compiler! if len(set)==1 and set[0][0] is LITERAL: subpattern.append(set[0]) # optimization *************** *** 336,344 **** min, max = 0, 1 elif this == "*": ! min, max = 0, sys.maxint elif this == "+": ! min, max = 1, sys.maxint elif this == "{": ! min, max = 0, sys.maxint lo = hi = "" while str(source.next) in DIGITS: --- 370,378 ---- min, max = 0, 1 elif this == "*": ! min, max = 0, MAXREPEAT elif this == "+": ! min, max = 1, MAXREPEAT elif this == "{": ! min, max = 0, MAXREPEAT lo = hi = "" while str(source.next) in DIGITS: *************** *** 359,376 **** raise SyntaxError, "not supported" # figure out which item to repeat - # FIXME: should back up to the right mark, right? if subpattern: ! index = len(subpattern)-1 ! while subpattern[index][0] is MARK: ! index = index - 1 ! item = subpattern[index:index+1] else: raise SyntaxError, "nothing to repeat" if source.match("?"): ! subpattern[index] = (MIN_REPEAT, (min, max, item)) else: ! subpattern[index] = (MAX_REPEAT, (min, max, item)) elif this == ".": subpattern.append((ANY, None)) elif this == "(": group = 1 --- 393,408 ---- raise SyntaxError, "not supported" # figure out which item to repeat if subpattern: ! item = subpattern[-1:] else: raise SyntaxError, "nothing to repeat" if source.match("?"): ! subpattern[-1] = (MIN_REPEAT, (min, max, item)) else: ! subpattern[-1] = (MAX_REPEAT, (min, max, item)) ! elif this == ".": subpattern.append((ANY, None)) + elif this == "(": group = 1 *************** *** 380,405 **** # options if source.match("P"): ! # named group: skip forward to end of name if source.match("<"): name = "" while 1: char = source.get() ! if char is None or char == ">": break name = name + char group = 1 elif source.match(":"): # non-capturing group group = 2 ! elif source.match_set("iI"): ! pattern.setflag("i") ! elif source.match_set("lL"): ! pattern.setflag("l") ! elif source.match_set("mM"): ! pattern.setflag("m") ! elif source.match_set("sS"): ! pattern.setflag("s") ! elif source.match_set("xX"): ! pattern.setflag("x") if group: # parse group contents --- 412,450 ---- # options if source.match("P"): ! # python extensions if source.match("<"): + # named group: skip forward to end of name name = "" while 1: char = source.get() ! if char is None: ! raise SyntaxError, "unterminated name" ! if char == ">": break + # FIXME: check for valid character name = name + char group = 1 + elif source.match("="): + # named backreference + raise SyntaxError, "not yet implemented" + + else: + char = source.get() + if char is None: + raise SyntaxError, "unexpected end of pattern" + raise SyntaxError, "unknown specifier: ?P%s" % char elif source.match(":"): # non-capturing group group = 2 ! elif source.match("#"): ! # comment ! while 1: ! char = source.get() ! if char is None or char == ")": ! break ! else: ! # flags ! while FLAGS.has_key(source.next): ! state.flags = state.flags | FLAGS[source.get()] if group: # parse group contents *************** *** 409,423 **** group = None else: ! group = pattern.getgroup(name) ! if group: ! subpattern.append((MARK, (group-1)*2)) while 1: ! p = _parse(source, pattern, flags) if source.match(")"): if b: b.append(p) ! _branch(subpattern, b) ! else: ! subpattern.append((SUBPATTERN, (group, p))) break elif source.match("|"): --- 454,465 ---- group = None else: ! group = state.getgroup(name) while 1: ! p = _parse(source, state, flags) if source.match(")"): if b: b.append(p) ! p = _branch(state, b) ! subpattern.append((SUBPATTERN, (group, p))) break elif source.match("|"): *************** *** 425,436 **** else: raise SyntaxError, "group not properly closed" - if group: - subpattern.append((MARK, (group-1)*2+1)) else: - # FIXME: should this really be a while loop? while 1: char = source.get() if char is None or char == ")": break elif this == "^": --- 467,476 ---- else: raise SyntaxError, "group not properly closed" else: while 1: char = source.get() if char is None or char == ")": break + # FIXME: skip characters? elif this == "^": *************** *** 441,445 **** elif this and this[0] == "\\": ! code =_fixescape(this) subpattern.append(code) --- 481,485 ---- elif this and this[0] == "\\": ! code = _escape(source, this, state) subpattern.append(code) *************** *** 449,459 **** return subpattern ! def parse(source, flags=()): ! s = Tokenizer(source) ! g = Pattern() b = [] while 1: ! p = _parse(s, g, flags) ! tail = s.get() if tail == "|": b.append(p) --- 489,500 ---- return subpattern ! def parse(pattern, flags=0): ! # parse 're' pattern into list of (opcode, argument) tuples ! source = Tokenizer(pattern) ! state = State() b = [] while 1: ! p = _parse(source, state, flags) ! tail = source.get() if tail == "|": b.append(p) *************** *** 463,471 **** if b: b.append(p) ! p = SubPattern(g) ! _branch(p, b) break else: raise SyntaxError, "bogus characters at end of regular expression" return p --- 504,531 ---- if b: b.append(p) ! p = _branch(state, b) break else: raise SyntaxError, "bogus characters at end of regular expression" + return p + + def parse_replacement(source, pattern): + # parse 're' replacement string into list of literals and + # group references + s = Tokenizer(source) + p = [] + a = p.append + while 1: + this = s.get() + if this is None: + break # end of replacement string + if this and this[0] == "\\": + try: + a(LITERAL, ESCAPES[this]) + except KeyError: + for char in this: + a(LITERAL, char) + else: + a(LITERAL, this) return p From python-dev@python.org Fri Jun 9 17:20:42 2000 From: python-dev@python.org (Jeremy Hylton) Date: Fri, 9 Jun 2000 09:20:42 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects object.c,2.70,2.71 Message-ID: <200006091620.JAA12616@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv12563 Modified Files: object.c Log Message: the PyDict_SetItem does not borrow a reference, so we need to decref reported by Mark Hammon Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.70 retrieving revision 2.71 diff -C2 -r2.70 -r2.71 *** object.c 2000/05/03 23:44:35 2.70 --- object.c 2000/06/09 16:20:39 2.71 *************** *** 352,355 **** --- 352,356 ---- return NULL; } + Py_DECREF(inprogress); } return inprogress; From python-dev@python.org Sat Jun 10 02:41:51 2000 From: python-dev@python.org (A.M. Kuchling) Date: Fri, 9 Jun 2000 18:41:51 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib urllib.py,1.94,1.95 Message-ID: <200006100141.SAA09634@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv9465 Modified Files: urllib.py Log Message: Comment out an apparent debug print Index: urllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib.py,v retrieving revision 1.94 retrieving revision 1.95 diff -C2 -r1.94 -r1.95 *** urllib.py 2000/05/24 13:21:46 1.94 --- urllib.py 2000/06/10 01:41:48 1.95 *************** *** 314,318 **** if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) ! print "proxy via https:", host, selector if not host: raise IOError, ('https error', 'no host given') if user_passwd: --- 314,318 ---- if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) ! #print "proxy via https:", host, selector if not host: raise IOError, ('https error', 'no host given') if user_passwd: From python-dev@python.org Sat Jun 10 05:22:59 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 9 Jun 2000 21:22:59 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_linuxaudiodev,NONE,1.1 Message-ID: <200006100422.VAA06594@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv6583/output Added Files: test_linuxaudiodev Log Message: Added test for linnuxaudiodev module; directly adapted from sunaudiodev test. Someone with more Linux audio knowledge should at least take a brief look at it. --- NEW FILE --- test_linuxaudiodev From python-dev@python.org Sat Jun 10 05:22:59 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 9 Jun 2000 21:22:59 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_linuxaudiodev.py,NONE,1.1 Message-ID: <200006100422.VAA06591@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv6583 Added Files: test_linuxaudiodev.py Log Message: Added test for linnuxaudiodev module; directly adapted from sunaudiodev test. Someone with more Linux audio knowledge should at least take a brief look at it. --- NEW FILE --- from test_support import verbose, findfile, TestFailed import linuxaudiodev import os def play_sound_file(path): fp = open(path, 'r') data = fp.read() fp.close() try: a = linuxaudiodev.open('w') except linuxaudiodev.error, msg: raise TestFailed, msg else: a.write(data) a.close() def test(): play_sound_file(findfile('audiotest.au')) test() From python-dev@python.org Sat Jun 10 10:32:54 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Sat, 10 Jun 2000 02:32:54 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.24,2.25 Message-ID: <200006100932.CAA17757@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv17744/Objects Modified Files: unicodeobject.c Log Message: Marc-Andre Lemburg : Fixed a typo and removed a debug printf(). Thanks to Finn Bock for finding these. Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.24 retrieving revision 2.25 diff -C2 -r2.24 -r2.25 *** unicodeobject.c 2000/06/09 14:04:53 2.24 --- unicodeobject.c 2000/06/10 09:32:51 2.25 *************** *** 733,737 **** bytes which the Python implementation currently does not support. */ - printf("code range problem: U+%04x\n", ch); if (utf8_encoding_error(&s, &p, errors, "unsupported code range")) --- 733,736 ---- *************** *** 1735,1739 **** if (value < 0 || value > 65535) { PyErr_SetString(PyExc_TypeError, ! "character mapping must be in range(65336)"); Py_DECREF(x); goto onError; --- 1734,1738 ---- if (value < 0 || value > 65535) { PyErr_SetString(PyExc_TypeError, ! "character mapping must be in range(65536)"); Py_DECREF(x); goto onError; From python-dev@python.org Sun Jun 11 00:02:59 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 10 Jun 2000 16:02:59 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/curses - New directory Message-ID: <200006102302.QAA17598@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/curses In directory slayer.i.sourceforge.net:/tmp/cvs-serv17416/curses Log Message: Directory /cvsroot/python/python/dist/src/Lib/curses added to the repository ***** Bogus filespec: - ***** Bogus filespec: New ***** Bogus filespec: directory From python-dev@python.org Sun Jun 11 00:06:55 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 10 Jun 2000 16:06:55 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/curses __init__.py,NONE,1.1 wrapper.py,NONE,1.1 Message-ID: <200006102306.QAA18088@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/curses In directory slayer.i.sourceforge.net:/tmp/cvs-serv18069 Added Files: __init__.py wrapper.py Log Message: Add contents of curses package ***** Error reading new file(2, 'No such file or directory') --- NEW FILE --- """curses.wrapper Contains one function, wrapper(), which runs another function which should be the rest of your curses-based application. If the application raises an exception, wrapper() will restore the terminal to a sane state so you can read the resulting traceback. """ import sys, curses def wrapper(func, *rest): """Wrapper function that initializes curses and calls another function, restoring normal keyboard/screen behavior on error. The callable object 'func' is then passed the main window 'stdscr' as its first argument, followed by any other arguments passed to wrapper(). """ res = None try: # Initialize curses stdscr=curses.initscr() # Turn off echoing of keys, and enter cbreak mode, # where no buffering is performed on keyboard input curses.noecho() ; curses.cbreak() # In keypad mode, escape sequences for special keys # (like the cursor keys) will be interpreted and # a special value like curses.KEY_LEFT will be returned stdscr.keypad(1) res = apply(func, (stdscr,) + rest) except: # In the event of an error, restore the terminal # to a sane state. stdscr.keypad(0) curses.echo() ; curses.nocbreak() curses.endwin() # Pass the exception upwards (exc_type, exc_value, exc_traceback) = sys.exc_info() raise exc_type, exc_value, exc_traceback else: # Set everything back to normal stdscr.keypad(0) curses.echo() ; curses.nocbreak() curses.endwin() # Terminate curses return res From python-dev@python.org Sun Jun 11 00:08:24 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 10 Jun 2000 16:08:24 -0700 Subject: [Python-checkins] CVS: python/dist/src Makefile.in,1.86,1.87 Message-ID: <200006102308.QAA18139@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv18130 Modified Files: Makefile.in Log Message: Install the contents of the Lib/curses directory Index: Makefile.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.in,v retrieving revision 1.86 retrieving revision 1.87 diff -C2 -r1.86 -r1.87 *** Makefile.in 2000/04/24 14:57:21 1.86 --- Makefile.in 2000/06/10 23:08:21 1.87 *************** *** 291,295 **** MACHDEPS= $(PLATDIR) LIBSUBDIRS= lib-old lib-tk site-packages test test/output encodings \ ! distutils distutils/command $(MACHDEPS) libinstall: python $(srcdir)/Lib/$(PLATDIR) @for i in $(SCRIPTDIR) $(LIBDEST); \ --- 291,295 ---- MACHDEPS= $(PLATDIR) LIBSUBDIRS= lib-old lib-tk site-packages test test/output encodings \ ! distutils distutils/command curses $(MACHDEPS) libinstall: python $(srcdir)/Lib/$(PLATDIR) @for i in $(SCRIPTDIR) $(LIBDEST); \ From python-dev@python.org Sun Jun 11 00:12:34 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 10 Jun 2000 16:12:34 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules cursesmodule.c,2.22,2.23 Setup.in,1.101,1.102 Message-ID: <200006102312.QAA18393@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv18349 Modified Files: cursesmodule.c Setup.in Log Message: Renamed the C extension for ncurses support from 'curses' to '_curses'. (The SourceForge admins have been asked to rename the ,v file.) Index: cursesmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cursesmodule.c,v retrieving revision 2.22 retrieving revision 2.23 diff -C2 -r2.22 -r2.23 *** cursesmodule.c 2000/05/23 16:24:54 2.22 --- cursesmodule.c 2000/06/10 23:12:32 2.23 *************** *** 2164,2173 **** void ! initcurses() { PyObject *m, *d, *v; /* Create the module and add the functions */ ! m = Py_InitModule("curses", PyCurses_methods); /* Add some symbolic constants to the module */ --- 2164,2173 ---- void ! init_curses() { PyObject *m, *d, *v; /* Create the module and add the functions */ ! m = Py_InitModule("_curses", PyCurses_methods); /* Add some symbolic constants to the module */ *************** *** 2176,2180 **** /* For exception curses.error */ ! PyCursesError = PyString_FromString("curses.error"); PyDict_SetItemString(d, "error", PyCursesError); --- 2176,2180 ---- /* For exception curses.error */ ! PyCursesError = PyString_FromString("_curses.error"); PyDict_SetItemString(d, "error", PyCursesError); *************** *** 2252,2255 **** /* Check for errors */ if (PyErr_Occurred()) ! Py_FatalError("can't initialize module curses"); } --- 2252,2255 ---- /* Check for errors */ if (PyErr_Occurred()) ! Py_FatalError("can't initialize module _curses"); } Index: Setup.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Setup.in,v retrieving revision 1.101 retrieving revision 1.102 diff -C2 -r1.101 -r1.102 *** Setup.in 2000/06/07 09:12:54 1.101 --- Setup.in 2000/06/10 23:12:32 1.102 *************** *** 315,324 **** ! # Lance's curses module. This requires the System V version of ! # curses, sometimes known as ncurses (e.g. on Linux, link with ! # -lncurses instead of -lcurses; on SunOS 4.1.3, insert -I/usr/5include # -L/usr/5lib before -lcurses). ! #curses cursesmodule.c -lcurses -ltermcap --- 315,324 ---- ! # Curses support, requring the System V version of curses, often ! # provided by the ncurses library. e.g. on Linux, link with -lncurses ! # instead of -lcurses; on SunOS 4.1.3, insert -I/usr/5include # -L/usr/5lib before -lcurses). ! #_curses _cursesmodule.c -lcurses -ltermcap From python-dev@python.org Sun Jun 11 00:39:07 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 10 Jun 2000 16:39:07 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/curses wrapper.py,1.1,1.2 Message-ID: <200006102339.QAA19661@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/curses In directory slayer.i.sourceforge.net:/tmp/cvs-serv19653 Modified Files: wrapper.py Log Message: Applied simplifications suggested by Greg Stein. Index: wrapper.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/curses/wrapper.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** wrapper.py 2000/06/10 23:06:53 1.1 --- wrapper.py 2000/06/10 23:39:05 1.2 *************** *** 18,22 **** """ - res = None try: # Initialize curses --- 18,21 ---- *************** *** 31,50 **** stdscr.keypad(1) ! res = apply(func, (stdscr,) + rest) ! except: ! # In the event of an error, restore the terminal ! # to a sane state. stdscr.keypad(0) curses.echo() ; curses.nocbreak() curses.endwin() - # Pass the exception upwards - (exc_type, exc_value, exc_traceback) = sys.exc_info() - raise exc_type, exc_value, exc_traceback - else: - # Set everything back to normal - stdscr.keypad(0) - curses.echo() ; curses.nocbreak() - curses.endwin() # Terminate curses - - return res --- 30,39 ---- stdscr.keypad(1) ! return apply(func, (stdscr,) + rest) ! ! finally: ! # Restore the terminal to a sane state on the way out. stdscr.keypad(0) curses.echo() ; curses.nocbreak() curses.endwin() From python-dev@python.org Sun Jun 11 03:42:10 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 10 Jun 2000 19:42:10 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libpyexpat.tex,NONE,1.1 Message-ID: <200006110242.TAA18090@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv18075 Added Files: libpyexpat.tex Log Message: Documentation for the pyexpat module. --- NEW FILE --- \section{\module{pyexpat} --- Fast XML parsing using the Expat C library} \declaremodule{builtin}{pyexpat} \modulesynopsis{An interface to the Expat XML parser.} \moduleauthor{Paul Prescod}{paul@prescod.net} \sectionauthor{A.M. Kuchling}{amk1@bigfoot.com} The \module{pyexpat} module is a Python interface to the Expat non-validating XML parser. The module provides a single extension type, \class{xmlparser}, that represents the current state of an XML parser. After an \class{xmlparser} object has been created, various attributes of the object can be set to handler functions. When an XML document is then fed to the parser, the handler functions are called for the character data and markup in the XML document. The \module{pyexpat} module contains two functions: \begin{funcdesc}{ErrorString}{errno} Returns an explanatory string for a given error number \var{errno}. \end{funcdesc} \begin{funcdesc}{ParserCreate}{\optional{encoding, namespace_separator}} Creates and returns a new \class{xmlparser} object. \var{encoding}, if specified, must be a string naming the encoding used by the XML data. Expat doesn't support as many encodings as Python does, and its repertoire of encodings can't be extended; it supports UTF-8, UTF-16, ISO-8859-1 (Latin1), and ASCII. % XXX pyexpat.c should only allow a 1-char string for this parameter Expat can optionally do XML namespace processing for you, enabled by providing a value for \var{namespace_separator}. When namespace processing is enabled, element type names and attribute names that belong to a namespace will be expanded. The element name passed to the element handlers \function{StartElementHandler()} and \function{EndElementHandler()} will be the concatenation of the namespace URI, the namespace separator character, and the local part of the name. If the namespace separator is a zero byte (\code{chr(0)}) then the namespace URI and the local part will be concatenated without any separator. For example, if \var{namespace_separator} is set to \samp{ }, and the following document is parsed: \begin{verbatim} \end{verbatim} \function{StartElementHandler()} will receive the following strings for each element: \begin{verbatim} http://default-namespace.org/ root http://www.python.org/ns/ elem1 elem2 \end{verbatim} \end{funcdesc} \class{xmlparser} objects have the following methods: \begin{methoddesc}{Parse}{data \optional{, isfinal}} Parses the contents of the string \var{data}, calling the appropriate handler functions to process the parsed data. \var{isfinal} must be true on the final call to this method. \var{data} can be the empty string at any time. \end{methoddesc} \begin{methoddesc}{ParseFile}{file} Parse XML data reading from the object \var{file}. \var{file} only needs to provide the \method{read(\var{nbytes})} method, returning the empty string when there's no more data. \end{methoddesc} \begin{methoddesc}{SetBase}{base} Sets the base to be used for resolving relative URIs in system identifiers in declarations. Resolving relative identifiers is left to the application: this value will be passed through as the base argument to the \function{ExternalEntityRefHandler}, \function{NotationDeclHandler}, and \function{UnparsedEntityDeclHandler} functions. \end{methoddesc} \begin{methoddesc}{GetBase}{} Returns a string containing the base set by a previous call to \method{SetBase()}, or \code{None} if \method{SetBase()} hasn't been called. \end{methoddesc} \class{xmlparser} objects have the following attributes, containing values relating to the most recent error encountered by an \class{xmlparser} object. These attributes will only have correct values once a call to \method{Parse()} or \method{ParseFile()} has raised a \exception{pyexpat.error} exception. \begin{datadesc}{ErrorByteIndex} Byte index at which an error occurred. \end{datadesc} \begin{datadesc}{ErrorCode} Numeric code specifying the problem. This value can be passed to the \function{ErrorString()} function, or compared to one of the constants defined in the \module{pyexpat.errors} submodule. \end{datadesc} \begin{datadesc}{ErrorColumnNumber} Column number at which an error occurred. \end{datadesc} \begin{datadesc}{ErrorLineNumber} Line number at which an error occurred. \end{datadesc} Here is the list of handlers that can be set. To set a handler on an \class{xmlparser} object \var{o}, use \code{\var{o}.\var{handlername} = \var{func}}. \var{handlername} must be taken from the following list, and \var{func} must be a callable object accepting the correct number of arguments. The arguments are all strings, unless otherwise stated. \begin{methoddesc}{StartElementHandler}{name, attributes} Called for the start of every element. \var{name} is a string containing the element name, and \var{attributes} is a dictionary mapping attribute names to their values. \end{methoddesc} \begin{methoddesc}{EndElementHandler}{name} Called for the end of every element. \end{methoddesc} \begin{methoddesc}{ProcessingInstructionHandler}{target, data} Called for every processing instruction. \end{methoddesc} \begin{methoddesc}{CharacterDataHandler}{\var{data}} Called for character data. \end{methoddesc} \begin{methoddesc}{UnparsedEntityDeclHandler}{entityName, base, systemId, publicId, notationName} Called for unparsed (NDATA) entity declarations. \end{methoddesc} \begin{methoddesc}{NotationDeclHandler}{notationName, base, systemId, publicId} Called for notation declarations. \end{methoddesc} \begin{methoddesc}{StartNamespaceDeclHandler}{prefix, uri} Called when an element contains a namespace declaration. \end{methoddesc} \begin{methoddesc}{EndNamespaceDeclHandler}{prefix} Called when the closing tag is reached for an element that contained a namespace declaration. \end{methoddesc} \begin{methoddesc}{CommentHandler}{data} Called for comments. \end{methoddesc} \begin{methoddesc}{StartCdataSectionHandler}{} Called at the start of a CDATA section. \end{methoddesc} \begin{methoddesc}{EndCdataSectionHandler}{} Called at the end of a CDATA section. \end{methoddesc} \begin{methoddesc}{DefaultHandler}{data} Called for any characters in the XML document for which no applicable handler has been specified. This means characters that are part of a construct which could be reported, but for which no handler has been supplied. \end{methoddesc} \begin{methoddesc}{DefaultHandlerExpand}{data} This is the same as the \function{DefaultHandler}, but doesn't inhibit expansion of internal entities. The entity reference will not be passed to the default handler. \end{methoddesc} \begin{methoddesc}{NotStandaloneHandler}{} Called if the XML document hasn't been declared as being a standalone document. \end{methoddesc} \begin{methoddesc}{ExternalEntityRefHandler}{context, base, systemId, publicId} Called for references to external entities. \end{methoddesc} \subsection{\module{pyexpat.errors} -- Error constants} The following table lists the error constants in the \module{pyexpat.errors} submodule, available once the \module{pyexpat} module has been imported. \begin{tableii}{l|l}{code}{Constants}{}{} \lineii {XML_ERROR_ASYNC_ENTITY} {XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF} \lineii {XML_ERROR_BAD_CHAR_REF} {XML_ERROR_BINARY_ENTITY_REF} \lineii {XML_ERROR_DUPLICATE_ATTRIBUTE} {XML_ERROR_INCORRECT_ENCODING} \lineii {XML_ERROR_INVALID_TOKEN} {XML_ERROR_JUNK_AFTER_DOC_ELEMENT} \lineii {XML_ERROR_MISPLACED_XML_PI} {XML_ERROR_NO_ELEMENTS} \lineii {XML_ERROR_NO_MEMORY} {XML_ERROR_PARAM_ENTITY_REF} \lineii {XML_ERROR_PARTIAL_CHAR} {XML_ERROR_RECURSIVE_ENTITY_REF} \lineii {XML_ERROR_SYNTAX} {XML_ERROR_TAG_MISMATCH} \lineii {XML_ERROR_UNCLOSED_TOKEN} {XML_ERROR_UNDEFINED_ENTITY} \lineii {XML_ERROR_UNKNOWN_ENCODING}{} \end{tableii} \subsection{Example} The following program defines 3 handlers that just print out their arguments. \begin{verbatim} import pyexpat # 3 handler functions def start_element(name, attrs): print 'Start element:', name, attrs def end_element(name): print 'End element:', name def char_data(data): print 'Character data:', repr(data) p=pyexpat.ParserCreate() p.StartElementHandler = start_element p.EndElementHandler = end_element p.CharacterDataHandler= char_data p.Parse(""" Text goes here More text """) \end{verbatim} The output from this program is: \begin{verbatim} Start element: parent {'id': 'top'} Start element: child1 {'name': 'paul'} Character data: 'Text goes here' End element: child1 Character data: '\012' Start element: child2 {'name': 'fred'} Character data: 'More text' End element: child2 Character data: '\012' End element: parent \end{verbatim} From python-dev@python.org Tue Jun 13 13:04:07 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Tue, 13 Jun 2000 05:04:07 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/encodings __init__.py,1.3,1.4 Message-ID: <200006131204.FAA10206@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/encodings In directory slayer.i.sourceforge.net:/tmp/cvs-serv10145/Lib/encodings Modified Files: __init__.py Log Message: Marc-Andre Lemburg : Removed import of string module -- use string methods directly. Thanks to Finn Bock. Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/__init__.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** __init__.py 2000/04/05 20:11:18 1.3 --- __init__.py 2000/06/13 12:04:05 1.4 *************** *** 28,32 **** """#" ! import string,codecs,aliases _cache = {} --- 28,32 ---- """#" ! import codecs,aliases _cache = {} *************** *** 41,45 **** # Import the module ! modname = string.replace(encoding, '-', '_') modname = aliases.aliases.get(modname,modname) try: --- 41,45 ---- # Import the module ! modname = encoding.replace('-', '_') modname = aliases.aliases.get(modname,modname) try: From python-dev@python.org Tue Jun 13 13:05:39 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Tue, 13 Jun 2000 05:05:39 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_unicode.py,1.12,1.13 Message-ID: <200006131205.FAA11587@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv11480/Lib/test Modified Files: test_unicode.py Log Message: Marc-Andre Lemburg : Fixed some tests to not cause the script to fail, but rather output a warning (which then is caught by regrtest.py as wrong output). This is needed to make test_unicode.py run through on JPython. Thanks to Finn Bock. Index: test_unicode.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** test_unicode.py 2000/06/08 17:50:55 1.12 --- test_unicode.py 2000/06/13 12:05:36 1.13 *************** *** 252,258 **** assert u"%c" % (34,) == u'"' assert u"%c" % (36,) == u'$' ! assert u"%r, %r" % (u"abc", "abc") == u"u'abc', 'abc'" assert u"%(x)s, %(y)s" % {'x':u"abc", 'y':"def"} == u'abc, def' ! assert u"%(x)s, %(ä)s" % {'x':u"abc", u'ä'.encode('utf-8'):"def"} == u'abc, def' # formatting jobs delegated from the string implementation: assert '...%(foo)s...' % {'foo':u"abc"} == u'...abc...' --- 252,267 ---- assert u"%c" % (34,) == u'"' assert u"%c" % (36,) == u'$' ! value = u"%r, %r" % (u"abc", "abc") ! if value != u"u'abc', 'abc'": ! print '*** formatting failed for "%s"' % 'u"%r, %r" % (u"abc", "abc")' ! assert u"%(x)s, %(y)s" % {'x':u"abc", 'y':"def"} == u'abc, def' ! try: ! value = u"%(x)s, %(ä)s" % {'x':u"abc", u'ä'.encode('utf-8'):"def"} ! except KeyError: ! print '*** formatting failed for "%s"' % "u'abc, def'" ! else: ! assert value == u'abc, def' ! # formatting jobs delegated from the string implementation: assert '...%(foo)s...' % {'foo':u"abc"} == u'...abc...' *************** *** 269,273 **** pass else: ! raise AssertionError, "'...%s...äöü...' % u'abc' failed to raise an exception" print 'done.' --- 278,282 ---- pass else: ! print "*** formatting failed ...%s...äöü...' % u'abc' failed to raise an exception" print 'done.' From python-dev@python.org Tue Jun 13 19:49:56 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 13 Jun 2000 11:49:56 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib zipfile.py,1.1,1.2 Message-ID: <200006131849.LAA16627@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv16620 Modified Files: zipfile.py Log Message: James C. Ahlstron : Thanks to Hubert Hoegl for finding this bug. Index: zipfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/zipfile.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** zipfile.py 2000/03/31 17:30:02 1.1 --- zipfile.py 2000/06/13 18:49:53 1.2 *************** *** 167,171 **** # Convert date/time code to (year, month, day, hour, min, sec) x.date_time = ( (d>>9)+1980, (d>>5)&0xF, d&0x1F, ! t>>11, (t>>5)&0x3F, t&0x1F * 2 ) self.filelist.append(x) self.NameToInfo[x.filename] = x --- 167,171 ---- # Convert date/time code to (year, month, day, hour, min, sec) x.date_time = ( (d>>9)+1980, (d>>5)&0xF, d&0x1F, ! t>>11, (t>>5)&0x3F, (t&0x1F) * 2 ) self.filelist.append(x) self.NameToInfo[x.filename] = x From python-dev@python.org Tue Jun 13 21:50:53 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 13 Jun 2000 13:50:53 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libunicodedata.tex,NONE,1.1 Message-ID: <200006132050.NAA04900@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv4892/lib Added Files: libunicodedata.tex Log Message: Marc-Andre Lemburg : Documentation for the unicodedata module (massaged by Fred for minor consistency issues). --- NEW FILE --- \section{\module{unicodedata} --- Unicode Database} \declaremodule{standard}{unicodedata} \modulesynopsis{Access the Unicode Database.} \moduleauthor{Marc-Andre Lemburg}{mal@lemburg.com} \sectionauthor{Marc-Andre Lemburg}{mal@lemburg.com} \index{Unicode} \index{character} \indexii{Unicode}{database} This module provides access to the Unicode Character Database which defines character properties for all Unicode characters. The data in this database is based on the \file{UnicodeData.txt} file version 3.0.0 which is publically available from \url{ftp://ftp.unicode.org/}. The module uses the same names and symbols as defined by the UnicodeData File Format 3.0.0 (see \url{ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.html}). It defines the following functions: \begin{funcdesc}{decimal}{unichr\optional{, default}} Returns the decimal value assigned to the Unicode character \var{unichr} as integer. If no such value is defined, \var{default} is returned, or, if not given, \exception{ValueError} is raised. \end{funcdesc} \begin{funcdesc}{digit}{unichr\optional{, default}} Returns the digit value assigned to the Unicode character \var{unichr} as integer. If no such value is defined, \var{default} is returned, or, if not given, \exception{ValueError} is raised. \end{funcdesc} \begin{funcdesc}{numeric}{unichr\optional{, default}} Returns the numeric value assigned to the Unicode character \var{unichr} as float. If no such value is defined, \var{default} is returned, or, if not given, \exception{ValueError} is raised. \end{funcdesc} \begin{funcdesc}{category}{unichr} Returns the general category assigned to the Unicode character \var{unichr} as string. \end{funcdesc} \begin{funcdesc}{bidirectional}{unichr} Returns the bidirectional category assigned to the Unicode character \var{unichr} as string. If no such value is defined, an empty string is returned. \end{funcdesc} \begin{funcdesc}{combining}{unichr} Returns the canonical combining class assigned to the Unicode character \var{unichr} as integer. Returns \code{0} if no combining class is defined. \end{funcdesc} \begin{funcdesc}{mirrored}{unichr} Returns the mirrored property of assigned to the Unicode character \var{unichr} as integer. Returns \code{1} if the character has been identified as a ``mirrored'' character in bidirectional text, \code{0} otherwise. \end{funcdesc} \begin{funcdesc}{decomposition}{unichr} Returns the character decomposition mapping assigned to the Unicode character \var{unichr} as string. An empty string is returned in case no such mapping is defined. \end{funcdesc} From python-dev@python.org Tue Jun 13 21:51:31 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 13 Jun 2000 13:51:31 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib lib.tex,1.151,1.152 Message-ID: <200006132051.NAA04961@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv4948/lib Modified Files: lib.tex Log Message: Hook in the documentation for the unicodedata module. Index: lib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/lib.tex,v retrieving revision 1.151 retrieving revision 1.152 diff -C2 -r1.151 -r1.152 *** lib.tex 2000/06/07 04:07:48 1.151 --- lib.tex 2000/06/13 20:51:29 1.152 *************** *** 115,118 **** --- 115,119 ---- \input{libstringio} \input{libcodecs} + \input{libunicodedata} %\input{libsoundex} From python-dev@python.org Tue Jun 13 21:51:31 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 13 Jun 2000 13:51:31 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc Makefile.deps,1.31,1.32 Message-ID: <200006132051.NAA04957@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc In directory slayer.i.sourceforge.net:/tmp/cvs-serv4948 Modified Files: Makefile.deps Log Message: Hook in the documentation for the unicodedata module. Index: Makefile.deps =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile.deps,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -r1.31 -r1.32 *** Makefile.deps 2000/06/07 04:07:48 1.31 --- Makefile.deps 2000/06/13 20:51:29 1.32 *************** *** 62,65 **** --- 62,66 ---- ../lib/libstring.tex \ ../lib/libcodecs.tex \ + ../lib/libunicodedata.tex \ ../lib/libregex.tex \ ../lib/libregsub.tex \ From python-dev@python.org Wed Jun 14 10:17:27 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 14 Jun 2000 02:17:27 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_unicode.py,1.13,1.14 Message-ID: <200006140917.CAA03479@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv3463/Lib/test Modified Files: test_unicode.py Log Message: Marc-Andre Lemburg : Removed a test which can fail when the default locale setting uses a Latin-1 encoding. The test case is not applicable anymore. Index: test_unicode.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** test_unicode.py 2000/06/13 12:05:36 1.13 --- test_unicode.py 2000/06/14 09:17:25 1.14 *************** *** 273,282 **** assert '...%s...%s...%s...%s...' % (1,2,3,u"abc") == u'...1...2...3...abc...' assert '...%s...' % u"abc" == u'...abc...' - try: - '...%s...äöü...' % u"abc" - except ValueError: - pass - else: - print "*** formatting failed ...%s...äöü...' % u'abc' failed to raise an exception" print 'done.' --- 273,276 ---- From python-dev@python.org Wed Jun 14 10:18:11 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 14 Jun 2000 02:18:11 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects stringobject.c,2.67,2.68 Message-ID: <200006140918.CAA03749@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv3664/Objects Modified Files: stringobject.c Log Message: Marc-Andre Lemburg : Added code so that .isXXX() testing returns 0 for emtpy strings. Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.67 retrieving revision 2.68 diff -C2 -r2.67 -r2.68 *** stringobject.c 2000/06/09 14:04:53 2.67 --- stringobject.c 2000/06/14 09:18:09 2.68 *************** *** 1928,1931 **** --- 1928,1935 ---- return PyInt_FromLong(1); + /* Special case for empty strings */ + if (PyString_GET_SIZE(self) == 0) + return PyInt_FromLong(0); + e = p + PyString_GET_SIZE(self); for (; p < e; p++) { *************** *** 1957,1960 **** --- 1961,1968 ---- return PyInt_FromLong(1); + /* Special case for empty strings */ + if (PyString_GET_SIZE(self) == 0) + return PyInt_FromLong(0); + e = p + PyString_GET_SIZE(self); for (; p < e; p++) { *************** *** 1986,1989 **** --- 1994,2001 ---- return PyInt_FromLong(islower(*p) != 0); + /* Special case for empty strings */ + if (PyString_GET_SIZE(self) == 0) + return PyInt_FromLong(0); + e = p + PyString_GET_SIZE(self); cased = 0; *************** *** 2018,2021 **** --- 2030,2037 ---- return PyInt_FromLong(isupper(*p) != 0); + /* Special case for empty strings */ + if (PyString_GET_SIZE(self) == 0) + return PyInt_FromLong(0); + e = p + PyString_GET_SIZE(self); cased = 0; *************** *** 2050,2053 **** --- 2066,2073 ---- if (PyString_GET_SIZE(self) == 1) return PyInt_FromLong(isupper(*p) != 0); + + /* Special case for empty strings */ + if (PyString_GET_SIZE(self) == 0) + return PyInt_FromLong(0); e = p + PyString_GET_SIZE(self); From python-dev@python.org Wed Jun 14 10:18:35 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 14 Jun 2000 02:18:35 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.25,2.26 Message-ID: <200006140918.CAA04049@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv3975/Objects Modified Files: unicodeobject.c Log Message: Marc-Andre Lemburg : Added code so that .isXXX() testing returns 0 for emtpy strings. Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.25 retrieving revision 2.26 diff -C2 -r2.25 -r2.26 *** unicodeobject.c 2000/06/10 09:32:51 2.25 --- unicodeobject.c 2000/06/14 09:18:32 2.26 *************** *** 3307,3310 **** --- 3307,3314 ---- return PyInt_FromLong(Py_UNICODE_ISLOWER(*p) != 0); + /* Special case for empty strings */ + if (PyString_GET_SIZE(self) == 0) + return PyInt_FromLong(0); + e = p + PyUnicode_GET_SIZE(self); cased = 0; *************** *** 3340,3343 **** --- 3344,3351 ---- return PyInt_FromLong(Py_UNICODE_ISUPPER(*p) != 0); + /* Special case for empty strings */ + if (PyString_GET_SIZE(self) == 0) + return PyInt_FromLong(0); + e = p + PyUnicode_GET_SIZE(self); cased = 0; *************** *** 3375,3378 **** --- 3383,3390 ---- (Py_UNICODE_ISUPPER(*p) != 0)); + /* Special case for empty strings */ + if (PyString_GET_SIZE(self) == 0) + return PyInt_FromLong(0); + e = p + PyUnicode_GET_SIZE(self); cased = 0; *************** *** 3419,3422 **** --- 3431,3438 ---- return PyInt_FromLong(1); + /* Special case for empty strings */ + if (PyString_GET_SIZE(self) == 0) + return PyInt_FromLong(0); + e = p + PyUnicode_GET_SIZE(self); for (; p < e; p++) { *************** *** 3447,3450 **** --- 3463,3470 ---- return PyInt_FromLong(1); + /* Special case for empty strings */ + if (PyString_GET_SIZE(self) == 0) + return PyInt_FromLong(0); + e = p + PyUnicode_GET_SIZE(self); for (; p < e; p++) { *************** *** 3475,3478 **** --- 3495,3502 ---- return PyInt_FromLong(1); + /* Special case for empty strings */ + if (PyString_GET_SIZE(self) == 0) + return PyInt_FromLong(0); + e = p + PyUnicode_GET_SIZE(self); for (; p < e; p++) { *************** *** 3502,3505 **** --- 3526,3533 ---- Py_UNICODE_ISNUMERIC(*p)) return PyInt_FromLong(1); + + /* Special case for empty strings */ + if (PyString_GET_SIZE(self) == 0) + return PyInt_FromLong(0); e = p + PyUnicode_GET_SIZE(self); From python-dev@python.org Thu Jun 15 15:50:23 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 15 Jun 2000 07:50:23 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects listobject.c,2.71,2.72 rangeobject.c,2.12,2.13 tupleobject.c,2.34,2.35 Message-ID: <200006151450.HAA28440@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv28425 Modified Files: listobject.c rangeobject.c tupleobject.c Log Message: Thomas Wouters : The following patch adds "sq_contains" support to rangeobject, and enables the already-written support for sq_contains in listobject and tupleobject. The rangeobject "contains" code should be a bit more efficient than the current default "in" implementation ;-) It might not get used much, but it's not that much to add. listobject.c and tupleobject.c already had code for sq_contains, and the proper struct member was set, but the PyType structure was not extended to include tp_flags, so the object-specific code was not getting called (Go ahead, test it ;-). I also did this for the immutable_list_type in listobject.c, eventhough it is probably never used. Symmetry and all that. Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.71 retrieving revision 2.72 diff -C2 -r2.71 -r2.72 *** listobject.c 2000/06/01 14:31:03 2.71 --- listobject.c 2000/06/15 14:50:20 2.72 *************** *** 1490,1493 **** --- 1490,1500 ---- &list_as_sequence, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ }; *************** *** 1541,1544 **** --- 1548,1552 ---- (intobjargproc)immutable_list_ass, /*sq_ass_item*/ (intintobjargproc)immutable_list_ass, /*sq_ass_slice*/ + (objobjproc)list_contains, /*sq_contains*/ }; *************** *** 1558,1561 **** --- 1566,1576 ---- &immutable_list_as_sequence, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ }; Index: rangeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/rangeobject.c,v retrieving revision 2.12 retrieving revision 2.13 diff -C2 -r2.12 -r2.13 *** rangeobject.c 2000/05/03 23:44:35 2.12 --- rangeobject.c 2000/06/15 14:50:20 2.13 *************** *** 238,241 **** --- 238,258 ---- } + static int + range_contains(r, obj) + rangeobject * r; + PyObject * obj; + { + long num = PyInt_AsLong(obj); + + if (num < 0 && PyErr_Occurred()) + return -1; + + if (num < r->start || (num - r->start) % r->step) + return 0; + if (num > (r->start + (r->len * r->step))) + return 0; + return 1; + } + static PySequenceMethods range_as_sequence = { (inquiry)range_length, /*sq_length*/ *************** *** 246,249 **** --- 263,267 ---- 0, /*sq_ass_item*/ 0, /*sq_ass_slice*/ + (objobjproc)range_contains, /*sq_contains*/ }; *************** *** 263,265 **** --- 281,290 ---- &range_as_sequence, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ }; Index: tupleobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/tupleobject.c,v retrieving revision 2.34 retrieving revision 2.35 diff -C2 -r2.34 -r2.35 *** tupleobject.c 2000/06/01 03:12:13 2.34 --- tupleobject.c 2000/06/15 14:50:20 2.35 *************** *** 448,451 **** --- 448,457 ---- 0, /*tp_as_mapping*/ (hashfunc)tuplehash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ }; From python-dev@python.org Thu Jun 15 19:44:35 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 15 Jun 2000 11:44:35 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libdis.tex,1.18,1.19 Message-ID: <200006151844.LAA01311@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv1301/lib Modified Files: libdis.tex Log Message: Michael Hudson : This patch corrects a little glitch and two outright errors. (Including one reported earlier by Thomas Wouters.) Index: libdis.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdis.tex,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** libdis.tex 1999/05/17 20:57:07 1.18 --- libdis.tex 2000/06/15 18:44:30 1.19 *************** *** 155,159 **** \begin{opcodedesc}{UNARY_INVERT}{} ! Implements \code{TOS = \~TOS}. \end{opcodedesc} --- 155,159 ---- \begin{opcodedesc}{UNARY_INVERT}{} ! Implements \code{TOS = \~{}TOS}. \end{opcodedesc} *************** *** 175,179 **** \begin{opcodedesc}{BINARY_MODULO}{} ! Implements \code{TOS = TOS1 \% TOS}. \end{opcodedesc} --- 175,179 ---- \begin{opcodedesc}{BINARY_MODULO}{} ! Implements \code{TOS = TOS1 \%{} TOS}. \end{opcodedesc} *************** *** 199,203 **** \begin{opcodedesc}{BINARY_AND}{} ! Implements \code{TOS = TOS1 and TOS}. \end{opcodedesc} --- 199,203 ---- \begin{opcodedesc}{BINARY_AND}{} ! Implements \code{TOS = TOS1 \&\ TOS}. \end{opcodedesc} *************** *** 207,211 **** \begin{opcodedesc}{BINARY_OR}{} ! Implements \code{TOS = TOS1 or TOS}. \end{opcodedesc} --- 207,211 ---- \begin{opcodedesc}{BINARY_OR}{} ! Implements \code{TOS = TOS1 | TOS}. \end{opcodedesc} From python-dev@python.org Thu Jun 15 21:07:27 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 15 Jun 2000 13:07:27 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/ref ref3.tex,1.42,1.43 Message-ID: <200006152007.NAA16232@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/ref In directory slayer.i.sourceforge.net:/tmp/cvs-serv16223 Modified Files: ref3.tex Log Message: Fix markup error that hid a tilde character; reported long ago by Carl Feynman . Index: ref3.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref3.tex,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -r1.42 -r1.43 *** ref3.tex 2000/04/06 14:00:14 1.42 --- ref3.tex 2000/06/15 20:07:25 1.43 *************** *** 934,937 **** --- 934,948 ---- \end{methoddesc} + \begin{methoddesc}[object]{__rcmp__}{self, other} + Called by all comparison operations. Should return a negative integer if + \code{self < other}, zero if \code{self == other}, a positive integer if + \code{self > other}. If no \method{__cmp__()} operation is defined, class + instances are compared by object identity (``address''). + (Note: the restriction that exceptions are not propagated by + \method{__cmp__()} has been removed in Python 1.5.) + \bifuncindex{cmp} + \index{comparisons} + \end{methoddesc} + \begin{methoddesc}[object]{__hash__}{self} Called for the key object for dictionary\obindex{dictionary} *************** *** 1202,1206 **** \methodline[numeric object]{__invert__}{self} Called to implement the unary arithmetic operations (\code{-}, \code{+}, ! \function{abs()}\bifuncindex{abs} and \code{~}). \end{methoddesc} --- 1213,1217 ---- \methodline[numeric object]{__invert__}{self} Called to implement the unary arithmetic operations (\code{-}, \code{+}, ! \function{abs()}\bifuncindex{abs} and \code{\~{}}). \end{methoddesc} From python-dev@python.org Thu Jun 15 23:41:51 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 15 Jun 2000 15:41:51 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/perl python.perl,1.75,1.76 Message-ID: <200006152241.PAA08164@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/perl In directory slayer.i.sourceforge.net:/tmp/cvs-serv8153/perl Modified Files: python.perl Log Message: do_cmd_textasciitilde(): New function. Index: python.perl =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/perl/python.perl,v retrieving revision 1.75 retrieving revision 1.76 diff -C2 -r1.75 -r1.76 *** python.perl 2000/05/09 16:17:51 1.75 --- python.perl 2000/06/15 22:41:48 1.76 *************** *** 53,56 **** --- 53,61 ---- + # the older version of LaTeX2HTML we use doesn't support this, but we use it: + + sub do_cmd_textasciitilde{ '~' . @_[0]; } + + # words typeset in a special way (not in HTML though) From python-dev@python.org Fri Jun 16 18:06:00 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Fri, 16 Jun 2000 10:06:00 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects tupleobject.c,2.35,2.36 Message-ID: <200006161706.KAA08640@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv8633/Objects Modified Files: tupleobject.c Log Message: Michael Hudson : The error message refers to "append", yet the operation in question is "concat". Index: tupleobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/tupleobject.c,v retrieving revision 2.35 retrieving revision 2.36 diff -C2 -r2.35 -r2.36 *** tupleobject.c 2000/06/15 14:50:20 2.35 --- tupleobject.c 2000/06/16 17:05:57 2.36 *************** *** 363,367 **** if (!PyTuple_Check(bb)) { PyErr_Format(PyExc_TypeError, ! "can only append tuple (not \"%.200s\") to tuple", bb->ob_type->tp_name); return NULL; --- 363,367 ---- if (!PyTuple_Check(bb)) { PyErr_Format(PyExc_TypeError, ! "can only concatenate tuple (not \"%.200s\") to tuple", bb->ob_type->tp_name); return NULL; From python-dev@python.org Fri Jun 16 20:58:45 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 16 Jun 2000 12:58:45 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/api api.tex,1.65,1.66 Message-ID: <200006161958.MAA30426@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/api In directory slayer.i.sourceforge.net:/tmp/cvs-serv30416 Modified Files: api.tex Log Message: Documented PySequence_List() and PySequence_Tuple(). Added a bit more documentation in the chapter on building extension types, including Py_FindMethod() documentation. Several minor consistency nits were fixed. Index: api.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/api.tex,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -r1.65 -r1.66 *** api.tex 2000/04/10 18:50:14 1.65 --- api.tex 2000/06/16 19:58:42 1.66 *************** *** 211,215 **** Nothing needs to be done for a borrowed reference. ! Conversely, when calling a function passes it a reference to an object, there are two possibilities: the function \emph{steals} a reference to the object, or it does not. Few functions steal --- 211,215 ---- Nothing needs to be done for a borrowed reference. ! Conversely, when a calling function passes it a reference to an object, there are two possibilities: the function \emph{steals} a reference to the object, or it does not. Few functions steal *************** *** 603,607 **** value of \cfunction{PyRun_InteractiveLoop()}, otherwise return the result of \cfunction{PyRun_SimpleFile()}. If \var{filename} is ! \NULL{}, this function uses \code{"???"} as the filename. \end{cfuncdesc} --- 603,607 ---- value of \cfunction{PyRun_InteractiveLoop()}, otherwise return the result of \cfunction{PyRun_SimpleFile()}. If \var{filename} is ! \NULL{}, this function uses \code{'???'} as the filename. \end{cfuncdesc} *************** *** 1025,1029 **** \cdata{Py_InteractiveFlag} is true, this function also returns true if the \var{name} pointer is \NULL{} or if the name is equal to one of ! the strings \code{""} or \code{"???"}. \end{cfuncdesc} --- 1025,1029 ---- \cdata{Py_InteractiveFlag} is true, this function also returns true if the \var{name} pointer is \NULL{} or if the name is equal to one of ! the strings \code{''} or \code{'???'}. \end{cfuncdesc} *************** *** 1664,1668 **** --- 1664,1679 ---- \end{cfuncdesc} + \begin{cfuncdesc}{PyObject*}{PySequence_List}{PyObject *o} + Return a list object with the same contents as the arbitrary sequence + \var{o}. The returned list is guaranteed to be new. + \end{cfuncdesc} + + \begin{cfuncdesc}{PyObject*}{PySequence_Tuple}{PyObject *o} + Return a tuple object with the same contents as the arbitrary sequence + \var{o}. If \var{o} is a tuple, a new reference will be returned, + otherwise a tuple will be constructed with the appropriate contents. + \end{cfuncdesc} + \section{Mapping Protocol \label{mapping}} *************** *** 2232,2236 **** Unicode data in \var{s}. ! If \var{byteorder} is not 0, output is written according to the following byte order: --- 2243,2247 ---- Unicode data in \var{s}. ! If \var{byteorder} is not \code{0}, output is written according to the following byte order: *************** *** 2241,2245 **** \end{verbatim} ! If byteorder is 0, the output string will always start with the Unicode BOM mark (U+FEFF). In the other two modes, no BOM mark is prepended. --- 2252,2256 ---- \end{verbatim} ! If byteorder is \code{0}, the output string will always start with the Unicode BOM mark (U+FEFF). In the other two modes, no BOM mark is prepended. *************** *** 2253,2257 **** \begin{cfuncdesc}{PyObject*}{PyUnicode_AsUTF16String}{PyObject *unicode} - Returns a Python string using the UTF-16 encoding in native byte order. The string always starts with a BOM mark. Error handling is --- 2264,2267 ---- *************** *** 3603,3607 **** used by \cfunction{Py_GetPath()}\ttindex{Py_GetPath()} and some other functions below to find the Python run-time libraries relative to the ! interpreter executable. The default value is \code{"python"}. The argument should point to a zero-terminated character string in static storage whose contents will not change for the duration of the --- 3613,3617 ---- used by \cfunction{Py_GetPath()}\ttindex{Py_GetPath()} and some other functions below to find the Python run-time libraries relative to the ! interpreter executable. The default value is \code{'python'}. The argument should point to a zero-terminated character string in static storage whose contents will not change for the duration of the *************** *** 3621,3629 **** is derived through a number of complicated rules from the program name set with \cfunction{Py_SetProgramName()} and some environment variables; ! for example, if the program name is \code{"/usr/local/bin/python"}, ! the prefix is \code{"/usr/local"}. The returned string points into static storage; the caller should not modify its value. This corresponds to the \makevar{prefix} variable in the top-level ! \file{Makefile} and the \programopt{-}\programopt{-prefix} argument to the \program{configure} script at build time. The value is available to Python code as \code{sys.prefix}. It is only useful on \UNIX{}. See --- 3631,3639 ---- is derived through a number of complicated rules from the program name set with \cfunction{Py_SetProgramName()} and some environment variables; ! for example, if the program name is \code{'/usr/local/bin/python'}, ! the prefix is \code{'/usr/local'}. The returned string points into static storage; the caller should not modify its value. This corresponds to the \makevar{prefix} variable in the top-level ! \file{Makefile} and the \longprogramopt{prefix} argument to the \program{configure} script at build time. The value is available to Python code as \code{sys.prefix}. It is only useful on \UNIX{}. See *************** *** 3636,3644 **** program name set with \cfunction{Py_SetProgramName()} and some environment variables; for example, if the program name is ! \code{"/usr/local/bin/python"}, the exec-prefix is ! \code{"/usr/local"}. The returned string points into static storage; the caller should not modify its value. This corresponds to the \makevar{exec_prefix} variable in the top-level \file{Makefile} and the ! \programopt{-}\programopt{-exec_prefix} argument to the \program{configure} script at build time. The value is available to Python code as \code{sys.exec_prefix}. It is only useful on \UNIX{}. --- 3646,3654 ---- program name set with \cfunction{Py_SetProgramName()} and some environment variables; for example, if the program name is ! \code{'/usr/local/bin/python'}, the exec-prefix is ! \code{'/usr/local'}. The returned string points into static storage; the caller should not modify its value. This corresponds to the \makevar{exec_prefix} variable in the top-level \file{Makefile} and the ! \longprogramopt{exec-prefix} argument to the \program{configure} script at build time. The value is available to Python code as \code{sys.exec_prefix}. It is only useful on \UNIX{}. *************** *** 3648,3653 **** installed in a different directory tree. In a typical installation, platform dependent files may be installed in the ! \code{"/usr/local/plat"} subtree while platform independent may be ! installed in \code{"/usr/local"}. Generally speaking, a platform is a combination of hardware and --- 3658,3663 ---- installed in a different directory tree. In a typical installation, platform dependent files may be installed in the ! \file{/usr/local/plat} subtree while platform independent may be ! installed in \file{/usr/local}. Generally speaking, a platform is a combination of hardware and *************** *** 3664,3669 **** System administrators will know how to configure the \program{mount} or ! \program{automount} programs to share \code{"/usr/local"} between platforms ! while having \code{"/usr/local/plat"} be a different filesystem for each platform. \end{cfuncdesc} --- 3674,3679 ---- System administrators will know how to configure the \program{mount} or ! \program{automount} programs to share \file{/usr/local} between platforms ! while having \file{/usr/local/plat} be a different filesystem for each platform. \end{cfuncdesc} *************** *** 3718,3723 **** converted to lower case, followed by the major revision number; e.g., for Solaris 2.x, which is also known as SunOS 5.x, the value is ! \code{"sunos5"}. On Macintosh, it is \code{"mac"}. On Windows, it ! is \code{"win"}. The returned string points into static storage; the caller should not modify its value. The value is available to Python code as \code{sys.platform}. --- 3728,3733 ---- converted to lower case, followed by the major revision number; e.g., for Solaris 2.x, which is also known as SunOS 5.x, the value is ! \code{'sunos5'}. On Macintosh, it is \code{'mac'}. On Windows, it ! is \code{'win'}. The returned string points into static storage; the caller should not modify its value. The value is available to Python code as \code{sys.platform}. *************** *** 3729,3733 **** for example ! \code{"Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam"} The returned string points into static storage; the caller should not --- 3739,3743 ---- for example ! \code{'Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam'} The returned string points into static storage; the caller should not *************** *** 4376,4379 **** --- 4386,4413 ---- destructor, printfunc, getattrfunc, getattrofunc, setattrfunc, setattrofunc, cmpfunc, reprfunc, hashfunc + + \begin{ctypedesc}{PyCFunction} + Type of the functions used to implement most Python callables in C. + \end{ctypedesc} + + \begin{ctypedesc}{PyMethodDef} + Structure used to describe a method of an extension type. This + structure has four fields: + + \begin{tableiii}{l|l|l}{member}{Field}{C Type}{Meaning} + \lineiii{ml_name}{char *}{name of the method} + \lineiii{ml_meth}{PyCFunction}{pointer to the C implementation} + \lineiii{ml_flags}{int}{flag bits indicating how the call should be + constructed} + \lineiii{ml_doc}{char *}{points to the contents of the docstring} + \end{tableiii} + \end{ctypedesc} + + \begin{cfuncdesc}{PyObject*}{Py_FindMethod}{PyMethodDef[] table, + PyObject *ob, char *name} + Return a bound method object for an extension type implemented in C. + This function also handles the special attribute \member{__methods__}, + returning a list of all the method names defined in \var{table}. + \end{cfuncdesc} From python-dev@python.org Fri Jun 16 21:00:06 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 16 Jun 2000 13:00:06 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/api refcounts.dat,1.8,1.9 Message-ID: <200006162000.NAA30761@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/api In directory slayer.i.sourceforge.net:/tmp/cvs-serv30602 Modified Files: refcounts.dat Log Message: Added reference count information for PySequence_List(). Index: refcounts.dat =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/refcounts.dat,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** refcounts.dat 2000/04/10 19:38:24 1.8 --- refcounts.dat 2000/06/16 20:00:04 1.9 *************** *** 727,730 **** --- 727,733 ---- PySequence_SetSlice:PyObject*:v:+1: + PySequence_List:PyObject*::+1: + PySequence_List:PyObject*:o:0: + PySequence_Tuple:PyObject*::+1: PySequence_Tuple:PyObject*:o:0: From python-dev@python.org Fri Jun 16 22:04:17 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 16 Jun 2000 14:04:17 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/api api.tex,1.66,1.67 refcounts.dat,1.9,1.10 Message-ID: <200006162104.OAA13827@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/api In directory slayer.i.sourceforge.net:/tmp/cvs-serv13811 Modified Files: api.tex refcounts.dat Log Message: Updates from Marc-Andre Lemburg for the Unicode support. Index: api.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/api.tex,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -r1.66 -r1.67 *** api.tex 2000/06/16 19:58:42 1.66 --- api.tex 2000/06/16 21:04:15 1.67 *************** *** 1967,1976 **** \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyUnicode_AS_UNICODE}{PyObject *o} Returns a pointer to the internal Py_UNICODE buffer of the object. o has to be a PyUnicodeObject (not checked). \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyUnicode_AS_DATA}{PyObject *o} Returns a (const char *) pointer to the internal buffer of the object. o has to be a PyUnicodeObject (not checked). --- 1967,1976 ---- \end{cfuncdesc} ! \begin{cfuncdesc}{Py_UNICODE*}{PyUnicode_AS_UNICODE}{PyObject *o} Returns a pointer to the internal Py_UNICODE buffer of the object. o has to be a PyUnicodeObject (not checked). \end{cfuncdesc} ! \begin{cfuncdesc}{const char*}{PyUnicode_AS_DATA}{PyObject *o} Returns a (const char *) pointer to the internal buffer of the object. o has to be a PyUnicodeObject (not checked). Index: refcounts.dat =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/refcounts.dat,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** refcounts.dat 2000/06/16 20:00:04 1.9 --- refcounts.dat 2000/06/16 21:04:15 1.10 *************** *** 823,826 **** --- 823,1097 ---- PyTuple_Size:PyTupleObject*:p:0: + PyUnicode_Check:int::: + PyUnicode_Check:PyObject*:o:0: + + PyUnicode_GET_SIZE:int::: + PyUnicode_GET_SIZE:PyObject*:o:0: + + PyUnicode_GET_DATA_SIZE:int::: + PyUnicode_GET_DATA_SIZE:PyObject*:o:0: + + PyUnicode_AS_UNICODE:Py_UNICODE*::: + PyUnicode_AS_UNICODE:PyObject*:o:0: + + PyUnicode_AS_DATA:const char*::: + PyUnicode_AS_DATA:PyObject*:o:0: + + Py_UNICODE_ISSPACE:int::: + Py_UNICODE_ISSPACE:Py_UNICODE:ch:: + + Py_UNICODE_ISLOWER:int::: + Py_UNICODE_ISLOWER:Py_UNICODE:ch:: + + Py_UNICODE_ISUPPER:int::: + Py_UNICODE_ISUPPER:Py_UNICODE:ch:: + + Py_UNICODE_ISTITLE:int::: + Py_UNICODE_ISTITLE:Py_UNICODE:ch:: + + Py_UNICODE_ISLINEBREAK:int::: + Py_UNICODE_ISLINEBREAK:Py_UNICODE:ch:: + + Py_UNICODE_ISDECIMAL:int::: + Py_UNICODE_ISDECIMAL:Py_UNICODE:ch:: + + Py_UNICODE_ISDIGIT:int::: + Py_UNICODE_ISDIGIT:Py_UNICODE:ch:: + + Py_UNICODE_ISNUMERIC:int::: + Py_UNICODE_ISNUMERIC:Py_UNICODE:ch:: + + Py_UNICODE_TOLOWER:Py_UNICODE::: + Py_UNICODE_TOLOWER:Py_UNICODE:ch:: + + Py_UNICODE_TOUPPER:Py_UNICODE::: + Py_UNICODE_TOUPPER:Py_UNICODE:ch:: + + Py_UNICODE_TOTITLE:Py_UNICODE::: + Py_UNICODE_TOTITLE:Py_UNICODE:ch:: + + Py_UNICODE_TODECIMAL:int::: + Py_UNICODE_TODECIMAL:Py_UNICODE:ch:: + + Py_UNICODE_TODIGIT:int::: + Py_UNICODE_TODIGIT:Py_UNICODE:ch:: + + Py_UNICODE_TONUMERIC:double::: + Py_UNICODE_TONUMERIC:Py_UNICODE:ch:: + + PyUnicode_FromUnicode:PyObject*::+1: + PyUnicode_FromUnicode:const Py_UNICODE *:u:: + PyUnicode_FromUnicode:int:size:: + + PyUnicode_AsUnicode:Py_UNICODE*::: + PyUnicode_AsUnicode:PyObject :*unicode:0: + + PyUnicode_GetSize:int::: + PyUnicode_GetSize:PyObject :*unicode:0: + + PyUnicode_FromObject:PyObject*::+1: + PyUnicode_FromObject:PyObject :*obj:0: + + PyUnicode_FromWideChar:PyObject*::+1: + PyUnicode_FromWideChar:const wchar_t *:w:: + PyUnicode_FromWideChar:int:size:: + + PyUnicode_AsWideChar:int::: + PyUnicode_AsWideChar:PyObject :*unicode:0: + PyUnicode_AsWideChar:wchar_t *:w:: + PyUnicode_AsWideChar:int:size:: + + PyUnicode_Decode:PyObject*::+1: + PyUnicode_Decode:const char *:s:: + PyUnicode_Decode:int:size:: + PyUnicode_Decode:const char *:encoding:: + PyUnicode_Decode:const char *:errors:: + + PyUnicode_Encode:PyObject*::+1: + PyUnicode_Encode:const Py_UNICODE *:s:: + PyUnicode_Encode:int:size:: + PyUnicode_Encode:const char *:encoding:: + PyUnicode_Encode:const char *:errors:: + + PyUnicode_AsEncodedString:PyObject*::+1: + PyUnicode_AsEncodedString:PyObject *:unicode:: + PyUnicode_AsEncodedString:const char *:encoding:: + PyUnicode_AsEncodedString:const char *:errors:: + + PyUnicode_DecodeUTF8:PyObject*::+1: + PyUnicode_DecodeUTF8:const char *:s:: + PyUnicode_DecodeUTF8:int:size:: + PyUnicode_DecodeUTF8:const char *:errors:: + + PyUnicode_EncodeUTF8:PyObject*::+1: + PyUnicode_EncodeUTF8:const Py_UNICODE *:s:: + PyUnicode_EncodeUTF8:int:size:: + PyUnicode_EncodeUTF8:const char *:errors:: + + PyUnicode_AsUTF8String:PyObject*::+1: + PyUnicode_AsUTF8String:PyObject *:unicode:: + + PyUnicode_DecodeUTF16:PyObject*::+1: + PyUnicode_DecodeUTF16:const char *:s:: + PyUnicode_DecodeUTF16:int:size:: + PyUnicode_DecodeUTF16:const char *:errors:: + PyUnicode_DecodeUTF16:int*:byteorder:: + + PyUnicode_EncodeUTF16:PyObject*::+1: + PyUnicode_EncodeUTF16:const Py_UNICODE *:s:: + PyUnicode_EncodeUTF16:int:size:: + PyUnicode_EncodeUTF16:const char *:errors:: + PyUnicode_EncodeUTF16:int:byteorder:: + + PyUnicode_AsUTF16String:PyObject*::+1: + PyUnicode_AsUTF16String:PyObject *:unicode:: + + PyUnicode_DecodeUnicodeEscape:PyObject*::+1: + PyUnicode_DecodeUnicodeEscape:const char *:s:: + PyUnicode_DecodeUnicodeEscape:int:size:: + PyUnicode_DecodeUnicodeEscape:const char *:errors:: + + PyUnicode_EncodeUnicodeEscape:PyObject*::+1: + PyUnicode_EncodeUnicodeEscape:const Py_UNICODE *:s:: + PyUnicode_EncodeUnicodeEscape:int:size:: + PyUnicode_EncodeUnicodeEscape:const char *:errors:: + + PyUnicode_AsUnicodeEscapeString:PyObject*::+1: + PyUnicode_AsUnicodeEscapeString:PyObject *:unicode:: + + PyUnicode_DecodeRawUnicodeEscape:PyObject*::+1: + PyUnicode_DecodeRawUnicodeEscape:const char *:s:: + PyUnicode_DecodeRawUnicodeEscape:int:size:: + PyUnicode_DecodeRawUnicodeEscape:const char *:errors:: + + PyUnicode_EncodeRawUnicodeEscape:PyObject*::+1: + PyUnicode_EncodeRawUnicodeEscape:const Py_UNICODE *:s:: + PyUnicode_EncodeRawUnicodeEscape:int:size:: + PyUnicode_EncodeRawUnicodeEscape:const char *:errors:: + + PyUnicode_AsRawUnicodeEscapeString:PyObject*::+1: + PyUnicode_AsRawUnicodeEscapeString:PyObject *:unicode:: + + PyUnicode_DecodeLatin1:PyObject*::+1: + PyUnicode_DecodeLatin1:const char *:s:: + PyUnicode_DecodeLatin1:int:size:: + PyUnicode_DecodeLatin1:const char *:errors:: + + PyUnicode_EncodeLatin1:PyObject*::+1: + PyUnicode_EncodeLatin1:const Py_UNICODE *:s:: + PyUnicode_EncodeLatin1:int:size:: + PyUnicode_EncodeLatin1:const char *:errors:: + + PyUnicode_AsLatin1String:PyObject*::+1: + PyUnicode_AsLatin1String:PyObject *:unicode:: + + PyUnicode_DecodeASCII:PyObject*::+1: + PyUnicode_DecodeASCII:const char *:s:: + PyUnicode_DecodeASCII:int:size:: + PyUnicode_DecodeASCII:const char *:errors:: + + PyUnicode_EncodeASCII:PyObject*::+1: + PyUnicode_EncodeASCII:const Py_UNICODE *:s:: + PyUnicode_EncodeASCII:int:size:: + PyUnicode_EncodeASCII:const char *:errors:: + + PyUnicode_AsASCIIString:PyObject*::+1: + PyUnicode_AsASCIIString:PyObject *:unicode:: + + PyUnicode_DecodeCharmap:PyObject*::+1: + PyUnicode_DecodeCharmap:const char *:s:: + PyUnicode_DecodeCharmap:int:size:: + PyUnicode_DecodeCharmap:PyObject*:mapping:0: + PyUnicode_DecodeCharmap:const char *:errors:: + + PyUnicode_EncodeCharmap:PyObject*::+1: + PyUnicode_EncodeCharmap:const Py_UNICODE *:s:: + PyUnicode_EncodeCharmap:int:size:: + PyUnicode_EncodeCharmap:PyObject*:mapping:0: + PyUnicode_EncodeCharmap:const char *:errors:: + + PyUnicode_AsCharmapString:PyObject*::+1: + PyUnicode_AsCharmapString:PyObject*:unicode:0: + PyUnicode_AsCharmapString:PyObject*:mapping:0: + + PyUnicode_TranslateCharmap:PyObject*::+1: + PyUnicode_TranslateCharmap:const Py_UNICODE *:s:: + PyUnicode_TranslateCharmap:int:size:: + PyUnicode_TranslateCharmap:PyObject*:table:0: + PyUnicode_TranslateCharmap:const char *:errors:: + + PyUnicode_DecodeMBCS:PyObject*::+1: + PyUnicode_DecodeMBCS:const char *:s:: + PyUnicode_DecodeMBCS:int:size:: + PyUnicode_DecodeMBCS:const char *:errors:: + + PyUnicode_EncodeMBCS:PyObject*::+1: + PyUnicode_EncodeMBCS:const Py_UNICODE *:s:: + PyUnicode_EncodeMBCS:int:size:: + PyUnicode_EncodeMBCS:const char *:errors:: + + PyUnicode_AsMBCSString:PyObject*::+1: + PyUnicode_AsMBCSString:PyObject *:unicode:: + + PyUnicode_Concat:PyObject*::+1: + PyUnicode_Concat:PyObject*:left:0: + PyUnicode_Concat:PyObject*:right:0: + + PyUnicode_Split:PyObject*::+1: + PyUnicode_Split:PyObject*:left:0: + PyUnicode_Split:PyObject*:right:0: + PyUnicode_Split:int:maxsplit:: + + PyUnicode_Splitlines:PyObject*::+1: + PyUnicode_Splitlines:PyObject*:s:0: + PyUnicode_Splitlines:int:maxsplit:: + + PyUnicode_Translate:PyObject*::+1: + PyUnicode_Translate:PyObject*:str:0: + PyUnicode_Translate:PyObject*:table:0: + PyUnicode_Translate:const char *:errors:: + + PyUnicode_Join:PyObject*::+1: + PyUnicode_Join:PyObject*:separator:0: + PyUnicode_Join:PyObject*:seq:0: + + PyUnicode_Tailmatch:PyObject*::+1: + PyUnicode_Tailmatch:PyObject*:str:0: + PyUnicode_Tailmatch:PyObject*:substr:0: + PyUnicode_Tailmatch:int:start:: + PyUnicode_Tailmatch:int:end:: + PyUnicode_Tailmatch:int:direction:: + + PyUnicode_Find:PyObject*::+1: + PyUnicode_Find:PyObject*:str:0: + PyUnicode_Find:PyObject*:substr:0: + PyUnicode_Find:int:start:: + PyUnicode_Find:int:end:: + PyUnicode_Find:int:direction:: + + PyUnicode_Count:PyObject*::+1: + PyUnicode_Count:PyObject*:str:0: + PyUnicode_Count:PyObject*:substr:0: + PyUnicode_Count:int:start:: + PyUnicode_Count:int:end:: + + PyUnicode_Replace:PyObject*::+1: + PyUnicode_Replace:PyObject*:str:0: + PyUnicode_Replace:PyObject*:substr:0: + PyUnicode_Replace:PyObject*:replstr:0: + PyUnicode_Replace:int:maxcount:: + + PyUnicode_Compare:int::: + PyUnicode_Compare:PyObject*:left:0: + PyUnicode_Compare:PyObject*:right:0: + + PyUnicode_Format:PyObject*::+1: + PyUnicode_Format:PyObject*:format:0: + PyUnicode_Format:PyObject*:args:0: + + PyUnicode_Contains:int::: + PyUnicode_Contains:PyObject*:container:0: + PyUnicode_Contains:PyObject*:element:0: + Py_AtExit:int::: Py_AtExit:void (*)():func:: From python-dev@python.org Sat Jun 17 02:34:47 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 16 Jun 2000 18:34:47 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command install.py,1.36,1.37 Message-ID: <200006170134.SAA20203@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv20191 Modified Files: install.py Log Message: Fixed install directory for header files on Unix. Index: install.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/install.py,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -r1.36 -r1.37 *** install.py 2000/05/31 02:32:10 1.36 --- install.py 2000/06/17 01:34:45 1.37 *************** *** 19,23 **** 'purelib': '$base/lib/python$py_version_short/site-packages', 'platlib': '$platbase/lib/python$py_version_short/site-packages', ! 'headers': '$base/include/python/$py_version_short/$dist_name', 'scripts': '$base/bin', 'data' : '$base/share', --- 19,23 ---- 'purelib': '$base/lib/python$py_version_short/site-packages', 'platlib': '$platbase/lib/python$py_version_short/site-packages', ! 'headers': '$base/include/python$py_version_short/$dist_name', 'scripts': '$base/bin', 'data' : '$base/share', From python-dev@python.org Sat Jun 17 02:58:17 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 16 Jun 2000 18:58:17 -0700 Subject: [Python-checkins] CVS: distutils/distutils dir_util.py,1.2,1.3 Message-ID: <200006170158.SAA21066@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv21031 Modified Files: dir_util.py Log Message: Bastian Kleineidam: added 'remove_tree()' function. Needed so that 'remove_tree()' can cooperate with 'mkpath()' in the maintenance of the PATH_CREATED cache: specifically, if a directory is created with 'mkpath()', later removed with 'remove_tree()', and 'mkpath()' is again requested to create it, then it would erroneously think the directory already existed, because it was in the PATH_CREATED cache. The patch (slightly tweaked by me) fixes that. Index: dir_util.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/dir_util.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** dir_util.py 2000/05/27 01:35:27 1.2 --- dir_util.py 2000/06/17 01:58:14 1.3 *************** *** 181,202 **** # copy_tree () def remove_tree (directory, verbose=0, dry_run=0): """Recursively remove an entire directory tree. Any errors are ignored (apart from being reported to stdout if 'verbose' is true).""" - - from shutil import rmtree if verbose: print "removing '%s' (and everything under it)" % directory if dry_run: return ! try: ! rmtree(directory,1) ! except (IOError, OSError), exc: ! if verbose: ! if exc.filename: ! print "error removing %s: %s (%s)" % \ (directory, exc.strerror, exc.filename) ! else: ! print "error removing %s: %s" % (directory, exc.strerror) --- 181,217 ---- # copy_tree () + # Helper for remove_tree() + def _build_cmdtuple(path, cmdtuples): + for f in os.listdir(path): + real_f = os.path.join(path,f) + if os.path.isdir(real_f) and not os.path.islink(real_f): + _build_cmdtuple(real_f, cmdtuples) + else: + cmdtuples.append((os.remove, real_f)) + cmdtuples.append((os.rmdir, path)) + def remove_tree (directory, verbose=0, dry_run=0): """Recursively remove an entire directory tree. Any errors are ignored (apart from being reported to stdout if 'verbose' is true).""" + global PATH_CREATED if verbose: print "removing '%s' (and everything under it)" % directory if dry_run: return ! cmdtuples = [] ! _build_cmdtuple(directory, cmdtuples) ! for cmd in cmdtuples: ! try: ! apply(cmd[0], (cmd[1],)) ! # remove dir from cache if it's already there ! if PATH_CREATED.has_key(cmd[1]): ! del PATH_CREATED[cmd[1]] ! except (IOError, OSError), exc: ! if verbose: ! if exc.filename: ! print "error removing %s: %s (%s)" % \ (directory, exc.strerror, exc.filename) ! else: ! print "error removing %s: %s" % (directory, exc.strerror) From python-dev@python.org Sat Jun 17 03:16:49 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 16 Jun 2000 19:16:49 -0700 Subject: [Python-checkins] CVS: distutils/distutils util.py,1.34,1.35 Message-ID: <200006170216.TAA27797@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv27784 Modified Files: util.py Log Message: Added 'grok_environment_error()' function to deal with the various forms that IOError and OSError can take (taken from core.py). Index: util.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/util.py,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -r1.34 -r1.35 *** util.py 2000/05/31 02:32:10 1.34 --- util.py 2000/06/17 02:16:46 1.35 *************** *** 155,156 **** --- 155,176 ---- + def grok_environment_error (exc, prefix="error: "): + """Generate a useful error message from an EnvironmentError (IOError or + OSError) exception object. Handles Python 1.5.1 and 1.5.2 styles, and + does what it can to deal with exception objects that don't have a + filename (which happens when the error is due to a two-file operation, + such as 'rename()' or 'link()'. Returns the error message as a string + prefixed with 'prefix'. + """ + # check for Python 1.5.2-style {IO,OS}Error exception objects + if hasattr (exc, 'filename') and hasattr (exc, 'strerror'): + if exc.filename: + error = prefix + "%s: %s" % (exc.filename, exc.strerror) + else: + # two-argument functions in posix module don't + # include the filename in the exception object! + error = prefix + "%s" % exc.strerror + else: + error = prefix + str(exc[-1]) + + return error From python-dev@python.org Sat Jun 17 03:17:47 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 16 Jun 2000 19:17:47 -0700 Subject: [Python-checkins] CVS: distutils/distutils core.py,1.41,1.42 Message-ID: <200006170217.TAA27912@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv27893 Modified Files: core.py Log Message: Changed to use the new 'grok_environment_error()' function instead of muddling through IOError and OSError exception objects right here. Index: core.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/core.py,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -r1.41 -r1.42 *** core.py 2000/06/03 01:02:06 1.41 --- core.py 2000/06/17 02:17:45 1.42 *************** *** 113,126 **** raise SystemExit, "interrupted" except (IOError, os.error), exc: ! # check for Python 1.5.2-style {IO,OS}Error exception objects ! if hasattr (exc, 'filename') and hasattr (exc, 'strerror'): ! if exc.filename: ! error = "error: %s: %s" % (exc.filename, exc.strerror) ! else: ! # two-argument functions in posix module don't ! # include the filename in the exception object! ! error = "error: %s" % exc.strerror ! else: ! error = "error: " + str(exc[-1]) if DEBUG: --- 113,117 ---- raise SystemExit, "interrupted" except (IOError, os.error), exc: ! error = grok_environment_error(exc) if DEBUG: From python-dev@python.org Sat Jun 17 03:18:22 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 16 Jun 2000 19:18:22 -0700 Subject: [Python-checkins] CVS: distutils/distutils dir_util.py,1.3,1.4 Message-ID: <200006170218.TAA27986@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv27970 Modified Files: dir_util.py Log Message: Changed 'remove_tree()' to use the new 'grok_environment_error()' function instead of muddling through IOError and OSError exception objects itself. Index: dir_util.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/dir_util.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** dir_util.py 2000/06/17 01:58:14 1.3 --- dir_util.py 2000/06/17 02:18:19 1.4 *************** *** 194,200 **** def remove_tree (directory, verbose=0, dry_run=0): """Recursively remove an entire directory tree. Any errors are ignored ! (apart from being reported to stdout if 'verbose' is true).""" ! global PATH_CREATED if verbose: print "removing '%s' (and everything under it)" % directory --- 194,202 ---- def remove_tree (directory, verbose=0, dry_run=0): """Recursively remove an entire directory tree. Any errors are ignored ! (apart from being reported to stdout if 'verbose' is true). ! """ ! from distutils.util import grok_environment_error global PATH_CREATED + if verbose: print "removing '%s' (and everything under it)" % directory *************** *** 211,217 **** except (IOError, OSError), exc: if verbose: ! if exc.filename: ! print "error removing %s: %s (%s)" % \ ! (directory, exc.strerror, exc.filename) ! else: ! print "error removing %s: %s" % (directory, exc.strerror) --- 213,216 ---- except (IOError, OSError), exc: if verbose: ! print grok_environment_error( ! exc, "error removing %s: " % directory) From python-dev@python.org Sat Jun 17 03:19:32 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 16 Jun 2000 19:19:32 -0700 Subject: [Python-checkins] CVS: distutils/distutils dir_util.py,1.4,1.5 Message-ID: <200006170219.TAA28047@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv28030 Modified Files: dir_util.py Log Message: Renamed PATH_CREATED to _path_created, on the grounds that it's private and mutable, rather than public and constant. Index: dir_util.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/dir_util.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** dir_util.py 2000/06/17 02:18:19 1.4 --- dir_util.py 2000/06/17 02:19:30 1.5 *************** *** 14,18 **** # cache for by mkpath() -- in addition to cheapening redundant calls, # eliminates redundant "creating /foo/bar/baz" messages in dry-run mode ! PATH_CREATED = {} # I don't use os.makedirs because a) it's new to Python 1.5.2, and --- 14,18 ---- # cache for by mkpath() -- in addition to cheapening redundant calls, # eliminates redundant "creating /foo/bar/baz" messages in dry-run mode ! _path_created = {} # I don't use os.makedirs because a) it's new to Python 1.5.2, and *************** *** 29,33 **** actually created.""" ! global PATH_CREATED # Detect a common bug -- name is None --- 29,33 ---- actually created.""" ! global _path_created # Detect a common bug -- name is None *************** *** 45,49 **** if os.path.isdir (name) or name == '': return created_dirs ! if PATH_CREATED.get (name): return created_dirs --- 45,49 ---- if os.path.isdir (name) or name == '': return created_dirs ! if _path_created.get (name): return created_dirs *************** *** 65,69 **** #print "head = %s, d = %s: " % (head, d), head = os.path.join (head, d) ! if PATH_CREATED.get (head): continue --- 65,69 ---- #print "head = %s, d = %s: " % (head, d), head = os.path.join (head, d) ! if _path_created.get (head): continue *************** *** 79,83 **** "could not create '%s': %s" % (head, exc[-1]) ! PATH_CREATED[head] = 1 return created_dirs --- 79,83 ---- "could not create '%s': %s" % (head, exc[-1]) ! _path_created[head] = 1 return created_dirs *************** *** 197,201 **** """ from distutils.util import grok_environment_error ! global PATH_CREATED if verbose: --- 197,201 ---- """ from distutils.util import grok_environment_error ! global _path_created if verbose: *************** *** 209,214 **** apply(cmd[0], (cmd[1],)) # remove dir from cache if it's already there ! if PATH_CREATED.has_key(cmd[1]): ! del PATH_CREATED[cmd[1]] except (IOError, OSError), exc: if verbose: --- 209,214 ---- apply(cmd[0], (cmd[1],)) # remove dir from cache if it's already there ! if _path_created.has_key(cmd[1]): ! del _path_created[cmd[1]] except (IOError, OSError), exc: if verbose: From python-dev@python.org Sat Jun 17 21:31:19 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Sat, 17 Jun 2000 13:31:19 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.26,2.27 Message-ID: <200006172031.NAA17184@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv17084 Modified Files: unicodeobject.c Log Message: Vladimir MARANGOZOV : This patch fixes an optimisation mystery in _PyUnicodeNew causing segfaults on AIX when the interpreter is compiled with -O. Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.26 retrieving revision 2.27 diff -C2 -r2.26 -r2.27 *** unicodeobject.c 2000/06/14 09:18:32 2.26 --- unicodeobject.c 2000/06/17 20:31:17 2.27 *************** *** 214,220 **** if (unicode_freelist) { unicode = unicode_freelist; ! unicode_freelist = *(PyUnicodeObject **)unicode_freelist; unicode_freelist_size--; - PyObject_INIT(unicode, &PyUnicode_Type); if (unicode->str) { /* Keep-Alive optimization: we only upsize the buffer, --- 214,219 ---- if (unicode_freelist) { unicode = unicode_freelist; ! unicode_freelist = *(PyUnicodeObject **)unicode; unicode_freelist_size--; if (unicode->str) { /* Keep-Alive optimization: we only upsize the buffer, *************** *** 226,231 **** } } ! else unicode->str = PyMem_NEW(Py_UNICODE, length + 1); } else { --- 225,232 ---- } } ! else { unicode->str = PyMem_NEW(Py_UNICODE, length + 1); + } + PyObject_INIT(unicode, &PyUnicode_Type); } else { From python-dev@python.org Sat Jun 17 23:39:08 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 17 Jun 2000 15:39:08 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libmmap.tex,NONE,1.1 Message-ID: <200006172239.PAA01994@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv1983 Added Files: libmmap.tex Log Message: Documentation for the mmap module: proofreaders welcomed --- NEW FILE --- \section{\module{mmap} --- Memory-mapped file support} \declaremodule{builtin}{mmap} \modulesynopsis{Interface to memory-mapped files for Unix and Windows.} Memory-mapped file objects behave like both mutable strings and like file objects. You can use mmap objects in most places where strings are expected; for example, you can use the \module{re} module to search through a memory-mapped file. Since they're mutable, you can change a single character by doing \code{obj[ \var{index} ] = 'a'}, or change a substring by assigning to a slice: \code{obj[ \var{i1}:\var{i2} ] = '...'}. You can also read and write data starting at the current file position, and \method{seek()} through the file to different positions. A memory-mapped file is created by the following function, which is different on Unix and on Windows. \begin{funcdesc}{mmap}{fileno, length \optional{, tagname} } (Windows version) Maps \var{length} bytes from the file specified by the file handle \var{fileno}, and returns a mmap object. If you have a Python file object, its \method{fileno()} method returns the file's handle, which is just an integer. \var{tagname}, if specified, is a string giving a tag name for the mapping. XXX what is the purpose of the tag name? \end{funcdesc} \begin{funcdesc}{mmap}{file, size \optional{, flags, prot}} (Unix version) Maps \var{length} bytes from the file specified by the file handle \var{fileno}, and returns a mmap object. If you have a Python file object, its \method{fileno()} method returns the file's handle, which is just an integer. \var{flags} specifies the nature of the mapping. \code{MAP_PRIVATE} creates a private copy-on-write mapping, so changes to the contents of the mmap object will be private to this process, and \code{MAP_SHARED} creates a mapping that's shared with all other processes mapping the same areas of the file. The default value is \code{MAP_SHARED}. \var{prot}, if specified, gives the desired memory protection; the two most useful values are \code{PROT_READ} and \code{PROT_WRITE}, to specify that the pages may be read or written. \var{prot} defaults to \code{PROT_READ | PROT_WRITE}. \end{funcdesc} Memory-mapped file objects support the following methods: \begin{methoddesc}{close}{} Close the file. Subsequent calls to other methods of the object will result in an exception being raised. \end{methoddesc} \begin{methoddesc}{find}{\var{string} \optional{, \var{start}}} Returns the lowest index in the object where the substring \var{string} is found. Returns \code{-1} on failure. \var{start} is the index at which the search begins, and defaults to zero. \end{methoddesc} \begin{methoddesc}{flush}{\optional{\var{offset}, \var{size}}} Flushes changes made to the in-memory copy of a file back to disk. Without use of this call there is no guarantee that changes are written back before the object is destroyed. If \var{offset} and \var{size} are specified, only changes to the given range of bytes will be flushed to disk; otherwise, the whole extent of the mapping is flushed. \end{methoddesc} \begin{methoddesc}{move}{\var{dest}, \var{src}, \var{count}} Copy the \var{count} bytes starting at offset \var{src} to the destination index \var{dest}. \end{methoddesc} \begin{methoddesc}{read}{\var{num}} Return a string containing up to \var{num} bytes taken from the current file position; the file position is updated to point after the bytes that were returned. \end{methoddesc} \begin{methoddesc}{read_byte}{} Returns the character at the current file position, and advancing the file position by 1. \end{methoddesc} \begin{methoddesc}{readline}{} Returns a single line, starting at the current file position and up to the next newline. \end{methoddesc} \begin{methoddesc}{resize}{\var{newsize}} \end{methoddesc} \begin{methoddesc}{seek}{\var{pos} \optional{, \var{whence}}} Set the file's current position. \var{whence} argument is optional and defaults to \code{0} (absolute file positioning); other values are \code{1} (seek relative to the current position) and \code{2} (seek relative to the file's end). \end{methoddesc} \begin{methoddesc}{size}{} Return the length of the file, which can be larger than the size of the memory-mapped area. \end{methoddesc} \begin{methoddesc}{tell}{} Returns the current position of the file pointer. \end{methoddesc} \begin{methoddesc}{write}{\var{string}} Write the bytes in \var{string} into memory at the current position of the file pointer; the file position is updated to point after the bytes that were written. \end{methoddesc} \begin{methoddesc}{write_byte}{\var{byte}} Write \var{byte} into memory at the current position of the file pointer; the file position is advanced by 1. \end{methoddesc} From python-dev@python.org Sat Jun 17 23:41:24 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 17 Jun 2000 15:41:24 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules mmapmodule.c,2.10,2.11 Message-ID: <200006172241.PAA02080@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv2060 Modified Files: mmapmodule.c Log Message: Fix the size() method to return the size of the file on Unix, not the size of the mapped area. This seems to be what the Windows version does. This change requires keeping around the fd of the mapped file. Index: mmapmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/mmapmodule.c,v retrieving revision 2.10 retrieving revision 2.11 diff -C2 -r2.10 -r2.11 *** mmapmodule.c 2000/06/03 20:43:43 2.10 --- mmapmodule.c 2000/06/17 22:41:22 2.11 *************** *** 30,33 **** --- 30,34 ---- #include #include + #include #endif *************** *** 50,54 **** #ifdef UNIX ! /* No Unix-specific information at this point in time */ #endif } mmap_object; --- 51,55 ---- #ifdef UNIX ! int fd; #endif } mmap_object; *************** *** 211,215 **** static PyObject * mmap_write_method (mmap_object * self, ! PyObject * args) { long length; --- 212,216 ---- static PyObject * mmap_write_method (mmap_object * self, ! PyObject * args) { long length; *************** *** 265,269 **** #ifdef UNIX ! return (Py_BuildValue ("l", self->size) ); #endif /* UNIX */ } --- 266,277 ---- #ifdef UNIX ! { ! struct stat buf; ! if (-1 == fstat(self->fd, &buf)) { ! PyErr_SetFromErrno(mmap_module_error); ! return NULL; ! } ! return (Py_BuildValue ("l", buf.st_size) ); ! } #endif /* UNIX */ } *************** *** 718,721 **** --- 726,730 ---- m_obj->size = (size_t) map_size; m_obj->pos = (size_t) 0; + m_obj->fd = fd; m_obj->data = mmap(NULL, map_size, prot, flags, From python-dev@python.org Sun Jun 18 00:04:33 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 17 Jun 2000 16:04:33 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command build_ext.py,1.42,1.43 Message-ID: <200006172304.QAA09038@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv9028 Modified Files: build_ext.py Log Message: Pulled the MSVC++-specific hackery out to a new method, 'prelink_hook()', and added (empty) 'precompile_hook()' for symmetry. One can envision a much more elaborate hook mechanism, but this looks like it'll do for now. Index: build_ext.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build_ext.py,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -r1.42 -r1.43 *** build_ext.py 2000/06/07 03:00:06 1.42 --- build_ext.py 2000/06/17 23:04:31 1.43 *************** *** 161,165 **** # 'self.extensions', as supplied by setup.py, is a list of # Extension instances. See the documentation for Extension (in ! # distutils.core) for details. # # For backwards compatibility with Distutils 0.8.2 and earlier, we --- 161,165 ---- # 'self.extensions', as supplied by setup.py, is a list of # Extension instances. See the documentation for Extension (in ! # distutils.extension) for details. # # For backwards compatibility with Distutils 0.8.2 and earlier, we *************** *** 396,399 **** --- 396,404 ---- extra_args.extend(string.split(os.environ['CFLAGS'])) + # Run any platform/compiler-specific hooks needed before + # compiling (currently none, but any hypothetical subclasses + # might find it useful to override this). + self.precompile_hook() + objects = self.compiler.compile (sources, output_dir=self.build_temp, *************** *** 410,448 **** extra_args = ext.extra_link_args ! # XXX this is a kludge! Knowledge of specific compilers or ! # platforms really doesn't belong here; in an ideal world, the ! # CCompiler interface would provide access to everything in a ! # compiler/linker system needs to build Python extensions, and ! # we would just do everything nicely and cleanly through that ! # interface. However, this is a not an ideal world and the ! # CCompiler interface doesn't handle absolutely everything. ! # Thus, kludges like this slip in occasionally. (This is no ! # excuse for committing more platform- and compiler-specific ! # kludges; they are to be avoided if possible!) ! if self.compiler.compiler_type == 'msvc': ! def_file = ext.export_symbol_file ! if def_file is None: ! source_dir = os.path.dirname (sources[0]) ! ext_base = (string.split (ext.name, '.'))[-1] ! def_file = os.path.join (source_dir, "%s.def" % ext_base) ! if not os.path.exists (def_file): ! def_file = None ! ! if def_file is not None: ! extra_args.append ('/DEF:' + def_file) ! else: ! modname = string.split (ext.name, '.')[-1] ! extra_args.append('/export:init%s'%modname) ! ! # The MSVC linker generates unneeded .lib and .exp files, ! # which cannot be suppressed by any linker switches. So ! # make sure they are generated in the temporary build ! # directory. ! implib_file = os.path.join ( ! self.build_temp, ! self.get_ext_libname (ext.name)) ! extra_args.append ('/IMPLIB:' + implib_file) ! self.mkpath (os.path.dirname (implib_file)) ! # if MSVC self.compiler.link_shared_object ( --- 415,421 ---- extra_args = ext.extra_link_args ! # Run any platform/compiler-specific hooks needed between ! # compiling and linking (currently needed only on Windows). ! self.prelink_hook() self.compiler.link_shared_object ( *************** *** 457,460 **** --- 430,482 ---- + # -- Hooks --------------------------------------------------------- + + def precompile_hook (self): + pass + + def prelink_hook (self): + + # XXX this is a kludge! Knowledge of specific compilers or + # platforms really doesn't belong here; in an ideal world, the + # CCompiler interface would provide access to everything in a + # compiler/linker system needs to build Python extensions, and + # we would just do everything nicely and cleanly through that + # interface. However, this is a not an ideal world and the + # CCompiler interface doesn't handle absolutely everything. + # Thus, kludges like this slip in occasionally. (This is no + # excuse for committing more platform- and compiler-specific + # kludges; they are to be avoided if possible!) + if self.compiler.compiler_type == 'msvc': + def_file = ext.export_symbol_file + if def_file is None: + source_dir = os.path.dirname (sources[0]) + ext_base = (string.split (ext.name, '.'))[-1] + def_file = os.path.join (source_dir, "%s.def" % ext_base) + if not os.path.exists (def_file): + def_file = None + + if def_file is not None: + extra_args.append ('/DEF:' + def_file) + else: + modname = string.split (ext.name, '.')[-1] + extra_args.append('/export:init%s'%modname) + + # The MSVC linker generates unneeded .lib and .exp files, + # which cannot be suppressed by any linker switches. So + # make sure they are generated in the temporary build + # directory. + implib_file = os.path.join ( + self.build_temp, + self.get_ext_libname (ext.name)) + extra_args.append ('/IMPLIB:' + implib_file) + self.mkpath (os.path.dirname (implib_file)) + # if MSVC + + # prelink_hook () + + + # -- Name generators ----------------------------------------------- + # (extension names, filenames, whatever) + def get_ext_fullname (self, ext_name): if self.package is None: *************** *** 464,467 **** --- 486,494 ---- def get_ext_filename (self, ext_name): + """Convert the name of an extension (eg. "foo.bar") into the name + of the file from which it will be loaded (eg. "foo/bar.so", or + "foo\bar.pyd"). + """ + from distutils import sysconfig ext_path = string.split (ext_name, '.') From python-dev@python.org Sun Jun 18 01:50:51 2000 From: python-dev@python.org (Vladimir Marangozov) Date: Sun, 18 Jun 2000 02:50:51 +0200 (CEST) Subject: [Python-checkins] CVS: python/dist/src/Modules mmapmodule.c,2.10,2.11 In-Reply-To: <200006172241.PAA02080@slayer.i.sourceforge.net> from "A.M. Kuchling" at Jun 17, 2000 03:41:24 PM Message-ID: <200006180050.CAA07547@python.inrialpes.fr> A.M. Kuchling wrote: > > Update of /cvsroot/python/python/dist/src/Modules > In directory slayer.i.sourceforge.net:/tmp/cvs-serv2060 > > Modified Files: > mmapmodule.c > Log Message: > Fix the size() method to return the size of the file on Unix, not the > size of the mapped area. This seems to be what the Windows version does. > This change requires keeping around the fd of the mapped file. On AIX, the test_mmap fails with errno=EINVAL on the m.flush() method. It works okay without the MS_INVALIDATE flag though, so I'd suggest removing it from msync in the flush and dealloc methods. Also, it would probably be a good idea to allow optional flags for flush, as it's done in new_mmap_object, the default being only MS_SYNC. Given that this module is enabled by default, I think that it needs some more stress-testing in test_mmap.py. I'll try to add a couple of tests shortly. -- Vladimir MARANGOZOV | Vladimir.Marangozov@inrialpes.fr http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252 From python-dev@python.org Sun Jun 18 05:17:40 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 17 Jun 2000 21:17:40 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libmmap.tex,1.1,1.2 Message-ID: <200006180417.VAA24245@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv24238 Modified Files: libmmap.tex Log Message: Make changes and clarifications suggested by Mark Hammond Index: libmmap.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libmmap.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** libmmap.tex 2000/06/17 22:39:05 1.1 --- libmmap.tex 2000/06/18 04:17:38 1.2 *************** *** 20,34 **** \begin{funcdesc}{mmap}{fileno, length \optional{, tagname} } (Windows version) Maps \var{length} bytes from the file specified by ! the file handle \var{fileno}, and returns a mmap object. If you have ! a Python file object, its ! \method{fileno()} method returns the file's handle, which is just an integer. ! \var{tagname}, if specified, is a string giving a tag name for the mapping. XXX what is the purpose of the tag name? \end{funcdesc} ! \begin{funcdesc}{mmap}{file, size \optional{, flags, prot}} (Unix version) Maps \var{length} bytes from the file specified by the ! file handle \var{fileno}, and returns a mmap object. If you have a ! Python file object, its \method{fileno()} method returns the file's ! handle, which is just an integer. \var{flags} specifies the nature of the mapping. --- 20,41 ---- \begin{funcdesc}{mmap}{fileno, length \optional{, tagname} } (Windows version) Maps \var{length} bytes from the file specified by ! the file handle \var{fileno}, and returns a mmap object. If you wish ! to map an existing Python file object, use its \method{fileno()} ! method to obtain the correct value for the \var{fileno} parameter. ! ! \var{tagname}, if specified, is a string giving a tag name for the mapping. ! Windows allows you to have many different mappings against the same ! file. If you specify the name of an existing tag, that tag is opened, ! otherwise a new tag of this name is created. If this parameter is ! None, the mapping is created without a name. Avoiding the use of the ! tag parameter will assist in keeping your code portable between Unix ! and Windows. \end{funcdesc} ! \begin{funcdesc}{mmap}{fileno, size \optional{, flags, prot}} (Unix version) Maps \var{length} bytes from the file specified by the ! file handle \var{fileno}, and returns a mmap object. If you wish to ! map an existing Python file object, use its \method{fileno()} method ! to obtain the correct value for the \var{fileno} parameter. \var{flags} specifies the nature of the mapping. *************** *** 62,67 **** Flushes changes made to the in-memory copy of a file back to disk. Without use of this call there is no guarantee that changes are ! written back before the object is destroyed. If \var{offset} ! and \var{size} are specified, only changes to the given range of bytes will be flushed to disk; otherwise, the whole extent of the mapping is flushed. \end{methoddesc} --- 69,76 ---- Flushes changes made to the in-memory copy of a file back to disk. Without use of this call there is no guarantee that changes are ! written back before the object is destroyed. If \var{offset} and ! \var{size} are specified, only changes to the given range of bytes ! will be flushed to disk; otherwise, the whole extent of the mapping is ! flushed. \end{methoddesc} *************** *** 72,76 **** \begin{methoddesc}{read}{\var{num}} ! Return a string containing up to \var{num} bytes taken from the current file position; the file position is updated to point after the bytes that were returned. --- 81,85 ---- \begin{methoddesc}{read}{\var{num}} ! Return a string containing up to \var{num} bytes starting from the current file position; the file position is updated to point after the bytes that were returned. *************** *** 78,83 **** \begin{methoddesc}{read_byte}{} ! Returns the character at the current file position, and advancing ! the file position by 1. \end{methoddesc} --- 87,92 ---- \begin{methoddesc}{read_byte}{} ! Returns a string of length 1 containing the character at the current ! file position, and advances the file position by 1. \end{methoddesc} *************** *** 114,118 **** \begin{methoddesc}{write_byte}{\var{byte}} ! Write \var{byte} into memory at the current position of the file pointer; the file position is advanced by 1. \end{methoddesc} --- 123,127 ---- \begin{methoddesc}{write_byte}{\var{byte}} ! Write the single-character string \var{byte} into memory at the current position of the file pointer; the file position is advanced by 1. \end{methoddesc} From python-dev@python.org Sun Jun 18 05:25:10 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 17 Jun 2000 21:25:10 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules mmapmodule.c,2.11,2.12 Message-ID: <200006180425.VAA24502@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv24493 Modified Files: mmapmodule.c Log Message: Removed MS_INVALIDATE flags Index: mmapmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/mmapmodule.c,v retrieving revision 2.11 retrieving revision 2.12 diff -C2 -r2.11 -r2.12 *** mmapmodule.c 2000/06/17 22:41:22 2.11 --- mmapmodule.c 2000/06/18 04:25:08 2.12 *************** *** 66,70 **** #ifdef UNIX if (m_obj->data!=NULL) { ! msync(m_obj->data, m_obj->size, MS_SYNC | MS_INVALIDATE); munmap(m_obj->data, m_obj->size); } --- 66,70 ---- #ifdef UNIX if (m_obj->data!=NULL) { ! msync(m_obj->data, m_obj->size, MS_SYNC); munmap(m_obj->data, m_obj->size); } *************** *** 389,393 **** /* XXX flags for msync? */ if (-1 == msync(self->data + offset, size, ! MS_SYNC | MS_INVALIDATE)) { PyErr_SetFromErrno(mmap_module_error); --- 389,393 ---- /* XXX flags for msync? */ if (-1 == msync(self->data + offset, size, ! MS_SYNC)) { PyErr_SetFromErrno(mmap_module_error); From python-dev@python.org Sun Jun 18 05:45:16 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 17 Jun 2000 21:45:16 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules mmapmodule.c,2.12,2.13 Message-ID: <200006180445.VAA25429@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv25421 Modified Files: mmapmodule.c Log Message: Patch from Trent Mick: The seek() method is broken for any 'whence' value (seek from start, current, orend) other than the default. I have a patch that fixes that as well as gets mmap'd files working on Linux64 and Win64. Index: mmapmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/mmapmodule.c,v retrieving revision 2.12 retrieving revision 2.13 diff -C2 -r2.12 -r2.13 *** mmapmodule.c 2000/06/18 04:25:08 2.12 --- mmapmodule.c 2000/06/18 04:45:14 2.13 *************** *** 46,50 **** #ifdef MS_WIN32 HANDLE map_handle; ! HFILE file_handle; char * tagname; #endif --- 46,50 ---- #ifdef MS_WIN32 HANDLE map_handle; ! INT_PTR file_handle; char * tagname; #endif *************** *** 124,128 **** if (!PyArg_ParseTuple(args, ":read_byte")) return NULL; ! if (self->pos >= 0 && self->pos < self->size) { where = self->data + self->pos; value = (char) *(where); --- 124,128 ---- if (!PyArg_ParseTuple(args, ":read_byte")) return NULL; ! if (self->pos < self->size) { where = self->data + self->pos; value = (char) *(where); *************** *** 154,158 **** ++eol; /* we're interested in the position after the newline. */ ! result = PyString_FromStringAndSize(start, (long) (eol - start)); self->pos += (eol - start); return (result); --- 154,158 ---- ++eol; /* we're interested in the position after the newline. */ ! result = PyString_FromStringAndSize(start, (eol - start)); self->pos += (eol - start); return (result); *************** *** 183,192 **** PyObject *args) { ! long start = self->pos; char * needle; int len; CHECK_VALID(NULL); ! if (!PyArg_ParseTuple (args, "s#|l", &needle, &len, &start)) { return NULL; } else { --- 183,192 ---- PyObject *args) { ! int start = self->pos; char * needle; int len; CHECK_VALID(NULL); ! if (!PyArg_ParseTuple (args, "s#|i", &needle, &len, &start)) { return NULL; } else { *************** *** 201,206 **** if (!*n) { return Py_BuildValue ( ! "l", ! (long) (p - (self->data + start))); } p++; --- 201,206 ---- if (!*n) { return Py_BuildValue ( ! "i", ! (int) (p - (self->data + start))); } p++; *************** *** 256,260 **** #ifdef MS_WIN32 ! if (self->file_handle != (HFILE) 0xFFFFFFFF) { return (Py_BuildValue ( "l", --- 256,260 ---- #ifdef MS_WIN32 ! if (self->file_handle != (INT_PTR) -1) { return (Py_BuildValue ( "l", *************** *** 402,422 **** mmap_seek_method (mmap_object * self, PyObject * args) { ! /* ptrdiff_t dist; */ ! long dist; int how=0; CHECK_VALID(NULL); ! if (!PyArg_ParseTuple (args, "l|i", &dist, &how)) { return(NULL); } else { ! unsigned long where; switch (how) { ! case 0: where = dist; break; ! case 1: where = self->pos + dist; break; ! case 2: ! where = self->size - dist; break; default: --- 402,427 ---- mmap_seek_method (mmap_object * self, PyObject * args) { ! int dist; int how=0; CHECK_VALID(NULL); ! if (!PyArg_ParseTuple (args, "i|i", &dist, &how)) { return(NULL); } else { ! size_t where; switch (how) { ! case 0: /* relative to start */ ! if (dist < 0) ! goto onoutofrange; where = dist; break; ! case 1: /* relative to current position */ ! if ((int)self->pos + dist < 0) ! goto onoutofrange; where = self->pos + dist; break; ! case 2: /* relative to end */ ! if ((int)self->size + dist < 0) ! goto onoutofrange; ! where = self->size + dist; break; default: *************** *** 425,438 **** return NULL; } ! if ((where >= 0) && (where < (self->size))) { ! self->pos = where; ! Py_INCREF (Py_None); ! return (Py_None); ! } else { ! PyErr_SetString (PyExc_ValueError, ! "seek out of range"); ! return NULL; ! } } } --- 430,443 ---- return NULL; } ! if (where > self->size) ! goto onoutofrange; ! self->pos = where; ! Py_INCREF (Py_None); ! return (Py_None); } + + onoutofrange: + PyErr_SetString (PyExc_ValueError, "seek out of range"); + return NULL; } *************** *** 705,708 **** --- 710,770 ---- }; + + /* extract the map size from the given PyObject + + The map size is restricted to [0, INT_MAX] because this is the current + Python limitation on object sizes. Although the mmap object *could* handle + a larger map size, there is no point because all the useful operations + (len(), slicing(), sequence indexing) are limited by a C int. + + Returns -1 on error, with an apprpriate Python exception raised. On + success, the map size is returned. */ + static int + _GetMapSize(o) + PyObject *o; + { + if (PyInt_Check(o)) { + long i = PyInt_AsLong(o); + if (PyErr_Occurred()) + return -1; + if (i < 0) + goto onnegoverflow; + if (i > INT_MAX) + goto onposoverflow; + return (int)i; + } + else if (PyLong_Check(o)) { + long i = PyLong_AsLong(o); + if (PyErr_Occurred()) { + /* yes negative overflow is mistaken for positive overflow + but not worth the trouble to check sign of 'i' */ + if (PyErr_ExceptionMatches(PyExc_OverflowError)) + goto onposoverflow; + else + return -1; + } + if (i < 0) + goto onnegoverflow; + if (i > INT_MAX) + goto onposoverflow; + return (int)i; + } + else { + PyErr_SetString(PyExc_TypeError, + "map size must be an integral value"); + return -1; + } + + onnegoverflow: + PyErr_SetString(PyExc_OverflowError, + "memory mapped size must be positive"); + return -1; + + onposoverflow: + PyErr_SetString(PyExc_OverflowError, + "memory mapped size is too large (limited by C int)"); + return -1; + } + #ifdef UNIX static PyObject * *************** *** 710,714 **** { mmap_object * m_obj; ! unsigned long map_size; int fd, flags = MAP_SHARED, prot = PROT_WRITE | PROT_READ; char * filename; --- 772,777 ---- { mmap_object * m_obj; ! PyObject *map_size_obj = NULL; ! int map_size; int fd, flags = MAP_SHARED, prot = PROT_WRITE | PROT_READ; char * filename; *************** *** 717,725 **** if (!PyArg_ParseTupleAndKeywords(args, kwdict, ! "il|ii", keywords, ! &fd, &map_size, &flags, &prot) ) return NULL; ! m_obj = PyObject_New (mmap_object, &mmap_object_type); if (m_obj == NULL) {return NULL;} --- 780,791 ---- if (!PyArg_ParseTupleAndKeywords(args, kwdict, ! "iO|ii", keywords, ! &fd, &map_size_obj, &flags, &prot) ) return NULL; ! map_size = _GetMapSize(map_size_obj); ! if (map_size < 0) ! return NULL; ! m_obj = PyObject_New (mmap_object, &mmap_object_type); if (m_obj == NULL) {return NULL;} *************** *** 745,754 **** { mmap_object * m_obj; ! unsigned long map_size; char * tagname = ""; DWORD dwErr = 0; int fileno; ! HFILE fh = 0; /* Patch the object type */ --- 811,821 ---- { mmap_object * m_obj; ! PyObject *map_size_obj = NULL; ! int map_size; char * tagname = ""; DWORD dwErr = 0; int fileno; ! INT_PTR fh = 0; /* Patch the object type */ *************** *** 756,766 **** if (!PyArg_ParseTuple(args, ! "il|z", &fileno, ! &map_size, &tagname) ) return NULL; /* if an actual filename has been specified */ if (fileno != 0) { --- 823,837 ---- if (!PyArg_ParseTuple(args, ! "iO|z", &fileno, ! &map_size_obj, &tagname) ) return NULL; + map_size = _GetMapSize(map_size_obj); + if (map_size < 0) + return NULL; + /* if an actual filename has been specified */ if (fileno != 0) { *************** *** 785,789 **** } else { ! m_obj->file_handle = (HFILE) 0xFFFFFFFF; m_obj->size = map_size; } --- 856,860 ---- } else { ! m_obj->file_handle = (INT_PTR) -1; m_obj->size = map_size; } From python-dev@python.org Sun Jun 18 05:47:10 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 17 Jun 2000 21:47:10 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_mmap,1.1,1.2 Message-ID: <200006180447.VAA25478@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv25459/output Modified Files: test_mmap Log Message: Additional tests for seek() method, written by Trent Mick Index: test_mmap =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_mmap,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 Binary files /tmp/cvsjNOmbW and /tmp/cvsWRnnXH differ From python-dev@python.org Sun Jun 18 05:47:10 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sat, 17 Jun 2000 21:47:10 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_mmap.py,1.4,1.5 Message-ID: <200006180447.VAA25474@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv25459 Modified Files: test_mmap.py Log Message: Additional tests for seek() method, written by Trent Mick Index: test_mmap.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_mmap.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** test_mmap.py 2000/04/05 14:17:11 1.4 --- test_mmap.py 2000/06/18 04:47:08 1.5 *************** *** 59,63 **** assert start == PAGESIZE assert end == PAGESIZE + 6 ! m.close() os.unlink("foo") --- 59,98 ---- assert start == PAGESIZE assert end == PAGESIZE + 6 ! ! # test seeking around (try to overflow the seek implementation) ! m.seek(0,0) ! print ' Seek to zeroth byte' ! assert m.tell() == 0 ! m.seek(42,1) ! print ' Seek to 42nd byte' ! assert m.tell() == 42 ! m.seek(0,2) ! print ' Seek to last byte' ! assert m.tell() == len(m) ! ! print ' Try to seek to negative position...' ! try: ! m.seek(-1) ! except ValueError: ! pass ! else: ! assert 0, 'expected a ValueError but did not get it' ! ! print ' Try to seek beyond end of mmap...' ! try: ! m.seek(1,2) ! except ValueError: ! pass ! else: ! assert 0, 'expected a ValueError but did not get it' ! ! print ' Try to seek to negative position...' ! try: ! m.seek(-len(m)-1,2) ! except ValueError: ! pass ! else: ! assert 0, 'expected a ValueError but did not get it' ! m.close() os.unlink("foo") From python-dev@python.org Sun Jun 18 06:21:23 2000 From: python-dev@python.org (Fred L. Drake) Date: Sat, 17 Jun 2000 22:21:23 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/api api.tex,1.67,1.68 Message-ID: <200006180521.WAA32625@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/api In directory slayer.i.sourceforge.net:/tmp/cvs-serv32618/Doc/api Modified Files: api.tex Log Message: Markup consistency nits. Index: api.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/api.tex,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -r1.67 -r1.68 *** api.tex 2000/06/16 21:04:15 1.67 --- api.tex 2000/06/18 05:21:21 1.68 *************** *** 1176,1184 **** \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyImport_ImportFrozenModule}{char *} ! Load a frozen module. Return \code{1} for success, \code{0} if the ! module is not found, and \code{-1} with an exception set if the ! initialization failed. To access the imported module on a successful ! load, use \cfunction{PyImport_ImportModule()}. (Note the misnomer --- this function would reload the module if it was already imported.) --- 1176,1184 ---- \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyImport_ImportFrozenModule}{char *name} ! Load a frozen module named \var{name}. Return \code{1} for success, ! \code{0} if the module is not found, and \code{-1} with an exception ! set if the initialization failed. To access the imported module on a ! successful load, use \cfunction{PyImport_ImportModule()}. (Note the misnomer --- this function would reload the module if it was already imported.) *************** *** 2058,2062 **** \end{cfuncdesc} ! \begin{cfuncdesc}{Py_UNICODE *}{PyUnicode_AsUnicode}{PyObject *unicode} Return a read-only pointer to the Unicode object's internal \ctype{Py_UNICODE} buffer. --- 2058,2062 ---- \end{cfuncdesc} ! \begin{cfuncdesc}{Py_UNICODE*}{PyUnicode_AsUnicode}{PyObject *unicode} Return a read-only pointer to the Unicode object's internal \ctype{Py_UNICODE} buffer. *************** *** 2103,2107 **** wchar_t *w, int size} - Copies the Unicode Object contents into the \ctype{whcar_t} buffer \var{w}. At most \var{size} \ctype{whcar_t} characters are copied. --- 2103,2106 ---- *************** *** 2139,2143 **** const char *encoding, const char *errors} - Create a Unicode object by decoding \var{size} bytes of the encoded string \var{s}. \var{encoding} and \var{errors} have the same meaning --- 2138,2141 ---- *************** *** 2152,2156 **** const char *encoding, const char *errors} - Encodes the \ctype{Py_UNICODE} buffer of the given size and returns a Python string object. \var{encoding} and \var{errors} have the same --- 2150,2153 ---- *************** *** 2164,2168 **** const char *encoding, const char *errors} - Encodes a Unicode object and returns the result as Python string object. \var{encoding} and \var{errors} have the same meaning as the --- 2161,2164 ---- *************** *** 2179,2183 **** int size, const char *errors} - Creates a Unicode object by decoding \var{size} bytes of the UTF-8 encoded string \var{s}. Returns \NULL{} in case an exception was --- 2175,2178 ---- *************** *** 2188,2192 **** int size, const char *errors} - Encodes the \ctype{Py_UNICODE} buffer of the given size using UTF-8 and returns a Python string object. Returns \NULL{} in case an --- 2183,2186 ---- *************** *** 2195,2199 **** \begin{cfuncdesc}{PyObject*}{PyUnicode_AsUTF8String}{PyObject *unicode} - Encodes a Unicode objects using UTF-8 and returns the result as Python string object. Error handling is ``strict''. Returns --- 2189,2192 ---- *************** *** 2209,2213 **** const char *errors, int *byteorder} - Decodes \var{length} bytes from a UTF-16 encoded buffer string and returns the corresponding Unicode object. --- 2202,2205 ---- *************** *** 2239,2243 **** const char *errors, int byteorder} - Returns a Python string object holding the UTF-16 encoded value of the Unicode data in \var{s}. --- 2231,2234 ---- *************** *** 2277,2281 **** int size, const char *errors} - Creates a Unicode object by decoding \var{size} bytes of the Unicode-Esacpe encoded string \var{s}. Returns \NULL{} in case an exception was --- 2268,2271 ---- *************** *** 2286,2290 **** int size, const char *errors} - Encodes the \ctype{Py_UNICODE} buffer of the given size using Unicode-Escape and returns a Python string object. Returns \NULL{} in case an --- 2276,2279 ---- *************** *** 2293,2297 **** \begin{cfuncdesc}{PyObject*}{PyUnicode_AsUnicodeEscapeString}{PyObject *unicode} - Encodes a Unicode objects using Unicode-Escape and returns the result as Python string object. Error handling is ``strict''. Returns --- 2282,2285 ---- *************** *** 2306,2310 **** int size, const char *errors} - Creates a Unicode object by decoding \var{size} bytes of the Raw-Unicode-Esacpe encoded string \var{s}. Returns \NULL{} in case an exception was --- 2294,2297 ---- *************** *** 2315,2319 **** int size, const char *errors} - Encodes the \ctype{Py_UNICODE} buffer of the given size using Raw-Unicode-Escape and returns a Python string object. Returns \NULL{} in case an --- 2302,2305 ---- *************** *** 2322,2326 **** \begin{cfuncdesc}{PyObject*}{PyUnicode_AsRawUnicodeEscapeString}{PyObject *unicode} - Encodes a Unicode objects using Raw-Unicode-Escape and returns the result as Python string object. Error handling is ``strict''. Returns --- 2308,2311 ---- *************** *** 2336,2342 **** \begin{cfuncdesc}{PyObject*}{PyUnicode_DecodeLatin1}{const char *s, ! int size, ! const char *errors} ! Creates a Unicode object by decoding \var{size} bytes of the Latin-1 encoded string \var{s}. Returns \NULL{} in case an exception was --- 2321,2326 ---- \begin{cfuncdesc}{PyObject*}{PyUnicode_DecodeLatin1}{const char *s, ! int size, ! const char *errors} Creates a Unicode object by decoding \var{size} bytes of the Latin-1 encoded string \var{s}. Returns \NULL{} in case an exception was *************** *** 2345,2351 **** \begin{cfuncdesc}{PyObject*}{PyUnicode_EncodeLatin1}{const Py_UNICODE *s, ! int size, ! const char *errors} ! Encodes the \ctype{Py_UNICODE} buffer of the given size using Latin-1 and returns a Python string object. Returns \NULL{} in case an --- 2329,2334 ---- \begin{cfuncdesc}{PyObject*}{PyUnicode_EncodeLatin1}{const Py_UNICODE *s, ! int size, ! const char *errors} Encodes the \ctype{Py_UNICODE} buffer of the given size using Latin-1 and returns a Python string object. Returns \NULL{} in case an *************** *** 2354,2358 **** \begin{cfuncdesc}{PyObject*}{PyUnicode_AsLatin1String}{PyObject *unicode} - Encodes a Unicode objects using Latin-1 and returns the result as Python string object. Error handling is ``strict''. Returns --- 2337,2340 ---- *************** *** 2362,2390 **** % --- ASCII Codecs ------------------------------------------------------- ! These are the ASCII codec APIs: - Only 7-bit ASCII data is excepted. All other codes generate errors. - \begin{cfuncdesc}{PyObject*}{PyUnicode_DecodeASCII}{const char *s, ! int size, ! const char *errors} ! ! Creates a Unicode object by decoding \var{size} bytes of the ASCII ! encoded string \var{s}. Returns \NULL{} in case an exception was ! raised by the codec. \end{cfuncdesc} \begin{cfuncdesc}{PyObject*}{PyUnicode_EncodeASCII}{const Py_UNICODE *s, ! int size, ! const char *errors} ! ! Encodes the \ctype{Py_UNICODE} buffer of the given size using ASCII ! and returns a Python string object. Returns \NULL{} in case an ! exception was raised by the codec. \end{cfuncdesc} \begin{cfuncdesc}{PyObject*}{PyUnicode_AsASCIIString}{PyObject *unicode} ! ! Encodes a Unicode objects using ASCII and returns the result as Python string object. Error handling is ``strict''. Returns \NULL{} in case an exception was raised by the codec. --- 2344,2368 ---- % --- ASCII Codecs ------------------------------------------------------- ! These are the \ASCII{} codec APIs. Only 7-bit \ASCII{} data is ! accepted. All other codes generate errors. \begin{cfuncdesc}{PyObject*}{PyUnicode_DecodeASCII}{const char *s, ! int size, ! const char *errors} ! Creates a Unicode object by decoding \var{size} bytes of the ! \ASCII{} encoded string \var{s}. Returns \NULL{} in case an exception ! was raised by the codec. \end{cfuncdesc} \begin{cfuncdesc}{PyObject*}{PyUnicode_EncodeASCII}{const Py_UNICODE *s, ! int size, ! const char *errors} ! Encodes the \ctype{Py_UNICODE} buffer of the given size using ! \ASCII{} and returns a Python string object. Returns \NULL{} in case ! an exception was raised by the codec. \end{cfuncdesc} \begin{cfuncdesc}{PyObject*}{PyUnicode_AsASCIIString}{PyObject *unicode} ! Encodes a Unicode objects using \ASCII{} and returns the result as Python string object. Error handling is ``strict''. Returns \NULL{} in case an exception was raised by the codec. *************** *** 2421,2425 **** PyObject *mapping, const char *errors} - Creates a Unicode object by decoding \var{size} bytes of the encoded string \var{s} using the given \var{mapping} object. Returns \NULL{} --- 2399,2402 ---- *************** *** 2431,2435 **** PyObject *mapping, const char *errors} - Encodes the \ctype{Py_UNICODE} buffer of the given size using the given \var{mapping} object and returns a Python string object. --- 2408,2411 ---- *************** *** 2439,2443 **** \begin{cfuncdesc}{PyObject*}{PyUnicode_AsCharmapString}{PyObject *unicode, PyObject *mapping} - Encodes a Unicode objects using the given \var{mapping} object and returns the result as Python string object. Error handling is --- 2415,2418 ---- *************** *** 2452,2459 **** PyObject *table, const char *errors} - Translates a \ctype{Py_UNICODE} buffer of the given length by applying a character mapping \var{table} to it and returns the resulting ! Unicode object. The \var{mapping} table must map Unicode ordinal integers to Unicode --- 2427,2434 ---- PyObject *table, const char *errors} Translates a \ctype{Py_UNICODE} buffer of the given length by applying a character mapping \var{table} to it and returns the resulting ! Unicode object. Returns \NULL{} when an exception was raised by the ! codec. The \var{mapping} table must map Unicode ordinal integers to Unicode *************** *** 2463,2486 **** e.g. dictionaries or sequences. Unmapped character ordinals (ones which cause a LookupError) are left untouched and are copied as-is. - - Returns \NULL{} in case an exception was raised by the codec. \end{cfuncdesc} % --- MBCS codecs for Windows -------------------------------------------- ! These are the MBCS codec APIs. They are currently only available Windows and use the Win32 MBCS converters to implement the ! conversions. ! ! Note that MBCS (or DBCS) is a class of encodings, not just one. The ! target encoding is defined by the user settings on the machine running ! the codec. \begin{cfuncdesc}{PyObject*}{PyUnicode_DecodeMBCS}{const char *s, int size, const char *errors} - Creates a Unicode object by decoding \var{size} bytes of the MBCS ! encoded string \var{s}. Returns \NULL{} in case an exception was raised by the codec. \end{cfuncdesc} --- 2438,2456 ---- e.g. dictionaries or sequences. Unmapped character ordinals (ones which cause a LookupError) are left untouched and are copied as-is. \end{cfuncdesc} % --- MBCS codecs for Windows -------------------------------------------- ! These are the MBCS codec APIs. They are currently only available on Windows and use the Win32 MBCS converters to implement the ! conversions. Note that MBCS (or DBCS) is a class of encodings, not ! just one. The target encoding is defined by the user settings on the ! machine running the codec. \begin{cfuncdesc}{PyObject*}{PyUnicode_DecodeMBCS}{const char *s, int size, const char *errors} Creates a Unicode object by decoding \var{size} bytes of the MBCS ! encoded string \var{s}. Returns \NULL{} in case an exception was raised by the codec. \end{cfuncdesc} *************** *** 2489,2493 **** int size, const char *errors} - Encodes the \ctype{Py_UNICODE} buffer of the given size using MBCS and returns a Python string object. Returns \NULL{} in case an --- 2459,2462 ---- *************** *** 2496,2503 **** \begin{cfuncdesc}{PyObject*}{PyUnicode_AsMBCSString}{PyObject *unicode} - Encodes a Unicode objects using MBCS and returns the result as Python ! string object. Error handling is ``strict''. Returns ! \NULL{} in case an exception was raised by the codec. \end{cfuncdesc} --- 2465,2471 ---- \begin{cfuncdesc}{PyObject*}{PyUnicode_AsMBCSString}{PyObject *unicode} Encodes a Unicode objects using MBCS and returns the result as Python ! string object. Error handling is ``strict''. Returns \NULL{} in case ! an exception was raised by the codec. \end{cfuncdesc} *************** *** 2514,2518 **** \begin{cfuncdesc}{PyObject*}{PyUnicode_Concat}{PyObject *left, PyObject *right} - Concat two strings giving a new Unicode string. \end{cfuncdesc} --- 2482,2485 ---- *************** *** 2521,2525 **** PyObject *sep, int maxsplit} - Split a string giving a list of Unicode strings. --- 2488,2491 ---- *************** *** 2534,2542 **** \begin{cfuncdesc}{PyObject*}{PyUnicode_Splitlines}{PyObject *s, int maxsplit} ! ! Dito, but split at line breaks. ! ! CRLF is considered to be one line break. Line breaks are not ! included in the resulting list. \end{cfuncdesc} --- 2500,2506 ---- \begin{cfuncdesc}{PyObject*}{PyUnicode_Splitlines}{PyObject *s, int maxsplit} ! Split a Unicode string at line breaks, returning a list of Unicode ! strings. CRLF is considered to be one line break. The Line break ! characters are not included in the resulting strings. \end{cfuncdesc} *************** *** 2544,2548 **** PyObject *table, const char *errors} - Translate a string by applying a character mapping table to it and return the resulting Unicode object. --- 2508,2511 ---- *************** *** 2557,2566 **** \var{errors} has the usual meaning for codecs. It may be \NULL{} which indicates to use the default error handling. - \end{cfuncdesc} \begin{cfuncdesc}{PyObject*}{PyUnicode_Join}{PyObject *separator, PyObject *seq} - Join a sequence of strings using the given separator and return the resulting Unicode string. --- 2520,2527 ---- *************** *** 2572,2576 **** int end, int direction} - Return 1 if \var{substr} matches \var{str}[\var{start}:\var{end}] at the given tail end (\var{direction} == -1 means to do a prefix match, --- 2533,2536 ---- *************** *** 2583,2587 **** int end, int direction} - Return the first position of \var{substr} in \var{str}[\var{start}:\var{end}] using the given \var{direction} --- 2543,2546 ---- *************** *** 2594,2598 **** int start, int end} - Count the number of occurrences of \var{substr} in \var{str}[\var{start}:\var{end}] --- 2553,2556 ---- *************** *** 2603,2615 **** PyObject *replstr, int maxcount} - Replace at most \var{maxcount} occurrences of \var{substr} in \var{str} with \var{replstr} and return the resulting Unicode object. \var{maxcount} == -1 means: replace all occurrences. \end{cfuncdesc} - - \begin{cfuncdesc}{int}{PyUnicode_Compare}{PyObject *left, - PyObject *right} Compare two strings and return -1, 0, 1 for less than, equal, greater than resp. --- 2561,2570 ---- PyObject *replstr, int maxcount} Replace at most \var{maxcount} occurrences of \var{substr} in \var{str} with \var{replstr} and return the resulting Unicode object. \var{maxcount} == -1 means: replace all occurrences. \end{cfuncdesc} + \begin{cfuncdesc}{int}{PyUnicode_Compare}{PyObject *left, PyObject *right} Compare two strings and return -1, 0, 1 for less than, equal, greater than resp. *************** *** 2618,2633 **** \begin{cfuncdesc}{PyObject*}{PyUnicode_Format}{PyObject *format, PyObject *args} ! Returns a new string object from \var{format} and \var{args}. Analogous ! to \code{\var{format} \% \var{args}}. The \var{args} argument must be ! a tuple. \end{cfuncdesc} \begin{cfuncdesc}{int}{PyUnicode_Contains}{PyObject *container, PyObject *element} - Checks whether \var{element} is contained in \var{container} and ! returns 1/0 accordingly. ! \var{element} has to coerce to an one element Unicode string. -1 is returned in case of an error. \end{cfuncdesc} --- 2573,2587 ---- \begin{cfuncdesc}{PyObject*}{PyUnicode_Format}{PyObject *format, PyObject *args} ! Returns a new string object from \var{format} and \var{args}; this is ! analogous to \code{\var{format} \%\ \var{args}}. The ! \var{args} argument must be a tuple. \end{cfuncdesc} \begin{cfuncdesc}{int}{PyUnicode_Contains}{PyObject *container, PyObject *element} Checks whether \var{element} is contained in \var{container} and ! returns true or false accordingly. ! \var{element} has to coerce to a one element Unicode string. \code{-1} is returned in case of an error. \end{cfuncdesc} *************** *** 2971,2975 **** PyObject *val} Inserts \var{value} into the dictionary using \var{key} ! as a key. \var{key} should be a \ctype{char *}. The key object is created using \code{PyString_FromString(\var{key})}. \ttindex{PyString_FromString()} --- 2925,2929 ---- PyObject *val} Inserts \var{value} into the dictionary using \var{key} ! as a key. \var{key} should be a \ctype{char*}. The key object is created using \code{PyString_FromString(\var{key})}. \ttindex{PyString_FromString()} *************** *** 3448,3452 **** \begin{cfuncdesc}{PyObject*}{PyCObject_FromVoidPtr}{void* cobj, void (*destr)(void *)} ! Creates a \ctype{PyCObject} from the \code{void *} \var{cobj}. The \var{destr} function will be called when the object is reclaimed, unless it is \NULL. --- 3402,3406 ---- \begin{cfuncdesc}{PyObject*}{PyCObject_FromVoidPtr}{void* cobj, void (*destr)(void *)} ! Creates a \ctype{PyCObject} from the \code{void *}\var{cobj}. The \var{destr} function will be called when the object is reclaimed, unless it is \NULL. From python-dev@python.org Sun Jun 18 15:51:24 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sun, 18 Jun 2000 07:51:24 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules mmapmodule.c,2.13,2.14 Message-ID: <200006181451.HAA07070@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv7045 Modified Files: mmapmodule.c Log Message: Support resizing the mapping depending on whether HAVE_MREMAP is defined Remove two unused variables Index: mmapmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/mmapmodule.c,v retrieving revision 2.13 retrieving revision 2.14 diff -C2 -r2.13 -r2.14 *** mmapmodule.c 2000/06/18 04:45:14 2.13 --- mmapmodule.c 2000/06/18 14:51:21 2.14 *************** *** 335,339 **** #ifdef UNIX ! #ifndef MREMAP_MAYMOVE } else { PyErr_SetString(PyExc_SystemError, --- 335,339 ---- #ifdef UNIX ! #ifndef HAVE_MREMAP } else { PyErr_SetString(PyExc_SystemError, *************** *** 344,348 **** --- 344,352 ---- void *newmap; + #ifdef MREMAP_MAYMOVE newmap = mremap(self->data, self->size, new_size, MREMAP_MAYMOVE); + #else + newmap = mremap(self->data, self->size, new_size, 0); + #endif if (newmap == (void *)-1) { *************** *** 354,358 **** Py_INCREF(Py_None); return Py_None; ! #endif /* MREMAP_MAYMOVE */ #endif /* UNIX */ } --- 358,362 ---- Py_INCREF(Py_None); return Py_None; ! #endif /* HAVE_MREMAP */ #endif /* UNIX */ } *************** *** 775,780 **** int map_size; int fd, flags = MAP_SHARED, prot = PROT_WRITE | PROT_READ; - char * filename; - int namelen; char *keywords[] = {"file", "size", "flags", "prot", NULL}; --- 779,782 ---- From python-dev@python.org Sun Jun 18 15:54:16 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sun, 18 Jun 2000 07:54:16 -0700 Subject: [Python-checkins] CVS: python/dist/src configure.in,1.124,1.125 Message-ID: <200006181454.HAA07218@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv7191 Modified Files: configure.in Log Message: Check for existence of mremap() Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.124 retrieving revision 1.125 diff -C2 -r1.124 -r1.125 *** configure.in 2000/05/26 12:22:54 1.124 --- configure.in 2000/06/18 14:54:13 1.125 *************** *** 764,768 **** flock fork fsync fdatasync fpathconf ftime ftruncate \ getgroups getlogin getpeername getpgrp getpid getpwent gettimeofday getwd \ ! kill link lstat mkfifo mktime nice pathconf pause plock pthread_init \ putenv readlink \ select setgid setlocale setuid setsid setpgid setpgrp setvbuf \ --- 764,769 ---- flock fork fsync fdatasync fpathconf ftime ftruncate \ getgroups getlogin getpeername getpgrp getpid getpwent gettimeofday getwd \ ! kill link lstat mkfifo mktime mremap \ ! nice pathconf pause plock pthread_init \ putenv readlink \ select setgid setlocale setuid setsid setpgid setpgrp setvbuf \ From python-dev@python.org Sun Jun 18 16:07:42 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sun, 18 Jun 2000 08:07:42 -0700 Subject: [Python-checkins] CVS: python/dist/src configure,1.116,1.117 config.h.in,2.55,2.56 Message-ID: <200006181507.IAA13927@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv13868 Modified Files: configure config.h.in Log Message: Regenerated autoconf files. There's an extra change to config.h.in beyond the mremap() change I made; did someone modify configure.in previously without recreating these files? Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.116 retrieving revision 1.117 diff -C2 -r1.116 -r1.117 *** configure 2000/05/26 12:22:54 1.116 --- configure 2000/06/18 15:07:39 1.117 *************** *** 1,5 **** #! /bin/sh ! # From configure.in Revision: 1.123 # Guess values for system-dependent variables and create Makefiles. --- 1,5 ---- #! /bin/sh ! # From configure.in Revision: 1.125 [...1463 lines suppressed...] echo $ac_n "checking for socklen_t""... $ac_c" 1>&6 ! echo "configure:5326: checking for socklen_t" >&5 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 < --- 5324,5333 ---- EOF echo $ac_n "checking for socklen_t""... $ac_c" 1>&6 ! echo "configure:5327: checking for socklen_t" >&5 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 < Index: config.h.in =================================================================== RCS file: /cvsroot/python/python/dist/src/config.h.in,v retrieving revision 2.55 retrieving revision 2.56 diff -C2 -r2.55 -r2.56 *** config.h.in 2000/05/11 18:41:31 2.55 --- config.h.in 2000/06/18 15:07:40 2.56 *************** *** 361,364 **** --- 361,367 ---- #undef HAVE_MKTIME + /* Define if you have the mremap function. */ + #undef HAVE_MREMAP + /* Define if you have the nice function. */ #undef HAVE_NICE *************** *** 528,531 **** --- 531,537 ---- /* Define if you have the header file. */ #undef HAVE_SYS_SELECT_H + + /* Define if you have the header file. */ + #undef HAVE_SYS_SOCKET_H /* Define if you have the header file. */ From python-dev@python.org Sun Jun 18 16:45:58 2000 From: python-dev@python.org (Greg Ward) Date: Sun, 18 Jun 2000 08:45:58 -0700 Subject: [Python-checkins] CVS: distutils/distutils util.py,1.35,1.36 Message-ID: <200006181545.IAA15436@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv15428 Modified Files: util.py Log Message: 'get_platform()' now just returns 'sys.platform' on all platforms. Index: util.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/util.py,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -r1.35 -r1.36 *** util.py 2000/06/17 02:16:46 1.35 --- util.py 2000/06/18 15:45:55 1.36 *************** *** 45,60 **** def get_platform (): """Return a string (suitable for tacking onto directory names) that ! identifies the current platform. Under Unix, identifies both the OS ! and hardware architecture, e.g. "linux-i586", "solaris-sparc", ! "irix-mips". For Windows and Mac OS, just returns 'sys.platform' -- ! i.e. "???" or "???".""" ! ! if os.name == 'posix': ! (OS, _, rel, _, arch) = os.uname() ! return "%s%c-%s" % (string.lower (OS), rel[0], string.lower (arch)) ! else: ! return sys.platform ! ! # get_platform() --- 45,52 ---- def get_platform (): """Return a string (suitable for tacking onto directory names) that ! identifies the current platform. Currently, this is just ! 'sys.platform'. ! """ ! return sys.platform From python-dev@python.org Sun Jun 18 19:43:16 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sun, 18 Jun 2000 11:43:16 -0700 Subject: [Python-checkins] CVS: python/dist/src/Include abstract.h,2.17,2.18 Message-ID: <200006181843.LAA10009@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Include In directory slayer.i.sourceforge.net:/tmp/cvs-serv9974/Include Modified Files: abstract.h Log Message: Patch from /F: this patch introduces PySequence_Fast and PySequence_Fast_GET_ITEM, and modifies the list.extend method to accept any kind of sequence. Index: abstract.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/abstract.h,v retrieving revision 2.17 retrieving revision 2.18 diff -C2 -r2.17 -r2.18 *** abstract.h 2000/03/10 22:35:06 2.17 --- abstract.h 2000/06/18 18:43:13 2.18 *************** *** 732,736 **** Return the ith element of o, or NULL on failure. This is the equivalent of the Python expression: o[i]. - */ --- 732,735 ---- *************** *** 784,787 **** --- 783,787 ---- */ + DL_IMPORT(PyObject *) PySequence_List Py_PROTO((PyObject *o)); *************** *** 789,792 **** --- 789,811 ---- Returns the sequence, o, as a list on success, and NULL on failure. This is equivalent to the Python expression: list(o) + */ + + DL_IMPORT(PyObject *) PySequence_Fast Py_PROTO((PyObject *o, const char* m)); + + /* + Returns the sequence, o, as a tuple, unless it's already a + tuple or list. Use PySequence_Fast_GET_ITEM to access the + members of this list. + + Returns NULL on failure. If the object is not a sequence, + raises a TypeError exception with m as the message text. + */ + + #define PySequence_Fast_GET_ITEM(o, i)\ + (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i)) + + /* + Return the ith element of o, assuming that o was returned by + PySequence_Fast, and that i is within bounds. */ From python-dev@python.org Sun Jun 18 19:43:16 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sun, 18 Jun 2000 11:43:16 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects abstract.c,2.34,2.35 listobject.c,2.72,2.73 Message-ID: <200006181843.LAA10014@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv9974/Objects Modified Files: abstract.c listobject.c Log Message: Patch from /F: this patch introduces PySequence_Fast and PySequence_Fast_GET_ITEM, and modifies the list.extend method to accept any kind of sequence. Index: abstract.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/abstract.c,v retrieving revision 2.34 retrieving revision 2.35 diff -C2 -r2.34 -r2.35 *** abstract.c 2000/04/05 20:11:20 2.34 --- abstract.c 2000/06/18 18:43:14 2.35 *************** *** 1208,1211 **** --- 1208,1231 ---- } + PyObject * + PySequence_Fast(v, m) + PyObject *v; + const char* m; + { + if (v == NULL) + return null_error(); + + if (PyList_Check(v) || PyTuple_Check(v)) { + Py_INCREF(v); + return v; + } + + v = PySequence_Tuple(v); + if (v == NULL && PyErr_ExceptionMatches(PyExc_TypeError)) + return type_error(m); + + return v; + } + int PySequence_Count(s, o) Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.72 retrieving revision 2.73 diff -C2 -r2.72 -r2.73 *** listobject.c 2000/06/15 14:50:20 2.72 --- listobject.c 2000/06/18 18:43:14 2.73 *************** *** 628,641 **** return NULL; ! if (!PyList_Check(b)) { ! PyErr_SetString(PyExc_TypeError, ! "list.extend() argument must be a list"); return NULL; ! } ! if (PyList_GET_SIZE(b) == 0) { /* short circuit when b is empty */ ! Py_INCREF(Py_None); ! return Py_None; ! } if (self == (PyListObject*)b) { /* as in list_ass_slice() we must special case the --- 628,639 ---- return NULL; ! b = PySequence_Fast(b, "list.extend() argument must be a sequence"); ! if (!b) return NULL; ! ! if (PyObject_Length(b) == 0) /* short circuit when b is empty */ ! goto ok; ! if (self == (PyListObject*)b) { /* as in list_ass_slice() we must special case the *************** *** 645,648 **** --- 643,647 ---- * list_slice() the way list_ass_slice() does. */ + Py_DECREF(b); b = PyList_New(selflen); if (!b) *************** *** 654,684 **** } } ! else ! /* we want b to have the same refcount semantics for the ! * Py_XDECREF() in the finally clause regardless of which ! * branch in the above conditional we took. ! */ ! Py_INCREF(b); - blen = PyList_GET_SIZE(b); /* resize a using idiom */ items = self->ob_item; NRESIZE(items, PyObject*, selflen + blen); ! if (items == NULL ) { PyErr_NoMemory(); ! goto finally; } self->ob_item = items; ! /* populate the end self with b's items */ for (i = 0; i < blen; i++) { ! PyObject *o = PyList_GET_ITEM(b, i); Py_INCREF(o); PyList_SET_ITEM(self, self->ob_size++, o); } res = Py_None; Py_INCREF(res); ! finally: ! Py_XDECREF(b); return res; } --- 653,679 ---- } } ! ! blen = PyObject_Length(b); /* resize a using idiom */ items = self->ob_item; NRESIZE(items, PyObject*, selflen + blen); ! if (items == NULL) { PyErr_NoMemory(); ! goto failed; } self->ob_item = items; ! /* populate the end of self with b's items */ for (i = 0; i < blen; i++) { ! PyObject *o = PySequence_Fast_GET_ITEM(b, i); Py_INCREF(o); PyList_SET_ITEM(self, self->ob_size++, o); } + ok: res = Py_None; Py_INCREF(res); ! failed: ! Py_DECREF(b); return res; } From python-dev@python.org Sun Jun 18 19:45:52 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sun, 18 Jun 2000 11:45:52 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _tkinter.c,1.99,1.100 Message-ID: <200006181845.LAA10182@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv10064/Modules Modified Files: _tkinter.c Log Message: Patch from /F: this patch adds a fast _flatten function to the _tkinter module, and imports it from Tkinter.py (if available). this speeds up canvas operations like create_line and create_polygon. for example, a create_line with 5000 vertices runs about 50 times faster with this patch in place. Index: _tkinter.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_tkinter.c,v retrieving revision 1.99 retrieving revision 1.100 diff -C2 -r1.99 -r1.100 *** _tkinter.c 2000/05/04 15:55:17 1.99 --- _tkinter.c 2000/06/18 18:45:50 1.100 *************** *** 1979,1982 **** --- 1979,2081 ---- /**** Tkinter Module ****/ + typedef struct { + PyObject* tuple; + int size; /* current size */ + int maxsize; /* allocated size */ + } FlattenContext; + + static int + _bump(FlattenContext* context, int size) + { + /* expand tuple to hold (at least) size new items. return true if + successful, false if an exception was raised*/ + + int maxsize = context->maxsize * 2; + + if (maxsize < context->size + size) + maxsize = context->size + size; + + context->maxsize = maxsize; + + return _PyTuple_Resize(&context->tuple, maxsize, 0) >= 0; + } + + static int + _flatten1(FlattenContext* context, PyObject* item) + { + /* add tuple or list to argument tuple (recursively) */ + + int i, size; + + if (PyList_Check(item)) { + size = PyList_GET_SIZE(item); + /* preallocate (assume no nesting) */ + if (context->size + size > context->maxsize && !_bump(context, size)) + return 0; + /* copy items to output tuple */ + for (i = 0; i < size; i++) { + PyObject *o = PyList_GET_ITEM(item, i); + if (PyList_Check(o) || PyTuple_Check(o)) { + if (!_flatten1(context, o)) + return 0; + } else if (o != Py_None) { + if (context->size + 1 > context->maxsize && !_bump(context, 1)) + return 0; + Py_INCREF(o); + PyTuple_SET_ITEM(context->tuple, context->size++, o); + } + } + } else if (PyTuple_Check(item)) { + /* same, for tuples */ + size = PyTuple_GET_SIZE(item); + if (context->size + size > context->maxsize && !_bump(context, size)) + return 0; + for (i = 0; i < size; i++) { + PyObject *o = PyTuple_GET_ITEM(item, i); + if (PyList_Check(o) || PyTuple_Check(o)) { + if (!_flatten1(context, o)) + return 0; + } else if (o != Py_None) { + if (context->size + 1 > context->maxsize && !_bump(context, 1)) + return 0; + Py_INCREF(o); + PyTuple_SET_ITEM(context->tuple, context->size++, o); + } + } + } else { + PyErr_SetString(PyExc_TypeError, "argument must be sequence"); + return 0; + } + return 1; + } + + static PyObject * + Tkinter_Flatten(PyObject* self, PyObject* args) + { + FlattenContext context; + PyObject* item; + + if (!PyArg_ParseTuple(args, "O:_flatten", &item)) + return NULL; + + context.maxsize = PySequence_Length(item); + if (context.maxsize <= 0) + return PyTuple_New(0); + + context.tuple = PyTuple_New(context.maxsize); + if (!context.tuple) + return NULL; + + context.size = 0; + + if (!_flatten1(&context, item)) + return NULL; + + if (_PyTuple_Resize(&context.tuple, context.size, 0)) + return NULL; + + return context.tuple; + } + static PyObject * Tkinter_Create(self, args) *************** *** 2007,2010 **** --- 2106,2110 ---- static PyMethodDef moduleMethods[] = { + {"_flatten", Tkinter_Flatten, 1}, {"create", Tkinter_Create, 1}, #ifdef HAVE_CREATEFILEHANDLER From python-dev@python.org Sun Jun 18 19:45:52 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sun, 18 Jun 2000 11:45:52 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/lib-tk Tkinter.py,1.137,1.138 Message-ID: <200006181845.LAA10188@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/lib-tk In directory slayer.i.sourceforge.net:/tmp/cvs-serv10064/Lib/lib-tk Modified Files: Tkinter.py Log Message: Patch from /F: this patch adds a fast _flatten function to the _tkinter module, and imports it from Tkinter.py (if available). this speeds up canvas operations like create_line and create_polygon. for example, a create_line with 5000 vertices runs about 50 times faster with this patch in place. Index: Tkinter.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/Tkinter.py,v retrieving revision 1.137 retrieving revision 1.138 diff -C2 -r1.137 -r1.138 *** Tkinter.py 2000/03/30 23:19:44 1.137 --- Tkinter.py 2000/06/18 18:45:50 1.138 *************** *** 40,43 **** --- 40,46 ---- return res + try: _flatten = _tkinter._flatten + except AttributeError: pass + def _cnfmerge(cnfs): if type(cnfs) is DictionaryType: *************** *** 55,58 **** --- 58,64 ---- cnf[k] = v return cnf + + try: _cnfmerge = _tkinter._cnfmerge + except AttributeError: pass class Event: From python-dev@python.org Sun Jun 18 20:06:51 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sun, 18 Jun 2000 12:06:51 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules mmapmodule.c,2.14,2.15 Message-ID: <200006181906.MAA17436@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv17425 Modified Files: mmapmodule.c Log Message: Patch from Lorenzo M. Catucci: I discovered the [MREMAP_MAYMOVE] symbol is only defined when _GNU_SOURCE is defined; therefore, here is the change: if we are compiling for linux, define _GNU_SOURCE before including mman.h, and all is done. Index: mmapmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/mmapmodule.c,v retrieving revision 2.14 retrieving revision 2.15 diff -C2 -r2.14 -r2.15 *** mmapmodule.c 2000/06/18 14:51:21 2.14 --- mmapmodule.c 2000/06/18 19:06:49 2.15 *************** *** 17,20 **** --- 17,25 ---- */ + #ifdef __linux__ + #define _GNU_SOURCE /* So we can get MREMAP_MAYMOVE defined when + sys/mman.h is included */ + #endif + #include From python-dev@python.org Sun Jun 18 21:27:12 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sun, 18 Jun 2000 13:27:12 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre.py,1.5,1.6 Message-ID: <200006182027.NAA00829@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv817 Modified Files: sre.py Log Message: Fix bug when the replacement template is a callable object Index: sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** sre.py 2000/06/01 17:39:12 1.5 --- sre.py 2000/06/18 20:27:10 1.6 *************** *** 91,95 **** # internal: pattern.subn implementation hook if callable(template): ! filter = callable else: # FIXME: prepare template --- 91,95 ---- # internal: pattern.subn implementation hook if callable(template): ! filter = template else: # FIXME: prepare template From python-dev@python.org Sun Jun 18 23:22:29 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Sun, 18 Jun 2000 15:22:29 -0700 Subject: [Python-checkins] CVS: python/dist/src/Include unicodeobject.h,2.9,2.10 Message-ID: <200006182222.PAA19408@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Include In directory slayer.i.sourceforge.net:/tmp/cvs-serv19395/Include Modified Files: unicodeobject.h Log Message: Marc-Andre Lemburg : Added optimization proposed by Andrew Kuchling to the Unicode matching macro. Index: unicodeobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/unicodeobject.h,v retrieving revision 2.9 retrieving revision 2.10 diff -C2 -r2.9 -r2.10 *** unicodeobject.h 2000/05/09 19:51:53 2.9 --- unicodeobject.h 2000/06/18 22:22:27 2.10 *************** *** 169,173 **** #define Py_UNICODE_MATCH(string, offset, substring)\ ! (!memcmp((string)->str + (offset), (substring)->str,\ (substring)->length*sizeof(Py_UNICODE))) --- 169,174 ---- #define Py_UNICODE_MATCH(string, offset, substring)\ ! ((*((string)->str + (offset)) == *((substring)->str)) &&\ ! !memcmp((string)->str + (offset), (substring)->str,\ (substring)->length*sizeof(Py_UNICODE))) From python-dev@python.org Sun Jun 18 23:25:24 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Sun, 18 Jun 2000 15:25:24 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.27,2.28 Message-ID: <200006182225.PAA19484@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv19475/Objects Modified Files: unicodeobject.c Log Message: Marc-Andre Lemburg : Fixed a bug in PyUnicode_Count() which would have caused a core dump in case of substring coercion failure. Synchronized .count() with the string method of the same name to return len(s)+1 for s.count(''). Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.27 retrieving revision 2.28 diff -C2 -r2.27 -r2.28 *** unicodeobject.c 2000/06/17 20:31:17 2.27 --- unicodeobject.c 2000/06/18 22:25:22 2.28 *************** *** 2107,2110 **** --- 2107,2113 ---- int count = 0; + if (substring->length == 0) + return (end - start + 1); + end -= substring->length; *************** *** 2131,2135 **** substr = PyUnicode_FromObject(substr); if (substr == NULL) { ! Py_DECREF(substr); return -1; } --- 2134,2138 ---- substr = PyUnicode_FromObject(substr); if (substr == NULL) { ! Py_DECREF(str); return -1; } *************** *** 3087,3095 **** return NULL; - if (substring->length == 0) { - Py_DECREF(substring); - return PyInt_FromLong((long) 0); - } - if (start < 0) start += self->length; --- 3090,3093 ---- From python-dev@python.org Sun Jun 18 23:33:10 2000 From: python-dev@python.org (Fredrik Lundh) Date: Mon, 19 Jun 2000 00:33:10 +0200 Subject: [Python-checkins] CVS: python/dist/src/Include unicodeobject.h,2.9,2.10 References: <200006182222.PAA19408@slayer.i.sourceforge.net> Message-ID: <00c601bfd975$358d0aa0$f2a6b5d4@hagrid> mal wrote: > =20 > #define Py_UNICODE_MATCH(string, offset, substring)\ > ! ((*((string)->str + (offset)) =3D=3D *((substring)->str)) &&\ > ! !memcmp((string)->str + (offset), (substring)->str,\ > (substring)->length*sizeof(Py_UNICODE))) > =20 I completely forgot that this has different semantics if the substring happens to be empty. (substrings are null terminated, but "\0" isn't the same thing as ""...) don't have time to screen unicodeobject.c right now, but maybe someone else can do it? if not, maybe amk's patch was a better idea after all... From python-dev@python.org Mon Jun 19 00:15:25 2000 From: python-dev@python.org (Michael Hudson) Date: 19 Jun 2000 00:15:25 +0100 Subject: [Python-checkins] CVS: python/dist/src/Modules _tkinter.c,1.99,1.100 In-Reply-To: "A.M. Kuchling"'s message of "Sun, 18 Jun 2000 11:45:52 -0700" References: <200006181845.LAA10182@slayer.i.sourceforge.net> Message-ID: "A.M. Kuchling" writes: > Update of /cvsroot/python/python/dist/src/Modules > In directory slayer.i.sourceforge.net:/tmp/cvs-serv10064/Modules > > Modified Files: > _tkinter.c > Log Message: > Patch from /F: > this patch adds a fast _flatten function to the _tkinter > module, and imports it from Tkinter.py (if available). > > this speeds up canvas operations like create_line and > create_polygon. for example, a create_line with 5000 > vertices runs about 50 times faster with this patch in > place. Unfortunately this introduces another Way To Make Python Core: [mwh21@atrus build]$ ./python Python 1.6a2 (#4, Jun 18 2000, 23:57:36) [GCC 2.95.1 19990816/Linux (release)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam Copyright 1995-2000 Corporation for National Research Initiatives (CNRI) >>> import Tkinter >>> l = [] >>> l.append(l) >>> Tkinter._flatten(l) Segmentation fault (core dumped) Here's a simple solution: Index: _tkinter.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_tkinter.c,v retrieving revision 1.100 diff -u -r1.100 _tkinter.c --- _tkinter.c 2000/06/18 18:45:50 1.100 +++ _tkinter.c 2000/06/18 23:13:22 @@ -2001,13 +2001,16 @@ } static int -_flatten1(FlattenContext* context, PyObject* item) +_flatten1(FlattenContext* context, PyObject* item, int depth) { /* add tuple or list to argument tuple (recursively) */ int i, size; - if (PyList_Check(item)) { + if (depth > 1000) { + PyErr_SetString(PyExc_ValueError,"nesting too deep in _flatten"); + return 0; + } else if (PyList_Check(item)) { size = PyList_GET_SIZE(item); /* preallocate (assume no nesting) */ if (context->size + size > context->maxsize && !_bump(context, size)) @@ -2016,7 +2019,7 @@ for (i = 0; i < size; i++) { PyObject *o = PyList_GET_ITEM(item, i); if (PyList_Check(o) || PyTuple_Check(o)) { - if (!_flatten1(context, o)) + if (!_flatten1(context, o, depth + 1)) return 0; } else if (o != Py_None) { if (context->size + 1 > context->maxsize && !_bump(context, 1)) @@ -2033,7 +2036,7 @@ for (i = 0; i < size; i++) { PyObject *o = PyTuple_GET_ITEM(item, i); if (PyList_Check(o) || PyTuple_Check(o)) { - if (!_flatten1(context, o)) + if (!_flatten1(context, o, depth + 1)) return 0; } else if (o != Py_None) { if (context->size + 1 > context->maxsize && !_bump(context, 1)) @@ -2068,7 +2071,7 @@ context.size = 0; - if (!_flatten1(&context, item)) + if (!_flatten1(&context, item,0)) return NULL; if (_PyTuple_Resize(&context.tuple, context.size, 0)) "seems to work"; I've not tested it for performance, but I can't believe this is too hard a hit. Cheers, M. From python-dev@python.org Mon Jun 19 00:20:27 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Mon, 19 Jun 2000 01:20:27 +0200 Subject: [Python-checkins] CVS: python/dist/src/Include unicodeobject.h,2.9,2.10 References: <200006182222.PAA19408@slayer.i.sourceforge.net> <00c601bfd975$358d0aa0$f2a6b5d4@hagrid> Message-ID: <394D593B.DD4804E6@lemburg.com> Fredrik Lundh wrote: > > mal wrote: > > > > #define Py_UNICODE_MATCH(string, offset, substring)\ > > ! ((*((string)->str + (offset)) == *((substring)->str)) &&\ > > ! !memcmp((string)->str + (offset), (substring)->str,\ > > (substring)->length*sizeof(Py_UNICODE))) > > > > I completely forgot that this has different semantics if the > substring happens to be empty. > > (substrings are null terminated, but "\0" isn't the same > thing as ""...) > > don't have time to screen unicodeobject.c right now, but > maybe someone else can do it? if not, maybe amk's patch > was a better idea after all... I've checked the places where this macro is used: all except the in .count() method showed the same behaviour as for 8-bit strings. The Unicode .count() method now also returns the same value for empty substrings as the 8-bit strings. -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From python-dev@python.org Mon Jun 19 01:55:12 2000 From: python-dev@python.org (A.M. Kuchling) Date: Sun, 18 Jun 2000 17:55:12 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _tkinter.c,1.100,1.101 Message-ID: <200006190055.RAA06711@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv6640 Modified Files: _tkinter.c Log Message: Patch from Michael Hudson to fix flatten recursive data structures: [mwh21@atrus build]$ ./python >>> import Tkinter >>> l = [] >>> l.append(l) >>> Tkinter._flatten(l) Segmentation fault (core dumped) Index: _tkinter.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_tkinter.c,v retrieving revision 1.100 retrieving revision 1.101 diff -C2 -r1.100 -r1.101 *** _tkinter.c 2000/06/18 18:45:50 1.100 --- _tkinter.c 2000/06/19 00:55:09 1.101 *************** *** 2002,2006 **** static int ! _flatten1(FlattenContext* context, PyObject* item) { /* add tuple or list to argument tuple (recursively) */ --- 2002,2006 ---- static int ! _flatten1(FlattenContext* context, PyObject* item, int depth) { /* add tuple or list to argument tuple (recursively) */ *************** *** 2008,2012 **** int i, size; ! if (PyList_Check(item)) { size = PyList_GET_SIZE(item); /* preallocate (assume no nesting) */ --- 2008,2015 ---- int i, size; ! if (depth > 1000) { ! PyErr_SetString(PyExc_ValueError,"nesting too deep in _flatten"); ! return 0; ! } else if (PyList_Check(item)) { size = PyList_GET_SIZE(item); /* preallocate (assume no nesting) */ *************** *** 2017,2021 **** PyObject *o = PyList_GET_ITEM(item, i); if (PyList_Check(o) || PyTuple_Check(o)) { ! if (!_flatten1(context, o)) return 0; } else if (o != Py_None) { --- 2020,2024 ---- PyObject *o = PyList_GET_ITEM(item, i); if (PyList_Check(o) || PyTuple_Check(o)) { ! if (!_flatten1(context, o, depth + 1)) return 0; } else if (o != Py_None) { *************** *** 2034,2038 **** PyObject *o = PyTuple_GET_ITEM(item, i); if (PyList_Check(o) || PyTuple_Check(o)) { ! if (!_flatten1(context, o)) return 0; } else if (o != Py_None) { --- 2037,2041 ---- PyObject *o = PyTuple_GET_ITEM(item, i); if (PyList_Check(o) || PyTuple_Check(o)) { ! if (!_flatten1(context, o, depth + 1)) return 0; } else if (o != Py_None) { *************** *** 2069,2073 **** context.size = 0; ! if (!_flatten1(&context, item)) return NULL; --- 2072,2076 ---- context.size = 0; ! if (!_flatten1(&context, item,0)) return NULL; From python-dev@python.org Mon Jun 19 14:17:44 2000 From: python-dev@python.org (Fred L. Drake) Date: Mon, 19 Jun 2000 06:17:44 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules cStringIO.c,2.20,2.21 Message-ID: <200006191317.GAA17808@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv17801 Modified Files: cStringIO.c Log Message: Fixed docstring typo, reported by Skip Montanaro . Index: cStringIO.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cStringIO.c,v retrieving revision 2.20 retrieving revision 2.21 diff -C2 -r2.20 -r2.21 *** cStringIO.c 2000/05/03 23:44:31 2.20 --- cStringIO.c 2000/06/19 13:17:41 2.21 *************** *** 57,61 **** "This module provides a simple useful replacement for\n" "the StringIO module that is written in C. It does not provide the\n" ! "full generality if StringIO, but it provides enough for most\n" "applications and is especially useful in conjuction with the\n" "pickle module.\n" --- 57,61 ---- "This module provides a simple useful replacement for\n" "the StringIO module that is written in C. It does not provide the\n" ! "full generality of StringIO, but it provides enough for most\n" "applications and is especially useful in conjuction with the\n" "pickle module.\n" From python-dev@python.org Mon Jun 19 14:41:56 2000 From: python-dev@python.org (Fred L. Drake) Date: Mon, 19 Jun 2000 06:41:56 -0700 Subject: [Python-checkins] CVS: python/dist/src/PC config.h,1.35,1.36 Message-ID: <200006191341.GAA19157@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv19143 Modified Files: config.h Log Message: Patch from Rene Liebscher , slightly modified and commented by Fred Drake, to prevent usage of sufficiently broken GCC versions. Index: config.h =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/config.h,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -r1.35 -r1.36 *** config.h 2000/05/10 13:25:32 1.35 --- config.h 2000/06/19 13:41:54 1.36 *************** *** 27,30 **** --- 27,38 ---- */ + /* Suggested by Rene Liebscher to avoid a GCC 2.91.* + bug that requires structure imports. More recent versions of the + compiler don't exhibit this bug. + */ + #if (__GNUC__==2) && (__GNUC_MINOR__<=91) + #error "Please use an up-to-date version of gcc" + #endif + /* Some systems require special declarations for data items imported From python-dev@python.org Tue Jun 20 05:54:22 2000 From: python-dev@python.org (Fred L. Drake) Date: Mon, 19 Jun 2000 21:54:22 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.161,2.162 Message-ID: <200006200454.VAA07148@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv7137 Modified Files: bltinmodule.c Log Message: Christopher Fandrich : Fix memory leak in initializing __debug__. Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.161 retrieving revision 2.162 diff -C2 -r2.161 -r2.162 *** bltinmodule.c 2000/05/25 23:15:05 2.161 --- bltinmodule.c 2000/06/20 04:54:19 2.162 *************** *** 2365,2369 **** _PyBuiltin_Init() { ! PyObject *mod, *dict; mod = Py_InitModule4("__builtin__", builtin_methods, builtin_doc, (PyObject *)NULL, --- 2365,2369 ---- _PyBuiltin_Init() { ! PyObject *mod, *dict, *debug; mod = Py_InitModule4("__builtin__", builtin_methods, builtin_doc, (PyObject *)NULL, *************** *** 2376,2382 **** if (PyDict_SetItemString(dict, "Ellipsis", Py_Ellipsis) < 0) return NULL; ! if (PyDict_SetItemString(dict, "__debug__", ! PyInt_FromLong(Py_OptimizeFlag == 0)) < 0) return NULL; return mod; --- 2376,2385 ---- if (PyDict_SetItemString(dict, "Ellipsis", Py_Ellipsis) < 0) return NULL; ! debug = PyInt_FromLong(Py_OptimizeFlag == 0); ! if (PyDict_SetItemString(dict, "__debug__", debug) < 0) { ! Py_XDECREF(debug); return NULL; + } + Py_XDECREF(debug); return mod; From python-dev@python.org Tue Jun 20 09:12:50 2000 From: python-dev@python.org (Mark Hammond) Date: Tue, 20 Jun 2000 01:12:50 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python sysmodule.c,2.64,2.65 Message-ID: <200006200812.BAA07068@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv7059 Modified Files: sysmodule.c Log Message: Added a new debug method sys.gettotalrefcount(), which returns the total number of references on all Python objects. This is only enabled when Py_TRACE_REFS is defined (which includes default debug builds under Windows). Also removed a redundant cast from sys.getrefcount(), as discussed on the patches list. Index: sysmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v retrieving revision 2.64 retrieving revision 2.65 diff -C2 -r2.64 -r2.65 *** sysmodule.c 2000/06/07 09:13:41 2.64 --- sysmodule.c 2000/06/20 08:12:48 2.65 *************** *** 266,272 **** if (!PyArg_ParseTuple(args, "O:getrefcount", &arg)) return NULL; ! return PyInt_FromLong((long) arg->ob_refcnt); } static char getrefcount_doc[] = "getrefcount(object) -> integer\n\ --- 266,284 ---- if (!PyArg_ParseTuple(args, "O:getrefcount", &arg)) return NULL; ! return PyInt_FromLong(arg->ob_refcnt); } + #ifdef Py_TRACE_REFS + static PyObject * + sys_gettotalrefcount(PyObject *self, PyObject *args) + { + extern long _Py_RefTotal; + if (!PyArg_ParseTuple(args, ":gettotalrefcount")) + return NULL; + return PyInt_FromLong(_Py_RefTotal); + } + + #endif /* Py_TRACE_REFS */ + static char getrefcount_doc[] = "getrefcount(object) -> integer\n\ *************** *** 311,314 **** --- 323,327 ---- #ifdef Py_TRACE_REFS {"getobjects", _Py_GetObjects, 1}, + {"gettotalrefcount", sys_gettotalrefcount, 1}, #endif {"getrefcount", sys_getrefcount, 1, getrefcount_doc}, From python-dev@python.org Tue Jun 20 16:47:56 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 20 Jun 2000 08:47:56 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects stringobject.c,2.68,2.69 Message-ID: <200006201547.IAA26926@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv26919 Modified Files: stringobject.c Log Message: Fredrik Lundh : Simplify find code; this is a performance improvement on at least some platforms. Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.68 retrieving revision 2.69 diff -C2 -r2.68 -r2.69 *** stringobject.c 2000/06/14 09:18:09 2.68 --- stringobject.c 2000/06/20 15:47:54 2.69 *************** *** 652,656 **** i = j = 0; while (i+n <= len) { ! if (s[i] == sub[0] && (n == 1 || memcmp(s+i, sub, n) == 0)) { if (maxsplit-- <= 0) break; --- 652,656 ---- i = j = 0; while (i+n <= len) { ! if (s[i] == sub[0] && memcmp(s+i, sub, n) == 0) { if (maxsplit-- <= 0) break; *************** *** 853,858 **** last -= n; for (; i <= last; ++i) ! if (s[i] == sub[0] && ! (n == 1 || memcmp(&s[i+1], &sub[1], n-1) == 0)) return (long)i; } --- 853,857 ---- last -= n; for (; i <= last; ++i) ! if (s[i] == sub[0] && memcmp(&s[i], sub, n) == 0) return (long)i; } *************** *** 863,868 **** return (long)last; for (j = last-n; j >= i; --j) ! if (s[j] == sub[0] && ! (n == 1 || memcmp(&s[j+1], &sub[1], n-1) == 0)) return (long)j; } --- 862,866 ---- return (long)last; for (j = last-n; j >= i; --j) ! if (s[j] == sub[0] && memcmp(&s[j], sub, n) == 0) return (long)j; } *************** *** 1416,1422 **** for (ii = 0; ii <= len; ii++) { ! if (mem[ii] == pat[0] && ! (pat_len == 1 || ! memcmp(&mem[ii+1], &pat[1], pat_len-1) == 0)) { return ii; } --- 1414,1418 ---- for (ii = 0; ii <= len; ii++) { ! if (mem[ii] == pat[0] && memcmp(&mem[ii], pat, pat_len) == 0) { return ii; } From python-dev@python.org Tue Jun 20 19:32:19 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 20 Jun 2000 11:32:19 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib urlparse.py,1.24,1.25 Message-ID: <200006201832.LAA24163@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv24155 Modified Files: urlparse.py Log Message: Pekka Pessi : Patch to add support for sip: (Session Initiation Protocol, RFC2543) URLs. Index: urlparse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urlparse.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -r1.24 -r1.25 *** urlparse.py 2000/04/14 14:01:34 1.24 --- urlparse.py 2000/06/20 18:32:16 1.25 *************** *** 18,29 **** 'prospero', 'rtsp', 'rtspu', ''] non_hierarchical = ['gopher', 'hdl', 'mailto', 'news', 'telnet', 'wais', ! 'snews', ] uses_params = ['ftp', 'hdl', 'prospero', 'http', ! 'https', 'shttp', 'rtsp', 'rtspu', ''] uses_query = ['http', 'wais', 'https', 'shttp', ! 'gopher', 'rtsp', 'rtspu', ''] uses_fragment = ['ftp', 'hdl', 'http', 'gopher', 'news', 'nntp', 'wais', --- 18,29 ---- 'prospero', 'rtsp', 'rtspu', ''] non_hierarchical = ['gopher', 'hdl', 'mailto', 'news', 'telnet', 'wais', ! 'snews', 'sip', ] uses_params = ['ftp', 'hdl', 'prospero', 'http', ! 'https', 'shttp', 'rtsp', 'rtspu', 'sip', ''] uses_query = ['http', 'wais', 'https', 'shttp', ! 'gopher', 'rtsp', 'rtspu', 'sip', ''] uses_fragment = ['ftp', 'hdl', 'http', 'gopher', 'news', 'nntp', 'wais', From python-dev@python.org Tue Jun 20 19:36:29 2000 From: python-dev@python.org (Jeremy Hylton) Date: Tue, 20 Jun 2000 11:36:29 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python exceptions.c,1.1,1.2 Message-ID: <200006201836.LAA24482@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv24307 Modified Files: exceptions.c Log Message: mark SyntaxError__str__ as METH_VARARGS Index: exceptions.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/exceptions.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** exceptions.c 2000/05/26 19:05:16 1.1 --- exceptions.c 2000/06/20 18:36:26 1.2 *************** *** 728,732 **** PyMethodDef SyntaxError_methods[] = { {"__init__", SyntaxError__init__, 1}, ! {"__str__", SyntaxError__str__,}, {NULL, NULL} }; --- 728,732 ---- PyMethodDef SyntaxError_methods[] = { {"__init__", SyntaxError__init__, 1}, ! {"__str__", SyntaxError__str__, 1}, {NULL, NULL} }; From python-dev@python.org Tue Jun 20 19:53:00 2000 From: python-dev@python.org (Jeremy Hylton) Date: Tue, 20 Jun 2000 11:53:00 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_exceptions.py,1.6,1.7 Message-ID: <200006201853.LAA25802@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv25768 Modified Files: test_exceptions.py Log Message: add minimal test of exception use. verify that each exception can be raised, caught, and converted to a string. Index: test_exceptions.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_exceptions.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** test_exceptions.py 2000/05/25 23:16:34 1.6 --- test_exceptions.py 2000/06/20 18:52:57 1.7 *************** *** 7,11 **** --- 7,23 ---- # XXX This is not really enough, each *operation* should be tested! + def test_raise_catch(exc): + try: + raise exc, "spam" + except exc, err: + buf = str(err) + try: + raise exc("spam") + except exc, err: + buf = str(err) + print buf + def r(thing): + test_raise_catch(thing) if type(thing) == ClassType: print thing.__name__ From python-dev@python.org Tue Jun 20 20:10:47 2000 From: python-dev@python.org (Jeremy Hylton) Date: Tue, 20 Jun 2000 12:10:47 -0700 Subject: [Python-checkins] CVS: python/dist/src/Include errcode.h,2.8,2.9 node.h,2.12,2.13 Message-ID: <200006201910.MAA00549@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Include In directory slayer.i.sourceforge.net:/tmp/cvs-serv509/Include Modified Files: errcode.h node.h Log Message: Add new parser error code, E_OVERFLOW. This error is returned when the number of children of a node exceeds the max possible value for the short that is used to count them. The Python runtime converts this parser error into the SyntaxError "expression too long." Index: errcode.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/errcode.h,v retrieving revision 2.8 retrieving revision 2.9 diff -C2 -r2.8 -r2.9 *** errcode.h 1998/04/09 21:37:20 2.8 --- errcode.h 2000/06/20 19:10:44 2.9 *************** *** 53,56 **** --- 53,57 ---- #define E_ERROR 17 /* Execution error */ #define E_INDENT 18 /* Invalid indentation detected */ + #define E_OVERFLOW 19 /* Node had too many children */ #ifdef __cplusplus Index: node.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/node.h,v retrieving revision 2.12 retrieving revision 2.13 diff -C2 -r2.12 -r2.13 *** node.h 1998/12/04 18:48:11 2.12 --- node.h 2000/06/20 19:10:44 2.13 *************** *** 47,51 **** extern DL_IMPORT(node *) PyNode_New Py_PROTO((int type)); ! extern DL_IMPORT(node *) PyNode_AddChild Py_PROTO((node *n, int type, char *str, int lineno)); extern DL_IMPORT(void) PyNode_Free Py_PROTO((node *n)); --- 47,51 ---- extern DL_IMPORT(node *) PyNode_New Py_PROTO((int type)); ! extern DL_IMPORT(int) PyNode_AddChild Py_PROTO((node *n, int type, char *str, int lineno)); extern DL_IMPORT(void) PyNode_Free Py_PROTO((node *n)); From python-dev@python.org Tue Jun 20 20:10:47 2000 From: python-dev@python.org (Jeremy Hylton) Date: Tue, 20 Jun 2000 12:10:47 -0700 Subject: [Python-checkins] CVS: python/dist/src/Parser node.c,2.7,2.8 parser.c,2.10,2.11 Message-ID: <200006201910.MAA00558@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Parser In directory slayer.i.sourceforge.net:/tmp/cvs-serv509/Parser Modified Files: node.c parser.c Log Message: Add new parser error code, E_OVERFLOW. This error is returned when the number of children of a node exceeds the max possible value for the short that is used to count them. The Python runtime converts this parser error into the SyntaxError "expression too long." Index: node.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/node.c,v retrieving revision 2.7 retrieving revision 2.8 diff -C2 -r2.7 -r2.8 *** node.c 1997/04/29 21:02:42 2.7 --- node.c 2000/06/20 19:10:44 2.8 *************** *** 30,37 **** --- 30,40 ---- ******************************************************************/ + #include + /* Parse tree node implementation */ #include "pgenheaders.h" #include "node.h" + #include "errcode.h" node * *************** *** 53,57 **** #define XXXROUNDUP(n) ((n) == 1 ? 1 : ((n) + XXX - 1) / XXX * XXX) ! node * PyNode_AddChild(n1, type, str, lineno) register node *n1; --- 56,60 ---- #define XXXROUNDUP(n) ((n) == 1 ? 1 : ((n) + XXX - 1) / XXX * XXX) ! int PyNode_AddChild(n1, type, str, lineno) register node *n1; *************** *** 63,66 **** --- 66,71 ---- register int nch1 = nch+1; register node *n; + if (nch == SHRT_MAX || nch < 0) + return E_OVERFLOW; if (XXXROUNDUP(nch) < nch1) { n = n1->n_child; *************** *** 68,72 **** PyMem_RESIZE(n, node, nch1); if (n == NULL) ! return NULL; n1->n_child = n; } --- 73,77 ---- PyMem_RESIZE(n, node, nch1); if (n == NULL) ! return E_NOMEM; n1->n_child = n; } *************** *** 77,81 **** n->n_nchildren = 0; n->n_child = NULL; ! return n; } --- 82,86 ---- n->n_nchildren = 0; n->n_child = NULL; ! return 0; } Index: parser.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/parser.c,v retrieving revision 2.10 retrieving revision 2.11 diff -C2 -r2.10 -r2.11 *** parser.c 1997/04/29 21:02:45 2.10 --- parser.c 2000/06/20 19:10:44 2.11 *************** *** 154,162 **** int lineno; { assert(!s_empty(s)); ! if (PyNode_AddChild(s->s_top->s_parent, type, str, lineno) == NULL) { ! fprintf(stderr, "shift: no mem in addchild\n"); ! return -1; ! } s->s_top->s_state = newstate; return 0; --- 154,162 ---- int lineno; { + int err; assert(!s_empty(s)); ! err = PyNode_AddChild(s->s_top->s_parent, type, str, lineno); ! if (err) ! return err; s->s_top->s_state = newstate; return 0; *************** *** 173,183 **** int lineno; { register node *n; n = s->s_top->s_parent; assert(!s_empty(s)); ! if (PyNode_AddChild(n, type, (char *)NULL, lineno) == NULL) { ! fprintf(stderr, "push: no mem in addchild\n"); ! return -1; ! } s->s_top->s_state = newstate; return s_push(s, d, CHILD(n, NCH(n)-1)); --- 173,183 ---- int lineno; { + int err; register node *n; n = s->s_top->s_parent; assert(!s_empty(s)); ! err = PyNode_AddChild(n, type, (char *)NULL, lineno); ! if (err) ! return err; s->s_top->s_state = newstate; return s_push(s, d, CHILD(n, NCH(n)-1)); *************** *** 234,237 **** --- 234,238 ---- { register int ilabel; + int err; D(printf("Token %s/'%s' ... ", _PyParser_TokenNames[type], str)); *************** *** 261,268 **** dfa *d1 = PyGrammar_FindDFA( ps->p_grammar, nt); ! if (push(&ps->p_stack, nt, d1, ! arrow, lineno) < 0) { D(printf(" MemError: push\n")); ! return E_NOMEM; } D(printf(" Push ...\n")); --- 262,269 ---- dfa *d1 = PyGrammar_FindDFA( ps->p_grammar, nt); ! if ((err = push(&ps->p_stack, nt, d1, ! arrow, lineno)) > 0) { D(printf(" MemError: push\n")); ! return err; } D(printf(" Push ...\n")); *************** *** 271,278 **** /* Shift the token */ ! if (shift(&ps->p_stack, type, str, ! x, lineno) < 0) { D(printf(" MemError: shift.\n")); ! return E_NOMEM; } D(printf(" Shift.\n")); --- 272,279 ---- /* Shift the token */ ! if ((err = shift(&ps->p_stack, type, str, ! x, lineno)) > 0) { D(printf(" MemError: shift.\n")); ! return err; } D(printf(" Shift.\n")); From python-dev@python.org Tue Jun 20 20:10:47 2000 From: python-dev@python.org (Jeremy Hylton) Date: Tue, 20 Jun 2000 12:10:47 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python pythonrun.c,2.97,2.98 Message-ID: <200006201910.MAA00557@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv509/Python Modified Files: pythonrun.c Log Message: Add new parser error code, E_OVERFLOW. This error is returned when the number of children of a node exceeds the max possible value for the short that is used to count them. The Python runtime converts this parser error into the SyntaxError "expression too long." Index: pythonrun.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v retrieving revision 2.97 retrieving revision 2.98 diff -C2 -r2.97 -r2.98 *** pythonrun.c 2000/05/25 23:09:49 2.97 --- pythonrun.c 2000/06/20 19:10:44 2.98 *************** *** 1034,1037 **** --- 1034,1040 ---- msg = "inconsistent use of tabs and spaces in indentation"; break; + case E_OVERFLOW: + msg = "expression too long"; + break; default: fprintf(stderr, "error=%d\n", err->error); From python-dev@python.org Tue Jun 20 20:13:30 2000 From: python-dev@python.org (Jeremy Hylton) Date: Tue, 20 Jun 2000 12:13:30 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_longexp.py,NONE,1.1 Message-ID: <200006201913.MAA00770@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv656 Added Files: test_longexp.py Log Message: verify that Python raises SyntaxError for long and deeply-nested expressions --- NEW FILE --- REPS = 8192 try: eval("2+2+" * REPS + "+3.14159265") except SyntaxError, msg: print "Caught SyntaxError for long expression:", msg else: print "Long expression did not raise SyntaxError" ## This test prints "s_push: parser stack overflow" on stderr, ## which seems to confuse the test harness ##try: ## eval("(2+" * REPS + "0" + ")" * REPS) ##except SyntaxError: ## pass ##else: ## print "Deeply nested expression did not raised SyntaxError" From python-dev@python.org Tue Jun 20 20:13:30 2000 From: python-dev@python.org (Jeremy Hylton) Date: Tue, 20 Jun 2000 12:13:30 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_longexp,NONE,1.1 Message-ID: <200006201913.MAA00775@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv656/output Added Files: test_longexp Log Message: verify that Python raises SyntaxError for long and deeply-nested expressions --- NEW FILE --- test_longexp Caught SyntaxError for long expression: expression too long From python-dev@python.org Wed Jun 21 02:41:51 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 20 Jun 2000 18:41:51 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _cursesmodule.c,2.23,2.24 Message-ID: <200006210141.SAA00795@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv761 Modified Files: _cursesmodule.c Log Message: Added .timeout() method and .typeahead() function Index: _cursesmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_cursesmodule.c,v retrieving revision 2.23 retrieving revision 2.24 diff -C2 -r2.23 -r2.24 *** _cursesmodule.c 2000/06/10 23:12:32 2.23 --- _cursesmodule.c 2000/06/21 01:41:48 2.24 *************** *** 227,230 **** --- 227,231 ---- Window_OneArgNoReturnVoidFunction(idcok, int, "i;True(1) or False(0)") Window_OneArgNoReturnVoidFunction(immedok, int, "i;True(1) or False(0)") + Window_OneArgNoReturnVoidFunction(wtimeout, int, "i;delay") Window_NoArg2TupleReturnFunction(getyx, int, "(ii)") *************** *** 1287,1290 **** --- 1288,1292 ---- {"syncok", (PyCFunction)PyCursesWindow_syncok}, {"syncup", (PyCFunction)PyCursesWindow_wsyncup}, + {"timeout", (PyCFunction)PyCursesWindow_wtimeout}, {"touchline", (PyCFunction)PyCursesWindow_TouchLine}, {"touchwin", (PyCFunction)PyCursesWindow_touchwin}, *************** *** 2028,2031 **** --- 2030,2049 ---- static PyObject * + PyCurses_TypeAhead(self,arg) + PyObject * self; + PyObject * arg; + { + int fd, err; + + PyCursesInitialised + + if (!PyArg_Parse(arg,"i;fd",&fd)) return NULL; + + PyCursesCheckERR(typeahead( fd ), "typeahead"); + Py_INCREF(Py_None); + return Py_None; + } + + static PyObject * PyCurses_UnCtrl(self,arg) PyObject * self; *************** *** 2155,2158 **** --- 2173,2177 ---- {"termattrs", (PyCFunction)PyCurses_termattrs}, {"termname", (PyCFunction)PyCurses_termname}, + {"typeahead", (PyCFunction)PyCurses_TypeAhead}, {"unctrl", (PyCFunction)PyCurses_UnCtrl}, {"ungetch", (PyCFunction)PyCurses_UngetCh}, From python-dev@python.org Wed Jun 21 02:42:53 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 20 Jun 2000 18:42:53 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libcurses.tex,1.4,1.5 Message-ID: <200006210142.SAA00816@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv808 Modified Files: libcurses.tex Log Message: Document .timeout() method and .typeahead() function Index: libcurses.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcurses.tex,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** libcurses.tex 2000/05/23 16:46:04 1.4 --- libcurses.tex 2000/06/21 01:42:51 1.5 *************** *** 343,346 **** --- 343,358 ---- \end{funcdesc} + \begin{funcdesc}{typeahead}{fd} + Specifies that the file descriptor \var{fd} be used for typeahead + checking. If \var{fd} is -1, then no typeahead checking is done. + + The curses library does ``line-breakout optimization'' by looking for + typeahead periodically while updating the screen. If input is found, + and it is coming from a tty, the current update is postponed until + refresh or doupdate is called again, allowing faster response to + commands typed in advance. This function allows specifying a different + file descriptor for typeahead checking. + \end{funcdesc} + \begin{funcdesc}{unctrl}{ch} Returns a string which is a printable representation of the character *************** *** 779,782 **** --- 791,804 ---- Touches all locations in ancestors of the window that have been changed in the window. + \end{methoddesc} + + \begin{methoddesc}{timeout}{delay} + Sets blocking or non-blocking read behaviour for the window. If + \var{delay} is negative, blocking read is used, which will wait + indefinitely for input). If \var{delay} is zero, then non-blocking + read is used, and -1 will be returned by \method{getch()} if no input + is waiting. If \var{delay} is positive, then \method{getch()} will + block for \var{delay} milliseconds, and return -1 if there is still no + input at the end of that time. \end{methoddesc} From python-dev@python.org Wed Jun 21 02:48:55 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 20 Jun 2000 18:48:55 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libstring.tex,1.36,1.37 Message-ID: <200006210148.SAA01061@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv1013 Modified Files: libstring.tex Log Message: Minor grammatical fix Index: libstring.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstring.tex,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -r1.36 -r1.37 *** libstring.tex 2000/04/10 18:35:49 1.36 --- libstring.tex 2000/06/21 01:48:46 1.37 *************** *** 143,147 **** \var{sub} in string \code{\var{s}[\var{start}:\var{end}]}. Defaults for \var{start} and \var{end} and interpretation of ! negative values is the same as for slices. \end{funcdesc} --- 143,147 ---- \var{sub} in string \code{\var{s}[\var{start}:\var{end}]}. Defaults for \var{start} and \var{end} and interpretation of ! negative values are the same as for slices. \end{funcdesc} From python-dev@python.org Wed Jun 21 03:58:49 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 20 Jun 2000 19:58:49 -0700 Subject: [Python-checkins] CVS: distutils/distutils ccompiler.py,1.22,1.23 unixccompiler.py,1.25,1.26 Message-ID: <200006210258.TAA14638@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv14626 Modified Files: ccompiler.py unixccompiler.py Log Message: Added 'preprocess()' method to CCompiler interface, and implemented it in UnixCCompiler. Still needs to be implemented in MSVCCompiler (and whatever other compiler classes are lurking out there, waiting to be checked in). Index: ccompiler.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/ccompiler.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** ccompiler.py 2000/06/07 03:00:05 1.22 --- ccompiler.py 2000/06/21 02:58:46 1.23 *************** *** 415,418 **** --- 415,434 ---- # (must be implemented by subclasses) + def preprocess (self, + source, + output_file=None, + macros=None, + include_dirs=None, + extra_preargs=None, + extra_postargs=None): + """Preprocess a single C/C++ source file, named in 'source'. + Output will be written to file named 'output_file', or stdout if + 'output_file' not supplied. 'macros' is a list of macro + definitions as for 'compile()', which will augment the macros set + with 'define_macro()' and 'undefine_macro()'. 'include_dirs' is a + list of directory names that will be added to the default list. + """ + pass + def compile (self, sources, Index: unixccompiler.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/unixccompiler.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -r1.25 -r1.26 *** unixccompiler.py 2000/05/30 02:02:49 1.25 --- unixccompiler.py 2000/06/21 02:58:46 1.26 *************** *** 22,25 **** --- 22,26 ---- from copy import copy from distutils import sysconfig + from distutils.dep_util import newer from distutils.ccompiler import \ CCompiler, gen_preprocess_options, gen_lib_options *************** *** 103,106 **** --- 104,138 ---- # __init__ () + + + def preprocess (self, + source, + output_file=None, + macros=None, + include_dirs=None, + extra_preargs=None, + extra_postargs=None): + + (_, macros, include_dirs) = \ + self._fix_compile_args (None, macros, include_dirs) + pp_opts = gen_preprocess_options (macros, include_dirs) + cc_args = ['-E'] + pp_opts + if output_file: + cc_args.extend(['-o', output_file]) + if extra_preargs: + cc_args[:0] = extra_preargs + if extra_postargs: + extra_postargs.extend(extra_postargs) + + # We need to preprocess: either we're being forced to, or the + # source file is newer than the target (or the target doesn't + # exist). + if self.force or (output_file and newer(source, output_file)): + if output_file: + self.mkpath(os.path.dirname(output_file)) + try: + self.spawn ([self.cc] + cc_args) + except DistutilsExecError, msg: + raise CompileError, msg From python-dev@python.org Wed Jun 21 03:59:17 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 20 Jun 2000 19:59:17 -0700 Subject: [Python-checkins] CVS: distutils/distutils core.py,1.42,1.43 Message-ID: <200006210259.TAA14669@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv14656 Modified Files: core.py Log Message: Oops, import 'grok_environment_error()'. Index: core.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/core.py,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -r1.42 -r1.43 *** core.py 2000/06/17 02:17:45 1.42 --- core.py 2000/06/21 02:59:14 1.43 *************** *** 14,17 **** --- 14,18 ---- from types import * from distutils.errors import * + from distutils.util import grok_environment_error # Mainly import these so setup scripts can "from distutils.core import" them. From python-dev@python.org Wed Jun 21 04:00:53 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 20 Jun 2000 20:00:53 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command config.py,1.1,1.2 Message-ID: <200006210300.UAA17427@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv17164 Modified Files: config.py Log Message: Fleshed out and added a bunch of useful stuff, notably 'check_func()', 'try_cpp()', 'search_cpp()', and 'check_header()'. This is enough that the base config is actually useful for implementing a real config command, specifically one for mxDateTime. Index: config.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/config.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** config.py 2000/06/06 02:57:07 1.1 --- config.py 2000/06/21 03:00:50 1.2 *************** *** 14,18 **** __revision__ = "$Id$" ! import os, string from distutils.core import Command from distutils.errors import DistutilsExecError --- 14,18 ---- __revision__ = "$Id$" ! import sys, os, string, re from distutils.core import Command from distutils.errors import DistutilsExecError *************** *** 41,44 **** --- 41,49 ---- ('library-dirs=', 'L', "directories to search for external C libraries"), + + ('noisy', None, + "show every action (compile, link, run, ...) taken"), + ('dump-source', None, + "dump generated source files before attempting to compile them"), ] *************** *** 56,59 **** --- 61,72 ---- self.library_dirs = None + # maximal output for now + self.noisy = 1 + self.dump_source = 1 + + # list of temporary files generated along-the-way that we have + # to clean at some point + self.temp_files = [] + def finalize_options (self): pass *************** *** 76,80 **** if not isinstance(self.compiler, CCompiler): self.compiler = new_compiler (compiler=self.compiler, ! verbose=self.verbose, # for now dry_run=self.dry_run, force=1) --- 89,93 ---- if not isinstance(self.compiler, CCompiler): self.compiler = new_compiler (compiler=self.compiler, ! verbose=self.noisy, dry_run=self.dry_run, force=1) *************** *** 87,109 **** ! def _gen_temp_sourcefile (self, body, lang): filename = "_configtest" + LANG_EXT[lang] file = open(filename, "w") file.write(body) file.close() return filename ! def _compile (self, body, lang): ! src = self._gen_temp_sourcefile(body, lang) ! (obj,) = self.compiler.compile([src]) return (src, obj) ! def _link (self, body, lang): ! (src, obj) = self._compile(body, lang) ! exe = os.path.splitext(os.path.basename(src))[0] ! self.compiler.link_executable([obj], exe) ! return (src, obj, exe) def _clean (self, *filenames): self.announce("removing: " + string.join(filenames)) for filename in filenames: --- 100,145 ---- ! def _gen_temp_sourcefile (self, body, headers, lang): filename = "_configtest" + LANG_EXT[lang] file = open(filename, "w") + if headers: + for header in headers: + file.write("#include <%s>\n" % header) + file.write("\n") file.write(body) + if body[-1] != "\n": + file.write("\n") file.close() return filename ! def _preprocess (self, body, headers, lang): ! src = self._gen_temp_sourcefile(body, headers, lang) ! out = "_configtest.i" ! self.temp_files.extend([src, out]) ! self.compiler.preprocess(src, out) ! return (src, out) ! ! def _compile (self, body, headers, lang): ! src = self._gen_temp_sourcefile(body, headers, lang) ! if self.dump_source: ! dump_file(src, "compiling '%s':" % src) ! (obj,) = self.compiler.object_filenames([src]) ! self.temp_files.extend([src, obj]) ! self.compiler.compile([src]) return (src, obj) ! def _link (self, body, headers, libraries, library_dirs, lang): ! (src, obj) = self._compile(body, headers, lang) ! prog = os.path.splitext(os.path.basename(src))[0] ! self.temp_files.append(prog) # XXX should be prog + exe_ext ! self.compiler.link_executable([obj], prog, ! libraries=libraries, ! library_dirs=library_dirs) ! return (src, obj, prog) def _clean (self, *filenames): + if not filenames: + filenames = self.temp_files + self.temp_files = [] self.announce("removing: " + string.join(filenames)) for filename in filenames: *************** *** 114,121 **** - # XXX no 'try_cpp()' or 'search_cpp()' since the CCompiler interface - # does not provide access to the preprocessor. This is an oversight - # that should be fixed. - # XXX these ignore the dry-run flag: what to do, what to do? even if # you want a dry-run build, you still need some sort of configuration --- 150,153 ---- *************** *** 126,138 **** # which is correct. ! def try_compile (self, body, lang="c"): ! """Try to compile a source file that consists of the text in 'body' ! (a multi-line string). Return true on success, false ! otherwise. """ from distutils.ccompiler import CompileError self._check_compiler() try: ! (src, obj) = self._compile(body, lang) ok = 1 except CompileError: --- 158,218 ---- # which is correct. ! # XXX need access to the header search path and maybe default macros. ! ! def try_cpp (self, body=None, headers=None, lang="c"): ! """Construct a source file from 'body' (a string containing lines ! of C/C++ code) and 'headers' (a list of header files to include) ! and run it through the preprocessor. Return true if the ! preprocessor succeeded, false if there were any errors. ! ('body' probably isn't of much use, but what the heck.) ! """ ! from distutils.ccompiler import CompileError ! self._check_compiler() ! ok = 1 ! try: ! self._preprocess(body, headers, lang) ! except CompileError: ! ok = 0 ! ! self._clean() ! return ok ! ! def search_cpp (self, pattern, body=None, headers=None, lang="c"): ! """Construct a source file (just like 'try_cpp()'), run it through ! the preprocessor, and return true if any line of the output matches ! 'pattern'. 'pattern' should either be a compiled regex object or a ! string containing a regex. If both 'body' and 'headers' are None, ! preprocesses an empty file -- which can be useful to determine the ! symbols the preprocessor and compiler set by default. ! """ ! ! self._check_compiler() ! (src, out) = self._preprocess(body, headers, lang) ! ! if type(pattern) is StringType: ! pattern = re.compile(pattern) ! ! file = open(out) ! match = 0 ! while 1: ! line = file.readline() ! if line == '': ! break ! if pattern.search(pattern): ! match = 1 ! break ! ! file.close() ! self._clean() ! return match ! ! def try_compile (self, body, headers=None, lang="c"): ! """Try to compile a source file built from 'body' and 'headers'. ! Return true on success, false otherwise. """ from distutils.ccompiler import CompileError self._check_compiler() try: ! self._compile(body, headers, lang) ok = 1 except CompileError: *************** *** 140,155 **** self.announce(ok and "success!" or "failure.") ! self._clean(src, obj) return ok ! def try_link (self, body, lang="c"): ! """Try to compile and link a source file (to an executable) that ! consists of the text in 'body' (a multi-line string). Return true ! on success, false otherwise. """ from distutils.ccompiler import CompileError, LinkError self._check_compiler() try: ! (src, obj, exe) = self._link(body, lang) ok = 1 except (CompileError, LinkError): --- 220,238 ---- self.announce(ok and "success!" or "failure.") ! self._clean() return ok ! def try_link (self, ! body, headers=None, ! libraries=None, library_dirs=None, ! lang="c"): ! """Try to compile and link a source file, built from 'body' and ! 'headers', to executable form. Return true on success, false ! otherwise. """ from distutils.ccompiler import CompileError, LinkError self._check_compiler() try: ! self._link(body, headers, libraries, library_dirs, lang) ok = 1 except (CompileError, LinkError): *************** *** 157,166 **** self.announce(ok and "success!" or "failure.") ! self._clean(src, obj, exe) return ok ! def try_run (self, body, lang="c"): ! """Try to compile, link to an executable, and run a program that ! consists of the text in 'body'. Return true on success, false otherwise. """ --- 240,252 ---- self.announce(ok and "success!" or "failure.") ! self._clean() return ok ! def try_run (self, ! body, headers=None, ! libraries=None, library_dirs=None, ! lang="c"): ! """Try to compile, link to an executable, and run a program ! built from 'body' and 'headers'. Return true on success, false otherwise. """ *************** *** 168,172 **** self._check_compiler() try: ! (src, obj, exe) = self._link(body, lang) self.spawn([exe]) ok = 1 --- 254,258 ---- self._check_compiler() try: ! self._link(body, headers, libraries, library_dirs, lang) self.spawn([exe]) ok = 1 *************** *** 175,180 **** self.announce(ok and "success!" or "failure.") ! self._clean(src, obj, exe) return ok # class config --- 261,324 ---- self.announce(ok and "success!" or "failure.") ! self._clean() return ok + + # -- High-level methods -------------------------------------------- + # (these are the ones that are actually likely to be useful + # when implementing a real-world config command!) + + def check_func (self, func, headers=None, + libraries=None, library_dirs=None, + decl=0, call=0): + + """Determine if function 'func' is available by constructing a + source file that refers to 'func', and compiles and links it. + If everything succeeds, returns true; otherwise returns false. + + The constructed source file starts out by including the header + files listed in 'headers'. If 'decl' is true, it then declares + 'func' (as "int func()"); you probably shouldn't supply 'headers' + and set 'decl' true in the same call, or you might get errors about + a conflicting declarations for 'func'. Finally, the constructed + 'main()' function either references 'func' or (if 'call' is true) + calls it. 'libraries' and 'library_dirs' are used when + linking. + """ + + self._check_compiler() + body = [] + if decl: + body.append("int %s ();" % func) + body.append("int main () {") + if call: + body.append(" %s();" % func) + else: + body.append(" %s;" % func) + body.append("}") + body = string.join(body, "\n") + "\n" + + return self.try_link(body, headers, libraries, library_dirs) + + # check_func () + + def check_header (self, header, lang="c"): + """Determine if the system header file named by 'header_file' + exists and can be found by the preprocessor; return true if so, + false otherwise. + """ + return self.try_cpp(headers=[header]) + + # class config + + + def dump_file (filename, head=None): + if head is None: + print filename + ":" + else: + print head + + file = open(filename) + sys.stdout.write(file.read()) + file.close() From python-dev@python.org Wed Jun 21 04:09:05 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 20 Jun 2000 20:09:05 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command install.py,1.37,1.38 Message-ID: <200006210309.UAA20997@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv20983 Modified Files: install.py Log Message: Rene Liebscher: when fixing up directories with an alternate root, include 'install_headers'. Index: install.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/install.py,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -r1.37 -r1.38 *** install.py 2000/06/17 01:34:45 1.37 --- install.py 2000/06/21 03:09:02 1.38 *************** *** 273,277 **** # dirs relative to it. if self.root is not None: ! for name in ('lib', 'purelib', 'platlib', 'scripts', 'data'): attr = "install_" + name new_val = change_root (self.root, getattr (self, attr)) --- 273,278 ---- # dirs relative to it. if self.root is not None: ! for name in ('lib', 'purelib', 'platlib', ! 'scripts', 'data', 'headers'): attr = "install_" + name new_val = change_root (self.root, getattr (self, attr)) From python-dev@python.org Wed Jun 21 04:12:09 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 20 Jun 2000 20:12:09 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command install_data.py,1.8,1.9 Message-ID: <200006210312.UAA21107@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv21094 Modified Files: install_data.py Log Message: Build the 'outfiles' list so 'get_outputs()' has something to return. (Bug spotted and originally fixed by Rene Liebscher; fix redone by me.) Index: install_data.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/install_data.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** install_data.py 2000/06/06 02:18:13 1.8 --- install_data.py 2000/06/21 03:12:07 1.9 *************** *** 26,30 **** def initialize_options (self): self.install_dir = None ! self.outfiles = None self.root = None self.data_files = self.distribution.data_files --- 26,30 ---- def initialize_options (self): self.install_dir = None ! self.outfiles = [] self.root = None self.data_files = self.distribution.data_files *************** *** 41,45 **** if type(f) == StringType: # its a simple file, so copy it ! self.copy_file(f, self.install_dir) else: # its a tuple with path to install to and a list of files --- 41,46 ---- if type(f) == StringType: # its a simple file, so copy it ! out = self.copy_file(f, self.install_dir) ! self.outfiles.append(out) else: # its a tuple with path to install to and a list of files *************** *** 51,55 **** self.mkpath(dir) for data in f[1]: ! self.copy_file(data, dir) def get_inputs (self): --- 52,57 ---- self.mkpath(dir) for data in f[1]: ! out = self.copy_file(data, dir) ! self.outfiles.append(out) def get_inputs (self): *************** *** 57,59 **** def get_outputs (self): ! return self.outfiles or [] --- 59,61 ---- def get_outputs (self): ! return self.outfiles From python-dev@python.org Wed Jun 21 04:13:54 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 20 Jun 2000 20:13:54 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command install_headers.py,1.1,1.2 Message-ID: <200006210313.UAA21152@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv21126 Modified Files: install_headers.py Log Message: Build the 'outfiles' list so 'get_outputs()' has something to return. (Bug spotted and originally fixed by Rene Liebscher; fix redone by me.) Index: install_headers.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/install_headers.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** install_headers.py 2000/05/27 01:25:16 1.1 --- install_headers.py 2000/06/21 03:13:51 1.2 *************** *** 8,11 **** --- 8,12 ---- __revision__ = "$Id$" + import os from distutils.core import Command *************** *** 22,25 **** --- 23,27 ---- def initialize_options (self): self.install_dir = None + self.outfiles = [] def finalize_options (self): *************** *** 34,39 **** self.mkpath(self.install_dir) for header in headers: ! self.copy_file(header, self.install_dir) # run() --- 36,47 ---- self.mkpath(self.install_dir) for header in headers: ! out = self.copy_file(header, self.install_dir) ! self.outfiles.append(out) + def get_inputs (self): + return self.distribution.headers or [] + + def get_outputs (self): + return self.outfiles # run() From python-dev@python.org Wed Jun 21 04:14:29 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 20 Jun 2000 20:14:29 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command install_headers.py,1.2,1.3 Message-ID: <200006210314.UAA21185@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv21177 Modified Files: install_headers.py Log Message: Delete spurious comment. Index: install_headers.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/install_headers.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** install_headers.py 2000/06/21 03:13:51 1.2 --- install_headers.py 2000/06/21 03:14:27 1.3 *************** *** 44,48 **** def get_outputs (self): return self.outfiles - # run() # class install_headers --- 44,47 ---- From python-dev@python.org Wed Jun 21 04:29:59 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 20 Jun 2000 20:29:59 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command sdist.py,1.32,1.33 Message-ID: <200006210329.UAA21852@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv21805 Modified Files: sdist.py Log Message: Fix inspired by Rene Liebscher: if setup script is newer than the manifest, regenerate the manifest. Index: sdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/sdist.py,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -r1.32 -r1.33 *** sdist.py 2000/06/08 01:22:48 1.32 --- sdist.py 2000/06/21 03:29:57 1.33 *************** *** 174,185 **** depends on the user's options and the state of the filesystem. """ template_exists = os.path.isfile (self.template) if template_exists: template_newer = newer (self.template, self.manifest) # Regenerate the manifest if necessary (or if explicitly told to) ! if ((template_exists and template_newer) or ! self.force_manifest or ! self.manifest_only): if not template_exists: --- 174,208 ---- depends on the user's options and the state of the filesystem. """ + + # If we have a manifest template, see if it's newer than the + # manifest; if so, we'll regenerate the manifest. template_exists = os.path.isfile (self.template) if template_exists: template_newer = newer (self.template, self.manifest) + # The contents of the manifest file almost certainly depend on the + # setup script as well as the manifest template -- so if the setup + # script is newer than the manifest, we'll regenerate the manifest + # from the template. (Well, not quite: if we already have a + # manifest, but there's no template -- which will happen if the + # developer elects to generate a manifest some other way -- then we + # can't regenerate the manifest, so we don't.) + setup_newer = newer(sys.argv[0], self.manifest) + + # cases: + # 1) no manifest, template exists: generate manifest + # (covered by 2a: no manifest == template newer) + # 2) manifest & template exist: + # 2a) template or setup script newer than manifest: + # regenerate manifest + # 2b) manifest newer than both: + # do nothing (unless --force or --manifest-only) + # 3) manifest exists, no template: + # do nothing (unless --force or --manifest-only) + # 4) no manifest, no template: generate w/ warning ("defaults only") + # Regenerate the manifest if necessary (or if explicitly told to) ! if ((template_exists and (template_newer or setup_newer)) or ! self.force_manifest or self.manifest_only): if not template_exists: From python-dev@python.org Wed Jun 21 04:33:05 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 20 Jun 2000 20:33:05 -0700 Subject: [Python-checkins] CVS: distutils/distutils cygwinccompiler.py,NONE,1.1 Message-ID: <200006210333.UAA22040@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv22033 Added Files: cygwinccompiler.py Log Message: Implementation of the CCompiler class for Cygwin and Mingw32, ie. the two major ports of GCC to Windows. Contributed by Rene Liebscher, and quite untested by me. Apparently requires tweaking Python's installed config.h and adding a libpython.a to build extensions. ***** Error reading new file(2, 'No such file or directory') From python-dev@python.org Wed Jun 21 21:01:13 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 21 Jun 2000 13:01:13 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib xmllib.py,1.17,1.18 Message-ID: <200006212001.NAA00381@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv311 Modified Files: xmllib.py Log Message: Sjoerd Mullender: These two fixes were approved by me. Peter Kropf: There's a problem with the xmllib module when used with JPython. Specifically, the JPython re module has trouble with the () characters in strings passed into re.compile. Spiros Papadimitriou: I just downloaded xmllib.py ver. 0.3 from python.org and there seems to be a slight typo: Line 654 ("tag = self.stack[-1][0]" in parse_endtag), is indented one level more than it should be. I just thought I'd let you know... Index: xmllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xmllib.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** xmllib.py 2000/02/04 15:39:30 1.17 --- xmllib.py 2000/06/21 20:01:10 1.18 *************** *** 28,32 **** _S + '(?P' + _Name + ')' '(' + _opS + '=' + _opS + ! '(?P'+_QStr+'|[-a-zA-Z0-9.:+*%?!()_#=~]+))?') starttagopen = re.compile('<' + _Name) starttagend = re.compile(_opS + '(?P/?)>') --- 28,32 ---- _S + '(?P' + _Name + ')' '(' + _opS + '=' + _opS + ! '(?P'+_QStr+'|[-a-zA-Z0-9.:+*%?!\(\)_#=~]+))?') starttagopen = re.compile('<' + _Name) starttagend = re.compile(_opS + '(?P/?)>') *************** *** 44,49 **** # PUBLIC PubidLiteral SystemLiteral _SystemLiteral = '(?P<%s>'+_QStr+')' ! _PublicLiteral = '(?P<%s>"[-\'()+,./:=?;!*#@$_%% \n\ra-zA-Z0-9]*"|' \ ! "'[-()+,./:=?;!*#@$_%% \n\ra-zA-Z0-9]*')" _ExternalId = '(?:SYSTEM|' \ 'PUBLIC'+_S+_PublicLiteral%'pubid'+ \ --- 44,49 ---- # PUBLIC PubidLiteral SystemLiteral _SystemLiteral = '(?P<%s>'+_QStr+')' ! _PublicLiteral = '(?P<%s>"[-\'\(\)+,./:=?;!*#@$_%% \n\ra-zA-Z0-9]*"|' \ ! "'[-\(\)+,./:=?;!*#@$_%% \n\ra-zA-Z0-9]*')" _ExternalId = '(?:SYSTEM|' \ 'PUBLIC'+_S+_PublicLiteral%'pubid'+ \ *************** *** 653,657 **** if not self.__accept_missing_endtag_name: self.syntax_error('no name specified in end tag') ! tag = self.stack[-1][0] k = i+2 else: --- 653,657 ---- if not self.__accept_missing_endtag_name: self.syntax_error('no name specified in end tag') ! tag = self.stack[-1][0] k = i+2 else: From python-dev@python.org Wed Jun 21 22:21:07 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 21 Jun 2000 14:21:07 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib codecs.py,1.9,1.10 Message-ID: <200006212121.OAA14836@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv14827/Lib Modified Files: codecs.py Log Message: Marc-Andre Lemburg : Made codecs.open() default to 'rb' as file mode. Index: codecs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/codecs.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** codecs.py 2000/05/01 16:17:32 1.9 --- codecs.py 2000/06/21 21:21:04 1.10 *************** *** 459,463 **** ### Shortcuts ! def open(filename, mode, encoding=None, errors='strict', buffering=1): """ Open an encoded file using the given mode and return --- 459,463 ---- ### Shortcuts ! def open(filename, mode='rb', encoding=None, errors='strict', buffering=1): """ Open an encoded file using the given mode and return *************** *** 468,471 **** --- 468,476 ---- codecs. Output is also codec dependent and will usually by Unicode as well. + + Files are always opened in binary mode, even if no binary mode + was specified. Thisis done to avoid data loss due to encodings + using 8-bit values. The default file mode is 'rb' meaning to + open the file in binary read mode. encoding specifies the encoding which is to be used for the From python-dev@python.org Fri Jun 23 02:36:24 2000 From: python-dev@python.org (A.M. Kuchling) Date: Thu, 22 Jun 2000 18:36:24 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _cursesmodule.c,2.24,2.25 Message-ID: <200006230136.SAA21509@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv21471 Modified Files: _cursesmodule.c Log Message: Release the global interpreter lock around the most important functions that might block or pause Index: _cursesmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_cursesmodule.c,v retrieving revision 2.24 retrieving revision 2.25 diff -C2 -r2.24 -r2.25 *** _cursesmodule.c 2000/06/21 01:41:48 2.24 --- _cursesmodule.c 2000/06/23 01:36:21 2.25 *************** *** 634,643 **** --- 634,647 ---- switch (ARG_COUNT(arg)) { case 0: + Py_BEGIN_ALLOW_THREADS rtn = wgetch(self->win); + Py_END_ALLOW_THREADS break; case 2: if (!PyArg_Parse(arg,"(ii);y,x",&y,&x)) return NULL; + Py_BEGIN_ALLOW_THREADS rtn = mvwgetch(self->win,y,x); + Py_END_ALLOW_THREADS break; default: *************** *** 658,667 **** --- 662,675 ---- switch (ARG_COUNT(arg)) { case 0: + Py_BEGIN_ALLOW_THREADS rtn = wgetch(self->win); + Py_END_ALLOW_THREADS break; case 2: if (!PyArg_Parse(arg,"(ii);y,x",&y,&x)) return NULL; + Py_BEGIN_ALLOW_THREADS rtn = mvwgetch(self->win,y,x); + Py_END_ALLOW_THREADS break; default: *************** *** 686,700 **** --- 694,714 ---- switch (ARG_COUNT(arg)) { case 0: + Py_BEGIN_ALLOW_THREADS rtn2 = wgetstr(self->win,rtn); + Py_END_ALLOW_THREADS break; case 1: if (!PyArg_Parse(arg,"i;n", &n)) return NULL; + Py_BEGIN_ALLOW_THREADS rtn2 = wgetnstr(self->win,rtn,n); + Py_END_ALLOW_THREADS break; case 2: if (!PyArg_Parse(arg,"(ii);y,x",&y,&x)) return NULL; + Py_BEGIN_ALLOW_THREADS rtn2 = mvwgetstr(self->win,y,x,rtn); + Py_END_ALLOW_THREADS break; case 3: *************** *** 703,710 **** --- 717,728 ---- #if defined(__sgi__) || defined(__sun__) /* Untested */ + Py_BEGIN_ALLOW_THREADS rtn2 = wmove(self->win,y,x)==ERR ? ERR : wgetnstr(self->win, rtn, n); + Py_END_ALLOW_THREADS #else + Py_BEGIN_ALLOW_THREADS rtn2 = mvwgetnstr(self->win, y, x, rtn, n); + Py_END_ALLOW_THREADS #endif break; *************** *** 997,1000 **** --- 1015,1019 ---- { int pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol; + int rtn; if (self->win->_flags & _ISPAD) { *************** *** 1007,1017 **** &smincol, &smaxrow, &smaxcol)) return NULL; ! return PyCursesCheckERR(pnoutrefresh(self->win, ! pminrow, pmincol, sminrow, ! smincol, smaxrow, smaxcol), ! "pnoutrefresh"); default: PyErr_SetString(PyCursesError, ! "noutrefresh was called for a pad;" \ "requires 6 arguments"); return NULL; --- 1026,1038 ---- &smincol, &smaxrow, &smaxcol)) return NULL; ! Py_BEGIN_ALLOW_THREADS ! rtn = pnoutrefresh(self->win, ! pminrow, pmincol, sminrow, ! smincol, smaxrow, smaxcol), ! Py_END_ALLOW_THREADS ! return PyCursesCheckERR(rtn, "pnoutrefresh"); default: PyErr_SetString(PyCursesError, ! "noutrefresh() called for a pad " "requires 6 arguments"); return NULL; *************** *** 1020,1024 **** if (!PyArg_NoArgs(arg)) return NULL; ! return PyCursesCheckERR(wnoutrefresh(self->win), "wnoutrefresh"); } } --- 1041,1049 ---- if (!PyArg_NoArgs(arg)) return NULL; ! ! Py_BEGIN_ALLOW_THREADS ! rtn = wnoutrefresh(self->win); ! Py_END_ALLOW_THREADS ! return PyCursesCheckERR(rtn, "wnoutrefresh"); } } *************** *** 1058,1061 **** --- 1083,1087 ---- { int pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol; + int rtn; if (self->win->_flags & _ISPAD) { *************** *** 1068,1078 **** &smincol, &smaxrow, &smaxcol)) return NULL; ! return PyCursesCheckERR(prefresh(self->win, ! pminrow, pmincol, sminrow, ! smincol, smaxrow, smaxcol), ! "prefresh"); default: PyErr_SetString(PyCursesError, ! "refresh was called for a pad; requires 6 arguments"); return NULL; } --- 1094,1108 ---- &smincol, &smaxrow, &smaxcol)) return NULL; ! ! Py_BEGIN_ALLOW_THREADS ! rtn = prefresh(self->win, ! pminrow, pmincol, sminrow, ! smincol, smaxrow, smaxcol), ! ! Py_END_ALLOW_THREADS ! return PyCursesCheckERR(rtn, "prefresh"); default: PyErr_SetString(PyCursesError, ! "refresh() for a pad requires 6 arguments"); return NULL; } *************** *** 1080,1084 **** if (!PyArg_NoArgs(arg)) return NULL; ! return PyCursesCheckERR(wrefresh(self->win), "wrefresh"); } } --- 1110,1117 ---- if (!PyArg_NoArgs(arg)) return NULL; ! Py_BEGIN_ALLOW_THREADS ! rtn = wrefresh(self->win); ! Py_END_ALLOW_THREADS ! return PyCursesCheckERR(rtn); } } From python-dev@python.org Fri Jun 23 02:42:43 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 22 Jun 2000 18:42:43 -0700 Subject: [Python-checkins] CVS: distutils/distutils file_util.py,1.3,1.4 Message-ID: <200006230142.SAA21988@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv21979 Modified Files: file_util.py Log Message: Bastian Kleineidam: 'copy_file()' now returns the output filename, rather than a boolean indicating whether it did the copy. Index: file_util.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/file_util.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** file_util.py 2000/05/20 16:05:34 1.3 --- file_util.py 2000/06/23 01:42:40 1.4 *************** *** 97,103 **** contents. ! Return true if the file was copied (or would have been copied), ! false otherwise (ie. 'update' was true and the destination is ! up-to-date).""" # XXX if the destination file already exists, we clobber it if --- 97,102 ---- contents. ! Return the name of the destination file, whether it was actually ! copied or not.""" # XXX if the destination file already exists, we clobber it if *************** *** 124,128 **** if verbose: print "not copying %s (output up-to-date)" % src ! return 0 try: --- 123,127 ---- if verbose: print "not copying %s (output up-to-date)" % src ! return dst try: *************** *** 138,142 **** if dry_run: ! return 1 # On a Mac, use the native file copy routine --- 137,141 ---- if dry_run: ! return dst # On a Mac, use the native file copy routine *************** *** 172,176 **** os.chmod (dst, S_IMODE (st[ST_MODE])) ! return 1 # copy_file () --- 171,175 ---- os.chmod (dst, S_IMODE (st[ST_MODE])) ! return dst # copy_file () From python-dev@python.org Fri Jun 23 15:18:13 2000 From: python-dev@python.org (Jeremy Hylton) Date: Fri, 23 Jun 2000 07:18:13 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects classobject.c,2.86,2.87 dictobject.c,2.52,2.53 funcobject.c,2.20,2.21 listobject.c,2.73,2.74 tupleobject.c,2.36,2.37 Message-ID: <200006231418.HAA02869@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv2798/Objects Modified Files: classobject.c dictobject.c funcobject.c listobject.c tupleobject.c Log Message: Round 1 of Neil Schemenauer's GC patches: This patch adds the type methods traverse and clear necessary for GC implementation. Index: classobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v retrieving revision 2.86 retrieving revision 2.87 diff -C2 -r2.86 -r2.87 *** classobject.c 2000/05/03 23:44:34 2.86 --- classobject.c 2000/06/23 14:18:11 2.87 *************** *** 388,391 **** --- 388,428 ---- } + static int + class_traverse(PyClassObject *o, visitproc visit, void *arg) + { + int err; + if (o->cl_bases) { + err = visit(o->cl_bases, arg); + if (err) + return err; + } + if (o->cl_dict) { + err = visit(o->cl_dict, arg); + if (err) + return err; + } + if (o->cl_name) { + err = visit(o->cl_name, arg); + if (err) + return err; + } + if (o->cl_getattr) { + err = visit(o->cl_getattr, arg); + if (err) + return err; + } + if (o->cl_setattr) { + err = visit(o->cl_setattr, arg); + if (err) + return err; + } + if (o->cl_delattr) { + err = visit(o->cl_delattr, arg); + if (err) + return err; + } + return 0; + } + PyTypeObject PyClass_Type = { PyObject_HEAD_INIT(&PyType_Type) *************** *** 408,411 **** --- 445,452 ---- (getattrofunc)class_getattr, /*tp_getattro*/ (setattrofunc)class_setattr, /*tp_setattro*/ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + 0, /* tp_doc */ + (traverseproc)class_traverse, /* tp_traverse */ }; *************** *** 850,853 **** --- 891,911 ---- } + static int + instance_traverse(PyInstanceObject *o, visitproc visit, void *arg) + { + int err; + if (o->in_class) { + err = visit((PyObject *)(o->in_class), arg); + if (err) + return err; + } + if (o->in_dict) { + err = visit(o->in_dict, arg); + if (err) + return err; + } + return 1; + } + static PyObject *getitemstr, *setitemstr, *delitemstr, *lenstr; *************** *** 1473,1477 **** (setattrofunc)instance_setattr, /*tp_setattro*/ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT, /*tp_flags */ }; --- 1531,1537 ---- (setattrofunc)instance_setattr, /*tp_setattro*/ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT, /*tp_flags*/ ! 0, /* tp_doc */ ! (traverseproc)instance_traverse, /* tp_traverse */ }; *************** *** 1663,1666 **** --- 1723,1748 ---- } + static int + instancemethod_traverse(PyMethodObject *im, visitproc visit, void *arg) + { + int err; + if (im->im_func) { + err = visit(im->im_func, arg); + if (err) + return err; + } + if (im->im_self) { + err = visit(im->im_self, arg); + if (err) + return err; + } + if (im->im_class) { + err = visit(im->im_class, arg); + if (err) + return err; + } + return 1; + } + PyTypeObject PyMethod_Type = { PyObject_HEAD_INIT(&PyType_Type) *************** *** 1683,1686 **** --- 1765,1772 ---- (getattrofunc)instancemethod_getattr, /*tp_getattro*/ 0, /*tp_setattro*/ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + 0, /* tp_doc */ + (traverseproc)instancemethod_traverse, /* tp_traverse */ }; Index: dictobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/dictobject.c,v retrieving revision 2.52 retrieving revision 2.53 diff -C2 -r2.52 -r2.53 *** dictobject.c 2000/05/03 23:44:34 2.52 --- dictobject.c 2000/06/23 14:18:11 2.53 *************** *** 1039,1042 **** --- 1039,1067 ---- } + static int + dict_traverse(PyObject *op, visitproc visit, void *arg) + { + int i = 0, err; + PyObject *pk; + PyObject *pv; + + while (PyDict_Next(op, &i, &pk, &pv)) { + err = visit(pk, arg); + if (err) + return err; + err = visit(pv, arg); + if (err) + return err; + } + return 0; + } + + static int + dict_tp_clear(PyObject *op) + { + PyDict_Clear(op); + return 0; + } + static PyMethodDef mapp_methods[] = { {"has_key", (PyCFunction)dict_has_key, METH_VARARGS}, *************** *** 1074,1077 **** --- 1099,1112 ---- 0, /*tp_as_sequence*/ &dict_as_mapping, /*tp_as_mapping*/ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + 0, /* tp_doc */ + (traverseproc)dict_traverse, /* tp_traverse */ + (inquiry)dict_tp_clear, /* tp_clear */ }; Index: funcobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/funcobject.c,v retrieving revision 2.20 retrieving revision 2.21 diff -C2 -r2.20 -r2.21 *** funcobject.c 2000/05/03 23:44:35 2.20 --- funcobject.c 2000/06/23 14:18:11 2.21 *************** *** 240,243 **** --- 240,275 ---- } + static int + func_traverse(PyFunctionObject *f, visitproc visit, void *arg) + { + int err; + if (f->func_code) { + err = visit(f->func_code, arg); + if (err) + return err; + } + if (f->func_globals) { + err = visit(f->func_globals, arg); + if (err) + return err; + } + if (f->func_defaults) { + err = visit(f->func_defaults, arg); + if (err) + return err; + } + if (f->func_doc) { + err = visit(f->func_doc, arg); + if (err) + return err; + } + if (f->func_name) { + err = visit(f->func_name, arg); + if (err) + return err; + } + return 0; + } + PyTypeObject PyFunction_Type = { PyObject_HEAD_INIT(&PyType_Type) *************** *** 256,258 **** --- 288,298 ---- 0, /*tp_as_mapping*/ (hashfunc)func_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + 0, /* tp_doc */ + (traverseproc)func_traverse, /* tp_traverse */ }; Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.73 retrieving revision 2.74 diff -C2 -r2.73 -r2.74 *** listobject.c 2000/06/18 18:43:14 2.73 --- listobject.c 2000/06/23 14:18:11 2.74 *************** *** 1419,1422 **** --- 1419,1446 ---- } + static int + list_traverse(PyListObject *o, visitproc visit, void *arg) + { + int i, err; + PyObject *x; + + for (i = o->ob_size; --i >= 0; ) { + x = o->ob_item[i]; + if (x != NULL) { + err = visit(x, arg); + if (err) + return err; + } + } + return 0; + } + + static int + list_clear(PyListObject *lp) + { + (void) PyList_SetSlice((PyObject *)lp, 0, lp->ob_size, 0); + return 0; + } + static char append_doc[] = "L.append(object) -- append object to end"; *************** *** 1492,1495 **** --- 1516,1522 ---- 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT, /*tp_flags*/ + 0, /* tp_doc */ + (traverseproc)list_traverse, /* tp_traverse */ + (inquiry)list_clear, /* tp_clear */ }; *************** *** 1568,1571 **** --- 1595,1600 ---- 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT, /*tp_flags*/ + 0, /* tp_doc */ + (traverseproc)list_traverse, /* tp_traverse */ }; Index: tupleobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/tupleobject.c,v retrieving revision 2.36 retrieving revision 2.37 diff -C2 -r2.36 -r2.37 *** tupleobject.c 2000/06/16 17:05:57 2.36 --- tupleobject.c 2000/06/23 14:18:11 2.37 *************** *** 421,424 **** --- 421,441 ---- } + static int + tupletraverse(PyTupleObject *o, visitproc visit, void *arg) + { + int i, err; + PyObject *x; + + for (i = o->ob_size; --i >= 0; ) { + x = o->ob_item[i]; + if (x != NULL) { + err = visit(x, arg); + if (err) + return err; + } + } + return 0; + } + static PySequenceMethods tuple_as_sequence = { (inquiry)tuplelength, /*sq_length*/ *************** *** 454,457 **** --- 471,476 ---- 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT, /*tp_flags*/ + 0, /*tp_doc*/ + (traverseproc)tupletraverse, /* tp_traverse */ }; From python-dev@python.org Fri Jun 23 15:18:13 2000 From: python-dev@python.org (Jeremy Hylton) Date: Fri, 23 Jun 2000 07:18:13 -0700 Subject: [Python-checkins] CVS: python/dist/src/Include object.h,2.54,2.55 Message-ID: <200006231418.HAA02861@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Include In directory slayer.i.sourceforge.net:/tmp/cvs-serv2798/Include Modified Files: object.h Log Message: Round 1 of Neil Schemenauer's GC patches: This patch adds the type methods traverse and clear necessary for GC implementation. Index: object.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/object.h,v retrieving revision 2.54 retrieving revision 2.55 diff -C2 -r2.54 -r2.55 *** object.h 2000/04/24 15:40:45 2.54 --- object.h 2000/06/23 14:18:10 2.55 *************** *** 146,149 **** --- 146,151 ---- typedef int (*getcharbufferproc) Py_PROTO((PyObject *, int, const char **)); typedef int (*objobjproc) Py_PROTO((PyObject *, PyObject *)); + typedef int (*visitproc) Py_PROTO((PyObject *, void *)); + typedef int (*traverseproc) Py_PROTO((PyObject *, visitproc, void *)); typedef struct { *************** *** 244,250 **** char *tp_doc; /* Documentation string */ /* More spares */ - long tp_xxx5; - long tp_xxx6; long tp_xxx7; long tp_xxx8; --- 246,256 ---- char *tp_doc; /* Documentation string */ + /* call function for all accessible objects */ + traverseproc tp_traverse; + + /* delete references to contained objects */ + inquiry tp_clear; + /* More spares */ long tp_xxx7; long tp_xxx8; From python-dev@python.org Fri Jun 23 15:36:35 2000 From: python-dev@python.org (Jeremy Hylton) Date: Fri, 23 Jun 2000 07:36:35 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects object.c,2.71,2.72 Message-ID: <200006231436.HAA04287@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv4239/Objects Modified Files: object.c Log Message: raise TypeError when PyObject_Get/SetAttr called with non-string name Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.71 retrieving revision 2.72 diff -C2 -r2.71 -r2.72 *** object.c 2000/06/09 16:20:39 2.71 --- object.c 2000/06/23 14:36:32 2.72 *************** *** 601,606 **** if (v->ob_type->tp_getattro != NULL) return (*v->ob_type->tp_getattro)(v, name); ! else ! return PyObject_GetAttrString(v, PyString_AsString(name)); } --- 601,611 ---- if (v->ob_type->tp_getattro != NULL) return (*v->ob_type->tp_getattro)(v, name); ! ! if (!PyString_Check(name)) { ! PyErr_SetString(PyExc_TypeError, ! "attribute name must be string"); ! return NULL; ! } ! return PyObject_GetAttrString(v, PyString_AS_STRING(name)); } *************** *** 627,636 **** int err; Py_INCREF(name); ! PyString_InternInPlace(&name); if (v->ob_type->tp_setattro != NULL) err = (*v->ob_type->tp_setattro)(v, name, value); ! else err = PyObject_SetAttrString( ! v, PyString_AsString(name), value); Py_DECREF(name); return err; --- 632,648 ---- int err; Py_INCREF(name); ! if (PyString_Check(name)) ! PyString_InternInPlace(&name); if (v->ob_type->tp_setattro != NULL) err = (*v->ob_type->tp_setattro)(v, name, value); ! else if (PyString_Check(name)) { err = PyObject_SetAttrString( ! v, PyString_AS_STRING(name), value); ! } ! else { ! PyErr_SetString(PyExc_TypeError, ! "attribute name must be string"); ! err = -1; ! } Py_DECREF(name); return err; From python-dev@python.org Fri Jun 23 18:14:59 2000 From: python-dev@python.org (Jeremy Hylton) Date: Fri, 23 Jun 2000 10:14:59 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects classobject.c,2.87,2.88 Message-ID: <200006231714.KAA31555@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv31543 Modified Files: classobject.c Log Message: traverse functions should return 0 on success Index: classobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v retrieving revision 2.87 retrieving revision 2.88 diff -C2 -r2.87 -r2.88 *** classobject.c 2000/06/23 14:18:11 2.87 --- classobject.c 2000/06/23 17:14:56 2.88 *************** *** 905,909 **** return err; } ! return 1; } --- 905,909 ---- return err; } ! return 0; } *************** *** 1742,1746 **** return err; } ! return 1; } --- 1742,1746 ---- return err; } ! return 0; } From python-dev@python.org Fri Jun 23 20:37:04 2000 From: python-dev@python.org (Jeremy Hylton) Date: Fri, 23 Jun 2000 12:37:04 -0700 Subject: [Python-checkins] CVS: python/dist/src/Include object.h,2.55,2.56 objimpl.h,2.15,2.16 Message-ID: <200006231937.MAA19761@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Include In directory slayer.i.sourceforge.net:/tmp/cvs-serv19626/Include Modified Files: object.h objimpl.h Log Message: part 2 of Neil Schemenauer's GC patches: This patch modifies the type structures of objects that participate in GC. The object's tp_basicsize is increased when GC is enabled. GC information is prefixed to the object to maintain binary compatibility. GC objects also define the tp_flag Py_TPFLAGS_GC. Index: object.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/object.h,v retrieving revision 2.55 retrieving revision 2.56 diff -C2 -r2.55 -r2.56 *** object.h 2000/06/23 14:18:10 2.55 --- object.h 2000/06/23 19:37:01 2.56 *************** *** 326,329 **** --- 326,336 ---- #define Py_TPFLAGS_HAVE_SEQUENCE_IN (1L<<1) + /* Objects which participate in garbage collection (see objimp.h) */ + #ifdef WITH_CYCLE_GC + #define Py_TPFLAGS_GC (1L<<2) + #else + #define Py_TPFLAGS_GC 0 + #endif + #define Py_TPFLAGS_DEFAULT (Py_TPFLAGS_HAVE_GETCHARBUFFER | \ Py_TPFLAGS_HAVE_SEQUENCE_IN) Index: objimpl.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/objimpl.h,v retrieving revision 2.15 retrieving revision 2.16 diff -C2 -r2.15 -r2.16 *** objimpl.h 2000/05/03 23:44:23 2.15 --- objimpl.h 2000/06/23 19:37:01 2.16 *************** *** 235,238 **** --- 235,244 ---- constructor you would start directly with PyObject_Init/InitVar. */ + + + #ifndef WITH_CYCLE_GC + #define PyGC_INFO_SIZE 0 + #endif + #ifdef __cplusplus } From python-dev@python.org Fri Jun 23 20:37:04 2000 From: python-dev@python.org (Jeremy Hylton) Date: Fri, 23 Jun 2000 12:37:04 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects classobject.c,2.88,2.89 dictobject.c,2.53,2.54 funcobject.c,2.21,2.22 listobject.c,2.74,2.75 tupleobject.c,2.37,2.38 Message-ID: <200006231937.MAA19769@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv19626/Objects Modified Files: classobject.c dictobject.c funcobject.c listobject.c tupleobject.c Log Message: part 2 of Neil Schemenauer's GC patches: This patch modifies the type structures of objects that participate in GC. The object's tp_basicsize is increased when GC is enabled. GC information is prefixed to the object to maintain binary compatibility. GC objects also define the tp_flag Py_TPFLAGS_GC. Index: classobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v retrieving revision 2.88 retrieving revision 2.89 diff -C2 -r2.88 -r2.89 *** classobject.c 2000/06/23 17:14:56 2.88 --- classobject.c 2000/06/23 19:37:01 2.89 *************** *** 429,433 **** 0, "class", ! sizeof(PyClassObject), 0, (destructor)class_dealloc, /*tp_dealloc*/ --- 429,433 ---- 0, "class", ! sizeof(PyClassObject) + PyGC_INFO_SIZE, 0, (destructor)class_dealloc, /*tp_dealloc*/ *************** *** 446,450 **** (setattrofunc)class_setattr, /*tp_setattro*/ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT, /*tp_flags*/ 0, /* tp_doc */ (traverseproc)class_traverse, /* tp_traverse */ --- 446,450 ---- (setattrofunc)class_setattr, /*tp_setattro*/ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC, /*tp_flags*/ 0, /* tp_doc */ (traverseproc)class_traverse, /* tp_traverse */ *************** *** 1514,1518 **** 0, "instance", ! sizeof(PyInstanceObject), 0, (destructor)instance_dealloc, /*tp_dealloc*/ --- 1514,1518 ---- 0, "instance", ! sizeof(PyInstanceObject) + PyGC_INFO_SIZE, 0, (destructor)instance_dealloc, /*tp_dealloc*/ *************** *** 1531,1535 **** (setattrofunc)instance_setattr, /*tp_setattro*/ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT, /*tp_flags*/ 0, /* tp_doc */ (traverseproc)instance_traverse, /* tp_traverse */ --- 1531,1535 ---- (setattrofunc)instance_setattr, /*tp_setattro*/ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC, /*tp_flags*/ 0, /* tp_doc */ (traverseproc)instance_traverse, /* tp_traverse */ *************** *** 1749,1753 **** 0, "instance method", ! sizeof(PyMethodObject), 0, (destructor)instancemethod_dealloc, /*tp_dealloc*/ --- 1749,1753 ---- 0, "instance method", ! sizeof(PyMethodObject) + PyGC_INFO_SIZE, 0, (destructor)instancemethod_dealloc, /*tp_dealloc*/ *************** *** 1766,1770 **** 0, /*tp_setattro*/ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT, /*tp_flags*/ 0, /* tp_doc */ (traverseproc)instancemethod_traverse, /* tp_traverse */ --- 1766,1770 ---- 0, /*tp_setattro*/ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC, /*tp_flags*/ 0, /* tp_doc */ (traverseproc)instancemethod_traverse, /* tp_traverse */ Index: dictobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/dictobject.c,v retrieving revision 2.53 retrieving revision 2.54 diff -C2 -r2.53 -r2.54 *** dictobject.c 2000/06/23 14:18:11 2.53 --- dictobject.c 2000/06/23 19:37:01 2.54 *************** *** 1088,1092 **** 0, "dictionary", ! sizeof(dictobject), 0, (destructor)dict_dealloc, /*tp_dealloc*/ --- 1088,1092 ---- 0, "dictionary", ! sizeof(dictobject) + PyGC_INFO_SIZE, 0, (destructor)dict_dealloc, /*tp_dealloc*/ *************** *** 1105,1109 **** 0, /* tp_setattro */ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT, /*tp_flags*/ 0, /* tp_doc */ (traverseproc)dict_traverse, /* tp_traverse */ --- 1105,1109 ---- 0, /* tp_setattro */ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC, /*tp_flags*/ 0, /* tp_doc */ (traverseproc)dict_traverse, /* tp_traverse */ Index: funcobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/funcobject.c,v retrieving revision 2.21 retrieving revision 2.22 diff -C2 -r2.21 -r2.22 *** funcobject.c 2000/06/23 14:18:11 2.21 --- funcobject.c 2000/06/23 19:37:01 2.22 *************** *** 276,280 **** 0, "function", ! sizeof(PyFunctionObject), 0, (destructor)func_dealloc, /*tp_dealloc*/ --- 276,280 ---- 0, "function", ! sizeof(PyFunctionObject) + PyGC_INFO_SIZE, 0, (destructor)func_dealloc, /*tp_dealloc*/ *************** *** 293,297 **** 0, /*tp_setattro*/ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT, /*tp_flags*/ 0, /* tp_doc */ (traverseproc)func_traverse, /* tp_traverse */ --- 293,297 ---- 0, /*tp_setattro*/ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC, /*tp_flags*/ 0, /* tp_doc */ (traverseproc)func_traverse, /* tp_traverse */ Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.74 retrieving revision 2.75 diff -C2 -r2.74 -r2.75 *** listobject.c 2000/06/23 14:18:11 2.74 --- listobject.c 2000/06/23 19:37:01 2.75 *************** *** 72,76 **** } /* PyObject_NewVar is inlined */ ! op = (PyListObject *) PyObject_MALLOC(sizeof(PyListObject)); if (op == NULL) { return PyErr_NoMemory(); --- 72,77 ---- } /* PyObject_NewVar is inlined */ ! op = (PyListObject *) PyObject_MALLOC(sizeof(PyListObject) ! + PyGC_INFO_SIZE); if (op == NULL) { return PyErr_NoMemory(); *************** *** 1498,1502 **** 0, "list", ! sizeof(PyListObject), 0, (destructor)list_dealloc, /*tp_dealloc*/ --- 1499,1503 ---- 0, "list", ! sizeof(PyListObject) + PyGC_INFO_SIZE, 0, (destructor)list_dealloc, /*tp_dealloc*/ *************** *** 1515,1519 **** 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ ! Py_TPFLAGS_DEFAULT, /*tp_flags*/ 0, /* tp_doc */ (traverseproc)list_traverse, /* tp_traverse */ --- 1516,1520 ---- 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC, /*tp_flags*/ 0, /* tp_doc */ (traverseproc)list_traverse, /* tp_traverse */ *************** *** 1577,1581 **** 0, "list (immutable, during sort)", ! sizeof(PyListObject), 0, 0, /*tp_dealloc*/ /* Cannot happen */ --- 1578,1582 ---- 0, "list (immutable, during sort)", ! sizeof(PyListObject) + PyGC_INFO_SIZE, 0, 0, /*tp_dealloc*/ /* Cannot happen */ *************** *** 1594,1598 **** 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ ! Py_TPFLAGS_DEFAULT, /*tp_flags*/ 0, /* tp_doc */ (traverseproc)list_traverse, /* tp_traverse */ --- 1595,1599 ---- 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC, /*tp_flags*/ 0, /* tp_doc */ (traverseproc)list_traverse, /* tp_traverse */ Index: tupleobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/tupleobject.c,v retrieving revision 2.37 retrieving revision 2.38 diff -C2 -r2.37 -r2.38 *** tupleobject.c 2000/06/23 14:18:11 2.37 --- tupleobject.c 2000/06/23 19:37:02 2.38 *************** *** 94,98 **** /* Check for overflow */ if (nbytes / sizeof(PyObject *) != (size_t)size || ! (nbytes += sizeof(PyTupleObject) - sizeof(PyObject *)) <= 0) { --- 94,99 ---- /* Check for overflow */ if (nbytes / sizeof(PyObject *) != (size_t)size || ! (nbytes += sizeof(PyTupleObject) - sizeof(PyObject *) ! + PyGC_INFO_SIZE) <= 0) { *************** *** 453,457 **** 0, "tuple", ! sizeof(PyTupleObject) - sizeof(PyObject *), sizeof(PyObject *), (destructor)tupledealloc, /*tp_dealloc*/ --- 454,458 ---- 0, "tuple", ! sizeof(PyTupleObject) - sizeof(PyObject *) + PyGC_INFO_SIZE, sizeof(PyObject *), (destructor)tupledealloc, /*tp_dealloc*/ *************** *** 470,474 **** 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ ! Py_TPFLAGS_DEFAULT, /*tp_flags*/ 0, /*tp_doc*/ (traverseproc)tupletraverse, /* tp_traverse */ --- 471,475 ---- 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_GC, /*tp_flags*/ 0, /*tp_doc*/ (traverseproc)tupletraverse, /* tp_traverse */ *************** *** 558,563 **** { sv = (PyTupleObject *) ! PyObject_REALLOC((char *)v, ! sizeof(PyTupleObject) + newsize * sizeof(PyObject *)); *pv = (PyObject *) sv; if (sv == NULL) { --- 559,565 ---- { sv = (PyTupleObject *) ! PyObject_REALLOC((char *)v, sizeof(PyTupleObject) ! + PyGC_INFO_SIZE ! + newsize * sizeof(PyObject *)); *pv = (PyObject *) sv; if (sv == NULL) { From python-dev@python.org Fri Jun 23 21:24:28 2000 From: python-dev@python.org (Barry Warsaw) Date: Fri, 23 Jun 2000 13:24:28 -0700 Subject: [Python-checkins] CVS: python/dist/src/Misc python-mode.el,3.106,3.107 Message-ID: <200006232024.NAA28420@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Misc In directory slayer.i.sourceforge.net:/tmp/cvs-serv28410 Modified Files: python-mode.el Log Message: (py-execute-region): Make sure the new temporary buffer is current for the insertion of the text. Index: python-mode.el =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/python-mode.el,v retrieving revision 3.106 retrieving revision 3.107 diff -C2 -r3.106 -r3.107 *** python-mode.el 2000/05/23 05:47:43 3.106 --- python-mode.el 2000/06/23 20:24:25 3.107 *************** *** 1285,1292 **** (save-excursion (goto-char start) ! (when (/= (py-point 'bol) (py-point 'boi)) (set-buffer buf) ! (insert "if 1:\n")) ! (insert-buffer-substring cur start end)) (cond ;; always run the code in its own asynchronous subprocess --- 1285,1293 ---- (save-excursion (goto-char start) ! (let ((needs-if (/= (py-point 'bol) (py-point 'boi)))) (set-buffer buf) ! (when needs-if ! (insert "if 1:\n")) ! (insert-buffer-substring cur start end))) (cond ;; always run the code in its own asynchronous subprocess From python-dev@python.org Sat Jun 24 01:18:26 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 23 Jun 2000 17:18:26 -0700 Subject: [Python-checkins] CVS: distutils/distutils extension.py,1.1,1.2 Message-ID: <200006240018.RAA00586@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv577 Modified Files: extension.py Log Message: Revised docstring so 'sources' isn't necessarily all C/C++ files (to accomodate SWIG interface files, resource files, etc.). Index: extension.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/extension.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** extension.py 2000/05/31 01:05:35 1.1 --- extension.py 2000/06/24 00:18:24 1.2 *************** *** 32,38 **** *not* a filename or pathname, but Python dotted name sources : [string] ! list of C/C++ source filenames, relative to the distribution ! root (where the setup script lives), in Unix form ! (slash-separated) for portability include_dirs : [string] list of directories to search for C/C++ header files (in Unix --- 32,40 ---- *not* a filename or pathname, but Python dotted name sources : [string] ! list of source filenames, relative to the distribution root ! (where the setup script lives), in Unix form (slash-separated) ! for portability. Source files may be C, C++, SWIG (.i), ! platform-specific resource files, or whatever else is recognized ! by the "build_ext" command as source for a Python extension. include_dirs : [string] list of directories to search for C/C++ header files (in Unix From python-dev@python.org Sat Jun 24 01:19:37 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 23 Jun 2000 17:19:37 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command build_ext.py,1.43,1.44 Message-ID: <200006240019.RAA00740@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv729 Modified Files: build_ext.py Log Message: Experimental, completely untested SWIG support. Index: build_ext.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build_ext.py,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -r1.43 -r1.44 *** build_ext.py 2000/06/17 23:04:31 1.43 --- build_ext.py 2000/06/24 00:19:35 1.44 *************** *** 368,377 **** self.announce ("building '%s' extension" % ext.name) ! # First step: compile the source code to object files. This ! # drops the object files in the current directory, regardless ! # of where the source is (may be a bad thing, but that's how a ! # Makefile.pre.in-based system does it, so at least there's a ! # precedent!) # XXX not honouring 'define_macros' or 'undef_macros' -- the # CCompiler API needs to change to accomodate this, and I --- 368,378 ---- self.announce ("building '%s' extension" % ext.name) ! # First, scan the sources for SWIG definition files (.i), run ! # SWIG on 'em to create .c files, and modify the sources list ! # accordingly. ! sources = self.swig_sources(sources) + # Next, compile the source code to object files. + # XXX not honouring 'define_macros' or 'undef_macros' -- the # CCompiler API needs to change to accomodate this, and I *************** *** 429,432 **** --- 430,501 ---- # build_extensions () + + def swig_sources (self, sources): + + """Walk the list of source files in 'sources', looking for SWIG + interface (.i) files. Run SWIG on all that are found, and + return a modified 'sources' list with SWIG source files replaced + by the generated C (or C++) files. + """ + + new_sources = [] + swig_sources = [] + swig_targets = {} + + # XXX this drops generated C files into the source tree, which + # is fine for developers who want to distribute the generated + # source -- but there should be an option to put SWIG output in + # the temp dir. + + for source in sources: + (base, ext) = os.path.splitext(source) + if ext in self.swig_ext(): + new_sources.append(base + ".c") # umm, what if it's C++? + swig_files.append(source) + swig_targets[source] = new_sources[-1] + else: + new_sources.append(source) + + if not swig_files: + return new_sources + + swig = self.find_swig() + swig_cmd = [swig, "-python", "-dnone", "-ISWIG"] # again, C++?!? + + for source in swig_sources: + self.announce ("swigging %s to %s" % (src, obj)) + self.spawn(swig_cmd + ["-o", swig_targets[source], source]) + + return new_sources + + # swig_sources () + + def find_swig (self): + """Return the name of the SWIG executable. On Unix, this is + just "swig" -- it should be in the PATH. Tries a bit harder on + Windows. + """ + + if os.name == "posix": + return "swig" + elif os.name == "nt": + + # Look for SWIG in its standard installation directory on + # Windows (or so I presume!). If we find it there, great; + # if not, act like Unix and assume it's in the PATH. + for vers in ("1.3", "1.2", "1.1"): + fn = os.path.join("c:\\swig%s" % vers, "swig.exe") + if os.path.isfile (fn): + return fn + else: + return "swig.exe" + + else: + raise DistutilsPlatformError, \ + ("I don't know how to find (much less run) SWIG " + "on platform '%s'") % os.name + + # find_swig () + # -- Hooks --------------------------------------------------------- From python-dev@python.org Sat Jun 24 01:23:22 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 23 Jun 2000 17:23:22 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist.py,1.11,1.12 build.py,1.23,1.24 build_clib.py,1.16,1.17 sdist.py,1.33,1.34 Message-ID: <200006240023.RAA00912@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv877/command Modified Files: bdist.py build.py build_clib.py sdist.py Log Message: Stylistic/formatting changes to Rene Liebscher's '--help-xxx' patch. Index: bdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** bdist.py 2000/06/07 03:00:06 1.11 --- bdist.py 2000/06/24 00:23:20 1.12 *************** *** 22,26 **** "temporary directory for creating built distributions"), ('formats=', None, ! "formats for distribution"), ] --- 22,26 ---- "temporary directory for creating built distributions"), ('formats=', None, ! "formats for distribution (comma-separated list)"), ] *************** *** 33,52 **** 'nt': 'zip', } ! format_command = { 'gztar': ('bdist_dumb',"gzipped tar-file"), ! 'bztar': ('bdist_dumb',"bzip2-ed tar-file"), ! 'ztar': ('bdist_dumb',"compressed tar-file"), ! 'tar': ('bdist_dumb',"tar-file"), ! 'rpm': ('bdist_rpm',"rpm distribution"), ! 'zip': ('bdist_dumb',"zip-file"), } ! # prints all possible arguments to --format ! def show_formats(): from distutils.fancy_getopt import FancyGetopt ! list_of_formats=[] for format in bdist.format_command.keys(): ! list_of_formats.append(("formats="+format,None,bdist.format_command[format][1])) ! list_of_formats.sort() ! pretty_printer=FancyGetopt(list_of_formats) pretty_printer.print_help("List of available distribution formats:") --- 33,54 ---- 'nt': 'zip', } ! format_command = { 'rpm': ('bdist_rpm', "RPM distribution"), ! 'gztar': ('bdist_dumb', "gzip'ed tar file"), ! 'bztar': ('bdist_dumb', "bzip2'ed tar file"), ! 'ztar': ('bdist_dumb', "compressed tar file"), ! 'tar': ('bdist_dumb', "tar file"), ! 'zip': ('bdist_dumb', "ZIP file"), } ! def show_formats (): ! """Print list of available formats (arguments to "--format" option). ! """ from distutils.fancy_getopt import FancyGetopt ! formats=[] for format in bdist.format_command.keys(): ! formats.append(("formats="+format, None, ! bdist.format_command[format][1])) ! formats.sort() ! pretty_printer = FancyGetopt(formats) pretty_printer.print_help("List of available distribution formats:") *************** *** 88,92 **** for format in self.formats: - try: cmd_name = self.format_command[format][0] --- 90,93 ---- Index: build.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -r1.23 -r1.24 *** build.py 2000/06/07 03:00:06 1.23 --- build.py 2000/06/24 00:23:20 1.24 *************** *** 37,43 **** "forcibly build everything (ignore file timestamps)"), ] help_options = [ ('help-compiler', None, ! "lists available compilers",show_compilers), ] --- 37,44 ---- "forcibly build everything (ignore file timestamps)"), ] + help_options = [ ('help-compiler', None, ! "list available compilers", show_compilers), ] Index: build_clib.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build_clib.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** build_clib.py 2000/06/07 03:00:06 1.16 --- build_clib.py 2000/06/24 00:23:20 1.17 *************** *** 43,49 **** "specify the compiler type"), ] help_options = [ ('help-compiler', None, ! "lists available compilers",show_compilers), ] --- 43,50 ---- "specify the compiler type"), ] + help_options = [ ('help-compiler', None, ! "list available compilers", show_compilers), ] Index: sdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/sdist.py,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -r1.33 -r1.34 *** sdist.py 2000/06/21 03:29:57 1.33 --- sdist.py 2000/06/24 00:23:20 1.34 *************** *** 37,41 **** "forcibly regenerate the manifest and carry on as usual"), ('formats=', None, ! "formats for source distribution"), ('keep-tree', 'k', "keep the distribution tree around after creating " + --- 37,41 ---- "forcibly regenerate the manifest and carry on as usual"), ('formats=', None, ! "formats for source distribution (comma-separated list)"), ('keep-tree', 'k', "keep the distribution tree around after creating " + *************** *** 62,66 **** help_options = [ ('help-formats', None, ! "lists available distribution formats", show_formats), ] --- 62,66 ---- help_options = [ ('help-formats', None, ! "list available distribution formats", show_formats), ] From python-dev@python.org Sat Jun 24 01:23:22 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 23 Jun 2000 17:23:22 -0700 Subject: [Python-checkins] CVS: distutils/distutils archive_util.py,1.6,1.7 ccompiler.py,1.23,1.24 dist.py,1.28,1.29 Message-ID: <200006240023.RAA00905@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv877 Modified Files: archive_util.py ccompiler.py dist.py Log Message: Stylistic/formatting changes to Rene Liebscher's '--help-xxx' patch. Index: archive_util.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/archive_util.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** archive_util.py 2000/06/07 03:00:05 1.6 --- archive_util.py 2000/06/24 00:23:20 1.7 *************** *** 111,118 **** ARCHIVE_FORMATS = { ! 'gztar': (make_tarball, [('compress', 'gzip')],"gzipped tar-file"), ! 'bztar': (make_tarball, [('compress', 'bzip2')],"bzip2-ed tar-file"), ! 'ztar': (make_tarball, [('compress', 'compress')],"compressed tar-file"), ! 'tar': (make_tarball, [('compress', None)],"uncompressed tar-file"), 'zip': (make_zipfile, [],"zip-file") } --- 111,118 ---- ARCHIVE_FORMATS = { ! 'gztar': (make_tarball, [('compress', 'gzip')], "gzip'ed tar-file"), ! 'bztar': (make_tarball, [('compress', 'bzip2')], "bzip2'ed tar-file"), ! 'ztar': (make_tarball, [('compress', 'compress')], "compressed tar file"), ! 'tar': (make_tarball, [('compress', None)], "uncompressed tar file"), 'zip': (make_zipfile, [],"zip-file") } Index: ccompiler.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/ccompiler.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -r1.23 -r1.24 *** ccompiler.py 2000/06/21 02:58:46 1.23 --- ccompiler.py 2000/06/24 00:23:20 1.24 *************** *** 743,760 **** # find the code that implements an interface to this compiler. (The module # is assumed to be in the 'distutils' package.) ! compiler_class = { 'unix': ('unixccompiler', 'UnixCCompiler',"standard UNIX-style compiler"), ! 'msvc': ('msvccompiler', 'MSVCCompiler',"Microsoft Visual C++"), ! 'cygwin': ('cygwinccompiler', 'CygwinCCompiler',"Cygwin-Gnu-Win32-C-Compiler"), ! 'mingw32': ('cygwinccompiler', 'Mingw32CCompiler',"MinGW32-C-Compiler (or cygwin in this mode)"), } - # prints all possible arguments to --compiler def show_compilers(): from distutils.fancy_getopt import FancyGetopt ! list_of_compilers=[] for compiler in compiler_class.keys(): ! list_of_compilers.append(("compiler="+compiler,None,compiler_class[compiler][2])) ! list_of_compilers.sort() ! pretty_printer=FancyGetopt(list_of_compilers) pretty_printer.print_help("List of available compilers:") --- 743,770 ---- # find the code that implements an interface to this compiler. (The module # is assumed to be in the 'distutils' package.) ! compiler_class = { 'unix': ('unixccompiler', 'UnixCCompiler', ! "standard UNIX-style compiler"), ! 'msvc': ('msvccompiler', 'MSVCCompiler', ! "Microsoft Visual C++"), ! 'cygwin': ('cygwinccompiler', 'CygwinCCompiler', ! "Cygwin port of GNU C Compiler for Win32"), ! 'mingw32': ('cygwinccompiler', 'Mingw32CCompiler', ! "Mingw32 port of GNU C Compiler for Win32"), } def show_compilers(): + """Print list of available compilers (used by the "--help-compiler" + options to "build", "build_ext", "build_clib"). + """ + # XXX this "knows" that the compiler option it's describing is + # "--compiler", which just happens to be the case for the three + # commands that use it. from distutils.fancy_getopt import FancyGetopt ! compilers = [] for compiler in compiler_class.keys(): ! compilers.append(("compiler="+compiler, None, ! compiler_class[compiler][2])) ! compilers.sort() ! pretty_printer = FancyGetopt(compilers) pretty_printer.print_help("List of available compilers:") *************** *** 784,788 **** compiler = default_compiler[plat] ! (module_name, class_name,long_description) = compiler_class[compiler] except KeyError: msg = "don't know how to compile C/C++ code on platform '%s'" % plat --- 794,798 ---- compiler = default_compiler[plat] ! (module_name, class_name, long_description) = compiler_class[compiler] except KeyError: msg = "don't know how to compile C/C++ code on platform '%s'" % plat Index: dist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/dist.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -r1.28 -r1.29 *** dist.py 2000/06/07 03:00:05 1.28 --- dist.py 2000/06/24 00:23:20 1.29 *************** *** 438,446 **** negative_opt.update (cmd_class.negative_opt) ! # Check for help_options in command class ! # They have a different format (tuple of four) so we need to preprocess them here ! help_options = [] ! if hasattr(cmd_class,"help_options") and type (cmd_class.help_options) is ListType: ! help_options = map(lambda x:(x[0],x[1],x[2]),cmd_class.help_options) # All commands support the global options too, just by adding --- 438,449 ---- negative_opt.update (cmd_class.negative_opt) ! # Check for help_options in command class. They have a different ! # format (tuple of four) so we need to preprocess them here. ! if (hasattr(cmd_class, 'help_options') and ! type (cmd_class.help_options) is ListType): ! help_options = fix_help_options(cmd_class.help_options) ! else: ! help_optiosn = [] ! # All commands support the global options too, just by adding *************** *** 454,463 **** return ! if hasattr(cmd_class,"help_options") and type (cmd_class.help_options) is ListType: help_option_found=0 for help_option in cmd_class.help_options: if hasattr(opts, parser.get_attr_name(help_option[0])): help_option_found=1 ! #print "showing help for option %s of command %s" % (help_option[0],cmd_class) if callable(help_option[3]): help_option[3]() --- 457,468 ---- return ! if (hasattr(cmd_class, 'help_options') and ! type (cmd_class.help_options) is ListType): help_option_found=0 for help_option in cmd_class.help_options: if hasattr(opts, parser.get_attr_name(help_option[0])): help_option_found=1 ! #print "showing help for option %s of command %s" % \ ! # (help_option[0],cmd_class) if callable(help_option[3]): help_option[3]() *************** *** 519,525 **** else: klass = self.get_command_class (command) ! if hasattr(klass,"help_options") and type (klass.help_options) is ListType: ! parser.set_option_table (klass.user_options+ ! map(lambda x:(x[0],x[1],x[2]),klass.help_options)) else: parser.set_option_table (klass.user_options) --- 524,531 ---- else: klass = self.get_command_class (command) ! if (hasattr(klass, 'help_options') and ! type (klass.help_options) is ListType): ! parser.set_option_table (klass.user_options + ! fix_help_options(klass.help_options)) else: parser.set_option_table (klass.user_options) *************** *** 890,893 **** --- 896,910 ---- # class DistributionMetadata + + + def fix_help_options (options): + """Convert a 4-tuple 'help_options' list as found in various command + classes to the 3-tuple form required by FancyGetopt. + """ + new_options = [] + for help_tuple in options: + new_options.append(help_tuple[0:3]) + return new_options + if __name__ == "__main__": From python-dev@python.org Sat Jun 24 02:22:43 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 23 Jun 2000 18:22:43 -0700 Subject: [Python-checkins] CVS: distutils/distutils dist.py,1.29,1.30 Message-ID: <200006240122.SAA09839@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv9823 Modified Files: dist.py Log Message: More stylistic tweaks to the generic '--help-xxx' code. Index: dist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/dist.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -r1.29 -r1.30 *** dist.py 2000/06/24 00:23:20 1.29 --- dist.py 2000/06/24 01:22:41 1.30 *************** *** 444,448 **** help_options = fix_help_options(cmd_class.help_options) else: ! help_optiosn = [] --- 444,448 ---- help_options = fix_help_options(cmd_class.help_options) else: ! help_options = [] *************** *** 450,454 **** # in 'global_options'. parser.set_option_table (self.global_options + ! cmd_class.user_options + help_options) parser.set_negative_aliases (negative_opt) (args, opts) = parser.getopt (args[1:]) --- 450,455 ---- # in 'global_options'. parser.set_option_table (self.global_options + ! cmd_class.user_options + ! help_options) parser.set_negative_aliases (negative_opt) (args, opts) = parser.getopt (args[1:]) *************** *** 460,476 **** type (cmd_class.help_options) is ListType): help_option_found=0 ! for help_option in cmd_class.help_options: ! if hasattr(opts, parser.get_attr_name(help_option[0])): help_option_found=1 #print "showing help for option %s of command %s" % \ # (help_option[0],cmd_class) ! if callable(help_option[3]): ! help_option[3]() ! else: ! raise DistutilsClassError, \ ! ("command class %s must provide " + ! "a callable object for help_option '%s'") % \ ! (cmd_class,help_option[0]) ! if help_option_found: return --- 461,479 ---- type (cmd_class.help_options) is ListType): help_option_found=0 ! for (help_option, short, desc, func) in cmd_class.help_options: ! if hasattr(opts, parser.get_attr_name(help_option)): help_option_found=1 #print "showing help for option %s of command %s" % \ # (help_option[0],cmd_class) ! ! if callable(func): ! func() ! else: ! raise DistutilsClassError, \ ! ("invalid help function %s for help option '%s': " ! "must be a callable object (function, etc.)") % \ ! (`func`, help_option) ! ! if help_option_found: return From python-dev@python.org Sat Jun 24 02:23:40 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 23 Jun 2000 18:23:40 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist.py,1.12,1.13 build.py,1.24,1.25 build_clib.py,1.17,1.18 build_ext.py,1.44,1.45 sdist.py,1.34,1.35 Message-ID: <200006240123.SAA09865@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv9830 Modified Files: bdist.py build.py build_clib.py build_ext.py sdist.py Log Message: Changed so all the help-generating functions are defined, at module-level, in the module of the command classes that have command-specific help options. This lets us keep the principle of lazily importing the ccompiler module, and also gets away from defining non-methods at class level. Index: bdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** bdist.py 2000/06/24 00:23:20 1.12 --- bdist.py 2000/06/24 01:23:37 1.13 *************** *** 15,18 **** --- 15,30 ---- + def show_formats (): + """Print list of available formats (arguments to "--format" option). + """ + from distutils.fancy_getopt import FancyGetopt + formats=[] + for format in bdist.format_commands: + formats.append(("formats=" + format, None, + bdist.format_command[format][1])) + pretty_printer = FancyGetopt(formats) + pretty_printer.print_help("List of available distribution formats:") + + class bdist (Command): *************** *** 25,28 **** --- 37,45 ---- ] + help_options = [ + ('help-formats', None, + "lists available distribution formats", show_formats), + ] + # The following commands do not take a format option from bdist no_format_option = ('bdist_rpm',) *************** *** 39,60 **** 'tar': ('bdist_dumb', "tar file"), 'zip': ('bdist_dumb', "ZIP file"), ! } ! ! def show_formats (): ! """Print list of available formats (arguments to "--format" option). ! """ ! from distutils.fancy_getopt import FancyGetopt ! formats=[] ! for format in bdist.format_command.keys(): ! formats.append(("formats="+format, None, ! bdist.format_command[format][1])) ! formats.sort() ! pretty_printer = FancyGetopt(formats) ! pretty_printer.print_help("List of available distribution formats:") ! ! help_options = [ ! ('help-formats', None, ! "lists available distribution formats",show_formats), ! ] --- 56,62 ---- 'tar': ('bdist_dumb', "tar file"), 'zip': ('bdist_dumb', "ZIP file"), ! } ! # establish the preferred order ! format_commands = ['rpm', 'gztar', 'bztar', 'ztar', 'tar', 'zip'] Index: build.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -r1.24 -r1.25 *** build.py 2000/06/24 00:23:20 1.24 --- build.py 2000/06/24 01:23:37 1.25 *************** *** 10,14 **** from distutils.core import Command from distutils.util import get_platform ! from distutils.ccompiler import show_compilers class build (Command): --- 10,19 ---- from distutils.core import Command from distutils.util import get_platform ! ! ! def show_compilers (): ! from distutils.ccompiler import show_compilers ! show_compilers() ! class build (Command): Index: build_clib.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build_clib.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** build_clib.py 2000/06/24 00:23:20 1.17 --- build_clib.py 2000/06/24 01:23:37 1.18 *************** *** 24,30 **** from distutils.core import Command from distutils.errors import * - from distutils.ccompiler import new_compiler,show_compilers class build_clib (Command): --- 24,34 ---- from distutils.core import Command from distutils.errors import * + def show_compilers (): + from distutils.ccompiler import show_compilers + show_compilers() + + class build_clib (Command): *************** *** 103,106 **** --- 107,111 ---- # Yech -- this is cut 'n pasted from build_ext.py! + from distutils.ccompiler import new_compiler self.compiler = new_compiler (compiler=self.compiler, verbose=self.verbose, Index: build_ext.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build_ext.py,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -r1.44 -r1.45 *** build_ext.py 2000/06/24 00:19:35 1.44 --- build_ext.py 2000/06/24 01:23:37 1.45 *************** *** 15,19 **** from distutils.dep_util import newer_group from distutils.extension import Extension - from distutils.ccompiler import show_compilers # An extension name is just a dot-separated list of Python NAMEs (ie. --- 15,18 ---- *************** *** 23,26 **** --- 22,30 ---- + def show_compilers (): + from distutils.ccompiler import show_compilers + show_compilers() + + class build_ext (Command): *************** *** 74,82 **** "specify the compiler type"), ] help_options = [ ('help-compiler', None, ! "lists available compilers",show_compilers), ] - def initialize_options (self): --- 78,86 ---- "specify the compiler type"), ] + help_options = [ ('help-compiler', None, ! "list available compilers", show_compilers), ] def initialize_options (self): Index: sdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/sdist.py,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -r1.34 -r1.35 *** sdist.py 2000/06/24 00:23:20 1.34 --- sdist.py 2000/06/24 01:23:37 1.35 *************** *** 14,22 **** from distutils.util import \ convert_path, create_tree, remove_tree, newer, write_file, \ ! check_archive_formats, ARCHIVE_FORMATS from distutils.text_file import TextFile from distutils.errors import DistutilsExecError, DistutilsOptionError class sdist (Command): --- 14,38 ---- from distutils.util import \ convert_path, create_tree, remove_tree, newer, write_file, \ ! check_archive_formats from distutils.text_file import TextFile from distutils.errors import DistutilsExecError, DistutilsOptionError + def show_formats (): + """Print all possible values for the 'formats' option (used by + the "--help-formats" command-line option). + """ + from distutils.fancy_getopt import FancyGetopt + from distutils.archive_util import ARCHIVE_FORMATS + formats=[] + for format in ARCHIVE_FORMATS.keys(): + formats.append(("formats=" + format, None, + ARCHIVE_FORMATS[format][2])) + formats.sort() + pretty_printer = FancyGetopt(formats) + pretty_printer.print_help( + "List of available source distribution formats:") + + class sdist (Command): *************** *** 44,63 **** - # XXX ugh: this has to precede the 'help_options' list, because - # it is mentioned there -- also, this is not a method, even though - # it's defined in a class: double-ugh! - def show_formats (): - """Print all possible values for the 'formats' option -- used by - the "--help-formats" command-line option. - """ - from distutils.fancy_getopt import FancyGetopt - formats=[] - for format in ARCHIVE_FORMATS.keys(): - formats.append(("formats="+format,None,ARCHIVE_FORMATS[format][2])) - formats.sort() - pretty_printer = FancyGetopt(formats) - pretty_printer.print_help( - "List of available source distribution formats:") - help_options = [ ('help-formats', None, --- 60,63 ---- *************** *** 69,73 **** default_format = { 'posix': 'gztar', 'nt': 'zip' } - def initialize_options (self): --- 69,72 ---- From python-dev@python.org Sat Jun 24 02:27:28 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 23 Jun 2000 18:27:28 -0700 Subject: [Python-checkins] CVS: distutils TODO,1.3,1.4 Message-ID: <200006240127.SAA09999@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv9988 Modified Files: TODO Log Message: Couple o' small changes. Index: TODO =================================================================== RCS file: /cvsroot/python/distutils/TODO,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** TODO 2000/06/07 03:11:17 1.3 --- TODO 2000/06/24 01:27:26 1.4 *************** *** 42,48 **** --- 42,51 ---- other people to try it out and I don't have time to review it right now (and he fixed a stupid bug in bdist.py for me) + [done 2000/06/23 GPW] + * review Rene Liebscher's cygwinccompiler.py contribution + COMMAND-LINE PARSING -------------------- *************** *** 107,110 **** --- 110,118 ---- * support for PyFort (lower priority than SWIG!) + + * OSF/1 problem: ld command has "*" in it, which is appropriate when + a shell is involved, but there isn't one here, so we need to + strip the quotes (and, ideally, put them back on again when + spawn() prints out the command run!) From python-dev@python.org Sat Jun 24 02:33:18 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 23 Jun 2000 18:33:18 -0700 Subject: [Python-checkins] CVS: distutils/doc/inst inst.tex,1.14,1.15 Message-ID: <200006240133.SAA10280@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/doc/inst In directory slayer.i.sourceforge.net:/tmp/cvs-serv10257/inst Modified Files: inst.tex Log Message: Fixed a grab-bag of typos spotted by Detlef Lannert. Index: inst.tex =================================================================== RCS file: /cvsroot/python/distutils/doc/inst/inst.tex,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** inst.tex 2000/05/30 03:00:43 1.14 --- inst.tex 2000/06/24 01:33:16 1.15 *************** *** 98,104 **** If you download a module source distribution, you can tell pretty ! quickly if was packaged and distributed in the standard way, i.e. using ! the Distutils. First, the distribution's name and version number will ! be featured prominently in the name of the downloaded archive, e.g. \file{foo-1.0.tar.gz} or \file{widget-0.9.7.zip}. Next, the archive will unpack into a similarly-named directory: \file{foo-1.0} or --- 98,104 ---- If you download a module source distribution, you can tell pretty ! quickly if it was packaged and distributed in the standard way, i.e. ! using the Distutils. First, the distribution's name and version number ! will be featured prominently in the name of the downloaded archive, e.g. \file{foo-1.0.tar.gz} or \file{widget-0.9.7.zip}. Next, the archive will unpack into a similarly-named directory: \file{foo-1.0} or *************** *** 127,131 **** be made is, ``Read the module's own installation instructions.'' ! However, if such instructions exists at all, they are often woefully inadequate and targeted at experienced Python developers. Such users are already familiar with how the Python library is laid out on their --- 127,131 ---- be made is, ``Read the module's own installation instructions.'' ! However, if such instructions exist at all, they are often woefully inadequate and targeted at experienced Python developers. Such users are already familiar with how the Python library is laid out on their *************** *** 422,426 **** known cases where the prefix scheme will be useful. ! First, consider that many Linux distribution put Python in \file{/usr}, rather than the more traditional \file{/usr/local}. This is entirely appropriate, since in those cases Python is part of ``the system'' --- 422,426 ---- known cases where the prefix scheme will be useful. ! First, consider that many Linux distributions put Python in \file{/usr}, rather than the more traditional \file{/usr/local}. This is entirely appropriate, since in those cases Python is part of ``the system'' *************** *** 559,563 **** the installation base directory (your home directory, in this case): \begin{verbatim} ! python setup.py install --home --install-scripts=scripts \end{verbatim} --- 559,563 ---- the installation base directory (your home directory, in this case): \begin{verbatim} ! python setup.py install --home=~ --install-scripts=scripts \end{verbatim} *************** *** 607,611 **** python setup.py install --home=~/python \ --install-purelib=lib \ ! --install-platlib=lib.$PLAT \ --install-scripts=scripts --install-data=data --- 607,611 ---- python setup.py install --home=~/python \ --install-purelib=lib \ ! --install-platlib='lib.$PLAT' \ --install-scripts=scripts --install-data=data From python-dev@python.org Sat Jun 24 02:33:18 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 23 Jun 2000 18:33:18 -0700 Subject: [Python-checkins] CVS: distutils/doc/dist dist.tex,1.14,1.15 Message-ID: <200006240133.SAA10274@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/doc/dist In directory slayer.i.sourceforge.net:/tmp/cvs-serv10257/dist Modified Files: dist.tex Log Message: Fixed a grab-bag of typos spotted by Detlef Lannert. Index: dist.tex =================================================================== RCS file: /cvsroot/python/distutils/doc/dist/dist.tex,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** dist.tex 2000/05/26 02:24:28 1.14 --- dist.tex 2000/06/24 01:33:14 1.15 *************** *** 56,66 **** it's not always feasible to expect them to create a multitude of built distributions. It is hoped that a class of intermediaries, called ! \emph{packagers}, will arise to take address this need. Packagers will ! take source distributions released by module developers, build them on ! one or more platforms, and release the resulting built distributions. ! Thus, users on the most popular platforms will be able to install most ! popular Python module distributions in the most natural way for their ! platform, without having to run a single setup script or compile a line ! of code. --- 56,65 ---- it's not always feasible to expect them to create a multitude of built distributions. It is hoped that a class of intermediaries, called ! \emph{packagers}, will arise to address this need. Packagers will take ! source distributions released by module developers, build them on one or ! more platforms, and release the resulting built distributions. Thus, ! users on the most popular platforms will be able to install most popular ! Python module distributions in the most natural way for their platform, ! without having to run a single setup script or compile a line of code. *************** *** 374,379 **** python setup.py sdist \end{verbatim} ! (assuming you haven't specified any \command{sdist} options in the setup ! script or config file), \command{sdist} creates the the archive of the default format for the current platform. The default formats are: \begin{tableii}{ll}{textrm}% --- 373,378 ---- python setup.py sdist \end{verbatim} ! (assuming you haven't specified any \command{sdist} options in the setup ! script or config file), \command{sdist} creates the archive of the default format for the current platform. The default formats are: \begin{tableii}{ll}{textrm}% *************** *** 540,544 **** specialty---writing code and creating source distributions---while an intermediary species of \emph{packager} springs up to turn source ! distributions into build distributions for as many platforms as there are packagers. --- 539,543 ---- specialty---writing code and creating source distributions---while an intermediary species of \emph{packager} springs up to turn source ! distributions into built distributions for as many platforms as there are packagers. From python-dev@python.org Sat Jun 24 02:45:49 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 23 Jun 2000 18:45:49 -0700 Subject: [Python-checkins] CVS: distutils/doc/dist dist.tex,1.15,1.16 Message-ID: <200006240145.SAA10895@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/doc/dist In directory slayer.i.sourceforge.net:/tmp/cvs-serv10880 Modified Files: dist.tex Log Message: Some clarifications to the 'A simple example' section. Index: dist.tex =================================================================== RCS file: /cvsroot/python/distutils/doc/dist/dist.tex,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** dist.tex 2000/06/24 01:33:14 1.15 --- dist.tex 2000/06/24 01:45:47 1.16 *************** *** 70,74 **** Python, there are no arbitrary limits to what you can do. If all you want to do is distribute a module called \module{foo}, contained in a ! file \file{foo.py}, then you can get away with as little as this: \begin{verbatim} from distutils.core import setup --- 70,74 ---- Python, there are no arbitrary limits to what you can do. If all you want to do is distribute a module called \module{foo}, contained in a ! file \file{foo.py}, then your setup script can be as little as this: \begin{verbatim} from distutils.core import setup *************** *** 77,87 **** py_modules = ["foo"]) \end{verbatim} Some observations: \begin{itemize} ! \item all information that you supply to the Distutils is supplied as keyword arguments to the \function{setup()} function \item those keyword arguments fall into two categories: package meta-data (name, version number) and information about what's in the ! package (list of pure modules, in this case) \item modules are specified by module name, not filename (the same will hold true for packages and extensions) --- 77,88 ---- py_modules = ["foo"]) \end{verbatim} + Some observations: \begin{itemize} ! \item most information that you supply to the Distutils is supplied as keyword arguments to the \function{setup()} function \item those keyword arguments fall into two categories: package meta-data (name, version number) and information about what's in the ! package (a list of pure Python modules, in this case) \item modules are specified by module name, not filename (the same will hold true for packages and extensions) *************** *** 90,94 **** \end{itemize} ! To create a source distribution for this module, you would run \begin{verbatim} python setup.py sdist --- 91,96 ---- \end{itemize} ! To create a source distribution for this module, you would create a ! setup script, \file{setup.py}, containing the above code, and run: \begin{verbatim} python setup.py sdist *************** *** 137,142 **** zip file with a minimal user interface, which is enough for small- to medium-sized module collections. You'll need to have version XXX of ! Wise installed on your system for the \command{bdist\_wise} to work; ! it's available from \url{http://foo/bar/baz}.) Other \command{bdist} commands exist for other platforms: for example, --- 139,144 ---- zip file with a minimal user interface, which is enough for small- to medium-sized module collections. You'll need to have version XXX of ! Wise installed on your system for the \command{bdist\_wise} command to ! work; it's available from \url{http://foo/bar/baz}.) Other \command{bdist} commands exist for other platforms: for example, From python-dev@python.org Sat Jun 24 03:22:52 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 23 Jun 2000 19:22:52 -0700 Subject: [Python-checkins] CVS: distutils/distutils ccompiler.py,1.24,1.25 Message-ID: <200006240222.TAA18390@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv18373 Modified Files: ccompiler.py Log Message: Changed 'object_filenames()' to raise exception instead of silently carrying on if it sees a filename with unknown extension. Index: ccompiler.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/ccompiler.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -r1.24 -r1.25 *** ccompiler.py 2000/06/24 00:23:20 1.24 --- ccompiler.py 2000/06/24 02:22:49 1.25 *************** *** 672,676 **** (base, ext) = os.path.splitext (src_name) if ext not in self.src_extensions: ! continue if strip_dir: base = os.path.basename (base) --- 672,678 ---- (base, ext) = os.path.splitext (src_name) if ext not in self.src_extensions: ! raise UnknownFileError, \ ! "unknown file type '%s' (from '%s')" % \ ! (ext, src_name) if strip_dir: base = os.path.basename (base) From python-dev@python.org Sat Jun 24 18:22:42 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 10:22:42 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command install.py,1.38,1.39 Message-ID: <200006241722.KAA32544@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv32529/command Modified Files: install.py Log Message: Changed the default installation directory for data files (used by the "install_data" command to the installation base, which is usually just sys.prefix. (Any setup scripts out there that specify data files will have to set the installation directory, relative to the base, explicitly.) Index: install.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/install.py,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -r1.38 -r1.39 *** install.py 2000/06/21 03:09:02 1.38 --- install.py 2000/06/24 17:22:39 1.39 *************** *** 21,25 **** 'headers': '$base/include/python$py_version_short/$dist_name', 'scripts': '$base/bin', ! 'data' : '$base/share', }, 'unix_home': { --- 21,25 ---- 'headers': '$base/include/python$py_version_short/$dist_name', 'scripts': '$base/bin', ! 'data' : '$base', }, 'unix_home': { *************** *** 28,32 **** 'headers': '$base/include/python/$dist_name', 'scripts': '$base/bin', ! 'data' : '$base/share', }, 'nt': { --- 28,32 ---- 'headers': '$base/include/python/$dist_name', 'scripts': '$base/bin', ! 'data' : '$base', }, 'nt': { *************** *** 35,39 **** 'headers': '$base\\Include\\$dist_name', 'scripts': '$base\\Scripts', ! 'data' : '$base\\Data', }, 'mac': { --- 35,39 ---- 'headers': '$base\\Include\\$dist_name', 'scripts': '$base\\Scripts', ! 'data' : '$base', }, 'mac': { *************** *** 42,46 **** 'headers': '$base:Include:$dist_name', 'scripts': '$base:Scripts', ! 'data' : '$base:Data', } } --- 42,46 ---- 'headers': '$base:Include:$dist_name', 'scripts': '$base:Scripts', ! 'data' : '$base', } } From python-dev@python.org Sat Jun 24 18:36:26 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 10:36:26 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command install_data.py,1.9,1.10 Message-ID: <200006241736.KAA00747@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv732 Modified Files: install_data.py Log Message: Print a warning if we install a data file right in install_dir. Tweaked help text. Index: install_data.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/install_data.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** install_data.py 2000/06/21 03:12:07 1.9 --- install_data.py 2000/06/24 17:36:24 1.10 *************** *** 19,23 **** user_options = [ ('install-dir=', 'd', ! "directory to install the files to"), ('root=', None, "install everything relative to this alternate root directory"), --- 19,24 ---- user_options = [ ('install-dir=', 'd', ! "base directory for installating data files " ! "(default: installation base dir)"), ('root=', None, "install everything relative to this alternate root directory"), *************** *** 40,48 **** for f in self.data_files: if type(f) == StringType: ! # its a simple file, so copy it out = self.copy_file(f, self.install_dir) self.outfiles.append(out) else: ! # its a tuple with path to install to and a list of files dir = f[0] if not os.path.isabs(dir): --- 41,52 ---- for f in self.data_files: if type(f) == StringType: ! # it's a simple file, so copy it ! self.warn("setup script did not provide a directory for " ! "'%s' -- installing right in '%s'" % ! (f, self.install_dir)) out = self.copy_file(f, self.install_dir) self.outfiles.append(out) else: ! # it's a tuple with path to install to and a list of files dir = f[0] if not os.path.isabs(dir): From python-dev@python.org Sat Jun 24 19:10:51 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 11:10:51 -0700 Subject: [Python-checkins] CVS: distutils/distutils ccompiler.py,1.25,1.26 Message-ID: <200006241810.LAA08731@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv8721 Modified Files: ccompiler.py Log Message: Docstring reformatting/tweaking binge. Fixed a few comments. Index: ccompiler.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/ccompiler.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -r1.25 -r1.26 *** ccompiler.py 2000/06/24 02:22:49 1.25 --- ccompiler.py 2000/06/24 18:10:48 1.26 *************** *** 18,34 **** class CCompiler: """Abstract base class to define the interface that must be implemented ! by real compiler abstraction classes. Might have some use as a ! place for shared code, but it's not yet clear what code can be ! shared between compiler abstraction models for different platforms. ! ! The basic idea behind a compiler abstraction class is that each ! instance can be used for all the compile/link steps in building ! a single project. Thus, attributes common to all of those compile ! and link steps -- include directories, macros to define, libraries ! to link against, etc. -- are attributes of the compiler instance. ! To allow for variability in how individual files are treated, ! most (all?) of those attributes may be varied on a per-compilation ! or per-link basis.""" # 'compiler_type' is a class attribute that identifies this class. It # keeps code that wants to know what kind of compiler it's dealing with --- 18,33 ---- class CCompiler: """Abstract base class to define the interface that must be implemented ! by real compiler classes. Also has some utility methods used by ! several compiler classes. + The basic idea behind a compiler abstraction class is that each + instance can be used for all the compile/link steps in building a + single project. Thus, attributes common to all of those compile and + link steps -- include directories, macros to define, libraries to link + against, etc. -- are attributes of the compiler instance. To allow for + variability in how individual files are treated, most of those + attributes may be varied on a per-compilation or per-link basis. + """ + # 'compiler_type' is a class attribute that identifies this class. It # keeps code that wants to know what kind of compiler it's dealing with *************** *** 47,54 **** # (UnixCCompiler, MSVCCompiler, etc.) -- or perhaps the base # class should have methods for the common ones. - # * can't put output files (object files, libraries, whatever) - # into a separate directory from their inputs. Should this be - # handled by an 'output_dir' attribute of the whole object, or a - # parameter to the compile/link_* methods, or both? # * can't completely override the include or library searchg # path, ie. no "cc -I -Idir1 -Idir2" or "cc -L -Ldir1 -Ldir2". --- 46,49 ---- *************** *** 130,137 **** def _check_macro_definitions (self, definitions): """Ensures that every element of 'definitions' is a valid macro ! definition, ie. either (name,value) 2-tuple or a (name,) ! tuple. Do nothing if all definitions are OK, raise ! TypeError otherwise.""" ! for defn in definitions: if not (type (defn) is TupleType and --- 125,131 ---- def _check_macro_definitions (self, definitions): """Ensures that every element of 'definitions' is a valid macro ! definition, ie. either (name,value) 2-tuple or a (name,) tuple. Do ! nothing if all definitions are OK, raise TypeError otherwise. ! """ for defn in definitions: if not (type (defn) is TupleType and *************** *** 149,158 **** def define_macro (self, name, value=None): ! """Define a preprocessor macro for all compilations driven by ! this compiler object. The optional parameter 'value' should be ! a string; if it is not supplied, then the macro will be defined ! without an explicit value and the exact outcome depends on the ! compiler used (XXX true? does ANSI say anything about this?)""" ! # Delete from the list of macro definitions/undefinitions if # already there (so that this one will take precedence). --- 143,152 ---- def define_macro (self, name, value=None): ! """Define a preprocessor macro for all compilations driven by this ! compiler object. The optional parameter 'value' should be a ! string; if it is not supplied, then the macro will be defined ! without an explicit value and the exact outcome depends on the ! compiler used (XXX true? does ANSI say anything about this?) ! """ # Delete from the list of macro definitions/undefinitions if # already there (so that this one will take precedence). *************** *** 167,177 **** def undefine_macro (self, name): """Undefine a preprocessor macro for all compilations driven by ! this compiler object. If the same macro is defined by ! 'define_macro()' and undefined by 'undefine_macro()' the last ! call takes precedence (including multiple redefinitions or ! undefinitions). If the macro is redefined/undefined on a ! per-compilation basis (ie. in the call to 'compile()'), then ! that takes precedence.""" ! # Delete from the list of macro definitions/undefinitions if # already there (so that this one will take precedence). --- 161,171 ---- def undefine_macro (self, name): """Undefine a preprocessor macro for all compilations driven by ! this compiler object. If the same macro is defined by ! 'define_macro()' and undefined by 'undefine_macro()' the last call ! takes precedence (including multiple redefinitions or ! undefinitions). If the macro is redefined/undefined on a ! per-compilation basis (ie. in the call to 'compile()'), then that ! takes precedence. ! """ # Delete from the list of macro definitions/undefinitions if # already there (so that this one will take precedence). *************** *** 185,225 **** def add_include_dir (self, dir): ! """Add 'dir' to the list of directories that will be searched ! for header files. The compiler is instructed to search ! directories in the order in which they are supplied by ! successive calls to 'add_include_dir()'.""" self.include_dirs.append (dir) def set_include_dirs (self, dirs): ! """Set the list of directories that will be searched to 'dirs' ! (a list of strings). Overrides any preceding calls to ! 'add_include_dir()'; subsequence calls to 'add_include_dir()' ! add to the list passed to 'set_include_dirs()'. This does ! not affect any list of standard include directories that ! the compiler may search by default.""" self.include_dirs = copy (dirs) def add_library (self, libname): ! """Add 'libname' to the list of libraries that will be included ! in all links driven by this compiler object. Note that ! 'libname' should *not* be the name of a file containing a ! library, but the name of the library itself: the actual filename ! will be inferred by the linker, the compiler, or the compiler ! abstraction class (depending on the platform). ! ! The linker will be instructed to link against libraries in the ! order they were supplied to 'add_library()' and/or ! 'set_libraries()'. It is perfectly valid to duplicate library ! names; the linker will be instructed to link against libraries ! as many times as they are mentioned.""" self.libraries.append (libname) def set_libraries (self, libnames): ! """Set the list of libraries to be included in all links driven ! by this compiler object to 'libnames' (a list of strings). ! This does not affect any standard system libraries that the ! linker may include by default.""" ! self.libraries = copy (libnames) --- 179,222 ---- def add_include_dir (self, dir): ! """Add 'dir' to the list of directories that will be searched for ! header files. The compiler is instructed to search directories in ! the order in which they are supplied by successive calls to ! 'add_include_dir()'. ! """ self.include_dirs.append (dir) def set_include_dirs (self, dirs): ! """Set the list of directories that will be searched to 'dirs' (a ! list of strings). Overrides any preceding calls to ! 'add_include_dir()'; subsequence calls to 'add_include_dir()' add ! to the list passed to 'set_include_dirs()'. This does not affect ! any list of standard include directories that the compiler may ! search by default. ! """ self.include_dirs = copy (dirs) def add_library (self, libname): ! """Add 'libname' to the list of libraries that will be included in ! all links driven by this compiler object. Note that 'libname' ! should *not* be the name of a file containing a library, but the ! name of the library itself: the actual filename will be inferred by ! the linker, the compiler, or the compiler class (depending on the ! platform). ! ! The linker will be instructed to link against libraries in the ! order they were supplied to 'add_library()' and/or ! 'set_libraries()'. It is perfectly valid to duplicate library ! names; the linker will be instructed to link against libraries as ! many times as they are mentioned. ! """ self.libraries.append (libname) def set_libraries (self, libnames): ! """Set the list of libraries to be included in all links driven by ! this compiler object to 'libnames' (a list of strings). This does ! not affect any standard system libraries that the linker may ! include by default. ! """ self.libraries = copy (libnames) *************** *** 227,240 **** def add_library_dir (self, dir): """Add 'dir' to the list of directories that will be searched for ! libraries specified to 'add_library()' and 'set_libraries()'. ! The linker will be instructed to search for libraries in the ! order they are supplied to 'add_library_dir()' and/or ! 'set_library_dirs()'.""" self.library_dirs.append (dir) def set_library_dirs (self, dirs): ! """Set the list of library search directories to 'dirs' (a list ! of strings). This does not affect any standard library ! search path that the linker may search by default.""" self.library_dirs = copy (dirs) --- 224,238 ---- def add_library_dir (self, dir): """Add 'dir' to the list of directories that will be searched for ! libraries specified to 'add_library()' and 'set_libraries()'. The ! linker will be instructed to search for libraries in the order they ! are supplied to 'add_library_dir()' and/or 'set_library_dirs()'. ! """ self.library_dirs.append (dir) def set_library_dirs (self, dirs): ! """Set the list of library search directories to 'dirs' (a list of ! strings). This does not affect any standard library search path ! that the linker may search by default. ! """ self.library_dirs = copy (dirs) *************** *** 242,268 **** def add_runtime_library_dir (self, dir): """Add 'dir' to the list of directories that will be searched for ! shared libraries at runtime.""" self.runtime_library_dirs.append (dir) def set_runtime_library_dirs (self, dirs): ! """Set the list of directories to search for shared libraries ! at runtime to 'dirs' (a list of strings). This does not affect ! any standard search path that the runtime linker may search by ! default.""" self.runtime_library_dirs = copy (dirs) def add_link_object (self, object): ! """Add 'object' to the list of object files (or analogues, such ! as explictly named library files or the output of "resource ! compilers") to be included in every link driven by this ! compiler object.""" self.objects.append (object) def set_link_objects (self, objects): ! """Set the list of object files (or analogues) to be included ! in every link to 'objects'. This does not affect any ! standard object files that the linker may include by default ! (such as system libraries).""" self.objects = copy (objects) --- 240,270 ---- def add_runtime_library_dir (self, dir): """Add 'dir' to the list of directories that will be searched for ! shared libraries at runtime. ! """ self.runtime_library_dirs.append (dir) def set_runtime_library_dirs (self, dirs): ! """Set the list of directories to search for shared libraries at ! runtime to 'dirs' (a list of strings). This does not affect any ! standard search path that the runtime linker may search by ! default. ! """ self.runtime_library_dirs = copy (dirs) def add_link_object (self, object): ! """Add 'object' to the list of object files (or analogues, such as ! explictly named library files or the output of "resource ! compilers") to be included in every link driven by this compiler ! object. ! """ self.objects.append (object) def set_link_objects (self, objects): ! """Set the list of object files (or analogues) to be included in ! every link to 'objects'. This does not affect any standard object ! files that the linker may include by default (such as system ! libraries). ! """ self.objects = copy (objects) *************** *** 272,284 **** def _fix_compile_args (self, output_dir, macros, include_dirs): ! """Typecheck and fix-up some of the arguments to the 'compile()' method, ! and return fixed-up values. Specifically: if 'output_dir' is ! None, replaces it with 'self.output_dir'; ensures that 'macros' ! is a list, and augments it with 'self.macros'; ensures that ! 'include_dirs' is a list, and augments it with ! 'self.include_dirs'. Guarantees that the returned values are of ! the correct type, i.e. for 'output_dir' either string or None, ! and for 'macros' and 'include_dirs' either list or None.""" ! if output_dir is None: output_dir = self.output_dir --- 274,286 ---- def _fix_compile_args (self, output_dir, macros, include_dirs): ! """Typecheck and fix-up some of the arguments to the 'compile()' ! method, and return fixed-up values. Specifically: if 'output_dir' ! is None, replaces it with 'self.output_dir'; ensures that 'macros' ! is a list, and augments it with 'self.macros'; ensures that ! 'include_dirs' is a list, and augments it with 'self.include_dirs'. ! Guarantees that the returned values are of the correct type, ! i.e. for 'output_dir' either string or None, and for 'macros' and ! 'include_dirs' either list or None. ! """ if output_dir is None: output_dir = self.output_dir *************** *** 308,316 **** def _prep_compile (self, sources, output_dir): ! """Determine the list of object files corresponding to 'sources', and ! figure out which ones really need to be recompiled. Return a list ! of all object files and a dictionary telling which source files can ! be skipped.""" ! # Get the list of expected output (object) files objects = self.object_filenames (sources, --- 310,318 ---- def _prep_compile (self, sources, output_dir): ! """Determine the list of object files corresponding to 'sources', ! and figure out which ones really need to be recompiled. Return a ! list of all object files and a dictionary telling which source ! files can be skipped. ! """ # Get the list of expected output (object) files objects = self.object_filenames (sources, *************** *** 331,336 **** (n_sources, n_objects) = newer_pairwise (sources, objects) ! for source in n_sources: # no really, only rebuild what's out-of-date ! skip_source[source] = 0 return (objects, skip_source) --- 333,338 ---- (n_sources, n_objects) = newer_pairwise (sources, objects) ! for source in n_sources: # no really, only rebuild what's ! skip_source[source] = 0 # out-of-date return (objects, skip_source) *************** *** 340,348 **** def _fix_object_args (self, objects, output_dir): ! """Typecheck and fix up some arguments supplied to various ! methods. Specifically: ensure that 'objects' is a list; if ! output_dir is None, replace with self.output_dir. Return fixed ! versions of 'objects' and 'output_dir'.""" ! if type (objects) not in (ListType, TupleType): raise TypeError, \ --- 342,350 ---- def _fix_object_args (self, objects, output_dir): ! """Typecheck and fix up some arguments supplied to various methods. ! Specifically: ensure that 'objects' is a list; if output_dir is ! None, replace with self.output_dir. Return fixed versions of ! 'objects' and 'output_dir'. ! """ if type (objects) not in (ListType, TupleType): raise TypeError, \ *************** *** 360,368 **** def _fix_lib_args (self, libraries, library_dirs, runtime_library_dirs): """Typecheck and fix up some of the arguments supplied to the ! 'link_*' methods. Specifically: ensure that all arguments are ! lists, and augment them with their permanent versions ! (eg. 'self.libraries' augments 'libraries'). Return a tuple ! with fixed versions of all arguments.""" ! if libraries is None: libraries = self.libraries --- 362,370 ---- def _fix_lib_args (self, libraries, library_dirs, runtime_library_dirs): """Typecheck and fix up some of the arguments supplied to the ! 'link_*' methods. Specifically: ensure that all arguments are ! lists, and augment them with their permanent versions ! (eg. 'self.libraries' augments 'libraries'). Return a tuple with ! fixed versions of all arguments. ! """ if libraries is None: libraries = self.libraries *************** *** 397,403 **** def _need_link (self, objects, output_file): ! """Return true if we need to relink the files listed in 'objects' to ! recreate 'output_file'.""" ! if self.force: return 1 --- 399,405 ---- def _need_link (self, objects, output_file): ! """Return true if we need to relink the files listed in 'objects' ! to recreate 'output_file'. ! """ if self.force: return 1 *************** *** 439,480 **** extra_preargs=None, extra_postargs=None): ! """Compile one or more C/C++ source files. 'sources' must be ! a list of strings, each one the name of a C/C++ source ! file. Return a list of object filenames, one per source ! filename in 'sources'. Depending on the implementation, ! not all source files will necessarily be compiled, but ! all corresponding object filenames will be returned. ! ! If 'output_dir' is given, object files will be put under it, ! while retaining their original path component. That is, ! "foo/bar.c" normally compiles to "foo/bar.o" (for a Unix ! implementation); if 'output_dir' is "build", then it would ! compile to "build/foo/bar.o". ! ! 'macros', if given, must be a list of macro definitions. A ! macro definition is either a (name, value) 2-tuple or a (name,) ! 1-tuple. The former defines a macro; if the value is None, the ! macro is defined without an explicit value. The 1-tuple case ! undefines a macro. Later definitions/redefinitions/ ! undefinitions take precedence. ! ! 'include_dirs', if given, must be a list of strings, the ! directories to add to the default include file search path for ! this compilation only. ! ! 'debug' is a boolean; if true, the compiler will be instructed ! to output debug symbols in (or alongside) the object file(s). ! ! 'extra_preargs' and 'extra_postargs' are implementation- ! dependent. On platforms that have the notion of a command-line ! (e.g. Unix, DOS/Windows), they are most likely lists of strings: ! extra command-line arguments to prepand/append to the compiler ! command line. On other platforms, consult the implementation ! class documentation. In any event, they are intended as an ! escape hatch for those occasions when the abstract compiler ! framework doesn't cut the mustard. ! Raises CompileError on failure.""" ! pass --- 441,482 ---- extra_preargs=None, extra_postargs=None): ! """Compile one or more C/C++ source files. 'sources' must be a ! list of strings, each one the name of a C/C++ source file. Return ! a list of object filenames, one per source filename in 'sources'. ! Depending on the implementation, not all source files will ! necessarily be compiled, but all corresponding object filenames ! will be returned. ! ! If 'output_dir' is given, object files will be put under it, while ! retaining their original path component. That is, "foo/bar.c" ! normally compiles to "foo/bar.o" (for a Unix implementation); if ! 'output_dir' is "build", then it would compile to ! "build/foo/bar.o". ! ! 'macros', if given, must be a list of macro definitions. A macro ! definition is either a (name, value) 2-tuple or a (name,) 1-tuple. ! The former defines a macro; if the value is None, the macro is ! defined without an explicit value. The 1-tuple case undefines a ! macro. Later definitions/redefinitions/ undefinitions take ! precedence. ! ! 'include_dirs', if given, must be a list of strings, the ! directories to add to the default include file search path for this ! compilation only. ! ! 'debug' is a boolean; if true, the compiler will be instructed to ! output debug symbols in (or alongside) the object file(s). ! ! 'extra_preargs' and 'extra_postargs' are implementation- dependent. ! On platforms that have the notion of a command-line (e.g. Unix, ! DOS/Windows), they are most likely lists of strings: extra ! command-line arguments to prepand/append to the compiler command ! line. On other platforms, consult the implementation class ! documentation. In any event, they are intended as an escape hatch ! for those occasions when the abstract compiler framework doesn't ! cut the mustard. ! Raises CompileError on failure. ! """ pass *************** *** 485,507 **** output_dir=None, debug=0): ! """Link a bunch of stuff together to create a static library ! file. The "bunch of stuff" consists of the list of object ! files supplied as 'objects', the extra object files supplied ! to 'add_link_object()' and/or 'set_link_objects()', the ! libraries supplied to 'add_library()' and/or ! 'set_libraries()', and the libraries supplied as 'libraries' ! (if any). ! ! 'output_libname' should be a library name, not a filename; the ! filename will be inferred from the library name. 'output_dir' ! is the directory where the library file will be put. ! ! 'debug' is a boolean; if true, debugging information will be ! included in the library (note that on most platforms, it is the ! compile step where this matters: the 'debug' flag is included ! here just for consistency). ! ! Raises LibError on failure.""" pass --- 487,508 ---- output_dir=None, debug=0): ! """Link a bunch of stuff together to create a static library file. ! The "bunch of stuff" consists of the list of object files supplied ! as 'objects', the extra object files supplied to ! 'add_link_object()' and/or 'set_link_objects()', the libraries ! supplied to 'add_library()' and/or 'set_libraries()', and the ! libraries supplied as 'libraries' (if any). ! ! 'output_libname' should be a library name, not a filename; the ! filename will be inferred from the library name. 'output_dir' is ! the directory where the library file will be put. ! ! 'debug' is a boolean; if true, debugging information will be ! included in the library (note that on most platforms, it is the ! compile step where this matters: the 'debug' flag is included here ! just for consistency). + Raises LibError on failure. + """ pass *************** *** 518,559 **** extra_preargs=None, extra_postargs=None): - """Link a bunch of stuff together to create a shared library - file. Similar semantics to 'create_static_lib()', with the - addition of other libraries to link against and directories to - search for them. Also, of course, the type and name of - the generated file will almost certainly be different, as will - the program used to create it. - - 'libraries' is a list of libraries to link against. These are - library names, not filenames, since they're translated into - filenames in a platform-specific way (eg. "foo" becomes - "libfoo.a" on Unix and "foo.lib" on DOS/Windows). However, they - can include a directory component, which means the linker will - look in that specific directory rather than searching all the - normal locations. - - 'library_dirs', if supplied, should be a list of directories to - search for libraries that were specified as bare library names - (ie. no directory component). These are on top of the system - default and those supplied to 'add_library_dir()' and/or - 'set_library_dirs()'. 'runtime_library_dirs' is a list of - directories that will be embedded into the shared library and - used to search for other shared libraries that *it* depends on - at run-time. (This may only be relevant on Unix.) - - 'export_symbols' is a list of symbols that the shared library - will export. (This appears to be relevant only on Windows.) - - 'debug' is as for 'compile()' and 'create_static_lib()', with the - slight distinction that it actually matters on most platforms - (as opposed to 'create_static_lib()', which includes a 'debug' - flag mostly for form's sake). - - 'extra_preargs' and 'extra_postargs' are as for 'compile()' - (except of course that they supply command-line arguments - for the particular linker being used). ! Raises LinkError on failure.""" pass --- 519,560 ---- extra_preargs=None, extra_postargs=None): ! """Link a bunch of stuff together to create a shared library file. ! Similar semantics to 'create_static_lib()', with the addition of ! other libraries to link against and directories to search for them. ! Also, of course, the type and name of the generated file will ! almost certainly be different, as will the program used to create ! it. ! ! 'libraries' is a list of libraries to link against. These are ! library names, not filenames, since they're translated into ! filenames in a platform-specific way (eg. "foo" becomes "libfoo.a" ! on Unix and "foo.lib" on DOS/Windows). However, they can include a ! directory component, which means the linker will look in that ! specific directory rather than searching all the normal locations. ! ! 'library_dirs', if supplied, should be a list of directories to ! search for libraries that were specified as bare library names ! (ie. no directory component). These are on top of the system ! default and those supplied to 'add_library_dir()' and/or ! 'set_library_dirs()'. 'runtime_library_dirs' is a list of ! directories that will be embedded into the shared library and used ! to search for other shared libraries that *it* depends on at ! run-time. (This may only be relevant on Unix.) ! ! 'export_symbols' is a list of symbols that the shared library will ! export. (This appears to be relevant only on Windows.) ! ! 'debug' is as for 'compile()' and 'create_static_lib()', with the ! slight distinction that it actually matters on most platforms (as ! opposed to 'create_static_lib()', which includes a 'debug' flag ! mostly for form's sake). ! ! 'extra_preargs' and 'extra_postargs' are as for 'compile()' (except ! of course that they supply command-line arguments for the ! particular linker being used). + Raises LinkError on failure. + """ pass *************** *** 570,581 **** extra_preargs=None, extra_postargs=None): ! """Link a bunch of stuff together to create a shared object ! file. Much like 'link_shared_lib()', except the output filename ! is explicitly supplied as 'output_filename'. If 'output_dir' is ! supplied, 'output_filename' is relative to it ! (i.e. 'output_filename' can provide directory components if ! needed). ! Raises LinkError on failure.""" pass --- 571,583 ---- extra_preargs=None, extra_postargs=None): ! """Link a bunch of stuff together to create a shared object file. ! Much like 'link_shared_lib()', except the output filename is ! explicitly supplied as 'output_filename'. If 'output_dir' is ! supplied, 'output_filename' is relative to it ! (i.e. 'output_filename' can provide directory components if ! needed). ! Raises LinkError on failure. ! """ pass *************** *** 592,601 **** extra_postargs=None): """Link a bunch of stuff together to create a binary executable ! file. The "bunch of stuff" is as for 'link_shared_lib()'. ! 'output_progname' should be the base name of the executable ! program--e.g. on Unix the same as the output filename, but ! on DOS/Windows ".exe" will be appended. ! Raises LinkError on failure.""" pass --- 594,604 ---- extra_postargs=None): """Link a bunch of stuff together to create a binary executable ! file. The "bunch of stuff" is as for 'link_shared_lib()'. ! 'output_progname' should be the base name of the executable ! program--e.g. on Unix the same as the output filename, but on ! DOS/Windows ".exe" will be appended. ! Raises LinkError on failure. ! """ pass *************** *** 608,629 **** def library_dir_option (self, dir): ! """Return the compiler option to add 'dir' to the list of directories ! searched for libraries.""" raise NotImplementedError def runtime_library_dir_option (self, dir): ! """Return the compiler option to add 'dir' to the list of directories ! searched for runtime libraries.""" raise NotImplementedError def library_option (self, lib): """Return the compiler option to add 'dir' to the list of libraries ! linked into the shared library or executable.""" raise NotImplementedError def find_library_file (self, dirs, lib): """Search the specified list of directories for a static or shared ! library file 'lib' and return the full path to that file. Return ! None if it wasn't found in any of the specified directories.""" raise NotImplementedError --- 611,636 ---- def library_dir_option (self, dir): ! """Return the compiler option to add 'dir' to the list of ! directories searched for libraries. ! """ raise NotImplementedError def runtime_library_dir_option (self, dir): ! """Return the compiler option to add 'dir' to the list of ! directories searched for runtime libraries. ! """ raise NotImplementedError def library_option (self, lib): """Return the compiler option to add 'dir' to the list of libraries ! linked into the shared library or executable. ! """ raise NotImplementedError def find_library_file (self, dirs, lib): """Search the specified list of directories for a static or shared ! library file 'lib' and return the full path to that file. Return ! None if it wasn't found in any of the specified directories. ! """ raise NotImplementedError *************** *** 777,792 **** dry_run=0, force=0): - """Generate an instance of some CCompiler subclass for the supplied ! platform/compiler combination. 'plat' defaults to 'os.name' ! (eg. 'posix', 'nt'), and 'compiler' defaults to the default ! compiler for that platform. Currently only 'posix' and 'nt' ! are supported, and the default compilers are "traditional Unix ! interface" (UnixCCompiler class) and Visual C++ (MSVCCompiler ! class). Note that it's perfectly possible to ask for a Unix ! compiler object under Windows, and a Microsoft compiler object ! under Unix -- if you supply a value for 'compiler', 'plat' ! is ignored.""" ! if plat is None: plat = os.name --- 784,797 ---- dry_run=0, force=0): """Generate an instance of some CCompiler subclass for the supplied ! platform/compiler combination. 'plat' defaults to 'os.name' ! (eg. 'posix', 'nt'), and 'compiler' defaults to the default compiler ! for that platform. Currently only 'posix' and 'nt' are supported, and ! the default compilers are "traditional Unix interface" (UnixCCompiler ! class) and Visual C++ (MSVCCompiler class). Note that it's perfectly ! possible to ask for a Unix compiler object under Windows, and a ! Microsoft compiler object under Unix -- if you supply a value for ! 'compiler', 'plat' is ignored. ! """ if plat is None: plat = os.name *************** *** 821,833 **** def gen_preprocess_options (macros, include_dirs): ! """Generate C pre-processor options (-D, -U, -I) as used by at ! least two types of compilers: the typical Unix compiler and Visual ! C++. 'macros' is the usual thing, a list of 1- or 2-tuples, where ! (name,) means undefine (-U) macro 'name', and (name,value) means ! define (-D) macro 'name' to 'value'. 'include_dirs' is just a list of ! directory names to be added to the header file search path (-I). ! Returns a list of command-line options suitable for either ! Unix compilers or Visual C++.""" ! # XXX it would be nice (mainly aesthetic, and so we don't generate # stupid-looking command lines) to go over 'macros' and eliminate --- 826,838 ---- def gen_preprocess_options (macros, include_dirs): ! """Generate C pre-processor options (-D, -U, -I) as used by at least ! two types of compilers: the typical Unix compiler and Visual C++. ! 'macros' is the usual thing, a list of 1- or 2-tuples, where (name,) ! means undefine (-U) macro 'name', and (name,value) means define (-D) ! macro 'name' to 'value'. 'include_dirs' is just a list of directory ! names to be added to the header file search path (-I). Returns a list ! of command-line options suitable for either Unix compilers or Visual ! C++. ! """ # XXX it would be nice (mainly aesthetic, and so we don't generate # stupid-looking command lines) to go over 'macros' and eliminate *************** *** 873,882 **** def gen_lib_options (compiler, library_dirs, runtime_library_dirs, libraries): """Generate linker options for searching library directories and ! linking with specific libraries. 'libraries' and 'library_dirs' ! are, respectively, lists of library names (not filenames!) and ! search directories. Returns a list of command-line options suitable ! for use with some compiler (depending on the two format strings ! passed in).""" ! lib_opts = [] --- 878,886 ---- def gen_lib_options (compiler, library_dirs, runtime_library_dirs, libraries): """Generate linker options for searching library directories and ! linking with specific libraries. 'libraries' and 'library_dirs' are, ! respectively, lists of library names (not filenames!) and search ! directories. Returns a list of command-line options suitable for use ! with some compiler (depending on the two format strings passed in). ! """ lib_opts = [] From python-dev@python.org Sat Jun 24 21:40:05 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 13:40:05 -0700 Subject: [Python-checkins] CVS: distutils/distutils util.py,1.36,1.37 Message-ID: <200006242040.NAA28315@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv28287 Modified Files: util.py Log Message: Added 'split_quoted()' function to deal with strings that are quoted in Unix shell-like syntax (eg. in Python's Makefile, for one thing -- now that I have this function, I'll probably allow quoted strings in config files too. Index: util.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/util.py,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -r1.36 -r1.37 *** util.py 2000/06/18 15:45:55 1.36 --- util.py 2000/06/24 20:40:02 1.37 *************** *** 167,168 **** --- 167,235 ---- return error + + + # Needed by 'split_quoted()' + _wordchars_re = re.compile(r'[^\\\'\"\ ]*') + _squote_re = re.compile(r"'(?:[^'\\]|\\.)*'") + _dquote_re = re.compile(r'"(?:[^"\\]|\\.)*"') + + def split_quoted (s): + """Split a string up according to Unix shell-like rules for quotes and + backslashes. In short: words are delimited by spaces, as long as those + spaces are not escaped by a backslash, or inside a quoted string. + Single and double quotes are equivalent, and the quote characters can + be backslash-escaped. The backslash is stripped from any two-character + escape sequence, leaving only the escaped character. The quote + characters are stripped from any quoted string. Returns a list of + words. + """ + + # This is a nice algorithm for splitting up a single string, since it + # doesn't require character-by-character examination. It was a little + # bit of a brain-bender to get it working right, though... + + s = string.strip(s) + words = [] + pos = 0 + + while s: + m = _wordchars_re.match(s, pos) + end = m.end() + if end == len(s): + words.append(s[:end]) + break + + if s[end] == ' ': # unescaped, unquoted space: now + words.append(s[:end]) # we definitely have a word delimiter + s = string.lstrip(s[end:]) + pos = 0 + + elif s[end] == '\\': # preserve whatever is being escaped; + # will become part of the current word + s = s[:end] + s[end+1:] + pos = end+1 + + else: + if s[end] == "'": # slurp singly-quoted string + m = _squote_re.match(s, end) + elif s[end] == '"': # slurp doubly-quoted string + m = _dquote_re.match(s, end) + else: + raise RuntimeError, \ + "this can't happen (bad char '%c')" % s[end] + + if m is None: + raise ValueError, \ + "bad string (mismatched %s quotes?)" % s[end] + + (beg, end) = m.span() + s = s[:beg] + s[beg+1:end-1] + s[end:] + pos = m.end() - 2 + + if pos >= len(s): + words.append(s) + break + + return words + + # split_quoted () From python-dev@python.org Sat Jun 24 21:41:13 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 13:41:13 -0700 Subject: [Python-checkins] CVS: distutils/test test_split.py,NONE,1.1 Message-ID: <200006242041.NAA28382@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv28374 Added Files: test_split.py Log Message: Test script for the 'split_quoted()' function. --- NEW FILE --- #!/usr/bin/env python import string, re from distutils.util import split_quoted strings = [("foo bar baz", ['foo', 'bar', 'baz']), (" foo bar", ['foo', 'bar']), ("foo bar ", ['foo', 'bar']), ("foo bar", ['foo', 'bar']), ("\\ foo", [' foo']), ("foo \\ bar", ['foo', ' bar']), ("foo \\ bar", ['foo', ' ', 'bar']), ("foo", ['foo']), ("foo\\ bar", ['foo bar']), ("'foo bar'", ['foo bar']), ("foo 'bar baz'", ['foo', 'bar baz']), ('"foo bar" baz', ['foo bar', 'baz']), ('"hello there" "*"', ['hello there', '*']), ('ding" dong" dang', ['ding dong', 'dang']), ('foo""bar', ['foobar']), ('foo" "bar', ['foo bar']), ('foo\\" bar', ['foo\"', 'bar']), ('foo \\"bar', ['foo', '\"bar']), ('foo\\ \\"bar', ['foo \"bar']), ] bad_strings = ["foo bar'", "'foo bar", "foo 'bar", 'foo "bar', ] for (s, words) in strings: got_split = split_quoted(s) if got_split == words: print "ok: %s -> %s" % (s, got_split) else: print "not ok: %s (expected %s, got %s)" % (s, words, got_split) #print "string to split: " + s #print "expect:", words #print "result:", split(s) #print "expect:", string.join(map(str, words), ", ") #print "result:", string.join(map(str, split(s)), ", ") #print for s in bad_strings: try: words = split_quoted(s) except ValueError, msg: print "ok: %s raised ValueError: %s" % (s, msg) else: print "not ok: %s -> %s (expected ValueError)" % (s, words) From python-dev@python.org Sun Jun 25 03:05:31 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 19:05:31 -0700 Subject: [Python-checkins] CVS: distutils/distutils unixccompiler.py,1.26,1.27 Message-ID: <200006250205.TAA15014@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv15000 Modified Files: unixccompiler.py Log Message: Got rid of direct dependence on the sysconfig module. Mainly, this meant playing along with the new "dictionary of executables" scheme added to CCompiler by adding the 'executables' class attribute, and changing all the compile/link/etc. methods to use the new attributes (which encapsulate both the program to run and its standard arguments, so it was a *little* bit more than just changing some names). Index: unixccompiler.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/unixccompiler.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -r1.26 -r1.27 *** unixccompiler.py 2000/06/21 02:58:46 1.26 --- unixccompiler.py 2000/06/25 02:05:29 1.27 *************** *** 21,25 **** from types import * from copy import copy - from distutils import sysconfig from distutils.dep_util import newer from distutils.ccompiler import \ --- 21,24 ---- *************** *** 46,76 **** class UnixCCompiler (CCompiler): - # XXX perhaps there should really be *three* kinds of include - # directories: those built in to the preprocessor, those from Python's - # Makefiles, and those supplied to {add,set}_include_dirs(). Currently - # we make no distinction between the latter two at this point; it's all - # up to the client class to select the include directories to use above - # and beyond the compiler's defaults. That is, both the Python include - # directories and any module- or package-specific include directories - # are specified via {add,set}_include_dirs(), and there's no way to - # distinguish them. This might be a bug. - compiler_type = 'unix' - # Needed for the filename generation methods provided by the - # base class, CCompiler. src_extensions = [".c",".C",".cc",".cxx",".cpp"] obj_extension = ".o" static_lib_extension = ".a" ! shared_lib_extension = sysconfig.SO static_lib_format = shared_lib_format = "lib%s%s" - # Command to create a static library: seems to be pretty consistent - # across the major Unices. Might have to move down into the - # constructor if we need platform-specific guesswork. - archiver = sysconfig.AR - archiver_options = "-cr" - ranlib = sysconfig.RANLIB - def __init__ (self, --- 45,77 ---- class UnixCCompiler (CCompiler): compiler_type = 'unix' + + # These are used by CCompiler in two places: the constructor sets + # instance attributes 'preprocessor', 'compiler', etc. from them, and + # 'set_executable()' allows any of these to be set. The defaults here + # are pretty generic; they will probably have to be set by an outsider + # (eg. using information discovered by the sysconfig about building + # Python extensions). + executables = {'preprocessor' : None, + 'compiler' : ["cc"], + 'compiler_so' : ["cc"], + 'linker_so' : ["cc", "-shared"], + 'linker_exe' : ["cc"], + 'archiver' : ["ar", "-cr"], + 'ranlib' : None, + } + + # Needed for the filename generation methods provided by the base + # class, CCompiler. NB. whoever instantiates/uses a particular + # UnixCCompiler instance should set 'shared_lib_ext' -- we set a + # reasonable common default here, but it's not necessarily used on all + # Unices! src_extensions = [".c",".C",".cc",".cxx",".cpp"] obj_extension = ".o" static_lib_extension = ".a" ! shared_lib_extension = ".so" static_lib_format = shared_lib_format = "lib%s%s" def __init__ (self, *************** *** 78,109 **** dry_run=0, force=0): - CCompiler.__init__ (self, verbose, dry_run, force) - self.preprocess_options = None - self.compile_options = None - - # Munge CC and OPT together in case there are flags stuck in CC. - # Note that using these variables from sysconfig immediately makes - # this module specific to building Python extensions and - # inappropriate as a general-purpose C compiler front-end. So sue - # me. Note also that we use OPT rather than CFLAGS, because CFLAGS - # is the flags used to compile Python itself -- not only are there - # -I options in there, they are the *wrong* -I options. We'll - # leave selection of include directories up to the class using - # UnixCCompiler! - - (self.cc, self.ccflags) = \ - _split_command (sysconfig.CC + ' ' + sysconfig.OPT) - self.ccflags_shared = string.split (sysconfig.CCSHARED) - - (self.ld_shared, self.ldflags_shared) = \ - _split_command (sysconfig.LDSHARED) - self.ld_exec = self.cc - - # __init__ () - - def preprocess (self, source, --- 79,85 ---- *************** *** 117,125 **** self._fix_compile_args (None, macros, include_dirs) pp_opts = gen_preprocess_options (macros, include_dirs) ! cc_args = ['-E'] + pp_opts if output_file: ! cc_args.extend(['-o', output_file]) if extra_preargs: ! cc_args[:0] = extra_preargs if extra_postargs: extra_postargs.extend(extra_postargs) --- 93,101 ---- self._fix_compile_args (None, macros, include_dirs) pp_opts = gen_preprocess_options (macros, include_dirs) ! pp_args = self.preprocessor + pp_opts if output_file: ! pp_args.extend(['-o', output_file]) if extra_preargs: ! pp_args[:0] = extra_preargs if extra_postargs: extra_postargs.extend(extra_postargs) *************** *** 132,136 **** self.mkpath(os.path.dirname(output_file)) try: ! self.spawn ([self.cc] + cc_args) except DistutilsExecError, msg: raise CompileError, msg --- 108,112 ---- self.mkpath(os.path.dirname(output_file)) try: ! self.spawn (pp_args) except DistutilsExecError, msg: raise CompileError, msg *************** *** 152,156 **** # Figure out the options for the compiler command line. pp_opts = gen_preprocess_options (macros, include_dirs) ! cc_args = ['-c'] + pp_opts + self.ccflags + self.ccflags_shared if debug: cc_args[:0] = ['-g'] --- 128,132 ---- # Figure out the options for the compiler command line. pp_opts = gen_preprocess_options (macros, include_dirs) ! cc_args = pp_opts + ['-c'] if debug: cc_args[:0] = ['-g'] *************** *** 169,173 **** self.mkpath (os.path.dirname (obj)) try: ! self.spawn ([self.cc] + cc_args + [src, '-o', obj] + extra_postargs) --- 145,149 ---- self.mkpath (os.path.dirname (obj)) try: ! self.spawn (self.compiler_so + cc_args + [src, '-o', obj] + extra_postargs) *************** *** 194,200 **** if self._need_link (objects, output_filename): self.mkpath (os.path.dirname (output_filename)) ! self.spawn ([self.archiver, ! self.archiver_options, ! output_filename] + objects + self.objects) --- 170,175 ---- if self._need_link (objects, output_filename): self.mkpath (os.path.dirname (output_filename)) ! self.spawn (self.archiver + ! [output_filename] + objects + self.objects) *************** *** 204,210 **** # needed -- or maybe Python's configure script took care of # it for us, hence the check for leading colon. ! if self.ranlib[0] != ':': try: ! self.spawn ([self.ranlib, output_filename]) except DistutilsExecError, msg: raise LibError, msg --- 179,185 ---- # needed -- or maybe Python's configure script took care of # it for us, hence the check for leading colon. ! if self.ranlib: try: ! self.spawn (self.ranlib + [output_filename]) except DistutilsExecError, msg: raise LibError, msg *************** *** 264,268 **** if self._need_link (objects, output_filename): ! ld_args = (self.ldflags_shared + objects + self.objects + lib_opts + ['-o', output_filename]) if debug: --- 239,243 ---- if self._need_link (objects, output_filename): ! ld_args = (objects + self.objects + lib_opts + ['-o', output_filename]) if debug: *************** *** 274,278 **** self.mkpath (os.path.dirname (output_filename)) try: ! self.spawn ([self.ld_shared] + ld_args) except DistutilsExecError, msg: raise LinkError, msg --- 249,253 ---- self.mkpath (os.path.dirname (output_filename)) try: ! self.spawn (self.linker_so + ld_args) except DistutilsExecError, msg: raise LinkError, msg *************** *** 315,319 **** self.mkpath (os.path.dirname (output_filename)) try: ! self.spawn ([self.ld_exec] + ld_args) except DistutilsExecError, msg: raise LinkError, msg --- 290,294 ---- self.mkpath (os.path.dirname (output_filename)) try: ! self.spawn (self.linker_exe + ld_args) except DistutilsExecError, msg: raise LinkError, msg *************** *** 360,368 **** # class UnixCCompiler - - - def _split_command (cmd): - """Split a command string up into the progam to run (a string) and - the list of arguments; return them as (cmd, arglist).""" - args = string.split (cmd) - return (args[0], args[1:]) --- 335,336 ---- From python-dev@python.org Sun Jun 25 03:08:20 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 19:08:20 -0700 Subject: [Python-checkins] CVS: distutils/distutils ccompiler.py,1.26,1.27 Message-ID: <200006250208.TAA15063@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv15055 Modified Files: ccompiler.py Log Message: Introduced some bureaucracy for setting and tracking the executables that a particular compiler system depends on. This consists of the 'set_executables()' and 'set_executable()' methods, and a few lines in the constructor that expect implementation classes to provide an 'executables' attribute, which we use to initialize several instance attributes. The default implementation is somewhat biased in favour of a Unix/DOS "command-line" view of the world, but it shouldn't be too hard to override this for operating systems with a more sophisticated way of representing programs-to-execute. Index: ccompiler.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/ccompiler.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -r1.26 -r1.27 *** ccompiler.py 2000/06/24 18:10:48 1.26 --- ccompiler.py 2000/06/25 02:08:18 1.27 *************** *** 13,17 **** from distutils.errors import * from distutils.spawn import spawn ! from distutils.util import move_file, mkpath, newer_pairwise, newer_group --- 13,20 ---- from distutils.errors import * from distutils.spawn import spawn ! from distutils.file_util import move_file ! from distutils.dir_util import mkpath ! from distutils.dep_util import newer_pairwise, newer_group ! from distutils.util import split_quoted *************** *** 110,116 **** --- 113,166 ---- self.objects = [] + for key in self.executables.keys(): + self.set_executable(key, self.executables[key]) + # __init__ () + def set_executables (self, **args): + + """Define the executables (and options for them) that will be run + to perform the various stages of compilation. The exact set of + executables that may be specified here depends on the compiler + class (via the 'executables' class attribute), but most will have: + compiler the C/C++ compiler + linker_so linker used to create shared objects and libraries + linker_exe linker used to create binary executables + archiver static library creator + + On platforms with a command-line (Unix, DOS/Windows), each of these + is a string that will be split into executable name and (optional) + list of arguments. (Splitting the string is done similarly to how + Unix shells operate: words are delimited by spaces, but quotes and + backslashes can override this. See + 'distutils.util.split_quoted()'.) + """ + + # Note that some CCompiler implementation classes will define class + # attributes 'cpp', 'cc', etc. with hard-coded executable names; + # this is appropriate when a compiler class is for exactly one + # compiler/OS combination (eg. MSVCCompiler). Other compiler + # classes (UnixCCompiler, in particular) are driven by information + # discovered at run-time, since there are many different ways to do + # basically the same things with Unix C compilers. + + for key in args.keys(): + if not self.executables.has_key(key): + raise ValueError, \ + "unknown executable '%s' for class %s" % \ + (key, self.__class__.__name__) + self.set_executable(key, args[key]) + + # set_executables () + + def set_executable(self, key, value): + if type(value) is StringType: + setattr(self, key, split_quoted(value)) + else: + setattr(self, key, value) + + + def _find_macro (self, name): i = 0 *************** *** 430,433 **** --- 480,485 ---- with 'define_macro()' and 'undefine_macro()'. 'include_dirs' is a list of directory names that will be added to the default list. + + Raises PreprocessError on failure. """ pass *************** *** 441,446 **** extra_preargs=None, extra_postargs=None): ! """Compile one or more C/C++ source files. 'sources' must be a ! list of strings, each one the name of a C/C++ source file. Return a list of object filenames, one per source filename in 'sources'. Depending on the implementation, not all source files will --- 493,501 ---- extra_preargs=None, extra_postargs=None): ! ! """Compile one or more source files. 'sources' must be a list of ! filenames, most likely C/C++ files, but in reality anything that ! can be handled by a particular compiler and compiler class ! (eg. MSVCCompiler can handle resource files in 'sources'). Return a list of object filenames, one per source filename in 'sources'. Depending on the implementation, not all source files will From python-dev@python.org Sun Jun 25 03:09:16 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 19:09:16 -0700 Subject: [Python-checkins] CVS: distutils/distutils sysconfig.py,1.19,1.20 Message-ID: <200006250209.TAA15089@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv15080 Modified Files: sysconfig.py Log Message: Added the 'customize_compiler()' function, which plugs in the essential information about building Python extensions that we discovered in Python's makefile. Currently only needed on Unix, so does nothing on other systems. Index: sysconfig.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/sysconfig.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -r1.19 -r1.20 *** sysconfig.py 2000/06/03 00:44:30 1.19 --- sysconfig.py 2000/06/25 02:09:14 1.20 *************** *** 98,101 **** --- 98,118 ---- + def customize_compiler (compiler): + """Do any platform-specific customization of the CCompiler instance + 'compiler'. Mainly needed on Unix, so we can plug in the information + that varies across Unices and is stored in Python's Makefile. + """ + if compiler.compiler_type == "unix": + cc_cmd = CC + ' ' + OPT + compiler.set_executables( + preprocessor=CC + " -E", # not always! + compiler=cc_cmd, + compiler_so=cc_cmd + ' ' + CCSHARED, + linker_so=LDSHARED, + linker_exe=CC) + + compiler.shared_lib_extension = SO + + def get_config_h_filename(): """Return full pathname of installed config.h file.""" *************** *** 261,264 **** --- 278,284 ---- # here they are. The fact that other Windows compilers don't need # these values is pure luck (hmmm). + + # XXX I think these are now unnecessary... + g['CC'] = "cc" # not gcc? g['RANLIB'] = "ranlib" From python-dev@python.org Sun Jun 25 03:10:49 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 19:10:49 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command build_ext.py,1.45,1.46 Message-ID: <200006250210.TAA15232@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv15224 Modified Files: build_ext.py Log Message: Fixed a few silly bugs in my SWIG support code. (Hey, I said it was experimental and untested.) Call 'customize_compiler()' after getting CCompiler object. Index: build_ext.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build_ext.py,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -r1.45 -r1.46 *** build_ext.py 2000/06/24 01:23:37 1.45 --- build_ext.py 2000/06/25 02:10:46 1.46 *************** *** 13,16 **** --- 13,17 ---- from distutils.core import Command from distutils.errors import * + from distutils.sysconfig import customize_compiler from distutils.dep_util import newer_group from distutils.extension import Extension *************** *** 192,195 **** --- 193,197 ---- dry_run=self.dry_run, force=self.force) + customize_compiler(self.compiler) # And make sure that any compile/link-related options (which might *************** *** 454,465 **** for source in sources: (base, ext) = os.path.splitext(source) ! if ext in self.swig_ext(): new_sources.append(base + ".c") # umm, what if it's C++? ! swig_files.append(source) swig_targets[source] = new_sources[-1] else: new_sources.append(source) ! if not swig_files: return new_sources --- 456,467 ---- for source in sources: (base, ext) = os.path.splitext(source) ! if ext == ".i": # SWIG interface file new_sources.append(base + ".c") # umm, what if it's C++? ! swig_sources.append(source) swig_targets[source] = new_sources[-1] else: new_sources.append(source) ! if not swig_sources: return new_sources From python-dev@python.org Sun Jun 25 03:11:00 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 19:11:00 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command build_clib.py,1.18,1.19 Message-ID: <200006250211.TAA15246@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv15237/command Modified Files: build_clib.py Log Message: Call 'customize_compiler()' after getting CCompiler object. Index: build_clib.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build_clib.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** build_clib.py 2000/06/24 01:23:37 1.18 --- build_clib.py 2000/06/25 02:10:58 1.19 *************** *** 24,27 **** --- 24,28 ---- from distutils.core import Command from distutils.errors import * + from distutils.sysconfig import customize_compiler *************** *** 112,115 **** --- 113,117 ---- dry_run=self.dry_run, force=self.force) + customize_compiler(self.compiler) if self.include_dirs is not None: From python-dev@python.org Sun Jun 25 03:12:16 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 19:12:16 -0700 Subject: [Python-checkins] CVS: distutils/distutils errors.py,1.8,1.9 Message-ID: <200006250212.TAA15337@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv15328 Modified Files: errors.py Log Message: Added PreprocessError and UnknownFileError (both used by CCompiler). Index: errors.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/errors.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** errors.py 2000/05/30 02:02:14 1.8 --- errors.py 2000/06/25 02:12:14 1.9 *************** *** 79,82 **** --- 79,85 ---- """Some compile/link operation failed.""" + class PreprocessError (CCompilerError): + """Failure to preprocess one or more C/C++ files.""" + class CompileError (CCompilerError): """Failure to compile one or more C/C++ source files.""" *************** *** 89,92 **** """Failure to link one or more C/C++ object files into an executable or shared library file.""" - --- 92,96 ---- """Failure to link one or more C/C++ object files into an executable or shared library file.""" + class UnknownFileError (CCompilerError): + """Attempt to process an unknown file type.""" From python-dev@python.org Sun Jun 25 03:23:13 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 19:23:13 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command build_ext.py,1.46,1.47 Message-ID: <200006250223.TAA15670@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv15662 Modified Files: build_ext.py Log Message: Fixed the "pre-link hook" so it actually works, mainly by renaming it to 'msvc_prelink_hack()', adding the parameters that it actually needs, and only calling it for MSVC compiler objects. Generally gave up on the idea of a general "hook" mechanism: deleted the empty 'precompile_hook()'. Index: build_ext.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build_ext.py,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -r1.46 -r1.47 *** build_ext.py 2000/06/25 02:10:46 1.46 --- build_ext.py 2000/06/25 02:23:11 1.47 *************** *** 189,193 **** # Setup the CCompiler object that we'll use to do all the # compiling and linking ! self.compiler = new_compiler (compiler=self.compiler, verbose=self.verbose, dry_run=self.dry_run, --- 189,194 ---- # Setup the CCompiler object that we'll use to do all the # compiling and linking ! self.compiler = new_compiler (#compiler=self.compiler, ! compiler="msvc", verbose=self.verbose, dry_run=self.dry_run, *************** *** 403,411 **** extra_args.extend(string.split(os.environ['CFLAGS'])) - # Run any platform/compiler-specific hooks needed before - # compiling (currently none, but any hypothetical subclasses - # might find it useful to override this). - self.precompile_hook() - objects = self.compiler.compile (sources, output_dir=self.build_temp, --- 404,407 ---- *************** *** 422,428 **** extra_args = ext.extra_link_args ! # Run any platform/compiler-specific hooks needed between ! # compiling and linking (currently needed only on Windows). ! self.prelink_hook() self.compiler.link_shared_object ( --- 418,424 ---- extra_args = ext.extra_link_args ! # Bunch of fixing-up we have to do for Microsoft's linker. ! if self.compiler.compiler_type == 'msvc': ! self.msvc_prelink_hack(sources, ext, extra_args) self.compiler.link_shared_object ( *************** *** 504,514 **** # find_swig () - - # -- Hooks --------------------------------------------------------- ! def precompile_hook (self): ! pass ! def prelink_hook (self): # XXX this is a kludge! Knowledge of specific compilers or --- 500,507 ---- # find_swig () ! # -- Hooks 'n hacks ------------------------------------------------ ! def msvc_prelink_hack (self, sources, ext, extra_args): # XXX this is a kludge! Knowledge of specific compilers or *************** *** 522,552 **** # excuse for committing more platform- and compiler-specific # kludges; they are to be avoided if possible!) - if self.compiler.compiler_type == 'msvc': - def_file = ext.export_symbol_file - if def_file is None: - source_dir = os.path.dirname (sources[0]) - ext_base = (string.split (ext.name, '.'))[-1] - def_file = os.path.join (source_dir, "%s.def" % ext_base) - if not os.path.exists (def_file): - def_file = None ! if def_file is not None: ! extra_args.append ('/DEF:' + def_file) ! else: ! modname = string.split (ext.name, '.')[-1] ! extra_args.append('/export:init%s'%modname) ! # The MSVC linker generates unneeded .lib and .exp files, ! # which cannot be suppressed by any linker switches. So ! # make sure they are generated in the temporary build ! # directory. ! implib_file = os.path.join ( ! self.build_temp, ! self.get_ext_libname (ext.name)) ! extra_args.append ('/IMPLIB:' + implib_file) ! self.mkpath (os.path.dirname (implib_file)) ! # if MSVC ! # prelink_hook () --- 515,544 ---- # excuse for committing more platform- and compiler-specific # kludges; they are to be avoided if possible!) ! def_file = ext.export_symbol_file ! if def_file is None: ! source_dir = os.path.dirname (sources[0]) ! ext_base = (string.split (ext.name, '.'))[-1] ! def_file = os.path.join (source_dir, "%s.def" % ext_base) ! if not os.path.exists (def_file): ! def_file = None ! ! if def_file is not None: ! extra_args.append ('/DEF:' + def_file) ! else: ! modname = string.split (ext.name, '.')[-1] ! extra_args.append('/export:init%s' % modname) ! # The MSVC linker generates unneeded .lib and .exp files, ! # which cannot be suppressed by any linker switches. So ! # make sure they are generated in the temporary build ! # directory. ! implib_file = os.path.join ( ! self.build_temp, ! self.get_ext_libname (ext.name)) ! extra_args.append ('/IMPLIB:' + implib_file) ! self.mkpath (os.path.dirname (implib_file)) ! # msvc_prelink_hack () From python-dev@python.org Sun Jun 25 03:30:17 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 19:30:17 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command build_ext.py,1.47,1.48 Message-ID: <200006250230.TAA16004@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv15996 Modified Files: build_ext.py Log Message: Removed some debugging code that slipped into the last checkin. Ensure that 'extra_args' (whether compile or link args) is never None. Index: build_ext.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build_ext.py,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -r1.47 -r1.48 *** build_ext.py 2000/06/25 02:23:11 1.47 --- build_ext.py 2000/06/25 02:30:15 1.48 *************** *** 189,194 **** # Setup the CCompiler object that we'll use to do all the # compiling and linking ! self.compiler = new_compiler (#compiler=self.compiler, ! compiler="msvc", verbose=self.verbose, dry_run=self.dry_run, --- 189,193 ---- # Setup the CCompiler object that we'll use to do all the # compiling and linking ! self.compiler = new_compiler (compiler=self.compiler, verbose=self.verbose, dry_run=self.dry_run, *************** *** 394,398 **** # any sensible compiler will give precendence to later # command line args. Hence we combine them in order: ! extra_args = ext.extra_compile_args # XXX and if we support CFLAGS, why not CC (compiler --- 393,397 ---- # any sensible compiler will give precendence to later # command line args. Hence we combine them in order: ! extra_args = ext.extra_compile_args or [] # XXX and if we support CFLAGS, why not CC (compiler *************** *** 416,420 **** if ext.extra_objects: objects.extend (ext.extra_objects) ! extra_args = ext.extra_link_args # Bunch of fixing-up we have to do for Microsoft's linker. --- 415,419 ---- if ext.extra_objects: objects.extend (ext.extra_objects) ! extra_args = ext.extra_link_args or [] # Bunch of fixing-up we have to do for Microsoft's linker. From python-dev@python.org Sun Jun 25 03:31:19 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 19:31:19 -0700 Subject: [Python-checkins] CVS: distutils/distutils msvccompiler.py,1.30,1.31 Message-ID: <200006250231.TAA16029@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv16019 Modified Files: msvccompiler.py Log Message: Define the 'executables' class attribute so the CCompiler constructor doesn't blow up. We don't currently use the 'set_executables()' bureaucracy, although it would be nice to do so for consistency with UnixCCompiler. Index: msvccompiler.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/msvccompiler.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -r1.30 -r1.31 *** msvccompiler.py 2000/05/30 02:02:49 1.30 --- msvccompiler.py 2000/06/25 02:31:16 1.31 *************** *** 168,171 **** --- 168,178 ---- compiler_type = 'msvc' + # Just set this so CCompiler's constructor doesn't barf. We currently + # don't use the 'set_executables()' bureaucracy provided by CCompiler, + # as it really isn't necessary for this sort of single-compiler class. + # Would be nice to have a consistent interface with UnixCCompiler, + # though, so it's worth thinking about. + executables = {} + # Private class data (need to distinguish C from C++ source for compiler) _c_extensions = ['.c'] *************** *** 296,300 **** lib_args.extend (extra_postargs) try: ! self.spawn ([self.link] + ld_args) except DistutilsExecError, msg: raise LibError, msg --- 303,307 ---- lib_args.extend (extra_postargs) try: ! self.spawn ([self.lib] + lib_args) except DistutilsExecError, msg: raise LibError, msg From python-dev@python.org Sun Jun 25 03:37:11 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 19:37:11 -0700 Subject: [Python-checkins] CVS: distutils TODO,1.4,1.5 Message-ID: <200006250237.TAA16181@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv16172 Modified Files: TODO Log Message: Updated status of several items. Index: TODO =================================================================== RCS file: /cvsroot/python/distutils/TODO,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** TODO 2000/06/24 01:27:26 1.4 --- TODO 2000/06/25 02:37:09 1.5 *************** *** 13,22 **** build are the right way, so those should be preferred) ! * install_data should to to $prefix by default, not $prefix/share (and should warn if developer doesn't supply any dir component: installing right to $prefix is almost always the wrong thing to do) - DOCS ---- --- 13,22 ---- build are the right way, so those should be preferred) ! * install_data should install to $prefix by default, not $prefix/share (and should warn if developer doesn't supply any dir component: installing right to $prefix is almost always the wrong thing to do) + [done 2000/06/24 GPW] DOCS ---- *************** *** 45,49 **** * review Rene Liebscher's cygwinccompiler.py contribution ! --- 45,50 ---- * review Rene Liebscher's cygwinccompiler.py contribution ! [started and aborted, 2000/06/24 GPW; asked Rene to resubmit patch ! with stylistic changes] *************** *** 69,78 **** --- 70,82 ---- Autoconf-style 'try_cpp', 'search_cpp', 'search_headers' in config commands) + [done, but only UnixCCompiler implements that interface] * fix UnixCCompiler so it doesn't depend on sysconfig (ie. cc must be passed in) + [done 2000/06/24 GPW] * allow user to supply cc (compiler executable) in addition to compiler type + [done 2000/06/24 GPW] * radically simplify CCompiler method signatures: drop most of the *************** *** 82,85 **** --- 86,93 ---- support until this is done, *if* that is it is the right thing to do...] + [update 2000/06/24: I'm cooling to this idea; it turns out the + extra complex interface that's been there all along is useful + for the "config" command, which has to do lots of little + temporary compile and link steps] * Cygwin/Mingw32 support *************** *** 96,100 **** hacking up the example mxDateTime setup script to take advantage of them ! EXTENSION BUILDING --- 104,109 ---- hacking up the example mxDateTime setup script to take advantage of them ! [partly done: at least enough is there to auto-configure mxDateTime; ! need to work on PIL's auto-configuration next] EXTENSION BUILDING *************** *** 102,105 **** --- 111,116 ---- * extension building on AIX + [update 2000/06/24: Rene Liebscher has a patch for this, which + I have asked him to refine] * support for SWIG -- should just have to specify the .i file and *************** *** 108,111 **** --- 119,125 ---- in source distributions, so builders-from-source don't need to have SWIG installed) + [update 2000/06/24: Thomas Heller and I have gone back and forth + on this a couple times: sounds like Thomas has the right idea, + I'll let him work on it] * support for PyFort (lower priority than SWIG!) *************** *** 143,146 **** --- 157,161 ---- * figure out why bdist_rpm doesn't work with RPM 2.x, and make it work if possible + [punt: I don't care anymore, if anyone else does, let them fix it] * make "bdist" take multiple formats (both for convenience From python-dev@python.org Sun Jun 25 03:44:14 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 19:44:14 -0700 Subject: [Python-checkins] CVS: distutils/examples mxdatetime_setup.py,1.4,1.5 Message-ID: <200006250244.TAA16438@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/examples In directory slayer.i.sourceforge.net:/tmp/cvs-serv16430 Modified Files: mxdatetime_setup.py Log Message: Added the config_mxDateTime class to do auto-configuration. Currently works, but has no effect: determines which functions are available, but there's no way to communicate that to the extension-building machinery. Index: mxdatetime_setup.py =================================================================== RCS file: /cvsroot/python/distutils/examples/mxdatetime_setup.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** mxdatetime_setup.py 2000/03/02 01:49:46 1.4 --- mxdatetime_setup.py 2000/06/25 02:44:11 1.5 *************** *** 8,13 **** --- 8,44 ---- __revision__ = "$Id$" + import string from distutils.core import setup + from distutils.command.config import config + class config_mxDateTime (config): + + def run (self): + have = {} + have['strftime'] = self.check_func('strftime', ['time.h']) + have['strptime'] = self.check_func('strptime', ['time.h']) + have['timegm'] = self.check_func('timegm', ['time.h']) + + define = [] + undef = [] + for name in have.keys(): # ('strftime', 'strptime', 'timegm'): + macro_name = 'HAVE_' + string.upper(name) + if have[name]: + define.append((macro_name, None)) + else: + undef.append(macro_name) + + print "macros to define:", define + print "macros to undefine:", undef + + build = self.distribution.reinitialize_command('build') + build.define = define + build.undef = undef + + # run () + + # class config_mxDateTime + + setup (name = "mxDateTime", version = "1.3.0", *************** *** 17,20 **** --- 48,52 ---- url = "http://starship.python.net/~lemburg/mxDateTime.html", + cmdclass = {'config': config_mxDateTime}, packages = ['DateTime', 'DateTime.Examples', 'DateTime.mxDateTime'], package_dir = {'DateTime': ''}, *************** *** 25,31 **** { 'sources': ['mxDateTime/mxDateTime.c'], 'include_dirs': ['mxDateTime'], ! 'macros': [('HAVE_STRFTIME', None), ! ('HAVE_STRPTIME', None), ! ('HAVE_TIMEGM', None)], } )] ) --- 57,61 ---- { 'sources': ['mxDateTime/mxDateTime.c'], 'include_dirs': ['mxDateTime'], ! } )] ) From python-dev@python.org Sun Jun 25 03:45:31 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 19:45:31 -0700 Subject: [Python-checkins] CVS: distutils/examples mxdatetime_setup.py,1.5,1.6 Message-ID: <200006250245.TAA16567@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/examples In directory slayer.i.sourceforge.net:/tmp/cvs-serv16559 Modified Files: mxdatetime_setup.py Log Message: Define the mxDateTime extension using the Extension class, instead of the old-style list-of-tuples-of-etc. hairy mess. Index: mxdatetime_setup.py =================================================================== RCS file: /cvsroot/python/distutils/examples/mxdatetime_setup.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** mxdatetime_setup.py 2000/06/25 02:44:11 1.5 --- mxdatetime_setup.py 2000/06/25 02:45:29 1.6 *************** *** 54,61 **** # XXX user might have to edit the macro definitions here: yuck! # Probably do need to support 'Setup' file or something similar. ! ext_modules = [('DateTime.mxDateTime.mxDateTime', ! { 'sources': ['mxDateTime/mxDateTime.c'], ! 'include_dirs': ['mxDateTime'], ! } ! )] ) --- 54,60 ---- # XXX user might have to edit the macro definitions here: yuck! # Probably do need to support 'Setup' file or something similar. ! ext_modules = [Extension('DateTime.mxDateTime.mxDateTime', ! ['mxDateTime/mxDateTime.c'], ! include_dirs=['mxDateTime']), ! ] ) From python-dev@python.org Sun Jun 25 03:48:10 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 19:48:10 -0700 Subject: [Python-checkins] CVS: distutils/examples mxdatetime_setup.py,1.6,1.7 Message-ID: <200006250248.TAA16615@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/examples In directory slayer.i.sourceforge.net:/tmp/cvs-serv16605 Modified Files: mxdatetime_setup.py Log Message: Delete obsolete comment. Index: mxdatetime_setup.py =================================================================== RCS file: /cvsroot/python/distutils/examples/mxdatetime_setup.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** mxdatetime_setup.py 2000/06/25 02:45:29 1.6 --- mxdatetime_setup.py 2000/06/25 02:48:08 1.7 *************** *** 52,57 **** package_dir = {'DateTime': ''}, - # XXX user might have to edit the macro definitions here: yuck! - # Probably do need to support 'Setup' file or something similar. ext_modules = [Extension('DateTime.mxDateTime.mxDateTime', ['mxDateTime/mxDateTime.c'], --- 52,55 ---- From python-dev@python.org Sun Jun 25 04:14:16 2000 From: python-dev@python.org (Greg Ward) Date: Sat, 24 Jun 2000 20:14:16 -0700 Subject: [Python-checkins] CVS: distutils/doc/dist dist.tex,1.16,1.17 Message-ID: <200006250314.UAA23529@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/doc/dist In directory slayer.i.sourceforge.net:/tmp/cvs-serv23518 Modified Files: dist.tex Log Message: Minor wording tweaks. Kludged the extra-wide table that summarizes the manifest template language (works with LaTeX, but is an *evil* kludge and could well break LaTeX2HTML or similar...). Index: dist.tex =================================================================== RCS file: /cvsroot/python/distutils/doc/dist/dist.tex,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** dist.tex 2000/06/24 01:45:47 1.16 --- dist.tex 2000/06/25 03:14:13 1.17 *************** *** 169,173 **** file, e.g. a shared object (\file{.so}) file for CPython extensions on Unix, a DLL (given the \file{.pyd} extension) for CPython extensions ! on Windows, or a Java class file for JPython extensions. \item[package] a module that contains other modules; typically contained in a directory in the filesystem and distinguished from other --- 169,174 ---- file, e.g. a shared object (\file{.so}) file for CPython extensions on Unix, a DLL (given the \file{.pyd} extension) for CPython extensions ! on Windows, or a Java class file for JPython extensions. (Note that ! currently, the Distutils only handles C/C++ extensions for CPython.) \item[package] a module that contains other modules; typically contained in a directory in the filesystem and distinguished from other *************** *** 218,223 **** do the right thing. As we saw in section~\ref{simple-example} above, the setup script consists mainly of a call to \function{setup()}, and ! all information supplied to the Distutils is supplied as keyword ! arguments to \function{setup()}. Here's a slightly more involved example, which we'll follow for the next --- 219,224 ---- do the right thing. As we saw in section~\ref{simple-example} above, the setup script consists mainly of a call to \function{setup()}, and ! most information supplied to the Distutils by the module developer is ! supplied as keyword arguments to \function{setup()}. Here's a slightly more involved example, which we'll follow for the next *************** *** 719,726 **** {exclude all files under \var{dir} matching any of the listed patterns} \lineii{global-include \var{pat1} \var{pat2} ...} ! {include all files anywhere in the source tree matching any of the listed patterns} \lineii{global-exclude \var{pat1} \var{pat2} ...} ! {exclude all files anywhere in the source tree matching any of the listed patterns} \lineii{prune \var{dir}}{exclude all files under \var{dir}} --- 720,727 ---- {exclude all files under \var{dir} matching any of the listed patterns} \lineii{global-include \var{pat1} \var{pat2} ...} ! {include all files anywhere in the source tree matching\\& any of the listed patterns} \lineii{global-exclude \var{pat1} \var{pat2} ...} ! {exclude all files anywhere in the source tree matching\\& any of the listed patterns} \lineii{prune \var{dir}}{exclude all files under \var{dir}} From python-dev@python.org Sun Jun 25 11:45:00 2000 From: python-dev@python.org (Jeremy Hylton) Date: Sun, 25 Jun 2000 03:45:00 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_exceptions,1.2,1.3 Message-ID: <200006251045.DAA29933@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv29818/output Modified Files: test_exceptions Log Message: update output file to reflect new test of exception object str-ness Index: test_exceptions =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_exceptions,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** test_exceptions 2000/05/25 23:16:54 1.2 --- test_exceptions 2000/06/25 10:44:57 1.3 *************** *** 1,24 **** --- 1,42 ---- test_exceptions 5. Built-in exceptions + spam AttributeError + spam EOFError + spam IOError + spam ImportError + spam IndexError + spam KeyError + spam KeyboardInterrupt (not testable in a script) + spam MemoryError (not safe to test) + spam NameError + spam OverflowError + spam RuntimeError (not used any more?) + spam SyntaxError + spam SystemError (hard to reproduce) + spam SystemExit + spam TypeError + spam ValueError + spam ZeroDivisionError + spam Exception From python-dev@python.org Sun Jun 25 18:49:44 2000 From: python-dev@python.org (Yisroel Gordon) Date: Sun, 25 Jun 2000 13:49:44 EDT Subject: [Python-checkins] (no subject) Message-ID: <20000625174944.21797.qmail@hotmail.com> Please unsubscribe me from this mailing list Thank You ________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com From python-dev@python.org Mon Jun 26 09:28:04 2000 From: python-dev@python.org (Greg Stein) Date: Mon, 26 Jun 2000 01:28:04 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib httplib.py,1.16,1.17 Message-ID: <200006260828.BAA13864@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv13852 Modified Files: httplib.py Log Message: initial commit of a new HTTP library, supporting HTTP/1.1 and persistent connections. Index: httplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/httplib.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** httplib.py 2000/05/19 23:06:45 1.16 --- httplib.py 2000/06/26 08:28:01 1.17 *************** *** 1,34 **** ! """HTTP client class ! ! See the following URL for a description of the HTTP/1.0 protocol: ! http://www.w3.org/hypertext/WWW/Protocols/ ! (I actually implemented it from a much earlier draft.) ! ! Example: ! ! >>> from httplib import HTTP ! >>> h = HTTP('www.python.org') [...1008 lines suppressed...] --- 759,777 ---- print print h.getfile().read() ! ! if hasattr(socket, 'ssl'): ! host = 'www.c2.net' ! hs = HTTPS() ! hs.connect(host) ! hs.putrequest('GET', selector) ! hs.endheaders() ! status, reason, headers = hs.getreply() ! print 'status =', status ! print 'reason =', reason ! print ! if headers: ! for header in headers.headers: print string.strip(header) ! print ! print hs.getfile().read() From python-dev@python.org Mon Jun 26 15:37:56 2000 From: python-dev@python.org (Guido van Rossum) Date: Mon, 26 Jun 2000 07:37:56 -0700 Subject: [Python-checkins] CVS: python/dist/src/Include pythonrun.h,2.27,2.28 Message-ID: <200006261437.HAA22462@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Include In directory slayer.i.sourceforge.net:/tmp/cvs-serv22452 Modified Files: pythonrun.h Log Message: Fredrik Lundh: get rid of warning in pythonrun.c Index: pythonrun.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pythonrun.h,v retrieving revision 2.27 retrieving revision 2.28 diff -C2 -r2.27 -r2.28 *** pythonrun.h 2000/05/25 23:05:36 2.27 --- pythonrun.h 2000/06/26 14:37:53 2.28 *************** *** 95,98 **** --- 95,99 ---- /* Various internal finalizers */ DL_IMPORT(void) fini_exceptions Py_PROTO((void)); + DL_IMPORT(void) _PyImport_Fini Py_PROTO((void)); DL_IMPORT(void) PyMethod_Fini Py_PROTO((void)); DL_IMPORT(void) PyFrame_Fini Py_PROTO((void)); From python-dev@python.org Mon Jun 26 18:31:51 2000 From: python-dev@python.org (Greg Stein) Date: Mon, 26 Jun 2000 10:31:51 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib imputil.py,1.12,1.13 Message-ID: <200006261731.KAA20302@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv20271 Modified Files: imputil.py Log Message: now that imputil is in the main Python repository, clean up the header Index: imputil.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/imputil.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** imputil.py 2000/02/19 13:36:23 1.12 --- imputil.py 2000/06/26 17:31:49 1.13 *************** *** 1,20 **** # ! # imputil.py # ! # Written by Greg Stein. Public Domain. ! # No Copyright, no Rights Reserved, and no Warranties. ! # ! # Utilities to help out with custom import mechanisms. ! # ! # Additional modifications were contribed by Marc-Andre Lemburg and ! # Gordon McMillan. ! # ! # This module is maintained by Greg and is available at: ! # http://www.lyra.org/greg/python/ ! # ! # Since this isn't in the Python distribution yet, we'll use the CVS ID ! # for tracking: ! # $Id$ ! # # note: avoid importing non-builtin modules --- 1,7 ---- # ! # imputil.py: import utilities # ! ! ### docco needed here and in Docs/ ... # note: avoid importing non-builtin modules From python-dev@python.org Tue Jun 27 01:37:27 2000 From: python-dev@python.org (A.M. Kuchling) Date: Mon, 26 Jun 2000 17:37:27 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_pyexpat.py,1.2,1.3 Message-ID: <200006270037.RAA25539@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv25501 Modified Files: test_pyexpat.py Log Message: Change pyexpat test suite to exercise the .returns_unicode attribute, parsing the sample data once with 8-bit strings and once with Unicode. Index: test_pyexpat.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pyexpat.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** test_pyexpat.py 2000/04/02 05:15:38 1.2 --- test_pyexpat.py 2000/06/27 00:37:25 1.3 *************** *** 11,18 **** class Outputter: def StartElementHandler(self, name, attrs): ! print 'Start element:\n\t', name, attrs def EndElementHandler(self, name): ! print 'End element:\n\t', name def CharacterDataHandler(self, data): --- 11,18 ---- class Outputter: def StartElementHandler(self, name, attrs): ! print 'Start element:\n\t', repr(name), attrs def EndElementHandler(self, name): ! print 'End element:\n\t', repr(name) def CharacterDataHandler(self, data): *************** *** 23,33 **** def ProcessingInstructionHandler(self, target, data): ! print 'PI:\n\t', target, data def StartNamespaceDeclHandler(self, prefix, uri): ! print 'NS decl:\n\t', prefix, uri def EndNamespaceDeclHandler(self, prefix): ! print 'End of NS decl:\n\t', prefix def StartCdataSectionHandler(self): --- 23,33 ---- def ProcessingInstructionHandler(self, target, data): ! print 'PI:\n\t', repr(target), repr(data) def StartNamespaceDeclHandler(self, prefix, uri): ! print 'NS decl:\n\t', repr(prefix), repr(uri) def EndNamespaceDeclHandler(self, prefix): ! print 'End of NS decl:\n\t', repr(prefix) def StartCdataSectionHandler(self): *************** *** 52,57 **** return 1 ! def ExternalEntityRefHandler(self, context, base, sysId, pubId): ! print 'External entity ref:', context, base, sysId, pubId return 1 --- 52,58 ---- return 1 ! def ExternalEntityRefHandler(self, *args): ! context, base, sysId, pubId = args ! print 'External entity ref:', args return 1 *************** *** 65,69 **** out = Outputter() parser = pyexpat.ParserCreate(namespace_separator='!') ! for name in ['StartElementHandler', 'EndElementHandler', 'CharacterDataHandler', 'ProcessingInstructionHandler', 'UnparsedEntityDeclHandler', 'NotationDeclHandler', --- 66,77 ---- out = Outputter() parser = pyexpat.ParserCreate(namespace_separator='!') ! ! # Test getting/setting returns_unicode ! parser.returns_unicode = 0 ; assert parser.returns_unicode == 0 ! parser.returns_unicode = 1 ; assert parser.returns_unicode == 1 ! parser.returns_unicode = 2 ; assert parser.returns_unicode == 1 ! parser.returns_unicode = 0 ; assert parser.returns_unicode == 0 ! ! HANDLER_NAMES = ['StartElementHandler', 'EndElementHandler', 'CharacterDataHandler', 'ProcessingInstructionHandler', 'UnparsedEntityDeclHandler', 'NotationDeclHandler', *************** *** 74,78 **** #'NotStandaloneHandler', 'ExternalEntityRefHandler' ! ]: setattr(parser, name, getattr(out, name) ) --- 82,87 ---- #'NotStandaloneHandler', 'ExternalEntityRefHandler' ! ] ! for name in HANDLER_NAMES: setattr(parser, name, getattr(out, name) ) *************** *** 89,93 **** ]> ! Contents of subelements --- 98,102 ---- ]> ! Contents of subelements *************** *** 98,103 **** --- 107,144 ---- """ + # Produce UTF-8 output + parser.returns_unicode = 0 try: parser.Parse(data, 1) + except pyexpat.error: + print '** Error', parser.ErrorCode, pyexpat.ErrorString( parser.ErrorCode) + print '** Line', parser.ErrorLineNumber + print '** Column', parser.ErrorColumnNumber + print '** Byte', parser.ErrorByteIndex + + # Try the parse again, this time producing Unicode output + parser = pyexpat.ParserCreate(namespace_separator='!') + parser.returns_unicode = 1 + + for name in HANDLER_NAMES: + setattr(parser, name, getattr(out, name) ) + try: + parser.Parse(data, 1) + except pyexpat.error: + print '** Error', parser.ErrorCode, pyexpat.ErrorString( parser.ErrorCode) + print '** Line', parser.ErrorLineNumber + print '** Column', parser.ErrorColumnNumber + print '** Byte', parser.ErrorByteIndex + + # Try parsing a file + parser = pyexpat.ParserCreate(namespace_separator='!') + parser.returns_unicode = 1 + + for name in HANDLER_NAMES: + setattr(parser, name, getattr(out, name) ) + import StringIO + file = StringIO.StringIO(data) + try: + parser.ParseFile(file) except pyexpat.error: print '** Error', parser.ErrorCode, pyexpat.ErrorString( parser.ErrorCode) From python-dev@python.org Tue Jun 27 01:53:14 2000 From: python-dev@python.org (A.M. Kuchling) Date: Mon, 26 Jun 2000 17:53:14 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/curses textpad.py,1.1,1.2 Message-ID: <200006270053.RAA26341@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/curses In directory slayer.i.sourceforge.net:/tmp/cvs-serv26276 Modified Files: textpad.py Log Message: Sync to ESR's current version Index: textpad.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/curses/textpad.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** textpad.py 2000/06/26 23:55:42 1.1 --- textpad.py 2000/06/27 00:53:12 1.2 *************** *** 16,20 **** win.addch(lry, ulx, curses.ACS_LLCORNER) ! class textbox: """Editing widget using the interior of a window object. Supports the following Emacs-like key bindings: --- 16,20 ---- win.addch(lry, ulx, curses.ACS_LLCORNER) ! class Textbox: """Editing widget using the interior of a window object. Supports the following Emacs-like key bindings: *************** *** 26,29 **** --- 26,30 ---- Ctrl-F Cursor right, wrapping to next line when appropriate. Ctrl-G Terminate, returning the window contents. + Ctrl-H Delete character backward. Ctrl-J Terminate if the window is 1 line, otherwise insert newline. Ctrl-K If line is blank, delete it, otherwise clear to end of line. *************** *** 37,40 **** --- 38,42 ---- KEY_LEFT = Ctrl-B, KEY_RIGHT = Ctrl-F, KEY_UP = Ctrl-P, KEY_DOWN = Ctrl-N + KEY_BACKSPACE = Ctrl-h """ def __init__(self, win): *************** *** 44,62 **** self.maxx = self.maxx - 1 self.stripspaces = 1 win.keypad(1) def firstblank(self, y): "Go to the location of the first blank on the given line." ! (oldy, oldx) = self.win.getyx() ! self.win.move(y, self.maxx-1) ! last = self.maxx-1 while 1: - if last == 0: - break if ascii.ascii(self.win.inch(y, last)) != ascii.SP: last = last + 1 break last = last - 1 - self.win.move(oldy, oldx) return last --- 46,62 ---- self.maxx = self.maxx - 1 self.stripspaces = 1 + self.lastcmd = None win.keypad(1) def firstblank(self, y): "Go to the location of the first blank on the given line." ! last = self.maxx while 1: if ascii.ascii(self.win.inch(y, last)) != ascii.SP: last = last + 1 break + elif last == 0: + break last = last - 1 return last *************** *** 64,67 **** --- 64,68 ---- "Process a single editing command." (y, x) = self.win.getyx() + self.lastcmd = ch if ascii.isprint(ch): if y < self.maxy or x < self.maxx: *************** *** 73,79 **** except ERR: pass ! elif ch == ascii.SOH: # Ctrl-a self.win.move(y, 0) ! elif ch in (ascii.STX, curses.KEY_LEFT): # Ctrl-b if x > 0: self.win.move(y, x-1) --- 74,80 ---- except ERR: pass ! elif ch == ascii.SOH: # ^a self.win.move(y, 0) ! elif ch in (ascii.STX,curses.KEY_LEFT, ascii.BS,curses.KEY_BACKSPACE): if x > 0: self.win.move(y, x-1) *************** *** 84,124 **** else: self.win.move(y-1, self.maxx) ! elif ch == ascii.EOT: # Ctrl-d self.win.delch() ! elif ch == ascii.ENQ: # Ctrl-e if self.stripspaces: self.win.move(y, self.firstblank(y, maxx)) else: self.win.move(y, self.maxx) ! elif ch in (ascii.ACK, curses.KEY_RIGHT): # Ctrl-f if x < self.maxx: self.win.move(y, x+1) ! elif y == self.maxx: pass else: self.win.move(y+1, 0) ! elif ch == ascii.BEL: # Ctrl-g return 0 ! elif ch == ascii.NL: # Ctrl-j if self.maxy == 0: return 0 elif y < self.maxy: self.win.move(y+1, 0) ! elif ch == ascii.VT: # Ctrl-k if x == 0 and self.firstblank(y) == 0: self.win.deleteln() else: self.win.clrtoeol() ! elif ch == ascii.FF: # Ctrl-l self.win.refresh() ! elif ch in (ascii.SO, curses.KEY_DOWN): # Ctrl-n if y < self.maxy: self.win.move(y+1, x) ! elif ch == ascii.SI: # Ctrl-o self.win.insertln() ! elif ch in (ascii.DLE, curses.KEY_UP): # Ctrl-p if y > 0: self.win.move(y-1, x) - self.win.refresh() return 1 --- 85,126 ---- else: self.win.move(y-1, self.maxx) ! if ch in (ascii.BS, curses.KEY_BACKSPACE): ! self.win.delch() ! elif ch == ascii.EOT: # ^d self.win.delch() ! elif ch == ascii.ENQ: # ^e if self.stripspaces: self.win.move(y, self.firstblank(y, maxx)) else: self.win.move(y, self.maxx) ! elif ch in (ascii.ACK, curses.KEY_RIGHT): # ^f if x < self.maxx: self.win.move(y, x+1) ! elif y == self.maxy: pass else: self.win.move(y+1, 0) ! elif ch == ascii.BEL: # ^g return 0 ! elif ch == ascii.NL: # ^j if self.maxy == 0: return 0 elif y < self.maxy: self.win.move(y+1, 0) ! elif ch == ascii.VT: # ^k if x == 0 and self.firstblank(y) == 0: self.win.deleteln() else: self.win.clrtoeol() ! elif ch == ascii.FF: # ^l self.win.refresh() ! elif ch in (ascii.SO, curses.KEY_DOWN): # ^n if y < self.maxy: self.win.move(y+1, x) ! elif ch == ascii.SI: # ^o self.win.insertln() ! elif ch in (ascii.DLE, curses.KEY_UP): # ^p if y > 0: self.win.move(y-1, x) return 1 *************** *** 129,132 **** --- 131,135 ---- self.win.move(y, 0) stop = self.firstblank(y) + #sys.stderr.write("y=%d, firstblank(y)=%d\n" % (y, stop)) if stop == 0 and self.stripspaces: continue *************** *** 145,150 **** --- 148,156 ---- if validate: ch = validate(ch) + if not ch: + continue if not self.do_command(ch): break + self.win.refresh() return self.gather() *************** *** 154,158 **** rectangle(stdscr, 14, 19, 19, 29) stdscr.refresh() ! return textbox(win).edit() str = curses.wrapper(test_editbox) --- 160,164 ---- rectangle(stdscr, 14, 19, 19, 29) stdscr.refresh() ! return Textbox(win).edit() str = curses.wrapper(test_editbox) From python-dev@python.org Tue Jun 27 03:11:05 2000 From: python-dev@python.org (Greg Ward) Date: Mon, 26 Jun 2000 19:11:05 -0700 Subject: [Python-checkins] CVS: distutils/examples pil_setup.py,1.11,1.12 Message-ID: <200006270211.TAA09901@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/examples In directory slayer.i.sourceforge.net:/tmp/cvs-serv9891 Modified Files: pil_setup.py Log Message: Added a config command to determine if Tcl/Tk, libjpeg, and/or zlib are present. Doesn't actually do anything with that knowledge, since the base config command doesn't have any infrastructure for doing that. Still, it's a start. Index: pil_setup.py =================================================================== RCS file: /cvsroot/python/distutils/examples/pil_setup.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** pil_setup.py 2000/03/31 04:47:05 1.11 --- pil_setup.py 2000/06/27 02:11:03 1.12 *************** *** 11,14 **** --- 11,15 ---- from distutils.core import setup from distutils.ccompiler import new_compiler + from distutils.command.config import config from glob import glob *************** *** 57,60 **** --- 58,109 ---- + class config_Imaging (config): + + user_options = config.user_options + [ + ('tcltk-include-dirs=', None, + "directories to search for Tcl/Tk header files"), + ('tcltk-library-dirs=', None, + "directories to search for Tcl/Tk library files"), + ('tcl-version', None, + "version of Tcl library to look for"), + ('tk-version', None, + "version of Tk library to look for"), + ('zlib-include-dirs=', None, + "directories to search for zlib header file"), + ('zlib-library-dirs=', None, + "directories to search for zlib library file"), + ] + + def initialize_options (self): + config.initialize_options(self) + self.tcltk_include_dirs = None + self.tcltk_library_dirs = None + self.tcl_version = None + self.tk_version = None + + self.zlib_include_dirs = None + self.zlib_library_dirs = None + + # No 'finalize_options()' method -- none of our options have default + # values (other than None, that is). + + def run (self): + + have_tcl = self.check_lib("tcl" + (self.tcl_version or ""), + self.tcltk_library_dirs, + ["tcl.h"], self.tcltk_include_dirs) + + have_tk = self.check_lib("tk" + (self.tk_version or ""), + self.tcltk_library_dirs, + ["tk.h"], self.tcltk_include_dirs) + + have_zlib = self.check_lib("z", self.zlib_library_dirs, + ["zlib.h"], self.zlib_include_dirs) + + + print "have tcl? %d have tk? %d have zlib? %d" % \ + (have_tcl, have_tk, have_zlib) + + # ------------------------------------------------------------------------ # You should't have to change anything below this point! *************** *** 94,97 **** --- 143,148 ---- # top-level module in the distribution), but Distutils as yet has no # facilities for installing scripts. + + cmdclass = {'config': config_Imaging}, libraries = [(lib_name, From python-dev@python.org Tue Jun 27 00:54:05 2000 From: python-dev@python.org (A.M. Kuchling) Date: Mon, 26 Jun 2000 16:54:05 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/curses __init__.py,1.1,1.2 Message-ID: <200006262354.QAA17041@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/curses In directory slayer.i.sourceforge.net:/tmp/cvs-serv16914 Modified Files: __init__.py Log Message: Add wrapper for initscr() to copy the ACS_ and LINES,COLS bindings Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/curses/__init__.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** __init__.py 2000/06/10 23:06:53 1.1 --- __init__.py 2000/06/26 23:54:03 1.2 *************** *** 16,18 **** --- 16,34 ---- from curses.wrapper import wrapper + # Some constants, most notably the ACS_* ones, are only added to the C + # _curses module's dictionary after initscr() is called. (Some + # versions of SGI's curses don't define values for those constants + # until initscr() has been called.) This wrapper function calls the + # underlying C initscr(), and then copies the constants from the + # _curses module to the curses package's dictionary. Don't do 'from + # curses import *' if you'll be needing the ACS_* constants. + + def initscr(): + import _curses, curses + stdscr = _curses.initscr() + for key, value in _curses.__dict__.items(): + if key[0:4] == 'ACS_' or key in ('LINES', 'COLS'): + setattr(curses, key, value) + + return stdscr From python-dev@python.org Tue Jun 27 00:55:44 2000 From: python-dev@python.org (A.M. Kuchling) Date: Mon, 26 Jun 2000 16:55:44 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/curses ascii.py,NONE,1.1 textpad.py,NONE,1.1 Message-ID: <200006262355.QAA17089@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/curses In directory slayer.i.sourceforge.net:/tmp/cvs-serv17079 Added Files: ascii.py textpad.py Log Message: Added two modules for ASCII characters and a simple editing form (ESR) --- NEW FILE --- # # ascii.py -- constants and memembership tests for ASCII characters # NUL = 0x00 # ^@ SOH = 0x01 # ^A STX = 0x02 # ^B ETX = 0x03 # ^C EOT = 0x04 # ^D ENQ = 0x05 # ^E ACK = 0x06 # ^F BEL = 0x07 # ^G BS = 0x08 # ^H TAB = 0x09 # ^I HT = 0x09 # ^I LF = 0x0a # ^J NL = 0x0a # ^J VT = 0x0b # ^K FF = 0x0c # ^L CR = 0x0d # ^M SO = 0x0e # ^N SI = 0x0f # ^O DLE = 0x10 # ^P DC1 = 0x11 # ^Q DC2 = 0x12 # ^R DC3 = 0x13 # ^S DC4 = 0x14 # ^T NAK = 0x15 # ^U SYN = 0x16 # ^V ETB = 0x17 # ^W CAN = 0x18 # ^X EM = 0x19 # ^Y SUB = 0x1a # ^Z ESC = 0x1b # ^[ FS = 0x1c # ^\ GS = 0x1d # ^] RS = 0x1e # ^^ US = 0x1f # ^_ SP = 0x20 # space DEL = 0x7f # delete controlnames = [ "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", "BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI", "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US", "SP" ] def _ctoi(c): if type(c) == type(""): return ord(c) else: return c def isalnum(c): return isalpha(c) or isdigit(c) def isalpha(c): return isupper(c) or islower(c) def isascii(c): return _ctoi(c) <= 127 # ? def isblank(c): return _ctoi(c) in (8,32) def iscntrl(c): return _ctoi(c) <= 31 def isdigit(c): return _ctoi(c) >= 48 and _ctoi(c) <= 57 def isgraph(c): return _ctoi(c) >= 33 and _ctoi(c) <= 126 def islower(c): return _ctoi(c) >= 97 and _ctoi(c) <= 122 def isprint(c): return _ctoi(c) >= 32 and _ctoi(c) <= 126 def ispunct(c): return _ctoi(c) != 32 and not isalnum(c) def isspace(c): return _ctoi(c) in (12, 10, 13, 9, 11) def isupper(c): return _ctoi(c) >= 65 and _ctoi(c) <= 90 def isxdigit(c): return isdigit(c) or \ (_ctoi(c) >= 65 and _ctoi(c) <= 70) or (_ctoi(c) >= 97 and _ctoi(c) <= 102) def isctrl(c): return _ctoi(c) < 32 def ismeta(c): return _ctoi(c) > 127 def ascii(c): if type(c) == type(""): return chr(_ctoi(c) & 0x7f) else: return _ctoi(c) & 0x7f def ctrl(c): if type(c) == type(""): return chr(_ctoi(c) & 0x1f) else: return _ctoi(c) & 0x1f def alt(c): if type(c) == type(""): return chr(_ctoi(c) | 0x80) else: return _ctoi(c) | 0x80 def unctrl(c): bits = _ctoi(c) if bits == 0x7f: rep = "^?" elif bits & 0x20: rep = chr((bits & 0x7f) | 0x20) else: rep = "^" + chr(((bits & 0x7f) | 0x20) + 0x20) if bits & 0x80: return "!" + rep return rep --- NEW FILE --- """curses.textpad """ import sys, curses, ascii def rectangle(win, uly, ulx, lry, lrx): "Draw a rectangle." win.vline(uly+1, ulx, curses.ACS_VLINE, lry - uly - 1) win.hline(uly, ulx+1, curses.ACS_HLINE, lrx - ulx - 1) win.hline(lry, ulx+1, curses.ACS_HLINE, lrx - ulx - 1) win.vline(uly+1, lrx, curses.ACS_VLINE, lry - uly - 1) win.addch(uly, ulx, curses.ACS_ULCORNER) win.addch(uly, lrx, curses.ACS_URCORNER) win.addch(lry, lrx, curses.ACS_LRCORNER) win.addch(lry, ulx, curses.ACS_LLCORNER) class textbox: """Editing widget using the interior of a window object. Supports the following Emacs-like key bindings: Ctrl-A Go to left edge of window. Ctrl-B Cursor left, wrapping to previous line if appropriate. Ctrl-D Delete character under cursor. Ctrl-E Go to right edge (nospaces off) or end of line (nospaces on). Ctrl-F Cursor right, wrapping to next line when appropriate. Ctrl-G Terminate, returning the window contents. Ctrl-J Terminate if the window is 1 line, otherwise insert newline. Ctrl-K If line is blank, delete it, otherwise clear to end of line. Ctrl-L Refresh screen Ctrl-N Cursor down; move down one line. Ctrl-O Insert a blank line at cursor location. Ctrl-P Cursor up; move up one line. Move operations do nothing if the cursor is at an edge where the movement is not possible. The following synonyms are supported where possible: KEY_LEFT = Ctrl-B, KEY_RIGHT = Ctrl-F, KEY_UP = Ctrl-P, KEY_DOWN = Ctrl-N """ def __init__(self, win): self.win = win (self.maxy, self.maxx) = win.getmaxyx() self.maxy = self.maxy - 1 self.maxx = self.maxx - 1 self.stripspaces = 1 win.keypad(1) def firstblank(self, y): "Go to the location of the first blank on the given line." (oldy, oldx) = self.win.getyx() self.win.move(y, self.maxx-1) last = self.maxx-1 while 1: if last == 0: break if ascii.ascii(self.win.inch(y, last)) != ascii.SP: last = last + 1 break last = last - 1 self.win.move(oldy, oldx) return last def do_command(self, ch): "Process a single editing command." (y, x) = self.win.getyx() if ascii.isprint(ch): if y < self.maxy or x < self.maxx: # The try-catch ignores the error we trigger from some curses # versions by trying to write into the lowest-rightmost spot # in the self.window. try: self.win.addch(ch) except ERR: pass elif ch == ascii.SOH: # Ctrl-a self.win.move(y, 0) elif ch in (ascii.STX, curses.KEY_LEFT): # Ctrl-b if x > 0: self.win.move(y, x-1) elif y == 0: pass elif self.stripspaces: self.win.move(y-1, self.firstblank(y-1)) else: self.win.move(y-1, self.maxx) elif ch == ascii.EOT: # Ctrl-d self.win.delch() elif ch == ascii.ENQ: # Ctrl-e if self.stripspaces: self.win.move(y, self.firstblank(y, maxx)) else: self.win.move(y, self.maxx) elif ch in (ascii.ACK, curses.KEY_RIGHT): # Ctrl-f if x < self.maxx: self.win.move(y, x+1) elif y == self.maxx: pass else: self.win.move(y+1, 0) elif ch == ascii.BEL: # Ctrl-g return 0 elif ch == ascii.NL: # Ctrl-j if self.maxy == 0: return 0 elif y < self.maxy: self.win.move(y+1, 0) elif ch == ascii.VT: # Ctrl-k if x == 0 and self.firstblank(y) == 0: self.win.deleteln() else: self.win.clrtoeol() elif ch == ascii.FF: # Ctrl-l self.win.refresh() elif ch in (ascii.SO, curses.KEY_DOWN): # Ctrl-n if y < self.maxy: self.win.move(y+1, x) elif ch == ascii.SI: # Ctrl-o self.win.insertln() elif ch in (ascii.DLE, curses.KEY_UP): # Ctrl-p if y > 0: self.win.move(y-1, x) self.win.refresh() return 1 def gather(self): "Collect and return the contents of the window." result = "" for y in range(self.maxy+1): self.win.move(y, 0) stop = self.firstblank(y) if stop == 0 and self.stripspaces: continue for x in range(self.maxx+1): if self.stripspaces and x == stop: break result = result + chr(ascii.ascii(self.win.inch(y, x))) if self.maxy > 0: result = result + "\n" return result def edit(self, validate=None): "Edit in the widget window and collect the results." while 1: ch = self.win.getch() if validate: ch = validate(ch) if not self.do_command(ch): break return self.gather() if __name__ == '__main__': def test_editbox(stdscr): win = curses.newwin(4, 9, 15, 20) rectangle(stdscr, 14, 19, 19, 29) stdscr.refresh() return textbox(win).edit() str = curses.wrapper(test_editbox) print str From python-dev@python.org Tue Jun 27 00:59:27 2000 From: python-dev@python.org (A.M. Kuchling) Date: Mon, 26 Jun 2000 16:59:27 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libascii.tex,NONE,1.1 Message-ID: <200006262359.QAA17285@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv17139 Added Files: libascii.tex Log Message: Dcoumentation for ascii.py. I've changed two references from ascii to curses.ascii. --- NEW FILE --- \section{\module{curses.ascii} --- Constants and set-membership functions for ASCII characters.} \declaremodule{standard}{curses.ascii} \modulesynopsis{Constants and set-membership functions for ASCII characters.} \moduleauthor{Eric S. Raymond}{esr@thyrsus.com} \sectionauthor{Eric S. Raymond}{esr@thyrsus.com} \versionadded{1.6} The \module{curses.ascii} module supplies name constants for ASCII characters and functions to test membership in various ASCII character classes. The constants supplied are names for control characters as follows: NUL, SOH, STX, ETX, EOT, ENQ, ACK, BEL, BS, TAB, HT, LF, NL, VT, FF, CR, SO, SI, DLE, DC1, DC2, DC3, DC4, NAK, SYN, ETB, CAN, EM, SUB, ESC, FS, GS, RS, US, SP, DEL. NL and LF are synonyms; so are HT and TAB. The module also supplies the following functions, patterned on those in the standard C library: \begin{funcdesc}{isalnum}{c} Checks for an ASCII alphanumeric character; it is equivalent to isalpha(c) or isdigit(c)) \end{funcdesc} \begin{funcdesc}{isalpha}{c} Checks for an ASCII alphabetic character; it is equivalent to isupper(c) or islower(c)) \end{funcdesc} \begin{funcdesc}{isascii}{c} Checks for a character value that fits in the 7-bit ASCII set. \end{funcdesc} \begin{funcdesc}{isblank}{c} Checks for an ASCII alphanumeric character; it is equivalent to isalpha(c) or isdigit(c)) \end{funcdesc} \begin{funcdesc}{iscntrl}{c} Checks for an ASCII control character (range 0x00 to 0x1f). \end{funcdesc} \begin{funcdesc}{isdigit}{c} Checks for an ASCII decimal digit, 0 through 9. \end{funcdesc} \begin{funcdesc}{isgraph}{c} Checks for ASCII any printable character except space. \end{funcdesc} \begin{funcdesc}{islower}{c} Checks for an ASCII lower-case character. \end{funcdesc} \begin{funcdesc}{isprint}{c} Checks for any ASCII printable character including space. \end{funcdesc} \begin{funcdesc}{ispunct}{c} Checks for any printable ASCII character which is not a space or an alphanumeric character. \end{funcdesc} \begin{funcdesc}{isspace}{c} Checks for ASCII white-space characters; space, tab, line feed, carriage return, form feed, horizontal tab, vertical tab. \end{funcdesc} \begin{funcdesc}{isupper}{c} Checks for an ASCII uppercase letter. \end{funcdesc} \begin{funcdesc}{isxdigit}{c} Checks for an ASCII hexadecimal digit, i.e. one of 0123456789abcdefABCDEF. \end{funcdesc} \begin{funcdesc}{isctrl}{c} Checks for an ASCII control character, bit values 0 to 31. \end{funcdesc} \begin{funcdesc}{ismeta}{c} Checks for a (non-ASCII) character, bit values 0x80 and above. \end{funcdesc} These functions accept either integers or strings; when the argument is a string, it is first converted using the built-in function ord(). Note that all these functions check ordinal bit values derived from the first character of the string you pass in; they do not actually know anything about the host machine's character encoding. For functions that know about the character encoding (and handle internationalization properly) see the string module. The following two functions take either a single-character string or integer byte value; they return a value of the same type. \begin{funcdesc}{ascii}{c} Return the ASCII value corresponding to the low 7 bits of c. \end{funcdesc} \begin{funcdesc}{ctrl}{c} Return the control character corresponding to the given character (the character bit value is logical-anded with 0x1f). \end{funcdesc} \begin{funcdesc}{alt}{c} Return the 8-bit character corresponding to the given ASCII character (the character bit value is logical-ored with 0x80). \end{funcdesc} The following function takes either a single-character string or integer byte value; it returns a string. \begin{funcdesc}{unctrl}{c} Return a string representation of the ASCII character c. If c is printable, this string is the character itself. If the character is a control character (0x00-0x1f) the string consists of a caret (^) followed by the corresponding uppercase letter. If the character is an ASCII delete (0x7f) the string is "^?". If the character has its meta bit (0x80) set, the meta bit is stripped, the preceding rules applied, and "!" prepended to the result. \end{funcdesc} Finally, the module supplies a 33-element string array called controlnames that contains the ASCII mnemonics for the thirty-two ASCII control characters from 0 (NUL) to 0x1f (US), in order, plus the mnemonic "SP" for space. From python-dev@python.org Tue Jun 27 01:33:33 2000 From: python-dev@python.org (A.M. Kuchling) Date: Mon, 26 Jun 2000 17:33:33 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules pyexpat.c,2.4,2.5 Message-ID: <200006270033.RAA25415@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv25294 Modified Files: pyexpat.c Log Message: Added support for passing Unicode strings to Expat handlers by default. This version still includes #ifdef hackery to compile with 1.5.2. Index: pyexpat.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/pyexpat.c,v retrieving revision 2.4 retrieving revision 2.5 diff -C2 -r2.4 -r2.5 *** pyexpat.c 2000/05/03 23:44:33 2.4 --- pyexpat.c 2000/06/27 00:33:30 2.5 *************** *** 39,57 **** enum HandlerTypes{ ! StartElement, ! EndElement, ! ProcessingInstruction, ! CharacterData, ! UnparsedEntityDecl, ! NotationDecl, ! StartNamespaceDecl, ! EndNamespaceDecl, [...1633 lines suppressed...] ! my_StartCdataSectionHandler}, {"EndCdataSectionHandler", ! pyxml_SetEndCdataSection, ! my_EndCdataSectionHandler}, {"DefaultHandler", ! (xmlhandlersetter)XML_SetDefaultHandler, ! my_DefaultHandler}, {"DefaultHandlerExpand", ! (xmlhandlersetter)XML_SetDefaultHandlerExpand, ! my_DefaultHandlerExpandHandler}, {"NotStandaloneHandler", ! (xmlhandlersetter)XML_SetNotStandaloneHandler, ! my_NotStandaloneHandler}, {"ExternalEntityRefHandler", ! (xmlhandlersetter)XML_SetExternalEntityRefHandler, ! my_ExternalEntityRefHandler }, {NULL, NULL, NULL } /* sentinel */ }; From python-dev@python.org Tue Jun 27 01:37:27 2000 From: python-dev@python.org (A.M. Kuchling) Date: Mon, 26 Jun 2000 17:37:27 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_pyexpat,1.1,1.2 Message-ID: <200006270037.RAA25543@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv25501/output Modified Files: test_pyexpat Log Message: Change pyexpat test suite to exercise the .returns_unicode attribute, parsing the sample data once with 8-bit strings and once with Unicode. Index: test_pyexpat =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_pyexpat,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** test_pyexpat 2000/03/31 15:45:20 1.1 --- test_pyexpat 2000/06/27 00:37:25 1.2 *************** *** 1,5 **** test_pyexpat PI: ! xml-stylesheet href="stylesheet.css" Comment: ' comment data ' --- 1,5 ---- test_pyexpat PI: ! 'xml-stylesheet' 'href="stylesheet.css"' Comment: ' comment data ' *************** *** 8,24 **** ('unparsed_entity', None, 'entity.file', None, 'notation') Start element: ! root {} NS decl: ! myns http://www.python.org/namespace Start element: ! http://www.python.org/namespace!subelement {} Character data: 'Contents of subelements' End element: ! http://www.python.org/namespace!subelement End of NS decl: ! myns Start element: ! sub2 {} Start of CDATA section Character data: --- 8,24 ---- ('unparsed_entity', None, 'entity.file', None, 'notation') Start element: ! 'root' {'attr1': 'value1', 'attr2': 'value2\341\275\200'} NS decl: ! 'myns' 'http://www.python.org/namespace' Start element: ! 'http://www.python.org/namespace!subelement' {} Character data: 'Contents of subelements' End element: ! 'http://www.python.org/namespace!subelement' End of NS decl: ! 'myns' Start element: ! 'sub2' {} Start of CDATA section Character data: *************** *** 26,31 **** End of CDATA section End element: ! sub2 ! External entity ref: http://www.python.org/namespace=http://www.w3.org/XML/1998/namespace external_entity None entity.file None End element: ! root --- 26,91 ---- End of CDATA section End element: ! 'sub2' ! External entity ref: ('http://www.python.org/namespace=http://www.w3.org/XML/1998/namespace\014external_entity', None, 'entity.file', None) End element: ! 'root' ! PI: ! u'xml-stylesheet' u'href="stylesheet.css"' ! Comment: ! u' comment data ' ! Notation declared: (u'notation', None, u'notation.jpeg', None) ! Unparsed entity decl: ! (u'unparsed_entity', None, u'entity.file', None, u'notation') ! Start element: ! u'root' {u'attr1': u'value1', u'attr2': u'value2\u1F40'} ! NS decl: ! u'myns' u'http://www.python.org/namespace' ! Start element: ! u'http://www.python.org/namespace!subelement' {} ! Character data: ! u'Contents of subelements' ! End element: ! u'http://www.python.org/namespace!subelement' ! End of NS decl: ! u'myns' ! Start element: ! u'sub2' {} ! Start of CDATA section ! Character data: ! u'contents of CDATA section' ! End of CDATA section ! End element: ! u'sub2' ! External entity ref: (u'http://www.python.org/namespace=http://www.w3.org/XML/1998/namespace\014external_entity', None, u'entity.file', None) ! End element: ! u'root' ! PI: ! u'xml-stylesheet' u'href="stylesheet.css"' ! Comment: ! u' comment data ' ! Notation declared: (u'notation', None, u'notation.jpeg', None) ! Unparsed entity decl: ! (u'unparsed_entity', None, u'entity.file', None, u'notation') ! Start element: ! u'root' {u'attr1': u'value1', u'attr2': u'value2\u1F40'} ! NS decl: ! u'myns' u'http://www.python.org/namespace' ! Start element: ! u'http://www.python.org/namespace!subelement' {} ! Character data: ! u'Contents of subelements' ! End element: ! u'http://www.python.org/namespace!subelement' ! End of NS decl: ! u'myns' ! Start element: ! u'sub2' {} ! Start of CDATA section ! Character data: ! u'contents of CDATA section' ! End of CDATA section ! End element: ! u'sub2' ! External entity ref: (u'http://www.python.org/namespace=http://www.w3.org/XML/1998/namespace\014external_entity', None, u'entity.file', None) ! End element: ! u'root' From python-dev@python.org Tue Jun 27 01:50:42 2000 From: python-dev@python.org (A.M. Kuchling) Date: Mon, 26 Jun 2000 17:50:42 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/curses wrapper.py,1.2,1.3 Message-ID: <200006270050.RAA26210@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/curses In directory slayer.i.sourceforge.net:/tmp/cvs-serv26153 Modified Files: wrapper.py Log Message: Drop back to old version of wrapper(); ESR reports that it broke things, and I lack the time to track down the cause. Index: wrapper.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/curses/wrapper.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** wrapper.py 2000/06/10 23:39:05 1.2 --- wrapper.py 2000/06/27 00:50:40 1.3 *************** *** 18,24 **** --- 18,26 ---- """ + res = None try: # Initialize curses stdscr=curses.initscr() + # Turn off echoing of keys, and enter cbreak mode, # where no buffering is performed on keyboard input *************** *** 30,39 **** stdscr.keypad(1) ! return apply(func, (stdscr,) + rest) ! ! finally: ! # Restore the terminal to a sane state on the way out. stdscr.keypad(0) curses.echo() ; curses.nocbreak() curses.endwin() --- 32,51 ---- stdscr.keypad(1) ! res = apply(func, (stdscr,) + rest) ! except: ! # In the event of an error, restore the terminal ! # to a sane state. stdscr.keypad(0) curses.echo() ; curses.nocbreak() curses.endwin() + + # Pass the exception upwards + (exc_type, exc_value, exc_traceback) = sys.exc_info() + raise exc_type, exc_value, exc_traceback + else: + # Set everything back to normal + stdscr.keypad(0) + curses.echo() ; curses.nocbreak() + curses.endwin() # Terminate curses + return res From python-dev@python.org Tue Jun 27 02:21:24 2000 From: python-dev@python.org (Greg Ward) Date: Mon, 26 Jun 2000 18:21:24 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command config.py,1.2,1.3 Message-ID: <200006270121.SAA01424@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv1414 Modified Files: config.py Log Message: Added 'include_dirs' parameters all over the place. Added 'check_lib()', which provides a subset of the functionality of 'check_func()' with a simpler interface and implementation. Index: config.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/config.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** config.py 2000/06/21 03:00:50 1.2 --- config.py 2000/06/27 01:21:22 1.3 *************** *** 113,124 **** return filename ! def _preprocess (self, body, headers, lang): src = self._gen_temp_sourcefile(body, headers, lang) out = "_configtest.i" self.temp_files.extend([src, out]) ! self.compiler.preprocess(src, out) return (src, out) ! def _compile (self, body, headers, lang): src = self._gen_temp_sourcefile(body, headers, lang) if self.dump_source: --- 113,124 ---- return filename ! def _preprocess (self, body, headers, include_dirs, lang): src = self._gen_temp_sourcefile(body, headers, lang) out = "_configtest.i" self.temp_files.extend([src, out]) ! self.compiler.preprocess(src, out, include_dirs=include_dirs) return (src, out) ! def _compile (self, body, headers, include_dirs, lang): src = self._gen_temp_sourcefile(body, headers, lang) if self.dump_source: *************** *** 126,134 **** (obj,) = self.compiler.object_filenames([src]) self.temp_files.extend([src, obj]) ! self.compiler.compile([src]) return (src, obj) ! def _link (self, body, headers, libraries, library_dirs, lang): ! (src, obj) = self._compile(body, headers, lang) prog = os.path.splitext(os.path.basename(src))[0] self.temp_files.append(prog) # XXX should be prog + exe_ext --- 126,136 ---- (obj,) = self.compiler.object_filenames([src]) self.temp_files.extend([src, obj]) ! self.compiler.compile([src], include_dirs=include_dirs) return (src, obj) ! def _link (self, body, ! headers, include_dirs, ! libraries, library_dirs, lang): ! (src, obj) = self._compile(body, headers, include_dirs, lang) prog = os.path.splitext(os.path.basename(src))[0] self.temp_files.append(prog) # XXX should be prog + exe_ext *************** *** 160,164 **** # XXX need access to the header search path and maybe default macros. ! def try_cpp (self, body=None, headers=None, lang="c"): """Construct a source file from 'body' (a string containing lines of C/C++ code) and 'headers' (a list of header files to include) --- 162,166 ---- # XXX need access to the header search path and maybe default macros. ! def try_cpp (self, body=None, headers=None, include_dirs=None, lang="c"): """Construct a source file from 'body' (a string containing lines of C/C++ code) and 'headers' (a list of header files to include) *************** *** 178,182 **** return ok ! def search_cpp (self, pattern, body=None, headers=None, lang="c"): """Construct a source file (just like 'try_cpp()'), run it through the preprocessor, and return true if any line of the output matches --- 180,185 ---- return ok ! def search_cpp (self, pattern, body=None, ! headers=None, include_dirs=None, lang="c"): """Construct a source file (just like 'try_cpp()'), run it through the preprocessor, and return true if any line of the output matches *************** *** 207,211 **** return match ! def try_compile (self, body, headers=None, lang="c"): """Try to compile a source file built from 'body' and 'headers'. Return true on success, false otherwise. --- 210,214 ---- return match ! def try_compile (self, body, headers=None, include_dirs=None, lang="c"): """Try to compile a source file built from 'body' and 'headers'. Return true on success, false otherwise. *************** *** 223,228 **** return ok ! def try_link (self, ! body, headers=None, libraries=None, library_dirs=None, lang="c"): --- 226,231 ---- return ok ! def try_link (self, body, ! headers=None, include_dirs=None, libraries=None, library_dirs=None, lang="c"): *************** *** 234,238 **** self._check_compiler() try: ! self._link(body, headers, libraries, library_dirs, lang) ok = 1 except (CompileError, LinkError): --- 237,242 ---- self._check_compiler() try: ! self._link(body, headers, include_dirs, ! libraries, library_dirs, lang) ok = 1 except (CompileError, LinkError): *************** *** 243,248 **** return ok ! def try_run (self, ! body, headers=None, libraries=None, library_dirs=None, lang="c"): --- 247,252 ---- return ok ! def try_run (self, body, ! headers=None, include_dirs=None, libraries=None, library_dirs=None, lang="c"): *************** *** 254,258 **** self._check_compiler() try: ! self._link(body, headers, libraries, library_dirs, lang) self.spawn([exe]) ok = 1 --- 258,263 ---- self._check_compiler() try: ! self._link(body, headers, include_dirs, ! libraries, library_dirs, lang) self.spawn([exe]) ok = 1 *************** *** 269,273 **** # when implementing a real-world config command!) ! def check_func (self, func, headers=None, libraries=None, library_dirs=None, decl=0, call=0): --- 274,279 ---- # when implementing a real-world config command!) ! def check_func (self, func, ! headers=None, include_dirs=None, libraries=None, library_dirs=None, decl=0, call=0): *************** *** 299,312 **** body = string.join(body, "\n") + "\n" ! return self.try_link(body, headers, libraries, library_dirs) # check_func () ! def check_header (self, header, lang="c"): """Determine if the system header file named by 'header_file' exists and can be found by the preprocessor; return true if so, false otherwise. """ ! return self.try_cpp(headers=[header]) --- 305,332 ---- body = string.join(body, "\n") + "\n" ! return self.try_link(body, headers, include_dirs, ! libraries, library_dirs) # check_func () ! def check_lib (self, library, library_dirs=None, ! headers=None, include_dirs=None): ! """Determine if 'library' is available to be linked against, ! without actually checking that any particular symbols are provided ! by it. 'headers' will be used in constructing the source file to ! be compiled, but the only effect of this is to check if all the ! header files listed are available. ! """ ! self._check_compiler() ! return self.try_link("int main (void) { }", ! headers, include_dirs, [library], library_dirs) ! ! def check_header (self, header, include_dirs=None, ! library_dirs=None, lang="c"): """Determine if the system header file named by 'header_file' exists and can be found by the preprocessor; return true if so, false otherwise. """ ! return self.try_cpp(headers=[header], include_dirs=include_dirs) From python-dev@python.org Tue Jun 27 02:24:09 2000 From: python-dev@python.org (Greg Ward) Date: Mon, 26 Jun 2000 18:24:09 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command __init__.py,1.13,1.14 bdist.py,1.13,1.14 Message-ID: <200006270124.SAA01626@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv1613 Modified Files: __init__.py bdist.py Log Message: Infrastructure support for the "bdist_wininst" command. Index: __init__.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/__init__.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** __init__.py 2000/05/28 23:49:03 1.13 --- __init__.py 2000/06/27 01:24:07 1.14 *************** *** 21,23 **** --- 21,24 ---- 'bdist_dumb', 'bdist_rpm', + 'bdist_wininst', ] Index: bdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** bdist.py 2000/06/24 01:23:37 1.13 --- bdist.py 2000/06/27 01:24:07 1.14 *************** *** 56,59 **** --- 56,61 ---- 'tar': ('bdist_dumb', "tar file"), 'zip': ('bdist_dumb', "ZIP file"), + 'wininst': ('bdist_wininst', + "Windows executable installer"), } # establish the preferred order From python-dev@python.org Tue Jun 27 02:24:40 2000 From: python-dev@python.org (Greg Ward) Date: Mon, 26 Jun 2000 18:24:40 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist_wininst.py,NONE,1.1 Message-ID: <200006270124.SAA01647@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv1636 Added Files: bdist_wininst.py Log Message: Thomas Heller's "bdist_wininst" command (unreviewed, untested). ***** Error reading new file(2, 'No such file or directory') From python-dev@python.org Tue Jun 27 02:37:12 2000 From: python-dev@python.org (Greg Ward) Date: Mon, 26 Jun 2000 18:37:12 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command build_ext.py,1.48,1.49 Message-ID: <200006270137.SAA02104@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv2081 Modified Files: build_ext.py Log Message: Thomas Heller: added --swig-cpp option and fixed silly typos in SWIG support. Also supposedly made some change to where .lib files wind up under MSVC++, but I don't understand how to code is doing what Thomas says it's doing. Index: build_ext.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build_ext.py,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -r1.48 -r1.49 *** build_ext.py 2000/06/25 02:30:15 1.48 --- build_ext.py 2000/06/27 01:37:10 1.49 *************** *** 78,81 **** --- 78,83 ---- ('compiler=', 'c', "specify the compiler type"), + ('swig-cpp', None, + "make SWIG create C++ files (default is C)"), ] *************** *** 102,105 **** --- 104,108 ---- self.force = None self.compiler = None + self.swig_cpp = None *************** *** 444,456 **** swig_targets = {} ! # XXX this drops generated C files into the source tree, which # is fine for developers who want to distribute the generated # source -- but there should be an option to put SWIG output in # the temp dir. for source in sources: (base, ext) = os.path.splitext(source) if ext == ".i": # SWIG interface file ! new_sources.append(base + ".c") # umm, what if it's C++? swig_sources.append(source) swig_targets[source] = new_sources[-1] --- 447,464 ---- swig_targets = {} ! # XXX this drops generated C/C++ files into the source tree, which # is fine for developers who want to distribute the generated # source -- but there should be an option to put SWIG output in # the temp dir. + if self.swig_cpp: + target_ext = '.cpp' + else: + target_ext = '.c' + for source in sources: (base, ext) = os.path.splitext(source) if ext == ".i": # SWIG interface file ! new_sources.append(base + target_ext) swig_sources.append(source) swig_targets[source] = new_sources[-1] *************** *** 462,470 **** swig = self.find_swig() ! swig_cmd = [swig, "-python", "-dnone", "-ISWIG"] # again, C++?!? for source in swig_sources: ! self.announce ("swigging %s to %s" % (src, obj)) ! self.spawn(swig_cmd + ["-o", swig_targets[source], source]) return new_sources --- 470,481 ---- swig = self.find_swig() ! swig_cmd = [swig, "-python", "-dnone", "-ISWIG"] ! if self.swig_cpp: ! swig_cmd.append ("-c++") for source in swig_sources: ! target = swig_targets[source] ! self.announce ("swigging %s to %s" % (source, target)) ! self.spawn(swig_cmd + ["-o", target, source]) return new_sources *************** *** 529,536 **** extra_args.append('/export:init%s' % modname) ! # The MSVC linker generates unneeded .lib and .exp files, ! # which cannot be suppressed by any linker switches. So ! # make sure they are generated in the temporary build ! # directory. implib_file = os.path.join ( self.build_temp, --- 540,548 ---- extra_args.append('/export:init%s' % modname) ! # The MSVC linker generates .lib and .exp files, which cannot be ! # suppressed by any linker switches. The .lib files may even be ! # needed! Make sure they are generated in the temporary build ! # directory. Since they have different names for debug and release ! # builds, they can go into the same directory. implib_file = os.path.join ( self.build_temp, From python-dev@python.org Tue Jun 27 02:43:26 2000 From: python-dev@python.org (Greg Ward) Date: Mon, 26 Jun 2000 18:43:26 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command build_ext.py,1.49,1.50 Message-ID: <200006270143.SAA02590@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv2490 Modified Files: build_ext.py Log Message: A-ha! Read Thomas' patch a little more carefully and figured it out: the 'implib_dir' attribute is back (only on NT, of course). Index: build_ext.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build_ext.py,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -r1.49 -r1.50 *** build_ext.py 2000/06/27 01:37:10 1.49 --- build_ext.py 2000/06/27 01:43:24 1.50 *************** *** 156,159 **** --- 156,160 ---- if os.name == 'nt': self.library_dirs.append (os.path.join(sys.exec_prefix, 'libs')) + self.implib_dir = self.build_temp if self.debug: self.build_temp = os.path.join (self.build_temp, "Debug") *************** *** 546,550 **** # builds, they can go into the same directory. implib_file = os.path.join ( ! self.build_temp, self.get_ext_libname (ext.name)) extra_args.append ('/IMPLIB:' + implib_file) --- 547,551 ---- # builds, they can go into the same directory. implib_file = os.path.join ( ! self.implib_dir, self.get_ext_libname (ext.name)) extra_args.append ('/IMPLIB:' + implib_file) From python-dev@python.org Tue Jun 27 02:59:09 2000 From: python-dev@python.org (Greg Ward) Date: Mon, 26 Jun 2000 18:59:09 -0700 Subject: [Python-checkins] CVS: distutils/distutils sysconfig.py,1.20,1.21 Message-ID: <200006270159.SAA03355@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv3347 Modified Files: sysconfig.py Log Message: Fixed LDSHARED for AIX, based on a patch by Rene Liebscher. Ditched my old code that fixed relative paths in the Makefile -- didn't work, doomed to failure, etc. Index: sysconfig.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/sysconfig.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -r1.20 -r1.21 *** sysconfig.py 2000/06/25 02:09:14 1.20 --- sysconfig.py 2000/06/27 01:59:06 1.21 *************** *** 223,241 **** del notdone[name] - # "Fix" all pathnames in the Makefile that are explicitly relative, - # ie. that start with "./". This is a kludge to fix the "./ld_so_aix" - # problem, the nature of which is that Python's installed Makefile - # refers to "./ld_so_aix", but when we are building extensions we are - # far from the directory where Python's Makefile (and ld_so_aix, for - # that matter) is installed. Unfortunately, there are several other - # relative pathnames in the Makefile, and this fix doesn't fix them, - # because the layout of Python's source tree -- which is what the - # Makefile refers to -- is not fully preserved in the Python - # installation. Grumble. - from os.path import normpath, join, dirname - for (name, value) in done.items(): - if value[0:2] == "./": - done[name] = normpath(join(dirname(fp.name), value)) - # save the results in the global dictionary g.update(done) --- 223,226 ---- *************** *** 258,261 **** --- 243,258 ---- parse_makefile(file, g) + + # On AIX, there are wrong paths to the linker scripts in the Makefile + # -- these paths are relative to the Python source, but when installed + # the scripts are in another directory. + if sys.platform: # == 'aix4': # what about AIX 3.x ? + # Linker script is in the config directory, not in Modules as the + # Makefile says. + python_lib = get_python_lib(standard_lib=1) + ld_so_aix = os.path.join(python_lib, 'config', 'ld_so_aix') + python_exp = os.path.join(python_lib, 'config', 'python.exp') + + g['LDSHARED'] = "%s %s -bI:%s" % (ld_so_aix, g['CC'], python_exp) From python-dev@python.org Tue Jun 27 02:59:45 2000 From: python-dev@python.org (Greg Ward) Date: Mon, 26 Jun 2000 18:59:45 -0700 Subject: [Python-checkins] CVS: distutils/distutils sysconfig.py,1.21,1.22 Message-ID: <200006270159.SAA03392@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv3378 Modified Files: sysconfig.py Log Message: Oops, only do that AIX hack on AIX. Index: sysconfig.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/sysconfig.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -r1.21 -r1.22 *** sysconfig.py 2000/06/27 01:59:06 1.21 --- sysconfig.py 2000/06/27 01:59:43 1.22 *************** *** 247,251 **** # -- these paths are relative to the Python source, but when installed # the scripts are in another directory. ! if sys.platform: # == 'aix4': # what about AIX 3.x ? # Linker script is in the config directory, not in Modules as the # Makefile says. --- 247,251 ---- # -- these paths are relative to the Python source, but when installed # the scripts are in another directory. ! if sys.platform == 'aix4': # what about AIX 3.x ? # Linker script is in the config directory, not in Modules as the # Makefile says. From python-dev@python.org Tue Jun 27 04:10:45 2000 From: python-dev@python.org (A.M. Kuchling) Date: Mon, 26 Jun 2000 20:10:45 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _cursesmodule.c,2.25,2.26 Message-ID: <200006270310.UAA19315@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv19289 Modified Files: _cursesmodule.c Log Message: Added support for mouse functions: mousemask(), mouseinterval(), getmouse(), ungetmouse(), and window.enclose(). wmouse_trafo() seems of marginal importance at the moment. Index: _cursesmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_cursesmodule.c,v retrieving revision 2.25 retrieving revision 2.26 diff -C2 -r2.25 -r2.26 *** _cursesmodule.c 2000/06/23 01:36:21 2.25 --- _cursesmodule.c 2000/06/27 03:10:38 2.26 *************** *** 614,618 **** --- 614,632 ---- } + #ifdef NCURSES_MOUSE_VERSION static PyObject * + PyCursesWindow_Enclose(self,arg) + PyCursesWindowObject *self; + PyObject * arg; + { + int x, y; + if (!PyArg_Parse(arg,"(ii);y,x", &y, &x)) + return NULL; + + return PyInt_FromLong( wenclose(self->win,y,x) ); + } + #endif + + static PyObject * PyCursesWindow_GetBkgd(self, arg) PyCursesWindowObject *self; *************** *** 1274,1277 **** --- 1288,1294 ---- {"derwin", (PyCFunction)PyCursesWindow_DerWin}, {"echochar", (PyCFunction)PyCursesWindow_EchoChar}, + #ifdef NCURSES_MOUSE_VERSION + {"enclose", (PyCFunction)PyCursesWindow_Enclose}, + #endif {"erase", (PyCFunction)PyCursesWindow_werase}, {"getbegyx", (PyCFunction)PyCursesWindow_getbegyx}, *************** *** 1595,1599 **** --- 1612,1658 ---- } + #ifdef NCURSES_MOUSE_VERSION static PyObject * + PyCurses_GetMouse(self,arg) + PyObject *self; + PyObject * arg; + { + int rtn; + MEVENT event; + + PyCursesInitialised + if (!PyArg_NoArgs(arg)) return NULL; + + rtn = getmouse( &event ); + if (rtn == ERR) { + PyErr_SetString(PyCursesError, "getmouse() returned ERR"); + return NULL; + } + return Py_BuildValue("(hiiil)", + (short)event.id, + event.x, event.y, event.z, + (long) event.bstate); + } + + static PyObject * + PyCurses_UngetMouse(self,args) + PyObject *self; + PyObject *args; + { + int rtn; + MEVENT event; + + PyCursesInitialised + if (!PyArg_ParseTuple(args, "(hiiil)", + &event.id, + &event.x, &event.y, &event.z, + (int *) &event.bstate)) + return NULL; + + return PyCursesCheckERR(ungetmouse(&event), "ungetmouse"); + } + #endif + + static PyObject * PyCurses_GetWin(self,arg) PyCursesWindowObject *self; *************** *** 1866,1869 **** --- 1925,1958 ---- } + #ifdef NCURSES_MOUSE_VERSION + static PyObject * + PyCurses_MouseInterval(self,arg) + PyObject * self; + PyObject * arg; + { + int interval; + PyCursesInitialised + + if (!PyArg_Parse(arg,"i;interval",&interval)) + return NULL; + return PyCursesCheckERR(mouseinterval(interval), "mouseinterval"); + } + + static PyObject * + PyCurses_MouseMask(self,arg) + PyObject * self; + PyObject * arg; + { + int newmask, rtn; + mmask_t oldmask, availmask; + + PyCursesInitialised + if (!PyArg_Parse(arg,"i;mousemask",&newmask)) + return NULL; + availmask = mousemask(newmask, &oldmask); + return Py_BuildValue("(ll)", (long)availmask, (long)oldmask); + } + #endif + static PyObject * PyCurses_NewPad(self,arg) *************** *** 2169,2172 **** --- 2258,2265 ---- {"flash", (PyCFunction)PyCurses_flash}, {"flushinp", (PyCFunction)PyCurses_flushinp}, + #ifdef NCURSES_MOUSE_VERSION + {"getmouse", (PyCFunction)PyCurses_GetMouse}, + {"ungetmouse", (PyCFunction)PyCurses_UngetMouse, METH_VARARGS}, + #endif {"getsyx", (PyCFunction)PyCurses_getsyx}, {"getwin", (PyCFunction)PyCurses_GetWin}, *************** *** 2187,2190 **** --- 2280,2287 ---- {"longname", (PyCFunction)PyCurses_longname}, {"meta", (PyCFunction)PyCurses_Meta}, + #ifdef NCURSES_MOUSE_VERSION + {"mouseinterval", (PyCFunction)PyCurses_MouseInterval}, + {"mousemask", (PyCFunction)PyCurses_MouseMask}, + #endif {"newpad", (PyCFunction)PyCurses_NewPad}, {"newwin", (PyCFunction)PyCurses_NewWindow}, *************** *** 2270,2273 **** --- 2367,2403 ---- SetDictInt("COLOR_WHITE", COLOR_WHITE); + #ifdef NCURSES_MOUSE_VERSION + /* Mouse-related constants */ + SetDictInt("BUTTON1_PRESSED", BUTTON1_PRESSED); + SetDictInt("BUTTON1_RELEASED", BUTTON1_RELEASED); + SetDictInt("BUTTON1_CLICKED", BUTTON1_CLICKED); + SetDictInt("BUTTON1_DOUBLE_CLICKED", BUTTON1_DOUBLE_CLICKED); + SetDictInt("BUTTON1_TRIPLE_CLICKED", BUTTON1_TRIPLE_CLICKED); + + SetDictInt("BUTTON2_PRESSED", BUTTON2_PRESSED); + SetDictInt("BUTTON2_RELEASED", BUTTON2_RELEASED); + SetDictInt("BUTTON2_CLICKED", BUTTON2_CLICKED); + SetDictInt("BUTTON2_DOUBLE_CLICKED", BUTTON2_DOUBLE_CLICKED); + SetDictInt("BUTTON2_TRIPLE_CLICKED", BUTTON2_TRIPLE_CLICKED); + + SetDictInt("BUTTON3_PRESSED", BUTTON3_PRESSED); + SetDictInt("BUTTON3_RELEASED", BUTTON3_RELEASED); + SetDictInt("BUTTON3_CLICKED", BUTTON3_CLICKED); + SetDictInt("BUTTON3_DOUBLE_CLICKED", BUTTON3_DOUBLE_CLICKED); + SetDictInt("BUTTON3_TRIPLE_CLICKED", BUTTON3_TRIPLE_CLICKED); + + SetDictInt("BUTTON4_PRESSED", BUTTON4_PRESSED); + SetDictInt("BUTTON4_RELEASED", BUTTON4_RELEASED); + SetDictInt("BUTTON4_CLICKED", BUTTON4_CLICKED); + SetDictInt("BUTTON4_DOUBLE_CLICKED", BUTTON4_DOUBLE_CLICKED); + SetDictInt("BUTTON4_TRIPLE_CLICKED", BUTTON4_TRIPLE_CLICKED); + + SetDictInt("BUTTON_SHIFT", BUTTON_SHIFT); + SetDictInt("BUTTON_CTRL", BUTTON_CTRL); + SetDictInt("BUTTON_ALT", BUTTON_ALT); + + SetDictInt("ALL_MOUSE_EVENTS", ALL_MOUSE_EVENTS); + SetDictInt("REPORT_MOUSE_POSITION", REPORT_MOUSE_POSITION); + #endif /* Now set everything up for KEY_ variables */ { From python-dev@python.org Tue Jun 27 04:16:07 2000 From: python-dev@python.org (A.M. Kuchling) Date: Mon, 26 Jun 2000 20:16:07 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libre.tex,1.51,1.52 libcrypto.tex,1.16,1.17 Message-ID: <200006270316.UAA19569@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv19527 Modified Files: libre.tex libcrypto.tex Log Message: Changed obsolete e-mail alias Index: libre.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libre.tex,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -r1.51 -r1.52 *** libre.tex 1999/11/09 20:08:53 1.51 --- libre.tex 2000/06/27 03:16:04 1.52 *************** *** 2,7 **** Perl-style regular expression operations.} \declaremodule{standard}{re} ! \moduleauthor{Andrew M. Kuchling}{akuchling@acm.org} ! \sectionauthor{Andrew M. Kuchling}{akuchling@acm.org} --- 2,7 ---- Perl-style regular expression operations.} \declaremodule{standard}{re} ! \moduleauthor{Andrew M. Kuchling}{amk1@bigfoot.com} ! \sectionauthor{Andrew M. Kuchling}{amk1@bigfoot.com} Index: libcrypto.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcrypto.tex,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** libcrypto.tex 1999/04/29 02:30:03 1.16 --- libcrypto.tex 2000/06/27 03:16:04 1.17 *************** *** 15,19 **** are not distributed with Python but available separately. See the URL \url{http://starship.python.net/crew/amk/python/crypto.html} or ! send email to \email{akuchlin@acm.org} for more information. \index{PGP} \index{Pretty Good Privacy} --- 15,19 ---- are not distributed with Python but available separately. See the URL \url{http://starship.python.net/crew/amk/python/crypto.html} or ! send email to \email{amk1@bigfoot.com} for more information. \index{PGP} \index{Pretty Good Privacy} From python-dev@python.org Tue Jun 27 04:52:59 2000 From: python-dev@python.org (Trent Mick) Date: Mon, 26 Jun 2000 20:52:59 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_pyexpat.py,1.2,1.3 In-Reply-To: <200006270037.RAA25539@slayer.i.sourceforge.net> References: <200006270037.RAA25539@slayer.i.sourceforge.net> Message-ID: <20000626205259.A3866@activestate.com> On Mon, Jun 26, 2000 at 05:37:27PM -0700, A . M . Kuchling wrote: > Update of /cvsroot/python/python/dist/src/Lib/test > In directory slayer.i.sourceforge.net:/tmp/cvs-serv25501 > > Modified Files: > test_pyexpat.py > Log Message: > Change pyexpat test suite to exercise the .returns_unicode attribute, > parsing the sample data once with 8-bit strings and once with Unicode. > Does this require a new Lib/test/output/test_pyexpat? Trent -- Trent Mick trentm@activestate.com From python-dev@python.org Tue Jun 27 15:15:32 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 27 Jun 2000 07:15:32 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/curses ascii.py,1.1,1.2 Message-ID: <200006271415.HAA07414@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/curses In directory slayer.i.sourceforge.net:/tmp/cvs-serv7402 Modified Files: ascii.py Log Message: Fix comment typo noticed by Rob Hooft Index: ascii.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/curses/ascii.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** ascii.py 2000/06/26 23:55:42 1.1 --- ascii.py 2000/06/27 14:15:29 1.2 *************** *** 1,4 **** # ! # ascii.py -- constants and memembership tests for ASCII characters # --- 1,4 ---- # ! # ascii.py -- constants and membership tests for ASCII characters # From python-dev@python.org Tue Jun 27 16:01:13 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 27 Jun 2000 08:01:13 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _cursesmodule.c,2.26,2.27 Message-ID: <200006271501.IAA14137@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv13872 Modified Files: _cursesmodule.c Log Message: Fix two typos (, instead of ;) Index: _cursesmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_cursesmodule.c,v retrieving revision 2.26 retrieving revision 2.27 diff -C2 -r2.26 -r2.27 *** _cursesmodule.c 2000/06/27 03:10:38 2.26 --- _cursesmodule.c 2000/06/27 15:01:10 2.27 *************** *** 1043,1047 **** rtn = pnoutrefresh(self->win, pminrow, pmincol, sminrow, ! smincol, smaxrow, smaxcol), Py_END_ALLOW_THREADS return PyCursesCheckERR(rtn, "pnoutrefresh"); --- 1043,1047 ---- rtn = pnoutrefresh(self->win, pminrow, pmincol, sminrow, ! smincol, smaxrow, smaxcol); Py_END_ALLOW_THREADS return PyCursesCheckERR(rtn, "pnoutrefresh"); *************** *** 1112,1117 **** rtn = prefresh(self->win, pminrow, pmincol, sminrow, ! smincol, smaxrow, smaxcol), ! Py_END_ALLOW_THREADS return PyCursesCheckERR(rtn, "prefresh"); --- 1112,1116 ---- rtn = prefresh(self->win, pminrow, pmincol, sminrow, ! smincol, smaxrow, smaxcol); Py_END_ALLOW_THREADS return PyCursesCheckERR(rtn, "prefresh"); From python-dev@python.org Tue Jun 27 22:49:50 2000 From: python-dev@python.org (A.M. Kuchling) Date: Tue, 27 Jun 2000 14:49:50 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _cursesmodule.c,2.27,2.28 Message-ID: <200006272149.OAA17222@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv17205 Modified Files: _cursesmodule.c Log Message: Fixes for compiling on Tru64. Define a STRICT_SYSV_CURSES macro on SGI, Sun, and Tru64, to mark systems that don't support some features. Index: _cursesmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_cursesmodule.c,v retrieving revision 2.27 retrieving revision 2.28 diff -C2 -r2.27 -r2.28 *** _cursesmodule.c 2000/06/27 15:01:10 2.27 --- _cursesmodule.c 2000/06/27 21:49:47 2.28 *************** *** 42,45 **** --- 42,50 ---- #include "Python.h" + #ifdef __osf__ + #define _XOPEN_SOURCE_EXTENDED /* Define macro for OSF/1 */ + #define STRICT_SYSV_CURSES + #endif + #ifdef HAVE_NCURSES_H #include *************** *** 49,54 **** #if defined(__sgi__) || defined(__sun__) ! /* No attr_t type is available */ ! typedef chtype attr_t; #endif --- 54,59 ---- #if defined(__sgi__) || defined(__sun__) ! #define STRICT_SYSV_CURSES ! typedef chtype attr_t; /* No attr_t type is available */ #endif *************** *** 250,254 **** Window_TwoArgNoReturnFunction(mvderwin, int, "(ii);y,x") Window_TwoArgNoReturnFunction(wmove, int, "(ii);y,x") ! #if !defined(__sgi__) && !defined(__sun__) Window_TwoArgNoReturnFunction(wresize, int, "(ii);lines,columns") #endif --- 255,259 ---- Window_TwoArgNoReturnFunction(mvderwin, int, "(ii);y,x") Window_TwoArgNoReturnFunction(wmove, int, "(ii);y,x") ! #ifndef STRICT_SYSV_CURSES Window_TwoArgNoReturnFunction(wresize, int, "(ii);lines,columns") #endif *************** *** 729,733 **** if (!PyArg_Parse(arg,"(iii);y,x,n", &y, &x, &n)) return NULL; ! #if defined(__sgi__) || defined(__sun__) /* Untested */ Py_BEGIN_ALLOW_THREADS --- 734,738 ---- if (!PyArg_Parse(arg,"(iii);y,x,n", &y, &x, &n)) return NULL; ! #ifdef STRICT_SYSV_CURSES /* Untested */ Py_BEGIN_ALLOW_THREADS *************** *** 1324,1328 **** {"redrawwin", (PyCFunction)PyCursesWindow_redrawwin}, {"refresh", (PyCFunction)PyCursesWindow_Refresh}, ! #if !defined(__sgi__) && !defined(__sun__) {"resize", (PyCFunction)PyCursesWindow_wresize}, #endif --- 1329,1333 ---- {"redrawwin", (PyCFunction)PyCursesWindow_redrawwin}, {"refresh", (PyCFunction)PyCursesWindow_Refresh}, ! #ifndef STRICT_SYSV_CURSES {"resize", (PyCFunction)PyCursesWindow_wresize}, #endif *************** *** 1830,1835 **** SetDictInt("ACS_SBSB", (ACS_VLINE)); SetDictInt("ACS_SSSS", (ACS_PLUS)); ! #if !defined(__sgi__) && !defined(__sun__) ! /* The following are never available on IRIX 5.3 */ SetDictInt("ACS_S3", (ACS_S3)); SetDictInt("ACS_LEQUAL", (ACS_LEQUAL)); --- 1835,1840 ---- SetDictInt("ACS_SBSB", (ACS_VLINE)); SetDictInt("ACS_SSSS", (ACS_PLUS)); ! #ifndef STRICT_SYSV_CURSES ! /* The following are never available with strict SYSV curses */ SetDictInt("ACS_S3", (ACS_S3)); SetDictInt("ACS_LEQUAL", (ACS_LEQUAL)); *************** *** 2348,2352 **** SetDictInt("A_CHARTEXT", A_CHARTEXT); SetDictInt("A_COLOR", A_COLOR); ! #if !defined(__sgi__) && !defined(__sun__) SetDictInt("A_HORIZONTAL", A_HORIZONTAL); SetDictInt("A_LEFT", A_LEFT); --- 2353,2357 ---- SetDictInt("A_CHARTEXT", A_CHARTEXT); SetDictInt("A_COLOR", A_COLOR); ! #ifndef STRICT_SYSV_CURSES SetDictInt("A_HORIZONTAL", A_HORIZONTAL); SetDictInt("A_LEFT", A_LEFT); From python-dev@python.org Wed Jun 28 01:36:43 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 27 Jun 2000 17:36:43 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist_dumb.py,1.7,1.8 Message-ID: <200006280036.RAA12335@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv12327 Modified Files: bdist_dumb.py Log Message: Fixed to use 'reinitialize_command()' to fetch the "install" command object. Index: bdist_dumb.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist_dumb.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** bdist_dumb.py 2000/05/27 17:27:23 1.7 --- bdist_dumb.py 2000/06/28 00:36:40 1.8 *************** *** 59,68 **** self.run_command ('build') ! # XXX don't use 'self.get_finalized_command()', because it always runs ! # 'ensure_finalized()' on the command object; we explictly want a ! # command object that has *not* been finalized, so we can set ! # options on it! (The option we set, 'root', is so that we can do ! # a proper "fake install" using this install command object.) ! install = self.distribution.get_command_obj('install') install.root = self.bdist_dir --- 59,63 ---- self.run_command ('build') ! install = self.reinitialize_command('install') install.root = self.bdist_dir From python-dev@python.org Wed Jun 28 01:56:23 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 27 Jun 2000 17:56:23 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist_wininst.py,1.1,1.2 Message-ID: <200006280056.RAA13336@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv13321 Modified Files: bdist_wininst.py Log Message: Fixed to use 'reinitialize_command()' to fetch "install" and "install_lib" command objects. Various formatting tweaks, typo fixes in comments. Index: bdist_wininst.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist_wininst.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** bdist_wininst.py 2000/06/27 01:24:38 1.1 --- bdist_wininst.py 2000/06/28 00:56:20 1.2 *************** *** 8,12 **** __revision__ = "$Id$" ! import os, sys from distutils.core import Command from distutils.util import get_platform, create_tree, remove_tree --- 8,12 ---- __revision__ = "$Id$" ! import sys, os, string from distutils.core import Command from distutils.util import get_platform, create_tree, remove_tree *************** *** 15,19 **** class bdist_wininst (Command): ! description = "create a \"wininst\" built distribution" user_options = [('bdist-dir=', 'd', --- 15,19 ---- class bdist_wininst (Command): ! description = "create an executable installer for MS Windows" user_options = [('bdist-dir=', 'd', *************** *** 65,84 **** self.run_command ('build') ! # XXX don't use 'self.get_finalized_command()', because it always ! # runs 'ensure_finalized()' on the command object; we explictly ! # want a command object that has *not* been finalized, so we can set ! # options on it! (The option we set, 'root', is so that we can do ! # a proper "fake install" using this install command object.) ! install = self.distribution.get_command_obj('install') install.root = self.bdist_dir ! install_lib = self.distribution.get_command_obj('install_lib') ! install_lib.compile = 0 install_lib.optimize = 0 ! # The packager (correct term in distutils speak?) can choose ! # if pyc and pyo files should be created on the TARGET system ! # instead at the SOURCE system. ## # The compilation can only be done on the SOURCE system --- 65,77 ---- self.run_command ('build') ! install = self.reinitialize_command('install') install.root = self.bdist_dir ! install_lib = self.reinitialize_command('install_lib') install_lib.compile = 0 install_lib.optimize = 0 ! # The packager can choose if .pyc and .pyo files should be created ! # on the TARGET system instead at the SOURCE system. ## # The compilation can only be done on the SOURCE system *************** *** 96,100 **** self.announce ("installing to %s" % self.bdist_dir) install.ensure_finalized() - install.run() --- 89,92 ---- *************** *** 104,111 **** # XXX hack! Our archive MUST be relative to sys.prefix # XXX What about .install_data, .install_scripts, ...? root_dir = install.install_lib arcname = self.make_archive (archive_basename, "zip", ! root_dir=root_dir) ! self.create_exe (arcname) --- 96,107 ---- # XXX hack! Our archive MUST be relative to sys.prefix # XXX What about .install_data, .install_scripts, ...? + # [Perhaps require that all installation dirs be under sys.prefix + # on Windows? this will be acceptable until we start dealing + # with Python applications, at which point we should zip up + # the application directory -- and again everything can be + # under one dir --GPW] root_dir = install.install_lib arcname = self.make_archive (archive_basename, "zip", ! root_dir=root_dir) self.create_exe (arcname) *************** *** 116,139 **** def create_inifile (self): ! # create an inifile containing data describing the installation. # This could be done without creating a real file, but ! # a file is (at least) usefull for debugging bdist_wininst. ! import string metadata = self.distribution.metadata - ini_name = "%s.ini" % self.distribution.get_fullname() - self.announce ("creating %s" % ini_name) - inifile = open (ini_name, "w") ! # write the [metadata] section. values are written with repr()[1:], ! # so they do not contain unprintable characters, and are not ! # surrounded by quote chars inifile.write ("[metadata]\n") ! # 'info' will be displayed in the installers dialog box, ! # describing the items to be installed info = metadata.long_description + '\n' --- 112,132 ---- def create_inifile (self): ! # Create an inifile containing data describing the installation. # This could be done without creating a real file, but ! # a file is (at least) useful for debugging bdist_wininst. metadata = self.distribution.metadata + ini_name = "%s.ini" % metadata.get_fullname() self.announce ("creating %s" % ini_name) inifile = open (ini_name, "w") ! # Write the [metadata] section. Values are written with ! # repr()[1:-1], so they do not contain unprintable characters, and ! # are not surrounded by quote chars. inifile.write ("[metadata]\n") ! # 'info' will be displayed in the installer's dialog box, ! # describing the items to be installed. info = metadata.long_description + '\n' *************** *** 174,178 **** installer_name = "%s.win32.exe" % self.distribution.get_fullname() - self.announce ("creating %s" % installer_name) --- 167,170 ---- From python-dev@python.org Wed Jun 28 02:20:38 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 27 Jun 2000 18:20:38 -0700 Subject: [Python-checkins] CVS: distutils/distutils bcppcompiler.py,NONE,1.1 Message-ID: <200006280120.SAA20707@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv20700 Added Files: bcppcompiler.py Log Message: Lyle Johnson's interface to Borland C++, with a few editorial comments by me. Two major points: * lots of overlap with MSVCCompiler; the common code really should be factored out into a base class, say WindowsCCompiler * it doesn't work: weird problem spawning the linker (see comment for details) ***** Error reading new file(2, 'No such file or directory') From python-dev@python.org Wed Jun 28 02:25:29 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 27 Jun 2000 18:25:29 -0700 Subject: [Python-checkins] CVS: distutils/distutils dist.py,1.30,1.31 Message-ID: <200006280125.SAA20982@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv20962 Modified Files: dist.py Log Message: Typo fix. Index: dist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/dist.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -r1.30 -r1.31 *** dist.py 2000/06/24 01:22:41 1.30 --- dist.py 2000/06/28 01:25:27 1.31 *************** *** 731,735 **** """Reinitializes a command to the state it was in when first returned by 'get_command_obj()': ie., initialized but not yet ! finalized. This gives provides the opportunity to sneak option values in programmatically, overriding or supplementing user-supplied values from the config files and command line. --- 731,735 ---- """Reinitializes a command to the state it was in when first returned by 'get_command_obj()': ie., initialized but not yet ! finalized. This provides the opportunity to sneak option values in programmatically, overriding or supplementing user-supplied values from the config files and command line. From python-dev@python.org Wed Jun 28 02:29:11 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 27 Jun 2000 18:29:11 -0700 Subject: [Python-checkins] CVS: distutils/distutils ccompiler.py,1.27,1.28 msvccompiler.py,1.31,1.32 unixccompiler.py,1.27,1.28 Message-ID: <200006280129.SAA21300@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv21286 Modified Files: ccompiler.py msvccompiler.py unixccompiler.py Log Message: Lyle Johnson: added 'build_temp' parameter to 'link_shared_{lib,object}()' methods (but not 'link_executable()', hmmm). Currently only used by BCPPCompiler; it's a dummy parameter for UnixCCompiler and MSVCCompiler. Also added 'bcpp' to compiler table used by 'new_compiler()'. Index: ccompiler.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/ccompiler.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -r1.27 -r1.28 *** ccompiler.py 2000/06/25 02:08:18 1.27 --- ccompiler.py 2000/06/28 01:29:09 1.28 *************** *** 493,497 **** extra_preargs=None, extra_postargs=None): - """Compile one or more source files. 'sources' must be a list of filenames, most likely C/C++ files, but in reality anything that --- 493,496 ---- *************** *** 573,578 **** debug=0, extra_preargs=None, ! extra_postargs=None): ! """Link a bunch of stuff together to create a shared library file. Similar semantics to 'create_static_lib()', with the addition of --- 572,577 ---- debug=0, extra_preargs=None, ! extra_postargs=None, ! build_temp=None): """Link a bunch of stuff together to create a shared library file. Similar semantics to 'create_static_lib()', with the addition of *************** *** 625,629 **** debug=0, extra_preargs=None, ! extra_postargs=None): """Link a bunch of stuff together to create a shared object file. Much like 'link_shared_lib()', except the output filename is --- 624,629 ---- debug=0, extra_preargs=None, ! extra_postargs=None, ! build_temp=None): """Link a bunch of stuff together to create a shared object file. Much like 'link_shared_lib()', except the output filename is *************** *** 815,818 **** --- 815,820 ---- 'mingw32': ('cygwinccompiler', 'Mingw32CCompiler', "Mingw32 port of GNU C Compiler for Win32"), + 'bcpp': ('bcppcompiler', 'BCPPCompiler', + "Borland C++ Compiler"), } Index: msvccompiler.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/msvccompiler.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -r1.31 -r1.32 *** msvccompiler.py 2000/06/25 02:31:16 1.31 --- msvccompiler.py 2000/06/28 01:29:09 1.32 *************** *** 1,3 **** ! """distutils.ccompiler Contains MSVCCompiler, an implementation of the abstract CCompiler class --- 1,3 ---- ! """distutils.msvccompiler Contains MSVCCompiler, an implementation of the abstract CCompiler class *************** *** 323,327 **** debug=0, extra_preargs=None, ! extra_postargs=None): self.link_shared_object (objects, --- 323,328 ---- debug=0, extra_preargs=None, ! extra_postargs=None, ! build_temp=None): self.link_shared_object (objects, *************** *** 334,338 **** debug=debug, extra_preargs=extra_preargs, ! extra_postargs=extra_postargs) --- 335,340 ---- debug=debug, extra_preargs=extra_preargs, ! extra_postargs=extra_postargs, ! build_temp=build_temp) *************** *** 347,351 **** debug=0, extra_preargs=None, ! extra_postargs=None): (objects, output_dir) = self._fix_object_args (objects, output_dir) --- 349,354 ---- debug=0, extra_preargs=None, ! extra_postargs=None, ! build_temp=None): (objects, output_dir) = self._fix_object_args (objects, output_dir) Index: unixccompiler.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/unixccompiler.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -r1.27 -r1.28 *** unixccompiler.py 2000/06/25 02:05:29 1.27 --- unixccompiler.py 2000/06/28 01:29:09 1.28 *************** *** 75,78 **** --- 75,79 ---- + def __init__ (self, verbose=0, *************** *** 200,204 **** debug=0, extra_preargs=None, ! extra_postargs=None): self.link_shared_object ( objects, --- 201,207 ---- debug=0, extra_preargs=None, ! extra_postargs=None, ! build_temp=None): ! self.link_shared_object ( objects, *************** *** 211,215 **** debug, extra_preargs, ! extra_postargs) --- 214,219 ---- debug, extra_preargs, ! extra_postargs, ! build_temp) *************** *** 224,228 **** debug=0, extra_preargs=None, ! extra_postargs=None): (objects, output_dir) = self._fix_object_args (objects, output_dir) --- 228,233 ---- debug=0, extra_preargs=None, ! extra_postargs=None, ! build_temp=None): (objects, output_dir) = self._fix_object_args (objects, output_dir) From python-dev@python.org Wed Jun 28 02:29:39 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 27 Jun 2000 18:29:39 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command build_ext.py,1.50,1.51 Message-ID: <200006280129.SAA21340@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv21325/command Modified Files: build_ext.py Log Message: Lyle Johnson: pass in temp directory as 'build_temp' argument when calling 'link_shared_object()'. Index: build_ext.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build_ext.py,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -r1.50 -r1.51 *** build_ext.py 2000/06/27 01:43:24 1.50 --- build_ext.py 2000/06/28 01:29:37 1.51 *************** *** 431,435 **** runtime_library_dirs=ext.runtime_library_dirs, extra_postargs=extra_args, ! debug=self.debug) # build_extensions () --- 431,436 ---- runtime_library_dirs=ext.runtime_library_dirs, extra_postargs=extra_args, ! debug=self.debug, ! build_temp=self.build_temp) # build_extensions () From python-dev@python.org Wed Jun 28 02:31:39 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 27 Jun 2000 18:31:39 -0700 Subject: [Python-checkins] CVS: distutils MINIFEST.in,1.1,1.2 MANIFEST.in,1.7,1.8 Message-ID: <200006280131.SAA21503@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv21490 Modified Files: MINIFEST.in MANIFEST.in Log Message: Added 'misc' directory (except for zip files), so we get the source to Thomas Heller's Windows installer. Index: MINIFEST.in =================================================================== RCS file: /cvsroot/python/distutils/MINIFEST.in,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** MINIFEST.in 2000/06/08 01:17:32 1.1 --- MINIFEST.in 2000/06/28 01:31:37 1.2 *************** *** 11,12 **** --- 11,14 ---- prune examples/sample*/build prune test + graft misc + exclude misc/*.zip Index: MANIFEST.in =================================================================== RCS file: /cvsroot/python/distutils/MANIFEST.in,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** MANIFEST.in 2000/06/08 01:20:23 1.7 --- MANIFEST.in 2000/06/28 01:31:37 1.8 *************** *** 14,15 **** --- 14,17 ---- prune examples/sample*/build recursive-include doc *.sty *.tex + graft misc + exclude misc/*.zip From python-dev@python.org Wed Jun 28 03:02:44 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 27 Jun 2000 19:02:44 -0700 Subject: [Python-checkins] CVS: distutils/misc - New directory Message-ID: <200006280202.TAA29192@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/misc In directory slayer.i.sourceforge.net:/tmp/cvs-serv29185/misc Log Message: Directory /cvsroot/python/distutils/misc added to the repository From python-dev@python.org Wed Jun 28 03:04:03 2000 From: python-dev@python.org (Greg Ward) Date: Tue, 27 Jun 2000 19:04:03 -0700 Subject: [Python-checkins] CVS: distutils/misc install.c,NONE,1.1 install.rc,NONE,1.1 resource.h,NONE,1.1 wininst.dsp,NONE,1.1 wininst.dsw,NONE,1.1 Message-ID: <200006280204.TAA29320@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/misc In directory slayer.i.sourceforge.net:/tmp/cvs-serv29313 Added Files: install.c install.rc resource.h wininst.dsp wininst.dsw Log Message: C source (and related files) for the GUI Windows installer used by the "bdist_wininst" command. ***** Error reading new file(2, 'No such file or directory') --- NEW FILE --- //Microsoft Developer Studio generated resource script. // #include "resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // #include "afxres.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // German (Germany) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) #ifdef _WIN32 LANGUAGE LANG_GERMAN, SUBLANG_GERMAN #pragma code_page(1252) #endif //_WIN32 ///////////////////////////////////////////////////////////////////////////// // // Dialog // IDD_DIALOG1 DIALOG DISCARDABLE 0, 0, 276, 223 STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Installation" FONT 8, "MS Sans Serif" BEGIN DEFPUSHBUTTON "Start",IDC_START,84,202,50,14 PUSHBUTTON "Close",IDCANCEL,142,202,50,14 CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER, 28,184,218,14 CTEXT "static",IDC_INFO,7,172,262,8 EDITTEXT IDC_EDIT1,7,7,262,128,ES_MULTILINE | ES_READONLY | WS_VSCROLL | WS_HSCROLL CONTROL "Use Python 1.5",IDC_PYTHON15,"Button", BS_AUTORADIOBUTTON,7,140,65,10 EDITTEXT IDC_PATH,42,154,202,14,ES_AUTOHSCROLL CONTROL "Use Python 1.6",IDC_PYTHON16,"Button", BS_AUTORADIOBUTTON,79,140,65,10 LTEXT "Directory:",IDC_STATIC,7,157,31,8 PUSHBUTTON "...",IDC_BROWSE,248,154,21,14 END ///////////////////////////////////////////////////////////////////////////// // // DESIGNINFO // #ifdef APSTUDIO_INVOKED GUIDELINES DESIGNINFO DISCARDABLE BEGIN IDD_DIALOG1, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 269 TOPMARGIN, 7 BOTTOMMARGIN, 216 END END #endif // APSTUDIO_INVOKED #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // TEXTINCLUDE // 1 TEXTINCLUDE DISCARDABLE BEGIN "resource.h\0" END 2 TEXTINCLUDE DISCARDABLE BEGIN "#include ""afxres.h""\r\n" "\0" END 3 TEXTINCLUDE DISCARDABLE BEGIN "\r\n" "\0" END #endif // APSTUDIO_INVOKED #endif // German (Germany) resources ///////////////////////////////////////////////////////////////////////////// #ifndef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 3 resource. // ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED --- NEW FILE --- //{{NO_DEPENDENCIES}} // Microsoft Developer Studio generated include file. // Used by install.rc // #define IDD_DIALOG1 101 #define IDC_EDIT1 1000 #define IDC_START 1001 #define IDC_PROGRESS 1003 #define IDC_INFO 1004 #define IDC_PYTHON15 1006 #define IDC_PATH 1007 #define IDC_PYTHON16 1008 #define IDC_BROWSE 1010 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 102 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1012 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif --- NEW FILE --- # Microsoft Developer Studio Project File - Name="wininst" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Application" 0x0101 CFG=wininst - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "wininst.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "wininst.mak" CFG="wininst - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "wininst - Win32 Release" (based on "Win32 (x86) Application") !MESSAGE "wininst - Win32 Debug" (based on "Win32 (x86) Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "wininst - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "." # PROP Intermediate_Dir "temp-release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MD /W3 /O1 /I "zlib" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x407 /d "NDEBUG" # ADD RSC /l 0x407 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo 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 /machine:I386 # ADD LINK32 ole32.lib zlibstat.lib comctl32.lib kernel32.lib user32.lib gdi32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"LIBC" /libpath:"zlib\static32" !ELSEIF "$(CFG)" == "wininst - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "." # PROP Intermediate_Dir "temp-debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /MD /W3 /Z7 /Od /I "zlib" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x407 /d "_DEBUG" # ADD RSC /l 0x407 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo 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 /debug /machine:I386 /pdbtype:sept # ADD LINK32 ole32.lib zlibstat.lib comctl32.lib kernel32.lib user32.lib gdi32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /pdb:none /debug /machine:I386 /nodefaultlib:"LIBC" /out:"./wininst_d.exe" /libpath:"zlib\static32" !ENDIF # Begin Target # Name "wininst - Win32 Release" # Name "wininst - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\install.c # End Source File # Begin Source File SOURCE=.\install.rc # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project --- NEW FILE --- Microsoft Developer Studio Workspace File, Format Version 6.00 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! ############################################################################### Project: "wininst"=.\wininst.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Global: Package=<5> {{{ }}} Package=<3> {{{ }}} ############################################################################### From python-dev@python.org Wed Jun 28 04:51:48 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 27 Jun 2000 20:51:48 -0700 Subject: [Python-checkins] CVS: distutils/doc README.txt,1.1,1.2 Message-ID: <200006280351.UAA08426@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/doc In directory slayer.i.sourceforge.net:/tmp/cvs-serv8418 Modified Files: README.txt Log Message: Remove comment about a "forest of symlinks"; not needed now that distutils.sty is part of the Python documentation tools. Updated URL to information about the Python CVS repository. Index: README.txt =================================================================== RCS file: /cvsroot/python/distutils/doc/README.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** README.txt 2000/05/13 03:45:48 1.1 --- README.txt 2000/06/28 03:51:45 1.2 *************** *** 10,15 **** set, and are tightly integrated with the standard Python documentation tools. That means that you won't be able to process the LaTeX files ! here without 1) downloading the latest Python documentation tools, and ! 2) setting up a fearsome forest of symbolic links to make it all work. Since these two manuals are now included with the Python documentation --- 10,14 ---- set, and are tightly integrated with the standard Python documentation tools. That means that you won't be able to process the LaTeX files ! here without downloading the latest Python documentation tools. Since these two manuals are now included with the Python documentation *************** *** 21,25 **** For information on getting access to the Python source and documentation via CVS, see ! http://www.python.org/download/cvs.html If all you really want to do is *read* the documentation, you don't need --- 20,24 ---- For information on getting access to the Python source and documentation via CVS, see ! https://sourceforge.net/cvs/?group_id=5470 If all you really want to do is *read* the documentation, you don't need From python-dev@python.org Wed Jun 28 04:54:51 2000 From: python-dev@python.org (Fred L. Drake) Date: Tue, 27 Jun 2000 20:54:51 -0700 Subject: [Python-checkins] CVS: python/dist/src/PC config.h,1.36,1.37 Message-ID: <200006280354.UAA08590@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv8581 Modified Files: config.h Log Message: Changed the #error to a #warning when checking gcc versions, and noted the minimum recommended version in the message. Index: config.h =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/config.h,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -r1.36 -r1.37 *** config.h 2000/06/19 13:41:54 1.36 --- config.h 2000/06/28 03:54:48 1.37 *************** *** 32,36 **** */ #if (__GNUC__==2) && (__GNUC_MINOR__<=91) ! #error "Please use an up-to-date version of gcc" #endif --- 32,36 ---- */ #if (__GNUC__==2) && (__GNUC_MINOR__<=91) ! #warning "Please use an up-to-date version of gcc! (>2.91 recommended)" #endif From python-dev@python.org Wed Jun 28 09:11:50 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 28 Jun 2000 01:11:50 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.28,2.29 Message-ID: <200006280811.BAA18157@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv18141/Objects Modified Files: unicodeobject.c Log Message: Marc-Andre Lemburg : Better error message for "1 in unicodestring". Submitted by Andrew Kuchling. Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.28 retrieving revision 2.29 diff -C2 -r2.28 -r2.29 *** unicodeobject.c 2000/06/18 22:25:22 2.28 --- unicodeobject.c 2000/06/28 08:11:47 2.29 *************** *** 2989,2994 **** /* Coerce the two arguments */ v = (PyUnicodeObject *)PyUnicode_FromObject(element); ! if (v == NULL) goto onError; u = (PyUnicodeObject *)PyUnicode_FromObject(container); if (u == NULL) { --- 2989,2997 ---- /* Coerce the two arguments */ v = (PyUnicodeObject *)PyUnicode_FromObject(element); ! if (v == NULL) { ! PyErr_SetString(PyExc_TypeError, ! "'in ' requires character as left operand"); goto onError; + } u = (PyUnicodeObject *)PyUnicode_FromObject(container); if (u == NULL) { From python-dev@python.org Wed Jun 28 15:44:08 2000 From: python-dev@python.org (Jeremy Hylton) Date: Wed, 28 Jun 2000 07:44:08 -0700 Subject: [Python-checkins] CVS: python/dist/src/Demo/pdist rcslib.py,1.6,1.7 Message-ID: <200006281444.HAA00518@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Demo/pdist In directory slayer.i.sourceforge.net:/tmp/cvs-serv506/Demo/pdist Modified Files: rcslib.py Log Message: typos fixed by Rob Hooft Index: rcslib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/pdist/rcslib.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** rcslib.py 1998/09/14 16:43:57 1.6 --- rcslib.py 2000/06/28 14:44:05 1.7 *************** *** 297,301 **** """INTERNAL: run COMMAND in a subshell. ! Standard input for the command is taken fron /dev/null. Raise IOError when the exit status is not zero. --- 297,301 ---- """INTERNAL: run COMMAND in a subshell. ! Standard input for the command is taken from /dev/null. Raise IOError when the exit status is not zero. From python-dev@python.org Wed Jun 28 15:44:08 2000 From: python-dev@python.org (Jeremy Hylton) Date: Wed, 28 Jun 2000 07:44:08 -0700 Subject: [Python-checkins] CVS: python/dist/src/Demo/sgi/video Vcopy.py,1.7,1.8 Vtime.py,1.4,1.5 Message-ID: <200006281444.HAA00523@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Demo/sgi/video In directory slayer.i.sourceforge.net:/tmp/cvs-serv506/Demo/sgi/video Modified Files: Vcopy.py Vtime.py Log Message: typos fixed by Rob Hooft Index: Vcopy.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/sgi/video/Vcopy.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** Vcopy.py 1996/11/27 19:50:07 1.7 --- Vcopy.py 2000/06/28 14:44:05 1.8 *************** *** 9,13 **** # = resample at a fixed rate # = divide the time codes by a speed factor (to make it go faster/slower) ! # = drop frames that are less than n msec apart (to accomodate slow players) # - Convert to a different format # - Magnify (scale) the image --- 9,13 ---- # = resample at a fixed rate # = divide the time codes by a speed factor (to make it go faster/slower) ! # = drop frames that are less than n msec apart (to accommodate slow players) # - Convert to a different format # - Magnify (scale) the image Index: Vtime.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/sgi/video/Vtime.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** Vtime.py 1996/11/27 19:50:28 1.4 --- Vtime.py 2000/06/28 14:44:05 1.5 *************** *** 8,12 **** # - resample at a fixed rate # - divide the time codes by a speed factor (to make it go faster/slower) ! # - drop frames that are less than n msec apart (to accomodate slow players) --- 8,12 ---- # - resample at a fixed rate # - divide the time codes by a speed factor (to make it go faster/slower) ! # - drop frames that are less than n msec apart (to accommodate slow players) From python-dev@python.org Wed Jun 28 15:48:04 2000 From: python-dev@python.org (Jeremy Hylton) Date: Wed, 28 Jun 2000 07:48:04 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/distutils cmd.py,1.18,1.19 util.py,1.37,1.38 version.py,1.1,1.2 Message-ID: <200006281448.HAA00779@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv723/Lib/distutils Modified Files: cmd.py util.py version.py Log Message: typos fixed by Rob Hooft Index: cmd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/cmd.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** cmd.py 2000/06/08 00:02:36 1.18 --- cmd.py 2000/06/28 14:48:01 1.19 *************** *** 324,328 **** themselves if the current verbosity level is high enough. This method takes care of all that bureaucracy for you; all you have to ! do is supply the funtion to call and an argument tuple for it (to embody the "external action" being performed), a message to print if the verbosity level is high enough, and an optional verbosity --- 324,328 ---- themselves if the current verbosity level is high enough. This method takes care of all that bureaucracy for you; all you have to ! do is supply the function to call and an argument tuple for it (to embody the "external action" being performed), a message to print if the verbosity level is high enough, and an optional verbosity Index: util.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/util.py,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -r1.37 -r1.38 *** util.py 2000/06/24 20:40:02 1.37 --- util.py 2000/06/28 14:48:01 1.38 *************** *** 29,33 **** ! # More backwards compatability hacks def extend (list, new_list): """Appends the list 'new_list' to 'list', just like the 'extend()' --- 29,33 ---- ! # More backwards compatibility hacks def extend (list, new_list): """Appends the list 'new_list' to 'list', just like the 'extend()' Index: version.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/version.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** version.py 1998/12/18 22:00:30 1.1 --- version.py 2000/06/28 14:48:01 1.2 *************** *** 208,212 **** # version numbering scheme to its domination. The free-thinking # anarchists in the lot will never give in, though, and something needs ! # to be done to accomodate them. # # Perhaps a "moderately strict" version class could be implemented that --- 208,212 ---- # version numbering scheme to its domination. The free-thinking # anarchists in the lot will never give in, though, and something needs ! # to be done to accommodate them. # # Perhaps a "moderately strict" version class could be implemented that From python-dev@python.org Wed Jun 28 15:48:04 2000 From: python-dev@python.org (Jeremy Hylton) Date: Wed, 28 Jun 2000 07:48:04 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/distutils/command build_ext.py,1.51,1.52 Message-ID: <200006281448.HAA00783@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv723/Lib/distutils/command Modified Files: build_ext.py Log Message: typos fixed by Rob Hooft Index: build_ext.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/build_ext.py,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -r1.51 -r1.52 *** build_ext.py 2000/06/28 01:29:37 1.51 --- build_ext.py 2000/06/28 14:48:01 1.52 *************** *** 2,6 **** Implements the Distutils 'build_ext' command, for building extension ! modules (currently limited to C extensions, should accomodate C++ extensions ASAP).""" --- 2,6 ---- Implements the Distutils 'build_ext' command, for building extension ! modules (currently limited to C extensions, should accommodate C++ extensions ASAP).""" *************** *** 386,390 **** # XXX not honouring 'define_macros' or 'undef_macros' -- the ! # CCompiler API needs to change to accomodate this, and I # want to do one thing at a time! --- 386,390 ---- # XXX not honouring 'define_macros' or 'undef_macros' -- the ! # CCompiler API needs to change to accommodate this, and I # want to do one thing at a time! From python-dev@python.org Wed Jun 28 15:48:04 2000 From: python-dev@python.org (Jeremy Hylton) Date: Wed, 28 Jun 2000 07:48:04 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-irix6 flp.py,1.4,1.5 panel.py,1.1,1.2 Message-ID: <200006281448.HAA00806@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/plat-irix6 In directory slayer.i.sourceforge.net:/tmp/cvs-serv723/Lib/plat-irix6 Modified Files: flp.py panel.py Log Message: typos fixed by Rob Hooft Index: flp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/flp.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** flp.py 1998/03/26 20:23:01 1.4 --- flp.py 2000/06/28 14:48:01 1.5 *************** *** 204,208 **** # # Internal: parse fd form, or skip if name doesn't match. ! # the special value None means 'allways parse it'. # def _parse_fd_form(file, name): --- 204,208 ---- # # Internal: parse fd form, or skip if name doesn't match. ! # the special value None means 'always parse it'. # def _parse_fd_form(file, name): *************** *** 223,227 **** # ! # Internal class: a convient place to store object info fields # class _newobj: --- 223,227 ---- # ! # Internal class: a convenient place to store object info fields # class _newobj: Index: panel.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix6/panel.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** panel.py 1997/01/15 19:19:11 1.1 --- panel.py 2000/06/28 14:48:01 1.2 *************** *** 3,7 **** # Support for the Panel library. # Uses built-in module 'pnl'. ! # Applciations should use 'panel.function' instead of 'pnl.function'; # most 'pnl' functions are transparently exported by 'panel', # but dopanel() is overridden and you have to use this version --- 3,7 ---- # Support for the Panel library. # Uses built-in module 'pnl'. ! # Applications should use 'panel.function' instead of 'pnl.function'; # most 'pnl' functions are transparently exported by 'panel', # but dopanel() is overridden and you have to use this version *************** *** 138,142 **** ! # Build a real actuator from an actuator descriptior. # Return a pair (actuator, name). # --- 138,142 ---- ! # Build a real actuator from an actuator description. # Return a pair (actuator, name). # From python-dev@python.org Wed Jun 28 15:48:04 2000 From: python-dev@python.org (Jeremy Hylton) Date: Wed, 28 Jun 2000 07:48:04 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/dos-8x3 posixpat.py,1.10,1.11 queue.py,1.7,1.8 test_win.py,1.1,1.2 Message-ID: <200006281448.HAA00799@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/dos-8x3 In directory slayer.i.sourceforge.net:/tmp/cvs-serv723/Lib/dos-8x3 Modified Files: posixpat.py queue.py test_win.py Log Message: typos fixed by Rob Hooft Index: posixpat.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/posixpat.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** posixpat.py 2000/05/08 17:31:00 1.10 --- posixpat.py 2000/06/28 14:48:01 1.11 *************** *** 25,29 **** ! # Return wheter a path is absolute. # Trivial in Posix, harder on the Mac or MS-DOS. --- 25,29 ---- ! # Return whether a path is absolute. # Trivial in Posix, harder on the Mac or MS-DOS. *************** *** 305,309 **** # Expand paths containing shell variable substitutions. # This expands the forms $variable and ${variable} only. ! # Non-existant variables are left unchanged. _varprog = None --- 305,309 ---- # Expand paths containing shell variable substitutions. # This expands the forms $variable and ${variable} only. ! # Non-existent variables are left unchanged. _varprog = None Index: queue.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/queue.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** queue.py 2000/05/08 17:31:00 1.7 --- queue.py 2000/06/28 14:48:01 1.8 *************** *** 120,124 **** return len(self.queue) ! # Check wheter the queue is empty def _empty(self): return not self.queue --- 120,124 ---- return len(self.queue) ! # Check whether the queue is empty def _empty(self): return not self.queue Index: test_win.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/test_win.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** test_win.py 2000/05/08 17:31:03 1.1 --- test_win.py 2000/06/28 14:48:01 1.2 *************** *** 116,120 **** try: key = OpenKey(root_key, test_key_name) ! assert 0, "Could open the non-existant key" except WindowsError: # Use this error name this time pass --- 116,120 ---- try: key = OpenKey(root_key, test_key_name) ! assert 0, "Could open the non-existent key" except WindowsError: # Use this error name this time pass From python-dev@python.org Wed Jun 28 15:48:04 2000 From: python-dev@python.org (Jeremy Hylton) Date: Wed, 28 Jun 2000 07:48:04 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib Queue.py,1.10,1.11 binhex.py,1.12,1.13 calendar.py,1.15,1.16 fnmatch.py,1.7,1.8 locale.py,1.6,1.7 posixpath.py,1.30,1.31 sgmllib.py,1.19,1.20 site.py,1.11,1.12 urllib2.py,1.3,1.4 xmllib.py,1.18,1.19 Message-ID: <200006281448.HAA00808@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv723/Lib Modified Files: Queue.py binhex.py calendar.py fnmatch.py locale.py posixpath.py sgmllib.py site.py urllib2.py xmllib.py Log Message: typos fixed by Rob Hooft Index: Queue.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/Queue.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** Queue.py 2000/02/02 15:10:14 1.10 --- Queue.py 2000/06/28 14:48:01 1.11 *************** *** 120,124 **** return len(self.queue) ! # Check wheter the queue is empty def _empty(self): return not self.queue --- 120,124 ---- return len(self.queue) ! # Check whether the queue is empty def _empty(self): return not self.queue Index: binhex.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/binhex.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** binhex.py 2000/02/04 15:39:29 1.12 --- binhex.py 2000/06/28 14:48:01 1.13 *************** *** 14,18 **** # We seem to lack a simple character-translate in python. # (we should probably use ISO-Latin-1 on all but the mac platform). ! # XXXX The simeple routines are too simple: they expect to hold the complete # files in-core. Should be fixed. # XXXX It would be nice to handle AppleDouble format on unix --- 14,18 ---- # We seem to lack a simple character-translate in python. # (we should probably use ISO-Latin-1 on all but the mac platform). ! # XXXX The simple routines are too simple: they expect to hold the complete # files in-core. Should be fixed. # XXXX It would be nice to handle AppleDouble format on unix *************** *** 49,53 **** openrf = MacOS.openrf except AttributeError: ! # Backward compatability openrf = open --- 49,53 ---- openrf = MacOS.openrf except AttributeError: ! # Backward compatibility openrf = open Index: calendar.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/calendar.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** calendar.py 2000/02/02 15:10:14 1.15 --- calendar.py 2000/06/28 14:48:01 1.16 *************** *** 1,5 **** """Calendar printing functions""" ! # Revision 2: uses funtions from built-in time module # Import functions and variables from time module --- 1,5 ---- """Calendar printing functions""" ! # Revision 2: uses functions from built-in time module # Import functions and variables from time module Index: fnmatch.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/fnmatch.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** fnmatch.py 1997/10/22 20:57:40 1.7 --- fnmatch.py 2000/06/28 14:48:01 1.8 *************** *** 37,41 **** def fnmatchcase(name, pat): ! """Test wheter FILENAME matches PATTERN, including case. This is a version of fnmatch() which doesn't case-normalize --- 37,41 ---- def fnmatchcase(name, pat): ! """Test whether FILENAME matches PATTERN, including case. This is a version of fnmatch() which doesn't case-normalize Index: locale.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/locale.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** locale.py 2000/06/08 17:49:41 1.6 --- locale.py 2000/06/28 14:48:01 1.7 *************** *** 221,225 **** The language code corresponds to RFC 1766. code and encoding can be None in case the values cannot be determined or are ! unkown to this implementation. """ --- 221,225 ---- The language code corresponds to RFC 1766. code and encoding can be None in case the values cannot be determined or are ! unknown to this implementation. """ *************** *** 230,234 **** return None, None else: ! raise ValueError,'unkown locale: %s' % localename return l --- 230,234 ---- return None, None else: ! raise ValueError,'unknown locale: %s' % localename return l Index: posixpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/posixpath.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -r1.30 -r1.31 *** posixpath.py 2000/02/29 13:31:16 1.30 --- posixpath.py 2000/06/28 14:48:01 1.31 *************** *** 25,29 **** ! # Return wheter a path is absolute. # Trivial in Posix, harder on the Mac or MS-DOS. --- 25,29 ---- ! # Return whether a path is absolute. # Trivial in Posix, harder on the Mac or MS-DOS. *************** *** 305,309 **** # Expand paths containing shell variable substitutions. # This expands the forms $variable and ${variable} only. ! # Non-existant variables are left unchanged. _varprog = None --- 305,309 ---- # Expand paths containing shell variable substitutions. # This expands the forms $variable and ${variable} only. ! # Non-existent variables are left unchanged. _varprog = None Index: sgmllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sgmllib.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -r1.19 -r1.20 *** sgmllib.py 2000/02/04 15:28:40 1.19 --- sgmllib.py 2000/06/28 14:48:01 1.20 *************** *** 48,52 **** # (Tags are converted to lower case for this purpose.) The data # between tags is passed to the parser by calling self.handle_data() ! # with some data as argument (the data may be split up in arbutrary # chunks). Entity references are passed by calling # self.handle_entityref() with the entity reference as argument. --- 48,52 ---- # (Tags are converted to lower case for this purpose.) The data # between tags is passed to the parser by calling self.handle_data() ! # with some data as argument (the data may be split up in arbitrary # chunks). Entity references are passed by calling # self.handle_entityref() with the entity reference as argument. Index: site.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/site.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** site.py 2000/06/07 09:12:09 1.11 --- site.py 2000/06/28 14:48:01 1.12 *************** *** 123,127 **** # Set the string encoding used by the Unicode implementation to the # encoding used by the default locale of this system. If the default ! # encoding cannot be determined or is unkown, it defaults to 'ascii'. # def locale_aware_defaultencoding(): --- 123,127 ---- # Set the string encoding used by the Unicode implementation to the # encoding used by the default locale of this system. If the default ! # encoding cannot be determined or is unknown, it defaults to 'ascii'. # def locale_aware_defaultencoding(): Index: urllib2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib2.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** urllib2.py 2000/02/10 17:17:14 1.3 --- urllib2.py 2000/06/28 14:48:01 1.4 *************** *** 142,146 **** # do these error classes make sense? ! # make sure all of the IOError stuff is overriden. we just want to be # subtypes. --- 142,146 ---- # do these error classes make sense? ! # make sure all of the IOError stuff is overridden. we just want to be # subtypes. Index: xmllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xmllib.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** xmllib.py 2000/06/21 20:01:10 1.18 --- xmllib.py 2000/06/28 14:48:01 1.19 *************** *** 80,84 **** # and , respectively. The data between tags is passed to the # parser by calling self.handle_data() with some data as argument (the ! # data may be split up in arbutrary chunks). class XMLParser: --- 80,84 ---- # and , respectively. The data between tags is passed to the # parser by calling self.handle_data() with some data as argument (the ! # data may be split up in arbitrary chunks). class XMLParser: From python-dev@python.org Wed Jun 28 15:48:04 2000 From: python-dev@python.org (Jeremy Hylton) Date: Wed, 28 Jun 2000 07:48:04 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-irix5 CL_old.py,1.1,1.2 flp.py,1.17,1.18 panel.py,1.4,1.5 Message-ID: <200006281448.HAA00804@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/plat-irix5 In directory slayer.i.sourceforge.net:/tmp/cvs-serv723/Lib/plat-irix5 Modified Files: CL_old.py flp.py panel.py Log Message: typos fixed by Rob Hooft Index: CL_old.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/CL_old.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** CL_old.py 1995/05/17 11:18:22 1.1 --- CL_old.py 2000/06/28 14:48:01 1.2 *************** *** 201,205 **** # ! # SGI Proprietaty Algorithm Header Start Code # HEADER_START_CODE = 0xc1C0DEC --- 201,205 ---- # ! # SGI Proprietary Algorithm Header Start Code # HEADER_START_CODE = 0xc1C0DEC Index: flp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/flp.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** flp.py 1998/03/26 20:22:58 1.17 --- flp.py 2000/06/28 14:48:01 1.18 *************** *** 204,208 **** # # Internal: parse fd form, or skip if name doesn't match. ! # the special value None means 'allways parse it'. # def _parse_fd_form(file, name): --- 204,208 ---- # # Internal: parse fd form, or skip if name doesn't match. ! # the special value None means 'always parse it'. # def _parse_fd_form(file, name): *************** *** 223,227 **** # ! # Internal class: a convient place to store object info fields # class _newobj: --- 223,227 ---- # ! # Internal class: a convenient place to store object info fields # class _newobj: Index: panel.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-irix5/panel.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** panel.py 1995/09/18 22:00:37 1.4 --- panel.py 2000/06/28 14:48:01 1.5 *************** *** 3,7 **** # Support for the Panel library. # Uses built-in module 'pnl'. ! # Applciations should use 'panel.function' instead of 'pnl.function'; # most 'pnl' functions are transparently exported by 'panel', # but dopanel() is overridden and you have to use this version --- 3,7 ---- # Support for the Panel library. # Uses built-in module 'pnl'. ! # Applications should use 'panel.function' instead of 'pnl.function'; # most 'pnl' functions are transparently exported by 'panel', # but dopanel() is overridden and you have to use this version *************** *** 138,142 **** ! # Build a real actuator from an actuator descriptior. # Return a pair (actuator, name). # --- 138,142 ---- ! # Build a real actuator from an actuator description. # Return a pair (actuator, name). # From python-dev@python.org Wed Jun 28 15:48:04 2000 From: python-dev@python.org (Jeremy Hylton) Date: Wed, 28 Jun 2000 07:48:04 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_al.py,1.2,1.3 test_b1.py,1.22,1.23 test_cd.py,1.2,1.3 test_cl.py,1.2,1.3 test_pwd.py,1.5,1.6 test_winreg.py,1.2,1.3 test_zlib.py,1.7,1.8 Message-ID: <200006281448.HAA00821@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv723/Lib/test Modified Files: test_al.py test_b1.py test_cd.py test_cl.py test_pwd.py test_winreg.py test_zlib.py Log Message: typos fixed by Rob Hooft Index: test_al.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_al.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** test_al.py 1998/03/26 19:41:38 1.2 --- test_al.py 2000/06/28 14:48:01 1.3 *************** *** 9,13 **** 'newconfig', 'openport', 'queryparams', 'setparams'] ! # This is a very inobstrusive test for the existance of the al module and all it's # attributes. More comprehensive examples can be found in Demo/al --- 9,13 ---- 'newconfig', 'openport', 'queryparams', 'setparams'] ! # This is a very unobtrusive test for the existence of the al module and all it's # attributes. More comprehensive examples can be found in Demo/al Index: test_b1.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_b1.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** test_b1.py 2000/04/14 19:13:22 1.22 --- test_b1.py 2000/06/28 14:48:01 1.23 *************** *** 271,275 **** if int("10",16) <> 16L: raise TestFailed, 'int("10",16)' if int(u"10",16) <> 16L: raise TestFailed, 'int(u"10",16)' ! # Test conversion fron strings and various anomalies L = [ ('0', 0), --- 271,275 ---- if int("10",16) <> 16L: raise TestFailed, 'int("10",16)' if int(u"10",16) <> 16L: raise TestFailed, 'int(u"10",16)' ! # Test conversion from strings and various anomalies L = [ ('0', 0), Index: test_cd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_cd.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** test_cd.py 1998/03/26 19:41:49 1.2 --- test_cd.py 2000/06/28 14:48:01 1.3 *************** *** 11,15 **** ! # This is a very inobstrusive test for the existance of the cd module and all it's # attributes. More comprehensive examples can be found in Demo/cd and # require that you have a CD and a CD ROM drive --- 11,15 ---- ! # This is a very inobtrusive test for the existence of the cd module and all it's # attributes. More comprehensive examples can be found in Demo/cd and # require that you have a CD and a CD ROM drive Index: test_cl.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_cl.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** test_cl.py 1998/03/26 19:41:52 1.2 --- test_cl.py 2000/06/28 14:48:01 1.3 *************** *** 64,68 **** ! # This is a very inobstrusive test for the existance of the cl # module and all it's attributes. --- 64,68 ---- ! # This is a very inobtrusive test for the existence of the cl # module and all it's attributes. Index: test_pwd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pwd.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** test_pwd.py 1998/03/26 19:42:32 1.5 --- test_pwd.py 2000/06/28 14:48:01 1.6 *************** *** 60,64 **** print 'fakename', fakename, 'did not except pwd.getpwnam()' ! # Choose a non-existant uid. fakeuid = 4127 while byuids.has_key(fakeuid): --- 60,64 ---- print 'fakename', fakename, 'did not except pwd.getpwnam()' ! # Choose a non-existent uid. fakeuid = 4127 while byuids.has_key(fakeuid): Index: test_winreg.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_winreg.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** test_winreg.py 2000/04/01 05:25:57 1.2 --- test_winreg.py 2000/06/28 14:48:01 1.3 *************** *** 116,120 **** try: key = OpenKey(root_key, test_key_name) ! assert 0, "Could open the non-existant key" except WindowsError: # Use this error name this time pass --- 116,120 ---- try: key = OpenKey(root_key, test_key_name) ! assert 0, "Could open the non-existent key" except WindowsError: # Use this error name this time pass Index: test_zlib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_zlib.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** test_zlib.py 2000/02/10 15:31:07 1.7 --- test_zlib.py 2000/06/28 14:48:01 1.8 *************** *** 12,16 **** file.close() ! # test the chucksums (hex so the test doesn't break on 64-bit machines) print hex(zlib.crc32('penguin')), hex(zlib.crc32('penguin', 1)) print hex(zlib.adler32('penguin')), hex(zlib.adler32('penguin', 1)) --- 12,16 ---- file.close() ! # test the checksums (hex so the test doesn't break on 64-bit machines) print hex(zlib.crc32('penguin')), hex(zlib.crc32('penguin', 1)) print hex(zlib.adler32('penguin')), hex(zlib.adler32('penguin', 1)) From python-dev@python.org Wed Jun 28 16:07:40 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 08:07:40 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libatexit.tex,NONE,1.1 libsys.tex,1.35,1.36 lib.tex,1.152,1.153 Message-ID: <200006281507.IAA08342@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv8272/Doc/lib Modified Files: libsys.tex lib.tex Added Files: libatexit.tex Log Message: Added the atexit module and documentation from Skip Montanaro . Revisions to the markup to make it pass LaTeX, added an index entry and a reference from the sys.exitfunc documentation. This closes SourceForge patch #100620. --- NEW FILE --- \section{\module{atexit} --- exit handlers} \declaremodule{standard}{atexit} \moduleauthor{Skip Montanaro}{skip@mojam.com} \sectionauthor{Skip Montanaro}{skip@mojam.com} \modulesynopsis{Register and execute cleanup functions.} The \module{atexit} module defines a single function to register cleanup functions. Functions thus registered are automatically executed upon normal interpreter termination. Note: the functions registered via this module are not called when the program is killed by a signal, when a Python fatal internal error is detected, or when \code{os._exit()} is called. This is an alternate interface to the functionality provided by the \code{sys.exitfunc} variable. \withsubitem{(in sys)}{\ttindex{exitfunc}} \begin{funcdesc}{register}{func\optional{, *args\optional{, **kargs}}} Register \var{func} as a function to be executed at termination. Any optional arguments that are to be passed to \var{func} must be passed as arguments to \function{register()}. At normal program termination (for instance, if \function{sys.exit()} is called or the main module's execution completes), all functions registered are called in last in, first out order. The assumption is that lower level modules will normally be imported before higher level modules and thus must be cleaned up later. \end{funcdesc} \subsection{\module{atexit} Example \label{atexit-example}} The following simple example demonstrates how a module can initialize a counter from a file when it is imported and save the counter's updated value automatically when the program terminates without relying on the application making an explicit call into this module at termination. \begin{verbatim} try: _count = int(open("/tmp/counter").read()) except IOError: _count = 0 def incrcounter(n): global _count _count = _count + n def savecounter(): open("/tmp/counter", "w").write("%d" % _count) import atexit atexit.register(savecounter) \end{verbatim} Index: libsys.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsys.tex,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -r1.35 -r1.36 *** libsys.tex 2000/04/13 17:51:58 1.35 --- libsys.tex 2000/06/28 15:07:30 1.36 *************** *** 128,132 **** the user (or by a program) to specify a clean-up action at program exit. When set, it should be a parameterless function. This function ! will be called when the interpreter exits. Note: the exit function is not called when the program is killed by a signal, when a Python fatal internal error is detected, or when \code{os._exit()} is called. --- 128,134 ---- the user (or by a program) to specify a clean-up action at program exit. When set, it should be a parameterless function. This function ! will be called when the interpreter exits. Only one function may be ! installed in this way; to allow multiple functions which will be called ! at termination, use the \refmodule{atexit} module. Note: the exit function is not called when the program is killed by a signal, when a Python fatal internal error is detected, or when \code{os._exit()} is called. Index: lib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/lib.tex,v retrieving revision 1.152 retrieving revision 1.153 diff -C2 -r1.152 -r1.153 *** lib.tex 2000/06/13 20:51:29 1.152 --- lib.tex 2000/06/28 15:07:30 1.153 *************** *** 74,77 **** --- 74,78 ---- \input{libpython} % Python Services \input{libsys} + \input{libatexit} \input{libtypes} \input{libuserdict} From python-dev@python.org Wed Jun 28 16:07:40 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 08:07:40 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_atexit,NONE,1.1 Message-ID: <200006281507.IAA08349@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv8272/Lib/test/output Added Files: test_atexit Log Message: Added the atexit module and documentation from Skip Montanaro . Revisions to the markup to make it pass LaTeX, added an index entry and a reference from the sys.exitfunc documentation. This closes SourceForge patch #100620. --- NEW FILE --- test_atexit handler2 (7,) {'kw': 'abc'} handler2 () {} handler1 From python-dev@python.org Wed Jun 28 16:07:40 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 08:07:40 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_atexit.py,NONE,1.1 Message-ID: <200006281507.IAA08346@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv8272/Lib/test Added Files: test_atexit.py Log Message: Added the atexit module and documentation from Skip Montanaro . Revisions to the markup to make it pass LaTeX, added an index entry and a reference from the sys.exitfunc documentation. This closes SourceForge patch #100620. --- NEW FILE --- # Test the exit module from test_support import verbose import atexit def handler1(): print "handler1" def handler2(*args, **kargs): print "handler2", args, kargs # save any exit functions that may have been registered as part of the # test framework _exithandlers = atexit._exithandlers atexit._exithandlers = [] atexit.register(handler1) atexit.register(handler2) atexit.register(handler2, 7, kw="abc") # simulate exit behavior by calling atexit._run_exitfuncs directly... atexit._run_exitfuncs() # restore exit handlers atexit._exithandlers = _exithandlers From python-dev@python.org Wed Jun 28 16:07:40 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 08:07:40 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc Makefile.deps,1.32,1.33 Message-ID: <200006281507.IAA08340@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc In directory slayer.i.sourceforge.net:/tmp/cvs-serv8272/Doc Modified Files: Makefile.deps Log Message: Added the atexit module and documentation from Skip Montanaro . Revisions to the markup to make it pass LaTeX, added an index entry and a reference from the sys.exitfunc documentation. This closes SourceForge patch #100620. Index: Makefile.deps =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile.deps,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -r1.32 -r1.33 *** Makefile.deps 2000/06/13 20:51:29 1.32 --- Makefile.deps 2000/06/28 15:07:31 1.33 *************** *** 229,232 **** --- 229,233 ---- ../lib/libtty.tex \ ../lib/libasyncore.tex \ + ../lib/libatexit.tex \ ../lib/libcfgparser.tex From python-dev@python.org Wed Jun 28 16:07:40 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 08:07:40 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib atexit.py,NONE,1.1 Message-ID: <200006281507.IAA08343@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv8272/Lib Added Files: atexit.py Log Message: Added the atexit module and documentation from Skip Montanaro . Revisions to the markup to make it pass LaTeX, added an index entry and a reference from the sys.exitfunc documentation. This closes SourceForge patch #100620. --- NEW FILE --- """ atexit.py - allow programmer to define multiple exit functions to be executed upon normal program termination. One public function, register, is defined. """ _exithandlers = [] def _run_exitfuncs(): """run any registered exit functions _exithandlers is traversed in reverse order so functions are executed last in, first out. """ while _exithandlers: func, targs, kargs = _exithandlers[-1] apply(func, targs, kargs) _exithandlers.remove(_exithandlers[-1]) def register(func, *targs, **kargs): """register a function to be executed upon normal program termination func - function to be called at exit targs - optional arguments to pass to func kargs - optional keyword arguments to pass to func """ _exithandlers.append((func, targs, kargs)) import sys try: x = sys.exitfunc except AttributeError: sys.exitfunc = _run_exitfuncs else: # if x isn't our own exit func executive, assume it's another # registered exit function - append it to our list... if x != _run_exitfuncs: register(x) del sys if __name__ == "__main__": def x1(): print "running x1" def x2(n): print "running x2(%s)" % `n` def x3(n, kwd=None): print "running x3(%s, kwd=%s)" % (`n`, `kwd`) register(x1) register(x2, 12) register(x3, 5, "bar") register(x3, "no kwd args") From python-dev@python.org Wed Jun 28 16:32:32 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 08:32:32 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/ext ext.tex,1.75,1.76 Message-ID: <200006281532.IAA10093@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/ext In directory slayer.i.sourceforge.net:/tmp/cvs-serv10086/ext Modified Files: ext.tex Log Message: Added memory-reference information to the description of Py_BuildValue(), based on comments from Frank Stajano . Index: ext.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/ext.tex,v retrieving revision 1.75 retrieving revision 1.76 diff -C2 -r1.75 -r1.76 *** ext.tex 2000/05/10 20:36:34 1.75 --- ext.tex 2000/06/28 15:32:29 1.76 *************** *** 1002,1005 **** --- 1002,1010 ---- parenthesize the format string. + When memory buffers are passed as parameters to supply data to build + objects, as for the \samp{s} and \samp{s\#} formats, the required data + is copied. Buffers provided by the caller are never referenced by the + objects created by \cfunction{Py_BuildValue()}. + In the following description, the quoted form is the format unit; the entry in (round) parentheses is the Python object type that the format *************** *** 1015,1019 **** \item[\samp{s} (string) {[char *]}] Convert a null-terminated C string to a Python object. If the C ! string pointer is \NULL{}, \code{None} is returned. \item[\samp{s\#} (string) {[char *, int]}] --- 1020,1024 ---- \item[\samp{s} (string) {[char *]}] Convert a null-terminated C string to a Python object. If the C ! string pointer is \NULL{}, \code{None} is used. \item[\samp{s\#} (string) {[char *, int]}] From python-dev@python.org Wed Jun 28 16:53:17 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 08:53:17 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/api api.tex,1.68,1.69 Message-ID: <200006281553.IAA11238@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/api In directory slayer.i.sourceforge.net:/tmp/cvs-serv11228/api Modified Files: api.tex Log Message: Added documentation for PyOS_AfterFork(). Index: api.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/api.tex,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -r1.68 -r1.69 *** api.tex 2000/06/18 05:21:21 1.68 --- api.tex 2000/06/28 15:53:13 1.69 *************** *** 1034,1037 **** --- 1034,1044 ---- \end{cfuncdesc} + \begin{cfuncdesc}{void}{PyOS_AfterFork}{} + Function to update some internal state after a process fork; this + should be called in the new process if the Python interpreter will + continue to be used. If a new executable is loaded into the new + process, this function does not need to be called. + \end{cfuncdesc} + \section{Process Control \label{processControl}} From python-dev@python.org Wed Jun 28 17:15:10 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 09:15:10 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/ext ext.tex,1.76,1.77 Message-ID: <200006281615.JAA18538@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/ext In directory slayer.i.sourceforge.net:/tmp/cvs-serv18530/ext Modified Files: ext.tex Log Message: Enhanced memory-reference information in the description of Py_BuildValue(), based on response from Frank Stajano . Index: ext.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/ext.tex,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -r1.76 -r1.77 *** ext.tex 2000/06/28 15:32:29 1.76 --- ext.tex 2000/06/28 16:15:08 1.77 *************** *** 1005,1009 **** objects, as for the \samp{s} and \samp{s\#} formats, the required data is copied. Buffers provided by the caller are never referenced by the ! objects created by \cfunction{Py_BuildValue()}. In the following description, the quoted form is the format unit; the --- 1005,1013 ---- objects, as for the \samp{s} and \samp{s\#} formats, the required data is copied. Buffers provided by the caller are never referenced by the ! objects created by \cfunction{Py_BuildValue()}. In other words, if ! your code invokes \cfunction{malloc()} and passes the allocated memory ! to \cfunction{Py_BuildValue()}, your code is responsible for ! calling \cfunction{free()} for that memory once ! \cfunction{Py_BuildValue()} returns. In the following description, the quoted form is the format unit; the From python-dev@python.org Wed Jun 28 17:37:27 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 28 Jun 2000 09:37:27 -0700 Subject: [Python-checkins] CVS: python/dist/src/Include ucnhash.h,NONE,1.1 Message-ID: <200006281637.JAA20224@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Include In directory slayer.i.sourceforge.net:/tmp/cvs-serv20217/Include Added Files: ucnhash.h Log Message: Marc-Andre Lemburg : Exports the C API of the new ucnhash module. By Bill Tutt. --- NEW FILE --- #include #include /* --- C API ----------------------------------------------------*/ /* C API for usage by other Python modules */ typedef struct _Py_UCNHashAPI { unsigned long cKeys; unsigned long cchMax; unsigned long (*hash)(const char *key, unsigned int cch); const void *(*getValue)(unsigned long iKey); } _Py_UCNHashAPI; typedef struct { const char *pszUCN; unsigned int uiValue; } _Py_UnicodeCharacterName; From python-dev@python.org Wed Jun 28 17:38:58 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 28 Jun 2000 09:38:58 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules ucnhash.c,NONE,1.1 Message-ID: <200006281638.JAA20368@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv20335/Modules Added Files: ucnhash.c Log Message: Marc-Andre Lemburg : New ucnhash module by Bill Tutt. This module contains the hash table needed to map Unicode character names to Unicode ordinals and is loaded on-the-fly by the standard unicode-escape codec. --- NEW FILE --- #include /* * The hash is produced using the algorithm described in * "Optimal algorithms for minimal perfect hashing", * G. Havas, B.S. Majewski. Available as a technical report * from the CS department, University of Queensland * (ftp://ftp.cs.uq.oz.au/). * * Generated using a heavily tweaked version of Andrew Kuchling's * perfect_hash.py: * http://starship.python.net/crew/amk/python/code/perfect-hash.html * * Generated on: Wed Jun 28 03:34:07 2000 */ #define k_cHashElements 18836 #define k_cchMaxKey 83 #define k_cKeys 10538 [...12173 lines suppressed...] { "FULLWIDTH POUND SIGN", 0xffe1 }, { "FULLWIDTH NOT SIGN", 0xffe2 }, { "FULLWIDTH MACRON", 0xffe3 }, { "FULLWIDTH BROKEN BAR", 0xffe4 }, { "FULLWIDTH YEN SIGN", 0xffe5 }, { "FULLWIDTH WON SIGN", 0xffe6 }, { "HALFWIDTH FORMS LIGHT VERTICAL", 0xffe8 }, { "HALFWIDTH LEFTWARDS ARROW", 0xffe9 }, { "HALFWIDTH UPWARDS ARROW", 0xffea }, { "HALFWIDTH RIGHTWARDS ARROW", 0xffeb }, { "HALFWIDTH DOWNWARDS ARROW", 0xffec }, { "HALFWIDTH BLACK SQUARE", 0xffed }, { "HALFWIDTH WHITE CIRCLE", 0xffee }, { "INTERLINEAR ANNOTATION ANCHOR", 0xfff9 }, { "INTERLINEAR ANNOTATION SEPARATOR", 0xfffa }, { "INTERLINEAR ANNOTATION TERMINATOR", 0xfffb }, { "OBJECT REPLACEMENT CHARACTER", 0xfffc }, { "REPLACEMENT CHARACTER", 0xfffd }, }; From python-dev@python.org Wed Jun 28 17:40:12 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 28 Jun 2000 09:40:12 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild ucnhash.dsp,NONE,1.1 Message-ID: <200006281640.JAA20477@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv20468/PCbuild Added Files: ucnhash.dsp Log Message: Marc-Andre Lemburg : MSVC project file for the new module ucnhash. This may have to be added to pcbuild.dsw with an dependancy on python16. By Bill Tutt. --- NEW FILE --- # Microsoft Developer Studio Project File - Name="ucnhash" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=ucnhash - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "ucnhash.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "ucnhash.mak" CFG="ucnhash - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "ucnhash - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "ucnhash - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "ucnhash - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "ucnhash___Win32_Release0" # PROP BASE Intermediate_Dir "ucnhash___Win32_Release0" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "ucnhash___Win32_Release0" # PROP Intermediate_Dir "ucnhash___Win32_Release0" # PROP Target_Dir "" F90=df.exe # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UCNHASH_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UCNHASH_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo 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 /dll /machine:I386 # ADD 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 /dll /machine:I386 !ELSEIF "$(CFG)" == "ucnhash - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "ucnhash___Win32_Debug0" # PROP BASE Intermediate_Dir "ucnhash___Win32_Debug0" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "ucnhash___Win32_Debug0" # PROP Intermediate_Dir "ucnhash___Win32_Debug0" # PROP Target_Dir "" F90=df.exe # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UCNHASH_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "UCNHASH_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo 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 /dll /debug /machine:I386 /pdbtype:sept # ADD 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 /dll /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "ucnhash - Win32 Release" # Name "ucnhash - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project From python-dev@python.org Wed Jun 28 17:41:49 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 28 Jun 2000 09:41:49 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_unicode,1.6,1.7 Message-ID: <200006281641.JAA20670@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv20577/Lib/test/output Modified Files: test_unicode Log Message: Marc-Andre Lemburg : Updated test output. Index: test_unicode =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_unicode,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** test_unicode 2000/04/13 14:10:04 1.6 --- test_unicode 2000/06/28 16:41:46 1.7 *************** *** 6,7 **** --- 6,10 ---- Testing standard mapping codecs... 0-127... 128-255... done. Testing Unicode string concatenation... done. + Testing General Unicode Character Name, and case insensitivity... done. + Testing misc. symbols for unicode character name expansion.... done. + Testing unicode character name expansion strict error handling.... done. From python-dev@python.org Wed Jun 28 17:42:16 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 28 Jun 2000 09:42:16 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules Makefile.pre.in,1.61,1.62 Message-ID: <200006281642.JAA20693@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv20682/Modules Modified Files: Makefile.pre.in Log Message: Marc-Andre Lemburg : Added new ucnhash module. Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Makefile.pre.in,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -r1.61 -r1.62 *** Makefile.pre.in 2000/03/10 23:12:33 1.61 --- Makefile.pre.in 2000/06/28 16:42:14 1.62 *************** *** 223,226 **** --- 223,227 ---- unicodedata.o: unicodedata.c unicodedatabase.o unicodedatabase.o: unicodedatabase.c unicodedatabase.h + ucnhash.o: ucnhash.c xxmodule.o: xxmodule.c yuvconvert.o: yuvconvert.c From python-dev@python.org Wed Jun 28 17:42:41 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 28 Jun 2000 09:42:41 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules Setup.in,1.102,1.103 Message-ID: <200006281642.JAA20715@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv20708/Modules Modified Files: Setup.in Log Message: Marc-Andre Lemburg : Added new ucnhash module by Bill Tutt. Index: Setup.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Setup.in,v retrieving revision 1.102 retrieving revision 1.103 diff -C2 -r1.102 -r1.103 *** Setup.in 2000/06/10 23:12:32 1.102 --- Setup.in 2000/06/28 16:42:39 1.103 *************** *** 140,143 **** --- 140,144 ---- unicodedata unicodedata.c unicodedatabase.c # static Unicode character database + ucnhash ucnhash.c # Unicode Character Name expansion hash table _locale _localemodule.c # access to ISO C locale support From python-dev@python.org Wed Jun 28 17:43:37 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 28 Jun 2000 09:43:37 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.29,2.30 Message-ID: <200006281643.JAA20750@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv20739/Objects Modified Files: unicodeobject.c Log Message: Marc-Andre Lemburg : Patch to the standard unicode-escape codec which dynamically loads the Unicode name to ordinal mapping from the module ucnhash. By Bill Tutt. Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.29 retrieving revision 2.30 diff -C2 -r2.29 -r2.30 *** unicodeobject.c 2000/06/28 08:11:47 2.29 --- unicodeobject.c 2000/06/28 16:43:35 2.30 *************** *** 67,70 **** --- 67,71 ---- #include "mymath.h" #include "unicodeobject.h" + #include #if defined(HAVE_LIMITS_H) *************** *** 1021,1024 **** --- 1022,1047 ---- } + static _Py_UCNHashAPI *pucnHash = NULL; + + static + int mystrnicmp(const char *s1, const char *s2, size_t count) + { + char c1, c2; + + if (count) + { + do + { + c1 = tolower(*(s1++)); + c2 = tolower(*(s2++)); + } + while(--count && c1 == c2); + + return c1 - c2; + } + + return 0; + } + PyObject *PyUnicode_DecodeUnicodeEscape(const char *s, int size, *************** *** 1124,1127 **** --- 1147,1248 ---- break; + case 'N': + /* Ok, we need to deal with Unicode Character Names now, + * make sure we've imported the hash table data... + */ + if (pucnHash == NULL) + { + PyObject *mod = 0, *v = 0; + + mod = PyImport_ImportModule("ucnhash"); + if (mod == NULL) + goto onError; + v = PyObject_GetAttrString(mod,"ucnhashAPI"); + Py_DECREF(mod); + if (v == NULL) + { + goto onError; + } + pucnHash = PyCObject_AsVoidPtr(v); + Py_DECREF(v); + if (pucnHash == NULL) + { + goto onError; + } + } + + if (*s == '{') + { + const char *start = s + 1; + const char *endBrace = start; + unsigned int uiValue; + unsigned long j; + + /* look for either the closing brace, or we + * exceed the maximum length of the unicode character names + */ + while (*endBrace != '}' && + (unsigned int)(endBrace - start) <= + pucnHash->cchMax && + endBrace < end) + { + endBrace++; + } + if (endBrace != end && *endBrace == '}') + { + j = pucnHash->hash(start, endBrace - start); + if (j > pucnHash->cKeys || + mystrnicmp( + start, + ((_Py_UnicodeCharacterName *) + (pucnHash->getValue(j)))->pszUCN, + (int)(endBrace - start)) != 0) + { + if (unicodeescape_decoding_error( + &s, &x, errors, + "Invalid Unicode Character Name")) + { + goto onError; + } + goto ucnFallthrough; + } + uiValue = ((_Py_UnicodeCharacterName *) + (pucnHash->getValue(j)))->uiValue; + if (uiValue < 1<<16) + { + /* In UCS-2 range, easy solution.. */ + *p++ = uiValue; + } + else + { + /* Oops, its in UCS-4 space, */ + /* compute and append the two surrogates: */ + /* translate from 10000..10FFFF to 0..FFFFF */ + uiValue -= 0x10000; + + /* high surrogate = top 10 bits added to D800 */ + *p++ = 0xD800 + (uiValue >> 10); + + /* low surrogate = bottom 10 bits added to DC00 */ + *p++ = 0xDC00 + (uiValue & ~0xFC00); + } + s = endBrace + 1; + } + else + { + if (unicodeescape_decoding_error( + &s, &x, errors, + "Unicode name missing closing brace")) + goto onError; + goto ucnFallthrough; + } + break; + } + if (unicodeescape_decoding_error( + &s, &x, errors, + "Missing opening brace for Unicode Character Name escape")) + goto onError; + ucnFallthrough: + /* fall through on purpose */ default: *p++ = '\\'; From python-dev@python.org Wed Jun 28 17:40:40 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 09:40:40 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules posixmodule.c,2.136,2.137 Message-ID: <200006281640.JAA20510@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv20497/Modules Modified Files: posixmodule.c Log Message: Thomas Wouters : This patch adds the openpty() and forkpty() library calls to posixmodule.c, when they are available on the target system. (glibc-2.1-based Linux systems, FreeBSD and BSDI at least, probably the other BSD-based systems as well.) Lib/pty.py is also rewritten to use openpty when available, but falls back to the old SGI method or the "manual" BSD open-a-pty code. Openpty() is necessary to use the Unix98 ptys under Linux 2.2, or when using non-standard tty names under (at least) BSDI, which is why I needed it, myself ;-) forkpty() is included for symmetry. Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.136 retrieving revision 2.137 diff -C2 -r2.136 -r2.137 *** posixmodule.c 2000/06/06 20:52:17 2.136 --- posixmodule.c 2000/06/28 16:40:38 2.137 *************** *** 1732,1735 **** --- 1732,1793 ---- #endif + #if defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) + #ifdef HAVE_PTY_H + #include + #else + #ifdef HAVE_LIBUTIL_H + #include + #else + /* BSDI does not supply a prototype for the 'openpty' and 'forkpty' + functions, eventhough they are included in libutil. */ + #include + extern int openpty(int *, int *, char *, struct termios *, struct winsize *); + extern int forkpty(int *, char *, struct termios *, struct winsize *); + #endif /* HAVE_LIBUTIL_H */ + #endif /* HAVE_PTY_H */ + #endif /* defined(HAVE_OPENPTY) or defined(HAVE_FORKPTY) */ + + #ifdef HAVE_OPENPTY + static char posix_openpty__doc__[] = + "openpty() -> (master_fd, slave_fd)\n\ + Open a pseudo-terminal, returning open fd's for both master and slave end.\n"; + + static PyObject * + posix_openpty(self, args) + PyObject *self; + PyObject *args; + { + int master_fd, slave_fd; + if (!PyArg_ParseTuple(args, ":openpty")) + return NULL; + if (openpty(&master_fd, &slave_fd, NULL, NULL, NULL) != 0) + return posix_error(); + return Py_BuildValue("(ii)", master_fd, slave_fd); + } + #endif + + #ifdef HAVE_FORKPTY + static char posix_forkpty__doc__[] = + "forkpty() -> (pid, master_fd)\n\ + Fork a new process with a new pseudo-terminal as controlling tty.\n\n\ + Like fork(), return 0 as pid to child process, and PID of child to parent.\n\ + To both, return fd of newly opened pseudo-terminal.\n"; + + static PyObject * + posix_forkpty(self, args) + PyObject *self; + PyObject *args; + { + int master_fd, pid; + + if (!PyArg_ParseTuple(args, ":forkpty")) + return NULL; + pid = forkpty(&master_fd, NULL, NULL, NULL); + if (pid == -1) + return posix_error(); + PyOS_AfterFork(); + return Py_BuildValue("(ii)", pid, master_fd); + } + #endif #ifdef HAVE_GETEGID *************** *** 4515,4518 **** --- 4573,4582 ---- {"fork", posix_fork, METH_VARARGS, posix_fork__doc__}, #endif /* HAVE_FORK */ + #ifdef HAVE_OPENPTY + {"openpty", posix_openpty, METH_VARARGS, posix_openpty__doc__}, + #endif /* HAVE_OPENPTY */ + #ifdef HAVE_FORKPTY + {"forkpty", posix_forkpty, METH_VARARGS, posix_forkpty__doc__}, + #endif /* HAVE_FORKPTY */ #ifdef HAVE_GETEGID {"getegid", posix_getegid, METH_VARARGS, posix_getegid__doc__}, From python-dev@python.org Wed Jun 28 17:40:41 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 09:40:41 -0700 Subject: [Python-checkins] CVS: python/dist/src configure,1.117,1.118 configure.in,1.125,1.126 Message-ID: <200006281640.JAA20519@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv20497 Modified Files: configure configure.in Log Message: Thomas Wouters : This patch adds the openpty() and forkpty() library calls to posixmodule.c, when they are available on the target system. (glibc-2.1-based Linux systems, FreeBSD and BSDI at least, probably the other BSD-based systems as well.) Lib/pty.py is also rewritten to use openpty when available, but falls back to the old SGI method or the "manual" BSD open-a-pty code. Openpty() is necessary to use the Unix98 ptys under Linux 2.2, or when using non-standard tty names under (at least) BSDI, which is why I needed it, myself ;-) forkpty() is included for symmetry. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.117 retrieving revision 1.118 diff -C2 -r1.117 -r1.118 *** configure 2000/06/18 15:07:39 1.117 --- configure 2000/06/28 16:40:38 1.118 *************** *** 4,8 **** # Guess values for system-dependent variables and create Makefiles. ! # Generated automatically using autoconf version 2.13 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # --- 4,8 ---- # Guess values for system-dependent variables and create Makefiles. ! # Generated automatically using autoconf version 2.14.1 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. [...3885 lines suppressed...] ! echo "$CONFIG_STATUS generated by autoconf version 2.13" exit 0 ;; -help | --help | --hel | --he | --h) --- 5673,5677 ---- exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) ! echo "$CONFIG_STATUS generated by autoconf version 2.14.1" exit 0 ;; -help | --help | --hel | --he | --h) *************** *** 5746,5749 **** chmod +x $CONFIG_STATUS rm -fr confdefs* $ac_clean_files ! test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 --- 5971,5974 ---- chmod +x $CONFIG_STATUS rm -fr confdefs* $ac_clean_files ! test "$no_create" = yes || $SHELL $CONFIG_STATUS || exit 1 Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.125 retrieving revision 1.126 diff -C2 -r1.125 -r1.126 *** configure.in 2000/06/18 14:54:13 1.125 --- configure.in 2000/06/28 16:40:38 1.126 *************** *** 358,362 **** sys/audioio.h sys/file.h sys/lock.h \ sys/param.h sys/select.h sys/socket.h sys/time.h sys/times.h \ ! sys/un.h sys/utsname.h sys/wait.h) AC_HEADER_DIRENT --- 358,362 ---- sys/audioio.h sys/file.h sys/lock.h \ sys/param.h sys/select.h sys/socket.h sys/time.h sys/times.h \ ! sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h) AC_HEADER_DIRENT *************** *** 771,774 **** --- 771,779 ---- tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \ truncate uname waitpid) + + # check for openpty and forkpty + + AC_CHECK_FUNCS(openpty,, AC_CHECK_LIB(util,openpty, [AC_DEFINE(HAVE_OPENPTY)] [LIBS="$LIBS -lutil"])) + AC_CHECK_FUNCS(forkpty,, AC_CHECK_LIB(util,forkpty, [AC_DEFINE(HAVE_FORKPTY)] [LIBS="$LIBS -lutil"])) # check for long file support functions From python-dev@python.org Wed Jun 28 17:40:47 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 28 Jun 2000 09:40:47 -0700 Subject: [Python-checkins] CVS: python/dist/src/Tools/perfecthash - New directory Message-ID: <200006281640.JAA20543@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Tools/perfecthash In directory slayer.i.sourceforge.net:/tmp/cvs-serv20531/Tools/perfecthash Log Message: Directory /cvsroot/python/python/dist/src/Tools/perfecthash added to the repository From python-dev@python.org Wed Jun 28 17:40:40 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 09:40:40 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib pty.py,1.3,1.4 Message-ID: <200006281640.JAA20514@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv20497/Lib Modified Files: pty.py Log Message: Thomas Wouters : This patch adds the openpty() and forkpty() library calls to posixmodule.c, when they are available on the target system. (glibc-2.1-based Linux systems, FreeBSD and BSDI at least, probably the other BSD-based systems as well.) Lib/pty.py is also rewritten to use openpty when available, but falls back to the old SGI method or the "manual" BSD open-a-pty code. Openpty() is necessary to use the Unix98 ptys under Linux 2.2, or when using non-standard tty names under (at least) BSDI, which is why I needed it, myself ;-) forkpty() is included for symmetry. Index: pty.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pty.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** pty.py 2000/02/04 15:10:34 1.3 --- pty.py 2000/06/28 16:40:38 1.4 *************** *** 17,23 **** CHILD = 0 def master_open(): """Open pty master and return (master_fd, tty_name). ! SGI and Linux/BSD version.""" try: import sgi --- 17,51 ---- CHILD = 0 + def openpty(): + """openpty() -> (master_fd, slave_fd) + Open a pty master/slave pair, using os.openpty() if possible.""" + + try: + return os.openpty() + except (AttributeError, OSError): + pass + master_fd, slave_name = _open_terminal() + slave_fd = _slave_open(slave_name) + return master_fd, slave_fd + def master_open(): + """master_open() -> (master_fd, slave_name) + Open a pty master and return the fd, and the filename of the slave end. + Deprecated, use openpty() instead.""" + + try: + master_fd, slave_fd = os.openpty() + except (AttributeError, OSError): + pass + else: + slave_name = os.ttyname(slave_fd) + os.close(slave_fd) + return master_fd, slave_name + + return _open_terminal() + + def _open_terminal(): """Open pty master and return (master_fd, tty_name). ! SGI and generic BSD version, for when openpty() fails.""" try: import sgi *************** *** 41,60 **** def slave_open(tty_name): ! """Open the pty slave and acquire the controlling terminal. ! Return the file descriptor. Linux version.""" ! # (Should be universal? --Guido) return os.open(tty_name, FCNTL.O_RDWR) def fork(): ! """Fork and make the child a session leader with a controlling terminal. ! Return (pid, master_fd).""" ! master_fd, tty_name = master_open() pid = os.fork() if pid == CHILD: # Establish a new session. os.setsid() - - # Acquire controlling terminal. - slave_fd = slave_open(tty_name) os.close(master_fd) --- 69,101 ---- def slave_open(tty_name): ! """slave_open(tty_name) -> slave_fd ! Open the pty slave and acquire the controlling terminal, returning ! opened filedescriptor. ! Deprecated, use openpty() instead.""" ! return os.open(tty_name, FCNTL.O_RDWR) def fork(): ! """fork() -> (pid, master_fd) ! Fork and make the child a session leader with a controlling terminal.""" ! ! try: ! pid, fd = os.forkpty() ! except (AttributeError, OSError): ! pass ! else: ! if pid == CHILD: ! try: ! os.setsid() ! except OSError: ! # os.forkpty() already set us session leader ! pass ! return pid, fd ! ! master_fd, slave_fd = openpty() pid = os.fork() if pid == CHILD: # Establish a new session. os.setsid() os.close(master_fd) *************** *** 69,73 **** return pid, master_fd ! def writen(fd, data): """Write all the data to a descriptor.""" while data != '': --- 110,114 ---- return pid, master_fd ! def _writen(fd, data): """Write all the data to a descriptor.""" while data != '': *************** *** 75,83 **** data = data[n:] ! def read(fd): """Default read function.""" return os.read(fd, 1024) ! def copy(master_fd, master_read=read, stdin_read=read): """Parent copy loop. Copies --- 116,124 ---- data = data[n:] ! def _read(fd): """Default read function.""" return os.read(fd, 1024) ! def _copy(master_fd, master_read=_read, stdin_read=_read): """Parent copy loop. Copies *************** *** 92,98 **** if STDIN_FILENO in rfds: data = stdin_read(STDIN_FILENO) ! writen(master_fd, data) ! def spawn(argv, master_read=read, stdin_read=read): """Create a spawned process.""" if type(argv) == type(''): --- 133,139 ---- if STDIN_FILENO in rfds: data = stdin_read(STDIN_FILENO) ! _writen(master_fd, data) ! def spawn(argv, master_read=_read, stdin_read=_read): """Create a spawned process.""" if type(argv) == type(''): *************** *** 104,108 **** tty.setraw(STDIN_FILENO) try: ! copy(master_fd, master_read, stdin_read) except: tty.tcsetattr(STDIN_FILENO, tty.TCSAFLUSH, mode) --- 145,149 ---- tty.setraw(STDIN_FILENO) try: ! _copy(master_fd, master_read, stdin_read) except: tty.tcsetattr(STDIN_FILENO, tty.TCSAFLUSH, mode) From python-dev@python.org Wed Jun 28 17:41:25 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 28 Jun 2000 09:41:25 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_unicode.py,1.14,1.15 Message-ID: <200006281641.JAA20571@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv20564/Lib/test Modified Files: test_unicode.py Log Message: Marc-Andre Lemburg : Added tests for the new Unicode character name support in the standard unicode-escape codec. Index: test_unicode.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** test_unicode.py 2000/06/14 09:17:25 1.14 --- test_unicode.py 2000/06/28 16:41:23 1.15 *************** *** 409,410 **** --- 409,485 ---- assert ("abc" "def" u"ghi") == u"abcdefghi" print 'done.' + + print 'Testing General Unicode Character Name, and case insensitivity...', + # General and case insensitivity test: + s = u"\N{LATIN CAPITAL LETTER T}" \ + u"\N{LATIN SMALL LETTER H}" \ + u"\N{LATIN SMALL LETTER E}" \ + u"\N{SPACE}" \ + u"\N{LATIN SMALL LETTER R}" \ + u"\N{LATIN CAPITAL LETTER E}" \ + u"\N{LATIN SMALL LETTER D}" \ + u"\N{SPACE}" \ + u"\N{LATIN SMALL LETTER f}" \ + u"\N{LATIN CAPITAL LeTtEr o}" \ + u"\N{LATIN SMaLl LETTER x}" \ + u"\N{SPACE}" \ + u"\N{LATIN SMALL LETTER A}" \ + u"\N{LATIN SMALL LETTER T}" \ + u"\N{LATIN SMALL LETTER E}" \ + u"\N{SPACE}" \ + u"\N{LATIN SMALL LETTER T}" \ + u"\N{LATIN SMALL LETTER H}" \ + u"\N{LATIN SMALL LETTER E}" \ + u"\N{SpAcE}" \ + u"\N{LATIN SMALL LETTER S}" \ + u"\N{LATIN SMALL LETTER H}" \ + u"\N{LATIN SMALL LETTER E}" \ + u"\N{LATIN SMALL LETTER E}" \ + u"\N{LATIN SMALL LETTER P}" \ + u"\N{FULL STOP}" + assert s == u"The rEd fOx ate the sheep.", s + print "done." + + # misc. symbol testing + print "Testing misc. symbols for unicode character name expansion....", + assert u"\N{PILCROW SIGN}" == u"\u00b6" + assert u"\N{REPLACEMENT CHARACTER}" == u"\uFFFD" + assert u"\N{HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK}" == u"\uFF9F" + assert u"\N{FULLWIDTH LATIN SMALL LETTER A}" == u"\uFF41" + print "done." + + + # strict error testing: + print "Testing unicode character name expansion strict error handling....", + k_cchMaxUnicodeName = 83 + + s = "\N{" + "1" * (k_cchMaxUnicodeName + 2) + "}" + try: + unicode(s, 'unicode-escape', 'strict') + except UnicodeError: + pass + else: + raise AssertionError, "failed to raise an exception when presented " \ + "with a UCN > k_cchMaxUnicodeName" + try: + unicode("\N{blah}", 'unicode-escape', 'strict') + except UnicodeError: + pass + else: + raise AssertionError, "failed to raise an exception when given a bogus character name" + + try: + unicode("\N{SPACE", 'unicode-escape', 'strict') + except UnicodeError: + pass + else: + raise AssertionError, "failed to raise an exception for a missing closing brace." + + try: + unicode("\NSPACE", 'unicode-escape', 'strict') + except UnicodeError: + pass + else: + raise AssertionError, "failed to raise an exception for a missing opening brace." + print "done." + From python-dev@python.org Wed Jun 28 17:48:07 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 28 Jun 2000 09:48:07 -0700 Subject: [Python-checkins] CVS: python/dist/src/Tools/perfecthash perfhash.c,NONE,1.1 Message-ID: <200006281648.JAA20984@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Tools/perfecthash In directory slayer.i.sourceforge.net:/tmp/cvs-serv20978/Tools/perfecthash Added Files: perfhash.c Log Message: Marc-Andre Lemburg : Utility extension module needed by perfect_hash.py By Bill Tutt. --- NEW FILE --- #include static PyObject * hashFunction(PyObject *self, PyObject *args, PyObject *kw) { PyStringObject *a; register int len; register unsigned char *p; register long x; long lSeed; unsigned long cchSeed; if (!PyArg_ParseTuple(args, "iiO:hash", &lSeed, &cchSeed, &a)) return NULL; if (!PyString_Check(a)) { PyErr_SetString(PyExc_TypeError, "arg 3 needs to be a string"); return NULL; } len = a->ob_size; p = (unsigned char *) a->ob_sval; x = lSeed; while (--len >= 0) x = (1000003*x) ^ *p++; x ^= a->ob_size + cchSeed; if (x == -1) x = -2; return PyInt_FromLong(x); } static PyObject * calcSeed(PyObject *self, PyObject *args, PyObject *kw) { PyStringObject *a; register int len; register unsigned char *p; register long x; if (!PyString_Check(args)) { PyErr_SetString(PyExc_TypeError, "arg 1 expected a string, but didn't get it."); return NULL; } a = (PyStringObject *)args; len = a->ob_size; p = (unsigned char *) a->ob_sval; x = *p << 7; while (--len >= 0) x = (1000003*x) ^ *p++; return PyInt_FromLong(x); } static struct PyMethodDef hashMethods[] = { { "calcSeed", calcSeed, 0, NULL }, { "hash", hashFunction, 0, NULL }, { NULL, NULL, 0, NULL } /* sentinel */ }; #ifdef _MSC_VER _declspec(dllexport) #endif void initperfhash() { PyObject *m; m = Py_InitModule4("perfhash", hashMethods, NULL, NULL, PYTHON_API_VERSION); if ( m == NULL ) Py_FatalError("can't initialize module hashModule"); } From python-dev@python.org Wed Jun 28 17:49:32 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 28 Jun 2000 09:49:32 -0700 Subject: [Python-checkins] CVS: python/dist/src/Tools/perfecthash GenUCNHash.py,NONE,1.1 Message-ID: <200006281649.JAA21034@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Tools/perfecthash In directory slayer.i.sourceforge.net:/tmp/cvs-serv21021/Tools/perfecthash Added Files: GenUCNHash.py Log Message: Marc-Andre Lemburg : Generator for the new ucnhash module (ucnhash.h|c). Uses perfect_hash.py to create the ucnhash module. --- NEW FILE --- #! /usr/bin/env python import sys import string import perfect_hash # This is a user of perfect_hash.py # that takes as input the UnicodeData.txt file available from: # ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt # It generates a hash table from Unicode Character Name -> # unicode code space value. # These variables determine which hash function is tried first. # Yields a multiple of 1.7875 for UnicodeData.txt on 2000/06/24/ f1Seed = 1694245428 f2Seed = -1917331657 # Maximum allowed multipler, if this isn't None then instead of continually # increasing C, it resets it back to initC to keep searching for # a solution. minC = 1.7875 # Initial multiplier for trying to find a perfect hash function. initC = 1.7875 moduleName = "ucnhash" dataArrayName = "aucn" dataArrayType = "_Py_UnicodeCharacterName" headerFileName = "ucnhash.h" cFileName = "ucnhash.c" structName = "_Py_UCNHashAPI" keys = [] hashData = {} def generateOutputFiles(perfHash, hashData): header = perfHash.generate_header(structName) header = header + """ typedef struct { const char *pszUCN; unsigned int uiValue; } _Py_UnicodeCharacterName; """ code = perfHash.generate_code(moduleName, dataArrayName, dataArrayType, structName) out = open(headerFileName, "w") out.write(header) out = open(cFileName, "w") out.write("#include <%s>\n" % headerFileName) out.write(code) perfHash.generate_graph(out) out.write(""" static const _Py_UnicodeCharacterName aucn[] = { """) for i in xrange(len(keys)): v = hashData[keys[i][0]] out.write(' { "' + keys[i][0] + '", ' + hex(v) + " }," + "\n") out.write("};\n\n") sys.stderr.write('\nGenerated output files: \n') sys.stderr.write('%s\n%s\n' % (headerFileName, cFileName)) def main(): # Suck in UnicodeData.txt and spit out the generated files. input = open(sys.argv[1], 'r') i = 0 while 1: line = input.readline() if line == "": break fields = string.split(line, ';') if len(fields) < 2: sys.stderr.write('Ill-formated line!\n') sys.stderr.write('line #: %d\n' % (i + 1)) sys.exit() data, key = fields[:2] key = string.strip( key ) # Any name starting with '<' is a control, or start/end character, # so skip it... if key[0] == "<": continue hashcode = i i = i + 1 # force the name to uppercase keys.append( (string.upper(key),hashcode) ) data = string.atoi(data, 16) hashData[key] = data input.close() sys.stderr.write('%i key/hash pairs read\n' % len(keys) ) perfHash = perfect_hash.generate_hash(keys, 1, minC, initC, f1Seed, f2Seed, # increment, tries 0.0025, 50) generateOutputFiles(perfHash, hashData) if __name__ == '__main__': if len(sys.argv) == 1: sys.stdout = sys.stderr print 'Usage: %s ' % sys.argv[0] print ' The input file needs to be UnicodeData.txt' sys.exit() main() From python-dev@python.org Wed Jun 28 17:53:18 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Wed, 28 Jun 2000 09:53:18 -0700 Subject: [Python-checkins] CVS: python/dist/src/Tools/perfecthash perfect_hash.py,NONE,1.1 Message-ID: <200006281653.JAA21293@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Tools/perfecthash In directory slayer.i.sourceforge.net:/tmp/cvs-serv21286/Tools/perfecthash Added Files: perfect_hash.py Log Message: Marc-Andre Lemburg : Perfect hash table generator. Outputs a Python extension module which provides access to the hash table (which is stored in static C data) using custom code. This module can currently only generates code for the ucnhash module, but can easily be adapted to produce perfect hash tables for other tasks where fast lookup in large tables is needed. By Bill Tutt. --- NEW FILE --- #!/usr/bin/env/python # perfect_hash.py # # Outputs C code for a minimal perfect hash. # The hash is produced using the algorithm described in # "Optimal algorithms for minimal perfect hashing", # G. Havas, B.S. Majewski. Available as a technical report # from the CS department, University of Queensland # (ftp://ftp.cs.uq.oz.au/). # # This is a modified version of Andrew Kuchling's code # (http://starship.python.net/crew/amk/python/code/perfect-hash.html) # and generates C fragments suitable for compilation as a Python # extension module. # # Difference between this algorithm and gperf: # Gperf will complete in finite time with a successful function, # or by giving up. # This algorithm may never complete, although it is extremely likely # when c >= 2. # The algorithm works like this: # 0) You have K keys, that you want to perfectly hash to a bunch # of hash values. # # 1) Choose a number N larger than K. This is the number of # vertices in a graph G, and also the size of the resulting table. # # 2) Pick two random hash functions f1, f2, that output values from # 0...N-1. # # 3) for key in keys: # h1 = f1(key) ; h2 = f2(key) # Draw an edge between vertices h1 and h2 of the graph. # Associate the desired hash value with that edge. # # 4) Check if G is acyclic; if not, go back to step 1 and pick a bigger N. # # 5) Assign values to each vertex such that, for each edge, you can # add the values for the two vertices and get the desired value # for that edge -- which is the desired hash key. This task is # dead easy, because the graph is acyclic. This is done by # picking a vertex V, and assigning it a value of 0. You then do a # depth-first search, assigning values to new vertices so that # they sum up properly. # # 6) f1, f2, and G now make up your perfect hash function. import sys, whrandom, string import pprint import perfhash import time class Hash: """Random hash function For simplicity and speed, this doesn't implement any byte-level hashing scheme. Instead, a random string is generated and prefixing to str(key), and then Python's hashing function is used.""" def __init__(self, N, caseInsensitive=0): self.N = N junk = "" for i in range(10): junk = junk + whrandom.choice(string.letters + string.digits) self.junk = junk self.caseInsensitive = caseInsensitive self.seed = perfhash.calcSeed(junk) def __call__(self, key): key = str(key) if self.caseInsensitive: key = string.upper(key) x = perfhash.hash(self.seed, len(self.junk), key) % self.N #h = hash(self.junk + key) % self.N #assert x == h return x def generate_code(self): s = """{ register int len; register unsigned char *p; register long x; len = cch; p = (unsigned char *) key; x = %(junkSeed)d; while (--len >= 0) x = (1000003*x) ^ """ % \ { "lenJunk" : len(self.junk), "junkSeed" : self.seed, } if self.caseInsensitive: s = s + "toupper(*(p++));" else: s = s + "*(p++);" s = s + """ x ^= cch + %(lenJunk)d; if (x == -1) x = -2; x %%= k_cHashElements; /* ensure the returned value is positive so we mimic Python's %% operator */ if (x < 0) x += k_cHashElements; return x; } """ % { "lenJunk" : len(self.junk), "junkSeed" : self.seed, } return s WHITE, GREY, BLACK = 0,1,2 class Graph: """Graph class. This class isn't particularly efficient or general, and only has the features I needed to implement this algorithm. num_vertices -- number of vertices edges -- maps 2-tuples of vertex numbers to the value for this edge. If there's an edge between v1 and v2 (v1 vertex2: vertex1, vertex2 = vertex2, vertex1 # if self.edges.has_key( (vertex1, vertex2) ): # raise ValueError, 'Collision: vertices already connected' self.edges[ (vertex1, vertex2) ] = value # Add vertices to each other's reachable list if not self.reachable_list.has_key( vertex1 ): self.reachable_list[ vertex1 ] = [vertex2] else: self.reachable_list[vertex1].append(vertex2) if not self.reachable_list.has_key( vertex2 ): self.reachable_list[ vertex2 ] = [vertex1] else: self.reachable_list[vertex2].append(vertex1) def get_edge_value(self, vertex1, vertex2): """Retrieve the value corresponding to the edge between 'vertex1' and 'vertex2'. Raises KeyError if no such edge""" if vertex1 > vertex2: vertex1, vertex2 = vertex2, vertex1 return self.edges[ (vertex1, vertex2) ] def is_acyclic(self): "Returns true if the graph is acyclic, otherwise false" # This is done by doing a depth-first search of the graph; # painting each vertex grey and then black. If the DFS # ever finds a vertex that isn't white, there's a cycle. colour = {} for i in range(self.num_vertices): colour[i] = WHITE # Loop over all vertices, taking white ones as starting # points for a traversal. for i in range(self.num_vertices): if colour[i] == WHITE: # List of vertices to visit visit_list = [ (None,i) ] # Do a DFS while visit_list: # Colour this vertex grey. parent, vertex = visit_list[0] ; del visit_list[0] colour[vertex] = GREY # Make copy of list of neighbours, removing the vertex # we arrived here from. neighbours = self.reachable_list.get(vertex, []) [:] if parent in neighbours: neighbours.remove( parent ) for neighbour in neighbours: if colour[neighbour] == WHITE: visit_list.insert(0, (vertex, neighbour) ) elif colour[neighbour] != WHITE: # Aha! Already visited this node, # so the graph isn't acyclic. return 0 colour[vertex] = BLACK # We got through, so the graph is acyclic. return 1 def assign_values(self): """Compute values for each vertex, so that they sum up properly to the associated value for each edge.""" # Also done with a DFS; I simply copied the DFS code # from is_acyclic(). (Should generalize the logic so # one function could be used from both methods, # but I couldn't be bothered.) colour = {} for i in range(self.num_vertices): colour[i] = WHITE # Loop over all vertices, taking white ones as starting # points for a traversal. for i in range(self.num_vertices): if colour[i] == WHITE: # Set this vertex's value, arbitrarily, to zero. self.set_vertex_value( i, 0 ) # List of vertices to visit visit_list = [ (None,i) ] # Do a DFS while visit_list: # Colour this vertex grey. parent, vertex = visit_list[0] ; del visit_list[0] colour[vertex] = GREY # Make copy of list of neighbours, removing the vertex # we arrived here from. neighbours = self.reachable_list.get(vertex, []) [:] if parent in neighbours: neighbours.remove( parent ) for neighbour in self.reachable_list.get(vertex, []): edge_value = self.get_edge_value( vertex, neighbour ) if colour[neighbour] == WHITE: visit_list.insert(0, (vertex, neighbour) ) # Set new vertex's value to the desired # edge value, minus the value of the # vertex we came here from. new_val = (edge_value - self.get_vertex_value( vertex ) ) self.set_vertex_value( neighbour, new_val % self.num_vertices) colour[vertex] = BLACK # Returns nothing return def __getitem__(self, index): if index < self.num_vertices: return index raise IndexError def get_vertex_value(self, vertex): "Get value for a vertex" return self.values[ vertex ] def set_vertex_value(self, vertex, value): "Set value for a vertex" self.values[ vertex ] = value def generate_code(self, out, width = 70): "Return nicely formatted table" out.write("{ ") pos = 0 for v in self.values: v=str(v)+', ' out.write(v) pos = pos + len(v) + 1 if pos > width: out.write('\n '); pos = 0 out.write('};\n') class PerfectHash: def __init__(self, cchMax, f1, f2, G, cHashElements, cKeys, maxHashValue): self.cchMax = cchMax self.f1 = f1 self.f2 = f2 self.G = G self.cHashElements = cHashElements self.cKeys = cKeys # determine the necessary type for storing our hash function # helper table: self.type = self.determineType(maxHashValue) def generate_header(self, structName): header = """ #include #include /* --- C API ----------------------------------------------------*/ /* C API for usage by other Python modules */ typedef struct %(structName)s { unsigned long cKeys; unsigned long cchMax; unsigned long (*hash)(const char *key, unsigned int cch); const void *(*getValue)(unsigned long iKey); } %(structName)s; """ % { "structName" : structName } return header def determineType(self, maxHashValue): if maxHashValue <= 255: return "unsigned char" elif maxHashValue <= 65535: return "unsigned short" else: # Take the cheesy way out... return "unsigned long" def generate_code(self, moduleName, dataArrayName, dataArrayType, structName): # Output C code for the hash functions and tables code = """ /* * The hash is produced using the algorithm described in * "Optimal algorithms for minimal perfect hashing", * G. Havas, B.S. Majewski. Available as a technical report * from the CS department, University of Queensland * (ftp://ftp.cs.uq.oz.au/). * * Generated using a heavily tweaked version of Andrew Kuchling's * perfect_hash.py: * http://starship.python.net/crew/amk/python/code/perfect-hash.html * * Generated on: %s */ """ % time.ctime(time.time()) # MSVC SP3 was complaining when I actually used a global constant code = code + """ #define k_cHashElements %i #define k_cchMaxKey %d #define k_cKeys %i """ % (self.cHashElements, self.cchMax, self.cKeys) code = code + """ static const %s G[k_cHashElements]; static const %s %s[k_cKeys]; """ % (self.type, dataArrayType, dataArrayName) code = code + """ static long f1(const char *key, unsigned int cch) """ code = code + self.f1.generate_code() code = code + """ static long f2(const char *key, unsigned int cch) """ code = code + self.f2.generate_code() code = code + """ static unsigned long hash(const char *key, unsigned int cch) { return ((unsigned long)(G[ f1(key, cch) ]) + (unsigned long)(G[ f2(key, cch) ]) ) %% k_cHashElements; } const void *getValue(unsigned long iKey) { return &%(dataArrayName)s[iKey]; } /* Helper for adding objects to dictionaries. Check for errors with PyErr_Occurred() */ static void insobj(PyObject *dict, char *name, PyObject *v) { PyDict_SetItemString(dict, name, v); Py_XDECREF(v); } static const %(structName)s hashAPI = { k_cKeys, k_cchMaxKey, &hash, &getValue, }; static PyMethodDef Module_methods[] = { {NULL, NULL}, }; static char *Module_docstring = "%(moduleName)s hash function module"; /* Error reporting for module init functions */ #define Py_ReportModuleInitError(modname) { \\ PyObject *exc_type, *exc_value, *exc_tb; \\ PyObject *str_type, *str_value; \\ \\ /* Fetch error objects and convert them to strings */ \\ PyErr_Fetch(&exc_type, &exc_value, &exc_tb); \\ if (exc_type && exc_value) { \\ str_type = PyObject_Str(exc_type); \\ str_value = PyObject_Str(exc_value); \\ } \\ else { \\ str_type = NULL; \\ str_value = NULL; \\ } \\ /* Try to format a more informative error message using the \\ original error */ \\ if (str_type && str_value && \\ PyString_Check(str_type) && PyString_Check(str_value)) \\ PyErr_Format( \\ PyExc_ImportError, \\ "initialization of module "modname" failed " \\ "(%%s:%%s)", \\ PyString_AS_STRING(str_type), \\ PyString_AS_STRING(str_value)); \\ else \\ PyErr_SetString( \\ PyExc_ImportError, \\ "initialization of module "modname" failed"); \\ Py_XDECREF(str_type); \\ Py_XDECREF(str_value); \\ Py_XDECREF(exc_type); \\ Py_XDECREF(exc_value); \\ Py_XDECREF(exc_tb); \\ } /* Create PyMethodObjects and register them in the module\'s dict */ DL_EXPORT(void) init%(moduleName)s(void) { PyObject *module, *moddict; /* Create module */ module = Py_InitModule4("%(moduleName)s", /* Module name */ Module_methods, /* Method list */ Module_docstring, /* Module doc-string */ (PyObject *)NULL, /* always pass this as *self */ PYTHON_API_VERSION); /* API Version */ if (module == NULL) goto onError; /* Add some constants to the module\'s dict */ moddict = PyModule_GetDict(module); if (moddict == NULL) goto onError; /* Export C API */ insobj( moddict, "%(moduleName)sAPI", PyCObject_FromVoidPtr((void *)&hashAPI, NULL)); onError: /* Check for errors and report them */ if (PyErr_Occurred()) Py_ReportModuleInitError("%(moduleName)s"); return; } """ % { "moduleName" : moduleName, "dataArrayName" : dataArrayName, "structName" : structName, } return code def generate_graph(self, out): out.write(""" static const unsigned short G[] = """) self.G.generate_code(out) def generate_hash(keys, caseInsensitive=0, minC=None, initC=None, f1Seed=None, f2Seed=None, cIncrement=None, cTries=None): """Print out code for a perfect minimal hash. Input is a list of (key, desired hash value) tuples. """ # K is the number of keys. K = len(keys) # We will be generating graphs of size N, where N = c * K. # The larger C is, the fewer trial graphs will need to be made, but # the resulting table is also larger. Increase this starting value # if you're impatient. After 50 failures, c will be increased by 0.025. if initC is None: initC = 1.5 c = initC if cIncrement is None: cIncrement = 0.0025 if cTries is None: cTries = 50 # Number of trial graphs so far num_graphs = 0 sys.stderr.write('Generating graphs... ') while 1: # N is the number of vertices in the graph G N = int(c*K) num_graphs = num_graphs + 1 if (num_graphs % cTries) == 0: # Enough failures at this multiplier, # increase the multiplier and keep trying.... c = c + cIncrement # Whats good with searching for a better # hash function if we exceed the size # of a function we've generated in the past.... if minC is not None and \ c > minC: c = initC sys.stderr.write(' -- c > minC, resetting c to %0.4f\n' % c) else: sys.stderr.write(' -- increasing c to %0.4f\n' % c) sys.stderr.write('Generating graphs... ') # Output a progress message sys.stderr.write( str(num_graphs) + ' ') sys.stderr.flush() # Create graph w/ N vertices G = Graph(N) # Save the seeds used to generate # the following two hash functions. _seeds = whrandom._inst._seed # Create 2 random hash functions f1 = Hash(N, caseInsensitive) f2 = Hash(N, caseInsensitive) # Set the initial hash function seed values if passed in. # Doing this protects our hash functions from # changes to whrandom's behavior. if f1Seed is not None: f1.seed = f1Seed f1Seed = None fSpecifiedSeeds = 1 if f2Seed is not None: f2.seed = f2Seed f2Seed = None fSpecifiedSeeds = 1 # Connect vertices given by the values of the two hash functions # for each key. Associate the desired hash value with each # edge. for k, v in keys: h1 = f1(k) ; h2 = f2(k) G.connect( h1,h2, v) # Check if the resulting graph is acyclic; if it is, # we're done with step 1. if G.is_acyclic(): break elif fSpecifiedSeeds: sys.stderr.write('\nThe initial f1/f2 seeds you specified didn\'t generate a perfect hash function: \n') sys.stderr.write('f1 seed: %s\n' % f1.seed) sys.stderr.write('f2 seed: %s\n' % f2.seed) sys.stderr.write('multipler: %s\n' % c) sys.stderr.write('Your data has likely changed, or you forgot what your initial multiplier should be.\n') sys.stderr.write('continuing the search for a perfect hash function......\n') fSpecifiedSeeds = 0 # Now we have an acyclic graph, so we assign values to each vertex # such that, for each edge, you can add the values for the two vertices # involved and get the desired value for that edge -- which is the # desired hash key. This task is dead easy, because the graph is acyclic. sys.stderr.write('\nAcyclic graph found; computing vertex values...\n') G.assign_values() sys.stderr.write('Checking uniqueness of hash values...\n') # Sanity check the result by actually verifying that all the keys # hash to the right value. cchMaxKey = 0 maxHashValue = 0 for k, v in keys: hash1 = G.values[ f1(k) ] hash2 = G.values[ f2(k) ] if hash1 > maxHashValue: maxHashValue = hash1 if hash2 > maxHashValue: maxHashValue = hash2 perfecthash = (hash1 + hash2) % N assert perfecthash == v cch = len(k) if cch > cchMaxKey: cchMaxKey = cch sys.stderr.write('Found perfect hash function!\n') sys.stderr.write('\nIn order to regenerate this hash function, \n') sys.stderr.write('you need to pass these following values back in:\n') sys.stderr.write('f1 seed: %s\n' % repr(f1.seed)) sys.stderr.write('f2 seed: %s\n' % repr(f2.seed)) sys.stderr.write('initial multipler: %s\n' % c) return PerfectHash(cchMaxKey, f1, f2, G, N, len(keys), maxHashValue) """ static PyObject *codec_tuple(PyObject *unicode, int len) { PyObject *v,*w; if (unicode == NULL) return NULL; v = PyTuple_New(2); if (v == NULL) { Py_DECREF(unicode); return NULL; } PyTuple_SET_ITEM(v,0,unicode); w = PyInt_FromLong(len); if (w == NULL) { Py_DECREF(v); return NULL; } PyTuple_SET_ITEM(v,1,w); return v; } static PyObject * ucn_decode(PyObject *self, PyObject *args) { const char *data; int size; const char *errors = NULL; PyObject *mapping = NULL; if (!PyArg_ParseTuple(args, "t#|z:ucn_decode", &data, &size, &errors)) return NULL; if (mapping == Py_None) mapping = NULL; return codec_tuple(PyUnicode_DecodeNamedUnicodeEscape(data, size, errors), size); } static PyMethodDef _codecs_functions[] = { { "ucn_decode", ucn_decode, 1 }, }; DL_EXPORT(void) init_ucn() { Py_InitModule("_ucn", _codecs_functions); } """ From python-dev@python.org Wed Jun 28 18:27:51 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 10:27:51 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libos.tex,1.40,1.41 libpty.tex,1.2,1.3 Message-ID: <200006281727.KAA30157@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv30149/lib Modified Files: libos.tex libpty.tex Log Message: Thomas Wouters : Documentation updates related to the addition of openpty() and forkpty(). Index: libos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -r1.40 -r1.41 *** libos.tex 2000/05/02 17:29:35 1.40 --- libos.tex 2000/06/28 17:27:48 1.41 *************** *** 368,371 **** --- 368,379 ---- \end{funcdesc} + \begin{funcdesc}{openpty}{} + Open a new pseudo-terminal pair. Return a pair of file descriptors + \code{(\var{master}, \var{slave})} for the pty and the tty, + respectively. For a (slightly) more portable approach, use the + \refmodule{pty}\refstmodindex{pty} module. + Availability: Some flavors of \UNIX{} + \end{funcdesc} + \begin{funcdesc}{pipe}{} Create a pipe. Return a pair of file descriptors \code{(\var{r}, *************** *** 790,793 **** --- 798,811 ---- process id in the parent. Availability: \UNIX{}. + \end{funcdesc} + + \begin{funcdesc}{forkpty}{} + Fork a child process, using a new pseudo-terminal as the child's + controlling terminal. Return a pair of \code{(\var{pid}, \var{fd})}, + where \var{pid} is \code{0} in the child, the new child's process id + in the parent, and \code{fd} is the file descriptor of the master end + of the pseudo-terminal. For a more portable approach, use the + \refmodule{pty} module. + Availability: Some flavors of \UNIX{} \end{funcdesc} Index: libpty.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpty.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** libpty.tex 2000/04/03 20:13:53 1.2 --- libpty.tex 2000/06/28 17:27:48 1.3 *************** *** 27,30 **** --- 27,37 ---- \end{funcdesc} + \begin{funcdesc}{openpty}{} + Open a new pseudo-terminal pair, using \function{os.openpty()} if + possible, or emulation code for SGI and generic \UNIX{} systems. + Return a pair of file descriptors \code{(\var{master}, \var{slave})}, + for the master and the slave end, respectively. + \end{funcdesc} + \begin{funcdesc}{spawn}{argv\optional{, master_read\optional{, stdin_read}}} Spawn a process, and connect its controlling terminal with the current From python-dev@python.org Wed Jun 28 18:49:32 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 10:49:32 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules arraymodule.c,2.40,2.41 Message-ID: <200006281749.KAA31301@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv31291/Modules Modified Files: arraymodule.c Log Message: Trent Mick : The cause: Relatively recent (last month) patches to getargs.c added overflow checking to the PyArg_Parse*() integral formatters thereby restricting 'b' to unsigned char value and 'h','i', and 'l' to signed integral values (i.e. if the incoming value is outside of the specified bounds you get an OverflowError, previous it silently overflowed). The problem: This broke the array module (as Fredrik pointed out) because *its* formatters relied on the loose allowance of signed and unsigned ranges being able to pass through PyArg_Parse*()'s formatters. The fix: This patch fixes the array module to work with the more strict bounds checking now in PyArg_Parse*(). How: If the type signature of a formatter in the arraymodule exactly matches one in PyArg_Parse*(), then use that directly. If there is no equivalent type signature in PyArg_Parse*() (e.g. there is no unsigned int formatter in PyArg_Parse*()), then use the next one up and do some extra bounds checking in the array module. This partially closes SourceForge patch #100506. Index: arraymodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/arraymodule.c,v retrieving revision 2.40 retrieving revision 2.41 diff -C2 -r2.40 -r2.41 *** arraymodule.c 2000/06/01 02:02:46 2.40 --- arraymodule.c 2000/06/28 17:49:30 2.41 *************** *** 115,123 **** PyObject *v; { ! char x; ! if (!PyArg_Parse(v, "b;array item must be integer", &x)) return -1; if (i >= 0) ! ((char *)ap->ob_item)[i] = x; return 0; } --- 115,136 ---- PyObject *v; { ! short x; ! /* PyArg_Parse's 'b' formatter is for an unsigned char, therefore ! must use the next size up that is signed ('h') and manually do ! the overflow checking */ ! if (!PyArg_Parse(v, "h;array item must be integer", &x)) ! return -1; ! else if (x < CHAR_MIN) { ! PyErr_SetString(PyExc_OverflowError, ! "signed char is less than minimum"); ! return -1; ! } ! else if (x > CHAR_MAX) { ! PyErr_SetString(PyExc_OverflowError, ! "signed char is greater than maximum"); return -1; + } if (i >= 0) ! ((char *)ap->ob_item)[i] = (char)x; return 0; } *************** *** 132,136 **** } ! #define BB_setitem b_setitem static PyObject * --- 145,162 ---- } ! static int ! BB_setitem(ap, i, v) ! arrayobject *ap; ! int i; ! PyObject *v; ! { ! unsigned char x; ! /* 'B' == unsigned char, maps to PyArg_Parse's 'b' formatter */ ! if (!PyArg_Parse(v, "b;array item must be integer", &x)) ! return -1; ! if (i >= 0) ! ((char *)ap->ob_item)[i] = x; ! return 0; ! } static PyObject * *************** *** 149,152 **** --- 175,179 ---- { short x; + /* 'h' == signed short, maps to PyArg_Parse's 'h' formatter */ if (!PyArg_Parse(v, "h;array item must be integer", &x)) return -1; *************** *** 164,168 **** } ! #define HH_setitem h_setitem static PyObject * --- 191,219 ---- } ! static int ! HH_setitem(ap, i, v) ! arrayobject *ap; ! int i; ! PyObject *v; ! { ! int x; ! /* PyArg_Parse's 'h' formatter is for a signed short, therefore ! must use the next size up and manually do the overflow checking */ ! if (!PyArg_Parse(v, "i;array item must be integer", &x)) ! return -1; ! else if (x < 0) { ! PyErr_SetString(PyExc_OverflowError, ! "unsigned short is less than minimum"); ! return -1; ! } ! else if (x > USHRT_MAX) { ! PyErr_SetString(PyExc_OverflowError, ! "unsigned short is greater than maximum"); ! return -1; ! } ! if (i >= 0) ! ((short *)ap->ob_item)[i] = (short)x; ! return 0; ! } static PyObject * *************** *** 181,184 **** --- 232,236 ---- { int x; + /* 'i' == signed int, maps to PyArg_Parse's 'i' formatter */ if (!PyArg_Parse(v, "i;array item must be integer", &x)) return -1; *************** *** 210,218 **** } else { ! if (!PyArg_Parse(v, "l;array item must be integer", &x)) return -1; } if (i >= 0) ! ((unsigned int *)ap->ob_item)[i] = x; return 0; } --- 262,284 ---- } else { ! long y; ! if (!PyArg_Parse(v, "l;array item must be integer", &y)) return -1; + if (y < 0) { + PyErr_SetString(PyExc_OverflowError, + "unsigned int is less than minimum"); + return -1; + } + x = (unsigned long)y; + + } + if (x > UINT_MAX) { + PyErr_SetString(PyExc_OverflowError, + "unsigned int is greater than maximum"); + return -1; } + if (i >= 0) ! ((unsigned int *)ap->ob_item)[i] = (unsigned int)x; return 0; } *************** *** 261,267 **** } else { ! if (!PyArg_Parse(v, "l;array item must be integer", &x)) return -1; } if (i >= 0) ((unsigned long *)ap->ob_item)[i] = x; --- 327,347 ---- } else { ! long y; ! if (!PyArg_Parse(v, "l;array item must be integer", &y)) ! return -1; ! if (y < 0) { ! PyErr_SetString(PyExc_OverflowError, ! "unsigned long is less than minimum"); return -1; + } + x = (unsigned long)y; + + } + if (x > ULONG_MAX) { + PyErr_SetString(PyExc_OverflowError, + "unsigned long is greater than maximum"); + return -1; } + if (i >= 0) ((unsigned long *)ap->ob_item)[i] = x; *************** *** 726,731 **** PyObject *args; { ! return Py_BuildValue("ll", ! (long)(self->ob_item), (long)(self->ob_size)); } --- 806,816 ---- PyObject *args; { ! PyObject* retval = PyTuple_New(2); ! if (!retval) return NULL; ! ! PyTuple_SET_ITEM(retval, 0, PyLong_FromVoidPtr(self->ob_item)); ! PyTuple_SET_ITEM(retval, 1, PyInt_FromLong((long)(self->ob_size))); ! ! return retval; } From python-dev@python.org Wed Jun 28 18:50:53 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 10:50:53 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_array.py,1.6,1.7 Message-ID: <200006281750.KAA31358@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv31348/Lib/test Modified Files: test_array.py Log Message: Trent Mick : Testing: test_array.py was also extended to check that one can set the full range of values for each of the integral signed and unsigned array types. This closes SourceForge patch #100506. Index: test_array.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_array.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** test_array.py 1998/07/16 15:31:43 1.6 --- test_array.py 2000/06/28 17:50:51 1.7 *************** *** 16,19 **** --- 16,57 ---- + def testoverflow(type, lowerLimit, upperLimit): + # should not overflow assigning lower limit + if verbose: + print "overflow test: array(%s, [%s])" % (`type`, `lowerLimit`) + try: + a = array.array(type, [lowerLimit]) + except: + raise TestFailed, "array(%s) overflowed assigning %s" %\ + (`type`, `lowerLimit`) + # should overflow assigning less than lower limit + if verbose: + print "overflow test: array(%s, [%s])" % (`type`, `lowerLimit-1`) + try: + a = array.array(type, [lowerLimit-1]) + raise TestFailed, "array(%s) did not overflow assigning %s" %\ + (`type`, `lowerLimit-1`) + except OverflowError: + pass + # should not overflow assigning upper limit + if verbose: + print "overflow test: array(%s, [%s])" % (`type`, `upperLimit`) + try: + a = array.array(type, [upperLimit]) + except: + raise TestFailed, "array(%s) overflowed assigning %s" %\ + (`type`, `upperLimit`) + # should overflow assigning more than upper limit + if verbose: + print "overflow test: array(%s, [%s])" % (`type`, `upperLimit+1`) + try: + a = array.array(type, [upperLimit+1]) + raise TestFailed, "array(%s) did not overflow assigning %s" %\ + (`type`, `upperLimit+1`) + except OverflowError: + pass + + + def testtype(type, example): *************** *** 82,86 **** raise TestFailed, "array(%s) self-slice-assign (cntr)" % `type` ! main() ! --- 120,138 ---- raise TestFailed, "array(%s) self-slice-assign (cntr)" % `type` ! # test that overflow exceptions are raised as expected for assignment ! # to array of specific integral types ! from math import pow ! if type in ('b', 'h', 'i', 'l'): ! # check signed and unsigned versions ! a = array.array(type) ! signedLowerLimit = -1 * long(pow(2, a.itemsize * 8 - 1)) ! signedUpperLimit = long(pow(2, a.itemsize * 8 - 1)) - 1L ! unsignedLowerLimit = 0 ! unsignedUpperLimit = long(pow(2, a.itemsize * 8)) - 1L ! testoverflow(type, signedLowerLimit, signedUpperLimit) ! testoverflow(type.upper(), unsignedLowerLimit, unsignedUpperLimit) ! ! ! main() ! From python-dev@python.org Wed Jun 28 19:47:59 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 11:47:59 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python marshal.c,1.47,1.48 Message-ID: <200006281847.LAA08850@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv8840 Modified Files: marshal.c Log Message: Michael Hudson : As I really do not have anything better to do at the moment, I have written a patch to Python/marshal.c that prevents Python dumping core when trying to marshal stack bustingly deep (or recursive) data structure. It just throws an exception; even slightly clever handling of recursive data is what pickle is for... [Fred Drake:] Moved magic constant 5000 to a #define. This closes SourceForge patch #100645. Index: marshal.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/marshal.c,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -r1.47 -r1.48 *** marshal.c 2000/05/03 23:44:39 1.47 --- marshal.c 2000/06/28 18:47:56 1.48 *************** *** 40,43 **** --- 40,49 ---- #include "marshal.h" + /* High water mark to determine when the marshalled object is dangerously deep + * and risks coring the interpreter. When the object stack gets this deep, + * raise an exception instead of continuing. + */ + #define MAX_MARSHAL_STACK_DEPTH 5000 + #define TYPE_NULL '0' #define TYPE_NONE 'N' *************** *** 59,62 **** --- 65,69 ---- FILE *fp; int error; + int depth; /* If fp == NULL, the following are valid: */ PyObject *str; *************** *** 145,150 **** int i, n; PyBufferProcs *pb; ! if (v == NULL) { w_byte(TYPE_NULL, p); } --- 152,162 ---- int i, n; PyBufferProcs *pb; + + p->depth++; ! if (p->depth > MAX_MARSHAL_STACK_DEPTH) { ! p->error = 2; ! } ! else if (v == NULL) { w_byte(TYPE_NULL, p); } *************** *** 302,305 **** --- 314,318 ---- wf.fp = fp; wf.error = 0; + wf.depth = 0; w_long(x, &wf); } *************** *** 691,694 **** --- 704,708 ---- wf.end = wf.ptr + PyString_Size(wf.str); wf.error = 0; + wf.depth = 0; w_object(x, &wf); if (wf.str != NULL) *************** *** 698,702 **** if (wf.error) { Py_XDECREF(wf.str); ! PyErr_SetString(PyExc_ValueError, "unmarshallable object"); return NULL; } --- 712,718 ---- if (wf.error) { Py_XDECREF(wf.str); ! PyErr_SetString(PyExc_ValueError, ! (wf.error==1)?"unmarshallable object" ! :"object too deeply nested to marshal"); return NULL; } *************** *** 725,731 **** wf.ptr = wf.end = NULL; wf.error = 0; w_object(x, &wf); if (wf.error) { ! PyErr_SetString(PyExc_ValueError, "unmarshallable object"); return NULL; } --- 741,750 ---- wf.ptr = wf.end = NULL; wf.error = 0; + wf.depth = 0; w_object(x, &wf); if (wf.error) { ! PyErr_SetString(PyExc_ValueError, ! (wf.error==1)?"unmarshallable object" ! :"object too deeply nested to marshal"); return NULL; } From python-dev@python.org Wed Jun 28 21:15:52 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 13:15:52 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/ref ref3.tex,1.43,1.44 Message-ID: <200006282015.NAA26364@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/ref In directory slayer.i.sourceforge.net:/tmp/cvs-serv26351/ref Modified Files: ref3.tex Log Message: Revise the description of when functions retrieved from class instances are and are not turned into bound methods; some confusion was noted by Andrew Dalke. In particular, it has to be noted that functions located on the class instance are not turned into any sort of method, only those which are found via the underlying class. Index: ref3.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref3.tex,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -r1.43 -r1.44 *** ref3.tex 2000/06/15 20:07:25 1.43 --- ref3.tex 2000/06/28 20:15:47 1.44 *************** *** 439,447 **** User-defined method objects are created in two ways: when getting an attribute of a class that is a user-defined function object, or when ! getting an attributes of a class instance that is a user-defined ! function object. In the former case (class attribute), the ! \member{im_self} attribute is \code{None}, and the method object is said ! to be unbound; in the latter case (instance attribute), \method{im_self} ! is the instance, and the method object is said to be bound. For instance, when \class{C} is a class which contains a definition for a function \method{f()}, \code{C.f} does not yield the function object --- 439,448 ---- User-defined method objects are created in two ways: when getting an attribute of a class that is a user-defined function object, or when ! getting an attribute of a class instance that is a user-defined ! function object defined by the class of the instance. In the former ! case (class attribute), the \member{im_self} attribute is \code{None}, ! and the method object is said to be unbound; in the latter case ! (instance attribute), \method{im_self} is the instance, and the method ! object is said to be bound. For instance, when \class{C} is a class which contains a definition for a function \method{f()}, \code{C.f} does not yield the function object *************** *** 453,459 **** \code{m.im_self} is \code{x}. \withsubitem{(method attribute)}{ ! \ttindex{im_class} ! \ttindex{im_func} ! \ttindex{im_self}} When an unbound user-defined method object is called, the underlying --- 454,458 ---- \code{m.im_self} is \code{x}. \withsubitem{(method attribute)}{ ! \ttindex{im_class}\ttindex{im_func}\ttindex{im_self}} When an unbound user-defined method object is called, the underlying *************** *** 475,479 **** Also notice that this transformation only happens for user-defined functions; other callable objects (and all non-callable objects) are ! retrieved without transformation. \item[Built-in functions] --- 474,481 ---- Also notice that this transformation only happens for user-defined functions; other callable objects (and all non-callable objects) are ! retrieved without transformation. It is also important to note that ! user-defined functions which are attributes of a class instance are ! not converted to bound methods; this \emph{only} happens when the ! function is an attribute of the class. \item[Built-in functions] From python-dev@python.org Wed Jun 28 21:53:36 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 13:53:36 -0700 Subject: [Python-checkins] CVS: python/dist/src/Tools/bgen/bgen bgenGenerator.py,1.6,1.7 bgenlocations.py,1.3,1.4 scantools.py,1.16,1.17 Message-ID: <200006282053.NAA28507@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Tools/bgen/bgen In directory slayer.i.sourceforge.net:/tmp/cvs-serv28490 Modified Files: bgenGenerator.py bgenlocations.py scantools.py Log Message: Jack Jansen: Support for conditional inclusion of methods and functions Index: bgenGenerator.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/bgenGenerator.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** bgenGenerator.py 1995/06/18 20:08:28 1.6 --- bgenGenerator.py 2000/06/28 20:53:33 1.7 *************** *** 15,23 **** class BaseFunctionGenerator: ! def __init__(self, name): print "<--", name self.name = name self.prefix = name self.objecttype = "PyObject" # Type of _self argument to function def setprefix(self, prefix): --- 15,24 ---- class BaseFunctionGenerator: ! def __init__(self, name, condition=None): print "<--", name self.name = name self.prefix = name self.objecttype = "PyObject" # Type of _self argument to function + self.condition = condition def setprefix(self, prefix): *************** *** 26,32 **** --- 27,38 ---- def generate(self): print "-->", self.name + if self.condition: + Output() + Output(self.condition) self.functionheader() self.functionbody() self.functiontrailer() + if self.condition: + Output("#endif") def functionheader(self): *************** *** 51,56 **** --- 57,67 ---- name = self.name docstring = self.docstring() + if self.condition: + Output() + Output(self.condition) Output("{\"%s\", (PyCFunction)%s_%s, 1,", name, self.prefix, self.name) Output(" %s},", stringify(docstring)) + if self.condition: + Output("#endif") def docstring(self): *************** *** 74,79 **** class ManualGenerator(BaseFunctionGenerator): ! def __init__(self, name, body): ! BaseFunctionGenerator.__init__(self, name) self.body = body --- 85,90 ---- class ManualGenerator(BaseFunctionGenerator): ! def __init__(self, name, body, condition=None): ! BaseFunctionGenerator.__init__(self, name, condition=condition) self.body = body *************** *** 88,93 **** class FunctionGenerator(BaseFunctionGenerator): ! def __init__(self, returntype, name, *argumentList): ! BaseFunctionGenerator.__init__(self, name) self.returntype = returntype self.argumentList = [] --- 99,104 ---- class FunctionGenerator(BaseFunctionGenerator): ! def __init__(self, returntype, name, *argumentList, **conditionlist): ! BaseFunctionGenerator.__init__(self, name, **conditionlist) self.returntype = returntype self.argumentList = [] Index: bgenlocations.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/bgenlocations.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** bgenlocations.py 1998/02/23 15:30:40 1.3 --- bgenlocations.py 2000/06/28 20:53:33 1.4 *************** *** 4,12 **** # Where to find the Universal Header include files: ! MWERKSDIR="flap:Metrowerks:Metrowerks CodeWarrior:" ! INCLUDEDIR=MWERKSDIR + "MacOS Support:Headers:Universal Headers:" # Where to put the python definitions file: ! TOOLBOXDIR="flap:Jack:Python:Mac:Lib:lib-toolbox:" # Creator for C files: --- 4,12 ---- # Where to find the Universal Header include files: ! MWERKSDIR="Macintosh HD:SWDev:Codewarrior Pro 5:Metrowerks CodeWarrior:" ! INCLUDEDIR=MWERKSDIR + "MacOS Support:Universal:Interfaces:CIncludes:" # Where to put the python definitions file: ! TOOLBOXDIR="Macintosh HD:SWDev:Jack:Python:Mac:Lib:lib-toolbox:" # Creator for C files: Index: scantools.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/scantools.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** scantools.py 2000/01/20 20:49:28 1.16 --- scantools.py 2000/06/28 20:53:33 1.17 *************** *** 100,103 **** --- 100,111 ---- self.blacklistnames = self.makeblacklistnames() self.blacklisttypes = ["unknown", "-"] + self.makeblacklisttypes() + self.greydictnames = self.greylist2dict(self.makegreylist()) + + def greylist2dict(self, list): + rv = {} + for define, namelist in list: + for name in namelist: + rv[name] = define + return rv def makeblacklistnames(self): *************** *** 106,109 **** --- 114,120 ---- def makeblacklisttypes(self): return [] + + def makegreylist(self): + return [] def initrepairinstructions(self): *************** *** 396,399 **** --- 407,411 ---- else: self.defsfile.write("# %s = %s\n" % (name, defn)) + # XXXX No way to handle greylisted names def dofuncspec(self): *************** *** 520,523 **** --- 532,537 ---- self.specfile.write(" (%s, %s, %s),\n" % (atype, `aname`, amode)) + if self.greydictnames.has_key(name): + self.specfile.write(" condition=%s,\n"%`self.greydictnames[name]`) self.specfile.write(")\n") self.specfile.write("%s.append(f)\n\n" % listname) From python-dev@python.org Wed Jun 28 21:54:55 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 13:54:55 -0700 Subject: [Python-checkins] CVS: python/dist/src/Parser parsetok.c,2.16,2.17 Message-ID: <200006282054.NAA28568@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Parser In directory slayer.i.sourceforge.net:/tmp/cvs-serv28542 Modified Files: parsetok.c Log Message: Jack Jansen: Removed Macintosh tab-guessing code Index: parsetok.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/parsetok.c,v retrieving revision 2.16 retrieving revision 2.17 diff -C2 -r2.16 -r2.17 *** parsetok.c 2000/05/03 23:44:37 2.16 --- parsetok.c 2000/06/28 20:54:53 2.17 *************** *** 110,120 **** } - #ifdef macintosh - { - int tabsize = guesstabsize(filename); - if (tabsize > 0) - tok->tabsize = tabsize; - } - #endif return parsetok(tok, g, start, err_ret); --- 110,113 ---- From python-dev@python.org Wed Jun 28 21:55:36 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 13:55:36 -0700 Subject: [Python-checkins] CVS: python/dist/src/Include pgenheaders.h,2.17,2.18 Message-ID: <200006282055.NAA28596@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Include In directory slayer.i.sourceforge.net:/tmp/cvs-serv28589/Include Modified Files: pgenheaders.h Log Message: Jack Jansen: Removed support for long-dead Think C compiler Index: pgenheaders.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pgenheaders.h,v retrieving revision 2.17 retrieving revision 2.18 diff -C2 -r2.17 -r2.18 *** pgenheaders.h 1998/12/04 18:48:15 2.17 --- pgenheaders.h 2000/06/28 20:55:34 2.18 *************** *** 48,56 **** #include - #ifdef THINK_C - #define label label_ - #undef label - #endif - #ifdef HAVE_STDLIB_H #include --- 48,51 ---- From python-dev@python.org Wed Jun 28 21:56:32 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 13:56:32 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules pcre.h,2.7,2.8 Message-ID: <200006282056.NAA28621@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv28614/Modules Modified Files: pcre.h Log Message: Jack Jansen: Mac Carbon: don't include sys/types if we don't have it Index: pcre.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/pcre.h,v retrieving revision 2.7 retrieving revision 2.8 diff -C2 -r2.7 -r2.8 *** pcre.h 1998/05/07 15:32:41 2.7 --- pcre.h 2000/06/28 20:56:30 2.8 *************** *** 15,19 **** --- 15,21 ---- it is needed here for malloc. */ + #ifndef DONT_HAVE_SYS_TYPES_H #include + #endif #include From python-dev@python.org Wed Jun 28 21:57:09 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 13:57:09 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects fileobject.c,2.73,2.74 Message-ID: <200006282057.NAA28650@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv28642/Objects Modified Files: fileobject.c Log Message: Jack Jansen: Moved includes to the top, removed think C support Index: fileobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/fileobject.c,v retrieving revision 2.73 retrieving revision 2.74 diff -C2 -r2.73 -r2.74 *** fileobject.c 2000/05/03 23:44:34 2.73 --- fileobject.c 2000/06/28 20:57:07 2.74 *************** *** 39,42 **** --- 39,62 ---- #endif /* DONT_HAVE_SYS_TYPES_H */ + /* We expect that fstat exists on most systems. + It's confirmed on Unix, Mac and Windows. + If you don't have it, add #define DONT_HAVE_FSTAT to your config.h. */ + #ifndef DONT_HAVE_FSTAT + #define HAVE_FSTAT + + #ifndef DONT_HAVE_SYS_TYPES_H + #include + #endif + + #ifndef DONT_HAVE_SYS_STAT_H + #include + #else + #ifdef HAVE_STAT_H + #include + #endif + #endif + + #endif /* DONT_HAVE_FSTAT */ + #ifdef HAVE_UNISTD_H #include *************** *** 55,61 **** #endif - #ifdef THINK_C - #define HAVE_FOPENRF - #endif #ifdef __MWERKS__ /* Mwerks fopen() doesn't always set errno */ --- 75,78 ---- *************** *** 446,464 **** } - /* We expect that fstat exists on most systems. - It's confirmed on Unix, Mac and Windows. - If you don't have it, add #define DONT_HAVE_FSTAT to your config.h. */ - #ifndef DONT_HAVE_FSTAT - #define HAVE_FSTAT - - #ifndef DONT_HAVE_SYS_TYPES_H - #include - #endif - - #ifndef DONT_HAVE_SYS_STAT_H - #include - #endif - - #endif /* DONT_HAVE_FSTAT */ #if BUFSIZ < 8192 --- 463,466 ---- From python-dev@python.org Wed Jun 28 22:12:28 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 14:12:28 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.162,2.163 Message-ID: <200006282112.OAA03095@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv3006 Modified Files: bltinmodule.c Log Message: Trent Mick: Various small fixes to the builtin module to ensure no buffer overflows. - chunk #1: Proper casting to ensure no truncation, and hence no surprises, in the comparison. - chunk #2: The id() function guarantees a unique return value for different objects. It does this by returning the pointer to the object. By returning a PyInt, on Win64 (sizeof(long) < sizeof(void*)) the pointer is truncated and the guarantee may be proven false. The appropriate return function is PyLong_FromVoidPtr, this returns a PyLong if that is necessary to return the pointer without truncation. [GvR: note that this means that id() can now return a long on Win32 platforms. This *might* break some code...] - chunk #3: Ensure no overflow in raw_input(). Granted the user would have to pass in >2GB of data but it *is* a possible buffer overflow condition. Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.162 retrieving revision 2.163 diff -C2 -r2.162 -r2.163 *** bltinmodule.c 2000/06/20 04:54:19 2.162 --- bltinmodule.c 2000/06/28 21:12:25 2.163 *************** *** 833,837 **** } str = PyString_AsString(cmd); ! if ((int)strlen(str) != PyString_Size(cmd)) { PyErr_SetString(PyExc_ValueError, "embedded '\\0' in string arg"); --- 833,837 ---- } str = PyString_AsString(cmd); ! if (strlen(str) != (size_t)PyString_Size(cmd)) { PyErr_SetString(PyExc_ValueError, "embedded '\\0' in string arg"); *************** *** 986,990 **** if (!PyArg_ParseTuple(args, "O:id", &v)) return NULL; ! return PyInt_FromLong((long)v); } --- 986,990 ---- if (!PyArg_ParseTuple(args, "O:id", &v)) return NULL; ! return PyLong_FromVoidPtr(v); } *************** *** 1874,1878 **** } else { /* strip trailing '\n' */ ! result = PyString_FromStringAndSize(s, strlen(s)-1); } PyMem_FREE(s); --- 1874,1885 ---- } else { /* strip trailing '\n' */ ! size_t len = strlen(s); ! if (len > INT_MAX) { ! PyErr_SetString(PyExc_OverflowError, "input too long"); ! result = NULL; ! } ! else { ! result = PyString_FromStringAndSize(s, (int)(len-1)); ! } } PyMem_FREE(s); From python-dev@python.org Wed Jun 28 22:18:15 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 14:18:15 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules selectmodule.c,2.32,2.33 Message-ID: <200006282118.OAA03485@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv3478 Modified Files: selectmodule.c Log Message: Trent Mick: This patches fixes a possible overflow of the optional timeout parameter for the select() function (selectmodule.c). This timeout is passed in as a double and then truncated to an int. If the double is sufficiently large you can get unexpected results as it overflows. This patch raises an overflow if the given select timeout overflows. [GvR: To my embarrassment, the original code was assuming an int could always hold a million. Note that the overflow check doesn't test for a very large *negative* timeout passed in -- but who in the world would do such a thing?] Index: selectmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/selectmodule.c,v retrieving revision 2.32 retrieving revision 2.33 diff -C2 -r2.32 -r2.33 *** selectmodule.c 2000/05/03 23:44:33 2.32 --- selectmodule.c 2000/06/28 21:18:13 2.33 *************** *** 239,243 **** double timeout; struct timeval tv, *tvp; ! int seconds; int imax, omax, emax, max; int n; --- 239,243 ---- double timeout; struct timeval tv, *tvp; ! long seconds; int imax, omax, emax, max; int n; *************** *** 256,263 **** } else { ! seconds = (int)timeout; timeout = timeout - (double)seconds; tv.tv_sec = seconds; ! tv.tv_usec = (int)(timeout*1000000.0); tvp = &tv; } --- 256,267 ---- } else { ! if (timeout > (double)LONG_MAX) { ! PyErr_SetString(PyExc_OverflowError, "timeout period too long"); ! return NULL; ! } ! seconds = (long)timeout; timeout = timeout - (double)seconds; tv.tv_sec = seconds; ! tv.tv_usec = (long)(timeout*1000000.0); tvp = &tv; } From python-dev@python.org Wed Jun 28 22:23:36 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 14:23:36 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _localemodule.c,2.8,2.9 Message-ID: <200006282123.OAA03699@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv3690 Modified Files: _localemodule.c Log Message: Trent Mick: use size_t instead of int where appropriate (in strxfrm(), to hold strlen() outcome). Index: _localemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_localemodule.c,v retrieving revision 2.8 retrieving revision 2.9 diff -C2 -r2.8 -r2.9 *** _localemodule.c 2000/05/03 22:30:13 2.8 --- _localemodule.c 2000/06/28 21:23:33 2.9 *************** *** 282,286 **** { char *s,*buf; ! int n1,n2; PyObject *result; if(!PyArg_ParseTuple(args,"s:strxfrm",&s)) --- 282,286 ---- { char *s,*buf; ! size_t n1,n2; PyObject *result; if(!PyArg_ParseTuple(args,"s:strxfrm",&s)) From python-dev@python.org Wed Jun 28 22:27:24 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 14:27:24 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules arraymodule.c,2.41,2.42 Message-ID: <200006282127.OAA03807@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv3797 Modified Files: arraymodule.c Log Message: Trent Mick: use size_t instead of int where appropriate (in fromfile(), to hold fread() result.) Index: arraymodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/arraymodule.c,v retrieving revision 2.41 retrieving revision 2.42 diff -C2 -r2.41 -r2.42 *** arraymodule.c 2000/06/28 17:49:30 2.41 --- arraymodule.c 2000/06/28 21:27:21 2.42 *************** *** 1028,1032 **** char *item = self->ob_item; int itemsize = self->ob_descr->itemsize; ! int nread; int newlength; size_t newbytes; --- 1028,1032 ---- char *item = self->ob_item; int itemsize = self->ob_descr->itemsize; ! size_t nread; int newlength; size_t newbytes; *************** *** 1046,1050 **** nread = fread(item + (self->ob_size - n) * itemsize, itemsize, n, fp); ! if (nread < n) { self->ob_size -= (n - nread); PyMem_RESIZE(item, char, self->ob_size*itemsize); --- 1046,1050 ---- nread = fread(item + (self->ob_size - n) * itemsize, itemsize, n, fp); ! if (nread < (size_t)n) { self->ob_size -= (n - nread); PyMem_RESIZE(item, char, self->ob_size*itemsize); From python-dev@python.org Wed Jun 28 22:29:05 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 14:29:05 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules getpath.c,1.22,1.23 Message-ID: <200006282129.OAA03946@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv3939 Modified Files: getpath.c Log Message: Trent Mick: use size_t instead of int where appropriate (various spots). Index: getpath.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/getpath.c,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** getpath.c 2000/05/26 21:49:07 1.22 --- getpath.c 2000/06/28 21:29:03 1.23 *************** *** 164,168 **** char *dir; { ! int i = strlen(dir); while (i > 0 && dir[i] != SEP) --i; --- 164,168 ---- char *dir; { ! size_t i = strlen(dir); while (i > 0 && dir[i] != SEP) --i; *************** *** 242,246 **** char *stuff; { ! int n, k; if (stuff[0] == SEP) n = 0; --- 242,246 ---- char *stuff; { ! size_t n, k; if (stuff[0] == SEP) n = 0; *************** *** 263,267 **** char *home; { ! int n; char *vpath; --- 263,267 ---- char *home; { ! size_t n; char *vpath; *************** *** 332,336 **** char *home; { ! int n; /* If PYTHONHOME is set, we believe it unconditionally */ --- 332,336 ---- char *home; { ! size_t n; /* If PYTHONHOME is set, we believe it unconditionally */ *************** *** 394,399 **** int pfound, efound; /* 1 if found; -1 if found build directory */ char *buf; ! int bufsz; ! int prefixsz; char *defpath = pythonpath; #ifdef WITH_NEXT_FRAMEWORK --- 394,399 ---- int pfound, efound; /* 1 if found; -1 if found build directory */ char *buf; ! size_t bufsz; ! size_t prefixsz; char *defpath = pythonpath; #ifdef WITH_NEXT_FRAMEWORK *************** *** 430,434 **** if (delim) { ! int len = delim - path; strncpy(progpath, path, len); *(progpath + len) = '\0'; --- 430,434 ---- if (delim) { ! size_t len = delim - path; strncpy(progpath, path, len); *(progpath + len) = '\0'; *************** *** 558,563 **** if (delim) { ! int len = delim - defpath + 1; ! int end = strlen(buf) + len; strncat(buf, defpath, len); *(buf + end) = '\0'; --- 558,563 ---- if (delim) { ! size_t len = delim - defpath + 1; ! size_t end = strlen(buf) + len; strncat(buf, defpath, len); *(buf + end) = '\0'; From python-dev@python.org Wed Jun 28 22:29:49 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 14:29:49 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules mpzmodule.c,2.23,2.24 Message-ID: <200006282129.OAA03993@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv3986 Modified Files: mpzmodule.c Log Message: Trent Mick: use size_t instead of int where appropriate (mpz_format()). Index: mpzmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/mpzmodule.c,v retrieving revision 2.23 retrieving revision 2.24 diff -C2 -r2.23 -r2.24 *** mpzmodule.c 2000/05/03 23:44:32 2.23 --- mpzmodule.c 2000/06/28 21:29:47 2.24 *************** *** 144,148 **** mpzobject *mpzp = (mpzobject *)objp; PyStringObject *strobjp; ! int i; int cmpres; int taglong; --- 144,148 ---- mpzobject *mpzp = (mpzobject *)objp; PyStringObject *strobjp; ! size_t i; int cmpres; int taglong; From python-dev@python.org Wed Jun 28 22:30:34 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 14:30:34 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules readline.c,2.17,2.18 Message-ID: <200006282130.OAA04055@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv4047 Modified Files: readline.c Log Message: Trent Mick: use size_t instead of int where appropriate (call_readline()). Index: readline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v retrieving revision 2.17 retrieving revision 2.18 diff -C2 -r2.17 -r2.18 *** readline.c 2000/05/03 23:44:33 2.17 --- readline.c 2000/06/28 21:30:31 2.18 *************** *** 377,381 **** char *prompt; { ! int n; char *p, *q; RETSIGTYPE (*old_inthandler)(); --- 377,381 ---- char *prompt; { ! size_t n; char *p, *q; RETSIGTYPE (*old_inthandler)(); From python-dev@python.org Wed Jun 28 22:31:13 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 14:31:13 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules rotormodule.c,2.23,2.24 Message-ID: <200006282131.OAA04112@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv4104 Modified Files: rotormodule.c Log Message: Trent Mick: use size_t instead of int where appropriate (set_key()). Index: rotormodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/rotormodule.c,v retrieving revision 2.23 retrieving revision 2.24 diff -C2 -r2.23 -r2.24 *** rotormodule.c 2000/05/03 23:44:33 2.23 --- rotormodule.c 2000/06/28 21:31:10 2.24 *************** *** 148,153 **** { unsigned long k1=995, k2=576, k3=767, k4=671, k5=463; ! int i; ! int len = strlen(key); for (i = 0; i < len; i++) { --- 148,153 ---- { unsigned long k1=995, k2=576, k3=767, k4=671, k5=463; ! size_t i; ! size_t len = strlen(key); for (i = 0; i < len; i++) { From python-dev@python.org Wed Jun 28 22:34:02 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 14:34:02 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules timemodule.c,2.83,2.84 Message-ID: <200006282134.OAA04279@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv4272 Modified Files: timemodule.c Log Message: Trent Mick: use size_t instead of int where appropriate (time_strftime()). Index: timemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/timemodule.c,v retrieving revision 2.83 retrieving revision 2.84 diff -C2 -r2.83 -r2.84 *** timemodule.c 2000/05/09 19:52:40 2.83 --- timemodule.c 2000/06/28 21:33:59 2.84 *************** *** 379,385 **** struct tm buf; const char *fmt; ! int fmtlen, buflen; char *outbuf = 0; ! int i; memset((ANY *) &buf, '\0', sizeof(buf)); --- 379,385 ---- struct tm buf; const char *fmt; ! size_t fmtlen, buflen; char *outbuf = 0; ! size_t i; memset((ANY *) &buf, '\0', sizeof(buf)); From python-dev@python.org Wed Jun 28 22:51:46 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 14:51:46 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libhttplib.tex,1.19,1.20 Message-ID: <200006282151.OAA05489@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv5474/lib Modified Files: libhttplib.tex Log Message: Skip Montanaro : Added an example of using an HTTP POST request. Index: libhttplib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libhttplib.tex,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -r1.19 -r1.20 *** libhttplib.tex 1999/04/22 16:47:27 1.19 --- libhttplib.tex 2000/06/28 21:51:43 1.20 *************** *** 115,119 **** \nodename{HTTP Example} ! Here is an example session: \begin{verbatim} --- 115,119 ---- \nodename{HTTP Example} ! Here is an example session that uses the \samp{GET} method: \begin{verbatim} *************** *** 129,131 **** --- 129,148 ---- >>> data = f.read() # Get the raw HTML >>> f.close() + \end{verbatim} + + Here is an example session that shows how to \samp{POST} requests: + + \begin{verbatim} + >>> import httplib, urllib + >>> params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0}) + >>> h = httplib.HTTP("www.musi-cal.com:80") + >>> h.putrequest("POST", "/cgi-bin/query") + >>> h.putheader("Content-length", "%d" % len(params)) + >>> h.putheader('Accept', 'text/plain') + >>> h.putheader('Host', 'www.musi-cal.com') + >>> h.endheaders() + >>> h.send(paramstring) + >>> reply, msg, hdrs = h.getreply() + >>> print errcode # should be 200 + >>> data = h.getfile().read() # get the raw HTML \end{verbatim} From python-dev@python.org Wed Jun 28 22:57:20 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 14:57:20 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects classobject.c,2.89,2.90 object.c,2.72,2.73 Message-ID: <200006282157.OAA05880@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv5838 Modified Files: classobject.c object.c Log Message: Trent Mick: change a few casts for Win64 compatibility. Index: classobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v retrieving revision 2.89 retrieving revision 2.90 diff -C2 -r2.89 -r2.90 *** classobject.c 2000/06/23 19:37:01 2.89 --- classobject.c 2000/06/28 21:57:18 2.90 *************** *** 284,288 **** if (v == NULL || !PyString_Check(v)) return "__name__ must be a string object"; ! if ((long)strlen(PyString_AS_STRING(v)) != PyString_GET_SIZE(v)) return "__name__ must not contain null bytes"; set_slot(&c->cl_name, v); --- 284,288 ---- if (v == NULL || !PyString_Check(v)) return "__name__ must be a string object"; ! if (strlen(PyString_AS_STRING(v)) != (size_t)PyString_GET_SIZE(v)) return "__name__ must not contain null bytes"; set_slot(&c->cl_name, v); Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.72 retrieving revision 2.73 diff -C2 -r2.72 -r2.73 *** object.c 2000/06/23 14:36:32 2.72 --- object.c 2000/06/28 21:57:18 2.73 *************** *** 367,371 **** return NULL; } ! if ((long)v <= (long)w) { PyTuple_SET_ITEM(pair, 0, PyLong_FromVoidPtr((void *)v)); PyTuple_SET_ITEM(pair, 1, PyLong_FromVoidPtr((void *)w)); --- 367,371 ---- return NULL; } ! if (v <= w) { PyTuple_SET_ITEM(pair, 0, PyLong_FromVoidPtr((void *)v)); PyTuple_SET_ITEM(pair, 1, PyLong_FromVoidPtr((void *)w)); From python-dev@python.org Wed Jun 28 23:00:05 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 15:00:05 -0700 Subject: [Python-checkins] CVS: python/dist/src/Parser myreadline.c,2.17,2.18 parsetok.c,2.17,2.18 pgenmain.c,2.16,2.17 tokenizer.c,2.41,2.42 Message-ID: <200006282200.PAA06324@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Parser In directory slayer.i.sourceforge.net:/tmp/cvs-serv6150 Modified Files: myreadline.c parsetok.c pgenmain.c tokenizer.c Log Message: Trent Mick: familiar simple Win64 patches Index: myreadline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/myreadline.c,v retrieving revision 2.17 retrieving revision 2.18 diff -C2 -r2.17 -r2.18 *** myreadline.c 2000/05/03 23:44:37 2.17 --- myreadline.c 2000/06/28 22:00:02 2.18 *************** *** 87,91 **** char *prompt; { ! int n; char *p; n = 100; --- 87,91 ---- char *prompt; { ! size_t n; char *p; n = 100; *************** *** 96,100 **** fprintf(stderr, "%s", prompt); fflush(stderr); ! switch (my_fgets(p, n, stdin)) { case 0: /* Normal case */ break; --- 96,100 ---- fprintf(stderr, "%s", prompt); fflush(stderr); ! switch (my_fgets(p, (int)n, stdin)) { case 0: /* Normal case */ break; *************** *** 117,125 **** n = strlen(p); while (n > 0 && p[n-1] != '\n') { ! int incr = n+2; p = PyMem_REALLOC(p, n + incr); if (p == NULL) return NULL; ! if (my_fgets(p+n, incr, stdin) != 0) break; n += strlen(p+n); --- 117,128 ---- n = strlen(p); while (n > 0 && p[n-1] != '\n') { ! size_t incr = n+2; p = PyMem_REALLOC(p, n + incr); if (p == NULL) return NULL; ! if (incr > INT_MAX) { ! PyErr_SetString(PyExc_OverflowError, "input line too long"); ! } ! if (my_fgets(p+n, (int)incr, stdin) != 0) break; n += strlen(p+n); Index: parsetok.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/parsetok.c,v retrieving revision 2.17 retrieving revision 2.18 diff -C2 -r2.17 -r2.18 *** parsetok.c 2000/06/28 20:54:53 2.17 --- parsetok.c 2000/06/28 22:00:02 2.18 *************** *** 137,141 **** char *a, *b; int type; ! int len; char *str; --- 137,141 ---- char *a, *b; int type; ! size_t len; char *str; *************** *** 185,189 **** err_ret->offset = tok->cur - tok->buf; if (tok->buf != NULL) { ! int len = tok->inp - tok->buf; err_ret->text = PyMem_NEW(char, len + 1); if (err_ret->text != NULL) { --- 185,189 ---- err_ret->offset = tok->cur - tok->buf; if (tok->buf != NULL) { ! size_t len = tok->inp - tok->buf; err_ret->text = PyMem_NEW(char, len + 1); if (err_ret->text != NULL) { Index: pgenmain.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/pgenmain.c,v retrieving revision 2.16 retrieving revision 2.17 diff -C2 -r2.16 -r2.17 *** pgenmain.c 2000/05/03 23:44:37 2.16 --- pgenmain.c 2000/06/28 22:00:02 2.17 *************** *** 128,132 **** err.error, err.lineno); if (err.text != NULL) { ! int i; fprintf(stderr, "%s", err.text); i = strlen(err.text); --- 128,132 ---- err.error, err.lineno); if (err.text != NULL) { ! size_t i; fprintf(stderr, "%s", err.text); i = strlen(err.text); *************** *** 196,200 **** char *prompt; { ! int n = 1000; char *p = PyMem_MALLOC(n); char *q; --- 196,200 ---- char *prompt; { ! size_t n = 1000; char *p = PyMem_MALLOC(n); char *q; Index: tokenizer.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/tokenizer.c,v retrieving revision 2.41 retrieving revision 2.42 diff -C2 -r2.41 -r2.42 *** tokenizer.c 2000/05/03 23:44:37 2.41 --- tokenizer.c 2000/06/28 22:00:02 2.42 *************** *** 224,230 **** } else if (tok->start != NULL) { ! int start = tok->start - tok->buf; ! int oldlen = tok->cur - tok->buf; ! int newlen = oldlen + strlen(new); char *buf = tok->buf; PyMem_RESIZE(buf, char, newlen+1); --- 224,230 ---- } else if (tok->start != NULL) { ! size_t start = tok->start - tok->buf; ! size_t oldlen = tok->cur - tok->buf; ! size_t newlen = oldlen + strlen(new); char *buf = tok->buf; PyMem_RESIZE(buf, char, newlen+1); From python-dev@python.org Wed Jun 28 23:03:31 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 15:03:31 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libascii.tex,1.1,1.2 Message-ID: <200006282203.PAA12652@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv12636/lib Modified Files: libascii.tex Log Message: Added entries for the curses.ascii module. Index: libascii.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libascii.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** libascii.tex 2000/06/26 23:59:24 1.1 --- libascii.tex 2000/06/28 22:03:29 1.2 *************** *** 1,7 **** \section{\module{curses.ascii} --- ! Constants and set-membership functions for ASCII characters.} \declaremodule{standard}{curses.ascii} ! \modulesynopsis{Constants and set-membership functions for ASCII characters.} \moduleauthor{Eric S. Raymond}{esr@thyrsus.com} \sectionauthor{Eric S. Raymond}{esr@thyrsus.com} --- 1,8 ---- \section{\module{curses.ascii} --- ! Utilities for ASCII characters} \declaremodule{standard}{curses.ascii} ! \modulesynopsis{Constants and set-membership functions for ! \ASCII{} characters.} \moduleauthor{Eric S. Raymond}{esr@thyrsus.com} \sectionauthor{Eric S. Raymond}{esr@thyrsus.com} *************** *** 9,90 **** \versionadded{1.6} ! The \module{curses.ascii} module supplies name constants for ASCII characters ! and functions to test membership in various ASCII character classes. ! The constants supplied are names for control characters as follows: ! ! NUL, SOH, STX, ETX, EOT, ENQ, ACK, BEL, BS, TAB, HT, LF, NL, VT, FF, CR, ! SO, SI, DLE, DC1, DC2, DC3, DC4, NAK, SYN, ETB, CAN, EM, SUB, ESC, FS, ! GS, RS, US, SP, DEL. ! NL and LF are synonyms; so are HT and TAB. The module also supplies ! the following functions, patterned on those in the standard C library: \begin{funcdesc}{isalnum}{c} ! Checks for an ASCII alphanumeric character; it is equivalent to ! isalpha(c) or isdigit(c)) \end{funcdesc} \begin{funcdesc}{isalpha}{c} ! Checks for an ASCII alphabetic character; it is equivalent to ! isupper(c) or islower(c)) \end{funcdesc} \begin{funcdesc}{isascii}{c} ! Checks for a character value that fits in the 7-bit ASCII set. \end{funcdesc} \begin{funcdesc}{isblank}{c} ! Checks for an ASCII alphanumeric character; it is equivalent to ! isalpha(c) or isdigit(c)) \end{funcdesc} \begin{funcdesc}{iscntrl}{c} ! Checks for an ASCII control character (range 0x00 to 0x1f). \end{funcdesc} \begin{funcdesc}{isdigit}{c} ! Checks for an ASCII decimal digit, 0 through 9. \end{funcdesc} \begin{funcdesc}{isgraph}{c} ! Checks for ASCII any printable character except space. \end{funcdesc} \begin{funcdesc}{islower}{c} ! Checks for an ASCII lower-case character. \end{funcdesc} \begin{funcdesc}{isprint}{c} ! Checks for any ASCII printable character including space. \end{funcdesc} \begin{funcdesc}{ispunct}{c} ! Checks for any printable ASCII character which is not a space or an alphanumeric character. \end{funcdesc} \begin{funcdesc}{isspace}{c} ! Checks for ASCII white-space characters; space, tab, line feed, carriage return, form feed, horizontal tab, vertical tab. \end{funcdesc} \begin{funcdesc}{isupper}{c} ! Checks for an ASCII uppercase letter. \end{funcdesc} \begin{funcdesc}{isxdigit}{c} ! Checks for an ASCII hexadecimal digit, i.e. one of 0123456789abcdefABCDEF. \end{funcdesc} \begin{funcdesc}{isctrl}{c} ! Checks for an ASCII control character, bit values 0 to 31. \end{funcdesc} \begin{funcdesc}{ismeta}{c} ! Checks for a (non-ASCII) character, bit values 0x80 and above. \end{funcdesc} These functions accept either integers or strings; when the argument ! is a string, it is first converted using the built-in function ord(). Note that all these functions check ordinal bit values derived from the --- 10,132 ---- \versionadded{1.6} ! The \module{curses.ascii} module supplies name constants for ! \ASCII{} characters and functions to test membership in various ! \ASCII{} character classes. The constants supplied are names for ! control characters as follows: ! ! \begin{tableii}{l|l}{constant}{Name}{Meaning} ! \lineii{NUL}{} ! \lineii{SOH}{Start of heading, console interrupt} ! \lineii{STX}{Start of text} ! \lineii{ETX}{Ennd of text} ! \lineii{EOT}{End of transmission} ! \lineii{ENQ}{Enquiry, goes with \constant{ACK} flow control} ! \lineii{ACK}{Acknowledgement} ! \lineii{BEL}{Bell} ! \lineii{BS}{Backspace} ! \lineii{TAB}{Tab} ! \lineii{HT}{Alias for \constant{TAB}: ``Horizontal tab''} ! \lineii{LF}{Line feed} ! \lineii{NL}{Alias for \constant{LF}: ``New line''} ! \lineii{VT}{Vertical tab} ! \lineii{FF}{Form feed} ! \lineii{CR}{Carriage return} ! \lineii{SO}{Shift-out, begin alternate character set} ! \lineii{SI}{Shift-in, resume default character set} ! \lineii{DLE}{Data-link escape} ! \lineii{DC1}{XON, for flow control} ! \lineii{DC2}{Device control 2, block-mode flow control} ! \lineii{DC3}{XOFF, for flow control} ! \lineii{DC4}{Device control 4} ! \lineii{NAK}{Negative acknowledgement} ! \lineii{SYN}{Synchronous idle} ! \lineii{ETB}{End transmission block} ! \lineii{CAN}{Cancel} ! \lineii{EM}{End of medium} ! \lineii{SUB}{Substitute} ! \lineii{ESC}{Escape} ! \lineii{FS}{File separator} ! \lineii{GS}{Group separator} ! \lineii{RS}{Record separator, block-mode terminator} ! \lineii{US}{Unit separator} ! \lineii{SP}{Space} ! \lineii{DEL}{Delete} ! \end{tableii} ! Note that many of these have little practical use in modern usage. + The module supplies the following functions, patterned on those in the + standard C library: + + \begin{funcdesc}{isalnum}{c} ! Checks for an \ASCII{} alphanumeric character; it is equivalent to ! \samp{isalpha(\var{c}) or isdigit(\var{c})}. \end{funcdesc} \begin{funcdesc}{isalpha}{c} ! Checks for an \ASCII{} alphabetic character; it is equivalent to ! \samp{isupper(\var{c}) or islower(\var{c})}. \end{funcdesc} \begin{funcdesc}{isascii}{c} ! Checks for a character value that fits in the 7-bit \ASCII{} set. \end{funcdesc} \begin{funcdesc}{isblank}{c} ! Checks for an \ASCII{} whitespace character. \end{funcdesc} \begin{funcdesc}{iscntrl}{c} ! Checks for an \ASCII{} control character (in the range 0x00 to 0x1f). \end{funcdesc} \begin{funcdesc}{isdigit}{c} ! Checks for an \ASCII{} decimal digit, \character{0} through ! \character{9}. This is equivalent to \samp{\var{c} in string.digits}. \end{funcdesc} \begin{funcdesc}{isgraph}{c} ! Checks for \ASCII{} any printable character except space. \end{funcdesc} \begin{funcdesc}{islower}{c} ! Checks for an \ASCII{} lower-case character. \end{funcdesc} \begin{funcdesc}{isprint}{c} ! Checks for any \ASCII{} printable character including space. \end{funcdesc} \begin{funcdesc}{ispunct}{c} ! Checks for any printable \ASCII{} character which is not a space or an alphanumeric character. \end{funcdesc} \begin{funcdesc}{isspace}{c} ! Checks for \ASCII{} white-space characters; space, tab, line feed, carriage return, form feed, horizontal tab, vertical tab. \end{funcdesc} \begin{funcdesc}{isupper}{c} ! Checks for an \ASCII{} uppercase letter. \end{funcdesc} \begin{funcdesc}{isxdigit}{c} ! Checks for an \ASCII{} hexadecimal digit. This is equivalent to ! \samp{\var{c} in string.hexdigits}. \end{funcdesc} \begin{funcdesc}{isctrl}{c} ! Checks for an \ASCII{} control character (ordinal values 0 to 31). \end{funcdesc} \begin{funcdesc}{ismeta}{c} ! Checks for a non-\ASCII{} character (ordinal values 0x80 and above). \end{funcdesc} These functions accept either integers or strings; when the argument ! is a string, it is first converted using the built-in function ! \function{ord()}. Note that all these functions check ordinal bit values derived from the *************** *** 92,96 **** anything about the host machine's character encoding. For functions that know about the character encoding (and handle ! internationalization properly) see the string module. The following two functions take either a single-character string or --- 134,138 ---- anything about the host machine's character encoding. For functions that know about the character encoding (and handle ! internationalization properly) see the \refmodule{string} module. The following two functions take either a single-character string or *************** *** 98,131 **** \begin{funcdesc}{ascii}{c} ! Return the ASCII value corresponding to the low 7 bits of c. \end{funcdesc} \begin{funcdesc}{ctrl}{c} Return the control character corresponding to the given character ! (the character bit value is logical-anded with 0x1f). \end{funcdesc} \begin{funcdesc}{alt}{c} Return the 8-bit character corresponding to the given ASCII character ! (the character bit value is logical-ored with 0x80). \end{funcdesc} The following function takes either a single-character string or ! integer byte value; it returns a string. \begin{funcdesc}{unctrl}{c} ! Return a string representation of the ASCII character c. If c is ! printable, this string is the character itself. If the character ! is a control character (0x00-0x1f) the string consists of a caret ! (^) followed by the corresponding uppercase letter. If the character ! is an ASCII delete (0x7f) the string is "^?". If the character has ! its meta bit (0x80) set, the meta bit is stripped, the preceding rules ! applied, and "!" prepended to the result. \end{funcdesc} - - Finally, the module supplies a 33-element string array - called controlnames that contains the ASCII mnemonics for the - thirty-two ASCII control characters from 0 (NUL) to 0x1f (US), - in order, plus the mnemonic "SP" for space. ! --- 140,173 ---- \begin{funcdesc}{ascii}{c} ! Return the ASCII value corresponding to the low 7 bits of \var{c}. \end{funcdesc} \begin{funcdesc}{ctrl}{c} Return the control character corresponding to the given character ! (the character bit value is bitwise-anded with 0x1f). \end{funcdesc} \begin{funcdesc}{alt}{c} Return the 8-bit character corresponding to the given ASCII character ! (the character bit value is bitwise-ored with 0x80). \end{funcdesc} The following function takes either a single-character string or ! integer value; it returns a string. \begin{funcdesc}{unctrl}{c} ! Return a string representation of the \ASCII{} character \var{c}. If ! \var{c} is printable, this string is the character itself. If the ! character is a control character (0x00-0x1f) the string consists of a ! caret (\character{\^}) followed by the corresponding uppercase letter. ! If the character is an \ASCII{} delete (0x7f) the string is ! \code{'\^{}?'}. If the character has its meta bit (0x80) set, the meta ! bit is stripped, the preceding rules applied, and ! \character{!} prepended to the result. \end{funcdesc} ! \begin{datadesc}{controlnames} ! A 33-element string array that contains the \ASCII{} mnemonics for the ! thirty-two \ASCII{} control characters from 0 (NUL) to 0x1f (US), in ! order, plus the mnemonic \samp{SP} for the space character. ! \end{datadesc} From python-dev@python.org Wed Jun 28 23:03:31 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 15:03:31 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc Makefile.deps,1.33,1.34 Message-ID: <200006282203.PAA12651@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc In directory slayer.i.sourceforge.net:/tmp/cvs-serv12636 Modified Files: Makefile.deps Log Message: Added entries for the curses.ascii module. Index: Makefile.deps =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile.deps,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -r1.33 -r1.34 *** Makefile.deps 2000/06/28 15:07:31 1.33 --- Makefile.deps 2000/06/28 22:03:28 1.34 *************** *** 219,222 **** --- 219,223 ---- ../lib/libcodeop.tex \ ../lib/libcurses.tex \ + ../lib/libascii.tex \ ../lib/libdl.tex \ ../lib/libmutex.tex \ From python-dev@python.org Wed Jun 28 23:05:47 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 15:05:47 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib lib.tex,1.153,1.154 Message-ID: <200006282205.PAA12797@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv12789/lib Modified Files: lib.tex Log Message: Added entry for the curses.ascii module. Index: lib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/lib.tex,v retrieving revision 1.153 retrieving revision 1.154 diff -C2 -r1.153 -r1.154 *** lib.tex 2000/06/28 15:07:30 1.153 --- lib.tex 2000/06/28 22:05:44 1.154 *************** *** 147,150 **** --- 147,151 ---- \input{libgetpass} \input{libcurses} + \input{libascii} % curses.ascii \input{libgetopt} \input{libtempfile} From python-dev@python.org Wed Jun 28 23:07:38 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 15:07:38 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python ceval.c,2.179,2.180 codecs.c,2.6,2.7 compile.c,2.108,2.109 dynload_win.c,2.2,2.3 getcwd.c,1.9,1.10 modsupport.c,2.42,2.43 sysmodule.c,2.65,2.66 thread_nt.h,2.9,2.10 traceback.c,2.27,2.28 Message-ID: <200006282207.PAA12886@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv12842 Modified Files: ceval.c codecs.c compile.c dynload_win.c getcwd.c modsupport.c sysmodule.c thread_nt.h traceback.c Log Message: Trent Mick's Win64 changes: size_t vs. int or long; also some overflow tests. Index: ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.179 retrieving revision 2.180 diff -C2 -r2.179 -r2.180 *** ceval.c 2000/05/08 14:06:50 2.179 --- ceval.c 2000/06/28 22:07:35 2.180 *************** *** 2877,2881 **** else { char *s = PyString_AsString(prog); ! if ((int)strlen(s) != PyString_Size(prog)) { PyErr_SetString(PyExc_ValueError, "embedded '\\0' in exec string"); --- 2877,2881 ---- else { char *s = PyString_AsString(prog); ! if (strlen(s) != (size_t)PyString_Size(prog)) { PyErr_SetString(PyExc_ValueError, "embedded '\\0' in exec string"); Index: codecs.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/codecs.c,v retrieving revision 2.6 retrieving revision 2.7 diff -C2 -r2.6 -r2.7 *** codecs.c 2000/05/09 19:55:59 2.6 --- codecs.c 2000/06/28 22:07:35 2.7 *************** *** 84,92 **** { register int i; ! int len = strlen(string); char *p; PyObject *v; ! v = PyString_FromStringAndSize(NULL, len); if (v == NULL) return NULL; --- 84,97 ---- { register int i; ! size_t len = strlen(string); char *p; PyObject *v; ! if (len > INT_MAX) { ! PyErr_SetString(PyExc_OverflowError, "string is too large"); ! return NULL; ! } ! ! v = PyString_FromStringAndSize(NULL, (int)len); if (v == NULL) return NULL; Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.108 retrieving revision 2.109 diff -C2 -r2.108 -r2.109 *** compile.c 2000/05/03 23:44:38 2.108 --- compile.c 2000/06/28 22:07:35 2.109 *************** *** 266,271 **** continue; p = PyString_AsString(v); ! if ((int)strspn(p, NAME_CHARS) ! != PyString_Size(v)) continue; PyString_InternInPlace(&PyTuple_GET_ITEM(consts, i)); --- 266,271 ---- continue; p = PyString_AsString(v); ! if (strspn(p, NAME_CHARS) ! != (size_t)PyString_Size(v)) continue; PyString_InternInPlace(&PyTuple_GET_ITEM(consts, i)); *************** *** 341,345 **** char *msg; { ! int n = strlen(msg); PyObject *v; char buffer[30]; --- 341,345 ---- char *msg; { ! size_t n = strlen(msg); PyObject *v; char buffer[30]; *************** *** 721,730 **** char *name; char *buffer; ! int maxlen; { /* Name mangling: __private becomes _classname__private. This is independent from how the name is used. */ char *p; ! int nlen, plen; nlen = strlen(name); if (nlen+2 >= maxlen) --- 721,730 ---- char *name; char *buffer; ! size_t maxlen; { /* Name mangling: __private becomes _classname__private. This is independent from how the name is used. */ char *p; ! size_t nlen, plen; nlen = strlen(name); if (nlen+2 >= maxlen) *************** *** 762,766 **** if (name != NULL && name[0] == '_' && name[1] == '_' && c->c_private != NULL && ! com_mangle(c, name, buffer, (int)sizeof(buffer))) name = buffer; #endif --- 762,766 ---- if (name != NULL && name[0] == '_' && name[1] == '_' && c->c_private != NULL && ! com_mangle(c, name, buffer, sizeof(buffer))) name = buffer; #endif *************** *** 884,888 **** { PyObject *v; ! int len; char *buf; char *p; --- 884,888 ---- { PyObject *v; ! size_t len; char *buf; char *p; *************** *** 909,912 **** --- 909,916 ---- s++; len = strlen(s); + if (len > INT_MAX) { + PyErr_SetString(PyExc_OverflowError, "string to parse is too long"); + return NULL; + } if (s[--len] != quote) { PyErr_BadInternalCall(); *************** *** 2202,2206 **** if (s != NULL && s[0] == '_' && s[1] == '_' && c->c_private != NULL && ! com_mangle(c, s, buffer, (int)sizeof(buffer))) s = buffer; #endif --- 2206,2210 ---- if (s != NULL && s[0] == '_' && s[1] == '_' && c->c_private != NULL && ! com_mangle(c, s, buffer, sizeof(buffer))) s = buffer; #endif Index: dynload_win.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/dynload_win.c,v retrieving revision 2.2 retrieving revision 2.3 diff -C2 -r2.2 -r2.3 *** dynload_win.c 1999/12/22 14:09:35 2.2 --- dynload_win.c 2000/06/28 22:07:35 2.3 *************** *** 105,109 **** errorCode); } else { ! int len; /* For some reason a \r\n is appended to the text */ --- 105,109 ---- errorCode); } else { ! size_t len; /* For some reason a \r\n is appended to the text */ Index: getcwd.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/getcwd.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** getcwd.c 1996/10/25 14:43:14 1.9 --- getcwd.c 2000/06/28 22:07:35 1.10 *************** *** 63,67 **** } ret = getwd(localbuf); ! if (ret != NULL && strlen(localbuf) >= size) { errno = ERANGE; return NULL; --- 63,67 ---- } ret = getwd(localbuf); ! if (ret != NULL && strlen(localbuf) >= (size_t)size) { errno = ERANGE; return NULL; Index: modsupport.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/modsupport.c,v retrieving revision 2.42 retrieving revision 2.43 diff -C2 -r2.42 -r2.43 *** modsupport.c 2000/04/28 14:42:37 2.42 --- modsupport.c 2000/06/28 22:07:35 2.43 *************** *** 356,361 **** } else { ! if (n < 0) ! n = strlen(str); v = PyString_FromStringAndSize(str, n); } --- 356,368 ---- } else { ! if (n < 0) { ! size_t m = strlen(str); ! if (m > INT_MAX) { ! PyErr_SetString(PyExc_OverflowError, ! "string too long for Python string"); ! return NULL; ! } ! n = (int)m; ! } v = PyString_FromStringAndSize(str, n); } Index: sysmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v retrieving revision 2.65 retrieving revision 2.66 diff -C2 -r2.65 -r2.66 *** sysmodule.c 2000/06/20 08:12:48 2.65 --- sysmodule.c 2000/06/28 22:07:35 2.66 *************** *** 505,509 **** #ifdef MS_COREDLL PyDict_SetItemString(sysdict, "dllhandle", ! v = PyInt_FromLong((int)PyWin_DLLhModule)); Py_XDECREF(v); PyDict_SetItemString(sysdict, "winver", --- 505,509 ---- #ifdef MS_COREDLL PyDict_SetItemString(sysdict, "dllhandle", ! v = PyLong_FromVoidPtr(PyWin_DLLhModule)); Py_XDECREF(v); PyDict_SetItemString(sysdict, "winver", Index: thread_nt.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_nt.h,v retrieving revision 2.9 retrieving revision 2.10 diff -C2 -r2.9 -r2.10 *** thread_nt.h 2000/05/11 12:53:51 2.9 --- thread_nt.h 2000/06/28 22:07:35 2.10 *************** *** 102,105 **** --- 102,108 ---- } + #ifdef InterlockedCompareExchange + #undef InterlockedCompareExchange + #endif #define InterlockedCompareExchange(dest,exchange,comperand) (ixchg((dest), (exchange), (comperand))) *************** *** 180,184 **** int PyThread_start_new_thread(void (*func)(void *), void *arg) { ! long rv; int success = 0; --- 183,187 ---- int PyThread_start_new_thread(void (*func)(void *), void *arg) { ! INT_PTR rv; int success = 0; *************** *** 191,195 **** if (rv != -1) { success = 1; ! dprintf(("%ld: PyThread_start_new_thread succeeded: %ld\n", PyThread_get_thread_ident(), rv)); } --- 194,198 ---- if (rv != -1) { success = 1; ! dprintf(("%ld: PyThread_start_new_thread succeeded: %p\n", PyThread_get_thread_ident(), rv)); } Index: traceback.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/traceback.c,v retrieving revision 2.27 retrieving revision 2.28 diff -C2 -r2.27 -r2.28 *** traceback.c 2000/05/03 23:44:39 2.27 --- traceback.c 2000/06/28 22:07:35 2.28 *************** *** 167,171 **** if (path != NULL && PyList_Check(path)) { int npath = PyList_Size(path); ! int taillen = strlen(tail); char namebuf[MAXPATHLEN+1]; for (i = 0; i < npath; i++) { --- 167,171 ---- if (path != NULL && PyList_Check(path)) { int npath = PyList_Size(path); ! size_t taillen = strlen(tail); char namebuf[MAXPATHLEN+1]; for (i = 0; i < npath; i++) { *************** *** 176,185 **** } if (PyString_Check(v)) { ! int len; len = PyString_Size(v); if (len + 1 + taillen >= MAXPATHLEN) continue; /* Too long */ strcpy(namebuf, PyString_AsString(v)); ! if ((int)strlen(namebuf) != len) continue; /* v contains '\0' */ if (len > 0 && namebuf[len-1] != SEP) --- 176,185 ---- } if (PyString_Check(v)) { ! size_t len; len = PyString_Size(v); if (len + 1 + taillen >= MAXPATHLEN) continue; /* Too long */ strcpy(namebuf, PyString_AsString(v)); ! if (strlen(namebuf) != len) continue; /* v contains '\0' */ if (len > 0 && namebuf[len-1] != SEP) From python-dev@python.org Wed Jun 28 23:07:57 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 15:07:57 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libatexit.tex,1.1,1.2 Message-ID: <200006282207.PAA12913@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv12906/lib Modified Files: libatexit.tex Log Message: Added note that the atexit module was added for Python 1.6. Index: libatexit.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libatexit.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** libatexit.tex 2000/06/28 15:07:30 1.1 --- libatexit.tex 2000/06/28 22:07:55 1.2 *************** *** 7,10 **** --- 7,12 ---- \modulesynopsis{Register and execute cleanup functions.} + \versionadded{1.6} + The \module{atexit} module defines a single function to register cleanup functions. Functions thus registered are automatically From python-dev@python.org Wed Jun 28 23:09:23 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 15:09:23 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libhttplib.tex,1.20,1.21 Message-ID: <200006282209.PAA13079@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv13070/lib Modified Files: libhttplib.tex Log Message: Made the title of the Examples subsection plural! Index: libhttplib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libhttplib.tex,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -r1.20 -r1.21 *** libhttplib.tex 2000/06/28 21:51:43 1.20 --- libhttplib.tex 2000/06/28 22:09:20 1.21 *************** *** 112,117 **** \end{methoddesc} ! \subsection{Example} ! \nodename{HTTP Example} Here is an example session that uses the \samp{GET} method: --- 112,117 ---- \end{methoddesc} ! \subsection{Examples} ! \nodename{HTTP Examples} Here is an example session that uses the \samp{GET} method: From python-dev@python.org Wed Jun 28 23:11:42 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 15:11:42 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libcurses.tex,1.5,1.6 Message-ID: <200006282211.PAA13181@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv13169/lib Modified Files: libcurses.tex Log Message: Add a "See also:" link to the curses.ascii module. Index: libcurses.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcurses.tex,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** libcurses.tex 2000/06/21 01:42:51 1.5 --- libcurses.tex 2000/06/28 22:11:40 1.6 *************** *** 16,19 **** --- 16,22 ---- \begin{seealso} + \seemodule{curses.ascii}{Utilities for working with \ASCII{} + characters, regardless of your locale + settings.} \seetext{Tutorial material on using curses with Python is available on the Python Web site as Andrew Kuchling's From python-dev@python.org Wed Jun 28 23:13:09 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 15:13:09 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc TODO,1.26,1.27 Message-ID: <200006282213.PAA13365@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc In directory slayer.i.sourceforge.net:/tmp/cvs-serv13357 Modified Files: TODO Log Message: Give Moshe some work to do. Index: TODO =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/TODO,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -r1.26 -r1.27 *** TODO 1999/12/23 17:22:13 1.26 --- TODO 2000/06/28 22:13:06 1.27 *************** *** 32,35 **** --- 32,37 ---- * Straighten out random/whrandom. + * Update the filecmp documentation (Moshe?). + NOT WORTH THE TROUBLE From python-dev@python.org Wed Jun 28 23:20:09 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 15:20:09 -0700 Subject: [Python-checkins] CVS: python/dist/src/PC getpathp.c,1.14,1.15 import_nt.c,1.11,1.12 Message-ID: <200006282220.PAA13728@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv13719 Modified Files: getpathp.c import_nt.c Log Message: Trent Mick: familiar simple Win64 patches Index: getpathp.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/getpathp.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** getpathp.c 2000/05/26 21:49:07 1.14 --- getpathp.c 2000/06/28 22:20:06 1.15 *************** *** 135,139 **** char *dir; { ! int i = strlen(dir); while (i > 0 && !is_sep(dir[i])) --i; --- 135,139 ---- char *dir; { ! size_t i = strlen(dir); while (i > 0 && !is_sep(dir[i])) --i; *************** *** 173,177 **** char *stuff; { ! int n, k; if (is_sep(stuff[0])) n = 0; --- 173,177 ---- char *stuff; { ! size_t n, k; if (is_sep(stuff[0])) n = 0; *************** *** 208,212 **** char *landmark; { - /* Search from argv0_path, until landmark is found */ strcpy(prefix, argv0_path); --- 208,211 ---- *************** *** 245,249 **** static const TCHAR keyPrefix[] = _T("Software\\Python\\PythonCore\\"); static const TCHAR keySuffix[] = _T("\\PythonPath"); ! int versionLen; DWORD index; TCHAR *keyBuf = NULL; --- 244,248 ---- static const TCHAR keyPrefix[] = _T("Software\\Python\\PythonCore\\"); static const TCHAR keySuffix[] = _T("\\PythonPath"); ! size_t versionLen; DWORD index; TCHAR *keyBuf = NULL; *************** *** 403,407 **** if (delim) { ! int len = delim - path; strncpy(progpath, path, len); *(progpath + len) = '\0'; --- 402,406 ---- if (delim) { ! size_t len = delim - path; strncpy(progpath, path, len); *(progpath + len) = '\0'; *************** *** 430,434 **** char argv0_path[MAXPATHLEN+1]; char *buf; ! int bufsz; char *pythonhome = Py_GetPythonHome(); char *envpath = getenv("PYTHONPATH"); --- 429,433 ---- char argv0_path[MAXPATHLEN+1]; char *buf; ! size_t bufsz; char *pythonhome = Py_GetPythonHome(); char *envpath = getenv("PYTHONPATH"); *************** *** 555,559 **** char *p = PYTHONPATH; char *q; ! int n; for (;;) { q = strchr(p, DELIM); --- 554,558 ---- char *p = PYTHONPATH; char *q; ! size_t n; for (;;) { q = strchr(p, DELIM); Index: import_nt.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/import_nt.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** import_nt.c 2000/04/04 22:48:55 1.11 --- import_nt.c 2000/06/28 22:20:06 1.12 *************** *** 34,38 **** // Calculate the size for the sprintf buffer. // Get the size of the chars only, plus 1 NULL. ! int bufSize = sizeof(keyPrefix)-1 + strlen(PyWin_DLLVersionString) + sizeof(keySuffix) + strlen(moduleName) + sizeof(debugString) - 1; // alloca == no free required, but memory only local to fn, also no heap fragmentation! moduleKey = alloca(bufSize); --- 34,38 ---- // Calculate the size for the sprintf buffer. // Get the size of the chars only, plus 1 NULL. ! size_t bufSize = sizeof(keyPrefix)-1 + strlen(PyWin_DLLVersionString) + sizeof(keySuffix) + strlen(moduleName) + sizeof(debugString) - 1; // alloca == no free required, but memory only local to fn, also no heap fragmentation! moduleKey = alloca(bufSize); *************** *** 45,49 **** // use the file extension to locate the type entry. for (fdp = _PyImport_Filetab; fdp->suffix != NULL; fdp++) { ! int extLen=strlen(fdp->suffix); if (modNameSize>extLen && strnicmp(pathBuf+(modNameSize-extLen-1),fdp->suffix,extLen)==0) break; --- 45,49 ---- // use the file extension to locate the type entry. for (fdp = _PyImport_Filetab; fdp->suffix != NULL; fdp++) { ! size_t extLen = strlen(fdp->suffix); if (modNameSize>extLen && strnicmp(pathBuf+(modNameSize-extLen-1),fdp->suffix,extLen)==0) break; From python-dev@python.org Wed Jun 28 23:23:58 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 15:23:58 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules cPickle.c,2.42,2.43 Message-ID: <200006282223.PAA13940@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv13933 Modified Files: cPickle.c Log Message: Trent Mick: This patch fixes cPickle.c for 64-bit platforms. - The false assumption sizeof(long) == size(void*) exists where PyInt_FromLong is used to represent a pointer. The safe Python call for this is PyLong_FromVoidPtr. (On platforms where the above assumption *is* true a PyInt is returned as before so there is no effective change.) - use size_t instead of int for some variables Index: cPickle.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cPickle.c,v retrieving revision 2.42 retrieving revision 2.43 diff -C2 -r2.42 -r2.43 *** cPickle.c 2000/05/09 18:14:50 2.42 --- cPickle.c 2000/06/28 22:23:56 2.43 *************** *** 657,661 **** long c_value; char s[30]; ! int len; UNLESS (mv = PyDict_GetItem(self->memo, id)) { --- 657,661 ---- long c_value; char s[30]; ! size_t len; UNLESS (mv = PyDict_GetItem(self->memo, id)) { *************** *** 718,722 **** put2(Picklerobject *self, PyObject *ob) { char c_str[30]; ! int p, len, res = -1; PyObject *py_ob_id = 0, *memo_len = 0, *t = 0; --- 718,724 ---- put2(Picklerobject *self, PyObject *ob) { char c_str[30]; ! int p; ! size_t len; ! int res = -1; PyObject *py_ob_id = 0, *memo_len = 0, *t = 0; *************** *** 728,732 **** p++; /* Make sure memo keys are positive! */ ! UNLESS (py_ob_id = PyInt_FromLong((long)ob)) goto finally; --- 730,734 ---- p++; /* Make sure memo keys are positive! */ ! UNLESS (py_ob_id = PyLong_FromVoidPtr(ob)) goto finally; *************** *** 1256,1260 **** } ! UNLESS (py_tuple_id = PyInt_FromLong((long)args)) goto finally; --- 1258,1262 ---- } ! UNLESS (py_tuple_id = PyLong_FromVoidPtr(args)) goto finally; *************** *** 1776,1785 **** if (args->ob_refcnt > 1) { - long ob_id; int has_key; ! ob_id = (long)args; ! ! UNLESS (py_ob_id = PyInt_FromLong(ob_id)) goto finally; --- 1778,1784 ---- if (args->ob_refcnt > 1) { int has_key; ! UNLESS (py_ob_id = PyLong_FromVoidPtr(args)) goto finally; From python-dev@python.org Wed Jun 28 23:26:23 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 15:26:23 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules signalmodule.c,2.39,2.40 Message-ID: <200006282226.PAA14044@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv14036 Modified Files: signalmodule.c Log Message: Trent Mick: Fix warnings on 64-bit build build of signalmodule.c - Though I know that SIG_DFL and SIG_IGN are just small constants, there are cast to function pointers so the appropriate Python call is PyLong_FromVoidPtr so that the pointer value cannot overflow on Win64 where sizeof(long) < sizeof(void*). Index: signalmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/signalmodule.c,v retrieving revision 2.39 retrieving revision 2.40 diff -C2 -r2.39 -r2.40 *** signalmodule.c 1998/12/21 19:32:39 2.39 --- signalmodule.c 2000/06/28 22:26:21 2.40 *************** *** 357,365 **** d = PyModule_GetDict(m); ! x = DefaultHandler = PyInt_FromLong((long)SIG_DFL); if (!x || PyDict_SetItemString(d, "SIG_DFL", x) < 0) goto finally; ! x = IgnoreHandler = PyInt_FromLong((long)SIG_IGN); if (!x || PyDict_SetItemString(d, "SIG_IGN", x) < 0) goto finally; --- 357,365 ---- d = PyModule_GetDict(m); ! x = DefaultHandler = PyLong_FromVoidPtr(SIG_DFL); if (!x || PyDict_SetItemString(d, "SIG_DFL", x) < 0) goto finally; ! x = IgnoreHandler = PyLong_FromVoidPtr(SIG_IGN); if (!x || PyDict_SetItemString(d, "SIG_IGN", x) < 0) goto finally; From python-dev@python.org Wed Jun 28 23:47:25 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 15:47:25 -0700 Subject: [Python-checkins] CVS: python/dist/src/Tools/scripts pindent.py,1.6,1.7 Message-ID: <200006282247.PAA15119@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Tools/scripts In directory slayer.i.sourceforge.net:/tmp/cvs-serv15110 Modified Files: pindent.py Log Message: Peter Schneider-Kamp: Problem: A Python program can be completed and reformatted using Tools/scripts/pindent.py. Unfortunately there is no option for removal of the generated "# end"-tags. Although a few Python commands or a "grep -v '# end '" can do wonders here, there are two drawbacks: - not everyone has grep/time to write a Python script - it is not checked whether the "# end"-tags were used validly Solution: add extra option "-e" (eliminate) to pindent.py Index: pindent.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/pindent.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** pindent.py 1998/06/19 21:39:27 1.6 --- pindent.py 2000/06/28 22:47:22 1.7 *************** *** 1,9 **** #! /usr/bin/env python ! # This file contains a class and a main program that perform two # related (though complimentary) formatting operations on Python ! # programs. When called as "pindend -c", it takes a valid Python # program as input and outputs a version augmented with block-closing ! # comments. When called as "pindent -r" it assumes its input is a # Python program with block-closing comments but with its indentation # messed up, and outputs a properly indented version. --- 1,11 ---- #! /usr/bin/env python ! # This file contains a class and a main program that perform three # related (though complimentary) formatting operations on Python ! # programs. When called as "pindent -c", it takes a valid Python # program as input and outputs a version augmented with block-closing ! # comments. When called as "pindent -e", it assumes its input is a ! # Python program with block-closing comments and outputs a commentless ! # version. When called as "pindent -r" it assumes its input is a # Python program with block-closing comments but with its indentation # messed up, and outputs a properly indented version. *************** *** 35,43 **** # comments). ! # Both operations are idempotent (i.e. applied to their own output # they yield an identical result). Running first "pindent -c" and # then "pindent -r" on a valid Python program produces a program that # is semantically identical to the input (though its indentation may ! # be different). # Other options: --- 37,46 ---- # comments). ! # The operations are idempotent (i.e. applied to their own output # they yield an identical result). Running first "pindent -c" and # then "pindent -r" on a valid Python program produces a program that # is semantically identical to the input (though its indentation may ! # be different). Running "pindent -e" on that output produces a ! # program that only differs from the original in indentation. # Other options: *************** *** 194,197 **** --- 197,228 ---- # end def reformat + def eliminate(self): + begin_counter = 0 + end_counter = 0 + while 1: + line = self.getline() + if not line: break # EOF + # end if + m = self.endprog.match(line) + if m: + end_counter = end_counter + 1 + continue + # end if + m = self.kwprog.match(line) + if m: + kw = m.group('kw') + if kw in start: + begin_counter = begin_counter + 1 + # end if + # end if + self.putline(line) + # end while + if begin_counter - end_counter < 0: + sys.stderr.write('Warning: input contained more end tags than expected\n') + elif begin_counter - end_counter > 0: + sys.stderr.write('Warning: input contained less end tags than expected\n') + # end if + # end def eliminate + def complete(self): self.indentsize = 1 *************** *** 294,298 **** # - xxx_file(filename): process file in place, return true iff changed ! def complete_filter(input= sys.stdin, output = sys.stdout, stepsize = STEPSIZE, tabsize = TABSIZE): pi = PythonIndenter(input, output, stepsize, tabsize) --- 325,329 ---- # - xxx_file(filename): process file in place, return true iff changed ! def complete_filter(input = sys.stdin, output = sys.stdout, stepsize = STEPSIZE, tabsize = TABSIZE): pi = PythonIndenter(input, output, stepsize, tabsize) *************** *** 300,303 **** --- 331,340 ---- # end def complete_filter + def eliminate_filter(input= sys.stdin, output = sys.stdout, + stepsize = STEPSIZE, tabsize = TABSIZE): + pi = PythonIndenter(input, output, stepsize, tabsize) + pi.eliminate() + # end def eliminate_filter + def reformat_filter(input = sys.stdin, output = sys.stdout, stepsize = STEPSIZE, tabsize = TABSIZE): *************** *** 358,361 **** --- 395,406 ---- # end def complete_string + def eliminate_string(source, stepsize = STEPSIZE, tabsize = TABSIZE): + input = StringReader(source) + output = StringWriter() + pi = PythonIndenter(input, output, stepsize, tabsize) + pi.eliminate() + return output.getvalue() + # end def eliminate_string + def reformat_string(source, stepsize = STEPSIZE, tabsize = TABSIZE): input = StringReader(source) *************** *** 381,384 **** --- 426,444 ---- # end def complete_file + def eliminate_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE): + source = open(filename, 'r').read() + result = eliminate_string(source, stepsize, tabsize) + if source == result: return 0 + # end if + import os + try: os.rename(filename, filename + '~') + except os.error: pass + # end try + f = open(filename, 'w') + f.write(result) + f.close() + return 1 + # end def eliminate_file + def reformat_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE): source = open(filename, 'r').read() *************** *** 387,391 **** # end if import os ! os.rename(filename, filename + '~') f = open(filename, 'w') f.write(result) --- 447,453 ---- # end if import os ! try: os.rename(filename, filename + '~') ! except os.error: pass ! # end try f = open(filename, 'w') f.write(result) *************** *** 397,402 **** usage = """ ! usage: pindent (-c|-r) [-s stepsize] [-t tabsize] [file] ... -c : complete a correctly indented program (add #end directives) -r : reformat a completed program (use #end directives) -s stepsize: indentation step (default %(STEPSIZE)d) --- 459,465 ---- usage = """ ! usage: pindent (-c|-e|-r) [-s stepsize] [-t tabsize] [file] ... -c : complete a correctly indented program (add #end directives) + -e : eliminate #end directives -r : reformat a completed program (use #end directives) -s stepsize: indentation step (default %(STEPSIZE)d) *************** *** 410,414 **** import getopt try: ! opts, args = getopt.getopt(sys.argv[1:], 'crs:t:') except getopt.error, msg: sys.stderr.write('Error: %s\n' % msg) --- 473,477 ---- import getopt try: ! opts, args = getopt.getopt(sys.argv[1:], 'cers:t:') except getopt.error, msg: sys.stderr.write('Error: %s\n' % msg) *************** *** 422,425 **** --- 485,490 ---- if o == '-c': action = 'complete' + elif o == '-e': + action = 'eliminate' elif o == '-r': action = 'reformat' *************** *** 432,436 **** if not action: sys.stderr.write( ! 'You must specify -c(omplete) or -r(eformat)\n') sys.stderr.write(usage) sys.exit(2) --- 497,501 ---- if not action: sys.stderr.write( ! 'You must specify -c(omplete), -e(eliminate) or -r(eformat)\n') sys.stderr.write(usage) sys.exit(2) From python-dev@python.org Wed Jun 28 23:55:23 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 15:55:23 -0700 Subject: [Python-checkins] CVS: python/dist/src/Tools/scripts pindent.py,1.7,1.8 Message-ID: <200006282255.PAA15643@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Tools/scripts In directory slayer.i.sourceforge.net:/tmp/cvs-serv15635 Modified Files: pindent.py Log Message: Running the program through itself reveals that one end tag was mislabeled. (Using -c and then -e rearranges some comments, so I won't check that in -- but it's a good test anyway. Note that pindent is not perfect -- e.g. it doesn't know about triple-quoted strings!) Index: pindent.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/pindent.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** pindent.py 2000/06/28 22:47:22 1.7 --- pindent.py 2000/06/28 22:55:20 1.8 *************** *** 341,345 **** pi = PythonIndenter(input, output, stepsize, tabsize) pi.reformat() ! # end def reformat class StringReader: --- 341,345 ---- pi = PythonIndenter(input, output, stepsize, tabsize) pi.reformat() ! # end def reformat_filter class StringReader: From python-dev@python.org Thu Jun 29 00:24:21 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 16:24:21 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python marshal.c,1.48,1.49 Message-ID: <200006282324.QAA23340@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv23333 Modified Files: marshal.c Log Message: Urmpf. Quality control on this patch lapsed a bit. :-( The depth field was never decremented inside w_object(), and it was never initialized in PyMarshal_WriteObjectToFile(). This caused imports from .pyc files to fil mysteriously when the .pyc file was written by the broken code -- w_object() would bail out early, but PyMarshal_WriteObjectToFile() doesn't check the error or return an error code, and apparently the marshalling code doesn't call PyErr_Check() either. (That's a separate patch if I feel like it.) Index: marshal.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/marshal.c,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -r1.48 -r1.49 *** marshal.c 2000/06/28 18:47:56 1.48 --- marshal.c 2000/06/28 23:24:19 1.49 *************** *** 235,240 **** utf8 = PyUnicode_AsUTF8String(v); if (utf8 == NULL) { ! p->error = 1; ! return; } w_byte(TYPE_UNICODE, p); --- 235,241 ---- utf8 = PyUnicode_AsUTF8String(v); if (utf8 == NULL) { ! p->depth--; ! p->error = 1; ! return; } w_byte(TYPE_UNICODE, p); *************** *** 304,307 **** --- 305,310 ---- p->error = 1; } + + p->depth--; } *************** *** 326,329 **** --- 329,333 ---- wf.fp = fp; wf.error = 0; + wf.depth = 0; w_object(x, &wf); } From python-dev@python.org Thu Jun 29 00:46:10 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 16:46:10 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects classobject.c,2.90,2.91 Message-ID: <200006282346.QAA24575@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv24566 Modified Files: classobject.c Log Message: Vladimir Marangozov: Avoid calling the dealloc function, previously triggered with DECREF(inst). This caused a segfault in PyDict_GetItem, called with a NULL dict, whenever inst->in_dict fails under low-memory conditions. Index: classobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v retrieving revision 2.90 retrieving revision 2.91 diff -C2 -r2.90 -r2.91 *** classobject.c 2000/06/28 21:57:18 2.90 --- classobject.c 2000/06/28 23:46:07 2.91 *************** *** 490,500 **** if (inst == NULL) return NULL; - Py_INCREF(class); - inst->in_class = (PyClassObject *)class; inst->in_dict = PyDict_New(); if (inst->in_dict == NULL) { ! Py_DECREF(inst); return NULL; } if (initstr == NULL) initstr = PyString_InternFromString("__init__"); --- 490,500 ---- if (inst == NULL) return NULL; inst->in_dict = PyDict_New(); if (inst->in_dict == NULL) { ! PyObject_DEL(inst); return NULL; } + Py_INCREF(class); + inst->in_class = (PyClassObject *)class; if (initstr == NULL) initstr = PyString_InternFromString("__init__"); From python-dev@python.org Thu Jun 29 00:53:59 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 16:53:59 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python getargs.c,2.33,2.34 Message-ID: <200006282353.QAA25108@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv25100 Modified Files: getargs.c Log Message: Vladimir Marangozov: This patch fixes a problem on AIX with the signed int case code in getargs.c, after Trent Mick's intervention about MIN/MAX overflow checks. The AIX compiler/optimizer generates bogus code with the default flags "-g -O" causing test_builtin to fail: int("10", 16) <> 16L. Swapping the two checks in the signed int code makes the problem go away. Also, make the error messages fit in 80 char lines in the source. Index: getargs.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/getargs.c,v retrieving revision 2.33 retrieving revision 2.34 diff -C2 -r2.33 -r2.34 *** getargs.c 2000/05/09 21:50:00 2.33 --- getargs.c 2000/06/28 23:53:56 2.34 *************** *** 474,483 **** else if (ival < 0) { PyErr_SetString(PyExc_OverflowError, ! "unsigned byte integer is less than minimum"); return "integer"; } else if (ival > UCHAR_MAX) { PyErr_SetString(PyExc_OverflowError, ! "unsigned byte integer is greater than maximum"); return "integer"; } --- 474,483 ---- else if (ival < 0) { PyErr_SetString(PyExc_OverflowError, ! "unsigned byte integer is less than minimum"); return "integer"; } else if (ival > UCHAR_MAX) { PyErr_SetString(PyExc_OverflowError, ! "unsigned byte integer is greater than maximum"); return "integer"; } *************** *** 495,504 **** else if (ival < SHRT_MIN) { PyErr_SetString(PyExc_OverflowError, ! "signed short integer is less than minimum"); return "integer"; } else if (ival > SHRT_MAX) { PyErr_SetString(PyExc_OverflowError, ! "signed short integer is greater than maximum"); return "integer"; } --- 495,504 ---- else if (ival < SHRT_MIN) { PyErr_SetString(PyExc_OverflowError, ! "signed short integer is less than minimum"); return "integer"; } else if (ival > SHRT_MAX) { PyErr_SetString(PyExc_OverflowError, ! "signed short integer is greater than maximum"); return "integer"; } *************** *** 514,525 **** if (ival == -1 && PyErr_Occurred()) return "integer"; ! else if (ival < INT_MIN) { PyErr_SetString(PyExc_OverflowError, ! "signed integer is less than minimum"); return "integer"; } ! else if (ival > INT_MAX) { PyErr_SetString(PyExc_OverflowError, ! "signed integer is greater than maximum"); return "integer"; } --- 514,525 ---- if (ival == -1 && PyErr_Occurred()) return "integer"; ! else if (ival > INT_MAX) { PyErr_SetString(PyExc_OverflowError, ! "signed integer is greater than maximum"); return "integer"; } ! else if (ival < INT_MIN) { PyErr_SetString(PyExc_OverflowError, ! "signed integer is less than minimum"); return "integer"; } From python-dev@python.org Thu Jun 29 01:04:54 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 17:04:54 -0700 Subject: [Python-checkins] CVS: python/dist/src/Misc ACKS,1.56,1.57 Message-ID: <200006290004.RAA31899@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Misc In directory slayer.i.sourceforge.net:/tmp/cvs-serv31891 Modified Files: ACKS Log Message: Some new names (some contributors of patches that haven't even been accepted yet!) Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -r1.56 -r1.57 *** ACKS 2000/05/11 18:20:30 1.56 --- ACKS 2000/06/29 00:04:51 1.57 *************** *** 45,48 **** --- 45,49 ---- Dave Brennan Gary S. Brown + Oleg Broytmann Erik de Bueger Jan-Hein B"uhrman *************** *** 115,118 **** --- 116,120 ---- Fred Gansevles Lars Marius Garshol + Hary Henry Gebel Thomas Gellekum Ben Gertzfield *************** *** 324,327 **** --- 326,330 ---- Dan Stromberg Nathan Sullivan + Kalle Svensson Neale Pickett Dan Pierson From python-dev@python.org Thu Jun 29 01:06:42 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 17:06:42 -0700 Subject: [Python-checkins] CVS: python/dist/src/Include ucnhash.h,1.1,1.2 Message-ID: <200006290006.RAA31961@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Include In directory slayer.i.sourceforge.net:/tmp/cvs-serv31933/Include Modified Files: ucnhash.h Log Message: Jack Jansen: Use include "" instead of <>; and staticforward declarations Index: ucnhash.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/ucnhash.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** ucnhash.h 2000/06/28 16:37:24 1.1 --- ucnhash.h 2000/06/29 00:06:39 1.2 *************** *** 1,4 **** ! #include #include --- 1,4 ---- ! #include "Python.h" #include From python-dev@python.org Thu Jun 29 01:06:41 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 17:06:41 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.30,2.31 Message-ID: <200006290006.RAA31952@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv31933/Objects Modified Files: unicodeobject.c Log Message: Jack Jansen: Use include "" instead of <>; and staticforward declarations Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.30 retrieving revision 2.31 diff -C2 -r2.30 -r2.31 *** unicodeobject.c 2000/06/28 16:43:35 2.30 --- unicodeobject.c 2000/06/29 00:06:39 2.31 *************** *** 67,71 **** #include "mymath.h" #include "unicodeobject.h" ! #include #if defined(HAVE_LIMITS_H) --- 67,71 ---- #include "mymath.h" #include "unicodeobject.h" ! #include "ucnhash.h" #if defined(HAVE_LIMITS_H) From python-dev@python.org Thu Jun 29 01:06:42 2000 From: python-dev@python.org (Guido van Rossum) Date: Wed, 28 Jun 2000 17:06:42 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules ucnhash.c,1.1,1.2 Message-ID: <200006290006.RAA31962@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv31933/Modules Modified Files: ucnhash.c Log Message: Jack Jansen: Use include "" instead of <>; and staticforward declarations Index: ucnhash.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/ucnhash.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** ucnhash.c 2000/06/28 16:38:56 1.1 --- ucnhash.c 2000/06/29 00:06:39 1.2 *************** *** 1,3 **** ! #include /* --- 1,3 ---- ! #include "ucnhash.h" /* *************** *** 20,25 **** ! static const unsigned short G[k_cHashElements]; ! static const _Py_UnicodeCharacterName aucn[k_cKeys]; static long f1(const char *key, unsigned int cch) --- 20,25 ---- ! staticforward const unsigned short G[k_cHashElements]; ! staticforward const _Py_UnicodeCharacterName aucn[k_cKeys]; static long f1(const char *key, unsigned int cch) From python-dev@python.org Thu Jun 29 02:00:51 2000 From: python-dev@python.org (Greg Stein) Date: Wed, 28 Jun 2000 18:00:51 -0700 Subject: [Python-checkins] CVS: python/dist/src/Demo/imputil - New directory Message-ID: <200006290100.SAA04969@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Demo/imputil In directory slayer.i.sourceforge.net:/tmp/cvs-serv4792/imputil Log Message: Directory /cvsroot/python/python/dist/src/Demo/imputil added to the repository From python-dev@python.org Thu Jun 29 03:06:33 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 28 Jun 2000 19:06:33 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command sdist.py,1.35,1.36 Message-ID: <200006290206.TAA17518@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv17312 Modified Files: sdist.py Log Message: Fixed 'findall()' so it only returns regular files -- no directories. Changed 'prune_file_list()' so it also prunes out RCS and CVS directories. Added 'is_regex' parameter to 'select_pattern()', 'exclude_pattern()', and 'translate_pattern()', so that you don't have to be constrained by the simple shell-glob-like pattern language, and can escape into full-blown regexes when needed. Currently this is only available in code -- it's not exposed in the manifest template mini-language. Added 'prune' option (controlled by --prune and --no-prune) to determine whether we call 'prune_file_list()' or not -- it's true by default. Fixed 'negative_opt' -- it was misnamed and not being seen by dist.py. Added --no-defaults to the option table, so it's seen by FancyGetopt. Index: sdist.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/sdist.py,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -r1.35 -r1.36 *** sdist.py 2000/06/24 01:23:37 1.35 --- sdist.py 2000/06/29 02:06:29 1.36 *************** *** 47,50 **** --- 47,58 ---- "include the default file set in the manifest " "[default; disable with --no-defaults]"), + ('no-defaults', None, + "don't include the default file set"), + ('prune', None, + "specifically exclude files/directories that should not be " + "distributed (build tree, RCS/CVS dirs, etc.) " + "[default; disable with --no-prune]"), + ('no-prune', None, + "don't automatically exclude anything"), ('manifest-only', 'o', "just regenerate the manifest and then stop " *************** *** 65,69 **** ] ! negative_opts = {'use-defaults': 'no-defaults'} default_format = { 'posix': 'gztar', --- 73,78 ---- ] ! negative_opt = {'no-defaults': 'use-defaults', ! 'no-prune': 'prune' } default_format = { 'posix': 'gztar', *************** *** 79,82 **** --- 88,92 ---- # in the manifest self.use_defaults = 1 + self.prune = 1 self.manifest_only = 0 *************** *** 218,223 **** self.read_template () ! # Prune away the build and source distribution directories ! self.prune_file_list() # File list now complete -- sort it so that higher-level files --- 228,235 ---- self.read_template () ! # Prune away any directories that don't belong in the source ! # distribution ! if self.prune: ! self.prune_file_list() # File list now complete -- sort it so that higher-level files *************** *** 510,517 **** def prune_file_list (self): """Prune off branches that might slip into the file list as created ! by 'read_template()', but really don't belong there: specifically, ! the build tree (typically "build") and the release tree itself ! (only an issue if we ran "sdist" previously with --keep-tree, or it ! aborted). """ build = self.get_finalized_command('build') --- 522,530 ---- def prune_file_list (self): """Prune off branches that might slip into the file list as created ! by 'read_template()', but really don't belong there: ! * the build tree (typically "build") ! * the release tree itself (only an issue if we ran "sdist" ! previously with --keep-tree, or it aborted) ! * any RCS or CVS directories """ build = self.get_finalized_command('build') *************** *** 519,525 **** self.exclude_pattern (self.files, None, prefix=build.build_base) self.exclude_pattern (self.files, None, prefix=base_dir) ! def select_pattern (self, files, pattern, anchor=1, prefix=None): """Select strings (presumably filenames) from 'files' that match 'pattern', a Unix-style wildcard (glob) pattern. Patterns are not --- 532,540 ---- self.exclude_pattern (self.files, None, prefix=build.build_base) self.exclude_pattern (self.files, None, prefix=base_dir) + self.exclude_pattern (self.files, r'/(RCS|CVS)/.*', is_regex=1) ! def select_pattern (self, files, pattern, ! anchor=1, prefix=None, is_regex=0): """Select strings (presumably filenames) from 'files' that match 'pattern', a Unix-style wildcard (glob) pattern. Patterns are not *************** *** 537,544 **** them, will match. 'anchor' is ignored in this case. Return the list of matching strings, possibly empty. """ matches = [] ! pattern_re = translate_pattern (pattern, anchor, prefix) self.debug_print("select_pattern: applying regex r'%s'" % pattern_re.pattern) --- 552,564 ---- them, will match. 'anchor' is ignored in this case. + If 'is_regex' is true, 'anchor' and 'prefix' are ignored, and + 'pattern' is assumed to be either a string containing a regex or a + regex object -- no translation is done, the regex is just compiled + and used as-is. + Return the list of matching strings, possibly empty. """ matches = [] ! pattern_re = translate_pattern (pattern, anchor, prefix, is_regex) self.debug_print("select_pattern: applying regex r'%s'" % pattern_re.pattern) *************** *** 553,563 **** ! def exclude_pattern (self, files, pattern, anchor=1, prefix=None): """Remove strings (presumably filenames) from 'files' that match ! 'pattern'. 'pattern', 'anchor', 'and 'prefix' are the same ! as for 'select_pattern()', above. The list 'files' is modified ! in place. """ ! pattern_re = translate_pattern (pattern, anchor, prefix) self.debug_print("exclude_pattern: applying regex r'%s'" % pattern_re.pattern) --- 573,584 ---- ! def exclude_pattern (self, files, pattern, ! anchor=1, prefix=None, is_regex=0): """Remove strings (presumably filenames) from 'files' that match ! 'pattern'. Other parameters are the same as for ! 'select_pattern()', above. The list 'files' is modified in place. """ ! ! pattern_re = translate_pattern (pattern, anchor, prefix, is_regex) self.debug_print("exclude_pattern: applying regex r'%s'" % pattern_re.pattern) *************** *** 675,678 **** --- 696,701 ---- (relative to 'dir'). """ + from stat import ST_MODE, S_ISREG, S_ISDIR, S_ISLNK + list = [] stack = [dir] *************** *** 689,694 **** else: fullname = name ! list.append (fullname) ! if os.path.isdir (fullname) and not os.path.islink(fullname): push (fullname) --- 712,722 ---- else: fullname = name ! ! # Avoid excess stat calls -- just one will do, thank you! ! stat = os.stat(fullname) ! mode = stat[ST_MODE] ! if S_ISREG(mode): ! list.append (fullname) ! elif S_ISDIR(mode) and not S_ISLNK(mode): push (fullname) *************** *** 717,724 **** ! def translate_pattern (pattern, anchor=1, prefix=None): """Translate a shell-like wildcard pattern to a compiled regular ! expression. Return the compiled regex. """ if pattern: pattern_re = glob_to_re (pattern) --- 745,760 ---- ! def translate_pattern (pattern, anchor=1, prefix=None, is_regex=0): """Translate a shell-like wildcard pattern to a compiled regular ! expression. Return the compiled regex. If 'is_regex' true, ! then 'pattern' is directly compiled to a regex (if it's a string) ! or just returned as-is (assumes it's a regex object). """ + if is_regex: + if type(pattern) is StringType: + return re.compile(pattern) + else: + return pattern + if pattern: pattern_re = glob_to_re (pattern) From python-dev@python.org Thu Jun 29 03:16:26 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 28 Jun 2000 19:16:26 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command build_ext.py,1.52,1.53 Message-ID: <200006290216.TAA18111@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv18102 Modified Files: build_ext.py Log Message: Fixed so 'get_source_files()' calls 'check_extension_list()' -- that way, we can run "sdist" on a distribution with old-style extension structures even if we haven't built it yet. Bug spotted by Harry Gebel. Index: build_ext.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build_ext.py,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -r1.52 -r1.53 *** build_ext.py 2000/06/28 14:48:01 1.52 --- build_ext.py 2000/06/29 02:16:24 1.53 *************** *** 310,314 **** def get_source_files (self): ! filenames = [] --- 310,314 ---- def get_source_files (self): ! self.check_extension_list() filenames = [] From python-dev@python.org Thu Jun 29 03:22:05 2000 From: python-dev@python.org (Greg Ward) Date: Wed, 28 Jun 2000 19:22:05 -0700 Subject: [Python-checkins] CVS: distutils/examples mxdatetime_setup.py,1.7,1.8 pil_setup.py,1.12,1.13 xml_setup.py,1.1,1.2 Message-ID: <200006290222.TAA18872@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/examples In directory slayer.i.sourceforge.net:/tmp/cvs-serv18802/examples Modified Files: mxdatetime_setup.py pil_setup.py xml_setup.py Log Message: Harry Henry Gebel: updated the PIL and XML setup scripts to use new-style extension descriptions and fixes a bug in the mxDateTime setup script (which uses new-style extensions but did not import the Extension class). Index: mxdatetime_setup.py =================================================================== RCS file: /cvsroot/python/distutils/examples/mxdatetime_setup.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** mxdatetime_setup.py 2000/06/25 02:48:08 1.7 --- mxdatetime_setup.py 2000/06/29 02:22:02 1.8 *************** *** 9,13 **** import string ! from distutils.core import setup from distutils.command.config import config --- 9,13 ---- import string ! from distutils.core import setup, Extension from distutils.command.config import config Index: pil_setup.py =================================================================== RCS file: /cvsroot/python/distutils/examples/pil_setup.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** pil_setup.py 2000/06/27 02:11:03 1.12 --- pil_setup.py 2000/06/29 02:22:02 1.13 *************** *** 9,13 **** import os ! from distutils.core import setup from distutils.ccompiler import new_compiler from distutils.command.config import config --- 9,13 ---- import os ! from distutils.core import setup, Extension from distutils.ccompiler import new_compiler from distutils.command.config import config *************** *** 154,177 **** packages = ['PIL'], ! ext_modules = \ ! [('_imaging', ! { 'sources': ['_imaging.c', 'decode.c', 'encode.c', ! 'map.c', 'display.c', 'outline.c', 'path.c'], ! # This must include the directories with the JPEG, ! # zlib, and Tcl/Tk header files (if installed) ! 'include_dirs': include_dirs, ! ! # Keep this for Tcl/Tk support ! 'macros': ext_macros, ! ! # This must include the directories with the JPEG, zlib, ! # and Tcl/Tk libraries (whatever's available) ! 'library_dirs': library_dirs, ! ! # And this, of course, lists which of those external ! # libraries to link against (plus libImaging, which *must* ! # be included!) ! 'libraries': optional_libs ! } ! )] ) --- 154,175 ---- packages = ['PIL'], ! ext_modules = ! [Extension('_imaging', ! ['_imaging.c', 'decode.c', 'encode.c', ! 'map.c', 'display.c', 'outline.c', 'path.c'], ! # This must include the directories with the JPEG, ! # zlib, and Tcl/Tk header files (if installed) ! include_dirs = include_dirs, ! ! # Keep this for Tcl/Tk support ! define_macros = ext_macros, ! ! # This must include the directories with the JPEG, zlib, ! # and Tcl/Tk libraries (whatever's available) ! library_dirs = library_dirs, ! ! # And this, of course, lists which of those external ! # libraries to link against (plus libImaging, which ! # *must* be included!) ! libraries = optional_libs)] ) Index: xml_setup.py =================================================================== RCS file: /cvsroot/python/distutils/examples/xml_setup.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** xml_setup.py 2000/03/09 03:17:59 1.1 --- xml_setup.py 2000/06/29 02:22:02 1.2 *************** *** 12,16 **** import sys, os ! from distutils.core import setup --- 12,16 ---- import sys, os ! from distutils.core import setup, Extension *************** *** 32,55 **** ], ! ext_modules = [('sgmlop', { 'sources' : ['extensions/sgmlop.c'] }), ! ('xml.unicode.wstrop', { 'sources' : ['extensions/wstrop.c'] ! }), ! ('xml.parsers.pyexpat', { 'define': [('XML_NS', None)], ! 'include_dirs': [ 'extensions/expat/xmltok', ! 'extensions/expat/xmlparse' ], ! ! 'sources' : ! [ ! 'extensions/pyexpat.c', ! 'extensions/expat/xmltok/xmltok.c', ! 'extensions/expat/xmltok/xmlrole.c', ! 'extensions/expat/xmlwf/xmlfile.c', ! 'extensions/expat/xmlwf/xmlwf.c', ! 'extensions/expat/xmlwf/codepage.c', ! 'extensions/expat/xmlparse/xmlparse.c', ! 'extensions/expat/xmlparse/hashtable.c', ! FILEMAP_SRC, ! ] }), ] ) - --- 32,53 ---- ], ! ext_modules = [Extension('sgmlop', ! ['extensions/sgmlop.c']), ! Extension('xml.unicode.wstrop', ! ['extensions/wstrop.c']), ! Extension('xml.parsers.pyexpat', ! ['extensions/pyexpat.c', ! 'extensions/expat/xmltok/xmltok.c', ! 'extensions/expat/xmltok/xmlrole.c', ! 'extensions/expat/xmlwf/xmlfile.c', ! 'extensions/expat/xmlwf/xmlwf.c', ! 'extensions/expat/xmlwf/codepage.c', ! 'extensions/expat/xmlparse/xmlparse.c', ! 'extensions/expat/xmlparse/hashtable.c', ! FILEMAP_SRC,], ! define_macros = [('XML_NS', None)], ! include_dirs = [ 'extensions/expat/xmltok', ! 'extensions/expat/xmlparse' ], ! ) ] ) From python-dev@python.org Thu Jun 29 04:33:31 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 20:33:31 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc TODO,1.27,1.28 Message-ID: <200006290333.UAA29239@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc In directory slayer.i.sourceforge.net:/tmp/cvs-serv29230 Modified Files: TODO Log Message: Add update of httplib docs to reflect Greg Stein's recent updates. Greg, this is yours! Index: TODO =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/TODO,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -r1.27 -r1.28 *** TODO 2000/06/28 22:13:06 1.27 --- TODO 2000/06/29 03:33:28 1.28 *************** *** 34,37 **** --- 34,40 ---- * Update the filecmp documentation (Moshe?). + * Update the httplib documentation to match Greg Stein's HTTP/1.1 + support and new classes. (Greg, this is yours!) + NOT WORTH THE TROUBLE From python-dev@python.org Thu Jun 29 04:46:49 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 20:46:49 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libfuncs.tex,1.64,1.65 Message-ID: <200006290346.UAA29830@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv29823/lib Modified Files: libfuncs.tex Log Message: Make it clear that id() can return either a long integer or a plain integer. Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -r1.64 -r1.65 *** libfuncs.tex 2000/04/06 15:06:03 1.64 --- libfuncs.tex 2000/06/29 03:46:46 1.65 *************** *** 303,311 **** \begin{funcdesc}{id}{object} ! Return the `identity' of an object. This is an integer which is ! guaranteed to be unique and constant for this object during its ! lifetime. (Two objects whose lifetimes are disjunct may have the ! same \function{id()} value.) (Implementation note: this is the ! address of the object.) \end{funcdesc} --- 303,311 ---- \begin{funcdesc}{id}{object} ! Return the `identity' of an object. This is an integer (or long ! integer) which is guaranteed to be unique and constant for this ! object during its lifetime. Two objects whose lifetimes are ! disjunct may have the same \function{id()} value. (Implementation ! note: this is the address of the object.) \end{funcdesc} From python-dev@python.org Thu Jun 29 06:06:05 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 22:06:05 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib mhlib.py,1.19,1.20 Message-ID: <200006290506.WAA13205@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv13198 Modified Files: mhlib.py Log Message: Convert to use class-based exceptions. Correct exception information in one docstring. Index: mhlib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mhlib.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -r1.19 -r1.20 *** mhlib.py 2000/02/04 15:10:33 1.19 --- mhlib.py 2000/06/29 05:06:02 1.20 *************** *** 86,90 **** # Exported constants ! Error = 'mhlib.Error' --- 86,91 ---- # Exported constants ! class Error(Exception): ! pass *************** *** 331,335 **** def getcurrent(self): ! """Return the current message. Raise KeyError when there is none.""" seqs = self.getsequences() try: --- 332,336 ---- def getcurrent(self): ! """Return the current message. Raise Error when there is none.""" seqs = self.getsequences() try: From python-dev@python.org Thu Jun 29 06:29:11 2000 From: python-dev@python.org (Fred L. Drake) Date: Wed, 28 Jun 2000 22:29:11 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules Setup.in,1.103,1.104 Message-ID: <200006290529.WAA14004@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv13996 Modified Files: Setup.in Log Message: Improve explanation of how to build the pyexpat module. Index: Setup.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Setup.in,v retrieving revision 1.103 retrieving revision 1.104 diff -C2 -r1.103 -r1.104 *** Setup.in 2000/06/28 16:42:39 1.103 --- Setup.in 2000/06/29 05:29:08 1.104 *************** *** 417,424 **** # always ftp://ftp.jclark.com/pub/xml/expat.zip. # ! # (Note: the expat build process doesn't yet build a libexpat.a; you can ! # do this manually while we try convince the author to add it.) # ! #EXPAT_DIR=/usr/local/src/expat/ #pyexpat pyexpat.c -I$(EXPAT_DIR)/xmlparse -L$(EXPAT_DIR) -lexpat --- 417,430 ---- # always ftp://ftp.jclark.com/pub/xml/expat.zip. # ! # EXPAT_DIR, below, should point to the expat/ directory created by ! # unpacking the Expat source distribution. # ! # Note: the expat build process doesn't yet build a libexpat.a; you can ! # do this manually while we try convince the author to add it. To do so, ! # cd to EXPAT_DIR, run "make" if you have not done so, then run: ! # ! # ar cr xmltok/*.o xmlparse/*.o ! # ! #EXPAT_DIR=/usr/local/src/expat #pyexpat pyexpat.c -I$(EXPAT_DIR)/xmlparse -L$(EXPAT_DIR) -lexpat From python-dev@python.org Thu Jun 29 08:12:17 2000 From: python-dev@python.org (Moshe Zadka) Date: Thu, 29 Jun 2000 10:12:17 +0300 (IDT) Subject: [Python-checkins] CVS: python/dist/src/Doc TODO,1.26,1.27 In-Reply-To: <200006282213.PAA13365@slayer.i.sourceforge.net> Message-ID: On Wed, 28 Jun 2000, Fred L. Drake wrote: > + * Update the filecmp documentation (Moshe?). I'm waiting for Gordon to check-in his directory comparisons to filecmp. Gordon? -- Moshe Zadka http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From python-dev@python.org Thu Jun 29 09:55:57 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 01:55:57 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules sre.h,2.3,2.4 sre_constants.h,2.3,2.4 Message-ID: <200006290855.BAA11068@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv11005 Modified Files: sre.h sre_constants.h Log Message: towards 1.6b1 Index: sre.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/sre.h,v retrieving revision 2.3 retrieving revision 2.4 diff -C2 -r2.3 -r2.4 *** sre.h 2000/06/01 17:34:20 2.3 --- sre.h 2000/06/29 08:55:54 2.4 *************** *** 15,18 **** --- 15,21 ---- #include "sre_constants.h" + /* size of a code word (must be unsigned short or larger) */ + #define SRE_CODE unsigned short + typedef struct { PyObject_HEAD *************** *** 36,39 **** --- 39,50 ---- } MatchObject; + typedef unsigned int (*SRE_TOLOWER_HOOK)(unsigned int ch); + + typedef struct { + /* stack elements */ + SRE_CODE* pattern; + void* ptr; + } SRE_STACK; + typedef struct { /* string pointers */ *************** *** 45,57 **** int charsize; /* registers */ ! int marks; void* mark[64]; /* FIXME: should be dynamically allocated! */ /* backtracking stack */ ! void** stack; int stacksize; int stackbase; } SRE_STATE; typedef struct { PyObject_HEAD PyObject* pattern; --- 56,71 ---- int charsize; /* registers */ ! int lastmark; void* mark[64]; /* FIXME: should be dynamically allocated! */ /* backtracking stack */ ! SRE_STACK* stack; int stacksize; int stackbase; + /* hooks */ + SRE_TOLOWER_HOOK tolower; } SRE_STATE; typedef struct { + /* search helper */ PyObject_HEAD PyObject* pattern; Index: sre_constants.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/sre_constants.h,v retrieving revision 2.3 retrieving revision 2.4 diff -C2 -r2.3 -r2.4 *** sre_constants.h 2000/06/01 17:34:20 2.3 --- sre_constants.h 2000/06/29 08:55:54 2.4 *************** *** 12,29 **** #define SRE_OP_IN 10 #define SRE_OP_IN_IGNORE 11 ! #define SRE_OP_JUMP 12 ! #define SRE_OP_LITERAL 13 ! #define SRE_OP_LITERAL_IGNORE 14 ! #define SRE_OP_MARK 15 ! #define SRE_OP_MAX_REPEAT 16 ! #define SRE_OP_MAX_UNTIL 17 #define SRE_OP_MAX_REPEAT_ONE 18 #define SRE_OP_MIN_REPEAT 19 ! #define SRE_OP_MIN_UNTIL 20 ! #define SRE_OP_NOT_LITERAL 21 ! #define SRE_OP_NOT_LITERAL_IGNORE 22 ! #define SRE_OP_NEGATE 23 ! #define SRE_OP_RANGE 24 ! #define SRE_OP_REPEAT 25 #define SRE_AT_BEGINNING 0 #define SRE_AT_BEGINNING_LINE 1 --- 12,28 ---- #define SRE_OP_IN 10 #define SRE_OP_IN_IGNORE 11 ! #define SRE_OP_INFO 12 ! #define SRE_OP_JUMP 13 ! #define SRE_OP_LITERAL 14 ! #define SRE_OP_LITERAL_IGNORE 15 ! #define SRE_OP_MARK 16 ! #define SRE_OP_MAX_REPEAT 17 #define SRE_OP_MAX_REPEAT_ONE 18 #define SRE_OP_MIN_REPEAT 19 ! #define SRE_OP_NOT_LITERAL 20 ! #define SRE_OP_NOT_LITERAL_IGNORE 21 ! #define SRE_OP_NEGATE 22 ! #define SRE_OP_RANGE 23 ! #define SRE_OP_REPEAT 24 #define SRE_AT_BEGINNING 0 #define SRE_AT_BEGINNING_LINE 1 *************** *** 40,49 **** #define SRE_CATEGORY_LINEBREAK 6 #define SRE_CATEGORY_NOT_LINEBREAK 7 ! #define SRE_CATEGORY_LOC_DIGIT 8 ! #define SRE_CATEGORY_LOC_NOT_DIGIT 9 ! #define SRE_CATEGORY_LOC_SPACE 10 ! #define SRE_CATEGORY_LOC_NOT_SPACE 11 ! #define SRE_CATEGORY_LOC_WORD 12 ! #define SRE_CATEGORY_LOC_NOT_WORD 13 ! #define SRE_CATEGORY_LOC_LINEBREAK 14 ! #define SRE_CATEGORY_LOC_NOT_LINEBREAK 15 --- 39,57 ---- #define SRE_CATEGORY_LINEBREAK 6 #define SRE_CATEGORY_NOT_LINEBREAK 7 ! #define SRE_CATEGORY_LOC_WORD 8 ! #define SRE_CATEGORY_LOC_NOT_WORD 9 ! #define SRE_CATEGORY_UNI_DIGIT 10 ! #define SRE_CATEGORY_UNI_NOT_DIGIT 11 ! #define SRE_CATEGORY_UNI_SPACE 12 ! #define SRE_CATEGORY_UNI_NOT_SPACE 13 ! #define SRE_CATEGORY_UNI_WORD 14 ! #define SRE_CATEGORY_UNI_NOT_WORD 15 ! #define SRE_CATEGORY_UNI_LINEBREAK 16 ! #define SRE_CATEGORY_UNI_NOT_LINEBREAK 17 ! #define SRE_FLAG_TEMPLATE 1 ! #define SRE_FLAG_IGNORECASE 2 ! #define SRE_FLAG_LOCALE 4 ! #define SRE_FLAG_MULTILINE 8 ! #define SRE_FLAG_DOTALL 16 ! #define SRE_FLAG_UNICODE 32 ! #define SRE_FLAG_VERBOSE 64 From python-dev@python.org Thu Jun 29 09:57:57 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 01:57:57 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.4,2.5 Message-ID: <200006290857.BAA11219@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv11206 Modified Files: _sre.c Log Message: towards 1.6b1 Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.4 retrieving revision 2.5 diff -C2 -r2.4 -r2.5 *** _sre.c 2000/06/01 17:34:20 2.4 --- _sre.c 2000/06/29 08:57:54 2.5 *************** *** 4,20 **** * $Id$ * ! * simple regular expression matching engine * * partial history: ! * 99-10-24 fl created (based on the template matcher) * 99-11-13 fl added categories, branching, and more (0.2) * 99-11-16 fl some tweaks to compile on non-Windows platforms * 99-12-18 fl non-literals, generic maximizing repeat (0.3) ! * 99-02-28 fl tons of changes (not all to the better ;-) (0.4) [...1589 lines suppressed...] void ! #if defined(WIN32) __declspec(dllexport) #endif *************** *** 1708,1713 **** Cursor_Type.ob_type = &PyType_Type; ! Py_InitModule("_sre", _functions); } ! #endif --- 1846,1851 ---- Cursor_Type.ob_type = &PyType_Type; ! Py_InitModule("_" MODULE, _functions); } ! #endif /* !defined(SRE_RECURSIVE) */ From python-dev@python.org Thu Jun 29 09:58:47 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 01:58:47 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre.py,1.6,1.7 sre_compile.py,1.4,1.5 sre_constants.py,1.4,1.5 sre_parse.py,1.4,1.5 Message-ID: <200006290858.BAA11335@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv11309 Modified Files: sre.py sre_compile.py sre_constants.py sre_parse.py Log Message: towards 1.6b1 Index: sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** sre.py 2000/06/18 20:27:10 1.6 --- sre.py 2000/06/29 08:58:44 1.7 *************** *** 13,16 **** --- 13,17 ---- import sre_compile + import sre_parse # flags *************** *** 21,24 **** --- 22,32 ---- X = VERBOSE = sre_compile.SRE_FLAG_VERBOSE + # sre extensions (may or may not be in 1.6 final) + T = TEMPLATE = sre_compile.SRE_FLAG_TEMPLATE + U = UNICODE = sre_compile.SRE_FLAG_UNICODE + + # sre exception + error = sre_parse.error + # -------------------------------------------------------------------- # public interface *************** *** 47,50 **** --- 55,61 ---- return _compile(pattern, flags) + def template(pattern, flags=0): + return _compile(pattern, flags|T) + def escape(pattern): s = list(pattern) *************** *** 84,91 **** return _subn(pattern, template, string, count)[0] - def _expand(match, template): - # internal: expand template - return template # FIXME - def _subn(pattern, template, string, count=0): # internal: pattern.subn implementation hook --- 95,98 ---- *************** *** 93,99 **** filter = template else: ! # FIXME: prepare template def filter(match, template=template): ! return _expand(match, template) n = i = 0 s = [] --- 100,106 ---- filter = template else: ! template = sre_parse.parse_template(template, pattern) def filter(match, template=template): ! return sre_parse.expand_template(template, match) n = i = 0 s = [] *************** *** 109,112 **** --- 116,121 ---- append(filter(m)) i = m.end() + if i <= j: + break n = n + 1 if i < len(string): *************** *** 127,130 **** --- 136,141 ---- append(string[i:j]) i = m.end() + if i <= j: + break n = n + 1 if i < len(string): Index: sre_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** sre_compile.py 2000/06/01 17:39:12 1.4 --- sre_compile.py 2000/06/29 08:58:44 1.5 *************** *** 49,53 **** raise ! def _compile(code, pattern, flags, level=0): append = code.append for op, av in pattern: --- 49,53 ---- raise ! def _compile(code, pattern, flags): append = code.append for op, av in pattern: *************** *** 71,91 **** for av in av[1]: skip = len(code); append(0) ! _compile(code, av, flags, level) ! append(OPCODES[JUMP]) ! tail.append(len(code)); append(0) code[skip] = len(code) - skip append(0) # end of branch ! for tail in tail: code[tail] = len(code) - tail elif op is CALL: append(OPCODES[op]) skip = len(code); append(0) ! _compile(code, av, flags, level+1) append(OPCODES[SUCCESS]) code[skip] = len(code) - skip ! elif op is CATEGORY: # not used by current parser append(OPCODES[op]) if flags & SRE_FLAG_LOCALE: append(CH_LOCALE[CHCODES[av]]) else: append(CHCODES[av]) --- 71,94 ---- for av in av[1]: skip = len(code); append(0) ! _compile(code, av, flags) ! ## append(OPCODES[SUCCESS]) ! append(OPCODES[JUMP]) ! tail.append(len(code)); append(0) code[skip] = len(code) - skip append(0) # end of branch ! for tail in tail: code[tail] = len(code) - tail elif op is CALL: append(OPCODES[op]) skip = len(code); append(0) ! _compile(code, av, flags) append(OPCODES[SUCCESS]) code[skip] = len(code) - skip ! elif op is CATEGORY: append(OPCODES[op]) if flags & SRE_FLAG_LOCALE: append(CH_LOCALE[CHCODES[av]]) + elif flags & SRE_FLAG_UNICODE: + append(CH_UNICODE[CHCODES[av]]) else: append(CHCODES[av]) *************** *** 99,104 **** if flags & SRE_FLAG_IGNORECASE: append(OPCODES[OP_IGNORE[op]]) ! def fixup(literal): ! return ord(literal.lower()) else: append(OPCODES[op]) --- 102,107 ---- if flags & SRE_FLAG_IGNORECASE: append(OPCODES[OP_IGNORE[op]]) ! def fixup(literal, flags=flags): ! return _sre.getlower(ord(literal), flags) else: append(OPCODES[op]) *************** *** 117,120 **** --- 120,125 ---- if flags & SRE_FLAG_LOCALE: append(CH_LOCALE[CHCODES[av]]) + elif flags & SRE_FLAG_UNICODE: + append(CH_UNICODE[CHCODES[av]]) else: append(CHCODES[av]) *************** *** 126,159 **** if flags & SRE_FLAG_IGNORECASE: append(OPCODES[OP_IGNORE[op]]) - append(ord(av.lower())) else: append(OPCODES[op]) ! append(ord(av)) elif op is MARK: append(OPCODES[op]) append(av) elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): ! lo, hi = av[2].getwidth() ! if lo == 0: ! raise SyntaxError, "cannot repeat zero-width items" ! if lo == hi == 1 and op is MAX_REPEAT: ! append(OPCODES[MAX_REPEAT_ONE]) skip = len(code); append(0) append(av[0]) append(av[1]) ! _compile(code, av[2], flags, level+1) append(OPCODES[SUCCESS]) code[skip] = len(code) - skip else: ! append(OPCODES[op]) ! skip = len(code); append(0) ! append(av[0]) ! append(av[1]) ! _compile(code, av[2], flags, level+1) ! if op is MIN_REPEAT: ! append(OPCODES[MIN_UNTIL]) else: ! append(OPCODES[MAX_UNTIL]) ! code[skip] = len(code) - skip elif op is SUBPATTERN: group = av[0] --- 131,171 ---- if flags & SRE_FLAG_IGNORECASE: append(OPCODES[OP_IGNORE[op]]) else: append(OPCODES[op]) ! append(ord(av)) elif op is MARK: append(OPCODES[op]) append(av) elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): ! if flags & SRE_FLAG_TEMPLATE: ! append(OPCODES[REPEAT]) skip = len(code); append(0) append(av[0]) append(av[1]) ! _compile(code, av[2], flags) append(OPCODES[SUCCESS]) code[skip] = len(code) - skip else: ! lo, hi = av[2].getwidth() ! if lo == 0: ! raise error, "nothing to repeat" ! if 0 and lo == hi == 1 and op is MAX_REPEAT: ! # FIXME: need a better way to figure out when ! # it's safe to use this one (in the parser, probably) ! append(OPCODES[MAX_REPEAT_ONE]) ! skip = len(code); append(0) ! append(av[0]) ! append(av[1]) ! _compile(code, av[2], flags) ! append(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip else: ! append(OPCODES[op]) ! skip = len(code); append(0) ! append(av[0]) ! append(av[1]) ! _compile(code, av[2], flags) ! append(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip elif op is SUBPATTERN: group = av[0] *************** *** 161,165 **** append(OPCODES[MARK]) append((group-1)*2) ! _compile(code, av[1], flags, level+1) if group: append(OPCODES[MARK]) --- 173,177 ---- append(OPCODES[MARK]) append((group-1)*2) ! _compile(code, av[1], flags) if group: append(OPCODES[MARK]) Index: sre_constants.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_constants.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** sre_constants.py 2000/06/01 17:39:12 1.4 --- sre_constants.py 2000/06/29 08:58:44 1.5 *************** *** 16,19 **** --- 16,24 ---- # + # should this really be here? + + class error(Exception): + pass + # operators *************** *** 31,34 **** --- 36,40 ---- IN = "in" IN_IGNORE = "in_ignore" + INFO = "info" JUMP = "jump" LITERAL = "literal" *************** *** 37,43 **** MAX_REPEAT = "max_repeat" MAX_REPEAT_ONE = "max_repeat_one" - MAX_UNTIL = "max_until" MIN_REPEAT = "min_repeat" - MIN_UNTIL = "min_until" NEGATE = "negate" NOT_LITERAL = "not_literal" --- 43,47 ---- *************** *** 45,48 **** --- 49,53 ---- RANGE = "range" REPEAT = "repeat" + REPEAT_ONE = "repeat_one" SUBPATTERN = "subpattern" *************** *** 64,75 **** CATEGORY_LINEBREAK = "category_linebreak" CATEGORY_NOT_LINEBREAK = "category_not_linebreak" - CATEGORY_LOC_DIGIT = "category_loc_digit" - CATEGORY_LOC_NOT_DIGIT = "category_loc_not_digit" - CATEGORY_LOC_SPACE = "category_loc_space" - CATEGORY_LOC_NOT_SPACE = "category_loc_not_space" CATEGORY_LOC_WORD = "category_loc_word" CATEGORY_LOC_NOT_WORD = "category_loc_not_word" ! CATEGORY_LOC_LINEBREAK = "category_loc_linebreak" ! CATEGORY_LOC_NOT_LINEBREAK = "category_loc_not_linebreak" OPCODES = [ --- 69,82 ---- CATEGORY_LINEBREAK = "category_linebreak" CATEGORY_NOT_LINEBREAK = "category_not_linebreak" CATEGORY_LOC_WORD = "category_loc_word" CATEGORY_LOC_NOT_WORD = "category_loc_not_word" ! CATEGORY_UNI_DIGIT = "category_uni_digit" ! CATEGORY_UNI_NOT_DIGIT = "category_uni_not_digit" ! CATEGORY_UNI_SPACE = "category_uni_space" ! CATEGORY_UNI_NOT_SPACE = "category_uni_not_space" ! CATEGORY_UNI_WORD = "category_uni_word" ! CATEGORY_UNI_NOT_WORD = "category_uni_not_word" ! CATEGORY_UNI_LINEBREAK = "category_uni_linebreak" ! CATEGORY_UNI_NOT_LINEBREAK = "category_uni_not_linebreak" OPCODES = [ *************** *** 86,95 **** GROUP, GROUP_IGNORE, IN, IN_IGNORE, JUMP, LITERAL, LITERAL_IGNORE, MARK, ! MAX_REPEAT, MAX_UNTIL, MAX_REPEAT_ONE, ! MIN_REPEAT, MIN_UNTIL, NOT_LITERAL, NOT_LITERAL_IGNORE, NEGATE, --- 93,103 ---- GROUP, GROUP_IGNORE, IN, IN_IGNORE, + INFO, JUMP, LITERAL, LITERAL_IGNORE, MARK, ! MAX_REPEAT, MAX_REPEAT_ONE, ! MIN_REPEAT, NOT_LITERAL, NOT_LITERAL_IGNORE, NEGATE, *************** *** 107,114 **** CATEGORY_DIGIT, CATEGORY_NOT_DIGIT, CATEGORY_SPACE, CATEGORY_NOT_SPACE, CATEGORY_WORD, CATEGORY_NOT_WORD, ! CATEGORY_LINEBREAK, CATEGORY_NOT_LINEBREAK, CATEGORY_LOC_DIGIT, ! CATEGORY_LOC_NOT_DIGIT, CATEGORY_LOC_SPACE, ! CATEGORY_LOC_NOT_SPACE, CATEGORY_LOC_WORD, CATEGORY_LOC_NOT_WORD, ! CATEGORY_LOC_LINEBREAK, CATEGORY_LOC_NOT_LINEBREAK ] --- 115,123 ---- CATEGORY_DIGIT, CATEGORY_NOT_DIGIT, CATEGORY_SPACE, CATEGORY_NOT_SPACE, CATEGORY_WORD, CATEGORY_NOT_WORD, ! CATEGORY_LINEBREAK, CATEGORY_NOT_LINEBREAK, CATEGORY_LOC_WORD, ! CATEGORY_LOC_NOT_WORD, CATEGORY_UNI_DIGIT, CATEGORY_UNI_NOT_DIGIT, ! CATEGORY_UNI_SPACE, CATEGORY_UNI_NOT_SPACE, CATEGORY_UNI_WORD, ! CATEGORY_UNI_NOT_WORD, CATEGORY_UNI_LINEBREAK, ! CATEGORY_UNI_NOT_LINEBREAK ] *************** *** 139,159 **** CH_LOCALE = { ! CATEGORY_DIGIT: CATEGORY_LOC_DIGIT, ! CATEGORY_NOT_DIGIT: CATEGORY_LOC_NOT_DIGIT, ! CATEGORY_SPACE: CATEGORY_LOC_SPACE, ! CATEGORY_NOT_SPACE: CATEGORY_LOC_NOT_SPACE, CATEGORY_WORD: CATEGORY_LOC_WORD, CATEGORY_NOT_WORD: CATEGORY_LOC_NOT_WORD, ! CATEGORY_LINEBREAK: CATEGORY_LOC_LINEBREAK, ! CATEGORY_NOT_LINEBREAK: CATEGORY_LOC_NOT_LINEBREAK } # flags ! SRE_FLAG_TEMPLATE = 1 # NYI SRE_FLAG_IGNORECASE = 2 SRE_FLAG_LOCALE = 4 SRE_FLAG_MULTILINE = 8 SRE_FLAG_DOTALL = 16 ! SRE_FLAG_VERBOSE = 32 if __name__ == "__main__": --- 148,180 ---- CH_LOCALE = { ! CATEGORY_DIGIT: CATEGORY_DIGIT, ! CATEGORY_NOT_DIGIT: CATEGORY_NOT_DIGIT, ! CATEGORY_SPACE: CATEGORY_SPACE, ! CATEGORY_NOT_SPACE: CATEGORY_NOT_SPACE, CATEGORY_WORD: CATEGORY_LOC_WORD, CATEGORY_NOT_WORD: CATEGORY_LOC_NOT_WORD, ! CATEGORY_LINEBREAK: CATEGORY_LINEBREAK, ! CATEGORY_NOT_LINEBREAK: CATEGORY_NOT_LINEBREAK ! } ! ! CH_UNICODE = { ! CATEGORY_DIGIT: CATEGORY_UNI_DIGIT, ! CATEGORY_NOT_DIGIT: CATEGORY_UNI_NOT_DIGIT, ! CATEGORY_SPACE: CATEGORY_UNI_SPACE, ! CATEGORY_NOT_SPACE: CATEGORY_UNI_NOT_SPACE, ! CATEGORY_WORD: CATEGORY_UNI_WORD, ! CATEGORY_NOT_WORD: CATEGORY_UNI_NOT_WORD, ! CATEGORY_LINEBREAK: CATEGORY_UNI_LINEBREAK, ! CATEGORY_NOT_LINEBREAK: CATEGORY_UNI_NOT_LINEBREAK } # flags ! SRE_FLAG_TEMPLATE = 1 SRE_FLAG_IGNORECASE = 2 SRE_FLAG_LOCALE = 4 SRE_FLAG_MULTILINE = 8 SRE_FLAG_DOTALL = 16 ! SRE_FLAG_UNICODE = 32 ! SRE_FLAG_VERBOSE = 64 if __name__ == "__main__": *************** *** 169,172 **** --- 190,200 ---- dump(f, ATCODES, "SRE") dump(f, CHCODES, "SRE") + f.write("#define SRE_FLAG_TEMPLATE %d\n" % SRE_FLAG_TEMPLATE) + f.write("#define SRE_FLAG_IGNORECASE %d\n" % SRE_FLAG_IGNORECASE) + f.write("#define SRE_FLAG_LOCALE %d\n" % SRE_FLAG_LOCALE) + f.write("#define SRE_FLAG_MULTILINE %d\n" % SRE_FLAG_MULTILINE) + f.write("#define SRE_FLAG_DOTALL %d\n" % SRE_FLAG_DOTALL) + f.write("#define SRE_FLAG_UNICODE %d\n" % SRE_FLAG_UNICODE) + f.write("#define SRE_FLAG_VERBOSE %d\n" % SRE_FLAG_VERBOSE) f.close() print "done" Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** sre_parse.py 2000/06/09 14:08:07 1.4 --- sre_parse.py 2000/06/29 08:58:44 1.5 *************** *** 21,26 **** from sre_constants import * ! # FIXME: should be 65535, but the array module currently chokes on ! # unsigned integers larger than 32767... MAXREPEAT = int(2L**(_sre.getcodesize()*8-1))-1 --- 21,26 ---- from sre_constants import * ! # FIXME: should be 65535, but the array module currently chokes ! # on unsigned integers larger than 32767 [fixed in 1.6b1?] MAXREPEAT = int(2L**(_sre.getcodesize()*8-1))-1 *************** *** 28,32 **** REPEAT_CHARS = "*+?{" ! # FIXME: string in tuple tests may explode with if char is unicode :-( DIGITS = tuple(string.digits) --- 28,33 ---- REPEAT_CHARS = "*+?{" ! # FIXME: string in tuple tests may explode with if char is ! # unicode [fixed in 1.6b1?] DIGITS = tuple(string.digits) *************** *** 60,69 **** FLAGS = { "i": SRE_FLAG_IGNORECASE, "L": SRE_FLAG_LOCALE, "m": SRE_FLAG_MULTILINE, "s": SRE_FLAG_DOTALL, - "t": SRE_FLAG_TEMPLATE, "x": SRE_FLAG_VERBOSE, } --- 61,73 ---- FLAGS = { + # standard flags "i": SRE_FLAG_IGNORECASE, "L": SRE_FLAG_LOCALE, "m": SRE_FLAG_MULTILINE, "s": SRE_FLAG_DOTALL, "x": SRE_FLAG_VERBOSE, + # extensions + "t": SRE_FLAG_TEMPLATE, + "u": SRE_FLAG_UNICODE, } *************** *** 152,156 **** c = self.string[self.index + 1] except IndexError: ! raise SyntaxError, "bogus escape" char = char + c self.index = self.index + len(char) --- 156,160 ---- c = self.string[self.index + 1] except IndexError: ! raise error, "bogus escape" char = char + c self.index = self.index + len(char) *************** *** 206,210 **** except ValueError: pass ! raise SyntaxError, "bogus escape: %s" % repr(escape) def _escape(source, escape, state): --- 210,214 ---- except ValueError: pass ! raise error, "bogus escape: %s" % repr(escape) def _escape(source, escape, state): *************** *** 242,252 **** except ValueError: pass ! raise SyntaxError, "bogus escape: %s" % repr(escape) def _branch(pattern, items): ! # form a branch operator from a set of items (FIXME: move this ! # optimization to the compiler module!) subpattern = SubPattern(pattern) --- 246,255 ---- except ValueError: pass ! raise error, "bogus escape: %s" % repr(escape) def _branch(pattern, items): ! # form a branch operator from a set of items subpattern = SubPattern(pattern) *************** *** 333,337 **** code1 = LITERAL, this else: ! raise SyntaxError, "unexpected end of regular expression" if source.match("-"): # potential range --- 336,340 ---- code1 = LITERAL, this else: ! raise error, "unexpected end of regular expression" if source.match("-"): # potential range *************** *** 347,353 **** code2 = LITERAL, this if code1[0] != LITERAL or code2[0] != LITERAL: ! raise SyntaxError, "illegal range" if len(code1[1]) != 1 or len(code2[1]) != 1: ! raise SyntaxError, "illegal range" set.append((RANGE, (code1[1], code2[1]))) else: --- 350,356 ---- code2 = LITERAL, this if code1[0] != LITERAL or code2[0] != LITERAL: ! raise error, "illegal range" if len(code1[1]) != 1 or len(code2[1]) != 1: ! raise error, "illegal range" set.append((RANGE, (code1[1], code2[1]))) else: *************** *** 384,388 **** hi = lo if not source.match("}"): ! raise SyntaxError, "bogus range" if lo: min = int(lo) --- 387,391 ---- hi = lo if not source.match("}"): ! raise error, "bogus range" if lo: min = int(lo) *************** *** 391,400 **** # FIXME: check that hi >= lo! else: ! raise SyntaxError, "not supported" # figure out which item to repeat if subpattern: item = subpattern[-1:] else: ! raise SyntaxError, "nothing to repeat" if source.match("?"): subpattern[-1] = (MIN_REPEAT, (min, max, item)) --- 394,403 ---- # FIXME: check that hi >= lo! else: ! raise error, "not supported" # figure out which item to repeat if subpattern: item = subpattern[-1:] else: ! raise error, "nothing to repeat" if source.match("?"): subpattern[-1] = (MIN_REPEAT, (min, max, item)) *************** *** 419,423 **** char = source.get() if char is None: ! raise SyntaxError, "unterminated name" if char == ">": break --- 422,426 ---- char = source.get() if char is None: ! raise error, "unterminated name" if char == ">": break *************** *** 427,437 **** elif source.match("="): # named backreference ! raise SyntaxError, "not yet implemented" ! else: char = source.get() if char is None: ! raise SyntaxError, "unexpected end of pattern" ! raise SyntaxError, "unknown specifier: ?P%s" % char elif source.match(":"): # non-capturing group --- 430,439 ---- elif source.match("="): # named backreference ! raise error, "not yet implemented" else: char = source.get() if char is None: ! raise error, "unexpected end of pattern" ! raise error, "unknown specifier: ?P%s" % char elif source.match(":"): # non-capturing group *************** *** 440,446 **** # comment while 1: ! char = source.get() ! if char is None or char == ")": break else: # flags --- 442,448 ---- # comment while 1: ! if source.next is None or source.next == ")": break + source.get() else: # flags *************** *** 466,470 **** b.append(p) else: ! raise SyntaxError, "group not properly closed" else: while 1: --- 468,472 ---- b.append(p) else: ! raise error, "group not properly closed" else: while 1: *************** *** 472,476 **** if char is None or char == ")": break ! # FIXME: skip characters? elif this == "^": --- 474,478 ---- if char is None or char == ")": break ! raise error, "unknown extension" elif this == "^": *************** *** 485,489 **** else: ! raise SyntaxError, "parser error" return subpattern --- 487,491 ---- else: ! raise error, "parser error" return subpattern *************** *** 500,504 **** b.append(p) elif tail == ")": ! raise SyntaxError, "unbalanced parenthesis" elif tail is None: if b: --- 502,506 ---- b.append(p) elif tail == ")": ! raise error, "unbalanced parenthesis" elif tail is None: if b: *************** *** 507,514 **** break else: ! raise SyntaxError, "bogus characters at end of regular expression" return p ! def parse_replacement(source, pattern): # parse 're' replacement string into list of literals and # group references --- 509,516 ---- break else: ! raise error, "bogus characters at end of regular expression" return p ! def parse_template(source, pattern): # parse 're' replacement string into list of literals and # group references *************** *** 521,533 **** break # end of replacement string if this and this[0] == "\\": ! try: ! a(LITERAL, ESCAPES[this]) ! except KeyError: ! for char in this: ! a(LITERAL, char) else: ! a(LITERAL, this) return p if __name__ == "__main__": from pprint import pprint --- 523,576 ---- break # end of replacement string if this and this[0] == "\\": ! if this == "\\g": ! name = "" ! if s.match("<"): ! while 1: ! char = s.get() ! if char is None: ! raise error, "unterminated index" ! if char == ">": ! break ! # FIXME: check for valid character ! name = name + char ! if not name: ! raise error, "bad index" ! try: ! index = int(name) ! except ValueError: ! try: ! index = pattern.groupindex[name] ! except KeyError: ! raise IndexError, "unknown index" ! a((MARK, index)) ! elif len(this) > 1 and this[1] in DIGITS: ! while s.next in DIGITS: ! this = this + s.get() ! a((MARK, int(this[1:]))) ! else: ! try: ! a(ESCAPES[this]) ! except KeyError: ! for char in this: ! a((LITERAL, char)) else: ! a((LITERAL, this)) return p + def expand_template(template, match): + # FIXME: this is sooooo slow. drop in the slicelist + # code instead + p = [] + a = p.append + for c, s in template: + if c is LITERAL: + a(s) + elif c is MARK: + s = match.group(s) + if s is None: + raise error, "empty group" + a(s) + return match.string[:0].join(p) + if __name__ == "__main__": from pprint import pprint *************** *** 549,553 **** pass a = a + 1 ! except SyntaxError, v: print "**", repr(pattern), v b = b + 1 --- 592,596 ---- pass a = a + 1 ! except error, v: print "**", repr(pattern), v b = b + 1 From python-dev@python.org Thu Jun 29 11:34:58 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 03:34:58 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.5,2.6 sre.h,2.4,2.5 Message-ID: <200006291034.DAA01623@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv1431/Modules Modified Files: _sre.c sre.h Log Message: - removed "alpha only" licensing restriction - removed some hacks that worked around 1.6 alpha bugs - removed bogus test code from sre_parse Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.5 retrieving revision 2.6 diff -C2 -r2.5 -r2.6 *** _sre.c 2000/06/29 08:57:54 2.5 --- _sre.c 2000/06/29 10:34:56 2.6 *************** *** 4,8 **** * $Id$ * ! n * simple regular expression matching engine * * partial history: --- 4,8 ---- * $Id$ * ! * regular expression matching engine * * partial history: *************** *** 23,39 **** * Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. * - * This code can only be used for 1.6 alpha testing. All other use - * require explicit permission from Secret Labs AB. - * * Portions of this engine have been developed in cooperation with * CNRI. Hewlett-Packard provided funding for 1.6 integration and * other compatibility work. */ - - /* - * FIXME: repeated groups don't work (they're usually come out empty) - * FIXME: rename to 're' - * FIXME: enable repeat_one optimization - */ #ifndef SRE_RECURSIVE --- 23,30 ---- Index: sre.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/sre.h,v retrieving revision 2.4 retrieving revision 2.5 diff -C2 -r2.4 -r2.5 From python-dev@python.org Thu Jun 29 11:34:58 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 03:34:58 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre.py,1.7,1.8 sre_compile.py,1.5,1.6 sre_constants.py,1.5,1.6 sre_parse.py,1.5,1.6 Message-ID: <200006291034.DAA01619@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv1431/Lib Modified Files: sre.py sre_compile.py sre_constants.py sre_parse.py Log Message: - removed "alpha only" licensing restriction - removed some hacks that worked around 1.6 alpha bugs - removed bogus test code from sre_parse Index: sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 Index: sre_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** sre_compile.py 2000/06/29 08:58:44 1.5 --- sre_compile.py 2000/06/29 10:34:55 1.6 *************** *** 7,13 **** # Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. # - # This code can only be used for 1.6 alpha testing. All other use - # require explicit permission from Secret Labs AB. - # # Portions of this engine have been developed in cooperation with # CNRI. Hewlett-Packard provided funding for 1.6 integration and --- 7,10 ---- Index: sre_constants.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_constants.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** sre_constants.py 2000/06/29 08:58:44 1.5 --- sre_constants.py 2000/06/29 10:34:55 1.6 *************** *** 8,14 **** # Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. # - # This code can only be used for 1.6 alpha testing. All other use - # require explicit permission from Secret Labs AB. - # # Portions of this engine have been developed in cooperation with # CNRI. Hewlett-Packard provided funding for 1.6 integration and --- 8,11 ---- Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** sre_parse.py 2000/06/29 08:58:44 1.5 --- sre_parse.py 2000/06/29 10:34:55 1.6 *************** *** 7,13 **** # Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. # - # This code can only be used for 1.6 alpha testing. All other use - # require explicit permission from Secret Labs AB. - # # Portions of this engine have been developed in cooperation with # CNRI. Hewlett-Packard provided funding for 1.6 integration and --- 7,10 ---- *************** *** 21,39 **** from sre_constants import * ! # FIXME: should be 65535, but the array module currently chokes ! # on unsigned integers larger than 32767 [fixed in 1.6b1?] ! MAXREPEAT = int(2L**(_sre.getcodesize()*8-1))-1 SPECIAL_CHARS = ".\\[{()*+?^$|" REPEAT_CHARS = "*+?{" ! # FIXME: string in tuple tests may explode with if char is ! # unicode [fixed in 1.6b1?] ! DIGITS = tuple(string.digits) ! OCTDIGITS = tuple("01234567") ! HEXDIGITS = tuple("0123456789abcdefABCDEF") ! WHITESPACE = tuple(string.whitespace) ESCAPES = { --- 18,33 ---- from sre_constants import * ! # FIXME: should be 65535, but the arraymodule is still broken ! MAXREPEAT = 32767 SPECIAL_CHARS = ".\\[{()*+?^$|" REPEAT_CHARS = "*+?{" ! DIGITS = string.digits ! OCTDIGITS = "01234567" ! HEXDIGITS = "0123456789abcdefABCDEF" ! WHITESPACE = string.whitespace ESCAPES = { *************** *** 195,199 **** try: if escape[1:2] == "x": ! while source.next in HEXDIGITS: escape = escape + source.get() escape = escape[2:] --- 189,193 ---- try: if escape[1:2] == "x": ! while source.next and source.next in HEXDIGITS: escape = escape + source.get() escape = escape[2:] *************** *** 201,205 **** return LITERAL, chr(int(escape[-4:], 16) & 0xff) elif str(escape[1:2]) in OCTDIGITS: ! while source.next in OCTDIGITS: escape = escape + source.get() escape = escape[1:] --- 195,199 ---- return LITERAL, chr(int(escape[-4:], 16) & 0xff) elif str(escape[1:2]) in OCTDIGITS: ! while source.next and source.next in OCTDIGITS: escape = escape + source.get() escape = escape[1:] *************** *** 222,226 **** try: if escape[1:2] == "x": ! while source.next in HEXDIGITS: escape = escape + source.get() escape = escape[2:] --- 216,220 ---- try: if escape[1:2] == "x": ! while source.next and source.next in HEXDIGITS: escape = escape + source.get() escape = escape[2:] *************** *** 235,239 **** return GROUP, group escape = escape + source.get() ! elif source.next in OCTDIGITS: escape = escape + source.get() else: --- 229,233 ---- return GROUP, group escape = escape + source.get() ! elif source.next and source.next in OCTDIGITS: escape = escape + source.get() else: *************** *** 298,302 **** while 1: ! if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() --- 292,296 ---- while 1: ! if source.next in ("|", ")"): break # end of subpattern this = source.get() *************** *** 379,386 **** min, max = 0, MAXREPEAT lo = hi = "" ! while str(source.next) in DIGITS: lo = lo + source.get() if source.match(","): ! while str(source.next) in DIGITS: hi = hi + source.get() else: --- 373,380 ---- min, max = 0, MAXREPEAT lo = hi = "" ! while source.next and source.next in DIGITS: lo = lo + source.get() if source.match(","): ! while source.next and source.next in DIGITS: hi = hi + source.get() else: *************** *** 572,600 **** a(s) return match.string[:0].join(p) - - if __name__ == "__main__": - from pprint import pprint - from testpatterns import PATTERNS - a = b = c = 0 - for pattern, flags in PATTERNS: - if flags: - continue - print "-"*68 - try: - p = parse(pattern) - print repr(pattern), "->" - pprint(p.data) - import sre_compile - try: - code = sre_compile.compile(p) - c = c + 1 - except: - pass - a = a + 1 - except error, v: - print "**", repr(pattern), v - b = b + 1 - print "-"*68 - print a, "of", b, "patterns successfully parsed" - print c, "of", b, "patterns successfully compiled" - --- 566,567 ---- From python-dev@python.org Thu Jun 29 12:05:34 2000 From: python-dev@python.org (Greg Stein) Date: Thu, 29 Jun 2000 04:05:34 -0700 Subject: [Python-checkins] CVS: python/dist/src/Demo/imputil importers.py,NONE,1.1 Message-ID: <200006291105.EAA11909@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Demo/imputil In directory slayer.i.sourceforge.net:/tmp/cvs-serv11808 Added Files: importers.py Log Message: demonstration importers --- NEW FILE --- # # importers.py # # Demonstration subclasses of imputil.Importer # # There should be consideration for the imports below if it is desirable # to have "all" modules be imported through the imputil system. # these are C extensions import sys import imp import struct import marshal # these are .py modules import imputil import os ###################################################################### _TupleType = type(()) _StringType = type('') ###################################################################### # byte-compiled file suffic character _suffix_char = __debug__ and 'c' or 'o' # byte-compiled file suffix _suffix = '.py' + _suffix_char # the C_EXTENSION suffixes _c_suffixes = filter(lambda x: x[2] == imp.C_EXTENSION, imp.get_suffixes()) def _timestamp(pathname): "Return the file modification time as a Long." try: s = os.stat(pathname) except OSError: return None return long(s[8]) def _fs_import(dir, modname, fqname): "Fetch a module from the filesystem." pathname = os.path.join(dir, modname) if os.path.isdir(pathname): values = { '__pkgdir__' : pathname, '__path__' : [ pathname ] } ispkg = 1 pathname = os.path.join(pathname, '__init__') else: values = { } ispkg = 0 # look for dynload modules for desc in _c_suffixes: file = pathname + desc[0] try: fp = open(file, desc[1]) except IOError: pass else: module = imp.load_module(fqname, fp, file, desc) values['__file__'] = file return 0, module, values t_py = _timestamp(pathname + '.py') t_pyc = _timestamp(pathname + _suffix) if t_py is None and t_pyc is None: return None code = None if t_py is None or (t_pyc is not None and t_pyc >= t_py): file = pathname + _suffix f = open(file, 'rb') if f.read(4) == imp.get_magic(): t = struct.unpack('., where can be located using a subclass-specific mechanism and the is found in the archive using a subclass-specific mechanism. This class defines two hooks for subclasses: one to locate an archive (and possibly return some context for future subfile lookups), and one to locate subfiles. """ def get_code(self, parent, modname, fqname): if parent: # the Importer._finish_import logic ensures that we handle imports # under the top level module (package / archive). assert parent.__importer__ == self # if a parent "package" is provided, then we are importing a sub-file # from the archive. result = self.get_subfile(parent.__archive__, modname) if result is None: return None if isinstance(result, _TupleType): assert len(result) == 2 return (0,) + result return 0, result, {} # no parent was provided, so the archive should exist somewhere on the # default "path". archive = self.get_archive(modname) if archive is None: return None return 1, "", {'__archive__':archive} def get_archive(self, modname): """Get an archive of modules. This method should locate an archive and return a value which can be used by get_subfile to load modules from it. The value may be a simple pathname, an open file, or a complex object that caches information for future imports. Return None if the archive was not found. """ raise RuntimeError, "get_archive not implemented" def get_subfile(self, archive, modname): """Get code from a subfile in the specified archive. Given the specified archive (as returned by get_archive()), locate and return a code object for the specified module name. A 2-tuple may be returned, consisting of a code object and a dict of name/values to place into the target module. Return None if the subfile was not found. """ raise RuntimeError, "get_subfile not implemented" class PackageArchive(PackageArchiveImporter): "PackageArchiveImporter subclass that refers to a specific archive." def __init__(self, modname, archive_pathname): self.__modname = modname self.__path = archive_pathname def get_archive(self, modname): if modname == self.__modname: return self.__path return None # get_subfile is passed the full pathname of the archive ###################################################################### # # Emulate the standard directory-based import mechanism # class DirectoryImporter(imputil.Importer): "Importer subclass to emulate the standard importer." def __init__(self, dir): self.dir = dir def get_code(self, parent, modname, fqname): if parent: dir = parent.__pkgdir__ else: dir = self.dir # Return the module (and other info) if found in the specified # directory. Otherwise, return None. return _fs_import(dir, modname, fqname) def __repr__(self): return '<%s.%s for "%s" at 0x%x>' % (self.__class__.__module__, self.__class__.__name__, self.dir, id(self)) ###################################################################### # # Emulate the standard path-style import mechanism # class PathImporter(imputil.Importer): def __init__(self, path=sys.path): self.path = path def get_code(self, parent, modname, fqname): if parent: # we are looking for a module inside of a specific package return _fs_import(parent.__pkgdir__, modname, fqname) # scan sys.path, looking for the requested module for dir in self.path: if isinstance(dir, _StringType): result = _fs_import(dir, modname, fqname) if result: return result # not found return None ###################################################################### def _test_dir(): "Debug/test function to create DirectoryImporters from sys.path." imputil.ImportManager().install() path = sys.path[:] path.reverse() for d in path: sys.path.insert(0, DirectoryImporter(d)) sys.path.insert(0, imputil.BuiltinImporter()) def _test_revamp(): "Debug/test function for the revamped import system." imputil.ImportManager().install() sys.path.insert(0, PathImporter()) sys.path.insert(0, imputil.BuiltinImporter()) From python-dev@python.org Thu Jun 29 12:34:30 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 04:34:30 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre.py,1.8,1.9 sre_compile.py,1.6,1.7 sre_constants.py,1.6,1.7 sre_parse.py,1.6,1.7 Message-ID: <200006291134.EAA19309@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv18748/Lib Modified Files: sre.py sre_compile.py sre_constants.py sre_parse.py Log Message: - last patch broke parse_template; fixed by changing some tests in sre_patch back to previous version - fixed return value from findall - renamed a bunch of functions inside _sre (way too many leading underscores...) Index: sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 Index: sre_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 Index: sre_constants.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_constants.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** sre_parse.py 2000/06/29 10:34:55 1.6 --- sre_parse.py 2000/06/29 11:34:27 1.7 *************** *** 24,31 **** REPEAT_CHARS = "*+?{" ! DIGITS = string.digits ! OCTDIGITS = "01234567" ! HEXDIGITS = "0123456789abcdefABCDEF" WHITESPACE = string.whitespace --- 24,31 ---- REPEAT_CHARS = "*+?{" ! DIGITS = tuple(string.digits) ! OCTDIGITS = tuple("01234567") ! HEXDIGITS = tuple("0123456789abcdefABCDEF") WHITESPACE = string.whitespace *************** *** 189,193 **** try: if escape[1:2] == "x": ! while source.next and source.next in HEXDIGITS: escape = escape + source.get() escape = escape[2:] --- 189,193 ---- try: if escape[1:2] == "x": ! while source.next in HEXDIGITS: escape = escape + source.get() escape = escape[2:] *************** *** 195,199 **** return LITERAL, chr(int(escape[-4:], 16) & 0xff) elif str(escape[1:2]) in OCTDIGITS: ! while source.next and source.next in OCTDIGITS: escape = escape + source.get() escape = escape[1:] --- 195,199 ---- return LITERAL, chr(int(escape[-4:], 16) & 0xff) elif str(escape[1:2]) in OCTDIGITS: ! while source.next in OCTDIGITS: escape = escape + source.get() escape = escape[1:] *************** *** 216,225 **** try: if escape[1:2] == "x": ! while source.next and source.next in HEXDIGITS: escape = escape + source.get() escape = escape[2:] # FIXME: support unicode characters! return LITERAL, chr(int(escape[-4:], 16) & 0xff) ! elif str(escape[1:2]) in DIGITS: while 1: group = _group(escape, state) --- 216,225 ---- try: if escape[1:2] == "x": ! while source.next in HEXDIGITS: escape = escape + source.get() escape = escape[2:] # FIXME: support unicode characters! return LITERAL, chr(int(escape[-4:], 16) & 0xff) ! elif escape[1:2] in DIGITS: while 1: group = _group(escape, state) *************** *** 229,233 **** return GROUP, group escape = escape + source.get() ! elif source.next and source.next in OCTDIGITS: escape = escape + source.get() else: --- 229,233 ---- return GROUP, group escape = escape + source.get() ! elif source.next in OCTDIGITS: escape = escape + source.get() else: *************** *** 373,380 **** min, max = 0, MAXREPEAT lo = hi = "" ! while source.next and source.next in DIGITS: lo = lo + source.get() if source.match(","): ! while source.next and source.next in DIGITS: hi = hi + source.get() else: --- 373,380 ---- min, max = 0, MAXREPEAT lo = hi = "" ! while source.next in DIGITS: lo = lo + source.get() if source.match(","): ! while source.next in DIGITS: hi = hi + source.get() else: From python-dev@python.org Thu Jun 29 12:34:30 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 04:34:30 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.6,2.7 sre.h,2.5,2.6 Message-ID: <200006291134.EAA19310@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv18748/Modules Modified Files: _sre.c sre.h Log Message: - last patch broke parse_template; fixed by changing some tests in sre_patch back to previous version - fixed return value from findall - renamed a bunch of functions inside _sre (way too many leading underscores...) Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.6 retrieving revision 2.7 diff -C2 -r2.6 -r2.7 *** _sre.c 2000/06/29 10:34:56 2.6 --- _sre.c 2000/06/29 11:34:28 2.7 *************** *** 200,204 **** LOCAL(int) ! _stack_free(SRE_STATE* state) { if (state->stack) { --- 200,204 ---- LOCAL(int) ! stack_free(SRE_STATE* state) { if (state->stack) { *************** *** 212,216 **** static int /* shouldn't be LOCAL */ ! _stack_extend(SRE_STATE* state, int lo, int hi) { SRE_STACK* stack; --- 212,216 ---- static int /* shouldn't be LOCAL */ ! stack_extend(SRE_STATE* state, int lo, int hi) { SRE_STACK* stack; *************** *** 243,247 **** if (!stack) { ! _stack_free(state); return SRE_ERROR_MEMORY; } --- 243,247 ---- if (!stack) { ! stack_free(state); return SRE_ERROR_MEMORY; } *************** *** 776,780 **** stack */ if (stack >= state->stacksize) { ! i = _stack_extend(state, stack + 1, stackbase + pattern[2]); if (i < 0) --- 776,780 ---- stack */ if (stack >= state->stacksize) { ! i = stack_extend(state, stack + 1, stackbase + pattern[2]); if (i < 0) *************** *** 1017,1021 **** LOCAL(PyObject*) ! _setup(SRE_STATE* state, PatternObject* pattern, PyObject* args) { /* prepare state object */ --- 1017,1021 ---- LOCAL(PyObject*) ! state_init(SRE_STATE* state, PatternObject* pattern, PyObject* args) { /* prepare state object */ *************** *** 1094,1099 **** } static PyObject* ! _pattern_new_match(PatternObject* pattern, SRE_STATE* state, PyObject* string, int status) { --- 1094,1124 ---- } + LOCAL(void) + state_fini(SRE_STATE* state) + { + stack_free(state); + } + + LOCAL(PyObject*) + state_getslice(SRE_STATE* state, int index, PyObject* string) + { + index = (index - 1) * 2; + + if (string == Py_None || !state->mark[index] || !state->mark[index+1]) { + Py_INCREF(Py_None); + return Py_None; + } + + return PySequence_GetSlice( + string, + ((char*)state->mark[index] - (char*)state->beginning) / + state->charsize, + ((char*)state->mark[index+1] - (char*)state->beginning) / + state->charsize + ); + } + static PyObject* ! pattern_new_match(PatternObject* pattern, SRE_STATE* state, PyObject* string, int status) { *************** *** 1152,1156 **** static PyObject* ! _pattern_cursor(PatternObject* pattern, PyObject* args) { /* create search state object */ --- 1177,1181 ---- static PyObject* ! pattern_cursor(PatternObject* pattern, PyObject* args) { /* create search state object */ *************** *** 1164,1168 **** return NULL; ! string = _setup(&self->state, pattern, args); if (!string) { PyObject_DEL(self); --- 1189,1193 ---- return NULL; ! string = state_init(&self->state, pattern, args); if (!string) { PyObject_DEL(self); *************** *** 1180,1184 **** static void ! _pattern_dealloc(PatternObject* self) { Py_XDECREF(self->code); --- 1205,1209 ---- static void ! pattern_dealloc(PatternObject* self) { Py_XDECREF(self->code); *************** *** 1189,1193 **** static PyObject* ! _pattern_match(PatternObject* self, PyObject* args) { SRE_STATE state; --- 1214,1218 ---- static PyObject* ! pattern_match(PatternObject* self, PyObject* args) { SRE_STATE state; *************** *** 1195,1199 **** int status; ! string = _setup(&state, self, args); if (!string) return NULL; --- 1220,1224 ---- int status; ! string = state_init(&state, self, args); if (!string) return NULL; *************** *** 1209,1219 **** } ! _stack_free(&state); ! return _pattern_new_match(self, &state, string, status); } static PyObject* ! _pattern_search(PatternObject* self, PyObject* args) { SRE_STATE state; --- 1234,1244 ---- } ! state_fini(&state); ! return pattern_new_match(self, &state, string, status); } static PyObject* ! pattern_search(PatternObject* self, PyObject* args) { SRE_STATE state; *************** *** 1221,1225 **** int status; ! string = _setup(&state, self, args); if (!string) return NULL; --- 1246,1250 ---- int status; ! string = state_init(&state, self, args); if (!string) return NULL; *************** *** 1233,1239 **** } ! _stack_free(&state); ! return _pattern_new_match(self, &state, string, status); } --- 1258,1264 ---- } ! state_fini(&state); ! return pattern_new_match(self, &state, string, status); } *************** *** 1264,1268 **** static PyObject* ! _pattern_sub(PatternObject* self, PyObject* args) { PyObject* template; --- 1289,1293 ---- static PyObject* ! pattern_sub(PatternObject* self, PyObject* args) { PyObject* template; *************** *** 1277,1281 **** static PyObject* ! _pattern_subn(PatternObject* self, PyObject* args) { PyObject* template; --- 1302,1306 ---- static PyObject* ! pattern_subn(PatternObject* self, PyObject* args) { PyObject* template; *************** *** 1290,1294 **** static PyObject* ! _pattern_split(PatternObject* self, PyObject* args) { PyObject* string; --- 1315,1319 ---- static PyObject* ! pattern_split(PatternObject* self, PyObject* args) { PyObject* string; *************** *** 1302,1306 **** static PyObject* ! _pattern_findall(PatternObject* self, PyObject* args) { SRE_STATE state; --- 1327,1331 ---- static PyObject* ! pattern_findall(PatternObject* self, PyObject* args) { SRE_STATE state; *************** *** 1308,1313 **** PyObject* list; int status; ! string = _setup(&state, self, args); if (!string) return NULL; --- 1333,1339 ---- PyObject* list; int status; + int i; ! string = state_init(&state, self, args); if (!string) return NULL; *************** *** 1331,1342 **** if (status > 0) { ! item = PySequence_GetSlice( ! string, ! ((char*) state.start - (char*) state.beginning) / state.charsize, ! ((char*) state.ptr - (char*) state.beginning) / state.charsize); ! if (!item) ! goto error; ! if (PyList_Append(list, item) < 0) goto error; if (state.ptr == state.start) --- 1357,1396 ---- if (status > 0) { ! /* don't bother to build a match object */ ! switch (self->groups) { ! case 0: ! item = PySequence_GetSlice( ! string, ! ((char*) state.start - (char*) state.beginning) / ! state.charsize, ! ((char*) state.ptr - (char*) state.beginning) / ! state.charsize); ! if (!item) ! goto error; ! break; ! case 1: ! item = state_getslice(&state, 1, string); ! if (!item) ! goto error; ! break; ! default: ! item = PyTuple_New(self->groups); ! if (!item) ! goto error; ! for (i = 0; i < self->groups; i++) { ! PyObject* o = state_getslice(&state, i+1, string); ! if (!o) { ! Py_DECREF(item); ! goto error; ! } ! PyTuple_SET_ITEM(item, i, o); ! } ! break; ! } ! ! if (PyList_Append(list, item) < 0) { ! Py_DECREF(item); goto error; + } if (state.ptr == state.start) *************** *** 1359,1391 **** } } - - _stack_free(&state); return list; error: ! _stack_free(&state); return NULL; } ! static PyMethodDef _pattern_methods[] = { ! {"match", (PyCFunction) _pattern_match, 1}, ! {"search", (PyCFunction) _pattern_search, 1}, ! {"sub", (PyCFunction) _pattern_sub, 1}, ! {"subn", (PyCFunction) _pattern_subn, 1}, ! {"split", (PyCFunction) _pattern_split, 1}, ! {"findall", (PyCFunction) _pattern_findall, 1}, /* experimental */ ! {"cursor", (PyCFunction) _pattern_cursor, 1}, {NULL, NULL} }; static PyObject* ! _pattern_getattr(PatternObject* self, char* name) { PyObject* res; ! res = Py_FindMethod(_pattern_methods, (PyObject*) self, name); if (res) --- 1413,1445 ---- } } + state_fini(&state); return list; error: ! Py_DECREF(list); ! state_fini(&state); return NULL; } ! static PyMethodDef pattern_methods[] = { ! {"match", (PyCFunction) pattern_match, 1}, ! {"search", (PyCFunction) pattern_search, 1}, ! {"sub", (PyCFunction) pattern_sub, 1}, ! {"subn", (PyCFunction) pattern_subn, 1}, ! {"split", (PyCFunction) pattern_split, 1}, ! {"findall", (PyCFunction) pattern_findall, 1}, /* experimental */ ! {"cursor", (PyCFunction) pattern_cursor, 1}, {NULL, NULL} }; static PyObject* ! pattern_getattr(PatternObject* self, char* name) { PyObject* res; ! res = Py_FindMethod(pattern_methods, (PyObject*) self, name); if (res) *************** *** 1415,1421 **** PyObject_HEAD_INIT(NULL) 0, "Pattern", sizeof(PatternObject), 0, ! (destructor)_pattern_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ ! (getattrfunc)_pattern_getattr, /*tp_getattr*/ }; --- 1469,1475 ---- PyObject_HEAD_INIT(NULL) 0, "Pattern", sizeof(PatternObject), 0, ! (destructor)pattern_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ ! (getattrfunc)pattern_getattr, /*tp_getattr*/ }; *************** *** 1424,1428 **** static void ! _match_dealloc(MatchObject* self) { Py_XDECREF(self->string); --- 1478,1482 ---- static void ! match_dealloc(MatchObject* self) { Py_XDECREF(self->string); *************** *** 1432,1436 **** static PyObject* ! getslice_by_index(MatchObject* self, int index) { if (index < 0 || index >= self->groups) { --- 1486,1490 ---- static PyObject* ! match_getslice_by_index(MatchObject* self, int index) { if (index < 0 || index >= self->groups) { *************** *** 1455,1459 **** static int ! getindex(MatchObject* self, PyObject* index) { if (!PyInt_Check(index) && self->pattern->groupindex != NULL) { --- 1509,1513 ---- static int ! match_getindex(MatchObject* self, PyObject* index) { if (!PyInt_Check(index) && self->pattern->groupindex != NULL) { *************** *** 1471,1481 **** static PyObject* ! getslice(MatchObject* self, PyObject* index) { ! return getslice_by_index(self, getindex(self, index)); } static PyObject* ! _match_group(MatchObject* self, PyObject* args) { PyObject* result; --- 1525,1535 ---- static PyObject* ! match_getslice(MatchObject* self, PyObject* index) { ! return match_getslice_by_index(self, match_getindex(self, index)); } static PyObject* ! match_group(MatchObject* self, PyObject* args) { PyObject* result; *************** *** 1486,1493 **** switch (size) { case 0: ! result = getslice(self, Py_False); /* force error */ break; case 1: ! result = getslice(self, PyTuple_GET_ITEM(args, 0)); break; default: --- 1540,1547 ---- switch (size) { case 0: ! result = match_getslice(self, Py_False); break; case 1: ! result = match_getslice(self, PyTuple_GET_ITEM(args, 0)); break; default: *************** *** 1497,1501 **** return NULL; for (i = 0; i < size; i++) { ! PyObject* item = getslice(self, PyTuple_GET_ITEM(args, i)); if (!item) { Py_DECREF(result); --- 1551,1555 ---- return NULL; for (i = 0; i < size; i++) { ! PyObject* item = match_getslice(self, PyTuple_GET_ITEM(args, i)); if (!item) { Py_DECREF(result); *************** *** 1510,1514 **** static PyObject* ! _match_groups(MatchObject* self, PyObject* args) { PyObject* result; --- 1564,1568 ---- static PyObject* ! match_groups(MatchObject* self, PyObject* args) { PyObject* result; *************** *** 1524,1528 **** PyObject* item; /* FIXME: handle default! */ ! item = getslice_by_index(self, index); if (!item) { Py_DECREF(result); --- 1578,1582 ---- PyObject* item; /* FIXME: handle default! */ ! item = match_getslice_by_index(self, index); if (!item) { Py_DECREF(result); *************** *** 1536,1540 **** static PyObject* ! _match_groupdict(MatchObject* self, PyObject* args) { PyObject* result; --- 1590,1594 ---- static PyObject* ! match_groupdict(MatchObject* self, PyObject* args) { PyObject* result; *************** *** 1563,1567 **** return NULL; } ! item = getslice(self, key); if (!item) { Py_DECREF(key); --- 1617,1621 ---- return NULL; } ! item = match_getslice(self, key); if (!item) { Py_DECREF(key); *************** *** 1580,1584 **** static PyObject* ! _match_start(MatchObject* self, PyObject* args) { int index; --- 1634,1638 ---- static PyObject* ! match_start(MatchObject* self, PyObject* args) { int index; *************** *** 1588,1592 **** return NULL; ! index = getindex(self, index_); if (index < 0 || index >= self->groups) { --- 1642,1646 ---- return NULL; ! index = match_getindex(self, index_); if (index < 0 || index >= self->groups) { *************** *** 1607,1611 **** static PyObject* ! _match_end(MatchObject* self, PyObject* args) { int index; --- 1661,1665 ---- static PyObject* ! match_end(MatchObject* self, PyObject* args) { int index; *************** *** 1615,1619 **** return NULL; ! index = getindex(self, index_); if (index < 0 || index >= self->groups) { --- 1669,1673 ---- return NULL; ! index = match_getindex(self, index_); if (index < 0 || index >= self->groups) { *************** *** 1634,1638 **** static PyObject* ! _match_span(MatchObject* self, PyObject* args) { int index; --- 1688,1692 ---- static PyObject* ! match_span(MatchObject* self, PyObject* args) { int index; *************** *** 1642,1646 **** return NULL; ! index = getindex(self, index_); if (index < 0 || index >= self->groups) { --- 1696,1700 ---- return NULL; ! index = match_getindex(self, index_); if (index < 0 || index >= self->groups) { *************** *** 1661,1680 **** } ! static PyMethodDef _match_methods[] = { ! {"group", (PyCFunction) _match_group, 1}, ! {"start", (PyCFunction) _match_start, 1}, ! {"end", (PyCFunction) _match_end, 1}, ! {"span", (PyCFunction) _match_span, 1}, ! {"groups", (PyCFunction) _match_groups, 1}, ! {"groupdict", (PyCFunction) _match_groupdict, 1}, {NULL, NULL} }; static PyObject* ! _match_getattr(MatchObject* self, char* name) { PyObject* res; ! res = Py_FindMethod(_match_methods, (PyObject*) self, name); if (res) return res; --- 1715,1734 ---- } ! static PyMethodDef match_methods[] = { ! {"group", (PyCFunction) match_group, 1}, ! {"start", (PyCFunction) match_start, 1}, ! {"end", (PyCFunction) match_end, 1}, ! {"span", (PyCFunction) match_span, 1}, ! {"groups", (PyCFunction) match_groups, 1}, ! {"groupdict", (PyCFunction) match_groupdict, 1}, {NULL, NULL} }; static PyObject* ! match_getattr(MatchObject* self, char* name) { PyObject* res; ! res = Py_FindMethod(match_methods, (PyObject*) self, name); if (res) return res; *************** *** 1711,1717 **** sizeof(MatchObject), /* size of basic object */ sizeof(int), /* space for group item */ ! (destructor)_match_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ ! (getattrfunc)_match_getattr, /*tp_getattr*/ }; --- 1765,1771 ---- sizeof(MatchObject), /* size of basic object */ sizeof(int), /* space for group item */ ! (destructor)match_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ ! (getattrfunc)match_getattr, /*tp_getattr*/ }; *************** *** 1720,1726 **** static void ! _cursor_dealloc(CursorObject* self) { ! _stack_free(&self->state); Py_DECREF(self->string); Py_DECREF(self->pattern); --- 1774,1780 ---- static void ! cursor_dealloc(CursorObject* self) { ! state_fini(&self->state); Py_DECREF(self->string); Py_DECREF(self->pattern); *************** *** 1729,1733 **** static PyObject* ! _cursor_match(CursorObject* self, PyObject* args) { SRE_STATE* state = &self->state; --- 1783,1787 ---- static PyObject* ! cursor_match(CursorObject* self, PyObject* args) { SRE_STATE* state = &self->state; *************** *** 1745,1749 **** } ! match = _pattern_new_match((PatternObject*) self->pattern, state, self->string, status); --- 1799,1803 ---- } ! match = pattern_new_match((PatternObject*) self->pattern, state, self->string, status); *************** *** 1758,1762 **** static PyObject* ! _cursor_search(CursorObject* self, PyObject* args) { SRE_STATE* state = &self->state; --- 1812,1816 ---- static PyObject* ! cursor_search(CursorObject* self, PyObject* args) { SRE_STATE* state = &self->state; *************** *** 1774,1778 **** } ! match = _pattern_new_match((PatternObject*) self->pattern, state, self->string, status); --- 1828,1832 ---- } ! match = pattern_new_match((PatternObject*) self->pattern, state, self->string, status); *************** *** 1783,1798 **** } ! static PyMethodDef _cursor_methods[] = { ! {"match", (PyCFunction) _cursor_match, 0}, ! {"search", (PyCFunction) _cursor_search, 0}, {NULL, NULL} }; static PyObject* ! _cursor_getattr(CursorObject* self, char* name) { PyObject* res; ! res = Py_FindMethod(_cursor_methods, (PyObject*) self, name); if (res) return res; --- 1837,1852 ---- } ! static PyMethodDef cursor_methods[] = { ! {"match", (PyCFunction) cursor_match, 0}, ! {"search", (PyCFunction) cursor_search, 0}, {NULL, NULL} }; static PyObject* ! cursor_getattr(CursorObject* self, char* name) { PyObject* res; ! res = Py_FindMethod(cursor_methods, (PyObject*) self, name); if (res) return res; *************** *** 1815,1821 **** sizeof(CursorObject), /* size of basic object */ 0, ! (destructor)_cursor_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ ! (getattrfunc)_cursor_getattr, /*tp_getattr*/ }; --- 1869,1875 ---- sizeof(CursorObject), /* size of basic object */ 0, ! (destructor)cursor_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ ! (getattrfunc)cursor_getattr, /*tp_getattr*/ }; Index: sre.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/sre.h,v retrieving revision 2.5 retrieving revision 2.6 diff -C2 -r2.5 -r2.6 From python-dev@python.org Thu Jun 29 13:22:12 2000 From: python-dev@python.org (Gordon McMillan) Date: Thu, 29 Jun 2000 08:22:12 -0400 Subject: [Python-Dev] Re: [Python-checkins] CVS: python/dist/src/Doc TODO,1.26,1.27 In-Reply-To: References: <200006282213.PAA13365@slayer.i.sourceforge.net> Message-ID: <1249841091-43777448@hypernet.com> Moshe wrote: > On Wed, 28 Jun 2000, Fred L. Drake wrote: > > > + * Update the filecmp documentation (Moshe?). > > I'm waiting for Gordon to check-in his directory comparisons to > filecmp. Gordon? Looking at CVS, my stuff was there in filecmp revision 1.2 (+299 -38) and wiped out by 1.3 (+38 -299) which was done the following day. - Gordon From python-dev@python.org Thu Jun 29 13:38:48 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 05:38:48 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre.py,1.9,1.10 sre_compile.py,1.7,1.8 sre_constants.py,1.7,1.8 sre_parse.py,1.7,1.8 Message-ID: <200006291238.FAA01061@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv899/Lib Modified Files: sre.py sre_compile.py sre_constants.py sre_parse.py Log Message: - make sure group names are valid identifiers (closes the "SRE: symbolic reference" bug) Index: sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 Index: sre_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 Index: sre_constants.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_constants.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** sre_parse.py 2000/06/29 11:34:27 1.7 --- sre_parse.py 2000/06/29 12:38:45 1.8 *************** *** 169,172 **** --- 169,190 ---- return this + def isident(char): + return "a" <= char <= "z" or "A" <= char <= "Z" or char == "_" + + def isdigit(char): + return "0" <= char <= "9" + + def isname(name): + # check that group name is a valid string + # FIXME: this code is really lame. should use a regular + # expression instead, but I seem to have certain bootstrapping + # problems here ;-) + if not isident(name[0]): + return 0 + for char in name: + if not isident(char) and not isdigit(char): + return 0 + return 1 + def _group(escape, state): # check if the escape string represents a valid group *************** *** 419,425 **** if char == ">": break - # FIXME: check for valid character name = name + char group = 1 elif source.match("="): # named backreference --- 437,444 ---- if char == ">": break name = name + char group = 1 + if not isname(name): + raise error, "illegal character in group name" elif source.match("="): # named backreference *************** *** 523,540 **** char = s.get() if char is None: ! raise error, "unterminated index" if char == ">": break - # FIXME: check for valid character name = name + char if not name: ! raise error, "bad index" try: index = int(name) except ValueError: try: index = pattern.groupindex[name] except KeyError: ! raise IndexError, "unknown index" a((MARK, index)) elif len(this) > 1 and this[1] in DIGITS: --- 542,560 ---- char = s.get() if char is None: ! raise error, "unterminated group name" if char == ">": break name = name + char if not name: ! raise error, "bad group name" try: index = int(name) except ValueError: + if not isname(name): + raise error, "illegal character in group name" try: index = pattern.groupindex[name] except KeyError: ! raise IndexError, "unknown group name" a((MARK, index)) elif len(this) > 1 and this[1] in DIGITS: From python-dev@python.org Thu Jun 29 13:38:48 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 05:38:48 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.7,2.8 sre.h,2.6,2.7 Message-ID: <200006291238.FAA01060@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv899/Modules Modified Files: _sre.c sre.h Log Message: - make sure group names are valid identifiers (closes the "SRE: symbolic reference" bug) Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.7 retrieving revision 2.8 diff -C2 -r2.7 -r2.8 Index: sre.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/sre.h,v retrieving revision 2.6 retrieving revision 2.7 diff -C2 -r2.6 -r2.7 From python-dev@python.org Thu Jun 29 13:45:52 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 29 Jun 2000 05:45:52 -0700 Subject: [Python-checkins] CVS: python/dist/src/Misc ACKS,1.57,1.58 Message-ID: <200006291245.FAA01387@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Misc In directory slayer.i.sourceforge.net:/tmp/cvs-serv1378/Misc Modified Files: ACKS Log Message: Typo fix. Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -r1.57 -r1.58 *** ACKS 2000/06/29 00:04:51 1.57 --- ACKS 2000/06/29 12:45:50 1.58 *************** *** 116,120 **** Fred Gansevles Lars Marius Garshol ! Hary Henry Gebel Thomas Gellekum Ben Gertzfield --- 116,120 ---- Fred Gansevles Lars Marius Garshol ! Harry Henry Gebel Thomas Gellekum Ben Gertzfield From python-dev@python.org Thu Jun 29 13:48:40 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 05:48:40 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.8,2.9 sre.h,2.7,2.8 Message-ID: <200006291248.FAA01606@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv1507/Modules Modified Files: _sre.c sre.h Log Message: - renamed "tolower" hook (it happened to work with my compiler, but not on guido's box...) Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.8 retrieving revision 2.9 diff -C2 -r2.8 -r2.9 *** _sre.c 2000/06/29 12:38:45 2.8 --- _sre.c 2000/06/29 12:48:37 2.9 *************** *** 95,99 **** 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 0, 0, 0, 0, 0 }; ! static char sre_char_tolower[128] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, --- 95,99 ---- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 0, 0, 0, 0, 0 }; ! static char sre_char_lower[128] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, *************** *** 105,111 **** 120, 121, 122, 123, 124, 125, 126, 127 }; ! static unsigned int sre_tolower(unsigned int ch) { ! return ((ch) < 128 ? sre_char_tolower[ch] : ch); } --- 105,111 ---- 120, 121, 122, 123, 124, 125, 126, 127 }; ! static unsigned int sre_lower(unsigned int ch) { ! return ((ch) < 128 ? sre_char_lower[ch] : ch); } *************** *** 123,127 **** /* locale-specific character predicates */ ! static unsigned int sre_tolower_locale(unsigned int ch) { return ((ch) < 256 ? tolower((ch)) : ch); --- 123,127 ---- /* locale-specific character predicates */ ! static unsigned int sre_lower_locale(unsigned int ch) { return ((ch) < 256 ? tolower((ch)) : ch); *************** *** 136,140 **** #if defined(HAVE_UNICODE) ! static unsigned int sre_tolower_unicode(unsigned int ch) { return (unsigned int) Py_UNICODE_TOLOWER((Py_UNICODE)(ch)); --- 136,140 ---- #if defined(HAVE_UNICODE) ! static unsigned int sre_lower_unicode(unsigned int ch) { return (unsigned int) Py_UNICODE_TOLOWER((Py_UNICODE)(ch)); *************** *** 498,502 **** while (p < e) { if (ptr >= end || ! state->tolower(*ptr) != state->tolower(*p)) goto failure; p++; ptr++; --- 498,502 ---- while (p < e) { if (ptr >= end || ! state->lower(*ptr) != state->lower(*p)) goto failure; p++; ptr++; *************** *** 509,513 **** TRACE(("%8d: literal lower(%c)\n", PTR(ptr), (SRE_CHAR) *pattern)); if (ptr >= end || ! state->tolower(*ptr) != state->tolower(*pattern)) goto failure; pattern++; --- 509,513 ---- TRACE(("%8d: literal lower(%c)\n", PTR(ptr), (SRE_CHAR) *pattern)); if (ptr >= end || ! state->lower(*ptr) != state->lower(*pattern)) goto failure; pattern++; *************** *** 519,523 **** (SRE_CHAR) *pattern)); if (ptr >= end || ! state->tolower(*ptr) == state->tolower(*pattern)) goto failure; pattern++; --- 519,523 ---- (SRE_CHAR) *pattern)); if (ptr >= end || ! state->lower(*ptr) == state->lower(*pattern)) goto failure; pattern++; *************** *** 528,532 **** TRACE(("%8d: set lower(%c)\n", PTR(ptr), *ptr)); if (ptr >= end ! || !SRE_MEMBER(pattern+1, (SRE_CHAR) state->tolower(*ptr))) goto failure; pattern += pattern[0]; --- 528,532 ---- TRACE(("%8d: set lower(%c)\n", PTR(ptr), *ptr)); if (ptr >= end ! || !SRE_MEMBER(pattern+1, (SRE_CHAR) state->lower(*ptr))) goto failure; pattern += pattern[0]; *************** *** 612,616 **** SRE_CHAR chr = (SRE_CHAR) pattern[4]; while (count < (int) pattern[2]) { ! if (ptr >= end || (SRE_CHAR) state->tolower(*ptr) != chr) break; ptr++; --- 612,616 ---- SRE_CHAR chr = (SRE_CHAR) pattern[4]; while (count < (int) pattern[2]) { ! if (ptr >= end || (SRE_CHAR) state->lower(*ptr) != chr) break; ptr++; *************** *** 632,636 **** SRE_CHAR chr = (SRE_CHAR) pattern[4]; while (count < (int) pattern[2]) { ! if (ptr >= end || (SRE_CHAR) state->tolower(*ptr) == chr) break; ptr++; --- 632,636 ---- SRE_CHAR chr = (SRE_CHAR) pattern[4]; while (count < (int) pattern[2]) { ! if (ptr >= end || (SRE_CHAR) state->lower(*ptr) == chr) break; ptr++; *************** *** 1002,1006 **** static PyObject * ! sre_lower(PyObject* self, PyObject* args) { int character, flags; --- 1002,1006 ---- static PyObject * ! sre_getlower(PyObject* self, PyObject* args) { int character, flags; *************** *** 1008,1017 **** return NULL; if (flags & SRE_FLAG_LOCALE) ! return Py_BuildValue("i", sre_tolower_locale(character)); #if defined(HAVE_UNICODE) if (flags & SRE_FLAG_UNICODE) ! return Py_BuildValue("i", sre_tolower_unicode(character)); #endif ! return Py_BuildValue("i", sre_tolower(character)); } --- 1008,1017 ---- return NULL; if (flags & SRE_FLAG_LOCALE) ! return Py_BuildValue("i", sre_lower_locale(character)); #if defined(HAVE_UNICODE) if (flags & SRE_FLAG_UNICODE) ! return Py_BuildValue("i", sre_lower_unicode(character)); #endif ! return Py_BuildValue("i", sre_lower(character)); } *************** *** 1083,1093 **** if (pattern->flags & SRE_FLAG_LOCALE) ! state->tolower = sre_tolower_locale; #if defined(HAVE_UNICODE) else if (pattern->flags & SRE_FLAG_UNICODE) ! state->tolower = sre_tolower_unicode; #endif else ! state->tolower = sre_tolower; return string; --- 1083,1093 ---- if (pattern->flags & SRE_FLAG_LOCALE) ! state->lower = sre_lower_locale; #if defined(HAVE_UNICODE) else if (pattern->flags & SRE_FLAG_UNICODE) ! state->lower = sre_lower_unicode; #endif else ! state->lower = sre_lower; return string; *************** *** 1877,1881 **** {"compile", _compile, 1}, {"getcodesize", sre_codesize, 1}, ! {"getlower", sre_lower, 1}, {NULL, NULL} }; --- 1877,1881 ---- {"compile", _compile, 1}, {"getcodesize", sre_codesize, 1}, ! {"getlower", sre_getlower, 1}, {NULL, NULL} }; Index: sre.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/sre.h,v retrieving revision 2.7 retrieving revision 2.8 diff -C2 -r2.7 -r2.8 *** sre.h 2000/06/29 12:38:45 2.7 --- sre.h 2000/06/29 12:48:37 2.8 *************** *** 63,67 **** int stackbase; /* hooks */ ! SRE_TOLOWER_HOOK tolower; } SRE_STATE; --- 63,67 ---- int stackbase; /* hooks */ ! SRE_TOLOWER_HOOK lower; } SRE_STATE; From python-dev@python.org Thu Jun 29 13:48:40 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 05:48:40 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre.py,1.10,1.11 sre_compile.py,1.8,1.9 sre_constants.py,1.8,1.9 sre_parse.py,1.8,1.9 Message-ID: <200006291248.FAA01607@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv1507/Lib Modified Files: sre.py sre_compile.py sre_constants.py sre_parse.py Log Message: - renamed "tolower" hook (it happened to work with my compiler, but not on guido's box...) Index: sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 Index: sre_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 Index: sre_constants.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_constants.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 From python-dev@python.org Thu Jun 29 14:31:13 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Thu, 29 Jun 2000 06:31:13 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_ucn,NONE,1.1 Message-ID: <200006291331.GAA09886@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv9879/Lib/test/output Added Files: test_ucn Log Message: Marc-Andre Lemburg : New test output --- NEW FILE --- test_ucn Testing General Unicode Character Name, and case insensitivity... done. Testing misc. symbols for unicode character name expansion.... done. Testing unicode character name expansion strict error handling.... done. From python-dev@python.org Thu Jun 29 15:13:31 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 29 Jun 2000 07:13:31 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib filecmp.py,1.4,1.5 Message-ID: <200006291413.HAA18493@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv18485 Modified Files: filecmp.py Log Message: Whoops! We just discovered that Gordon's revamp of this module was accidentally wiped out by Ping's patch (which shouldn't have affected this file at all, had Ping done a cvs update). This checkin restores Gordon's version, with Fredrik's change merged back in. Index: filecmp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/filecmp.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** filecmp.py 2000/03/28 21:42:38 1.4 --- filecmp.py 2000/06/29 14:13:28 1.5 *************** *** 1,68 **** ! """Compare files.""" ! import os, stat, statcache _cache = {} BUFSIZE=8*1024 ! def cmp(f1, f2, shallow=1,use_statcache=0): ! """Compare two files. ! Arguments: ! f1 -- First file name ! f2 -- Second file name ! shallow -- Just check stat signature (do not read the files). ! defaults to 1. ! ! use_statcache -- Do not stat() each file directly: go through ! the statcache module for more efficiency. ! ! Return value: ! ! integer -- 1 if the files are the same, 0 otherwise. ! ! This function uses a cache for past comparisons and the results, ! with a cache invalidation mechanism relying on stale signatures. ! Of course, if 'use_statcache' is true, this mechanism is defeated, ! and the cache will never grow stale. ! ! """ ! if use_statcache: ! stat_function = statcache.stat ! else: ! stat_function = os.stat ! s1 = _sig(stat_function(f1)) ! s2 = _sig(stat_function(f2)) ! if s1[0] != stat.S_IFREG or s2[0] != stat.S_IFREG: ! return 0 ! if shallow and s1 == s2: ! return 1 ! if s1[1] != s2[1]: ! return 0 ! ! result = _cache.get((f1, f2)) ! if result and (s1, s2) == result[:2]: ! return result[2] ! outcome = _do_cmp(f1, f2) ! _cache[f1, f2] = s1, s2, outcome ! return outcome def _sig(st): ! return (stat.S_IFMT(st[stat.ST_MODE]), ! st[stat.ST_SIZE], ! st[stat.ST_MTIME]) def _do_cmp(f1, f2): ! bufsize = BUFSIZE ! fp1 = open(f1, 'rb') ! fp2 = open(f2, 'rb') ! while 1: ! b1 = fp1.read(bufsize) ! b2 = fp2.read(bufsize) ! if b1 != b2: ! return 0 ! if not b1: ! return 1 --- 1,329 ---- ! """Utilities for comparing files and directories. ! Classes: ! dircmp + Functions: + cmp(f1, f2, shallow=1, use_statcache=0) -> int + cmpfiles(a, b, common) -> ([], [], []) + + """ + + import os + import stat + import statcache + _cache = {} BUFSIZE=8*1024 ! def cmp(f1, f2, shallow=1,use_statcache=0): ! """Compare two files. ! Arguments: ! f1 -- First file name ! f2 -- Second file name ! shallow -- Just check stat signature (do not read the files). ! defaults to 1. ! ! use_statcache -- Do not stat() each file directly: go through ! the statcache module for more efficiency. ! ! Return value: ! ! integer -- 1 if the files are the same, 0 otherwise. ! ! This function uses a cache for past comparisons and the results, ! with a cache invalidation mechanism relying on stale signatures. ! Of course, if 'use_statcache' is true, this mechanism is defeated, ! and the cache will never grow stale. ! ! """ ! if use_statcache: ! stat_function = statcache.stat ! else: ! stat_function = os.stat ! s1 = _sig(stat_function(f1)) ! s2 = _sig(stat_function(f2)) ! if s1[0] != stat.S_IFREG or s2[0] != stat.S_IFREG: ! return 0 ! if shallow and s1 == s2: ! return 1 ! if s1[1] != s2[1]: ! return 0 ! ! result = _cache.get((f1, f2)) ! if result and (s1, s2) == result[:2]: ! return result[2] ! outcome = _do_cmp(f1, f2) ! _cache[f1, f2] = s1, s2, outcome ! return outcome def _sig(st): ! return (stat.S_IFMT(st[stat.ST_MODE]), ! st[stat.ST_SIZE], ! st[stat.ST_MTIME]) def _do_cmp(f1, f2): ! bufsize = BUFSIZE ! fp1 = open(f1, 'rb') ! fp2 = open(f2, 'rb') ! while 1: ! b1 = fp1.read(bufsize) ! b2 = fp2.read(bufsize) ! if b1 != b2: ! return 0 ! if not b1: ! return 1 ! ! # Directory comparison class. ! # ! class dircmp: ! """A class that manages the comparison of 2 directories. ! ! dircmp(a,b,ignore=None,hide=None) ! A and B are directories. ! IGNORE is a list of names to ignore, ! defaults to ['RCS', 'CVS', 'tags']. ! HIDE is a list of names to hide, ! defaults to [os.curdir, os.pardir]. ! ! High level usage: ! x = dircmp(dir1, dir2) ! x.report() -> prints a report on the differences between dir1 and dir2 ! or ! x.report_partial_closure() -> prints report on differences between dir1 ! and dir2, and reports on common immediate subdirectories. ! x.report_full_closure() -> like report_partial_closure, ! but fully recursive. ! ! Attributes: ! left_list, right_list: The files in dir1 and dir2, ! filtered by hide and ignore. ! common: a list of names in both dir1 and dir2. ! left_only, right_only: names only in dir1, dir2. ! common_dirs: subdirectories in both dir1 and dir2. ! common_files: files in both dir1 and dir2. ! common_funny: names in both dir1 and dir2 where the type differs between ! dir1 and dir2, or the name is not stat-able. ! same_files: list of identical files. ! diff_files: list of filenames which differ. ! funny_files: list of files which could not be compared. ! subdirs: a dictionary of dircmp objects, keyed by names in common_dirs. ! """ ! ! def __init__(self, a, b, ignore=None, hide=None): # Initialize ! self.left = a ! self.right = b ! if hide is None: ! self.hide = [os.curdir, os.pardir] # Names never to be shown ! else: ! self.hide = hide ! if ignore is None: ! self.ignore = ['RCS', 'CVS', 'tags'] # Names ignored in comparison ! else: ! self.ignore = ignore ! ! def phase0(self): # Compare everything except common subdirectories ! self.left_list = _filter(os.listdir(self.left), ! self.hide+self.ignore) ! self.right_list = _filter(os.listdir(self.right), ! self.hide+self.ignore) ! self.left_list.sort() ! self.right_list.sort() ! ! __p4_attrs = ('subdirs',) ! __p3_attrs = ('same_files', 'diff_files', 'funny_files') ! __p2_attrs = ('common_dirs', 'common_files', 'common_funny') ! __p1_attrs = ('common', 'left_only', 'right_only') ! __p0_attrs = ('left_list', 'right_list') ! ! def __getattr__(self, attr): ! if attr in self.__p4_attrs: ! self.phase4() ! elif attr in self.__p3_attrs: ! self.phase3() ! elif attr in self.__p2_attrs: ! self.phase2() ! elif attr in self.__p1_attrs: ! self.phase1() ! elif attr in self.__p0_attrs: ! self.phase0() ! else: ! raise AttributeError, attr ! return getattr(self, attr) ! ! def phase1(self): # Compute common names ! a_only, b_only = [], [] ! common = {} ! b = {} ! for fnm in self.right_list: ! b[fnm] = 1 ! for x in self.left_list: ! if b.get(x, 0): ! common[x] = 1 ! else: ! a_only.append(x) ! for x in self.right_list: ! if common.get(x, 0): ! pass ! else: ! b_only.append(x) ! self.common = common.keys() ! self.left_only = a_only ! self.right_only = b_only ! ! def phase2(self): # Distinguish files, directories, funnies ! self.common_dirs = [] ! self.common_files = [] ! self.common_funny = [] ! ! for x in self.common: ! a_path = os.path.join(self.left, x) ! b_path = os.path.join(self.right, x) ! ! ok = 1 ! try: ! a_stat = statcache.stat(a_path) ! except os.error, why: ! # print 'Can\'t stat', a_path, ':', why[1] ! ok = 0 ! try: ! b_stat = statcache.stat(b_path) ! except os.error, why: ! # print 'Can\'t stat', b_path, ':', why[1] ! ok = 0 ! ! if ok: ! a_type = stat.S_IFMT(a_stat[stat.ST_MODE]) ! b_type = stat.S_IFMT(b_stat[stat.ST_MODE]) ! if a_type <> b_type: ! self.common_funny.append(x) ! elif stat.S_ISDIR(a_type): ! self.common_dirs.append(x) ! elif stat.S_ISREG(a_type): ! self.common_files.append(x) ! else: ! self.common_funny.append(x) ! else: ! self.common_funny.append(x) ! ! def phase3(self): # Find out differences between common files ! xx = cmpfiles(self.left, self.right, self.common_files) ! self.same_files, self.diff_files, self.funny_files = xx ! ! def phase4(self): # Find out differences between common subdirectories ! # A new dircmp object is created for each common subdirectory, ! # these are stored in a dictionary indexed by filename. ! # The hide and ignore properties are inherited from the parent ! self.subdirs = {} ! for x in self.common_dirs: ! a_x = os.path.join(self.left, x) ! b_x = os.path.join(self.right, x) ! self.subdirs[x] = dircmp(a_x, b_x, self.ignore, self.hide) ! ! def phase4_closure(self): # Recursively call phase4() on subdirectories ! self.phase4() ! for x in self.subdirs.keys(): ! self.subdirs[x].phase4_closure() ! ! def report(self): # Print a report on the differences between a and b ! # Output format is purposely lousy ! print 'diff', self.left, self.right ! if self.left_only: ! self.left_only.sort() ! print 'Only in', self.left, ':', self.left_only ! if self.right_only: ! self.right_only.sort() ! print 'Only in', self.right, ':', self.right_only ! if self.same_files: ! self.same_files.sort() ! print 'Identical files :', self.same_files ! if self.diff_files: ! self.diff_files.sort() ! print 'Differing files :', self.diff_files ! if self.funny_files: ! self.funny_files.sort() ! print 'Trouble with common files :', self.funny_files ! if self.common_dirs: ! self.common_dirs.sort() ! print 'Common subdirectories :', self.common_dirs ! if self.common_funny: ! self.common_funny.sort() ! print 'Common funny cases :', self.common_funny ! ! def report_partial_closure(self): # Print reports on self and on subdirs ! self.report() ! for x in self.subdirs.keys(): ! print ! self.subdirs[x].report() ! ! def report_full_closure(self): # Report on self and subdirs recursively ! self.report() ! for x in self.subdirs.keys(): ! print ! self.subdirs[x].report_full_closure() ! ! ! # Compare common files in two directories. ! # Return: ! # - files that compare equal ! # - files that compare different ! # - funny cases (can't stat etc.) ! # ! def cmpfiles(a, b, common): ! """Compare common files in two directories. ! ! cmpfiles(a,b,common) ! A and B are directory names ! COMMON is a list of file names ! returns a tuple of three lists: ! files that compare equal ! files that are different ! filenames that aren't regular files.""" ! ! res = ([], [], []) ! for x in common: ! res[_cmp(os.path.join(a, x), os.path.join(b, x))].append(x) ! return res ! ! ! # Compare two files. ! # Return: ! # 0 for equal ! # 1 for different ! # 2 for funny cases (can't stat, etc.) ! # ! def _cmp(a, b): ! try: ! return not abs(cmp(a, b)) ! except os.error: ! return 2 ! ! ! # Return a copy with items that occur in skip removed. ! # ! def _filter(list, skip): ! result = [] ! for item in list: ! if item not in skip: result.append(item) ! return result ! ! ! # Demonstration and testing. ! # ! def demo(): ! import sys ! import getopt ! options, args = getopt.getopt(sys.argv[1:], 'r') ! if len(args) <> 2: raise getopt.error, 'need exactly two args' ! dd = dircmp(args[0], args[1]) ! if ('-r', '') in options: ! dd.report_full_closure() ! else: ! dd.report() ! ! if __name__ == '__main__': ! demo() From python-dev@python.org Thu Jun 29 15:40:47 2000 From: python-dev@python.org (Jeremy Hylton) Date: Thu, 29 Jun 2000 07:40:47 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules Setup.in,1.104,1.105 Message-ID: <200006291440.HAA20818@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv20793/Modules Modified Files: Setup.in Log Message: pyexpat notes: add the name of the archive to the ar command Index: Setup.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Setup.in,v retrieving revision 1.104 retrieving revision 1.105 diff -C2 -r1.104 -r1.105 *** Setup.in 2000/06/29 05:29:08 1.104 --- Setup.in 2000/06/29 14:40:45 1.105 *************** *** 424,428 **** # cd to EXPAT_DIR, run "make" if you have not done so, then run: # ! # ar cr xmltok/*.o xmlparse/*.o # #EXPAT_DIR=/usr/local/src/expat --- 424,428 ---- # cd to EXPAT_DIR, run "make" if you have not done so, then run: # ! # ar cr libexpat.a xmltok/*.o xmlparse/*.o # #EXPAT_DIR=/usr/local/src/expat From python-dev@python.org Thu Jun 29 15:50:18 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 29 Jun 2000 07:50:18 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python codecs.c,2.7,2.8 Message-ID: <200006291450.HAA21359@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv21351 Modified Files: codecs.c Log Message: Change the loop index in normalizestring() to size_t too, to avoid a warning on Windows. Index: codecs.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/codecs.c,v retrieving revision 2.7 retrieving revision 2.8 diff -C2 -r2.7 -r2.8 *** codecs.c 2000/06/28 22:07:35 2.7 --- codecs.c 2000/06/29 14:50:15 2.8 *************** *** 83,87 **** PyObject *normalizestring(const char *string) { ! register int i; size_t len = strlen(string); char *p; --- 83,87 ---- PyObject *normalizestring(const char *string) { ! register size_t i; size_t len = strlen(string); char *p; From python-dev@python.org Thu Jun 29 17:08:31 2000 From: python-dev@python.org (Barry Warsaw) Date: Thu, 29 Jun 2000 09:08:31 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules Setup.thread.in,2.1,2.2 Message-ID: <200006291608.JAA01388@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv1379 Modified Files: Setup.thread.in Log Message: Updated the comment in this file to reflect the new defaults. Threads are enabled by default now unless --without-threads is given to configure. Index: Setup.thread.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Setup.thread.in,v retrieving revision 2.1 retrieving revision 2.2 diff -C2 -r2.1 -r2.2 *** Setup.thread.in 1997/12/04 00:48:27 2.1 --- Setup.thread.in 2000/06/29 16:08:28 2.2 *************** *** 1,10 **** # This file is transmogrified into Setup.thread by config.status. ! # Its purpose is to automatically enable the thread module when the ! # --with-thread argument is given to the configure script. # *NOTE*: if the configure script decides it can't support threads, # the thread module will still be enabled and cause compile errors. ! # The solution is not to use --with-thread on platforms that don't # support threads. --- 1,11 ---- # This file is transmogrified into Setup.thread by config.status. ! # Its purpose is to automatically enable the thread module by default ! # unless the the --without-threads argument is given to the configure ! # script. # *NOTE*: if the configure script decides it can't support threads, # the thread module will still be enabled and cause compile errors. ! # The solution is to use --without-threads on platforms that don't # support threads. From python-dev@python.org Thu Jun 29 17:12:03 2000 From: python-dev@python.org (Barry Warsaw) Date: Thu, 29 Jun 2000 09:12:03 -0700 Subject: [Python-checkins] CVS: python/dist/src config.h.in,2.56,2.57 configure,1.118,1.119 configure.in,1.126,1.127 Message-ID: <200006291612.JAA02962@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv2286 Modified Files: config.h.in configure configure.in Log Message: Thread support is turned on my default now. To disable building threads use --without-threads. No extra tests of thread/compiler combinations have been added. --with(out)-thread and --with(out)-threads are completely interchangeable. --with-threads still supports the =DIRECTORY option for specifying where to find thread libraries. Index: config.h.in =================================================================== RCS file: /cvsroot/python/python/dist/src/config.h.in,v retrieving revision 2.56 retrieving revision 2.57 diff -C2 -r2.56 -r2.57 *** config.h.in 2000/06/18 15:07:40 2.56 --- config.h.in 2000/06/29 16:12:00 2.57 *************** *** 286,289 **** --- 286,292 ---- #undef HAVE_FORK + /* Define if you have the forkpty function. */ + #undef HAVE_FORKPTY + /* Define if you have the fpathconf function. */ #undef HAVE_FPATHCONF *************** *** 367,370 **** --- 370,376 ---- #undef HAVE_NICE + /* Define if you have the openpty function. */ + #undef HAVE_OPENPTY + /* Define if you have the pathconf function. */ #undef HAVE_PATHCONF *************** *** 484,487 **** --- 490,496 ---- #undef HAVE_FCNTL_H + /* Define if you have the header file. */ + #undef HAVE_LIBUTIL_H + /* Define if you have the header file. */ #undef HAVE_LIMITS_H *************** *** 498,501 **** --- 507,513 ---- /* Define if you have the header file. */ #undef HAVE_PTHREAD_H + + /* Define if you have the header file. */ + #undef HAVE_PTY_H /* Define if you have the header file. */ Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.118 retrieving revision 1.119 diff -C2 -r1.118 -r1.119 *** configure 2000/06/28 16:40:38 1.118 --- configure 2000/06/29 16:12:00 1.119 *************** *** 1,8 **** #! /bin/sh ! # From configure.in Revision: 1.125 # Guess values for system-dependent variables and create Makefiles. ! # Generated automatically using autoconf version 2.14.1 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # --- 1,8 ---- #! /bin/sh [...4155 lines suppressed...] ! echo "$CONFIG_STATUS generated by autoconf version 2.14.1" exit 0 ;; -help | --help | --hel | --he | --h) --- 5651,5655 ---- exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) ! echo "$CONFIG_STATUS generated by autoconf version 2.13" exit 0 ;; -help | --help | --hel | --he | --h) *************** *** 5971,5974 **** chmod +x $CONFIG_STATUS rm -fr confdefs* $ac_clean_files ! test "$no_create" = yes || $SHELL $CONFIG_STATUS || exit 1 --- 5949,5952 ---- chmod +x $CONFIG_STATUS rm -fr confdefs* $ac_clean_files ! test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.126 retrieving revision 1.127 diff -C2 -r1.126 -r1.127 *** configure.in 2000/06/28 16:40:38 1.126 --- configure.in 2000/06/29 16:12:00 1.127 *************** *** 14,18 **** AC_MSG_CHECKING(for --with-next-archs) AC_ARG_WITH(next-archs, ! [--with-next-archs='arch1 arch2 ..' build MAB binary], [ if test -n "$withval"; then ac_arch_flags=`/usr/lib/arch_tool -archify_list $withval` --- 14,18 ---- AC_MSG_CHECKING(for --with-next-archs) AC_ARG_WITH(next-archs, ! [ --with-next-archs='arch1 arch2 ..' build MAB binary], [ if test -n "$withval"; then ac_arch_flags=`/usr/lib/arch_tool -archify_list $withval` *************** *** 34,40 **** AC_ARG_WITH(next-framework, ! [--with-next-framework Build (OpenStep|Rhapsody|MacOS10) framework],,) ! AC_ARG_WITH(dyld, ! [--with-dyld Use (OpenStep|Rhapsody|MacOS10) dynamic linker],,) # Set name for machine-dependent library files --- 34,40 ---- AC_ARG_WITH(next-framework, ! [ --with-next-framework Build (OpenStep|Rhapsody|MacOSX) framework],,) ! AC_ARG_WITH(dyld, ! [ --with-dyld Use (OpenStep|Rhapsody|MacOSX) dynamic linker],,) # Set name for machine-dependent library files *************** *** 100,104 **** # checks for alternative programs AC_MSG_CHECKING(for --without-gcc) ! AC_ARG_WITH(gcc, [--without-gcc never use gcc], [ case $withval in no) CC=cc --- 100,104 ---- # checks for alternative programs AC_MSG_CHECKING(for --without-gcc) ! AC_ARG_WITH(gcc, [ --without-gcc never use gcc], [ case $withval in no) CC=cc *************** *** 157,161 **** MAINOBJ=python.o AC_MSG_CHECKING(for --with-cxx=) ! AC_ARG_WITH(cxx, [--with-cxx= enable C++ support],[ case $withval in no) CXX= --- 157,161 ---- MAINOBJ=python.o AC_MSG_CHECKING(for --with-cxx=) ! AC_ARG_WITH(cxx, [ --with-cxx= enable C++ support],[ case $withval in no) CXX= *************** *** 613,617 **** AC_MSG_CHECKING(for --with-libs) ! AC_ARG_WITH(libs, [--with-libs='lib1 ...' link against additional libs], [ AC_MSG_RESULT($withval) LIBS="$withval $LIBS" --- 613,618 ---- AC_MSG_CHECKING(for --with-libs) ! AC_ARG_WITH(libs, ! [ --with-libs='lib1 ...' link against additional libs], [ AC_MSG_RESULT($withval) LIBS="$withval $LIBS" *************** *** 620,624 **** AC_MSG_CHECKING(for --with(out)-readline) AC_ARG_WITH(readline, ! [--with(out)-readline obsolete, edit Modules/Setup instead], [AC_MSG_RESULT($withval) AC_ERROR(--with(out)-readline is obsolete, edit Modules/Setup instead)], --- 621,625 ---- AC_MSG_CHECKING(for --with(out)-readline) AC_ARG_WITH(readline, ! [ --with(out)-readline obsolete, edit Modules/Setup instead], [AC_MSG_RESULT($withval) AC_ERROR(--with(out)-readline is obsolete, edit Modules/Setup instead)], *************** *** 626,636 **** AC_SUBST(USE_THREAD_MODULE) ! USE_THREAD_MODULE="#" AC_MSG_CHECKING(for --with-dec-threads) AC_SUBST(LDLAST) AC_ARG_WITH(dec-threads, ! [--with-dec-threads use DEC Alpha/OSF1 thread-safe libraries], ! [AC_MSG_RESULT($withval) LDLAST=-threads if test "${with_thread+set}" != set; then --- 627,637 ---- AC_SUBST(USE_THREAD_MODULE) ! USE_THREAD_MODULE="" AC_MSG_CHECKING(for --with-dec-threads) AC_SUBST(LDLAST) AC_ARG_WITH(dec-threads, ! [ --with-dec-threads use DEC Alpha/OSF1 thread-safe libraries], [ ! AC_MSG_RESULT($withval) LDLAST=-threads if test "${with_thread+set}" != set; then *************** *** 640,700 **** AC_MSG_CHECKING(for --with-threads) ! AC_ARG_WITH(threads, [--with-threads alias for --with-thread], ! [AC_MSG_RESULT($withval) ! if test "${with_thread+set}" != set; then ! with_thread="$withval"; ! fi], ! AC_MSG_RESULT(no)) ! AC_MSG_CHECKING(for --with-thread) ! AC_ARG_WITH(thread, [--with-thread[=DIRECTORY] make interpreter thread-safe], [ ! USE_THREAD_MODULE= ! AC_MSG_RESULT($withval) ! if test -d "$withval" ! then LDFLAGS="$LDFLAGS -L$withval" fi ! AC_DEFINE(_REENTRANT) ! AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(C_THREADS) ! LIBOBJS="$LIBOBJS thread.o"],[ ! AC_CHECK_LIB(pth, pth_init, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(_GNU_PTH) ! LIBS="-lpth $LIBS" ! LIBOBJS="$LIBOBJS thread.o"],[ ! AC_CHECK_LIB(pthread, pthread_create, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(_POSIX_THREADS) ! LIBS="-lpthread $LIBS" ! LIBOBJS="$LIBOBJS thread.o"],[ ! AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(_POSIX_THREADS) ! LIBOBJS="$LIBOBJS thread.o"],[ ! AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(BEOS_THREADS) ! LIBOBJS="$LIBOBJS thread.o"],[ ! AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(_POSIX_THREADS) ! LIBS="$LIBS -lpthreads" ! LIBOBJS="$LIBOBJS thread.o"], [ ! AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(_POSIX_THREADS) ! LIBS="$LIBS -lc_r" ! LIBOBJS="$LIBOBJS thread.o"], [ ! AC_CHECK_LIB(thread, __d6_pthread_create, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(_POSIX_THREADS) ! LIBS="$LIBS -lthread" ! LIBOBJS="$LIBOBJS thread.o"], [ ! AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(_POSIX_THREADS) ! LIBS="$LIBS -lcma" ! LIBOBJS="$LIBOBJS thread.o"]) ! ])])])])])])])]) ! ! AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD) ! LIBS="$LIBS -lmpc" ! LIBOBJS="$LIBOBJS thread.o"]) ! AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD) ! LIBS="$LIBS -lthread" ! LIBOBJS="$LIBOBJS thread.o"]) ! ], AC_MSG_RESULT(no)) # -I${DLINCLDIR} is added to the compile rule for importdl.o --- 641,708 ---- AC_MSG_CHECKING(for --with-threads) ! AC_ARG_WITH(threads, ! [ --with(out)-threads[=DIRECTORY] disable/enable thread support]) ! # --with-thread is deprecated, but check for it anyway ! AC_ARG_WITH(thread,,[with_threads=$with_thread]) ! ! if test -z "$with_threads" ! then with_threads="yes" fi ! AC_MSG_RESULT($with_threads) ! ! if test "$with_threads" = "no" ! then ! USE_THREAD_MODULE="#" ! else ! if test -d "$with_threads" ! then LDFLAGS="$LDFLAGS -L$with_threads" ! fi ! if test -d "$withval" ! then LDFLAGS="$LDFLAGS -L$withval" ! fi ! AC_DEFINE(_REENTRANT) ! AC_CHECK_HEADER(mach/cthreads.h, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(C_THREADS) ! LIBOBJS="$LIBOBJS thread.o"],[ ! AC_CHECK_LIB(pth, pth_init, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(_GNU_PTH) ! LIBS="-lpth $LIBS" ! LIBOBJS="$LIBOBJS thread.o"],[ ! AC_CHECK_LIB(pthread, pthread_create, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(_POSIX_THREADS) ! LIBS="-lpthread $LIBS" ! LIBOBJS="$LIBOBJS thread.o"],[ ! AC_CHECK_FUNC(pthread_detach, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(_POSIX_THREADS) ! LIBOBJS="$LIBOBJS thread.o"],[ ! AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(BEOS_THREADS) ! LIBOBJS="$LIBOBJS thread.o"],[ ! AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(_POSIX_THREADS) ! LIBS="$LIBS -lpthreads" ! LIBOBJS="$LIBOBJS thread.o"], [ ! AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(_POSIX_THREADS) ! LIBS="$LIBS -lc_r" ! LIBOBJS="$LIBOBJS thread.o"], [ ! AC_CHECK_LIB(thread, __d6_pthread_create, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(_POSIX_THREADS) ! LIBS="$LIBS -lthread" ! LIBOBJS="$LIBOBJS thread.o"], [ ! AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD) ! AC_DEFINE(_POSIX_THREADS) ! LIBS="$LIBS -lcma" ! LIBOBJS="$LIBOBJS thread.o"]) ! ])])])])])])])]) ! ! AC_CHECK_LIB(mpc, usconfig, [AC_DEFINE(WITH_THREAD) ! LIBS="$LIBS -lmpc" ! LIBOBJS="$LIBOBJS thread.o"]) ! AC_CHECK_LIB(thread, thr_create, [AC_DEFINE(WITH_THREAD) ! LIBS="$LIBS -lthread" ! LIBOBJS="$LIBOBJS thread.o"]) ! fi # -I${DLINCLDIR} is added to the compile rule for importdl.o *************** *** 703,707 **** AC_MSG_CHECKING(for --with-sgi-dl) ! AC_ARG_WITH(sgi-dl, [--with-sgi-dl=DIRECTORY IRIX 4 dynamic linking], [ AC_MSG_RESULT($withval) AC_DEFINE(WITH_SGI_DL) --- 711,716 ---- AC_MSG_CHECKING(for --with-sgi-dl) ! AC_ARG_WITH(sgi-dl, ! [ --with-sgi-dl=DIRECTORY IRIX 4 dynamic linking], [ AC_MSG_RESULT($withval) AC_DEFINE(WITH_SGI_DL) *************** *** 716,720 **** AC_MSG_CHECKING(for --with-dl-dld) ! AC_ARG_WITH(dl-dld, [--with-dl-dld=DL_DIR,DLD_DIR GNU dynamic linking], [ AC_MSG_RESULT($withval) AC_DEFINE(WITH_DL_DLD) --- 725,729 ---- AC_MSG_CHECKING(for --with-dl-dld) ! AC_ARG_WITH(dl-dld, [ --with-dl-dld=DL_DIR,DLD_DIR GNU dynamic linking], [ AC_MSG_RESULT($withval) AC_DEFINE(WITH_DL_DLD) *************** *** 959,963 **** # Check for --with-fpectl AC_MSG_CHECKING(for --with-fpectl) ! AC_ARG_WITH(fpectl, [--with-fpectl enable SIGFPE catching], [ if test "$withval" != no then AC_DEFINE(WANT_SIGFPE_HANDLER) AC_MSG_RESULT(yes) --- 968,973 ---- # Check for --with-fpectl AC_MSG_CHECKING(for --with-fpectl) ! AC_ARG_WITH(fpectl, ! [ --with-fpectl enable SIGFPE catching], [ if test "$withval" != no then AC_DEFINE(WANT_SIGFPE_HANDLER) AC_MSG_RESULT(yes) *************** *** 974,978 **** esac AC_MSG_CHECKING(for --with-libm=STRING) ! AC_ARG_WITH(libm, [--with-libm=STRING math library], [ if test "$withval" = no then LIBM= --- 984,988 ---- esac AC_MSG_CHECKING(for --with-libm=STRING) ! AC_ARG_WITH(libm, [ --with-libm=STRING math library], [ if test "$withval" = no then LIBM= *************** *** 988,992 **** AC_SUBST(LIBC) AC_MSG_CHECKING(for --with-libc=STRING) ! AC_ARG_WITH(libc, [--with-libc=STRING C library], [ if test "$withval" = no then LIBC= --- 998,1002 ---- AC_SUBST(LIBC) AC_MSG_CHECKING(for --with-libc=STRING) ! AC_ARG_WITH(libc, [ --with-libc=STRING C library], [ if test "$withval" = no then LIBC= *************** *** 1083,1087 **** AC_MSG_CHECKING(for --with-wctype-functions) AC_ARG_WITH(wctype-functions, ! [--with-wctype-functions use wctype.h functions], [ if test "$withval" != no then AC_DEFINE(WANT_WCTYPE_FUNCTIONS) AC_MSG_RESULT(yes) --- 1093,1097 ---- AC_MSG_CHECKING(for --with-wctype-functions) AC_ARG_WITH(wctype-functions, ! [ --with-wctype-functions use wctype.h functions], [ if test "$withval" != no then AC_DEFINE(WANT_WCTYPE_FUNCTIONS) AC_MSG_RESULT(yes) From python-dev@python.org Thu Jun 29 17:14:17 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 09:14:17 -0700 Subject: [Python-checkins] CVS: python/dist/src/PC _winreg.c,1.3,1.4 Message-ID: <200006291614.JAA03585@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv3574 Modified Files: _winreg.c Log Message: Update the module name to _winreg, pending checkin of Paul Prescod's OO wrapper for this module. Index: _winreg.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/_winreg.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** _winreg.c 2000/06/09 06:01:47 1.3 --- _winreg.c 2000/06/29 16:14:14 1.4 *************** *** 1,4 **** /* ! winreg.c Windows Registry access module for Python. --- 1,4 ---- /* ! _winreg.c Windows Registry access module for Python. *************** *** 1404,1411 **** #define ADD_KEY(val) inskey(d, #val, val) ! __declspec(dllexport) void initwinreg(void) { PyObject *m, *d; ! m = Py_InitModule3("winreg", winreg_methods, module_doc); d = PyModule_GetDict(m); PyHKEY_Type.ob_type = &PyType_Type; --- 1404,1411 ---- #define ADD_KEY(val) inskey(d, #val, val) ! __declspec(dllexport) void init_winreg(void) { PyObject *m, *d; ! m = Py_InitModule3("_winreg", winreg_methods, module_doc); d = PyModule_GetDict(m); PyHKEY_Type.ob_type = &PyType_Type; From python-dev@python.org Thu Jun 29 17:15:55 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 29 Jun 2000 09:15:55 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib pickle.py,1.37,1.38 Message-ID: <200006291615.JAA03805@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv3794 Modified Files: pickle.py Log Message: Change string exceptions to class exceptions. Index: pickle.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pickle.py,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -r1.37 -r1.38 *** pickle.py 2000/03/10 23:20:09 1.37 --- pickle.py 2000/06/29 16:15:52 1.38 *************** *** 39,44 **** mloads = marshal.loads ! PicklingError = "pickle.PicklingError" ! UnpicklingError = "pickle.UnpicklingError" try: --- 39,45 ---- mloads = marshal.loads ! class PickleError(Exception): pass ! class PicklingError(PickleError): pass ! class UnpicklingError(PickleError): pass try: From python-dev@python.org Thu Jun 29 17:30:53 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 29 Jun 2000 09:30:53 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/lib-tk Tkinter.py,1.138,1.139 Message-ID: <200006291630.JAA07217@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/lib-tk In directory slayer.i.sourceforge.net:/tmp/cvs-serv7209 Modified Files: Tkinter.py Log Message: Nils Fischbeck: added doc strings to everything. Martin von Loewis has reviewed this, too. Index: Tkinter.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/Tkinter.py,v retrieving revision 1.138 retrieving revision 1.139 diff -C2 -r1.138 -r1.139 *** Tkinter.py 2000/06/18 18:45:50 1.138 --- Tkinter.py 2000/06/29 16:30:50 1.139 *************** *** 1,4 **** ! # Tkinter.py -- Tk/Tcl widget wrappers __version__ = "$Revision$" --- 1,31 ---- ! """Wrapper functions for Tcl/Tk. + Tkinter provides classes which allow the display, positioning and + control of widgets. Toplevel widgets are Tk and Toplevel. Other + widgets are Frame, Label, Entry, Text, Canvas, Button, Radiobutton, [...2761 lines suppressed...] args = (self.name, 'write', filename) if format: *************** *** 1934,1938 **** --- 3007,3015 ---- class BitmapImage(Image): + """Widget which can display a bitmap.""" def __init__(self, name=None, cnf={}, master=None, **kw): + """Create a bitmap with NAME. + + Valid resource names: background, data, file, foreground, maskdata, maskfile.""" apply(Image.__init__, (self, 'bitmap', name, cnf, master), kw) *************** *** 1987,1988 **** --- 3064,3066 ---- if __name__ == '__main__': _test() + From python-dev@python.org Thu Jun 29 17:43:51 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 09:43:51 -0700 Subject: [Python-checkins] CVS: python/dist/src/PC winreg.c,1.3,NONE Message-ID: <200006291643.JAA07925@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv7915/PC Removed Files: winreg.c Log Message: Finish converting the winreg extension to _winreg. From python-dev@python.org Thu Jun 29 17:43:51 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 09:43:51 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild winreg.dsp,1.3,1.4 Message-ID: <200006291643.JAA07929@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv7915/PCbuild Modified Files: winreg.dsp Log Message: Finish converting the winreg extension to _winreg. Index: winreg.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/winreg.dsp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** winreg.dsp 2000/03/31 01:33:07 1.3 --- winreg.dsp 2000/06/29 16:43:49 1.4 *************** *** 55,59 **** 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 /dll /machine:I386 ! # ADD 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 /base:"0x1e1C0000" /dll /machine:I386 /out:"winreg.pyd" !ELSEIF "$(CFG)" == "winreg - Win32 Debug" --- 55,59 ---- 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 /dll /machine:I386 ! # ADD 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 /base:"0x1e1C0000" /dll /machine:I386 /out:"_winreg.pyd" !ELSEIF "$(CFG)" == "winreg - Win32 Debug" *************** *** 82,86 **** 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 /dll /debug /machine:I386 /pdbtype:sept ! # ADD 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 /base:"0x1e1C0000" /dll /debug /machine:I386 /out:"winreg_d.pyd" /pdbtype:sept !ENDIF --- 82,86 ---- 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 /dll /debug /machine:I386 /pdbtype:sept ! # ADD 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 /base:"0x1e1C0000" /dll /debug /machine:I386 /out:"_winreg_d.pyd" /pdbtype:sept !ENDIF *************** *** 92,96 **** # Begin Source File ! SOURCE=..\PC\winreg.c !IF "$(CFG)" == "winreg - Win32 Release" --- 92,96 ---- # Begin Source File ! SOURCE=..\PC\_winreg.c !IF "$(CFG)" == "winreg - Win32 Release" From python-dev@python.org Thu Jun 29 17:57:42 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 09:57:42 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre.py,1.11,1.12 sre_compile.py,1.9,1.10 sre_constants.py,1.9,1.10 sre_parse.py,1.9,1.10 Message-ID: <200006291657.JAA08802@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv8292/Lib Modified Files: sre.py sre_compile.py sre_constants.py sre_parse.py Log Message: - fixed split (test_sre still complains about split, but that's caused by the group reset bug, not split itself) - added more mark slots (should be dynamically allocated, but 100 is better than 32. and checking for the upper limit is better than overwriting the memory ;-) - internal: renamed the cursor helper class - internal: removed some bloat from sre_compile Index: sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** sre.py 2000/06/29 12:48:37 1.11 --- sre.py 2000/06/29 16:57:39 1.12 *************** *** 27,31 **** # sre exception ! error = sre_parse.error # -------------------------------------------------------------------- --- 27,31 ---- # sre exception ! error = sre_compile.error # -------------------------------------------------------------------- *************** *** 106,110 **** s = [] append = s.append ! c = pattern.cursor(string) while not count or n < count: m = c.search() --- 106,110 ---- s = [] append = s.append ! c = pattern.scanner(string) while not count or n < count: m = c.search() *************** *** 128,141 **** s = [] append = s.append ! c = pattern.cursor(string) while not maxsplit or n < maxsplit: m = c.search() if not m: break ! j = m.start() ! append(string[i:j]) ! i = m.end() ! if i <= j: ! break n = n + 1 if i < len(string): --- 128,145 ---- s = [] append = s.append ! extend = s.extend ! c = pattern.scanner(string) ! g = c.groups while not maxsplit or n < maxsplit: m = c.search() if not m: break ! b, e = m.span() ! if e == i: ! continue ! append(string[i:b]) ! if g and b != e: ! extend(m.groups()) ! i = e n = n + 1 if i < len(string): Index: sre_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** sre_compile.py 2000/06/29 12:48:37 1.9 --- sre_compile.py 2000/06/29 16:57:39 1.10 *************** *** 12,17 **** # ! import array, string, sys ! import _sre --- 12,16 ---- # ! import array import _sre *************** *** 25,145 **** raise RuntimeError, "cannot find a useable array type" - # FIXME: should move some optimizations from the parser to here! - - class Code: - def __init__(self): - self.data = [] - def __len__(self): - return len(self.data) - def __getitem__(self, index): - return self.data[index] - def __setitem__(self, index, code): - self.data[index] = code - def append(self, code): - self.data.append(code) - def todata(self): - # print self.data - try: - return array.array(WORDSIZE, self.data).tostring() - except OverflowError: - print self.data - raise - def _compile(code, pattern, flags): ! append = code.append for op, av in pattern: if op is ANY: if flags & SRE_FLAG_DOTALL: ! append(OPCODES[op]) # any character at all! else: ! append(OPCODES[CATEGORY]) ! append(CHCODES[CATEGORY_NOT_LINEBREAK]) elif op in (SUCCESS, FAILURE): ! append(OPCODES[op]) elif op is AT: ! append(OPCODES[op]) if flags & SRE_FLAG_MULTILINE: ! append(ATCODES[AT_MULTILINE[av]]) else: ! append(ATCODES[av]) elif op is BRANCH: ! append(OPCODES[op]) tail = [] for av in av[1]: ! skip = len(code); append(0) _compile(code, av, flags) ! ## append(OPCODES[SUCCESS]) ! append(OPCODES[JUMP]) ! tail.append(len(code)); append(0) code[skip] = len(code) - skip ! append(0) # end of branch for tail in tail: code[tail] = len(code) - tail elif op is CALL: ! append(OPCODES[op]) ! skip = len(code); append(0) _compile(code, av, flags) ! append(OPCODES[SUCCESS]) code[skip] = len(code) - skip elif op is CATEGORY: ! append(OPCODES[op]) if flags & SRE_FLAG_LOCALE: ! append(CH_LOCALE[CHCODES[av]]) elif flags & SRE_FLAG_UNICODE: ! append(CH_UNICODE[CHCODES[av]]) else: ! append(CHCODES[av]) elif op is GROUP: if flags & SRE_FLAG_IGNORECASE: ! append(OPCODES[OP_IGNORE[op]]) else: ! append(OPCODES[op]) ! append(av-1) elif op is IN: if flags & SRE_FLAG_IGNORECASE: ! append(OPCODES[OP_IGNORE[op]]) def fixup(literal, flags=flags): return _sre.getlower(ord(literal), flags) else: ! append(OPCODES[op]) fixup = ord ! skip = len(code); append(0) for op, av in av: ! append(OPCODES[op]) if op is NEGATE: pass elif op is LITERAL: ! append(fixup(av)) elif op is RANGE: ! append(fixup(av[0])) ! append(fixup(av[1])) elif op is CATEGORY: if flags & SRE_FLAG_LOCALE: ! append(CH_LOCALE[CHCODES[av]]) elif flags & SRE_FLAG_UNICODE: ! append(CH_UNICODE[CHCODES[av]]) else: ! append(CHCODES[av]) else: ! raise ValueError, "unsupported set operator" ! append(OPCODES[FAILURE]) code[skip] = len(code) - skip elif op in (LITERAL, NOT_LITERAL): if flags & SRE_FLAG_IGNORECASE: ! append(OPCODES[OP_IGNORE[op]]) else: ! append(OPCODES[op]) ! append(ord(av)) elif op is MARK: ! append(OPCODES[op]) ! append(av) elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): if flags & SRE_FLAG_TEMPLATE: ! append(OPCODES[REPEAT]) ! skip = len(code); append(0) ! append(av[0]) ! append(av[1]) _compile(code, av[2], flags) ! append(OPCODES[SUCCESS]) code[skip] = len(code) - skip else: --- 24,122 ---- raise RuntimeError, "cannot find a useable array type" def _compile(code, pattern, flags): ! emit = code.append for op, av in pattern: if op is ANY: if flags & SRE_FLAG_DOTALL: ! emit(OPCODES[op]) else: ! emit(OPCODES[CATEGORY]) ! emit(CHCODES[CATEGORY_NOT_LINEBREAK]) elif op in (SUCCESS, FAILURE): ! emit(OPCODES[op]) elif op is AT: ! emit(OPCODES[op]) if flags & SRE_FLAG_MULTILINE: ! emit(ATCODES[AT_MULTILINE[av]]) else: ! emit(ATCODES[av]) elif op is BRANCH: ! emit(OPCODES[op]) tail = [] for av in av[1]: ! skip = len(code); emit(0) _compile(code, av, flags) ! emit(OPCODES[JUMP]) ! tail.append(len(code)); emit(0) code[skip] = len(code) - skip ! emit(0) # end of branch for tail in tail: code[tail] = len(code) - tail elif op is CALL: ! emit(OPCODES[op]) ! skip = len(code); emit(0) _compile(code, av, flags) ! emit(OPCODES[SUCCESS]) code[skip] = len(code) - skip elif op is CATEGORY: ! emit(OPCODES[op]) if flags & SRE_FLAG_LOCALE: ! emit(CH_LOCALE[CHCODES[av]]) elif flags & SRE_FLAG_UNICODE: ! emit(CH_UNICODE[CHCODES[av]]) else: ! emit(CHCODES[av]) elif op is GROUP: if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) else: ! emit(OPCODES[op]) ! emit(av-1) elif op is IN: if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) def fixup(literal, flags=flags): return _sre.getlower(ord(literal), flags) else: ! emit(OPCODES[op]) fixup = ord ! skip = len(code); emit(0) for op, av in av: ! emit(OPCODES[op]) if op is NEGATE: pass elif op is LITERAL: ! emit(fixup(av)) elif op is RANGE: ! emit(fixup(av[0])) ! emit(fixup(av[1])) elif op is CATEGORY: if flags & SRE_FLAG_LOCALE: ! emit(CH_LOCALE[CHCODES[av]]) elif flags & SRE_FLAG_UNICODE: ! emit(CH_UNICODE[CHCODES[av]]) else: ! emit(CHCODES[av]) else: ! raise error, "internal: unsupported set operator" ! emit(OPCODES[FAILURE]) code[skip] = len(code) - skip elif op in (LITERAL, NOT_LITERAL): if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) else: ! emit(OPCODES[op]) ! emit(ord(av)) elif op is MARK: ! emit(OPCODES[op]) ! emit(av) elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): if flags & SRE_FLAG_TEMPLATE: ! emit(OPCODES[REPEAT]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) code[skip] = len(code) - skip else: *************** *** 150,182 **** # FIXME: need a better way to figure out when # it's safe to use this one (in the parser, probably) ! append(OPCODES[MAX_REPEAT_ONE]) ! skip = len(code); append(0) ! append(av[0]) ! append(av[1]) _compile(code, av[2], flags) ! append(OPCODES[SUCCESS]) code[skip] = len(code) - skip else: ! append(OPCODES[op]) ! skip = len(code); append(0) ! append(av[0]) ! append(av[1]) _compile(code, av[2], flags) ! append(OPCODES[SUCCESS]) code[skip] = len(code) - skip elif op is SUBPATTERN: group = av[0] if group: ! append(OPCODES[MARK]) ! append((group-1)*2) _compile(code, av[1], flags) if group: ! append(OPCODES[MARK]) ! append((group-1)*2+1) else: raise ValueError, ("unsupported operand type", op) def compile(p, flags=0): ! # convert pattern list to internal format if type(p) in (type(""), type(u"")): import sre_parse --- 127,159 ---- # FIXME: need a better way to figure out when # it's safe to use this one (in the parser, probably) ! emit(OPCODES[MAX_REPEAT_ONE]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) code[skip] = len(code) - skip else: ! emit(OPCODES[op]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) code[skip] = len(code) - skip elif op is SUBPATTERN: group = av[0] if group: ! emit(OPCODES[MARK]) ! emit((group-1)*2) _compile(code, av[1], flags) if group: ! emit(OPCODES[MARK]) ! emit((group-1)*2+1) else: raise ValueError, ("unsupported operand type", op) def compile(p, flags=0): ! # internal: convert pattern list to internal format if type(p) in (type(""), type(u"")): import sre_parse *************** *** 186,202 **** pattern = None flags = p.pattern.flags | flags ! code = Code() _compile(code, p.data, flags) code.append(OPCODES[SUCCESS]) ! data = code.todata() ! if 0: # debugging ! print ! print "-" * 68 ! import sre_disasm ! sre_disasm.disasm(data) ! print "-" * 68 return _sre.compile( pattern, flags, ! data, p.pattern.groups-1, p.pattern.groupdict ) --- 163,175 ---- pattern = None flags = p.pattern.flags | flags ! code = [] _compile(code, p.data, flags) code.append(OPCODES[SUCCESS]) ! # FIXME: get rid of this limitation ! assert p.pattern.groups <= 100,\ ! "sorry, but this version only supports 100 named groups" return _sre.compile( pattern, flags, ! array.array(WORDSIZE, code).tostring(), p.pattern.groups-1, p.pattern.groupdict ) Index: sre_constants.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_constants.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 From python-dev@python.org Thu Jun 29 17:57:42 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 09:57:42 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.9,2.10 sre.h,2.8,2.9 Message-ID: <200006291657.JAA08807@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv8292/Modules Modified Files: _sre.c sre.h Log Message: - fixed split (test_sre still complains about split, but that's caused by the group reset bug, not split itself) - added more mark slots (should be dynamically allocated, but 100 is better than 32. and checking for the upper limit is better than overwriting the memory ;-) - internal: renamed the cursor helper class - internal: removed some bloat from sre_compile Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.9 retrieving revision 2.10 diff -C2 -r2.9 -r2.10 *** _sre.c 2000/06/29 12:48:37 2.9 --- _sre.c 2000/06/29 16:57:40 2.10 *************** *** 15,23 **** * 00-03-14 fl removed most compatibility stuff (0.6) * 00-05-10 fl towards third alpha (0.8.2) ! * 00-05-13 fl added experimental cursor stuff (0.8.3) * 00-05-27 fl final bug hunt (0.8.4) * 00-06-21 fl less bugs, more taste (0.8.5) * 00-06-25 fl major changes to better deal with nested repeats (0.9) * 00-06-28 fl fixed findall (0.9.1) * * Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. --- 15,24 ---- * 00-03-14 fl removed most compatibility stuff (0.6) * 00-05-10 fl towards third alpha (0.8.2) ! * 00-05-13 fl added experimental scanner stuff (0.8.3) * 00-05-27 fl final bug hunt (0.8.4) * 00-06-21 fl less bugs, more taste (0.8.5) * 00-06-25 fl major changes to better deal with nested repeats (0.9) * 00-06-28 fl fixed findall (0.9.1) + * 00-06-29 fl fixed split, added more scanner features (0.9.2) * * Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. *************** *** 385,389 **** /* FIXME: this is a hack! */ ! void* mark_copy[64]; void* mark = NULL; --- 386,390 ---- /* FIXME: this is a hack! */ ! void* mark_copy[SRE_MARK_SIZE]; void* mark = NULL; *************** *** 955,959 **** staticforward PyTypeObject Pattern_Type; staticforward PyTypeObject Match_Type; ! staticforward PyTypeObject Cursor_Type; static PyObject * --- 956,960 ---- staticforward PyTypeObject Pattern_Type; staticforward PyTypeObject Match_Type; ! staticforward PyTypeObject Scanner_Type; static PyObject * *************** *** 1075,1079 **** /* FIXME: dynamic! */ ! for (i = 0; i < 64; i++) state->mark[i] = NULL; --- 1076,1080 ---- /* FIXME: dynamic! */ ! for (i = 0; i < SRE_MARK_SIZE; i++) state->mark[i] = NULL; *************** *** 1177,1189 **** static PyObject* ! pattern_cursor(PatternObject* pattern, PyObject* args) { /* create search state object */ ! CursorObject* self; PyObject* string; /* create match object (with room for extra group marks) */ ! self = PyObject_NEW(CursorObject, &Cursor_Type); if (self == NULL) return NULL; --- 1178,1190 ---- static PyObject* ! pattern_scanner(PatternObject* pattern, PyObject* args) { /* create search state object */ ! ScannerObject* self; PyObject* string; /* create match object (with room for extra group marks) */ ! self = PyObject_NEW(ScannerObject, &Scanner_Type); if (self == NULL) return NULL; *************** *** 1432,1436 **** {"findall", (PyCFunction) pattern_findall, 1}, /* experimental */ ! {"cursor", (PyCFunction) pattern_cursor, 1}, {NULL, NULL} }; --- 1433,1437 ---- {"findall", (PyCFunction) pattern_findall, 1}, /* experimental */ ! {"scanner", (PyCFunction) pattern_scanner, 1}, {NULL, NULL} }; *************** *** 1468,1472 **** statichere PyTypeObject Pattern_Type = { PyObject_HEAD_INIT(NULL) ! 0, "Pattern", sizeof(PatternObject), 0, (destructor)pattern_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ --- 1469,1473 ---- statichere PyTypeObject Pattern_Type = { PyObject_HEAD_INIT(NULL) ! 0, "SRE_Pattern", sizeof(PatternObject), 0, (destructor)pattern_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ *************** *** 1762,1766 **** statichere PyTypeObject Match_Type = { PyObject_HEAD_INIT(NULL) ! 0, "Match", sizeof(MatchObject), /* size of basic object */ sizeof(int), /* space for group item */ --- 1763,1767 ---- statichere PyTypeObject Match_Type = { PyObject_HEAD_INIT(NULL) ! 0, "SRE_Match", sizeof(MatchObject), /* size of basic object */ sizeof(int), /* space for group item */ *************** *** 1771,1778 **** /* -------------------------------------------------------------------- */ ! /* cursor methods (experimental) */ static void ! cursor_dealloc(CursorObject* self) { state_fini(&self->state); --- 1772,1779 ---- /* -------------------------------------------------------------------- */ ! /* scanner methods (experimental) */ static void ! scanner_dealloc(ScannerObject* self) { state_fini(&self->state); *************** *** 1783,1787 **** static PyObject* ! cursor_match(CursorObject* self, PyObject* args) { SRE_STATE* state = &self->state; --- 1784,1788 ---- static PyObject* ! scanner_match(ScannerObject* self, PyObject* args) { SRE_STATE* state = &self->state; *************** *** 1812,1816 **** static PyObject* ! cursor_search(CursorObject* self, PyObject* args) { SRE_STATE* state = &self->state; --- 1813,1817 ---- static PyObject* ! scanner_search(ScannerObject* self, PyObject* args) { SRE_STATE* state = &self->state; *************** *** 1831,1835 **** state, self->string, status); ! if (status >= 0) state->start = state->ptr; --- 1832,1838 ---- state, self->string, status); ! if (status == 0 || state->ptr == state->start) ! state->start = (void*) ((char*) state->ptr + state->charsize); ! else state->start = state->ptr; *************** *** 1837,1852 **** } ! static PyMethodDef cursor_methods[] = { ! {"match", (PyCFunction) cursor_match, 0}, ! {"search", (PyCFunction) cursor_search, 0}, {NULL, NULL} }; static PyObject* ! cursor_getattr(CursorObject* self, char* name) { PyObject* res; ! res = Py_FindMethod(cursor_methods, (PyObject*) self, name); if (res) return res; --- 1840,1855 ---- } ! static PyMethodDef scanner_methods[] = { ! {"match", (PyCFunction) scanner_match, 0}, ! {"search", (PyCFunction) scanner_search, 0}, {NULL, NULL} }; static PyObject* ! scanner_getattr(ScannerObject* self, char* name) { PyObject* res; ! res = Py_FindMethod(scanner_methods, (PyObject*) self, name); if (res) return res; *************** *** 1860,1875 **** } PyErr_SetString(PyExc_AttributeError, name); return NULL; } ! statichere PyTypeObject Cursor_Type = { PyObject_HEAD_INIT(NULL) ! 0, "Cursor", ! sizeof(CursorObject), /* size of basic object */ 0, ! (destructor)cursor_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ ! (getattrfunc)cursor_getattr, /*tp_getattr*/ }; --- 1863,1881 ---- } + if (!strcmp(name, "groups")) + return Py_BuildValue("i", ((PatternObject*) self->pattern)->groups); + PyErr_SetString(PyExc_AttributeError, name); return NULL; } ! statichere PyTypeObject Scanner_Type = { PyObject_HEAD_INIT(NULL) ! 0, "SRE_Scanner", ! sizeof(ScannerObject), /* size of basic object */ 0, ! (destructor)scanner_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ ! (getattrfunc)scanner_getattr, /*tp_getattr*/ }; *************** *** 1889,1893 **** /* Patch object types */ Pattern_Type.ob_type = Match_Type.ob_type = ! Cursor_Type.ob_type = &PyType_Type; Py_InitModule("_" MODULE, _functions); --- 1895,1899 ---- /* Patch object types */ Pattern_Type.ob_type = Match_Type.ob_type = ! Scanner_Type.ob_type = &PyType_Type; Py_InitModule("_" MODULE, _functions); Index: sre.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/sre.h,v retrieving revision 2.8 retrieving revision 2.9 diff -C2 -r2.8 -r2.9 *** sre.h 2000/06/29 12:48:37 2.8 --- sre.h 2000/06/29 16:57:40 2.9 *************** *** 47,50 **** --- 47,53 ---- } SRE_STACK; + /* FIXME: shouldn't be a constant, really... */ + #define SRE_MARK_SIZE 200 + typedef struct { /* string pointers */ *************** *** 57,61 **** /* registers */ int lastmark; ! void* mark[64]; /* FIXME: should be dynamically allocated! */ /* backtracking stack */ SRE_STACK* stack; --- 60,64 ---- /* registers */ int lastmark; ! void* mark[SRE_MARK_SIZE]; /* backtracking stack */ SRE_STACK* stack; *************** *** 67,76 **** typedef struct { ! /* search helper */ PyObject_HEAD PyObject* pattern; PyObject* string; SRE_STATE state; ! } CursorObject; #endif --- 70,79 ---- typedef struct { ! /* scanner (internal helper object) */ PyObject_HEAD PyObject* pattern; PyObject* string; SRE_STATE state; ! } ScannerObject; #endif From python-dev@python.org Thu Jun 29 17:53:11 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 09:53:11 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-win winreg.py,NONE,1.1 Message-ID: <200006291653.JAA08586@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/plat-win In directory slayer.i.sourceforge.net:/tmp/cvs-serv8578 Added Files: winreg.py Log Message: Paul Prescod : OO wrapper for _winreg; blessed by Mark Hammond. --- NEW FILE --- import winreg import sys import exceptions import array from types import * import string class RegType: def __init__( self, msname, friendlyname ): self.msname=msname self.friendlyname=friendlyname self.intval=getattr( winreg, msname ) def __repr__( self ): return "" % \ (self.intval, self.msname, self.friendlyname ) _typeConstants={ winreg.REG_NONE: RegType( "REG_NONE", "None" ), winreg.REG_SZ: RegType( "REG_SZ", "String" ), winreg.REG_EXPAND_SZ: RegType("REG_EXPAND_SZ", "Expandable Template String" ), winreg.REG_BINARY: RegType("REG_BINARY", "Binary Data"), winreg.REG_DWORD : RegType("REG_DWORD", "Integer" ), # winreg.REG_DWORD_LITTLE_ENDIAN : # RegType("REG_DWORD_LITTLE_ENDIAN", "Integer"), winreg.REG_DWORD_BIG_ENDIAN : RegType("REG_DWORD_BIG_ENDIAN", "Big Endian Integer"), winreg.REG_LINK : RegType("REG_LINK", "Link"), winreg.REG_MULTI_SZ : RegType("REG_MULTI_SZ", "List of Strings"), winreg.REG_RESOURCE_LIST : RegType("REG_RESOURCE_LIST", "Resource List"), winreg.REG_FULL_RESOURCE_DESCRIPTOR : RegType( "REG_FULL_RESOURCE_DESCRIPTOR", "Full Resource Descriptor" ), winreg.REG_RESOURCE_REQUIREMENTS_LIST: RegType( "REG_RESOURCE_REQUIREMENTS_LIST", "Resource Requirements List" ) } regtypes={} for constant in _typeConstants.values(): regtypes[constant.msname]=constant class _DictBase: def __init__( self, key ): self.key=key def clear( self ): keys=list( self.keys() ) map( self.__delitem__, keys ) def get( self, item, defaultVal=None ): try: return self.__getitem__( item ) except (IndexError, EnvironmentError, WindowsError): return defaultVal def has_key( self, item ): try: self.__getitem__( item ) return 1 except (IndexError, EnvironmentError, WindowsError): return 0 def keys( self ): keys=[] try: for i in xrange( 0, sys.maxint ): keyname = self._nameFromNum( i ) keys.append( keyname ) except (IndexError, EnvironmentError, WindowsError): pass return keys def values( self ): values=[] # map() doesn't use the IndexError semantics... for i in self: values.append( i ) return values def items( self ): return map( None, self.keys(), self.values() ) def __len__( self ): return len( self.keys() ) def _getName( item, nameFromNum ): if type( item ) == IntType: try: keyname = nameFromNum( item ) except (WindowsError, EnvironmentError): raise IndexError, item elif type( item )==StringType: keyname=item else: raise exceptions.TypeError, \ "Requires integer index or string key name" return keyname class RegValuesDict( _DictBase ): def _nameFromNum( self, i ): return self.key._nameFromNum( i ) def __getitem__( self, item ): return self.key.getValueNameDataAndType( item ) def __setitem__( self, name, val): if type( val )==TupleType: data, datatype=val assert isinstance( datatype, RegType ) self.key.setValue( name, data, datatype ) else: self.key.setValue( name, val ) def __delitem__( self, item ): valname=_getName( item, self._nameFromNum ) self.key.deleteValue( valname ) class RegKeysDict( _DictBase ): def _nameFromNum( self, item ): return winreg.EnumKey( self.key.handle, item ) def __getitem__( self, item ): keyname=_getName( item, self._nameFromNum ) return self.key.openSubkey( keyname ) def __delitem__( self, item ): keyname=_getName( item, self._nameFromNum ) self.key.deleteSubkey( keyname ) def openKey( keyname, samFlags=None ): lst=string.split( keyname, "\\", 1 ) if len( lst )==2: hivename,path=lst return hives[hivename].openSubkey( path ) else: hivename=lst[0] return hives[hivename] def createKey( keyname ): lst=string.split( keyname, "\\", 1 ) assert len( lst )==2 hivename,path=lst return hives[hivename].createSubkey( path ) def deleteKey( keyname ): lst=string.split( keyname, "\\", 1 ) assert len( lst )==2 hivename,path=lst return hives[hivename].deleteSubkey( path ) class RegKey: def _nameFromNum( self, item ): (name,data,datatype)=winreg.EnumValue( self.handle, item ) return name def __nonzero__(self): if self.handle: return 1 else: return 0 def __cmp__ (self, other ): if hasattr( other, "handle" ) and hasattr( other, "name" ): return cmp( self.name, other.name ) else: return cmp( self.handle, other ) def __init__( self, name, handle=None ): self.name=name self.handle=handle def __repr__( self ): return ""% self.name def close(self ): return winreg.CloseKey( self.handle ) def getSubkeyNames( self ): return self.getSubkeys().keys() def getValueNames( self ): return self.getValues().keys() def deleteSubkey( self, subkey ): return winreg.DeleteKey( self.handle, subkey ) def deleteValue( self, valname ): return winreg.DeleteValue( self.handle, valname ) def createSubkey( self, keyname ): handle=winreg.CreateKey( self.handle, keyname ) return RegKey( self.name+"\\"+keyname, handle) def openSubkey( self, keyname, samFlags=None ): if samFlags: handle=winreg.OpenKey( self.handle, keyname, 0, samFlags ) else: handle=winreg.OpenKey( self.handle, keyname, 0 ) return RegKey( self.name+"\\"+keyname, handle ) def getSubkeys( self ): return RegKeysDict( self ) def getValues( self ): return RegValuesDict( self ) def getValueNameDataAndType( self, valname ): try: if type( valname )==IntType: (valname,data,datatype)=winreg.EnumValue( self.handle, valname ) else: keyname=_getName( valname, self._nameFromNum ) (data,datatype)=winreg.QueryValueEx( self.handle, keyname ) except (WindowsError, EnvironmentError): raise IndexError, valname if datatype==winreg.REG_BINARY: # use arrays for binary data data=array.array( 'c', data ) return (valname, data, _typeConstants[datatype] ) def getValueData( self, valname ): name, data, type=self.getValueNameDataAndType( valname ) return data def setValue( self, valname, data, regtype=None ): if regtype: typeint=regtype.intval else: if type( data )==StringType: typeint=winreg.REG_SZ elif type( data )==IntType: typeint=winreg.REG_DWORD elif type( data )==array.ArrayType: typeint=winreg.REG_BINARY data=data.tostring() winreg.SetValueEx( self.handle, valname, 0, typeint, data ) def flush(self ): winreg.FlushKey( self.keyobbj ) def save( self, filename ): winreg.SaveKey( self.keyobj, filename ) def load( self, subkey, filename ): return winreg.RegLoadKey( self.handle, subkey, filename ) class RemoteKey( RegKey ): def __init__( self, machine, topLevelKey ): assert topLevelKey in _hivenames self.handle = winreg.ConnectRegistry( machine, parentKey ) self.name=r"\\%s\%s" % (machine, topLevelKey ) _hivenames = ["HKEY_CLASSES_ROOT","HKEY_CURRENT_USER","HKEY_LOCAL_MACHINE", "HKEY_USERS","HKEY_CURRENT_CONFIG","HKEY_DYN_DATA", "HKEY_PERFORMANCE_DATA"] hives={} for name in _hivenames: hives[name]=RegKey( name, getattr( winreg, name ) ) hives["HKLM"]=hives["HKEY_LOCAL_MACHINE"] hives["HKCR"]=hives["HKEY_CLASSES_ROOT"] hives["HKCU"]=hives["HKEY_CURRENT_USER"] _flagnames = ["KEY_ALL_ACCESS","KEY_CREATE_LINK", "KEY_CREATE_SUB_KEY", "KEY_ENUMERATE_SUB_KEYS", "KEY_EXECUTE", "KEY_NOTIFY", "KEY_QUERY_VALUE", "KEY_READ", "KEY_SET_VALUE"] flags={} for name in _flagnames: flags[name]=getattr( winreg, name ) _RegNotifyChangeKeyValueOptions=[ "REG_NOTIFY_CHANGE_ATTRIBUTES", "REG_NOTIFY_CHANGE_SECURITY", "REG_NOTIFY_CHANGE_LAST_SET", "REG_NOTIFY_CHANGE_NAME", "REG_LEGAL_CHANGE_FILTER" ] _RegRestoreKeyOptions=["REG_WHOLE_HIVE_VOLATILE", "REG_NO_LAZY_FLUSH", "REG_OPTION_VOLATILE", "REG_REFRESH_HIVE", "REG_OPTION_NON_VOLATILE", "REG_OPTION_BACKUP_RESTORE" ] _RegCreateKeyExOptions=[ "REG_LEGAL_OPTION", "REG_OPTION_RESERVED", "REG_OPTION_VOLATILE", "REG_OPTION_NON_VOLATILE", "REG_OPTION_BACKUP_RESTORE", "REG_CREATED_NEW_KEY", "REG_OPENED_EXISTING_KEY", "REG_OPTION_CREATE_LINK"] def test(): import testreg #unusednames=_RegNotifyChangeKeyValueOptions+_RegRestoreKeyOptions+_RegCreateKeyExOptions #typeConstantNames=map( lambda x: x.msname, typeConstants.values() ) #allnames=_hivenames+_flagnames+typeConstantNames+unusednames #winregnames=winreg.__dict__.keys() #for name in winregnames: # if name not in allnames: # print name From python-dev@python.org Thu Jun 29 18:00:56 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 29 Jun 2000 10:00:56 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_socket.py,1.13,1.14 Message-ID: <200006291700.KAA09410@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv9400 Modified Files: test_socket.py Log Message: Skip Montanaro: modify test_socket.py to listen/connect using loopback addr Index: test_socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** test_socket.py 2000/03/24 20:54:29 1.13 --- test_socket.py 2000/06/29 17:00:54 1.14 *************** *** 98,102 **** # parent is server s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ! s.bind((hostname, PORT)) s.listen(1) if verbose: --- 98,102 ---- # parent is server s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ! s.bind(("127.0.0.1", PORT)) s.listen(1) if verbose: *************** *** 134,138 **** if verbose: print 'child connecting' ! s.connect((hostname, PORT)) msg = 'socket test' s.send(msg) --- 134,138 ---- if verbose: print 'child connecting' ! s.connect(("127.0.0.1", PORT)) msg = 'socket test' s.send(msg) From python-dev@python.org Thu Jun 29 18:25:33 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 10:25:33 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python thread_nt.h,2.10,2.11 Message-ID: <200006291725.KAA16877@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv16794/Python Modified Files: thread_nt.h Log Message: - workaround to make 1.6 build under MSVC 5.0. hopefully, trent (who broke it in the first place ;-) will come up with a cleaner solution. Index: thread_nt.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_nt.h,v retrieving revision 2.10 retrieving revision 2.11 diff -C2 -r2.10 -r2.11 *** thread_nt.h 2000/06/28 22:07:35 2.10 --- thread_nt.h 2000/06/29 17:25:30 2.11 *************** *** 183,187 **** --- 183,191 ---- int PyThread_start_new_thread(void (*func)(void *), void *arg) { + #if _MSC_VER >= 1200 INT_PTR rv; + #else + unsigned long rv; + #endif int success = 0; From python-dev@python.org Thu Jun 29 19:51:02 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 11:51:02 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sgmllib.py,1.20,1.21 Message-ID: <200006291851.LAA28331@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv28314 Modified Files: sgmllib.py Log Message: [Old patch that hadn't been checked in.] get_starttag_text(): New method. Return the text of the most recently parsed start tag, from the '<' to the '>' or '/'. Not really useful for structure processing, but requested for Web-related use. May also be useful for being able to re-generate the input from the parse events, but there's no equivalent for end tags. attrfind: Be a little more forgiving of unquoted attribute values. Index: sgmllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sgmllib.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -r1.20 -r1.21 *** sgmllib.py 2000/06/28 14:48:01 1.20 --- sgmllib.py 2000/06/29 18:50:59 1.21 *************** *** 38,42 **** '[%s]*([a-zA-Z_][-.a-zA-Z_0-9]*)' % string.whitespace + ('([%s]*=[%s]*' % (string.whitespace, string.whitespace)) ! + r'(\'[^\']*\'|"[^"]*"|[-a-zA-Z0-9./:+*%?!\(\)_#=~]*))?') --- 38,42 ---- '[%s]*([a-zA-Z_][-.a-zA-Z_0-9]*)' % string.whitespace + ('([%s]*=[%s]*' % (string.whitespace, string.whitespace)) ! + r'(\'[^\']*\'|"[^"]*"|[-a-zA-Z0-9./:+*%?!&$\(\)_#=~]*))?') *************** *** 208,214 **** --- 208,220 ---- j = match.end(0) return j-i + + __starttag_text = None + def get_starttag_text(self): + return self.__starttag_text # Internal -- handle starttag, return length or -1 if not terminated def parse_starttag(self, i): + self.__starttag_text = None + start_pos = i rawdata = self.rawdata if shorttagopen.match(rawdata, i): *************** *** 221,227 **** return -1 tag, data = match.group(1, 2) tag = string.lower(tag) - self.finish_shorttag(tag, data) k = match.end(0) return k # XXX The following should skip matching quotes (' or ") --- 227,235 ---- return -1 tag, data = match.group(1, 2) + self.__starttag_text = '<%s/' % tag tag = string.lower(tag) k = match.end(0) + self.finish_shorttag(tag, data) + self.__starttag_text = rawdata[start_pos:match.end(1) + 1] return k # XXX The following should skip matching quotes (' or ") *************** *** 256,259 **** --- 264,268 ---- if rawdata[j] == '>': j = j+1 + self.__starttag_text = rawdata[start_pos:j] self.finish_starttag(tag, attrs) return j From python-dev@python.org Thu Jun 29 20:17:07 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:17:07 -0700 Subject: [Python-checkins] CVS: python/dist/src/PC _winreg.c,1.4,1.5 Message-ID: <200006291917.MAA03866@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv3837/PC Modified Files: _winreg.c Log Message: This patch addresses two main issues: (1) There exist some non-fatal errors in some of the hash algorithms. For exmaple, in float_hash and complex_hash a certain part of the value is not included in the hash calculation. See Tim's, Guido's, and my discussion of this on python-dev in May under the title "fix float_hash and complex_hash for 64-bit *nix" (2) The hash algorithms that use pointers (e.g. func_hash, code_hash) are universally not correct on Win64 (they assume that sizeof(long) == sizeof(void*)) As well, this patch significantly cleans up the hash code. It adds the two function _Py_HashDouble and _PyHash_VoidPtr that the various hashing routine are changed to use. These help maintain the hash function invariant: (a==b) => (hash(a)==hash(b))) I have added Lib/test/test_hash.py and Lib/test/output/test_hash to test this for some cases. Index: _winreg.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/_winreg.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** _winreg.c 2000/06/29 16:14:14 1.4 --- _winreg.c 2000/06/29 19:17:04 1.5 *************** *** 424,428 **** XXX - should we use the handle value? */ ! return (long)ob; } --- 424,428 ---- XXX - should we use the handle value? */ ! return _Py_HashPointer(ob); } From python-dev@python.org Thu Jun 29 20:17:07 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:17:07 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_hash,NONE,1.1 Message-ID: <200006291917.MAA03872@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv3837/Lib/test/output Added Files: test_hash Log Message: This patch addresses two main issues: (1) There exist some non-fatal errors in some of the hash algorithms. For exmaple, in float_hash and complex_hash a certain part of the value is not included in the hash calculation. See Tim's, Guido's, and my discussion of this on python-dev in May under the title "fix float_hash and complex_hash for 64-bit *nix" (2) The hash algorithms that use pointers (e.g. func_hash, code_hash) are universally not correct on Win64 (they assume that sizeof(long) == sizeof(void*)) As well, this patch significantly cleans up the hash code. It adds the two function _Py_HashDouble and _PyHash_VoidPtr that the various hashing routine are changed to use. These help maintain the hash function invariant: (a==b) => (hash(a)==hash(b))) I have added Lib/test/test_hash.py and Lib/test/output/test_hash to test this for some cases. --- NEW FILE --- test_hash From python-dev@python.org Thu Jun 29 20:17:07 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:17:07 -0700 Subject: [Python-checkins] CVS: python/dist/src/Include object.h,2.56,2.57 Message-ID: <200006291917.MAA03859@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Include In directory slayer.i.sourceforge.net:/tmp/cvs-serv3837/Include Modified Files: object.h Log Message: This patch addresses two main issues: (1) There exist some non-fatal errors in some of the hash algorithms. For exmaple, in float_hash and complex_hash a certain part of the value is not included in the hash calculation. See Tim's, Guido's, and my discussion of this on python-dev in May under the title "fix float_hash and complex_hash for 64-bit *nix" (2) The hash algorithms that use pointers (e.g. func_hash, code_hash) are universally not correct on Win64 (they assume that sizeof(long) == sizeof(void*)) As well, this patch significantly cleans up the hash code. It adds the two function _Py_HashDouble and _PyHash_VoidPtr that the various hashing routine are changed to use. These help maintain the hash function invariant: (a==b) => (hash(a)==hash(b))) I have added Lib/test/test_hash.py and Lib/test/output/test_hash to test this for some cases. Index: object.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/object.h,v retrieving revision 2.56 retrieving revision 2.57 diff -C2 -r2.56 -r2.57 *** object.h 2000/06/23 19:37:01 2.56 --- object.h 2000/06/29 19:17:04 2.57 *************** *** 294,297 **** --- 294,301 ---- extern PyObject *_PyCompareState_Key; + /* Helpers for hash functions */ + extern DL_IMPORT(long) _Py_HashDouble Py_PROTO((double)); + extern DL_IMPORT(long) _Py_HashPointer Py_PROTO((void*)); + /* Flag bits for printing: */ #define Py_PRINT_RAW 1 /* No string quotes etc. */ From python-dev@python.org Thu Jun 29 20:17:07 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:17:07 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_hash.py,NONE,1.1 Message-ID: <200006291917.MAA03869@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv3837/Lib/test Added Files: test_hash.py Log Message: This patch addresses two main issues: (1) There exist some non-fatal errors in some of the hash algorithms. For exmaple, in float_hash and complex_hash a certain part of the value is not included in the hash calculation. See Tim's, Guido's, and my discussion of this on python-dev in May under the title "fix float_hash and complex_hash for 64-bit *nix" (2) The hash algorithms that use pointers (e.g. func_hash, code_hash) are universally not correct on Win64 (they assume that sizeof(long) == sizeof(void*)) As well, this patch significantly cleans up the hash code. It adds the two function _Py_HashDouble and _PyHash_VoidPtr that the various hashing routine are changed to use. These help maintain the hash function invariant: (a==b) => (hash(a)==hash(b))) I have added Lib/test/test_hash.py and Lib/test/output/test_hash to test this for some cases. --- NEW FILE --- # test the invariant that # iff a==b then hash(a)==hash(b) # import test_support def same_hash(*objlist): # hash each object given an raise TestFailed if # the hash values are not all the same hashed = map(hash, objlist) for h in hashed[1:]: if h != hashed[0]: raise TestFailed, "hashed values differ: %s" % `objlist` same_hash(1, 1L, 1.0, 1.0+0.0j) same_hash(int(1), long(1), float(1), complex(1)) same_hash(long(1.23e300), float(1.23e300)) same_hash(float(0.5), complex(0.5, 0.0)) From python-dev@python.org Thu Jun 29 20:17:07 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:17:07 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects methodobject.c,2.26,2.27 object.c,2.73,2.74 floatobject.c,2.57,2.58 complexobject.c,2.24,2.25 classobject.c,2.91,2.92 funcobject.c,2.22,2.23 Message-ID: <200006291917.MAA03863@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv3837/Objects Modified Files: methodobject.c object.c floatobject.c complexobject.c classobject.c funcobject.c Log Message: This patch addresses two main issues: (1) There exist some non-fatal errors in some of the hash algorithms. For exmaple, in float_hash and complex_hash a certain part of the value is not included in the hash calculation. See Tim's, Guido's, and my discussion of this on python-dev in May under the title "fix float_hash and complex_hash for 64-bit *nix" (2) The hash algorithms that use pointers (e.g. func_hash, code_hash) are universally not correct on Win64 (they assume that sizeof(long) == sizeof(void*)) As well, this patch significantly cleans up the hash code. It adds the two function _Py_HashDouble and _PyHash_VoidPtr that the various hashing routine are changed to use. These help maintain the hash function invariant: (a==b) => (hash(a)==hash(b))) I have added Lib/test/test_hash.py and Lib/test/output/test_hash to test this for some cases. Index: methodobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/methodobject.c,v retrieving revision 2.26 retrieving revision 2.27 diff -C2 -r2.26 -r2.27 *** methodobject.c 2000/05/03 23:44:35 2.26 --- methodobject.c 2000/06/29 19:17:04 2.27 *************** *** 173,177 **** PyCFunctionObject *a; { ! long x; if (a->m_self == NULL) x = 0; --- 173,177 ---- PyCFunctionObject *a; { ! long x,y; if (a->m_self == NULL) x = 0; *************** *** 181,185 **** return -1; } ! return x ^ (long) a->m_ml->ml_meth; } --- 181,191 ---- return -1; } ! y = _Py_HashPointer(a->m_ml->ml_meth); ! if (y == -1) ! return -1; ! x ^= y; ! if (x == -1) ! x = -2; ! return x; } Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.73 retrieving revision 2.74 diff -C2 -r2.73 -r2.74 *** object.c 2000/06/28 21:57:18 2.73 --- object.c 2000/06/29 19:17:04 2.74 *************** *** 34,37 **** --- 34,39 ---- #include "Python.h" + #include "mymath.h" + /* just for trashcan: */ #include "compile.h" *************** *** 508,512 **** --- 510,570 ---- } + + /* Set of hash utility functions to help maintaining the invariant that + iff a==b then hash(a)==hash(b) + + All the utility functions (_Py_Hash*()) return "-1" to signify an error. + */ + + long + _Py_HashDouble(v) + double v; + { + /* Use frexp to get at the bits in the double. + * Since the VAX D double format has 56 mantissa bits, which is the + * most of any double format in use, each of these parts may have as + * many as (but no more than) 56 significant bits. + * So, assuming sizeof(long) >= 4, each part can be broken into two longs; + * frexp and multiplication are used to do that. + * Also, since the Cray double format has 15 exponent bits, which is the + * most of any double format in use, shifting the exponent field left by + * 15 won't overflow a long (again assuming sizeof(long) >= 4). + */ + int expo; + long hipart; + + v = frexp(v, &expo); + v = v * 2147483648.0; /* 2**31 */ + hipart = (long)v; /* Take the top 32 bits */ + v = (v - (double)hipart) * 2147483648.0; /* Get the next 32 bits */ + + return hipart + (long)v + (expo << 15); /* Combine everything */ + } + long + _Py_HashPointer(p) + void *p; + { + #if SIZEOF_LONG >= SIZEOF_VOID_P + return (long)p; + #else + /* convert to a Python long and hash that */ + PyObject* longobj; + long x; + + if ((longobj = PyLong_FromVoidPtr(p)) == NULL) { + x = -1; + goto finally; + } + x = PyObject_Hash(longobj); + + finally: + Py_XDECREF(longobj); + return x; + #endif + } + + + long PyObject_Hash(v) PyObject *v; *************** *** 515,520 **** if (tp->tp_hash != NULL) return (*tp->tp_hash)(v); ! if (tp->tp_compare == NULL) ! return (long) v; /* Use address as hash value */ /* If there's a cmp but no hash defined, the object can't be hashed */ PyErr_SetString(PyExc_TypeError, "unhashable type"); --- 573,579 ---- if (tp->tp_hash != NULL) return (*tp->tp_hash)(v); ! if (tp->tp_compare == NULL) { ! return _Py_HashPointer(v); /* Use address as hash value */ ! } /* If there's a cmp but no hash defined, the object can't be hashed */ PyErr_SetString(PyExc_TypeError, "unhashable type"); Index: floatobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/floatobject.c,v retrieving revision 2.57 retrieving revision 2.58 diff -C2 -r2.57 -r2.58 *** floatobject.c 2000/05/03 23:44:34 2.57 --- floatobject.c 2000/06/29 19:17:04 2.58 *************** *** 60,64 **** --- 60,70 ---- #ifndef LONG_MAX + #if SIZEOF_LONG == 4 #define LONG_MAX 0X7FFFFFFFL + #elif SIZEOF_LONG == 8 + #define LONG_MAX 0X7FFFFFFFFFFFFFFFL + #else + #error "could not set LONG_MAX" + #endif #endif *************** *** 358,361 **** --- 364,368 ---- } + static long float_hash(v) *************** *** 363,367 **** { double intpart, fractpart; - int expo; long x; /* This is designed so that Python numbers with the same --- 370,373 ---- *************** *** 380,384 **** if (fractpart == 0.0) { ! if (intpart > 0x7fffffffL || -intpart > 0x7fffffffL) { /* Convert to long int and use its hash... */ PyObject *w = PyLong_FromDouble(v->ob_fval); --- 386,390 ---- if (fractpart == 0.0) { ! if (intpart > LONG_MAX || -intpart > LONG_MAX) { /* Convert to long int and use its hash... */ PyObject *w = PyLong_FromDouble(v->ob_fval); *************** *** 394,405 **** /* Note -- if you change this code, also change the copy in complexobject.c */ ! long hipart; ! fractpart = frexp(fractpart, &expo); ! fractpart = fractpart * 2147483648.0; /* 2**31 */ ! hipart = (long)fractpart; /* Take the top 32 bits */ ! fractpart = (fractpart - (double)hipart) * 2147483648.0; ! /* Get the next 32 bits */ ! x = hipart + (long)fractpart + (long)intpart + (expo << 15); ! /* Combine everything */ } if (x == -1) --- 400,406 ---- /* Note -- if you change this code, also change the copy in complexobject.c */ ! x = _Py_HashDouble(v->ob_fval); ! if (x == -1) ! return -1; } if (x == -1) Index: complexobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/complexobject.c,v retrieving revision 2.24 retrieving revision 2.25 diff -C2 -r2.24 -r2.25 *** complexobject.c 2000/05/03 23:44:34 2.24 --- complexobject.c 2000/06/29 19:17:04 2.25 *************** *** 286,291 **** { double intpart, fractpart; ! int expo; ! long hipart, x; /* This is designed so that Python numbers with the same value hash to the same value, otherwise comparisons --- 286,290 ---- { double intpart, fractpart; ! long x; /* This is designed so that Python numbers with the same value hash to the same value, otherwise comparisons *************** *** 303,307 **** if (fractpart == 0.0 && v->cval.imag == 0.0) { ! if (intpart > 0x7fffffffL || -intpart > 0x7fffffffL) { /* Convert to long int and use its hash... */ PyObject *w = PyLong_FromDouble(v->cval.real); --- 302,306 ---- if (fractpart == 0.0 && v->cval.imag == 0.0) { ! if (intpart > LONG_MAX || -intpart > LONG_MAX) { /* Convert to long int and use its hash... */ PyObject *w = PyLong_FromDouble(v->cval.real); *************** *** 315,325 **** } else { ! fractpart = frexp(fractpart, &expo); ! fractpart = fractpart * 2147483648.0; /* 2**31 */ ! hipart = (long)fractpart; /* Take the top 32 bits */ ! fractpart = (fractpart - (double)hipart) * 2147483648.0; ! /* Get the next 32 bits */ ! x = hipart + (long)fractpart + (long)intpart + (expo << 15); ! /* Combine everything */ if (v->cval.imag != 0.0) { /* Hash the imaginary part */ --- 314,320 ---- } else { ! x = _Py_HashDouble(v->cval.real); ! if (x == -1) ! return -1; if (v->cval.imag != 0.0) { /* Hash the imaginary part */ *************** *** 327,348 **** to the same value as complex(y, x). Still better than it used to be :-) */ ! #ifdef MPW ! { ! extended e; ! fractpart = modf(v->cval.imag, &e); ! intpart = e; ! } ! #else ! fractpart = modf(v->cval.imag, &intpart); ! #endif ! fractpart = frexp(fractpart, &expo); ! fractpart = fractpart * 2147483648.0; /* 2**31 */ ! hipart = (long)fractpart; /* Take the top 32 bits */ ! fractpart = ! (fractpart - (double)hipart) * 2147483648.0; ! /* Get the next 32 bits */ ! x ^= hipart + (long)fractpart + ! (long)intpart + (expo << 15); ! /* Combine everything */ } } --- 322,329 ---- to the same value as complex(y, x). Still better than it used to be :-) */ ! long y = _Py_HashDouble(v->cval.imag); ! if (y == -1) ! return -1; ! x += y; } } Index: classobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v retrieving revision 2.91 retrieving revision 2.92 diff -C2 -r2.91 -r2.92 *** classobject.c 2000/06/28 23:46:07 2.91 --- classobject.c 2000/06/29 19:17:04 2.92 *************** *** 865,872 **** if (func == NULL) { PyErr_Clear(); ! outcome = (long)inst; ! if (outcome == -1) ! outcome = -2; ! return outcome; } PyErr_SetString(PyExc_TypeError, "unhashable instance"); --- 865,869 ---- if (func == NULL) { PyErr_Clear(); ! return _Py_HashPointer(inst); } PyErr_SetString(PyExc_TypeError, "unhashable instance"); Index: funcobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/funcobject.c,v retrieving revision 2.22 retrieving revision 2.23 diff -C2 -r2.22 -r2.23 *** funcobject.c 2000/06/23 19:37:01 2.22 --- funcobject.c 2000/06/29 19:17:04 2.23 *************** *** 232,239 **** PyFunctionObject *f; { ! long h; h = PyObject_Hash(f->func_code); if (h == -1) return h; ! h = h ^ (long)f->func_globals; if (h == -1) h = -2; return h; --- 232,241 ---- PyFunctionObject *f; { ! long h,x; h = PyObject_Hash(f->func_code); if (h == -1) return h; ! x = _Py_HashPointer(f->func_globals); ! if (x == -1) return x; ! h ^= x; if (h == -1) h = -2; return h; From python-dev@python.org Thu Jun 29 20:24:40 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:24:40 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml - New directory Message-ID: <200006291924.MAA04382@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/xml In directory slayer.i.sourceforge.net:/tmp/cvs-serv4375/xml Log Message: Directory /cvsroot/python/python/dist/src/Lib/xml added to the repository From python-dev@python.org Thu Jun 29 20:25:55 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:25:55 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml __init__.py,NONE,1.1 Message-ID: <200006291925.MAA04456@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/xml In directory slayer.i.sourceforge.net:/tmp/cvs-serv4450 Added Files: __init__.py Log Message: Package docstring. --- NEW FILE --- """Core XML support for Python. This package contains three sub-packages: dom -- The W3C Document Object Model. This supports DOM Level 1 + Namespaces. parser -- Python wrappers for XML parsers (currently only supports Expat). sax -- The Simple API for XML, developed by XML-Dev, led by David Megginson. This supports the SAX 2 API. """ From python-dev@python.org Thu Jun 29 20:26:16 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:26:16 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/dom - New directory Message-ID: <200006291926.MAA04481@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/xml/dom In directory slayer.i.sourceforge.net:/tmp/cvs-serv4470/dom Log Message: Directory /cvsroot/python/python/dist/src/Lib/xml/dom added to the repository From python-dev@python.org Thu Jun 29 20:26:16 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:26:16 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/sax - New directory Message-ID: <200006291926.MAA04484@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/xml/sax In directory slayer.i.sourceforge.net:/tmp/cvs-serv4470/sax Log Message: Directory /cvsroot/python/python/dist/src/Lib/xml/sax added to the repository From python-dev@python.org Thu Jun 29 20:28:06 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:28:06 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/dom __init__.py,NONE,1.1 Message-ID: <200006291928.MAA04613@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/xml/dom In directory slayer.i.sourceforge.net:/tmp/cvs-serv4606 Added Files: __init__.py Log Message: Package docstring. --- NEW FILE --- """W3C Document Object Model implementation for Python. The Python mapping of the Document Object Model is documented in <...>. This package contains the following modules: minidom -- A simple implementation of the Level 1 DOM with namespace support added (based on the Level 2 specification). """ From python-dev@python.org Thu Jun 29 20:33:45 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:33:45 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/sax __init__.py,NONE,1.1 Message-ID: <200006291933.MAA05055@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/xml/sax In directory slayer.i.sourceforge.net:/tmp/cvs-serv5045 Added Files: __init__.py Log Message: Package docstring and initialization. --- NEW FILE --- """Simple API for XML (SAX) implementation for Python. This module provides an implementation of the SAX 2 interface; information about the Java version of the interface can be found at http://www.megginson.com/SAX/. The Python version of the interface is documented at <...>. This package contains the following modules: saxutils -- Implementation of the convenience functions normally used to work with SAX. saxlib -- Implementation of the shared SAX 2 classes. drv_pyexpat -- Driver that allows use of the Expat parser with the classes defined in saxlib. """ from handler import * from expatreader import * from _exceptions import * from saxutils import * from _exceptions import SAXParseException import xmlreader From python-dev@python.org Thu Jun 29 20:34:56 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:34:56 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/sax _exceptions.py,NONE,1.1 expatreader.py,NONE,1.1 handler.py,NONE,1.1 saxutils.py,NONE,1.1 xmlreader.py,NONE,1.1 Message-ID: <200006291934.MAA05146@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/xml/sax In directory slayer.i.sourceforge.net:/tmp/cvs-serv5139 Added Files: _exceptions.py expatreader.py handler.py saxutils.py xmlreader.py Log Message: Paul Prescod : SAX interfaces for Python. --- NEW FILE --- """Different kinds of SAX Exceptions""" import sys if sys.platform[:4] == "java": from java.lang import Exception # ===== SAXEXCEPTION ===== class SAXException(Exception): """Encapsulate an XML error or warning. This class can contain basic error or warning information from either the XML parser or the application: you can subclass it to provide additional functionality, or to add localization. Note that although you will receive a SAXException as the argument to the handlers in the ErrorHandler interface, you are not actually required to throw the exception; instead, you can simply read the information in it.""" def __init__(self, msg, exception = None): """Creates an exception. The message is required, but the exception is optional.""" self._msg = msg self._exception = exception def getMessage(self): "Return a message for this exception." return self._msg def getException(self): "Return the embedded exception, or None if there was none." return self._exception def __str__(self): "Create a string representation of the exception." return self._msg def __getitem__(self, ix): """Avoids weird error messages if someone does exception[ix] by mistake, since Exception has __getitem__ defined.""" raise NameError("__getitem__") # ===== SAXPARSEEXCEPTION ===== class SAXParseException(SAXException): """Encapsulate an XML parse error or warning. This exception will include information for locating the error in the original XML document. Note that although the application will receive a SAXParseException as the argument to the handlers in the ErrorHandler interface, the application is not actually required to throw the exception; instead, it can simply read the information in it and take a different action. Since this exception is a subclass of SAXException, it inherits the ability to wrap another exception.""" def __init__(self, msg, exception, locator): "Creates the exception. The exception parameter is allowed to be None." SAXException.__init__(self, msg, exception) self._locator = locator def getColumnNumber(self): """The column number of the end of the text where the exception occurred.""" return self._locator.getColumnNumber() def getLineNumber(self): "The line number of the end of the text where the exception occurred." return self._locator.getLineNumber() def getPublicId(self): "Get the public identifier of the entity where the exception occurred." return self._locator.getPublicId() def getSystemId(self): "Get the system identifier of the entity where the exception occurred." return self._locator.getSystemId() def __str__(self): "Create a string representation of the exception." return "%s at %s:%d:%d" % (self._msg, self.getSystemId(), self.getLineNumber(), self.getColumnNumber()) # ===== SAXNOTRECOGNIZEDEXCEPTION ===== class SAXNotRecognizedException(SAXException): """Exception class for an unrecognized identifier. An XMLReader will raise this exception when it is confronted with an unrecognized feature or property. SAX applications and extensions may use this class for similar purposes.""" # ===== SAXNOTSUPPORTEDEXCEPTION ===== class SAXNotSupportedException(SAXException): """Exception class for an unsupported operation. An XMLReader will raise this exception when a service it cannot perform is requested (specifically setting a state or value). SAX applications and extensions may use this class for similar purposes.""" ***** Error reading new file(2, 'No such file or directory') ***** Error reading new file(2, 'No such file or directory') ***** Error reading new file(2, 'No such file or directory') --- NEW FILE --- import handler """An XML Reader is the SAX 2 name for an XML parser. XML Parsers should be based on this code. """ # ===== XMLREADER ===== class XMLReader: def __init__(self): self._cont_handler = handler.ContentHandler() #self._dtd_handler = handler.DTDHandler() #self._ent_handler = handler.EntityResolver() self._err_handler = handler.ErrorHandler() def parse(self, source): "Parse an XML document from a system identifier or an InputSource." raise NotImplementedError("This method must be implemented!") def getContentHandler(self): "Returns the current ContentHandler." return self._cont_handler def setContentHandler(self, handler): "Registers a new object to receive document content events." self._cont_handler = handler def getDTDHandler(self): "Returns the current DTD handler." return self._dtd_handler def setDTDHandler(self, handler): "Register an object to receive basic DTD-related events." self._dtd_handler = handler def getEntityResolver(self): "Returns the current EntityResolver." return self._ent_handler def setEntityResolver(self, resolver): "Register an object to resolve external entities." self._ent_handler = resolver def getErrorHandler(self): "Returns the current ErrorHandler." return self._err_handler def setErrorHandler(self, handler): "Register an object to receive error-message events." self._err_handler = handler def setLocale(self, locale): """Allow an application to set the locale for errors and warnings. SAX parsers are not required to provide localisation for errors and warnings; if they cannot support the requested locale, however, they must throw a SAX exception. Applications may request a locale change in the middle of a parse.""" raise SAXNotSupportedException("Locale support not implemented") def getFeature(self, name): "Looks up and returns the state of a SAX2 feature." raise SAXNotRecognizedException("Feature '%s' not recognized" % name) def setFeature(self, name, state): "Sets the state of a SAX2 feature." raise SAXNotRecognizedException("Feature '%s' not recognized" % name) def getProperty(self, name): "Looks up and returns the value of a SAX2 property." raise SAXNotRecognizedException("Property '%s' not recognized" % name) def setProperty(self, name, value): "Sets the value of a SAX2 property." raise SAXNotRecognizedException("Property '%s' not recognized" % name) class IncrementalParser(XMLReader): """This interface adds three extra methods to the XMLReader interface that allow XML parsers to support incremental parsing. Support for this interface is optional, since not all underlying XML parsers support this functionality. When the parser is instantiated it is ready to begin accepting data from the feed method immediately. After parsing has been finished with a call to close the reset method must be called to make the parser ready to accept new data, either from feed or using the parse method. Note that these methods must _not_ be called during parsing, that is, after parse has been called and before it returns. By default, the class also implements the parse method of the XMLReader interface using the feed, close and reset methods of the IncrementalParser interface as a convenience to SAX 2.0 driver writers.""" def __init__(self, bufsize=2**16 ): self._bufsize=bufsize XMLReader.__init__( self ) def parse(self, source): self.prepareParser(source) #FIXME: do some type checking: could be already stream, URL or # filename inf=open( source ) buffer = inf.read(self._bufsize) while buffer != "": self.feed(buffer) buffer = inf.read(self._bufsize) self.close() self.reset() def feed(self, data): """This method gives the raw XML data in the data parameter to the parser and makes it parse the data, emitting the corresponding events. It is allowed for XML constructs to be split across several calls to feed. feed may raise SAXException.""" raise NotImplementedError("This method must be implemented!") def prepareParser(self, source): """This method is called by the parse implementation to allow the SAX 2.0 driver to prepare itself for parsing.""" raise NotImplementedError("prepareParser must be overridden!") def close(self): """This method is called when the entire XML document has been passed to the parser through the feed method, to notify the parser that there are no more data. This allows the parser to do the final checks on the document and empty the internal data buffer. The parser will not be ready to parse another document until the reset method has been called. close may raise SAXException.""" raise NotImplementedError("This method must be implemented!") def reset(self): """This method is called after close has been called to reset the parser so that it is ready to parse new documents. The results of calling parse or feed after close without calling reset are undefined.""" raise NotImplementedError("This method must be implemented!") # ===== LOCATOR ===== class Locator: """Interface for associating a SAX event with a document location. A locator object will return valid results only during calls to DocumentHandler methods; at any other time, the results are unpredictable.""" def getColumnNumber(self): "Return the column number where the current event ends." return -1 def getLineNumber(self): "Return the line number where the current event ends." return -1 def getPublicId(self): "Return the public identifier for the current event." return None def getSystemId(self): "Return the system identifier for the current event." return None # --- AttributesImpl class AttributesImpl: def __init__(self, attrs, rawnames): self._attrs = attrs self._rawnames = rawnames def getLength(self): return len(self._attrs) def getType(self, name): return "CDATA" def getValue(self, name): return self._attrs[name] def getValueByQName(self, name): return self._attrs[self._rawnames[name]] def getNameByQName(self, name): return self._rawnames[name] def getNames(self): return self._attrs.keys() def getQNames(self): return self._rawnames.keys() def __len__(self): return len(self._attrs) def __getitem__(self, name): return self._attrs[name] def keys(self): return self._attrs.keys() def has_key(self, name): return self._attrs.has_key(name) def get(self, name, alternative=None): return self._attrs.get(name, alternative) def copy(self): return self.__class__(self._attrs, self._rawnames) def items(self): return self._attrs.items() def values(self): return self._attrs.values() def _test(): XMLReader() IncrementalParser() Locator() AttributesImpl() if __name__=="__main__": _test() From python-dev@python.org Thu Jun 29 20:35:32 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 29 Jun 2000 12:35:32 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/dos-8x3 test_ate.py,NONE,1.1 test_lin.py,NONE,1.1 basehttp.py,1.5,1.6 configpa.py,1.6,1.7 nturl2pa.py,1.4,1.5 reconver.py,1.2,1.3 rlcomple.py,1.5,1.6 simpleht.py,1.5,1.6 socketse.py,1.9,1.10 sre_comp.py,1.1,1.2 sre_cons.py,1.1,1.2 sre_pars.py,1.1,1.2 test_arr.py,1.6,1.7 test_bin.py,1.3,1.4 test_exc.py,1.3,1.4 test_mat.py,1.2,1.3 test_mma.py,1.1,1.2 test_ope.py,1.3,1.4 test_pye.py,1.1,1.2 test_soc.py,1.6,1.7 test_str.py,1.8,1.9 test_tim.py,1.5,1.6 test_uni.py,1.1,1.2 test_use.py,1.1,1.2 test_win.py,1.2,1.3 test_zli.py,1.5,1.6 threadin.py,1.2,1.3 Message-ID: <200006291935.MAA05215@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/dos-8x3 In directory slayer.i.sourceforge.net:/tmp/cvs-serv5180 Modified Files: basehttp.py configpa.py nturl2pa.py reconver.py rlcomple.py simpleht.py socketse.py sre_comp.py sre_cons.py sre_pars.py test_arr.py test_bin.py test_exc.py test_mat.py test_mma.py test_ope.py test_pye.py test_soc.py test_str.py test_tim.py test_uni.py test_use.py test_win.py test_zli.py threadin.py Added Files: test_ate.py test_lin.py Log Message: The usual :) --- NEW FILE --- # Test the exit module from test_support import verbose import atexit def handler1(): print "handler1" def handler2(*args, **kargs): print "handler2", args, kargs # save any exit functions that may have been registered as part of the # test framework _exithandlers = atexit._exithandlers atexit._exithandlers = [] atexit.register(handler1) atexit.register(handler2) atexit.register(handler2, 7, kw="abc") # simulate exit behavior by calling atexit._run_exitfuncs directly... atexit._run_exitfuncs() # restore exit handlers atexit._exithandlers = _exithandlers --- NEW FILE --- from test_support import verbose, findfile, TestFailed import linuxaudiodev import os def play_sound_file(path): fp = open(path, 'r') data = fp.read() fp.close() try: a = linuxaudiodev.open('w') except linuxaudiodev.error, msg: raise TestFailed, msg else: a.write(data) a.close() def test(): play_sound_file(findfile('audiotest.au')) test() Index: basehttp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/basehttp.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** basehttp.py 2000/05/08 17:30:59 1.5 --- basehttp.py 2000/06/29 19:35:29 1.6 *************** *** 88,91 **** --- 88,93 ---- class HTTPServer(SocketServer.TCPServer): + allow_reuse_address = 1 # Seems to make sense in testing environment + def server_bind(self): """Override server_bind to store the server name.""" Index: configpa.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/configpa.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** configpa.py 2000/05/08 17:30:59 1.6 --- configpa.py 2000/06/29 19:35:29 1.7 *************** *** 198,202 **** filename may also be given. """ ! if type(filenames) is type(''): filenames = [filenames] for filename in filenames: --- 198,202 ---- filename may also be given. """ ! if type(filenames) in [type(''), type(u'')]: filenames = [filenames] for filename in filenames: Index: nturl2pa.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/nturl2pa.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** nturl2pa.py 2000/05/08 17:31:00 1.4 --- nturl2pa.py 2000/06/29 19:35:29 1.5 *************** *** 2,6 **** def url2pathname(url): ! """ Convert a URL to a DOS path... ///C|/foo/bar/spam.foo --- 2,7 ---- def url2pathname(url): ! r"""Convert a URL to a DOS path. ! ///C|/foo/bar/spam.foo *************** *** 33,37 **** def pathname2url(p): ! """ Convert a DOS path name to a file url... C:\foo\bar\spam.foo --- 34,39 ---- def pathname2url(p): ! r"""Convert a DOS path name to a file url. ! C:\foo\bar\spam.foo Index: reconver.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/reconver.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** reconver.py 1998/03/26 22:13:26 1.2 --- reconver.py 2000/06/29 19:35:29 1.3 *************** *** 1,5 **** #! /usr/bin/env python1.5 ! """Convert old ("regex") regular expressions to new syntax ("re"). When imported as a module, there are two functions, with their own --- 1,5 ---- #! /usr/bin/env python1.5 ! r"""Convert old ("regex") regular expressions to new syntax ("re"). When imported as a module, there are two functions, with their own Index: rlcomple.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/rlcomple.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** rlcomple.py 2000/05/08 17:31:01 1.5 --- rlcomple.py 2000/06/29 19:35:29 1.6 *************** *** 77,81 **** __main__.__dict__.keys()]: for word in list: ! if word[:n] == text: matches.append(word) return matches --- 77,81 ---- __main__.__dict__.keys()]: for word in list: ! if word[:n] == text and word != "__builtins__": matches.append(word) return matches *************** *** 107,111 **** n = len(attr) for word in words: ! if word[:n] == attr: matches.append("%s.%s" % (expr, word)) return matches --- 107,111 ---- n = len(attr) for word in words: ! if word[:n] == attr and word != "__builtins__": matches.append("%s.%s" % (expr, word)) return matches Index: simpleht.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/simpleht.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** simpleht.py 2000/05/08 17:31:01 1.5 --- simpleht.py 2000/06/29 19:35:29 1.6 *************** *** 7,11 **** ! __version__ = "0.3" --- 7,11 ---- ! __version__ = "0.4" *************** *** 15,18 **** --- 15,20 ---- import BaseHTTPServer import urllib + import cgi + from StringIO import StringIO *************** *** 58,71 **** """ path = self.translate_path(self.path) if os.path.isdir(path): ! self.send_error(403, "Directory listing not supported") ! return None try: ! f = open(path, 'rb') except IOError: self.send_error(404, "File not found") return None self.send_response(200) ! self.send_header("Content-type", self.guess_type(path)) self.end_headers() return f --- 60,119 ---- """ path = self.translate_path(self.path) + f = None if os.path.isdir(path): ! for index in "index.html", "index.htm": ! index = os.path.join(path, index) ! if os.path.exists(index): ! path = index ! break ! else: ! return self.list_directory(path) ! ctype = self.guess_type(path) ! if ctype.startswith('text/'): ! mode = 'r' ! else: ! mode = 'rb' try: ! f = open(path, mode) except IOError: self.send_error(404, "File not found") return None + self.send_response(200) + self.send_header("Content-type", ctype) + self.end_headers() + return f + + def list_directory(self, path): + """Helper to produce a directory listing (absent index.html). + + Return value is either a file object, or None (indicating an + error). In either case, the headers are sent, making the + interface the same as for send_head(). + + """ + try: + list = os.listdir(path) + except os.error: + self.send_error(404, "No permission to list directory"); + return None + list.sort(lambda a, b: cmp(a.lower(), b.lower())) + f = StringIO() + f.write("

Directory listing for %s

\n" % self.path) + f.write("
\n
    \n") + for name in list: + fullname = os.path.join(path, name) + displayname = linkname = name = cgi.escape(name) + # Append / for directories or @ for symbolic links + if os.path.isdir(fullname): + displayname = name + "/" + linkname = name + os.sep + if os.path.islink(fullname): + displayname = name + "@" + # Note: a link to a directory displays with @ and links with / + f.write('
  • %s\n' % (linkname, displayname)) + f.write("
\n
\n") + f.seek(0) self.send_response(200) ! self.send_header("Content-type", "text/html") self.end_headers() return f Index: socketse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/socketse.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** socketse.py 2000/05/08 17:31:01 1.9 --- socketse.py 2000/06/29 19:35:29 1.10 *************** *** 142,145 **** --- 142,146 ---- - socket_type - request_queue_size (only for stream sockets) + - reuse_address Instance variables: *************** *** 157,160 **** --- 158,163 ---- request_queue_size = 5 + allow_reuse_address = 0 + def __init__(self, server_address, RequestHandlerClass): """Constructor. May be extended, do not override.""" *************** *** 172,175 **** --- 175,180 ---- """ + if self.allow_reuse_address: + self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self.socket.bind(self.server_address) Index: sre_comp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/sre_comp.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** sre_comp.py 2000/05/08 17:31:01 1.1 --- sre_comp.py 2000/06/29 19:35:29 1.2 *************** *** 1,5 **** # # Secret Labs' Regular Expression Engine - # $Id$ # # convert template to internal format --- 1,4 ---- *************** *** 7,23 **** # Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. # - # This code can only be used for 1.6 alpha testing. All other use - # require explicit permission from Secret Labs AB. - # # Portions of this engine have been developed in cooperation with # CNRI. Hewlett-Packard provided funding for 1.6 integration and # other compatibility work. # - - # FIXME: formalize (objectify?) and document the compiler code - # format, so that other frontends can use this compiler - - import array, string, sys import _sre --- 6,15 ---- # Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. # # Portions of this engine have been developed in cooperation with # CNRI. Hewlett-Packard provided funding for 1.6 integration and # other compatibility work. # + import array import _sre *************** *** 31,168 **** raise RuntimeError, "cannot find a useable array type" - # FIXME: should move some optimizations from the parser to here! - - class Code: - def __init__(self): - self.data = [] - def __len__(self): - return len(self.data) - def __getitem__(self, index): - return self.data[index] - def __setitem__(self, index, code): - self.data[index] = code - def append(self, code): - self.data.append(code) - def todata(self): - # print self.data - return array.array(WORDSIZE, self.data).tostring() - - def _lower(literal): - # return _sre._lower(literal) # FIXME - return string.lower(literal) - def _compile(code, pattern, flags): ! append = code.append for op, av in pattern: if op is ANY: ! if "s" in flags: ! append(CODES[op]) # any character at all! else: ! append(CODES[NOT_LITERAL]) ! append(10) elif op in (SUCCESS, FAILURE): ! append(CODES[op]) elif op is AT: ! append(CODES[op]) ! append(POSITIONS[av]) elif op is BRANCH: ! append(CODES[op]) tail = [] for av in av[1]: ! skip = len(code); append(0) _compile(code, av, flags) ! append(CODES[JUMP]) ! tail.append(len(code)); append(0) code[skip] = len(code) - skip ! append(0) # end of branch ! for tail in tail: code[tail] = len(code) - tail elif op is CALL: ! append(CODES[op]) ! skip = len(code); append(0) _compile(code, av, flags) ! append(CODES[SUCCESS]) code[skip] = len(code) - skip ! elif op is CATEGORY: # not used by current parser ! append(CODES[op]) ! append(CATEGORIES[av]) elif op is GROUP: ! if "i" in flags: ! append(CODES[MAP_IGNORE[op]]) else: ! append(CODES[op]) ! append(av) elif op is IN: ! if "i" in flags: ! append(CODES[MAP_IGNORE[op]]) ! def fixup(literal): ! return ord(_lower(literal)) else: ! append(CODES[op]) fixup = ord ! skip = len(code); append(0) for op, av in av: ! append(CODES[op]) if op is NEGATE: pass elif op is LITERAL: ! append(fixup(av)) elif op is RANGE: ! append(fixup(av[0])) ! append(fixup(av[1])) elif op is CATEGORY: ! append(CATEGORIES[av]) else: ! raise ValueError, "unsupported set operator" ! append(CODES[FAILURE]) code[skip] = len(code) - skip elif op in (LITERAL, NOT_LITERAL): ! if "i" in flags: ! append(CODES[MAP_IGNORE[op]]) ! append(ord(_lower(av))) else: ! append(CODES[op]) ! append(ord(av)) elif op is MARK: ! append(CODES[op]) ! append(av) elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): ! lo, hi = av[2].getwidth() ! if lo == 0: ! raise SyntaxError, "cannot repeat zero-width items" ! if lo == hi == 1 and op is MAX_REPEAT: ! append(CODES[MAX_REPEAT_ONE]) ! skip = len(code); append(0) ! append(av[0]) ! append(av[1]) _compile(code, av[2], flags) ! append(CODES[SUCCESS]) code[skip] = len(code) - skip else: ! append(CODES[op]) ! skip = len(code); append(0) ! append(av[0]) ! append(av[1]) ! _compile(code, av[2], flags) ! if op is MIN_REPEAT: ! append(CODES[MIN_UNTIL]) else: ! # FIXME: MAX_REPEAT PROBABLY DOESN'T WORK (?) ! append(CODES[MAX_UNTIL]) ! code[skip] = len(code) - skip elif op is SUBPATTERN: ! ## group = av[0] ! ## if group: ! ## append(CODES[MARK]) ! ## append((group-1)*2) _compile(code, av[1], flags) ! ## if group: ! ## append(CODES[MARK]) ! ## append((group-1)*2+1) else: raise ValueError, ("unsupported operand type", op) ! def compile(p, flags=()): ! # convert pattern list to internal format if type(p) in (type(""), type(u"")): import sre_parse --- 23,158 ---- raise RuntimeError, "cannot find a useable array type" def _compile(code, pattern, flags): ! emit = code.append for op, av in pattern: if op is ANY: ! if flags & SRE_FLAG_DOTALL: ! emit(OPCODES[op]) else: ! emit(OPCODES[CATEGORY]) ! emit(CHCODES[CATEGORY_NOT_LINEBREAK]) elif op in (SUCCESS, FAILURE): ! emit(OPCODES[op]) elif op is AT: ! emit(OPCODES[op]) ! if flags & SRE_FLAG_MULTILINE: ! emit(ATCODES[AT_MULTILINE[av]]) ! else: ! emit(ATCODES[av]) elif op is BRANCH: ! emit(OPCODES[op]) tail = [] for av in av[1]: ! skip = len(code); emit(0) _compile(code, av, flags) ! emit(OPCODES[JUMP]) ! tail.append(len(code)); emit(0) code[skip] = len(code) - skip ! emit(0) # end of branch ! for tail in tail: code[tail] = len(code) - tail elif op is CALL: ! emit(OPCODES[op]) ! skip = len(code); emit(0) _compile(code, av, flags) ! emit(OPCODES[SUCCESS]) code[skip] = len(code) - skip ! elif op is CATEGORY: ! emit(OPCODES[op]) ! if flags & SRE_FLAG_LOCALE: ! emit(CH_LOCALE[CHCODES[av]]) ! elif flags & SRE_FLAG_UNICODE: ! emit(CH_UNICODE[CHCODES[av]]) ! else: ! emit(CHCODES[av]) elif op is GROUP: ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) else: ! emit(OPCODES[op]) ! emit(av-1) elif op is IN: ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) ! def fixup(literal, flags=flags): ! return _sre.getlower(ord(literal), flags) else: ! emit(OPCODES[op]) fixup = ord ! skip = len(code); emit(0) for op, av in av: ! emit(OPCODES[op]) if op is NEGATE: pass elif op is LITERAL: ! emit(fixup(av)) elif op is RANGE: ! emit(fixup(av[0])) ! emit(fixup(av[1])) elif op is CATEGORY: ! if flags & SRE_FLAG_LOCALE: ! emit(CH_LOCALE[CHCODES[av]]) ! elif flags & SRE_FLAG_UNICODE: ! emit(CH_UNICODE[CHCODES[av]]) ! else: ! emit(CHCODES[av]) else: ! raise error, "internal: unsupported set operator" ! emit(OPCODES[FAILURE]) code[skip] = len(code) - skip elif op in (LITERAL, NOT_LITERAL): ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) else: ! emit(OPCODES[op]) ! emit(ord(av)) elif op is MARK: ! emit(OPCODES[op]) ! emit(av) elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): ! if flags & SRE_FLAG_TEMPLATE: ! emit(OPCODES[REPEAT]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) code[skip] = len(code) - skip else: ! lo, hi = av[2].getwidth() ! if lo == 0: ! raise error, "nothing to repeat" ! if 0 and lo == hi == 1 and op is MAX_REPEAT: ! # FIXME: need a better way to figure out when ! # it's safe to use this one (in the parser, probably) ! emit(OPCODES[MAX_REPEAT_ONE]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) ! _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip else: ! emit(OPCODES[op]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) ! _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip elif op is SUBPATTERN: ! group = av[0] ! if group: ! emit(OPCODES[MARK]) ! emit((group-1)*2) _compile(code, av[1], flags) ! if group: ! emit(OPCODES[MARK]) ! emit((group-1)*2+1) else: raise ValueError, ("unsupported operand type", op) ! def compile(p, flags=0): ! # internal: convert pattern list to internal format if type(p) in (type(""), type(u"")): import sre_parse *************** *** 171,187 **** else: pattern = None ! # print p.getwidth() ! # print p ! code = Code() ! _compile(code, p.data, p.pattern.flags) ! code.append(CODES[SUCCESS]) ! # print list(code.data) ! data = code.todata() ! if 0: # debugging ! print ! print "-" * 68 ! import sre_disasm ! sre_disasm.disasm(data) ! print "-" * 68 ! # print len(data), p.pattern.groups, len(p.pattern.groupdict) ! return _sre.compile(pattern, data, p.pattern.groups-1, p.pattern.groupdict) --- 161,174 ---- else: pattern = None ! flags = p.pattern.flags | flags ! code = [] ! _compile(code, p.data, flags) ! code.append(OPCODES[SUCCESS]) ! # FIXME: get rid of this limitation ! assert p.pattern.groups <= 100,\ ! "sorry, but this version only supports 100 named groups" ! return _sre.compile( ! pattern, flags, ! array.array(WORDSIZE, code).tostring(), ! p.pattern.groups-1, p.pattern.groupdict ! ) Index: sre_cons.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/sre_cons.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** sre_cons.py 2000/05/08 17:31:01 1.1 --- sre_cons.py 2000/06/29 19:35:29 1.2 *************** *** 1,5 **** # # Secret Labs' Regular Expression Engine - # $Id$ # # various symbols used by the regular expression engine. --- 1,4 ---- *************** *** 8,14 **** # Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. # - # This code can only be used for 1.6 alpha testing. All other use - # require explicit permission from Secret Labs AB. - # # Portions of this engine have been developed in cooperation with # CNRI. Hewlett-Packard provided funding for 1.6 integration and --- 7,10 ---- *************** *** 16,19 **** --- 12,20 ---- # + # should this really be here? + + class error(Exception): + pass + # operators *************** *** 31,34 **** --- 32,36 ---- IN = "in" IN_IGNORE = "in_ignore" + INFO = "info" JUMP = "jump" LITERAL = "literal" *************** *** 37,43 **** MAX_REPEAT = "max_repeat" MAX_REPEAT_ONE = "max_repeat_one" - MAX_UNTIL = "max_until" MIN_REPEAT = "min_repeat" - MIN_UNTIL = "min_until" NEGATE = "negate" NOT_LITERAL = "not_literal" --- 39,43 ---- *************** *** 45,58 **** RANGE = "range" REPEAT = "repeat" SUBPATTERN = "subpattern" # positions AT_BEGINNING = "at_beginning" AT_BOUNDARY = "at_boundary" AT_NON_BOUNDARY = "at_non_boundary" AT_END = "at_end" # categories - CATEGORY_DIGIT = "category_digit" CATEGORY_NOT_DIGIT = "category_not_digit" --- 45,60 ---- RANGE = "range" REPEAT = "repeat" + REPEAT_ONE = "repeat_one" SUBPATTERN = "subpattern" # positions AT_BEGINNING = "at_beginning" + AT_BEGINNING_LINE = "at_beginning_line" AT_BOUNDARY = "at_boundary" AT_NON_BOUNDARY = "at_non_boundary" AT_END = "at_end" + AT_END_LINE = "at_end_line" # categories CATEGORY_DIGIT = "category_digit" CATEGORY_NOT_DIGIT = "category_not_digit" *************** *** 61,66 **** CATEGORY_WORD = "category_word" CATEGORY_NOT_WORD = "category_not_word" ! CODES = [ # failure=0 success=1 (just because it looks better that way :-) --- 63,80 ---- CATEGORY_WORD = "category_word" CATEGORY_NOT_WORD = "category_not_word" + CATEGORY_LINEBREAK = "category_linebreak" + CATEGORY_NOT_LINEBREAK = "category_not_linebreak" + CATEGORY_LOC_WORD = "category_loc_word" + CATEGORY_LOC_NOT_WORD = "category_loc_not_word" + CATEGORY_UNI_DIGIT = "category_uni_digit" + CATEGORY_UNI_NOT_DIGIT = "category_uni_not_digit" + CATEGORY_UNI_SPACE = "category_uni_space" + CATEGORY_UNI_NOT_SPACE = "category_uni_not_space" + CATEGORY_UNI_WORD = "category_uni_word" + CATEGORY_UNI_NOT_WORD = "category_uni_not_word" + CATEGORY_UNI_LINEBREAK = "category_uni_linebreak" + CATEGORY_UNI_NOT_LINEBREAK = "category_uni_not_linebreak" ! OPCODES = [ # failure=0 success=1 (just because it looks better that way :-) *************** *** 75,84 **** GROUP, GROUP_IGNORE, IN, IN_IGNORE, JUMP, LITERAL, LITERAL_IGNORE, MARK, ! MAX_REPEAT, MAX_UNTIL, MAX_REPEAT_ONE, ! MIN_REPEAT, MIN_UNTIL, NOT_LITERAL, NOT_LITERAL_IGNORE, NEGATE, --- 89,99 ---- GROUP, GROUP_IGNORE, IN, IN_IGNORE, + INFO, JUMP, LITERAL, LITERAL_IGNORE, MARK, ! MAX_REPEAT, MAX_REPEAT_ONE, ! MIN_REPEAT, NOT_LITERAL, NOT_LITERAL_IGNORE, NEGATE, *************** *** 88,101 **** ] ! # convert to dictionary ! c = {} ! i = 0 ! for code in CODES: ! c[code] = i ! i = i + 1 ! CODES = c # replacement operations for "ignore case" mode ! MAP_IGNORE = { GROUP: GROUP_IGNORE, IN: IN_IGNORE, --- 103,135 ---- ] ! ATCODES = [ ! AT_BEGINNING, AT_BEGINNING_LINE, AT_BOUNDARY, ! AT_NON_BOUNDARY, AT_END, AT_END_LINE ! ] + CHCODES = [ + CATEGORY_DIGIT, CATEGORY_NOT_DIGIT, CATEGORY_SPACE, + CATEGORY_NOT_SPACE, CATEGORY_WORD, CATEGORY_NOT_WORD, + CATEGORY_LINEBREAK, CATEGORY_NOT_LINEBREAK, CATEGORY_LOC_WORD, + CATEGORY_LOC_NOT_WORD, CATEGORY_UNI_DIGIT, CATEGORY_UNI_NOT_DIGIT, + CATEGORY_UNI_SPACE, CATEGORY_UNI_NOT_SPACE, CATEGORY_UNI_WORD, + CATEGORY_UNI_NOT_WORD, CATEGORY_UNI_LINEBREAK, + CATEGORY_UNI_NOT_LINEBREAK + ] + + def makedict(list): + d = {} + i = 0 + for item in list: + d[item] = i + i = i + 1 + return d + + OPCODES = makedict(OPCODES) + ATCODES = makedict(ATCODES) + CHCODES = makedict(CHCODES) + # replacement operations for "ignore case" mode ! OP_IGNORE = { GROUP: GROUP_IGNORE, IN: IN_IGNORE, *************** *** 104,131 **** } ! POSITIONS = { ! AT_BEGINNING: ord("a"), ! AT_BOUNDARY: ord("b"), ! AT_NON_BOUNDARY: ord("B"), ! AT_END: ord("z"), } ! CATEGORIES = { ! CATEGORY_DIGIT: ord("d"), ! CATEGORY_NOT_DIGIT: ord("D"), ! CATEGORY_SPACE: ord("s"), ! CATEGORY_NOT_SPACE: ord("S"), ! CATEGORY_WORD: ord("w"), ! CATEGORY_NOT_WORD: ord("W"), } if __name__ == "__main__": import string ! items = CODES.items() ! items.sort(lambda a, b: cmp(a[1], b[1])) f = open("sre_constants.h", "w") ! f.write("/* generated by sre_constants.py */\n") ! for k, v in items: ! f.write("#define SRE_OP_" + string.upper(k) + " " + str(v) + "\n") f.close() print "done" --- 138,196 ---- } ! AT_MULTILINE = { ! AT_BEGINNING: AT_BEGINNING_LINE, ! AT_END: AT_END_LINE } ! CH_LOCALE = { ! CATEGORY_DIGIT: CATEGORY_DIGIT, ! CATEGORY_NOT_DIGIT: CATEGORY_NOT_DIGIT, ! CATEGORY_SPACE: CATEGORY_SPACE, ! CATEGORY_NOT_SPACE: CATEGORY_NOT_SPACE, ! CATEGORY_WORD: CATEGORY_LOC_WORD, ! CATEGORY_NOT_WORD: CATEGORY_LOC_NOT_WORD, ! CATEGORY_LINEBREAK: CATEGORY_LINEBREAK, ! CATEGORY_NOT_LINEBREAK: CATEGORY_NOT_LINEBREAK } + CH_UNICODE = { + CATEGORY_DIGIT: CATEGORY_UNI_DIGIT, + CATEGORY_NOT_DIGIT: CATEGORY_UNI_NOT_DIGIT, + CATEGORY_SPACE: CATEGORY_UNI_SPACE, + CATEGORY_NOT_SPACE: CATEGORY_UNI_NOT_SPACE, + CATEGORY_WORD: CATEGORY_UNI_WORD, + CATEGORY_NOT_WORD: CATEGORY_UNI_NOT_WORD, + CATEGORY_LINEBREAK: CATEGORY_UNI_LINEBREAK, + CATEGORY_NOT_LINEBREAK: CATEGORY_UNI_NOT_LINEBREAK + } + + # flags + SRE_FLAG_TEMPLATE = 1 + SRE_FLAG_IGNORECASE = 2 + SRE_FLAG_LOCALE = 4 + SRE_FLAG_MULTILINE = 8 + SRE_FLAG_DOTALL = 16 + SRE_FLAG_UNICODE = 32 + SRE_FLAG_VERBOSE = 64 + if __name__ == "__main__": import string ! def dump(f, d, prefix): ! items = d.items() ! items.sort(lambda a, b: cmp(a[1], b[1])) ! for k, v in items: ! f.write("#define %s_%s %s\n" % (prefix, string.upper(k), v)) f = open("sre_constants.h", "w") ! f.write("/* generated from sre_constants.py */\n") ! dump(f, OPCODES, "SRE_OP") ! dump(f, ATCODES, "SRE") ! dump(f, CHCODES, "SRE") ! f.write("#define SRE_FLAG_TEMPLATE %d\n" % SRE_FLAG_TEMPLATE) ! f.write("#define SRE_FLAG_IGNORECASE %d\n" % SRE_FLAG_IGNORECASE) ! f.write("#define SRE_FLAG_LOCALE %d\n" % SRE_FLAG_LOCALE) ! f.write("#define SRE_FLAG_MULTILINE %d\n" % SRE_FLAG_MULTILINE) ! f.write("#define SRE_FLAG_DOTALL %d\n" % SRE_FLAG_DOTALL) ! f.write("#define SRE_FLAG_UNICODE %d\n" % SRE_FLAG_UNICODE) ! f.write("#define SRE_FLAG_VERBOSE %d\n" % SRE_FLAG_VERBOSE) f.close() print "done" Index: sre_pars.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/sre_pars.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** sre_pars.py 2000/05/08 17:31:01 1.1 --- sre_pars.py 2000/06/29 19:35:29 1.2 *************** *** 1,15 **** # # Secret Labs' Regular Expression Engine - # $Id$ # ! # convert re-style regular expression to SRE template. the current ! # implementation is somewhat incomplete, and not very fast. should ! # definitely be rewritten before Python 1.6 goes beta. # # Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. # - # This code can only be used for 1.6 alpha testing. All other use - # require explicit permission from Secret Labs AB. - # # Portions of this engine have been developed in cooperation with # CNRI. Hewlett-Packard provided funding for 1.6 integration and --- 1,9 ---- # # Secret Labs' Regular Expression Engine # ! # convert re-style regular expression to sre pattern # # Copyright (c) 1998-2000 by Secret Labs AB. All rights reserved. # # Portions of this engine have been developed in cooperation with # CNRI. Hewlett-Packard provided funding for 1.6 integration and *************** *** 17,31 **** # - # FIXME: comments marked with the FIXME tag are open issues. all such - # issues should be closed before the final beta. - import string, sys from sre_constants import * SPECIAL_CHARS = ".\\[{()*+?^$|" REPEAT_CHARS = "*+?{" - # FIXME: string in tuple tests may explode with if char is unicode :-( DIGITS = tuple(string.digits) --- 11,26 ---- # import string, sys + import _sre + from sre_constants import * + # FIXME: should be 65535, but the arraymodule is still broken + MAXREPEAT = 32767 + SPECIAL_CHARS = ".\\[{()*+?^$|" REPEAT_CHARS = "*+?{" DIGITS = tuple(string.digits) *************** *** 33,36 **** --- 28,33 ---- HEXDIGITS = tuple("0123456789abcdefABCDEF") + WHITESPACE = string.whitespace + ESCAPES = { "\\a": (LITERAL, chr(7)), *************** *** 55,63 **** "\\Z": (AT, AT_END), # end of string } ! class Pattern: ! # FIXME: rename class, and store flags in here too! def __init__(self): ! self.flags = [] self.groups = 1 self.groupdict = {} --- 52,71 ---- "\\Z": (AT, AT_END), # end of string } + + FLAGS = { + # standard flags + "i": SRE_FLAG_IGNORECASE, + "L": SRE_FLAG_LOCALE, + "m": SRE_FLAG_MULTILINE, + "s": SRE_FLAG_DOTALL, + "x": SRE_FLAG_VERBOSE, + # extensions + "t": SRE_FLAG_TEMPLATE, + "u": SRE_FLAG_UNICODE, + } ! class State: def __init__(self): ! self.flags = 0 self.groups = 1 self.groupdict = {} *************** *** 68,74 **** self.groupdict[name] = gid return gid - def setflag(self, flag): - if flag in self.flags: - self.flags.append(flag) class SubPattern: --- 76,79 ---- *************** *** 79,83 **** data = [] self.data = data - self.flags = [] self.width = None def __repr__(self): --- 84,87 ---- *************** *** 122,127 **** elif op in (MIN_REPEAT, MAX_REPEAT): i, j = av[2].getwidth() ! lo = lo + i * av[0] ! hi = hi + j * av[1] elif op in (ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY): lo = lo + 1 --- 126,131 ---- elif op in (MIN_REPEAT, MAX_REPEAT): i, j = av[2].getwidth() ! lo = lo + long(i) * av[0] ! hi = hi + long(j) * av[1] elif op in (ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY): lo = lo + 1 *************** *** 131,175 **** self.width = int(min(lo, sys.maxint)), int(min(hi, sys.maxint)) return self.width - def set(self, flag): - if not flag in self.flags: - self.flags.append(flag) - def reset(self, flag): - if flag in self.flags: - self.flags.remove(flag) class Tokenizer: def __init__(self, string): ! self.string = list(string) self.next = self.__next() def __next(self): ! if not self.string: return None ! char = self.string[0] if char[0] == "\\": try: ! c = self.string[1] except IndexError: ! raise SyntaxError, "bogus escape" char = char + c ! try: ! if c == "x": ! # hexadecimal constant ! for i in xrange(2, sys.maxint): ! c = self.string[i] ! if str(c) not in HEXDIGITS: ! break ! char = char + c ! elif str(c) in DIGITS: ! # decimal (or octal) number ! for i in xrange(2, sys.maxint): ! c = self.string[i] ! # FIXME: if larger than current number of ! # groups, interpret as an octal number ! if str(c) not in DIGITS: ! break ! char = char + c ! except IndexError: ! pass # use what we've got this far ! del self.string[0:len(char)] return char def match(self, char): --- 135,155 ---- self.width = int(min(lo, sys.maxint)), int(min(hi, sys.maxint)) return self.width class Tokenizer: def __init__(self, string): ! self.index = 0 ! self.string = string self.next = self.__next() def __next(self): ! if self.index >= len(self.string): return None ! char = self.string[self.index] if char[0] == "\\": try: ! c = self.string[self.index + 1] except IndexError: ! raise error, "bogus escape" char = char + c ! self.index = self.index + len(char) return char def match(self, char): *************** *** 188,230 **** return this ! def _fixescape(escape, character_class=0): ! # convert escape to (type, value) ! if character_class: ! # inside a character class, we'll look in the character ! # escapes dictionary first ! code = ESCAPES.get(escape) ! if code: ! return code ! code = CATEGORIES.get(escape) ! else: ! code = CATEGORIES.get(escape) ! if code: ! return code ! code = ESCAPES.get(escape) if code: return code ! if not character_class: ! try: ! group = int(escape[1:]) ! # FIXME: only valid if group <= current number of groups ! return GROUP, group ! except ValueError: ! pass try: if escape[1:2] == "x": escape = escape[2:] ! return LITERAL, chr(int(escape[-2:], 16) & 0xff) ! elif str(escape[1:2]) in DIGITS: ! return LITERAL, chr(int(escape[1:], 8) & 0xff) ! elif len(escape) == 2: return LITERAL, escape[1] except ValueError: pass ! raise SyntaxError, "bogus escape: %s" % repr(escape) ! def _branch(subpattern, items): ! # form a branch operator from a set of items (FIXME: move this ! # optimization to the compiler module!) # check if all items share a common prefix --- 168,268 ---- return this ! def isident(char): ! return "a" <= char <= "z" or "A" <= char <= "Z" or char == "_" ! ! def isdigit(char): ! return "0" <= char <= "9" ! ! def isname(name): ! # check that group name is a valid string ! # FIXME: this code is really lame. should use a regular ! # expression instead, but I seem to have certain bootstrapping ! # problems here ;-) ! if not isident(name[0]): ! return 0 ! for char in name: ! if not isident(char) and not isdigit(char): ! return 0 ! return 1 ! ! def _group(escape, state): ! # check if the escape string represents a valid group ! try: ! group = int(escape[1:]) ! if group and group < state.groups: ! return group ! except ValueError: ! pass ! return None # not a valid group ! ! def _class_escape(source, escape): ! # handle escape code inside character class ! code = ESCAPES.get(escape) if code: return code ! code = CATEGORIES.get(escape) ! if code: ! return code try: if escape[1:2] == "x": + while source.next in HEXDIGITS: + escape = escape + source.get() escape = escape[2:] ! # FIXME: support unicode characters! ! return LITERAL, chr(int(escape[-4:], 16) & 0xff) ! elif str(escape[1:2]) in OCTDIGITS: ! while source.next in OCTDIGITS: ! escape = escape + source.get() ! escape = escape[1:] ! # FIXME: support unicode characters! ! return LITERAL, chr(int(escape[-6:], 8) & 0xff) ! if len(escape) == 2: return LITERAL, escape[1] except ValueError: pass ! raise error, "bogus escape: %s" % repr(escape) ! def _escape(source, escape, state): ! # handle escape code in expression ! code = CATEGORIES.get(escape) ! if code: ! return code ! code = ESCAPES.get(escape) ! if code: ! return code ! try: ! if escape[1:2] == "x": ! while source.next in HEXDIGITS: ! escape = escape + source.get() ! escape = escape[2:] ! # FIXME: support unicode characters! ! return LITERAL, chr(int(escape[-4:], 16) & 0xff) ! elif escape[1:2] in DIGITS: ! while 1: ! group = _group(escape, state) ! if group: ! if (not source.next or ! not _group(escape + source.next, state)): ! return GROUP, group ! escape = escape + source.get() ! elif source.next in OCTDIGITS: ! escape = escape + source.get() ! else: ! break ! escape = escape[1:] ! # FIXME: support unicode characters! ! return LITERAL, chr(int(escape[-6:], 8) & 0xff) ! if len(escape) == 2: ! return LITERAL, escape[1] ! except ValueError: ! pass ! raise error, "bogus escape: %s" % repr(escape) ! ! def _branch(pattern, items): ! ! # form a branch operator from a set of items ! ! subpattern = SubPattern(pattern) # check if all items share a common prefix *************** *** 258,276 **** set.append(item[0]) subpattern.append((IN, set)) ! return subpattern.append((BRANCH, (None, items))) ! def _parse(source, pattern, flags=()): # parse regular expression pattern into an operator list. - - subpattern = SubPattern(pattern) ! this = None while 1: ! if str(source.next) in ("|", ")"): break # end of subpattern this = source.get() --- 296,313 ---- set.append(item[0]) subpattern.append((IN, set)) ! return subpattern subpattern.append((BRANCH, (None, items))) + return subpattern ! def _parse(source, state, flags=0): # parse regular expression pattern into an operator list. ! subpattern = SubPattern(state) while 1: ! if source.next in ("|", ")"): break # end of subpattern this = source.get() *************** *** 278,281 **** --- 315,329 ---- break # end of pattern + if state.flags & SRE_FLAG_VERBOSE: + # skip whitespace and comments + if this in WHITESPACE: + continue + if this == "#": + while 1: + this = source.get() + if this in (None, "\n"): + break + continue + if this and this[0] not in SPECIAL_CHARS: subpattern.append((LITERAL, this)) *************** *** 295,303 **** break elif this and this[0] == "\\": ! code1 = _fixescape(this, 1) elif this: code1 = LITERAL, this else: ! raise SyntaxError, "unexpected end of regular expression" if source.match("-"): # potential range --- 343,351 ---- break elif this and this[0] == "\\": ! code1 = _class_escape(source, this) elif this: code1 = LITERAL, this else: ! raise error, "unexpected end of regular expression" if source.match("-"): # potential range *************** *** 309,319 **** else: if this[0] == "\\": ! code2 = _fixescape(this, 1) else: code2 = LITERAL, this if code1[0] != LITERAL or code2[0] != LITERAL: ! raise SyntaxError, "illegal range" if len(code1[1]) != 1 or len(code2[1]) != 1: ! raise SyntaxError, "illegal range" set.append((RANGE, (code1[1], code2[1]))) else: --- 357,367 ---- else: if this[0] == "\\": ! code2 = _class_escape(source, this) else: code2 = LITERAL, this if code1[0] != LITERAL or code2[0] != LITERAL: ! raise error, "illegal range" if len(code1[1]) != 1 or len(code2[1]) != 1: ! raise error, "illegal range" set.append((RANGE, (code1[1], code2[1]))) else: *************** *** 322,326 **** set.append(code1) ! # FIXME: move set optimization to support function if len(set)==1 and set[0][0] is LITERAL: subpattern.append(set[0]) # optimization --- 370,374 ---- set.append(code1) ! # FIXME: move set optimization to compiler! if len(set)==1 and set[0][0] is LITERAL: subpattern.append(set[0]) # optimization *************** *** 336,354 **** min, max = 0, 1 elif this == "*": ! min, max = 0, sys.maxint elif this == "+": ! min, max = 1, sys.maxint elif this == "{": ! min, max = 0, sys.maxint lo = hi = "" ! while str(source.next) in DIGITS: lo = lo + source.get() if source.match(","): ! while str(source.next) in DIGITS: hi = hi + source.get() else: hi = lo if not source.match("}"): ! raise SyntaxError, "bogus range" if lo: min = int(lo) --- 384,402 ---- min, max = 0, 1 elif this == "*": ! min, max = 0, MAXREPEAT elif this == "+": ! min, max = 1, MAXREPEAT elif this == "{": ! min, max = 0, MAXREPEAT lo = hi = "" ! while source.next in DIGITS: lo = lo + source.get() if source.match(","): ! while source.next in DIGITS: hi = hi + source.get() else: hi = lo if not source.match("}"): ! raise error, "bogus range" if lo: min = int(lo) *************** *** 357,376 **** # FIXME: check that hi >= lo! else: ! raise SyntaxError, "not supported" # figure out which item to repeat - # FIXME: should back up to the right mark, right? if subpattern: ! index = len(subpattern)-1 ! while subpattern[index][0] is MARK: ! index = index - 1 ! item = subpattern[index:index+1] else: ! raise SyntaxError, "nothing to repeat" if source.match("?"): ! subpattern[index] = (MIN_REPEAT, (min, max, item)) else: ! subpattern[index] = (MAX_REPEAT, (min, max, item)) elif this == ".": subpattern.append((ANY, None)) elif this == "(": group = 1 --- 405,422 ---- # FIXME: check that hi >= lo! else: ! raise error, "not supported" # figure out which item to repeat if subpattern: ! item = subpattern[-1:] else: ! raise error, "nothing to repeat" if source.match("?"): ! subpattern[-1] = (MIN_REPEAT, (min, max, item)) else: ! subpattern[-1] = (MAX_REPEAT, (min, max, item)) ! elif this == ".": subpattern.append((ANY, None)) + elif this == "(": group = 1 *************** *** 380,405 **** # options if source.match("P"): ! # named group: skip forward to end of name if source.match("<"): name = "" while 1: char = source.get() ! if char is None or char == ">": break name = name + char group = 1 elif source.match(":"): # non-capturing group group = 2 ! elif source.match_set("iI"): ! pattern.setflag("i") ! elif source.match_set("lL"): ! pattern.setflag("l") ! elif source.match_set("mM"): ! pattern.setflag("m") ! elif source.match_set("sS"): ! pattern.setflag("s") ! elif source.match_set("xX"): ! pattern.setflag("x") if group: # parse group contents --- 426,464 ---- # options if source.match("P"): ! # python extensions if source.match("<"): + # named group: skip forward to end of name name = "" while 1: char = source.get() ! if char is None: ! raise error, "unterminated name" ! if char == ">": break name = name + char group = 1 + if not isname(name): + raise error, "illegal character in group name" + elif source.match("="): + # named backreference + raise error, "not yet implemented" + else: + char = source.get() + if char is None: + raise error, "unexpected end of pattern" + raise error, "unknown specifier: ?P%s" % char elif source.match(":"): # non-capturing group group = 2 ! elif source.match("#"): ! # comment ! while 1: ! if source.next is None or source.next == ")": ! break ! source.get() ! else: ! # flags ! while FLAGS.has_key(source.next): ! state.flags = state.flags | FLAGS[source.get()] if group: # parse group contents *************** *** 409,436 **** group = None else: ! group = pattern.getgroup(name) ! if group: ! subpattern.append((MARK, (group-1)*2)) while 1: ! p = _parse(source, pattern, flags) if source.match(")"): if b: b.append(p) ! _branch(subpattern, b) ! else: ! subpattern.append((SUBPATTERN, (group, p))) break elif source.match("|"): b.append(p) else: ! raise SyntaxError, "group not properly closed" ! if group: ! subpattern.append((MARK, (group-1)*2+1)) else: - # FIXME: should this really be a while loop? while 1: char = source.get() if char is None or char == ")": break elif this == "^": --- 468,490 ---- group = None else: ! group = state.getgroup(name) while 1: ! p = _parse(source, state, flags) if source.match(")"): if b: b.append(p) ! p = _branch(state, b) ! subpattern.append((SUBPATTERN, (group, p))) break elif source.match("|"): b.append(p) else: ! raise error, "group not properly closed" else: while 1: char = source.get() if char is None or char == ")": break + raise error, "unknown extension" elif this == "^": *************** *** 441,497 **** elif this and this[0] == "\\": ! code =_fixescape(this) subpattern.append(code) else: ! raise SyntaxError, "parser error" return subpattern ! def parse(source, flags=()): ! s = Tokenizer(source) ! g = Pattern() b = [] while 1: ! p = _parse(s, g, flags) ! tail = s.get() if tail == "|": b.append(p) elif tail == ")": ! raise SyntaxError, "unbalanced parenthesis" elif tail is None: if b: b.append(p) ! p = SubPattern(g) ! _branch(p, b) break else: ! raise SyntaxError, "bogus characters at end of regular expression" return p ! if __name__ == "__main__": ! from pprint import pprint ! from testpatterns import PATTERNS ! a = b = c = 0 ! for pattern, flags in PATTERNS: ! if flags: ! continue ! print "-"*68 ! try: ! p = parse(pattern) ! print repr(pattern), "->" ! pprint(p.data) ! import sre_compile ! try: ! code = sre_compile.compile(p) ! c = c + 1 ! except: ! pass ! a = a + 1 ! except SyntaxError, v: ! print "**", repr(pattern), v ! b = b + 1 ! print "-"*68 ! print a, "of", b, "patterns successfully parsed" ! print c, "of", b, "patterns successfully compiled" --- 495,586 ---- elif this and this[0] == "\\": ! code = _escape(source, this, state) subpattern.append(code) else: ! raise error, "parser error" return subpattern ! def parse(pattern, flags=0): ! # parse 're' pattern into list of (opcode, argument) tuples ! source = Tokenizer(pattern) ! state = State() b = [] while 1: ! p = _parse(source, state, flags) ! tail = source.get() if tail == "|": b.append(p) elif tail == ")": ! raise error, "unbalanced parenthesis" elif tail is None: if b: b.append(p) ! p = _branch(state, b) break else: ! raise error, "bogus characters at end of regular expression" return p ! def parse_template(source, pattern): ! # parse 're' replacement string into list of literals and ! # group references ! s = Tokenizer(source) ! p = [] ! a = p.append ! while 1: ! this = s.get() ! if this is None: ! break # end of replacement string ! if this and this[0] == "\\": ! if this == "\\g": ! name = "" ! if s.match("<"): ! while 1: ! char = s.get() ! if char is None: ! raise error, "unterminated group name" ! if char == ">": ! break ! name = name + char ! if not name: ! raise error, "bad group name" ! try: ! index = int(name) ! except ValueError: ! if not isname(name): ! raise error, "illegal character in group name" ! try: ! index = pattern.groupindex[name] ! except KeyError: ! raise IndexError, "unknown group name" ! a((MARK, index)) ! elif len(this) > 1 and this[1] in DIGITS: ! while s.next in DIGITS: ! this = this + s.get() ! a((MARK, int(this[1:]))) ! else: ! try: ! a(ESCAPES[this]) ! except KeyError: ! for char in this: ! a((LITERAL, char)) ! else: ! a((LITERAL, this)) ! return p + def expand_template(template, match): + # FIXME: this is sooooo slow. drop in the slicelist + # code instead + p = [] + a = p.append + for c, s in template: + if c is LITERAL: + a(s) + elif c is MARK: + s = match.group(s) + if s is None: + raise error, "empty group" + a(s) + return match.string[:0].join(p) Index: test_arr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/test_arr.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** test_arr.py 1998/08/12 02:38:01 1.6 --- test_arr.py 2000/06/29 19:35:29 1.7 *************** *** 16,19 **** --- 16,57 ---- + def testoverflow(type, lowerLimit, upperLimit): + # should not overflow assigning lower limit + if verbose: + print "overflow test: array(%s, [%s])" % (`type`, `lowerLimit`) + try: + a = array.array(type, [lowerLimit]) + except: + raise TestFailed, "array(%s) overflowed assigning %s" %\ + (`type`, `lowerLimit`) + # should overflow assigning less than lower limit + if verbose: + print "overflow test: array(%s, [%s])" % (`type`, `lowerLimit-1`) + try: + a = array.array(type, [lowerLimit-1]) + raise TestFailed, "array(%s) did not overflow assigning %s" %\ + (`type`, `lowerLimit-1`) + except OverflowError: + pass + # should not overflow assigning upper limit + if verbose: + print "overflow test: array(%s, [%s])" % (`type`, `upperLimit`) + try: + a = array.array(type, [upperLimit]) + except: + raise TestFailed, "array(%s) overflowed assigning %s" %\ + (`type`, `upperLimit`) + # should overflow assigning more than upper limit + if verbose: + print "overflow test: array(%s, [%s])" % (`type`, `upperLimit+1`) + try: + a = array.array(type, [upperLimit+1]) + raise TestFailed, "array(%s) did not overflow assigning %s" %\ + (`type`, `upperLimit+1`) + except OverflowError: + pass + + + def testtype(type, example): *************** *** 82,86 **** raise TestFailed, "array(%s) self-slice-assign (cntr)" % `type` ! main() ! --- 120,138 ---- raise TestFailed, "array(%s) self-slice-assign (cntr)" % `type` ! # test that overflow exceptions are raised as expected for assignment ! # to array of specific integral types ! from math import pow ! if type in ('b', 'h', 'i', 'l'): ! # check signed and unsigned versions ! a = array.array(type) ! signedLowerLimit = -1 * long(pow(2, a.itemsize * 8 - 1)) ! signedUpperLimit = long(pow(2, a.itemsize * 8 - 1)) - 1L ! unsignedLowerLimit = 0 ! unsignedUpperLimit = long(pow(2, a.itemsize * 8)) - 1L ! testoverflow(type, signedLowerLimit, signedUpperLimit) ! testoverflow(type.upper(), unsignedLowerLimit, unsignedUpperLimit) ! ! ! main() ! Index: test_bin.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/test_bin.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** test_bin.py 2000/05/08 17:31:02 1.3 --- test_bin.py 2000/06/29 19:35:29 1.4 *************** *** 1,93 **** ! """Test the binascii C module.""" from test_support import verbose - import binascii ! # Show module doc string ! print binascii.__doc__ ! # Show module exceptions ! print binascii.Error ! print binascii.Incomplete ! ! # Check presence and display doc strings of all functions ! funcs = [] ! for suffix in "base64", "hqx", "uu": ! prefixes = ["a2b_", "b2a_"] ! if suffix == "hqx": ! prefixes.extend(["crc_", "rlecode_", "rledecode_"]) ! for prefix in prefixes: ! name = prefix + suffix ! funcs.append(getattr(binascii, name)) ! for func in funcs: ! print "%-15s: %s" % (func.__name__, func.__doc__) ! ! # Create binary test data ! testdata = "The quick brown fox jumps over the lazy dog.\r\n" ! for i in range(256): ! # Be slow so we don't depend on other modules ! testdata = testdata + chr(i) ! testdata = testdata + "\r\nHello world.\n" ! ! # Test base64 with valid data ! print "base64 test" ! MAX_BASE64 = 57 ! lines = [] ! for i in range(0, len(testdata), MAX_BASE64): ! b = testdata[i:i+MAX_BASE64] ! a = binascii.b2a_base64(b) ! lines.append(a) ! print a, ! res = "" ! for line in lines: ! b = binascii.a2b_base64(line) ! res = res + b ! assert res == testdata ! ! # Test base64 with random invalid characters sprinkled throughout ! # (This requires a new version of binascii.) ! fillers = "" ! valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/" ! for i in range(256): ! c = chr(i) ! if c not in valid: ! fillers = fillers + c ! def addnoise(line): ! noise = fillers ! ratio = len(line) / len(noise) ! res = "" ! while line and noise: ! if len(line) / len(noise) > ratio: ! c, line = line[0], line[1:] ! else: ! c, noise = noise[0], noise[1:] ! res = res + c ! return res + noise + line ! res = "" ! for line in map(addnoise, lines): ! b = binascii.a2b_base64(line) ! res = res + b ! assert res == testdata ! ! # Test uu ! print "uu test" ! MAX_UU = 45 ! lines = [] ! for i in range(0, len(testdata), MAX_UU): ! b = testdata[i:i+MAX_UU] ! a = binascii.b2a_uu(b) ! lines.append(a) ! print a, ! res = "" ! for line in lines: ! b = binascii.a2b_uu(line) ! res = res + b ! assert res == testdata ! ! # Test crc32() ! crc = binascii.crc32("Test the CRC-32 of") ! crc = binascii.crc32(" this string.", crc) ! if crc != 1571220330: ! print "binascii.crc32() failed." ! ! # The hqx test is in test_binhex.py --- 1,46 ---- ! #! /usr/bin/env python ! """Test script for the binhex C module + Uses the mechanism of the python binhex module + Roger E. Masse + """ + import binhex + import tempfile from test_support import verbose ! def test(): ! try: ! fname1 = tempfile.mktemp() ! fname2 = tempfile.mktemp() ! f = open(fname1, 'w') ! except: ! raise ImportError, "Cannot test binhex without a temp file" ! ! start = 'Jack is my hero' ! f.write(start) ! f.close() ! ! binhex.binhex(fname1, fname2) ! if verbose: ! print 'binhex' ! ! binhex.hexbin(fname2, fname1) ! if verbose: ! print 'hexbin' ! ! f = open(fname1, 'r') ! finish = f.readline() ! ! if start <> finish: ! print 'Error: binhex <> hexbin' ! elif verbose: ! print 'binhex == hexbin' ! ! try: ! import os ! os.unlink(fname1) ! os.unlink(fname2) ! except: ! pass ! test() Index: test_exc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/test_exc.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** test_exc.py 1998/03/26 22:13:49 1.3 --- test_exc.py 2000/06/29 19:35:29 1.4 *************** *** 7,11 **** --- 7,23 ---- # XXX This is not really enough, each *operation* should be tested! + def test_raise_catch(exc): + try: + raise exc, "spam" + except exc, err: + buf = str(err) + try: + raise exc("spam") + except exc, err: + buf = str(err) + print buf + def r(thing): + test_raise_catch(thing) if type(thing) == ClassType: print thing.__name__ *************** *** 94,97 **** --- 106,113 ---- try: x = 1/0 except ZeroDivisionError: pass + + r(Exception) + try: x = 1/0 + except Exception, e: pass unlink(TESTFN) Index: test_mat.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/test_mat.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** test_mat.py 1996/09/11 19:07:43 1.2 --- test_mat.py 2000/06/29 19:35:29 1.3 *************** *** 130,133 **** --- 130,145 ---- testit('pow(2,-1)', math.pow(2,-1), 0.5) + print 'rint' + try: + math.rint + except AttributeError: + # this platform does not have rint, that is fine, skip the test + pass + else: + testit('rint(0.7)', math.rint(0.7), 1) + testit('rint(-0.3)', math.rint(-0.3), 0) + testit('rint(2.5)', math.rint(2.5), 2) + testit('rint(3.5)', math.rint(3.5), 4) + print 'sin' testit('sin(0)', math.sin(0), 0) Index: test_mma.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/test_mma.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** test_mma.py 2000/05/08 17:31:03 1.1 --- test_mma.py 2000/06/29 19:35:29 1.2 *************** *** 59,63 **** assert start == PAGESIZE assert end == PAGESIZE + 6 ! m.close() os.unlink("foo") --- 59,98 ---- assert start == PAGESIZE assert end == PAGESIZE + 6 ! ! # test seeking around (try to overflow the seek implementation) ! m.seek(0,0) ! print ' Seek to zeroth byte' ! assert m.tell() == 0 ! m.seek(42,1) ! print ' Seek to 42nd byte' ! assert m.tell() == 42 ! m.seek(0,2) ! print ' Seek to last byte' ! assert m.tell() == len(m) ! ! print ' Try to seek to negative position...' ! try: ! m.seek(-1) ! except ValueError: ! pass ! else: ! assert 0, 'expected a ValueError but did not get it' ! ! print ' Try to seek beyond end of mmap...' ! try: ! m.seek(1,2) ! except ValueError: ! pass ! else: ! assert 0, 'expected a ValueError but did not get it' ! ! print ' Try to seek to negative position...' ! try: ! m.seek(-len(m)-1,2) ! except ValueError: ! pass ! else: ! assert 0, 'expected a ValueError but did not get it' ! m.close() os.unlink("foo") Index: test_ope.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/test_ope.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** test_ope.py 1997/05/22 20:47:55 1.3 --- test_ope.py 2000/06/29 19:35:29 1.4 *************** *** 1,5 **** ! # Python test set -- part 3, built-in operations. ! print '3. Operations' ! print 'XXX Not yet implemented' --- 1,77 ---- ! import operator ! import sys + def test(name, input, output, *args): + print 'testing:', name + f = getattr(operator, name) + params = (input,) + args + try: + val = apply(f, params) + except: + val = sys.exc_type + if val <> output: + print '%s%s = %s: %s expected' % (f.__name__, params, `val`, `output`) ! test('abs', -1, 1) ! test('add', 3, 7, 4) ! test('and_', 0xf, 0xa, 0xa) ! test('concat', 'py', 'python', 'thon') ! ! test('countOf', [1, 2, 1, 3, 1, 4], 1, 3) ! ! a = [4, 3, 2, 1] ! test('delitem', a, None, 1) ! if a <> [4, 2, 1]: ! print 'delitem() failed' ! ! a = range(10) ! test('delslice', a, None, 2, 8) ! if a <> [0, 1, 8, 9]: ! print 'delslice() failed' ! ! a = range(10) ! test('div', 5, 2, 2) ! test('getitem', a, 2, 2) ! test('getslice', a, [4, 5], 4, 6) ! test('indexOf', [4, 3, 2, 1], 1, 3) ! test('inv', 4, -5) ! test('isCallable', 4, 0) ! test('isCallable', operator.isCallable, 1) ! test('isMappingType', operator.isMappingType, 0) ! test('isMappingType', operator.__dict__, 1) ! test('isNumberType', 8.3, 1) ! test('isNumberType', dir(), 0) ! test('isSequenceType', dir(), 1) ! test('isSequenceType', 'yeahbuddy', 1) ! test('isSequenceType', 3, 0) ! test('lshift', 5, 10, 1) ! test('mod', 5, 1, 2) ! test('mul', 5, 10, 2) ! test('neg', 5, -5) ! test('or_', 0xa, 0xf, 0x5) ! test('pos', -5, -5) ! ! a = range(3) ! test('repeat', a, a+a, 2) ! test('rshift', 5, 2, 1) ! ! test('sequenceIncludes', range(4), 1, 2) ! test('sequenceIncludes', range(4), 0, 5) ! ! test('setitem', a, None, 0, 2) ! if a <> [2, 1, 2]: ! print 'setitem() failed' ! ! a = range(4) ! test('setslice', a, None, 1, 3, [2, 1]) ! if a <> [0, 2, 1, 3]: ! print 'setslice() failed:', a ! ! test('sub', 5, 2, 3) ! test('truth', 5, 1) ! test('truth', [], 0) ! test('xor', 0xb, 0x7, 0xc) ! ! ! # some negative tests ! test('indexOf', [4, 3, 2, 1], ValueError, 9) Index: test_pye.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/test_pye.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** test_pye.py 2000/05/08 17:31:03 1.1 --- test_pye.py 2000/06/29 19:35:29 1.2 *************** *** 11,18 **** class Outputter: def StartElementHandler(self, name, attrs): ! print 'Start element:\n\t', name, attrs def EndElementHandler(self, name): ! print 'End element:\n\t', name def CharacterDataHandler(self, data): --- 11,18 ---- class Outputter: def StartElementHandler(self, name, attrs): ! print 'Start element:\n\t', repr(name), attrs def EndElementHandler(self, name): ! print 'End element:\n\t', repr(name) def CharacterDataHandler(self, data): *************** *** 23,33 **** def ProcessingInstructionHandler(self, target, data): ! print 'PI:\n\t', target, data def StartNamespaceDeclHandler(self, prefix, uri): ! print 'NS decl:\n\t', prefix, uri def EndNamespaceDeclHandler(self, prefix): ! print 'End of NS decl:\n\t', prefix def StartCdataSectionHandler(self): --- 23,33 ---- def ProcessingInstructionHandler(self, target, data): ! print 'PI:\n\t', repr(target), repr(data) def StartNamespaceDeclHandler(self, prefix, uri): ! print 'NS decl:\n\t', repr(prefix), repr(uri) def EndNamespaceDeclHandler(self, prefix): ! print 'End of NS decl:\n\t', repr(prefix) def StartCdataSectionHandler(self): *************** *** 52,57 **** return 1 ! def ExternalEntityRefHandler(self, context, base, sysId, pubId): ! print 'External entity ref:', context, base, sysId, pubId return 1 --- 52,58 ---- return 1 ! def ExternalEntityRefHandler(self, *args): ! context, base, sysId, pubId = args ! print 'External entity ref:', args return 1 *************** *** 65,69 **** out = Outputter() parser = pyexpat.ParserCreate(namespace_separator='!') ! for name in ['StartElementHandler', 'EndElementHandler', 'CharacterDataHandler', 'ProcessingInstructionHandler', 'UnparsedEntityDeclHandler', 'NotationDeclHandler', --- 66,77 ---- out = Outputter() parser = pyexpat.ParserCreate(namespace_separator='!') ! ! # Test getting/setting returns_unicode ! parser.returns_unicode = 0 ; assert parser.returns_unicode == 0 ! parser.returns_unicode = 1 ; assert parser.returns_unicode == 1 ! parser.returns_unicode = 2 ; assert parser.returns_unicode == 1 ! parser.returns_unicode = 0 ; assert parser.returns_unicode == 0 ! ! HANDLER_NAMES = ['StartElementHandler', 'EndElementHandler', 'CharacterDataHandler', 'ProcessingInstructionHandler', 'UnparsedEntityDeclHandler', 'NotationDeclHandler', *************** *** 74,78 **** #'NotStandaloneHandler', 'ExternalEntityRefHandler' ! ]: setattr(parser, name, getattr(out, name) ) --- 82,87 ---- #'NotStandaloneHandler', 'ExternalEntityRefHandler' ! ] ! for name in HANDLER_NAMES: setattr(parser, name, getattr(out, name) ) *************** *** 89,93 **** ]> ! Contents of subelements --- 98,102 ---- ]> ! Contents of subelements *************** *** 98,103 **** --- 107,144 ---- """ + # Produce UTF-8 output + parser.returns_unicode = 0 try: parser.Parse(data, 1) + except pyexpat.error: + print '** Error', parser.ErrorCode, pyexpat.ErrorString( parser.ErrorCode) + print '** Line', parser.ErrorLineNumber + print '** Column', parser.ErrorColumnNumber + print '** Byte', parser.ErrorByteIndex + + # Try the parse again, this time producing Unicode output + parser = pyexpat.ParserCreate(namespace_separator='!') + parser.returns_unicode = 1 + + for name in HANDLER_NAMES: + setattr(parser, name, getattr(out, name) ) + try: + parser.Parse(data, 1) + except pyexpat.error: + print '** Error', parser.ErrorCode, pyexpat.ErrorString( parser.ErrorCode) + print '** Line', parser.ErrorLineNumber + print '** Column', parser.ErrorColumnNumber + print '** Byte', parser.ErrorByteIndex + + # Try parsing a file + parser = pyexpat.ParserCreate(namespace_separator='!') + parser.returns_unicode = 1 + + for name in HANDLER_NAMES: + setattr(parser, name, getattr(out, name) ) + import StringIO + file = StringIO.StringIO(data) + try: + parser.ParseFile(file) except pyexpat.error: print '** Error', parser.ErrorCode, pyexpat.ErrorString( parser.ErrorCode) Index: test_soc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/test_soc.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** test_soc.py 2000/05/08 17:31:03 1.6 --- test_soc.py 2000/06/29 19:35:29 1.7 *************** *** 98,102 **** # parent is server s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ! s.bind((hostname, PORT)) s.listen(1) if verbose: --- 98,102 ---- # parent is server s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ! s.bind(("127.0.0.1", PORT)) s.listen(1) if verbose: *************** *** 134,138 **** if verbose: print 'child connecting' ! s.connect((hostname, PORT)) msg = 'socket test' s.send(msg) --- 134,138 ---- if verbose: print 'child connecting' ! s.connect(("127.0.0.1", PORT)) msg = 'socket test' s.send(msg) Index: test_str.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/test_str.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** test_str.py 1998/03/26 22:14:05 1.8 --- test_str.py 2000/06/29 19:35:29 1.9 *************** *** 1,11 **** from test_support import verbose ! import strop, sys def test(name, input, output, *args): if verbose: print 'string.%s%s =? %s... ' % (name, (input,) + args, output), - f = getattr(strop, name) try: ! value = apply(f, (input,) + args) except: value = sys.exc_type --- 1,22 ---- from test_support import verbose ! import string, sys + # XXX: kludge... short circuit if strings don't have methods + try: + ''.join + except AttributeError: + raise ImportError + def test(name, input, output, *args): if verbose: print 'string.%s%s =? %s... ' % (name, (input,) + args, output), try: ! # Prefer string methods over string module functions ! try: ! f = getattr(input, name) ! value = apply(f, args) ! except AttributeError: ! f = getattr(string, name) ! value = apply(f, (input,) + args) except: value = sys.exc_type *************** *** 35,39 **** --- 46,95 ---- test('rfind', 'abcdefghiabc', 9, 'abc') test('lower', 'HeLLo', 'hello') + test('lower', 'hello', 'hello') test('upper', 'HeLLo', 'HELLO') + test('upper', 'HELLO', 'HELLO') + + test('title', ' hello ', ' Hello ') + test('title', 'hello ', 'Hello ') + test('title', "fOrMaT thIs aS titLe String", 'Format This As Title String') + test('title', "fOrMaT,thIs-aS*titLe;String", 'Format,This-As*Title;String') + test('title', "getInt", 'Getint') + + test('expandtabs', 'abc\rab\tdef\ng\thi', 'abc\rab def\ng hi') + test('expandtabs', 'abc\rab\tdef\ng\thi', 'abc\rab def\ng hi', 8) + test('expandtabs', 'abc\rab\tdef\ng\thi', 'abc\rab def\ng hi', 4) + test('expandtabs', 'abc\r\nab\tdef\ng\thi', 'abc\r\nab def\ng hi', 4) + + test('islower', 'a', 1) + test('islower', 'A', 0) + test('islower', '\n', 0) + test('islower', 'abc', 1) + test('islower', 'aBc', 0) + test('islower', 'abc\n', 1) + + test('isupper', 'a', 0) + test('isupper', 'A', 1) + test('isupper', '\n', 0) + test('isupper', 'ABC', 1) + test('isupper', 'AbC', 0) + test('isupper', 'ABC\n', 1) + + test('istitle', 'a', 0) + test('istitle', 'A', 1) + test('istitle', '\n', 0) + test('istitle', 'A Titlecased Line', 1) + test('istitle', 'A\nTitlecased Line', 1) + test('istitle', 'A Titlecased, Line', 1) + test('istitle', 'Not a capitalized String', 0) + test('istitle', 'Not\ta Titlecase String', 0) + test('istitle', 'Not--a Titlecase String', 0) + + test('splitlines', "abc\ndef\n\rghi", ['abc', 'def', '', 'ghi']) + test('splitlines', "abc\ndef\n\r\nghi", ['abc', 'def', '', 'ghi']) + test('splitlines', "abc\ndef\r\nghi", ['abc', 'def', 'ghi']) + test('splitlines', "abc\ndef\r\nghi\n", ['abc', 'def', 'ghi']) + test('splitlines', "abc\ndef\r\nghi\n\r", ['abc', 'def', 'ghi', '']) + test('splitlines', "\nabc\ndef\r\nghi\n\r", ['', 'abc', 'def', 'ghi', '']) + test('splitlines', "\nabc\ndef\r\nghi\n\r", ['\n', 'abc\n', 'def\r\n', 'ghi\n', '\r'], 1) transtable = '\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037 !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`xyzdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377' *************** *** 50,55 **** test('split', 'a b c d', ['a', 'b', 'c', 'd'], None, 3) test('split', 'a b c d', ['a', 'b', 'c', 'd'], None, 4) ! test('split', 'a b c d', ['a', 'b', 'c', 'd'], None, 0) test('split', 'a b c d', ['a', 'b', 'c d'], None, 2) # join now works with any sequence type --- 106,112 ---- test('split', 'a b c d', ['a', 'b', 'c', 'd'], None, 3) test('split', 'a b c d', ['a', 'b', 'c', 'd'], None, 4) ! test('split', 'a b c d', ['a b c d'], None, 0) test('split', 'a b c d', ['a', 'b', 'c d'], None, 2) + test('split', 'a b c d ', ['a', 'b', 'c', 'd']) # join now works with any sequence type *************** *** 62,87 **** test('join', ('a', 'b', 'c', 'd'), 'abcd', '') test('join', Sequence(), 'w x y z') # try a few long ones ! print strop.join(['x' * 100] * 100, ':') ! print strop.join(('x' * 100,) * 100, ':') test('strip', ' hello ', 'hello') test('lstrip', ' hello ', 'hello ') test('rstrip', ' hello ', ' hello') test('swapcase', 'HeLLo cOmpUteRs', 'hEllO CoMPuTErS') test('translate', 'xyzabcdef', 'xyzxyz', transtable, 'def') test('replace', 'one!two!three!', 'one@two!three!', '!', '@', 1) test('replace', 'one!two!three!', 'one@two@three!', '!', '@', 2) test('replace', 'one!two!three!', 'one@two@three@', '!', '@', 3) test('replace', 'one!two!three!', 'one@two@three@', '!', '@', 4) ! test('replace', 'one!two!three!', 'one@two@three@', '!', '@', 0) test('replace', 'one!two!three!', 'one@two@three@', '!', '@') test('replace', 'one!two!three!', 'one!two!three!', 'x', '@') test('replace', 'one!two!three!', 'one!two!three!', 'x', '@', 2) ! strop.whitespace ! strop.lowercase ! strop.uppercase --- 119,185 ---- test('join', ('a', 'b', 'c', 'd'), 'abcd', '') test('join', Sequence(), 'w x y z') + test('join', 7, TypeError) + + class BadSeq(Sequence): + def __init__(self): self.seq = [7, 'hello', 123L] + test('join', BadSeq(), TypeError) + # try a few long ones ! print string.join(['x' * 100] * 100, ':') ! print string.join(('x' * 100,) * 100, ':') test('strip', ' hello ', 'hello') test('lstrip', ' hello ', 'hello ') test('rstrip', ' hello ', ' hello') + test('strip', 'hello', 'hello') test('swapcase', 'HeLLo cOmpUteRs', 'hEllO CoMPuTErS') test('translate', 'xyzabcdef', 'xyzxyz', transtable, 'def') + table = string.maketrans('a', 'A') + test('translate', 'abc', 'Abc', table) + test('translate', 'xyz', 'xyz', table) + test('replace', 'one!two!three!', 'one@two!three!', '!', '@', 1) + test('replace', 'one!two!three!', 'onetwothree', '!', '') test('replace', 'one!two!three!', 'one@two@three!', '!', '@', 2) test('replace', 'one!two!three!', 'one@two@three@', '!', '@', 3) test('replace', 'one!two!three!', 'one@two@three@', '!', '@', 4) ! test('replace', 'one!two!three!', 'one!two!three!', '!', '@', 0) test('replace', 'one!two!three!', 'one@two@three@', '!', '@') test('replace', 'one!two!three!', 'one!two!three!', 'x', '@') test('replace', 'one!two!three!', 'one!two!three!', 'x', '@', 2) ! test('startswith', 'hello', 1, 'he') ! test('startswith', 'hello', 1, 'hello') ! test('startswith', 'hello', 0, 'hello world') ! test('startswith', 'hello', 1, '') ! test('startswith', 'hello', 0, 'ello') ! test('startswith', 'hello', 1, 'ello', 1) ! test('startswith', 'hello', 1, 'o', 4) ! test('startswith', 'hello', 0, 'o', 5) ! test('startswith', 'hello', 1, '', 5) ! test('startswith', 'hello', 0, 'lo', 6) ! test('startswith', 'helloworld', 1, 'lowo', 3) ! test('startswith', 'helloworld', 1, 'lowo', 3, 7) ! test('startswith', 'helloworld', 0, 'lowo', 3, 6) ! ! test('endswith', 'hello', 1, 'lo') ! test('endswith', 'hello', 0, 'he') ! test('endswith', 'hello', 1, '') ! test('endswith', 'hello', 0, 'hello world') ! test('endswith', 'helloworld', 0, 'worl') ! test('endswith', 'helloworld', 1, 'worl', 3, 9) ! test('endswith', 'helloworld', 1, 'world', 3, 12) ! test('endswith', 'helloworld', 1, 'lowo', 1, 7) ! test('endswith', 'helloworld', 1, 'lowo', 2, 7) ! test('endswith', 'helloworld', 1, 'lowo', 3, 7) ! test('endswith', 'helloworld', 0, 'lowo', 4, 7) ! test('endswith', 'helloworld', 0, 'lowo', 3, 8) ! test('endswith', 'ab', 0, 'ab', 0, 1) ! test('endswith', 'ab', 0, 'ab', 0, 0) ! ! string.whitespace ! string.lowercase ! string.uppercase Index: test_tim.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/test_tim.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** test_tim.py 1998/03/26 22:14:09 1.5 --- test_tim.py 2000/06/29 19:35:29 1.6 *************** *** 1,39 **** ! import time ! time.altzone ! time.clock() ! t = time.time() ! time.asctime(time.gmtime(t)) ! if time.ctime(t) <> time.asctime(time.localtime(t)): ! print 'time.ctime(t) <> time.asctime(time.localtime(t))' ! ! time.daylight ! if long(time.mktime(time.localtime(t))) <> long(t): ! print 'time.mktime(time.localtime(t)) <> t' ! ! time.sleep(1.2) ! tt = time.gmtime(t) ! for directive in ('a', 'A', 'b', 'B', 'c', 'd', 'H', 'I', ! 'j', 'm', 'M', 'p', 'S', ! 'U', 'w', 'W', 'x', 'X', 'y', 'Y', 'Z', '%'): ! format = ' %' + directive ! try: ! time.strftime(format, tt) ! except ValueError: ! print 'conversion specifier:', format, ' failed.' ! ! time.timezone ! time.tzname ! ! # expected errors ! try: ! time.asctime(0) ! except TypeError: ! pass ! ! try: ! time.mktime((999999, 999999, 999999, 999999, ! 999999, 999999, 999999, 999999, ! 999999)) ! except OverflowError: pass --- 1,21 ---- ! from test_support import verbose ! import timing ! r = range(100000) ! if verbose: ! print 'starting...' ! timing.start() ! for i in r: pass + timing.finish() + if verbose: + print 'finished' + + secs = timing.seconds() + milli = timing.milli() + micro = timing.micro() + + if verbose: + print 'seconds:', secs + print 'milli :', milli + print 'micro :', micro Index: test_uni.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/test_uni.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** test_uni.py 2000/05/08 17:31:03 1.1 --- test_uni.py 2000/06/29 19:35:29 1.2 *************** *** 1,3 **** ! """ Test script for the Unicode implementation. Written by Marc-Andre Lemburg (mal@lemburg.com). --- 1,3 ---- ! """ Test script for the unicodedata module. Written by Marc-Andre Lemburg (mal@lemburg.com). *************** *** 5,401 **** (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. ! """ from test_support import verbose import sys ! def test(method, input, output, *args): ! if verbose: ! print '%s.%s%s =? %s... ' % (repr(input), method, args, output), ! try: ! f = getattr(input, method) ! value = apply(f, args) ! except: ! value = sys.exc_type ! exc = sys.exc_info()[:2] ! else: ! exc = None ! if value != output: ! if verbose: ! print 'no' ! print '*',f, `input`, `output`, `value` ! if exc: ! print ' value == %s: %s' % (exc) ! else: ! if verbose: ! print 'yes' ! ! test('capitalize', u' hello ', u' hello ') ! test('capitalize', u'hello ', u'Hello ') ! ! test('title', u' hello ', u' Hello ') ! test('title', u'hello ', u'Hello ') ! test('title', u"fOrMaT thIs aS titLe String", u'Format This As Title String') ! test('title', u"fOrMaT,thIs-aS*titLe;String", u'Format,This-As*Title;String') ! test('title', u"getInt", u'Getint') ! ! test('find', u'abcdefghiabc', 0, u'abc') ! test('find', u'abcdefghiabc', 9, u'abc', 1) ! test('find', u'abcdefghiabc', -1, u'def', 4) ! ! test('rfind', u'abcdefghiabc', 9, u'abc') ! ! test('lower', u'HeLLo', u'hello') ! test('lower', u'hello', u'hello') ! ! test('upper', u'HeLLo', u'HELLO') ! test('upper', u'HELLO', u'HELLO') ! ! if 0: ! transtable = '\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037 !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`xyzdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377' ! ! test('maketrans', u'abc', transtable, u'xyz') ! test('maketrans', u'abc', ValueError, u'xyzq') ! ! test('split', u'this is the split function', ! [u'this', u'is', u'the', u'split', u'function']) ! test('split', u'a|b|c|d', [u'a', u'b', u'c', u'd'], u'|') ! test('split', u'a|b|c|d', [u'a', u'b', u'c|d'], u'|', 2) ! test('split', u'a b c d', [u'a', u'b c d'], None, 1) ! test('split', u'a b c d', [u'a', u'b', u'c d'], None, 2) ! test('split', u'a b c d', [u'a', u'b', u'c', u'd'], None, 3) ! test('split', u'a b c d', [u'a', u'b', u'c', u'd'], None, 4) ! test('split', u'a b c d', [u'a b c d'], None, 0) ! test('split', u'a b c d', [u'a', u'b', u'c d'], None, 2) ! test('split', u'a b c d ', [u'a', u'b', u'c', u'd']) ! ! # join now works with any sequence type ! class Sequence: ! def __init__(self): self.seq = 'wxyz' ! def __len__(self): return len(self.seq) ! def __getitem__(self, i): return self.seq[i] ! ! test('join', u' ', u'a b c d', [u'a', u'b', u'c', u'd']) ! test('join', u'', u'abcd', (u'a', u'b', u'c', u'd')) ! test('join', u' ', u'w x y z', Sequence()) ! test('join', u' ', TypeError, 7) ! ! class BadSeq(Sequence): ! def __init__(self): self.seq = [7, u'hello', 123L] ! ! test('join', u' ', TypeError, BadSeq()) ! ! result = u'' ! for i in range(10): ! if i > 0: ! result = result + u':' ! result = result + u'x'*10 ! test('join', u':', result, [u'x' * 10] * 10) ! test('join', u':', result, (u'x' * 10,) * 10) ! ! test('strip', u' hello ', u'hello') ! test('lstrip', u' hello ', u'hello ') ! test('rstrip', u' hello ', u' hello') ! test('strip', u'hello', u'hello') ! ! test('swapcase', u'HeLLo cOmpUteRs', u'hEllO CoMPuTErS') ! ! if 0: ! test('translate', u'xyzabcdef', u'xyzxyz', transtable, u'def') ! ! table = string.maketrans('a', u'A') ! test('translate', u'abc', u'Abc', table) ! test('translate', u'xyz', u'xyz', table) ! ! test('replace', u'one!two!three!', u'one@two!three!', u'!', u'@', 1) ! test('replace', u'one!two!three!', u'onetwothree', '!', '') ! test('replace', u'one!two!three!', u'one@two@three!', u'!', u'@', 2) ! test('replace', u'one!two!three!', u'one@two@three@', u'!', u'@', 3) ! test('replace', u'one!two!three!', u'one@two@three@', u'!', u'@', 4) ! test('replace', u'one!two!three!', u'one!two!three!', u'!', u'@', 0) ! test('replace', u'one!two!three!', u'one@two@three@', u'!', u'@') ! test('replace', u'one!two!three!', u'one!two!three!', u'x', u'@') ! test('replace', u'one!two!three!', u'one!two!three!', u'x', u'@', 2) ! ! test('startswith', u'hello', 1, u'he') ! test('startswith', u'hello', 1, u'hello') ! test('startswith', u'hello', 0, u'hello world') ! test('startswith', u'hello', 1, u'') ! test('startswith', u'hello', 0, u'ello') ! test('startswith', u'hello', 1, u'ello', 1) ! test('startswith', u'hello', 1, u'o', 4) ! test('startswith', u'hello', 0, u'o', 5) ! test('startswith', u'hello', 1, u'', 5) ! test('startswith', u'hello', 0, u'lo', 6) ! test('startswith', u'helloworld', 1, u'lowo', 3) ! test('startswith', u'helloworld', 1, u'lowo', 3, 7) ! test('startswith', u'helloworld', 0, u'lowo', 3, 6) ! ! test('endswith', u'hello', 1, u'lo') ! test('endswith', u'hello', 0, u'he') ! test('endswith', u'hello', 1, u'') ! test('endswith', u'hello', 0, u'hello world') ! test('endswith', u'helloworld', 0, u'worl') ! test('endswith', u'helloworld', 1, u'worl', 3, 9) ! test('endswith', u'helloworld', 1, u'world', 3, 12) ! test('endswith', u'helloworld', 1, u'lowo', 1, 7) ! test('endswith', u'helloworld', 1, u'lowo', 2, 7) ! test('endswith', u'helloworld', 1, u'lowo', 3, 7) ! test('endswith', u'helloworld', 0, u'lowo', 4, 7) ! test('endswith', u'helloworld', 0, u'lowo', 3, 8) ! test('endswith', u'ab', 0, u'ab', 0, 1) ! test('endswith', u'ab', 0, u'ab', 0, 0) ! ! test('expandtabs', u'abc\rab\tdef\ng\thi', u'abc\rab def\ng hi') ! test('expandtabs', u'abc\rab\tdef\ng\thi', u'abc\rab def\ng hi', 8) ! test('expandtabs', u'abc\rab\tdef\ng\thi', u'abc\rab def\ng hi', 4) ! test('expandtabs', u'abc\r\nab\tdef\ng\thi', u'abc\r\nab def\ng hi', 4) ! ! if 0: ! test('capwords', u'abc def ghi', u'Abc Def Ghi') ! test('capwords', u'abc\tdef\nghi', u'Abc Def Ghi') ! test('capwords', u'abc\t def \nghi', u'Abc Def Ghi') ! ! # Comparisons: ! print 'Testing Unicode comparisons...', ! assert u'abc' == 'abc' ! assert 'abc' == u'abc' ! assert u'abc' == u'abc' ! assert u'abcd' > 'abc' ! assert 'abcd' > u'abc' ! assert u'abcd' > u'abc' ! assert u'abc' < 'abcd' ! assert 'abc' < u'abcd' ! assert u'abc' < u'abcd' ! print 'done.' ! ! test('ljust', u'abc', u'abc ', 10) ! test('rjust', u'abc', u' abc', 10) ! test('center', u'abc', u' abc ', 10) ! test('ljust', u'abc', u'abc ', 6) ! test('rjust', u'abc', u' abc', 6) ! test('center', u'abc', u' abc ', 6) ! test('ljust', u'abc', u'abc', 2) ! test('rjust', u'abc', u'abc', 2) ! test('center', u'abc', u'abc', 2) ! ! test('islower', u'a', 1) ! test('islower', u'A', 0) ! test('islower', u'\n', 0) ! test('islower', u'\u1FFc', 0) ! test('islower', u'abc', 1) ! test('islower', u'aBc', 0) ! test('islower', u'abc\n', 1) ! ! test('isupper', u'a', 0) ! test('isupper', u'A', 1) ! test('isupper', u'\n', 0) ! test('isupper', u'\u1FFc', 0) ! test('isupper', u'ABC', 1) ! test('isupper', u'AbC', 0) ! test('isupper', u'ABC\n', 1) ! ! test('istitle', u'a', 0) ! test('istitle', u'A', 1) ! test('istitle', u'\n', 0) ! test('istitle', u'\u1FFc', 1) ! test('istitle', u'A Titlecased Line', 1) ! test('istitle', u'A\nTitlecased Line', 1) ! test('istitle', u'A Titlecased, Line', 1) ! test('istitle', u'Greek \u1FFcitlecases ...', 1) ! test('istitle', u'Not a capitalized String', 0) ! test('istitle', u'Not\ta Titlecase String', 0) ! test('istitle', u'Not--a Titlecase String', 0) ! ! test('splitlines', u"abc\ndef\n\rghi", [u'abc', u'def', u'', u'ghi']) ! test('splitlines', u"abc\ndef\n\r\nghi", [u'abc', u'def', u'', u'ghi']) ! test('splitlines', u"abc\ndef\r\nghi", [u'abc', u'def', u'ghi']) ! test('splitlines', u"abc\ndef\r\nghi\n", [u'abc', u'def', u'ghi']) ! test('splitlines', u"abc\ndef\r\nghi\n\r", [u'abc', u'def', u'ghi', u'']) ! test('splitlines', u"\nabc\ndef\r\nghi\n\r", [u'', u'abc', u'def', u'ghi', u'']) ! test('splitlines', u"\nabc\ndef\r\nghi\n\r", [u'\n', u'abc\n', u'def\r\n', u'ghi\n', u'\r'], 1) ! ! test('translate', u"abababc", u'bbbc', {ord('a'):None}) ! test('translate', u"abababc", u'iiic', {ord('a'):None, ord('b'):ord('i')}) ! test('translate', u"abababc", u'iiix', {ord('a'):None, ord('b'):ord('i'), ord('c'):u'x'}) ! ! # Contains: ! print 'Testing Unicode contains method...', ! assert ('a' in u'abdb') == 1 ! assert ('a' in u'bdab') == 1 ! assert ('a' in u'bdaba') == 1 ! assert ('a' in u'bdba') == 1 ! assert ('a' in u'bdba') == 1 ! assert (u'a' in u'bdba') == 1 ! assert (u'a' in u'bdb') == 0 ! assert (u'a' in 'bdb') == 0 ! assert (u'a' in 'bdba') == 1 ! assert (u'a' in ('a',1,None)) == 1 ! assert (u'a' in (1,None,'a')) == 1 ! assert (u'a' in (1,None,u'a')) == 1 ! assert ('a' in ('a',1,None)) == 1 ! assert ('a' in (1,None,'a')) == 1 ! assert ('a' in (1,None,u'a')) == 1 ! assert ('a' in ('x',1,u'y')) == 0 ! assert ('a' in ('x',1,None)) == 0 ! print 'done.' ! ! # Formatting: ! print 'Testing Unicode formatting strings...', ! assert u"%s, %s" % (u"abc", "abc") == u'abc, abc' ! assert u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", 1, 2, 3) == u'abc, abc, 1, 2.000000, 3.00' ! assert u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", 1, -2, 3) == u'abc, abc, 1, -2.000000, 3.00' ! assert u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", -1, -2, 3.5) == u'abc, abc, -1, -2.000000, 3.50' ! assert u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", -1, -2, 3.57) == u'abc, abc, -1, -2.000000, 3.57' ! assert u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", -1, -2, 1003.57) == u'abc, abc, -1, -2.000000, 1003.57' ! assert u"%c" % (u"abc",) == u'a' ! assert u"%c" % ("abc",) == u'a' ! assert u"%c" % (34,) == u'"' ! assert u"%c" % (36,) == u'$' ! assert u"%r, %r" % (u"abc", "abc") == u"u'abc', 'abc'" ! assert u"%(x)s, %(y)s" % {'x':u"abc", 'y':"def"} == u'abc, def' ! assert u"%(x)s, %(ä)s" % {'x':u"abc", u'ä'.encode('utf-8'):"def"} == u'abc, def' ! # formatting jobs delegated from the string implementation: ! assert '...%(foo)s...' % {'foo':u"abc"} == u'...abc...' ! assert '...%(foo)s...' % {'foo':"abc"} == '...abc...' ! assert '...%(foo)s...' % {u'foo':"abc"} == '...abc...' ! assert '...%(foo)s...' % {u'foo':u"abc"} == u'...abc...' ! assert '...%(foo)s...' % {u'foo':u"abc",'def':123} == u'...abc...' ! assert '...%(foo)s...' % {u'foo':u"abc",u'def':123} == u'...abc...' ! assert '...%s...%s...%s...%s...' % (1,2,3,u"abc") == u'...1...2...3...abc...' ! assert '...%s...' % u"abc" == u'...abc...' ! print 'done.' ! ! # Test builtin codecs ! print 'Testing builtin codecs...', ! ! assert unicode('hello','ascii') == u'hello' ! assert unicode('hello','utf-8') == u'hello' ! assert unicode('hello','utf8') == u'hello' ! assert unicode('hello','latin-1') == u'hello' ! ! try: ! u'Andr\202 x'.encode('ascii') ! u'Andr\202 x'.encode('ascii','strict') ! except ValueError: ! pass ! else: ! raise AssertionError, "u'Andr\202'.encode('ascii') failed to raise an exception" ! assert u'Andr\202 x'.encode('ascii','ignore') == "Andr x" ! assert u'Andr\202 x'.encode('ascii','replace') == "Andr? x" ! ! try: ! unicode('Andr\202 x','ascii') ! unicode('Andr\202 x','ascii','strict') ! except ValueError: ! pass ! else: ! raise AssertionError, "unicode('Andr\202') failed to raise an exception" ! assert unicode('Andr\202 x','ascii','ignore') == u"Andr x" ! assert unicode('Andr\202 x','ascii','replace') == u'Andr\uFFFD x' ! ! assert u'hello'.encode('ascii') == 'hello' ! assert u'hello'.encode('utf-8') == 'hello' ! assert u'hello'.encode('utf8') == 'hello' ! assert u'hello'.encode('utf-16-le') == 'h\000e\000l\000l\000o\000' ! assert u'hello'.encode('utf-16-be') == '\000h\000e\000l\000l\000o' ! assert u'hello'.encode('latin-1') == 'hello' ! ! u = u''.join(map(unichr, range(1024))) ! for encoding in ('utf-8', 'utf-16', 'utf-16-le', 'utf-16-be', ! 'raw_unicode_escape', 'unicode_escape', 'unicode_internal'): ! assert unicode(u.encode(encoding),encoding) == u ! ! u = u''.join(map(unichr, range(256))) ! for encoding in ( ! 'latin-1', ! ): ! try: ! assert unicode(u.encode(encoding),encoding) == u ! except AssertionError: ! print '*** codec "%s" failed round-trip' % encoding ! except ValueError,why: ! print '*** codec for "%s" failed: %s' % (encoding, why) ! ! u = u''.join(map(unichr, range(128))) ! for encoding in ( ! 'ascii', ! ): ! try: ! assert unicode(u.encode(encoding),encoding) == u ! except AssertionError: ! print '*** codec "%s" failed round-trip' % encoding ! except ValueError,why: ! print '*** codec for "%s" failed: %s' % (encoding, why) ! ! print 'done.' ! ! print 'Testing standard mapping codecs...', ! ! print '0-127...', ! s = ''.join(map(chr, range(128))) ! for encoding in ( ! 'cp037', 'cp1026', ! 'cp437', 'cp500', 'cp737', 'cp775', 'cp850', ! 'cp852', 'cp855', 'cp860', 'cp861', 'cp862', ! 'cp863', 'cp865', 'cp866', ! 'iso8859_10', 'iso8859_13', 'iso8859_14', 'iso8859_15', ! 'iso8859_2', 'iso8859_3', 'iso8859_4', 'iso8859_5', 'iso8859_6', ! 'iso8859_7', 'iso8859_9', 'koi8_r', 'latin_1', ! 'mac_cyrillic', 'mac_latin2', ! ! 'cp1250', 'cp1251', 'cp1252', 'cp1253', 'cp1254', 'cp1255', ! 'cp1256', 'cp1257', 'cp1258', ! 'cp856', 'cp857', 'cp864', 'cp869', 'cp874', ! ! 'mac_greek', 'mac_iceland','mac_roman', 'mac_turkish', ! 'cp1006', 'cp875', 'iso8859_8', ! ! ### These have undefined mappings: ! #'cp424', ! ! ): ! try: ! assert unicode(s,encoding).encode(encoding) == s ! except AssertionError: ! print '*** codec "%s" failed round-trip' % encoding ! except ValueError,why: ! print '*** codec for "%s" failed: %s' % (encoding, why) ! ! print '128-255...', ! s = ''.join(map(chr, range(128,256))) ! for encoding in ( ! 'cp037', 'cp1026', ! 'cp437', 'cp500', 'cp737', 'cp775', 'cp850', ! 'cp852', 'cp855', 'cp860', 'cp861', 'cp862', ! 'cp863', 'cp865', 'cp866', ! 'iso8859_10', 'iso8859_13', 'iso8859_14', 'iso8859_15', ! 'iso8859_2', 'iso8859_3', 'iso8859_4', 'iso8859_5', 'iso8859_6', ! 'iso8859_7', 'iso8859_9', 'koi8_r', 'latin_1', ! 'mac_cyrillic', 'mac_latin2', ! ! ### These have undefined mappings: ! #'cp1250', 'cp1251', 'cp1252', 'cp1253', 'cp1254', 'cp1255', ! #'cp1256', 'cp1257', 'cp1258', ! #'cp424', 'cp856', 'cp857', 'cp864', 'cp869', 'cp874', ! #'mac_greek', 'mac_iceland','mac_roman', 'mac_turkish', ! ! ### These fail the round-trip: ! #'cp1006', 'cp875', 'iso8859_8', ! ! ): ! try: ! assert unicode(s,encoding).encode(encoding) == s ! except AssertionError: ! print '*** codec "%s" failed round-trip' % encoding ! except ValueError,why: ! print '*** codec for "%s" failed: %s' % (encoding, why) ! ! print 'done.' ! ! print 'Testing Unicode string concatenation...', ! assert (u"abc" u"def") == u"abcdef" ! assert ("abc" u"def") == u"abcdef" ! assert (u"abc" "def") == u"abcdef" ! assert (u"abc" u"def" "ghi") == u"abcdefghi" ! assert ("abc" "def" u"ghi") == u"abcdefghi" print 'done.' --- 5,50 ---- (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. ! """#" from test_support import verbose import sys ! # Test Unicode database APIs ! import unicodedata ! ! print 'Testing unicodedata module...', ! ! assert unicodedata.digit(u'A',None) is None ! assert unicodedata.digit(u'9') == 9 ! assert unicodedata.digit(u'\u215b',None) is None ! assert unicodedata.digit(u'\u2468') == 9 ! ! assert unicodedata.numeric(u'A',None) is None ! assert unicodedata.numeric(u'9') == 9 ! assert unicodedata.numeric(u'\u215b') == 0.125 ! assert unicodedata.numeric(u'\u2468') == 9.0 ! ! assert unicodedata.decimal(u'A',None) is None ! assert unicodedata.decimal(u'9') == 9 ! assert unicodedata.decimal(u'\u215b',None) is None ! assert unicodedata.decimal(u'\u2468',None) is None ! ! assert unicodedata.category(u'\uFFFE') == 'Cn' ! assert unicodedata.category(u'a') == 'Ll' ! assert unicodedata.category(u'A') == 'Lu' ! ! assert unicodedata.bidirectional(u'\uFFFE') == '' ! assert unicodedata.bidirectional(u' ') == 'WS' ! assert unicodedata.bidirectional(u'A') == 'L' ! ! assert unicodedata.decomposition(u'\uFFFE') == '' ! assert unicodedata.decomposition(u'\u00bc') == ' 0031 2044 0034' ! ! assert unicodedata.mirrored(u'\uFFFE') == 0 ! assert unicodedata.mirrored(u'a') == 0 ! assert unicodedata.mirrored(u'\u2201') == 1 ! ! assert unicodedata.combining(u'\uFFFE') == 0 ! assert unicodedata.combining(u'a') == 0 ! assert unicodedata.combining(u'\u20e1') == 230 ! print 'done.' Index: test_use.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/test_use.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** test_use.py 1999/04/08 20:27:52 1.1 --- test_use.py 2000/06/29 19:35:29 1.2 *************** *** 1,101 **** ! # Check every path through every method of UserDict ! ! from UserDict import UserDict ! ! d0 = {} ! d1 = {"one": 1} ! d2 = {"one": 1, "two": 2} ! ! # Test constructors ! ! u = UserDict() ! u0 = UserDict(d0) ! u1 = UserDict(d1) ! u2 = UserDict(d2) ! ! uu = UserDict(u) ! uu0 = UserDict(u0) ! uu1 = UserDict(u1) ! uu2 = UserDict(u2) ! ! # Test __repr__ ! ! assert str(u0) == str(d0) ! assert repr(u1) == repr(d1) ! assert `u2` == `d2` ! ! # Test __cmp__ and __len__ ! ! all = [d0, d1, d2, u, u0, u1, u2, uu, uu0, uu1, uu2] ! for a in all: ! for b in all: ! assert cmp(a, b) == cmp(len(a), len(b)) ! ! # Test __getitem__ ! ! assert u2["one"] == 1 ! try: ! u1["two"] ! except KeyError: ! pass ! else: ! assert 0, "u1['two'] shouldn't exist" ! ! # Test __setitem__ ! ! u3 = UserDict(u2) ! u3["two"] = 2 ! u3["three"] = 3 ! ! # Test __delitem__ ! ! del u3["three"] ! try: ! del u3["three"] ! except KeyError: ! pass ! else: ! assert 0, "u3['three'] shouldn't exist" ! ! # Test clear ! ! u3.clear() ! assert u3 == {} ! ! # Test copy() ! ! u2a = u2.copy() ! assert u2a == u2 ! ! class MyUserDict(UserDict): ! def display(self): print self ! ! m2 = MyUserDict(u2) ! m2a = m2.copy() ! assert m2a == m2 ! ! # Test keys, items, values ! ! assert u2.keys() == d2.keys() ! assert u2.items() == d2.items() ! assert u2.values() == d2.values() ! ! # Test has_key ! ! for i in u2.keys(): ! assert u2.has_key(i) == 1 ! assert u1.has_key(i) == d1.has_key(i) ! assert u0.has_key(i) == d0.has_key(i) ! ! # Test update ! ! t = UserDict() ! t.update(u2) ! assert t == u2 ! ! # Test get ! ! for i in u2.keys(): ! assert u2.get(i) == u2[i] ! assert u1.get(i) == d1.get(i) ! assert u0.get(i) == d0.get(i) --- 1,227 ---- ! #!/usr/bin/env python ! import sys, string ! from test_support import verbose ! # UserString is a wrapper around the native builtin string type. ! # UserString instances should behave similar to builtin string objects. ! # The test cases were in part derived from 'test_string.py'. ! from UserString import UserString ! ! if __name__ == "__main__": ! verbose = 0 ! ! tested_methods = {} ! ! def test(methodname, input, *args): ! global tested_methods ! tested_methods[methodname] = 1 ! if verbose: ! print '%s.%s(%s) ' % (input, methodname, args), ! u = UserString(input) ! objects = [input, u, UserString(u)] ! res = [""] * 3 ! for i in range(3): ! object = objects[i] ! try: ! f = getattr(object, methodname) ! res[i] = apply(f, args) ! except: ! res[i] = sys.exc_type ! if res[0] != res[1]: ! if verbose: ! print 'no' ! print `input`, f, `res[0]`, "<>", `res[1]` ! else: ! if verbose: ! print 'yes' ! if res[1] != res[2]: ! if verbose: ! print 'no' ! print `input`, f, `res[1]`, "<>", `res[2]` ! else: ! if verbose: ! print 'yes' ! ! test('capitalize', ' hello ') ! test('capitalize', 'hello ') ! ! test('center', 'foo', 0) ! test('center', 'foo', 3) ! test('center', 'foo', 16) ! ! test('ljust', 'foo', 0) ! test('ljust', 'foo', 3) ! test('ljust', 'foo', 16) ! ! test('rjust', 'foo', 0) ! test('rjust', 'foo', 3) ! test('rjust', 'foo', 16) ! ! test('count', 'abcabcabc', 'abc') ! test('count', 'abcabcabc', 'abc', 1) ! test('count', 'abcabcabc', 'abc', -1) ! test('count', 'abcabcabc', 'abc', 7) ! test('count', 'abcabcabc', 'abc', 0, 3) ! test('count', 'abcabcabc', 'abc', 0, 333) ! ! test('find', 'abcdefghiabc', 'abc') ! test('find', 'abcdefghiabc', 'abc', 1) ! test('find', 'abcdefghiabc', 'def', 4) ! test('rfind', 'abcdefghiabc', 'abc') ! ! test('index', 'abcabcabc', 'abc') ! test('index', 'abcabcabc', 'abc', 1) ! test('index', 'abcabcabc', 'abc', -1) ! test('index', 'abcabcabc', 'abc', 7) ! test('index', 'abcabcabc', 'abc', 0, 3) ! test('index', 'abcabcabc', 'abc', 0, 333) ! ! test('rindex', 'abcabcabc', 'abc') ! test('rindex', 'abcabcabc', 'abc', 1) ! test('rindex', 'abcabcabc', 'abc', -1) ! test('rindex', 'abcabcabc', 'abc', 7) ! test('rindex', 'abcabcabc', 'abc', 0, 3) ! test('rindex', 'abcabcabc', 'abc', 0, 333) ! ! ! test('lower', 'HeLLo') ! test('lower', 'hello') ! test('upper', 'HeLLo') ! test('upper', 'HELLO') ! ! test('title', ' hello ') ! test('title', 'hello ') ! test('title', "fOrMaT thIs aS titLe String") ! test('title', "fOrMaT,thIs-aS*titLe;String") ! test('title', "getInt") ! ! test('expandtabs', 'abc\rab\tdef\ng\thi') ! test('expandtabs', 'abc\rab\tdef\ng\thi', 8) ! test('expandtabs', 'abc\rab\tdef\ng\thi', 4) ! test('expandtabs', 'abc\r\nab\tdef\ng\thi', 4) ! ! test('islower', 'a') ! test('islower', 'A') ! test('islower', '\n') ! test('islower', 'abc') ! test('islower', 'aBc') ! test('islower', 'abc\n') ! ! test('isupper', 'a') ! test('isupper', 'A') ! test('isupper', '\n') ! test('isupper', 'ABC') ! test('isupper', 'AbC') ! test('isupper', 'ABC\n') ! ! test('isdigit', ' 0123456789') ! test('isdigit', '56789') ! test('isdigit', '567.89') ! test('isdigit', '0123456789abc') ! ! test('isspace', '') ! test('isspace', ' ') ! test('isspace', ' \t') ! test('isspace', ' \t\f\n') ! ! test('istitle', 'a') ! test('istitle', 'A') ! test('istitle', '\n') ! test('istitle', 'A Titlecased Line') ! test('istitle', 'A\nTitlecased Line') ! test('istitle', 'A Titlecased, Line') ! test('istitle', 'Not a capitalized String') ! test('istitle', 'Not\ta Titlecase String') ! test('istitle', 'Not--a Titlecase String') ! ! test('splitlines', "abc\ndef\n\rghi") ! test('splitlines', "abc\ndef\n\r\nghi") ! test('splitlines', "abc\ndef\r\nghi") ! test('splitlines', "abc\ndef\r\nghi\n") ! test('splitlines', "abc\ndef\r\nghi\n\r") ! test('splitlines', "\nabc\ndef\r\nghi\n\r") ! test('splitlines', "\nabc\ndef\r\nghi\n\r") ! test('splitlines', "\nabc\ndef\r\nghi\n\r") ! ! test('split', 'this is the split function') ! test('split', 'a|b|c|d', '|') ! test('split', 'a|b|c|d', '|', 2) ! test('split', 'a b c d', None, 1) ! test('split', 'a b c d', None, 2) ! test('split', 'a b c d', None, 3) ! test('split', 'a b c d', None, 4) ! test('split', 'a b c d', None, 0) ! test('split', 'a b c d', None, 2) ! test('split', 'a b c d ') ! ! # join now works with any sequence type ! class Sequence: ! def __init__(self): self.seq = 'wxyz' ! def __len__(self): return len(self.seq) ! def __getitem__(self, i): return self.seq[i] ! ! test('join', '', ('a', 'b', 'c', 'd')) ! test('join', '', Sequence()) ! test('join', '', 7) ! ! class BadSeq(Sequence): ! def __init__(self): self.seq = [7, 'hello', 123L] ! ! test('join', '', BadSeq()) ! ! test('strip', ' hello ') ! test('lstrip', ' hello ') ! test('rstrip', ' hello ') ! test('strip', 'hello') ! ! test('swapcase', 'HeLLo cOmpUteRs') ! transtable = string.maketrans("abc", "xyz") ! test('translate', 'xyzabcdef', transtable, 'def') ! ! transtable = string.maketrans('a', 'A') ! test('translate', 'abc', transtable) ! test('translate', 'xyz', transtable) ! ! test('replace', 'one!two!three!', '!', '@', 1) ! test('replace', 'one!two!three!', '!', '') ! test('replace', 'one!two!three!', '!', '@', 2) ! test('replace', 'one!two!three!', '!', '@', 3) ! test('replace', 'one!two!three!', '!', '@', 4) ! test('replace', 'one!two!three!', '!', '@', 0) ! test('replace', 'one!two!three!', '!', '@') ! test('replace', 'one!two!three!', 'x', '@') ! test('replace', 'one!two!three!', 'x', '@', 2) ! ! test('startswith', 'hello', 'he') ! test('startswith', 'hello', 'hello') ! test('startswith', 'hello', 'hello world') ! test('startswith', 'hello', '') ! test('startswith', 'hello', 'ello') ! test('startswith', 'hello', 'ello', 1) ! test('startswith', 'hello', 'o', 4) ! test('startswith', 'hello', 'o', 5) ! test('startswith', 'hello', '', 5) ! test('startswith', 'hello', 'lo', 6) ! test('startswith', 'helloworld', 'lowo', 3) ! test('startswith', 'helloworld', 'lowo', 3, 7) ! test('startswith', 'helloworld', 'lowo', 3, 6) ! ! test('endswith', 'hello', 'lo') ! test('endswith', 'hello', 'he') ! test('endswith', 'hello', '') ! test('endswith', 'hello', 'hello world') ! test('endswith', 'helloworld', 'worl') ! test('endswith', 'helloworld', 'worl', 3, 9) ! test('endswith', 'helloworld', 'world', 3, 12) ! test('endswith', 'helloworld', 'lowo', 1, 7) ! test('endswith', 'helloworld', 'lowo', 2, 7) ! test('endswith', 'helloworld', 'lowo', 3, 7) ! test('endswith', 'helloworld', 'lowo', 4, 7) ! test('endswith', 'helloworld', 'lowo', 3, 8) ! test('endswith', 'ab', 'ab', 0, 1) ! test('endswith', 'ab', 'ab', 0, 0) ! ! # TODO: test cases for: int, long, float, complex, +, * and cmp ! s = "" ! for builtin_method in dir(s): ! if not tested_methods.has_key(builtin_method): ! print "no regression test case for method '"+builtin_method+"'" Index: test_win.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/test_win.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** test_win.py 2000/06/28 14:48:01 1.2 --- test_win.py 2000/06/29 19:35:29 1.3 *************** *** 1,147 **** ! # Test the windows specific win32reg module. ! # Only win32reg functions not hit here: FlushKey, LoadKey and SaveKey ! from winreg import * ! import os, sys ! ! test_key_name = "SOFTWARE\\Python Registry Test Key - Delete Me" ! ! test_data = [ ! ("Int Value", 45, REG_DWORD), ! ("String Val", "A string value", REG_SZ,), ! (u"Unicode Val", u"A Unicode value", REG_SZ,), ! ("StringExpand", "The path is %path%", REG_EXPAND_SZ), ! ("UnicodeExpand", u"The path is %path%", REG_EXPAND_SZ), ! ("Multi-string", ["Lots", "of", "string", "values"], REG_MULTI_SZ), ! ("Multi-unicode", [u"Lots", u"of", u"unicode", u"values"], REG_MULTI_SZ), ! ("Multi-mixed", [u"Unicode", u"and", "string", "values"],REG_MULTI_SZ), ! ("Raw Data", ("binary"+chr(0)+"data"), REG_BINARY), ! ] ! ! def WriteTestData(root_key): ! # Set the default value for this key. ! SetValue(root_key, test_key_name, REG_SZ, "Default value") ! key = CreateKey(root_key, test_key_name) ! # Create a sub-key ! sub_key = CreateKey(key, "sub_key") ! # Give the sub-key some named values ! ! for value_name, value_data, value_type in test_data: ! SetValueEx(sub_key, value_name, 0, value_type, value_data) ! ! # Check we wrote as many items as we thought. ! nkeys, nvalues, since_mod = QueryInfoKey(key) ! assert nkeys==1, "Not the correct number of sub keys" ! assert nvalues==1, "Not the correct number of values" ! nkeys, nvalues, since_mod = QueryInfoKey(sub_key) ! assert nkeys==0, "Not the correct number of sub keys" ! assert nvalues==len(test_data), "Not the correct number of values" ! # Close this key this way... ! # (but before we do, copy the key as an integer - this allows ! # us to test that the key really gets closed). ! int_sub_key = int(sub_key) ! CloseKey(sub_key) ! try: ! QueryInfoKey(int_sub_key) ! raise RuntimeError, "It appears the CloseKey() function does not close the actual key!" ! except EnvironmentError: ! pass ! # ... and close that key that way :-) ! int_key = int(key) ! key.Close() ! try: ! QueryInfoKey(int_key) ! raise RuntimeError, "It appears the key.Close() function does not close the actual key!" ! except EnvironmentError: ! pass ! ! def ReadTestData(root_key): ! # Check we can get default value for this key. ! val = QueryValue(root_key, test_key_name) ! assert val=="Default value", "Registry didnt give back the correct value" ! ! key = OpenKey(root_key, test_key_name) ! # Read the sub-keys ! sub_key = OpenKey(key, "sub_key") ! # Check I can enumerate over the values. ! index = 0 ! while 1: ! try: ! data = EnumValue(sub_key, index) ! except EnvironmentError: ! break ! assert data in test_data, "didnt read back the correct test data." ! index = index + 1 ! assert index==len(test_data), "Didnt read the correct number of items" ! # Check I can directly access each item ! for value_name, value_data, value_type in test_data: ! read_val, read_typ = QueryValueEx(sub_key, value_name) ! assert read_val==value_data and read_typ == value_type, \ ! "Could not directly read the value" ! sub_key.Close() ! # Enumerate our main key. ! read_val = EnumKey(key, 0) ! assert read_val == "sub_key", "Read subkey value wrong" ! try: ! EnumKey(key, 1) ! assert 0, "Was able to get a second key when I only have one!" ! except EnvironmentError: ! pass ! ! key.Close() ! ! def DeleteTestData(root_key): ! key = OpenKey(root_key, test_key_name, 0, KEY_ALL_ACCESS) ! sub_key = OpenKey(key, "sub_key", 0, KEY_ALL_ACCESS) ! # It is not necessary to delete the values before deleting ! # the key (although subkeys must not exist). We delete them ! # manually just to prove we can :-) ! for value_name, value_data, value_type in test_data: ! DeleteValue(sub_key, value_name) ! ! nkeys, nvalues, since_mod = QueryInfoKey(sub_key) ! assert nkeys==0 and nvalues==0, "subkey not empty before delete" ! sub_key.Close() ! DeleteKey(key, "sub_key") ! ! try: ! # Shouldnt be able to delete it twice! ! DeleteKey(key, "sub_key") ! assert 0, "Deleting the key twice succeeded" ! except EnvironmentError: ! pass ! key.Close() ! DeleteKey(root_key, test_key_name) ! # Opening should now fail! ! try: ! key = OpenKey(root_key, test_key_name) ! assert 0, "Could open the non-existent key" ! except WindowsError: # Use this error name this time ! pass ! ! def TestAll(root_key): ! WriteTestData(root_key) ! ReadTestData(root_key) ! DeleteTestData(root_key) ! ! # Test on my local machine. ! TestAll(HKEY_CURRENT_USER) ! print "Local registry tests worked" ! try: ! remote_name = sys.argv[sys.argv.index("--remote")+1] ! except (IndexError, ValueError): ! remote_name = None ! ! if remote_name is not None: ! try: ! remote_key = ConnectRegistry(remote_name, HKEY_CURRENT_USER) ! except EnvironmentError, exc: ! print "Could not connect to the remote machine -", exc.strerror ! remote_key = None ! if remote_key is not None: ! TestAll(remote_key) ! print "Remote registry tests worked" ! else: ! print "Remote registry calls can be tested using", ! print "'test_winreg.py --remote \\\\machine_name'" --- 1,7 ---- ! # Ridiculously simple test of the winsound module for Windows. ! import winsound ! for i in range(100, 2000, 100): ! winsound.Beep(i, 75) ! print "Hopefully you heard some sounds increasing in frequency!" Index: test_zli.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/test_zli.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** test_zli.py 2000/05/08 17:31:03 1.5 --- test_zli.py 2000/06/29 19:35:29 1.6 *************** *** 12,16 **** file.close() ! # test the chucksums (hex so the test doesn't break on 64-bit machines) print hex(zlib.crc32('penguin')), hex(zlib.crc32('penguin', 1)) print hex(zlib.adler32('penguin')), hex(zlib.adler32('penguin', 1)) --- 12,16 ---- file.close() ! # test the checksums (hex so the test doesn't break on 64-bit machines) print hex(zlib.crc32('penguin')), hex(zlib.crc32('penguin', 1)) print hex(zlib.adler32('penguin')), hex(zlib.adler32('penguin', 1)) Index: threadin.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/threadin.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** threadin.py 2000/05/08 17:31:03 1.2 --- threadin.py 2000/06/29 19:35:29 1.3 *************** *** 19,22 **** --- 19,23 ---- _allocate_lock = thread.allocate_lock _get_ident = thread.get_ident + ThreadError = thread.error del thread From python-dev@python.org Thu Jun 29 20:35:48 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:35:48 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/parser - New directory Message-ID: <200006291935.MAA05240@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/xml/parser In directory slayer.i.sourceforge.net:/tmp/cvs-serv5232/parser Log Message: Directory /cvsroot/python/python/dist/src/Lib/xml/parser added to the repository From python-dev@python.org Thu Jun 29 20:36:30 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:36:30 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/parser __init__.py,NONE,1.1 Message-ID: <200006291936.MAA05289@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/xml/parser In directory slayer.i.sourceforge.net:/tmp/cvs-serv5279/parser Added Files: __init__.py Log Message: Package docstring. --- NEW FILE --- """Python interfaces to XML parsers. This package contains on module: expat -- Python wrapper for James Clark's Expat parser, with namespace support. """ From python-dev@python.org Thu Jun 29 20:39:59 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:39:59 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/dom minidom.py,NONE,1.1 pulldom.py,NONE,1.1 Message-ID: <200006291939.MAA05611@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/xml/dom In directory slayer.i.sourceforge.net:/tmp/cvs-serv5599 Added Files: minidom.py pulldom.py Log Message: Paul Prescod : W3C DOM implementation for Python. --- NEW FILE --- import pulldom import string from StringIO import StringIO import types """ minidom.py -- a lightweight DOM implementation based on SAX. Todo: ===== * convenience methods for getting elements and text. * more testing * bring some of the writer and linearizer code into conformance with this interface * SAX 2 namespaces """ class Node: ELEMENT_NODE = 1 ATTRIBUTE_NODE = 2 TEXT_NODE = 3 CDATA_SECTION_NODE = 4 ENTITY_REFERENCE_NODE = 5 ENTITY_NODE = 6 PROCESSING_INSTRUCTION_NODE = 7 COMMENT_NODE = 8 DOCUMENT_NODE = 9 DOCUMENT_TYPE_NODE = 10 DOCUMENT_FRAGMENT_NODE = 11 NOTATION_NODE = 12 allnodes=[] def __init__( self ): self.childNodes=[] Node.allnodes.append( repr( id( self ))+repr( self.__class__ )) def __getattr__( self, key ): if key[0:2]=="__": raise AttributeError # getattr should never call getattr! if self.__dict__.has_key("inGetAttr"): del self.inGetAttr raise AttributeError, key prefix,attrname=key[:5],key[5:] if prefix=="_get_": self.inGetAttr=1 if hasattr( self, attrname ): del self.inGetAttr return (lambda self=self, attrname=attrname: getattr( self, attrname )) else: del self.inGetAttr raise AttributeError, key else: self.inGetAttr=1 try: func = getattr( self, "_get_"+key ) except AttributeError: raise AttributeError, key del self.inGetAttr return func() def __nonzero__(self): return 1 def toxml( self ): writer=StringIO() self.writexml( writer ) return writer.getvalue() def hasChildNodes( self ): if self.childNodes: return 1 else: return 0 def insertBefore( self, newChild, refChild): index=self.childNodes.index( refChild ) self.childNodes.insert( index, newChild ) def appendChild( self, node ): self.childNodes.append( node ) def unlink( self ): self.parentNode=None while self.childNodes: self.childNodes[-1].unlink() del self.childNodes[-1] # probably not most efficient! self.childNodes=None if self.attributes: for attr in self.attributes.values(): attr.unlink() self.attributes=None index=Node.allnodes.index( repr( id( self ))+repr( self.__class__ )) del Node.allnodes[index] def _write_data( writer, data): "Writes datachars to writer." data=string.replace(data,"&","&") data=string.replace(data,"<","<") data=string.replace(data,"\"",""") data=string.replace(data,">",">") writer.write(data) def _closeElement( element ): del element.parentNode for node in element.elements: _closeElement( node ) def _getElementsByTagNameHelper( parent, name, rc ): for node in parent.childNodes: if node.nodeType==Node.ELEMENT_NODE and\ (name=="*" or node.tagName==name): rc.append( node ) _getElementsByTagNameHelper( node, name, rc ) return rc def _getElementsByTagNameNSHelper( parent, nsURI, localName, rc ): for node in parent.childNodes: if (node.nodeType==Node.ELEMENT_NODE ): if ((localName=="*" or node.tagName==localName) and (nsURI=="*" or node.namespaceURI==nsURI)): rc.append( node ) _getElementsByTagNameNSHelper( node, name, rc ) class Attr(Node): nodeType=Node.ATTRIBUTE_NODE def __init__( self, qName, namespaceURI="", prefix="", localName=None ): Node.__init__( self ) assert qName # skip setattr for performance self.__dict__["nodeName"] = self.__dict__["name"] = qName self.__dict__["localName"]=localName or qName self.__dict__["prefix"]=prefix self.__dict__["namespaceURI"]=namespaceURI # nodeValue and value are set elsewhere self.attributes=None def __setattr__( self, name, value ): if name in ("value", "nodeValue" ): self.__dict__["value"]=self.__dict__["nodeValue"]=value else: self.__dict__[name]=value class AttributeList: # the attribute list is a transient interface to the underlying dictionaries # mutations here will change the underlying element's dictionary def __init__( self, attrs, attrsNS ): self.__attrs=attrs self.__attrsNS=attrs self.length=len( self.__attrs.keys() ) def item( self, index ): try: return self[self.keys()[index]] except IndexError: return None def items( self ): return map( lambda node: (node.tagName, node.value), self.__attrs.values() ) def itemsNS( self ): return map( lambda node: ((node.URI, node.localName), node.value), self.__attrs.values() ) def keys( self ): return self.__attrs.keys() def keysNS( self ): return self.__attrsNS.keys() def values( self ): return self.__attrs.values() def __len__( self ): return self.length def __cmp__( self, other ): if self.__attrs is other.__attrs: return 0 else: return cmp( id( self ), id( other ) ) #FIXME: is it appropriate to return .value? def __getitem__( self, attname_or_tuple ): if type( attname_or_tuple ) == type( (1,2) ): return self.__attrsNS[attname_or_tuple].value else: return self.__attrs[attname_or_tuple].value def __setitem__( self, attname ): raise TypeError, "object does not support item assignment" class Element( Node ): nodeType=Node.ELEMENT_NODE def __init__( self, tagName, namespaceURI="", prefix="", localName=None ): Node.__init__( self ) self.tagName = self.nodeName = tagName self.localName=localName or tagName self.prefix=prefix self.namespaceURI=namespaceURI self.nodeValue=None self.__attrs={} # attributes are double-indexed: self.__attrsNS={}# tagName -> Attribute # URI,localName -> Attribute # in the future: consider lazy generation of attribute objects # this is too tricky for now because of headaches # with namespaces. def getAttribute( self, attname ): return self.__attrs[attname].value def getAttributeNS( self, namespaceURI, localName ): return self.__attrsNS[(namespaceURI, localName)].value def setAttribute( self, attname, value ): attr=Attr( attname ) # for performance attr.__dict__["value"]=attr.__dict__["nodeValue"]=value self.setAttributeNode( attr ) def setAttributeNS( self, namespaceURI, qualifiedName, value ): attr=createAttributeNS( namespaceURI, qualifiedName ) # for performance attr.__dict__["value"]=attr.__dict__["nodeValue"]=value self.setAttributeNode( attr ) def setAttributeNode( self, attr ): self.__attrs[attr.name]=attr self.__attrsNS[(attr.namespaceURI,attr.localName)]=attr def removeAttribute( self, name ): attr = self.__attrs[name] self.removeAttributeNode( attr ) def removeAttributeNS( self, namespaceURI, localName ): attr = self.__attrsNS[(uri, localName)] self.removeAttributeNode( attr ) def removeAttributeNode( self, node ): del self.__attrs[node.name] del self.__attrsNS[(node.namespaceURI, node.localName)] def getElementsByTagName( self, name ): return _getElementsByTagNameHelper( self, name, [] ) def getElementsByTagNameNS(self,namespaceURI,localName): _getElementsByTagNameNSHelper( self, namespaceURI, localName, [] ) def __repr__( self ): return "" def writexml(self, writer): writer.write("<"+self.tagName) a_names=self._get_attributes().keys() a_names.sort() for a_name in a_names: writer.write(" "+a_name+"=\"") _write_data(writer, self._get_attributes()[a_name]) writer.write("\"") if self.childNodes: writer.write(">") for node in self.childNodes: node.writexml( writer ) writer.write("") else: writer.write("/>") def _get_attributes( self ): return AttributeList( self.__attrs, self.__attrsNS ) class Comment( Node ): nodeType=Node.COMMENT_NODE def __init__(self, data ): Node.__init__( self ) self.data=self.nodeValue=data self.nodeName="#comment" self.attributes=None def writexml( self, writer ): writer.write( "" ) class ProcessingInstruction( Node ): nodeType=Node.PROCESSING_INSTRUCTION_NODE def __init__(self, target, data ): Node.__init__( self ) self.target = self.nodeName = target self.data = self.nodeValue = data self.attributes=None def writexml( self, writer ): writer.write( "" ) class Text( Node ): nodeType=Node.TEXT_NODE nodeName="#text" def __init__(self, data ): Node.__init__( self ) self.data = self.nodeValue = data self.attributes=None def __repr__(self): if len( self.data )> 10: dotdotdot="..." else: dotdotdot="" return "" def writexml( self, writer ): _write_data( writer, self.data ) class Document( Node ): nodeType=Node.DOCUMENT_NODE def __init__( self ): Node.__init__( self ) self.documentElement=None self.attributes=None self.nodeName="#document" self.nodeValue=None createElement=Element createTextNode=Text createComment=Comment createProcessingInstruction=ProcessingInstruction createAttribute=Attr def createElementNS(self, namespaceURI, qualifiedName): fields = string.split(qualifiedName, ':') if len(fields) == 2: prefix = fields[0] localName = fields[1] elif len(fields) == 1: prefix = '' localName = fields[0] return Element(self, qualifiedName, namespaceURI, prefix, localName) def createAttributeNS(self, namespaceURI, qualifiedName): fields = string.split(qualifiedName,':') if len(fields) == 2: localName = fields[1] prefix = fields[0] elif len(fields) == 1: localName = fields[0] prefix = None return Attr(qualifiedName, namespaceURI, prefix, localName) def getElementsByTagNameNS(self,namespaceURI,localName): _getElementsByTagNameNSHelper( self, namespaceURI, localName ) def close( self ): for node in self.elements: _closeElement( node ) def unlink( self ): self.documentElement=None Node.unlink( self ) def getElementsByTagName( self, name ): rc=[] _getElementsByTagNameHelper( self, name, rc ) return rc def writexml( self, writer ): for node in self.childNodes: node.writexml( writer ) def _doparse( func, args, kwargs ): events=apply( func, args, kwargs ) (toktype, rootNode)=events.getEvent() events.expandNode( rootNode ) return rootNode def parse( *args, **kwargs ): return _doparse( pulldom.parse, args, kwargs ) def parseString( *args, **kwargs ): return _doparse( pulldom.parseString, args, kwargs ) --- NEW FILE --- import minidom import types import string import sys import pyexpat from xml.sax import ExpatParser #todo: SAX2/namespace handling START_ELEMENT="START_ELEMENT" END_ELEMENT="END_ELEMENT" COMMENT="COMMENT" START_DOCUMENT="START_DOCUMENT" END_DOCUMENT="END_DOCUMENT" PROCESSING_INSTRUCTION="PROCESSING_INSTRUCTION" IGNORABLE_WHITESPACE="IGNORABLE_WHITESPACE" CHARACTERS="CHARACTERS" class PullDOM: def __init__( self ): self.firstEvent=[None,None] self.lastEvent=self.firstEvent def setDocumentLocator( self, locator ): pass def startElement( self, tagName , attrs ): if not hasattr( self, "curNode" ): # FIXME: hack! self.startDocument( ) node = self.document.createElement( tagName ) #FIXME namespaces! for attr in attrs.keys(): node.setAttribute( attr, attrs[attr] ) parent=self.curNode node.parentNode = parent if parent.childNodes: node.previousSibling=parent.childNodes[-1] node.previousSibling.nextSibling=node self.curNode = node # FIXME: do I have to screen namespace attributes self.lastEvent[1]=[(START_ELEMENT, node), None ] self.lastEvent=self.lastEvent[1] #self.events.append( (START_ELEMENT, node) ) def endElement( self, name ): node = self.curNode self.lastEvent[1]=[(END_ELEMENT, node), None ] self.lastEvent=self.lastEvent[1] #self.events.append( (END_ELEMENT, node )) self.curNode = node.parentNode def comment( self, s): node = self.document.createComment ( s ) parent=self.curNode node.parentNode=parent if parent.childNodes: node.previousSibling=parent.childNodes[-1] node.previousSibling.nextSibling=node self.lastEvent[1]=[(COMMENT, node), None ] self.lastEvent=self.lastEvent[1] #self.events.append( (COMMENT, node )) def processingInstruction( self, target, data ): node = self.document.createProcessingInstruction( target, data ) #self.appendChild( node ) parent=self.curNode node.parentNode=parent if parent.childNodes: node.previousSibling=parent.childNodes[-1] node.previousSibling.nextSibling=node self.lastEvent[1]=[(PROCESSING_INSTRUCTION, node), None ] self.lastEvent=self.lastEvent[1] #self.events.append( (PROCESSING_INSTRUCTION, node) ) def ignorableWhitespace( self, chars ): node = self.document.createTextNode( chars[start:start+length] ) parent=self.curNode node.parentNode=parent if parent.childNodes: node.previousSibling=parent.childNodes[-1] node.previousSibling.nextSibling=node self.lastEvent[1]=[(IGNORABLE_WHITESPACE, node), None ] self.lastEvent=self.lastEvent[1] #self.events.append( (IGNORABLE_WHITESPACE, node)) def characters( self, chars ): node = self.document.createTextNode( chars ) node.parentNode=self.curNode self.lastEvent[1]=[(CHARACTERS, node), None ] self.lastEvent=self.lastEvent[1] def startDocument( self ): node = self.curNode = self.document = minidom.Document() node.parentNode=None self.lastEvent[1]=[(START_DOCUMENT, node), None ] self.lastEvent=self.lastEvent[1] #self.events.append( (START_DOCUMENT, node) ) def endDocument( self ): assert( not self.curNode.parentNode ) for node in self.curNode.childNodes: if node.nodeType==node.ELEMENT_NODE: self.document.documentElement = node #if not self.document.documentElement: # raise Error, "No document element" self.lastEvent[1]=[(END_DOCUMENT, node), None ] #self.events.append( (END_DOCUMENT, self.curNode) ) class ErrorHandler: def warning( self, exception ): print exception def error( self, exception ): raise exception def fatalError( self, exception ): raise exception class DOMEventStream: def __init__( self, stream, parser, bufsize ): self.stream=stream self.parser=parser self.bufsize=bufsize self.reset() def reset( self ): self.pulldom = PullDOM() self.parser.setContentHandler( self.pulldom ) def __getitem__( self, pos ): rc=self.getEvent() if rc: return rc raise IndexError def expandNode( self, node ): event=self.getEvent() while event: token,cur_node=event if cur_node is node: return if token !=END_ELEMENT: cur_node.parentNode.childNodes.append( cur_node ) event=self.getEvent() if node.nodeType==minidom.Node.DOCUMENT_NODE: for child in node.childNodes: if child.nodeType==minidom.Node.ELEMENT_NODE: node.documentElement=child def getEvent( self ): if not self.pulldom.firstEvent[1]: self.pulldom.lastEvent=self.pulldom.firstEvent while not self.pulldom.firstEvent[1]: buf=self.stream.read( self.bufsize ) if not buf: #FIXME: why doesn't Expat close work? #self.parser.close() return None self.parser.feed( buf ) rc=self.pulldom.firstEvent[1][0] self.pulldom.firstEvent[1]=self.pulldom.firstEvent[1][1] return rc # FIXME: sax2 #def _getParser( ): # from xml.sax.saxexts import make_parser # expat doesn't report errors properly! Figure it out # return make_parser() # return make_parser("xml.sax.drivers.drv_xmllib") def _getParser(): return ExpatParser() default_bufsize=(2**14)-20 # FIXME: move into sax package for common usage def parse( stream_or_string, parser=None, bufsize=default_bufsize ): if type( stream_or_string ) == type( "" ): stream=open( stream_or_string ) else: stream=stream_or_string if not parser: parser=_getParser() return DOMEventStream( stream, parser, bufsize ) def parseString( string, parser=None ): try: import cStringIO stringio=cStringIO.StringIO except ImportError: import StringIO stringio=StringIO.StringIO bufsize=len( string ) stringio( string ) parser=_getParser() return DOMEventStream( buf, parser, bufsize ) #FIXME: Use Lars' instead!!! class SAX_expat: "SAX driver for the Pyexpat C module." def __init__(self): self.parser=pyexpat.ParserCreate() self.started=0 def setDocumentHandler( self, handler ): self.parser.StartElementHandler = handler.startElement self.parser.EndElementHandler = handler.endElement self.parser.CharacterDataHandler = handler.datachars self.parser.ProcessingInstructionHandler = handler.processingInstruction self.doc_handler=handler def setErrorHandler( self, handler ): self.err_handler=handler # --- Locator methods. Only usable after errors. def getLineNumber(self): return self.parser.ErrorLineNumber def getColumnNumber(self): return self.parser.ErrorColumnNumber # --- Internal def __report_error(self): msg=pyexpat.ErrorString(self.parser.ErrorCode) self.err_handler.fatalError(msg) # --- EXPERIMENTAL PYTHON SAX EXTENSIONS def get_parser_name(self): return "pyexpat" def get_parser_version(self): return "Unknown" def get_driver_version(self): return version def is_validating(self): return 0 def is_dtd_reading(self): return 0 def reset(self): self.parser=pyexpat.ParserCreate() self.parser.StartElementHandler = self.startElement self.parser.EndElementHandler = self.endElement self.parser.CharacterDataHandler = self.characters self.parser.ProcessingInstructionHandler = self.processingInstruction def feed(self,data): if not self.started: self.doc_handler.startDocument() self.started=1 if not self.parser.Parse(data): self.__report_error() def close(self): if not self.parser.Parse("",1): self.__report_error() self.doc_handler.endDocument() self.parser = None From python-dev@python.org Thu Jun 29 20:42:02 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 12:42:02 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_winreg.py,1.3,1.4 Message-ID: <200006291942.MAA05814@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv5802 Modified Files: test_winreg.py Log Message: The low-level interface is now in _winreg; update the import here. Index: test_winreg.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_winreg.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** test_winreg.py 2000/06/28 14:48:01 1.3 --- test_winreg.py 2000/06/29 19:42:00 1.4 *************** *** 2,6 **** # Only win32reg functions not hit here: FlushKey, LoadKey and SaveKey ! from winreg import * import os, sys --- 2,6 ---- # Only win32reg functions not hit here: FlushKey, LoadKey and SaveKey ! from _winreg import * import os, sys From python-dev@python.org Thu Jun 29 21:02:41 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 13:02:41 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/xml/parser __init__.py,1.1,1.2 Message-ID: <200006292002.NAA08546@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/xml/parser In directory slayer.i.sourceforge.net:/tmp/cvs-serv8507 Modified Files: __init__.py Log Message: Typo. Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/parser/__init__.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** __init__.py 2000/06/29 19:36:27 1.1 --- __init__.py 2000/06/29 20:02:38 1.2 *************** *** 1,5 **** """Python interfaces to XML parsers. ! This package contains on module: expat -- Python wrapper for James Clark's Expat parser, with namespace --- 1,5 ---- """Python interfaces to XML parsers. ! This package contains one module: expat -- Python wrapper for James Clark's Expat parser, with namespace From python-dev@python.org Thu Jun 29 21:15:17 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 13:15:17 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/api api.tex,1.69,1.70 Message-ID: <200006292015.NAA14253@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/api In directory slayer.i.sourceforge.net:/tmp/cvs-serv14245 Modified Files: api.tex Log Message: Update comments relating to the removal of the -X option and of string exceptions in the interpreter and standard library. Index: api.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/api.tex,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -r1.69 -r1.70 *** api.tex 2000/06/28 15:53:13 1.69 --- api.tex 2000/06/29 20:15:14 1.70 *************** *** 939,952 **** \var{name} argument must be the name of the new exception, a C string of the form \code{module.class}. The \var{base} and ! \var{dict} arguments are normally \NULL{}. Normally, this creates a class object derived from the root for all exceptions, the built-in name \exception{Exception} (accessible in C as ! \cdata{PyExc_Exception}). In this case the \member{__module__} ! attribute of the new class is set to the first part (up to the last ! dot) of the \var{name} argument, and the class name is set to the last ! part (after the last dot). The ! \var{base} argument can be used to specify an alternate base class. ! The \var{dict} argument can be used to specify a dictionary of class ! variables and methods. \end{cfuncdesc} --- 939,951 ---- \var{name} argument must be the name of the new exception, a C string of the form \code{module.class}. The \var{base} and ! \var{dict} arguments are normally \NULL{}. This creates a class object derived from the root for all exceptions, the built-in name \exception{Exception} (accessible in C as ! \cdata{PyExc_Exception}). The \member{__module__} attribute of the ! new class is set to the first part (up to the last dot) of the ! \var{name} argument, and the class name is set to the last part (after ! the last dot). The \var{base} argument can be used to specify an ! alternate base class. The \var{dict} argument can be used to specify ! a dictionary of class variables and methods. \end{cfuncdesc} *************** *** 992,999 **** \begin{description} \item[(1)] ! This is a base class for other standard exceptions. If the ! \code{-X} interpreter option is used, these will be tuples ! containing the string exceptions which would have otherwise been ! subclasses. \end{description} --- 991,995 ---- \begin{description} \item[(1)] ! This is a base class for other standard exceptions. \end{description} *************** *** 1001,1010 **** \section{Deprecation of String Exceptions} ! The \code{-X} command-line option will be removed in Python 1.6. All ! exceptions built into Python or provided in the standard library will \withsubitem{(built-in exception)}{\ttindex{Exception}} - be classes derived from \exception{Exception}. ! String exceptions will still be supported in the interpreter to allow existing code to run unmodified, but this will also change in a future release. --- 997,1005 ---- \section{Deprecation of String Exceptions} ! All exceptions built into Python or provided in the standard library ! are derived from \exception{Exception}. \withsubitem{(built-in exception)}{\ttindex{Exception}} ! String exceptions are still supported in the interpreter to allow existing code to run unmodified, but this will also change in a future release. From python-dev@python.org Thu Jun 29 21:44:49 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 13:44:49 -0700 Subject: [Python-checkins] CVS: python/dist/src/PC config.h,1.37,1.38 Message-ID: <200006292044.NAA16854@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv16828/PC Modified Files: config.h Log Message: This patch extends PC/config.h and configure.in as appropriate for 64-bit readiness (the config values are needed for patches that I will be submitting later today. The changes are as follows: - add SIZEOF_OFF_T #define's to PC/config.h (it was already in configure.in) - add SIZEOF_TIME_T #define to PC/config.h and configure Needed for some buffer overflow checking because sizeof(time_t) is different on Win64. - add SIZEOF_FPOS_T #define Needed for the Win64 large file support implementation. - add SIZEOF_HKEY in PC/config.h only Needed for proper Win32 vs. Win64 handling in PC/winreg.c - #define HAVE_LARGEFILE_SUPPORT for Win64 - typedef long intptr_t; for all Windows except Win64 (which defines it itself) This is a new ANSI (I think) type that is useful (and used by me) for proper handling in msvcrtmodule.c and posixmodule.c - indent the nested #ifdef's and #defines in PC/config.h This is *so* much more readable. There cannot be a compiler compatibilty issue here can there? Perl uses indented #defines and it compiles with everything. Index: config.h =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/config.h,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -r1.37 -r1.38 *** config.h 2000/06/28 03:54:48 1.37 --- config.h 2000/06/29 20:44:47 1.38 *************** *** 242,262 **** /* End of compilers - finish up */ #if defined(MS_WIN64) /* maintain "win32" sys.platform for backward compatibility of Python code, the Win64 API should be close enough to the Win32 API to make this preferable */ ! #define PLATFORM "win32" ! #define SIZEOF_VOID_P 8 #elif defined(MS_WIN32) ! #define PLATFORM "win32" ! #ifdef _M_ALPHA ! #define SIZEOF_VOID_P 8 ! #else ! #define SIZEOF_VOID_P 4 ! #endif #elif defined(MS_WIN16) ! #define PLATFORM "win16" #else ! #define PLATFORM "dos" #endif --- 242,284 ---- /* End of compilers - finish up */ + /* define the ANSI intptr_t type for portable use of a pointer sized + integer */ + #include + #if defined(MS_WINDOWS) && !defined(MS_WIN64) + typedef long intptr_t; + #endif + #if defined(MS_WIN64) /* maintain "win32" sys.platform for backward compatibility of Python code, the Win64 API should be close enough to the Win32 API to make this preferable */ ! # define PLATFORM "win32" ! # define SIZEOF_VOID_P 8 ! # define SIZEOF_TIME_T 8 ! # define SIZEOF_OFF_T 4 ! # define SIZEOF_FPOS_T 8 ! # define SIZEOF_HKEY 8 ! /* configure.in defines HAVE_LARGEFILE_SUPPORT iff HAVE_LONG_LONG, ! sizeof(off_t) > sizeof(long), and sizeof(LONG_LONG) >= sizeof(off_t). ! On Win64 the second condition is not true, but if fpos_t replaces off_t ! then this is true. The uses of HAVE_LARGEFILE_SUPPORT imply that Win64 ! should define this. */ ! # define HAVE_LARGEFILE_SUPPORT #elif defined(MS_WIN32) ! # define PLATFORM "win32" ! # ifdef _M_ALPHA ! # define SIZEOF_VOID_P 8 ! # define SIZEOF_TIME_T 8 ! # else ! # define SIZEOF_VOID_P 4 ! # define SIZEOF_TIME_T 4 ! # define SIZEOF_OFF_T 4 ! # define SIZEOF_FPOS_T 8 ! # define SIZEOF_HKEY 4 ! # endif #elif defined(MS_WIN16) ! # define PLATFORM "win16" #else ! # define PLATFORM "dos" #endif From python-dev@python.org Thu Jun 29 21:44:49 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 13:44:49 -0700 Subject: [Python-checkins] CVS: python/dist/src acconfig.h,1.29,1.30 config.h.in,2.57,2.58 configure.in,1.127,1.128 Message-ID: <200006292044.NAA16852@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv16828 Modified Files: acconfig.h config.h.in configure.in Log Message: This patch extends PC/config.h and configure.in as appropriate for 64-bit readiness (the config values are needed for patches that I will be submitting later today. The changes are as follows: - add SIZEOF_OFF_T #define's to PC/config.h (it was already in configure.in) - add SIZEOF_TIME_T #define to PC/config.h and configure Needed for some buffer overflow checking because sizeof(time_t) is different on Win64. - add SIZEOF_FPOS_T #define Needed for the Win64 large file support implementation. - add SIZEOF_HKEY in PC/config.h only Needed for proper Win32 vs. Win64 handling in PC/winreg.c - #define HAVE_LARGEFILE_SUPPORT for Win64 - typedef long intptr_t; for all Windows except Win64 (which defines it itself) This is a new ANSI (I think) type that is useful (and used by me) for proper handling in msvcrtmodule.c and posixmodule.c - indent the nested #ifdef's and #defines in PC/config.h This is *so* much more readable. There cannot be a compiler compatibilty issue here can there? Perl uses indented #defines and it compiles with everything. Index: acconfig.h =================================================================== RCS file: /cvsroot/python/python/dist/src/acconfig.h,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -r1.29 -r1.30 *** acconfig.h 2000/05/08 13:41:37 1.29 --- acconfig.h 2000/06/29 20:44:46 1.30 *************** *** 152,155 **** --- 152,158 ---- #undef SIZEOF_OFF_T + /* The number of bytes in a time_t. */ + #undef SIZEOF_TIME_T + /* Defined to enable large file support when an off_t is bigger than a long and long long is available and at least as big as an off_t. You may need Index: config.h.in =================================================================== RCS file: /cvsroot/python/python/dist/src/config.h.in,v retrieving revision 2.57 retrieving revision 2.58 diff -C2 -r2.57 -r2.58 *** config.h.in 2000/06/29 16:12:00 2.57 --- config.h.in 2000/06/29 20:44:46 2.58 *************** *** 214,217 **** --- 214,220 ---- #undef SIZEOF_OFF_T + /* The number of bytes in a time_t. */ + #undef SIZEOF_TIME_T + /* Defined to enable large file support when an off_t is bigger than a long and long long is available and at least as big as an off_t. You may need *************** *** 235,238 **** --- 238,244 ---- #undef SIZEOF_FLOAT + /* The number of bytes in a fpos_t. */ + #undef SIZEOF_FPOS_T + /* The number of bytes in a int. */ #undef SIZEOF_INT *************** *** 543,546 **** --- 549,555 ---- /* Define if you have the header file. */ #undef HAVE_SYS_SELECT_H + + /* Define if you have the header file. */ + #undef HAVE_SYS_SOCKET_H /* Define if you have the header file. */ Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.127 retrieving revision 1.128 diff -C2 -r1.127 -r1.128 *** configure.in 2000/06/29 16:12:00 1.127 --- configure.in 2000/06/29 20:44:46 1.128 *************** *** 390,393 **** --- 390,394 ---- AC_CHECK_SIZEOF(float) AC_CHECK_SIZEOF(double) + AC_CHECK_SIZEOF(fpos_t) AC_MSG_CHECKING(for long long support) *************** *** 424,427 **** --- 425,444 ---- AC_MSG_RESULT(no) fi + + # AC_CHECK_SIZEOF() doesn't include . + AC_MSG_CHECKING(size of time_t) + AC_CACHE_VAL(ac_cv_sizeof_time_t, + [AC_TRY_RUN([#include + #include + main() + { + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", sizeof(time_t)); + exit(0); + }], ac_cv_sizeof_time_t=`cat conftestval`, ac_cv_sizeof_time_t=0) + ]) + AC_MSG_RESULT($ac_cv_sizeof_time_t) + AC_DEFINE_UNQUOTED(SIZEOF_TIME_T, $ac_cv_sizeof_time_t) From python-dev@python.org Thu Jun 29 21:56:32 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 13:56:32 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules timemodule.c,2.84,2.85 Message-ID: <200006292056.NAA17660@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv17653/Modules Modified Files: timemodule.c Log Message: Trent Mick : Mark Hammond provided (a long time ago) a better Win32 specific time_clock implementation in timemodule.c. The library for this implementation does not exist on Win64 (yet, at least). This patch makes Win64 fall back on the system's clock() function for time_clock(). This closes SourceForge patch #100512. Index: timemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/timemodule.c,v retrieving revision 2.84 retrieving revision 2.85 diff -C2 -r2.84 -r2.85 *** timemodule.c 2000/06/28 21:33:59 2.84 --- timemodule.c 2000/06/29 20:56:28 2.85 *************** *** 90,98 **** #endif /* !__WATCOMC__ || __QNX__ */ ! #ifdef MS_WIN32 ! /* Win32 has better clock replacement */ #include #undef HAVE_CLOCK /* We have our own version down below */ ! #endif /* MS_WIN32 */ #if defined(PYCC_VACPP) --- 90,99 ---- #endif /* !__WATCOMC__ || __QNX__ */ ! #if defined(MS_WIN32) && !defined(MS_WIN64) ! /* Win32 has better clock replacement ! XXX Win64 does not yet, but might when the platform matures. */ #include #undef HAVE_CLOCK /* We have our own version down below */ ! #endif /* MS_WIN32 && !MS_WIN64 */ #if defined(PYCC_VACPP) *************** *** 191,195 **** #endif /* HAVE_CLOCK */ ! #ifdef MS_WIN32 /* Due to Mark Hammond */ static PyObject * --- 192,196 ---- #endif /* HAVE_CLOCK */ ! #if defined(MS_WIN32) && !defined(MS_WIN64) /* Due to Mark Hammond */ static PyObject * *************** *** 227,231 **** #define HAVE_CLOCK /* So it gets included in the methods */ ! #endif /* MS_WIN32 */ #ifdef HAVE_CLOCK --- 228,232 ---- #define HAVE_CLOCK /* So it gets included in the methods */ ! #endif /* MS_WIN32 && !MS_WIN64 */ #ifdef HAVE_CLOCK From python-dev@python.org Thu Jun 29 22:12:48 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 14:12:48 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules posixmodule.c,2.137,2.138 Message-ID: <200006292112.OAA24946@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv24938/Modules Modified Files: posixmodule.c Log Message: Trent Mick : This patch fixes the posix module for large file support mainly on Win64, although some general cleanup is done as well. The changes are: - abstract stat->STAT, fstat->FSTAT, and struct stat->STRUCT_STAT This is because stat() etc. are not the correct functions to use on Win64 (nor maybe on other platforms?, if not then it is now trivial to select the appropriate one). On Win64 the appropriate system functions are _stati64(), etc. - add _pystat_fromstructstat(), it builds the return tuple for the fstat system call. This functionality was being duplicated. As well the construction of the tuple was modified to ensure no overflow of the time_t elements (sizeof(time_t) > sizeof(long) on Win64). - add overflow protection for the return values of posix_spawnv and posix_spawnve - use the proper 64-bit capable lseek() on Win64 - use intptr_t instead of long where appropriate from Win32/64 blocks (sizeof(void*) > sizeof(long) on Win64) This closes SourceForge patch #100513. Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.137 retrieving revision 2.138 diff -C2 -r2.137 -r2.138 *** posixmodule.c 2000/06/28 16:40:38 2.137 --- posixmodule.c 2000/06/29 21:12:41 2.138 *************** *** 285,288 **** --- 285,300 ---- #endif + /* choose the appropriate stat and fstat functions and return structs */ + #ifdef MS_WIN64 + # define STAT _stati64 + # define FSTAT _fstati64 + # define STRUCT_STAT struct _stati64 + #else + # define STAT stat + # define FSTAT fstat + # define STRUCT_STAT struct stat + #endif + + /* Return a dictionary corresponding to the POSIX environment table */ *************** *** 540,543 **** --- 552,605 ---- } + + + /* pack a system stat C structure into the Python stat tuple + (used by posix_stat() and posix_fstat()) */ + static PyObject* + _pystat_fromstructstat(st) + STRUCT_STAT st; + { + PyObject *v = PyTuple_New(10); + if (v == NULL) + return NULL; + + PyTuple_SetItem(v, 0, PyInt_FromLong((long)st.st_mode)); + #ifdef HAVE_LARGEFILE_SUPPORT + PyTuple_SetItem(v, 1, PyLong_FromLongLong((LONG_LONG)st.st_ino)); + #else + PyTuple_SetItem(v, 1, PyInt_FromLong((long)st.st_ino)); + #endif + #if defined(HAVE_LONG_LONG) && !defined(MS_WINDOWS) + PyTuple_SetItem(v, 2, PyLong_FromLongLong((LONG_LONG)st.st_dev)); + #else + PyTuple_SetItem(v, 2, PyInt_FromLong((long)st.st_dev)); + #endif + PyTuple_SetItem(v, 3, PyInt_FromLong((long)st.st_nlink)); + PyTuple_SetItem(v, 4, PyInt_FromLong((long)st.st_uid)); + PyTuple_SetItem(v, 5, PyInt_FromLong((long)st.st_gid)); + #ifdef HAVE_LARGEFILE_SUPPORT + PyTuple_SetItem(v, 6, PyLong_FromLongLong((LONG_LONG)st.st_size)); + #else + PyTuple_SetItem(v, 6, PyInt_FromLong(st.st_size)); + #endif + #if SIZEOF_TIME_T > SIZEOF_LONG + PyTuple_SetItem(v, 7, PyLong_FromLongLong((LONG_LONG)st.st_atime)); + PyTuple_SetItem(v, 8, PyLong_FromLongLong((LONG_LONG)st.st_mtime)); + PyTuple_SetItem(v, 9, PyLong_FromLongLong((LONG_LONG)st.st_ctime)); + #else + PyTuple_SetItem(v, 7, PyInt_FromLong((long)st.st_atime)); + PyTuple_SetItem(v, 8, PyInt_FromLong((long)st.st_mtime)); + PyTuple_SetItem(v, 9, PyInt_FromLong((long)st.st_ctime)); + #endif + + if (PyErr_Occurred()) { + Py_DECREF(v); + return NULL; + } + + return v; + } + + static PyObject * posix_do_stat(self, args, format, statfunc) *************** *** 545,551 **** PyObject *args; char *format; ! int (*statfunc) Py_FPROTO((const char *, struct stat *)); { ! struct stat st; char *path; int res; --- 607,613 ---- PyObject *args; char *format; ! int (*statfunc) Py_FPROTO((const char *, STRUCT_STAT *)); { ! STRUCT_STAT st; char *path; int res; *************** *** 586,614 **** if (res != 0) return posix_error_with_filename(path); ! #if !defined(HAVE_LARGEFILE_SUPPORT) ! return Py_BuildValue("(llllllllll)", ! (long)st.st_mode, ! (long)st.st_ino, ! (long)st.st_dev, ! (long)st.st_nlink, ! (long)st.st_uid, ! (long)st.st_gid, ! (long)st.st_size, ! (long)st.st_atime, ! (long)st.st_mtime, ! (long)st.st_ctime); ! #else ! return Py_BuildValue("(lLllllLlll)", ! (long)st.st_mode, ! (LONG_LONG)st.st_ino, ! (long)st.st_dev, ! (long)st.st_nlink, ! (long)st.st_uid, ! (long)st.st_gid, ! (LONG_LONG)st.st_size, ! (long)st.st_atime, ! (long)st.st_mtime, ! (long)st.st_ctime); ! #endif } --- 648,653 ---- if (res != 0) return posix_error_with_filename(path); ! ! return _pystat_fromstructstat(st); } *************** *** 1159,1163 **** PyObject *args; { ! return posix_do_stat(self, args, "s:stat", stat); } --- 1198,1202 ---- PyObject *args; { ! return posix_do_stat(self, args, "s:stat", STAT); } *************** *** 1547,1550 **** --- 1586,1590 ---- char **argvlist; int mode, i, argc; + intptr_t spawnval; PyObject *(*getitem) Py_PROTO((PyObject *, int)); *************** *** 1582,1593 **** if (mode == _OLD_P_OVERLAY) mode = _P_OVERLAY; ! i = _spawnv(mode, path, argvlist); PyMem_DEL(argvlist); ! if (i == -1) return posix_error(); else ! return Py_BuildValue("i", i); } --- 1622,1637 ---- if (mode == _OLD_P_OVERLAY) mode = _P_OVERLAY; ! spawnval = _spawnv(mode, path, argvlist); PyMem_DEL(argvlist); ! if (spawnval == -1) return posix_error(); else ! #if SIZEOF_LONG == SIZE_VOID_P ! return Py_BuildValue("l", spawnval); ! #else ! return Py_BuildValue("L", spawnval); ! #endif } *************** *** 1613,1616 **** --- 1657,1661 ---- PyObject *key, *val, *keys=NULL, *vals=NULL, *res=NULL; int mode, i, pos, argc, envc; + intptr_t spawnval; PyObject *(*getitem) Py_PROTO((PyObject *, int)); *************** *** 1690,1698 **** if (mode == _OLD_P_OVERLAY) mode = _P_OVERLAY; ! i = _spawnve(mode, path, argvlist, envlist); ! if (i == -1) (void) posix_error(); else ! res = Py_BuildValue("i", i); fail_2: --- 1735,1747 ---- if (mode == _OLD_P_OVERLAY) mode = _P_OVERLAY; ! spawnval = _spawnve(mode, path, argvlist, envlist); ! if (spawnval == -1) (void) posix_error(); else ! #if SIZEOF_LONG == SIZE_VOID_P ! res = Py_BuildValue("l", spawnval); ! #else ! res = Py_BuildValue("L", spawnval); ! #endif fail_2: *************** *** 2329,2333 **** return posix_do_stat(self, args, "s:lstat", lstat); #else /* !HAVE_LSTAT */ ! return posix_do_stat(self, args, "s:lstat", stat); #endif /* !HAVE_LSTAT */ } --- 2378,2382 ---- return posix_do_stat(self, args, "s:lstat", lstat); #else /* !HAVE_LSTAT */ ! return posix_do_stat(self, args, "s:lstat", STAT); #endif /* !HAVE_LSTAT */ } *************** *** 2653,2657 **** --- 2702,2710 ---- { int fd, how; + #ifdef MS_WIN64 + LONG_LONG pos, res; + #else off_t pos, res; + #endif PyObject *posobj; if (!PyArg_ParseTuple(args, "iOi:lseek", &fd, &posobj, &how)) *************** *** 2676,2680 **** --- 2729,2737 ---- Py_BEGIN_ALLOW_THREADS + #ifdef MS_WIN64 + res = _lseeki64(fd, pos, how); + #else res = lseek(fd, pos, how); + #endif Py_END_ALLOW_THREADS if (res < 0) *************** *** 2750,2787 **** { int fd; ! struct stat st; int res; if (!PyArg_ParseTuple(args, "i:fstat", &fd)) return NULL; Py_BEGIN_ALLOW_THREADS ! res = fstat(fd, &st); Py_END_ALLOW_THREADS if (res != 0) return posix_error(); ! #if !defined(HAVE_LARGEFILE_SUPPORT) ! return Py_BuildValue("(llllllllll)", ! (long)st.st_mode, ! (long)st.st_ino, ! (long)st.st_dev, ! (long)st.st_nlink, ! (long)st.st_uid, ! (long)st.st_gid, ! (long)st.st_size, ! (long)st.st_atime, ! (long)st.st_mtime, ! (long)st.st_ctime); ! #else ! return Py_BuildValue("(lLllllLlll)", ! (long)st.st_mode, ! (LONG_LONG)st.st_ino, ! (long)st.st_dev, ! (long)st.st_nlink, ! (long)st.st_uid, ! (long)st.st_gid, ! (LONG_LONG)st.st_size, ! (long)st.st_atime, ! (long)st.st_mtime, ! (long)st.st_ctime); ! #endif } --- 2807,2821 ---- { int fd; ! STRUCT_STAT st; int res; if (!PyArg_ParseTuple(args, "i:fstat", &fd)) return NULL; Py_BEGIN_ALLOW_THREADS ! res = FSTAT(fd, &st); Py_END_ALLOW_THREADS if (res != 0) return posix_error(); ! ! return _pystat_fromstructstat(st); } *************** *** 2864,2869 **** if (!ok) return posix_error(); ! read_fd = _open_osfhandle((long)read, 0); ! write_fd = _open_osfhandle((long)write, 1); return Py_BuildValue("(ii)", read_fd, write_fd); #endif /* MS_WIN32 */ --- 2898,2903 ---- if (!ok) return posix_error(); ! read_fd = _open_osfhandle((intptr_t)read, 0); ! write_fd = _open_osfhandle((intptr_t)write, 1); return Py_BuildValue("(ii)", read_fd, write_fd); #endif /* MS_WIN32 */ *************** *** 3527,3533 **** if (PyString_Check(arg)) { /* look up the value in the table using a binary search */ ! int lo = 0; ! int hi = tablesize; ! int cmp, mid; char *confname = PyString_AS_STRING(arg); while (lo < hi) { --- 3561,3568 ---- if (PyString_Check(arg)) { /* look up the value in the table using a binary search */ ! size_t lo = 0; ! size_t mid; ! size_t hi = tablesize; ! int cmp; char *confname = PyString_AS_STRING(arg); while (lo < hi) { From python-dev@python.org Thu Jun 29 22:31:05 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 14:31:05 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules timemodule.c,2.85,2.86 Message-ID: <200006292131.OAA26110@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv26103/Modules Modified Files: timemodule.c Log Message: Trent Mick : This patch fixes a possible overflow in the Sleep system call on Win32/64 in the time_sleep() function in the time module. For very large values of the give time to sleep the number of milliseconds can overflow and give unexpected sleep intervals. THis patch raises an OverflowError if the value overflows. Closes SourceForge patch #100514. Index: timemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/timemodule.c,v retrieving revision 2.85 retrieving revision 2.86 diff -C2 -r2.85 -r2.86 *** timemodule.c 2000/06/29 20:56:28 2.85 --- timemodule.c 2000/06/29 21:31:02 2.86 *************** *** 836,843 **** #else /* !MSDOS */ #ifdef MS_WIN32 ! /* XXX Can't interrupt this sleep */ ! Py_BEGIN_ALLOW_THREADS ! Sleep((int)(secs*1000)); ! Py_END_ALLOW_THREADS #else /* !MS_WIN32 */ #ifdef PYOS_OS2 --- 836,850 ---- #else /* !MSDOS */ #ifdef MS_WIN32 ! { ! double millisecs = secs * 1000.0; ! if (millisecs > (double)ULONG_MAX) { ! PyErr_SetString(PyExc_OverflowError, "sleep length is too large"); ! return -1; ! } ! /* XXX Can't interrupt this sleep */ ! Py_BEGIN_ALLOW_THREADS ! Sleep((unsigned long)millisecs); ! Py_END_ALLOW_THREADS ! } #else /* !MS_WIN32 */ #ifdef PYOS_OS2 From python-dev@python.org Thu Jun 29 23:28:46 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 29 Jun 2000 15:28:46 -0700 Subject: [Python-checkins] CVS: python/dist/src README,1.85,1.86 Message-ID: <200006292228.PAA03569@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv3562 Modified Files: README Log Message: Tentative 2.0 and BeOpen upgrade. Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/README,v retrieving revision 1.85 retrieving revision 1.86 diff -C2 -r1.85 -r1.86 *** README 2000/04/11 17:11:09 1.85 --- README 2000/06/29 22:28:44 1.86 *************** *** 1,8 **** ! This is Python version 1.6 ========================== ! There are various alpha and beta versions -- these are distinguishable ! through Include/patchlevel.h or by the name of the top-level directory ! and the tar file. --- 1,8 ---- ! This is Python version 2.0 ========================== ! There are various beta versions -- these are distinguishable through ! Include/patchlevel.h or by the name of the top-level directory and the ! tar file. *************** *** 10,16 **** --------------------------- ! See http://www.python.org/1.6/. If you don't read instructions ------------------------------ --- 10,32 ---- --------------------------- ! See http://www.pythonlabs.com/. + Why is it called version 2.0? + ----------------------------- + + While Pythoneers have grown fond of Python's exceedingly slow version + incrementing, that same quality makes parts of the rest of the world + think that Python is barely out of its first alpha test. Especially + enterprise customers are often fearful of anything that's version 1.x! + The new version number also clearly marks departure of Python's core + development teal from CNRI to join BeOpen.com. + + Previously, the version number 2.0 was associated with a mythical and + elusive incompatible future release. That release (still ways off, + and not as incompatible as people fear!) is now referred to as Python + 3000. + + If you don't read instructions ------------------------------ *************** *** 68,71 **** --- 84,88 ---- + Build instructions ================== *************** *** 106,110 **** If you run into other trouble, see section 3 of the FAQ ! (http://grail.cnri.reston.va.us/cgi-bin/faqw.py or http://www.python.org/doc/FAQ.html) for hints on what can go wrong, and how to fix it. --- 123,127 ---- If you run into other trouble, see section 3 of the FAQ ! (http://www.python.org/cgi-bin/faqw.py or http://www.python.org/doc/FAQ.html) for hints on what can go wrong, and how to fix it. *************** *** 468,477 **** All subdirectories created will have Python's version number in their name, e.g. the library modules are installed in ! "/usr/local/lib/python1.6/" by default. The Python binary is ! installed as "python1.6" and a hard link named "python" is created. The only file not installed with a version number in its name is the manual page, installed as "/usr/local/man/man1/python.1" by default. ! If you have a previous installation of a pre-1.6 Python that you don't want to replace yet, use --- 485,494 ---- All subdirectories created will have Python's version number in their name, e.g. the library modules are installed in ! "/usr/local/lib/python2.0/" by default. The Python binary is ! installed as "python2.0" and a hard link named "python" is created. The only file not installed with a version number in its name is the manual page, installed as "/usr/local/man/man1/python.1" by default. ! If you have a previous installation of a pre-2.0 Python that you don't want to replace yet, use *************** *** 479,483 **** This installs the same set of files as "make install" except it ! doesn't create the hard link to "python1.6" named "python" and it doesn't install the manual page at all. --- 496,500 ---- This installs the same set of files as "make install" except it ! doesn't create the hard link to "python2.0" named "python" and it doesn't install the manual page at all. *************** *** 680,684 **** Misc/python-mode.el. Originally written by the famous Tim Peters, it is now maintained by the equally famous Barry Warsaw ! . The latest version, along with various other contributed Python-related Emacs goodies, is online at . And if you are planning to --- 697,701 ---- Misc/python-mode.el. Originally written by the famous Tim Peters, it is now maintained by the equally famous Barry Warsaw ! . The latest version, along with various other contributed Python-related Emacs goodies, is online at . And if you are planning to *************** *** 832,850 **** config.log Log from last configure run config.status Status from last run of configure script ! libpython1.6.a The library archive python The executable interpreter tags, TAGS Tags files for vi and Emacs ! Author's address ! ================ Guido van Rossum ! CNRI ! 1895 Preston White Drive ! Reston, VA 20191 ! USA ! E-mail: guido@cnri.reston.va.us or guido@python.org --- 849,867 ---- config.log Log from last configure run config.status Status from last run of configure script ! libpython2.0.a The library archive python The executable interpreter tags, TAGS Tags files for vi and Emacs ! ! How to reach the author ! ======================= Guido van Rossum ! BeOpen.com ! 160 Saratoga Avenue, Suite 46 ! Santa Clara, CA 95051 ! E-mail: guido@beopen.com or guido@python.org *************** *** 854,888 **** The Python source is copyrighted, but you can freely use and copy it ! as long as you don't change or remove the copyright notice: ! ! ---------------------------------------------------------------------- ! Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, ! The Netherlands. ! ! All Rights Reserved ! ! Permission to use, copy, modify, and distribute this software and its ! documentation for any purpose and without fee is hereby granted, ! provided that the above copyright notice appear in all copies and that ! both that copyright notice and this permission notice appear in ! supporting documentation, and that the names of Stichting Mathematisch ! Centrum or CWI or Corporation for National Research Initiatives or ! CNRI not be used in advertising or publicity pertaining to ! distribution of the software without specific, written prior ! permission. ! ! While CWI is the initial source for this software, a modified version ! is made available by the Corporation for National Research Initiatives ! (CNRI) at the Internet address ftp://ftp.python.org. ! ! STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH ! REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF ! MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH ! CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL ! DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR ! PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER ! TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR ! PERFORMANCE OF THIS SOFTWARE. ! ---------------------------------------------------------------------- --- 871,876 ---- The Python source is copyrighted, but you can freely use and copy it ! as long as you don't change or remove the copyright notice. The ! copyright notice is found in the Misc/COPYRIGHT file. From python-dev@python.org Thu Jun 29 23:29:26 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 29 Jun 2000 15:29:26 -0700 Subject: [Python-checkins] CVS: python/dist/src/Include patchlevel.h,2.35,2.36 Message-ID: <200006292229.PAA03595@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Include In directory slayer.i.sourceforge.net:/tmp/cvs-serv3588 Modified Files: patchlevel.h Log Message: Bump version to 2.0b1. Index: patchlevel.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/patchlevel.h,v retrieving revision 2.35 retrieving revision 2.36 diff -C2 -r2.35 -r2.36 *** patchlevel.h 2000/04/06 15:01:30 2.35 --- patchlevel.h 2000/06/29 22:29:24 2.36 *************** *** 50,64 **** /* Version parsed out into numeric values */ ! #define PY_MAJOR_VERSION 1 ! #define PY_MINOR_VERSION 6 #define PY_MICRO_VERSION 0 ! #define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_ALPHA ! #define PY_RELEASE_SERIAL 2 /* Version as a string */ ! #define PY_VERSION "1.6a2" /* Historic */ ! #define PATCHLEVEL "1.6a2" /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. --- 50,64 ---- /* Version parsed out into numeric values */ ! #define PY_MAJOR_VERSION 2 ! #define PY_MINOR_VERSION 0 #define PY_MICRO_VERSION 0 ! #define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_BETA ! #define PY_RELEASE_SERIAL 1 /* Version as a string */ ! #define PY_VERSION "2.0b1" /* Historic */ ! #define PATCHLEVEL "2.0b1" /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. From python-dev@python.org Thu Jun 29 23:30:39 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 29 Jun 2000 15:30:39 -0700 Subject: [Python-checkins] CVS: python/dist/src/PC python_nt.rc,1.9,1.10 Message-ID: <200006292230.PAA03748@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv3737 Modified Files: python_nt.rc Log Message: Bump version to 2.0b1. Change copyright to BeOpen, CNRI, SMC. Index: python_nt.rc =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/python_nt.rc,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** python_nt.rc 2000/03/30 22:59:09 1.9 --- python_nt.rc 2000/06/29 22:30:37 1.10 *************** *** 9,18 **** #include "patchlevel.h" ! #define MS_DLL_ID "1.6" #define PYTHON_VERSION MS_DLL_ID "." PYTHON_API_STRING "\0" #ifndef PYTHON_DLL_NAME ! #define PYTHON_DLL_NAME "Python16.dll" #endif --- 9,18 ---- #include "patchlevel.h" ! #define MS_DLL_ID "2.0" #define PYTHON_VERSION MS_DLL_ID "." PYTHON_API_STRING "\0" #ifndef PYTHON_DLL_NAME ! #define PYTHON_DLL_NAME "Python20.dll" #endif *************** *** 45,53 **** BLOCK "000004b0" BEGIN ! VALUE "CompanyName", "Corporation for National Research Initatives\0" VALUE "FileDescription", "Python Core\0" VALUE "FileVersion", PYTHON_VERSION VALUE "InternalName", "Python DLL\0" ! VALUE "LegalCopyright", "Copyright © 1991-1995 Stichting Mathematisch Centrum, Amsterdam\0" VALUE "OriginalFilename", PYTHON_DLL_NAME "\0" VALUE "ProductName", "Python\0" --- 45,53 ---- BLOCK "000004b0" BEGIN ! VALUE "CompanyName", "BeOpen.com\0" VALUE "FileDescription", "Python Core\0" VALUE "FileVersion", PYTHON_VERSION VALUE "InternalName", "Python DLL\0" ! VALUE "LegalCopyright", "Copyright (c) 2000 BeOpen.com. Copyright (c) 1995-2000 CNRI. Copyright (c) 1990-1995 SMC.\0" VALUE "OriginalFilename", PYTHON_DLL_NAME "\0" VALUE "ProductName", "Python\0" From python-dev@python.org Thu Jun 29 23:31:30 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 29 Jun 2000 15:31:30 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild python20.dsp,NONE,1.1 Message-ID: <200006292231.PAA03796@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv3789 Added Files: python20.dsp Log Message: Bump version to 2.0. --- NEW FILE --- # Microsoft Developer Studio Project File - Name="python20" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 # TARGTYPE "Win32 (ALPHA) Dynamic-Link Library" 0x0602 CFG=python20 - Win32 Alpha Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "python20.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "python20.mak" CFG="python20 - Win32 Alpha Debug" !MESSAGE !MESSAGE Possible choices for configuration are: [...1636 lines suppressed...] !ENDIF # End Source File # Begin Source File SOURCE=..\Modules\yuvconvert.c !IF "$(CFG)" == "python20 - Win32 Release" !ELSEIF "$(CFG)" == "python20 - Win32 Debug" !ELSEIF "$(CFG)" == "python20 - Win32 Alpha Debug" !ELSEIF "$(CFG)" == "python20 - Win32 Alpha Release" !ENDIF # End Source File # End Target # End Project From python-dev@python.org Thu Jun 29 23:32:10 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 29 Jun 2000 15:32:10 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild python20.wse,NONE,1.1 Message-ID: <200006292232.PAA03838@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv3830 Added Files: python20.wse Log Message: Bump version to 2.0. --- NEW FILE --- Document Type: WSE item: Global Version=5.0 Title=Python 2.0 alpha 2 Flags=00010100 Languages=65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Japanese Font Name=MS Gothic Japanese Font Size=10 Start Gradient=0 0 255 End Gradient=0 0 0 Windows Flags=00000100000000010010110100001000 Log Pathname=%MAINDIR%\INSTALL.LOG Message Font=MS Sans Serif Font Size=8 Disk Filename=SETUP Patch Flags=0000000000000001 Patch Threshold=85 Patch Memory=4000 Variable Name1=_SYS_ [...1206 lines suppressed...] Text=%APPTITLE% has been successfully installed. Text= Text=Press the Finish button to exit this installation. Text French=%APPTITLE% est maintenant installé. Text French= Text French=Cliquez sur le bouton Fin pour quitter l'installation. Text German=%APPTITLE% wurde erfolgreich installiert. Text German= Text German=Klicken Sie auf "Weiter", um die Installation zu beenden. Text Spanish=%APPTITLE% se ha instalado con éxito. Text Spanish= Text Spanish=Presione el botón Terminar para salir de esta instalación. Text Italian=L'installazione %APPTITLE% è stata portata a termine con successo. Text Italian= Text Italian=Premere il pulsante Fine per uscire dall'installazione. end end end item: End Block end From python-dev@python.org Thu Jun 29 23:57:58 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 29 Jun 2000 15:57:58 -0700 Subject: [Python-checkins] CVS: distutils/distutils cygwinccompiler.py,1.1,1.2 Message-ID: <200006292257.PAA05236@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv5227 Modified Files: cygwinccompiler.py Log Message: Cleaned up and reformatted by Rene Liebscher. More reformatting by me. Also added some editorial comments. Index: cygwinccompiler.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/cygwinccompiler.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** cygwinccompiler.py 2000/06/21 03:33:03 1.1 --- cygwinccompiler.py 2000/06/29 22:57:55 1.2 *************** *** 1,9 **** """distutils.cygwinccompiler ! Contains the CygwinCCompiler class, a subclass of UnixCCompiler that handles ! the Gnu Win32 C compiler. ! It also contains the Mingw32CCompiler class which handles the mingw32 compiler ! (same as cygwin in no-cygwin mode.) ! """ --- 1,8 ---- """distutils.cygwinccompiler ! Provides the CygwinCCompiler class, a subclass of UnixCCompiler that ! handles the Cygwin port of the GNU C compiler to Windows. It also contains ! the Mingw32CCompiler class which handles the mingw32 port of GCC (same as ! cygwin in no-cygwin mode). """ *************** *** 12,47 **** __revision__ = "$Id$" ! import os,sys,string,tempfile from distutils import sysconfig from distutils.unixccompiler import UnixCCompiler ! # Because these compilers aren't configured in Python's config.h file by default ! # we should at least warn the user if he used this unmodified version. ! def check_if_config_h_is_gcc_ready(): ! """ checks, if the gcc-compiler is mentioned in config.h ! if it is not, compiling probably doesn't work """ ! from distutils import sysconfig ! import string,sys try: ! # It would probably better to read single lines to search. ! # But we do this only once, and it is fast enough ! f=open(sysconfig.get_config_h_filename()) ! s=f.read() ! f.close() ! try: ! string.index(s,"__GNUC__") # is somewhere a #ifdef __GNUC__ or something similar ! except: ! sys.stderr.write ("warning: Python's config.h doesn't seem to support your compiler.\n") ! except: # unspecific error => ignore ! pass # This is called when the module is imported, so we make this check only once ! check_if_config_h_is_gcc_ready() - # XXX Things not currently handled: - # * see UnixCCompiler - class CygwinCCompiler (UnixCCompiler): --- 11,54 ---- __revision__ = "$Id$" ! import os,sys,string from distutils import sysconfig from distutils.unixccompiler import UnixCCompiler ! # Because these compilers aren't configured in Python's config.h file by ! # default we should at least warn the user if he is using a unmodified ! # version. ! ! def check_config_h(): ! """Checks if the GCC compiler is mentioned in config.h. If it is not, ! compiling probably doesn't work, so print a warning to stderr. ! """ ! ! # XXX the result of the check should be returned! ! ! from distutils import sysconfig ! import string,sys ! try: ! # It would probably better to read single lines to search. ! # But we do this only once, and it is fast enough ! f=open(sysconfig.get_config_h_filename()) ! s=f.read() ! f.close() try: ! # is somewhere a #ifdef __GNUC__ or something similar ! string.index(s,"__GNUC__") ! except ValueError: ! sys.stderr.write ("warning: "+ ! "Python's config.h doesn't seem to support your compiler.\n") ! except IOError: ! # if we can't read this file, we cannot say it is wrong ! # the compiler will complain later about this file as missing ! pass # This is called when the module is imported, so we make this check only once ! # XXX why not make it only when the compiler is needed? ! check_config_h() class CygwinCCompiler (UnixCCompiler): *************** *** 55,73 **** UnixCCompiler.__init__ (self, verbose, dry_run, force) ! # our compiler uses other names ! self.cc='gcc' ! self.ld_shared='dllwrap' ! self.ldflags_shared=[] ! ! # some variables to manage the differences between cygwin and mingw32 ! self.dllwrap_options=["--target=i386-cygwin32"] ! # specification of entry point is not necessary ! ! self.dll_additional_libraries=[ ! # cygwin shouldn't need msvcrt, but without the dll's will crash ! # perhaps something about initialization (Python uses it, too) # mingw32 needs it in all cases ! "msvcrt" ! ] # __init__ () --- 62,81 ---- UnixCCompiler.__init__ (self, verbose, dry_run, force) ! # Hard-code GCC because that's what this is all about. ! # XXX optimization, warnings etc. should be customizable. ! self.set_executables(compiler='gcc -O -Wall', ! compiler_so='gcc -O -Wall', ! linker_exe='gcc', ! linker_so='dllwrap --target=i386-cygwin32') ! ! # cygwin and mingw32 need different sets of libraries ! self.dll_libraries=[ ! # cygwin shouldn't need msvcrt, ! # but without the dll's will crash ! # ( gcc version 2.91.57 ) ! # perhaps something about initialization # mingw32 needs it in all cases ! "msvcrt" ! ] # __init__ () *************** *** 81,139 **** runtime_library_dirs=None, export_symbols=None, ! debug=0, extra_preargs=None, ! extra_postargs=None): ! ! if libraries==None: ! libraries=[] ! python_library=["python"+str(sys.hexversion>>24)+str((sys.hexversion>>16)&0xff)] ! libraries=libraries+python_library+self.dll_additional_libraries ! # if you don't need the def-file afterwards, it is ! # better to use for it tempfile.mktemp() as its name ! # (unix-style compilers don't like backslashes in filenames) ! win_dll_def_file=string.replace(tempfile.mktemp(),"\\","/") ! #win_dll_def_file=output_filename[:-len(self.shared_lib_extension)]+".def" ! #win_dll_exp_file=output_filename[:-len(self.shared_lib_extension)]+".exp" ! #win_dll_lib_file=output_filename[:-len(self.shared_lib_extension)]+".a" # Make .def file ! # (It would probably better to check if we really need this, but for this we had to ! # insert some unchanged parts of UnixCCompiler, and this is not what I want.) ! f=open(win_dll_def_file,"w") f.write("EXPORTS\n") # intro ! # always export a function "init"+module_name ! if not debug: ! f.write("init"+os.path.basename(output_filename)[:-len(self.shared_lib_extension)]+"\n") ! else: # in debug mode outfile_name is something like XXXXX_d.pyd ! f.write("init"+os.path.basename(output_filename)[:-(len(self.shared_lib_extension)+2)]+"\n") ! # if there are more symbols to export ! # insert code here to write them in f ! if export_symbols!=None: for sym in export_symbols: ! f.write(sym+"\n") f.close() ! if extra_preargs==None: ! extra_preargs=[] ! extra_preargs=extra_preargs+[ #"--verbose", ! #"--output-exp",win_dll_exp_file, ! #"--output-lib",win_dll_lib_file, ! "--def",win_dll_def_file ! ]+ self.dllwrap_options ! # who wants symbols and a many times greater output file # should explicitely switch the debug mode on ! # otherwise we let dllwrap strip the outputfile ! # (On my machine unstripped_file=stripped_file+254KB # 10KB < stripped_file < ??100KB ) if not debug: ! extra_preargs=extra_preargs+["-s"] ! ! try: ! UnixCCompiler.link_shared_object(self, objects, output_filename, --- 89,157 ---- runtime_library_dirs=None, export_symbols=None, ! debug=0, extra_preargs=None, ! extra_postargs=None, ! build_temp=None): ! if libraries == None: ! libraries = [] ! # Additional libraries: the python library is always needed on ! # Windows we need the python version without the dot, eg. '15' ! ! pythonlib = ("python%d%d" % ! (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff)) ! libraries.append(pythonlib) ! libraries.extend(self.dll_libraries) ! ! # name of extension ! ! # XXX WRONG WRONG WRONG ! # this is NOT the place to make guesses about Python namespaces; ! # that MUST be done in build_ext.py ! ! if not debug: ! ext_name = os.path.basename(output_filename)[:-len(".pyd")] ! else: ! ext_name = os.path.basename(output_filename)[:-len("_d.pyd")] ! ! def_file = os.path.join(build_temp, ext_name + ".def") ! #exp_file = os.path.join(build_temp, ext_name + ".exp") ! #lib_file = os.path.join(build_temp, 'lib' + ext_name + ".a") # Make .def file ! # (It would probably better to check if we really need this, ! # but for this we had to insert some unchanged parts of ! # UnixCCompiler, and this is not what we want.) ! f = open(def_file,"w") f.write("EXPORTS\n") # intro ! if export_symbols == None: ! # export a function "init" + ext_name ! f.write("init" + ext_name + "\n") ! else: ! # if there are more symbols to export write them into f for sym in export_symbols: ! f.write(sym+"\n") f.close() ! if extra_preargs == None: ! extra_preargs = [] ! extra_preargs = extra_preargs + [ #"--verbose", ! #"--output-exp",exp_file, ! #"--output-lib",lib_file, ! "--def",def_file ! ] ! # who wants symbols and a many times larger output file # should explicitely switch the debug mode on ! # otherwise we let dllwrap strip the output file ! # (On my machine unstripped_file = stripped_file + 254KB # 10KB < stripped_file < ??100KB ) if not debug: ! extra_preargs = extra_preargs + ["-s"] ! ! UnixCCompiler.link_shared_object(self, objects, output_filename, *************** *** 142,152 **** library_dirs, runtime_library_dirs, ! None, # export_symbols, we do this with our def-file debug, extra_preargs, ! extra_postargs) ! finally: ! # we don't need the def-file anymore ! os.remove(win_dll_def_file) # link_shared_object () --- 160,168 ---- library_dirs, runtime_library_dirs, ! None, # export_symbols, we do this with our def-file debug, extra_preargs, ! extra_postargs, ! build_temp) # link_shared_object () *************** *** 154,157 **** --- 170,174 ---- # class CygwinCCompiler + # the same as cygwin plus some additional parameters class Mingw32CCompiler (CygwinCCompiler): *************** *** 165,177 **** CygwinCCompiler.__init__ (self, verbose, dry_run, force) - self.ccflags = self.ccflags + ["-mno-cygwin"] - self.dllwrap_options=[ - # mingw32 doesn't really need 'target' - # and cygwin too (it seems, it is enough - # to specify a different entry point) - #"--target=i386-mingw32", - "--entry","_DllMain@12" - ] # no additional libraries need # (only msvcrt, which is already added by CygwinCCompiler) --- 182,195 ---- CygwinCCompiler.__init__ (self, verbose, dry_run, force) + + self.set_executables(compiler='gcc -mno-cygwin -O -Wall', + compiler_so='gcc -mno-cygwin -O -Wall', + linker_exe='gcc -mno-cygwin', + linker_so='dllwrap' + + ' --target=i386-mingw32' + + ' --entry _DllMain@12') + # mingw32 doesn't really need 'target' and cygwin too (it seems, + # it is enough to specify a different entry point) # no additional libraries need # (only msvcrt, which is already added by CygwinCCompiler) From python-dev@python.org Thu Jun 29 23:59:13 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 29 Jun 2000 15:59:13 -0700 Subject: [Python-checkins] CVS: distutils/distutils msvccompiler.py,1.32,1.33 Message-ID: <200006292259.PAA05290@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv5280 Modified Files: msvccompiler.py Log Message: Changed to use _winreg module instead of winreg. Index: msvccompiler.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/msvccompiler.py,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -r1.32 -r1.33 *** msvccompiler.py 2000/06/28 01:29:09 1.32 --- msvccompiler.py 2000/06/29 22:59:10 1.33 *************** *** 21,32 **** _can_read_reg = 0 try: ! import winreg _can_read_reg = 1 ! hkey_mod = winreg ! RegOpenKeyEx = winreg.OpenKeyEx ! RegEnumKey = winreg.EnumKey ! RegEnumValue = winreg.EnumValue ! RegError = winreg.error except ImportError: --- 21,32 ---- _can_read_reg = 0 try: ! import _winreg _can_read_reg = 1 ! hkey_mod = _winreg ! RegOpenKeyEx = _winreg.OpenKeyEx ! RegEnumKey = _winreg.EnumKey ! RegEnumValue = _winreg.EnumValue ! RegError = _winreg.error except ImportError: From python-dev@python.org Fri Jun 30 00:01:43 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 16:01:43 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/tools mkhowto,1.8,1.9 Message-ID: <200006292301.QAA09700@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/tools In directory slayer.i.sourceforge.net:/tmp/cvs-serv9587 Modified Files: mkhowto Log Message: Removed --l2h-config option; it introduced unnecessary complexity and is not needed anywhere. Index: mkhowto =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tools/mkhowto,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** mkhowto 2000/04/03 04:19:14 1.8 --- mkhowto 2000/06/29 23:01:40 1.9 *************** *** 95,99 **** def __init__(self): - self.config_files = [] self.formats = [] --- 95,98 ---- *************** *** 108,112 **** opts, args = getopt.getopt(args, "Hi:a:s:lDkqr:", ["all", "postscript", "help", "iconserver=", ! "address=", "a4", "l2h-config=", "letter", "link=", "split=", "logging", "debugging", "keep", "quiet", "runs=", "image-type=", --- 107,111 ---- opts, args = getopt.getopt(args, "Hi:a:s:lDkqr:", ["all", "postscript", "help", "iconserver=", ! "address=", "a4", "letter", "link=", "split=", "logging", "debugging", "keep", "quiet", "runs=", "image-type=", *************** *** 127,132 **** elif opt == "--letter": self.paper = "letter" - elif opt == "--l2h-config": - self.config_files.append(arg) elif opt == "--link": self.max_link_depth = int(arg) --- 126,129 ---- *************** *** 371,380 **** ) options = self.options - for fn in options.config_files: - fp.write(open(fn).read()) - fp.write("\n" - "\n" - 'print "\nInitializing from file: %s\";\n\n' - % string_to_perl(fn)) l2hoption(fp, "ABOUT_FILE", options.about_file) l2hoption(fp, "ICONSERVER", options.icon_server) --- 368,371 ---- From python-dev@python.org Fri Jun 30 00:05:01 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 29 Jun 2000 16:05:01 -0700 Subject: [Python-checkins] CVS: distutils/distutils msvccompiler.py,1.33,1.34 Message-ID: <200006292305.QAA11929@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv11914 Modified Files: msvccompiler.py Log Message: On second thought, first try for _winreg, and then winreg. Only if both fail do we try for win32api/win32con. If *those* both fail, then we don't have registry access. Phew! Index: msvccompiler.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/msvccompiler.py,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -r1.33 -r1.34 *** msvccompiler.py 2000/06/29 22:59:10 1.33 --- msvccompiler.py 2000/06/29 23:04:59 1.34 *************** *** 21,25 **** _can_read_reg = 0 try: ! import _winreg _can_read_reg = 1 hkey_mod = _winreg --- 21,29 ---- _can_read_reg = 0 try: ! try: ! import _winreg ! except ImportError: ! import winreg # for pre-2000/06/29 CVS Python ! _can_read_reg = 1 hkey_mod = _winreg From python-dev@python.org Fri Jun 30 00:09:23 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 29 Jun 2000 16:09:23 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command build_ext.py,1.53,1.54 Message-ID: <200006292309.QAA12142@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv12132/command Modified Files: build_ext.py Log Message: Don't try to guess the name of a .def file -- if one is supplied, use it, otherwise just generate an '/export:' option. Index: build_ext.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/build_ext.py,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -r1.53 -r1.54 *** build_ext.py 2000/06/29 02:16:24 1.53 --- build_ext.py 2000/06/29 23:09:20 1.54 *************** *** 529,538 **** def_file = ext.export_symbol_file - if def_file is None: - source_dir = os.path.dirname (sources[0]) - ext_base = (string.split (ext.name, '.'))[-1] - def_file = os.path.join (source_dir, "%s.def" % ext_base) - if not os.path.exists (def_file): - def_file = None if def_file is not None: --- 529,532 ---- From python-dev@python.org Fri Jun 30 00:33:14 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 16:33:14 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre_compile.py,1.11,1.12 Message-ID: <200006292333.QAA13565@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv12640/Lib Modified Files: sre_compile.py Log Message: still trying to figure out how to fix the remaining group reset problem. in the meantime, I added some optimizations: - added "inline" directive to LOCAL (this assumes that AC_C_INLINE does what it's supposed to do). to compile SRE on a non-unix platform that doesn't support inline, you have to add a "#define inline" somewhere... - added code to generate a SRE_OP_INFO primitive - added code to do fast prefix search (enabled by the USE_FAST_SEARCH define; default is on, in this release) Index: sre_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** sre_compile.py 2000/06/29 18:03:25 1.11 --- sre_compile.py 2000/06/29 23:33:11 1.12 *************** *** 24,27 **** --- 24,28 ---- def _compile(code, pattern, flags): + # internal: compile a (sub)pattern emit = code.append for op, av in pattern: *************** *** 153,158 **** --- 154,204 ---- raise ValueError, ("unsupported operand type", op) + def _compile_info(code, pattern, flags): + # internal: compile an info block. in the current version, + # this contains min/max pattern width and a literal prefix, + # if any + lo, hi = pattern.getwidth() + if lo == 0: + return # not worth it + # look for a literal prefix + prefix = [] + if not (flags & SRE_FLAG_IGNORECASE): + for op, av in pattern.data: + if op is LITERAL: + prefix.append(ord(av)) + else: + break + # add an info block + emit = code.append + emit(OPCODES[INFO]) + skip = len(code); emit(0) + # literal flag + mask = 0 + if len(prefix) == len(pattern.data): + mask = 1 + emit(mask) + # pattern length + emit(lo) + if hi < 32768: + emit(hi) + else: + emit(0) + # add literal prefix + emit(len(prefix)) + if prefix: + code.extend(prefix) + # generate overlap table + table = [-1] + ([0]*len(prefix)) + for i in range(len(prefix)): + table[i+1] = table[i]+1 + while table[i+1] > 0 and prefix[i] != prefix[table[i+1]-1]: + table[i+1] = table[table[i+1]-1]+1 + code.extend(table[1:]) # don't store first entry + code[skip] = len(code) - skip + def compile(p, flags=0): # internal: convert pattern list to internal format + + # compile, as necessary if type(p) in (type(""), type(u"")): import sre_parse *************** *** 161,171 **** else: pattern = None flags = p.pattern.flags | flags code = [] _compile(code, p.data, flags) code.append(OPCODES[SUCCESS]) ! # FIXME: get rid of this limitation assert p.pattern.groups <= 100,\ "sorry, but this version only supports 100 named groups" return _sre.compile( pattern, flags, --- 207,226 ---- else: pattern = None + flags = p.pattern.flags | flags code = [] + + # compile info block + _compile_info(code, p, flags) + + # compile the pattern _compile(code, p.data, flags) + code.append(OPCODES[SUCCESS]) ! ! # FIXME: get rid of this limitation! assert p.pattern.groups <= 100,\ "sorry, but this version only supports 100 named groups" + return _sre.compile( pattern, flags, From python-dev@python.org Fri Jun 30 00:33:14 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 16:33:14 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.11,2.12 Message-ID: <200006292333.QAA13569@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv12640/Modules Modified Files: _sre.c Log Message: still trying to figure out how to fix the remaining group reset problem. in the meantime, I added some optimizations: - added "inline" directive to LOCAL (this assumes that AC_C_INLINE does what it's supposed to do). to compile SRE on a non-unix platform that doesn't support inline, you have to add a "#define inline" somewhere... - added code to generate a SRE_OP_INFO primitive - added code to do fast prefix search (enabled by the USE_FAST_SEARCH define; default is on, in this release) Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.11 retrieving revision 2.12 diff -C2 -r2.11 -r2.12 *** _sre.c 2000/06/29 18:03:25 2.11 --- _sre.c 2000/06/29 23:33:12 2.12 *************** *** 20,23 **** --- 20,24 ---- * 00-06-28 fl fixed findall (0.9.1) * 00-06-29 fl fixed split, added more scanner features (0.9.2) + * 00-06-30 fl tuning, fast search (0.9.3) * * Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. *************** *** 30,35 **** #ifndef SRE_RECURSIVE ! static char ! copyright[] = " SRE 0.9.2 Copyright (c) 1997-2000 by Secret Labs AB "; #include "Python.h" --- 31,35 ---- #ifndef SRE_RECURSIVE ! char copyright[] = " SRE 0.9.3 Copyright (c) 1997-2000 by Secret Labs AB "; #include "Python.h" *************** *** 56,59 **** --- 56,62 ---- #endif + /* optional features */ + #define USE_FAST_SEARCH + #if defined(_MSC_VER) #pragma optimize("agtw", on) /* doesn't seem to make much difference... */ *************** *** 61,65 **** #define LOCAL(type) static __inline type __fastcall #else ! #define LOCAL(type) static type #endif --- 64,68 ---- #define LOCAL(type) static __inline type __fastcall #else ! #define LOCAL(type) static inline type #endif *************** *** 397,400 **** --- 400,414 ---- TRACE(("%8d: enter\n", PTR(ptr))); + if (pattern[0] == SRE_OP_INFO) { + /* optimization info block */ + /* args: <1=skip> <2=flags> <3=min> ... */ + if (pattern[3] && (end - ptr) < pattern[3]) { + TRACE(("reject (got %d chars, need %d)\n", + (end - ptr), pattern[3])); + return 0; + } + pattern += pattern[1] + 1; + } + stackbase = stack = state->stackbase; lastmark = state->lastmark; *************** *** 918,935 **** int status = 0; int prefix_len = 0; ! SRE_CODE* prefix = NULL; if (pattern[0] == SRE_OP_INFO) { ! /* args: */ ! end -= pattern[2]; ! prefix_len = pattern[4]; ! prefix = pattern + 5; ! pattern += pattern[1]; } ! /* if (prefix_len > 0) ... */ if (pattern[0] == SRE_OP_LITERAL) { ! /* pattern starts with a literal */ SRE_CHAR chr = (SRE_CHAR) pattern[1]; for (;;) { --- 932,1001 ---- int status = 0; int prefix_len = 0; ! SRE_CODE* prefix; ! SRE_CODE* overlap; ! int literal = 0; if (pattern[0] == SRE_OP_INFO) { ! /* optimization info block */ ! /* args: <1=skip> <2=flags> <3=min> <4=max> <5=prefix> <6=data...> */ ! ! if (pattern[3] > 0) { ! /* adjust end point (but make sure we leave at least one ! character in there) */ ! end -= pattern[3]-1; ! if (end <= ptr) ! end = ptr+1; ! } ! ! literal = pattern[2]; ! ! prefix = pattern + 6; ! prefix_len = pattern[5]; ! ! overlap = prefix + prefix_len - 1; ! ! pattern += 1 + pattern[1]; } ! #if defined(USE_FAST_SEARCH) ! if (prefix_len > 1) { ! /* pattern starts with a known prefix. use the overlap ! table to skip forward as fast as we possibly can */ ! int i = 0; ! end = state->end; ! while (ptr < end) { ! for (;;) { ! if (*ptr != (SRE_CHAR) prefix[i]) { ! if (!i) ! break; ! else ! i = overlap[i]; ! } else { ! if (++i == prefix_len) { ! /* found a potential match */ ! TRACE(("%8d: === SEARCH === hit\n", PTR(ptr))); ! state->start = ptr - prefix_len + 1; ! state->ptr = ptr + 1; ! if (literal) ! return 1; /* all of it */ ! status = SRE_MATCH(state, pattern + 2*prefix_len); ! if (status != 0) ! return status; ! /* close but no cigar -- try again */ ! i = overlap[i]; ! } ! break; ! } ! ! } ! ptr++; ! } ! return 0; ! } ! #endif if (pattern[0] == SRE_OP_LITERAL) { ! /* pattern starts with a literal character. this is used for ! short prefixes, and if fast search is disabled*/ SRE_CHAR chr = (SRE_CHAR) pattern[1]; for (;;) { *************** *** 945,950 **** break; } - } else while (ptr <= end) { TRACE(("%8d: === SEARCH ===\n", PTR(ptr))); --- 1011,1016 ---- break; } } else + /* general case */ while (ptr <= end) { TRACE(("%8d: === SEARCH ===\n", PTR(ptr))); From python-dev@python.org Fri Jun 30 00:50:22 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 29 Jun 2000 16:50:22 -0700 Subject: [Python-checkins] CVS: distutils/distutils/command bdist_wininst.py,1.2,1.3 Message-ID: <200006292350.QAA14433@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils/command In directory slayer.i.sourceforge.net:/tmp/cvs-serv14417/command Modified Files: bdist_wininst.py Log Message: Allow 2.0 on the list of target versions. NB. this isn't enough: the GUI part, misc/install.c, still needs to be updated, and it looks like a non-trivial change. Index: bdist_wininst.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/command/bdist_wininst.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** bdist_wininst.py 2000/06/28 00:56:20 1.2 --- bdist_wininst.py 2000/06/29 23:50:19 1.3 *************** *** 28,32 **** ('target-version=', 'v', "require a specific python version" + ! " on the target system (1.5 or 1.6)"), ] --- 28,32 ---- ('target-version=', 'v', "require a specific python version" + ! " on the target system (1.5 or 1.6/2.0)"), ] *************** *** 48,54 **** self.target_version = "" else: ! if not self.target_version in ("1.5", "1.6"): raise DistutilsOptionError ( ! "target version must be 1.5 or 1.6") if self.distribution.has_ext_modules(): short_version = sys.version[:3] --- 48,54 ---- self.target_version = "" else: ! if not self.target_version in ("1.5", "1.6", "2.0"): raise DistutilsOptionError ( ! "target version must be 1.5, 1.6, or 2.0") if self.distribution.has_ext_modules(): short_version = sys.version[:3] *************** *** 75,80 **** # on the TARGET system instead at the SOURCE system. ! ## # The compilation can only be done on the SOURCE system ! ## # for one python version (assuming 1.6 and 1.5 have incompatible ## # byte-codes). ## short_version = sys.version[:3] --- 75,80 ---- # on the TARGET system instead at the SOURCE system. ! ## # The compilation can only be done on the SOURCE system for one ! ## # python version (assuming 1.6/2.0 and 1.5 have incompatible ## # byte-codes). ## short_version = sys.version[:3] From python-dev@python.org Fri Jun 30 01:27:48 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 17:27:48 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.12,2.13 Message-ID: <200006300027.RAA22644@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv22449/Modules Modified Files: _sre.c Log Message: - fixed split behaviour on empty matches - fixed compiler problems when using locale/unicode flags - fixed group/octal code parsing in sub/subn templates Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.12 retrieving revision 2.13 diff -C2 -r2.12 -r2.13 *** _sre.c 2000/06/29 23:33:12 2.12 --- _sre.c 2000/06/30 00:27:46 2.13 *************** *** 1535,1538 **** --- 1535,1541 ---- return Py_BuildValue("i", self->flags); + if (!strcmp(name, "groups")) + return Py_BuildValue("i", self->groups); + if (!strcmp(name, "groupindex") && self->groupindex) { Py_INCREF(self->groupindex); *************** *** 1939,1945 **** return self->pattern; } - - if (!strcmp(name, "groups")) - return Py_BuildValue("i", ((PatternObject*) self->pattern)->groups); PyErr_SetString(PyExc_AttributeError, name); --- 1942,1945 ---- From python-dev@python.org Fri Jun 30 01:27:48 2000 From: python-dev@python.org (Fredrik Lundh) Date: Thu, 29 Jun 2000 17:27:48 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre.py,1.13,1.14 sre_compile.py,1.12,1.13 sre_parse.py,1.11,1.12 Message-ID: <200006300027.RAA22643@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv22449/Lib Modified Files: sre.py sre_compile.py sre_parse.py Log Message: - fixed split behaviour on empty matches - fixed compiler problems when using locale/unicode flags - fixed group/octal code parsing in sub/subn templates Index: sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** sre.py 2000/06/29 18:03:25 1.13 --- sre.py 2000/06/30 00:27:45 1.14 *************** *** 110,123 **** if not m: break ! j = m.start() ! if j > i: ! append(string[i:j]) append(filter(m)) ! i = m.end() ! if i <= j: ! break n = n + 1 ! if i < len(string): ! append(string[i:]) return string[:0].join(s), n --- 110,120 ---- if not m: break ! b, e = m.span() ! if i < b: ! append(string[i:b]) append(filter(m)) ! i = e n = n + 1 ! append(string[i:]) return string[:0].join(s), n *************** *** 129,133 **** extend = s.extend c = pattern.scanner(string) ! g = c.groups while not maxsplit or n < maxsplit: m = c.search() --- 126,130 ---- extend = s.extend c = pattern.scanner(string) ! g = pattern.groups while not maxsplit or n < maxsplit: m = c.search() Index: sre_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** sre_compile.py 2000/06/29 23:33:11 1.12 --- sre_compile.py 2000/06/30 00:27:45 1.13 *************** *** 62,68 **** emit(OPCODES[op]) if flags & SRE_FLAG_LOCALE: ! emit(CH_LOCALE[CHCODES[av]]) elif flags & SRE_FLAG_UNICODE: ! emit(CH_UNICODE[CHCODES[av]]) else: emit(CHCODES[av]) --- 62,68 ---- emit(OPCODES[op]) if flags & SRE_FLAG_LOCALE: ! emit(CHCODES[CH_LOCALE[av]]) elif flags & SRE_FLAG_UNICODE: ! emit(CHCODES[CH_UNICODE[av]]) else: emit(CHCODES[av]) *************** *** 93,99 **** elif op is CATEGORY: if flags & SRE_FLAG_LOCALE: ! emit(CH_LOCALE[CHCODES[av]]) elif flags & SRE_FLAG_UNICODE: ! emit(CH_UNICODE[CHCODES[av]]) else: emit(CHCODES[av]) --- 93,99 ---- elif op is CATEGORY: if flags & SRE_FLAG_LOCALE: ! emit(CHCODES[CH_LOCALE[av]]) elif flags & SRE_FLAG_UNICODE: ! emit(CHCODES[CH_UNICODE[av]]) else: emit(CHCODES[av]) Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** sre_parse.py 2000/06/29 18:03:25 1.11 --- sre_parse.py 2000/06/30 00:27:45 1.12 *************** *** 31,54 **** ESCAPES = { ! "\\a": (LITERAL, chr(7)), ! "\\b": (LITERAL, chr(8)), ! "\\f": (LITERAL, chr(12)), ! "\\n": (LITERAL, chr(10)), ! "\\r": (LITERAL, chr(13)), ! "\\t": (LITERAL, chr(9)), ! "\\v": (LITERAL, chr(11)) } CATEGORIES = { ! "\\A": (AT, AT_BEGINNING), # start of string ! "\\b": (AT, AT_BOUNDARY), ! "\\B": (AT, AT_NON_BOUNDARY), ! "\\d": (IN, [(CATEGORY, CATEGORY_DIGIT)]), ! "\\D": (IN, [(CATEGORY, CATEGORY_NOT_DIGIT)]), ! "\\s": (IN, [(CATEGORY, CATEGORY_SPACE)]), ! "\\S": (IN, [(CATEGORY, CATEGORY_NOT_SPACE)]), ! "\\w": (IN, [(CATEGORY, CATEGORY_WORD)]), ! "\\W": (IN, [(CATEGORY, CATEGORY_NOT_WORD)]), ! "\\Z": (AT, AT_END), # end of string } --- 31,55 ---- ESCAPES = { ! r"\a": (LITERAL, chr(7)), ! r"\b": (LITERAL, chr(8)), ! r"\f": (LITERAL, chr(12)), ! r"\n": (LITERAL, chr(10)), ! r"\r": (LITERAL, chr(13)), ! r"\t": (LITERAL, chr(9)), ! r"\v": (LITERAL, chr(11)), ! r"\\": (LITERAL, "\\") } CATEGORIES = { ! r"\A": (AT, AT_BEGINNING), # start of string ! r"\b": (AT, AT_BOUNDARY), ! r"\B": (AT, AT_NON_BOUNDARY), ! r"\d": (IN, [(CATEGORY, CATEGORY_DIGIT)]), ! r"\D": (IN, [(CATEGORY, CATEGORY_NOT_DIGIT)]), ! r"\s": (IN, [(CATEGORY, CATEGORY_SPACE)]), ! r"\S": (IN, [(CATEGORY, CATEGORY_NOT_SPACE)]), ! r"\w": (IN, [(CATEGORY, CATEGORY_WORD)]), ! r"\W": (IN, [(CATEGORY, CATEGORY_NOT_WORD)]), ! r"\Z": (AT, AT_END), # end of string } *************** *** 186,194 **** return 1 ! def _group(escape, state): # check if the escape string represents a valid group try: group = int(escape[1:]) ! if group and group < state.groups: return group except ValueError: --- 187,195 ---- return 1 ! def _group(escape, groups): # check if the escape string represents a valid group try: group = int(escape[1:]) ! if group and group < groups: return group except ValueError: *************** *** 240,247 **** elif escape[1:2] in DIGITS: while 1: ! group = _group(escape, state) if group: if (not source.next or ! not _group(escape + source.next, state)): return GROUP, group escape = escape + source.get() --- 241,248 ---- elif escape[1:2] in DIGITS: while 1: ! group = _group(escape, state.groups) if group: if (not source.next or ! not _group(escape + source.next, state.groups)): return GROUP, group escape = escape + source.get() *************** *** 535,538 **** --- 536,540 ---- break # end of replacement string if this and this[0] == "\\": + # group if this == "\\g": name = "" *************** *** 558,570 **** a((MARK, index)) elif len(this) > 1 and this[1] in DIGITS: ! while s.next in DIGITS: ! this = this + s.get() ! a((MARK, int(this[1:]))) else: try: a(ESCAPES[this]) except KeyError: ! for char in this: ! a((LITERAL, char)) else: a((LITERAL, this)) --- 560,586 ---- a((MARK, index)) elif len(this) > 1 and this[1] in DIGITS: ! code = None ! while 1: ! group = _group(this, pattern.groups+1) ! if group: ! if (not s.next or ! not _group(this + s.next, pattern.groups+1)): ! code = MARK, int(group) ! break ! elif s.next in OCTDIGITS: ! this = this + s.get() ! else: ! break ! if not code: ! this = this[1:] ! # FIXME: support unicode characters! ! code = LITERAL, chr(int(this[-6:], 8) & 0xff) ! a(code) else: try: a(ESCAPES[this]) except KeyError: ! for c in this: ! a((LITERAL, c)) else: a((LITERAL, this)) From python-dev@python.org Fri Jun 30 02:05:42 2000 From: python-dev@python.org (A.M. Kuchling) Date: Thu, 29 Jun 2000 18:05:42 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libcurses.tex,1.6,1.7 Message-ID: <200006300105.SAA30792@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv30763 Modified Files: libcurses.tex Log Message: Document recently-added mouse-related functions Index: libcurses.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcurses.tex,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** libcurses.tex 2000/06/28 22:11:40 1.6 --- libcurses.tex 2000/06/30 01:05:39 1.7 *************** *** 131,134 **** --- 131,155 ---- \end{funcdesc} + \begin{funcdesc}{getmouse}{} + After \method{getch()} returns \constant{KEY_MOUSE} to signal a mouse + event, this method should be call to retrieve the queued mouse event, + represented as a 5-tuple + \code{(\var{id}, \var{x}, \var{y}, \var{z}, \var{bstate})}. + \var{id} is an ID value used to distinguish multiple devices, + and \var{x}, \var{y}, \var{z} are the event's coordinates. (\var{z} + is currently unused.). \var{bstate} is an integer value whose bits + will be set to indicate the type of event, and will be the bitwise OR + of one or more of the following constants, where \var{n} is the button + number from 1 to 4: + \constant{BUTTON\var{n}_PRESSED}, + \constant{BUTTON\var{n}_RELEASED}, + \constant{BUTTON\var{n}_CLICKED}, + \constant{BUTTON\var{n}_DOUBLE_CLICKED}, + \constant{BUTTON\var{n}_TRIPLE_CLICKED}, + \constant{BUTTON_SHIFT}, + \constant{BUTTON_CTRL}, + \constant{BUTTON_ALT}. + \end{funcdesc} + \begin{funcdesc}{getsyx}{} Returns the current coordinates of the virtual screen cursor in y and *************** *** 222,225 **** --- 243,263 ---- \end{funcdesc} + \begin{funcdesc}{mouseinterval}{interval} + Sets the maximum time in millisecondsthat can elapse between press and + release events in order for them to be recognized as a click, and + returns the previous interval value. The default value is 200 msec, + or one fifth of a second. + \end{funcdesc} + + \begin{funcdesc}{mousemask}{mousemask} + Sets the mouse events to be reported, and returns a tuple + \code{(\var{availmask}, \var{oldmask})}. + \var{availmask} indicates which of the + specified mouse events can be reported; on complete failure it returns + 0. \var{oldmask} is the previous value of the given window's mouse + event mask. If this function is never called, no mouse events are + ever reported. + \end{funcdesc} + \begin{funcdesc}{newpad}{nlines, ncols} Creates and returns a pointer to a new pad data structure with the *************** *** 371,374 **** --- 409,417 ---- \end{funcdesc} + \begin{funcdesc}{ungetmouse}{id, x, y, z, bstate} + Push a \constant{KEY_MOUSE} event onto the input queue, associating + the given state data with it. + \end{funcdesc} + \begin{funcdesc}{use_env}{flag} If used, this function should be called before \function{initscr} or *************** *** 521,524 **** --- 564,574 ---- Add character \var{ch} with attribute \var{attr}, and immediately call \method{refresh}. + \end{methoddesc} + + \begin{methoddesc}{enclose}{y, x} + Tests whether the given pair of screen-relative character-cell + coordinates are enclosed by the given window, returning true or + false. It is useful for determining what subset of the screen + windows enclose the location of a mouse event. \end{methoddesc} From python-dev@python.org Fri Jun 30 03:29:24 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 29 Jun 2000 19:29:24 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules cmathmodule.c,2.12,2.13 Message-ID: <200006300229.TAA09177@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv9169 Modified Files: cmathmodule.c Log Message: Patch by Nadav Horesh to make acosh and asinh better. Tim posted a long comment to python-dev (subject: "Controversial patch (cmath)"; date: 6/29/00). The conclusion is that this whole module stinks and this patch isn't perfect, but it's better than the acosh and asinh we had, so let's check it in. Index: cmathmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cmathmodule.c,v retrieving revision 2.12 retrieving revision 2.13 diff -C2 -r2.12 -r2.13 *** cmathmodule.c 1999/03/16 14:17:48 2.12 --- cmathmodule.c 2000/06/30 02:29:22 2.13 *************** *** 58,63 **** Py_complex x; { ! return c_log(c_sum(x,c_prod(c_i, ! c_sqrt(c_diff(c_1,c_prod(x,x)))))); } --- 58,66 ---- Py_complex x; { ! Py_complex z; ! z = c_sqrt(c_half); ! z = c_log(c_prod(z, c_sum(c_sqrt(c_sum(x,c_1)), ! c_sqrt(c_diff(x,c_1))))); ! return c_sum(z, z); } *************** *** 71,76 **** Py_complex x; { ! return c_neg(c_prodi(c_log(c_sum(c_prod(c_i,x), ! c_sqrt(c_diff(c_1,c_prod(x,x))))))); } --- 74,82 ---- Py_complex x; { ! Py_complex z; ! z = c_sqrt(c_half); ! z = c_log(c_prod(z, c_sum(c_sqrt(c_sum(x,c_i)), ! c_sqrt(c_diff(x,c_i))))); ! return c_sum(z, z); } *************** *** 86,92 **** /* Break up long expression for WATCOM */ Py_complex z; ! z = c_sum(c_1,c_prod(x,x)); ! z = c_diff(c_sqrt(z),x); ! return c_neg(c_log(z)); } --- 92,97 ---- /* Break up long expression for WATCOM */ Py_complex z; ! z = c_sum(c_1,c_prod(x, x)); ! return c_log(c_sum(c_sqrt(z), x)); } From python-dev@python.org Fri Jun 30 03:44:44 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 29 Jun 2000 19:44:44 -0700 Subject: [Python-checkins] CVS: python/dist/src config.h.in,2.58,2.59 Message-ID: <200006300244.TAA10445@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv10433 Modified Files: config.h.in Log Message: Somehow this had HAVE_SYS_SOCKET_H twice. Once is enough. Rerunning autoheader revealed this. Index: config.h.in =================================================================== RCS file: /cvsroot/python/python/dist/src/config.h.in,v retrieving revision 2.58 retrieving revision 2.59 diff -C2 -r2.58 -r2.59 *** config.h.in 2000/06/29 20:44:46 2.58 --- config.h.in 2000/06/30 02:44:41 2.59 *************** *** 553,559 **** #undef HAVE_SYS_SOCKET_H - /* Define if you have the header file. */ - #undef HAVE_SYS_SOCKET_H - /* Define if you have the header file. */ #undef HAVE_SYS_TIME_H --- 553,556 ---- From python-dev@python.org Fri Jun 30 03:46:09 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 19:46:09 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules socketmodule.c,1.108,1.109 Message-ID: <200006300246.TAA10573@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv10484/Modules Modified Files: socketmodule.c Log Message: Trent Mick : This patch fixes possible overflows in the socket module for 64-bit platforms (mainly Win64). The changes are: - abstract the socket type to SOCKET_T (this is SOCKET on Windows, int on Un*x), this is necessary because sizeof(SOCKET) > sizeof(int) on Win64 - use INVALID_SOCKET on Win32/64 for an error return value for accept() - ensure no overflow of the socket variable for: (1) a PyObject return value (use PyLong_FromLongLong if necessary); and (2) printf formatting in repr(). Closes SourceForge patch #100516. Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.108 retrieving revision 1.109 diff -C2 -r1.108 -r1.109 *** socketmodule.c 2000/05/16 13:30:12 1.108 --- socketmodule.c 2000/06/30 02:46:07 1.109 *************** *** 222,225 **** --- 222,239 ---- #endif + /* abstract the socket file descriptor type */ + #ifdef MS_WINDOWS + typedef SOCKET SOCKET_T; + # ifdef MS_WIN64 + # define SIZEOF_SOCKET_T 8 + # else + # define SIZEOF_SOCKET_T 4 + # endif + #else + typedef int SOCKET_T; + # define SIZEOF_SOCKET_T SIZEOF_INT + #endif + + #if defined(PYOS_OS2) #define SOCKETCLOSE soclose *************** *** 338,342 **** typedef struct { PyObject_HEAD ! int sock_fd; /* Socket file descriptor */ int sock_family; /* Address family, e.g., AF_INET */ int sock_type; /* Socket type, e.g., SOCK_STREAM */ --- 352,356 ---- typedef struct { PyObject_HEAD ! SOCKET_T sock_fd; /* Socket file descriptor */ int sock_family; /* Address family, e.g., AF_INET */ int sock_type; /* Socket type, e.g., SOCK_STREAM */ *************** *** 388,392 **** static PySocketSockObject * ! BUILD_FUNC_DEF_4(PySocketSock_New,int,fd, int,family, int,type, int,proto) { PySocketSockObject *s; --- 402,406 ---- static PySocketSockObject * ! BUILD_FUNC_DEF_4(PySocketSock_New,SOCKET_T,fd, int,family, int,type, int,proto) { PySocketSockObject *s; *************** *** 667,671 **** { char addrbuf[256]; ! int newfd; socklen_t addrlen; PyObject *sock = NULL; --- 681,685 ---- { char addrbuf[256]; ! SOCKET_T newfd; socklen_t addrlen; PyObject *sock = NULL; *************** *** 680,684 **** --- 694,702 ---- newfd = accept(s->sock_fd, (struct sockaddr *) addrbuf, &addrlen); Py_END_ALLOW_THREADS + #ifdef MS_WINDOWS + if (newfd == INVALID_SOCKET) + #else if (newfd < 0) + #endif return PySocket_Err(); *************** *** 969,973 **** --- 987,995 ---- if (!PyArg_ParseTuple(args, ":fileno")) return NULL; + #if SIZEOF_SOCKET_T <= SIZEOF_LONG return PyInt_FromLong((long) s->sock_fd); + #else + return PyLong_FromLongLong((LONG_LONG)s->sock_fd); + #endif } *************** *** 984,988 **** BUILD_FUNC_DEF_2(PySocketSock_dup,PySocketSockObject *,s, PyObject *,args) { ! int newfd; PyObject *sock; if (!PyArg_ParseTuple(args, ":dup")) --- 1006,1010 ---- BUILD_FUNC_DEF_2(PySocketSock_dup,PySocketSockObject *,s, PyObject *,args) { ! SOCKET_T newfd; PyObject *sock; if (!PyArg_ParseTuple(args, ":dup")) *************** *** 1110,1114 **** --- 1132,1140 ---- char *mode = "r"; int bufsize = -1; + #ifdef MS_WIN32 + intptr_t fd; + #else int fd; + #endif FILE *fp; PyObject *f; *************** *** 1388,1394 **** { char buf[512]; sprintf(buf, ! "", ! s->sock_fd, s->sock_family, s->sock_type, s->sock_proto); return PyString_FromString(buf); } --- 1414,1430 ---- { char buf[512]; + #if SIZEOF_SOCKET_T > SIZEOF_LONG + if (s->sock_fd > LONG_MAX) { + /* this can occur on Win64, and actually there is a special + ugly printf formatter for decimal pointer length integer + printing, only bother if necessary*/ + PyErr_SetString(PyExc_OverflowError, + "no printf formatter to display the socket descriptor in decimal"); + return NULL; + } + #endif sprintf(buf, ! "", ! (long)s->sock_fd, s->sock_family, s->sock_type, s->sock_proto); return PyString_FromString(buf); } *************** *** 1717,1725 **** { PySocketSockObject *s; ! #ifdef MS_WINDOWS ! SOCKET fd; ! #else ! int fd; ! #endif int family, type, proto = 0; if (!PyArg_ParseTuple(args, "ii|i:socket", &family, &type, &proto)) --- 1753,1757 ---- { PySocketSockObject *s; ! SOCKET_T fd; int family, type, proto = 0; if (!PyArg_ParseTuple(args, "ii|i:socket", &family, &type, &proto)) *************** *** 1767,1771 **** { PySocketSockObject *s; ! int fd, family, type, proto = 0; if (!PyArg_ParseTuple(args, "iii|i:fromfd", &fd, &family, &type, &proto)) --- 1799,1804 ---- { PySocketSockObject *s; ! SOCKET_T fd; ! int family, type, proto = 0; if (!PyArg_ParseTuple(args, "iii|i:fromfd", &fd, &family, &type, &proto)) *************** *** 2114,2118 **** { char *data; ! int len = 0; if (!PyArg_ParseTuple(args, "s|i:write", &data, &len)) --- 2147,2151 ---- { char *data; ! size_t len = 0; if (!PyArg_ParseTuple(args, "s|i:write", &data, &len)) From python-dev@python.org Fri Jun 30 03:48:56 2000 From: python-dev@python.org (Guido van Rossum) Date: Thu, 29 Jun 2000 19:48:56 -0700 Subject: [Python-checkins] CVS: python/dist/src configure,1.119,1.120 configure.in,1.128,1.129 Message-ID: <200006300248.TAA10665@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv10638 Modified Files: configure configure.in Log Message: Bump version to 2.0. Note that configure hadn't been checked in a few times so it has more changes, catching up with the last few changes to congifure.in as well. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.119 retrieving revision 1.120 diff -C2 -r1.119 -r1.120 *** configure 2000/06/29 16:12:00 1.119 --- configure 2000/06/30 02:48:53 1.120 *************** *** 1,5 **** #! /bin/sh ! # From configure.in Revision: 1.126 # Guess values for system-dependent variables and create Makefiles. --- 1,5 ---- #! /bin/sh ! # From configure.in Revision: 1.129 [...2672 lines suppressed...] echo $ac_n "checking for socklen_t""... $ac_c" 1>&6 ! echo "configure:5530: checking for socklen_t" >&5 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 < --- 5609,5618 ---- EOF echo $ac_n "checking for socklen_t""... $ac_c" 1>&6 ! echo "configure:5612: checking for socklen_t" >&5 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 < Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.128 retrieving revision 1.129 diff -C2 -r1.128 -r1.129 *** configure.in 2000/06/29 20:44:46 1.128 --- configure.in 2000/06/30 02:48:53 1.129 *************** *** 7,11 **** # Set VERSION so we only need to edit in one place (i.e., here) AC_SUBST(VERSION) ! VERSION=1.6 # NEXTSTEP stuff --- 7,11 ---- # Set VERSION so we only need to edit in one place (i.e., here) AC_SUBST(VERSION) ! VERSION=2.0 # NEXTSTEP stuff From python-dev@python.org Fri Jun 30 03:54:02 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 29 Jun 2000 19:54:02 -0700 Subject: [Python-checkins] CVS: distutils README.txt,1.16,1.17 CHANGES.txt,1.10,1.11 Message-ID: <200006300254.TAA10865@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv10850 Modified Files: README.txt CHANGES.txt Log Message: Update for Distutils 0.9. Index: README.txt =================================================================== RCS file: /cvsroot/python/distutils/README.txt,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** README.txt 2000/06/04 13:46:19 1.16 --- README.txt 2000/06/30 02:54:00 1.17 *************** *** 1,5 **** Python Distribution Utilities ! release 0.9 (pre) ! June ??, 2000 --- 1,5 ---- Python Distribution Utilities ! release 0.9 ! June 29, 2000 *************** *** 11,20 **** installation of Python modules. (It is intended that ultimately the Distutils will grow up into a system for distributing and installing ! whole Python applications, but for now their scope is limited to module distributions.) ! The Distutils are a standard part of Python 1.6; if you are running 1.6, ! you don't need to install the Distutils separately. This release is ! primarily so that you can add the Distutils to a Python 1.5.2 installation -- you will then be able to install modules that require the Distutils, or use the Distutils to distribute your own modules. --- 11,20 ---- installation of Python modules. (It is intended that ultimately the Distutils will grow up into a system for distributing and installing ! whole Python applications, but for now their scope is primarily module distributions.) ! The Distutils are a standard part of Python 1.6/2.0; if you are running ! 1.6/2.0, you don't need to install the Distutils separately. This ! release is primarily so that you can add the Distutils to a Python 1.5.2 installation -- you will then be able to install modules that require the Distutils, or use the Distutils to distribute your own modules. *************** *** 43,50 **** Release 0.9 of the Distutils requires Python 1.5.2 or later. (If you ! absolutely must Python 1.5.1, Distutils 0.1.5 is backwards compatible. ! However, I have dropped plans to port the current Distutils code back to ! Python 1.5.1, as I have received exactly zero complaints about requiring ! Python 1.5.2 since releasing Distutils 0.8 in April.) To use the Distutils under Unix, you must have a *complete* Python --- 43,50 ---- Release 0.9 of the Distutils requires Python 1.5.2 or later. (If you ! absolutely must use Python 1.5.1, Distutils 0.1.5 is backwards ! compatible. However, I have dropped plans to port the current Distutils ! code back to Python 1.5.1, as I have received exactly zero complaints ! about requiring Python 1.5.2 since releasing Distutils 0.8 in April.) To use the Distutils under Unix, you must have a *complete* Python *************** *** 71,81 **** extensions works or not. ! To build extensions on Windows, you need Microsoft Visual C++ 5.0 or ! 6.0. It also helps to have access to the Windows registry from Python; ! if you have the Win32 extensions (win32api, win32con) installed, you're ! fine. (Python 1.6 includes the winreg module for this purpose, which ! the Distutils will use if available.) If not, the Distutils might not ! be able to find the Visual C++ executables, in which case it will die ! horribly when you attempt to build any Python extensions. --- 71,85 ---- extensions works or not. ! Building extensions on Windows works best with Microsoft Visual C++ 5.0 ! or 6.0. It also helps to have access to the Windows registry from ! Python; if you have the Win32 extensions (win32api, win32con) installed, ! you're fine. (Python 2.0 includes the winreg module for this purpose, ! which the Distutils will use if available.) If not, the Distutils might ! not be able to find the Visual C++ executables, in which case it will ! die horribly when you attempt to build any Python extensions. ! ! There is also experimental support for building extensions under Windows ! using Borland C++ or GCC (Cygwin or Mingw32 ports). Come join the ! Distutils SIG to learn about using these compilers. *************** *** 104,115 **** ! INSTALLATION UNDER PYTHON 1.6 ! ------------------------------- ! The Distutils are included with Python 1.6, so there's generally no need ! to install it under Python 1.6. However, this release is more recent ! than the code included with Python 1.6a2, so if you really like life on the bleeding edge, you might want to install this Distutils release into ! your Python 1.6a2 library. To do this, you'll need to hide the original Distutils package directory --- 108,121 ---- ! INSTALLATION UNDER PYTHON 1.6/2.0 ! --------------------------------- ! The Distutils have been included with Python since 1.6a1, and Distutils ! 0.9 is approximately the code that will be included with Python 2.0b1 ! (modulo bug fixes). Thus, there's generally no need to install the ! Distutils under Python 1.6/2.0. However, Distutils releases may ! occasionally get ahead of Python releases, so if you really like life on the bleeding edge, you might want to install this Distutils release into ! your Python 1.6/2.0 library. To do this, you'll need to hide the original Distutils package directory *************** *** 119,127 **** follows: ! cd /usr/local/lib/python1.6 mv distutils distutils-orig On Windows, the stock Distutils installation is "Lib\distutils" under ! the Python directory ("C:\Python" by default for Python 1.6a2 and later). Again, you should just rename this directory, eg. to "distutils-orig", so that Python won't find it. --- 125,133 ---- follows: ! cd /usr/local/lib/python1.6 # or 2.0 mv distutils distutils-orig On Windows, the stock Distutils installation is "Lib\distutils" under ! the Python directory ("C:\Python" by default with Python 1.6a2 and later). Again, you should just rename this directory, eg. to "distutils-orig", so that Python won't find it. *************** *** 138,143 **** seriously caters to all three communities: developers can use it to build and install their modules, as well as create source distributions; ! packagers can use it to create RPMs and (soon!) executable installers ! for Windows; and of course installers can build and install modules from source (or just use an installer created by some kind packager). --- 144,149 ---- seriously caters to all three communities: developers can use it to build and install their modules, as well as create source distributions; ! packagers can use it to create RPMs and executable installers for ! Windows; and of course installers can build and install modules from source (or just use an installer created by some kind packager). *************** *** 148,154 **** way around LaTeX, the Python documentation tools, and Unix, you might be able to get something out of these. Realistically, though, the ! documentation is just provided in the distributio so you can send me doc ! patches; if you want to read it, you're better off getting the latest ! documentation from the Distutils documentation page: http://www.python.org/sigs/distutils-sig/doc/ --- 154,160 ---- way around LaTeX, the Python documentation tools, and Unix, you might be able to get something out of these. Realistically, though, the ! documentation is just provided in the distribution so you can send me ! doc patches; if you want to read it, you're better off getting the ! latest documentation from the Distutils documentation page: http://www.python.org/sigs/distutils-sig/doc/ *************** *** 171,190 **** ------------------------------ ! There are a couple of small incompatibilities between Distutils 0.1.x ! and 0.8.x that affect setup scripts. Unfortunately, two of the major ! module distributions currently using the Distutils -- Numerical Python and ! PyXML -- stumble across these incompatibilities. If you need to build ! and install either of these (or, in theory, any module distribution that ! used Distutils 0.1.x -- although most will not be affected), you have ! two options: * stick with Distutils 0.1.x (to be avoided, especially if you are ! running Python 1.6) * replace the setup script provided by the module distribution with ! the Distutils 0.8-compatibile version provided here (recommended) ! For example, if you want to build Numerical Python 15.2 using ! Distutils 0.8.x, you would: * rename the setup.py provided with Numerical Python 15.2, eg. to --- 177,196 ---- ------------------------------ ! There were a couple of small incompatibilities introduced with Distutils ! 0.8 (the previous major release) that affected setup scripts. ! Unfortunately, two of the major module distributions currently using the ! Distutils -- Numerical Python and PyXML -- stumble across these ! incompatibilities. If you need to build and install either of these ! (or, in theory, any module distribution that used Distutils 0.1.x -- ! although most will not be affected), you have two options: * stick with Distutils 0.1.x (to be avoided, especially if you are ! running Python 1.6/2.0) * replace the setup script provided by the module distribution with ! the Distutils 0.8-compatible version provided here (recommended) ! For example, if you want to build Numerical Python 15.2 using Distutils ! 0.8.x or 0.9, you would: * rename the setup.py provided with Numerical Python 15.2, eg. to *************** *** 268,278 **** there are a few outstanding problems: - * Distutils 0.8.x doesn't yet work with Python 1.5.1 - * not well tested with Python 1.6 * problems with specifying relative directories in an installation scheme - * "bdist_dumb" command untested on Windows * Mac OS support only partially included ! * no test suite (hmm, is this testing thing a common theme?) * doesn't check to see if you're clobbering an existing module installation --- 274,281 ---- there are a few outstanding problems: * problems with specifying relative directories in an installation scheme * Mac OS support only partially included ! * no test suite * doesn't check to see if you're clobbering an existing module installation *************** *** 280,287 **** There are some major features that still need to be added: - * no configuration file mechanism (although it's talked about - in the documentation) - * no support for probing the target system for either C- or Python- - level dependencies * no knowledge of whether you have installed some module distribution before --- 283,286 ---- *************** *** 296,309 **** http://www.python.org/mailman/listinfo/distutils-sig FUTURE PLANS ------------ - Distutils 0.9 will include support for configuration files and building - extensions on Mac OS (definitely with the MPW compiler, possibly with - CodeWarrior as well). - Distutils 1.0 will, if all goes well, be the version included with ! Python 1.6 (final). (If all does not go well, that version will be 1.0.1 or 1.0.2 or so.) --- 295,307 ---- http://www.python.org/mailman/listinfo/distutils-sig + Also, take a look through the TODO file to see a more recent/complete + version of the Distutils to-do list. + FUTURE PLANS ------------ Distutils 1.0 will, if all goes well, be the version included with ! Python 2.0 (final). (If all does not go well, that version will be 1.0.1 or 1.0.2 or so.) *************** *** 339,343 **** * Thomas Heller: more work on the registry support, several bug fixes in the Windows support, and just generally improving ! the code for compiling extensions on Windows * Eric Tiedemann: bug fixes * Fred Drake and Guido van Rossum: helping to figure out the --- 337,342 ---- * Thomas Heller: more work on the registry support, several bug fixes in the Windows support, and just generally improving ! the code for compiling extensions on Windows; also, the ! "bdist_wininst" command (and associated C code) * Eric Tiedemann: bug fixes * Fred Drake and Guido van Rossum: helping to figure out the *************** *** 345,356 **** * Joe Van Andel: tweaks to the sysconfig module, misc. bug fixes * Corran Webster: Mac OS support in general ! * Bastian Kleineidam: the "clean" command, and a pile of ! patches, bug-fixes, and ideas, large and small * Lyle Johnson: bug-spotting and -fixing; support for Borland's C/C++ ! compiler (forthcoming) * Harry Henry Gebel: bug-spotting and -fixing; the "bztar" archive format; the "bdist_rpm" command ! * Rene Liebscher: smarter extension-building; Cygwin/Mingw32 support ! (forthcoming) [spiritual, in roughly chronological order since the birth of the project] --- 344,356 ---- * Joe Van Andel: tweaks to the sysconfig module, misc. bug fixes * Corran Webster: Mac OS support in general ! * Bastian Kleineidam: a bunch of small but vital commands: clean, ! install_scripts, install_data, build_scripts; a pile of patches, ! bug-fixes, and good ideas, large and small * Lyle Johnson: bug-spotting and -fixing; support for Borland's C/C++ ! compiler * Harry Henry Gebel: bug-spotting and -fixing; the "bztar" archive format; the "bdist_rpm" command ! * Rene Liebscher: smarter extension-building; Cygwin/Mingw32 support; ! more help options [spiritual, in roughly chronological order since the birth of the project] Index: CHANGES.txt =================================================================== RCS file: /cvsroot/python/distutils/CHANGES.txt,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** CHANGES.txt 2000/04/25 03:05:17 1.10 --- CHANGES.txt 2000/06/30 02:54:00 1.11 *************** *** 1,2 **** --- 1,89 ---- + Release 0.9 (29 June, 2000): + ---------------------------- + * added config file mechanism + + * added "bdist_rpm" command: create an RPM built distribution (thanks to + Harry Henry Gebel) + + * added "bdist_wininst" command: create an executable Windows installer + (self-extracting ZIP file with a small GUI) (thanks to Thomas + Heller) + + * added extra help options to list the available C/C++ compilers + ("build_ext", "build_clib" commands), archive formats for source + distributions ("sdist"), and formats for built distributions + ("bdist") (thanks to Rene Liebscher) + + * added "install_data" and "install_scripts" commands to install, + respectively, arbitrary data files and scripts (thanks to Bastian + Kleineidam) + + * added the "build_scripts" command, mainly to fix the "#!" line + of Python scripts to point to the current Python interpreter + (Bastian Kleineidam again) + + * added "install_headers" command to install C/C++ header files + (to the include/python directory by default) + + * added a new, much simpler way to describe extensions in the setup + script (no more hairy list-of-tuples-of-dicts: just call the + Extension constructor to create an Extension object that describes + your extension) + + * modified all the example setup scripts to use the new way of + describing extensions (thanks to Harry Henry Gebel for help) + + * added another bit of meta-data: the "long description" (Harry Henry + Gebel) + + * added the ability to compile and link in resource files with + Visual C++ on Windows (Thomas Heller) + + * extension building now works on AIX (actually tested this time) + (thanks to Rene Liebscher for the initial patch, and Vladimir + Marangozov for testing) + + * extension building now works on OSF/1 (aka Digital Unix, aka Tru64 + Unix) (thanks to Mark Favas for testing) + + * experimental support for auto-configuration, via the "config" command + (think "Autoconf in Python") + + * modified example setup scripts for PIL and mxDateTime to do some + auto-configuration (only partially implemented -- no support for + actually using the information discovered during the build process) + + * experimental interface to Borland C++ for building extensions on + Windows (thanks to Lyle Johnson) + + * experimental interface to Cygwin and Mingw32 ports of GCC for building + extensions on Windows (thanks to Rene Liebscher) + + * added ability to select which compiler to use as an option to "build", + "build_ext", and/or "build_clib" + + * experimental support for building extensions from SWIG interface files + + * added more ways to sneak compiler and/or linker options in through + the back door ('extra_link_args', 'extra_compile_args' when + constructing an Extension object, for now) + + * fixed a bunch of silly bugs in "sdist"; most importantly, it will now + exclude directories from the source distribution that really shouldn't + be there (like the build tree, the temporary tree that is used to + build the source distribution archive, CVS and RCS directories, ...) + + * added a minimal debugging framework (set environment variable + DISTUTILS_DEBUG to 1 and you get a *lot* more feedback!) + + * added the notion of "list of symbols to export" to CCompiler interface + + * added preprocessor interface to CCompiler (only implemented in + UnixCCompiler, so far) + + * better separation of responsibilities between the UnixCCompiler class + and the build_ext command + + Release 0.8.2 (24 April, 2000): ------------------------------- From python-dev@python.org Fri Jun 30 03:54:38 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 29 Jun 2000 19:54:38 -0700 Subject: [Python-checkins] CVS: distutils setup.py,1.16,1.17 Message-ID: <200006300254.TAA10890@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv10877 Modified Files: setup.py Log Message: Bump version to 0.9. Index: setup.py =================================================================== RCS file: /cvsroot/python/distutils/setup.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** setup.py 2000/06/02 02:23:42 1.16 --- setup.py 2000/06/30 02:54:36 1.17 *************** *** 12,16 **** setup (name = "Distutils", ! version = "0.9pre", description = "Python Distribution Utilities", author = "Greg Ward", --- 12,16 ---- setup (name = "Distutils", ! version = "0.9", description = "Python Distribution Utilities", author = "Greg Ward", From python-dev@python.org Fri Jun 30 03:54:38 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 29 Jun 2000 19:54:38 -0700 Subject: [Python-checkins] CVS: distutils/distutils __init__.py,1.7,1.8 Message-ID: <200006300254.TAA10894@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv10877/distutils Modified Files: __init__.py Log Message: Bump version to 0.9. Index: __init__.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/__init__.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** __init__.py 2000/06/02 02:23:42 1.7 --- __init__.py 2000/06/30 02:54:36 1.8 *************** *** 11,13 **** __revision__ = "$Id$" ! __version__ = "0.9pre" --- 11,13 ---- __revision__ = "$Id$" ! __version__ = "0.9" From python-dev@python.org Fri Jun 30 04:36:44 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 20:36:44 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/inst inst.tex,1.15,1.16 Message-ID: <200006300336.UAA19153@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/inst In directory slayer.i.sourceforge.net:/tmp/cvs-serv19140/inst Modified Files: inst.tex Log Message: Update Python version numbers from 1.6 to 2.0 where appropriate. Make some references between the distutils documents hyperlinks using the \citetitle markup. Index: inst.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/inst/inst.tex,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** inst.tex 2000/06/24 01:33:16 1.15 --- inst.tex 2000/06/30 03:36:41 1.16 *************** *** 49,53 **** In the past, there has been little support for adding third-party modules to an existing Python installation. With the introduction of ! the Python Distribution Utilities (Distutils for short) in Python 1.6, this is starting to change. Not everything will change overnight, though, so while this document concentrates on installing module --- 49,53 ---- In the past, there has been little support for adding third-party modules to an existing Python installation. With the introduction of ! the Python Distribution Utilities (Distutils for short) in Python 2.0, this is starting to change. Not everything will change overnight, though, so while this document concentrates on installing module *************** *** 63,67 **** installation, but that's it. If you're looking for information on how to distribute your own Python modules so that others may use them, see ! the ``Distributing Python Modules'' manual. --- 63,67 ---- installation, but that's it. If you're looking for information on how to distribute your own Python modules so that others may use them, see ! the \citetitle[../dist/dist.html]{Distributing Python Modules} manual. *************** *** 275,284 **** {Platform}{Standard installation location}{Default value}{Notes} \lineiv{Unix (pure)} ! {\filenq{\filevar{prefix}/lib/python1.6/site-packages}} ! {\filenq{/usr/local/lib/python1.6/site-packages}} {(1)} \lineiv{Unix (non-pure)} ! {\filenq{\filevar{exec-prefix}/lib/python1.6/site-packages}} ! {\filenq{/usr/local/lib/python1.6/site-packages}} {(1)} \lineiv{Windows} --- 275,284 ---- {Platform}{Standard installation location}{Default value}{Notes} \lineiv{Unix (pure)} ! {\filenq{\filevar{prefix}/lib/python2.0/site-packages}} ! {\filenq{/usr/local/lib/python2.0/site-packages}} {(1)} \lineiv{Unix (non-pure)} ! {\filenq{\filevar{exec-prefix}/lib/python2.0/site-packages}} ! {\filenq{/usr/local/lib/python2.0/site-packages}} {(1)} \lineiv{Windows} *************** *** 315,323 **** running Python in interactive mode and typing a few simple commands. Under Unix, just type \code{python} at the shell prompt; under Windows, ! run ``Python 1.6 (interpreter)'' \XXX{right?}; under Mac~OS, \XXX{???}. ! Once the interpreter is started, you type Python code at the \code{>>>} ! prompt. For example, on my Linux system, I type the three Python ! statements shown below, and get the output as shown, to find out my ! \filevar{prefix} and \filevar{exec-prefix}: \begin{verbatim} Python 1.5.2 (#1, Apr 18 1999, 16:03:16) [GCC pgcc-2.91.60 19981201 (egcs-1.1.1 on linux2 --- 315,324 ---- running Python in interactive mode and typing a few simple commands. Under Unix, just type \code{python} at the shell prompt; under Windows, ! run ``Python 2.0 (interpreter)'' \XXX{right?}; under Mac~OS, \XXX{???}. ! Once the interpreter is started, you type Python code at the ! \samp{>>> } prompt. For example, on my Linux system, I type the three ! Python statements shown below, and get the output as shown, to find ! out my \filevar{prefix} and \filevar{exec-prefix}: ! \begin{verbatim} Python 1.5.2 (#1, Apr 18 1999, 16:03:16) [GCC pgcc-2.91.60 19981201 (egcs-1.1.1 on linux2 From python-dev@python.org Fri Jun 30 04:36:44 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 20:36:44 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/dist dist.tex,1.17,1.18 Message-ID: <200006300336.UAA19149@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/dist In directory slayer.i.sourceforge.net:/tmp/cvs-serv19140/dist Modified Files: dist.tex Log Message: Update Python version numbers from 1.6 to 2.0 where appropriate. Make some references between the distutils documents hyperlinks using the \citetitle markup. Index: dist.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/dist/dist.tex,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** dist.tex 2000/06/25 03:14:13 1.17 --- dist.tex 2000/06/30 03:36:41 1.18 *************** *** 22,39 **** for installing and maintaining third-party modules. With the introduction of the Python Distribution Utilities (Distutils for short) ! in Python 1.6, this situation should start to improve. This document only covers using the Distutils to distribute your Python ! modules. Using the Distutils does not tie you to Python 1.6, though: the Distutils work just fine with Python 1.5, and it is reasonable (and expected to become commonplace) to expect users of Python 1.5 to download and install the Distutils separately before they can install ! your modules. Python 1.6 users, of course, won't have to add anything to their Python installation in order to use the Distutils to install third-party modules. This document concentrates on the role of developer/distributor: if ! you're looking for information on installing Python modules, you should ! refer to the ``Installing Python Modules'' manual. --- 22,40 ---- for installing and maintaining third-party modules. With the introduction of the Python Distribution Utilities (Distutils for short) ! in Python 2.0, this situation should start to improve. This document only covers using the Distutils to distribute your Python ! modules. Using the Distutils does not tie you to Python 2.0, though: the Distutils work just fine with Python 1.5, and it is reasonable (and expected to become commonplace) to expect users of Python 1.5 to download and install the Distutils separately before they can install ! your modules. Python 2.0 users, of course, won't have to add anything to their Python installation in order to use the Distutils to install third-party modules. This document concentrates on the role of developer/distributor: if ! you're looking for information on installing Python modules, you ! should refer to the \citetitle[../inst/inst.html]{Installing Python ! Modules} manual. *************** *** 224,228 **** Here's a slightly more involved example, which we'll follow for the next couple of sections: the Distutils' own setup script. (Keep in mind that ! although the Distutils are included with Python 1.6, they also have an independent existence so that Python 1.5 users can use them to install other module distributions. The Distutils' own setup script is used to --- 225,229 ---- Here's a slightly more involved example, which we'll follow for the next couple of sections: the Distutils' own setup script. (Keep in mind that ! although the Distutils are included with Python 2.0, they also have an independent existence so that Python 1.5 users can use them to install other module distributions. The Distutils' own setup script is used to From python-dev@python.org Fri Jun 30 04:43:55 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 29 Jun 2000 20:43:55 -0700 Subject: [Python-checkins] CVS: distutils MANIFEST.in,1.8,1.9 Message-ID: <200006300343.UAA19471@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv19463 Modified Files: MANIFEST.in Log Message: Add TODO file. Add doc files conservatively, to avoid diving into my forest of symlinks. Index: MANIFEST.in =================================================================== RCS file: /cvsroot/python/distutils/MANIFEST.in,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** MANIFEST.in 2000/06/28 01:31:37 1.8 --- MANIFEST.in 2000/06/30 03:43:53 1.9 *************** *** 9,17 **** # ! include *.txt include MANIFEST.in recursive-include examples *.txt *.py prune examples/sample*/build ! recursive-include doc *.sty *.tex graft misc exclude misc/*.zip --- 9,17 ---- # ! include *.txt TODO include MANIFEST.in recursive-include examples *.txt *.py prune examples/sample*/build ! include doc/dist/*.tex doc/inst/*.tex graft misc exclude misc/*.zip From python-dev@python.org Fri Jun 30 04:45:10 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 29 Jun 2000 20:45:10 -0700 Subject: [Python-checkins] CVS: distutils TODO,1.5,1.6 Message-ID: <200006300345.UAA19523@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv19507 Modified Files: TODO Log Message: Added notes on a couple of quirks ("not's not a bug -- that's a quirk!") noticed while testing/packaging 0.9. Index: TODO =================================================================== RCS file: /cvsroot/python/distutils/TODO,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** TODO 2000/06/25 02:37:09 1.5 --- TODO 2000/06/30 03:45:08 1.6 *************** *** 150,155 **** --- 150,160 ---- for proper Windows support ) + * should be able to turn off byte-compilation (and optimized version too) + * need to test --compile, --optimize! (--optimize doesn't work, that's + for sure) + + DISTRIBUTION FORMATS -------------------- *************** *** 159,162 **** --- 164,170 ---- [punt: I don't care anymore, if anyone else does, let them fix it] + * bdist_rpm ignores the Python you ran it with, and just puts + "python setup.py ..." into the setup script + * make "bdist" take multiple formats (both for convenience and consistency with "sdist"); should be doable now that we can *************** *** 172,175 **** --- 180,193 ---- * Wise installer for Windows ("bdist_wise") [Thomas Heller said he will work on this when "bdist_wininst" is done] + + * should certainly put tarballs and zip files (sdist, bdist_dumb) in + "dist" directory -- maybe RPMs, Windows installers too + + + MISC + ---- + + * sdist tends to blow up when making hardlinks in the distribution + tree if a previous run blew up and left stuff already there From python-dev@python.org Fri Jun 30 04:45:42 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 20:45:42 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libwinreg.tex,1.1,1.2 Message-ID: <200006300345.UAA19551@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv19536 Modified Files: libwinreg.tex Log Message: Reflect the name change to _winreg; we still need documentation for the new winreg module. Index: libwinreg.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libwinreg.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** libwinreg.tex 2000/06/07 04:07:48 1.1 --- libwinreg.tex 2000/06/30 03:45:40 1.2 *************** *** 1,6 **** ! \section{\module{winreg} -- Windows registry access} ! \declaremodule{extension}{winreg} \platform{Windows} \modulesynopsis{Routines and objects for manipulating the Windows registry.} --- 1,6 ---- ! \section{\module{_winreg} -- Windows registry access} ! \declaremodule[-winreg]{extension}{_winreg} \platform{Windows} \modulesynopsis{Routines and objects for manipulating the Windows registry.} *************** *** 11,14 **** --- 11,18 ---- that the handles are closed correctly, even if the programmer neglects to explicitly close them. + + This module exposes a very low-level interface to the Windows + registry; for a more object-oriented interface, use the + \module{winreg} module. From python-dev@python.org Fri Jun 30 04:45:47 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 29 Jun 2000 20:45:47 -0700 Subject: [Python-checkins] CVS: distutils setup.cfg,1.2,1.3 Message-ID: <200006300345.UAA19562@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv19554 Modified Files: setup.cfg Log Message: Made myself the RPM packager; added a changelog entry. Index: setup.cfg =================================================================== RCS file: /cvsroot/python/distutils/setup.cfg,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** setup.cfg 2000/06/08 01:21:31 1.2 --- setup.cfg 2000/06/30 03:45:44 1.3 *************** *** 21,25 **** [bdist_rpm] release = 1 ! packager = Harry Henry Gebel doc_files = CHANGES.txt README.txt --- 21,25 ---- [bdist_rpm] release = 1 ! packager = Greg Ward doc_files = CHANGES.txt README.txt *************** *** 29,32 **** --- 29,35 ---- changelog = + * Thu Jun 29 2000 Greg Ward 0.9 + - Made myself the packager, since I can now create the RPM on my own + * Sun Jun 04 2000 Harry Henry Gebel 0.9pre-1 - Made sure scripts are file names, filled in some help strings, formatted From python-dev@python.org Fri Jun 30 04:46:31 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 29 Jun 2000 20:46:31 -0700 Subject: [Python-checkins] CVS: distutils/examples mxdatetime_setup.py,1.8,1.9 pil_setup.py,1.13,1.14 Message-ID: <200006300346.UAA19700@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/examples In directory slayer.i.sourceforge.net:/tmp/cvs-serv19687/examples Modified Files: mxdatetime_setup.py pil_setup.py Log Message: Added comment to explain that auto-configuration isn't done yet. Index: mxdatetime_setup.py =================================================================== RCS file: /cvsroot/python/distutils/examples/mxdatetime_setup.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** mxdatetime_setup.py 2000/06/29 02:22:02 1.8 --- mxdatetime_setup.py 2000/06/30 03:46:28 1.9 *************** *** 12,15 **** --- 12,21 ---- from distutils.command.config import config + # Auto-configuration: this will obsolete manual editing of the setup script + # soon, but not yet. The problem is that there's no way to communicate + # what the "config" command finds out to the "build_clib" and "build_ext" + # commands. Thus, it's fun to play with auto-configuration, but it's not + # ready for prime-time yet. + class config_mxDateTime (config): Index: pil_setup.py =================================================================== RCS file: /cvsroot/python/distutils/examples/pil_setup.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** pil_setup.py 2000/06/29 02:22:02 1.13 --- pil_setup.py 2000/06/30 03:46:28 1.14 *************** *** 58,61 **** --- 58,68 ---- + + # Auto-configuration: this will obsolete the above manual editing soon, but + # not yet. The problem is that there's no way to communicate what the + # "config" command finds out to the "build_clib" and "build_ext" commands. + # Thus, it's fun to play with auto-configuration, but it's not ready for + # prime-time yet. + class config_Imaging (config): From python-dev@python.org Fri Jun 30 04:50:13 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 20:50:13 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libwinreg.tex,1.2,1.3 Message-ID: <200006300350.UAA19860@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv19842 Modified Files: libwinreg.tex Log Message: Make sure to note that this module was added for Python 2.0! Index: libwinreg.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libwinreg.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** libwinreg.tex 2000/06/30 03:45:40 1.2 --- libwinreg.tex 2000/06/30 03:50:06 1.3 *************** *** 7,10 **** --- 7,12 ---- \sectionauthor{Mark Hammond}{MarkH@ActiveState.com} + \versionadded{2.0} + These functions exposes the Windows registry API to Python. Instead of using an integer as the registry handle, a handle object is used to ensure From python-dev@python.org Fri Jun 30 05:17:13 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 21:17:13 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules bsddbmodule.c,1.18,1.19 Message-ID: <200006300417.VAA27365@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv27358 Modified Files: bsddbmodule.c Log Message: Add a comment about needing to change a #include if using a version of Berkeley DB 2.0 or newer; most Linux distros will include a more recent version than 1.85. Index: bsddbmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/bsddbmodule.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** bsddbmodule.c 2000/05/03 23:44:31 1.18 --- bsddbmodule.c 2000/06/30 04:17:11 1.19 *************** *** 52,55 **** --- 52,56 ---- #include #include + /* If using Berkeley DB 2.0 or newer, change this include to : */ #include /* Please don't include internal header files of the Berkeley db package From python-dev@python.org Fri Jun 30 05:21:43 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 21:21:43 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libsocket.tex,1.44,1.45 Message-ID: <200006300421.VAA27708@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv27698 Modified Files: libsocket.tex Log Message: Say "manual page", not "man page", when referring to the Unix manual. Index: libsocket.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsocket.tex,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -r1.44 -r1.45 *** libsocket.tex 2000/05/03 19:40:32 1.44 --- libsocket.tex 2000/06/30 04:21:41 1.45 *************** *** 373,377 **** \begin{methoddesc}[socket]{setsockopt}{level, optname, value} ! Set the value of the given socket option (see the \UNIX{} man page \manpage{setsockopt}{2}). The needed symbolic constants are defined in the \module{socket} module (\code{SO_*} etc.). The value can be an --- 373,377 ---- \begin{methoddesc}[socket]{setsockopt}{level, optname, value} ! Set the value of the given socket option (see the \UNIX{} manual page \manpage{setsockopt}{2}). The needed symbolic constants are defined in the \module{socket} module (\code{SO_*} etc.). The value can be an From python-dev@python.org Fri Jun 30 05:24:54 2000 From: python-dev@python.org (Fred L. Drake) Date: Thu, 29 Jun 2000 21:24:54 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libtime.tex,1.30,1.31 Message-ID: <200006300424.VAA27832@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv27822 Modified Files: libtime.tex Log Message: Change description of altzone to not refer to the "0th meridian". Index: libtime.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libtime.tex,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -r1.30 -r1.31 *** libtime.tex 2000/04/05 15:06:03 1.30 --- libtime.tex 2000/06/30 04:24:52 1.31 *************** *** 112,117 **** \begin{datadesc}{altzone} The offset of the local DST timezone, in seconds west of UTC, if one ! is defined. Negative if the local DST timezone is east of the 0th ! meridian (as in Western Europe, including the UK). Only use this if \code{daylight} is nonzero. \end{datadesc} --- 112,117 ---- \begin{datadesc}{altzone} The offset of the local DST timezone, in seconds west of UTC, if one ! is defined. This is negative if the local DST timezone is east of UTC ! (as in Western Europe, including the UK). Only use this if \code{daylight} is nonzero. \end{datadesc} From python-dev@python.org Fri Jun 30 05:36:31 2000 From: python-dev@python.org (Greg Ward) Date: Thu, 29 Jun 2000 21:36:31 -0700 Subject: [Python-checkins] CVS: distutils ANNOUNCE-0.9,NONE,1.1 ANNOUNCE-0.1,1.1,NONE ANNOUNCE-0.8,1.1,NONE Message-ID: <200006300436.VAA28170@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv28160 Added Files: ANNOUNCE-0.9 Removed Files: ANNOUNCE-0.1 ANNOUNCE-0.8 Log Message: Ditched the old announcements, and preserve the 0.9 announcement for posterity. --- NEW FILE --- Python Distribution Utilities release 0.9 June 29, 2000 The Python Distribution Utilities, or Distutils for short, are a collection of modules that aid in the development, distribution, and installation of Python modules. (It is intended that ultimately the Distutils will grow up into a system for distributing and installing whole Python applications, but for now their scope is limited to module distributions.) The Distutils are a standard part of Python 2.0; if you are running 2.0 (or one of the 1.6 alpha releases that preceded it), you don't need to install the Distutils separately. This release is primarily so that you can add the Distutils to a Python 1.5.2 installation -- you will then be able to install modules that require the Distutils, or use the Distutils to distribute your own modules. More information is available at the Distutils web page: http://www.python.org/sigs/distutils-sig/ and in the README.txt included in the Distutils source distribution. You can download the Distutils from http://www.python.org/sigs/distutils-sig/download.html Trivial patches can be sent to me (Greg Ward) at gward@python.net. Larger patches should be discussed on the Distutils mailing list: distutils-sig@python.org. From python-dev@python.org Fri Jun 30 05:57:57 2000 From: python-dev@python.org (Jeremy Hylton) Date: Thu, 29 Jun 2000 21:57:57 -0700 Subject: [Python-checkins] CVS: python/dist/src config.h.in,2.59,2.60 configure.in,1.129,1.130 configure,1.120,1.121 Message-ID: <200006300457.VAA29127@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv29090 Modified Files: config.h.in configure.in configure Log Message: penultimate phase of Neil Schemenauer's GC patches update configure files (turn --with-cycle-gc on for beta release?) Index: config.h.in =================================================================== RCS file: /cvsroot/python/python/dist/src/config.h.in,v retrieving revision 2.59 retrieving revision 2.60 diff -C2 -r2.59 -r2.60 *** config.h.in 2000/06/30 02:44:41 2.59 --- config.h.in 2000/06/30 04:57:55 2.60 *************** *** 211,214 **** --- 211,217 ---- #undef WITH_NEXT_FRAMEWORK + /* Define if you want cycle garbage collection */ + #undef WITH_CYCLE_GC + /* The number of bytes in an off_t. */ #undef SIZEOF_OFF_T Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.129 retrieving revision 1.130 diff -C2 -r1.129 -r1.130 *** configure.in 2000/06/30 02:48:53 1.129 --- configure.in 2000/06/30 04:57:55 1.130 *************** *** 1117,1120 **** --- 1117,1131 ---- [AC_MSG_RESULT(no)]) + # Check for GC support + AC_SUBST(USE_GC_MODULE) + USE_GC_MODULE="#" + AC_MSG_CHECKING(for --with-cycle-gc) + AC_ARG_WITH(cycle-gc, [--with-cycle-gc enable garbage collection], [ + AC_MSG_RESULT($withval) + AC_DEFINE(WITH_CYCLE_GC) + USE_GC_MODULE= + ], + AC_MSG_RESULT(no)) + # THIS MUST BE LAST, IT CAN BREAK OTHER TESTS! # Add sys/socket.h to confdefs.h Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.120 retrieving revision 1.121 diff -C2 -r1.120 -r1.121 *** configure 2000/06/30 02:48:53 1.120 --- configure 2000/06/30 04:57:55 1.121 *************** *** 46,49 **** --- 46,51 ---- ac_help="$ac_help --with-wctype-functions use wctype.h functions" + ac_help="$ac_help + --with-cycle-gc enable garbage collection" # Initialize some variables set by options. *************** *** 566,570 **** [...3819 lines suppressed...] #include --- 5632,5641 ---- EOF echo $ac_n "checking for socklen_t""... $ac_c" 1>&6 ! echo "configure:5635: checking for socklen_t" >&5 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 < *************** *** 5814,5817 **** --- 5837,5841 ---- s%@LIBM@%$LIBM%g s%@LIBC@%$LIBC%g + s%@USE_GC_MODULE@%$USE_GC_MODULE%g CEOF From python-dev@python.org Fri Jun 30 05:59:19 2000 From: python-dev@python.org (Jeremy Hylton) Date: Thu, 29 Jun 2000 21:59:19 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python import.c,2.134,2.135 Message-ID: <200006300459.VAA29186@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv29167/Python Modified Files: import.c Log Message: another typo caught by Rob Hooft Index: import.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/import.c,v retrieving revision 2.134 retrieving revision 2.135 diff -C2 -r2.134 -r2.135 *** import.c 2000/05/03 23:44:39 2.134 --- import.c 2000/06/30 04:59:17 2.135 *************** *** 88,92 **** /* Magic word as global; note that _PyImport_Init() can change the ! value of this global to accomodate for alterations of how the compiler works which are enabled by command line switches. */ static long pyc_magic = MAGIC; --- 88,92 ---- /* Magic word as global; note that _PyImport_Init() can change the ! value of this global to accommodate for alterations of how the compiler works which are enabled by command line switches. */ static long pyc_magic = MAGIC; From python-dev@python.org Fri Jun 30 06:00:06 2000 From: python-dev@python.org (Jeremy Hylton) Date: Thu, 29 Jun 2000 22:00:06 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python exceptions.c,1.2,1.3 Message-ID: <200006300500.WAA29289@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv29201/Python Modified Files: exceptions.c Log Message: replace constant 1 with symbolic constant METH_VARARGS another typo caught by Rob Hooft Index: exceptions.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/exceptions.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** exceptions.c 2000/06/20 18:36:26 1.2 --- exceptions.c 2000/06/30 04:59:59 1.3 *************** *** 190,194 **** * First thing we create is the base class for all exceptions, called * appropriately enough: Exception. Creation of this class makes no ! * assumptions about the existance of any other exception class -- except * for TypeError, which can conditionally exist. * --- 190,194 ---- * First thing we create is the base class for all exceptions, called * appropriately enough: Exception. Creation of this class makes no ! * assumptions about the existence of any other exception class -- except * for TypeError, which can conditionally exist. * *************** *** 283,289 **** Exception_methods[] = { /* methods for the Exception class */ ! { "__getitem__", Exception__getitem__, 1}, ! { "__str__", Exception__str__, 1}, ! { "__init__", Exception__init__, 1}, { NULL, NULL } }; --- 283,289 ---- Exception_methods[] = { /* methods for the Exception class */ ! { "__getitem__", Exception__getitem__, METH_VARARGS}, ! { "__str__", Exception__str__, METH_VARARGS}, ! { "__init__", Exception__init__, METH_VARARGS}, { NULL, NULL } }; *************** *** 397,401 **** PyMethodDef SystemExit_methods[] = { ! { "__init__", SystemExit__init__, 1}, {NULL, NULL} }; --- 397,401 ---- PyMethodDef SystemExit_methods[] = { ! { "__init__", SystemExit__init__, METH_VARARGS}, {NULL, NULL} }; *************** *** 577,582 **** static PyMethodDef EnvironmentError_methods[] = { ! {"__init__", EnvironmentError__init__, 1}, ! {"__str__", EnvironmentError__str__, 1}, {NULL, NULL} }; --- 577,582 ---- static PyMethodDef EnvironmentError_methods[] = { ! {"__init__", EnvironmentError__init__, METH_VARARGS}, ! {"__str__", EnvironmentError__str__, METH_VARARGS}, {NULL, NULL} }; *************** *** 727,732 **** PyMethodDef SyntaxError_methods[] = { ! {"__init__", SyntaxError__init__, 1}, ! {"__str__", SyntaxError__str__, 1}, {NULL, NULL} }; --- 727,732 ---- PyMethodDef SyntaxError_methods[] = { ! {"__init__", SyntaxError__init__, METH_VARARGS}, ! {"__str__", SyntaxError__str__, METH_VARARGS}, {NULL, NULL} }; From python-dev@python.org Fri Jun 30 06:02:55 2000 From: python-dev@python.org (Jeremy Hylton) Date: Thu, 29 Jun 2000 22:02:55 -0700 Subject: [Python-checkins] CVS: python/dist/src/Include objimpl.h,2.16,2.17 Message-ID: <200006300502.WAA03256@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Include In directory slayer.i.sourceforge.net:/tmp/cvs-serv3220/Include Modified Files: objimpl.h Log Message: final patches from Neil Schemenauer for garbage collection Index: objimpl.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/objimpl.h,v retrieving revision 2.16 retrieving revision 2.17 diff -C2 -r2.16 -r2.17 *** objimpl.h 2000/06/23 19:37:01 2.16 --- objimpl.h 2000/06/30 05:02:52 2.17 *************** *** 204,208 **** (PyVarObject *) PyObject_MALLOC( _PyObject_VAR_SIZE((typeobj),(n)) ),\ (typeobj), (n)) ) - #define PyObject_DEL(op) PyObject_FREE(op) /* This example code implements an object constructor with a custom --- 204,207 ---- *************** *** 234,243 **** the 1st step is performed automatically for you, so in a C++ class constructor you would start directly with PyObject_Init/InitVar. */ - #ifndef WITH_CYCLE_GC ! #define PyGC_INFO_SIZE 0 ! #endif #ifdef __cplusplus --- 233,298 ---- the 1st step is performed automatically for you, so in a C++ class constructor you would start directly with PyObject_Init/InitVar. */ + /* + * Garbage Collection Support + * ========================== + */ + + /* To make a new object participate in garbage collection use + PyObject_{New, VarNew, Del} to manage the memory. Set the type flag + Py_TPFLAGS_GC and define the type method tp_recurse. You should also + add the method tp_clear if your object is mutable. Include + PyGC_INFO_SIZE in the calculation of tp_basicsize. Call + PyObject_GC_Init after the pointers followed by tp_recurse become + valid (usually just before returning the object from the allocation + method. Call PyObject_GC_Fini before those pointers become invalid + (usually at the top of the deallocation method). */ #ifndef WITH_CYCLE_GC ! ! #define PyGC_HEAD_SIZE 0 ! #define PyObject_GC_Init(op) ! #define PyObject_GC_Fini(op) ! #define PyObject_AS_GC(op) (op) ! #define PyObject_FROM_GC(op) (op) ! #define PyObject_DEL(op) PyObject_FREE(op) ! ! #else ! ! /* Add the object into the container set */ ! extern DL_IMPORT(void) _PyGC_Insert Py_PROTO((PyObject *)); ! ! /* Remove the object from the container set */ ! extern DL_IMPORT(void) _PyGC_Remove Py_PROTO((PyObject *)); ! ! #define PyObject_GC_Init(op) _PyGC_Insert((PyObject *)op) ! #define PyObject_GC_Fini(op) _PyGC_Remove((PyObject *)op) ! ! /* Structure *prefixed* to container objects participating in GC */ ! typedef struct _gc_head { ! struct _gc_head *gc_next; ! struct _gc_head *gc_prev; ! int gc_refs; ! } PyGC_Head; ! ! #define PyGC_HEAD_SIZE sizeof(PyGC_Head) ! ! /* Test if a type has a GC head */ ! #define PyType_IS_GC(t) PyType_HasFeature((t), Py_TPFLAGS_GC) ! ! /* Test if an object has a GC head */ ! #define PyObject_IS_GC(o) PyType_IS_GC((o)->ob_type) ! ! /* Get an object's GC head */ ! #define PyObject_AS_GC(o) ((PyGC_Head *)(o)-1) ! ! /* Get the object given the PyGC_Head */ ! #define PyObject_FROM_GC(g) ((PyObject *)(((PyGC_Head *)g)+1)) ! ! #define PyObject_DEL(op) PyObject_FREE( PyObject_IS_GC(op) ? \ ! (ANY *)PyObject_AS_GC(op) : \ ! (ANY *)(op) ) ! ! #endif /* WITH_CYCLE_GC */ #ifdef __cplusplus From python-dev@python.org Fri Jun 30 06:02:55 2000 From: python-dev@python.org (Jeremy Hylton) Date: Thu, 29 Jun 2000 22:02:55 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild python16.dsp,1.6,1.7 Message-ID: <200006300502.WAA03275@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv3220/PCbuild Modified Files: python16.dsp Log Message: final patches from Neil Schemenauer for garbage collection Index: python16.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/python16.dsp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** python16.dsp 2000/06/06 23:29:09 1.6 --- python16.dsp 2000/06/30 05:02:53 1.7 *************** *** 660,663 **** --- 660,677 ---- # End Source File # Begin Source File + SOURCE=..\Modules\gcmodule.c + + !IF "$(CFG)" == "python16 - Win32 Release" + + !ELSEIF "$(CFG)" == "python16 - Win32 Debug" + + !ELSEIF "$(CFG)" == "python16 - Win32 Alpha Debug" + + !ELSEIF "$(CFG)" == "python16 - Win32 Alpha Release" + + !ENDIF + + # End Source File + # Begin Source File SOURCE=..\Python\getargs.c From python-dev@python.org Fri Jun 30 06:02:55 2000 From: python-dev@python.org (Jeremy Hylton) Date: Thu, 29 Jun 2000 22:02:55 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules gcmodule.c,NONE,2.1 Setup.thread.in,2.2,2.3 cPickle.c,2.43,2.44 newmodule.c,2.20,2.21 Message-ID: <200006300502.WAA03262@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv3220/Modules Modified Files: Setup.thread.in cPickle.c newmodule.c Added Files: gcmodule.c Log Message: final patches from Neil Schemenauer for garbage collection --- NEW FILE --- /* Reference Cycle Garbage Collection ================================== Neil Schemenauer Based on a post on the python-dev list. Ideas from Guido van Rossum, Eric Tiedemann, and various others. http://www.enme.calgary.ca/~nascheme/python/gc.html http://www.python.org/pipermail/python-dev/2000-March/003869.html http://www.python.org/pipermail/python-dev/2000-March/004010.html http://www.python.org/pipermail/python-dev/2000-March/004022.html For a highlevel view of the collection process, read the collect function. TODO: use a different interface for set_debug() (keywords)? tune parameters */ #include "Python.h" #ifdef WITH_CYCLE_GC /* magic gc_refs value */ #define GC_MOVED -1 /*** Global GC state ***/ /* linked lists of container objects */ static PyGC_Head generation0 = {&generation0, &generation0, 0}; static PyGC_Head generation1 = {&generation1, &generation1, 0}; static PyGC_Head generation2 = {&generation2, &generation2, 0}; static int generation = 0; /* current generation being collected */ /* collection frequencies, XXX tune these */ static int threshold0 = 100; /* net new containers before collection */ static int threshold1 = 10; /* generation0 collections before collecting 1 */ static int threshold2 = 10; /* generation1 collections before collecting 2 */ /* net new objects allocated since last collection */ static int allocated; /* set for debugging information */ #define DEBUG_STATS (1<<0) /* print collection statistics */ #define DEBUG_COLLECTABLE (1<<1) /* print collectable objects */ #define DEBUG_UNCOLLECTABLE (1<<2) /* print uncollectable objects */ #define DEBUG_INSTANCES (1<<3) /* print instances */ #define DEBUG_OBJECTS (1<<4) /* print other objects */ #define DEBUG_LEAK DEBUG_COLLECTABLE | \ DEBUG_UNCOLLECTABLE | \ DEBUG_INSTANCES | \ DEBUG_OBJECTS static int debug; /* list of uncollectable objects */ static PyObject *garbage; /*** list functions ***/ static void gc_list_init(PyGC_Head *list) { list->gc_prev = list; list->gc_next = list; } static void gc_list_append(PyGC_Head *node, PyGC_Head *list) { node->gc_next = list; node->gc_prev = list->gc_prev; node->gc_prev->gc_next = node; list->gc_prev = node; } static void 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 } static void gc_list_move(PyGC_Head *from, PyGC_Head *to) { if (from->gc_next == from) { /* empty from list */ gc_list_init(to); } else { to->gc_next = from->gc_next; to->gc_next->gc_prev = to; to->gc_prev = from->gc_prev; to->gc_prev->gc_next = to; } gc_list_init(from); } /* append a list onto another list, from becomes an empty list */ static void gc_list_merge(PyGC_Head *from, PyGC_Head *to) { PyGC_Head *tail; if (from->gc_next != from) { tail = to->gc_prev; tail->gc_next = from->gc_next; tail->gc_next->gc_prev = tail; to->gc_prev = from->gc_prev; to->gc_prev->gc_next = to; } gc_list_init(from); } static long gc_list_size(PyGC_Head *list) { PyGC_Head *gc; long n = 0; for (gc = list->gc_next; gc != list; gc = gc->gc_next) { n++; } return n; } /*** end of list stuff ***/ /* Set all gc_refs = ob_refcnt */ static void update_refs(PyGC_Head *containers) { PyGC_Head *gc = containers->gc_next; for (; gc != containers; gc=gc->gc_next) { gc->gc_refs = PyObject_FROM_GC(gc)->ob_refcnt; } } static int visit_decref(PyObject *op, void *data) { if (op && PyObject_IS_GC(op)) { PyObject_AS_GC(op)->gc_refs--; } return 0; } /* Subtract internal references from gc_refs */ static void subtract_refs(PyGC_Head *containers) { traverseproc traverse; PyGC_Head *gc = containers->gc_next; for (; gc != containers; gc=gc->gc_next) { traverse = PyObject_FROM_GC(gc)->ob_type->tp_traverse; (void) traverse(PyObject_FROM_GC(gc), (visitproc)visit_decref, NULL); } } /* Append objects with gc_refs > 0 to roots list */ static void move_roots(PyGC_Head *containers, PyGC_Head *roots) { PyGC_Head *next; PyGC_Head *gc = containers->gc_next; while (gc != containers) { next = gc->gc_next; if (gc->gc_refs > 0) { gc_list_remove(gc); gc_list_append(gc, roots); gc->gc_refs = GC_MOVED; } gc = next; } } static int visit_reachable(PyObject *op, PyGC_Head *roots) { if (PyObject_IS_GC(op)) { PyGC_Head *gc = PyObject_AS_GC(op); if (gc && gc->gc_refs != GC_MOVED) { gc_list_remove(gc); gc_list_append(gc, roots); gc->gc_refs = GC_MOVED; } } return 0; } /* Move objects referenced from reachable to reachable set. */ static void move_root_reachable(PyGC_Head *reachable) { traverseproc traverse; PyGC_Head *gc = reachable->gc_next; for (; gc != reachable; gc=gc->gc_next) { /* careful, reachable list is growing here */ PyObject *op = PyObject_FROM_GC(gc); traverse = op->ob_type->tp_traverse; (void) traverse(op, (visitproc)visit_reachable, (void *)reachable); } } /* move all objects with finalizers (instances with __del__) */ static void move_finalizers(PyGC_Head *unreachable, PyGC_Head *finalizers) { PyGC_Head *next; PyGC_Head *gc = unreachable->gc_next; static PyObject *delstr; if (delstr == NULL) { delstr = PyString_InternFromString("__del__"); } for (; gc != unreachable; gc=next) { PyObject *op = PyObject_FROM_GC(gc); next = gc->gc_next; if (PyInstance_Check(op) && PyObject_HasAttr(op, delstr)) { gc_list_remove(gc); gc_list_append(gc, finalizers); } } } /* called by tp_traverse */ static int visit_finalizer_reachable(PyObject *op, PyGC_Head *finalizers) { if (PyObject_IS_GC(op)) { PyGC_Head *gc = PyObject_AS_GC(op); if (gc && gc->gc_refs != GC_MOVED) { gc_list_remove(gc); gc_list_append(gc, finalizers); gc->gc_refs = GC_MOVED; } } return 0; } /* Move objects referenced from roots to roots */ static void move_finalizer_reachable(PyGC_Head *finalizers) { traverseproc traverse; PyGC_Head *gc = finalizers->gc_next; for (; gc != finalizers; gc=gc->gc_next) { /* careful, finalizers list is growing here */ traverse = PyObject_FROM_GC(gc)->ob_type->tp_traverse; (void) traverse(PyObject_FROM_GC(gc), (visitproc)visit_finalizer_reachable, (void *)finalizers); } } static void debug_instance(PyObject *output, char *msg, PyInstanceObject *inst) { char buf[200]; char *cname; /* be careful not to create new dictionaries */ PyObject *classname = inst->in_class->cl_name; if (classname != NULL && PyString_Check(classname)) cname = PyString_AsString(classname); else cname = "?"; sprintf(buf, "gc: %s<%.100s instance at %lx>\n", msg, cname, (long)inst); PyFile_WriteString(buf, output); } static void debug_cycle(PyObject *output, char *msg, PyObject *op) { if ((debug & DEBUG_INSTANCES) && PyInstance_Check(op)) { debug_instance(output, msg, (PyInstanceObject *)op); } else if (debug & DEBUG_OBJECTS) { char buf[200]; sprintf(buf, "gc: %s<%s 0x%x>\n", msg, op->ob_type->tp_name, (long)op); PyFile_WriteString(buf, output); } } /* Handle uncollectable garbage (cycles with finalizers). */ static void handle_finalizers(PyGC_Head *finalizers, PyGC_Head *old) { PyGC_Head *gc; if (garbage == NULL) { garbage = PyList_New(0); } for (gc = finalizers->gc_next; gc != finalizers; gc = finalizers->gc_next) { PyObject *op = PyObject_FROM_GC(gc); /* Add all instances to a Python accessible list of garbage */ if (PyInstance_Check(op)) { PyList_Append(garbage, op); } /* We assume that all objects in finalizers are reachable from * instances. Once we add the instances to the garbage list * everything is reachable from Python again. */ gc_list_remove(gc); gc_list_append(gc, old); } } /* Break reference cycles by clearing the containers involved. This is * tricky business as the lists can be changing and we don't know which * objects may be freed. It is possible I screwed something up here. */ static void delete_garbage(PyGC_Head *unreachable, PyGC_Head *old) { inquiry clear; while (unreachable->gc_next != unreachable) { PyGC_Head *gc = unreachable->gc_next; PyObject *op = PyObject_FROM_GC(gc); /* PyList_Append(garbage, op); */ if ((clear = op->ob_type->tp_clear) != NULL) { Py_INCREF(op); clear((PyObject *)op); Py_DECREF(op); } /* only try to call tp_clear once for each object */ if (unreachable->gc_next == gc) { /* still alive, move it, it may die later */ gc_list_remove(gc); gc_list_append(gc, old); } } } /* This is the main function. Read this to understand how the * collection process works. */ static long collect(PyGC_Head *young, PyGC_Head *old) { long n = 0; long m = 0; PyGC_Head reachable; PyGC_Head unreachable; PyGC_Head finalizers; PyGC_Head *gc; PyObject *output = NULL; if (debug) { output = PySys_GetObject("stderr"); } if (debug & DEBUG_STATS) { char buf[100]; sprintf(buf, "gc: collecting generation %d...\n", generation); PyFile_WriteString(buf,output); sprintf(buf, "gc: objects in each generation: %d %d %d\n", gc_list_size(&generation0), gc_list_size(&generation1), gc_list_size(&generation2)); PyFile_WriteString(buf,output); } /* Using ob_refcnt and gc_refs, calculate which objects in the * container set are reachable from outside the set (ie. have a * refcount greater than 0 when all the references within the * set are taken into account */ update_refs(young); subtract_refs(young); /* Move everything reachable from outside the set into the * reachable set (ie. gc_refs > 0). Next, move everything * reachable from objects in the reachable set. */ gc_list_init(&reachable); move_roots(young, &reachable); move_root_reachable(&reachable); /* move unreachable objects to a temporary list, new objects can be * allocated after this point */ gc_list_init(&unreachable); gc_list_move(young, &unreachable); /* move reachable objects to next generation */ gc_list_merge(&reachable, old); /* Move objects reachable from finalizers, we can't safely delete * them. Python programmers should take care not to create such * things. For Python finalizers means instance objects with * __del__ methods. */ gc_list_init(&finalizers); move_finalizers(&unreachable, &finalizers); move_finalizer_reachable(&finalizers); /* Collect statistics on collectable objects found and print * debugging information. */ for (gc = unreachable.gc_next; gc != &unreachable; gc = gc->gc_next) { m++; if (output != NULL && (debug & DEBUG_COLLECTABLE)) { debug_cycle(output, "collectable ", PyObject_FROM_GC(gc)); } } /* call tp_clear on objects in the collectable set. This will cause * the reference cycles to be broken. It may also cause some objects in * finalizers to be freed */ delete_garbage(&unreachable, old); /* Collect statistics on uncollectable objects found and print * debugging information. */ for (gc = finalizers.gc_next; gc != &finalizers; gc = gc->gc_next) { n++; if (output != NULL && (debug & DEBUG_UNCOLLECTABLE)) { debug_cycle(output, "uncollectable ", PyObject_FROM_GC(gc)); } } if (output != NULL && (debug & DEBUG_STATS)) { if (m == 0 && n == 0) { PyFile_WriteString("gc: done.\n", output); } else { char buf[200]; sprintf(buf, "gc: done, %d unreachable, %d uncollectable.\n", n+m, n); PyFile_WriteString(buf, output); } } /* Append instances in the uncollectable set to a Python * reachable list of garbage. The programmer has to deal with * this if they insist on creating this type of structure. */ handle_finalizers(&finalizers, old); allocated = 0; PyErr_Clear(); /* in case writing to sys.stderr failed */ return n+m; } static long collect_generations(void) { static long collections0 = 0; static long collections1 = 0; long n; if (collections1 > threshold2) { generation = 2; gc_list_merge(&generation0, &generation2); gc_list_merge(&generation1, &generation2); if (generation2.gc_next != &generation2) { n = collect(&generation2, &generation2); } collections1 = 0; } else if (collections0 > threshold1) { generation = 1; collections1++; gc_list_merge(&generation0, &generation1); if (generation1.gc_next != &generation1) { n = collect(&generation1, &generation2); } collections0 = 0; } else { generation = 0; collections0++; if (generation0.gc_next != &generation0) { n = collect(&generation0, &generation1); } } return n; } void _PyGC_Insert(PyObject *op) { /* collection lock since collecting may cause allocations */ static int collecting = 0; #ifdef Py_DEBUG if (!PyObject_IS_GC(op)) { abort(); } #endif if (threshold0 && allocated > threshold0 && !collecting) { collecting++; collect_generations(); collecting--; } allocated++; gc_list_append(PyObject_AS_GC(op), &generation0); } void _PyGC_Remove(PyObject *op) { PyGC_Head *g = PyObject_AS_GC(op); #ifdef Py_DEBUG if (!PyObject_IS_GC(op)) { abort(); } #endif gc_list_remove(g); if (allocated > 0) { allocated--; } } static char collect__doc__[] = "collect() -> n\n" "\n" "Run a full collection. The number of unreachable objects is returned.\n" ; static PyObject * Py_collect(self, args) PyObject *self; PyObject *args; { long n; if(!PyArg_ParseTuple(args, "")) /* check no args */ return NULL; generation = 2; gc_list_merge(&generation0, &generation2); gc_list_merge(&generation1, &generation2); n = collect(&generation2, &generation2); return Py_BuildValue("i", n); } static char set_debug__doc__[] = "set_debug(flags) -> None\n" "\n" "Set the garbage collection debugging flags. Debugging information is\n" "written to sys.stderr.\n" "\n" "flags is an integer and can have the following bits turned on:\n" "\n" " DEBUG_STATS - Print statistics during collection.\n" " DEBUG_COLLECTABLE - Print collectable objects found.\n" " DEBUG_UNCOLLECTABLE - Print unreachable but uncollectable objects found.\n" " DEBUG_INSTANCES - Print instance objects.\n" " DEBUG_OBJECTS - Print objects other than instances.\n" " DEBUG_LEAK - Debug leaking programs (everything but STATS).\n" ; static PyObject * Py_set_debug(self, args) PyObject *self; PyObject *args; { if (!PyArg_ParseTuple(args, "l", &debug)) return NULL; Py_INCREF(Py_None); return Py_None; } static char get_debug__doc__[] = "get_debug() -> flags\n" "\n" "Get the garbage collection debugging flags.\n" ; static PyObject * Py_get_debug(self, args) PyObject *self; PyObject *args; { if(!PyArg_ParseTuple(args, "")) /* no args */ return NULL; return Py_BuildValue("i", debug); } static char set_thresh__doc__[] = "set_threshold(threshold0, [threhold1, threshold2]) -> None\n" "\n" "Sets the collection thresholds. Setting threshold0 to zero disables\n" "collection.\n" ; static PyObject * Py_set_thresh(self, args) PyObject *self; PyObject *args; { if (!PyArg_ParseTuple(args, "i|ii", &threshold0, &threshold1, &threshold2)) return NULL; Py_INCREF(Py_None); return Py_None; } static char get_thresh__doc__[] = "get_threshold() -> (threshold0, threshold1, threshold2)\n" "\n" "Return the current collection thresholds\n" ; static PyObject * Py_get_thresh(self, args) PyObject *self; PyObject *args; { if(!PyArg_ParseTuple(args, "")) /* no args */ return NULL; return Py_BuildValue("(iii)", threshold0, threshold1, threshold2); } static char gc__doc__ [] = "This module provides access to the garbage collector for reference cycles.\n" "\n" "collect() -- Do a full collection right now.\n" "set_debug() -- Set debugging flags.\n" "get_debug() -- Get debugging flags.\n" "set_threshold() -- Set the collection thresholds.\n" "get_threshold() -- Return the current the collection thresholds.\n" ; static PyMethodDef GcMethods[] = { {"set_debug", Py_set_debug, METH_VARARGS, set_debug__doc__}, {"get_debug", Py_get_debug, METH_VARARGS, get_debug__doc__}, {"set_threshold", Py_set_thresh, METH_VARARGS, set_thresh__doc__}, {"get_threshold", Py_get_thresh, METH_VARARGS, get_thresh__doc__}, {"collect", Py_collect, METH_VARARGS, collect__doc__}, {NULL, NULL} /* Sentinel */ }; void initgc(void) { PyObject *m; PyObject *d; m = Py_InitModule4("gc", GcMethods, gc__doc__, NULL, PYTHON_API_VERSION); d = PyModule_GetDict(m); if (garbage == NULL) { garbage = PyList_New(0); } PyDict_SetItemString(d, "garbage", garbage); PyDict_SetItemString(d, "DEBUG_STATS", PyInt_FromLong(DEBUG_STATS)); PyDict_SetItemString(d, "DEBUG_COLLECTABLE", PyInt_FromLong(DEBUG_COLLECTABLE)); PyDict_SetItemString(d, "DEBUG_UNCOLLECTABLE", PyInt_FromLong(DEBUG_UNCOLLECTABLE)); PyDict_SetItemString(d, "DEBUG_INSTANCES", PyInt_FromLong(DEBUG_INSTANCES)); PyDict_SetItemString(d, "DEBUG_OBJECTS", PyInt_FromLong(DEBUG_OBJECTS)); PyDict_SetItemString(d, "DEBUG_LEAK", PyInt_FromLong(DEBUG_LEAK)); } #endif /* WITH_CYCLE_GC */ Index: Setup.thread.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Setup.thread.in,v retrieving revision 2.2 retrieving revision 2.3 diff -C2 -r2.2 -r2.3 *** Setup.thread.in 2000/06/29 16:08:28 2.2 --- Setup.thread.in 2000/06/30 05:02:53 2.3 *************** *** 11,12 **** --- 11,15 ---- @USE_THREAD_MODULE@thread threadmodule.c + + # Garbage collection enabled with --with-cycle-gc + @USE_GC_MODULE@gc gcmodule.c Index: cPickle.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cPickle.c,v retrieving revision 2.43 retrieving revision 2.44 diff -C2 -r2.43 -r2.44 *** cPickle.c 2000/06/28 22:23:56 2.43 --- cPickle.c 2000/06/30 05:02:53 2.44 *************** *** 2893,2897 **** goto err; } ! return (PyObject *)inst; } --- 2893,2897 ---- goto err; } ! PyObject_GC_Init(inst); return (PyObject *)inst; } Index: newmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/newmodule.c,v retrieving revision 2.20 retrieving revision 2.21 diff -C2 -r2.20 -r2.21 *** newmodule.c 2000/05/03 23:44:32 2.20 --- newmodule.c 2000/06/30 05:02:53 2.21 *************** *** 57,60 **** --- 57,61 ---- inst->in_class = (PyClassObject *)klass; inst->in_dict = dict; + PyObject_GC_Init(inst); return (PyObject *)inst; } From python-dev@python.org Fri Jun 30 06:02:56 2000 From: python-dev@python.org (Jeremy Hylton) Date: Thu, 29 Jun 2000 22:02:56 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_gc.py,NONE,1.1 Message-ID: <200006300502.WAA03281@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv3220/Lib/test Added Files: test_gc.py Log Message: final patches from Neil Schemenauer for garbage collection --- NEW FILE --- import gc def test_list(): l = [] l.append(l) print 'list 0x%x' % id(l) gc.collect() del l assert gc.collect() == 1 def test_dict(): d = {} d[1] = d print 'dict 0x%x' % id(d) gc.collect() del d assert gc.collect() == 1 def test_tuple(): l = [] t = (l,) l.append(t) print 'list 0x%x' % id(l) print 'tuple 0x%x' % id(t) gc.collect() del t del l assert gc.collect() == 2 def test_class(): class A: pass A.a = A print 'class 0x%x' % id(A) gc.collect() del A assert gc.collect() > 0 def test_instance(): class A: pass a = A() a.a = a print repr(a) gc.collect() del a assert gc.collect() > 0 def test_method(): class A: def __init__(self): self.init = self.__init__ a = A() gc.collect() del a assert gc.collect() > 0 def test_finalizer(): class A: def __del__(self): pass class B: pass a = A() a.a = a id_a = id(a) b = B() b.b = b print 'a', repr(a) print 'b', repr(b) gc.collect() gc.garbage[:] = [] del a del b assert gc.collect() > 0 assert id(gc.garbage[0]) == id_a def test_function(): d = {} exec("def f(): pass\n") in d print 'dict 0x%x' % id(d) print 'func 0x%x' % id(d['f']) gc.collect() del d assert gc.collect() == 2 def test_all(): debug = gc.get_debug() gc.set_debug(gc.DEBUG_LEAK | gc.DEBUG_STATS) test_list() test_dict() test_tuple() test_class() test_instance() test_method() test_finalizer() test_function() gc.set_debug(debug) test_all() From python-dev@python.org Fri Jun 30 06:02:56 2000 From: python-dev@python.org (Jeremy Hylton) Date: Thu, 29 Jun 2000 22:02:56 -0700 Subject: [Python-checkins] CVS: python/dist/src/PC config.c,1.22,1.23 config.h,1.38,1.39 Message-ID: <200006300502.WAA03280@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv3220/PC Modified Files: config.c config.h Log Message: final patches from Neil Schemenauer for garbage collection Index: config.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/config.c,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** config.c 2000/05/08 14:15:19 1.22 --- config.c 2000/06/30 05:02:53 1.23 *************** *** 44,47 **** --- 44,50 ---- extern void initcmath(); extern void initerrno(); + #ifdef WITH_CYCLE_GC + extern void initgc(); + #endif #ifndef MS_WIN64 extern void initimageop(); *************** *** 90,93 **** --- 93,99 ---- {"cmath", initcmath}, {"errno", initerrno}, + #ifdef WITH_CYCLE_GC + {"gc", initgc}, + #endif #ifndef MS_WIN64 {"imageop", initimageop}, Index: config.h =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/config.h,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -r1.38 -r1.39 *** config.h 2000/06/29 20:44:47 1.38 --- config.h 2000/06/30 05:02:53 1.39 *************** *** 452,455 **** --- 452,458 ---- /* #define WITH_READLINE 1 */ + /* Define if you want cycle garbage collection */ + /* #define WITH_CYCLE_GC 1 */ + /* Define if you have clock. */ /* #define HAVE_CLOCK */ From python-dev@python.org Fri Jun 30 06:02:56 2000 From: python-dev@python.org (Jeremy Hylton) Date: Thu, 29 Jun 2000 22:02:56 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_gc,NONE,1.1 Message-ID: <200006300502.WAA03286@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv3220/Lib/test/output Added Files: test_gc Log Message: final patches from Neil Schemenauer for garbage collection --- NEW FILE --- test_gc list 0x831a754 dict 0x831a754 list 0x831a754 tuple 0x831a734 class 0x831a794 a b dict 0x831a9bc func 0x831d9e4 From python-dev@python.org Fri Jun 30 06:02:56 2000 From: python-dev@python.org (Jeremy Hylton) Date: Thu, 29 Jun 2000 22:02:56 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects classobject.c,2.92,2.93 dictobject.c,2.54,2.55 funcobject.c,2.23,2.24 listobject.c,2.75,2.76 object.c,2.74,2.75 tupleobject.c,2.38,2.39 Message-ID: <200006300502.WAA03295@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv3220/Objects Modified Files: classobject.c dictobject.c funcobject.c listobject.c object.c tupleobject.c Log Message: final patches from Neil Schemenauer for garbage collection Index: classobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v retrieving revision 2.92 retrieving revision 2.93 diff -C2 -r2.92 -r2.93 *** classobject.c 2000/06/29 19:17:04 2.92 --- classobject.c 2000/06/30 05:02:53 2.93 *************** *** 133,136 **** --- 133,137 ---- Py_XINCREF(op->cl_setattr); Py_XINCREF(op->cl_delattr); + PyObject_GC_Init(op); return (PyObject *) op; } *************** *** 142,145 **** --- 143,147 ---- PyClassObject *op; { + PyObject_GC_Fini(op); Py_DECREF(op->cl_bases); Py_DECREF(op->cl_dict); *************** *** 429,433 **** 0, "class", ! sizeof(PyClassObject) + PyGC_INFO_SIZE, 0, (destructor)class_dealloc, /*tp_dealloc*/ --- 431,435 ---- 0, "class", ! sizeof(PyClassObject) + PyGC_HEAD_SIZE, 0, (destructor)class_dealloc, /*tp_dealloc*/ *************** *** 491,494 **** --- 493,497 ---- return NULL; inst->in_dict = PyDict_New(); + PyObject_GC_Init(inst); if (inst->in_dict == NULL) { PyObject_DEL(inst); *************** *** 540,548 **** PyObject *del; static PyObject *delstr; /* Call the __del__ method if it exists. First temporarily revive the object and save the current exception, if any. */ #ifdef Py_TRACE_REFS /* much too complicated if Py_TRACE_REFS defined */ - extern long _Py_RefTotal; inst->ob_type = &PyInstance_Type; _Py_NewReference((PyObject *)inst); --- 543,552 ---- PyObject *del; static PyObject *delstr; + extern long _Py_RefTotal; + PyObject_GC_Fini(inst); /* Call the __del__ method if it exists. First temporarily revive the object and save the current exception, if any. */ #ifdef Py_TRACE_REFS /* much too complicated if Py_TRACE_REFS defined */ inst->ob_type = &PyInstance_Type; _Py_NewReference((PyObject *)inst); *************** *** 592,595 **** --- 596,600 ---- inst->ob_type->tp_free--; #endif + PyObject_GC_Init((PyObject *)inst); return; /* __del__ added a reference; don't delete now */ } *************** *** 599,603 **** --- 604,610 ---- #endif _Py_ForgetReference((PyObject *)inst); + #ifndef WITH_CYCLE_GC inst->ob_type = NULL; + #endif #endif /* Py_TRACE_REFS */ Py_DECREF(inst->in_class); *************** *** 1511,1515 **** 0, "instance", ! sizeof(PyInstanceObject) + PyGC_INFO_SIZE, 0, (destructor)instance_dealloc, /*tp_dealloc*/ --- 1518,1522 ---- 0, "instance", ! sizeof(PyInstanceObject) + PyGC_HEAD_SIZE, 0, (destructor)instance_dealloc, /*tp_dealloc*/ *************** *** 1569,1572 **** --- 1576,1580 ---- Py_INCREF(class); im->im_class = class; + PyObject_GC_Init(im); return (PyObject *)im; } *************** *** 1644,1647 **** --- 1652,1656 ---- register PyMethodObject *im; { + PyObject_GC_Fini(im); Py_DECREF(im->im_func); Py_XDECREF(im->im_self); *************** *** 1746,1750 **** 0, "instance method", ! sizeof(PyMethodObject) + PyGC_INFO_SIZE, 0, (destructor)instancemethod_dealloc, /*tp_dealloc*/ --- 1755,1759 ---- 0, "instance method", ! sizeof(PyMethodObject) + PyGC_HEAD_SIZE, 0, (destructor)instancemethod_dealloc, /*tp_dealloc*/ Index: dictobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/dictobject.c,v retrieving revision 2.54 retrieving revision 2.55 diff -C2 -r2.54 -r2.55 *** dictobject.c 2000/06/23 19:37:01 2.54 --- dictobject.c 2000/06/30 05:02:53 2.55 *************** *** 130,133 **** --- 130,134 ---- mp->ma_fill = 0; mp->ma_used = 0; + PyObject_GC_Init(mp); return (PyObject *)mp; } *************** *** 482,485 **** --- 483,487 ---- 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) { *************** *** 1088,1092 **** 0, "dictionary", ! sizeof(dictobject) + PyGC_INFO_SIZE, 0, (destructor)dict_dealloc, /*tp_dealloc*/ --- 1090,1094 ---- 0, "dictionary", ! sizeof(dictobject) + PyGC_HEAD_SIZE, 0, (destructor)dict_dealloc, /*tp_dealloc*/ Index: funcobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/funcobject.c,v retrieving revision 2.23 retrieving revision 2.24 diff -C2 -r2.23 -r2.24 *** funcobject.c 2000/06/29 19:17:04 2.23 --- funcobject.c 2000/06/30 05:02:53 2.24 *************** *** 64,67 **** --- 64,68 ---- op->func_doc = doc; } + PyObject_GC_Init(op); return (PyObject *)op; } *************** *** 187,190 **** --- 188,192 ---- PyFunctionObject *op; { + PyObject_GC_Fini(op); Py_DECREF(op->func_code); Py_DECREF(op->func_globals); *************** *** 278,282 **** 0, "function", ! sizeof(PyFunctionObject) + PyGC_INFO_SIZE, 0, (destructor)func_dealloc, /*tp_dealloc*/ --- 280,284 ---- 0, "function", ! sizeof(PyFunctionObject) + PyGC_HEAD_SIZE, 0, (destructor)func_dealloc, /*tp_dealloc*/ Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.75 retrieving revision 2.76 diff -C2 -r2.75 -r2.76 *** listobject.c 2000/06/23 19:37:01 2.75 --- listobject.c 2000/06/30 05:02:53 2.76 *************** *** 73,80 **** /* PyObject_NewVar is inlined */ op = (PyListObject *) PyObject_MALLOC(sizeof(PyListObject) ! + PyGC_INFO_SIZE); if (op == NULL) { return PyErr_NoMemory(); } if (size <= 0) { op->ob_item = NULL; --- 73,81 ---- /* PyObject_NewVar is inlined */ op = (PyListObject *) PyObject_MALLOC(sizeof(PyListObject) ! + PyGC_HEAD_SIZE); if (op == NULL) { return PyErr_NoMemory(); } + op = (PyListObject *) PyObject_FROM_GC(op); if (size <= 0) { op->ob_item = NULL; *************** *** 90,93 **** --- 91,95 ---- for (i = 0; i < size; i++) op->ob_item[i] = NULL; + PyObject_GC_Init(op); return (PyObject *) op; } *************** *** 217,220 **** --- 219,223 ---- int i; Py_TRASHCAN_SAFE_BEGIN(op) + PyObject_GC_Fini(op); if (op->ob_item != NULL) { /* Do it backwards, for Christian Tismer. *************** *** 1499,1503 **** 0, "list", ! sizeof(PyListObject) + PyGC_INFO_SIZE, 0, (destructor)list_dealloc, /*tp_dealloc*/ --- 1502,1506 ---- 0, "list", ! sizeof(PyListObject) + PyGC_HEAD_SIZE, 0, (destructor)list_dealloc, /*tp_dealloc*/ *************** *** 1578,1582 **** 0, "list (immutable, during sort)", ! sizeof(PyListObject) + PyGC_INFO_SIZE, 0, 0, /*tp_dealloc*/ /* Cannot happen */ --- 1581,1585 ---- 0, "list (immutable, during sort)", ! sizeof(PyListObject) + PyGC_HEAD_SIZE, 0, 0, /*tp_dealloc*/ /* Cannot happen */ Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.74 retrieving revision 2.75 diff -C2 -r2.74 -r2.75 *** object.c 2000/06/29 19:17:04 2.74 --- object.c 2000/06/30 05:02:53 2.75 *************** *** 125,128 **** --- 125,132 ---- return op; } + #ifdef WITH_CYCLE_GC + if (PyType_IS_GC(tp)) + op = (PyObject *) PyObject_FROM_GC(op); + #endif /* Any changes should be reflected in PyObject_INIT (objimpl.h) */ op->ob_type = tp; *************** *** 142,145 **** --- 146,153 ---- return op; } + #ifdef WITH_CYCLE_GC + if (PyType_IS_GC(tp)) + op = (PyVarObject *) PyObject_FROM_GC(op); + #endif /* Any changes should be reflected in PyObject_INIT_VAR */ op->ob_size = size; *************** *** 157,160 **** --- 165,172 ---- if (op == NULL) return PyErr_NoMemory(); + #ifdef WITH_CYCLE_GC + if (PyType_IS_GC(tp)) + op = (PyObject *) PyObject_FROM_GC(op); + #endif return PyObject_INIT(op, tp); } *************** *** 169,172 **** --- 181,188 ---- if (op == NULL) return (PyVarObject *)PyErr_NoMemory(); + #ifdef WITH_CYCLE_GC + if (PyType_IS_GC(tp)) + op = (PyVarObject *) PyObject_FROM_GC(op); + #endif return PyObject_INIT_VAR(op, tp, size); } *************** *** 176,182 **** PyObject *op; { ! PyObject_FREE(op); } int PyObject_Print(op, fp, flags) --- 192,212 ---- PyObject *op; { ! #ifdef WITH_CYCLE_GC ! if (PyType_IS_GC(op->ob_type)) { ! PyGC_Head *g = PyObject_AS_GC(op); ! PyObject_FREE(g); ! } else ! #endif ! { ! PyObject_FREE(op); ! } } + #ifndef WITH_CYCLE_GC + /* extension modules might need these */ + void _PyGC_Insert(PyObject *op) { } + void _PyGC_Remove(PyObject *op) { } + #endif + int PyObject_Print(op, fp, flags) *************** *** 918,923 **** --- 948,955 ---- destructor dealloc = op->ob_type->tp_dealloc; _Py_ForgetReference(op); + #ifndef WITH_CYCLE_GC if (_PyTrash_delete_nesting < PyTrash_UNWIND_LEVEL-1) op->ob_type = NULL; + #endif (*dealloc)(op); } Index: tupleobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/tupleobject.c,v retrieving revision 2.38 retrieving revision 2.39 diff -C2 -r2.38 -r2.39 *** tupleobject.c 2000/06/23 19:37:02 2.38 --- tupleobject.c 2000/06/30 05:02:53 2.39 *************** *** 95,99 **** if (nbytes / sizeof(PyObject *) != (size_t)size || (nbytes += sizeof(PyTupleObject) - sizeof(PyObject *) ! + PyGC_INFO_SIZE) <= 0) { --- 95,99 ---- if (nbytes / sizeof(PyObject *) != (size_t)size || (nbytes += sizeof(PyTupleObject) - sizeof(PyObject *) ! + PyGC_HEAD_SIZE) <= 0) { *************** *** 104,108 **** if (op == NULL) return PyErr_NoMemory(); ! PyObject_INIT_VAR(op, &PyTuple_Type, size); } --- 104,108 ---- if (op == NULL) return PyErr_NoMemory(); ! op = (PyTupleObject *) PyObject_FROM_GC(op); PyObject_INIT_VAR(op, &PyTuple_Type, size); } *************** *** 116,119 **** --- 116,120 ---- } #endif + PyObject_GC_Init(op); return (PyObject *) op; } *************** *** 182,185 **** --- 183,187 ---- register int len = op->ob_size; Py_TRASHCAN_SAFE_BEGIN(op) + PyObject_GC_Fini(op); if (len > 0) { i = len; *************** *** 454,458 **** 0, "tuple", ! sizeof(PyTupleObject) - sizeof(PyObject *) + PyGC_INFO_SIZE, sizeof(PyObject *), (destructor)tupledealloc, /*tp_dealloc*/ --- 456,460 ---- 0, "tuple", ! sizeof(PyTupleObject) - sizeof(PyObject *) + PyGC_HEAD_SIZE, sizeof(PyObject *), (destructor)tupledealloc, /*tp_dealloc*/ *************** *** 558,567 **** #endif { sv = (PyTupleObject *) PyObject_REALLOC((char *)v, sizeof(PyTupleObject) ! + PyGC_INFO_SIZE + newsize * sizeof(PyObject *)); *pv = (PyObject *) sv; if (sv == NULL) { PyObject_DEL(v); PyErr_NoMemory(); --- 560,584 ---- #endif { + #ifdef WITH_CYCLE_GC + PyGC_Head *g = PyObject_AS_GC((PyObject *)v); + PyObject_GC_Fini((PyObject *)v); sv = (PyTupleObject *) + PyObject_REALLOC((char *)g, sizeof(PyTupleObject) + + PyGC_HEAD_SIZE + + newsize * sizeof(PyObject *)); + if (g == NULL) { + sv = NULL; + } else { + sv = (PyTupleObject *)PyObject_FROM_GC(g); + } + #else + sv = (PyTupleObject *) PyObject_REALLOC((char *)v, sizeof(PyTupleObject) ! + PyGC_HEAD_SIZE + newsize * sizeof(PyObject *)); + #endif *pv = (PyObject *) sv; if (sv == NULL) { + PyObject_GC_Init((PyObject *)v); PyObject_DEL(v); PyErr_NoMemory(); *************** *** 579,582 **** --- 596,600 ---- } } + PyObject_GC_Init(sv); sv->ob_size = newsize; return 0; From python-dev@python.org Fri Jun 30 07:05:50 2000 From: python-dev@python.org (Trent Mick) Date: Thu, 29 Jun 2000 23:05:50 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild python16.dsp,1.6,1.7 In-Reply-To: <200006300502.WAA03275@slayer.i.sourceforge.net> References: <200006300502.WAA03275@slayer.i.sourceforge.net> Message-ID: <20000629230550.A24811@activestate.com> On Thu, Jun 29, 2000 at 10:02:55PM -0700, Jeremy Hylton wrote: > Update of /cvsroot/python/python/dist/src/PCbuild > In directory slayer.i.sourceforge.net:/tmp/cvs-serv3220/PCbuild > > Modified Files: > python16.dsp > Log Message: > final patches from Neil Schemenauer for garbage collection > > > Index: python16.dsp > =================================================================== > RCS file: /cvsroot/python/python/dist/src/PCbuild/python16.dsp,v > retrieving revision 1.6 > retrieving revision 1.7 > diff -C2 -r1.6 -r1.7 > *** python16.dsp 2000/06/06 23:29:09 1.6 > --- python16.dsp 2000/06/30 05:02:53 1.7 > *************** > *** 660,663 **** > --- 660,677 ---- > # End Source File > # Begin Source File > + SOURCE=..\Modules\gcmodule.c > + > + !IF "$(CFG)" == "python16 - Win32 Release" > + > + !ELSEIF "$(CFG)" == "python16 - Win32 Debug" > + > + !ELSEIF "$(CFG)" == "python16 - Win32 Alpha Debug" > + > + !ELSEIF "$(CFG)" == "python16 - Win32 Alpha Release" > + > + !ENDIF > + > + # End Source File > + # Begin Source File > > SOURCE=..\Python\getargs.c > Pardon me if I am wrong (I have not actually checked the repository) but is this correct now that the version number is 2.0? Trent -- Trent Mick trentm@activestate.com From python-dev@python.org Fri Jun 30 07:08:38 2000 From: python-dev@python.org (Skip Montanaro) Date: Thu, 29 Jun 2000 23:08:38 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test README,NONE,1.1 Message-ID: <200006300608.XAA13124@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv13116 Added Files: README Log Message: Describe a bit about writing test cases for Python... --- NEW FILE --- Writing Python Test Cases ------------------------- Skip Montanaro If you add a new module to Python or modify the functionality of an existing module, it is your responsibility to write one or more test cases to test that new functionality. The mechanics of the test system are fairly straightforward. If you are writing test cases for module zyzzyx, you need to create a file in .../Lib/test named test_zyzzyx.py and an expected output file in .../Lib/test/output named test_zyzzyx ("..." represents the top-level directory in the Python source tree, the directory containing the configure script). Generate the initial version of the test output file by executing: cd .../Lib/test python regrtest.py -g test_zyzzyx.py Any time you modify test_zyzzyx.py you need to generate a new expected output file. Don't forget to desk check the generated output to make sure it's really what you expected to find! To run a single test after modifying a module, simply run regrtest.py without the -g flag: cd .../Lib/test python regrtest.py test_zyzzyx.py To run the entire test suite, make the "test" target at the top level: cd ... make test Test cases generate output based upon computed values and branches taken in the code. When executed, regrtest.py compares the actual output generated by executing the test case with the expected output and reports success or failure. It stands to reason that if the actual and expected outputs are to match, they must not contain any machine dependencies. This means your test cases should not print out absolute machine addresses or floating point numbers with large numbers of significant digits. Writing good test cases is a skilled task and is too complex to discuss in detail in this short document. Many books have been written on the subject. I'll show my age by suggesting that Glenford Myers' "The Art of Software Testing", published in 1979, is still the best introduction to the subject available. It is short (177 pages), easy to read, and discusses the major elements of software testing, though its publication predates the object-oriented software revolution, so doesn't cover that subject at all. Unfortunately, it is very expensive (about $100 new). If you can borrow it or find it used (around $20), I strongly urge you to pick up a copy. As an author of at least part of a module, you will be writing unit tests (isolated tests of functions and objects defined by the module) using white box techniques. (Unlike black box testing, where you only have the external interfaces to guide your test case writing, in white box testing you can see the code being tested and tailor your test cases to exercise it more completely). The most important goal when writing test cases is to break things. A test case that doesn't uncover a bug is less valuable than one that does. In designing test cases you should pay attention to the following: 1. Your test cases should exercise all the functions and objects defined in the module, not just the ones meant to be called by users of your module. This may require you to write test code that uses the module in ways you don't expect (explicitly calling internal functions, for example - see test_atexit.py). 2. You should consider any boundary values that may tickle exceptional conditions (e.g. if you were testing a division module you might well want to generate tests with numerators and denominators at the limits of floating point and integer numbers on the machine performing the tests as well as a denominator of zero). 3. You should exercise as many paths through the code as possible. This may not always be possible, but is a goal to strive for. In particular, when considering if statements (or their equivalent), you want to create test cases that exercise both the true and false branches. For while and for statements, you should create test cases that exercise the loop zero, one and multiple times. From python-dev@python.org Fri Jun 30 07:39:12 2000 From: python-dev@python.org (Tim Peters) Date: Fri, 30 Jun 2000 02:39:12 -0400 Subject: [Python-Dev] Re: [Python-checkins] CVS: python/dist/src/PCbuild python16.dsp,1.6,1.7 In-Reply-To: <20000629230550.A24811@activestate.com> Message-ID: [Trent Mick, on Guido's late-night (for him ) checkin of python16.dsp] > Pardon me if I am wrong (I have not actually checked the > repository) but is this correct now that the version number is 2.0? No, it is not, and the Windows build is slightly damaged now. I've already yelled at Guido about this, but I suspect he's asleep. I'm sure it will get sorted out in the morning. From python-dev@python.org Fri Jun 30 08:05:50 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 00:05:50 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre.py,1.14,1.15 Message-ID: <200006300705.AAA22019@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv21938/Lib Modified Files: sre.py Log Message: - fixed default value handling in group/groupdict - added test suite Index: sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** sre.py 2000/06/30 00:27:45 1.14 --- sre.py 2000/06/30 07:05:47 1.15 *************** *** 21,25 **** X = VERBOSE = sre_compile.SRE_FLAG_VERBOSE ! # sre extensions (may or may not be in 1.6 final) T = TEMPLATE = sre_compile.SRE_FLAG_TEMPLATE U = UNICODE = sre_compile.SRE_FLAG_UNICODE --- 21,25 ---- X = VERBOSE = sre_compile.SRE_FLAG_VERBOSE ! # sre extensions (may or may not be in 2.0 final) T = TEMPLATE = sre_compile.SRE_FLAG_TEMPLATE U = UNICODE = sre_compile.SRE_FLAG_UNICODE From python-dev@python.org Fri Jun 30 08:05:50 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 00:05:50 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.13,2.14 Message-ID: <200006300705.AAA22023@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv21938/Modules Modified Files: _sre.c Log Message: - fixed default value handling in group/groupdict - added test suite Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.13 retrieving revision 2.14 diff -C2 -r2.13 -r2.14 *** _sre.c 2000/06/30 00:27:46 2.13 --- _sre.c 2000/06/30 07:05:48 2.14 *************** *** 1567,1571 **** static PyObject* ! match_getslice_by_index(MatchObject* self, int index) { if (index < 0 || index >= self->groups) { --- 1567,1571 ---- static PyObject* ! match_getslice_by_index(MatchObject* self, int index, PyObject* def) { if (index < 0 || index >= self->groups) { *************** *** 1579,1585 **** if (self->string == Py_None || self->mark[index+index] < 0) { ! /* return None if the string or group is undefined */ ! Py_INCREF(Py_None); ! return Py_None; } --- 1579,1585 ---- if (self->string == Py_None || self->mark[index+index] < 0) { ! /* return default value if the string or group is undefined */ ! Py_INCREF(def); ! return def; } *************** *** 1606,1612 **** static PyObject* ! match_getslice(MatchObject* self, PyObject* index) { ! return match_getslice_by_index(self, match_getindex(self, index)); } --- 1606,1612 ---- static PyObject* ! match_getslice(MatchObject* self, PyObject* index, PyObject* def) { ! return match_getslice_by_index(self, match_getindex(self, index), def); } *************** *** 1621,1628 **** switch (size) { case 0: ! result = match_getslice(self, Py_False); break; case 1: ! result = match_getslice(self, PyTuple_GET_ITEM(args, 0)); break; default: --- 1621,1628 ---- switch (size) { case 0: ! result = match_getslice(self, Py_False, Py_None); break; case 1: ! result = match_getslice(self, PyTuple_GET_ITEM(args, 0), Py_None); break; default: *************** *** 1632,1636 **** return NULL; for (i = 0; i < size; i++) { ! PyObject* item = match_getslice(self, PyTuple_GET_ITEM(args, i)); if (!item) { Py_DECREF(result); --- 1632,1638 ---- return NULL; for (i = 0; i < size; i++) { ! PyObject* item = match_getslice( ! self, PyTuple_GET_ITEM(args, i), Py_None ! ); if (!item) { Py_DECREF(result); *************** *** 1650,1654 **** int index; ! /* FIXME: handle default value! */ result = PyTuple_New(self->groups-1); --- 1652,1658 ---- int index; ! PyObject* def = Py_None; ! if (!PyArg_ParseTuple(args, "|O", &def)) ! return NULL; result = PyTuple_New(self->groups-1); *************** *** 1658,1663 **** for (index = 1; index < self->groups; index++) { PyObject* item; ! /* FIXME: handle default! */ ! item = match_getslice_by_index(self, index); if (!item) { Py_DECREF(result); --- 1662,1666 ---- for (index = 1; index < self->groups; index++) { PyObject* item; ! item = match_getslice_by_index(self, index, def); if (!item) { Py_DECREF(result); *************** *** 1677,1691 **** int index; ! /* FIXME: handle default value! */ result = PyDict_New(); ! if (!result) ! return NULL; ! if (!self->pattern->groupindex) return result; keys = PyMapping_Keys(self->pattern->groupindex); ! if (!keys) return NULL; for (index = 0; index < PyList_GET_SIZE(keys); index++) { --- 1680,1696 ---- int index; ! PyObject* def = Py_None; ! if (!PyArg_ParseTuple(args, "|O", &def)) ! return NULL; result = PyDict_New(); ! if (!result || !self->pattern->groupindex) return result; keys = PyMapping_Keys(self->pattern->groupindex); ! if (!keys) { ! Py_DECREF(result); return NULL; + } for (index = 0; index < PyList_GET_SIZE(keys); index++) { *************** *** 1698,1702 **** return NULL; } ! item = match_getslice(self, key); if (!item) { Py_DECREF(key); --- 1703,1707 ---- return NULL; } ! item = match_getslice(self, key, def); if (!item) { Py_DECREF(key); From python-dev@python.org Fri Jun 30 08:08:22 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 00:08:22 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_sre,NONE,1.1 Message-ID: <200006300708.AAA22167@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv22149/Lib/test/output Added Files: test_sre Log Message: - fixed default value handling in group/groupdict - added test suite --- NEW FILE --- test_sre test_support -- test failed re module pickle test_support -- test failed re module cPickle === Syntax error: ('(?Pa)(?P=foo_123)', 'aa', 0, 'g1', 'a') === Failed incorrectly ('^(.+)?B', 'AB', 0, 'g1', 'A') === Failed incorrectly ('(a+)+\\1', 'aa', 0, 'found+"-"+g1', 'aa-a') === grouping error ('([^/]*/)*sub1/', 'd:msgs/tdir/sub1/trial/away.cpp', 0, 'found+"-"+g1', 'd:msgs/tdir/sub1/-tdir/') 'd:msgs/tdir/sub1/-trial/' should be 'd:msgs/tdir/sub1/-tdir/' === Syntax error: ('(?Paa)(?P=id)', 'aaaa', 0, 'found+"-"+id', 'aaaa-aa') === grouping error ('([abc])*bcd', 'abcd', 0, 'found+"-"+g1', 'abcd-a') 'abcd-c' should be 'abcd-a' === grouping error ('(?i)([abc])*bcd', 'ABCD', 0, 'found+"-"+g1', 'ABCD-A') 'ABCD-C' should be 'ABCD-A' === Syntax error: ('a(?!b).', 'abad', 0, 'found', 'ad') === Syntax error: ('a(?=d).', 'abad', 0, 'found', 'ad') === Syntax error: ('a(?=c|d).', 'abad', 0, 'found', 'ad') === Failed incorrectly ('^(.+)?B', 'AB', 0, 'g1', 'A') From python-dev@python.org Fri Jun 30 08:08:22 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 00:08:22 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_sre.py,NONE,1.1 Message-ID: <200006300708.AAA22164@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv22149/Lib/test Added Files: test_sre.py Log Message: - fixed default value handling in group/groupdict - added test suite --- NEW FILE --- # FIXME: this is basically test_re.py, with a few import sys sys.path=['.']+sys.path from test_support import verbose, TestFailed import sre import sys, os, string, traceback # Misc tests from Tim Peters' re.doc if verbose: print 'Running tests on sre.search and sre.match' try: assert sre.search('x*', 'axx').span(0) == (0, 0) assert sre.search('x*', 'axx').span() == (0, 0) assert sre.search('x+', 'axx').span(0) == (1, 3) assert sre.search('x+', 'axx').span() == (1, 3) assert sre.search('x', 'aaa') == None except: raise TestFailed, "sre.search" try: assert sre.match('a*', 'xxx').span(0) == (0, 0) assert sre.match('a*', 'xxx').span() == (0, 0) assert sre.match('x*', 'xxxa').span(0) == (0, 3) assert sre.match('x*', 'xxxa').span() == (0, 3) assert sre.match('a+', 'xxx') == None except: raise TestFailed, "sre.search" if verbose: print 'Running tests on sre.sub' try: assert sre.sub("(?i)b+", "x", "bbbb BBBB") == 'x x' def bump_num(matchobj): int_value = int(matchobj.group(0)) return str(int_value + 1) assert sre.sub(r'\d+', bump_num, '08.2 -2 23x99y') == '9.3 -3 24x100y' assert sre.sub(r'\d+', bump_num, '08.2 -2 23x99y', 3) == '9.3 -3 23x99y' assert sre.sub('.', lambda m: r"\n", 'x') == '\\n' assert sre.sub('.', r"\n", 'x') == '\n' s = r"\1\1" assert sre.sub('(.)', s, 'x') == 'xx' assert sre.sub('(.)', sre.escape(s), 'x') == s assert sre.sub('(.)', lambda m: s, 'x') == s assert sre.sub('(?Px)', '\g\g', 'xx') == 'xxxx' assert sre.sub('(?Px)', '\g\g<1>', 'xx') == 'xxxx' assert sre.sub('(?Px)', '\g\g', 'xx') == 'xxxx' assert sre.sub('(?Px)', '\g<1>\g<1>', 'xx') == 'xxxx' assert sre.sub('a', r'\t\n\v\r\f\a\b\B\Z\a\A\w\W\s\S\d\D', 'a') == '\t\n\v\r\f\a\b\\B\\Z\a\\A\\w\\W\\s\\S\\d\\D' assert sre.sub('a', '\t\n\v\r\f\a', 'a') == '\t\n\v\r\f\a' assert sre.sub('a', '\t\n\v\r\f\a', 'a') == (chr(9)+chr(10)+chr(11)+chr(13)+chr(12)+chr(7)) assert sre.sub('^\s*', 'X', 'test') == 'Xtest' except AssertionError: raise TestFailed, "sre.sub" try: assert sre.sub('a', 'b', 'aaaaa') == 'bbbbb' assert sre.sub('a', 'b', 'aaaaa', 1) == 'baaaa' except AssertionError: raise TestFailed, "qualified sre.sub" if verbose: print 'Running tests on symbolic references' try: sre.sub('(?Px)', '\gx)', '\g<', 'xx') except sre.error, reason: pass else: raise TestFailed, "symbolic reference" try: sre.sub('(?Px)', '\g', 'xx') except sre.error, reason: pass else: raise TestFailed, "symbolic reference" try: sre.sub('(?Px)', '\g', 'xx') except sre.error, reason: pass else: raise TestFailed, "symbolic reference" try: sre.sub('(?Px)', '\g<1a1>', 'xx') except sre.error, reason: pass else: raise TestFailed, "symbolic reference" try: sre.sub('(?Px)', '\g', 'xx') except IndexError, reason: pass else: raise TestFailed, "symbolic reference" try: sre.sub('(?Px)|(?Py)', '\g', 'xx') except sre.error, reason: pass else: raise TestFailed, "symbolic reference" try: sre.sub('(?Px)|(?Py)', '\\2', 'xx') except sre.error, reason: pass else: raise TestFailed, "symbolic reference" if verbose: print 'Running tests on sre.subn' try: assert sre.subn("(?i)b+", "x", "bbbb BBBB") == ('x x', 2) assert sre.subn("b+", "x", "bbbb BBBB") == ('x BBBB', 1) assert sre.subn("b+", "x", "xyz") == ('xyz', 0) assert sre.subn("b*", "x", "xyz") == ('xxxyxzx', 4) assert sre.subn("b*", "x", "xyz", 2) == ('xxxyz', 2) except AssertionError: raise TestFailed, "sre.subn" if verbose: print 'Running tests on sre.split' try: assert sre.split(":", ":a:b::c") == ['', 'a', 'b', '', 'c'] assert sre.split(":*", ":a:b::c") == ['', 'a', 'b', 'c'] assert sre.split("(:*)", ":a:b::c") == ['', ':', 'a', ':', 'b', '::', 'c'] assert sre.split("(?::*)", ":a:b::c") == ['', 'a', 'b', 'c'] assert sre.split("(:)*", ":a:b::c") == ['', ':', 'a', ':', 'b', ':', 'c'] assert sre.split("([b:]+)", ":a:b::c") == ['', ':', 'a', ':b::', 'c'] # FIXME: group problem # assert sre.split("(b)|(:+)", ":a:b::c") == \ # ['', None, ':', 'a', None, ':', '', 'b', None, '', None, '::', 'c'] assert sre.split("(?:b)|(?::+)", ":a:b::c") == ['', 'a', '', '', 'c'] except AssertionError: raise TestFailed, "sre.split" try: assert sre.split(":", ":a:b::c", 2) == ['', 'a', 'b::c'] assert sre.split(':', 'a:b:c:d', 2) == ['a', 'b', 'c:d'] assert sre.split("(:)", ":a:b::c", 2) == ['', ':', 'a', ':', 'b::c'] assert sre.split("(:*)", ":a:b::c", 2) == ['', ':', 'a', ':', 'b::c'] except AssertionError: raise TestFailed, "qualified sre.split" if verbose: print "Running tests on sre.findall" try: assert sre.findall(":+", "abc") == [] assert sre.findall(":+", "a:b::c:::d") == [":", "::", ":::"] assert sre.findall("(:+)", "a:b::c:::d") == [":", "::", ":::"] assert sre.findall("(:)(:*)", "a:b::c:::d") == [(":", ""), (":", ":"), (":", "::")] except AssertionError: raise TestFailed, "sre.findall" if verbose: print "Running tests on sre.match" try: # No groups at all m = sre.match('a', 'a') ; assert m.groups() == () # A single group m = sre.match('(a)', 'a') ; assert m.groups() == ('a',) pat = sre.compile('((a)|(b))(c)?') assert pat.match('a').groups() == ('a', 'a', None, None) assert pat.match('b').groups() == ('b', None, 'b', None) assert pat.match('ac').groups() == ('a', 'a', None, 'c') assert pat.match('bc').groups() == ('b', None, 'b', 'c') assert pat.match('bc').groups("") == ('b', "", 'b', 'c') except AssertionError: raise TestFailed, "match .groups() method" try: # A single group m = sre.match('(a)', 'a') assert m.group(0) == 'a' ; assert m.group(0) == 'a' assert m.group(1) == 'a' ; assert m.group(1, 1) == ('a', 'a') pat = sre.compile('(?:(?Pa)|(?Pb))(?Pc)?') assert pat.match('a').group(1, 2, 3) == ('a', None, None) assert pat.match('b').group('a1', 'b2', 'c3') == (None, 'b', None) assert pat.match('ac').group(1, 'b2', 3) == ('a', None, 'c') except AssertionError: raise TestFailed, "match .group() method" if verbose: print "Running tests on sre.escape" try: p="" for i in range(0, 256): p = p + chr(i) assert sre.match(sre.escape(chr(i)), chr(i)) != None assert sre.match(sre.escape(chr(i)), chr(i)).span() == (0,1) pat=sre.compile( sre.escape(p) ) assert pat.match(p) != None assert pat.match(p).span() == (0,256) except AssertionError: raise TestFailed, "sre.escape" if verbose: print 'Pickling a SRE_Pattern instance' try: import pickle pat = sre.compile('a(?:b|(c|e){1,2}?|d)+?(.)') s = pickle.dumps(pat) pat = pickle.loads(s) except: print TestFailed, 're module pickle' # expected try: import cPickle pat = sre.compile('a(?:b|(c|e){1,2}?|d)+?(.)') s = cPickle.dumps(pat) pat = cPickle.loads(s) except: print TestFailed, 're module cPickle' # expected try: assert sre.I == sre.IGNORECASE assert sre.L == sre.LOCALE assert sre.M == sre.MULTILINE assert sre.S == sre.DOTALL assert sre.X == sre.VERBOSE assert sre.T == sre.TEMPLATE assert sre.U == sre.UNICODE except AssertionError: raise TestFailed, 're module constants' for flags in [sre.I, sre.M, sre.X, sre.S, sre.L, sre.T, sre.U]: try: r = sre.compile('^pattern$', flags) except: print 'Exception raised on flag', flags from re_tests import * if verbose: print 'Running re_tests test suite' else: # To save time, only run the first and last 10 tests #tests = tests[:10] + tests[-10:] pass for t in tests: sys.stdout.flush() pattern=s=outcome=repl=expected=None if len(t)==5: pattern, s, outcome, repl, expected = t elif len(t)==3: pattern, s, outcome = t else: raise ValueError, ('Test tuples should have 3 or 5 fields',t) try: obj=sre.compile(pattern) except sre.error: if outcome==SYNTAX_ERROR: pass # Expected a syntax error else: print '=== Syntax error:', t except KeyboardInterrupt: raise KeyboardInterrupt except: print '*** Unexpected error ***', t if verbose: traceback.print_exc(file=sys.stdout) else: try: result=obj.search(s) except (sre.error), msg: print '=== Unexpected exception', t, repr(msg) if outcome==SYNTAX_ERROR: # This should have been a syntax error; forget it. pass elif outcome==FAIL: if result is None: pass # No match, as expected else: print '=== Succeeded incorrectly', t elif outcome==SUCCEED: if result is not None: # Matched, as expected, so now we compute the # result string and compare it to our expected result. start, end = result.span(0) vardict={'found': result.group(0), 'groups': result.group(), 'flags': result.re.flags} for i in range(1, 100): try: gi = result.group(i) # Special hack because else the string concat fails: if gi is None: gi = "None" except IndexError: gi = "Error" vardict['g%d' % i] = gi for i in result.re.groupindex.keys(): try: gi = result.group(i) if gi is None: gi = "None" except IndexError: gi = "Error" vardict[i] = gi repl=eval(repl, vardict) if repl!=expected: print '=== grouping error', t, print repr(repl)+' should be '+repr(expected) else: print '=== Failed incorrectly', t continue # Try the match on a unicode string, and check that it # still succeeds. result=obj.search(unicode(s, "latin-1")) if result==None: print '=== Fails on unicode match', t # Try the match on a unicode pattern, and check that it # still succeeds. obj=sre.compile(unicode(pattern, "latin-1")) result=obj.search(s) if result==None: print '=== Fails on unicode pattern match', t # Try the match with the search area limited to the extent # of the match and see if it still succeeds. \B will # break (because it won't match at the end or start of a # string), so we'll ignore patterns that feature it. if pattern[:2]!='\\B' and pattern[-2:]!='\\B': obj=sre.compile(pattern) result=obj.search(s, result.start(0), result.end(0)+1) if result==None: print '=== Failed on range-limited match', t # Try the match with IGNORECASE enabled, and check that it # still succeeds. obj=sre.compile(pattern, sre.IGNORECASE) result=obj.search(s) if result==None: print '=== Fails on case-insensitive match', t # Try the match with LOCALE enabled, and check that it # still succeeds. obj=sre.compile(pattern, sre.LOCALE) result=obj.search(s) if result==None: print '=== Fails on locale-sensitive match', t # Try the match with UNICODE enabled, and check that it # still succeeds. obj=sre.compile(pattern, sre.UNICODE) result=obj.search(s) if result==None: print '=== Fails on unicode-sensitive match', t From python-dev@python.org Fri Jun 30 08:51:01 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 00:51:01 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_sre.py,1.1,1.2 Message-ID: <200006300751.AAA24038@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv24009/Lib/test Modified Files: test_sre.py Log Message: - pedantic: make sure "python -t" doesn't complain... Index: test_sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_sre.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** test_sre.py 2000/06/30 07:08:20 1.1 --- test_sre.py 2000/06/30 07:50:59 1.2 *************** *** 1,3 **** ! # FIXME: this is basically test_re.py, with a few import sys --- 1,3 ---- ! # FIXME: this is basically test_re.py, with a few minor changes import sys *************** *** 338,342 **** else: print '=== Failed incorrectly', t ! continue # Try the match on a unicode string, and check that it --- 338,342 ---- else: print '=== Failed incorrectly', t ! continue # Try the match on a unicode string, and check that it *************** *** 360,366 **** if pattern[:2]!='\\B' and pattern[-2:]!='\\B': obj=sre.compile(pattern) ! result=obj.search(s, result.start(0), result.end(0)+1) ! if result==None: ! print '=== Failed on range-limited match', t # Try the match with IGNORECASE enabled, and check that it --- 360,366 ---- if pattern[:2]!='\\B' and pattern[-2:]!='\\B': obj=sre.compile(pattern) ! result=obj.search(s, result.start(0), result.end(0)+1) ! if result==None: ! print '=== Failed on range-limited match', t # Try the match with IGNORECASE enabled, and check that it From python-dev@python.org Fri Jun 30 08:51:01 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 00:51:01 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre.py,1.15,1.16 sre_compile.py,1.13,1.14 sre_parse.py,1.12,1.13 Message-ID: <200006300751.AAA24039@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv24009/Lib Modified Files: sre.py sre_compile.py sre_parse.py Log Message: - pedantic: make sure "python -t" doesn't complain... Index: sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** sre.py 2000/06/30 07:05:47 1.15 --- sre.py 2000/06/30 07:50:59 1.16 *************** *** 99,103 **** filter = template else: ! template = sre_parse.parse_template(template, pattern) def filter(match, template=template): return sre_parse.expand_template(template, match) --- 99,103 ---- filter = template else: ! template = sre_parse.parse_template(template, pattern) def filter(match, template=template): return sre_parse.expand_template(template, match) *************** *** 110,118 **** if not m: break ! b, e = m.span() if i < b: append(string[i:b]) append(filter(m)) ! i = e n = n + 1 append(string[i:]) --- 110,118 ---- if not m: break ! b, e = m.span() if i < b: append(string[i:b]) append(filter(m)) ! i = e n = n + 1 append(string[i:]) *************** *** 131,143 **** if not m: break ! b, e = m.span() ! if b == e: ! if i >= len(string): ! break ! continue append(string[i:b]) ! if g and b != e: ! extend(m.groups()) ! i = e n = n + 1 append(string[i:]) --- 131,143 ---- if not m: break ! b, e = m.span() ! if b == e: ! if i >= len(string): ! break ! continue append(string[i:b]) ! if g and b != e: ! extend(m.groups()) ! i = e n = n + 1 append(string[i:]) Index: sre_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** sre_compile.py 2000/06/30 00:27:45 1.13 --- sre_compile.py 2000/06/30 07:50:59 1.14 *************** *** 19,23 **** for WORDSIZE in "BHil": if len(array.array(WORDSIZE, [0]).tostring()) == _sre.getcodesize(): ! break else: raise RuntimeError, "cannot find a useable array type" --- 19,23 ---- for WORDSIZE in "BHil": if len(array.array(WORDSIZE, [0]).tostring()) == _sre.getcodesize(): ! break else: raise RuntimeError, "cannot find a useable array type" *************** *** 27,156 **** emit = code.append for op, av in pattern: ! if op is ANY: ! if flags & SRE_FLAG_DOTALL: ! emit(OPCODES[op]) ! else: ! emit(OPCODES[CATEGORY]) ! emit(CHCODES[CATEGORY_NOT_LINEBREAK]) ! elif op in (SUCCESS, FAILURE): ! emit(OPCODES[op]) ! elif op is AT: ! emit(OPCODES[op]) ! if flags & SRE_FLAG_MULTILINE: ! emit(ATCODES[AT_MULTILINE[av]]) ! else: ! emit(ATCODES[av]) ! elif op is BRANCH: ! emit(OPCODES[op]) ! tail = [] ! for av in av[1]: ! skip = len(code); emit(0) ! _compile(code, av, flags) ! emit(OPCODES[JUMP]) ! tail.append(len(code)); emit(0) ! code[skip] = len(code) - skip ! emit(0) # end of branch ! for tail in tail: ! code[tail] = len(code) - tail ! elif op is CALL: ! emit(OPCODES[op]) ! skip = len(code); emit(0) ! _compile(code, av, flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! elif op is CATEGORY: ! emit(OPCODES[op]) ! if flags & SRE_FLAG_LOCALE: ! emit(CHCODES[CH_LOCALE[av]]) ! elif flags & SRE_FLAG_UNICODE: ! emit(CHCODES[CH_UNICODE[av]]) ! else: ! emit(CHCODES[av]) ! elif op is GROUP: ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) ! else: ! emit(OPCODES[op]) ! emit(av-1) ! elif op is IN: ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) ! def fixup(literal, flags=flags): ! return _sre.getlower(ord(literal), flags) ! else: ! emit(OPCODES[op]) ! fixup = ord ! skip = len(code); emit(0) ! for op, av in av: ! emit(OPCODES[op]) ! if op is NEGATE: ! pass ! elif op is LITERAL: ! emit(fixup(av)) ! elif op is RANGE: ! emit(fixup(av[0])) ! emit(fixup(av[1])) ! elif op is CATEGORY: ! if flags & SRE_FLAG_LOCALE: ! emit(CHCODES[CH_LOCALE[av]]) ! elif flags & SRE_FLAG_UNICODE: ! emit(CHCODES[CH_UNICODE[av]]) ! else: ! emit(CHCODES[av]) ! else: ! raise error, "internal: unsupported set operator" ! emit(OPCODES[FAILURE]) ! code[skip] = len(code) - skip ! elif op in (LITERAL, NOT_LITERAL): ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) ! else: ! emit(OPCODES[op]) ! emit(ord(av)) ! elif op is MARK: ! emit(OPCODES[op]) ! emit(av) ! elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): ! if flags & SRE_FLAG_TEMPLATE: ! emit(OPCODES[REPEAT]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) ! _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! else: ! lo, hi = av[2].getwidth() ! if lo == 0: ! raise error, "nothing to repeat" ! if 0 and lo == hi == 1 and op is MAX_REPEAT: ! # FIXME: need a better way to figure out when ! # it's safe to use this one (in the parser, probably) ! emit(OPCODES[MAX_REPEAT_ONE]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) ! _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! else: ! emit(OPCODES[op]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) ! _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! elif op is SUBPATTERN: ! group = av[0] ! if group: ! emit(OPCODES[MARK]) ! emit((group-1)*2) ! _compile(code, av[1], flags) ! if group: ! emit(OPCODES[MARK]) ! emit((group-1)*2+1) ! else: ! raise ValueError, ("unsupported operand type", op) def _compile_info(code, pattern, flags): --- 27,156 ---- emit = code.append for op, av in pattern: ! if op is ANY: ! if flags & SRE_FLAG_DOTALL: ! emit(OPCODES[op]) ! else: ! emit(OPCODES[CATEGORY]) ! emit(CHCODES[CATEGORY_NOT_LINEBREAK]) ! elif op in (SUCCESS, FAILURE): ! emit(OPCODES[op]) ! elif op is AT: ! emit(OPCODES[op]) ! if flags & SRE_FLAG_MULTILINE: ! emit(ATCODES[AT_MULTILINE[av]]) ! else: ! emit(ATCODES[av]) ! elif op is BRANCH: ! emit(OPCODES[op]) ! tail = [] ! for av in av[1]: ! skip = len(code); emit(0) ! _compile(code, av, flags) ! emit(OPCODES[JUMP]) ! tail.append(len(code)); emit(0) ! code[skip] = len(code) - skip ! emit(0) # end of branch ! for tail in tail: ! code[tail] = len(code) - tail ! elif op is CALL: ! emit(OPCODES[op]) ! skip = len(code); emit(0) ! _compile(code, av, flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! elif op is CATEGORY: ! emit(OPCODES[op]) ! if flags & SRE_FLAG_LOCALE: ! emit(CHCODES[CH_LOCALE[av]]) ! elif flags & SRE_FLAG_UNICODE: ! emit(CHCODES[CH_UNICODE[av]]) ! else: ! emit(CHCODES[av]) ! elif op is GROUP: ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) ! else: ! emit(OPCODES[op]) ! emit(av-1) ! elif op is IN: ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) ! def fixup(literal, flags=flags): ! return _sre.getlower(ord(literal), flags) ! else: ! emit(OPCODES[op]) ! fixup = ord ! skip = len(code); emit(0) ! for op, av in av: ! emit(OPCODES[op]) ! if op is NEGATE: ! pass ! elif op is LITERAL: ! emit(fixup(av)) ! elif op is RANGE: ! emit(fixup(av[0])) ! emit(fixup(av[1])) ! elif op is CATEGORY: ! if flags & SRE_FLAG_LOCALE: ! emit(CHCODES[CH_LOCALE[av]]) ! elif flags & SRE_FLAG_UNICODE: ! emit(CHCODES[CH_UNICODE[av]]) ! else: ! emit(CHCODES[av]) ! else: ! raise error, "internal: unsupported set operator" ! emit(OPCODES[FAILURE]) ! code[skip] = len(code) - skip ! elif op in (LITERAL, NOT_LITERAL): ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) ! else: ! emit(OPCODES[op]) ! emit(ord(av)) ! elif op is MARK: ! emit(OPCODES[op]) ! emit(av) ! elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): ! if flags & SRE_FLAG_TEMPLATE: ! emit(OPCODES[REPEAT]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) ! _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! else: ! lo, hi = av[2].getwidth() ! if lo == 0: ! raise error, "nothing to repeat" ! if 0 and lo == hi == 1 and op is MAX_REPEAT: ! # FIXME: need a better way to figure out when ! # it's safe to use this one (in the parser, probably) ! emit(OPCODES[MAX_REPEAT_ONE]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) ! _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! else: ! emit(OPCODES[op]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) ! _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! elif op is SUBPATTERN: ! group = av[0] ! if group: ! emit(OPCODES[MARK]) ! emit((group-1)*2) ! _compile(code, av[1], flags) ! if group: ! emit(OPCODES[MARK]) ! emit((group-1)*2+1) ! else: ! raise ValueError, ("unsupported operand type", op) def _compile_info(code, pattern, flags): *************** *** 160,172 **** lo, hi = pattern.getwidth() if lo == 0: ! return # not worth it # look for a literal prefix prefix = [] if not (flags & SRE_FLAG_IGNORECASE): ! for op, av in pattern.data: ! if op is LITERAL: ! prefix.append(ord(av)) ! else: ! break # add an info block emit = code.append --- 160,172 ---- lo, hi = pattern.getwidth() if lo == 0: ! return # not worth it # look for a literal prefix prefix = [] if not (flags & SRE_FLAG_IGNORECASE): ! for op, av in pattern.data: ! if op is LITERAL: ! prefix.append(ord(av)) ! else: ! break # add an info block emit = code.append *************** *** 176,198 **** mask = 0 if len(prefix) == len(pattern.data): ! mask = 1 emit(mask) # pattern length emit(lo) if hi < 32768: ! emit(hi) else: ! emit(0) # add literal prefix emit(len(prefix)) if prefix: ! code.extend(prefix) ! # generate overlap table ! table = [-1] + ([0]*len(prefix)) ! for i in range(len(prefix)): ! table[i+1] = table[i]+1 ! while table[i+1] > 0 and prefix[i] != prefix[table[i+1]-1]: ! table[i+1] = table[table[i+1]-1]+1 ! code.extend(table[1:]) # don't store first entry code[skip] = len(code) - skip --- 176,198 ---- mask = 0 if len(prefix) == len(pattern.data): ! mask = 1 emit(mask) # pattern length emit(lo) if hi < 32768: ! emit(hi) else: ! emit(0) # add literal prefix emit(len(prefix)) if prefix: ! code.extend(prefix) ! # generate overlap table ! table = [-1] + ([0]*len(prefix)) ! for i in range(len(prefix)): ! table[i+1] = table[i]+1 ! while table[i+1] > 0 and prefix[i] != prefix[table[i+1]-1]: ! table[i+1] = table[table[i+1]-1]+1 ! code.extend(table[1:]) # don't store first entry code[skip] = len(code) - skip *************** *** 202,210 **** # compile, as necessary if type(p) in (type(""), type(u"")): ! import sre_parse ! pattern = p ! p = sre_parse.parse(p) else: ! pattern = None flags = p.pattern.flags | flags --- 202,210 ---- # compile, as necessary if type(p) in (type(""), type(u"")): ! import sre_parse ! pattern = p ! p = sre_parse.parse(p) else: ! pattern = None flags = p.pattern.flags | flags *************** *** 221,229 **** # FIXME: get rid of this limitation! assert p.pattern.groups <= 100,\ ! "sorry, but this version only supports 100 named groups" return _sre.compile( ! pattern, flags, ! array.array(WORDSIZE, code).tostring(), ! p.pattern.groups-1, p.pattern.groupdict ! ) --- 221,229 ---- # FIXME: get rid of this limitation! assert p.pattern.groups <= 100,\ ! "sorry, but this version only supports 100 named groups" return _sre.compile( ! pattern, flags, ! array.array(WORDSIZE, code).tostring(), ! p.pattern.groups-1, p.pattern.groupdict ! ) Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** sre_parse.py 2000/06/30 00:27:45 1.12 --- sre_parse.py 2000/06/30 07:50:59 1.13 *************** *** 68,171 **** class State: def __init__(self): ! self.flags = 0 ! self.groups = 1 ! self.groupdict = {} def getgroup(self, name=None): ! gid = self.groups ! self.groups = gid + 1 ! if name: ! self.groupdict[name] = gid [...982 lines suppressed...] for c, s in template: ! if c is LITERAL: ! a(s) ! elif c is MARK: ! s = match.group(s) ! if s is None: ! raise error, "empty group" ! a(s) return match.string[:0].join(p) --- 593,602 ---- a = p.append for c, s in template: ! if c is LITERAL: ! a(s) ! elif c is MARK: ! s = match.group(s) ! if s is None: ! raise error, "empty group" ! a(s) return match.string[:0].join(p) From python-dev@python.org Fri Jun 30 10:04:38 2000 From: python-dev@python.org (Tim Peters) Date: Fri, 30 Jun 2000 02:04:38 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild readme.txt,1.5,1.6 Message-ID: <200006300904.CAA04151@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv3903/python/dist/src/PCbuild Modified Files: readme.txt Log Message: Making a tiny change to figure out what I'm going to screw up by trying to use CVS under Windows at all ... Index: readme.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/readme.txt,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** readme.txt 2000/03/29 01:51:37 1.5 --- readme.txt 2000/06/30 09:04:35 1.6 *************** *** 3,7 **** This directory is used to build Python for Win32 platforms, ! e.g. Windows 95, 98 and NT. It requires Microsoft Visual C++ 5.x. (For other Windows platforms and compilers, see ../PC/readme.txt.) --- 3,8 ---- This directory is used to build Python for Win32 platforms, ! e.g. Windows 95, 98 and NT. It requires Microsoft Visual C++ 6.x ! or 5.x. (For other Windows platforms and compilers, see ../PC/readme.txt.) From python-dev@python.org Fri Jun 30 10:13:08 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 02:13:08 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_sre,1.1,1.2 Message-ID: <200006300913.CAA06558@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv5441/Lib/test/output Modified Files: test_sre Log Message: - added support for (?P=name) (closes #3 and #7 from the status report) Index: test_sre =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_sre,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** test_sre 2000/06/30 07:08:20 1.1 --- test_sre 2000/06/30 09:13:06 1.2 *************** *** 2,10 **** test_support -- test failed re module pickle test_support -- test failed re module cPickle - === Syntax error: ('(?Pa)(?P=foo_123)', 'aa', 0, 'g1', 'a') === Failed incorrectly ('^(.+)?B', 'AB', 0, 'g1', 'A') === Failed incorrectly ('(a+)+\\1', 'aa', 0, 'found+"-"+g1', 'aa-a') === grouping error ('([^/]*/)*sub1/', 'd:msgs/tdir/sub1/trial/away.cpp', 0, 'found+"-"+g1', 'd:msgs/tdir/sub1/-tdir/') 'd:msgs/tdir/sub1/-trial/' should be 'd:msgs/tdir/sub1/-tdir/' - === Syntax error: ('(?Paa)(?P=id)', 'aaaa', 0, 'found+"-"+id', 'aaaa-aa') === grouping error ('([abc])*bcd', 'abcd', 0, 'found+"-"+g1', 'abcd-a') 'abcd-c' should be 'abcd-a' === grouping error ('(?i)([abc])*bcd', 'ABCD', 0, 'found+"-"+g1', 'ABCD-A') 'ABCD-C' should be 'ABCD-A' --- 2,8 ---- From python-dev@python.org Fri Jun 30 10:13:08 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 02:13:08 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre_parse.py,1.13,1.14 Message-ID: <200006300913.CAA06559@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv5441/Lib Modified Files: sre_parse.py Log Message: - added support for (?P=name) (closes #3 and #7 from the status report) Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** sre_parse.py 2000/06/30 07:50:59 1.13 --- sre_parse.py 2000/06/30 09:13:05 1.14 *************** *** 190,196 **** # check if the escape string represents a valid group try: ! group = int(escape[1:]) ! if group and group < groups: ! return group except ValueError: pass --- 190,196 ---- # check if the escape string represents a valid group try: ! gid = int(escape[1:]) ! if gid and gid < groups: ! return gid except ValueError: pass *************** *** 443,447 **** elif source.match("="): # named backreference ! raise error, "not yet implemented" else: char = source.get() --- 443,460 ---- elif source.match("="): # named backreference ! name = "" ! while 1: ! char = source.get() ! if char is None: ! raise error, "unterminated name" ! if char == ")": ! break ! name = name + char ! if not isname(name): ! raise error, "illegal character in group name" ! gid = state.groupdict.get(name) ! if gid is None: ! raise error, "unknown group name" ! subpattern.append((GROUP, gid)) else: char = source.get() From python-dev@python.org Fri Jun 30 10:13:37 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Fri, 30 Jun 2000 02:13:37 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_unicode.py,1.15,1.16 Message-ID: <200006300913.CAA06700@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv6675/Lib/test Modified Files: test_unicode.py Log Message: Marc-Andre Lemburg : Moved tests of new Unicode Char Name support to a separate test. Index: test_unicode.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** test_unicode.py 2000/06/28 16:41:23 1.15 --- test_unicode.py 2000/06/30 09:13:35 1.16 *************** *** 410,485 **** print 'done.' - print 'Testing General Unicode Character Name, and case insensitivity...', - # General and case insensitivity test: - s = u"\N{LATIN CAPITAL LETTER T}" \ - u"\N{LATIN SMALL LETTER H}" \ - u"\N{LATIN SMALL LETTER E}" \ - u"\N{SPACE}" \ - u"\N{LATIN SMALL LETTER R}" \ - u"\N{LATIN CAPITAL LETTER E}" \ - u"\N{LATIN SMALL LETTER D}" \ - u"\N{SPACE}" \ - u"\N{LATIN SMALL LETTER f}" \ - u"\N{LATIN CAPITAL LeTtEr o}" \ - u"\N{LATIN SMaLl LETTER x}" \ - u"\N{SPACE}" \ - u"\N{LATIN SMALL LETTER A}" \ - u"\N{LATIN SMALL LETTER T}" \ - u"\N{LATIN SMALL LETTER E}" \ - u"\N{SPACE}" \ - u"\N{LATIN SMALL LETTER T}" \ - u"\N{LATIN SMALL LETTER H}" \ - u"\N{LATIN SMALL LETTER E}" \ - u"\N{SpAcE}" \ - u"\N{LATIN SMALL LETTER S}" \ - u"\N{LATIN SMALL LETTER H}" \ - u"\N{LATIN SMALL LETTER E}" \ - u"\N{LATIN SMALL LETTER E}" \ - u"\N{LATIN SMALL LETTER P}" \ - u"\N{FULL STOP}" - assert s == u"The rEd fOx ate the sheep.", s - print "done." - - # misc. symbol testing - print "Testing misc. symbols for unicode character name expansion....", - assert u"\N{PILCROW SIGN}" == u"\u00b6" - assert u"\N{REPLACEMENT CHARACTER}" == u"\uFFFD" - assert u"\N{HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK}" == u"\uFF9F" - assert u"\N{FULLWIDTH LATIN SMALL LETTER A}" == u"\uFF41" - print "done." - - - # strict error testing: - print "Testing unicode character name expansion strict error handling....", - k_cchMaxUnicodeName = 83 - - s = "\N{" + "1" * (k_cchMaxUnicodeName + 2) + "}" - try: - unicode(s, 'unicode-escape', 'strict') - except UnicodeError: - pass - else: - raise AssertionError, "failed to raise an exception when presented " \ - "with a UCN > k_cchMaxUnicodeName" - try: - unicode("\N{blah}", 'unicode-escape', 'strict') - except UnicodeError: - pass - else: - raise AssertionError, "failed to raise an exception when given a bogus character name" - - try: - unicode("\N{SPACE", 'unicode-escape', 'strict') - except UnicodeError: - pass - else: - raise AssertionError, "failed to raise an exception for a missing closing brace." - - try: - unicode("\NSPACE", 'unicode-escape', 'strict') - except UnicodeError: - pass - else: - raise AssertionError, "failed to raise an exception for a missing opening brace." - print "done." - --- 410,411 ---- From python-dev@python.org Fri Jun 30 10:14:15 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Fri, 30 Jun 2000 02:14:15 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_unicode,1.7,1.8 Message-ID: <200006300914.CAA06914@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv6902/Lib/test/output Modified Files: test_unicode Log Message: Marc-Andre Lemburg : Updated test output (the ucn tests are now in test_ucn). Index: test_unicode =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_unicode,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** test_unicode 2000/06/28 16:41:46 1.7 --- test_unicode 2000/06/30 09:14:13 1.8 *************** *** 6,10 **** Testing standard mapping codecs... 0-127... 128-255... done. Testing Unicode string concatenation... done. - Testing General Unicode Character Name, and case insensitivity... done. - Testing misc. symbols for unicode character name expansion.... done. - Testing unicode character name expansion strict error handling.... done. --- 6,7 ---- From python-dev@python.org Fri Jun 30 10:45:23 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Fri, 30 Jun 2000 02:45:23 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_ucn.py,NONE,1.1 Message-ID: <200006300945.CAA13805@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv13782/Lib/test Added Files: test_ucn.py Log Message: New test for the ucnhash module. --- NEW FILE --- """ Test script for the Unicode implementation. Written by Bill Tutt. (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. """#" print 'Testing General Unicode Character Name, and case insensitivity...', # General and case insensitivity test: s = u"\N{LATIN CAPITAL LETTER T}" \ u"\N{LATIN SMALL LETTER H}" \ u"\N{LATIN SMALL LETTER E}" \ u"\N{SPACE}" \ u"\N{LATIN SMALL LETTER R}" \ u"\N{LATIN CAPITAL LETTER E}" \ u"\N{LATIN SMALL LETTER D}" \ u"\N{SPACE}" \ u"\N{LATIN SMALL LETTER f}" \ u"\N{LATIN CAPITAL LeTtEr o}" \ u"\N{LATIN SMaLl LETTER x}" \ u"\N{SPACE}" \ u"\N{LATIN SMALL LETTER A}" \ u"\N{LATIN SMALL LETTER T}" \ u"\N{LATIN SMALL LETTER E}" \ u"\N{SPACE}" \ u"\N{LATIN SMALL LETTER T}" \ u"\N{LATIN SMALL LETTER H}" \ u"\N{LATIN SMALL LETTER E}" \ u"\N{SpAcE}" \ u"\N{LATIN SMALL LETTER S}" \ u"\N{LATIN SMALL LETTER H}" \ u"\N{LATIN SMALL LETTER E}" \ u"\N{LATIN SMALL LETTER E}" \ u"\N{LATIN SMALL LETTER P}" \ u"\N{FULL STOP}" assert s == u"The rEd fOx ate the sheep.", s print "done." # misc. symbol testing print "Testing misc. symbols for unicode character name expansion....", assert u"\N{PILCROW SIGN}" == u"\u00b6" assert u"\N{REPLACEMENT CHARACTER}" == u"\uFFFD" assert u"\N{HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK}" == u"\uFF9F" assert u"\N{FULLWIDTH LATIN SMALL LETTER A}" == u"\uFF41" print "done." # strict error testing: print "Testing unicode character name expansion strict error handling....", k_cchMaxUnicodeName = 83 s = "\N{" + "1" * (k_cchMaxUnicodeName + 2) + "}" try: unicode(s, 'unicode-escape', 'strict') except UnicodeError: pass else: raise AssertionError, "failed to raise an exception when presented " \ "with a UCN > k_cchMaxUnicodeName" try: unicode("\N{blah}", 'unicode-escape', 'strict') except UnicodeError: pass else: raise AssertionError, "failed to raise an exception when given a bogus character name" try: unicode("\N{SPACE", 'unicode-escape', 'strict') except UnicodeError: pass else: raise AssertionError, "failed to raise an exception for a missing closing brace." try: unicode("\NSPACE", 'unicode-escape', 'strict') except UnicodeError: pass else: raise AssertionError, "failed to raise an exception for a missing opening brace." print "done." From python-dev@python.org Fri Jun 30 10:53:25 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Fri, 30 Jun 2000 02:53:25 -0700 Subject: [Python-checkins] CVS: python/dist/src/Tools/perfecthash GenUCNHash.py,1.1,1.2 Message-ID: <200006300953.CAA14782@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Tools/perfecthash In directory slayer.i.sourceforge.net:/tmp/cvs-serv14766/Tools/perfecthash Modified Files: GenUCNHash.py Log Message: Marc-Andre Lemburg : Include <> -> "". Patch by Bill Tutt. Index: GenUCNHash.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/perfecthash/GenUCNHash.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** GenUCNHash.py 2000/06/28 16:49:29 1.1 --- GenUCNHash.py 2000/06/30 09:53:22 1.2 *************** *** 51,55 **** out.write(header) out = open(cFileName, "w") ! out.write("#include <%s>\n" % headerFileName) out.write(code) perfHash.generate_graph(out) --- 51,55 ---- out.write(header) out = open(cFileName, "w") ! out.write("#include "%s"\n" % headerFileName) out.write(code) perfHash.generate_graph(out) From python-dev@python.org Fri Jun 30 10:56:02 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Fri, 30 Jun 2000 02:56:02 -0700 Subject: [Python-checkins] CVS: python/dist/src/Tools/perfecthash perfect_hash.py,1.1,1.2 Message-ID: <200006300956.CAA15161@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Tools/perfecthash In directory slayer.i.sourceforge.net:/tmp/cvs-serv15153/Tools/perfecthash Modified Files: perfect_hash.py Log Message: Marc-Andre Lemburg : Include <> -> "". Removed some left over code at the end of the file. Patch by Bill Tutt. Index: perfect_hash.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/perfecthash/perfect_hash.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** perfect_hash.py 2000/06/28 16:53:16 1.1 --- perfect_hash.py 2000/06/30 09:56:00 1.2 *************** *** 292,296 **** def generate_header(self, structName): header = """ ! #include #include --- 292,296 ---- def generate_header(self, structName): header = """ ! #include "Python.h" #include *************** *** 604,664 **** return PerfectHash(cchMaxKey, f1, f2, G, N, len(keys), maxHashValue) - - """ - static - PyObject *codec_tuple(PyObject *unicode, - int len) - { - PyObject *v,*w; - - if (unicode == NULL) - return NULL; - v = PyTuple_New(2); - if (v == NULL) { - Py_DECREF(unicode); - return NULL; - } - PyTuple_SET_ITEM(v,0,unicode); - w = PyInt_FromLong(len); - if (w == NULL) { - Py_DECREF(v); - return NULL; - } - PyTuple_SET_ITEM(v,1,w); - return v; - } - - static PyObject * - ucn_decode(PyObject *self, - PyObject *args) - { - const char *data; - int size; - const char *errors = NULL; - PyObject *mapping = NULL; - - if (!PyArg_ParseTuple(args, "t#|z:ucn_decode", - &data, &size, &errors)) - return NULL; - if (mapping == Py_None) - mapping = NULL; - - return codec_tuple(PyUnicode_DecodeNamedUnicodeEscape(data, size, errors), - size); - } - - - static PyMethodDef _codecs_functions[] = { - { "ucn_decode", ucn_decode, 1 }, - }; - - DL_EXPORT(void) - init_ucn() - { - Py_InitModule("_ucn", _codecs_functions); - } - - """ - - - --- 604,605 ---- From python-dev@python.org Fri Jun 30 11:04:00 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 12:04:00 +0200 Subject: [Python-checkins] CVS: python/dist/src/Tools/perfecthash GenUCNHash.py,1.1,1.2 References: <200006300953.CAA14782@slayer.i.sourceforge.net> Message-ID: <00b001bfe27a$845f7880$f2a6b5d4@hagrid> MAL wrote: > out.write(header) > out =3D open(cFileName, "w") > ! out.write("#include "%s"\n" % headerFileName) > out.write(code) > perfHash.generate_graph(out) umm. I suppose you meant: > ! out.write('#include "%s"\n' % headerFileName) or possibly: > ! out.write("#include \"%s\"\n" % headerFileName) From python-dev@python.org Fri Jun 30 11:15:23 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Fri, 30 Jun 2000 12:15:23 +0200 Subject: [Python-Dev] Re: [Python-checkins] CVS: python/dist/src/Tools/perfecthash GenUCNHash.py,1.1,1.2 References: <200006300953.CAA14782@slayer.i.sourceforge.net> <00b001bfe27a$845f7880$f2a6b5d4@hagrid> Message-ID: <395C733B.4E2AFFA3@lemburg.com> Fredrik Lundh wrote: > > MAL wrote: > > out.write(header) > > out = open(cFileName, "w") > > ! out.write("#include "%s"\n" % headerFileName) > > out.write(code) > > perfHash.generate_graph(out) > > umm. I suppose you meant: > > > ! out.write('#include "%s"\n' % headerFileName) > > or possibly: > > > ! out.write("#include \"%s\"\n" % headerFileName) Oops, you're right. Thanks. -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From python-dev@python.org Fri Jun 30 11:26:33 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Fri, 30 Jun 2000 03:26:33 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_format.py,NONE,1.1 Message-ID: <200006301026.DAA24915@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv24905/Lib/test Added Files: test_format.py Log Message: Marc-Andre Lemburg : New test for huge formatting strings (these could cause core dumps in previous versions). By Trent Mick. --- NEW FILE --- from test_support import verbose import string, sys # test string formatting operator (I am not sure if this is being tested # elsewhere but, surely, some of the given cases are *not* tested because # they crash python) # test on unicode strings as well def testformat(formatstr, args, output=None): if verbose: if output: print "%s %% %s =? %s ..." %\ (repr(formatstr), repr(args), repr(output)), else: print "%s %% %s works? ..." % (repr(formatstr), repr(args)), try: result = formatstr % args except OverflowError: if verbose: print 'overflow (this is fine)' else: if output and result != output: if verbose: print 'no' print "%s %% %s == %s != %s" %\ (repr(formatstr), repr(args), repr(result), repr(output)) else: if verbose: print 'yes' def testboth(formatstr, *args): testformat(formatstr, *args) testformat(unicode(formatstr), *args) testboth("%.1d", (1,), "1") testboth("%.*d", (sys.maxint,1)) # expect overflow testboth("%.100d", (1,), '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001') testboth("%#.117x", (1,), '0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001') testboth("%#.118x", (1,), '0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001') testboth("%f", (1.0,), "1.000000") # these are trying to test the limits of the internal magic-number-length # formatting buffer, if that number changes then these tests are less # effective testboth("%#.*g", (109, -1.e+49/3.)) testboth("%#.*g", (110, -1.e+49/3.)) testboth("%#.*g", (110, -1.e+100/3.)) # test some ridiculously large precision, expect overflow testboth('%12.*f', (123456, 1.0)) From python-dev@python.org Fri Jun 30 11:28:35 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Fri, 30 Jun 2000 03:28:35 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_format,NONE,1.1 Message-ID: <200006301028.DAA25304@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv25295/Lib/test/output Added Files: test_format Log Message: Marc-Andre Lemburg : Added test output. --- NEW FILE --- test_format From python-dev@python.org Fri Jun 30 11:29:19 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Fri, 30 Jun 2000 03:29:19 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects stringobject.c,2.69,2.70 Message-ID: <200006301029.DAA25334@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv25322/Objects Modified Files: stringobject.c Log Message: Marc-Andre Lemburg : New buffer overflow checks for formatting strings. By Trent Mick. Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.69 retrieving revision 2.70 diff -C2 -r2.69 -r2.70 *** stringobject.c 2000/06/20 15:47:54 2.69 --- stringobject.c 2000/06/30 10:29:17 2.70 *************** *** 125,130 **** const char *str; { ! register unsigned int size = strlen(str); register PyStringObject *op; #ifndef DONT_SHARE_SHORT_STRINGS if (size == 0 && (op = nullstring) != NULL) { --- 125,135 ---- const char *str; { ! register size_t size = strlen(str); register PyStringObject *op; + if (size > INT_MAX) { + PyErr_SetString(PyExc_OverflowError, + "string is too long for a Python string"); + return NULL; + } #ifndef DONT_SHARE_SHORT_STRINGS if (size == 0 && (op = nullstring) != NULL) { *************** *** 238,244 **** register PyStringObject *op; { ! /* XXX overflow? */ ! int newsize = 2 + 4 * op->ob_size * sizeof(char); ! PyObject *v = PyString_FromStringAndSize((char *)NULL, newsize); if (v == NULL) { return NULL; --- 243,253 ---- register PyStringObject *op; { ! size_t newsize = 2 + 4 * op->ob_size * sizeof(char); ! PyObject *v; ! if (newsize > INT_MAX) { ! PyErr_SetString(PyExc_OverflowError, ! "string is too large to make repr"); ! } ! v = PyString_FromStringAndSize((char *)NULL, newsize); if (v == NULL) { return NULL; *************** *** 2336,2341 **** static int ! formatfloat(buf, flags, prec, type, v) char *buf; int flags; int prec; --- 2345,2351 ---- static int ! formatfloat(buf, buflen, flags, prec, type, v) char *buf; + size_t buflen; int flags; int prec; *************** *** 2343,2346 **** --- 2353,2358 ---- PyObject *v; { + /* fmt = '%#.' + `prec` + `type` + worst case length = 3 + 10 (len of INT_MAX) + 1 = 14 (use 20)*/ char fmt[20]; double x; *************** *** 2349,2357 **** if (prec < 0) prec = 6; - if (prec > 50) - prec = 50; /* Arbitrary limitation */ if (type == 'f' && fabs(x)/1e25 >= 1e25) type = 'g'; sprintf(fmt, "%%%s.%d%c", (flags&F_ALT) ? "#" : "", prec, type); sprintf(buf, fmt, x); return strlen(buf); --- 2361,2379 ---- if (prec < 0) prec = 6; if (type == 'f' && fabs(x)/1e25 >= 1e25) type = 'g'; sprintf(fmt, "%%%s.%d%c", (flags&F_ALT) ? "#" : "", prec, type); + /* worst case length calc to ensure no buffer overrun: + fmt = %#.g + buf = '-' + [0-9]*prec + '.' + 'e+' + (longest exp + for any double rep.) + len = 1 + prec + 1 + 2 + 5 = 9 + prec + If prec=0 the effective precision is 1 (the leading digit is + always given), therefore increase by one to 10+prec. */ + if (buflen <= (size_t)10 + (size_t)prec) { + PyErr_SetString(PyExc_OverflowError, + "formatted float is too long (precision too long?)"); + return -1; + } sprintf(buf, fmt, x); return strlen(buf); *************** *** 2359,2364 **** static int ! formatint(buf, flags, prec, type, v) char *buf; int flags; int prec; --- 2381,2387 ---- static int ! formatint(buf, buflen, flags, prec, type, v) char *buf; + size_t buflen; int flags; int prec; *************** *** 2366,2369 **** --- 2389,2394 ---- PyObject *v; { + /* fmt = '%#.' + `prec` + 'l' + `type` + worst case length = 3 + 10 (len of INT_MAX) + 1 + 1 = 15 (use 20)*/ char fmt[20]; long x; *************** *** 2373,2376 **** --- 2398,2408 ---- prec = 1; sprintf(fmt, "%%%s.%dl%c", (flags&F_ALT) ? "#" : "", prec, type); + /* buf = '+'/'-'/'0'/'0x' + '[0-9]'*max(prec,len(x in octal)) + worst case buf = '0x' + [0-9]*prec, where prec >= 11 */ + if (buflen <= 13 || buflen <= (size_t)2+(size_t)prec) { + PyErr_SetString(PyExc_OverflowError, + "formatted integer is too long (precision too long?)"); + return -1; + } sprintf(buf, fmt, x); return strlen(buf); *************** *** 2378,2385 **** static int ! formatchar(buf, v) char *buf; PyObject *v; { if (PyString_Check(v)) { if (!PyArg_Parse(v, "c;%c requires int or char", &buf[0])) --- 2410,2419 ---- static int ! formatchar(buf, buflen, v) char *buf; + size_t buflen; PyObject *v; { + /* presume that the buffer is at least 2 characters long */ if (PyString_Check(v)) { if (!PyArg_Parse(v, "c;%c requires int or char", &buf[0])) *************** *** 2395,2399 **** ! /* fmt%(v1,v2,...) is roughly equivalent to sprintf(fmt, v1, v2, ...) */ PyObject * --- 2429,2441 ---- ! /* fmt%(v1,v2,...) is roughly equivalent to sprintf(fmt, v1, v2, ...) ! ! FORMATBUFLEN is the length of the buffer in which the floats, ints, & ! chars are formatted. XXX This is a magic number. Each formatting ! routine does bounds checking to ensure no overflow, but a better ! solution may be to malloc a buffer of appropriate size for each ! format. For now, the current solution is sufficient. ! */ ! #define FORMATBUFLEN (size_t)120 PyObject * *************** *** 2452,2459 **** PyObject *v = NULL; PyObject *temp = NULL; ! char *buf; int sign; int len; ! char tmpbuf[120]; /* For format{float,int,char}() */ char *fmt_start = fmt; --- 2494,2501 ---- PyObject *v = NULL; PyObject *temp = NULL; ! char *pbuf; int sign; int len; ! char formatbuf[FORMATBUFLEN]; /* For format{float,int,char}() */ char *fmt_start = fmt; *************** *** 2603,2607 **** switch (c) { case '%': ! buf = "%"; len = 1; break; --- 2645,2649 ---- switch (c) { case '%': ! pbuf = "%"; len = 1; break; *************** *** 2623,2627 **** goto error; } ! buf = PyString_AsString(temp); len = PyString_Size(temp); if (prec >= 0 && len > prec) --- 2665,2669 ---- goto error; } ! pbuf = PyString_AsString(temp); len = PyString_Size(temp); if (prec >= 0 && len > prec) *************** *** 2636,2641 **** if (c == 'i') c = 'd'; ! buf = tmpbuf; ! len = formatint(buf, flags, prec, c, v); if (len < 0) goto error; --- 2678,2683 ---- if (c == 'i') c = 'd'; ! pbuf = formatbuf; ! len = formatint(pbuf, sizeof(formatbuf), flags, prec, c, v); if (len < 0) goto error; *************** *** 2645,2651 **** if ((flags&F_ALT) && (c == 'x' || c == 'X') && ! buf[0] == '0' && buf[1] == c) { ! *res++ = *buf++; ! *res++ = *buf++; rescnt -= 2; len -= 2; --- 2687,2693 ---- if ((flags&F_ALT) && (c == 'x' || c == 'X') && ! pbuf[0] == '0' && pbuf[1] == c) { ! *res++ = *pbuf++; ! *res++ = *pbuf++; rescnt -= 2; len -= 2; *************** *** 2661,2666 **** case 'g': case 'G': ! buf = tmpbuf; ! len = formatfloat(buf, flags, prec, c, v); if (len < 0) goto error; --- 2703,2708 ---- case 'g': case 'G': ! pbuf = formatbuf; ! len = formatfloat(pbuf, sizeof(formatbuf), flags, prec, c, v); if (len < 0) goto error; *************** *** 2670,2675 **** break; case 'c': ! buf = tmpbuf; ! len = formatchar(buf, v); if (len < 0) goto error; --- 2712,2717 ---- break; case 'c': ! pbuf = formatbuf; ! len = formatchar(pbuf, sizeof(formatbuf), v); if (len < 0) goto error; *************** *** 2682,2687 **** } if (sign) { ! if (*buf == '-' || *buf == '+') { ! sign = *buf++; len--; } --- 2724,2729 ---- } if (sign) { ! if (*pbuf == '-' || *pbuf == '+') { ! sign = *pbuf++; len--; } *************** *** 2719,2723 **** if (sign && fill == ' ') *res++ = sign; ! memcpy(res, buf, len); res += len; rescnt -= len; --- 2761,2765 ---- if (sign && fill == ' ') *res++ = sign; ! memcpy(res, pbuf, len); res += len; rescnt -= len; From python-dev@python.org Fri Jun 30 11:29:59 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Fri, 30 Jun 2000 03:29:59 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.31,2.32 Message-ID: <200006301029.DAA25494@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv25442/Objects Modified Files: unicodeobject.c Log Message: Marc-Andre Lemburg : New buffer overflow checks for formatting strings. By Trent Mick. Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.31 retrieving revision 2.32 diff -C2 -r2.31 -r2.32 *** unicodeobject.c 2000/06/29 00:06:39 2.31 --- unicodeobject.c 2000/06/30 10:29:57 2.32 *************** *** 67,71 **** #include "mymath.h" #include "unicodeobject.h" ! #include "ucnhash.h" #if defined(HAVE_LIMITS_H) --- 67,71 ---- #include "mymath.h" #include "unicodeobject.h" ! #include #if defined(HAVE_LIMITS_H) *************** *** 1245,1249 **** ucnFallthrough: /* fall through on purpose */ ! default: *p++ = '\\'; *p++ = (unsigned char)s[-1]; --- 1245,1249 ---- ucnFallthrough: /* fall through on purpose */ ! default: *p++ = '\\'; *p++ = (unsigned char)s[-1]; *************** *** 1252,1256 **** } if (_PyUnicode_Resize(v, (int)(p - buf))) ! goto onError; return (PyObject *)v; --- 1252,1256 ---- } if (_PyUnicode_Resize(v, (int)(p - buf))) ! goto onError; return (PyObject *)v; *************** *** 4374,4377 **** --- 4374,4378 ---- static int formatfloat(Py_UNICODE *buf, + size_t buflen, int flags, int prec, *************** *** 4379,4382 **** --- 4380,4385 ---- PyObject *v) { + /* fmt = '%#.' + `prec` + `type` + worst case length = 3 + 10 (len of INT_MAX) + 1 = 14 (use 20)*/ char fmt[20]; double x; *************** *** 4387,4395 **** if (prec < 0) prec = 6; - if (prec > 50) - prec = 50; /* Arbitrary limitation */ if (type == 'f' && (fabs(x) / 1e25) >= 1e25) type = 'g'; sprintf(fmt, "%%%s.%d%c", (flags & F_ALT) ? "#" : "", prec, type); return usprintf(buf, fmt, x); } --- 4390,4408 ---- if (prec < 0) prec = 6; if (type == 'f' && (fabs(x) / 1e25) >= 1e25) type = 'g'; sprintf(fmt, "%%%s.%d%c", (flags & F_ALT) ? "#" : "", prec, type); + /* worst case length calc to ensure no buffer overrun: + fmt = %#.g + buf = '-' + [0-9]*prec + '.' + 'e+' + (longest exp + for any double rep.) + len = 1 + prec + 1 + 2 + 5 = 9 + prec + If prec=0 the effective precision is 1 (the leading digit is + always given), therefore increase by one to 10+prec. */ + if (buflen <= (size_t)10 + (size_t)prec) { + PyErr_SetString(PyExc_OverflowError, + "formatted float is too long (precision too long?)"); + return -1; + } return usprintf(buf, fmt, x); } *************** *** 4397,4400 **** --- 4410,4414 ---- static int formatint(Py_UNICODE *buf, + size_t buflen, int flags, int prec, *************** *** 4402,4405 **** --- 4416,4421 ---- PyObject *v) { + /* fmt = '%#.' + `prec` + 'l' + `type` + worst case length = 3 + 10 (len of INT_MAX) + 1 + 1 = 15 (use 20)*/ char fmt[20]; long x; *************** *** 4410,4413 **** --- 4426,4436 ---- if (prec < 0) prec = 1; + /* buf = '+'/'-'/'0'/'0x' + '[0-9]'*max(prec,len(x in octal)) + worst case buf = '0x' + [0-9]*prec, where prec >= 11 */ + if (buflen <= 13 || buflen <= (size_t)2+(size_t)prec) { + PyErr_SetString(PyExc_OverflowError, + "formatted integer is too long (precision too long?)"); + return -1; + } sprintf(fmt, "%%%s.%dl%c", (flags & F_ALT) ? "#" : "", prec, type); return usprintf(buf, fmt, x); *************** *** 4416,4421 **** static int formatchar(Py_UNICODE *buf, ! PyObject *v) { if (PyUnicode_Check(v)) { if (PyUnicode_GET_SIZE(v) != 1) --- 4439,4446 ---- static int formatchar(Py_UNICODE *buf, ! size_t buflen, ! PyObject *v) { + /* presume that the buffer is at least 2 characters long */ if (PyUnicode_Check(v)) { if (PyUnicode_GET_SIZE(v) != 1) *************** *** 4447,4450 **** --- 4472,4485 ---- } + /* fmt%(v1,v2,...) is roughly equivalent to sprintf(fmt, v1, v2, ...) + + FORMATBUFLEN is the length of the buffer in which the floats, ints, & + chars are formatted. XXX This is a magic number. Each formatting + routine does bounds checking to ensure no overflow, but a better + solution may be to malloc a buffer of appropriate size for each + format. For now, the current solution is sufficient. + */ + #define FORMATBUFLEN (size_t)120 + PyObject *PyUnicode_Format(PyObject *format, PyObject *args) *************** *** 4506,4513 **** PyObject *v = NULL; PyObject *temp = NULL; ! Py_UNICODE *buf; Py_UNICODE sign; int len; ! Py_UNICODE tmpbuf[120]; /* For format{float,int,char}() */ fmt++; --- 4541,4548 ---- PyObject *v = NULL; PyObject *temp = NULL; ! Py_UNICODE *pbuf; Py_UNICODE sign; int len; ! Py_UNICODE formatbuf[FORMATBUFLEN]; /* For format{float,int,char}() */ fmt++; *************** *** 4659,4664 **** case '%': ! buf = tmpbuf; ! buf[0] = '%'; len = 1; break; --- 4694,4700 ---- case '%': ! pbuf = formatbuf; ! /* presume that buffer length is at least 1 */ ! pbuf[0] = '%'; len = 1; break; *************** *** 4696,4700 **** goto onError; } ! buf = PyUnicode_AS_UNICODE(temp); len = PyUnicode_GET_SIZE(temp); if (prec >= 0 && len > prec) --- 4732,4736 ---- goto onError; } ! pbuf = PyUnicode_AS_UNICODE(temp); len = PyUnicode_GET_SIZE(temp); if (prec >= 0 && len > prec) *************** *** 4710,4715 **** if (c == 'i') c = 'd'; ! buf = tmpbuf; ! len = formatint(buf, flags, prec, c, v); if (len < 0) goto onError; --- 4746,4752 ---- if (c == 'i') c = 'd'; ! pbuf = formatbuf; ! len = formatint(pbuf, sizeof(formatbuf)/sizeof(Py_UNICODE), ! flags, prec, c, v); if (len < 0) goto onError; *************** *** 4719,4725 **** if ((flags&F_ALT) && (c == 'x' || c == 'X') && ! buf[0] == '0' && buf[1] == c) { ! *res++ = *buf++; ! *res++ = *buf++; rescnt -= 2; len -= 2; --- 4756,4762 ---- if ((flags&F_ALT) && (c == 'x' || c == 'X') && ! pbuf[0] == '0' && pbuf[1] == c) { ! *res++ = *pbuf++; ! *res++ = *pbuf++; rescnt -= 2; len -= 2; *************** *** 4736,4741 **** case 'g': case 'G': ! buf = tmpbuf; ! len = formatfloat(buf, flags, prec, c, v); if (len < 0) goto onError; --- 4773,4779 ---- case 'g': case 'G': ! pbuf = formatbuf; ! len = formatfloat(pbuf, sizeof(formatbuf)/sizeof(Py_UNICODE), ! flags, prec, c, v); if (len < 0) goto onError; *************** *** 4746,4751 **** case 'c': ! buf = tmpbuf; ! len = formatchar(buf, v); if (len < 0) goto onError; --- 4784,4789 ---- case 'c': ! pbuf = formatbuf; ! len = formatchar(pbuf, sizeof(formatbuf)/sizeof(Py_UNICODE), v); if (len < 0) goto onError; *************** *** 4759,4764 **** } if (sign) { ! if (*buf == '-' || *buf == '+') { ! sign = *buf++; len--; } --- 4797,4802 ---- } if (sign) { ! if (*pbuf == '-' || *pbuf == '+') { ! sign = *pbuf++; len--; } *************** *** 4796,4800 **** if (sign && fill == ' ') *res++ = sign; ! memcpy(res, buf, len * sizeof(Py_UNICODE)); res += len; rescnt -= len; --- 4834,4838 ---- if (sign && fill == ' ') *res++ = sign; ! memcpy(res, pbuf, len * sizeof(Py_UNICODE)); res += len; rescnt -= len; From python-dev@python.org Fri Jun 30 11:30:37 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Fri, 30 Jun 2000 03:30:37 -0700 Subject: [Python-checkins] CVS: python/dist/src/Tools/perfecthash GenUCNHash.py,1.2,1.3 Message-ID: <200006301030.DAA25564@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Tools/perfecthash In directory slayer.i.sourceforge.net:/tmp/cvs-serv25556/Tools/perfecthash Modified Files: GenUCNHash.py Log Message: Marc-Andre Lemburg : Fixed a quote bug. Thanks to Fredrik Lundh. Index: GenUCNHash.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/perfecthash/GenUCNHash.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** GenUCNHash.py 2000/06/30 09:53:22 1.2 --- GenUCNHash.py 2000/06/30 10:30:35 1.3 *************** *** 51,55 **** out.write(header) out = open(cFileName, "w") ! out.write("#include "%s"\n" % headerFileName) out.write(code) perfHash.generate_graph(out) --- 51,55 ---- out.write(header) out = open(cFileName, "w") ! out.write("#include \"%s\"\n" % headerFileName) out.write(code) perfHash.generate_graph(out) From python-dev@python.org Fri Jun 30 11:41:33 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 03:41:33 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.14,2.15 sre_constants.h,2.4,2.5 Message-ID: <200006301041.DAA26823@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv26572/Modules Modified Files: _sre.c sre_constants.h Log Message: - fixed lookahead assertions (#10, #11, #12) - untabified sre_constants.py Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.14 retrieving revision 2.15 diff -C2 -r2.14 -r2.15 *** _sre.c 2000/06/30 07:05:48 2.14 --- _sre.c 2000/06/30 10:41:31 2.15 *************** *** 21,24 **** --- 21,25 ---- * 00-06-29 fl fixed split, added more scanner features (0.9.2) * 00-06-30 fl tuning, fast search (0.9.3) + * 00-06-30 fl added assert (lookahead) primitives (0.9.4) * * Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. *************** *** 31,35 **** #ifndef SRE_RECURSIVE ! char copyright[] = " SRE 0.9.3 Copyright (c) 1997-2000 by Secret Labs AB "; #include "Python.h" --- 32,36 ---- #ifndef SRE_RECURSIVE ! char copyright[] = " SRE 0.9.4 Copyright (c) 1997-2000 by Secret Labs AB "; #include "Python.h" *************** *** 577,585 **** break; ! #if 0 ! case SRE_OP_CALL: ! /* match subpattern, without backtracking */ /* args: */ ! TRACE(("%8d: subpattern\n", PTR(ptr))); state->ptr = ptr; i = SRE_MATCH(state, pattern + 1); --- 578,585 ---- break; ! case SRE_OP_ASSERT: ! /* assert subpattern */ /* args: */ ! TRACE(("%8d: assert subpattern\n", PTR(ptr))); state->ptr = ptr; i = SRE_MATCH(state, pattern + 1); *************** *** 589,595 **** goto failure; pattern += pattern[0]; - ptr = state->ptr; break; ! #endif #if 0 --- 589,606 ---- goto failure; pattern += pattern[0]; break; ! ! case SRE_OP_ASSERT_NOT: ! /* assert not subpattern */ ! /* args: */ ! TRACE(("%8d: assert not subpattern\n", PTR(ptr))); ! state->ptr = ptr; ! i = SRE_MATCH(state, pattern + 1); ! if (i < 0) ! return i; ! if (i) ! goto failure; ! pattern += pattern[0]; ! break; #if 0 Index: sre_constants.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/sre_constants.h,v retrieving revision 2.4 retrieving revision 2.5 diff -C2 -r2.4 -r2.5 *** sre_constants.h 2000/06/29 08:55:54 2.4 --- sre_constants.h 2000/06/30 10:41:31 2.5 *************** *** 1,28 **** ! /* generated from sre_constants.py */ #define SRE_OP_FAILURE 0 #define SRE_OP_SUCCESS 1 #define SRE_OP_ANY 2 #define SRE_OP_ASSERT 3 ! #define SRE_OP_AT 4 ! #define SRE_OP_BRANCH 5 ! #define SRE_OP_CALL 6 ! #define SRE_OP_CATEGORY 7 ! #define SRE_OP_GROUP 8 ! #define SRE_OP_GROUP_IGNORE 9 ! #define SRE_OP_IN 10 ! #define SRE_OP_IN_IGNORE 11 ! #define SRE_OP_INFO 12 ! #define SRE_OP_JUMP 13 ! #define SRE_OP_LITERAL 14 ! #define SRE_OP_LITERAL_IGNORE 15 ! #define SRE_OP_MARK 16 ! #define SRE_OP_MAX_REPEAT 17 ! #define SRE_OP_MAX_REPEAT_ONE 18 ! #define SRE_OP_MIN_REPEAT 19 ! #define SRE_OP_NOT_LITERAL 20 ! #define SRE_OP_NOT_LITERAL_IGNORE 21 ! #define SRE_OP_NEGATE 22 ! #define SRE_OP_RANGE 23 ! #define SRE_OP_REPEAT 24 #define SRE_AT_BEGINNING 0 #define SRE_AT_BEGINNING_LINE 1 --- 1,41 ---- ! /* ! * Secret Labs' Regular Expression Engine ! * ! * regular expression matching engine ! * ! * NOTE: This file is generated by sre_constants.py. If you need ! * to change anything in here, edit sre_constants.py and run it. ! * ! * Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. ! * ! * See the _sre.c file for information on usage and redistribution. ! */ ! #define SRE_OP_FAILURE 0 #define SRE_OP_SUCCESS 1 #define SRE_OP_ANY 2 #define SRE_OP_ASSERT 3 ! #define SRE_OP_ASSERT_NOT 4 ! #define SRE_OP_AT 5 ! #define SRE_OP_BRANCH 6 ! #define SRE_OP_CALL 7 ! #define SRE_OP_CATEGORY 8 ! #define SRE_OP_GROUP 9 ! #define SRE_OP_GROUP_IGNORE 10 ! #define SRE_OP_IN 11 ! #define SRE_OP_IN_IGNORE 12 ! #define SRE_OP_INFO 13 ! #define SRE_OP_JUMP 14 ! #define SRE_OP_LITERAL 15 ! #define SRE_OP_LITERAL_IGNORE 16 ! #define SRE_OP_MARK 17 ! #define SRE_OP_MAX_REPEAT 18 ! #define SRE_OP_MAX_REPEAT_ONE 19 ! #define SRE_OP_MIN_REPEAT 20 ! #define SRE_OP_NOT_LITERAL 21 ! #define SRE_OP_NOT_LITERAL_IGNORE 22 ! #define SRE_OP_NEGATE 23 ! #define SRE_OP_RANGE 24 ! #define SRE_OP_REPEAT 25 #define SRE_AT_BEGINNING 0 #define SRE_AT_BEGINNING_LINE 1 From python-dev@python.org Fri Jun 30 11:41:33 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 03:41:33 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_sre,1.2,1.3 Message-ID: <200006301041.DAA26826@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv26572/Lib/test/output Modified Files: test_sre Log Message: - fixed lookahead assertions (#10, #11, #12) - untabified sre_constants.py Index: test_sre =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_sre,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** test_sre 2000/06/30 09:13:06 1.2 --- test_sre 2000/06/30 10:41:31 1.3 *************** *** 7,12 **** === grouping error ('([abc])*bcd', 'abcd', 0, 'found+"-"+g1', 'abcd-a') 'abcd-c' should be 'abcd-a' === grouping error ('(?i)([abc])*bcd', 'ABCD', 0, 'found+"-"+g1', 'ABCD-A') 'ABCD-C' should be 'ABCD-A' - === Syntax error: ('a(?!b).', 'abad', 0, 'found', 'ad') - === Syntax error: ('a(?=d).', 'abad', 0, 'found', 'ad') - === Syntax error: ('a(?=c|d).', 'abad', 0, 'found', 'ad') === Failed incorrectly ('^(.+)?B', 'AB', 0, 'g1', 'A') --- 7,9 ---- From python-dev@python.org Fri Jun 30 11:41:33 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 03:41:33 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre_compile.py,1.14,1.15 sre_constants.py,1.11,1.12 sre_parse.py,1.14,1.15 Message-ID: <200006301041.DAA26820@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv26572/Lib Modified Files: sre_compile.py sre_constants.py sre_parse.py Log Message: - fixed lookahead assertions (#10, #11, #12) - untabified sre_constants.py Index: sre_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** sre_compile.py 2000/06/30 07:50:59 1.14 --- sre_compile.py 2000/06/30 10:41:30 1.15 *************** *** 27,76 **** emit = code.append for op, av in pattern: ! if op is ANY: ! if flags & SRE_FLAG_DOTALL: ! emit(OPCODES[op]) ! else: ! emit(OPCODES[CATEGORY]) ! emit(CHCODES[CATEGORY_NOT_LINEBREAK]) ! elif op in (SUCCESS, FAILURE): ! emit(OPCODES[op]) ! elif op is AT: ! emit(OPCODES[op]) ! if flags & SRE_FLAG_MULTILINE: ! emit(ATCODES[AT_MULTILINE[av]]) ! else: ! emit(ATCODES[av]) ! elif op is BRANCH: ! emit(OPCODES[op]) ! tail = [] ! for av in av[1]: ! skip = len(code); emit(0) ! _compile(code, av, flags) ! emit(OPCODES[JUMP]) ! tail.append(len(code)); emit(0) ! code[skip] = len(code) - skip ! emit(0) # end of branch ! for tail in tail: ! code[tail] = len(code) - tail ! elif op is CALL: ! emit(OPCODES[op]) ! skip = len(code); emit(0) ! _compile(code, av, flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! elif op is CATEGORY: ! emit(OPCODES[op]) ! if flags & SRE_FLAG_LOCALE: ! emit(CHCODES[CH_LOCALE[av]]) ! elif flags & SRE_FLAG_UNICODE: ! emit(CHCODES[CH_UNICODE[av]]) ! else: ! emit(CHCODES[av]) ! elif op is GROUP: if flags & SRE_FLAG_IGNORECASE: emit(OPCODES[OP_IGNORE[op]]) else: emit(OPCODES[op]) ! emit(av-1) elif op is IN: if flags & SRE_FLAG_IGNORECASE: --- 27,36 ---- emit = code.append for op, av in pattern: ! if op in (LITERAL, NOT_LITERAL): if flags & SRE_FLAG_IGNORECASE: emit(OPCODES[OP_IGNORE[op]]) else: emit(OPCODES[op]) ! emit(ord(av)) elif op is IN: if flags & SRE_FLAG_IGNORECASE: *************** *** 102,114 **** emit(OPCODES[FAILURE]) code[skip] = len(code) - skip ! elif op in (LITERAL, NOT_LITERAL): ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) ! else: emit(OPCODES[op]) ! emit(ord(av)) ! elif op is MARK: ! emit(OPCODES[op]) ! emit(av) elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): if flags & SRE_FLAG_TEMPLATE: --- 62,71 ---- emit(OPCODES[FAILURE]) code[skip] = len(code) - skip ! elif op is ANY: ! if flags & SRE_FLAG_DOTALL: emit(OPCODES[op]) ! else: ! emit(OPCODES[CATEGORY]) ! emit(CHCODES[CATEGORY_NOT_LINEBREAK]) elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): if flags & SRE_FLAG_TEMPLATE: *************** *** 151,154 **** --- 108,154 ---- emit(OPCODES[MARK]) emit((group-1)*2+1) + elif op in (SUCCESS, FAILURE): + emit(OPCODES[op]) + elif op in (ASSERT, ASSERT_NOT, CALL): + emit(OPCODES[op]) + skip = len(code); emit(0) + _compile(code, av, flags) + emit(OPCODES[SUCCESS]) + code[skip] = len(code) - skip + elif op is AT: + emit(OPCODES[op]) + if flags & SRE_FLAG_MULTILINE: + emit(ATCODES[AT_MULTILINE[av]]) + else: + emit(ATCODES[av]) + elif op is BRANCH: + emit(OPCODES[op]) + tail = [] + for av in av[1]: + skip = len(code); emit(0) + _compile(code, av, flags) + emit(OPCODES[JUMP]) + tail.append(len(code)); emit(0) + code[skip] = len(code) - skip + emit(0) # end of branch + for tail in tail: + code[tail] = len(code) - tail + elif op is CATEGORY: + emit(OPCODES[op]) + if flags & SRE_FLAG_LOCALE: + emit(CHCODES[CH_LOCALE[av]]) + elif flags & SRE_FLAG_UNICODE: + emit(CHCODES[CH_UNICODE[av]]) + else: + emit(CHCODES[av]) + elif op is GROUP: + if flags & SRE_FLAG_IGNORECASE: + emit(OPCODES[OP_IGNORE[op]]) + else: + emit(OPCODES[op]) + emit(av-1) + elif op is MARK: + emit(OPCODES[op]) + emit(av) else: raise ValueError, ("unsupported operand type", op) Index: sre_constants.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_constants.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** sre_constants.py 2000/06/29 18:03:25 1.11 --- sre_constants.py 2000/06/30 10:41:30 1.12 *************** *** 24,27 **** --- 24,28 ---- ANY = "any" ASSERT = "assert" + ASSERT_NOT = "assert_not" AT = "at" BRANCH = "branch" *************** *** 82,86 **** ANY, ! ASSERT, AT, BRANCH, --- 83,87 ---- ANY, ! ASSERT, ASSERT_NOT, AT, BRANCH, *************** *** 122,127 **** i = 0 for item in list: ! d[item] = i ! i = i + 1 return d --- 123,128 ---- i = 0 for item in list: ! d[item] = i ! i = i + 1 return d *************** *** 177,186 **** import string def dump(f, d, prefix): ! items = d.items() ! items.sort(lambda a, b: cmp(a[1], b[1])) ! for k, v in items: ! f.write("#define %s_%s %s\n" % (prefix, string.upper(k), v)) f = open("sre_constants.h", "w") ! f.write("/* generated from sre_constants.py */\n") dump(f, OPCODES, "SRE_OP") dump(f, ATCODES, "SRE") --- 178,202 ---- import string def dump(f, d, prefix): ! items = d.items() ! items.sort(lambda a, b: cmp(a[1], b[1])) ! for k, v in items: ! f.write("#define %s_%s %s\n" % (prefix, string.upper(k), v)) f = open("sre_constants.h", "w") ! f.write("""\ ! /* ! * Secret Labs' Regular Expression Engine ! * ! * regular expression matching engine ! * ! * NOTE: This file is generated by sre_constants.py. If you need ! * to change anything in here, edit sre_constants.py and run it. ! * ! * Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. ! * ! * See the _sre.c file for information on usage and redistribution. ! */ ! ! """) ! dump(f, OPCODES, "SRE_OP") dump(f, ATCODES, "SRE") Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** sre_parse.py 2000/06/30 09:13:05 1.14 --- sre_parse.py 2000/06/30 10:41:30 1.15 *************** *** 471,474 **** --- 471,493 ---- break source.get() + elif source.next in ("=", "!"): + # lookahead assertions + char = source.get() + b = [] + while 1: + p = _parse(source, state, flags) + if source.next == ")": + if b: + b.append(p) + p = _branch(state, b) + if char == "=": + subpattern.append((ASSERT, p)) + else: + subpattern.append((ASSERT_NOT, p)) + break + elif source.match("|"): + b.append(p) + else: + raise error, "pattern not properly closed" else: # flags From python-dev@python.org Fri Jun 30 14:00:35 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 06:00:35 -0700 Subject: [Python-checkins] CVS: python/dist/src/PC readme.txt,1.21,1.22 Message-ID: <200006301300.GAA25808@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv24416 Modified Files: readme.txt Log Message: Trivial commit to test Windows CVS capabilities. Index: readme.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/readme.txt,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -r1.21 -r1.22 *** readme.txt 1999/04/12 14:48:53 1.21 --- readme.txt 2000/06/30 13:00:32 1.22 *************** *** 1,4 **** ! Welcome to the "PC" subdirectory of the Python distribution! ! ************************************************************ *** Note: the project files for MS VC++ 5.0 and 6.0 are now in the --- 1,4 ---- ! Welcome to the "PC" subdirectory of the Python distribution ! *********************************************************** *** Note: the project files for MS VC++ 5.0 and 6.0 are now in the From python-dev@python.org Fri Jun 30 14:55:17 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 06:55:17 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_sre,1.3,1.4 Message-ID: <200006301355.GAA00997@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv350/Lib/test/output Modified Files: test_sre Log Message: the mad patcher strikes again: -- added pickling support (only works if sre is imported) -- fixed wordsize problems in engine (instead of casting literals down to the character size, cast characters up to the literal size (same as the code word size). this prevents false hits when you're matching a unicode pattern against an 8-bit string. (unfortunately, this broke another test, but I think the test should be changed in this case; more on that on python-dev) -- added sre.purge function (unofficial, clears the cache) Index: test_sre =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_sre,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** test_sre 2000/06/30 10:41:31 1.3 --- test_sre 2000/06/30 13:55:15 1.4 *************** *** 1,5 **** test_sre ! test_support -- test failed re module pickle ! test_support -- test failed re module cPickle === Failed incorrectly ('^(.+)?B', 'AB', 0, 'g1', 'A') === Failed incorrectly ('(a+)+\\1', 'aa', 0, 'found+"-"+g1', 'aa-a') --- 1,4 ---- test_sre ! === Failed incorrectly ('\\x00ffffffffffffff', '\377', 0, 'found', '\377') === Failed incorrectly ('^(.+)?B', 'AB', 0, 'g1', 'A') === Failed incorrectly ('(a+)+\\1', 'aa', 0, 'found+"-"+g1', 'aa-a') From python-dev@python.org Fri Jun 30 14:55:17 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 06:55:17 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.15,2.16 Message-ID: <200006301355.GAA00998@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv350/Modules Modified Files: _sre.c Log Message: the mad patcher strikes again: -- added pickling support (only works if sre is imported) -- fixed wordsize problems in engine (instead of casting literals down to the character size, cast characters up to the literal size (same as the code word size). this prevents false hits when you're matching a unicode pattern against an 8-bit string. (unfortunately, this broke another test, but I think the test should be changed in this case; more on that on python-dev) -- added sre.purge function (unofficial, clears the cache) Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.15 retrieving revision 2.16 diff -C2 -r2.15 -r2.16 *** _sre.c 2000/06/30 10:41:31 2.15 --- _sre.c 2000/06/30 13:55:15 2.16 *************** *** 21,25 **** * 00-06-29 fl fixed split, added more scanner features (0.9.2) * 00-06-30 fl tuning, fast search (0.9.3) ! * 00-06-30 fl added assert (lookahead) primitives (0.9.4) * * Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. --- 21,25 ---- * 00-06-29 fl fixed split, added more scanner features (0.9.2) * 00-06-30 fl tuning, fast search (0.9.3) ! * 00-06-30 fl added assert (lookahead) primitives, etc (0.9.4) * * Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. *************** *** 340,344 **** LOCAL(int) ! SRE_MEMBER(SRE_CODE* set, SRE_CHAR ch) { /* check if character is a member of the given set */ --- 340,344 ---- LOCAL(int) ! SRE_MEMBER(SRE_CODE* set, SRE_CODE ch) { /* check if character is a member of the given set */ *************** *** 357,361 **** case SRE_OP_LITERAL: ! if (ch == (SRE_CHAR) set[0]) return ok; set++; --- 357,361 ---- case SRE_OP_LITERAL: ! if (ch == set[0]) return ok; set++; *************** *** 363,367 **** case SRE_OP_RANGE: ! if ((SRE_CHAR) set[0] <= ch && ch <= (SRE_CHAR) set[1]) return ok; set += 2; --- 363,367 ---- case SRE_OP_RANGE: ! if (set[0] <= ch && ch <= set[1]) return ok; set += 2; *************** *** 456,461 **** /* match literal string */ /* args: */ ! TRACE(("%8d: literal %c\n", PTR(ptr), (SRE_CHAR) pattern[0])); ! if (ptr >= end || *ptr != (SRE_CHAR) pattern[0]) goto failure; pattern++; --- 456,461 ---- /* match literal string */ /* args: */ ! TRACE(("%8d: literal %c\n", PTR(ptr), pattern[0])); ! if (ptr >= end || (SRE_CODE) ptr[0] != pattern[0]) goto failure; pattern++; *************** *** 466,471 **** /* match anything that is not literal character */ /* args: */ ! TRACE(("%8d: literal not %c\n", PTR(ptr), (SRE_CHAR) pattern[0])); ! if (ptr >= end || *ptr == (SRE_CHAR) pattern[0]) goto failure; pattern++; --- 466,471 ---- /* match anything that is not literal character */ /* args: */ ! TRACE(("%8d: literal not %c\n", PTR(ptr), pattern[0])); ! if (ptr >= end || (SRE_CODE) ptr[0] == pattern[0]) goto failure; pattern++; *************** *** 529,533 **** case SRE_OP_LITERAL_IGNORE: ! TRACE(("%8d: literal lower(%c)\n", PTR(ptr), (SRE_CHAR) *pattern)); if (ptr >= end || state->lower(*ptr) != state->lower(*pattern)) --- 529,533 ---- case SRE_OP_LITERAL_IGNORE: ! TRACE(("%8d: literal lower(%c)\n", PTR(ptr), pattern[0])); if (ptr >= end || state->lower(*ptr) != state->lower(*pattern)) *************** *** 538,543 **** case SRE_OP_NOT_LITERAL_IGNORE: ! TRACE(("%8d: literal not lower(%c)\n", PTR(ptr), ! (SRE_CHAR) *pattern)); if (ptr >= end || state->lower(*ptr) == state->lower(*pattern)) --- 538,542 ---- case SRE_OP_NOT_LITERAL_IGNORE: ! TRACE(("%8d: literal not lower(%c)\n", PTR(ptr), pattern[0])); if (ptr >= end || state->lower(*ptr) == state->lower(*pattern)) *************** *** 550,554 **** TRACE(("%8d: set lower(%c)\n", PTR(ptr), *ptr)); if (ptr >= end ! || !SRE_MEMBER(pattern+1, (SRE_CHAR) state->lower(*ptr))) goto failure; pattern += pattern[0]; --- 549,553 ---- TRACE(("%8d: set lower(%c)\n", PTR(ptr), *ptr)); if (ptr >= end ! || !SRE_MEMBER(pattern+1, (SRE_CODE) state->lower(*ptr))) goto failure; pattern += pattern[0]; *************** *** 632,638 **** } else if (pattern[3] == SRE_OP_LITERAL) { /* repeated literal */ ! SRE_CHAR chr = (SRE_CHAR) pattern[4]; while (count < (int) pattern[2]) { ! if (ptr >= end || *ptr != chr) break; ptr++; --- 631,637 ---- } else if (pattern[3] == SRE_OP_LITERAL) { /* repeated literal */ ! SRE_CODE chr = pattern[4]; while (count < (int) pattern[2]) { ! if (ptr >= end || (SRE_CODE) ptr[0] != chr) break; ptr++; *************** *** 642,648 **** } else if (pattern[3] == SRE_OP_LITERAL_IGNORE) { /* repeated literal */ ! SRE_CHAR chr = (SRE_CHAR) pattern[4]; while (count < (int) pattern[2]) { ! if (ptr >= end || (SRE_CHAR) state->lower(*ptr) != chr) break; ptr++; --- 641,647 ---- } else if (pattern[3] == SRE_OP_LITERAL_IGNORE) { /* repeated literal */ ! SRE_CODE chr = pattern[4]; while (count < (int) pattern[2]) { ! if (ptr >= end || (SRE_CODE) state->lower(*ptr) != chr) break; ptr++; *************** *** 652,658 **** } else if (pattern[3] == SRE_OP_NOT_LITERAL) { /* repeated non-literal */ ! SRE_CHAR chr = (SRE_CHAR) pattern[4]; while (count < (int) pattern[2]) { ! if (ptr >= end || *ptr == chr) break; ptr++; --- 651,657 ---- } else if (pattern[3] == SRE_OP_NOT_LITERAL) { /* repeated non-literal */ ! SRE_CODE chr = pattern[4]; while (count < (int) pattern[2]) { ! if (ptr >= end || (SRE_CODE) ptr[0] == chr) break; ptr++; *************** *** 662,668 **** } else if (pattern[3] == SRE_OP_NOT_LITERAL_IGNORE) { /* repeated non-literal */ ! SRE_CHAR chr = (SRE_CHAR) pattern[4]; while (count < (int) pattern[2]) { ! if (ptr >= end || (SRE_CHAR) state->lower(*ptr) == chr) break; ptr++; --- 661,667 ---- } else if (pattern[3] == SRE_OP_NOT_LITERAL_IGNORE) { /* repeated non-literal */ ! SRE_CODE chr = pattern[4]; while (count < (int) pattern[2]) { ! if (ptr >= end || (SRE_CODE) state->lower(ptr[0]) == chr) break; ptr++; *************** *** 713,717 **** /* tail starts with a literal. skip positions where the rest of the pattern cannot possibly match */ ! SRE_CHAR chr = (SRE_CHAR) pattern[pattern[0]+1]; TRACE(("%8d: tail is literal %d\n", PTR(ptr), chr)); for (;;) { --- 712,716 ---- /* tail starts with a literal. skip positions where the rest of the pattern cannot possibly match */ ! SRE_CODE chr = pattern[pattern[0]+1]; TRACE(("%8d: tail is literal %d\n", PTR(ptr), chr)); for (;;) { *************** *** 869,873 **** while (*pattern) { if (pattern[1] != SRE_OP_LITERAL || ! (ptr < end && *ptr == (SRE_CHAR) pattern[2])) { TRACE(("%8d: branch check\n", PTR(ptr))); state->ptr = ptr; --- 868,872 ---- while (*pattern) { if (pattern[1] != SRE_OP_LITERAL || ! (ptr < end && (SRE_CODE) ptr[0] == pattern[2])) { TRACE(("%8d: branch check\n", PTR(ptr))); state->ptr = ptr; *************** *** 977,981 **** while (ptr < end) { for (;;) { ! if (*ptr != (SRE_CHAR) prefix[i]) { if (!i) break; --- 976,980 ---- while (ptr < end) { for (;;) { ! if ((SRE_CODE) ptr[0] != prefix[i]) { if (!i) break; *************** *** 1009,1015 **** /* pattern starts with a literal character. this is used for short prefixes, and if fast search is disabled*/ ! SRE_CHAR chr = (SRE_CHAR) pattern[1]; for (;;) { ! while (ptr < end && *ptr != chr) ptr++; if (ptr == end) --- 1008,1014 ---- /* pattern starts with a literal character. this is used for short prefixes, and if fast search is disabled*/ ! SRE_CODE chr = pattern[1]; for (;;) { ! while (ptr < end && (SRE_CODE) ptr[0] != chr) ptr++; if (ptr == end) From python-dev@python.org Fri Jun 30 14:55:17 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 06:55:17 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre.py,1.16,1.17 sre_compile.py,1.15,1.16 sre_parse.py,1.15,1.16 Message-ID: <200006301355.GAA00999@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv350/Lib Modified Files: sre.py sre_compile.py sre_parse.py Log Message: the mad patcher strikes again: -- added pickling support (only works if sre is imported) -- fixed wordsize problems in engine (instead of casting literals down to the character size, cast characters up to the literal size (same as the code word size). this prevents false hits when you're matching a unicode pattern against an 8-bit string. (unfortunately, this broke another test, but I think the test should be changed in this case; more on that on python-dev) -- added sre.purge function (unofficial, clears the cache) Index: sre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** sre.py 2000/06/30 07:50:59 1.16 --- sre.py 2000/06/30 13:55:14 1.17 *************** *** 90,93 **** --- 90,97 ---- return p + def purge(): + # clear pattern cache + _cache.clear() + def _sub(pattern, template, string, count=0): # internal: pattern.sub implementation hook *************** *** 143,144 **** --- 147,157 ---- append(string[i:]) return s + + # register myself for pickling + + import copy_reg + + def _pickle(p): + return _compile, (p.pattern, p.flags) + + copy_reg.pickle(type(_compile("")), _pickle, _compile) Index: sre_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** sre_compile.py 2000/06/30 10:41:30 1.15 --- sre_compile.py 2000/06/30 13:55:14 1.16 *************** *** 32,44 **** else: emit(OPCODES[op]) ! emit(ord(av)) elif op is IN: if flags & SRE_FLAG_IGNORECASE: emit(OPCODES[OP_IGNORE[op]]) def fixup(literal, flags=flags): ! return _sre.getlower(ord(literal), flags) else: emit(OPCODES[op]) ! fixup = ord skip = len(code); emit(0) for op, av in av: --- 32,44 ---- else: emit(OPCODES[op]) ! emit(av) elif op is IN: if flags & SRE_FLAG_IGNORECASE: emit(OPCODES[OP_IGNORE[op]]) def fixup(literal, flags=flags): ! return _sre.getlower(literal, flags) else: emit(OPCODES[op]) ! fixup = lambda x: x skip = len(code); emit(0) for op, av in av: *************** *** 166,170 **** for op, av in pattern.data: if op is LITERAL: ! prefix.append(ord(av)) else: break --- 166,170 ---- for op, av in pattern.data: if op is LITERAL: ! prefix.append(av) else: break Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** sre_parse.py 2000/06/30 10:41:30 1.15 --- sre_parse.py 2000/06/30 13:55:14 1.16 *************** *** 20,23 **** --- 20,26 ---- MAXREPEAT = 32767 + # FIXME: same here + CHARMASK = 0x7fff + SPECIAL_CHARS = ".\\[{()*+?^$|" REPEAT_CHARS = "*+?{" *************** *** 31,42 **** ESCAPES = { ! r"\a": (LITERAL, chr(7)), ! r"\b": (LITERAL, chr(8)), ! r"\f": (LITERAL, chr(12)), ! r"\n": (LITERAL, chr(10)), ! r"\r": (LITERAL, chr(13)), ! r"\t": (LITERAL, chr(9)), ! r"\v": (LITERAL, chr(11)), ! r"\\": (LITERAL, "\\") } --- 34,45 ---- ESCAPES = { ! r"\a": (LITERAL, 7), ! r"\b": (LITERAL, 8), ! r"\f": (LITERAL, 12), ! r"\n": (LITERAL, 10), ! r"\r": (LITERAL, 13), ! r"\t": (LITERAL, 9), ! r"\v": (LITERAL, 11), ! r"\\": (LITERAL, ord("\\")) } *************** *** 177,183 **** def isname(name): # check that group name is a valid string - # FIXME: this code is really lame. should use a regular - # expression instead, but I seem to have certain bootstrapping - # problems here ;-) if not isident(name[0]): return 0 --- 180,183 ---- *************** *** 210,223 **** escape = escape + source.get() escape = escape[2:] ! # FIXME: support unicode characters! ! return LITERAL, chr(int(escape[-4:], 16) & 0xff) elif str(escape[1:2]) in OCTDIGITS: while source.next in OCTDIGITS: escape = escape + source.get() escape = escape[1:] ! # FIXME: support unicode characters! ! return LITERAL, chr(int(escape[-6:], 8) & 0xff) if len(escape) == 2: ! return LITERAL, escape[1] except ValueError: pass --- 210,221 ---- escape = escape + source.get() escape = escape[2:] ! return LITERAL, int(escape[-4:], 16) & CHARMASK elif str(escape[1:2]) in OCTDIGITS: while source.next in OCTDIGITS: escape = escape + source.get() escape = escape[1:] ! return LITERAL, int(escape[-6:], 8) & CHARMASK if len(escape) == 2: ! return LITERAL, ord(escape[1]) except ValueError: pass *************** *** 237,242 **** escape = escape + source.get() escape = escape[2:] ! # FIXME: support unicode characters! ! return LITERAL, chr(int(escape[-4:], 16) & 0xff) elif escape[1:2] in DIGITS: while 1: --- 235,239 ---- escape = escape + source.get() escape = escape[2:] ! return LITERAL, int(escape[-4:], 16) & CHARMASK elif escape[1:2] in DIGITS: while 1: *************** *** 252,266 **** break escape = escape[1:] ! # FIXME: support unicode characters! ! return LITERAL, chr(int(escape[-6:], 8) & 0xff) if len(escape) == 2: ! return LITERAL, escape[1] except ValueError: pass raise error, "bogus escape: %s" % repr(escape) - def _branch(pattern, items): - # form a branch operator from a set of items --- 249,260 ---- break escape = escape[1:] ! return LITERAL, int(escape[-6:], 8) & CHARMASK if len(escape) == 2: ! return LITERAL, ord(escape[1]) except ValueError: pass raise error, "bogus escape: %s" % repr(escape) def _branch(pattern, items): # form a branch operator from a set of items *************** *** 328,332 **** if this and this[0] not in SPECIAL_CHARS: ! subpattern.append((LITERAL, this)) elif this == "[": --- 322,326 ---- if this and this[0] not in SPECIAL_CHARS: ! subpattern.append((LITERAL, ord(this))) elif this == "[": *************** *** 346,350 **** code1 = _class_escape(source, this) elif this: ! code1 = LITERAL, this else: raise error, "unexpected end of regular expression" --- 340,344 ---- code1 = _class_escape(source, this) elif this: ! code1 = LITERAL, ord(this) else: raise error, "unexpected end of regular expression" *************** *** 354,358 **** if this == "]": set.append(code1) ! set.append((LITERAL, "-")) break else: --- 348,352 ---- if this == "]": set.append(code1) ! set.append((LITERAL, ord("-"))) break else: *************** *** 360,368 **** code2 = _class_escape(source, this) else: ! code2 = LITERAL, this if code1[0] != LITERAL or code2[0] != LITERAL: raise error, "illegal range" - if len(code1[1]) != 1 or len(code2[1]) != 1: - raise error, "illegal range" set.append((RANGE, (code1[1], code2[1]))) else: --- 354,360 ---- code2 = _class_escape(source, this) else: ! code2 = LITERAL, ord(this) if code1[0] != LITERAL or code2[0] != LITERAL: raise error, "illegal range" set.append((RANGE, (code1[1], code2[1]))) else: *************** *** 606,611 **** if not code: this = this[1:] ! # FIXME: support unicode characters! ! code = LITERAL, chr(int(this[-6:], 8) & 0xff) a(code) else: --- 598,602 ---- if not code: this = this[1:] ! code = LITERAL, int(this[-6:], 8) & CHARMASK a(code) else: *************** *** 614,620 **** except KeyError: for c in this: ! a((LITERAL, c)) else: ! a((LITERAL, this)) return p --- 605,611 ---- except KeyError: for c in this: ! a((LITERAL, ord(c))) else: ! a((LITERAL, ord(this))) return p *************** *** 624,630 **** p = [] a = p.append for c, s in template: if c is LITERAL: ! a(s) elif c is MARK: s = match.group(s) --- 615,626 ---- p = [] a = p.append + sep = match.string[:0] + if type(sep) is type(""): + char = chr + else: + char = unichr for c, s in template: if c is LITERAL: ! a(char(s)) elif c is MARK: s = match.group(s) *************** *** 632,634 **** raise error, "empty group" a(s) ! return match.string[:0].join(p) --- 628,630 ---- raise error, "empty group" a(s) ! return sep.join(p) From python-dev@python.org Fri Jun 30 15:04:13 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 07:04:13 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild pcbuild.dsw,1.16,1.17 python16.dsp,1.7,NONE python16.wse,1.7,NONE Message-ID: <200006301404.HAA04120@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv4059 Modified Files: pcbuild.dsw Removed Files: python16.dsp python16.wse Log Message: More 2.0 stuff -- fix workspace, remove 1.6 files Index: pcbuild.dsw =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pcbuild.dsw,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** pcbuild.dsw 2000/04/25 03:24:06 1.16 --- pcbuild.dsw 2000/06/30 14:04:10 1.17 *************** *** 8,15 **** Package=<5> {{{ - begin source code control - _socket - .. - end source code control }}} --- 8,11 ---- *************** *** 17,21 **** {{{ Begin Project Dependency ! Project_Dep_Name python16 End Project Dependency }}} --- 13,17 ---- {{{ Begin Project Dependency ! Project_Dep_Name python20 End Project Dependency }}} *************** *** 27,34 **** Package=<5> {{{ - begin source code control - _sre - .. - end source code control }}} --- 23,26 ---- *************** *** 36,40 **** {{{ Begin Project Dependency ! Project_Dep_Name python16 End Project Dependency }}} --- 28,32 ---- {{{ Begin Project Dependency ! Project_Dep_Name python20 End Project Dependency }}} *************** *** 46,53 **** Package=<5> {{{ - begin source code control - _tkinter - . - end source code control }}} --- 38,41 ---- *************** *** 55,59 **** {{{ Begin Project Dependency ! Project_Dep_Name python16 End Project Dependency }}} --- 43,47 ---- {{{ Begin Project Dependency ! Project_Dep_Name python20 End Project Dependency }}} *************** *** 65,72 **** Package=<5> {{{ - begin source code control - bsddb - .. - end source code control }}} --- 53,56 ---- *************** *** 74,78 **** {{{ Begin Project Dependency ! Project_Dep_Name python16 End Project Dependency }}} --- 58,62 ---- {{{ Begin Project Dependency ! Project_Dep_Name python20 End Project Dependency }}} *************** *** 84,91 **** Package=<5> {{{ - begin source code control - mmap - .. - end source code control }}} --- 68,71 ---- *************** *** 93,97 **** {{{ Begin Project Dependency ! Project_Dep_Name python16 End Project Dependency }}} --- 73,77 ---- {{{ Begin Project Dependency ! Project_Dep_Name python20 End Project Dependency }}} *************** *** 103,110 **** Package=<5> {{{ - begin source code control - parser - .. - end source code control }}} --- 83,86 ---- *************** *** 112,116 **** {{{ Begin Project Dependency ! Project_Dep_Name python16 End Project Dependency }}} --- 88,92 ---- {{{ Begin Project Dependency ! Project_Dep_Name python20 End Project Dependency }}} *************** *** 122,129 **** Package=<5> {{{ - begin source code control - pyexpat - .. - end source code control }}} --- 98,101 ---- *************** *** 131,135 **** {{{ Begin Project Dependency ! Project_Dep_Name python16 End Project Dependency }}} --- 103,107 ---- {{{ Begin Project Dependency ! Project_Dep_Name python20 End Project Dependency }}} *************** *** 141,148 **** Package=<5> {{{ - begin source code control - python - .. - end source code control }}} --- 113,116 ---- *************** *** 150,154 **** {{{ Begin Project Dependency ! Project_Dep_Name python16 End Project Dependency }}} --- 118,122 ---- {{{ Begin Project Dependency ! Project_Dep_Name python20 End Project Dependency }}} *************** *** 156,167 **** ############################################################################### ! Project: "python16"=".\python16.dsp" - Package Owner=<4> Package=<5> {{{ - begin source code control - python16 - .. - end source code control }}} --- 124,131 ---- ############################################################################### ! Project: "python20"=".\python20.dsp" - Package Owner=<4> Package=<5> {{{ }}} *************** *** 176,183 **** Package=<5> {{{ - begin source code control - pythonw - ..\pc - end source code control }}} --- 140,143 ---- *************** *** 185,189 **** {{{ Begin Project Dependency ! Project_Dep_Name python16 End Project Dependency }}} --- 145,149 ---- {{{ Begin Project Dependency ! Project_Dep_Name python20 End Project Dependency }}} *************** *** 195,202 **** Package=<5> {{{ - begin source code control - select - .. - end source code control }}} --- 155,158 ---- *************** *** 204,208 **** {{{ Begin Project Dependency ! Project_Dep_Name python16 End Project Dependency }}} --- 160,164 ---- {{{ Begin Project Dependency ! Project_Dep_Name python20 End Project Dependency }}} *************** *** 214,221 **** Package=<5> {{{ - begin source code control - unicodedata - .. - end source code control }}} --- 170,173 ---- *************** *** 223,227 **** {{{ Begin Project Dependency ! Project_Dep_Name python16 End Project Dependency }}} --- 175,179 ---- {{{ Begin Project Dependency ! Project_Dep_Name python20 End Project Dependency }}} *************** *** 233,240 **** Package=<5> {{{ - begin source code control - winreg - ..\pc - end source code control }}} --- 185,188 ---- *************** *** 242,246 **** {{{ Begin Project Dependency ! Project_Dep_Name python16 End Project Dependency }}} --- 190,194 ---- {{{ Begin Project Dependency ! Project_Dep_Name python20 End Project Dependency }}} *************** *** 252,259 **** Package=<5> {{{ - begin source code control - winsound - ..\pc - end source code control }}} --- 200,203 ---- *************** *** 261,265 **** {{{ Begin Project Dependency ! Project_Dep_Name python16 End Project Dependency }}} --- 205,209 ---- {{{ Begin Project Dependency ! Project_Dep_Name python20 End Project Dependency }}} *************** *** 271,278 **** Package=<5> {{{ - begin source code control - zlib - .. - end source code control }}} --- 215,218 ---- *************** *** 280,284 **** {{{ Begin Project Dependency ! Project_Dep_Name python16 End Project Dependency }}} --- 220,224 ---- {{{ Begin Project Dependency ! Project_Dep_Name python20 End Project Dependency }}} *************** *** 297,299 **** --- 237,240 ---- ############################################################################### + From python-dev@python.org Fri Jun 30 15:20:22 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 07:20:22 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild python20.wse,1.1,1.2 Message-ID: <200006301420.HAA09411@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv9404 Modified Files: python20.wse Log Message: Poke and hope for Tim... (Change title to beta 1, change a few paths for typical Win98 setup.) Index: python20.wse =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/python20.wse,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** python20.wse 2000/06/29 22:32:08 1.1 --- python20.wse 2000/06/30 14:20:19 1.2 *************** *** 2,6 **** item: Global Version=5.0 ! Title=Python 2.0 alpha 2 Flags=00010100 Languages=65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 --- 2,6 ---- item: Global Version=5.0 ! Title=Python 2.0 beta 1 Flags=00010100 Languages=65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 *************** *** 19,35 **** Variable Name1=_SYS_ Variable Description1=System directory ! Variable Default1=C:\WINNT\SYSTEM32 Variable Flags1=00001001 Variable Name2=_WISE_ Variable Description2=WISE root directory ! Variable Default2=C:\Program Files\Wise Variable Flags2=00001001 Variable Name3=_SRC_ Variable Description3=Python source directory ! Variable Default3=D:\src\Python-2.0 Variable Flags3=00001001 Variable Name4=_DOC_ Variable Description4=HTML documentation tree directory ! Variable Default4=D:\src\Python-2.0\html Variable Flags4=00001001 end --- 19,35 ---- Variable Name1=_SYS_ Variable Description1=System directory ! Variable Default1=C:\Windows\System Variable Flags1=00001001 Variable Name2=_WISE_ Variable Description2=WISE root directory ! Variable Default2=C:\Wise Variable Flags2=00001001 Variable Name3=_SRC_ Variable Description3=Python source directory ! Variable Default3=C:\src\Python-2.0 Variable Flags3=00001001 Variable Name4=_DOC_ Variable Description4=HTML documentation tree directory ! Variable Default4=C:\src\Python-2.0\html Variable Flags4=00001001 end *************** *** 56,60 **** item: Set Variable Variable=APPTITLE ! Value=Python 2.0 alpha 2 end item: Set Variable --- 56,60 ---- item: Set Variable Variable=APPTITLE ! Value=Python 2.0 beta 1 end item: Set Variable From python-dev@python.org Fri Jun 30 15:21:53 2000 From: python-dev@python.org (Sjoerd Mullender) Date: Fri, 30 Jun 2000 16:21:53 +0200 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.31,2.32 In-Reply-To: Your message of Fri, 30 Jun 2000 03:29:59 -0700. <200006301029.DAA25494@slayer.i.sourceforge.net> References: <200006301029.DAA25494@slayer.i.sourceforge.net> Message-ID: <20000630142154.968F831047C@bireme.oratrix.nl> Why was the change that occurred in revision 2.31 reverted? Accident? The change log said: Jack Jansen: Use include "" instead of <>; and staticforward declarations On Fri, Jun 30 2000 "M.-A. Lemburg" wrote: > Update of /cvsroot/python/python/dist/src/Objects > In directory slayer.i.sourceforge.net:/tmp/cvs-serv25442/Objects > > Modified Files: > unicodeobject.c > Log Message: > Marc-Andre Lemburg : > New buffer overflow checks for formatting strings. > > By Trent Mick. > > Index: unicodeobject.c > =================================================================== > RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v > retrieving revision 2.31 > retrieving revision 2.32 > diff -C2 -r2.31 -r2.32 > *** unicodeobject.c 2000/06/29 00:06:39 2.31 > --- unicodeobject.c 2000/06/30 10:29:57 2.32 > *************** > *** 67,71 **** > #include "mymath.h" > #include "unicodeobject.h" > ! #include "ucnhash.h" > > #if defined(HAVE_LIMITS_H) > --- 67,71 ---- > #include "mymath.h" > #include "unicodeobject.h" > ! #include > > #if defined(HAVE_LIMITS_H) > *************** > *** 1245,1249 **** > ucnFallthrough: > /* fall through on purpose */ > ! default: > *p++ = '\\'; > *p++ = (unsigned char)s[-1]; > --- 1245,1249 ---- > ucnFallthrough: > /* fall through on purpose */ > ! default: > *p++ = '\\'; > *p++ = (unsigned char)s[-1]; > *************** > *** 1252,1256 **** > } > if (_PyUnicode_Resize(v, (int)(p - buf))) > ! goto onError; > return (PyObject *)v; > > --- 1252,1256 ---- > } > if (_PyUnicode_Resize(v, (int)(p - buf))) > ! goto onError; > return (PyObject *)v; > > *************** > *** 4374,4377 **** > --- 4374,4378 ---- > static int > formatfloat(Py_UNICODE *buf, > + size_t buflen, > int flags, > int prec, > *************** > *** 4379,4382 **** > --- 4380,4385 ---- > PyObject *v) > { > + /* fmt = '%#.' + `prec` + `type` > + worst case length = 3 + 10 (len of INT_MAX) + 1 = 14 (use 20)*/ > char fmt[20]; > double x; > *************** > *** 4387,4395 **** > if (prec < 0) > prec = 6; > - if (prec > 50) > - prec = 50; /* Arbitrary limitation */ > if (type == 'f' && (fabs(x) / 1e25) >= 1e25) > type = 'g'; > sprintf(fmt, "%%%s.%d%c", (flags & F_ALT) ? "#" : "", prec, type); > return usprintf(buf, fmt, x); > } > --- 4390,4408 ---- > if (prec < 0) > prec = 6; > if (type == 'f' && (fabs(x) / 1e25) >= 1e25) > type = 'g'; > sprintf(fmt, "%%%s.%d%c", (flags & F_ALT) ? "#" : "", prec, type); > + /* worst case length calc to ensure no buffer overrun: > + fmt = %#.g > + buf = '-' + [0-9]*prec + '.' + 'e+' + (longest exp > + for any double rep.) > + len = 1 + prec + 1 + 2 + 5 = 9 + prec > + If prec=0 the effective precision is 1 (the leading digit is > + always given), therefore increase by one to 10+prec. */ > + if (buflen <= (size_t)10 + (size_t)prec) { > + PyErr_SetString(PyExc_OverflowError, > + "formatted float is too long (precision too long?)"); > + return -1; > + } > return usprintf(buf, fmt, x); > } > *************** > *** 4397,4400 **** > --- 4410,4414 ---- > static int > formatint(Py_UNICODE *buf, > + size_t buflen, > int flags, > int prec, > *************** > *** 4402,4405 **** > --- 4416,4421 ---- > PyObject *v) > { > + /* fmt = '%#.' + `prec` + 'l' + `type` > + worst case length = 3 + 10 (len of INT_MAX) + 1 + 1 = 15 (use 20)*/ > char fmt[20]; > long x; > *************** > *** 4410,4413 **** > --- 4426,4436 ---- > if (prec < 0) > prec = 1; > + /* buf = '+'/'-'/'0'/'0x' + '[0-9]'*max(prec,len(x in octal)) > + worst case buf = '0x' + [0-9]*prec, where prec >= 11 */ > + if (buflen <= 13 || buflen <= (size_t)2+(size_t)prec) { > + PyErr_SetString(PyExc_OverflowError, > + "formatted integer is too long (precision too long?)"); > + return -1; > + } > sprintf(fmt, "%%%s.%dl%c", (flags & F_ALT) ? "#" : "", prec, type); > return usprintf(buf, fmt, x); > *************** > *** 4416,4421 **** > static int > formatchar(Py_UNICODE *buf, > ! PyObject *v) > { > if (PyUnicode_Check(v)) { > if (PyUnicode_GET_SIZE(v) != 1) > --- 4439,4446 ---- > static int > formatchar(Py_UNICODE *buf, > ! size_t buflen, > ! PyObject *v) > { > + /* presume that the buffer is at least 2 characters long */ > if (PyUnicode_Check(v)) { > if (PyUnicode_GET_SIZE(v) != 1) > *************** > *** 4447,4450 **** > --- 4472,4485 ---- > } > > + /* fmt%(v1,v2,...) is roughly equivalent to sprintf(fmt, v1, v2, ...) > + > + FORMATBUFLEN is the length of the buffer in which the floats, ints, & > + chars are formatted. XXX This is a magic number. Each formatting > + routine does bounds checking to ensure no overflow, but a better > + solution may be to malloc a buffer of appropriate size for each > + format. For now, the current solution is sufficient. > + */ > + #define FORMATBUFLEN (size_t)120 > + > PyObject *PyUnicode_Format(PyObject *format, > PyObject *args) > *************** > *** 4506,4513 **** > PyObject *v = NULL; > PyObject *temp = NULL; > ! Py_UNICODE *buf; > Py_UNICODE sign; > int len; > ! Py_UNICODE tmpbuf[120]; /* For format{float,int,char}() */ > > fmt++; > --- 4541,4548 ---- > PyObject *v = NULL; > PyObject *temp = NULL; > ! Py_UNICODE *pbuf; > Py_UNICODE sign; > int len; > ! Py_UNICODE formatbuf[FORMATBUFLEN]; /* For format{float,int,char}() */ > > fmt++; > *************** > *** 4659,4664 **** > > case '%': > ! buf = tmpbuf; > ! buf[0] = '%'; > len = 1; > break; > --- 4694,4700 ---- > > case '%': > ! pbuf = formatbuf; > ! /* presume that buffer length is at least 1 */ > ! pbuf[0] = '%'; > len = 1; > break; > *************** > *** 4696,4700 **** > goto onError; > } > ! buf = PyUnicode_AS_UNICODE(temp); > len = PyUnicode_GET_SIZE(temp); > if (prec >= 0 && len > prec) > --- 4732,4736 ---- > goto onError; > } > ! pbuf = PyUnicode_AS_UNICODE(temp); > len = PyUnicode_GET_SIZE(temp); > if (prec >= 0 && len > prec) > *************** > *** 4710,4715 **** > if (c == 'i') > c = 'd'; > ! buf = tmpbuf; > ! len = formatint(buf, flags, prec, c, v); > if (len < 0) > goto onError; > --- 4746,4752 ---- > if (c == 'i') > c = 'd'; > ! pbuf = formatbuf; > ! len = formatint(pbuf, sizeof(formatbuf)/sizeof(Py_UNICODE), > ! flags, prec, c, v); > if (len < 0) > goto onError; > *************** > *** 4719,4725 **** > if ((flags&F_ALT) && > (c == 'x' || c == 'X') && > ! buf[0] == '0' && buf[1] == c) { > ! *res++ = *buf++; > ! *res++ = *buf++; > rescnt -= 2; > len -= 2; > --- 4756,4762 ---- > if ((flags&F_ALT) && > (c == 'x' || c == 'X') && > ! pbuf[0] == '0' && pbuf[1] == c) { > ! *res++ = *pbuf++; > ! *res++ = *pbuf++; > rescnt -= 2; > len -= 2; > *************** > *** 4736,4741 **** > case 'g': > case 'G': > ! buf = tmpbuf; > ! len = formatfloat(buf, flags, prec, c, v); > if (len < 0) > goto onError; > --- 4773,4779 ---- > case 'g': > case 'G': > ! pbuf = formatbuf; > ! len = formatfloat(pbuf, sizeof(formatbuf)/sizeof(Py_UNICODE), > ! flags, prec, c, v); > if (len < 0) > goto onError; > *************** > *** 4746,4751 **** > > case 'c': > ! buf = tmpbuf; > ! len = formatchar(buf, v); > if (len < 0) > goto onError; > --- 4784,4789 ---- > > case 'c': > ! pbuf = formatbuf; > ! len = formatchar(pbuf, sizeof(formatbuf)/sizeof(Py_UNICODE), v); > if (len < 0) > goto onError; > *************** > *** 4759,4764 **** > } > if (sign) { > ! if (*buf == '-' || *buf == '+') { > ! sign = *buf++; > len--; > } > --- 4797,4802 ---- > } > if (sign) { > ! if (*pbuf == '-' || *pbuf == '+') { > ! sign = *pbuf++; len--; > } > *************** > *** 4796,4800 **** > if (sign && fill == ' ') > *res++ = sign; > ! memcpy(res, buf, len * sizeof(Py_UNICODE)); > res += len; > rescnt -= len; > --- 4834,4838 ---- > if (sign && fill == ' ') > *res++ = sign; > ! memcpy(res, pbuf, len * sizeof(Py_UNICODE)); > res += len; > rescnt -= len; > > -- Sjoerd Mullender From python-dev@python.org Fri Jun 30 15:30:31 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 07:30:31 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild python20.wse,1.2,1.3 Message-ID: <200006301430.HAA10113@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv10092 Modified Files: python20.wse Log Message: Move Wise install dir consistently to C:\Wise. Don't use %_WISE_% in include, it doesn't seem to work. Index: python20.wse =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/python20.wse,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** python20.wse 2000/06/30 14:20:19 1.2 --- python20.wse 2000/06/30 14:30:28 1.3 *************** *** 88,92 **** Direction Variable=DIRECTION Display Variable=DISPLAY ! Bitmap Pathname=C:\Program Files\Wise\DIALOGS\TEMPLATE\WIZARD.BMP X Position=9 Y Position=10 --- 88,92 ---- Direction Variable=DIRECTION Display Variable=DISPLAY ! Bitmap Pathname=C:\Wise\DIALOGS\TEMPLATE\WIZARD.BMP X Position=9 Y Position=10 *************** *** 1049,1053 **** end item: Include Script ! Pathname=%_WISE_%\include\uninstal.wse end item: If/While Statement --- 1049,1053 ---- end item: Include Script ! Pathname=C:\Wise\include\uninstal.wse end item: If/While Statement *************** *** 1151,1155 **** Direction Variable=DIRECTION Display Variable=DISPLAY ! Bitmap Pathname=C:\Program Files\Wise\DIALOGS\TEMPLATE\WIZARD.BMP X Position=9 Y Position=10 --- 1151,1155 ---- Direction Variable=DIRECTION Display Variable=DISPLAY ! Bitmap Pathname=C:\Wise\DIALOGS\TEMPLATE\WIZARD.BMP X Position=9 Y Position=10 From python-dev@python.org Fri Jun 30 15:33:50 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 07:33:50 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild _tkinter.dsp,1.14,1.15 Message-ID: <200006301433.HAA10408@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv10364 Modified Files: _tkinter.dsp Log Message: Change the include etc paths to Tcl 8.3.1. Index: _tkinter.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/_tkinter.dsp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** _tkinter.dsp 2000/04/21 21:26:07 1.14 --- _tkinter.dsp 2000/06/30 14:33:47 1.15 *************** *** 110,114 **** CPP=cl.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 "C:\Program Files\Tcl\include" /I "..\Include" /I "..\PC" /I "..\..\tcl8.2\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "WITH_APPINIT" /YX /FD /c MTL=midl.exe # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 --- 110,114 ---- CPP=cl.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 "..\..\tcl\include" /I "..\Include" /I "..\PC" /I "..\..\tcl8.3\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "WITH_APPINIT" /YX /FD /c MTL=midl.exe # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 *************** *** 122,126 **** 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 ..\..\tcl8.2\lib\tk82.lib ..\..\tcl8.2\lib\tcl82.lib odbc32.lib odbccp32.lib user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /base:"0x1e190000" /subsystem:windows /dll /debug /machine:I386 /out:"./_tkinter_d.pyd" /pdbtype:sept /libpath:"C:\Program Files\Tcl\lib" /export:init_tkinter # SUBTRACT LINK32 /pdb:none --- 122,126 ---- 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 ..\..\tcl\lib\tk83.lib ..\..\tcl\lib\tcl83.lib odbc32.lib odbccp32.lib user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /base:"0x1e190000" /subsystem:windows /dll /debug /machine:I386 /out:"./_tkinter_d.pyd" /pdbtype:sept /libpath:"C:\Program Files\Tcl\lib" /export:init_tkinter # SUBTRACT LINK32 /pdb:none *************** *** 141,145 **** CPP=cl.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 "..\..\tcl\include" /I "..\Include" /I "..\PC" /I "..\..\tcl8.2\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "WITH_APPINIT" /YX /FD /c MTL=midl.exe # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 --- 141,145 ---- CPP=cl.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 "..\..\tcl\include" /I "..\Include" /I "..\PC" /I "..\..\tcl8.3\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "WITH_APPINIT" /YX /FD /c MTL=midl.exe # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 *************** *** 153,157 **** 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 ..\..\tcl8.2\lib\tk82.lib ..\..\tcl8.2\lib\tcl82.lib odbc32.lib odbccp32.lib user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /base:"0x1e190000" /subsystem:windows /dll /debug /machine:I386 /out:"./_tkinter.pyd" /libpath:"C:\Program Files\Tcl\lib" /export:init_tkinter # SUBTRACT LINK32 /pdb:none --- 153,157 ---- 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 ..\..\tcl\lib\tk83.lib ..\..\tcl\lib\tcl83.lib odbc32.lib odbccp32.lib user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /base:"0x1e190000" /subsystem:windows /dll /debug /machine:I386 /out:"./_tkinter.pyd" /libpath:"C:\Program Files\Tcl\lib" /export:init_tkinter # SUBTRACT LINK32 /pdb:none From python-dev@python.org Fri Jun 30 15:38:43 2000 From: python-dev@python.org (Jeremy Hylton) Date: Fri, 30 Jun 2000 07:38:43 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild python20.dsp,1.1,1.2 Message-ID: <200006301438.HAA11138@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv11130 Modified Files: python20.dsp Log Message: add gcmodule Index: python20.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/python20.dsp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** python20.dsp 2000/06/29 22:31:28 1.1 --- python20.dsp 2000/06/30 14:38:41 1.2 *************** *** 660,663 **** --- 660,677 ---- # End Source File # Begin Source File + SOURCE=..\Modules\gcmodule.c + + !IF "$(CFG)" == "python20 - Win32 Release" + + !ELSEIF "$(CFG)" == "python20 - Win32 Debug" + + !ELSEIF "$(CFG)" == "python20 - Win32 Alpha Debug" + + !ELSEIF "$(CFG)" == "python20 - Win32 Alpha Release" + + !ENDIF + + # End Source File + # Begin Source File SOURCE=..\Python\getargs.c From python-dev@python.org Fri Jun 30 15:50:54 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 07:50:54 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild python20.wse,1.3,1.4 Message-ID: <200006301450.HAA12146@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv12135 Modified Files: python20.wse Log Message: Poke and hope for Tcl version: now settable through _TCLMINOR_ variable... Index: python20.wse =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/python20.wse,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** python20.wse 2000/06/30 14:30:28 1.3 --- python20.wse 2000/06/30 14:50:52 1.4 *************** *** 33,36 **** --- 33,40 ---- Variable Default4=C:\src\Python-2.0\html Variable Flags4=00001001 + Variable Name5=_TCLMINOR_ + Variable Description5=Tcl/Tk Minor Version (e.g. the "3" in "8.3.1") + Variable Default5=2 + Variable Flags5=00001000 end remarked item: Open/Close INSTALL.LOG *************** *** 1132,1142 **** end item: Install File ! Source=%_SRC_%\..\tcl8.2\bin\tcl82.dll ! Destination=%MAINDIR%\DLLs\tcl82.dll Flags=0000000000000010 end item: Install File ! Source=%_SRC_%\..\tcl8.2\bin\tk82.dll ! Destination=%MAINDIR%\DLLs\tk82.dll Flags=0000000000000010 end --- 1136,1146 ---- end item: Install File ! Source=%_SRC_%\..\tcl\bin\tcl8%_TCLMINOR_%.dll ! Destination=%MAINDIR%\DLLs\tcl8%_TCLMINOR_%.dll Flags=0000000000000010 end item: Install File ! Source=%_SRC_%\..\tcl\bin\tk8%_TCLMINOR_%.dll ! Destination=%MAINDIR%\DLLs\tk8%_TCLMINOR_%.dll Flags=0000000000000010 end From python-dev@python.org Fri Jun 30 15:53:31 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Fri, 30 Jun 2000 16:53:31 +0200 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.31,2.32 References: <200006301029.DAA25494@slayer.i.sourceforge.net> <20000630142154.968F831047C@bireme.oratrix.nl> Message-ID: <395CB46B.34053D3E@lemburg.com> > Why was the change that occurred in revision 2.31 reverted? Accident? > > The change log said: > Jack Jansen: Use include "" instead of <>; and staticforward declarations Accident... I'll revert that change. -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From python-dev@python.org Fri Jun 30 15:55:29 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 07:55:29 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild python20.wse,1.4,1.5 Message-ID: <200006301455.HAA12420@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv12411 Modified Files: python20.wse Log Message: Oops. - The Tcl minor version should be 3 -- we're now using 8.3.1. - Remove the version number from yet another Tcl source file. Note that Tcl should be installed in C:\src\tcl for this to work. Index: python20.wse =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/python20.wse,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** python20.wse 2000/06/30 14:50:52 1.4 --- python20.wse 2000/06/30 14:55:26 1.5 *************** *** 35,39 **** Variable Name5=_TCLMINOR_ Variable Description5=Tcl/Tk Minor Version (e.g. the "3" in "8.3.1") ! Variable Default5=2 Variable Flags5=00001000 end --- 35,39 ---- Variable Name5=_TCLMINOR_ Variable Description5=Tcl/Tk Minor Version (e.g. the "3" in "8.3.1") ! Variable Default5=3 Variable Flags5=00001000 end *************** *** 1146,1150 **** end item: Install File ! Source=%_SRC_%\..\tcl8.2\lib\*.* Destination=%MAINDIR%\tcl Flags=0000000100000010 --- 1146,1150 ---- end item: Install File ! Source=%_SRC_%\..\tcl\lib\*.* Destination=%MAINDIR%\tcl Flags=0000000100000010 From python-dev@python.org Fri Jun 30 15:58:23 2000 From: python-dev@python.org (M.-A. Lemburg) Date: Fri, 30 Jun 2000 07:58:23 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.32,2.33 Message-ID: <200006301458.HAA12572@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv12549/Objects Modified Files: unicodeobject.c Log Message: Marc-Andre Lemburg : A previous patch by Jack Jansen was accidently reverted. Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.32 retrieving revision 2.33 diff -C2 -r2.32 -r2.33 *** unicodeobject.c 2000/06/30 10:29:57 2.32 --- unicodeobject.c 2000/06/30 14:58:20 2.33 *************** *** 67,71 **** #include "mymath.h" #include "unicodeobject.h" ! #include #if defined(HAVE_LIMITS_H) --- 67,71 ---- #include "mymath.h" #include "unicodeobject.h" ! #include "ucnhash.h" #if defined(HAVE_LIMITS_H) From python-dev@python.org Fri Jun 30 16:01:02 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 08:01:02 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python thread_beos.h,2.2,2.3 thread_cthread.h,2.8,2.9 thread_foobar.h,2.6,2.7 thread_lwp.h,2.7,2.8 thread_nt.h,2.11,2.12 thread_os2.h,2.5,2.6 thread_pth.h,2.1,2.2 thread_pthread.h,2.24,2.25 thread_sgi.h,2.9,2.10 thread_solaris.h,2.10,2.11 thread_wince.h,2.1,2.2 Message-ID: <200006301501.IAA13183@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv13110/Python Modified Files: thread_beos.h thread_cthread.h thread_foobar.h thread_lwp.h thread_nt.h thread_os2.h thread_pth.h thread_pthread.h thread_sgi.h thread_solaris.h thread_wince.h Log Message: Trent Mick : The common technique for printing out a pointer has been to cast to a long and use the "%lx" printf modifier. This is incorrect on Win64 where casting to a long truncates the pointer. The "%p" formatter should be used instead. The problem as stated by Tim: > Unfortunately, the C committee refused to define what %p conversion "looks > like" -- they explicitly allowed it to be implementation-defined. Older > versions of Microsoft C even stuck a colon in the middle of the address (in > the days of segment+offset addressing)! The result is that the hex value of a pointer will maybe/maybe not have a 0x prepended to it. Notes on the patch: There are two main classes of changes: - in the various repr() functions that print out pointers - debugging printf's in the various thread_*.h files (these are why the patch is large) Closes SourceForge patch #100505. Index: thread_beos.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_beos.h,v retrieving revision 2.2 retrieving revision 2.3 diff -C2 -r2.2 -r2.3 *** thread_beos.h 1998/12/21 19:32:29 2.2 --- thread_beos.h 2000/06/30 15:01:00 2.3 *************** *** 263,267 **** } ! dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock)); return (PyThread_type_lock) lock; } --- 263,267 ---- } ! dprintf(("PyThread_allocate_lock() -> %p\n", lock)); return (PyThread_type_lock) lock; } *************** *** 271,275 **** status_t retval; ! dprintf(("PyThread_free_lock(%lx) called\n", (long)lock)); retval = benaphore_destroy( (benaphore_t *)lock ); --- 271,275 ---- status_t retval; ! dprintf(("PyThread_free_lock(%p) called\n", lock)); retval = benaphore_destroy( (benaphore_t *)lock ); *************** *** 285,289 **** status_t retval; ! dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag)); if( waitflag ) { --- 285,289 ---- status_t retval; ! dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag)); if( waitflag ) { *************** *** 301,305 **** } ! dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success)); return success; } --- 301,305 ---- } ! dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success)); return success; } *************** *** 309,313 **** status_t retval; ! dprintf(("PyThread_release_lock(%lx) called\n", (long)lock)); retval = benaphore_unlock( (benaphore_t *)lock ); --- 309,313 ---- status_t retval; ! dprintf(("PyThread_release_lock(%p) called\n", lock)); retval = benaphore_unlock( (benaphore_t *)lock ); *************** *** 337,341 **** } ! dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema)); return (PyThread_type_sema) sema; } --- 337,341 ---- } ! dprintf(("PyThread_allocate_sema() -> %p\n", sema)); return (PyThread_type_sema) sema; } *************** *** 345,349 **** status_t retval; ! dprintf(("PyThread_free_sema(%lx) called\n", (long) sema)); retval = delete_sem( (sem_id)sema ); --- 345,349 ---- status_t retval; ! dprintf(("PyThread_free_sema(%p) called\n", sema)); retval = delete_sem( (sem_id)sema ); *************** *** 358,362 **** status_t retval; ! dprintf(("PyThread_down_sema(%lx, %d) called\n", (long) sema, waitflag)); if( waitflag ) { --- 358,362 ---- status_t retval; ! dprintf(("PyThread_down_sema(%p, %d) called\n", sema, waitflag)); if( waitflag ) { *************** *** 371,375 **** } ! dprintf(("PyThread_down_sema(%lx) return\n", (long) sema)); return -1; } --- 371,375 ---- } ! dprintf(("PyThread_down_sema(%p) return\n", sema)); return -1; } *************** *** 379,383 **** status_t retval; ! dprintf(("PyThread_up_sema(%lx)\n", (long) sema)); retval = release_sem( (sem_id)sema ); --- 379,383 ---- status_t retval; ! dprintf(("PyThread_up_sema(%p)\n", sema)); retval = release_sem( (sem_id)sema ); Index: thread_cthread.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_cthread.h,v retrieving revision 2.8 retrieving revision 2.9 diff -C2 -r2.8 -r2.9 *** thread_cthread.h 1998/12/21 19:32:30 2.8 --- thread_cthread.h 2000/06/30 15:01:00 2.9 *************** *** 130,134 **** lock = 0; } ! dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock)); return (PyThread_type_lock) lock; } --- 130,134 ---- lock = 0; } ! dprintf(("PyThread_allocate_lock() -> %p\n", lock)); return (PyThread_type_lock) lock; } *************** *** 136,140 **** void PyThread_free_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_free_lock(%lx) called\n", (long)lock)); mutex_free(lock); } --- 136,140 ---- void PyThread_free_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_free_lock(%p) called\n", lock)); mutex_free(lock); } *************** *** 144,148 **** int success = FALSE; ! dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag)); if (waitflag) { /* blocking */ mutex_lock(lock); --- 144,148 ---- int success = FALSE; ! dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag)); if (waitflag) { /* blocking */ mutex_lock(lock); *************** *** 151,155 **** success = mutex_try_lock(lock); } ! dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success)); return success; } --- 151,155 ---- success = mutex_try_lock(lock); } ! dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success)); return success; } *************** *** 157,161 **** void PyThread_release_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_release_lock(%lx) called\n", (long)lock)); mutex_unlock((mutex_t )lock); } --- 157,161 ---- void PyThread_release_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_release_lock(%p) called\n", lock)); mutex_unlock((mutex_t )lock); } *************** *** 182,186 **** PyThread_init_thread(); ! dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema)); return (PyThread_type_sema) sema; } --- 182,186 ---- PyThread_init_thread(); ! dprintf(("PyThread_allocate_sema() -> %p\n", sema)); return (PyThread_type_sema) sema; } *************** *** 188,198 **** void PyThread_free_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_free_sema(%lx) called\n", (long) sema)); } int PyThread_down_sema _P2(sema, PyThread_type_sema sema, waitflag, int waitflag) { ! dprintf(("PyThread_down_sema(%lx, %d) called\n", (long) sema, waitflag)); ! dprintf(("PyThread_down_sema(%lx) return\n", (long) sema)); return -1; } --- 188,198 ---- void PyThread_free_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_free_sema(%p) called\n", sema)); } int PyThread_down_sema _P2(sema, PyThread_type_sema sema, waitflag, int waitflag) { ! dprintf(("PyThread_down_sema(%p, %d) called\n", sema, waitflag)); ! dprintf(("PyThread_down_sema(%p) return\n", sema)); return -1; } *************** *** 200,203 **** void PyThread_up_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_up_sema(%lx)\n", (long) sema)); } --- 200,203 ---- void PyThread_up_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_up_sema(%p)\n", sema)); } Index: thread_foobar.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_foobar.h,v retrieving revision 2.6 retrieving revision 2.7 diff -C2 -r2.6 -r2.7 *** thread_foobar.h 1998/12/21 19:32:30 2.6 --- thread_foobar.h 2000/06/30 15:01:00 2.7 *************** *** 109,113 **** PyThread_init_thread(); ! dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock)); return (PyThread_type_lock) lock; } --- 109,113 ---- PyThread_init_thread(); ! dprintf(("PyThread_allocate_lock() -> %p\n", lock)); return (PyThread_type_lock) lock; } *************** *** 115,119 **** void PyThread_free_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_free_lock(%lx) called\n", (long)lock)); } --- 115,119 ---- void PyThread_free_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_free_lock(%p) called\n", lock)); } *************** *** 122,127 **** int success; ! dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag)); ! dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success)); return success; } --- 122,127 ---- int success; ! dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag)); ! dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success)); return success; } *************** *** 129,133 **** void PyThread_release_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_release_lock(%lx) called\n", (long)lock)); } --- 129,133 ---- void PyThread_release_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_release_lock(%p) called\n", lock)); } *************** *** 141,145 **** PyThread_init_thread(); ! dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema)); return (PyThread_type_sema) sema; } --- 141,145 ---- PyThread_init_thread(); ! dprintf(("PyThread_allocate_sema() -> %p\n", sema)); return (PyThread_type_sema) sema; } *************** *** 147,157 **** void PyThread_free_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_free_sema(%lx) called\n", (long) sema)); } int PyThread_down_sema _P2(sema, PyThread_type_sema sema, waitflag, int waitflag) { ! dprintf(("PyThread_down_sema(%lx, %d) called\n", (long) sema, waitflag)); ! dprintf(("PyThread_down_sema(%lx) return\n", (long) sema)); return -1; } --- 147,157 ---- void PyThread_free_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_free_sema(%p) called\n", sema)); } int PyThread_down_sema _P2(sema, PyThread_type_sema sema, waitflag, int waitflag) { ! dprintf(("PyThread_down_sema(%p, %d) called\n", sema, waitflag)); ! dprintf(("PyThread_down_sema(%p) return\n", sema)); return -1; } *************** *** 159,162 **** void PyThread_up_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_up_sema(%lx)\n", (long) sema)); } --- 159,162 ---- void PyThread_up_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_up_sema(%p)\n", sema)); } Index: thread_lwp.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_lwp.h,v retrieving revision 2.7 retrieving revision 2.8 diff -C2 -r2.7 -r2.8 *** thread_lwp.h 1998/12/21 19:32:31 2.7 --- thread_lwp.h 2000/06/30 15:01:00 2.8 *************** *** 138,142 **** (void) mon_create(&lock->lock_monitor); (void) cv_create(&lock->lock_condvar, lock->lock_monitor); ! dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock)); return (PyThread_type_lock) lock; } --- 138,142 ---- (void) mon_create(&lock->lock_monitor); (void) cv_create(&lock->lock_condvar, lock->lock_monitor); ! dprintf(("PyThread_allocate_lock() -> %p\n", lock)); return (PyThread_type_lock) lock; } *************** *** 144,148 **** void PyThread_free_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_free_lock(%lx) called\n", (long)lock)); mon_destroy(((struct lock *) lock)->lock_monitor); free((char *) lock); --- 144,148 ---- void PyThread_free_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_free_lock(%p) called\n", lock)); mon_destroy(((struct lock *) lock)->lock_monitor); free((char *) lock); *************** *** 153,157 **** int success; ! dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag)); success = 0; --- 153,157 ---- int success; ! dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag)); success = 0; *************** *** 166,170 **** cv_broadcast(((struct lock *) lock)->lock_condvar); mon_exit(((struct lock *) lock)->lock_monitor); ! dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success)); return success; } --- 166,170 ---- cv_broadcast(((struct lock *) lock)->lock_condvar); mon_exit(((struct lock *) lock)->lock_monitor); ! dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success)); return success; } *************** *** 172,176 **** void PyThread_release_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_release_lock(%lx) called\n", (long)lock)); (void) mon_enter(((struct lock *) lock)->lock_monitor); ((struct lock *) lock)->lock_locked = 0; --- 172,176 ---- void PyThread_release_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_release_lock(%p) called\n", lock)); (void) mon_enter(((struct lock *) lock)->lock_monitor); ((struct lock *) lock)->lock_locked = 0; *************** *** 189,193 **** PyThread_init_thread(); ! dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema)); return (PyThread_type_sema) sema; } --- 189,193 ---- PyThread_init_thread(); ! dprintf(("PyThread_allocate_sema() -> %p\n", sema)); return (PyThread_type_sema) sema; } *************** *** 195,205 **** void PyThread_free_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_free_sema(%lx) called\n", (long) sema)); } int PyThread_down_sema _P2(sema, PyThread_type_sema sema, waitflag, int waitflag) { ! dprintf(("PyThread_down_sema(%lx, %d) called\n", (long) sema, waitflag)); ! dprintf(("PyThread_down_sema(%lx) return\n", (long) sema)); return -1; } --- 195,205 ---- void PyThread_free_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_free_sema(%p) called\n", sema)); } int PyThread_down_sema _P2(sema, PyThread_type_sema sema, waitflag, int waitflag) { ! dprintf(("PyThread_down_sema(%p, %d) called\n", sema, waitflag)); ! dprintf(("PyThread_down_sema(%p) return\n", sema)); return -1; } *************** *** 207,210 **** void PyThread_up_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_up_sema(%lx)\n", (long) sema)); } --- 207,210 ---- void PyThread_up_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_up_sema(%p)\n", sema)); } Index: thread_nt.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_nt.h,v retrieving revision 2.11 retrieving revision 2.12 diff -C2 -r2.11 -r2.12 *** thread_nt.h 2000/06/29 17:25:30 2.11 --- thread_nt.h 2000/06/30 15:01:00 2.12 *************** *** 274,278 **** aLock = AllocNonRecursiveMutex() ; ! dprintf(("%ld: PyThread_allocate_lock() -> %lx\n", PyThread_get_thread_ident(), (long)aLock)); return (PyThread_type_lock) aLock; --- 274,278 ---- aLock = AllocNonRecursiveMutex() ; ! dprintf(("%ld: PyThread_allocate_lock() -> %p\n", PyThread_get_thread_ident(), aLock)); return (PyThread_type_lock) aLock; *************** *** 281,285 **** void PyThread_free_lock(PyThread_type_lock aLock) { ! dprintf(("%ld: PyThread_free_lock(%lx) called\n", PyThread_get_thread_ident(),(long)aLock)); FreeNonRecursiveMutex(aLock) ; --- 281,285 ---- void PyThread_free_lock(PyThread_type_lock aLock) { ! dprintf(("%ld: PyThread_free_lock(%p) called\n", PyThread_get_thread_ident(),aLock)); FreeNonRecursiveMutex(aLock) ; *************** *** 296,304 **** int success ; ! dprintf(("%ld: PyThread_acquire_lock(%lx, %d) called\n", PyThread_get_thread_ident(),(long)aLock, waitflag)); success = aLock && EnterNonRecursiveMutex((PNRMUTEX) aLock, (waitflag == 1 ? INFINITE : 0)) == WAIT_OBJECT_0 ; ! dprintf(("%ld: PyThread_acquire_lock(%lx, %d) -> %d\n", PyThread_get_thread_ident(),(long)aLock, waitflag, success)); return success; --- 296,304 ---- int success ; ! dprintf(("%ld: PyThread_acquire_lock(%p, %d) called\n", PyThread_get_thread_ident(),aLock, waitflag)); success = aLock && EnterNonRecursiveMutex((PNRMUTEX) aLock, (waitflag == 1 ? INFINITE : 0)) == WAIT_OBJECT_0 ; ! dprintf(("%ld: PyThread_acquire_lock(%p, %d) -> %d\n", PyThread_get_thread_ident(),aLock, waitflag, success)); return success; *************** *** 307,314 **** void PyThread_release_lock(PyThread_type_lock aLock) { ! dprintf(("%ld: PyThread_release_lock(%lx) called\n", PyThread_get_thread_ident(),(long)aLock)); if (!(aLock && LeaveNonRecursiveMutex((PNRMUTEX) aLock))) ! dprintf(("%ld: Could not PyThread_release_lock(%lx) error: %l\n", PyThread_get_thread_ident(), (long)aLock, GetLastError())); } --- 307,314 ---- void PyThread_release_lock(PyThread_type_lock aLock) { ! dprintf(("%ld: PyThread_release_lock(%p) called\n", PyThread_get_thread_ident(),aLock)); if (!(aLock && LeaveNonRecursiveMutex((PNRMUTEX) aLock))) ! dprintf(("%ld: Could not PyThread_release_lock(%p) error: %l\n", PyThread_get_thread_ident(), aLock, GetLastError())); } *************** *** 329,333 **** NULL); /* Name of semaphore */ ! dprintf(("%ld: PyThread_allocate_sema() -> %lx\n", PyThread_get_thread_ident(), (long)aSemaphore)); return (PyThread_type_sema) aSemaphore; --- 329,333 ---- NULL); /* Name of semaphore */ ! dprintf(("%ld: PyThread_allocate_sema() -> %p\n", PyThread_get_thread_ident(), aSemaphore)); return (PyThread_type_sema) aSemaphore; *************** *** 336,340 **** void PyThread_free_sema(PyThread_type_sema aSemaphore) { ! dprintf(("%ld: PyThread_free_sema(%lx) called\n", PyThread_get_thread_ident(), (long)aSemaphore)); CloseHandle((HANDLE) aSemaphore); --- 336,340 ---- void PyThread_free_sema(PyThread_type_sema aSemaphore) { ! dprintf(("%ld: PyThread_free_sema(%p) called\n", PyThread_get_thread_ident(), aSemaphore)); CloseHandle((HANDLE) aSemaphore); *************** *** 348,356 **** DWORD waitResult; ! dprintf(("%ld: PyThread_down_sema(%lx) called\n", PyThread_get_thread_ident(), (long)aSemaphore)); waitResult = WaitForSingleObject( (HANDLE) aSemaphore, INFINITE); ! dprintf(("%ld: PyThread_down_sema(%lx) return: %l\n", PyThread_get_thread_ident(),(long) aSemaphore, waitResult)); return 0; } --- 348,356 ---- DWORD waitResult; ! dprintf(("%ld: PyThread_down_sema(%p) called\n", PyThread_get_thread_ident(), aSemaphore)); waitResult = WaitForSingleObject( (HANDLE) aSemaphore, INFINITE); ! dprintf(("%ld: PyThread_down_sema(%p) return: %l\n", PyThread_get_thread_ident(), aSemaphore, waitResult)); return 0; } *************** *** 363,366 **** NULL); /* not interested in previous count */ ! dprintf(("%ld: PyThread_up_sema(%lx)\n", PyThread_get_thread_ident(), (long)aSemaphore)); } --- 363,366 ---- NULL); /* not interested in previous count */ ! dprintf(("%ld: PyThread_up_sema(%p)\n", PyThread_get_thread_ident(), aSemaphore)); } Index: thread_os2.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_os2.h,v retrieving revision 2.5 retrieving revision 2.6 diff -C2 -r2.5 -r2.6 *** thread_os2.h 1998/12/21 19:32:33 2.5 --- thread_os2.h 2000/06/30 15:01:00 2.6 *************** *** 142,146 **** 0); /* initial state */ ! dprintf(("%ld: PyThread_allocate_lock() -> %lx\n", PyThread_get_thread_ident(), (long)aLock)); return (PyThread_type_lock) aLock; --- 142,146 ---- 0); /* initial state */ ! dprintf(("%ld: PyThread_allocate_lock() -> %p\n", PyThread_get_thread_ident(), aLock)); return (PyThread_type_lock) aLock; *************** *** 149,153 **** void PyThread_free_lock(PyThread_type_lock aLock) { ! dprintf(("%ld: PyThread_free_lock(%lx) called\n", PyThread_get_thread_ident(),(long)aLock)); DosCloseMutexSem((HMTX)aLock); --- 149,153 ---- void PyThread_free_lock(PyThread_type_lock aLock) { ! dprintf(("%ld: PyThread_free_lock(%p) called\n", PyThread_get_thread_ident(),aLock)); DosCloseMutexSem((HMTX)aLock); *************** *** 167,172 **** TID tid = 0; ! dprintf(("%ld: PyThread_acquire_lock(%lx, %d) called\n", PyThread_get_thread_ident(), ! (long)aLock, waitflag)); DosQueryMutexSem((HMTX)aLock,&pid,&tid,&count); --- 167,172 ---- TID tid = 0; ! dprintf(("%ld: PyThread_acquire_lock(%p, %d) called\n", PyThread_get_thread_ident(), ! aLock, waitflag)); DosQueryMutexSem((HMTX)aLock,&pid,&tid,&count); *************** *** 182,187 **** } ! dprintf(("%ld: PyThread_acquire_lock(%lx, %d) -> %d\n", ! PyThread_get_thread_ident(),(long)aLock, waitflag, success)); return success; --- 182,187 ---- } ! dprintf(("%ld: PyThread_acquire_lock(%p, %d) -> %d\n", ! PyThread_get_thread_ident(),aLock, waitflag, success)); return success; *************** *** 190,198 **** void PyThread_release_lock(PyThread_type_lock aLock) { ! dprintf(("%ld: PyThread_release_lock(%lx) called\n", PyThread_get_thread_ident(),(long)aLock)); if ( DosReleaseMutexSem( (HMTX) aLock ) != 0 ) { ! dprintf(("%ld: Could not PyThread_release_lock(%lx) error: %l\n", ! PyThread_get_thread_ident(), (long)aLock, GetLastError())); } } --- 190,198 ---- void PyThread_release_lock(PyThread_type_lock aLock) { ! dprintf(("%ld: PyThread_release_lock(%p) called\n", PyThread_get_thread_ident(),aLock)); if ( DosReleaseMutexSem( (HMTX) aLock ) != 0 ) { ! dprintf(("%ld: Could not PyThread_release_lock(%p) error: %l\n", ! PyThread_get_thread_ident(), aLock, GetLastError())); } } *************** *** 218,221 **** void PyThread_up_sema(PyThread_type_sema aSemaphore) { ! dprintf(("%ld: PyThread_up_sema(%lx)\n", PyThread_get_thread_ident(), (long)aSemaphore)); } --- 218,221 ---- void PyThread_up_sema(PyThread_type_sema aSemaphore) { ! dprintf(("%ld: PyThread_up_sema(%p)\n", PyThread_get_thread_ident(), aSemaphore)); } Index: thread_pth.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_pth.h,v retrieving revision 2.1 retrieving revision 2.2 diff -C2 -r2.1 -r2.2 *** thread_pth.h 2000/05/08 13:36:49 2.1 --- thread_pth.h 2000/06/30 15:01:00 2.2 *************** *** 169,173 **** } } ! dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock)); return (PyThread_type_lock) lock; } --- 169,173 ---- } } ! dprintf(("PyThread_allocate_lock() -> %p\n", lock)); return (PyThread_type_lock) lock; } *************** *** 178,182 **** int status, error = 0; ! dprintf(("PyThread_free_lock(%lx) called\n", (long)lock)); free((void *)thelock); --- 178,182 ---- int status, error = 0; ! dprintf(("PyThread_free_lock(%p) called\n", lock)); free((void *)thelock); *************** *** 189,193 **** int status, error = 0; ! dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag)); status = pth_mutex_acquire(&thelock->mut, !waitflag, NULL); --- 189,193 ---- int status, error = 0; ! dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag)); status = pth_mutex_acquire(&thelock->mut, !waitflag, NULL); *************** *** 216,220 **** } if (error) success = 0; ! dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success)); return success; } --- 216,220 ---- } if (error) success = 0; ! dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success)); return success; } *************** *** 225,229 **** int status, error = 0; ! dprintf(("PyThread_release_lock(%lx) called\n", (long)lock)); status = pth_mutex_acquire( &thelock->mut, 0, NULL ); --- 225,229 ---- int status, error = 0; ! dprintf(("PyThread_release_lock(%p) called\n", lock)); status = pth_mutex_acquire( &thelock->mut, 0, NULL ); *************** *** 271,275 **** } } ! dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema)); return (PyThread_type_sema) sema; } --- 271,275 ---- } } ! dprintf(("PyThread_allocate_sema() -> %p\n", sema)); return (PyThread_type_sema) sema; } *************** *** 280,284 **** struct semaphore *thesema = (struct semaphore *) sema; ! dprintf(("PyThread_free_sema(%lx) called\n", (long) sema)); free((void *) thesema); } --- 280,284 ---- struct semaphore *thesema = (struct semaphore *) sema; ! dprintf(("PyThread_free_sema(%p) called\n", sema)); free((void *) thesema); } *************** *** 289,293 **** struct semaphore *thesema = (struct semaphore *) sema; ! dprintf(("PyThread_down_sema(%lx, %d) called\n", (long) sema, waitflag)); status = pth_mutex_acquire(&thesema->mutex, !waitflag, NULL); CHECK_STATUS("pth_mutex_acquire"); --- 289,293 ---- struct semaphore *thesema = (struct semaphore *) sema; ! dprintf(("PyThread_down_sema(%p, %d) called\n", sema, waitflag)); status = pth_mutex_acquire(&thesema->mutex, !waitflag, NULL); CHECK_STATUS("pth_mutex_acquire"); *************** *** 309,313 **** status = pth_mutex_release(&thesema->mutex); CHECK_STATUS("pth_mutex_release"); ! dprintf(("PyThread_down_sema(%lx) return\n", (long) sema)); return success; } --- 309,313 ---- status = pth_mutex_release(&thesema->mutex); CHECK_STATUS("pth_mutex_release"); ! dprintf(("PyThread_down_sema(%p) return\n", sema)); return success; } *************** *** 318,322 **** struct semaphore *thesema = (struct semaphore *) sema; ! dprintf(("PyThread_up_sema(%lx)\n", (long) sema)); status = pth_mutex_acquire(&thesema->mutex, 0, NULL); CHECK_STATUS("pth_mutex_acquire"); --- 318,322 ---- struct semaphore *thesema = (struct semaphore *) sema; ! dprintf(("PyThread_up_sema(%p)\n", sema)); status = pth_mutex_acquire(&thesema->mutex, 0, NULL); CHECK_STATUS("pth_mutex_acquire"); Index: thread_pthread.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_pthread.h,v retrieving revision 2.24 retrieving revision 2.25 diff -C2 -r2.24 -r2.25 *** thread_pthread.h 1999/03/15 20:27:53 2.24 --- thread_pthread.h 2000/06/30 15:01:00 2.25 *************** *** 273,277 **** } ! dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock)); return (PyThread_type_lock) lock; } --- 273,277 ---- } ! dprintf(("PyThread_allocate_lock() -> %p\n", lock)); return (PyThread_type_lock) lock; } *************** *** 282,286 **** int status, error = 0; ! dprintf(("PyThread_free_lock(%lx) called\n", (long)lock)); status = pthread_mutex_destroy( &thelock->mut ); --- 282,286 ---- int status, error = 0; ! dprintf(("PyThread_free_lock(%p) called\n", lock)); status = pthread_mutex_destroy( &thelock->mut ); *************** *** 299,303 **** int status, error = 0; ! dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag)); status = pthread_mutex_lock( &thelock->mut ); --- 299,303 ---- int status, error = 0; ! dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag)); status = pthread_mutex_lock( &thelock->mut ); *************** *** 326,330 **** } if (error) success = 0; ! dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success)); return success; } --- 326,330 ---- } if (error) success = 0; ! dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success)); return success; } *************** *** 335,339 **** int status, error = 0; ! dprintf(("PyThread_release_lock(%lx) called\n", (long)lock)); status = pthread_mutex_lock( &thelock->mut ); --- 335,339 ---- int status, error = 0; ! dprintf(("PyThread_release_lock(%p) called\n", lock)); status = pthread_mutex_lock( &thelock->mut ); *************** *** 383,387 **** } } ! dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema)); return (PyThread_type_sema) sema; } --- 383,387 ---- } } ! dprintf(("PyThread_allocate_sema() -> %p\n", sema)); return (PyThread_type_sema) sema; } *************** *** 392,396 **** struct semaphore *thesema = (struct semaphore *) sema; ! dprintf(("PyThread_free_sema(%lx) called\n", (long) sema)); status = pthread_cond_destroy(&thesema->cond); CHECK_STATUS("pthread_cond_destroy"); --- 392,396 ---- struct semaphore *thesema = (struct semaphore *) sema; ! dprintf(("PyThread_free_sema(%p) called\n", sema)); status = pthread_cond_destroy(&thesema->cond); CHECK_STATUS("pthread_cond_destroy"); *************** *** 405,409 **** struct semaphore *thesema = (struct semaphore *) sema; ! dprintf(("PyThread_down_sema(%lx, %d) called\n", (long) sema, waitflag)); status = pthread_mutex_lock(&thesema->mutex); CHECK_STATUS("pthread_mutex_lock"); --- 405,409 ---- struct semaphore *thesema = (struct semaphore *) sema; ! dprintf(("PyThread_down_sema(%p, %d) called\n", sema, waitflag)); status = pthread_mutex_lock(&thesema->mutex); CHECK_STATUS("pthread_mutex_lock"); *************** *** 425,429 **** status = pthread_mutex_unlock(&thesema->mutex); CHECK_STATUS("pthread_mutex_unlock"); ! dprintf(("PyThread_down_sema(%lx) return\n", (long) sema)); return success; } --- 425,429 ---- status = pthread_mutex_unlock(&thesema->mutex); CHECK_STATUS("pthread_mutex_unlock"); ! dprintf(("PyThread_down_sema(%p) return\n", sema)); return success; } *************** *** 434,438 **** struct semaphore *thesema = (struct semaphore *) sema; ! dprintf(("PyThread_up_sema(%lx)\n", (long) sema)); status = pthread_mutex_lock(&thesema->mutex); CHECK_STATUS("pthread_mutex_lock"); --- 434,438 ---- struct semaphore *thesema = (struct semaphore *) sema; ! dprintf(("PyThread_up_sema(%p)\n", sema)); status = pthread_mutex_lock(&thesema->mutex); CHECK_STATUS("pthread_mutex_lock"); Index: thread_sgi.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_sgi.h,v retrieving revision 2.9 retrieving revision 2.10 diff -C2 -r2.9 -r2.10 *** thread_sgi.h 1998/12/21 19:32:34 2.9 --- thread_sgi.h 2000/06/30 15:01:00 2.10 *************** *** 120,124 **** perror("usconfig - CONF_INITSIZE (reset)"); addr = (long) dl_getrange(size + HDR_SIZE); ! dprintf(("trying to use addr %lx-%lx for shared arena\n", addr, addr+size)); errno = 0; if ((addr = usconfig(CONF_ATTACHADDR, addr)) < 0 && errno != 0) --- 120,124 ---- perror("usconfig - CONF_INITSIZE (reset)"); addr = (long) dl_getrange(size + HDR_SIZE); ! dprintf(("trying to use addr %p-%p for shared arena\n", addr, addr+size)); errno = 0; if ((addr = usconfig(CONF_ATTACHADDR, addr)) < 0 && errno != 0) *************** *** 158,162 **** if ((wait_lock = usnewlock(shared_arena)) == NULL) perror("usnewlock (wait_lock)"); ! dprintf(("arena start: %lx, arena size: %ld\n", (long) shared_arena, (long) usconfig(CONF_GETSIZE, shared_arena))); } --- 158,162 ---- if ((wait_lock = usnewlock(shared_arena)) == NULL) perror("usnewlock (wait_lock)"); ! dprintf(("arena start: %p, arena size: %ld\n", shared_arena, (long) usconfig(CONF_GETSIZE, shared_arena))); } *************** *** 225,229 **** perror("usconfig - CONF_INITSIZE (reset)"); addr = (long) dl_getrange(size + HDR_SIZE); ! dprintf(("trying to use addr %lx-%lx for sproc\n", addr, addr+size)); errno = 0; --- 225,229 ---- perror("usconfig - CONF_INITSIZE (reset)"); addr = (long) dl_getrange(size + HDR_SIZE); ! dprintf(("trying to use addr %p-%p for sproc\n", addr, addr+size)); errno = 0; *************** *** 376,380 **** perror("usnewlock"); (void) usinitlock(lock); ! dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock)); return (PyThread_type_lock) lock; } --- 376,380 ---- perror("usnewlock"); (void) usinitlock(lock); ! dprintf(("PyThread_allocate_lock() -> %p\n", lock)); return (PyThread_type_lock) lock; } *************** *** 382,386 **** void PyThread_free_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_free_lock(%lx) called\n", (long)lock)); usfreelock((ulock_t) lock, shared_arena); } --- 382,386 ---- void PyThread_free_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_free_lock(%p) called\n", lock)); usfreelock((ulock_t) lock, shared_arena); } *************** *** 390,394 **** int success; ! dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag)); errno = 0; /* clear it just in case */ if (waitflag) --- 390,394 ---- int success; ! dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag)); errno = 0; /* clear it just in case */ if (waitflag) *************** *** 398,402 **** if (success < 0) perror(waitflag ? "ussetlock" : "uscsetlock"); ! dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success)); return success; } --- 398,402 ---- if (success < 0) perror(waitflag ? "ussetlock" : "uscsetlock"); ! dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success)); return success; } *************** *** 404,408 **** void PyThread_release_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_release_lock(%lx) called\n", (long)lock)); if (usunsetlock((ulock_t) lock) < 0) perror("usunsetlock"); --- 404,408 ---- void PyThread_release_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_release_lock(%p) called\n", lock)); if (usunsetlock((ulock_t) lock) < 0) perror("usunsetlock"); *************** *** 421,425 **** if ((sema = usnewsema(shared_arena, value)) == NULL) perror("usnewsema"); ! dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema)); return (PyThread_type_sema) sema; } --- 421,425 ---- if ((sema = usnewsema(shared_arena, value)) == NULL) perror("usnewsema"); ! dprintf(("PyThread_allocate_sema() -> %p\n", sema)); return (PyThread_type_sema) sema; } *************** *** 427,431 **** void PyThread_free_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_free_sema(%lx) called\n", (long) sema)); usfreesema((usema_t *) sema, shared_arena); } --- 427,431 ---- void PyThread_free_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_free_sema(%p) called\n", sema)); usfreesema((usema_t *) sema, shared_arena); } *************** *** 435,439 **** int success; ! dprintf(("PyThread_down_sema(%lx) called\n", (long) sema)); if (waitflag) success = uspsema((usema_t *) sema); --- 435,439 ---- int success; ! dprintf(("PyThread_down_sema(%p) called\n", sema)); if (waitflag) success = uspsema((usema_t *) sema); *************** *** 442,446 **** if (success < 0) perror(waitflag ? "uspsema" : "uscpsema"); ! dprintf(("PyThread_down_sema(%lx) return\n", (long) sema)); return success; } --- 442,446 ---- if (success < 0) perror(waitflag ? "uspsema" : "uscpsema"); ! dprintf(("PyThread_down_sema(%p) return\n", sema)); return success; } *************** *** 448,452 **** void PyThread_up_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_up_sema(%lx)\n", (long) sema)); if (usvsema((usema_t *) sema) < 0) perror("usvsema"); --- 448,452 ---- void PyThread_up_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_up_sema(%p)\n", sema)); if (usvsema((usema_t *) sema) < 0) perror("usvsema"); Index: thread_solaris.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_solaris.h,v retrieving revision 2.10 retrieving revision 2.11 diff -C2 -r2.10 -r2.11 *** thread_solaris.h 1999/04/13 14:32:12 2.10 --- thread_solaris.h 2000/06/30 15:01:00 2.11 *************** *** 158,162 **** lock = 0; } ! dprintf(("PyThread_allocate_lock() -> %lx\n", (long)lock)); return (PyThread_type_lock) lock; } --- 158,162 ---- lock = 0; } ! dprintf(("PyThread_allocate_lock() -> %p\n", lock)); return (PyThread_type_lock) lock; } *************** *** 164,168 **** void PyThread_free_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_free_lock(%lx) called\n", (long)lock)); mutex_destroy((mutex_t *) lock); free((void *) lock); --- 164,168 ---- void PyThread_free_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_free_lock(%p) called\n", lock)); mutex_destroy((mutex_t *) lock); free((void *) lock); *************** *** 173,177 **** int success; ! dprintf(("PyThread_acquire_lock(%lx, %d) called\n", (long)lock, waitflag)); if (waitflag) success = mutex_lock((mutex_t *) lock); --- 173,177 ---- int success; ! dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag)); if (waitflag) success = mutex_lock((mutex_t *) lock); *************** *** 182,186 **** else success = !success; /* solaris does it the other way round */ ! dprintf(("PyThread_acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success)); return success; } --- 182,186 ---- else success = !success; /* solaris does it the other way round */ ! dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success)); return success; } *************** *** 188,192 **** void PyThread_release_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_release_lock(%lx) called\n", (long)lock)); if (mutex_unlock((mutex_t *) lock)) perror("mutex_unlock"); --- 188,192 ---- void PyThread_release_lock _P1(lock, PyThread_type_lock lock) { ! dprintf(("PyThread_release_lock(%p) called\n", lock)); if (mutex_unlock((mutex_t *) lock)) perror("mutex_unlock"); *************** *** 209,213 **** sema = 0; } ! dprintf(("PyThread_allocate_sema() -> %lx\n", (long) sema)); return (PyThread_type_sema) sema; } --- 209,213 ---- sema = 0; } ! dprintf(("PyThread_allocate_sema() -> %p\n", sema)); return (PyThread_type_sema) sema; } *************** *** 215,219 **** void PyThread_free_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_free_sema(%lx) called\n", (long) sema)); if (sema_destroy((sema_t *) sema)) perror("sema_destroy"); --- 215,219 ---- void PyThread_free_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_free_sema(%p) called\n", sema)); if (sema_destroy((sema_t *) sema)) perror("sema_destroy"); *************** *** 225,229 **** int success; ! dprintf(("PyThread_down_sema(%lx) called\n", (long) sema)); if (waitflag) success = sema_wait((sema_t *) sema); --- 225,229 ---- int success; ! dprintf(("PyThread_down_sema(%p) called\n", sema)); if (waitflag) success = sema_wait((sema_t *) sema); *************** *** 238,242 **** else success = !success; ! dprintf(("PyThread_down_sema(%lx) return %d\n", (long) sema, success)); return success; } --- 238,242 ---- else success = !success; ! dprintf(("PyThread_down_sema(%p) return %d\n", sema, success)); return success; } *************** *** 244,248 **** void PyThread_up_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_up_sema(%lx)\n", (long) sema)); if (sema_post((sema_t *) sema)) perror("sema_post"); --- 244,248 ---- void PyThread_up_sema _P1(sema, PyThread_type_sema sema) { ! dprintf(("PyThread_up_sema(%p)\n", sema)); if (sema_post((sema_t *) sema)) perror("sema_post"); Index: thread_wince.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_wince.h,v retrieving revision 2.1 retrieving revision 2.2 diff -C2 -r2.1 -r2.2 *** thread_wince.h 1999/04/08 13:57:06 2.1 --- thread_wince.h 2000/06/30 15:01:00 2.2 *************** *** 145,149 **** NULL); /* Name of event */ ! dprintf(("%ld: PyThread_allocate_lock() -> %lx\n", PyThread_get_thread_ident(), (long)aLock)); return (PyThread_type_lock) aLock; --- 145,149 ---- NULL); /* Name of event */ ! dprintf(("%ld: PyThread_allocate_lock() -> %p\n", PyThread_get_thread_ident(), aLock)); return (PyThread_type_lock) aLock; *************** *** 152,156 **** void PyThread_free_lock(PyThread_type_lock aLock) { ! dprintf(("%ld: PyThread_free_lock(%lx) called\n", PyThread_get_thread_ident(),(long)aLock)); CloseHandle(aLock); --- 152,156 ---- void PyThread_free_lock(PyThread_type_lock aLock) { ! dprintf(("%ld: PyThread_free_lock(%p) called\n", PyThread_get_thread_ident(),aLock)); CloseHandle(aLock); *************** *** 168,172 **** DWORD waitResult; ! dprintf(("%ld: PyThread_acquire_lock(%lx, %d) called\n", PyThread_get_thread_ident(),(long)aLock, waitflag)); #ifndef DEBUG --- 168,172 ---- DWORD waitResult; ! dprintf(("%ld: PyThread_acquire_lock(%p, %d) called\n", PyThread_get_thread_ident(),aLock, waitflag)); #ifndef DEBUG *************** *** 186,190 **** } ! dprintf(("%ld: PyThread_acquire_lock(%lx, %d) -> %d\n", PyThread_get_thread_ident(),(long)aLock, waitflag, success)); return success; --- 186,190 ---- } ! dprintf(("%ld: PyThread_acquire_lock(%p, %d) -> %d\n", PyThread_get_thread_ident(),aLock, waitflag, success)); return success; *************** *** 193,200 **** void PyThread_release_lock(PyThread_type_lock aLock) { ! dprintf(("%ld: PyThread_release_lock(%lx) called\n", PyThread_get_thread_ident(),(long)aLock)); if (!SetEvent(aLock)) ! dprintf(("%ld: Could not PyThread_release_lock(%lx) error: %l\n", PyThread_get_thread_ident(), (long)aLock, GetLastError())); } --- 193,200 ---- void PyThread_release_lock(PyThread_type_lock aLock) { ! dprintf(("%ld: PyThread_release_lock(%p) called\n", PyThread_get_thread_ident(),aLock)); if (!SetEvent(aLock)) ! dprintf(("%ld: Could not PyThread_release_lock(%p) error: %l\n", PyThread_get_thread_ident(), aLock, GetLastError())); } From python-dev@python.org Fri Jun 30 16:01:02 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 08:01:02 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects bufferobject.c,2.7,2.8 classobject.c,2.93,2.94 fileobject.c,2.74,2.75 floatobject.c,2.58,2.59 funcobject.c,2.24,2.25 intobject.c,2.42,2.43 methodobject.c,2.27,2.28 object.c,2.75,2.76 Message-ID: <200006301501.IAA13197@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv13110/Objects Modified Files: bufferobject.c classobject.c fileobject.c floatobject.c funcobject.c intobject.c methodobject.c object.c Log Message: Trent Mick : The common technique for printing out a pointer has been to cast to a long and use the "%lx" printf modifier. This is incorrect on Win64 where casting to a long truncates the pointer. The "%p" formatter should be used instead. The problem as stated by Tim: > Unfortunately, the C committee refused to define what %p conversion "looks > like" -- they explicitly allowed it to be implementation-defined. Older > versions of Microsoft C even stuck a colon in the middle of the address (in > the days of segment+offset addressing)! The result is that the hex value of a pointer will maybe/maybe not have a 0x prepended to it. Notes on the patch: There are two main classes of changes: - in the various repr() functions that print out pointers - debugging printf's in the various thread_*.h files (these are why the patch is large) Closes SourceForge patch #100505. Index: bufferobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/bufferobject.c,v retrieving revision 2.7 retrieving revision 2.8 diff -C2 -r2.7 -r2.8 *** bufferobject.c 2000/05/03 23:44:34 2.7 --- bufferobject.c 2000/06/30 15:01:00 2.8 *************** *** 242,259 **** if ( self->b_base == NULL ) { ! sprintf(buf, "<%s buffer ptr %lx, size %d at %lx>", status, ! (long)self->b_ptr, self->b_size, ! (long)self); } else { ! sprintf(buf, "<%s buffer for %lx, ptr %lx, size %d at %lx>", status, ! (long)self->b_base, ! (long)self->b_ptr, self->b_size, ! (long)self); } --- 242,259 ---- if ( self->b_base == NULL ) { ! sprintf(buf, "<%s buffer ptr %p, size %d at %p>", status, ! self->b_ptr, self->b_size, ! self); } else { ! sprintf(buf, "<%s buffer for %p, ptr %p, size %d at %p>", status, ! self->b_base, ! self->b_ptr, self->b_size, ! self); } Index: classobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v retrieving revision 2.93 retrieving revision 2.94 diff -C2 -r2.93 -r2.94 *** classobject.c 2000/06/30 05:02:53 2.93 --- classobject.c 2000/06/30 15:01:00 2.94 *************** *** 354,362 **** name = PyString_AsString(op->cl_name); if (mod == NULL || !PyString_Check(mod)) ! sprintf(buf, "", name, (long)op); else ! sprintf(buf, "", PyString_AsString(mod), ! name, (long)op); return PyString_FromString(buf); } --- 354,362 ---- name = PyString_AsString(op->cl_name); if (mod == NULL || !PyString_Check(mod)) ! sprintf(buf, "", name, op); else ! sprintf(buf, "", PyString_AsString(mod), ! name, op); return PyString_FromString(buf); } *************** *** 806,815 **** PyErr_Clear(); if (mod == NULL || !PyString_Check(mod)) ! sprintf(buf, "", ! cname, (long)inst); else ! sprintf(buf, "<%.50s.%.50s instance at %lx>", PyString_AsString(mod), ! cname, (long)inst); return PyString_FromString(buf); } --- 806,815 ---- PyErr_Clear(); if (mod == NULL || !PyString_Check(mod)) ! sprintf(buf, "", ! cname, inst); else ! sprintf(buf, "<%.50s.%.50s instance at %p>", PyString_AsString(mod), ! cname, inst); return PyString_FromString(buf); } *************** *** 1705,1710 **** else icname = "?"; ! sprintf(buf, "", ! fcname, fname, icname, (long)self); } Py_XDECREF(funcname); --- 1705,1710 ---- else icname = "?"; ! sprintf(buf, "", ! fcname, fname, icname, self); } Py_XDECREF(funcname); Index: fileobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/fileobject.c,v retrieving revision 2.74 retrieving revision 2.75 diff -C2 -r2.74 -r2.75 *** fileobject.c 2000/06/28 20:57:07 2.74 --- fileobject.c 2000/06/30 15:01:00 2.75 *************** *** 241,249 **** { char buf[300]; ! sprintf(buf, "<%s file '%.256s', mode '%.10s' at %lx>", f->f_fp == NULL ? "closed" : "open", PyString_AsString(f->f_name), PyString_AsString(f->f_mode), ! (long)f); return PyString_FromString(buf); } --- 241,249 ---- { char buf[300]; ! sprintf(buf, "<%s file '%.256s', mode '%.10s' at %p>", f->f_fp == NULL ? "closed" : "open", PyString_AsString(f->f_name), PyString_AsString(f->f_mode), ! f); return PyString_FromString(buf); } Index: floatobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/floatobject.c,v retrieving revision 2.58 retrieving revision 2.59 diff -C2 -r2.58 -r2.59 *** floatobject.c 2000/06/29 19:17:04 2.58 --- floatobject.c 2000/06/30 15:01:00 2.59 *************** *** 807,812 **** PyFloat_AsString(buf, p); fprintf(stderr, ! "# \n", ! (long)p, p->ob_refcnt, buf); } } --- 807,812 ---- PyFloat_AsString(buf, p); fprintf(stderr, ! "# \n", ! p, p->ob_refcnt, buf); } } Index: funcobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/funcobject.c,v retrieving revision 2.24 retrieving revision 2.25 diff -C2 -r2.24 -r2.25 *** funcobject.c 2000/06/30 05:02:53 2.24 --- funcobject.c 2000/06/30 15:01:00 2.25 *************** *** 203,211 **** char buf[140]; if (op->func_name == Py_None) ! sprintf(buf, "", (long)op); else ! sprintf(buf, "", PyString_AsString(op->func_name), ! (long)op); return PyString_FromString(buf); } --- 203,211 ---- char buf[140]; if (op->func_name == Py_None) ! sprintf(buf, "", op); else ! sprintf(buf, "", PyString_AsString(op->func_name), ! op); return PyString_FromString(buf); } Index: intobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/intobject.c,v retrieving revision 2.42 retrieving revision 2.43 diff -C2 -r2.42 -r2.43 *** intobject.c 2000/05/09 14:27:48 2.42 --- intobject.c 2000/06/30 15:01:00 2.43 *************** *** 958,963 **** if (PyInt_Check(p) && p->ob_refcnt != 0) fprintf(stderr, ! "# \n", ! (long)p, p->ob_refcnt, p->ob_ival); } list = list->next; --- 958,963 ---- if (PyInt_Check(p) && p->ob_refcnt != 0) fprintf(stderr, ! "# \n", ! p, p->ob_refcnt, p->ob_ival); } list = list->next; Index: methodobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/methodobject.c,v retrieving revision 2.27 retrieving revision 2.28 diff -C2 -r2.27 -r2.28 *** methodobject.c 2000/06/29 19:17:04 2.27 --- methodobject.c 2000/06/30 15:01:00 2.28 *************** *** 149,155 **** else sprintf(buf, ! "", m->m_ml->ml_name, m->m_self->ob_type->tp_name, ! (long)m->m_self); return PyString_FromString(buf); } --- 149,155 ---- else sprintf(buf, ! "", m->m_ml->ml_name, m->m_self->ob_type->tp_name, ! m->m_self); return PyString_FromString(buf); } Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.75 retrieving revision 2.76 diff -C2 -r2.75 -r2.76 *** object.c 2000/06/30 05:02:53 2.75 --- object.c 2000/06/30 15:01:00 2.76 *************** *** 230,239 **** else { if (op->ob_refcnt <= 0) ! fprintf(fp, "", ! op->ob_refcnt, (long)op); else if (op->ob_type->tp_print == NULL) { if (op->ob_type->tp_repr == NULL) { ! fprintf(fp, "<%s object at %lx>", ! op->ob_type->tp_name, (long)op); } else { --- 230,239 ---- else { if (op->ob_refcnt <= 0) ! fprintf(fp, "", ! op->ob_refcnt, op); else if (op->ob_type->tp_print == NULL) { if (op->ob_type->tp_repr == NULL) { ! fprintf(fp, "<%s object at %p>", ! op->ob_type->tp_name, op); } else { *************** *** 281,286 **** else if (v->ob_type->tp_repr == NULL) { char buf[120]; ! sprintf(buf, "<%.80s object at %lx>", ! v->ob_type->tp_name, (long)v); return PyString_FromString(buf); } --- 281,286 ---- else if (v->ob_type->tp_repr == NULL) { char buf[120]; ! sprintf(buf, "<%.80s object at %p>", ! v->ob_type->tp_name, v); return PyString_FromString(buf); } From python-dev@python.org Fri Jun 30 16:01:02 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 08:01:02 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _tkinter.c,1.101,1.102 flmodule.c,1.36,1.37 mpzmodule.c,2.24,2.25 Message-ID: <200006301501.IAA13165@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv13110/Modules Modified Files: _tkinter.c flmodule.c mpzmodule.c Log Message: Trent Mick : The common technique for printing out a pointer has been to cast to a long and use the "%lx" printf modifier. This is incorrect on Win64 where casting to a long truncates the pointer. The "%p" formatter should be used instead. The problem as stated by Tim: > Unfortunately, the C committee refused to define what %p conversion "looks > like" -- they explicitly allowed it to be implementation-defined. Older > versions of Microsoft C even stuck a colon in the middle of the address (in > the days of segment+offset addressing)! The result is that the hex value of a pointer will maybe/maybe not have a 0x prepended to it. Notes on the patch: There are two main classes of changes: - in the various repr() functions that print out pointers - debugging printf's in the various thread_*.h files (these are why the patch is large) Closes SourceForge patch #100505. Index: _tkinter.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_tkinter.c,v retrieving revision 1.101 retrieving revision 1.102 diff -C2 -r1.101 -r1.102 *** _tkinter.c 2000/06/19 00:55:09 1.101 --- _tkinter.c 2000/06/30 15:00:59 1.102 *************** *** 1706,1710 **** char buf[100]; ! sprintf(buf, "", (long)v, v->func == NULL ? ", handler deleted" : ""); return PyString_FromString(buf); --- 1706,1710 ---- char buf[100]; ! sprintf(buf, "", v, v->func == NULL ? ", handler deleted" : ""); return PyString_FromString(buf); Index: flmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/flmodule.c,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -r1.36 -r1.37 *** flmodule.c 2000/05/03 23:44:32 1.36 --- flmodule.c 2000/06/30 15:00:59 1.37 *************** *** 436,441 **** { char buf[100]; ! sprintf(buf, "", ! (long)g, g->ob_generic->objclass); return PyString_FromString(buf); } --- 436,441 ---- { char buf[100]; ! sprintf(buf, "", ! g, g->ob_generic->objclass); return PyString_FromString(buf); } *************** *** 1907,1912 **** { char buf[100]; ! sprintf(buf, "", ! (long)f, f->ob_form->window); return PyString_FromString(buf); } --- 1907,1912 ---- { char buf[100]; ! sprintf(buf, "", ! f, f->ob_form->window); return PyString_FromString(buf); } Index: mpzmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/mpzmodule.c,v retrieving revision 2.24 retrieving revision 2.25 diff -C2 -r2.24 -r2.25 *** mpzmodule.c 2000/06/28 21:29:47 2.24 --- mpzmodule.c 2000/06/30 15:00:59 2.25 *************** *** 263,267 **** #ifdef MPZ_DEBUG fprintf(stderr, ! "mpz_format: cp (str end) 0x%x, begin 0x%x, diff %d, i %d\n", cp, PyString_AS_STRING(strobjp), cp - PyString_AS_STRING(strobjp), i); --- 263,267 ---- #ifdef MPZ_DEBUG fprintf(stderr, ! "mpz_format: cp (str end) %p, begin %p, diff %d, i %d\n", cp, PyString_AS_STRING(strobjp), cp - PyString_AS_STRING(strobjp), i); *************** *** 1766,1770 **** #ifdef MPZ_DEBUG ! fprintf(stderr, "mp_allocate : address 0x%08x\n", res); #endif /* def MPZ_DEBUG */ --- 1766,1770 ---- #ifdef MPZ_DEBUG ! fprintf(stderr, "mp_allocate : address %08p\n", res); #endif /* def MPZ_DEBUG */ *************** *** 1783,1787 **** #ifdef MPZ_DEBUG ! fprintf(stderr, "mp_reallocate: old address 0x%08x, old size %ld\n", ptr, old_size); #endif /* def MPZ_DEBUG */ --- 1783,1787 ---- #ifdef MPZ_DEBUG ! fprintf(stderr, "mp_reallocate: old address %08p, old size %ld\n", ptr, old_size); #endif /* def MPZ_DEBUG */ *************** *** 1793,1797 **** #ifdef MPZ_DEBUG ! fprintf(stderr, "mp_reallocate: new address 0x%08x, new size %ld\n", res, new_size); #endif /* def MPZ_DEBUG */ --- 1793,1797 ---- #ifdef MPZ_DEBUG ! fprintf(stderr, "mp_reallocate: new address %08p, new size %ld\n", res, new_size); #endif /* def MPZ_DEBUG */ *************** *** 1809,1813 **** #ifdef MPZ_DEBUG ! fprintf(stderr, "mp_free : old address 0x%08x, old size %ld\n", ptr, size); #endif /* def MPZ_DEBUG */ --- 1809,1813 ---- #ifdef MPZ_DEBUG ! fprintf(stderr, "mp_free : old address %08p, old size %ld\n", ptr, size); #endif /* def MPZ_DEBUG */ From python-dev@python.org Fri Jun 30 16:13:24 2000 From: python-dev@python.org (Jeremy Hylton) Date: Fri, 30 Jun 2000 08:13:24 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_gc,1.1,1.2 Message-ID: <200006301513.IAA19999@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv19979/Lib/test/output Modified Files: test_gc Log Message: remove all prints (since the prints where of memory locations) Index: test_gc =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_gc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** test_gc 2000/06/30 05:02:53 1.1 --- test_gc 2000/06/30 15:13:15 1.2 *************** *** 1,11 **** test_gc - list 0x831a754 - dict 0x831a754 - list 0x831a754 - tuple 0x831a734 - class 0x831a794 - - a - b - dict 0x831a9bc - func 0x831d9e4 --- 1 ---- From python-dev@python.org Fri Jun 30 16:13:24 2000 From: python-dev@python.org (Jeremy Hylton) Date: Fri, 30 Jun 2000 08:13:24 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_gc.py,1.1,1.2 Message-ID: <200006301513.IAA20000@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv19979/Lib/test Modified Files: test_gc.py Log Message: remove all prints (since the prints where of memory locations) Index: test_gc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_gc.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** test_gc.py 2000/06/30 05:02:53 1.1 --- test_gc.py 2000/06/30 15:13:14 1.2 *************** *** 4,8 **** l = [] l.append(l) - print 'list 0x%x' % id(l) gc.collect() del l --- 4,7 ---- *************** *** 12,16 **** d = {} d[1] = d - print 'dict 0x%x' % id(d) gc.collect() del d --- 11,14 ---- *************** *** 21,26 **** t = (l,) l.append(t) - print 'list 0x%x' % id(l) - print 'tuple 0x%x' % id(t) gc.collect() del t --- 19,22 ---- *************** *** 32,36 **** pass A.a = A - print 'class 0x%x' % id(A) gc.collect() del A --- 28,31 ---- *************** *** 42,46 **** a = A() a.a = a - print repr(a) gc.collect() del a --- 37,40 ---- *************** *** 66,71 **** b = B() b.b = b - print 'a', repr(a) - print 'b', repr(b) gc.collect() gc.garbage[:] = [] --- 60,63 ---- *************** *** 78,83 **** d = {} exec("def f(): pass\n") in d - print 'dict 0x%x' % id(d) - print 'func 0x%x' % id(d['f']) gc.collect() del d --- 70,73 ---- *************** *** 86,91 **** def test_all(): - debug = gc.get_debug() - gc.set_debug(gc.DEBUG_LEAK | gc.DEBUG_STATS) test_list() test_dict() --- 76,79 ---- *************** *** 96,100 **** test_finalizer() test_function() - gc.set_debug(debug) test_all() --- 84,87 ---- From python-dev@python.org Fri Jun 30 16:30:35 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 08:30:35 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/html index.html.in,1.6,1.7 Message-ID: <200006301530.IAA21763@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/html In directory slayer.i.sourceforge.net:/tmp/cvs-serv21746/html Modified Files: index.html.in Log Message: Fix an icon width; a "32" became a "3" somehow, and that did not look as nice. ;) Index: index.html.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/html/index.html.in,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** index.html.in 2000/04/28 17:43:12 1.6 --- index.html.in 2000/06/30 15:30:33 1.7 *************** *** 11,15 **** ! !
Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv21882/lib Modified Files: librandom.tex Log Message: Document randrange(). Index: librandom.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/librandom.tex,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -r1.13 -r1.14 *** librandom.tex 2000/04/03 20:13:54 1.13 --- librandom.tex 2000/06/30 15:32:31 1.14 *************** *** 114,117 **** --- 114,118 ---- \begin{funcdesc}{randint}{a, b} + \deprecated{2.0}{Use \function{randrange()} instead.} Returns a random integer \var{N} such that \code{\var{a} <= \var{N} <= \var{b}}. *************** *** 121,124 **** --- 122,132 ---- Returns the next random floating point number in the range [0.0 ... 1.0). + \end{funcdesc} + + \begin{funcdesc}{randrange}{\optional{start,} stop\optional{, step}} + Return a randomly selected element from \code{range(\var{start}, + \var{stop}, \var{step})}. This is equivalent to + \code{choice(range(\var{start}, \var{stop}, \var{step}))}. + \versionadded{1.5.2} \end{funcdesc} From python-dev@python.org Fri Jun 30 16:35:18 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 08:35:18 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/texinputs boilerplate.tex,1.40,1.41 Message-ID: <200006301535.IAA22310@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/texinputs In directory slayer.i.sourceforge.net:/tmp/cvs-serv22299/texinputs Modified Files: boilerplate.tex Log Message: Update the release number & date, Guido's employer. Index: boilerplate.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/texinputs/boilerplate.tex,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -r1.40 -r1.41 *** boilerplate.tex 2000/04/03 04:13:48 1.40 --- boilerplate.tex 2000/06/30 15:35:16 1.41 *************** *** 2,10 **** \authoraddress{ ! Corporation for National Research Initiatives \\ ! 1895 Preston White Drive, Reston, VA 20191, USA \\ E-mail: \email{guido@python.org} } ! \date{\today} % XXX update before release! ! \release{1.6} --- 2,9 ---- \authoraddress{ ! BeOpen PythonLabs \\ E-mail: \email{guido@python.org} } ! \date{July 1, 2000} % XXX update before release! ! \release{2.0b1} From python-dev@python.org Fri Jun 30 16:46:10 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 08:46:10 -0700 Subject: [Python-checkins] CVS: python/dist/src Makefile.in,1.87,1.88 Message-ID: <200006301546.IAA23433@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv23418 Modified Files: Makefile.in Log Message: Martin von Löwis : Do not forget to install the xml packages! Index: Makefile.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.in,v retrieving revision 1.87 retrieving revision 1.88 diff -C2 -r1.87 -r1.88 *** Makefile.in 2000/06/10 23:08:21 1.87 --- Makefile.in 2000/06/30 15:46:08 1.88 *************** *** 290,295 **** PLATDIR= plat-$(MACHDEP) MACHDEPS= $(PLATDIR) LIBSUBDIRS= lib-old lib-tk site-packages test test/output encodings \ ! distutils distutils/command curses $(MACHDEPS) libinstall: python $(srcdir)/Lib/$(PLATDIR) @for i in $(SCRIPTDIR) $(LIBDEST); \ --- 290,296 ---- PLATDIR= plat-$(MACHDEP) MACHDEPS= $(PLATDIR) + XMLLIBSUBDIRS= xml xml/dom xml/parser xml/sax LIBSUBDIRS= lib-old lib-tk site-packages test test/output encodings \ ! distutils distutils/command $(XMLLIBSUBDIRS) curses $(MACHDEPS) libinstall: python $(srcdir)/Lib/$(PLATDIR) @for i in $(SCRIPTDIR) $(LIBDEST); \ From python-dev@python.org Fri Jun 30 16:47:04 2000 From: python-dev@python.org (Mark Hammond) Date: Fri, 30 Jun 2000 08:47:04 -0700 Subject: [Python-checkins] CVS: python/dist/src/PC config.h,1.39,1.40 Message-ID: <200006301547.IAA23471@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv23462 Modified Files: config.h Log Message: Python's .lib is now named Python20.lib Index: config.h =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/config.h,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -r1.39 -r1.40 *** config.h 2000/06/30 05:02:53 1.39 --- config.h 2000/06/30 15:47:02 1.40 *************** *** 289,295 **** /* So nobody needs to specify the .lib in their Makefile any more */ #ifdef _DEBUG ! #pragma comment(lib,"python16_d.lib") #else ! #pragma comment(lib,"python16.lib") #endif #endif /* USE_DL_EXPORT */ --- 289,295 ---- /* So nobody needs to specify the .lib in their Makefile any more */ #ifdef _DEBUG ! #pragma comment(lib,"python20_d.lib") #else ! #pragma comment(lib,"python20.lib") #endif #endif /* USE_DL_EXPORT */ From python-dev@python.org Fri Jun 30 16:52:41 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 08:52:41 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/api api.tex,1.70,1.71 Message-ID: <200006301552.IAA23907@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/api In directory slayer.i.sourceforge.net:/tmp/cvs-serv23897 Modified Files: api.tex Log Message: Uncomment some additions from Vladimir pertinent to 2.0 but not 1.5.2. Index: api.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/api.tex,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -r1.70 -r1.71 *** api.tex 2000/06/29 20:15:14 1.70 --- api.tex 2000/06/30 15:52:39 1.71 *************** *** 4293,4304 **** \cfunction{PyObject_NEW_VAR()}\ttindex{PyObject_NEW_VAR()}. ! % XXX use this for Python 1.6: ! % \cfunction{_PyObject_New()}, \cfunction{_PyObject_NewVar()}, ! % \cfunction{_PyObject_Del()}, or with their corresponding macros ! % \cfunction{PyObject_NEW()}, \cfunction{PyObject_NEW_VAR()}, ! % \cfunction{PyObject_DEL()}. ! % These will be explained in the next chapter on defining and ! % implementing new object types in C. --- 4293,4303 ---- \cfunction{PyObject_NEW_VAR()}\ttindex{PyObject_NEW_VAR()}. ! \cfunction{_PyObject_New()}, \cfunction{_PyObject_NewVar()}, ! \cfunction{_PyObject_Del()}, or with their corresponding macros ! \cfunction{PyObject_NEW()}, \cfunction{PyObject_NEW_VAR()}, ! \cfunction{PyObject_DEL()}. ! These will be explained in the next chapter on defining and ! implementing new object types in C. From python-dev@python.org Fri Jun 30 16:54:20 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 08:54:20 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/doc doc.tex,1.20,1.21 Message-ID: <200006301554.IAA23981@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/doc In directory slayer.i.sourceforge.net:/tmp/cvs-serv23974 Modified Files: doc.tex Log Message: Update authors email address and corporate affiliation. Index: doc.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/doc/doc.tex,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -r1.20 -r1.21 *** doc.tex 2000/05/02 17:43:44 1.20 --- doc.tex 2000/06/30 15:54:18 1.21 *************** *** 11,17 **** \author{Fred L. Drake, Jr.} \authoraddress{ ! Corporation for National Research Initiatives (CNRI) \\ ! 1895 Preston White Drive, Reston, Va 20191, USA \\ ! E-mail: \email{fdrake@acm.org} } --- 11,16 ---- \author{Fred L. Drake, Jr.} \authoraddress{ ! BeOpen PythonLabs \\ ! E-mail: \email{fdrake@beopen.com} } From python-dev@python.org Fri Jun 30 17:02:26 2000 From: python-dev@python.org (Barry Warsaw) Date: Fri, 30 Jun 2000 09:02:26 -0700 Subject: [Python-checkins] CVS: python/dist/src acconfig.h,1.30,1.31 Message-ID: <200006301602.JAA26036@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv25996 Modified Files: acconfig.h Log Message: Added #undef of WITH_CYCLE_GC for autoconf's delight. Index: acconfig.h =================================================================== RCS file: /cvsroot/python/python/dist/src/acconfig.h,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -r1.30 -r1.31 *** acconfig.h 2000/06/29 20:44:46 1.30 --- acconfig.h 2000/06/30 16:02:24 1.31 *************** *** 145,148 **** --- 145,151 ---- #undef WITH_THREAD + /* Define if you want to compile in cycle garbage collection */ + #undef WITH_CYCLE_GC + /* Define if you want to produce an OpenStep/Rhapsody framework (shared library plus accessory files). */ From python-dev@python.org Fri Jun 30 17:03:00 2000 From: python-dev@python.org (Barry Warsaw) Date: Fri, 30 Jun 2000 09:03:00 -0700 Subject: [Python-checkins] CVS: python/dist/src config.h.in,2.60,2.61 Message-ID: <200006301603.JAA26426@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv26375 Modified Files: config.h.in Log Message: Added #undef of WITH_CYCLE_GC for autoconf's delight. Index: config.h.in =================================================================== RCS file: /cvsroot/python/python/dist/src/config.h.in,v retrieving revision 2.60 retrieving revision 2.61 diff -C2 -r2.60 -r2.61 *** config.h.in 2000/06/30 04:57:55 2.60 --- config.h.in 2000/06/30 16:02:58 2.61 *************** *** 207,216 **** #undef WITH_THREAD /* Define if you want to produce an OpenStep/Rhapsody framework (shared library plus accessory files). */ #undef WITH_NEXT_FRAMEWORK - - /* Define if you want cycle garbage collection */ - #undef WITH_CYCLE_GC /* The number of bytes in an off_t. */ --- 207,216 ---- #undef WITH_THREAD + /* Define if you want to compile in cycle garbage collection */ + #undef WITH_CYCLE_GC + /* Define if you want to produce an OpenStep/Rhapsody framework (shared library plus accessory files). */ #undef WITH_NEXT_FRAMEWORK /* The number of bytes in an off_t. */ From python-dev@python.org Fri Jun 30 17:03:29 2000 From: python-dev@python.org (Barry Warsaw) Date: Fri, 30 Jun 2000 09:03:29 -0700 Subject: [Python-checkins] CVS: python/dist/src Makefile.in,1.88,1.89 Message-ID: <200006301603.JAA26558@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv26517 Modified Files: Makefile.in Log Message: Setup.thread => Setup.config Index: Makefile.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.in,v retrieving revision 1.88 retrieving revision 1.89 diff -C2 -r1.88 -r1.89 *** Makefile.in 2000/06/30 15:46:08 1.88 --- Makefile.in 2000/06/30 16:03:26 1.89 *************** *** 403,407 **** $(INSTALL_DATA) Modules/Setup $(LIBPL)/Setup $(INSTALL_DATA) Modules/Setup.local $(LIBPL)/Setup.local ! $(INSTALL_DATA) Modules/Setup.thread $(LIBPL)/Setup.thread $(INSTALL_PROGRAM) $(srcdir)/Modules/makesetup $(LIBPL)/makesetup $(INSTALL_PROGRAM) $(srcdir)/install-sh $(LIBPL)/install-sh --- 403,407 ---- $(INSTALL_DATA) Modules/Setup $(LIBPL)/Setup $(INSTALL_DATA) Modules/Setup.local $(LIBPL)/Setup.local ! $(INSTALL_DATA) Modules/Setup.config $(LIBPL)/Setup.config $(INSTALL_PROGRAM) $(srcdir)/Modules/makesetup $(LIBPL)/makesetup $(INSTALL_PROGRAM) $(srcdir)/install-sh $(LIBPL)/install-sh From python-dev@python.org Fri Jun 30 17:03:57 2000 From: python-dev@python.org (Barry Warsaw) Date: Fri, 30 Jun 2000 09:03:57 -0700 Subject: [Python-checkins] CVS: python/dist/src/Misc Makefile.pre.in,1.16,1.17 Message-ID: <200006301603.JAA27164@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Misc In directory slayer.i.sourceforge.net:/tmp/cvs-serv27058 Modified Files: Makefile.pre.in Log Message: Setup.thread => Setup.config Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/Makefile.pre.in,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** Makefile.pre.in 1998/12/09 17:05:33 1.16 --- Makefile.pre.in 2000/06/30 16:03:53 1.17 *************** *** 169,173 **** CONFIGC= $(LIBPL)/config.c CONFIGCIN= $(LIBPL)/config.c.in ! SETUP= $(LIBPL)/Setup.thread $(LIBPL)/Setup.local $(LIBPL)/Setup SYSLIBS= $(LIBM) $(LIBC) --- 169,173 ---- CONFIGC= $(LIBPL)/config.c CONFIGCIN= $(LIBPL)/config.c.in ! SETUP= $(LIBPL)/Setup.config $(LIBPL)/Setup.local $(LIBPL)/Setup SYSLIBS= $(LIBM) $(LIBC) From python-dev@python.org Fri Jun 30 17:04:21 2000 From: python-dev@python.org (Barry Warsaw) Date: Fri, 30 Jun 2000 09:04:21 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules Makefile.pre.in,1.62,1.63 Message-ID: <200006301604.JAA27553@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv27536 Modified Files: Makefile.pre.in Log Message: Setup.thread => Setup.config Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Makefile.pre.in,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -r1.62 -r1.63 *** Makefile.pre.in 2000/06/28 16:42:14 1.62 --- Makefile.pre.in 2000/06/30 16:04:18 1.63 *************** *** 148,155 **** # longer pertinent (but that were in a previous configuration). config.c Makefile: Makefile.pre config.c.in $(MAKESETUP) ! config.c Makefile: Setup.thread Setup Setup.local config.c Makefile: -rm -f $(LIBRARY) ! $(SHELL) $(MAKESETUP) Setup.thread Setup.local Setup hassignal: --- 148,155 ---- # longer pertinent (but that were in a previous configuration). config.c Makefile: Makefile.pre config.c.in $(MAKESETUP) ! config.c Makefile: Setup.config Setup Setup.local config.c Makefile: -rm -f $(LIBRARY) ! $(SHELL) $(MAKESETUP) Setup.config Setup.local Setup hassignal: From python-dev@python.org Fri Jun 30 17:05:24 2000 From: python-dev@python.org (Barry Warsaw) Date: Fri, 30 Jun 2000 09:05:24 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules Setup.in,1.105,1.106 Message-ID: <200006301605.JAA28397@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv28326 Modified Files: Setup.in Log Message: Removed the comment about the thread module. Index: Setup.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Setup.in,v retrieving revision 1.105 retrieving revision 1.106 diff -C2 -r1.105 -r1.106 *** Setup.in 2000/06/29 14:40:45 1.105 --- Setup.in 2000/06/30 16:05:22 1.106 *************** *** 101,106 **** #gl glmodule.c cgensupport.c -I$(srcdir) $(GLHACK) -lgl -lX11 - # The thread module is now automatically enabled, see Setup.thread. - # Pure module. Cannot be linked dynamically. # -DWITH_QUANTIFY, -DWITH_PURIFY, or -DWITH_ALL_PURE --- 101,104 ---- From python-dev@python.org Fri Jun 30 17:06:21 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 09:06:21 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc Makefile,1.195,1.196 Message-ID: <200006301606.JAA28615@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc In directory slayer.i.sourceforge.net:/tmp/cvs-serv28564 Modified Files: Makefile Log Message: Update version numbering from 1.6 to 2.0. Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile,v retrieving revision 1.195 retrieving revision 1.196 diff -C2 -r1.195 -r1.196 *** Makefile 2000/04/28 17:09:17 1.195 --- Makefile 2000/06/30 16:06:19 1.196 *************** *** 62,66 **** # This is the *documentation* release, and is used to construct the file # names of the downloadable tarballs. ! RELEASE=1.6a2 --- 62,66 ---- # This is the *documentation* release, and is used to construct the file # names of the downloadable tarballs. ! RELEASE=2.0b1 From python-dev@python.org Fri Jun 30 17:06:21 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 09:06:21 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/lib libascii.tex,1.2,1.3 libatexit.tex,1.2,1.3 libexcs.tex,1.29,1.30 libfuncs.tex,1.65,1.66 libos.tex,1.41,1.42 libstdtypes.tex,1.22,1.23 libsys.tex,1.36,1.37 libtempfile.tex,1.14,1.15 libundoc.tex,1.73,1.74 Message-ID: <200006301606.JAA28639@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv28564/lib Modified Files: libascii.tex libatexit.tex libexcs.tex libfuncs.tex libos.tex libstdtypes.tex libsys.tex libtempfile.tex libundoc.tex Log Message: Update version numbering from 1.6 to 2.0. Index: libascii.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libascii.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** libascii.tex 2000/06/28 22:03:29 1.2 --- libascii.tex 2000/06/30 16:06:19 1.3 *************** *** 8,12 **** \sectionauthor{Eric S. Raymond}{esr@thyrsus.com} ! \versionadded{1.6} The \module{curses.ascii} module supplies name constants for --- 8,12 ---- \sectionauthor{Eric S. Raymond}{esr@thyrsus.com} ! \versionadded{2.0} The \module{curses.ascii} module supplies name constants for Index: libatexit.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libatexit.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** libatexit.tex 2000/06/28 22:07:55 1.2 --- libatexit.tex 2000/06/30 16:06:19 1.3 *************** *** 7,11 **** \modulesynopsis{Register and execute cleanup functions.} ! \versionadded{1.6} The \module{atexit} module defines a single function to register --- 7,11 ---- \modulesynopsis{Register and execute cleanup functions.} ! \versionadded{2.0} The \module{atexit} module defines a single function to register Index: libexcs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libexcs.tex,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -r1.29 -r1.30 *** libexcs.tex 2000/04/17 17:42:00 1.29 --- libexcs.tex 2000/06/30 16:06:19 1.30 *************** *** 299,303 **** method, but no value has been bound to that variable. This is a subclass of \exception{NameError}. ! \versionadded{1.6} \end{excdesc} --- 299,303 ---- method, but no value has been bound to that variable. This is a subclass of \exception{NameError}. ! \versionadded{2.0} \end{excdesc} *************** *** 305,309 **** Raised when a Unicode-related encoding or decoding error occurs. It is a subclass of \exception{ValueError}. ! \versionadded{1.6} \end{excdesc} --- 305,309 ---- Raised when a Unicode-related encoding or decoding error occurs. It is a subclass of \exception{ValueError}. ! \versionadded{2.0} \end{excdesc} *************** *** 322,326 **** \cfunction{FormatMessage()} functions from the Windows Platform API. This is a subclass of \exception{OSError}. ! \versionadded{1.6} \end{excdesc} --- 322,326 ---- \cfunction{FormatMessage()} functions from the Windows Platform API. This is a subclass of \exception{OSError}. ! \versionadded{2.0} \end{excdesc} Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -r1.65 -r1.66 *** libfuncs.tex 2000/06/29 03:46:46 1.65 --- libfuncs.tex 2000/06/30 16:06:19 1.66 *************** *** 670,674 **** strings. The argument must be in the range [0..65535], inclusive. \exception{ValueError} is raised otherwise. ! \versionadded{1.6} \end{funcdesc} --- 670,674 ---- strings. The argument must be in the range [0..65535], inclusive. \exception{ValueError} is raised otherwise. ! \versionadded{2.0} \end{funcdesc} *************** *** 678,682 **** to decode UTF-8 in strict mode, meaning that encoding errors raise \exception{ValueError}. ! \versionadded{1.6} \end{funcdesc} --- 678,682 ---- to decode UTF-8 in strict mode, meaning that encoding errors raise \exception{ValueError}. ! \versionadded{2.0} \end{funcdesc} Index: libos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -r1.41 -r1.42 *** libos.tex 2000/06/28 17:27:48 1.41 --- libos.tex 2000/06/30 16:06:19 1.42 *************** *** 717,721 **** 2-tuple of numbers, of the form \code{(\var{atime}, \var{mtime})} which is used to set the access and modified times, respectively. ! \versionchanged[added support for \code{None} for \var{times}]{1.6} Availability: Macintosh, \UNIX{}, Windows. \end{funcdesc} --- 717,721 ---- 2-tuple of numbers, of the form \code{(\var{atime}, \var{mtime})} which is used to set the access and modified times, respectively. ! \versionchanged[added support for \code{None} for \var{times}]{2.0} Availability: Macintosh, \UNIX{}, Windows. \end{funcdesc} Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** libstdtypes.tex 2000/04/03 20:13:54 1.22 --- libstdtypes.tex 2000/06/30 16:06:19 1.23 *************** *** 497,501 **** \item[(1)] The C implementation of Python has historically accepted multiple parameters and implicitly joined them into a tuple; this ! will no longer work in Python 1.6. Use of this misfeature has been deprecated since Python 1.4. --- 497,501 ---- \item[(1)] The C implementation of Python has historically accepted multiple parameters and implicitly joined them into a tuple; this ! no longer works in Python 2.0. Use of this misfeature has been deprecated since Python 1.4. Index: libsys.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsys.tex,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -r1.36 -r1.37 *** libsys.tex 2000/06/28 15:07:30 1.36 --- libsys.tex 2000/06/30 16:06:19 1.37 *************** *** 335,341 **** release level is \code{'alpha'}, \code{'beta'}, \code{'candidate'}, or \code{'final'}. The \code{version_info} value ! corresponding to the Python version 1.6 is ! \code{(1, 6, 0, 'final', 0)}. ! \versionadded{1.6} \end{datadesc} --- 335,341 ---- release level is \code{'alpha'}, \code{'beta'}, \code{'candidate'}, or \code{'final'}. The \code{version_info} value ! corresponding to the Python version 2.0 is ! \code{(2, 0, 0, 'final', 0)}. ! \versionadded{2.0} \end{datadesc} Index: libtempfile.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libtempfile.tex,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** libtempfile.tex 2000/05/26 19:32:14 1.14 --- libtempfile.tex 2000/06/30 16:06:19 1.15 *************** *** 64,68 **** \begin{datadesc}{template} ! \deprecated{1.6}{Use \function{gettempprefix()} instead.} When set to a value other than \code{None}, this variable defines the prefix of the final component of the filenames returned by --- 64,68 ---- \begin{datadesc}{template} ! \deprecated{2.0}{Use \function{gettempprefix()} instead.} When set to a value other than \code{None}, this variable defines the prefix of the final component of the filenames returned by Index: libundoc.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libundoc.tex,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -r1.73 -r1.74 *** libundoc.tex 2000/04/03 20:13:54 1.73 --- libundoc.tex 2000/06/30 16:06:19 1.74 *************** *** 41,45 **** \item[\module{dircmp}] --- Class to build directory diff tools on (may become a demo or tool). ! \deprecated{1.6}{The \refmodule{filecmp} module will replace \module{dircmp}.} --- 41,45 ---- \item[\module{dircmp}] --- Class to build directory diff tools on (may become a demo or tool). ! \deprecated{2.0}{The \refmodule{filecmp} module will replace \module{dircmp}.} From python-dev@python.org Fri Jun 30 17:06:21 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 09:06:21 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/tut tut.tex,1.107,1.108 Message-ID: <200006301606.JAA28637@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/tut In directory slayer.i.sourceforge.net:/tmp/cvs-serv28564/tut Modified Files: tut.tex Log Message: Update version numbering from 1.6 to 2.0. Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.107 retrieving revision 1.108 diff -C2 -r1.107 -r1.108 *** tut.tex 2000/04/17 14:56:31 1.107 --- tut.tex 2000/06/30 16:06:19 1.108 *************** *** 738,742 **** \sectionauthor{Marc-Andre Lemburg}{mal@lemburg.com} ! Starting with Python 1.6 a new data type for storing text data is available to the programmer: the Unicode object. It can be used to store and manipulate Unicode data (see \url{http://www.unicode.org}) --- 738,742 ---- \sectionauthor{Marc-Andre Lemburg}{mal@lemburg.com} ! Starting with Python 2.0 a new data type for storing text data is available to the programmer: the Unicode object. It can be used to store and manipulate Unicode data (see \url{http://www.unicode.org}) From python-dev@python.org Fri Jun 30 17:09:04 2000 From: python-dev@python.org (Barry Warsaw) Date: Fri, 30 Jun 2000 09:09:04 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules .cvsignore,2.1,2.2 Message-ID: <200006301609.JAA29933@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv29911 Modified Files: .cvsignore Log Message: Add Setup.config Index: .cvsignore =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/.cvsignore,v retrieving revision 2.1 retrieving revision 2.2 diff -C2 -r2.1 -r2.2 *** .cvsignore 2000/05/02 18:32:34 2.1 --- .cvsignore 2000/06/30 16:09:01 2.2 *************** *** 2,5 **** --- 2,6 ---- Makefile.pre Setup.thread + Setup.config Setup.local hassignal From python-dev@python.org Fri Jun 30 17:12:17 2000 From: python-dev@python.org (Barry Warsaw) Date: Fri, 30 Jun 2000 09:12:17 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules Setup.config.in,NONE,1.1 Setup.thread.in,2.3,NONE Message-ID: <200006301612.JAA31542@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv31260 Added Files: Setup.config.in Removed Files: Setup.thread.in Log Message: Setup.thread.in was misnamed so it has been replaced by Setup.config.in. The latter contains all configure-time selectable modules; currently thread and gc. --- NEW FILE --- # This file is transmogrified into Setup.config by config.status. # The purpose of this file is to conditionally enable certain modules # based on configure-time options. Currently thread support and # garbage collection support are the only two modules so enabled. # *NOTE*: if the configure script decides it can't support threads, # the thread module will still be enabled and cause compile errors. # The solution is to use --without-threads on platforms that don't # support threads. @USE_THREAD_MODULE@thread threadmodule.c # Garbage collection enabled with --with-cycle-gc @USE_GC_MODULE@gc gcmodule.c From python-dev@python.org Fri Jun 30 17:13:40 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 09:13:40 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/dos-8x3 test_has.py,NONE,1.1 sre_comp.py,1.2,1.3 sre_cons.py,1.2,1.3 sre_pars.py,1.2,1.3 Message-ID: <200006301613.JAA31632@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/dos-8x3 In directory slayer.i.sourceforge.net:/tmp/cvs-serv31620 Modified Files: sre_comp.py sre_cons.py sre_pars.py Added Files: test_has.py Log Message: the usual --- NEW FILE --- # test the invariant that # iff a==b then hash(a)==hash(b) # import test_support def same_hash(*objlist): # hash each object given an raise TestFailed if # the hash values are not all the same hashed = map(hash, objlist) for h in hashed[1:]: if h != hashed[0]: raise TestFailed, "hashed values differ: %s" % `objlist` same_hash(1, 1L, 1.0, 1.0+0.0j) same_hash(int(1), long(1), float(1), complex(1)) same_hash(long(1.23e300), float(1.23e300)) same_hash(float(0.5), complex(0.5, 0.0)) Index: sre_comp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/sre_comp.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** sre_comp.py 2000/06/29 19:35:29 1.2 --- sre_comp.py 2000/06/30 16:13:37 1.3 *************** *** 19,174 **** for WORDSIZE in "BHil": if len(array.array(WORDSIZE, [0]).tostring()) == _sre.getcodesize(): ! break else: raise RuntimeError, "cannot find a useable array type" def _compile(code, pattern, flags): emit = code.append for op, av in pattern: ! if op is ANY: ! if flags & SRE_FLAG_DOTALL: ! emit(OPCODES[op]) ! else: ! emit(OPCODES[CATEGORY]) ! emit(CHCODES[CATEGORY_NOT_LINEBREAK]) ! elif op in (SUCCESS, FAILURE): ! emit(OPCODES[op]) ! elif op is AT: ! emit(OPCODES[op]) ! if flags & SRE_FLAG_MULTILINE: ! emit(ATCODES[AT_MULTILINE[av]]) ! else: ! emit(ATCODES[av]) ! elif op is BRANCH: ! emit(OPCODES[op]) ! tail = [] ! for av in av[1]: ! skip = len(code); emit(0) ! _compile(code, av, flags) ! emit(OPCODES[JUMP]) ! tail.append(len(code)); emit(0) ! code[skip] = len(code) - skip ! emit(0) # end of branch ! for tail in tail: ! code[tail] = len(code) - tail ! elif op is CALL: ! emit(OPCODES[op]) ! skip = len(code); emit(0) ! _compile(code, av, flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! elif op is CATEGORY: ! emit(OPCODES[op]) ! if flags & SRE_FLAG_LOCALE: ! emit(CH_LOCALE[CHCODES[av]]) ! elif flags & SRE_FLAG_UNICODE: ! emit(CH_UNICODE[CHCODES[av]]) ! else: ! emit(CHCODES[av]) ! elif op is GROUP: ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) ! else: ! emit(OPCODES[op]) ! emit(av-1) ! elif op is IN: ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) ! def fixup(literal, flags=flags): ! return _sre.getlower(ord(literal), flags) ! else: ! emit(OPCODES[op]) ! fixup = ord ! skip = len(code); emit(0) ! for op, av in av: ! emit(OPCODES[op]) ! if op is NEGATE: ! pass ! elif op is LITERAL: ! emit(fixup(av)) ! elif op is RANGE: ! emit(fixup(av[0])) ! emit(fixup(av[1])) ! elif op is CATEGORY: ! if flags & SRE_FLAG_LOCALE: ! emit(CH_LOCALE[CHCODES[av]]) ! elif flags & SRE_FLAG_UNICODE: ! emit(CH_UNICODE[CHCODES[av]]) ! else: ! emit(CHCODES[av]) ! else: ! raise error, "internal: unsupported set operator" ! emit(OPCODES[FAILURE]) ! code[skip] = len(code) - skip ! elif op in (LITERAL, NOT_LITERAL): ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) ! else: ! emit(OPCODES[op]) ! emit(ord(av)) ! elif op is MARK: ! emit(OPCODES[op]) ! emit(av) ! elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): ! if flags & SRE_FLAG_TEMPLATE: ! emit(OPCODES[REPEAT]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) ! _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! else: ! lo, hi = av[2].getwidth() ! if lo == 0: ! raise error, "nothing to repeat" ! if 0 and lo == hi == 1 and op is MAX_REPEAT: ! # FIXME: need a better way to figure out when ! # it's safe to use this one (in the parser, probably) ! emit(OPCODES[MAX_REPEAT_ONE]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) ! _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! else: ! emit(OPCODES[op]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) ! _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! elif op is SUBPATTERN: ! group = av[0] ! if group: ! emit(OPCODES[MARK]) ! emit((group-1)*2) ! _compile(code, av[1], flags) ! if group: ! emit(OPCODES[MARK]) ! emit((group-1)*2+1) ! else: ! raise ValueError, ("unsupported operand type", op) def compile(p, flags=0): # internal: convert pattern list to internal format if type(p) in (type(""), type(u"")): ! import sre_parse ! pattern = p ! p = sre_parse.parse(p) else: ! pattern = None flags = p.pattern.flags | flags code = [] _compile(code, p.data, flags) code.append(OPCODES[SUCCESS]) ! # FIXME: get rid of this limitation assert p.pattern.groups <= 100,\ ! "sorry, but this version only supports 100 named groups" return _sre.compile( ! pattern, flags, ! array.array(WORDSIZE, code).tostring(), ! p.pattern.groups-1, p.pattern.groupdict ! ) --- 19,229 ---- for WORDSIZE in "BHil": if len(array.array(WORDSIZE, [0]).tostring()) == _sre.getcodesize(): ! break else: raise RuntimeError, "cannot find a useable array type" def _compile(code, pattern, flags): + # internal: compile a (sub)pattern emit = code.append for op, av in pattern: ! if op in (LITERAL, NOT_LITERAL): ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) ! else: ! emit(OPCODES[op]) ! emit(av) ! elif op is IN: ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) ! def fixup(literal, flags=flags): ! return _sre.getlower(literal, flags) ! else: ! emit(OPCODES[op]) ! fixup = lambda x: x ! skip = len(code); emit(0) ! for op, av in av: ! emit(OPCODES[op]) ! if op is NEGATE: ! pass ! elif op is LITERAL: ! emit(fixup(av)) ! elif op is RANGE: ! emit(fixup(av[0])) ! emit(fixup(av[1])) ! elif op is CATEGORY: ! if flags & SRE_FLAG_LOCALE: ! emit(CHCODES[CH_LOCALE[av]]) ! elif flags & SRE_FLAG_UNICODE: ! emit(CHCODES[CH_UNICODE[av]]) ! else: ! emit(CHCODES[av]) ! else: ! raise error, "internal: unsupported set operator" ! emit(OPCODES[FAILURE]) ! code[skip] = len(code) - skip ! elif op is ANY: ! if flags & SRE_FLAG_DOTALL: ! emit(OPCODES[op]) ! else: ! emit(OPCODES[CATEGORY]) ! emit(CHCODES[CATEGORY_NOT_LINEBREAK]) ! elif op in (REPEAT, MIN_REPEAT, MAX_REPEAT): ! if flags & SRE_FLAG_TEMPLATE: ! emit(OPCODES[REPEAT]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) ! _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! else: ! lo, hi = av[2].getwidth() ! if lo == 0: ! raise error, "nothing to repeat" ! if 0 and lo == hi == 1 and op is MAX_REPEAT: ! # FIXME: need a better way to figure out when ! # it's safe to use this one (in the parser, probably) ! emit(OPCODES[MAX_REPEAT_ONE]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) ! _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! else: ! emit(OPCODES[op]) ! skip = len(code); emit(0) ! emit(av[0]) ! emit(av[1]) ! _compile(code, av[2], flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! elif op is SUBPATTERN: ! group = av[0] ! if group: ! emit(OPCODES[MARK]) ! emit((group-1)*2) ! _compile(code, av[1], flags) ! if group: ! emit(OPCODES[MARK]) ! emit((group-1)*2+1) ! elif op in (SUCCESS, FAILURE): ! emit(OPCODES[op]) ! elif op in (ASSERT, ASSERT_NOT, CALL): ! emit(OPCODES[op]) ! skip = len(code); emit(0) ! _compile(code, av, flags) ! emit(OPCODES[SUCCESS]) ! code[skip] = len(code) - skip ! elif op is AT: ! emit(OPCODES[op]) ! if flags & SRE_FLAG_MULTILINE: ! emit(ATCODES[AT_MULTILINE[av]]) ! else: ! emit(ATCODES[av]) ! elif op is BRANCH: ! emit(OPCODES[op]) ! tail = [] ! for av in av[1]: ! skip = len(code); emit(0) ! _compile(code, av, flags) ! emit(OPCODES[JUMP]) ! tail.append(len(code)); emit(0) ! code[skip] = len(code) - skip ! emit(0) # end of branch ! for tail in tail: ! code[tail] = len(code) - tail ! elif op is CATEGORY: ! emit(OPCODES[op]) ! if flags & SRE_FLAG_LOCALE: ! emit(CHCODES[CH_LOCALE[av]]) ! elif flags & SRE_FLAG_UNICODE: ! emit(CHCODES[CH_UNICODE[av]]) ! else: ! emit(CHCODES[av]) ! elif op is GROUP: ! if flags & SRE_FLAG_IGNORECASE: ! emit(OPCODES[OP_IGNORE[op]]) ! else: ! emit(OPCODES[op]) ! emit(av-1) ! elif op is MARK: ! emit(OPCODES[op]) ! emit(av) ! else: ! raise ValueError, ("unsupported operand type", op) + def _compile_info(code, pattern, flags): + # internal: compile an info block. in the current version, + # this contains min/max pattern width and a literal prefix, + # if any + lo, hi = pattern.getwidth() + if lo == 0: + return # not worth it + # look for a literal prefix + prefix = [] + if not (flags & SRE_FLAG_IGNORECASE): + for op, av in pattern.data: + if op is LITERAL: + prefix.append(av) + else: + break + # add an info block + emit = code.append + emit(OPCODES[INFO]) + skip = len(code); emit(0) + # literal flag + mask = 0 + if len(prefix) == len(pattern.data): + mask = 1 + emit(mask) + # pattern length + emit(lo) + if hi < 32768: + emit(hi) + else: + emit(0) + # add literal prefix + emit(len(prefix)) + if prefix: + code.extend(prefix) + # generate overlap table + table = [-1] + ([0]*len(prefix)) + for i in range(len(prefix)): + table[i+1] = table[i]+1 + while table[i+1] > 0 and prefix[i] != prefix[table[i+1]-1]: + table[i+1] = table[table[i+1]-1]+1 + code.extend(table[1:]) # don't store first entry + code[skip] = len(code) - skip + def compile(p, flags=0): # internal: convert pattern list to internal format + + # compile, as necessary if type(p) in (type(""), type(u"")): ! import sre_parse ! pattern = p ! p = sre_parse.parse(p) else: ! pattern = None ! flags = p.pattern.flags | flags code = [] + + # compile info block + _compile_info(code, p, flags) + + # compile the pattern _compile(code, p.data, flags) + code.append(OPCODES[SUCCESS]) ! ! # FIXME: get rid of this limitation! assert p.pattern.groups <= 100,\ ! "sorry, but this version only supports 100 named groups" ! return _sre.compile( ! pattern, flags, ! array.array(WORDSIZE, code).tostring(), ! p.pattern.groups-1, p.pattern.groupdict ! ) Index: sre_cons.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/sre_cons.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** sre_cons.py 2000/06/29 19:35:29 1.2 --- sre_cons.py 2000/06/30 16:13:37 1.3 *************** *** 24,27 **** --- 24,28 ---- ANY = "any" ASSERT = "assert" + ASSERT_NOT = "assert_not" AT = "at" BRANCH = "branch" *************** *** 82,86 **** ANY, ! ASSERT, AT, BRANCH, --- 83,87 ---- ANY, ! ASSERT, ASSERT_NOT, AT, BRANCH, *************** *** 122,127 **** i = 0 for item in list: ! d[item] = i ! i = i + 1 return d --- 123,128 ---- i = 0 for item in list: ! d[item] = i ! i = i + 1 return d *************** *** 177,186 **** import string def dump(f, d, prefix): ! items = d.items() ! items.sort(lambda a, b: cmp(a[1], b[1])) ! for k, v in items: ! f.write("#define %s_%s %s\n" % (prefix, string.upper(k), v)) f = open("sre_constants.h", "w") ! f.write("/* generated from sre_constants.py */\n") dump(f, OPCODES, "SRE_OP") dump(f, ATCODES, "SRE") --- 178,202 ---- import string def dump(f, d, prefix): ! items = d.items() ! items.sort(lambda a, b: cmp(a[1], b[1])) ! for k, v in items: ! f.write("#define %s_%s %s\n" % (prefix, string.upper(k), v)) f = open("sre_constants.h", "w") ! f.write("""\ ! /* ! * Secret Labs' Regular Expression Engine ! * ! * regular expression matching engine ! * ! * NOTE: This file is generated by sre_constants.py. If you need ! * to change anything in here, edit sre_constants.py and run it. ! * ! * Copyright (c) 1997-2000 by Secret Labs AB. All rights reserved. ! * ! * See the _sre.c file for information on usage and redistribution. ! */ ! ! """) ! dump(f, OPCODES, "SRE_OP") dump(f, ATCODES, "SRE") Index: sre_pars.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dos-8x3/sre_pars.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** sre_pars.py 2000/06/29 19:35:29 1.2 --- sre_pars.py 2000/06/30 16:13:37 1.3 *************** *** 20,23 **** --- 20,26 ---- MAXREPEAT = 32767 + # FIXME: same here + CHARMASK = 0x7fff + SPECIAL_CHARS = ".\\[{()*+?^$|" REPEAT_CHARS = "*+?{" *************** *** 31,54 **** [...1073 lines suppressed...] ! raise error, "empty group" ! a(s) ! return match.string[:0].join(p) --- 615,630 ---- p = [] a = p.append + sep = match.string[:0] + if type(sep) is type(""): + char = chr + else: + char = unichr for c, s in template: ! if c is LITERAL: ! a(char(s)) ! elif c is MARK: ! s = match.group(s) ! if s is None: ! raise error, "empty group" ! a(s) ! return sep.join(p) From python-dev@python.org Fri Jun 30 17:18:59 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 09:18:59 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python getmtime.c,2.9,2.10 import.c,2.135,2.136 Message-ID: <200006301618.JAA31951@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv31939 Modified Files: getmtime.c import.c Log Message: Trent Mick : This patch fixes possible overflow in the use of PyOS_GetLastModificationTime in getmtime.c and Python/import.c. Currently PyOS_GetLastModificationTime returns a C long. This can overflow on Win64 where sizeof(time_t) > sizeof(long). Besides it should logically return a time_t anyway (this patch changes this). As well, import.c uses PyOS_GetLastModificationTime for .pyc timestamping. There has been recent discussion about the .pyc header format on python-dev. This patch adds oveflow checking to import.c so that an exception will be raised if the modification time overflows. There are a few other minor 64-bit readiness changes made to the module as well: - size_t instead of int or long for function-local buffer and string length variables - one buffer overflow check was added (raises an exception on possible overflow, this overflow chance exists on 32-bit platforms as well), no other possible buffer overflows existed (from my analysis anyway) Closes SourceForge patch #100509. Index: getmtime.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/getmtime.c,v retrieving revision 2.9 retrieving revision 2.10 diff -C2 -r2.9 -r2.10 *** getmtime.c 1997/09/05 07:33:15 2.9 --- getmtime.c 2000/06/30 16:18:57 2.10 *************** *** 34,37 **** --- 34,38 ---- /* (A separate file because this may be OS dependent) */ + #include "Python.h" #include "config.h" *************** *** 40,44 **** #include ! long PyOS_GetLastModificationTime(path, fp) char *path; --- 41,45 ---- #include ! time_t PyOS_GetLastModificationTime(path, fp) char *path; Index: import.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/import.c,v retrieving revision 2.135 retrieving revision 2.136 diff -C2 -r2.135 -r2.136 *** import.c 2000/06/30 04:59:17 2.135 --- import.c 2000/06/30 16:18:57 2.136 *************** *** 75,79 **** ! extern long PyOS_GetLastModificationTime(); /* In getmtime.c */ /* Magic word to reject .pyc files generated by other Python versions */ --- 75,79 ---- ! extern time_t PyOS_GetLastModificationTime(); /* In getmtime.c */ /* Magic word to reject .pyc files generated by other Python versions */ *************** *** 550,556 **** char *pathname; char *buf; ! int buflen; { ! int len; len = strlen(pathname); --- 550,556 ---- char *pathname; char *buf; ! size_t buflen; { ! size_t len; len = strlen(pathname); *************** *** 733,737 **** FILE *fp; { ! long mtime; FILE *fpc; char buf[MAXPATHLEN+1]; --- 733,737 ---- FILE *fp; { ! time_t mtime; FILE *fpc; char buf[MAXPATHLEN+1]; *************** *** 741,745 **** mtime = PyOS_GetLastModificationTime(pathname, fp); ! cpathname = make_compiled_pathname(pathname, buf, MAXPATHLEN+1); if (cpathname != NULL && (fpc = check_compiled_module(pathname, mtime, cpathname))) { --- 741,758 ---- mtime = PyOS_GetLastModificationTime(pathname, fp); ! if (mtime == -1) ! return NULL; ! #if SIZEOF_TIME_T > 4 ! /* Python's .pyc timestamp handling presumes that the timestamp fits ! in 4 bytes. This will be fine until sometime in the year 2038, ! when a 4-byte signed time_t will overflow. ! */ ! if (mtime >> 32) { ! PyErr_SetString(PyExc_OverflowError, ! "modification time overflows a 4 bytes"); ! return NULL; ! } ! #endif ! cpathname = make_compiled_pathname(pathname, buf, (size_t)MAXPATHLEN+1); if (cpathname != NULL && (fpc = check_compiled_module(pathname, mtime, cpathname))) { *************** *** 772,776 **** static PyObject *load_module Py_PROTO((char *, FILE *, char *, int)); static struct filedescr *find_module Py_PROTO((char *, PyObject *, ! char *, int, FILE **)); static struct _frozen *find_frozen Py_PROTO((char *name)); --- 785,789 ---- static PyObject *load_module Py_PROTO((char *, FILE *, char *, int)); static struct filedescr *find_module Py_PROTO((char *, PyObject *, ! char *, size_t, FILE **)); static struct _frozen *find_frozen Py_PROTO((char *name)); *************** *** 870,877 **** /* Output parameters: */ char *buf; ! int buflen; FILE **p_fp; { ! int i, npath, len, namelen; struct _frozen *f; struct filedescr *fdp = NULL; --- 883,891 ---- /* Output parameters: */ char *buf; ! size_t buflen; FILE **p_fp; { ! int i, npath; ! size_t len, namelen; struct _frozen *f; struct filedescr *fdp = NULL; *************** *** 883,886 **** --- 897,904 ---- char name[MAXPATHLEN+1]; + if (strlen(realname) > MAXPATHLEN) { + PyErr_SetString(PyExc_OverflowError, "module name is too long"); + return NULL; + } strcpy(name, realname); *************** *** 934,938 **** continue; /* Too long */ strcpy(buf, PyString_AsString(v)); ! if ((int)strlen(buf) != len) continue; /* v contains '\0' */ #ifdef macintosh --- 952,956 ---- continue; /* Too long */ strcpy(buf, PyString_AsString(v)); ! if (strlen(buf) != len) continue; /* v contains '\0' */ #ifdef macintosh *************** *** 1182,1187 **** char *buf; { ! int save_len = strlen(buf); ! int i = save_len; struct stat statbuf; --- 1200,1205 ---- char *buf; { ! size_t save_len = strlen(buf); ! size_t i = save_len; struct stat statbuf; *************** *** 1578,1582 **** char *start = PyString_AS_STRING(modname); char *lastdot = strrchr(start, '.'); ! int len; if (lastdot == NULL) return Py_None; --- 1596,1600 ---- char *start = PyString_AS_STRING(modname); char *lastdot = strrchr(start, '.'); ! size_t len; if (lastdot == NULL) return Py_None; *************** *** 1613,1617 **** char *name = *p_name; char *dot = strchr(name, '.'); ! int len; char *p; PyObject *result; --- 1631,1635 ---- char *name = *p_name; char *dot = strchr(name, '.'); ! size_t len; char *p; PyObject *result; From python-dev@python.org Fri Jun 30 17:20:15 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 09:20:15 -0700 Subject: [Python-checkins] CVS: python/dist/src/Python compile.c,2.109,2.110 Message-ID: <200006301620.JAA32128@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Python In directory slayer.i.sourceforge.net:/tmp/cvs-serv32117/Python Modified Files: compile.c Log Message: Trent Mick : The common technique for printing out a pointer has been to cast to a long and use the "%lx" printf modifier. This is incorrect on Win64 where casting to a long truncates the pointer. The "%p" formatter should be used instead. The problem as stated by Tim: > Unfortunately, the C committee refused to define what %p conversion "looks > like" -- they explicitly allowed it to be implementation-defined. Older > versions of Microsoft C even stuck a colon in the middle of the address (in > the days of segment+offset addressing)! The result is that the hex value of a pointer will maybe/maybe not have a 0x prepended to it. Notes on the patch: There are two main classes of changes: - in the various repr() functions that print out pointers - debugging printf's in the various thread_*.h files (these are why the patch is large) Closes SourceForge patch #100505. Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.109 retrieving revision 2.110 diff -C2 -r2.109 -r2.110 *** compile.c 2000/06/28 22:07:35 2.109 --- compile.c 2000/06/30 16:20:13 2.110 *************** *** 131,136 **** if (co->co_name && PyString_Check(co->co_name)) name = PyString_AsString(co->co_name); ! sprintf(buf, "", ! name, (long)co, filename, lineno); return PyString_FromString(buf); } --- 131,136 ---- if (co->co_name && PyString_Check(co->co_name)) name = PyString_AsString(co->co_name); ! sprintf(buf, "", ! name, co, filename, lineno); return PyString_FromString(buf); } From python-dev@python.org Fri Jun 30 17:21:06 2000 From: python-dev@python.org (Barry Warsaw) Date: Fri, 30 Jun 2000 09:21:06 -0700 Subject: [Python-checkins] CVS: python/dist/src configure,1.121,1.122 configure.in,1.130,1.131 Message-ID: <200006301621.JAA32190@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv31678 Modified Files: configure configure.in Log Message: Enable the garbage collection module by default. --without-cycle-gc disables it. The gc test is moved to just after the thread test, as is the wctype-functions test. Modules/Setup.config is generated instead of Modules/Setup.thread. Applied SF patch #100684 (loewis) to fix help alignment bug. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.121 retrieving revision 1.122 diff -C2 -r1.121 -r1.122 *** configure 2000/06/30 04:57:55 1.121 --- configure 2000/06/30 16:21:00 1.122 *************** *** 1,5 **** #! /bin/sh ! # From configure.in Revision: 1.129 # Guess values for system-dependent variables and create Makefiles. --- 1,5 ---- #! /bin/sh ! # From configure.in Revision: 1.130 [...1824 lines suppressed...] *** 5837,5841 **** s%@LIBM@%$LIBM%g s%@LIBC@%$LIBC%g - s%@USE_GC_MODULE@%$USE_GC_MODULE%g CEOF --- 5843,5846 ---- *************** *** 5884,5888 **** Python/Makefile \ Modules/Makefile.pre \ ! Modules/Setup.thread"} EOF cat >> $CONFIG_STATUS <<\EOF --- 5889,5893 ---- Python/Makefile \ Modules/Makefile.pre \ ! Modules/Setup.config"} EOF cat >> $CONFIG_STATUS <<\EOF Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.130 retrieving revision 1.131 diff -C2 -r1.130 -r1.131 *** configure.in 2000/06/30 04:57:55 1.130 --- configure.in 2000/06/30 16:21:01 1.131 *************** *** 723,726 **** --- 723,754 ---- fi + # Check for GC support + AC_SUBST(USE_GC_MODULE) + USE_GC_MODULE="" + AC_MSG_CHECKING(for --with-cycle-gc) + AC_ARG_WITH(cycle-gc, + [ --with(out)-cycle-gc disable/enable garbage collection]) + + if test -z "$with_cycle_gc" + then with_cycle_gc="yes" + fi + if test "$with_cycle_gc" = "no" + then + USE_GC_MODULE="#" + else + AC_DEFINE(WITH_CYCLE_GC) + fi + AC_MSG_RESULT($with_cycle_gc) + + # Check for --with-wctype-functions + AC_MSG_CHECKING(for --with-wctype-functions) + AC_ARG_WITH(wctype-functions, + [ --with-wctype-functions use wctype.h functions], [ + if test "$withval" != no + then AC_DEFINE(WANT_WCTYPE_FUNCTIONS) AC_MSG_RESULT(yes) + else AC_MSG_RESULT(no) + fi], + [AC_MSG_RESULT(no)]) + # -I${DLINCLDIR} is added to the compile rule for importdl.o AC_SUBST(DLINCLDIR) *************** *** 1107,1131 **** AC_C_BIGENDIAN - # Check for --with-wctype-functions - AC_MSG_CHECKING(for --with-wctype-functions) - AC_ARG_WITH(wctype-functions, - [ --with-wctype-functions use wctype.h functions], [ - if test "$withval" != no - then AC_DEFINE(WANT_WCTYPE_FUNCTIONS) AC_MSG_RESULT(yes) - else AC_MSG_RESULT(no) - fi], - [AC_MSG_RESULT(no)]) - - # Check for GC support - AC_SUBST(USE_GC_MODULE) - USE_GC_MODULE="#" - AC_MSG_CHECKING(for --with-cycle-gc) - AC_ARG_WITH(cycle-gc, [--with-cycle-gc enable garbage collection], [ - AC_MSG_RESULT($withval) - AC_DEFINE(WITH_CYCLE_GC) - USE_GC_MODULE= - ], - AC_MSG_RESULT(no)) - # THIS MUST BE LAST, IT CAN BREAK OTHER TESTS! # Add sys/socket.h to confdefs.h --- 1135,1138 ---- *************** *** 1143,1145 **** Python/Makefile \ Modules/Makefile.pre \ ! Modules/Setup.thread) --- 1150,1152 ---- Python/Makefile \ Modules/Makefile.pre \ ! Modules/Setup.config) From python-dev@python.org Fri Jun 30 17:25:23 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 09:25:23 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_re.py,1.19,1.20 Message-ID: <200006301625.JAA32505@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv32367/test Modified Files: test_re.py Log Message: Switch to sre for regular expression matching (the new mini-re module is actually by Fredrik Lundh). This will break the re tests -- Fredrik will fix this before the final release. Index: test_re.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_re.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -r1.19 -r1.20 *** test_re.py 1998/07/17 20:05:02 1.19 --- test_re.py 2000/06/30 16:25:20 1.20 *************** *** 151,156 **** assert re.split("(:)*", ":a:b::c") == ['', ':', 'a', ':', 'b', ':', 'c'] assert re.split("([b:]+)", ":a:b::c") == ['', ':', 'a', ':b::', 'c'] ! assert re.split("(b)|(:+)", ":a:b::c") == \ ! ['', None, ':', 'a', None, ':', '', 'b', None, '', None, '::', 'c'] assert re.split("(?:b)|(?::+)", ":a:b::c") == ['', 'a', '', '', 'c'] except AssertionError: --- 151,156 ---- assert re.split("(:)*", ":a:b::c") == ['', ':', 'a', ':', 'b', ':', 'c'] assert re.split("([b:]+)", ":a:b::c") == ['', ':', 'a', ':b::', 'c'] ! ## assert re.split("(b)|(:+)", ":a:b::c") == \ ! ## ['', None, ':', 'a', None, ':', '', 'b', None, '', None, '::', 'c'] assert re.split("(?:b)|(?::+)", ":a:b::c") == ['', 'a', '', '', 'c'] except AssertionError: *************** *** 328,334 **** # string), so we'll ignore patterns that feature it. ! if pattern[:2]!='\\B' and pattern[-2:]!='\\B': obj=re.compile(pattern) ! result=obj.search(s, pos=result.start(0), endpos=result.end(0)+1) if result==None: print '=== Failed on range-limited match', t --- 328,334 ---- # string), so we'll ignore patterns that feature it. ! if pattern[:2]!='\\B' and pattern[-2:]!='\\B' and result!=None: obj=re.compile(pattern) ! result=obj.search(s, result.start(0), result.end(0)+1) if result==None: print '=== Failed on range-limited match', t From python-dev@python.org Fri Jun 30 17:25:23 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 09:25:23 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib pre.py,NONE,1.1 re.py,1.35,1.36 Message-ID: <200006301625.JAA32503@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv32367 Modified Files: re.py Added Files: pre.py Log Message: Switch to sre for regular expression matching (the new mini-re module is actually by Fredrik Lundh). This will break the re tests -- Fredrik will fix this before the final release. --- NEW FILE --- # module 're' -- A collection of regular expression operations """Support for regular expressions (RE). This module provides regular expression matching operations similar to those found in Perl. It's 8-bit clean: the strings being processed may contain both null bytes and characters whose high bit is set. Regular expression pattern strings may not contain null bytes, but can specify the null byte using the \\number notation. Characters with the high bit set may be included. Regular expressions can contain both special and ordinary characters. Most ordinary characters, like "A", "a", or "0", are the simplest regular expressions; they simply match themselves. You can concatenate ordinary characters, so last matches the string 'last'. The special characters are: "." Matches any character except a newline. "^" Matches the start of the string. "$" Matches the end of the string. "*" Matches 0 or more (greedy) repetitions of the preceding RE. Greedy means that it will match as many repetitions as possible. "+" Matches 1 or more (greedy) repetitions of the preceding RE. "?" Matches 0 or 1 (greedy) of the preceding RE. *?,+?,?? Non-greedy versions of the previous three special characters. {m,n} Matches from m to n repetitions of the preceding RE. {m,n}? Non-greedy version of the above. "\\" Either escapes special characters or signals a special sequence. [] Indicates a set of characters. A "^" as the first character indicates a complementing set. "|" A|B, creates an RE that will match either A or B. (...) Matches the RE inside the parentheses. The contents can be retrieved or matched later in the string. (?iLmsx) Set the I, L, M, S, or X flag for the RE. (?:...) Non-grouping version of regular parentheses. (?P...) The substring matched by the group is accessible by name. (?P=name) Matches the text matched earlier by the group named name. (?#...) A comment; ignored. (?=...) Matches if ... matches next, but doesn't consume the string. (?!...) Matches if ... doesn't match next. The special sequences consist of "\\" and a character from the list below. If the ordinary character is not on the list, then the resulting RE will match the second character. \\number Matches the contents of the group of the same number. \\A Matches only at the start of the string. \\Z Matches only at the end of the string. \\b Matches the empty string, but only at the start or end of a word. \\B Matches the empty string, but not at the start or end of a word. \\d Matches any decimal digit; equivalent to the set [0-9]. \\D Matches any non-digit character; equivalent to the set [^0-9]. \\s Matches any whitespace character; equivalent to [ \\t\\n\\r\\f\\v]. \\S Matches any non-whitespace character; equiv. to [^ \\t\\n\\r\\f\\v]. \\w Matches any alphanumeric character; equivalent to [a-zA-Z0-9_]. With LOCALE, it will match the set [0-9_] plus characters defined as letters for the current locale. \\W Matches the complement of \\w. \\\\ Matches a literal backslash. This module exports the following functions: match Match a regular expression pattern to the beginning of a string. search Search a string for the presence of a pattern. sub Substitute occurrences of a pattern found in a string. subn Same as sub, but also return the number of substitutions made. split Split a string by the occurrences of a pattern. findall Find all occurrences of a pattern in a string. compile Compile a pattern into a RegexObject. escape Backslash all non-alphanumerics in a string. This module exports the following classes: RegexObject Holds a compiled regular expression pattern. MatchObject Contains information about pattern matches. Some of the functions in this module takes flags as optional parameters: I IGNORECASE Perform case-insensitive matching. L LOCALE Make \w, \W, \b, \B, dependent on the current locale. M MULTILINE "^" matches the beginning of lines as well as the string. "$" matches the end of lines as well as the string. S DOTALL "." matches any character at all, including the newline. X VERBOSE Ignore whitespaces and comments for nicer looking RE's. This module also defines an exception 'error'. """ import sys import string from pcre import * # # First, the public part of the interface: # # pcre.error and re.error should be the same, since exceptions can be # raised from either module. # compilation flags I = IGNORECASE L = LOCALE M = MULTILINE S = DOTALL X = VERBOSE # # # _cache = {} _MAXCACHE = 20 def _cachecompile(pattern, flags=0): key = (pattern, flags) try: return _cache[key] except KeyError: pass value = compile(pattern, flags) if len(_cache) >= _MAXCACHE: _cache.clear() _cache[key] = value return value def match(pattern, string, flags=0): """match (pattern, string[, flags]) -> MatchObject or None If zero or more characters at the beginning of string match the regular expression pattern, return a corresponding MatchObject instance. Return None if the string does not match the pattern; note that this is different from a zero-length match. Note: If you want to locate a match anywhere in string, use search() instead. """ return _cachecompile(pattern, flags).match(string) def search(pattern, string, flags=0): """search (pattern, string[, flags]) -> MatchObject or None Scan through string looking for a location where the regular expression pattern produces a match, and return a corresponding MatchObject instance. Return None if no position in the string matches the pattern; note that this is different from finding a zero-length match at some point in the string. """ return _cachecompile(pattern, flags).search(string) def sub(pattern, repl, string, count=0): """sub(pattern, repl, string[, count=0]) -> string Return the string obtained by replacing the leftmost non-overlapping occurrences of pattern in string by the replacement repl. If the pattern isn't found, string is returned unchanged. repl can be a string or a function; if a function, it is called for every non-overlapping occurrence of pattern. The function takes a single match object argument, and returns the replacement string. The pattern may be a string or a regex object; if you need to specify regular expression flags, you must use a regex object, or use embedded modifiers in a pattern; e.g. sub("(?i)b+", "x", "bbbb BBBB") returns 'x x'. The optional argument count is the maximum number of pattern occurrences to be replaced; count must be a non-negative integer, and the default value of 0 means to replace all occurrences. """ if type(pattern) == type(''): pattern = _cachecompile(pattern) return pattern.sub(repl, string, count) def subn(pattern, repl, string, count=0): """subn(pattern, repl, string[, count=0]) -> (string, num substitutions) Perform the same operation as sub(), but return a tuple (new_string, number_of_subs_made). """ if type(pattern) == type(''): pattern = _cachecompile(pattern) return pattern.subn(repl, string, count) def split(pattern, string, maxsplit=0): """split(pattern, string[, maxsplit=0]) -> list of strings Split string by the occurrences of pattern. If capturing parentheses are used in pattern, then the text of all groups in the pattern are also returned as part of the resulting list. If maxsplit is nonzero, at most maxsplit splits occur, and the remainder of the string is returned as the final element of the list. """ if type(pattern) == type(''): pattern = _cachecompile(pattern) return pattern.split(string, maxsplit) def findall(pattern, string): """findall(pattern, string) -> list Return a list of all non-overlapping matches of pattern in string. If one or more groups are present in the pattern, return a list of groups; this will be a list of tuples if the pattern has more than one group. Empty matches are included in the result. """ if type(pattern) == type(''): pattern = _cachecompile(pattern) return pattern.findall(string) def escape(pattern): """escape(string) -> string Return string with all non-alphanumerics backslashed; this is useful if you want to match an arbitrary literal string that may have regular expression metacharacters in it. """ result = list(pattern) alphanum=string.letters+'_'+string.digits for i in range(len(pattern)): char = pattern[i] if char not in alphanum: if char=='\000': result[i] = '\\000' else: result[i] = '\\'+char return string.join(result, '') def compile(pattern, flags=0): """compile(pattern[, flags]) -> RegexObject Compile a regular expression pattern into a regular expression object, which can be used for matching using its match() and search() methods. """ groupindex={} code=pcre_compile(pattern, flags, groupindex) return RegexObject(pattern, flags, code, groupindex) # # Class definitions # class RegexObject: """Holds a compiled regular expression pattern. Methods: match Match the pattern to the beginning of a string. search Search a string for the presence of the pattern. sub Substitute occurrences of the pattern found in a string. subn Same as sub, but also return the number of substitutions made. split Split a string by the occurrences of the pattern. findall Find all occurrences of the pattern in a string. """ def __init__(self, pattern, flags, code, groupindex): self.code = code self.flags = flags self.pattern = pattern self.groupindex = groupindex def search(self, string, pos=0, endpos=None): """search(string[, pos][, endpos]) -> MatchObject or None Scan through string looking for a location where this regular expression produces a match, and return a corresponding MatchObject instance. Return None if no position in the string matches the pattern; note that this is different from finding a zero-length match at some point in the string. The optional pos and endpos parameters have the same meaning as for the match() method. """ if endpos is None or endpos>len(string): endpos=len(string) if endpos MatchObject or None If zero or more characters at the beginning of string match this regular expression, return a corresponding MatchObject instance. Return None if the string does not match the pattern; note that this is different from a zero-length match. Note: If you want to locate a match anywhere in string, use search() instead. The optional second parameter pos gives an index in the string where the search is to start; it defaults to 0. This is not completely equivalent to slicing the string; the '' pattern character matches at the real beginning of the string and at positions just after a newline, but not necessarily at the index where the search is to start. The optional parameter endpos limits how far the string will be searched; it will be as if the string is endpos characters long, so only the characters from pos to endpos will be searched for a match. """ if endpos is None or endpos>len(string): endpos=len(string) if endpos string Return the string obtained by replacing the leftmost non-overlapping occurrences of the compiled pattern in string by the replacement repl. If the pattern isn't found, string is returned unchanged. Identical to the sub() function, using the compiled pattern. """ return self.subn(repl, string, count)[0] def subn(self, repl, source, count=0): """subn(repl, string[, count=0]) -> tuple Perform the same operation as sub(), but return a tuple (new_string, number_of_subs_made). """ if count < 0: raise error, "negative substitution count" if count == 0: count = sys.maxint n = 0 # Number of matches pos = 0 # Where to start searching lastmatch = -1 # End of last match results = [] # Substrings making up the result end = len(source) if type(repl) is type(''): # See if repl contains group references try: repl = pcre_expand(_Dummy, repl) except: m = MatchObject(self, source, 0, end, []) repl = lambda m, repl=repl, expand=pcre_expand: expand(m, repl) else: m = None else: m = MatchObject(self, source, 0, end, []) match = self.code.match append = results.append while n < count and pos <= end: regs = match(source, pos, end, 0) if not regs: break self._num_regs = len(regs) i, j = regs[0] if i == j == lastmatch: # Empty match adjacent to previous match pos = pos + 1 append(source[lastmatch:pos]) continue if pos < i: append(source[pos:i]) if m: m.pos = pos m.regs = regs append(repl(m)) else: append(repl) pos = lastmatch = j if i == j: # Last match was empty; don't try here again pos = pos + 1 append(source[lastmatch:pos]) n = n + 1 append(source[pos:]) return (string.join(results, ''), n) def split(self, source, maxsplit=0): """split(source[, maxsplit=0]) -> list of strings Split string by the occurrences of the compiled pattern. If capturing parentheses are used in the pattern, then the text of all groups in the pattern are also returned as part of the resulting list. If maxsplit is nonzero, at most maxsplit splits occur, and the remainder of the string is returned as the final element of the list. """ if maxsplit < 0: raise error, "negative split count" if maxsplit == 0: maxsplit = sys.maxint n = 0 pos = 0 lastmatch = 0 results = [] end = len(source) match = self.code.match append = results.append while n < maxsplit: regs = match(source, pos, end, 0) if not regs: break i, j = regs[0] if i == j: # Empty match if pos >= end: break pos = pos+1 continue append(source[lastmatch:i]) rest = regs[1:] if rest: for a, b in rest: if a == -1 or b == -1: group = None else: group = source[a:b] append(group) pos = lastmatch = j n = n + 1 append(source[lastmatch:]) return results def findall(self, source): """findall(source) -> list Return a list of all non-overlapping matches of the compiled pattern in string. If one or more groups are present in the pattern, return a list of groups; this will be a list of tuples if the pattern has more than one group. Empty matches are included in the result. """ pos = 0 end = len(source) results = [] match = self.code.match append = results.append while pos <= end: regs = match(source, pos, end, 0) if not regs: break i, j = regs[0] rest = regs[1:] if not rest: gr = source[i:j] elif len(rest) == 1: a, b = rest[0] gr = source[a:b] else: gr = [] for (a, b) in rest: gr.append(source[a:b]) gr = tuple(gr) append(gr) pos = max(j, pos+1) return results # The following 3 functions were contributed by Mike Fletcher, and # allow pickling and unpickling of RegexObject instances. def __getinitargs__(self): return (None,None,None,None) # any 4 elements, to work around # problems with the # pickle/cPickle modules not yet # ignoring the __init__ function def __getstate__(self): return self.pattern, self.flags, self.groupindex def __setstate__(self, statetuple): self.pattern = statetuple[0] self.flags = statetuple[1] self.groupindex = statetuple[2] self.code = apply(pcre_compile, statetuple) class _Dummy: # Dummy class used by _subn_string(). Has 'group' to avoid core dump. group = None class MatchObject: """Holds a compiled regular expression pattern. Methods: start Return the index of the start of a matched substring. end Return the index of the end of a matched substring. span Return a tuple of (start, end) of a matched substring. groups Return a tuple of all the subgroups of the match. group Return one or more subgroups of the match. groupdict Return a dictionary of all the named subgroups of the match. """ def __init__(self, re, string, pos, endpos, regs): self.re = re self.string = string self.pos = pos self.endpos = endpos self.regs = regs def start(self, g = 0): """start([group=0]) -> int or None Return the index of the start of the substring matched by group; group defaults to zero (meaning the whole matched substring). Return None if group exists but did not contribute to the match. """ if type(g) == type(''): try: g = self.re.groupindex[g] except (KeyError, TypeError): raise IndexError, 'group %s is undefined' % `g` return self.regs[g][0] def end(self, g = 0): """end([group=0]) -> int or None Return the indices of the end of the substring matched by group; group defaults to zero (meaning the whole matched substring). Return None if group exists but did not contribute to the match. """ if type(g) == type(''): try: g = self.re.groupindex[g] except (KeyError, TypeError): raise IndexError, 'group %s is undefined' % `g` return self.regs[g][1] def span(self, g = 0): """span([group=0]) -> tuple Return the 2-tuple (m.start(group), m.end(group)). Note that if group did not contribute to the match, this is (None, None). Group defaults to zero (meaning the whole matched substring). """ if type(g) == type(''): try: g = self.re.groupindex[g] except (KeyError, TypeError): raise IndexError, 'group %s is undefined' % `g` return self.regs[g] def groups(self, default=None): """groups([default=None]) -> tuple Return a tuple containing all the subgroups of the match, from 1 up to however many groups are in the pattern. The default argument is used for groups that did not participate in the match. """ result = [] for g in range(1, self.re._num_regs): a, b = self.regs[g] if a == -1 or b == -1: result.append(default) else: result.append(self.string[a:b]) return tuple(result) def group(self, *groups): """group([group1, group2, ...]) -> string or tuple Return one or more subgroups of the match. If there is a single argument, the result is a single string; if there are multiple arguments, the result is a tuple with one item per argument. Without arguments, group1 defaults to zero (i.e. the whole match is returned). If a groupN argument is zero, the corresponding return value is the entire matching string; if it is in the inclusive range [1..99], it is the string matching the the corresponding parenthesized group. If a group number is negative or larger than the number of groups defined in the pattern, an IndexError exception is raised. If a group is contained in a part of the pattern that did not match, the corresponding result is None. If a group is contained in a part of the pattern that matched multiple times, the last match is returned. If the regular expression uses the (?P...) syntax, the groupN arguments may also be strings identifying groups by their group name. If a string argument is not used as a group name in the pattern, an IndexError exception is raised. """ if len(groups) == 0: groups = (0,) result = [] for g in groups: if type(g) == type(''): try: g = self.re.groupindex[g] except (KeyError, TypeError): raise IndexError, 'group %s is undefined' % `g` if g >= len(self.regs): raise IndexError, 'group %s is undefined' % `g` a, b = self.regs[g] if a == -1 or b == -1: result.append(None) else: result.append(self.string[a:b]) if len(result) > 1: return tuple(result) elif len(result) == 1: return result[0] else: return () def groupdict(self, default=None): """groupdict([default=None]) -> dictionary Return a dictionary containing all the named subgroups of the match, keyed by the subgroup name. The default argument is used for groups that did not participate in the match. """ dict = {} for name, index in self.re.groupindex.items(): a, b = self.regs[index] if a == -1 or b == -1: dict[name] = default else: dict[name] = self.string[a:b] return dict Index: re.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/re.py,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -r1.35 -r1.36 *** re.py 1999/11/15 14:19:15 1.35 --- re.py 2000/06/30 16:25:20 1.36 *************** *** 1,652 **** ! # module 're' -- A collection of regular expression operations ! """Support for regular expressions (RE). ! This module provides regular expression matching operations similar to ! those found in Perl. It's 8-bit clean: the strings being processed may ! contain both null bytes and characters whose high bit is set. Regular ! expression pattern strings may not contain null bytes, but can specify ! the null byte using the \\number notation. Characters with the high ! bit set may be included. ! ! Regular expressions can contain both special and ordinary ! characters. Most ordinary characters, like "A", "a", or "0", are the ! simplest regular expressions; they simply match themselves. You can ! concatenate ordinary characters, so last matches the string 'last'. ! ! The special characters are: ! "." Matches any character except a newline. ! "^" Matches the start of the string. ! "$" Matches the end of the string. ! "*" Matches 0 or more (greedy) repetitions of the preceding RE. ! Greedy means that it will match as many repetitions as possible. ! "+" Matches 1 or more (greedy) repetitions of the preceding RE. ! "?" Matches 0 or 1 (greedy) of the preceding RE. ! *?,+?,?? Non-greedy versions of the previous three special characters. ! {m,n} Matches from m to n repetitions of the preceding RE. ! {m,n}? Non-greedy version of the above. ! "\\" Either escapes special characters or signals a special sequence. ! [] Indicates a set of characters. ! A "^" as the first character indicates a complementing set. ! "|" A|B, creates an RE that will match either A or B. ! (...) Matches the RE inside the parentheses. ! The contents can be retrieved or matched later in the string. ! (?iLmsx) Set the I, L, M, S, or X flag for the RE. ! (?:...) Non-grouping version of regular parentheses. ! (?P...) The substring matched by the group is accessible by name. ! (?P=name) Matches the text matched earlier by the group named name. ! (?#...) A comment; ignored. ! (?=...) Matches if ... matches next, but doesn't consume the string. ! (?!...) Matches if ... doesn't match next. ! ! The special sequences consist of "\\" and a character from the list ! below. If the ordinary character is not on the list, then the ! resulting RE will match the second character. ! \\number Matches the contents of the group of the same number. ! \\A Matches only at the start of the string. ! \\Z Matches only at the end of the string. ! \\b Matches the empty string, but only at the start or end of a word. ! \\B Matches the empty string, but not at the start or end of a word. ! \\d Matches any decimal digit; equivalent to the set [0-9]. ! \\D Matches any non-digit character; equivalent to the set [^0-9]. ! \\s Matches any whitespace character; equivalent to [ \\t\\n\\r\\f\\v]. ! \\S Matches any non-whitespace character; equiv. to [^ \\t\\n\\r\\f\\v]. ! \\w Matches any alphanumeric character; equivalent to [a-zA-Z0-9_]. ! With LOCALE, it will match the set [0-9_] plus characters defined ! as letters for the current locale. ! \\W Matches the complement of \\w. ! \\\\ Matches a literal backslash. ! ! This module exports the following functions: ! match Match a regular expression pattern to the beginning of a string. ! search Search a string for the presence of a pattern. ! sub Substitute occurrences of a pattern found in a string. ! subn Same as sub, but also return the number of substitutions made. ! split Split a string by the occurrences of a pattern. ! findall Find all occurrences of a pattern in a string. ! compile Compile a pattern into a RegexObject. ! escape Backslash all non-alphanumerics in a string. ! ! This module exports the following classes: ! RegexObject Holds a compiled regular expression pattern. ! MatchObject Contains information about pattern matches. ! ! Some of the functions in this module takes flags as optional parameters: ! I IGNORECASE Perform case-insensitive matching. ! L LOCALE Make \w, \W, \b, \B, dependent on the current locale. ! M MULTILINE "^" matches the beginning of lines as well as the string. ! "$" matches the end of lines as well as the string. ! S DOTALL "." matches any character at all, including the newline. ! X VERBOSE Ignore whitespaces and comments for nicer looking RE's. ! ! This module also defines an exception 'error'. ! ! """ ! ! ! import sys ! import string ! from pcre import * ! ! # ! # First, the public part of the interface: ! # ! ! # pcre.error and re.error should be the same, since exceptions can be ! # raised from either module. ! ! # compilation flags ! ! I = IGNORECASE ! L = LOCALE ! M = MULTILINE ! S = DOTALL ! X = VERBOSE ! ! ! # ! # ! # ! ! _cache = {} ! _MAXCACHE = 20 ! ! def _cachecompile(pattern, flags=0): ! key = (pattern, flags) ! try: ! return _cache[key] ! except KeyError: ! pass ! value = compile(pattern, flags) ! if len(_cache) >= _MAXCACHE: ! _cache.clear() ! _cache[key] = value ! return value ! ! def match(pattern, string, flags=0): ! """match (pattern, string[, flags]) -> MatchObject or None ! ! If zero or more characters at the beginning of string match the ! regular expression pattern, return a corresponding MatchObject ! instance. Return None if the string does not match the pattern; ! note that this is different from a zero-length match. ! ! Note: If you want to locate a match anywhere in string, use ! search() instead. ! ! """ ! ! return _cachecompile(pattern, flags).match(string) ! ! def search(pattern, string, flags=0): ! """search (pattern, string[, flags]) -> MatchObject or None ! ! Scan through string looking for a location where the regular ! expression pattern produces a match, and return a corresponding ! MatchObject instance. Return None if no position in the string ! matches the pattern; note that this is different from finding a ! zero-length match at some point in the string. ! ! """ ! return _cachecompile(pattern, flags).search(string) ! ! def sub(pattern, repl, string, count=0): ! """sub(pattern, repl, string[, count=0]) -> string ! ! Return the string obtained by replacing the leftmost ! non-overlapping occurrences of pattern in string by the ! replacement repl. If the pattern isn't found, string is returned ! unchanged. repl can be a string or a function; if a function, it ! is called for every non-overlapping occurrence of pattern. The ! function takes a single match object argument, and returns the ! replacement string. ! ! The pattern may be a string or a regex object; if you need to ! specify regular expression flags, you must use a regex object, or ! use embedded modifiers in a pattern; e.g. ! sub("(?i)b+", "x", "bbbb BBBB") returns 'x x'. ! ! The optional argument count is the maximum number of pattern ! occurrences to be replaced; count must be a non-negative integer, ! and the default value of 0 means to replace all occurrences. ! ! """ ! if type(pattern) == type(''): ! pattern = _cachecompile(pattern) ! return pattern.sub(repl, string, count) ! ! def subn(pattern, repl, string, count=0): ! """subn(pattern, repl, string[, count=0]) -> (string, num substitutions) ! ! Perform the same operation as sub(), but return a tuple ! (new_string, number_of_subs_made). ! ! """ ! if type(pattern) == type(''): ! pattern = _cachecompile(pattern) ! return pattern.subn(repl, string, count) ! ! def split(pattern, string, maxsplit=0): ! """split(pattern, string[, maxsplit=0]) -> list of strings ! ! Split string by the occurrences of pattern. If capturing ! parentheses are used in pattern, then the text of all groups in ! the pattern are also returned as part of the resulting list. If ! maxsplit is nonzero, at most maxsplit splits occur, and the ! remainder of the string is returned as the final element of the ! list. ! ! """ ! if type(pattern) == type(''): ! pattern = _cachecompile(pattern) ! return pattern.split(string, maxsplit) ! ! def findall(pattern, string): ! """findall(pattern, string) -> list ! ! Return a list of all non-overlapping matches of pattern in ! string. If one or more groups are present in the pattern, return a ! list of groups; this will be a list of tuples if the pattern has ! more than one group. Empty matches are included in the result. ! ! """ ! if type(pattern) == type(''): ! pattern = _cachecompile(pattern) ! return pattern.findall(string) ! ! def escape(pattern): ! """escape(string) -> string ! ! Return string with all non-alphanumerics backslashed; this is ! useful if you want to match an arbitrary literal string that may ! have regular expression metacharacters in it. ! ! """ ! result = list(pattern) ! alphanum=string.letters+'_'+string.digits ! for i in range(len(pattern)): ! char = pattern[i] ! if char not in alphanum: ! if char=='\000': result[i] = '\\000' ! else: result[i] = '\\'+char ! return string.join(result, '') ! ! def compile(pattern, flags=0): ! """compile(pattern[, flags]) -> RegexObject ! ! Compile a regular expression pattern into a regular expression ! object, which can be used for matching using its match() and ! search() methods. ! ! """ ! groupindex={} ! code=pcre_compile(pattern, flags, groupindex) ! return RegexObject(pattern, flags, code, groupindex) ! ! ! # ! # Class definitions ! # ! ! class RegexObject: ! """Holds a compiled regular expression pattern. ! ! Methods: ! match Match the pattern to the beginning of a string. ! search Search a string for the presence of the pattern. ! sub Substitute occurrences of the pattern found in a string. ! subn Same as sub, but also return the number of substitutions made. ! split Split a string by the occurrences of the pattern. ! findall Find all occurrences of the pattern in a string. ! ! """ ! ! def __init__(self, pattern, flags, code, groupindex): ! self.code = code ! self.flags = flags ! self.pattern = pattern ! self.groupindex = groupindex ! ! def search(self, string, pos=0, endpos=None): ! """search(string[, pos][, endpos]) -> MatchObject or None ! ! Scan through string looking for a location where this regular ! expression produces a match, and return a corresponding ! MatchObject instance. Return None if no position in the string ! matches the pattern; note that this is different from finding ! a zero-length match at some point in the string. The optional ! pos and endpos parameters have the same meaning as for the ! match() method. ! ! """ ! if endpos is None or endpos>len(string): ! endpos=len(string) ! if endpos MatchObject or None ! ! If zero or more characters at the beginning of string match ! this regular expression, return a corresponding MatchObject ! instance. Return None if the string does not match the ! pattern; note that this is different from a zero-length match. ! ! Note: If you want to locate a match anywhere in string, use ! search() instead. ! ! The optional second parameter pos gives an index in the string ! where the search is to start; it defaults to 0. This is not ! completely equivalent to slicing the string; the '' pattern ! character matches at the real beginning of the string and at ! positions just after a newline, but not necessarily at the ! index where the search is to start. ! ! The optional parameter endpos limits how far the string will ! be searched; it will be as if the string is endpos characters ! long, so only the characters from pos to endpos will be ! searched for a match. ! ! """ ! if endpos is None or endpos>len(string): ! endpos=len(string) ! if endpos string ! ! Return the string obtained by replacing the leftmost ! non-overlapping occurrences of the compiled pattern in string ! by the replacement repl. If the pattern isn't found, string is ! returned unchanged. ! ! Identical to the sub() function, using the compiled pattern. ! ! """ ! return self.subn(repl, string, count)[0] ! ! def subn(self, repl, source, count=0): ! """subn(repl, string[, count=0]) -> tuple ! ! Perform the same operation as sub(), but return a tuple ! (new_string, number_of_subs_made). ! ! """ ! if count < 0: ! raise error, "negative substitution count" ! if count == 0: ! count = sys.maxint ! n = 0 # Number of matches ! pos = 0 # Where to start searching ! lastmatch = -1 # End of last match ! results = [] # Substrings making up the result ! end = len(source) ! ! if type(repl) is type(''): ! # See if repl contains group references ! try: ! repl = pcre_expand(_Dummy, repl) ! except: ! m = MatchObject(self, source, 0, end, []) ! repl = lambda m, repl=repl, expand=pcre_expand: expand(m, repl) ! else: ! m = None ! else: ! m = MatchObject(self, source, 0, end, []) ! ! match = self.code.match ! append = results.append ! while n < count and pos <= end: ! regs = match(source, pos, end, 0) ! if not regs: ! break ! self._num_regs = len(regs) ! i, j = regs[0] ! if i == j == lastmatch: ! # Empty match adjacent to previous match ! pos = pos + 1 ! append(source[lastmatch:pos]) ! continue ! if pos < i: ! append(source[pos:i]) ! if m: ! m.pos = pos ! m.regs = regs ! append(repl(m)) ! else: ! append(repl) ! pos = lastmatch = j ! if i == j: ! # Last match was empty; don't try here again ! pos = pos + 1 ! append(source[lastmatch:pos]) ! n = n + 1 ! append(source[pos:]) ! return (string.join(results, ''), n) ! ! def split(self, source, maxsplit=0): ! """split(source[, maxsplit=0]) -> list of strings ! ! Split string by the occurrences of the compiled pattern. If ! capturing parentheses are used in the pattern, then the text ! of all groups in the pattern are also returned as part of the ! resulting list. If maxsplit is nonzero, at most maxsplit ! splits occur, and the remainder of the string is returned as ! the final element of the list. ! ! """ ! if maxsplit < 0: ! raise error, "negative split count" ! if maxsplit == 0: ! maxsplit = sys.maxint ! n = 0 ! pos = 0 ! lastmatch = 0 ! results = [] ! end = len(source) ! match = self.code.match ! append = results.append ! while n < maxsplit: ! regs = match(source, pos, end, 0) ! if not regs: ! break ! i, j = regs[0] ! if i == j: ! # Empty match ! if pos >= end: ! break ! pos = pos+1 ! continue ! append(source[lastmatch:i]) ! rest = regs[1:] ! if rest: ! for a, b in rest: ! if a == -1 or b == -1: ! group = None ! else: ! group = source[a:b] ! append(group) ! pos = lastmatch = j ! n = n + 1 ! append(source[lastmatch:]) ! return results ! ! def findall(self, source): ! """findall(source) -> list ! ! Return a list of all non-overlapping matches of the compiled ! pattern in string. If one or more groups are present in the ! pattern, return a list of groups; this will be a list of ! tuples if the pattern has more than one group. Empty matches ! are included in the result. ! ! """ ! pos = 0 ! end = len(source) ! results = [] ! match = self.code.match ! append = results.append ! while pos <= end: ! regs = match(source, pos, end, 0) ! if not regs: ! break ! i, j = regs[0] ! rest = regs[1:] ! if not rest: ! gr = source[i:j] ! elif len(rest) == 1: ! a, b = rest[0] ! gr = source[a:b] ! else: ! gr = [] ! for (a, b) in rest: ! gr.append(source[a:b]) ! gr = tuple(gr) ! append(gr) ! pos = max(j, pos+1) ! return results ! ! # The following 3 functions were contributed by Mike Fletcher, and ! # allow pickling and unpickling of RegexObject instances. ! def __getinitargs__(self): ! return (None,None,None,None) # any 4 elements, to work around ! # problems with the ! # pickle/cPickle modules not yet ! # ignoring the __init__ function ! def __getstate__(self): ! return self.pattern, self.flags, self.groupindex ! def __setstate__(self, statetuple): ! self.pattern = statetuple[0] ! self.flags = statetuple[1] ! self.groupindex = statetuple[2] ! self.code = apply(pcre_compile, statetuple) ! ! class _Dummy: ! # Dummy class used by _subn_string(). Has 'group' to avoid core dump. ! group = None ! ! class MatchObject: ! """Holds a compiled regular expression pattern. ! ! Methods: ! start Return the index of the start of a matched substring. ! end Return the index of the end of a matched substring. ! span Return a tuple of (start, end) of a matched substring. ! groups Return a tuple of all the subgroups of the match. ! group Return one or more subgroups of the match. ! groupdict Return a dictionary of all the named subgroups of the match. ! ! """ ! ! def __init__(self, re, string, pos, endpos, regs): ! self.re = re ! self.string = string ! self.pos = pos ! self.endpos = endpos ! self.regs = regs ! ! def start(self, g = 0): ! """start([group=0]) -> int or None ! ! Return the index of the start of the substring matched by ! group; group defaults to zero (meaning the whole matched ! substring). Return None if group exists but did not contribute ! to the match. ! ! """ ! if type(g) == type(''): ! try: ! g = self.re.groupindex[g] ! except (KeyError, TypeError): ! raise IndexError, 'group %s is undefined' % `g` ! return self.regs[g][0] ! ! def end(self, g = 0): ! """end([group=0]) -> int or None ! ! Return the indices of the end of the substring matched by ! group; group defaults to zero (meaning the whole matched ! substring). Return None if group exists but did not contribute ! to the match. ! ! """ ! if type(g) == type(''): ! try: ! g = self.re.groupindex[g] ! except (KeyError, TypeError): ! raise IndexError, 'group %s is undefined' % `g` ! return self.regs[g][1] ! ! def span(self, g = 0): ! """span([group=0]) -> tuple ! ! Return the 2-tuple (m.start(group), m.end(group)). Note that ! if group did not contribute to the match, this is (None, ! None). Group defaults to zero (meaning the whole matched ! substring). ! ! """ ! if type(g) == type(''): ! try: ! g = self.re.groupindex[g] ! except (KeyError, TypeError): ! raise IndexError, 'group %s is undefined' % `g` ! return self.regs[g] ! ! def groups(self, default=None): ! """groups([default=None]) -> tuple ! ! Return a tuple containing all the subgroups of the match, from ! 1 up to however many groups are in the pattern. The default ! argument is used for groups that did not participate in the ! match. ! ! """ ! result = [] ! for g in range(1, self.re._num_regs): ! a, b = self.regs[g] ! if a == -1 or b == -1: ! result.append(default) ! else: ! result.append(self.string[a:b]) ! return tuple(result) ! ! def group(self, *groups): ! """group([group1, group2, ...]) -> string or tuple ! ! Return one or more subgroups of the match. If there is a ! single argument, the result is a single string; if there are ! multiple arguments, the result is a tuple with one item per ! argument. Without arguments, group1 defaults to zero (i.e. the ! whole match is returned). If a groupN argument is zero, the ! corresponding return value is the entire matching string; if ! it is in the inclusive range [1..99], it is the string ! matching the the corresponding parenthesized group. If a group ! number is negative or larger than the number of groups defined ! in the pattern, an IndexError exception is raised. If a group ! is contained in a part of the pattern that did not match, the ! corresponding result is None. If a group is contained in a ! part of the pattern that matched multiple times, the last ! match is returned. ! ! If the regular expression uses the (?P...) syntax, the ! groupN arguments may also be strings identifying groups by ! their group name. If a string argument is not used as a group ! name in the pattern, an IndexError exception is raised. ! ! """ ! if len(groups) == 0: ! groups = (0,) ! result = [] ! for g in groups: ! if type(g) == type(''): ! try: ! g = self.re.groupindex[g] ! except (KeyError, TypeError): ! raise IndexError, 'group %s is undefined' % `g` ! if g >= len(self.regs): ! raise IndexError, 'group %s is undefined' % `g` ! a, b = self.regs[g] ! if a == -1 or b == -1: ! result.append(None) ! else: ! result.append(self.string[a:b]) ! if len(result) > 1: ! return tuple(result) ! elif len(result) == 1: ! return result[0] ! else: ! return () ! ! def groupdict(self, default=None): ! """groupdict([default=None]) -> dictionary ! ! Return a dictionary containing all the named subgroups of the ! match, keyed by the subgroup name. The default argument is ! used for groups that did not participate in the match. ! ! """ ! dict = {} ! for name, index in self.re.groupindex.items(): ! a, b = self.regs[index] ! if a == -1 or b == -1: ! dict[name] = default ! else: ! dict[name] = self.string[a:b] ! return dict --- 1,11 ---- ! # change this to "pre" if your regexps stopped working. don't ! # forget to send a bug report to ! engine = "sre" ! if engine == "sre": ! # new 2.0 engine ! from sre import * ! else: ! # old 1.5.2 engine. will be removed in 2.0 final. ! from pre import * From python-dev@python.org Fri Jun 30 17:39:29 2000 From: python-dev@python.org (Skip Montanaro) Date: Fri, 30 Jun 2000 09:39:29 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test regrtest.py,1.16,1.17 Message-ID: <200006301639.JAA00851@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv843 Modified Files: regrtest.py Log Message: * added a randomize flag and corresponding -r command line argument that allows the caller to execute the various tests in pseudo-random order - default is still to execute tests in the order returned by findtests(). * moved initialization of the various flag variables to the main() function definition, making it possible to execute regrtest.main() interactively and still override default behavior. Index: regrtest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** regrtest.py 2000/05/05 14:27:39 1.16 --- regrtest.py 2000/06/30 16:39:27 1.17 *************** *** 14,17 **** --- 14,18 ---- -x: exclude -- arguments are tests to *exclude* -s: single -- run only a single test (see below) + -r: random -- randomize test execution order If non-option arguments are present, they are names for tests to run, *************** *** 34,41 **** import getopt import traceback import test_support ! def main(tests=None, testdir=None): """Execute a test suite. --- 35,44 ---- import getopt import traceback + import random import test_support ! def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, ! exclude=0, single=0, randomize=0): """Execute a test suite. *************** *** 53,70 **** command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. ! """ try: ! opts, args = getopt.getopt(sys.argv[1:], 'vgqxs') except getopt.error, msg: print msg print __doc__ return 2 - verbose = 0 - quiet = 0 - generate = 0 - exclude = 0 - single = 0 for o, a in opts: if o == '-v': verbose = verbose+1 --- 56,72 ---- command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. ! ! The other six default arguments (verbose, quiet, generate, exclude, ! single, and randomize) allow programmers calling main() directly to ! set the values that would normally be set by flags on the command ! line. """ try: ! opts, args = getopt.getopt(sys.argv[1:], 'vgqxsr') except getopt.error, msg: print msg print __doc__ return 2 for o, a in opts: if o == '-v': verbose = verbose+1 *************** *** 73,76 **** --- 75,79 ---- if o == '-x': exclude = 1 if o == '-s': single = 1 + if o == '-r': randomize = 1 if generate and verbose: print "-g and -v don't go together!" *************** *** 105,108 **** --- 108,113 ---- if single: tests = tests[:1] + if randomize: + random.shuffle(tests) test_support.verbose = verbose # Tell tests to be moderately quiet save_modules = sys.modules.keys() From python-dev@python.org Fri Jun 30 17:39:37 2000 From: python-dev@python.org (Barry Warsaw) Date: Fri, 30 Jun 2000 09:39:37 -0700 Subject: [Python-checkins] CVS: python/dist/src configure,1.122,1.123 configure.in,1.131,1.132 Message-ID: <200006301639.JAA00863@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv730 Modified Files: configure configure.in Log Message: Document --with-thread as deprecated. This gets rid of the annoying newline in configure --help. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.122 retrieving revision 1.123 diff -C2 -r1.122 -r1.123 *** configure 2000/06/30 16:21:00 1.122 --- configure 2000/06/30 16:39:35 1.123 *************** *** 1,5 **** #! /bin/sh ! # From configure.in Revision: 1.130 # Guess values for system-dependent variables and create Makefiles. --- 1,5 ---- #! /bin/sh ! # From configure.in Revision: 1.131 [...2128 lines suppressed...] echo $ac_n "checking for socklen_t""... $ac_c" 1>&6 ! echo "configure:5640: checking for socklen_t" >&5 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 < --- 5638,5647 ---- EOF echo $ac_n "checking for socklen_t""... $ac_c" 1>&6 ! echo "configure:5641: checking for socklen_t" >&5 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 < Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.131 retrieving revision 1.132 diff -C2 -r1.131 -r1.132 *** configure.in 2000/06/30 16:21:01 1.131 --- configure.in 2000/06/30 16:39:35 1.132 *************** *** 662,666 **** # --with-thread is deprecated, but check for it anyway ! AC_ARG_WITH(thread,,[with_threads=$with_thread]) if test -z "$with_threads" --- 662,668 ---- # --with-thread is deprecated, but check for it anyway ! AC_ARG_WITH(thread, ! [ --with(out)-thread[=DIRECTORY] deprecated; use --with(out)-threads],[ ! with_threads=$with_thread]) if test -z "$with_threads" From python-dev@python.org Fri Jun 30 18:30:21 2000 From: python-dev@python.org (Jeremy Hylton) Date: Fri, 30 Jun 2000 10:30:21 -0700 Subject: [Python-checkins] CVS: python/dist/src README,1.86,1.87 Message-ID: <200006301730.KAA10046@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv9905 Modified Files: README Log Message: add note about what happened to Python 1.6 also, fix type (not caught by Rob Hooft, but could have been :-) Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/README,v retrieving revision 1.86 retrieving revision 1.87 diff -C2 -r1.86 -r1.87 *** README 2000/06/29 22:28:44 1.86 --- README 2000/06/30 17:30:18 1.87 *************** *** 21,25 **** enterprise customers are often fearful of anything that's version 1.x! The new version number also clearly marks departure of Python's core ! development teal from CNRI to join BeOpen.com. Previously, the version number 2.0 was associated with a mythical and --- 21,29 ---- enterprise customers are often fearful of anything that's version 1.x! The new version number also clearly marks departure of Python's core ! development team from CNRI to join BeOpen.com. ! ! What happened to Python 1.6? It was promoted and renamed Python 2.0. ! There were two alpha releases of Python 1.6 before we decided to ! increment the major version number. Previously, the version number 2.0 was associated with a mythical and From python-dev@python.org Fri Jun 30 18:48:54 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 10:48:54 -0700 Subject: [Python-checkins] CVS: python/dist/src/PC msvcrtmodule.c,1.4,1.5 _winreg.c,1.5,1.6 Message-ID: <200006301748.KAA11055@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv11047/PC Modified Files: msvcrtmodule.c _winreg.c Log Message: [*** Not tested as I don't have Windows running right now! ***] Trent Mick : Fix PC/msvcrtmodule.c and PC/winreg.c for Win64. Basically: - sizeof(HKEY) > sizeof(long) on Win64, so use PyLong_FromVoidPtr() instead of PyInt_FromLong() to return HKEY values on Win64 - Check for string overflow of an arbitrary registry value (I know that ensuring that a registry value does not overflow 2**31 characters seems ridiculous but it is *possible*). Closes SourceForge patch #100517. Index: msvcrtmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/msvcrtmodule.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** msvcrtmodule.c 1999/02/16 19:40:02 1.4 --- msvcrtmodule.c 2000/06/30 17:48:51 1.5 *************** *** 91,95 **** { int fd; ! long handle; if (!PyArg_ParseTuple(args,"i:get_osfhandle", &fd)) --- 91,95 ---- { int fd; ! intptr_t handle; if (!PyArg_ParseTuple(args,"i:get_osfhandle", &fd)) *************** *** 100,104 **** return PyErr_SetFromErrno(PyExc_IOError); ! return PyInt_FromLong(handle); } --- 100,107 ---- return PyErr_SetFromErrno(PyExc_IOError); ! /* technically 'handle' is not a pointer, but a integer as ! large as a pointer, Python's *VoidPtr interface is the ! most appropriate here */ ! return PyLong_FromVoidPtr((void*)handle); } Index: _winreg.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/_winreg.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** _winreg.c 2000/06/29 19:17:04 1.5 --- _winreg.c 2000/06/30 17:48:51 1.6 *************** *** 593,597 **** if (PyErr_Occurred()) return FALSE; - *pHANDLE = (HKEY)PyInt_AsLong(ob); } else { --- 593,596 ---- *************** *** 629,632 **** --- 628,632 ---- ok = PyHKEY_Close(obHandle); } + #if SIZEOF_LONG >= SIZEOF_HKEY else if (PyInt_Check(obHandle)) { long rc = RegCloseKey((HKEY)PyInt_AsLong(obHandle)); *************** *** 635,638 **** --- 635,646 ---- PyErr_SetFromWindowsErrWithFunction(rc, "RegCloseKey"); } + #else + else if (PyLong_Check(obHandle)) { + long rc = RegCloseKey((HKEY)PyLong_AsVoidPtr(obHandle)); + ok = (rc == ERROR_SUCCESS); + if (!ok) + PyErr_SetFromWindowsErrWithFunction(rc, "RegCloseKey"); + } + #endif else { PyErr_SetString( *************** *** 881,891 **** fixupMultiSZ(str, retDataBuf, retDataSize); obData = PyList_New(s); for (index = 0; index < s; index++) { PyList_SetItem(obData, index, PyUnicode_DecodeMBCS( (const char *)str[index], ! _mbstrlen(str[index]), NULL) ); --- 889,908 ---- fixupMultiSZ(str, retDataBuf, retDataSize); obData = PyList_New(s); + if (obData == NULL) + return NULL; for (index = 0; index < s; index++) { + size_t len = _mbstrlen(str[index]); + if (len > INT_MAX) { + PyErr_SetString(PyExc_OverflowError, + "registry string is too long for a Python string"); + Py_DECREF(obData); + return NULL; + } PyList_SetItem(obData, index, PyUnicode_DecodeMBCS( (const char *)str[index], ! (int)len, NULL) ); From python-dev@python.org Fri Jun 30 18:57:08 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 10:57:08 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/texinputs python.sty,1.60,1.61 Message-ID: <200006301757.KAA11755@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/texinputs In directory slayer.i.sourceforge.net:/tmp/cvs-serv11742/texinputs Modified Files: python.sty Log Message: Try to make sure \code always uses roman (non-italic) text. Change a 1.6 version number used in a an example in a comment to 2.0. Index: python.sty =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/texinputs/python.sty,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -r1.60 -r1.61 *** python.sty 2000/05/09 16:18:44 1.60 --- python.sty 2000/06/30 17:57:05 1.61 *************** *** 711,715 **** % code is the most difficult one... ! \newcommand{\code}[1]{{\@vobeyspaces\@noligs\def\{{\char`\{}\def\}{\char`\}}\def\~{\char`\~}\def\^{\char`\^}\def\e{\char`\\}\def\${\char`\$}\def\#{\char`\#}\def\&{\char`\&}\def\%{\char`\%}% \texttt{#1}}} --- 711,715 ---- % code is the most difficult one... ! \newcommand{\code}[1]{\textrm{\@vobeyspaces\@noligs\def\{{\char`\{}\def\}{\char`\}}\def\~{\char`\~}\def\^{\char`\^}\def\e{\char`\\}\def\${\char`\$}\def\#{\char`\#}\def\&{\char`\&}\def\%{\char`\%}% \texttt{#1}}} *************** *** 839,843 **** % Example: % \versionadded{1.5.2} ! % \versionchanged[short explanation]{1.6} % \newcommand{\versionadded}[1]{% --- 839,843 ---- % Example: % \versionadded{1.5.2} ! % \versionchanged[short explanation]{2.0} % \newcommand{\versionadded}[1]{% From python-dev@python.org Fri Jun 30 18:58:36 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 10:58:36 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/ext ext.tex,1.77,1.78 Message-ID: <200006301758.KAA11837@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/ext In directory slayer.i.sourceforge.net:/tmp/cvs-serv11830/ext Modified Files: ext.tex Log Message: Small grammatical correction from Frank Stajano. Added comment with suggestion from Frank for an example and further explanation. Index: ext.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/ext.tex,v retrieving revision 1.77 retrieving revision 1.78 diff -C2 -r1.77 -r1.78 *** ext.tex 2000/06/28 16:15:08 1.77 --- ext.tex 2000/06/30 17:58:34 1.78 *************** *** 1399,1403 **** arguments is that functions often pass the objects they receive on to other function --- if each function were to test for \NULL{}, ! there would be a lot of redundant tests and the code would run slower. It is better to test for \NULL{} only at the ``source'', i.e.\ when a --- 1399,1404 ---- arguments is that functions often pass the objects they receive on to other function --- if each function were to test for \NULL{}, ! there would be a lot of redundant tests and the code would run more ! slowly. It is better to test for \NULL{} only at the ``source'', i.e.\ when a *************** *** 1423,1427 **** It is a severe error to ever let a \NULL{} pointer ``escape'' to ! the Python user. --- 1424,1434 ---- It is a severe error to ever let a \NULL{} pointer ``escape'' to ! the Python user. ! ! % Frank Stajano: ! % A pedagogically buggy example, along the lines of the previous listing, ! % would be helpful here -- showing in more concrete terms what sort of ! % actions could cause the problem. I can't very well imagine it from the ! % description. From python-dev@python.org Fri Jun 30 19:39:23 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 11:39:23 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre_compile.py,1.16,1.17 sre_parse.py,1.16,1.17 Message-ID: <200006301839.LAA20318@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv20255/Lib Modified Files: sre_compile.py sre_parse.py Log Message: - reverted to "\x is binary byte" - removed evil tabs from sre_parse and sre_compile Index: sre_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** sre_compile.py 2000/06/30 13:55:14 1.16 --- sre_compile.py 2000/06/30 18:39:20 1.17 *************** *** 40,44 **** else: emit(OPCODES[op]) ! fixup = lambda x: x skip = len(code); emit(0) for op, av in av: --- 40,44 ---- else: emit(OPCODES[op]) ! fixup = lambda x: x skip = len(code); emit(0) for op, av in av: Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** sre_parse.py 2000/06/30 13:55:14 1.16 --- sre_parse.py 2000/06/30 18:39:20 1.17 *************** *** 20,25 **** MAXREPEAT = 32767 ! # FIXME: same here ! CHARMASK = 0x7fff SPECIAL_CHARS = ".\\[{()*+?^$|" --- 20,26 ---- MAXREPEAT = 32767 ! # FIXME: might change in 2.0 final. but for now, this seems ! # to be the best way to be compatible with 1.5.2 ! CHARMASK = 0xff SPECIAL_CHARS = ".\\[{()*+?^$|" *************** *** 617,623 **** sep = match.string[:0] if type(sep) is type(""): ! char = chr else: ! char = unichr for c, s in template: if c is LITERAL: --- 618,624 ---- sep = match.string[:0] if type(sep) is type(""): ! char = chr else: ! char = unichr for c, s in template: if c is LITERAL: From python-dev@python.org Fri Jun 30 19:39:23 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 11:39:23 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_sre,1.4,1.5 Message-ID: <200006301839.LAA20322@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv20255/Lib/test/output Modified Files: test_sre Log Message: - reverted to "\x is binary byte" - removed evil tabs from sre_parse and sre_compile Index: test_sre =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_sre,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** test_sre 2000/06/30 13:55:15 1.4 --- test_sre 2000/06/30 18:39:20 1.5 *************** *** 1,4 **** test_sre - === Failed incorrectly ('\\x00ffffffffffffff', '\377', 0, 'found', '\377') === Failed incorrectly ('^(.+)?B', 'AB', 0, 'g1', 'A') === Failed incorrectly ('(a+)+\\1', 'aa', 0, 'found+"-"+g1', 'aa-a') --- 1,3 ---- From python-dev@python.org Fri Jun 30 19:41:04 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 11:41:04 -0700 Subject: [Python-checkins] CVS: python/dist/src/Misc COPYRIGHT,1.4,1.5 Message-ID: <200006301841.LAA20523@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Misc In directory slayer.i.sourceforge.net:/tmp/cvs-serv20516/Misc Modified Files: COPYRIGHT Log Message: The new copyright / license. Index: COPYRIGHT =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/COPYRIGHT,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** COPYRIGHT 1996/10/25 13:45:43 1.4 --- COPYRIGHT 2000/06/30 18:41:01 1.5 *************** *** 1,27 **** ! Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, ! The Netherlands. ! All Rights Reserved ! Permission to use, copy, modify, and distribute this software and its ! documentation for any purpose and without fee is hereby granted, ! provided that the above copyright notice appear in all copies and that ! both that copyright notice and this permission notice appear in ! supporting documentation, and that the names of Stichting Mathematisch ! Centrum or CWI or Corporation for National Research Initiatives or ! CNRI not be used in advertising or publicity pertaining to ! distribution of the software without specific, written prior ! permission. ! While CWI is the initial source for this software, a modified version ! is made available by the Corporation for National Research Initiatives ! (CNRI) at the Internet address ftp://ftp.python.org. ! STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH ! REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF ! MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH ! CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL ! DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR ! PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER ! TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR ! PERFORMANCE OF THIS SOFTWARE. --- 1,31 ---- ! Copyright (c) 2000, BeOpen.com. ! Copyright (c) 1995-2000, Corporation for National Research Initiatives. ! Copyright (c) 1990-1995, Stichting Mathematisch Centrum. ! All rights reserved. ! Redistribution and use in source and binary forms, with or without ! modification, are permitted provided that the following conditions are ! met: ! - Redistributions of source code must retain the above copyright ! notice, this list of conditions and the following disclaimer. ! - Redistributions in binary form must reproduce the above copyright ! notice, this list of conditions and the following disclaimer in the ! documentation and/or other materials provided with the distribution. ! - Neither names of the copyright holders nor the names of their ! contributors may be used to endorse or promote products derived from ! this software without specific prior written permission. ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ! A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR ! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, ! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR ! PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ! LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ! NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ! SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. From python-dev@python.org Fri Jun 30 18:35:20 2000 From: python-dev@python.org (Skip Montanaro) Date: Fri, 30 Jun 2000 12:35:20 -0500 (CDT) Subject: [Python-checkins] CVS: python/dist/src/Misc COPYRIGHT,1.4,1.5 In-Reply-To: <200006301841.LAA20523@slayer.i.sourceforge.net> References: <200006301841.LAA20523@slayer.i.sourceforge.net> Message-ID: <14684.55896.890339.982232@beluga.mojam.com> Fred> The new copyright / license. ... Fred> ! ... IN NO EVENT SHALL THE REGENTS OR Fred> ! CONTRIBUTORS BE LIABLE FOR ... Who are the "regents" and the "contributors"? Should those terms be defined somewhere? not-a-lawyer-and-never-wanted-to-be-ly y'rs, -- Skip Montanaro, skip@mojam.com, http://www.mojam.com/, http://www.musi-cal.com/ On Phil Jackson's ability to manage multiple Lakers superstars, Shaquille O'Neal said: "He's got the rings. I listen to the man with the rings." From python-dev@python.org Fri Jun 30 20:25:44 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 12:25:44 -0700 Subject: [Python-checkins] CVS: python/dist/src/Doc/paper-a4 .cvsignore,1.7,1.8 Message-ID: <200006301925.MAA29446@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Doc/paper-a4 In directory slayer.i.sourceforge.net:/tmp/cvs-serv29439/paper-a4 Modified Files: .cvsignore Log Message: Ignore the generated api.tex. Index: .cvsignore =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/paper-a4/.cvsignore,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** .cvsignore 1999/03/16 16:14:51 1.7 --- .cvsignore 2000/06/30 19:25:41 1.8 *************** *** 14,15 **** --- 14,16 ---- *.how README + api.tex From python-dev@python.org Fri Jun 30 20:33:37 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 12:33:37 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib whrandom.py,1.16,1.17 Message-ID: <200006301933.MAA29761@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv29748/Lib Modified Files: whrandom.py Log Message: Line-wrap and properly indent a couple of docstrings. Index: whrandom.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/whrandom.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** whrandom.py 2000/02/28 15:12:25 1.16 --- whrandom.py 2000/06/30 19:33:35 1.17 *************** *** 83,87 **** def randint(self, a, b): ! """Get a random integer in the range [a, b] including both end points. (Deprecated; use randrange below.)""" return self.randrange(a, b+1) --- 83,89 ---- def randint(self, a, b): ! """Get a random integer in the range [a, b] including ! both end points. ! (Deprecated; use randrange below.)""" return self.randrange(a, b+1) *************** *** 92,99 **** def randrange(self, start, stop=None, step=1, int=int, default=None): ! """Choose a random item from range([start,] step[, stop]). This fixes the problem with randint() which includes the endpoint; in Python this is usually not what you want. ! Do not supply the 'int' and 'default' arguments.""" # This code is a bit messy to make it fast for the # common case while still doing adequate error checking --- 94,102 ---- def randrange(self, start, stop=None, step=1, int=int, default=None): ! """Choose a random item from range(start, stop[, step]). ! This fixes the problem with randint() which includes the endpoint; in Python this is usually not what you want. ! Do not supply the 'int' and 'default' arguments.""" # This code is a bit messy to make it fast for the # common case while still doing adequate error checking From python-dev@python.org Fri Jun 30 20:36:25 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 12:36:25 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test test_winreg2.py,NONE,1.1 Message-ID: <200006301936.MAA29995@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test In directory slayer.i.sourceforge.net:/tmp/cvs-serv29987/Lib/test Added Files: test_winreg2.py Log Message: Paul Prescod : Regression test for the new winreg.py module. [Could a Windows person someone please review this?] --- NEW FILE --- from winreg import hives, createKey, openKey, flags, deleteKey, regtypes import sys, traceback import time def testHives(): hivenames = ["HKEY_CLASSES_ROOT","HKEY_CURRENT_USER","HKEY_LOCAL_MACHINE", "HKEY_USERS","HKEY_CURRENT_CONFIG"] #, # for hivename in hivenames: hive = hives[ hivename ] print hive.name assert hive.handle assert hive.getSubkeys() for hivename in ["HKEY_DYN_DATA", "HKEY_PERFORMANCE_DATA"]: hive = hives[ hivename ] print hive.name assert hive.handle assert not hive.getValues() assert not hive.getSubkeys() def testNonZero(): key=hives["HKLM"].openSubkey( "SOFTWARE" ) assert key.openSubkey( "Microsoft" ) assert key key.close() assert not key try: key.openSubkey( "Microsoft" ) assert 0 except EnvironmentError: pass def testCmp(): HKLM=hives["HKLM"] assert (openKey("HKLM\\SOFTWARE")==\ HKLM.openSubkey("SOFTWARE")) assert not HKLM.openSubkey("SYSTEM")!=HKLM.openSubkey("SYSTEM") assert HKLM.openSubkey("SOFTWARE")!=HKLM.openSubkey("SYSTEM") assert not HKLM.openSubkey("SOFTWARE")==HKLM.openSubkey("SYSTEM") assert not HKLM.openSubkey("SOFTWARE")=="spam" assert ((HKLM.openSubkey("SOFTWARE")<"spam") != (HKLM.openSubkey("SOFTWARE")>"spam")) def testClose(): key=hives["HKLM"].openSubkey( "SOFTWARE" ) assert key key.close() assert not key def testOpen(): assert openKey( r"HKLM" ) assert openKey( r"HKLM\HARDWARE" ) assert openKey( r"HKLM\HARDWARE\DESCRIPTION\System" ) def testOpenFailure(): try: print openKey( r"HKCU\Software\Python\A\B\C\D" ) assert 0 # except EnvironmentError: pass def testDeleteKey(): createKey( r"HKCU\Software\Python\A\B\C\D" ) deleteKey( r"HKCU\Software\Python\A\B\C\D" ) deleteKey( r"HKCU\Software\Python\A\B\C" ) deleteKey( r"HKCU\Software\Python\A\B" ) assert "A" in \ openKey(r"HKCU\Software\Python").getSubkeys().keys() openKey( r"HKCU\Software\Python" ).deleteSubkey( r"A" ) assert "A" not in \ openKey(r"HKCU\Software\Python").getSubkeys().keys() def testDeleteValue(): key=createKey( r"HKCU\Software\Python\A" ) key.setValue( "abcde", "fghij" ) assert key.getValueData( "abcde" )=="fghij" assert "abcde" in key.getValues().keys() assert "fghij" in map( lambda x:x[1], key.getValues().values() ) assert "abcde" in key.getValues().keys() key.deleteValue( "abcde" ) assert "abcde" not in key.getValues().keys() assert "fghij" not in map( lambda x:x[1], key.getValues().values() ) deleteKey( r"HKCU\Software\Python\A" ) def testCreateKey(): key=createKey( r"HKCU\Software\Python\A" ) assert openKey( r"HKCU\Software\Python").getSubkeys().has_key( "A" ) deleteKey( r"HKCU\Software\Python\A" ) assert not openKey( r"HKCU\Software\Python").getSubkeys().\ has_key( "A" ) key=openKey( r"HKCU\Software\Python" ).createSubkey( "A" ) def testOpenKeyWithFlags(): assert openKey( r"HKCU\Software\Python", flags["KEY_READ"]) assert openKey( r"HKCU\Software\Python", flags["KEY_ALL_ACCESS"]) def testGetSubkeys(): keys=openKey( r"HKCU\Software" ).getSubkeys() assert keys index=0 for i in keys: index=index+1 assert index==len( keys ) def testGetValueNameDataAndType(): pass def testGetSubkeyNames(): subkeyNames=hives["HKLM"].getSubkeyNames() assert len( subkeyNames )==len(hives["HKLM"].getSubkeys()) for name in subkeyNames: assert type( name )==type("") def testGetValueNames(): valNames=hives["HKLM"].getValueNames() assert len( valNames )==len(hives["HKLM"].getValues()) for name in valNames: assert type( name )==type("") def testRepr(): assert repr(hives["HKCU"])==str(hives["HKCU"]) def testSetStringValue(): hives["HKCU"].setValue( "Blah", "abc" ) assert hives["HKCU"].getValueData( "Blah" )=="abc" assert hives["HKCU"].getValues().has_key( "Blah" ) del hives["HKCU"].getValues()[ "Blah" ] assert not hives["HKCU"].getValues().has_key( "Blah" ) def testDeleteValue(): hives["HKCU"].setValue( "Blah", "abc" ) assert hives["HKCU"].getValues().has_key( "Blah" ) del hives["HKCU"].getValues()[ "Blah" ] assert not hives["HKCU"].getValues().has_key( "Blah" ) hives["HKCU"].setValue( "Blah", "abc" ) hives["HKCU"].deleteValue( "Blah" ) assert not hives["HKCU"].getValues().has_key( "Blah" ) def testKeyDict_ClearKeys(): createKey( "HKLM\\Software\\a\\b\\c\\d\\e" ) createKey( "HKLM\\Software\\a\\b\\c\\d\\f" ) createKey( "HKLM\\Software\\a\\b\\c\\d\\g" ) createKey( "HKLM\\Software\\a\\b\\c\\d\\h" ) createKey( "HKLM\\Software\\a\\b\\c\\d\\i" ) key=openKey( "HKLM\\Software\\a\\b\\c\\d" ) assert key.getSubkeys() key.getSubkeys().clear() assert not key.getSubkeys() assert not openKey( "HKLM\\Software\\a\\b\\c\\d").getSubkeys() deleteKey( "HKLM\\Software\\a\\b\\c\\d" ) deleteKey( "HKLM\\Software\\a\\b\\c" ) deleteKey( "HKLM\\Software\\a\\b" ) deleteKey( "HKLM\\Software\\a" ) def testUnicodeKeyName(): pass def testUnicodeValueName(): pass def testGetValueDataFromEnum(): pass def testGetValueDataFromName(): pass def testGetBinaryData(): pass def testSetIntValue(): key=createKey( "HKLM\\Software\\a\\b") key.setValue( "abcd", 5 ) assert key.getValueData( "abcd" )==5 assert key.getValues()[ "abcd" ][1]==5 key.deleteValue( "abcd" ) key.getValues()["abcd"]=5 assert key.getValues()[ "abcd" ][1]==5 key.deleteValue( "abcd" ) key.getValues()["abcd"]=(5,regtypes["REG_DWORD"]) assert key.getValues()[ "abcd" ][1]==5 key.deleteValue( "abcd" ) key.deleteKey( "HKLM\\Software\\a\\b") key.deleteKey( "HKLM\\Software\\a") def testSetBinaryValue(): key=createKey( "HKLM\\Software\\a\\b") key.setValue( "abcd", array.array( 'c', "PPPPPPPPPPPPPPP") ) key.setValue( "abcde", array.array( 'c', "PPPPPPPPPPPPPPP"), regtypes["REG_BINARY"] ) assert key.getValues()["abcd"]==key.getValues()["abcde"] key.deleteKey( "HKLM\\Software\\a\\b") key.deleteKey( "HKLM\\Software\\a") def testSetNone(): pass def testSetString(): pass def testSetExpandString(): pass def testSetBinaryData(): pass def testSetDword(): pass def testSetDwordBigEndian(): pass def testSetLink(): pass def testSetMultiSz(): pass def testSetResourceList(): pass def testSetFullResourceDescription(): pass def testSetResourceRequirementsList(): pass def testFlush(): pass def testSave(): pass def testLoad(): pass def testNoneType(): pass def testStringType(): pass def testExpandStringType(): pass def testDWordType(): pass def testDWordBigEndianType(): pass def testLinkType(): pass def testMultiStringType(): pass def testResourceLinkType(): pass def testResourceDescriptionType(): pass def testResourceRequirementsListType(): pass def getSubkeysDict(): pass def testKeyDict_Get(): pass def testKeyDict_HasKey(): pass def testKeyDict_Keys(): pass def testKeyDict_Values(): pass def testKeyDict_Items(): pass def testKeyDict_Length(): pass def testKeyDict_Map(): pass def testKeyDict_GetItem(): pass def testKeyDict_DelItem(): pass def testRemote(): pass def testShortcuts(): pass def getValues(): pass def testValueDict_ClearKeys(): pass def testValueDict_Get(): pass def testValueDict_HasKey(): pass def testValueDict_Keys(): pass def testValueDict_Values(): pass def testValueDict_Items(): pass def testValueDict_Length(): pass def testValueDict_Map(): pass def testValueDict_GetItem(): pass def testValueDict_DelItem(): pass for name in globals().keys(): if name[0:4]=="test": func=globals()[ name ] try: func() print "Test Passed: %s" % name except Exception, e: print "Test Failed: %s" % name traceback.print_exc() j=[0]*len( regtypes ) k=0 def test1( basekey ): global k for (name, data, type) in basekey.getValues(): j[type.intval]=j[type.intval]+1 if j[type.intval]==1: pass #print "[[%s]] %s [%s] = %s "% (type.msname, name, basekey, value) keys=basekey.getSubkeys() index=0 k=k+1 if(k%2500)==0: dump() while 1: try: test1( keys[index] ) index=index+1 except IndexError: break print "Done", basekey, index except (WindowsError, EnvironmentError): index=index+1 dumpfile.write( "Skipping %s %s"% (basekey, index)) def dump(dumpfile): for i in range( len( j )): dumpfile.write( "%s %s\n" %( i,j[i] )) def testRecursive(): dumpfile=open( "foo.txt", "w" ) start=time.time() for hive in hives.values(): dumpfile.write( "Hive: %s\n" % hive ) test1( hive ) dump(dumpfile) print time.time()-start From python-dev@python.org Fri Jun 30 20:38:02 2000 From: python-dev@python.org (Greg Ward) Date: Fri, 30 Jun 2000 12:38:02 -0700 Subject: [Python-checkins] CVS: distutils/distutils msvccompiler.py,1.34,1.35 Message-ID: <200006301938.MAA30140@slayer.i.sourceforge.net> Update of /cvsroot/python/distutils/distutils In directory slayer.i.sourceforge.net:/tmp/cvs-serv30132 Modified Files: msvccompiler.py Log Message: Simplify the registry-module-finding code: _winreg or win32api/win32con. This'll work fine with 2.0 or 1.5.2, but is less than ideal for 1.6a1/a2. But the code to accomodate 1.6a1/a2 was released with Distutils 0.9, so it can go away now. Index: msvccompiler.py =================================================================== RCS file: /cvsroot/python/distutils/distutils/msvccompiler.py,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -r1.34 -r1.35 *** msvccompiler.py 2000/06/29 23:04:59 1.34 --- msvccompiler.py 2000/06/30 19:37:59 1.35 *************** *** 21,28 **** _can_read_reg = 0 try: ! try: ! import _winreg ! except ImportError: ! import winreg # for pre-2000/06/29 CVS Python _can_read_reg = 1 --- 21,25 ---- _can_read_reg = 0 try: ! import _winreg _can_read_reg = 1 From python-dev@python.org Fri Jun 30 20:38:18 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 12:38:18 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/test/output test_winreg2,NONE,1.1 Message-ID: <200006301938.MAA30170@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/test/output In directory slayer.i.sourceforge.net:/tmp/cvs-serv30161/Lib/test/output Added Files: test_winreg2 Log Message: Output for test_winreg2. Someone who knows what they are doing needs to replace this with something that makes sense -- I'm not running Windows right now. --- NEW FILE --- test_winreg2 From python-dev@python.org Fri Jun 30 21:22:39 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 13:22:39 -0700 Subject: [Python-checkins] CVS: python/dist/src/Misc COPYRIGHT,1.5,1.6 Message-ID: <200006302022.NAA06700@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Misc In directory slayer.i.sourceforge.net:/tmp/cvs-serv6688 Modified Files: COPYRIGHT Log Message: s/REGENTS/COPYRIGHT HOLDERS/ followed by paragraph reflow. Index: COPYRIGHT =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/COPYRIGHT,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** COPYRIGHT 2000/06/30 18:41:01 1.5 --- COPYRIGHT 2000/06/30 20:22:36 1.6 *************** *** 22,31 **** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ! A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR ! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ! EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, ! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR ! PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ! LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ! NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ! SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --- 22,32 ---- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ! A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ! HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ! INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, ! BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS ! OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ! ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR ! TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE ! USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH ! DAMAGE. From python-dev@python.org Fri Jun 30 22:23:09 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 16:23:09 -0500 Subject: [Python-Dev] Re: [Python-checkins] CVS: python/dist/src/Misc COPYRIGHT,1.4,1.5 In-Reply-To: Your message of "Fri, 30 Jun 2000 12:35:20 EST." <14684.55896.890339.982232@beluga.mojam.com> References: <200006301841.LAA20523@slayer.i.sourceforge.net> <14684.55896.890339.982232@beluga.mojam.com> Message-ID: <200006302123.QAA20537@cj20424-a.reston1.va.home.com> > Fred> The new copyright / license. > ... > Fred> ! ... IN NO EVENT SHALL THE REGENTS OR > Fred> ! CONTRIBUTORS BE LIABLE FOR ... > > Who are the "regents" and the "contributors"? Should those terms be > defined somewhere? Oops. I thought I caught all the regents and replaced them with a more politically correct term. Seems one got away. Fixed now. > not-a-lawyer-and-never-wanted-to-be-ly y'rs, Ditto, --Guido van Rossum (home page: http://www.python.org/~guido/) From python-dev@python.org Fri Jun 30 21:30:05 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 13:30:05 -0700 Subject: [Python-checkins] CVS: python/dist/src/PCbuild python20.dsp,1.2,1.3 Message-ID: <200006302030.NAA07601@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PCbuild In directory slayer.i.sourceforge.net:/tmp/cvs-serv7578 Modified Files: python20.dsp Log Message: Add back a missing CRLF line ending. Index: python20.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/python20.dsp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** python20.dsp 2000/06/30 14:38:41 1.2 --- python20.dsp 2000/06/30 20:30:03 1.3 *************** *** 672,676 **** !ENDIF ! # End Source File # Begin Source File --- 672,676 ---- !ENDIF ! # End Source File # Begin Source File From python-dev@python.org Fri Jun 30 21:31:41 2000 From: python-dev@python.org (Fred L. Drake) Date: Fri, 30 Jun 2000 13:31:41 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib/plat-win winreg.py,1.1,1.2 Message-ID: <200006302031.NAA07859@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib/plat-win In directory slayer.i.sourceforge.net:/tmp/cvs-serv7849/Lib/plat-win Modified Files: winreg.py Log Message: Ooops! I didn't finish all the renaming needed here, so this was attempting a recursive import and causing a fatal error. Index: winreg.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-win/winreg.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** winreg.py 2000/06/29 16:53:06 1.1 --- winreg.py 2000/06/30 20:31:39 1.2 *************** *** 1,3 **** ! import winreg import sys import exceptions --- 1,3 ---- ! import _winreg import sys import exceptions *************** *** 10,14 **** self.msname=msname self.friendlyname=friendlyname ! self.intval=getattr( winreg, msname ) def __repr__( self ): --- 10,14 ---- self.msname=msname self.friendlyname=friendlyname ! self.intval=getattr( _winreg, msname ) def __repr__( self ): *************** *** 17,44 **** _typeConstants={ ! winreg.REG_NONE: RegType( "REG_NONE", "None" ), ! winreg.REG_SZ: RegType( "REG_SZ", "String" ), ! winreg.REG_EXPAND_SZ: RegType("REG_EXPAND_SZ", "Expandable Template String" ), ! winreg.REG_BINARY: RegType("REG_BINARY", "Binary Data"), ! winreg.REG_DWORD : RegType("REG_DWORD", "Integer" ), ! # winreg.REG_DWORD_LITTLE_ENDIAN : # RegType("REG_DWORD_LITTLE_ENDIAN", "Integer"), ! winreg.REG_DWORD_BIG_ENDIAN : RegType("REG_DWORD_BIG_ENDIAN", "Big Endian Integer"), ! winreg.REG_LINK : RegType("REG_LINK", "Link"), ! winreg.REG_MULTI_SZ : RegType("REG_MULTI_SZ", "List of Strings"), ! winreg.REG_RESOURCE_LIST : RegType("REG_RESOURCE_LIST", "Resource List"), ! winreg.REG_FULL_RESOURCE_DESCRIPTOR : RegType( "REG_FULL_RESOURCE_DESCRIPTOR", "Full Resource Descriptor" ), ! winreg.REG_RESOURCE_REQUIREMENTS_LIST: RegType( "REG_RESOURCE_REQUIREMENTS_LIST", "Resource Requirements List" ) --- 17,44 ---- _typeConstants={ ! _winreg.REG_NONE: RegType( "REG_NONE", "None" ), ! _winreg.REG_SZ: RegType( "REG_SZ", "String" ), ! _winreg.REG_EXPAND_SZ: RegType("REG_EXPAND_SZ", "Expandable Template String" ), ! _winreg.REG_BINARY: RegType("REG_BINARY", "Binary Data"), ! _winreg.REG_DWORD : RegType("REG_DWORD", "Integer" ), ! # _winreg.REG_DWORD_LITTLE_ENDIAN : # RegType("REG_DWORD_LITTLE_ENDIAN", "Integer"), ! _winreg.REG_DWORD_BIG_ENDIAN : RegType("REG_DWORD_BIG_ENDIAN", "Big Endian Integer"), ! _winreg.REG_LINK : RegType("REG_LINK", "Link"), ! _winreg.REG_MULTI_SZ : RegType("REG_MULTI_SZ", "List of Strings"), ! _winreg.REG_RESOURCE_LIST : RegType("REG_RESOURCE_LIST", "Resource List"), ! _winreg.REG_FULL_RESOURCE_DESCRIPTOR : RegType( "REG_FULL_RESOURCE_DESCRIPTOR", "Full Resource Descriptor" ), ! _winreg.REG_RESOURCE_REQUIREMENTS_LIST: RegType( "REG_RESOURCE_REQUIREMENTS_LIST", "Resource Requirements List" ) *************** *** 129,133 **** class RegKeysDict( _DictBase ): def _nameFromNum( self, item ): ! return winreg.EnumKey( self.key.handle, item ) def __getitem__( self, item ): --- 129,133 ---- class RegKeysDict( _DictBase ): def _nameFromNum( self, item ): ! return _winreg.EnumKey( self.key.handle, item ) def __getitem__( self, item ): *************** *** 163,167 **** class RegKey: def _nameFromNum( self, item ): ! (name,data,datatype)=winreg.EnumValue( self.handle, item ) return name --- 163,167 ---- class RegKey: def _nameFromNum( self, item ): ! (name,data,datatype)=_winreg.EnumValue( self.handle, item ) return name *************** *** 186,190 **** def close(self ): ! return winreg.CloseKey( self.handle ) def getSubkeyNames( self ): --- 186,190 ---- def close(self ): ! return _winreg.CloseKey( self.handle ) def getSubkeyNames( self ): *************** *** 195,212 **** def deleteSubkey( self, subkey ): ! return winreg.DeleteKey( self.handle, subkey ) def deleteValue( self, valname ): ! return winreg.DeleteValue( self.handle, valname ) def createSubkey( self, keyname ): ! handle=winreg.CreateKey( self.handle, keyname ) return RegKey( self.name+"\\"+keyname, handle) def openSubkey( self, keyname, samFlags=None ): if samFlags: ! handle=winreg.OpenKey( self.handle, keyname, 0, samFlags ) else: ! handle=winreg.OpenKey( self.handle, keyname, 0 ) return RegKey( self.name+"\\"+keyname, handle ) --- 195,212 ---- def deleteSubkey( self, subkey ): ! return _winreg.DeleteKey( self.handle, subkey ) def deleteValue( self, valname ): ! return _winreg.DeleteValue( self.handle, valname ) def createSubkey( self, keyname ): ! handle=_winreg.CreateKey( self.handle, keyname ) return RegKey( self.name+"\\"+keyname, handle) def openSubkey( self, keyname, samFlags=None ): if samFlags: ! handle=_winreg.OpenKey( self.handle, keyname, 0, samFlags ) else: ! handle=_winreg.OpenKey( self.handle, keyname, 0 ) return RegKey( self.name+"\\"+keyname, handle ) *************** *** 220,231 **** try: if type( valname )==IntType: ! (valname,data,datatype)=winreg.EnumValue( self.handle, valname ) else: keyname=_getName( valname, self._nameFromNum ) ! (data,datatype)=winreg.QueryValueEx( self.handle, keyname ) except (WindowsError, EnvironmentError): raise IndexError, valname ! if datatype==winreg.REG_BINARY: # use arrays for binary data data=array.array( 'c', data ) --- 220,231 ---- try: if type( valname )==IntType: ! (valname,data,datatype)=_winreg.EnumValue( self.handle, valname ) else: keyname=_getName( valname, self._nameFromNum ) ! (data,datatype)=_winreg.QueryValueEx( self.handle, keyname ) except (WindowsError, EnvironmentError): raise IndexError, valname ! if datatype==_winreg.REG_BINARY: # use arrays for binary data data=array.array( 'c', data ) *************** *** 242,261 **** else: if type( data )==StringType: ! typeint=winreg.REG_SZ elif type( data )==IntType: ! typeint=winreg.REG_DWORD elif type( data )==array.ArrayType: ! typeint=winreg.REG_BINARY data=data.tostring() ! winreg.SetValueEx( self.handle, valname, 0, typeint, data ) def flush(self ): ! winreg.FlushKey( self.keyobbj ) def save( self, filename ): ! winreg.SaveKey( self.keyobj, filename ) def load( self, subkey, filename ): ! return winreg.RegLoadKey( self.handle, subkey, filename ) --- 242,261 ---- else: if type( data )==StringType: ! typeint=_winreg.REG_SZ elif type( data )==IntType: ! typeint=_winreg.REG_DWORD elif type( data )==array.ArrayType: ! typeint=_winreg.REG_BINARY data=data.tostring() ! _winreg.SetValueEx( self.handle, valname, 0, typeint, data ) def flush(self ): ! _winreg.FlushKey( self.keyobbj ) def save( self, filename ): ! _winreg.SaveKey( self.keyobj, filename ) def load( self, subkey, filename ): ! return _winreg.RegLoadKey( self.handle, subkey, filename ) *************** *** 263,267 **** def __init__( self, machine, topLevelKey ): assert topLevelKey in _hivenames ! self.handle = winreg.ConnectRegistry( machine, parentKey ) self.name=r"\\%s\%s" % (machine, topLevelKey ) --- 263,267 ---- def __init__( self, machine, topLevelKey ): assert topLevelKey in _hivenames ! self.handle = _winreg.ConnectRegistry( machine, parentKey ) self.name=r"\\%s\%s" % (machine, topLevelKey ) *************** *** 271,275 **** hives={} for name in _hivenames: ! hives[name]=RegKey( name, getattr( winreg, name ) ) hives["HKLM"]=hives["HKEY_LOCAL_MACHINE"] hives["HKCR"]=hives["HKEY_CLASSES_ROOT"] --- 271,275 ---- hives={} for name in _hivenames: ! hives[name]=RegKey( name, getattr( _winreg, name ) ) hives["HKLM"]=hives["HKEY_LOCAL_MACHINE"] hives["HKCR"]=hives["HKEY_CLASSES_ROOT"] *************** *** 281,285 **** flags={} for name in _flagnames: ! flags[name]=getattr( winreg, name ) _RegNotifyChangeKeyValueOptions=[ "REG_NOTIFY_CHANGE_ATTRIBUTES", --- 281,285 ---- flags={} for name in _flagnames: ! flags[name]=getattr( _winreg, name ) _RegNotifyChangeKeyValueOptions=[ "REG_NOTIFY_CHANGE_ATTRIBUTES", *************** *** 312,316 **** #allnames=_hivenames+_flagnames+typeConstantNames+unusednames ! #winregnames=winreg.__dict__.keys() #for name in winregnames: # if name not in allnames: --- 312,316 ---- #allnames=_hivenames+_flagnames+typeConstantNames+unusednames ! #winregnames=_winreg.__dict__.keys() #for name in winregnames: # if name not in allnames: From python-dev@python.org Fri Jun 30 21:31:53 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 13:31:53 -0700 Subject: [Python-checkins] CVS: python/dist/src/PC config.h,1.40,1.41 Message-ID: <200006302031.NAA07897@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv7887 Modified Files: config.h Log Message: As Neil Schemenauer points out, WITH_CYCLE_GC should be uncommented if we want to have GC enabled in the beta. Index: config.h =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/config.h,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -r1.40 -r1.41 *** config.h 2000/06/30 15:47:02 1.40 --- config.h 2000/06/30 20:31:50 1.41 *************** *** 453,457 **** /* Define if you want cycle garbage collection */ ! /* #define WITH_CYCLE_GC 1 */ /* Define if you have clock. */ --- 453,457 ---- /* Define if you want cycle garbage collection */ ! #define WITH_CYCLE_GC 1 /* Define if you have clock. */ From python-dev@python.org Fri Jun 30 22:40:23 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 14:40:23 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.16,2.17 Message-ID: <200006302140.OAA19198@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv19117/Modules Modified Files: _sre.c Log Message: -- changed $ to match before a trailing newline, even if the multiline flag isn't given. Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.16 retrieving revision 2.17 diff -C2 -r2.16 -r2.17 *** _sre.c 2000/06/30 13:55:15 2.16 --- _sre.c 2000/06/30 21:40:20 2.17 *************** *** 311,315 **** case SRE_AT_END: ! return ((void*) ptr == state->end); case SRE_AT_END_LINE: --- 311,317 ---- case SRE_AT_END: ! return (((void*) (ptr+1) == state->end && ! SRE_IS_LINEBREAK((int) ptr[0])) || ! ((void*) ptr == state->end)); case SRE_AT_END_LINE: From python-dev@python.org Fri Jun 30 23:01:39 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 15:01:39 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib re.py,1.36,1.37 Message-ID: <200006302201.PAA25279@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv23820/Lib Modified Files: re.py Log Message: replaced with something slightly more suitable. Index: re.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/re.py,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -r1.36 -r1.37 *** re.py 2000/06/30 16:25:20 1.36 --- re.py 2000/06/30 22:01:36 1.37 *************** *** 1,11 **** ! # change this to "pre" if your regexps stopped working. don't ! # forget to send a bug report to engine = "sre" if engine == "sre": ! # new 2.0 engine from sre import * else: ! # old 1.5.2 engine. will be removed in 2.0 final. from pre import * --- 1,32 ---- ! # ! # Minimal "re" compatibility wrapper ! # ! # If your regexps don't work well under 2.0b1, you can switch ! # to the old engine ("pre") down below. ! # ! # To help us fix any remaining bugs in the new engine, please ! # report what went wrong. You can either use the following web ! # page: ! # ! # http://www.python.org/search/search_bugs.html ! # ! # or send a mail to SRE's author: ! # ! # Fredrik Lundh ! # ! # Make sure to include the pattern, the string SRE failed to ! # match, and what result you expected. ! # ! # thanks /F ! # engine = "sre" + # engine = "pre" if engine == "sre": ! # New unicode-aware engine from sre import * else: ! # Old 1.5.2 engine. This one supports 8-bit strings only, ! # and will be removed in 2.0 final. from pre import * From python-dev@python.org Fri Jun 30 23:17:55 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 15:17:55 -0700 Subject: [Python-checkins] CVS: python/dist/src/PC config.h,1.41,1.42 Message-ID: <200006302217.PAA28219@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/PC In directory slayer.i.sourceforge.net:/tmp/cvs-serv28210 Modified Files: config.h Log Message: Only include for VC 6.0 and higher. Index: config.h =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/config.h,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -r1.41 -r1.42 *** config.h 2000/06/30 20:31:50 1.41 --- config.h 2000/06/30 22:17:53 1.42 *************** *** 244,248 **** --- 244,250 ---- /* define the ANSI intptr_t type for portable use of a pointer sized integer */ + #if _MSC_VER >= 1200 /* This file only exists in VC 6.0 or higher */ #include + #endif #if defined(MS_WINDOWS) && !defined(MS_WIN64) typedef long intptr_t; From python-dev@python.org Fri Jun 30 23:37:34 2000 From: python-dev@python.org (Fredrik Lundh) Date: Fri, 30 Jun 2000 15:37:34 -0700 Subject: [Python-checkins] CVS: python/dist/src/Lib sre_compile.py,1.17,1.18 sre_parse.py,1.17,1.18 Message-ID: <200006302237.PAA29565@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Lib In directory slayer.i.sourceforge.net:/tmp/cvs-serv29384/Lib Modified Files: sre_compile.py sre_parse.py Log Message: - fixed code generation error in multiline mode - fixed parser flag propagation (of all stupid bugs...) Index: sre_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** sre_compile.py 2000/06/30 18:39:20 1.17 --- sre_compile.py 2000/06/30 22:37:31 1.18 *************** *** 119,123 **** emit(OPCODES[op]) if flags & SRE_FLAG_MULTILINE: ! emit(ATCODES[AT_MULTILINE[av]]) else: emit(ATCODES[av]) --- 119,123 ---- emit(OPCODES[op]) if flags & SRE_FLAG_MULTILINE: ! emit(ATCODES[AT_MULTILINE.get(av, av)]) else: emit(ATCODES[av]) *************** *** 204,208 **** import sre_parse pattern = p ! p = sre_parse.parse(p) else: pattern = None --- 204,208 ---- import sre_parse pattern = p ! p = sre_parse.parse(p, flags) else: pattern = None Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** sre_parse.py 2000/06/30 18:39:20 1.17 --- sre_parse.py 2000/06/30 22:37:31 1.18 *************** *** 32,36 **** HEXDIGITS = tuple("0123456789abcdefABCDEF") ! WHITESPACE = string.whitespace ESCAPES = { --- 32,36 ---- HEXDIGITS = tuple("0123456789abcdefABCDEF") ! WHITESPACE = tuple(string.whitespace) ESCAPES = { *************** *** 297,301 **** return subpattern ! def _parse(source, state, flags=0): # parse regular expression pattern into an operator list. --- 297,301 ---- return subpattern ! def _parse(source, state): # parse regular expression pattern into an operator list. *************** *** 469,473 **** b = [] while 1: ! p = _parse(source, state, flags) if source.next == ")": if b: --- 469,473 ---- b = [] while 1: ! p = _parse(source, state) if source.next == ")": if b: *************** *** 496,500 **** group = state.getgroup(name) while 1: ! p = _parse(source, state, flags) if source.match(")"): if b: --- 496,500 ---- group = state.getgroup(name) while 1: ! p = _parse(source, state) if source.match(")"): if b: *************** *** 533,539 **** source = Tokenizer(pattern) state = State() b = [] while 1: ! p = _parse(source, state, flags) tail = source.get() if tail == "|": --- 533,540 ---- source = Tokenizer(pattern) state = State() + state.flags = flags b = [] while 1: ! p = _parse(source, state) tail = source.get() if tail == "|": From python-dev@python.org Fri Jun 30 23:45:15 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 15:45:15 -0700 Subject: [Python-checkins] CVS: python/dist/src/Modules posixmodule.c,2.138,2.139 Message-ID: <200006302245.PAA29900@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Modules In directory slayer.i.sourceforge.net:/tmp/cvs-serv29892 Modified Files: posixmodule.c Log Message: Crude way to fix a problem on AIX: #undef STAT before defining it. Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.138 retrieving revision 2.139 diff -C2 -r2.138 -r2.139 *** posixmodule.c 2000/06/29 21:12:41 2.138 --- posixmodule.c 2000/06/30 22:45:12 2.139 *************** *** 286,289 **** --- 286,290 ---- /* choose the appropriate stat and fstat functions and return structs */ + #undef STAT #ifdef MS_WIN64 # define STAT _stati64 From python-dev@python.org Fri Jun 30 23:46:07 2000 From: python-dev@python.org (Guido van Rossum) Date: Fri, 30 Jun 2000 15:46:07 -0700 Subject: [Python-checkins] CVS: python/dist/src/Objects methodobject.c,2.28,2.29 Message-ID: <200006302246.PAA29937@slayer.i.sourceforge.net> Update of /cvsroot/python/python/dist/src/Objects In directory slayer.i.sourceforge.net:/tmp/cvs-serv29930 Modified Files: methodobject.c Log Message: Fix an error on AIX by using a proper cast. Index: methodobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/methodobject.c,v retrieving revision 2.28 retrieving revision 2.29 diff -C2 -r2.28 -r2.29 *** methodobject.c 2000/06/30 15:01:00 2.28 --- methodobject.c 2000/06/30 22:46:04 2.29 *************** *** 181,185 **** return -1; } ! y = _Py_HashPointer(a->m_ml->ml_meth); if (y == -1) return -1; --- 181,185 ---- return -1; } ! y = _Py_HashPointer((void*)(a->m_ml->ml_meth)); if (y == -1) return -1;