From rhettinger@users.sourceforge.net Sat Jun 1 00:03:35 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri, 31 May 2002 16:03:35 -0700 Subject: [Python-checkins] python/dist/src/Lib BaseHTTPServer.py,1.21,1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv15710 Modified Files: BaseHTTPServer.py Log Message: Use is None rather than general boolean Index: BaseHTTPServer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/BaseHTTPServer.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** BaseHTTPServer.py 16 Apr 2002 01:38:39 -0000 1.21 --- BaseHTTPServer.py 31 May 2002 23:03:33 -0000 1.22 *************** *** 332,336 **** except KeyError: short, long = '???', '???' ! if not message: message = short explain = long --- 332,336 ---- except KeyError: short, long = '???', '???' ! if message is None: message = short explain = long From rhettinger@users.sourceforge.net Sat Jun 1 00:54:47 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri, 31 May 2002 16:54:47 -0700 Subject: [Python-checkins] python/dist/src/Lib cgi.py,1.71,1.72 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv3227 Modified Files: cgi.py Log Message: Use is None rather than general boolean Index: cgi.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cgi.py,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** cgi.py 4 Apr 2002 22:55:58 -0000 1.71 --- cgi.py 31 May 2002 23:54:44 -0000 1.72 *************** *** 129,133 **** If true, errors raise a ValueError exception. """ ! if not fp: fp = sys.stdin if not environ.has_key('REQUEST_METHOD'): --- 129,133 ---- If true, errors raise a ValueError exception. """ ! if fp is None: fp = sys.stdin if not environ.has_key('REQUEST_METHOD'): From rhettinger@users.sourceforge.net Sat Jun 1 01:06:22 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri, 31 May 2002 17:06:22 -0700 Subject: [Python-checkins] python/dist/src/Lib compileall.py,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv9252 Modified Files: compileall.py Log Message: Use is None rather than general boolean Index: compileall.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/compileall.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** compileall.py 18 Mar 2002 12:44:08 -0000 1.10 --- compileall.py 1 Jun 2002 00:06:20 -0000 1.11 *************** *** 45,53 **** for name in names: fullname = os.path.join(dir, name) ! if ddir: dfile = os.path.join(ddir, name) else: dfile = None ! if rx: mo = rx.search(fullname) if mo: --- 45,53 ---- for name in names: fullname = os.path.join(dir, name) ! if ddir is not None: dfile = os.path.join(ddir, name) else: dfile = None ! if rx is not None: mo = rx.search(fullname) if mo: From rhettinger@users.sourceforge.net Sat Jun 1 01:57:57 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri, 31 May 2002 17:57:57 -0700 Subject: [Python-checkins] python/dist/src/Lib ConfigParser.py,1.41,1.42 dis.py,1.38,1.39 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv29718 Modified Files: ConfigParser.py dis.py Log Message: Replaced boolean test with 'is None' Index: ConfigParser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ConfigParser.py,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** ConfigParser.py 26 Apr 2002 02:29:55 -0000 1.41 --- ConfigParser.py 1 Jun 2002 00:57:55 -0000 1.42 *************** *** 271,275 **** d.update(sectdict) # Update with the entry specific variables ! if vars: d.update(vars) option = self.optionxform(option) --- 271,275 ---- d.update(sectdict) # Update with the entry specific variables ! if vars is not None: d.update(vars) option = self.optionxform(option) Index: dis.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dis.py,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** dis.py 11 Feb 2002 18:14:22 -0000 1.38 --- dis.py 1 Jun 2002 00:57:55 -0000 1.39 *************** *** 14,18 **** """ ! if not x: distb() return --- 14,18 ---- """ ! if x is None: distb() return *************** *** 45,49 **** def distb(tb=None): """Disassemble a traceback (default: last traceback).""" ! if not tb: try: tb = sys.last_traceback --- 45,49 ---- def distb(tb=None): """Disassemble a traceback (default: last traceback).""" ! if tb is None: try: tb = sys.last_traceback *************** *** 313,322 **** else: fn = None ! if not fn: f = sys.stdin else: f = open(fn) source = f.read() ! if fn: f.close() else: --- 313,322 ---- else: fn = None ! if fn is None: f = sys.stdin else: f = open(fn) source = f.read() ! if fn is not None: f.close() else: From rhettinger@users.sourceforge.net Sat Jun 1 02:29:18 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri, 31 May 2002 18:29:18 -0700 Subject: [Python-checkins] python/dist/src/Lib formatter.py,1.20,1.21 ftplib.py,1.69,1.70 gettext.py,1.13,1.14 hmac.py,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv7374 Modified Files: formatter.py ftplib.py gettext.py hmac.py Log Message: Replace boolean test with is None Index: formatter.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/formatter.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** formatter.py 29 May 2002 16:18:42 -0000 1.20 --- formatter.py 1 Jun 2002 01:29:16 -0000 1.21 *************** *** 39,43 **** def __init__(self, writer=None): ! if not writer: writer = NullWriter() self.writer = writer --- 39,43 ---- def __init__(self, writer=None): ! if writer is None: writer = NullWriter() self.writer = writer *************** *** 434,438 **** w = DumbWriter() f = AbstractFormatter(w) ! if file: fp = open(file) elif sys.argv[1:]: --- 434,438 ---- w = DumbWriter() f = AbstractFormatter(w) ! if file is not None: fp = open(file) elif sys.argv[1:]: Index: ftplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ftplib.py,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** ftplib.py 31 May 2002 14:13:03 -0000 1.69 --- ftplib.py 1 Jun 2002 01:29:16 -0000 1.70 *************** *** 660,664 **** def __init__(self, filename=None): ! if not filename: if os.environ.has_key("HOME"): filename = os.path.join(os.environ["HOME"], --- 660,664 ---- def __init__(self, filename=None): ! if filename is None: if os.environ.has_key("HOME"): filename = os.path.join(os.environ["HOME"], Index: gettext.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/gettext.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** gettext.py 11 Jan 2002 06:58:49 -0000 1.13 --- gettext.py 1 Jun 2002 01:29:16 -0000 1.14 *************** *** 105,109 **** self._charset = None self._fallback = None ! if fp: self._parse(fp) --- 105,109 ---- self._charset = None self._fallback = None ! if fp is not None: self._parse(fp) Index: hmac.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/hmac.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** hmac.py 31 May 2002 17:49:10 -0000 1.5 --- hmac.py 1 Jun 2002 01:29:16 -0000 1.6 *************** *** 47,51 **** self.outer.update(_strxor(key, opad)) self.inner.update(_strxor(key, ipad)) ! if (msg): self.update(msg) --- 47,51 ---- self.outer.update(_strxor(key, opad)) self.inner.update(_strxor(key, ipad)) ! if msg is not None: self.update(msg) From fdrake@acm.org Sat Jun 1 03:56:29 2002 From: fdrake@acm.org (Fred L. Drake, Jr.) Date: Fri, 31 May 2002 22:56:29 -0400 Subject: [Python-checkins] python/dist/src/Lib/xml/dom minidom.py,1.45,1.46 In-Reply-To: <3CF7E47F.5D61B8A2@metaslash.com> References: <15607.58244.442717.525000@grendel.zope.com> <3CF7E47F.5D61B8A2@metaslash.com> Message-ID: <15608.14301.989688.606420@grendel.zope.com> Neal Norwitz writes: > Could you please do it? I'm not a developer on PyXML. > Sorry, I wasn't sure if it was still maintained in a separate CVS. Sure, I'll be glad to. > Are PyXML and distutils the only modules maintained separately? > What about email and compiler? Distutils is *not* maintained in a separate CVS repository; the Lib/distutils/ directory is known by two names in CVS: python/dist/src/Lib/distutils/ distutils/distutils/ Changing either changes both. As for PyXML, the things in Lib/xml/ are maintained in both repositories, so separate checkins are needed. There are components in PyXML which are not part of Python's xml package. -Fred -- Fred L. Drake, Jr. PythonLabs at Zope Corporation From barry@zope.com Sat Jun 1 04:01:25 2002 From: barry@zope.com (Barry A. Warsaw) Date: Fri, 31 May 2002 23:01:25 -0400 Subject: [Python-checkins] python/dist/src/Lib/xml/dom minidom.py,1.45,1.46 References: <15607.58244.442717.525000@grendel.zope.com> <3CF7E47F.5D61B8A2@metaslash.com> <15608.14301.989688.606420@grendel.zope.com> Message-ID: <15608.14597.531902.527090@anthem.wooz.org> >>>>> "Fred" == Fred L Drake, Jr writes: >> Are PyXML and distutils the only modules maintained separately? >> What about email and compiler? Fred> Distutils is *not* maintained in a separate CVS repository; For that matter, neither is email. Fred> the Lib/distutils/ directory is known by two names in CVS: The old SF mimelib project exists solely to manage the detritus of distutils. I still haven't figured out the magic to get setup.py to live in the Lib/email directory. :( All the juicy bits live in the Python cvs tree. -Barry From rhettinger@users.sourceforge.net Sat Jun 1 04:06:33 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri, 31 May 2002 20:06:33 -0700 Subject: [Python-checkins] python/dist/src/Lib imaplib.py,1.46,1.47 imputil.py,1.23,1.24 inspect.py,1.33,1.34 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv2915 Modified Files: imaplib.py imputil.py inspect.py Log Message: Replaced boolean test with is None Index: imaplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/imaplib.py,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** imaplib.py 16 Apr 2002 01:38:39 -0000 1.46 --- imaplib.py 1 Jun 2002 03:06:31 -0000 1.47 *************** *** 540,544 **** self.untagged_responses = {} # Flush old responses. self.is_readonly = readonly ! if readonly: name = 'EXAMINE' else: --- 540,544 ---- self.untagged_responses = {} # Flush old responses. self.is_readonly = readonly ! if readonly is not None: name = 'EXAMINE' else: Index: imputil.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/imputil.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** imputil.py 11 Feb 2002 18:01:32 -0000 1.23 --- imputil.py 1 Jun 2002 03:06:31 -0000 1.24 *************** *** 67,71 **** # This is the Importer that we use for grabbing stuff from the # filesystem. It defines one more method (import_from_dir) for our use. ! if not fs_imp: cls = self.clsFilesystemImporter or _FilesystemImporter fs_imp = cls() --- 67,71 ---- # This is the Importer that we use for grabbing stuff from the # filesystem. It defines one more method (import_from_dir) for our use. ! if fs_imp is None: cls = self.clsFilesystemImporter or _FilesystemImporter fs_imp = cls() Index: inspect.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/inspect.py,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** inspect.py 20 May 2002 17:29:46 -0000 1.33 --- inspect.py 1 Jun 2002 03:06:31 -0000 1.34 *************** *** 666,672 **** spec = spec + formatvalue(defaults[i - firstdefault]) specs.append(spec) ! if varargs: specs.append(formatvarargs(varargs)) ! if varkw: specs.append(formatvarkw(varkw)) return '(' + string.join(specs, ', ') + ')' --- 666,672 ---- spec = spec + formatvalue(defaults[i - firstdefault]) specs.append(spec) ! if varargs is not None: specs.append(formatvarargs(varargs)) ! if varkw is not None: specs.append(formatvarkw(varkw)) return '(' + string.join(specs, ', ') + ')' From bwarsaw@users.sourceforge.net Sat Jun 1 04:56:09 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Fri, 31 May 2002 20:56:09 -0700 Subject: [Python-checkins] python/dist/src/Lib/email Charset.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email In directory usw-pr-cvs1:/tmp/cvs-serv15134/email Modified Files: Charset.py Log Message: _is_unicode(): Use UnicodeType instead of the unicode builtin for Python 2.1 compatibility. Index: Charset.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/Charset.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Charset.py 28 May 2002 18:49:03 -0000 1.3 --- Charset.py 1 Jun 2002 03:56:07 -0000 1.4 *************** *** 8,13 **** return 1==0 else: def _is_unicode(x): ! return isinstance(x, unicode) from email.Encoders import encode_7or8bit --- 8,15 ---- return 1==0 else: + # Use UnicodeType instead of built-in unicode for Py2.1 compatibility + from types import UnicodeType def _is_unicode(x): ! return isinstance(x, UnicodeType) from email.Encoders import encode_7or8bit From tim_one@users.sourceforge.net Sat Jun 1 06:22:57 2002 From: tim_one@users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri, 31 May 2002 22:22:57 -0700 Subject: [Python-checkins] python/dist/src/Objects listobject.c,2.107,2.108 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv31064/python/dist/src/Objects Modified Files: listobject.c Log Message: A bogus assert in the new listiter code prevented starting Python in a debug build. Repaired that, and rewrote other parts to reduce long-winded casting. Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.107 retrieving revision 2.108 diff -C2 -d -r2.107 -r2.108 *** listobject.c 31 May 2002 21:37:01 -0000 2.107 --- listobject.c 1 Jun 2002 05:22:55 -0000 2.108 *************** *** 1820,1825 **** typedef struct { PyObject_HEAD ! long it_index; ! PyObject *it_seq; } listiterobject; --- 1820,1825 ---- typedef struct { PyObject_HEAD ! long it_index; ! PyListObject *it_seq; } listiterobject; *************** *** 1840,1844 **** it->it_index = 0; Py_INCREF(seq); ! it->it_seq = seq; _PyObject_GC_TRACK(it); return (PyObject *)it; --- 1840,1844 ---- it->it_index = 0; Py_INCREF(seq); ! it->it_seq = (PyListObject *)seq; _PyObject_GC_TRACK(it); return (PyObject *)it; *************** *** 1856,1860 **** listiter_traverse(listiterobject *it, visitproc visit, void *arg) { ! return visit(it->it_seq, arg); } --- 1856,1860 ---- listiter_traverse(listiterobject *it, visitproc visit, void *arg) { ! return visit((PyObject *)it->it_seq, arg); } *************** *** 1868,1881 **** static PyObject * ! listiter_next(PyObject *it) { ! PyObject *seq; PyObject *item; ! assert(PyList_Check(it)); ! seq = ((listiterobject *)it)->it_seq; ! if (((listiterobject *)it)->it_index < PyList_GET_SIZE(seq)) { ! item = ((PyListObject *)(seq))->ob_item[((listiterobject *)it)->it_index++]; Py_INCREF(item); return item; --- 1868,1883 ---- static PyObject * ! listiter_next(listiterobject *it) { ! PyListObject *seq; PyObject *item; ! assert(it != NULL); ! seq = it->it_seq; ! assert(PyList_Check(seq)); ! if (it->it_index < PyList_GET_SIZE(seq)) { ! item = PyList_GET_ITEM(seq, it->it_index); ! ++it->it_index; Py_INCREF(item); return item; From bwarsaw@users.sourceforge.net Sat Jun 1 06:45:39 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Fri, 31 May 2002 22:45:39 -0700 Subject: [Python-checkins] python/dist/src/Lib/email Errors.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email In directory usw-pr-cvs1:/tmp/cvs-serv2993/email Modified Files: Errors.py Log Message: Slightly better docstring Index: Errors.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/Errors.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Errors.py 10 Apr 2002 21:01:30 -0000 1.4 --- Errors.py 1 Jun 2002 05:45:37 -0000 1.5 *************** *** 8,12 **** class MessageError(Exception): ! """Base class for errors in this module.""" --- 8,12 ---- class MessageError(Exception): ! """Base class for errors in the email package.""" From bwarsaw@users.sourceforge.net Sat Jun 1 06:49:19 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Fri, 31 May 2002 22:49:19 -0700 Subject: [Python-checkins] python/dist/src/Lib/email Header.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email In directory usw-pr-cvs1:/tmp/cvs-serv3679/email Modified Files: Header.py Log Message: The _compat modules now export _floordiv() instead of _intdiv2() for better code reuse. _split() Use _floordiv(). Index: Header.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/Header.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Header.py 23 May 2002 15:15:29 -0000 1.3 --- Header.py 1 Jun 2002 05:49:17 -0000 1.4 *************** *** 10,17 **** try: ! from email._compat22 import _intdiv2 except SyntaxError: # Python 2.1 spells integer division differently ! from email._compat21 import _intdiv2 CRLFSPACE = '\r\n ' --- 10,17 ---- try: ! from email._compat22 import _floordiv except SyntaxError: # Python 2.1 spells integer division differently ! from email._compat21 import _floordiv CRLFSPACE = '\r\n ' *************** *** 169,175 **** return self._split(first, charset) + self._split(last, charset) else: ! # Divide and conquer. BAW: halfway depends on integer division. ! # When porting to Python 2.2, use the // operator. ! halfway = _intdiv2(len(splittable)) first = charset.from_splittable(splittable[:halfway], 0) last = charset.from_splittable(splittable[halfway:], 0) --- 169,174 ---- return self._split(first, charset) + self._split(last, charset) else: ! # Divide and conquer. ! halfway = _floordiv(len(splittable), 2) first = charset.from_splittable(splittable[:halfway], 0) last = charset.from_splittable(splittable[halfway:], 0) From bwarsaw@users.sourceforge.net Sat Jun 1 06:59:14 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Fri, 31 May 2002 22:59:14 -0700 Subject: [Python-checkins] python/dist/src/Lib/email MIMEMultipart.py,NONE,1.1 MIMENonMultipart.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email In directory usw-pr-cvs1:/tmp/cvs-serv5735/email Added Files: MIMEMultipart.py MIMENonMultipart.py Log Message: These two classes provide bases for more specific content type subclasses. MIMENonMultipart: Base class for non-multipart/* content type subclass specializations, e.g. image/gif. This class overrides attach() which raises an exception, since it makes no sense to attach a subpart to e.g. an image/gif message. MIMEMultipart: Base class for multipart/* content type subclass specializations, e.g. multipart/mixed. Does little more than provide a useful constructor. --- NEW FILE: MIMEMultipart.py --- # Copyright (C) 2002 Python Software Foundation # Author: barry@zope.com (Barry Warsaw) """Base class for MIME multipart/* type messages. """ from email import MIMEBase class MIMEMultipart(MIMEBase.MIMEBase): """Base class for MIME multipart/* type messages.""" def __init__(self, _subtype='mixed', boundary=None, *_subparts, **_params): """Creates a multipart/* type message. By default, creates a multipart/mixed message, with proper Content-Type: and MIME-Version: headers. _subtype is the subtype of the multipart content type, defaulting to `mixed'. boundary is the multipart boundary string. By default it is calculated as needed. _subparts is a sequence of initial subparts for the multipart. It must be possible to convert this sequence to a list. You can always attach new subparts to the message by using the attach() method. Additional parameters for the Content-Type: header are taken from the keyword arguments (or passed into the _params argument). """ MIMEBase.MIMEBase.__init__(self, 'multipart', _subtype, **params) self.attach(*list(_subparts)) --- NEW FILE: MIMENonMultipart.py --- # Copyright (C) 2002 Python Software Foundation # Author: barry@zope.com (Barry Warsaw) """Base class for MIME type messages that are not multipart. """ from email import Errors from email import MIMEBase class MIMENonMultipart(MIMEBase.MIMEBase): """Base class for MIME multipart/* type messages.""" def attach(self, payload): # The public API prohibits attaching multiple subparts to MIMEBase # derived subtypes since none of them are, by definition, of content # type multipart/* raise Errors.MultipartConversionError( 'Cannot attach additional subparts to non-multipart/*') From tim_one@email.msn.com Sat Jun 1 07:02:34 2002 From: tim_one@email.msn.com (Tim Peters) Date: Sat, 1 Jun 2002 02:02:34 -0400 Subject: [Python-checkins] python/dist/src/Lib/email Header.py,1.3,1.4 In-Reply-To: Message-ID: [Barry] > Modified Files: > Header.py > Log Message: > The _compat modules now export _floordiv() instead of _intdiv2() for > better code reuse. FYI, there's no law (yet) against shifting right by 1, and i >> 1 is identical to i//2 for ints and longs. From bwarsaw@users.sourceforge.net Sat Jun 1 07:03:11 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Fri, 31 May 2002 23:03:11 -0700 Subject: [Python-checkins] python/dist/src/Lib/email __init__.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email In directory usw-pr-cvs1:/tmp/cvs-serv6736/email Modified Files: __init__.py Log Message: Bump to version 2.0.5, and also use absolute import paths. Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/__init__.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** __init__.py 22 May 2002 01:52:33 -0000 1.7 --- __init__.py 1 Jun 2002 06:03:09 -0000 1.8 *************** *** 5,9 **** """ ! __version__ = '2.0.4' __all__ = ['Charset', --- 5,9 ---- """ ! __version__ = '2.0.5' __all__ = ['Charset', *************** *** 30,35 **** # Some convenience routines ! from Parser import Parser as _Parser ! from Message import Message as _Message def message_from_string(s, _class=_Message): --- 30,35 ---- # Some convenience routines ! from email.Parser import Parser as _Parser ! from email.Message import Message as _Message def message_from_string(s, _class=_Message): From barry@zope.com Sat Jun 1 07:04:50 2002 From: barry@zope.com (Barry A. Warsaw) Date: Sat, 1 Jun 2002 02:04:50 -0400 Subject: [Python-checkins] python/dist/src/Lib/email Header.py,1.3,1.4 References: Message-ID: <15608.25602.581726.334861@anthem.wooz.org> >>>>> "TP" == Tim Peters writes: TP> [Barry] >> Modified Files: Header.py Log Message: The _compat modules now >> export _floordiv() instead of _intdiv2() for better code reuse. TP> FYI, there's no law (yet) against shifting right by 1, and i TP> >> 1 is identical to i//2 for ints and longs. Yup, but I needed to generalize floordiv away from a simple divide by 2 (I also needed a divide by three). shift-right-a-bit-and-a-half-ly y'rs, -Barry From rhettinger@users.sourceforge.net Sat Jun 1 15:18:50 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat, 01 Jun 2002 07:18:50 -0700 Subject: [Python-checkins] python/dist/src/Lib ConfigParser.py,1.42,1.43 SimpleHTTPServer.py,1.18,1.19 anydbm.py,1.12,1.13 bdb.py,1.40,1.41 cgi.py,1.72,1.73 cmd.py,1.29,1.30 codecs.py,1.24,1.25 copy.py,1.24,1.25 difflib.py,1.9,1.10 doctest.py,1.23,1.24 dospath.py,1.27,1.28 fnmatch.py,1.12,1.13 ftplib.py,1.70,1.71 gopherlib.py,1.11,1.12 httplib.py,1.50,1.51 ihooks.py,1.13,1.14 imaplib.py,1.47,1.48 inspect.py,1.34,1.35 linecache.py,1.9,1.10 mailbox.py,1.36,1.37 mailcap.py,1.10,1.11 mhlib.py,1.29,1.30 mimetools.py,1.25,1.26 mimetypes.py,1.21,1.22 netrc.py,1.14,1.15 ntpath.py,1.47,1.48 os.py,1.56,1.57 os2emxpath.py,1.4,1.5 pdb.py,1.52,1.53 pickle.py,1.65,1.66 posixpath.py,1.48,1.49 profile.py,1.44,1.45 pstats.py,1.23,1.24 pyclbr.py,1.23,1.24 pydoc.py,1.63,1.64 regsub.py,1.13,1.14 rexec.py,1.37,1.38 rfc822.py,1.70,1.71 sgmllib.py,1.39,1.40 site.py,1.42,1.43 smtplib.py,1.54,1.55 sre_parse.py,1.53,1.54 statcache.py,1.14,1.15 tempfile.py,1.38,1.39 toaiff.py,1.11,1.12 urllib.py,1.144,1.145 urllib2.py,1.28,1.29 user.py,1.5,1.6 warnings.py,1.14,1.15 weakref.py,1.15,1.16 webbrowser.py,1.30,1.31 xmllib.py,1.29,1.30 xmlrpclib.py,1.16,1.17 zipfile.py,1.21,1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv9058 Modified Files: ConfigParser.py SimpleHTTPServer.py anydbm.py bdb.py cgi.py cmd.py codecs.py copy.py difflib.py doctest.py dospath.py fnmatch.py ftplib.py gopherlib.py httplib.py ihooks.py imaplib.py inspect.py linecache.py mailbox.py mailcap.py mhlib.py mimetools.py mimetypes.py netrc.py ntpath.py os.py os2emxpath.py pdb.py pickle.py posixpath.py profile.py pstats.py pyclbr.py pydoc.py regsub.py rexec.py rfc822.py sgmllib.py site.py smtplib.py sre_parse.py statcache.py tempfile.py toaiff.py urllib.py urllib2.py user.py warnings.py weakref.py webbrowser.py xmllib.py xmlrpclib.py zipfile.py Log Message: SF 563203. Replaced 'has_key()' with 'in'. Index: ConfigParser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ConfigParser.py,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** ConfigParser.py 1 Jun 2002 00:57:55 -0000 1.42 --- ConfigParser.py 1 Jun 2002 14:18:45 -0000 1.43 *************** *** 192,196 **** already exists. """ ! if self.__sections.has_key(section): raise DuplicateSectionError(section) self.__sections[section] = {} --- 192,196 ---- already exists. """ ! if section in self.__sections: raise DuplicateSectionError(section) self.__sections[section] = {} *************** *** 210,214 **** raise NoSectionError(section) opts.update(self.__defaults) ! if opts.has_key('__name__'): del opts['__name__'] return opts.keys() --- 210,214 ---- raise NoSectionError(section) opts.update(self.__defaults) ! if '__name__' in opts: del opts['__name__'] return opts.keys() *************** *** 311,315 **** '0': 0, 'no': 0, 'false': 0, 'off': 0} v = self.get(section, option) ! if not states.has_key(v.lower()): raise ValueError, 'Not a boolean: %s' % v return states[v.lower()] --- 311,315 ---- '0': 0, 'no': 0, 'false': 0, 'off': 0} v = self.get(section, option) ! if not v.lower() in states: raise ValueError, 'Not a boolean: %s' % v return states[v.lower()] *************** *** 321,330 **** """Check for the existence of a given option in a given section.""" if not section or section == "DEFAULT": ! return self.__defaults.has_key(option) elif not self.has_section(section): return 0 else: option = self.optionxform(option) ! return self.__sections[section].has_key(option) def set(self, section, option, value): --- 321,330 ---- """Check for the existence of a given option in a given section.""" if not section or section == "DEFAULT": ! return option in self.__defaults elif not self.has_section(section): return 0 else: option = self.optionxform(option) ! return option in self.__sections[section] def set(self, section, option, value): *************** *** 366,370 **** raise NoSectionError(section) option = self.optionxform(option) ! existed = sectdict.has_key(option) if existed: del sectdict[option] --- 366,370 ---- raise NoSectionError(section) option = self.optionxform(option) ! existed = option in sectdict if existed: del sectdict[option] *************** *** 373,377 **** def remove_section(self, section): """Remove a file section.""" ! if self.__sections.has_key(section): del self.__sections[section] return True --- 373,377 ---- def remove_section(self, section): """Remove a file section.""" ! if section in self.__sections: del self.__sections[section] return True *************** *** 434,438 **** if mo: sectname = mo.group('header') ! if self.__sections.has_key(sectname): cursect = self.__sections[sectname] elif sectname == DEFAULTSECT: --- 434,438 ---- if mo: sectname = mo.group('header') ! if sectname in self.__sections: cursect = self.__sections[sectname] elif sectname == DEFAULTSECT: Index: SimpleHTTPServer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/SimpleHTTPServer.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** SimpleHTTPServer.py 17 Mar 2002 18:37:22 -0000 1.18 --- SimpleHTTPServer.py 1 Jun 2002 14:18:45 -0000 1.19 *************** *** 176,183 **** base, ext = posixpath.splitext(path) ! if self.extensions_map.has_key(ext): return self.extensions_map[ext] ext = ext.lower() ! if self.extensions_map.has_key(ext): return self.extensions_map[ext] else: --- 176,183 ---- base, ext = posixpath.splitext(path) ! if ext in self.extensions_map: return self.extensions_map[ext] ext = ext.lower() ! if ext in self.extensions_map: return self.extensions_map[ext] else: Index: anydbm.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/anydbm.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** anydbm.py 18 Mar 2002 03:07:20 -0000 1.12 --- anydbm.py 1 Jun 2002 14:18:45 -0000 1.13 *************** *** 26,30 **** del d[key] # delete data stored at key (raises KeyError # if no such key) ! flag = d.has_key(key) # true if the key exists list = d.keys() # return a list of all existing keys (slow!) --- 26,30 ---- del d[key] # delete data stored at key (raises KeyError # if no such key) ! flag = key in d # true if the key exists list = d.keys() # return a list of all existing keys (slow!) Index: bdb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/bdb.py,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** bdb.py 29 May 2002 00:54:38 -0000 1.40 --- bdb.py 1 Jun 2002 14:18:45 -0000 1.41 *************** *** 104,108 **** def break_here(self, frame): filename = self.canonic(frame.f_code.co_filename) ! if not self.breaks.has_key(filename): return False lineno = frame.f_lineno --- 104,108 ---- def break_here(self, frame): filename = self.canonic(frame.f_code.co_filename) ! if not filename in self.breaks: return False lineno = frame.f_lineno *************** *** 212,216 **** return 'Line %s:%d does not exist' % (filename, lineno) ! if not self.breaks.has_key(filename): self.breaks[filename] = [] list = self.breaks[filename] --- 212,216 ---- return 'Line %s:%d does not exist' % (filename, lineno) ! if not filename in self.breaks: self.breaks[filename] = [] list = self.breaks[filename] *************** *** 221,225 **** def clear_break(self, filename, lineno): filename = self.canonic(filename) ! if not self.breaks.has_key(filename): return 'There are no breakpoints in %s' % filename if lineno not in self.breaks[filename]: --- 221,225 ---- def clear_break(self, filename, lineno): filename = self.canonic(filename) ! if not filename in self.breaks: return 'There are no breakpoints in %s' % filename if lineno not in self.breaks[filename]: *************** *** 250,254 **** def clear_all_file_breaks(self, filename): filename = self.canonic(filename) ! if not self.breaks.has_key(filename): return 'There are no breakpoints in %s' % filename for line in self.breaks[filename]: --- 250,254 ---- def clear_all_file_breaks(self, filename): filename = self.canonic(filename) ! if not filename in self.breaks: return 'There are no breakpoints in %s' % filename for line in self.breaks[filename]: *************** *** 268,277 **** def get_break(self, filename, lineno): filename = self.canonic(filename) ! return self.breaks.has_key(filename) and \ lineno in self.breaks[filename] def get_breaks(self, filename, lineno): filename = self.canonic(filename) ! return self.breaks.has_key(filename) and \ lineno in self.breaks[filename] and \ Breakpoint.bplist[filename, lineno] or [] --- 268,277 ---- def get_break(self, filename, lineno): filename = self.canonic(filename) ! return filename in self.breaks and \ lineno in self.breaks[filename] def get_breaks(self, filename, lineno): filename = self.canonic(filename) ! return filename in self.breaks and \ lineno in self.breaks[filename] and \ Breakpoint.bplist[filename, lineno] or [] *************** *** 279,283 **** def get_file_breaks(self, filename): filename = self.canonic(filename) ! if self.breaks.has_key(filename): return self.breaks[filename] else: --- 279,283 ---- def get_file_breaks(self, filename): filename = self.canonic(filename) ! if filename in self.breaks: return self.breaks[filename] else: *************** *** 317,321 **** else: s = s + "" ! if frame.f_locals.has_key('__args__'): args = frame.f_locals['__args__'] else: --- 317,321 ---- else: s = s + "" ! if '__args__' in frame.f_locals: args = frame.f_locals['__args__'] else: *************** *** 325,329 **** else: s = s + '()' ! if frame.f_locals.has_key('__return__'): rv = frame.f_locals['__return__'] s = s + '->' --- 325,329 ---- else: s = s + '()' ! if '__return__' in frame.f_locals: rv = frame.f_locals['__return__'] s = s + '->' Index: cgi.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cgi.py,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** cgi.py 31 May 2002 23:54:44 -0000 1.72 --- cgi.py 1 Jun 2002 14:18:45 -0000 1.73 *************** *** 131,135 **** if fp is None: fp = sys.stdin ! if not environ.has_key('REQUEST_METHOD'): environ['REQUEST_METHOD'] = 'GET' # For testing stand-alone if environ['REQUEST_METHOD'] == 'POST': --- 131,135 ---- if fp is None: fp = sys.stdin ! if not 'REQUEST_METHOD' in environ: environ['REQUEST_METHOD'] = 'GET' # For testing stand-alone if environ['REQUEST_METHOD'] == 'POST': *************** *** 144,148 **** else: qs = '' # Unknown content-type ! if environ.has_key('QUERY_STRING'): if qs: qs = qs + '&' qs = qs + environ['QUERY_STRING'] --- 144,148 ---- else: qs = '' # Unknown content-type ! if 'QUERY_STRING' in environ: if qs: qs = qs + '&' qs = qs + environ['QUERY_STRING'] *************** *** 151,155 **** qs = qs + sys.argv[1] environ['QUERY_STRING'] = qs # XXX Shouldn't, really ! elif environ.has_key('QUERY_STRING'): qs = environ['QUERY_STRING'] else: --- 151,155 ---- qs = qs + sys.argv[1] environ['QUERY_STRING'] = qs # XXX Shouldn't, really ! elif 'QUERY_STRING' in environ: qs = environ['QUERY_STRING'] else: *************** *** 182,186 **** dict = {} for name, value in parse_qsl(qs, keep_blank_values, strict_parsing): ! if dict.has_key(name): dict[name].append(value) else: --- 182,186 ---- dict = {} for name, value in parse_qsl(qs, keep_blank_values, strict_parsing): ! if name in dict: dict[name].append(value) else: *************** *** 245,249 **** """ boundary = "" ! if pdict.has_key('boundary'): boundary = pdict['boundary'] if not valid_boundary(boundary): --- 245,249 ---- """ boundary = "" ! if 'boundary' in pdict: boundary = pdict['boundary'] if not valid_boundary(boundary): *************** *** 305,313 **** if key != 'form-data': continue ! if params.has_key('name'): name = params['name'] else: continue ! if partdict.has_key(name): partdict[name].append(data) else: --- 305,313 ---- if key != 'form-data': continue ! if 'name' in params: name = params['name'] else: continue ! if name in partdict: partdict[name].append(data) else: *************** *** 441,448 **** self.keep_blank_values = keep_blank_values self.strict_parsing = strict_parsing ! if environ.has_key('REQUEST_METHOD'): method = environ['REQUEST_METHOD'].upper() if method == 'GET' or method == 'HEAD': ! if environ.has_key('QUERY_STRING'): qs = environ['QUERY_STRING'] elif sys.argv[1:]: --- 441,448 ---- self.keep_blank_values = keep_blank_values self.strict_parsing = strict_parsing ! if 'REQUEST_METHOD' in environ: method = environ['REQUEST_METHOD'].upper() if method == 'GET' or method == 'HEAD': ! if 'QUERY_STRING' in environ: qs = environ['QUERY_STRING'] elif sys.argv[1:]: *************** *** 459,465 **** # Set default content-type for POST to what's traditional headers['content-type'] = "application/x-www-form-urlencoded" ! if environ.has_key('CONTENT_TYPE'): headers['content-type'] = environ['CONTENT_TYPE'] ! if environ.has_key('CONTENT_LENGTH'): headers['content-length'] = environ['CONTENT_LENGTH'] self.fp = fp or sys.stdin --- 459,465 ---- # Set default content-type for POST to what's traditional headers['content-type'] = "application/x-www-form-urlencoded" ! if 'CONTENT_TYPE' in environ: headers['content-type'] = environ['CONTENT_TYPE'] ! if 'CONTENT_LENGTH' in environ: headers['content-length'] = environ['CONTENT_LENGTH'] self.fp = fp or sys.stdin *************** *** 469,481 **** # Process content-disposition header cdisp, pdict = "", {} ! if self.headers.has_key('content-disposition'): cdisp, pdict = parse_header(self.headers['content-disposition']) self.disposition = cdisp self.disposition_options = pdict self.name = None ! if pdict.has_key('name'): self.name = pdict['name'] self.filename = None ! if pdict.has_key('filename'): self.filename = pdict['filename'] --- 469,481 ---- # Process content-disposition header cdisp, pdict = "", {} ! if 'content-disposition' in self.headers: cdisp, pdict = parse_header(self.headers['content-disposition']) self.disposition = cdisp self.disposition_options = pdict self.name = None ! if 'name' in pdict: self.name = pdict['name'] self.filename = None ! if 'filename' in pdict: self.filename = pdict['filename'] *************** *** 492,496 **** # See below for what we do if there does exist a content-type header, # but it happens to be something we don't understand. ! if self.headers.has_key('content-type'): ctype, pdict = parse_header(self.headers['content-type']) elif self.outerboundary or method != 'POST': --- 492,496 ---- # See below for what we do if there does exist a content-type header, # but it happens to be something we don't understand. ! if 'content-type' in self.headers: ctype, pdict = parse_header(self.headers['content-type']) elif self.outerboundary or method != 'POST': *************** *** 501,508 **** self.type_options = pdict self.innerboundary = "" ! if pdict.has_key('boundary'): self.innerboundary = pdict['boundary'] clen = -1 ! if self.headers.has_key('content-length'): try: clen = int(self.headers['content-length']) --- 501,508 ---- self.type_options = pdict self.innerboundary = "" ! if 'boundary' in pdict: self.innerboundary = pdict['boundary'] clen = -1 ! if 'content-length' in self.headers: try: clen = int(self.headers['content-length']) *************** *** 556,560 **** def getvalue(self, key, default=None): """Dictionary style get() method, including 'value' lookup.""" ! if self.has_key(key): value = self[key] if type(value) is type([]): --- 556,560 ---- def getvalue(self, key, default=None): """Dictionary style get() method, including 'value' lookup.""" ! if key in self: value = self[key] if type(value) is type([]): *************** *** 567,571 **** def getfirst(self, key, default=None): """ Return the first value received.""" ! if self.has_key(key): value = self[key] if type(value) is type([]): --- 567,571 ---- def getfirst(self, key, default=None): """ Return the first value received.""" ! if key in self: value = self[key] if type(value) is type([]): *************** *** 578,582 **** def getlist(self, key): """ Return list of received values.""" ! if self.has_key(key): value = self[key] if type(value) is type([]): --- 578,582 ---- def getlist(self, key): """ Return list of received values.""" ! if key in self: value = self[key] if type(value) is type([]): *************** *** 604,607 **** --- 604,615 ---- return False + def __contains__(self, key): + """Dictionary style __contains__ method.""" + if self.list is None: + raise TypeError, "not indexable" + for item in self.list: + if item.name == key: return True + return False + def __len__(self): """Dictionary style len(x) support.""" *************** *** 771,775 **** form[key] -> [value, value, ...] ! form.has_key(key) -> Boolean form.keys() -> [key, key, ...] form.values() -> [[val, val, ...], [val, val, ...], ...] --- 779,783 ---- form[key] -> [value, value, ...] ! key in form -> Boolean form.keys() -> [key, key, ...] form.values() -> [[val, val, ...], [val, val, ...], ...] *************** *** 848,855 **** """This class is present for backwards compatibility only.""" def values(self, key): ! if self.dict.has_key(key) :return self.dict[key] else: return None def indexed_value(self, key, location): ! if self.dict.has_key(key): if len(self.dict[key]) > location: return self.dict[key][location] --- 856,863 ---- """This class is present for backwards compatibility only.""" def values(self, key): ! if key in self.dict :return self.dict[key] else: return None def indexed_value(self, key, location): ! if key in self.dict: if len(self.dict[key]) > location: return self.dict[key][location] *************** *** 857,866 **** else: return None def value(self, key): ! if self.dict.has_key(key): return self.dict[key][0] else: return None def length(self, key): return len(self.dict[key]) def stripped(self, key): ! if self.dict.has_key(key): return self.dict[key][0].strip() else: return None def pars(self): --- 865,874 ---- else: return None def value(self, key): ! if key in self.dict: return self.dict[key][0] else: return None def length(self, key): return len(self.dict[key]) def stripped(self, key): ! if key in self.dict: return self.dict[key][0].strip() else: return None def pars(self): Index: cmd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cmd.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** cmd.py 29 May 2002 16:18:41 -0000 1.29 --- cmd.py 1 Jun 2002 14:18:45 -0000 1.30 *************** *** 305,309 **** prevname = name cmd=name[3:] ! if help.has_key(cmd): cmds_doc.append(cmd) del help[cmd] --- 305,309 ---- prevname = name cmd=name[3:] ! if cmd in help: cmds_doc.append(cmd) del help[cmd] Index: codecs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/codecs.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** codecs.py 5 Mar 2002 15:46:38 -0000 1.24 --- codecs.py 1 Jun 2002 14:18:45 -0000 1.25 *************** *** 612,616 **** m = {} for k,v in decoding_map.items(): ! if not m.has_key(v): m[v] = k else: --- 612,616 ---- m = {} for k,v in decoding_map.items(): ! if not v in m: m[v] = k else: Index: copy.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/copy.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** copy.py 28 Feb 2002 23:19:13 -0000 1.24 --- copy.py 1 Jun 2002 14:18:45 -0000 1.25 *************** *** 159,163 **** memo = {} d = id(x) ! if memo.has_key(d): return memo[d] try: --- 159,163 ---- memo = {} d = id(x) ! if d in memo: return memo[d] try: Index: difflib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/difflib.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** difflib.py 29 Apr 2002 01:37:32 -0000 1.9 --- difflib.py 1 Jun 2002 14:18:45 -0000 1.10 *************** *** 322,326 **** del d[elt] ! # Now for x in b, isjunk(x) == junkdict.has_key(x), but the # latter is much faster. Note too that while there may be a # lot of junk in the sequence, the number of *unique* junk --- 322,326 ---- del d[elt] ! # Now for x in b, isjunk(x) == x in junkdict, but the # latter is much faster. Note too that while there may be a # lot of junk in the sequence, the number of *unique* junk Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** doctest.py 3 Apr 2002 22:41:50 -0000 1.23 --- doctest.py 1 Jun 2002 14:18:45 -0000 1.24 *************** *** 1016,1020 **** d = self.name2ft for name, (f, t) in other.name2ft.items(): ! if d.has_key(name): print "*** Tester.merge: '" + name + "' in both" \ " testers; summing outcomes." --- 1016,1020 ---- d = self.name2ft for name, (f, t) in other.name2ft.items(): ! if name in d: print "*** Tester.merge: '" + name + "' in both" \ " testers; summing outcomes." *************** *** 1025,1029 **** def __record_outcome(self, name, f, t): ! if self.name2ft.has_key(name): print "*** Warning: '" + name + "' was tested before;", \ "summing outcomes." --- 1025,1029 ---- def __record_outcome(self, name, f, t): ! if name in self.name2ft: print "*** Warning: '" + name + "' was tested before;", \ "summing outcomes." Index: dospath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dospath.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** dospath.py 7 Apr 2002 06:36:22 -0000 1.27 --- dospath.py 1 Jun 2002 14:18:45 -0000 1.28 *************** *** 227,231 **** i = i+1 if i == 1: ! if not os.environ.has_key('HOME'): return path userhome = os.environ['HOME'] --- 227,231 ---- i = i+1 if i == 1: ! if not 'HOME' in os.environ: return path userhome = os.environ['HOME'] *************** *** 273,277 **** index = path.index('}') var = path[:index] ! if os.environ.has_key(var): res = res + os.environ[var] except ValueError: --- 273,277 ---- index = path.index('}') var = path[:index] ! if var in os.environ: res = res + os.environ[var] except ValueError: *************** *** 286,290 **** index = index + 1 c = path[index:index + 1] ! if os.environ.has_key(var): res = res + os.environ[var] if c != '': --- 286,290 ---- index = index + 1 c = path[index:index + 1] ! if var in os.environ: res = res + os.environ[var] if c != '': Index: fnmatch.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/fnmatch.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** fnmatch.py 6 Jun 2001 06:24:38 -0000 1.12 --- fnmatch.py 1 Jun 2002 14:18:45 -0000 1.13 *************** *** 43,47 **** result=[] pat=os.path.normcase(pat) ! if not _cache.has_key(pat): res = translate(pat) _cache[pat] = re.compile(res) --- 43,47 ---- result=[] pat=os.path.normcase(pat) ! if not pat in _cache: res = translate(pat) _cache[pat] = re.compile(res) *************** *** 65,69 **** """ ! if not _cache.has_key(pat): res = translate(pat) _cache[pat] = re.compile(res) --- 65,69 ---- """ ! if not pat in _cache: res = translate(pat) _cache[pat] = re.compile(res) Index: ftplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ftplib.py,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** ftplib.py 1 Jun 2002 01:29:16 -0000 1.70 --- ftplib.py 1 Jun 2002 14:18:45 -0000 1.71 *************** *** 661,665 **** def __init__(self, filename=None): if filename is None: ! if os.environ.has_key("HOME"): filename = os.path.join(os.environ["HOME"], ".netrc") --- 661,665 ---- def __init__(self, filename=None): if filename is None: ! if "HOME" in os.environ: filename = os.path.join(os.environ["HOME"], ".netrc") *************** *** 715,719 **** self.__defacct = acct or self.__defacct if host: ! if self.__hosts.has_key(host): ouser, opasswd, oacct = \ self.__hosts[host] --- 715,719 ---- self.__defacct = acct or self.__defacct if host: ! if host in self.__hosts: ouser, opasswd, oacct = \ self.__hosts[host] *************** *** 737,741 **** host = host.lower() user = passwd = acct = None ! if self.__hosts.has_key(host): user, passwd, acct = self.__hosts[host] user = user or self.__defuser --- 737,741 ---- host = host.lower() user = passwd = acct = None ! if host in self.__hosts: user, passwd, acct = self.__hosts[host] user = user or self.__defuser Index: gopherlib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/gopherlib.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** gopherlib.py 16 Feb 2002 23:06:16 -0000 1.11 --- gopherlib.py 1 Jun 2002 14:18:45 -0000 1.12 *************** *** 46,50 **** if name[:2] == 'A_': _type_to_name_map[eval(name)] = name[2:] ! if _type_to_name_map.has_key(gtype): return _type_to_name_map[gtype] return 'TYPE=' + `gtype` --- 46,50 ---- if name[:2] == 'A_': _type_to_name_map[eval(name)] = name[2:] ! if gtype in _type_to_name_map: return _type_to_name_map[gtype] return 'TYPE=' + `gtype` Index: httplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/httplib.py,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** httplib.py 20 Apr 2002 07:47:39 -0000 1.50 --- httplib.py 1 Jun 2002 14:18:45 -0000 1.51 *************** *** 550,554 **** # optional skip_host argument to putrequest(). The check is # harder because field names are case insensitive. ! if (headers.has_key('Host') or [k for k in headers.iterkeys() if k.lower() == "host"]): self.putrequest(method, url, skip_host=1) --- 550,554 ---- # optional skip_host argument to putrequest(). The check is # harder because field names are case insensitive. ! if 'Host' in (headers or [k for k in headers.iterkeys() if k.lower() == "host"]): self.putrequest(method, url, skip_host=1) Index: ihooks.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ihooks.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ihooks.py 9 Feb 2001 10:17:30 -0000 1.13 --- ihooks.py 1 Jun 2002 14:18:45 -0000 1.14 *************** *** 176,180 **** def add_module(self, name): d = self.modules_dict() ! if d.has_key(name): return d[name] d[name] = m = self.new_module(name) return m --- 176,180 ---- def add_module(self, name): d = self.modules_dict() ! if name in d: return d[name] d[name] = m = self.new_module(name) return m *************** *** 353,357 **** def import_module(self, name, globals={}, locals={}, fromlist=[]): ! if self.modules.has_key(name): return self.modules[name] # Fast path stuff = self.loader.find_module(name) --- 353,357 ---- def import_module(self, name, globals={}, locals={}, fromlist=[]): ! if name in self.modules: return self.modules[name] # Fast path stuff = self.loader.find_module(name) *************** *** 404,411 **** def determine_parent(self, globals): ! if not globals or not globals.has_key("__name__"): return None pname = globals['__name__'] ! if globals.has_key("__path__"): parent = self.modules[pname] assert globals is parent.__dict__ --- 404,411 ---- def determine_parent(self, globals): ! if not globals or not "__name__" in globals: return None pname = globals['__name__'] ! if "__path__" in globals: parent = self.modules[pname] assert globals is parent.__dict__ Index: imaplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/imaplib.py,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** imaplib.py 1 Jun 2002 03:06:31 -0000 1.47 --- imaplib.py 1 Jun 2002 14:18:45 -0000 1.48 *************** *** 169,175 **** self.welcome = self._get_response() ! if self.untagged_responses.has_key('PREAUTH'): self.state = 'AUTH' ! elif self.untagged_responses.has_key('OK'): self.state = 'NONAUTH' else: --- 169,175 ---- self.welcome = self._get_response() ! if 'PREAUTH' in self.untagged_responses: self.state = 'AUTH' ! elif 'OK' in self.untagged_responses: self.state = 'NONAUTH' else: *************** *** 178,182 **** cap = 'CAPABILITY' self._simple_command(cap) ! if not self.untagged_responses.has_key(cap): raise self.error('no CAPABILITY response from server') self.capabilities = tuple(self.untagged_responses[cap][-1].upper().split()) --- 178,182 ---- cap = 'CAPABILITY' self._simple_command(cap) ! if not cap in self.untagged_responses: raise self.error('no CAPABILITY response from server') self.capabilities = tuple(self.untagged_responses[cap][-1].upper().split()) *************** *** 197,201 **** def __getattr__(self, attr): # Allow UPPERCASE variants of IMAP4 command methods. ! if Commands.has_key(attr): return getattr(self, attr.lower()) raise AttributeError("Unknown IMAP4 command: '%s'" % attr) --- 197,201 ---- def __getattr__(self, attr): # Allow UPPERCASE variants of IMAP4 command methods. ! if attr in Commands: return getattr(self, attr.lower()) raise AttributeError("Unknown IMAP4 command: '%s'" % attr) *************** *** 455,459 **** except: typ, dat = 'NO', ['%s: %s' % sys.exc_info()[:2]] self.shutdown() ! if self.untagged_responses.has_key('BYE'): return 'BYE', self.untagged_responses['BYE'] return typ, dat --- 455,459 ---- except: typ, dat = 'NO', ['%s: %s' % sys.exc_info()[:2]] self.shutdown() ! if 'BYE' in self.untagged_responses: return 'BYE', self.untagged_responses['BYE'] return typ, dat *************** *** 549,553 **** return typ, dat self.state = 'SELECTED' ! if self.untagged_responses.has_key('READ-ONLY') \ and not readonly: if __debug__: --- 549,553 ---- return typ, dat self.state = 'SELECTED' ! if 'READ-ONLY' in self.untagged_responses \ and not readonly: if __debug__: *************** *** 620,624 **** """ command = command.upper() ! if not Commands.has_key(command): raise self.error("Unknown IMAP4 UID command: %s" % command) if self.state not in Commands[command]: --- 620,624 ---- """ command = command.upper() ! if not command in Commands: raise self.error("Unknown IMAP4 UID command: %s" % command) if self.state not in Commands[command]: *************** *** 655,659 **** #if not name in self.capabilities: # Let the server decide! # raise self.error('unknown extension command: %s' % name) ! if not Commands.has_key(name): Commands[name] = (self.state,) return apply(self._simple_command, (name,) + args) --- 655,659 ---- #if not name in self.capabilities: # Let the server decide! # raise self.error('unknown extension command: %s' % name) ! if not name in Commands: Commands[name] = (self.state,) return apply(self._simple_command, (name,) + args) *************** *** 672,676 **** self._mesg('untagged_responses[%s] %s += ["%s"]' % (typ, len(ur.get(typ,'')), dat)) ! if ur.has_key(typ): ur[typ].append(dat) else: --- 672,676 ---- self._mesg('untagged_responses[%s] %s += ["%s"]' % (typ, len(ur.get(typ,'')), dat)) ! if typ in ur: ur[typ].append(dat) else: *************** *** 692,699 **** for typ in ('OK', 'NO', 'BAD'): ! if self.untagged_responses.has_key(typ): del self.untagged_responses[typ] ! if self.untagged_responses.has_key('READ-ONLY') \ and not self.is_readonly: raise self.readonly('mailbox status changed to READ-ONLY') --- 692,699 ---- for typ in ('OK', 'NO', 'BAD'): ! if typ in self.untagged_responses: del self.untagged_responses[typ] ! if 'READ-ONLY' in self.untagged_responses \ and not self.is_readonly: raise self.readonly('mailbox status changed to READ-ONLY') *************** *** 783,787 **** if self._match(self.tagre, resp): tag = self.mo.group('tag') ! if not self.tagged_commands.has_key(tag): raise self.abort('unexpected tagged response: %s' % resp) --- 783,787 ---- if self._match(self.tagre, resp): tag = self.mo.group('tag') ! if not tag in self.tagged_commands: raise self.abort('unexpected tagged response: %s' % resp) *************** *** 936,940 **** if typ == 'NO': return typ, dat ! if not self.untagged_responses.has_key(name): return typ, [None] data = self.untagged_responses[name] --- 936,940 ---- if typ == 'NO': return typ, dat ! if not name in self.untagged_responses: return typ, [None] data = self.untagged_responses[name] Index: inspect.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/inspect.py,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** inspect.py 1 Jun 2002 03:06:31 -0000 1.34 --- inspect.py 1 Jun 2002 14:18:45 -0000 1.35 *************** *** 357,366 **** except TypeError: return None ! if modulesbyfile.has_key(file): return sys.modules[modulesbyfile[file]] for module in sys.modules.values(): if hasattr(module, '__file__'): modulesbyfile[getabsfile(module)] = module.__name__ ! if modulesbyfile.has_key(file): return sys.modules[modulesbyfile[file]] main = sys.modules['__main__'] --- 357,366 ---- except TypeError: return None ! if file in modulesbyfile: return sys.modules[modulesbyfile[file]] for module in sys.modules.values(): if hasattr(module, '__file__'): modulesbyfile[getabsfile(module)] = module.__name__ ! if file in modulesbyfile: return sys.modules[modulesbyfile[file]] main = sys.modules['__main__'] *************** *** 530,534 **** for c in classes: results.append((c, c.__bases__)) ! if children.has_key(c): results.append(walktree(children[c], children, c)) return results --- 530,534 ---- for c in classes: results.append((c, c.__bases__)) ! if c in children: results.append(walktree(children[c], children, c)) return results *************** *** 548,552 **** if c.__bases__: for parent in c.__bases__: ! if not children.has_key(parent): children[parent] = [] children[parent].append(c) --- 548,552 ---- if c.__bases__: for parent in c.__bases__: ! if not parent in children: children[parent] = [] children[parent].append(c) Index: linecache.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/linecache.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** linecache.py 14 Apr 2002 20:12:39 -0000 1.9 --- linecache.py 1 Jun 2002 14:18:45 -0000 1.10 *************** *** 36,40 **** Update the cache if it doesn't contain an entry for this file already.""" ! if cache.has_key(filename): return cache[filename][2] else: --- 36,40 ---- Update the cache if it doesn't contain an entry for this file already.""" ! if filename in cache: return cache[filename][2] else: *************** *** 62,66 **** and return an empty list.""" ! if cache.has_key(filename): del cache[filename] if not filename or filename[0] + filename[-1] == '<>': --- 62,66 ---- and return an empty list.""" ! if filename in cache: del cache[filename] if not filename or filename[0] + filename[-1] == '<>': Index: mailbox.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mailbox.py,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** mailbox.py 4 Apr 2002 22:55:58 -0000 1.36 --- mailbox.py 1 Jun 2002 14:18:45 -0000 1.37 *************** *** 266,270 **** if not args: for key in 'MAILDIR', 'MAIL', 'LOGNAME', 'USER': ! if os.environ.has_key(key): mbox = os.environ[key] break --- 266,270 ---- if not args: for key in 'MAILDIR', 'MAIL', 'LOGNAME', 'USER': ! if key in os.environ: mbox = os.environ[key] break Index: mailcap.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mailcap.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** mailcap.py 11 May 2001 18:47:54 -0000 1.10 --- mailcap.py 1 Jun 2002 14:18:46 -0000 1.11 *************** *** 26,30 **** fp.close() for key in morecaps.keys(): ! if not caps.has_key(key): caps[key] = morecaps[key] else: --- 26,30 ---- fp.close() for key in morecaps.keys(): ! if not key in caps: caps[key] = morecaps[key] else: *************** *** 35,43 **** """Return a list of all mailcap files found on the system.""" # XXX Actually, this is Unix-specific ! if os.environ.has_key('MAILCAPS'): str = os.environ['MAILCAPS'] mailcaps = str.split(':') else: ! if os.environ.has_key('HOME'): home = os.environ['HOME'] else: --- 35,43 ---- """Return a list of all mailcap files found on the system.""" # XXX Actually, this is Unix-specific ! if 'MAILCAPS' in os.environ: str = os.environ['MAILCAPS'] mailcaps = str.split(':') else: ! if 'HOME' in os.environ: home = os.environ['HOME'] else: *************** *** 83,87 **** key = '/'.join(types).lower() # Update the database ! if caps.has_key(key): caps[key].append(fields) else: --- 83,87 ---- key = '/'.join(types).lower() # Update the database ! if key in caps: caps[key].append(fields) else: *************** *** 113,117 **** fkey = field[:i].strip() fvalue = field[i+1:].strip() ! if fields.has_key(fkey): # Ignore it pass --- 113,117 ---- fkey = field[:i].strip() fvalue = field[i+1:].strip() ! if fkey in fields: # Ignore it pass *************** *** 148,152 **** # XXX This code should somehow check for the needsterminal flag. for e in entries: ! if e.has_key('test'): test = subst(e['test'], filename, plist) if test and os.system(test) != 0: --- 148,152 ---- # XXX This code should somehow check for the needsterminal flag. for e in entries: ! if 'test' in e: test = subst(e['test'], filename, plist) if test and os.system(test) != 0: *************** *** 158,169 **** def lookup(caps, MIMEtype, key=None): entries = [] ! if caps.has_key(MIMEtype): entries = entries + caps[MIMEtype] MIMEtypes = MIMEtype.split('/') MIMEtype = MIMEtypes[0] + '/*' ! if caps.has_key(MIMEtype): entries = entries + caps[MIMEtype] if key is not None: ! entries = filter(lambda e, key=key: e.has_key(key), entries) return entries --- 158,169 ---- def lookup(caps, MIMEtype, key=None): entries = [] ! if MIMEtype in caps: entries = entries + caps[MIMEtype] MIMEtypes = MIMEtype.split('/') MIMEtype = MIMEtypes[0] + '/*' ! if MIMEtype in caps: entries = entries + caps[MIMEtype] if key is not None: ! entries = filter(lambda e, key=key: key in e, entries) return entries Index: mhlib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mhlib.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** mhlib.py 4 Apr 2002 22:55:58 -0000 1.29 --- mhlib.py 1 Jun 2002 14:18:46 -0000 1.30 *************** *** 376,380 **** except Error, msg: seqs = self.getsequences() ! if not seqs.has_key(head): if not msg: msg = "bad message list %s" % seq --- 376,380 ---- except Error, msg: seqs = self.getsequences() ! if not head in seqs: if not msg: msg = "bad message list %s" % seq *************** *** 413,417 **** except Error, msg: seqs = self.getsequences() ! if not seqs.has_key(seq): if not msg: msg = "bad message list %s" % seq --- 413,417 ---- except Error, msg: seqs = self.getsequences() ! if not seq in seqs: if not msg: msg = "bad message list %s" % seq Index: mimetools.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mimetools.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** mimetools.py 26 Mar 2002 16:21:52 -0000 1.25 --- mimetools.py 1 Jun 2002 14:18:46 -0000 1.26 *************** *** 143,147 **** if encoding in ('7bit', '8bit'): return output.write(input.read()) ! if decodetab.has_key(encoding): pipethrough(input, decodetab[encoding], output) else: --- 143,147 ---- if encoding in ('7bit', '8bit'): return output.write(input.read()) ! if encoding in decodetab: pipethrough(input, decodetab[encoding], output) else: *************** *** 162,166 **** if encoding in ('7bit', '8bit'): return output.write(input.read()) ! if encodetab.has_key(encoding): pipethrough(input, encodetab[encoding], output) else: --- 162,166 ---- if encoding in ('7bit', '8bit'): return output.write(input.read()) ! if encoding in encodetab: pipethrough(input, encodetab[encoding], output) else: Index: mimetypes.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mimetypes.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** mimetypes.py 5 Dec 2001 15:58:29 -0000 1.21 --- mimetypes.py 1 Jun 2002 14:18:46 -0000 1.22 *************** *** 97,103 **** return type, None # never compressed, so encoding is None base, ext = posixpath.splitext(url) ! while self.suffix_map.has_key(ext): base, ext = posixpath.splitext(base + self.suffix_map[ext]) ! if self.encodings_map.has_key(ext): encoding = self.encodings_map[ext] base, ext = posixpath.splitext(base) --- 97,103 ---- return type, None # never compressed, so encoding is None base, ext = posixpath.splitext(url) ! while ext in self.suffix_map: base, ext = posixpath.splitext(base + self.suffix_map[ext]) ! if ext in self.encodings_map: encoding = self.encodings_map[ext] base, ext = posixpath.splitext(base) *************** *** 106,118 **** types_map = self.types_map common_types = self.common_types ! if types_map.has_key(ext): return types_map[ext], encoding ! elif types_map.has_key(ext.lower()): return types_map[ext.lower()], encoding elif strict: return None, encoding ! elif common_types.has_key(ext): return common_types[ext], encoding ! elif common_types.has_key(ext.lower()): return common_types[ext.lower()], encoding else: --- 106,118 ---- types_map = self.types_map common_types = self.common_types ! if ext in types_map: return types_map[ext], encoding ! elif ext.lower() in types_map: return types_map[ext.lower()], encoding elif strict: return None, encoding ! elif ext in common_types: return common_types[ext], encoding ! elif ext.lower() in common_types: return common_types[ext.lower()], encoding else: Index: netrc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/netrc.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** netrc.py 22 Mar 2002 02:46:41 -0000 1.14 --- netrc.py 1 Jun 2002 14:18:46 -0000 1.15 *************** *** 85,91 **** def authenticators(self, host): """Return a (user, account, password) tuple for given host.""" ! if self.hosts.has_key(host): return self.hosts[host] ! elif self.hosts.has_key('default'): return self.hosts['default'] else: --- 85,91 ---- def authenticators(self, host): """Return a (user, account, password) tuple for given host.""" ! if host in self.hosts: return self.hosts[host] ! elif 'default' in self.hosts: return self.hosts['default'] else: Index: ntpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ntpath.py,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** ntpath.py 7 Apr 2002 06:36:23 -0000 1.47 --- ntpath.py 1 Jun 2002 14:18:46 -0000 1.48 *************** *** 344,350 **** i = i + 1 if i == 1: ! if os.environ.has_key('HOME'): userhome = os.environ['HOME'] ! elif not os.environ.has_key('HOMEPATH'): return path else: --- 344,350 ---- i = i + 1 if i == 1: ! if 'HOME' in os.environ: userhome = os.environ['HOME'] ! elif not 'HOMEPATH' in os.environ: return path else: *************** *** 400,404 **** index = path.index('}') var = path[:index] ! if os.environ.has_key(var): res = res + os.environ[var] except ValueError: --- 400,404 ---- index = path.index('}') var = path[:index] ! if var in os.environ: res = res + os.environ[var] except ValueError: *************** *** 413,417 **** index = index + 1 c = path[index:index + 1] ! if os.environ.has_key(var): res = res + os.environ[var] if c != '': --- 413,417 ---- index = index + 1 c = path[index:index + 1] ! if var in os.environ: res = res + os.environ[var] if c != '': Index: os.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/os.py,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** os.py 2 May 2002 17:39:19 -0000 1.56 --- os.py 1 Jun 2002 14:18:46 -0000 1.57 *************** *** 334,338 **** apply(func, (file,) + argrest) return ! if env.has_key('PATH'): envpath = env['PATH'] else: --- 334,338 ---- apply(func, (file,) + argrest) return ! if 'PATH' in env: envpath = env['PATH'] else: *************** *** 407,411 **** del self.data[key.upper()] def has_key(self, key): ! return self.data.has_key(key.upper()) def get(self, key, failobj=None): return self.data.get(key.upper(), failobj) --- 407,413 ---- del self.data[key.upper()] def has_key(self, key): ! return key.upper() in self.data ! def __contains__(self, key): ! return key.upper() in self.data def get(self, key, failobj=None): return self.data.get(key.upper(), failobj) Index: os2emxpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/os2emxpath.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** os2emxpath.py 16 Apr 2002 01:38:39 -0000 1.4 --- os2emxpath.py 1 Jun 2002 14:18:46 -0000 1.5 *************** *** 292,298 **** i = i + 1 if i == 1: ! if os.environ.has_key('HOME'): userhome = os.environ['HOME'] ! elif not os.environ.has_key('HOMEPATH'): return path else: --- 292,298 ---- i = i + 1 if i == 1: ! if 'HOME' in os.environ: userhome = os.environ['HOME'] ! elif not 'HOMEPATH' in os.environ: return path else: *************** *** 348,352 **** index = path.index('}') var = path[:index] ! if os.environ.has_key(var): res = res + os.environ[var] except ValueError: --- 348,352 ---- index = path.index('}') var = path[:index] ! if var in os.environ: res = res + os.environ[var] except ValueError: *************** *** 361,365 **** index = index + 1 c = path[index:index + 1] ! if os.environ.has_key(var): res = res + os.environ[var] if c != '': --- 361,365 ---- index = index + 1 c = path[index:index + 1] ! if var in os.environ: res = res + os.environ[var] if c != '': Index: pdb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pdb.py,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** pdb.py 15 Apr 2002 00:48:24 -0000 1.52 --- pdb.py 1 Jun 2002 14:18:46 -0000 1.53 *************** *** 59,63 **** # Read $HOME/.pdbrc and ./.pdbrc self.rcLines = [] ! if os.environ.has_key('HOME'): envHome = os.environ['HOME'] try: --- 59,63 ---- # Read $HOME/.pdbrc and ./.pdbrc self.rcLines = [] ! if 'HOME' in os.environ: envHome = os.environ['HOME'] try: *************** *** 155,159 **** return line args = line.split() ! while self.aliases.has_key(args[0]): line = self.aliases[args[0]] ii = 1 --- 155,159 ---- return line args = line.split() ! while args[0] in self.aliases: line = self.aliases[args[0]] ii = 1 *************** *** 510,519 **** name = co.co_varnames[i] print name, '=', ! if dict.has_key(name): print dict[name] else: print "*** undefined ***" do_a = do_args def do_retval(self, arg): ! if self.curframe.f_locals.has_key('__return__'): print self.curframe.f_locals['__return__'] else: --- 510,519 ---- name = co.co_varnames[i] print name, '=', ! if name in dict: print dict[name] else: print "*** undefined ***" do_a = do_args def do_retval(self, arg): ! if '__return__' in self.curframe.f_locals: print self.curframe.f_locals['__return__'] else: *************** *** 615,619 **** print "%s = %s" % (alias, self.aliases[alias]) return ! if self.aliases.has_key(args[0]) and len (args) == 1: print "%s = %s" % (args[0], self.aliases[args[0]]) else: --- 615,619 ---- print "%s = %s" % (alias, self.aliases[alias]) return ! if args[0] in self.aliases and len (args) == 1: print "%s = %s" % (args[0], self.aliases[args[0]]) else: *************** *** 623,627 **** args = arg.split() if len(args) == 0: return ! if self.aliases.has_key(args[0]): del self.aliases[args[0]] --- 623,627 ---- args = arg.split() if len(args) == 0: return ! if args[0] in self.aliases: del self.aliases[args[0]] Index: pickle.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pickle.py,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** pickle.py 30 May 2002 12:12:04 -0000 1.65 --- pickle.py 1 Jun 2002 14:18:46 -0000 1.66 *************** *** 207,211 **** return ! if memo.has_key(d): self.write(self.get(memo[d][0])) return --- 207,211 ---- return ! if d in memo: self.write(self.get(memo[d][0])) return *************** *** 431,435 **** save(element) ! if len(object) and memo.has_key(d): if self.bin: write(POP_MARK + self.get(memo[d][0])) --- 431,435 ---- save(element) ! if len(object) and d in memo: if self.bin: write(POP_MARK + self.get(memo[d][0])) *************** *** 621,625 **** If the class cannot be found, return __main__. """ ! if classmap.has_key(cls): return classmap[cls] --- 621,625 ---- If the class cannot be found, return __main__. """ ! if cls in classmap: return classmap[cls] *************** *** 914,918 **** if type(callable) is not ClassType: ! if not safe_constructors.has_key(callable): try: safe = callable.__safe_for_unpickling__ --- 914,918 ---- if type(callable) is not ClassType: ! if not callable in safe_constructors: try: safe = callable.__safe_for_unpickling__ Index: posixpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/posixpath.py,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** posixpath.py 7 Apr 2002 06:36:23 -0000 1.48 --- posixpath.py 1 Jun 2002 14:18:46 -0000 1.49 *************** *** 306,310 **** i = i + 1 if i == 1: ! if not os.environ.has_key('HOME'): return path userhome = os.environ['HOME'] --- 306,310 ---- i = i + 1 if i == 1: ! if not 'HOME' in os.environ: return path userhome = os.environ['HOME'] *************** *** 344,348 **** if name[:1] == '{' and name[-1:] == '}': name = name[1:-1] ! if os.environ.has_key(name): tail = path[j:] path = path[:i] + os.environ[name] --- 344,348 ---- if name[:1] == '{' and name[-1:] == '}': name = name[1:-1] ! if name in os.environ: tail = path[j:] path = path[:i] + os.environ[name] Index: profile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/profile.py,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** profile.py 5 Dec 2001 22:27:47 -0000 1.44 --- profile.py 1 Jun 2002 14:18:46 -0000 1.45 *************** *** 269,273 **** self.cur = (t, 0, 0, fn, frame, self.cur) timings = self.timings ! if timings.has_key(fn): cc, ns, tt, ct, callers = timings[fn] timings[fn] = cc, ns + 1, tt, ct, callers --- 269,273 ---- self.cur = (t, 0, 0, fn, frame, self.cur) timings = self.timings ! if fn in timings: cc, ns, tt, ct, callers = timings[fn] timings[fn] = cc, ns + 1, tt, ct, callers *************** *** 301,305 **** cc = cc + 1 ! if callers.has_key(pfn): callers[pfn] = callers[pfn] + 1 # hack: gather more # stats such as the amount of time added to ct courtesy --- 301,305 ---- cc = cc + 1 ! if pfn in callers: callers[pfn] = callers[pfn] + 1 # hack: gather more # stats such as the amount of time added to ct courtesy Index: pstats.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pstats.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** pstats.py 8 Oct 2001 06:28:18 -0000 1.23 --- pstats.py 1 Jun 2002 14:18:46 -0000 1.24 *************** *** 152,156 **** for func in other.stats.keys(): ! if self.stats.has_key(func): old_func_stat = self.stats[func] else: --- 152,156 ---- for func in other.stats.keys(): ! if func in self.stats: old_func_stat = self.stats[func] else: *************** *** 184,188 **** if not fragment: break ! if dict.has_key(fragment): bad_list[fragment] = 0 break --- 184,188 ---- if not fragment: break ! if fragment in dict: bad_list[fragment] = 0 break *************** *** 244,248 **** newcallers[func_strip_path(func2)] = callers[func2] ! if newstats.has_key(newfunc): newstats[newfunc] = add_func_stats( newstats[newfunc], --- 244,248 ---- newcallers[func_strip_path(func2)] = callers[func2] ! if newfunc in newstats: newstats[newfunc] = add_func_stats( newstats[newfunc], *************** *** 265,273 **** self.all_callees = all_callees = {} for func in self.stats.keys(): ! if not all_callees.has_key(func): all_callees[func] = {} cc, nc, tt, ct, callers = self.stats[func] for func2 in callers.keys(): ! if not all_callees.has_key(func2): all_callees[func2] = {} all_callees[func2][func] = callers[func2] --- 265,273 ---- self.all_callees = all_callees = {} for func in self.stats.keys(): ! if not func in all_callees: all_callees[func] = {} cc, nc, tt, ct, callers = self.stats[func] for func2 in callers.keys(): ! if not func2 in all_callees: all_callees[func2] = {} all_callees[func2][func] = callers[func2] *************** *** 355,359 **** self.print_call_heading(width, "called...") for func in list: ! if self.all_callees.has_key(func): self.print_call_line(width, func, self.all_callees[func]) else: --- 355,359 ---- self.print_call_heading(width, "called...") for func in list: ! if func in self.all_callees: self.print_call_line(width, func, self.all_callees[func]) else: *************** *** 472,476 **** new_callers[func] = target[func] for func in source.keys(): ! if new_callers.has_key(func): new_callers[func] = source[func] + new_callers[func] else: --- 472,476 ---- new_callers[func] = target[func] for func in source.keys(): ! if func in new_callers: new_callers[func] = source[func] + new_callers[func] else: Index: pyclbr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pyclbr.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** pyclbr.py 24 Oct 2001 20:22:40 -0000 1.23 --- pyclbr.py 1 Jun 2002 14:18:46 -0000 1.24 *************** *** 172,176 **** return child ! if _modules.has_key(module): # we've seen this module before... return _modules[module] --- 172,176 ---- return child ! if module in _modules: # we've seen this module before... return _modules[module] *************** *** 266,270 **** for n in inherit.split(','): n = n.strip() ! if dict.has_key(n): # we know this super class n = dict[n] --- 266,270 ---- for n in inherit.split(','): n = n.strip() ! if n in dict: # we know this super class n = dict[n] *************** *** 279,285 **** m = c[-2] c = c[-1] ! if _modules.has_key(m): d = _modules[m] ! if d.has_key(c): n = d[c] names.append(n) --- 279,285 ---- m = c[-2] c = c[-1] ! if m in _modules: d = _modules[m] ! if c in d: n = d[c] names.append(n) *************** *** 317,321 **** for n in names: n = n.strip() ! if d.has_key(n): dict[n] = d[n] elif n == '*': --- 317,321 ---- for n in names: n = n.strip() ! if n in d: dict[n] = d[n] elif n == '*': *************** *** 327,331 **** for n in d.keys(): if n[0] != '_' and \ ! not dict.has_key(n): dict[n] = d[n] else: --- 327,331 ---- for n in d.keys(): if n[0] != '_' and \ ! not n in dict: dict[n] = d[n] else: Index: pydoc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pydoc.py,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** pydoc.py 21 May 2002 20:56:15 -0000 1.63 --- pydoc.py 1 Jun 2002 14:18:46 -0000 1.64 *************** *** 224,228 **** not the package at the beginning. If the optional 'forceload' argument is 1, we reload the module from disk (unless it's a dynamic extension).""" ! if forceload and sys.modules.has_key(path): # This is the only way to be sure. Checking the mtime of the file # isn't good enough (e.g. what if the module contains a class that --- 224,228 ---- not the package at the beginning. If the optional 'forceload' argument is 1, we reload the module from disk (unless it's a dynamic extension).""" ! if forceload and path in sys.modules: # This is the only way to be sure. Checking the mtime of the file # isn't good enough (e.g. what if the module contains a class that *************** *** 242,246 **** # Did the error occur before or after the module was found? (exc, value, tb) = info = sys.exc_info() ! if sys.modules.has_key(path): # An error occured while executing the imported module. raise ErrorDuringImport(sys.modules[path].__file__, info) --- 242,246 ---- # Did the error occur before or after the module was found? (exc, value, tb) = info = sys.exc_info() ! if path in sys.modules: # An error occured while executing the imported module. raise ErrorDuringImport(sys.modules[path].__file__, info) *************** *** 404,408 **** """Make a link for an identifier, given name-to-URL mappings.""" for dict in dicts: ! if dict.has_key(name): return '%s' % (dict[name], name) return name --- 404,408 ---- """Make a link for an identifier, given name-to-URL mappings.""" for dict in dicts: ! if name in dict: return '%s' % (dict[name], name) return name *************** *** 537,541 **** if modname != name and module and hasattr(module, key): if getattr(module, key) is base: ! if not cdict.has_key(key): cdict[key] = cdict[base] = modname + '.html#' + key funcs, fdict = [], {} --- 537,541 ---- if modname != name and module and hasattr(module, key): if getattr(module, key) is base: ! if not key in cdict: cdict[key] = cdict[base] = modname + '.html#' + key funcs, fdict = [], {} *************** *** 779,783 **** title = '%s' % (anchor, realname) else: ! if (cl and cl.__dict__.has_key(realname) and cl.__dict__[realname] is object): reallink = '%s' % ( --- 779,783 ---- title = '%s' % (anchor, realname) else: ! if (cl and realname in cl.__dict__ and cl.__dict__[realname] is object): reallink = '%s' % ( *************** *** 823,828 **** def found(name, ispackage, modpkgs=modpkgs, shadowed=shadowed, seen=seen): ! if not seen.has_key(name): ! modpkgs.append((name, '', ispackage, shadowed.has_key(name))) seen[name] = 1 shadowed[name] = 1 --- 823,828 ---- def found(name, ispackage, modpkgs=modpkgs, shadowed=shadowed, seen=seen): ! if not name in seen: ! modpkgs.append((name, '', ispackage, name)) in shadowed seen[name] = 1 shadowed[name] = 1 *************** *** 1141,1145 **** title = self.bold(realname) else: ! if (cl and cl.__dict__.has_key(realname) and cl.__dict__[realname] is object): skipdocs = 1 --- 1141,1145 ---- title = self.bold(realname) else: ! if (cl and realname in cl.__dict__ and cl.__dict__[realname] is object): skipdocs = 1 *************** *** 1190,1194 **** if os.environ.get('TERM') in ['dumb', 'emacs']: return plainpager ! if os.environ.has_key('PAGER'): if sys.platform == 'win32': # pipes completely broken in Windows return lambda text: tempfilepager(plain(text), os.environ['PAGER']) --- 1190,1194 ---- if os.environ.get('TERM') in ['dumb', 'emacs']: return plainpager ! if 'PAGER' in os.environ: if sys.platform == 'win32': # pipes completely broken in Windows return lambda text: tempfilepager(plain(text), os.environ['PAGER']) *************** *** 1376,1380 **** if modname: modname = pkgpath + modname ! if not done.has_key(modname): done[modname] = 1 writedoc(modname) --- 1376,1380 ---- if modname: modname = pkgpath + modname ! if not modname in done: done[modname] = 1 writedoc(modname) *************** *** 1547,1552 **** elif request[:8] == 'modules ': self.listmodules(split(request)[1]) ! elif self.keywords.has_key(request): self.showtopic(request) ! elif self.topics.has_key(request): self.showtopic(request) elif request: doc(request, 'Help on %s:') elif isinstance(request, Helper): self() --- 1547,1552 ---- elif request[:8] == 'modules ': self.listmodules(split(request)[1]) ! elif request in self.keywords: self.showtopic(request) ! elif request in self.topics: self.showtopic(request) elif request: doc(request, 'Help on %s:') elif isinstance(request, Helper): self() *************** *** 1741,1745 **** if os.path.isfile(path) and modname: modname = package + (package and '.') + modname ! if not seen.has_key(modname): seen[modname] = 1 # if we see spam.py, skip spam.pyc if key is None: --- 1741,1745 ---- if os.path.isfile(path) and modname: modname = package + (package and '.') + modname ! if not modname in seen: seen[modname] = 1 # if we see spam.py, skip spam.pyc if key is None: Index: regsub.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/regsub.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** regsub.py 15 Feb 2001 22:15:13 -0000 1.13 --- regsub.py 1 Jun 2002 14:18:46 -0000 1.14 *************** *** 135,139 **** return pat # Assume it is a compiled regex key = (pat, regex.get_syntax()) ! if cache.has_key(key): prog = cache[key] # Get it from the cache else: --- 135,139 ---- return pat # Assume it is a compiled regex key = (pat, regex.get_syntax()) ! if key in cache: prog = cache[key] # Get it from the cache else: Index: rexec.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/rexec.py,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** rexec.py 31 May 2002 21:12:17 -0000 1.37 --- rexec.py 1 Jun 2002 14:18:46 -0000 1.38 *************** *** 207,211 **** if name not in self.ok_dynamic_modules: raise ImportError, "untrusted dynamic module: %s" % name ! if sys.modules.has_key(name): src = sys.modules[name] else: --- 207,211 ---- if name not in self.ok_dynamic_modules: raise ImportError, "untrusted dynamic module: %s" % name ! if name in sys.modules: src = sys.modules[name] else: *************** *** 289,293 **** def add_module(self, mname): ! if self.modules.has_key(mname): return self.modules[mname] self.modules[mname] = m = self.hooks.new_module(mname) --- 289,293 ---- def add_module(self, mname): ! if mname in self.modules: return self.modules[mname] self.modules[mname] = m = self.hooks.new_module(mname) Index: rfc822.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/rfc822.py,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** rfc822.py 23 May 2002 03:21:01 -0000 1.70 --- rfc822.py 1 Jun 2002 14:18:46 -0000 1.71 *************** *** 407,411 **** """Delete all occurrences of a specific header, if it is present.""" name = name.lower() ! if not self.dict.has_key(name): return del self.dict[name] --- 407,411 ---- """Delete all occurrences of a specific header, if it is present.""" name = name.lower() ! if not name in self.dict: return del self.dict[name] *************** *** 428,432 **** def get(self, name, default=""): name = name.lower() ! if self.dict.has_key(name): return self.dict[name] else: --- 428,432 ---- def get(self, name, default=""): name = name.lower() ! if name in self.dict: return self.dict[name] else: *************** *** 435,439 **** def setdefault(self, name, default=""): lowername = name.lower() ! if self.dict.has_key(lowername): return self.dict[lowername] else: --- 435,439 ---- def setdefault(self, name, default=""): lowername = name.lower() ! if lowername in self.dict: return self.dict[lowername] else: *************** *** 447,451 **** def has_key(self, name): """Determine whether a message contains the named header.""" ! return self.dict.has_key(name.lower()) def keys(self): --- 447,455 ---- def has_key(self, name): """Determine whether a message contains the named header.""" ! return name.lower() in self.dict ! ! def __contains__(self, name): ! """Determine whether a message contains the named header.""" ! return name.lower() in self.dict def keys(self): *************** *** 920,924 **** tzoffset = None tz = tz.upper() ! if _timezones.has_key(tz): tzoffset = _timezones[tz] else: --- 924,928 ---- tzoffset = None tz = tz.upper() ! if tz in _timezones: tzoffset = _timezones[tz] else: *************** *** 1011,1016 **** print '-'*70 print 'len =', len(m) ! if m.has_key('Date'): print 'Date =', m['Date'] ! if m.has_key('X-Nonsense'): pass print 'keys =', m.keys() print 'values =', m.values() --- 1015,1020 ---- print '-'*70 print 'len =', len(m) ! if 'Date' in m: print 'Date =', m['Date'] ! if 'X-Nonsense' in m: pass print 'keys =', m.keys() print 'values =', m.values() Index: sgmllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sgmllib.py,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** sgmllib.py 26 Oct 2001 18:02:28 -0000 1.39 --- sgmllib.py 1 Jun 2002 14:18:46 -0000 1.40 *************** *** 397,401 **** """ table = self.entitydefs ! if table.has_key(name): self.handle_data(table[name]) else: --- 397,401 ---- """ table = self.entitydefs ! if name in table: self.handle_data(table[name]) else: Index: site.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/site.py,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** site.py 4 Apr 2002 17:52:50 -0000 1.42 --- site.py 1 Jun 2002 14:18:46 -0000 1.43 *************** *** 85,89 **** continue dir, dircase = makepath(dir) ! if not _dirs_in_sys_path.has_key(dircase): L.append(dir) _dirs_in_sys_path[dircase] = 1 --- 85,89 ---- continue dir, dircase = makepath(dir) ! if not dircase in _dirs_in_sys_path: L.append(dir) _dirs_in_sys_path[dircase] = 1 *************** *** 117,121 **** reset = 0 sitedir, sitedircase = makepath(sitedir) ! if not _dirs_in_sys_path.has_key(sitedircase): sys.path.append(sitedir) # Add path component try: --- 117,121 ---- reset = 0 sitedir, sitedircase = makepath(sitedir) ! if not sitedircase in _dirs_in_sys_path: sys.path.append(sitedir) # Add path component try: *************** *** 154,158 **** dir = dir[:-1] dir, dircase = makepath(sitedir, dir) ! if not _dirs_in_sys_path.has_key(dircase) and os.path.exists(dir): sys.path.append(dir) _dirs_in_sys_path[dircase] = 1 --- 154,158 ---- dir = dir[:-1] dir, dircase = makepath(sitedir, dir) ! if not dircase in _dirs_in_sys_path and os.path.exists(dir): sys.path.append(dir) _dirs_in_sys_path[dircase] = 1 Index: smtplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/smtplib.py,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** smtplib.py 31 May 2002 17:49:10 -0000 1.54 --- smtplib.py 1 Jun 2002 14:18:46 -0000 1.55 *************** *** 412,416 **** def has_extn(self, opt): """Does the server support a given SMTP service extension?""" ! return self.esmtp_features.has_key(opt.lower()) def help(self, args=''): --- 412,416 ---- def has_extn(self, opt): """Does the server support a given SMTP service extension?""" ! return opt.lower() in self.esmtp_features def help(self, args=''): Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** sre_parse.py 7 Apr 2002 06:36:23 -0000 1.53 --- sre_parse.py 1 Jun 2002 14:18:46 -0000 1.54 *************** *** 569,575 **** else: # flags ! if not FLAGS.has_key(source.next): raise error, "unexpected end of pattern" ! while FLAGS.has_key(source.next): state.flags = state.flags | FLAGS[source.get()] if group: --- 569,575 ---- else: # flags ! if not source.next in FLAGS: raise error, "unexpected end of pattern" ! while source.next in FLAGS: state.flags = state.flags | FLAGS[source.get()] if group: Index: statcache.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/statcache.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** statcache.py 10 Apr 2002 02:04:00 -0000 1.14 --- statcache.py 1 Jun 2002 14:18:46 -0000 1.15 *************** *** 17,21 **** # The cache. Keys are pathnames, values are os.stat outcomes. # Remember that multiple threads may be calling this! So, e.g., that ! # cache.has_key(path) returns 1 doesn't mean the cache will still contain # path on the next line. Code defensively. --- 17,21 ---- # The cache. Keys are pathnames, values are os.stat outcomes. # Remember that multiple threads may be calling this! So, e.g., that ! # path in cache returns 1 doesn't mean the cache will still contain # path on the next line. Code defensively. Index: tempfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tempfile.py,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** tempfile.py 24 Mar 2002 22:21:48 -0000 1.38 --- tempfile.py 1 Jun 2002 14:18:46 -0000 1.39 *************** *** 64,68 **** attempdirs.insert(0, scrapdir) for envname in 'TMPDIR', 'TEMP', 'TMP': ! if os.environ.has_key(envname): attempdirs.insert(0, os.environ[envname]) testfile = gettempprefix() + 'test' --- 64,68 ---- attempdirs.insert(0, scrapdir) for envname in 'TMPDIR', 'TEMP', 'TMP': ! if envname in os.environ: attempdirs.insert(0, os.environ[envname]) testfile = gettempprefix() + 'test' Index: toaiff.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/toaiff.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** toaiff.py 13 Aug 2001 14:40:47 -0000 1.11 --- toaiff.py 1 Jun 2002 14:18:47 -0000 1.12 *************** *** 96,100 **** if ftype == 'aiff': return fname ! if ftype is None or not table.has_key(ftype): raise error, \ filename + ': unsupported audio file type ' + `ftype` --- 96,100 ---- if ftype == 'aiff': return fname ! if ftype is None or not ftype in table: raise error, \ filename + ': unsupported audio file type ' + `ftype` Index: urllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib.py,v retrieving revision 1.144 retrieving revision 1.145 diff -C2 -d -r1.144 -r1.145 *** urllib.py 24 May 2002 17:58:05 -0000 1.144 --- urllib.py 1 Jun 2002 14:18:47 -0000 1.145 *************** *** 154,158 **** """Use URLopener().open(file) instead of open(file, 'r').""" fullurl = unwrap(toBytes(fullurl)) ! if self.tempcache and self.tempcache.has_key(fullurl): filename, headers = self.tempcache[fullurl] fp = open(filename, 'rb') --- 154,158 ---- """Use URLopener().open(file) instead of open(file, 'r').""" fullurl = unwrap(toBytes(fullurl)) ! if self.tempcache and fullurl in self.tempcache: filename, headers = self.tempcache[fullurl] fp = open(filename, 'rb') *************** *** 161,165 **** if not urltype: urltype = 'file' ! if self.proxies.has_key(urltype): proxy = self.proxies[urltype] urltype, proxyhost = splittype(proxy) --- 161,165 ---- if not urltype: urltype = 'file' ! if urltype in self.proxies: proxy = self.proxies[urltype] urltype, proxyhost = splittype(proxy) *************** *** 201,205 **** or (tempfilename, headers) for a remote object.""" url = unwrap(toBytes(url)) ! if self.tempcache and self.tempcache.has_key(url): return self.tempcache[url] type, url1 = splittype(url) --- 201,205 ---- or (tempfilename, headers) for a remote object.""" url = unwrap(toBytes(url)) ! if self.tempcache and url in self.tempcache: return self.tempcache[url] type, url1 = splittype(url) *************** *** 231,235 **** blocknum = 1 if reporthook: ! if headers.has_key("content-length"): size = int(headers["Content-Length"]) reporthook(0, bs, size) --- 231,235 ---- blocknum = 1 if reporthook: ! if "content-length" in headers: size = int(headers["Content-Length"]) reporthook(0, bs, size) *************** *** 474,478 **** v.close() try: ! if not self.ftpcache.has_key(key): self.ftpcache[key] = \ ftpwrapper(user, passwd, host, port, dirs) --- 474,478 ---- v.close() try: ! if not key in self.ftpcache: self.ftpcache[key] = \ ftpwrapper(user, passwd, host, port, dirs) *************** *** 567,573 **** def redirect_internal(self, url, fp, errcode, errmsg, headers, data): ! if headers.has_key('location'): newurl = headers['location'] ! elif headers.has_key('uri'): newurl = headers['uri'] else: --- 567,573 ---- def redirect_internal(self, url, fp, errcode, errmsg, headers, data): ! if 'location' in headers: newurl = headers['location'] ! elif 'uri' in headers: newurl = headers['uri'] else: *************** *** 590,594 **** See this URL for a description of the basic authentication scheme: http://www.ics.uci.edu/pub/ietf/http/draft-ietf-http-v10-spec-00.txt""" ! if not headers.has_key('www-authenticate'): URLopener.http_error_default(self, url, fp, errcode, errmsg, headers) --- 590,594 ---- See this URL for a description of the basic authentication scheme: http://www.ics.uci.edu/pub/ietf/http/draft-ietf-http-v10-spec-00.txt""" ! if not 'www-authenticate' in headers: URLopener.http_error_default(self, url, fp, errcode, errmsg, headers) *************** *** 634,638 **** def get_user_passwd(self, host, realm, clear_cache = 0): key = realm + '@' + host.lower() ! if self.auth_cache.has_key(key): if clear_cache: del self.auth_cache[key] --- 634,638 ---- def get_user_passwd(self, host, realm, clear_cache = 0): key = realm + '@' + host.lower() ! if key in self.auth_cache: if clear_cache: del self.auth_cache[key] *************** *** 1109,1113 **** for i in range(len(res)): c = res[i] ! if not _fast_safe.has_key(c): res[i] = '%%%02X' % ord(c) return ''.join(res) --- 1109,1113 ---- for i in range(len(res)): c = res[i] ! if not c in _fast_safe: res[i] = '%%%02X' % ord(c) return ''.join(res) *************** *** 1254,1258 **** proxies = {} # HTTP: ! if config.has_key('UseHTTPProxy') and config['UseHTTPProxy']: try: value = config['HTTPProxyHost'] --- 1254,1258 ---- proxies = {} # HTTP: ! if 'UseHTTPProxy' in config and config['UseHTTPProxy']: try: value = config['HTTPProxyHost'] Index: urllib2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib2.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** urllib2.py 20 May 2002 14:30:06 -0000 1.28 --- urllib2.py 1 Jun 2002 14:18:47 -0000 1.29 *************** *** 256,260 **** if meth[-5:] == '_open': protocol = meth[:-5] ! if self.handle_open.has_key(protocol): self.handle_open[protocol].append(handler) else: --- 256,260 ---- if meth[-5:] == '_open': protocol = meth[:-5] ! if protocol in self.handle_open: self.handle_open[protocol].append(handler) else: *************** *** 272,276 **** pass dict = self.handle_error.get(proto, {}) ! if dict.has_key(kind): dict[kind].append(handler) else: --- 272,276 ---- pass dict = self.handle_error.get(proto, {}) ! if kind in dict: dict[kind].append(handler) else: *************** *** 405,411 **** # attribute to the Request object. def http_error_302(self, req, fp, code, msg, headers): ! if headers.has_key('location'): newurl = headers['location'] ! elif headers.has_key('uri'): newurl = headers['uri'] else: --- 405,411 ---- # attribute to the Request object. def http_error_302(self, req, fp, code, msg, headers): ! if 'location' in headers: newurl = headers['location'] ! elif 'uri' in headers: newurl = headers['uri'] else: *************** *** 420,424 **** if hasattr(req, 'error_302_dict'): if len(req.error_302_dict)>10 or \ ! req.error_302_dict.has_key(newurl): raise HTTPError(req.get_full_url(), code, self.inf_msg + msg, headers, fp) --- 420,424 ---- if hasattr(req, 'error_302_dict'): if len(req.error_302_dict)>10 or \ ! newurl in req.error_302_dict: raise HTTPError(req.get_full_url(), code, self.inf_msg + msg, headers, fp) *************** *** 506,510 **** def add_proxy(self, cpo): ! if self.proxies.has_key(cpo.proto): self.proxies[cpo.proto].append(cpo) else: --- 506,510 ---- def add_proxy(self, cpo): ! if cpo.proto in self.proxies: self.proxies[cpo.proto].append(cpo) else: *************** *** 520,524 **** uri = [uri] uri = tuple(map(self.reduce_uri, uri)) ! if not self.passwd.has_key(realm): self.passwd[realm] = {} self.passwd[realm][uri] = (user, passwd) --- 520,524 ---- uri = [uri] uri = tuple(map(self.reduce_uri, uri)) ! if not realm in self.passwd: self.passwd[realm] = {} self.passwd[realm][uri] = (user, passwd) *************** *** 752,759 **** data = req.get_data() h.putrequest('POST', req.get_selector()) ! if not req.headers.has_key('Content-type'): h.putheader('Content-type', 'application/x-www-form-urlencoded') ! if not req.headers.has_key('Content-length'): h.putheader('Content-length', '%d' % len(data)) else: --- 752,759 ---- data = req.get_data() h.putrequest('POST', req.get_selector()) ! if not 'Content-type' in req.headers: h.putheader('Content-type', 'application/x-www-form-urlencoded') ! if not 'Content-length' in req.headers: h.putheader('Content-length', '%d' % len(data)) else: *************** *** 955,959 **** def connect_ftp(self, user, passwd, host, port, dirs): key = user, passwd, host, port ! if self.cache.has_key(key): self.timeout[key] = time.time() + self.delay else: --- 955,959 ---- def connect_ftp(self, user, passwd, host, port, dirs): key = user, passwd, host, port ! if key in self.cache: self.timeout[key] = time.time() + self.delay else: Index: user.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/user.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** user.py 30 Mar 2000 15:00:33 -0000 1.5 --- user.py 1 Jun 2002 14:18:47 -0000 1.6 *************** *** 25,33 **** home = os.curdir # Default ! if os.environ.has_key('HOME'): home = os.environ['HOME'] elif os.name == 'nt': # Contributed by Jeff Bauer ! if os.environ.has_key('HOMEPATH'): ! if os.environ.has_key('HOMEDRIVE'): home = os.environ['HOMEDRIVE'] + os.environ['HOMEPATH'] else: --- 25,33 ---- home = os.curdir # Default ! if 'HOME' in os.environ: home = os.environ['HOME'] elif os.name == 'nt': # Contributed by Jeff Bauer ! if 'HOMEPATH' in os.environ: ! if 'HOMEDRIVE' in os.environ: home = os.environ['HOMEDRIVE'] + os.environ['HOMEPATH'] else: Index: warnings.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/warnings.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** warnings.py 29 May 2002 15:54:53 -0000 1.14 --- warnings.py 1 Jun 2002 14:18:47 -0000 1.15 *************** *** 28,32 **** globals = caller.f_globals lineno = caller.f_lineno ! if globals.has_key('__name__'): module = globals['__name__'] else: --- 28,32 ---- globals = caller.f_globals lineno = caller.f_lineno ! if '__name__' in globals: module = globals['__name__'] else: Index: weakref.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/weakref.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** weakref.py 6 Nov 2001 16:36:53 -0000 1.15 --- weakref.py 1 Jun 2002 14:18:47 -0000 1.16 *************** *** 184,189 **** except TypeError: return 0 ! return self.data.has_key(wr) def items(self): L = [] --- 184,196 ---- except TypeError: return 0 ! return wr in self.data + def __contains__(self, key): + try: + wr = ref(key) + except TypeError: + return 0 + return wr in self.data + def items(self): L = [] Index: webbrowser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/webbrowser.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** webbrowser.py 4 Apr 2002 22:55:58 -0000 1.30 --- webbrowser.py 1 Jun 2002 14:18:47 -0000 1.31 *************** *** 313,317 **** # platform are, allow user to override them with the BROWSER variable. # ! if os.environ.has_key("BROWSER"): # It's the user's responsibility to register handlers for any unknown # browser referenced by this value, before calling open(). --- 313,317 ---- # platform are, allow user to override them with the BROWSER variable. # ! if "BROWSER" in os.environ: # It's the user's responsibility to register handlers for any unknown # browser referenced by this value, before calling open(). *************** *** 319,323 **** for cmd in _tryorder: ! if not _browsers.has_key(cmd.lower()): if _iscommand(cmd.lower()): register(cmd.lower(), None, GenericBrowser( --- 319,323 ---- for cmd in _tryorder: ! if not cmd.lower() in _browsers: if _iscommand(cmd.lower()): register(cmd.lower(), None, GenericBrowser( *************** *** 326,330 **** del cmd ! _tryorder = filter(lambda x: _browsers.has_key(x.lower()) or x.find("%s") > -1, _tryorder) # what to do if _tryorder is now empty? --- 326,330 ---- del cmd ! _tryorder = filter(lambda x: x.lower() in _browsers or x.find("%s") > -1, _tryorder) # what to do if _tryorder is now empty? Index: xmllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xmllib.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** xmllib.py 10 Apr 2002 02:04:00 -0000 1.29 --- xmllib.py 1 Jun 2002 14:18:47 -0000 1.30 *************** *** 103,115 **** def __init__(self, **kw): self.__fixed = 0 ! if kw.has_key('accept_unquoted_attributes'): self.__accept_unquoted_attributes = kw['accept_unquoted_attributes'] ! if kw.has_key('accept_missing_endtag_name'): self.__accept_missing_endtag_name = kw['accept_missing_endtag_name'] ! if kw.has_key('map_case'): self.__map_case = kw['map_case'] ! if kw.has_key('accept_utf8'): self.__accept_utf8 = kw['accept_utf8'] ! if kw.has_key('translate_attribute_references'): self.__translate_attribute_references = kw['translate_attribute_references'] self.reset() --- 103,115 ---- def __init__(self, **kw): self.__fixed = 0 ! if 'accept_unquoted_attributes' in kw: self.__accept_unquoted_attributes = kw['accept_unquoted_attributes'] ! if 'accept_missing_endtag_name' in kw: self.__accept_missing_endtag_name = kw['accept_missing_endtag_name'] ! if 'map_case' in kw: self.__map_case = kw['map_case'] ! if 'accept_utf8' in kw: self.__accept_utf8 = kw['accept_utf8'] ! if 'translate_attribute_references' in kw: self.__translate_attribute_references = kw['translate_attribute_references'] self.reset() *************** *** 207,211 **** i = i-1 elif all: ! if self.entitydefs.has_key(str): str = self.entitydefs[str] rescan = 1 --- 207,211 ---- i = i-1 elif all: ! if str in self.entitydefs: str = self.entitydefs[str] rescan = 1 *************** *** 376,380 **** if self.__map_case: name = name.lower() ! if self.entitydefs.has_key(name): self.rawdata = rawdata = rawdata[:res.start(0)] + self.entitydefs[name] + rawdata[i:] n = len(rawdata) --- 376,380 ---- if self.__map_case: name = name.lower() ! if name in self.entitydefs: self.rawdata = rawdata = rawdata[:res.start(0)] + self.entitydefs[name] + rawdata[i:] n = len(rawdata) *************** *** 534,540 **** self.syntax_error('namespace declaration inside namespace declaration') for attrname in attrdict.keys(): ! if not self.__xml_namespace_attributes.has_key(attrname): self.syntax_error("unknown attribute `%s' in xml:namespace tag" % attrname) ! if not attrdict.has_key('ns') or not attrdict.has_key('prefix'): self.syntax_error('xml:namespace without required attributes') prefix = attrdict.get('prefix') --- 534,540 ---- self.syntax_error('namespace declaration inside namespace declaration') for attrname in attrdict.keys(): ! if not attrname in self.__xml_namespace_attributes: self.syntax_error("unknown attribute `%s' in xml:namespace tag" % attrname) ! if not 'ns' in attrdict or not 'prefix' in attrdict: self.syntax_error('xml:namespace without required attributes') prefix = attrdict.get('prefix') *************** *** 542,546 **** self.syntax_error('xml:namespace illegal prefix value') return end.end(0) ! if self.__namespaces.has_key(prefix): self.syntax_error('xml:namespace prefix not unique') self.__namespaces[prefix] = attrdict['ns'] --- 542,546 ---- self.syntax_error('xml:namespace illegal prefix value') return end.end(0) ! if prefix in self.__namespaces: self.syntax_error('xml:namespace prefix not unique') self.__namespaces[prefix] = attrdict['ns'] *************** *** 582,586 **** if '<' in attrvalue: self.syntax_error("`<' illegal in attribute value") ! if attrdict.has_key(attrname): self.syntax_error("attribute `%s' specified twice" % attrname) attrvalue = attrvalue.translate(attrtrans) --- 582,586 ---- if '<' in attrvalue: self.syntax_error("`<' illegal in attribute value") ! if attrname in attrdict: self.syntax_error("attribute `%s' specified twice" % attrname) attrvalue = attrvalue.translate(attrtrans) *************** *** 620,624 **** ns = None for t, d, nst in self.stack: ! if d.has_key(prefix): ns = d[prefix] if ns is None and prefix != '': --- 620,624 ---- ns = None for t, d, nst in self.stack: ! if prefix in d: ns = d[prefix] if ns is None and prefix != '': *************** *** 646,650 **** ans = None for t, d, nst in self.stack: ! if d.has_key(aprefix): ans = d[aprefix] if ans is None and aprefix != '': --- 646,650 ---- ans = None for t, d, nst in self.stack: ! if aprefix in d: ans = d[aprefix] if ans is None and aprefix != '': *************** *** 662,669 **** if attributes is not None: for key in attrdict.keys(): ! if not attributes.has_key(key): self.syntax_error("unknown attribute `%s' in tag `%s'" % (attrnamemap[key], tagname)) for key, val in attributes.items(): ! if val is not None and not attrdict.has_key(key): attrdict[key] = val method = self.elements.get(nstag, (None, None))[0] --- 662,669 ---- if attributes is not None: for key in attrdict.keys(): ! if not key in attributes: self.syntax_error("unknown attribute `%s' in tag `%s'" % (attrnamemap[key], tagname)) for key, val in attributes.items(): ! if val is not None and not key in attrdict: attrdict[key] = val method = self.elements.get(nstag, (None, None))[0] Index: xmlrpclib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xmlrpclib.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** xmlrpclib.py 26 Mar 2002 16:23:28 -0000 1.16 --- xmlrpclib.py 1 Jun 2002 14:18:47 -0000 1.17 *************** *** 497,501 **** if value: i = id(value) ! if self.memo.has_key(i): raise TypeError, "cannot marshal recursive data structures" self.memo[i] = None --- 497,501 ---- if value: i = id(value) ! if i in self.memo: raise TypeError, "cannot marshal recursive data structures" self.memo[i] = None Index: zipfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/zipfile.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** zipfile.py 7 Apr 2002 06:36:23 -0000 1.21 --- zipfile.py 1 Jun 2002 14:18:47 -0000 1.22 *************** *** 355,359 **** def _writecheck(self, zinfo): """Check for errors before writing a file to the archive.""" ! if self.NameToInfo.has_key(zinfo.filename): if self.debug: # Warning for duplicate names print "Duplicate name:", zinfo.filename --- 355,359 ---- def _writecheck(self, zinfo): """Check for errors before writing a file to the archive.""" ! if zinfo.filename in self.NameToInfo: if self.debug: # Warning for duplicate names print "Duplicate name:", zinfo.filename From rhettinger@users.sourceforge.net Sat Jun 1 15:25:43 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat, 01 Jun 2002 07:25:43 -0700 Subject: [Python-checkins] python/dist/src/Lib dumbdbm.py,1.18,1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv11223 Modified Files: dumbdbm.py Log Message: SF 563203. Replaced 'has_key()' with 'in'. Index: dumbdbm.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dumbdbm.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** dumbdbm.py 29 May 2002 16:18:41 -0000 1.18 --- dumbdbm.py 1 Jun 2002 14:25:41 -0000 1.19 *************** *** 109,113 **** if not type(key) == type('') == type(val): raise TypeError, "keys and values must be strings" ! if not self._index.has_key(key): (pos, siz) = self._addval(val) self._addkey(key, (pos, siz)) --- 109,113 ---- if not type(key) == type('') == type(val): raise TypeError, "keys and values must be strings" ! if not key in self._index: (pos, siz) = self._addval(val) self._addkey(key, (pos, siz)) *************** *** 131,138 **** def has_key(self, key): ! return self._index.has_key(key) def __contains__(self, key): ! return self._index.has_key(key) def iterkeys(self): --- 131,138 ---- def has_key(self, key): ! return key in self._index def __contains__(self, key): ! return key in self._index def iterkeys(self): From rhettinger@users.sourceforge.net Sat Jun 1 17:07:18 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat, 01 Jun 2002 09:07:18 -0700 Subject: [Python-checkins] python/dist/src/Lib mhlib.py,1.30,1.31 netrc.py,1.15,1.16 poplib.py,1.20,1.21 pprint.py,1.21,1.22 profile.py,1.45,1.46 pstats.py,1.24,1.25 py_compile.py,1.19,1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv588 Modified Files: mhlib.py netrc.py poplib.py pprint.py profile.py pstats.py py_compile.py Log Message: Replace boolean test with is None. Index: mhlib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mhlib.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** mhlib.py 1 Jun 2002 14:18:46 -0000 1.30 --- mhlib.py 1 Jun 2002 16:07:16 -0000 1.31 *************** *** 99,105 **** def __init__(self, path = None, profile = None): """Constructor.""" ! if not profile: profile = MH_PROFILE self.profile = os.path.expanduser(profile) ! if not path: path = self.getprofile('Path') if not path: path = PATH if not os.path.isabs(path) and path[0] != '~': --- 99,105 ---- def __init__(self, path = None, profile = None): """Constructor.""" ! if profile is None: profile = MH_PROFILE self.profile = os.path.expanduser(profile) ! if path is None: path = self.getprofile('Path') if not path: path = PATH if not os.path.isabs(path) and path[0] != '~': *************** *** 666,670 **** self.folder = f self.number = n ! if not fp: path = f.getmessagefilename(n) fp = open(path, 'r') --- 666,670 ---- self.folder = f self.number = n ! if fp is None: path = f.getmessagefilename(n) fp = open(path, 'r') *************** *** 680,684 **** decide which headers to return (its argument is the header name converted to lower case).""" ! if not pred: return ''.join(self.headers) headers = [] --- 680,684 ---- decide which headers to return (its argument is the header name converted to lower case).""" ! if pred is None: return ''.join(self.headers) headers = [] *************** *** 792,796 **** self.sep = sep self.rng = rng ! if data: self.fromstring(data) def reset(self): --- 792,796 ---- self.sep = sep self.rng = rng ! if data is not None: self.fromstring(data) def reset(self): Index: netrc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/netrc.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** netrc.py 1 Jun 2002 14:18:46 -0000 1.15 --- netrc.py 1 Jun 2002 16:07:16 -0000 1.16 *************** *** 22,26 **** class netrc: def __init__(self, file=None): ! if not file: try: file = os.path.join(os.environ['HOME'], ".netrc") --- 22,26 ---- class netrc: def __init__(self, file=None): ! if file is None: try: file = os.path.join(os.environ['HOME'], ".netrc") Index: poplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/poplib.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** poplib.py 16 Feb 2002 23:06:18 -0000 1.20 --- poplib.py 1 Jun 2002 16:07:16 -0000 1.21 *************** *** 221,225 **** single response: the "scan listing" for that message. """ ! if which: return self._shortcmd('LIST %s' % which) return self._longcmd('LIST') --- 221,225 ---- single response: the "scan listing" for that message. """ ! if which is not None: return self._shortcmd('LIST %s' % which) return self._longcmd('LIST') *************** *** 314,318 **** the list ['response', ['mesgnum uid', ...], octets] """ ! if which: return self._shortcmd('UIDL %s' % which) return self._longcmd('UIDL') --- 314,318 ---- the list ['response', ['mesgnum uid', ...], octets] """ ! if which is not None: return self._shortcmd('UIDL %s' % which) return self._longcmd('UIDL') Index: pprint.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pprint.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** pprint.py 7 Apr 2002 06:36:23 -0000 1.21 --- pprint.py 1 Jun 2002 16:07:16 -0000 1.22 *************** *** 102,106 **** self.__indent_per_level = indent self.__width = width ! if stream: self.__stream = stream else: --- 102,106 ---- self.__indent_per_level = indent self.__width = width ! if stream is not None: self.__stream = stream else: Index: profile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/profile.py,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** profile.py 1 Jun 2002 14:18:46 -0000 1.45 --- profile.py 1 Jun 2002 16:07:16 -0000 1.46 *************** *** 151,155 **** self.bias = bias # Materialize in local dict for lookup speed. ! if not timer: if os.name == 'mac': self.timer = MacOS.GetTicks --- 151,155 ---- self.bias = bias # Materialize in local dict for lookup speed. ! if timer is None: if os.name == 'mac': self.timer = MacOS.GetTicks Index: pstats.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pstats.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** pstats.py 1 Jun 2002 14:18:46 -0000 1.24 --- pstats.py 1 Jun 2002 16:07:16 -0000 1.25 *************** *** 507,511 **** cmd.Cmd.__init__(self) self.prompt = "% " ! if profile: self.stats = Stats(profile) else: --- 507,511 ---- cmd.Cmd.__init__(self) self.prompt = "% " ! if profile is not None: self.stats = Stats(profile) else: Index: py_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/py_compile.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** py_compile.py 14 Apr 2002 20:12:40 -0000 1.19 --- py_compile.py 1 Jun 2002 16:07:16 -0000 1.20 *************** *** 68,72 **** 'File "%s"' % (dfile or file))) return ! if not cfile: cfile = file + (__debug__ and 'c' or 'o') fc = open(cfile, 'wb') --- 68,72 ---- 'File "%s"' % (dfile or file))) return ! if cfile is None: cfile = file + (__debug__ and 'c' or 'o') fc = open(cfile, 'wb') From nnorwitz@users.sourceforge.net Sat Jun 1 19:26:27 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Sat, 01 Jun 2002 11:26:27 -0700 Subject: [Python-checkins] python/dist/src/Python import.c,2.192.6.1,2.192.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv30573/Python Modified Files: Tag: release22-maint import.c Log Message: Fix SF #561858 Assertion with very long lists if co_stacksize was > 32767 (the maximum value which can be stored in 16 bits (signed)), the PyCodeObject would be written wrong. So on the second import (reading the .pyc) would cause a crash. Since we can't change the PYC magic, we go on (silently), but don't write the file. This means everything will work, but a .pyc will not be written and the file will need to be parsed on each import. I will backport. Index: import.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/import.c,v retrieving revision 2.192.6.1 retrieving revision 2.192.6.2 diff -C2 -d -r2.192.6.1 -r2.192.6.2 *** import.c 12 Jan 2002 11:13:24 -0000 2.192.6.1 --- import.c 1 Jun 2002 18:26:22 -0000 2.192.6.2 *************** *** 20,23 **** --- 20,26 ---- #endif + /* check if the int_value can't be written in 15 bits (signed) */ + #define CANT_WRITE(int_value) (int_value > 32767) + extern time_t PyOS_GetLastModificationTime(char *, FILE *); /* In getmtime.c */ *************** *** 687,690 **** --- 690,705 ---- { FILE *fp; + + if (CANT_WRITE(co->co_argcount) || + CANT_WRITE(co->co_nlocals) || + CANT_WRITE(co->co_stacksize) || + CANT_WRITE(co->co_flags) || + CANT_WRITE(co->co_firstlineno)) { + if (Py_VerboseFlag) + PySys_WriteStderr( + "# code too large: can't write %s\n", + cpathname); + return; + } fp = open_exclusive(cpathname); From nnorwitz@users.sourceforge.net Sat Jun 1 19:27:36 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Sat, 01 Jun 2002 11:27:36 -0700 Subject: [Python-checkins] python/dist/src/Python import.c,2.175.2.2,2.175.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv31405/Python Modified Files: Tag: release21-maint import.c Log Message: Fix SF #561858 Assertion with very long lists if co_stacksize was > 32767 (the maximum value which can be stored in 16 bits (signed)), the PyCodeObject would be written wrong. So on the second import (reading the .pyc) would cause a crash. Since we can't change the PYC magic, we go on (silently), but don't write the file. This means everything will work, but a .pyc will not be written and the file will need to be parsed on each import. Index: import.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/import.c,v retrieving revision 2.175.2.2 retrieving revision 2.175.2.3 diff -C2 -d -r2.175.2.2 -r2.175.2.3 *** import.c 11 Jul 2001 12:03:44 -0000 2.175.2.2 --- import.c 1 Jun 2002 18:27:34 -0000 2.175.2.3 *************** *** 33,36 **** --- 33,39 ---- #endif + /* check if the int_value can't be written in 15 bits (signed) */ + #define CANT_WRITE(int_value) (int_value > 32767) + extern time_t PyOS_GetLastModificationTime(char *, FILE *); /* In getmtime.c */ *************** *** 669,672 **** --- 672,687 ---- { FILE *fp; + + if (CANT_WRITE(co->co_argcount) || + CANT_WRITE(co->co_nlocals) || + CANT_WRITE(co->co_stacksize) || + CANT_WRITE(co->co_flags) || + CANT_WRITE(co->co_firstlineno)) { + if (Py_VerboseFlag) + PySys_WriteStderr( + "# code too large: can't write %s\n", + cpathname); + return; + } fp = open_exclusive(cpathname); From rhettinger@users.sourceforge.net Sat Jun 1 20:51:17 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat, 01 Jun 2002 12:51:17 -0700 Subject: [Python-checkins] python/dist/src/Lib CGIHTTPServer.py,1.24,1.25 compileall.py,1.11,1.12 dircache.py,1.10,1.11 dospath.py,1.28,1.29 filecmp.py,1.11,1.12 imputil.py,1.24,1.25 linecache.py,1.10,1.11 macpath.py,1.38,1.39 mhlib.py,1.31,1.32 ntpath.py,1.48,1.49 os2emxpath.py,1.5,1.6 posixpath.py,1.49,1.50 pstats.py,1.25,1.26 py_compile.py,1.20,1.21 pydoc.py,1.64,1.65 statcache.py,1.15,1.16 uu.py,1.18,1.19 zipfile.py,1.22,1.23 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv18955 Modified Files: CGIHTTPServer.py compileall.py dircache.py dospath.py filecmp.py imputil.py linecache.py macpath.py mhlib.py ntpath.py os2emxpath.py posixpath.py pstats.py py_compile.py pydoc.py statcache.py uu.py zipfile.py Log Message: Replaced obsolete stat module constants with equivalent attributes Index: CGIHTTPServer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/CGIHTTPServer.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** CGIHTTPServer.py 7 Apr 2002 06:36:22 -0000 1.24 --- CGIHTTPServer.py 1 Jun 2002 19:51:15 -0000 1.25 *************** *** 309,313 **** except os.error: return False ! return st[0] & 0111 != 0 --- 309,313 ---- except os.error: return False ! return st.st_mode & 0111 != 0 Index: compileall.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/compileall.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** compileall.py 1 Jun 2002 00:06:20 -0000 1.11 --- compileall.py 1 Jun 2002 19:51:15 -0000 1.12 *************** *** 14,18 **** import os - import stat import sys import py_compile --- 14,17 ---- *************** *** 57,62 **** if tail == '.py': cfile = fullname + (__debug__ and 'c' or 'o') ! ftime = os.stat(fullname)[stat.ST_MTIME] ! try: ctime = os.stat(cfile)[stat.ST_MTIME] except os.error: ctime = 0 if (ctime > ftime) and not force: continue --- 56,61 ---- if tail == '.py': cfile = fullname + (__debug__ and 'c' or 'o') ! ftime = os.stat(fullname).st_mtime ! try: ctime = os.stat(cfile).st_mtime except os.error: ctime = 0 if (ctime > ftime) and not force: continue Index: dircache.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dircache.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** dircache.py 16 Mar 2001 08:29:47 -0000 1.10 --- dircache.py 1 Jun 2002 19:51:15 -0000 1.11 *************** *** 24,28 **** cached_mtime, list = -1, [] try: ! mtime = os.stat(path)[8] except os.error: return [] --- 24,28 ---- cached_mtime, list = -1, [] try: ! mtime = os.stat(path).st_mtime except os.error: return [] Index: dospath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dospath.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** dospath.py 1 Jun 2002 14:18:45 -0000 1.28 --- dospath.py 1 Jun 2002 19:51:15 -0000 1.29 *************** *** 124,140 **** def getsize(filename): """Return the size of a file, reported by os.stat().""" ! st = os.stat(filename) ! return st[stat.ST_SIZE] def getmtime(filename): """Return the last modification time of a file, reported by os.stat().""" ! st = os.stat(filename) ! return st[stat.ST_MTIME] def getatime(filename): """Return the last access time of a file, reported by os.stat().""" - st = os.stat(filename) - return st[stat.ST_ATIME] def islink(path): --- 124,137 ---- def getsize(filename): """Return the size of a file, reported by os.stat().""" ! return os.stat(filename).st_size def getmtime(filename): """Return the last modification time of a file, reported by os.stat().""" ! return os.stat(filename).st_mtime def getatime(filename): """Return the last access time of a file, reported by os.stat().""" + return os.stat(filename).st_atime def islink(path): *************** *** 163,167 **** except os.error: return False ! return stat.S_ISDIR(st[stat.ST_MODE]) --- 160,164 ---- except os.error: return False ! return stat.S_ISDIR(st.st_mode) *************** *** 173,177 **** except os.error: return False ! return stat.S_ISREG(st[stat.ST_MODE]) --- 170,174 ---- except os.error: return False ! return stat.S_ISREG(st.st_mode) Index: filecmp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/filecmp.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** filecmp.py 4 Apr 2002 22:55:58 -0000 1.11 --- filecmp.py 1 Jun 2002 19:51:15 -0000 1.12 *************** *** 65,71 **** def _sig(st): ! return (stat.S_IFMT(st[stat.ST_MODE]), ! st[stat.ST_SIZE], ! st[stat.ST_MTIME]) def _do_cmp(f1, f2): --- 65,71 ---- def _sig(st): ! return (stat.S_IFMT(st.st_mode), ! st.st_size, ! st.st_mtime) def _do_cmp(f1, f2): *************** *** 200,205 **** 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) --- 200,205 ---- if ok: ! a_type = stat.S_IFMT(a_stat.st_mode) ! b_type = stat.S_IFMT(b_stat.st_mode) if a_type != b_type: self.common_funny.append(x) Index: imputil.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/imputil.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** imputil.py 1 Jun 2002 03:06:31 -0000 1.24 --- imputil.py 1 Jun 2002 19:51:15 -0000 1.25 *************** *** 485,489 **** except OSError: return None ! return (s[0] & 0170000) == 0040000 def _timestamp(pathname): --- 485,489 ---- except OSError: return None ! return (s.st_mode & 0170000) == 0040000 def _timestamp(pathname): *************** *** 493,497 **** except OSError: return None ! return long(s[8]) --- 493,497 ---- except OSError: return None ! return long(s.st_mtime) Index: linecache.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/linecache.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** linecache.py 1 Jun 2002 14:18:45 -0000 1.10 --- linecache.py 1 Jun 2002 19:51:15 -0000 1.11 *************** *** 8,12 **** import sys import os - from stat import * __all__ = ["getline","clearcache","checkcache"] --- 8,11 ---- *************** *** 53,57 **** del cache[filename] continue ! if size != stat[ST_SIZE] or mtime != stat[ST_MTIME]: del cache[filename] --- 52,56 ---- del cache[filename] continue ! if size != stat.st_size or mtime != stat.st_mtime: del cache[filename] *************** *** 97,101 **** ## print '*** Cannot open', fullname, ':', msg return [] ! size, mtime = stat[ST_SIZE], stat[ST_MTIME] cache[filename] = size, mtime, lines, fullname return lines --- 96,100 ---- ## print '*** Cannot open', fullname, ':', msg return [] ! size, mtime = stat.st_size, stat.st_mtime cache[filename] = size, mtime, lines, fullname return lines Index: macpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/macpath.py,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** macpath.py 23 May 2002 15:15:29 -0000 1.38 --- macpath.py 1 Jun 2002 19:51:15 -0000 1.39 *************** *** 101,105 **** except os.error: return 0 ! return S_ISDIR(st[ST_MODE]) --- 101,105 ---- except os.error: return 0 ! return S_ISDIR(st.st_mode) *************** *** 108,123 **** def getsize(filename): """Return the size of a file, reported by os.stat().""" ! st = os.stat(filename) ! return st[ST_SIZE] def getmtime(filename): """Return the last modification time of a file, reported by os.stat().""" ! st = os.stat(filename) ! return st[ST_MTIME] def getatime(filename): """Return the last access time of a file, reported by os.stat().""" ! st = os.stat(filename) ! return st[ST_ATIME] --- 108,120 ---- def getsize(filename): """Return the size of a file, reported by os.stat().""" ! return os.stat(filename).st_size def getmtime(filename): """Return the last modification time of a file, reported by os.stat().""" ! return os.stat(filename).st_mtime def getatime(filename): """Return the last access time of a file, reported by os.stat().""" ! return os.stat(filename).st_atime *************** *** 139,143 **** except os.error: return False ! return S_ISREG(st[ST_MODE]) --- 136,140 ---- except os.error: return False ! return S_ISREG(st.st_mode) Index: mhlib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mhlib.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** mhlib.py 1 Jun 2002 16:07:16 -0000 1.31 --- mhlib.py 1 Jun 2002 19:51:15 -0000 1.32 *************** *** 75,79 **** import os import sys - from stat import ST_NLINK import re import mimetools --- 75,78 ---- *************** *** 156,161 **** # Get the link count so we can avoid listing folders # that have no subfolders. ! st = os.stat(fullname) ! nlinks = st[ST_NLINK] if nlinks <= 2: return [] --- 155,159 ---- # Get the link count so we can avoid listing folders # that have no subfolders. ! nlinks = os.stat(fullname).st_nlink if nlinks <= 2: return [] *************** *** 184,189 **** # Get the link count so we can avoid listing folders # that have no subfolders. ! st = os.stat(fullname) ! nlinks = st[ST_NLINK] if nlinks <= 2: return [] --- 182,186 ---- # Get the link count so we can avoid listing folders # that have no subfolders. ! nlinks = os.stat(fullname).st_nlink if nlinks <= 2: return [] Index: ntpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ntpath.py,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** ntpath.py 1 Jun 2002 14:18:46 -0000 1.48 --- ntpath.py 1 Jun 2002 19:51:15 -0000 1.49 *************** *** 217,232 **** def getsize(filename): """Return the size of a file, reported by os.stat()""" ! st = os.stat(filename) ! return st[stat.ST_SIZE] def getmtime(filename): """Return the last modification time of a file, reported by os.stat()""" ! st = os.stat(filename) ! return st[stat.ST_MTIME] def getatime(filename): """Return the last access time of a file, reported by os.stat()""" ! st = os.stat(filename) ! return st[stat.ST_ATIME] --- 217,229 ---- def getsize(filename): """Return the size of a file, reported by os.stat()""" ! return os.stat(filename).st_size def getmtime(filename): """Return the last modification time of a file, reported by os.stat()""" ! return os.stat(filename).st_mtime def getatime(filename): """Return the last access time of a file, reported by os.stat()""" ! return os.stat(filename).st_atime *************** *** 261,265 **** except os.error: return False ! return stat.S_ISDIR(st[stat.ST_MODE]) --- 258,262 ---- except os.error: return False ! return stat.S_ISDIR(st.st_mode) *************** *** 274,278 **** except os.error: return False ! return stat.S_ISREG(st[stat.ST_MODE]) --- 271,275 ---- except os.error: return False ! return stat.S_ISREG(st.st_mode) Index: os2emxpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/os2emxpath.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** os2emxpath.py 1 Jun 2002 14:18:46 -0000 1.5 --- os2emxpath.py 1 Jun 2002 19:51:15 -0000 1.6 *************** *** 176,191 **** def getsize(filename): """Return the size of a file, reported by os.stat()""" ! st = os.stat(filename) ! return st[stat.ST_SIZE] def getmtime(filename): """Return the last modification time of a file, reported by os.stat()""" ! st = os.stat(filename) ! return st[stat.ST_MTIME] def getatime(filename): """Return the last access time of a file, reported by os.stat()""" ! st = os.stat(filename) ! return st[stat.ST_ATIME] --- 176,188 ---- def getsize(filename): """Return the size of a file, reported by os.stat()""" ! return os.stat(filename).st_size def getmtime(filename): """Return the last modification time of a file, reported by os.stat()""" ! return os.stat(filename).st_mtime def getatime(filename): """Return the last access time of a file, reported by os.stat()""" ! return os.stat(filename).st_atime *************** *** 218,222 **** except os.error: return False ! return stat.S_ISDIR(st[stat.ST_MODE]) --- 215,219 ---- except os.error: return False ! return stat.S_ISDIR(st.st_mode) *************** *** 231,235 **** except os.error: return False ! return stat.S_ISREG(st[stat.ST_MODE]) --- 228,232 ---- except os.error: return False ! return stat.S_ISREG(st.st_mode) Index: posixpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/posixpath.py,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** posixpath.py 1 Jun 2002 14:18:46 -0000 1.49 --- posixpath.py 1 Jun 2002 19:51:15 -0000 1.50 *************** *** 137,152 **** def getsize(filename): """Return the size of a file, reported by os.stat().""" ! st = os.stat(filename) ! return st[stat.ST_SIZE] def getmtime(filename): """Return the last modification time of a file, reported by os.stat().""" ! st = os.stat(filename) ! return st[stat.ST_MTIME] def getatime(filename): """Return the last access time of a file, reported by os.stat().""" ! st = os.stat(filename) ! return st[stat.ST_ATIME] --- 137,149 ---- def getsize(filename): """Return the size of a file, reported by os.stat().""" ! return os.stat(filename).st_size def getmtime(filename): """Return the last modification time of a file, reported by os.stat().""" ! return os.stat(filename).st_mtime def getatime(filename): """Return the last access time of a file, reported by os.stat().""" ! return os.stat(filename).st_atime *************** *** 160,164 **** except (os.error, AttributeError): return False ! return stat.S_ISLNK(st[stat.ST_MODE]) --- 157,161 ---- except (os.error, AttributeError): return False ! return stat.S_ISLNK(st.st_mode) *************** *** 185,189 **** except os.error: return False ! return stat.S_ISDIR(st[stat.ST_MODE]) --- 182,186 ---- except os.error: return False ! return stat.S_ISDIR(st.st_mode) *************** *** 198,202 **** except os.error: return False ! return stat.S_ISREG(st[stat.ST_MODE]) --- 195,199 ---- except os.error: return False ! return stat.S_ISREG(st.st_mode) *************** *** 225,230 **** def samestat(s1, s2): """Test whether two stat buffers reference the same file""" ! return s1[stat.ST_INO] == s2[stat.ST_INO] and \ ! s1[stat.ST_DEV] == s2[stat.ST_DEV] --- 222,227 ---- def samestat(s1, s2): """Test whether two stat buffers reference the same file""" ! return s1.st_ino == s2.st_ino and \ ! s1.st_dev == s2.st_dev *************** *** 239,248 **** except os.error: return False # It doesn't exist -- so not a mount point :-) ! dev1 = s1[stat.ST_DEV] ! dev2 = s2[stat.ST_DEV] if dev1 != dev2: return True # path/.. on a different device as path ! ino1 = s1[stat.ST_INO] ! ino2 = s2[stat.ST_INO] if ino1 == ino2: return True # path/.. is the same i-node as path --- 236,245 ---- except os.error: return False # It doesn't exist -- so not a mount point :-) ! dev1 = s1.st_dev ! dev2 = s2.st_dev if dev1 != dev2: return True # path/.. on a different device as path ! ino1 = s1.st_ino ! ino2 = s2.st_ino if ino1 == ino2: return True # path/.. is the same i-node as path Index: pstats.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pstats.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** pstats.py 1 Jun 2002 16:07:16 -0000 1.25 --- pstats.py 1 Jun 2002 19:51:15 -0000 1.26 *************** *** 109,113 **** try: file_stats = os.stat(arg) ! arg = time.ctime(file_stats[8]) + " " + arg except: # in case this is not unix pass --- 109,113 ---- try: file_stats = os.stat(arg) ! arg = time.ctime(file_stats.st_mtime) + " " + arg except: # in case this is not unix pass Index: py_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/py_compile.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** py_compile.py 1 Jun 2002 16:07:16 -0000 1.20 --- py_compile.py 1 Jun 2002 19:51:15 -0000 1.21 *************** *** 47,53 **** f = open(file, 'U') try: ! timestamp = long(os.fstat(f.fileno())[8]) except AttributeError: ! timestamp = long(os.stat(file)[8]) codestring = f.read() # If parsing from a string, line breaks are \n (see parsetok.c:tok_nextc) --- 47,53 ---- f = open(file, 'U') try: ! timestamp = long(os.fstat(f.fileno()).st_mtime) except AttributeError: ! timestamp = long(os.stat(file).st_mtime) codestring = f.read() # If parsing from a string, line breaks are \n (see parsetok.c:tok_nextc) Index: pydoc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pydoc.py,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** pydoc.py 1 Jun 2002 14:18:46 -0000 1.64 --- pydoc.py 1 Jun 2002 19:51:15 -0000 1.65 *************** *** 44,48 **** # path will be displayed. ! import sys, imp, os, stat, re, types, inspect from repr import Repr from string import expandtabs, find, join, lower, split, strip, rfind, rstrip --- 44,48 ---- # path will be displayed. ! import sys, imp, os, re, types, inspect from repr import Repr from string import expandtabs, find, join, lower, split, strip, rfind, rstrip *************** *** 154,158 **** def synopsis(filename, cache={}): """Get the one-line summary out of a module file.""" ! mtime = os.stat(filename)[stat.ST_MTIME] lastupdate, result = cache.get(filename, (0, None)) if lastupdate < mtime: --- 154,158 ---- def synopsis(filename, cache={}): """Get the one-line summary out of a module file.""" ! mtime = os.stat(filename).st_mtime lastupdate, result = cache.get(filename, (0, None)) if lastupdate < mtime: *************** *** 1699,1703 **** roots = map(lambda dir: (dir, ''), pathdirs()) Scanner.__init__(self, roots, self.submodules, self.isnewpackage) ! self.inodes = map(lambda (dir, pkg): os.stat(dir)[1], roots) def submodules(self, (dir, package)): --- 1699,1703 ---- roots = map(lambda dir: (dir, ''), pathdirs()) Scanner.__init__(self, roots, self.submodules, self.isnewpackage) ! self.inodes = map(lambda (dir, pkg): os.stat(dir).st_ino, roots) def submodules(self, (dir, package)): *************** *** 1713,1717 **** def isnewpackage(self, (dir, package)): ! inode = os.path.exists(dir) and os.stat(dir)[1] if not (os.path.islink(dir) and inode in self.inodes): self.inodes.append(inode) # detect circular symbolic links --- 1713,1717 ---- def isnewpackage(self, (dir, package)): ! inode = os.path.exists(dir) and os.stat(dir).st_ino if not (os.path.islink(dir) and inode in self.inodes): self.inodes.append(inode) # detect circular symbolic links Index: statcache.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/statcache.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** statcache.py 1 Jun 2002 14:18:46 -0000 1.15 --- statcache.py 1 Jun 2002 19:51:15 -0000 1.16 *************** *** 80,82 **** except _os.error: return False ! return S_ISDIR(st[ST_MODE]) --- 80,82 ---- except _os.error: return False ! return S_ISDIR(st.st_mode) Index: uu.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/uu.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** uu.py 17 Aug 2001 19:59:34 -0000 1.18 --- uu.py 1 Jun 2002 19:51:15 -0000 1.19 *************** *** 53,57 **** if mode is None: try: ! mode = os.stat(in_file)[0] except AttributeError: pass --- 53,57 ---- if mode is None: try: ! mode = os.stat(in_file).st_mode except AttributeError: pass Index: zipfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/zipfile.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** zipfile.py 1 Jun 2002 14:18:47 -0000 1.22 --- zipfile.py 1 Jun 2002 19:51:15 -0000 1.23 *************** *** 374,378 **** arcname.""" st = os.stat(filename) ! mtime = time.localtime(st[8]) date_time = mtime[0:6] # Create ZipInfo instance to store file information --- 374,378 ---- arcname.""" st = os.stat(filename) ! mtime = time.localtime(st.st_mtime) date_time = mtime[0:6] # Create ZipInfo instance to store file information *************** *** 573,580 **** file_pyo = pathname + ".pyo" if os.path.isfile(file_pyo) and \ ! os.stat(file_pyo)[8] >= os.stat(file_py)[8]: fname = file_pyo # Use .pyo file elif not os.path.isfile(file_pyc) or \ ! os.stat(file_pyc)[8] < os.stat(file_py)[8]: import py_compile if self.debug: --- 573,580 ---- file_pyo = pathname + ".pyo" if os.path.isfile(file_pyo) and \ ! os.stat(file_pyo).st_mtime >= os.stat(file_py).st_mtime: fname = file_pyo # Use .pyo file elif not os.path.isfile(file_pyc) or \ ! os.stat(file_pyc).st_mtime < os.stat(file_py).st_mtime: import py_compile if self.debug: From loewis@users.sourceforge.net Sat Jun 1 22:40:00 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Sat, 01 Jun 2002 14:40:00 -0700 Subject: [Python-checkins] python/dist/src configure,1.308,1.309 configure.in,1.318,1.319 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv13293a Modified Files: configure configure.in Log Message: Use somewhat longer C++ program to detect whether linking requires the C++ compiler. Fixes #559429. 2.2 bugfix candidate. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.308 retrieving revision 1.309 diff -C2 -d -r1.308 -r1.309 *** configure 27 May 2002 15:08:21 -0000 1.308 --- configure 1 Jun 2002 21:39:58 -0000 1.309 *************** *** 1,4 **** #! /bin/sh ! # From configure.in Revision: 1.317 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.53. --- 1,4 ---- #! /bin/sh ! # From configure.in Revision: 1.318 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.53. *************** *** 3038,3042 **** LINKCC="\$(PURIFY) \$(CC)" else ! echo 'int main(){return 0;}' > conftest.$ac_ext $CXX -c conftest.$ac_ext 2>&5 if $CC -o conftest$ac_exeext conftest.$ac_objext 2>&5 \ --- 3038,3042 ---- LINKCC="\$(PURIFY) \$(CC)" else ! echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext $CXX -c conftest.$ac_ext 2>&5 if $CC -o conftest$ac_exeext conftest.$ac_objext 2>&5 \ Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.318 retrieving revision 1.319 diff -C2 -d -r1.318 -r1.319 *** configure.in 27 May 2002 15:08:21 -0000 1.318 --- configure.in 1 Jun 2002 21:39:58 -0000 1.319 *************** *** 310,314 **** LINKCC="\$(PURIFY) \$(CC)" else ! echo 'int main(){return 0;}' > conftest.$ac_ext $CXX -c conftest.$ac_ext 2>&5 if $CC -o conftest$ac_exeext conftest.$ac_objext 2>&5 \ --- 310,314 ---- LINKCC="\$(PURIFY) \$(CC)" else ! echo 'void foo();int main(){foo();}void foo(){}' > conftest.$ac_ext $CXX -c conftest.$ac_ext 2>&5 if $CC -o conftest$ac_exeext conftest.$ac_objext 2>&5 \ From guido@python.org Sat Jun 1 23:41:32 2002 From: guido@python.org (Guido van Rossum) Date: Sat, 01 Jun 2002 18:41:32 -0400 Subject: [Python-checkins] python/dist/src/Python import.c,2.175.2.2,2.175.2.3 In-Reply-To: Your message of "Sat, 01 Jun 2002 11:27:36 PDT." References: Message-ID: <200206012241.g51MfW522767@pcp742651pcs.reston01.va.comcast.net> > + if (CANT_WRITE(co->co_argcount) || > + CANT_WRITE(co->co_nlocals) || > + CANT_WRITE(co->co_stacksize) || > + CANT_WRITE(co->co_flags) || > + CANT_WRITE(co->co_firstlineno)) { > + if (Py_VerboseFlag) > + PySys_WriteStderr( > + "# code too large: can't write %s\n", > + cpathname); > + return; > + } Maybe this should be a call to PyErr_Warn instead? --Guido van Rossum (home page: http://www.python.org/~guido/) From rhettinger@users.sourceforge.net Sun Jun 2 01:40:07 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat, 01 Jun 2002 17:40:07 -0700 Subject: [Python-checkins] python/dist/src/Lib sgmllib.py,1.40,1.41 shlex.py,1.16,1.17 shutil.py,1.20,1.21 smtplib.py,1.55,1.56 sre_compile.py,1.41,1.42 sre_parse.py,1.54,1.55 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv19353 Modified Files: sgmllib.py shlex.py shutil.py smtplib.py sre_compile.py sre_parse.py Log Message: Replace boolean test with is None. Index: sgmllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sgmllib.py,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** sgmllib.py 1 Jun 2002 14:18:46 -0000 1.40 --- sgmllib.py 2 Jun 2002 00:40:04 -0000 1.41 *************** *** 480,484 **** import sys ! if not args: args = sys.argv[1:] --- 480,484 ---- import sys ! if args is None: args = sys.argv[1:] Index: shlex.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/shlex.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** shlex.py 17 Apr 2001 17:20:19 -0000 1.16 --- shlex.py 2 Jun 2002 00:40:05 -0000 1.17 *************** *** 13,17 **** "A lexical analyzer class for simple shell-like syntaxes." def __init__(self, instream=None, infile=None): ! if instream: self.instream = instream self.infile = infile --- 13,17 ---- "A lexical analyzer class for simple shell-like syntaxes." def __init__(self, instream=None, infile=None): ! if instream is not None: self.instream = instream self.infile = infile *************** *** 48,52 **** self.lineno = 1 if self.debug: ! if newfile: print 'shlex: pushing to file %s' % (self.infile,) else: --- 48,52 ---- self.lineno = 1 if self.debug: ! if newfile is not None: print 'shlex: pushing to file %s' % (self.infile,) else: *************** *** 189,195 **** def error_leader(self, infile=None, lineno=None): "Emit a C-compiler-like, Emacs-friendly error-message leader." ! if not infile: infile = self.infile ! if not lineno: lineno = self.lineno return "\"%s\", line %d: " % (infile, lineno) --- 189,195 ---- def error_leader(self, infile=None, lineno=None): "Emit a C-compiler-like, Emacs-friendly error-message leader." ! if infile is None: infile = self.infile ! if lineno is None: lineno = self.lineno return "\"%s\", line %d: " % (infile, lineno) Index: shutil.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/shutil.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** shutil.py 15 Feb 2001 22:15:13 -0000 1.20 --- shutil.py 2 Jun 2002 00:40:05 -0000 1.21 *************** *** 123,127 **** if ignore_errors: pass ! elif onerror: onerror(cmd[0], cmd[1], exc) else: --- 123,127 ---- if ignore_errors: pass ! elif onerror is not None: onerror(cmd[0], cmd[1], exc) else: Index: smtplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/smtplib.py,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** smtplib.py 1 Jun 2002 14:18:46 -0000 1.55 --- smtplib.py 2 Jun 2002 00:40:05 -0000 1.56 *************** *** 237,241 **** if code != 220: raise SMTPConnectError(code, msg) ! if local_hostname: self.local_hostname = local_hostname else: --- 237,241 ---- if code != 220: raise SMTPConnectError(code, msg) ! if local_hostname is not None: self.local_hostname = local_hostname else: Index: sre_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** sre_compile.py 4 Sep 2001 19:10:20 -0000 1.41 --- sre_compile.py 2 Jun 2002 00:40:05 -0000 1.42 *************** *** 146,150 **** # compile charset subprogram emit = code.append ! if not fixup: fixup = lambda x: x for op, av in _optimize_charset(charset, fixup): --- 146,150 ---- # compile charset subprogram emit = code.append ! if fixup is None: fixup = lambda x: x for op, av in _optimize_charset(charset, fixup): Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** sre_parse.py 1 Jun 2002 14:18:46 -0000 1.54 --- sre_parse.py 2 Jun 2002 00:40:05 -0000 1.55 *************** *** 81,85 **** gid = self.groups self.groups = gid + 1 ! if name: ogid = self.groupdict.get(name, None) if ogid is not None: --- 81,85 ---- gid = self.groups self.groups = gid + 1 ! if name is not None: ogid = self.groupdict.get(name, None) if ogid is not None: *************** *** 98,102 **** def __init__(self, pattern, data=None): self.pattern = pattern ! if not data: data = [] self.data = data --- 98,102 ---- def __init__(self, pattern, data=None): self.pattern = pattern ! if data is None: data = [] self.data = data From tim_one@email.msn.com Sun Jun 2 01:40:27 2002 From: tim_one@email.msn.com (Tim Peters) Date: Sat, 1 Jun 2002 20:40:27 -0400 Subject: [Python-checkins] python/dist/src/Lib/email Header.py,1.3,1.4 In-Reply-To: <15608.25602.581726.334861@anthem.wooz.org> Message-ID: > Yup, but I needed to generalize floordiv away from a simple divide by > 2 (I also needed a divide by three). > > shift-right-a-bit-and-a-half-ly y'rs, No problem! For all i in 0 thru sys.maxint (on a 32-bit box), i // 3 == 715827883 * i >> 31 Note that this is a sharp upper bound, though: if i is sys.maxint+1, the multiply-and-shift method gives a result one too large. division-is-for-wimps-ly y'rs - tim From neal@metaslash.com Sun Jun 2 03:12:00 2002 From: neal@metaslash.com (Neal Norwitz) Date: Sat, 01 Jun 2002 22:12:00 -0400 Subject: [Python-checkins] python/dist/src/Python import.c,2.175.2.2,2.175.2.3 References: <200206012241.g51MfW522767@pcp742651pcs.reston01.va.comcast.net> Message-ID: <3CF97EF0.ED83E22@metaslash.com> Guido van Rossum wrote: > > > + if (CANT_WRITE(co->co_argcount) || > > + CANT_WRITE(co->co_nlocals) || > > + CANT_WRITE(co->co_stacksize) || > > + CANT_WRITE(co->co_flags) || > > + CANT_WRITE(co->co_firstlineno)) { > > + if (Py_VerboseFlag) > > + PySys_WriteStderr( > > + "# code too large: can't write %s\n", > > + cpathname); > > + return; > > + } > > Maybe this should be a call to PyErr_Warn instead? That's fine with me. But I'm not sure the warning will be helpful. Any suggestions for wording? Is what's there good enough? Here's my suggestion: PyOS_snprintf(buffer, sizeof(buffer), "code too large: can't write %.80s\n", cpathname); PyErr_Warn(PyExc_RuntimeWarning, buffer); Neal From rhettinger@users.sourceforge.net Sun Jun 2 04:04:54 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat, 01 Jun 2002 20:04:54 -0700 Subject: [Python-checkins] python/dist/src/Lib telnetlib.py,1.18,1.19 traceback.py,1.26,1.27 urllib.py,1.145,1.146 webbrowser.py,1.31,1.32 xmlrpclib.py,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv8152 Modified Files: telnetlib.py traceback.py urllib.py webbrowser.py xmlrpclib.py Log Message: Replaced boolean tests with is None. Index: telnetlib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/telnetlib.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** telnetlib.py 13 May 2002 14:55:33 -0000 1.18 --- telnetlib.py 2 Jun 2002 03:04:51 -0000 1.19 *************** *** 187,191 **** self.eof = 0 self.option_callback = None ! if host: self.open(host, port) --- 187,191 ---- self.eof = 0 self.option_callback = None ! if host is not None: self.open(host, port) Index: traceback.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/traceback.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** traceback.py 10 Jun 2001 18:58:26 -0000 1.26 --- traceback.py 2 Jun 2002 03:04:51 -0000 1.27 *************** *** 17,21 **** """Print the list of tuples as returned by extract_tb() or extract_stack() as a formatted stack trace to the given file.""" ! if not file: file = sys.stderr for filename, lineno, name, line in extracted_list: --- 17,21 ---- """Print the list of tuples as returned by extract_tb() or extract_stack() as a formatted stack trace to the given file.""" ! if file is None: file = sys.stderr for filename, lineno, name, line in extracted_list: *************** *** 52,56 **** method. """ ! if not file: file = sys.stderr if limit is None: --- 52,56 ---- method. """ ! if file is None: file = sys.stderr if limit is None: *************** *** 117,121 **** position of the error. """ ! if not file: file = sys.stderr if tb: --- 117,121 ---- position of the error. """ ! if file is None: file = sys.stderr if tb: *************** *** 204,208 **** (In fact, it uses sys.exc_info() to retrieve the same information in a thread-safe way.)""" ! if not file: file = sys.stderr try: --- 204,208 ---- (In fact, it uses sys.exc_info() to retrieve the same information in a thread-safe way.)""" ! if file is None: file = sys.stderr try: *************** *** 215,219 **** """This is a shorthand for 'print_exception(sys.last_type, sys.last_value, sys.last_traceback, limit, file)'.""" ! if not file: file = sys.stderr print_exception(sys.last_type, sys.last_value, sys.last_traceback, --- 215,219 ---- """This is a shorthand for 'print_exception(sys.last_type, sys.last_value, sys.last_traceback, limit, file)'.""" ! if file is None: file = sys.stderr print_exception(sys.last_type, sys.last_value, sys.last_traceback, Index: urllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib.py,v retrieving revision 1.145 retrieving revision 1.146 diff -C2 -d -r1.145 -r1.146 *** urllib.py 1 Jun 2002 14:18:47 -0000 1.145 --- urllib.py 2 Jun 2002 03:04:51 -0000 1.146 *************** *** 204,208 **** return self.tempcache[url] type, url1 = splittype(url) ! if not filename and (not type or type == 'file'): try: fp = self.open_local_file(url1) --- 204,208 ---- return self.tempcache[url] type, url1 = splittype(url) ! if filename is None and (not type or type == 'file'): try: fp = self.open_local_file(url1) *************** *** 663,667 **** """Return the IP address of the magic hostname 'localhost'.""" global _localhost ! if not _localhost: _localhost = socket.gethostbyname('localhost') return _localhost --- 663,667 ---- """Return the IP address of the magic hostname 'localhost'.""" global _localhost ! if _localhost is None: _localhost = socket.gethostbyname('localhost') return _localhost *************** *** 671,675 **** """Return the IP address of the current host.""" global _thishost ! if not _thishost: _thishost = socket.gethostbyname(socket.gethostname()) return _thishost --- 671,675 ---- """Return the IP address of the current host.""" global _thishost ! if _thishost is None: _thishost = socket.gethostbyname(socket.gethostname()) return _thishost *************** *** 679,683 **** """Return the set of errors raised by the FTP class.""" global _ftperrors ! if not _ftperrors: import ftplib _ftperrors = ftplib.all_errors --- 679,683 ---- """Return the set of errors raised by the FTP class.""" global _ftperrors ! if _ftperrors is None: import ftplib _ftperrors = ftplib.all_errors *************** *** 688,692 **** """Return an empty mimetools.Message object.""" global _noheaders ! if not _noheaders: import mimetools import StringIO --- 688,692 ---- """Return an empty mimetools.Message object.""" global _noheaders ! if _noheaders is None: import mimetools import StringIO Index: webbrowser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/webbrowser.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** webbrowser.py 1 Jun 2002 14:18:47 -0000 1.31 --- webbrowser.py 2 Jun 2002 03:04:52 -0000 1.32 *************** *** 18,22 **** def get(using=None): """Return a browser launcher instance appropriate for the environment.""" ! if using: alternatives = [using] else: --- 18,22 ---- def get(using=None): """Return a browser launcher instance appropriate for the environment.""" ! if using is not None: alternatives = [using] else: Index: xmlrpclib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xmlrpclib.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** xmlrpclib.py 1 Jun 2002 14:18:47 -0000 1.17 --- xmlrpclib.py 2 Jun 2002 03:04:52 -0000 1.18 *************** *** 756,760 **** assert len(params) == 1, "response tuple must be a singleton" ! if not encoding: encoding = "utf-8" --- 756,760 ---- assert len(params) == 1, "response tuple must be a singleton" ! if encoding is None: encoding = "utf-8" *************** *** 768,772 **** # standard XML-RPC wrappings ! if methodname: # a method call if not isinstance(methodname, StringType): --- 768,772 ---- # standard XML-RPC wrappings ! if methodname is not None: # a method call if not isinstance(methodname, StringType): From loewis@users.sourceforge.net Sun Jun 2 13:32:06 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun, 02 Jun 2002 05:32:06 -0700 Subject: [Python-checkins] python/dist/src/Lib smtplib.py,1.46.4.2,1.46.4.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv3096 Modified Files: Tag: release22-maint smtplib.py Log Message: Patch #552060: Add SSLFakeSocket.sendall. Index: smtplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/smtplib.py,v retrieving revision 1.46.4.2 retrieving revision 1.46.4.3 diff -C2 -d -r1.46.4.2 -r1.46.4.3 *** smtplib.py 25 Feb 2002 10:52:43 -0000 1.46.4.2 --- smtplib.py 2 Jun 2002 12:32:04 -0000 1.46.4.3 *************** *** 138,141 **** --- 138,143 ---- return len(str) + sendall = send + def close(self): self.realsock.close() From loewis@users.sourceforge.net Sun Jun 2 13:33:24 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun, 02 Jun 2002 05:33:24 -0700 Subject: [Python-checkins] python/dist/src/Lib smtplib.py,1.56,1.57 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv3419 Modified Files: smtplib.py Log Message: Patch #552060: Add SSLFakeSocket.sendall. Also committed for 2.2 maint. Index: smtplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/smtplib.py,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** smtplib.py 2 Jun 2002 00:40:05 -0000 1.56 --- smtplib.py 2 Jun 2002 12:33:22 -0000 1.57 *************** *** 138,141 **** --- 138,143 ---- return len(str) + sendall = send + def close(self): self.realsock.close() From guido@python.org Sun Jun 2 14:01:32 2002 From: guido@python.org (Guido van Rossum) Date: Sun, 02 Jun 2002 09:01:32 -0400 Subject: [Python-checkins] python/dist/src/Python import.c,2.175.2.2,2.175.2.3 In-Reply-To: Your message of "Sat, 01 Jun 2002 22:12:00 EDT." <3CF97EF0.ED83E22@metaslash.com> References: <200206012241.g51MfW522767@pcp742651pcs.reston01.va.comcast.net> <3CF97EF0.ED83E22@metaslash.com> Message-ID: <200206021301.g52D1W530851@pcp742651pcs.reston01.va.comcast.net> > > > + PySys_WriteStderr( > > > + "# code too large: can't write %s\n", > > > + cpathname); > > > > Maybe this should be a call to PyErr_Warn instead? > > That's fine with me. But I'm not sure the warning will be helpful. > Any suggestions for wording? Is what's there good enough? > > Here's my suggestion: > > PyOS_snprintf(buffer, sizeof(buffer), > "code too large: can't write %.80s\n", > cpathname); > PyErr_Warn(PyExc_RuntimeWarning, buffer); I take it back. All warnings with writing pyc files are reported in this fashion (i.e., a message is printed only in verbose mode). --Guido van Rossum (home page: http://www.python.org/~guido/) From mwh@users.sourceforge.net Sun Jun 2 17:12:09 2002 From: mwh@users.sourceforge.net (mwh@users.sourceforge.net) Date: Sun, 02 Jun 2002 09:12:09 -0700 Subject: [Python-checkins] python/dist/src/Lib mhlib.py,1.32,1.33 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv18754 Modified Files: mhlib.py Log Message: Make test_mhlib run again. There's some wierdness here, but the test ran before and not after, so I'm just hacking the change out. Someone more motivated than me can work out what's really happening. Raymond: *PLEASE* run the test suite before checking things like this in! Index: mhlib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mhlib.py,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** mhlib.py 1 Jun 2002 19:51:15 -0000 1.32 --- mhlib.py 2 Jun 2002 16:12:06 -0000 1.33 *************** *** 789,793 **** self.sep = sep self.rng = rng ! if data is not None: self.fromstring(data) def reset(self): --- 789,793 ---- self.sep = sep self.rng = rng ! if data: self.fromstring(data) def reset(self): From nnorwitz@users.sourceforge.net Sun Jun 2 17:38:16 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Sun, 02 Jun 2002 09:38:16 -0700 Subject: [Python-checkins] python/dist/src/Lib/email _compat21.py,1.1,1.2 _compat22.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email In directory usw-pr-cvs1:/tmp/cvs-serv24838 Modified Files: _compat21.py _compat22.py Log Message: Get email test to pass. Barry, hope this is what you had in mind Index: _compat21.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/_compat21.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** _compat21.py 19 May 2002 23:44:19 -0000 1.1 --- _compat21.py 2 Jun 2002 16:38:14 -0000 1.2 *************** *** 26,32 **** # Used internally by the Header class ! def _intdiv2(i): ! """Do an integer divide by 2.""" ! return i / 2 --- 26,32 ---- # Used internally by the Header class ! def _floordiv(x, y): ! """Do integer division.""" ! return x / y Index: _compat22.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/_compat22.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** _compat22.py 19 May 2002 23:44:19 -0000 1.1 --- _compat22.py 2 Jun 2002 16:38:14 -0000 1.2 *************** *** 27,33 **** # Used internally by the Header class ! def _intdiv2(i): ! """Do an integer divide by 2.""" ! return i // 2 --- 27,33 ---- # Used internally by the Header class ! def _floordiv(x, y): ! """Do integer division.""" ! return x // y From loewis@users.sourceforge.net Sun Jun 2 18:34:50 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun, 02 Jun 2002 10:34:50 -0700 Subject: [Python-checkins] python/dist/src configure,1.279.6.5,1.279.6.6 configure.in,1.288.6.5,1.288.6.6 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv4236 Modified Files: Tag: release22-maint configure configure.in Log Message: Run gcc with -w to work-around an autoconf 2.13 bug. Fixes #535545. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.279.6.5 retrieving revision 1.279.6.6 diff -C2 -d -r1.279.6.5 -r1.279.6.6 *** configure 18 Apr 2002 14:55:05 -0000 1.279.6.5 --- configure 2 Jun 2002 17:34:45 -0000 1.279.6.6 *************** *** 1,5 **** #! /bin/sh ! # From configure.in Revision: 1.288.6.4 # Guess values for system-dependent variables and create Makefiles. --- 1,5 ---- #! /bin/sh ! # From configure.in Revision: 1.288.6.5 [...4224 lines suppressed...] if eval "test \"`echo '$''{'ac_cv_type_socklen_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < *************** *** 7547,7551 **** SRCDIRS="Parser Grammar Objects Python Modules" echo $ac_n "checking for build directories""... $ac_c" 1>&6 ! echo "configure:7550: checking for build directories" >&5 for dir in $SRCDIRS; do if test ! -d $dir; then --- 7565,7569 ---- SRCDIRS="Parser Grammar Objects Python Modules" echo $ac_n "checking for build directories""... $ac_c" 1>&6 ! echo "configure:7568: checking for build directories" >&5 for dir in $SRCDIRS; do if test ! -d $dir; then Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.288.6.5 retrieving revision 1.288.6.6 diff -C2 -d -r1.288.6.5 -r1.288.6.6 *** configure.in 18 Apr 2002 14:55:08 -0000 1.288.6.5 --- configure.in 2 Jun 2002 17:34:47 -0000 1.288.6.6 *************** *** 521,524 **** --- 521,536 ---- # checks for header files AC_HEADER_STDC + + # If the compiler generates any stderr on these tests, the header file + # is considered absent. On some systems, gcc will produce warnings for + # some of the headers (Redhat 6 if kernel headers don't match glibc + # headers). Thus, disable warnings. This can go away if autoconf 2.50 + # is used, since it considers the gcc status to determine errors. + if test $GCC == yes + then + CPPFLAGS_save=$CPPFLAGS + CPPFLAGS="$CPPFLAGS -w" + fi + AC_CHECK_HEADERS(dlfcn.h fcntl.h grp.h limits.h langinfo.h locale.h \ ncurses.h poll.h pthread.h \ *************** *** 528,531 **** --- 540,549 ---- sys/un.h sys/utsname.h sys/wait.h pty.h term.h libutil.h \ ndbm.h db1/ndbm.h gdbm/ndbm.h sys/resource.h netpacket/packet.h) + + if test $GCC == yes + then + CPPFLAGS=$CPPFLAGS_save + fi + AC_HEADER_DIRENT From rhettinger@users.sourceforge.net Sun Jun 2 19:55:58 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun, 02 Jun 2002 11:55:58 -0700 Subject: [Python-checkins] python/dist/src/Lib copy.py,1.25,1.26 filecmp.py,1.12,1.13 inspect.py,1.35,1.36 mailcap.py,1.11,1.12 profile.py,1.46,1.47 pstats.py,1.26,1.27 pyclbr.py,1.24,1.25 rlcompleter.py,1.11,1.12 symtable.py,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv22744 Modified Files: copy.py filecmp.py inspect.py mailcap.py profile.py pstats.py pyclbr.py rlcompleter.py symtable.py Log Message: Replaced .keys() with dictionary iterators Index: copy.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/copy.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** copy.py 1 Jun 2002 14:18:45 -0000 1.25 --- copy.py 2 Jun 2002 18:55:56 -0000 1.26 *************** *** 235,240 **** y = {} memo[id(x)] = y ! for key in x.keys(): ! y[deepcopy(key, memo)] = deepcopy(x[key], memo) return y d[types.DictionaryType] = _deepcopy_dict --- 235,240 ---- y = {} memo[id(x)] = y ! for key, value in x.iteritems(): ! y[deepcopy(key, memo)] = deepcopy(value, memo) return y d[types.DictionaryType] = _deepcopy_dict *************** *** 336,341 **** return {'a': self.a, 'arg': self.arg} def __setstate__(self, state): ! for key in state.keys(): ! setattr(self, key, state[key]) def __deepcopy__(self, memo = None): new = self.__class__(deepcopy(self.arg, memo)) --- 336,341 ---- return {'a': self.a, 'arg': self.arg} def __setstate__(self, state): ! for key, value in state.iteritems(): ! setattr(self, key, value) def __deepcopy__(self, memo = None): new = self.__class__(deepcopy(self.arg, memo)) Index: filecmp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/filecmp.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** filecmp.py 1 Jun 2002 19:51:15 -0000 1.12 --- filecmp.py 2 Jun 2002 18:55:56 -0000 1.13 *************** *** 229,234 **** 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 --- 229,234 ---- def phase4_closure(self): # Recursively call phase4() on subdirectories self.phase4() ! for sd in self.subdirs.itervalues(): ! sd.phase4_closure() def report(self): # Print a report on the differences between a and b *************** *** 259,271 **** 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() --- 259,271 ---- def report_partial_closure(self): # Print reports on self and on subdirs self.report() ! for sd in self.subdirs.itervalues(): print ! sd.report() def report_full_closure(self): # Report on self and subdirs recursively self.report() ! for sd in self.subdirs.itervalues(): print ! sd.report_full_closure() Index: inspect.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/inspect.py,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** inspect.py 1 Jun 2002 14:18:45 -0000 1.35 --- inspect.py 2 Jun 2002 18:55:56 -0000 1.36 *************** *** 554,558 **** elif c not in roots: roots.append(c) ! for parent in children.keys(): if parent not in classes: roots.append(parent) --- 554,558 ---- elif c not in roots: roots.append(c) ! for parent in children: if parent not in classes: roots.append(parent) Index: mailcap.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mailcap.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** mailcap.py 1 Jun 2002 14:18:46 -0000 1.11 --- mailcap.py 2 Jun 2002 18:55:56 -0000 1.12 *************** *** 25,33 **** morecaps = readmailcapfile(fp) fp.close() ! for key in morecaps.keys(): if not key in caps: ! caps[key] = morecaps[key] else: ! caps[key] = caps[key] + morecaps[key] return caps --- 25,33 ---- morecaps = readmailcapfile(fp) fp.close() ! for key, value in morecaps.iteritems(): if not key in caps: ! caps[key] = value else: ! caps[key] = caps[key] + value return caps Index: profile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/profile.py,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** profile.py 1 Jun 2002 16:07:16 -0000 1.46 --- profile.py 2 Jun 2002 18:55:56 -0000 1.47 *************** *** 387,396 **** def snapshot_stats(self): self.stats = {} ! for func in self.timings.keys(): ! cc, ns, tt, ct, callers = self.timings[func] callers = callers.copy() nc = 0 ! for func_caller in callers.keys(): ! nc = nc + callers[func_caller] self.stats[func] = cc, nc, tt, ct, callers --- 387,395 ---- def snapshot_stats(self): self.stats = {} ! for func, (cc, ns, tt, ct, callers) in self.timings.iteritems(): callers = callers.copy() nc = 0 ! for callcnt in callers.itervalues(): ! nc += callcnt self.stats[func] = cc, nc, tt, ct, callers Index: pstats.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pstats.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** pstats.py 1 Jun 2002 19:51:15 -0000 1.26 --- pstats.py 2 Jun 2002 18:55:56 -0000 1.27 *************** *** 143,147 **** self.prim_calls += other.prim_calls self.total_tt += other.total_tt ! for func in other.top_level.keys(): self.top_level[func] = None --- 143,147 ---- self.prim_calls += other.prim_calls self.total_tt += other.total_tt ! for func in other.top_level: self.top_level[func] = None *************** *** 151,160 **** self.fcn_list = None ! for func in other.stats.keys(): if func in self.stats: old_func_stat = self.stats[func] else: old_func_stat = (0, 0, 0, 0, {},) ! self.stats[func] = add_func_stats(old_func_stat, other.stats[func]) return self --- 151,160 ---- self.fcn_list = None ! for func, stat in other.stats.iteritems(): if func in self.stats: old_func_stat = self.stats[func] else: old_func_stat = (0, 0, 0, 0, {},) ! self.stats[func] = add_func_stats(old_func_stat, stat) return self *************** *** 179,183 **** self.sort_arg_dict = dict = {} bad_list = {} ! for word in self.sort_arg_dict_default.keys(): fragment = word while fragment: --- 179,183 ---- self.sort_arg_dict = dict = {} bad_list = {} ! for word, tup in self.sort_arg_dict_default.iteritems(): fragment = word while fragment: *************** *** 187,193 **** bad_list[fragment] = 0 break ! dict[fragment] = self.sort_arg_dict_default[word] fragment = fragment[:-1] ! for word in bad_list.keys(): del dict[word] return self.sort_arg_dict --- 187,193 ---- bad_list[fragment] = 0 break ! dict[fragment] = tup fragment = fragment[:-1] ! for word in bad_list: del dict[word] return self.sort_arg_dict *************** *** 214,219 **** stats_list = [] ! for func in self.stats.keys(): ! cc, nc, tt, ct, callers = self.stats[func] stats_list.append((cc, nc, tt, ct) + func + (func_std_string(func), func)) --- 214,218 ---- stats_list = [] ! for func, (cc, nc, tt, ct, callers) in self.stats.iteritems(): stats_list.append((cc, nc, tt, ct) + func + (func_std_string(func), func)) *************** *** 235,246 **** self.stats = newstats = {} max_name_len = 0 ! for func in oldstats.keys(): ! cc, nc, tt, ct, callers = oldstats[func] newfunc = func_strip_path(func) if len(func_std_string(newfunc)) > max_name_len: max_name_len = len(func_std_string(newfunc)) newcallers = {} ! for func2 in callers.keys(): ! newcallers[func_strip_path(func2)] = callers[func2] if newfunc in newstats: --- 234,244 ---- self.stats = newstats = {} max_name_len = 0 ! for func, (cc, nc, tt, ct, callers) in oldstats.iteritems(): newfunc = func_strip_path(func) if len(func_std_string(newfunc)) > max_name_len: max_name_len = len(func_std_string(newfunc)) newcallers = {} ! for func2, caller in callers.iteritems(): ! newcallers[func_strip_path(func2)] = caller if newfunc in newstats: *************** *** 252,256 **** old_top = self.top_level self.top_level = new_top = {} ! for func in old_top.keys(): new_top[func_strip_path(func)] = None --- 250,254 ---- old_top = self.top_level self.top_level = new_top = {} ! for func in old_top: new_top[func_strip_path(func)] = None *************** *** 264,275 **** if self.all_callees: return self.all_callees = all_callees = {} ! for func in self.stats.keys(): if not func in all_callees: all_callees[func] = {} ! cc, nc, tt, ct, callers = self.stats[func] ! for func2 in callers.keys(): if not func2 in all_callees: all_callees[func2] = {} ! all_callees[func2][func] = callers[func2] return --- 262,272 ---- if self.all_callees: return self.all_callees = all_callees = {} ! for func, (cc, nc, tt, ct, callers) in self.stats.iteritems(): if not func in all_callees: all_callees[func] = {} ! for func2, caller in callers.iteritems(): if not func2 in all_callees: all_callees[func2] = {} ! all_callees[func2][func] = caller return *************** *** 331,335 **** if self.files: print indent = ' ' * 8 ! for func in self.top_level.keys(): print indent, func_get_function_name(func) --- 328,332 ---- if self.files: print indent = ' ' * 8 ! for func in self.top_level: print indent, func_get_function_name(func) *************** *** 469,479 **** """Combine two caller lists in a single list.""" new_callers = {} ! for func in target.keys(): ! new_callers[func] = target[func] ! for func in source.keys(): if func in new_callers: ! new_callers[func] = source[func] + new_callers[func] else: ! new_callers[func] = source[func] return new_callers --- 466,476 ---- """Combine two caller lists in a single list.""" new_callers = {} ! for func, caller in target.iteritems(): ! new_callers[func] = caller ! for func, caller in source.iteritems(): if func in new_callers: ! new_callers[func] = caller + new_callers[func] else: ! new_callers[func] = caller return new_callers *************** *** 481,486 **** """Sum the caller statistics to get total number of calls received.""" nc = 0 ! for func in callers.keys(): ! nc += callers[func] return nc --- 478,483 ---- """Sum the caller statistics to get total number of calls received.""" nc = 0 ! for calls in callers.itervalues(): ! nc += calls return nc *************** *** 596,605 **** def do_sort(self, line): ! abbrevs = self.stats.get_sort_arg_defs().keys() if line and not filter(lambda x,a=abbrevs: x not in a,line.split()): apply(self.stats.sort_stats, line.split()) else: print "Valid sort keys (unique prefixes are accepted):" ! for (key, value) in Stats.sort_arg_dict_default.items(): print "%s -- %s" % (key, value[1]) return 0 --- 593,602 ---- def do_sort(self, line): ! abbrevs = self.stats.get_sort_arg_defs() if line and not filter(lambda x,a=abbrevs: x not in a,line.split()): apply(self.stats.sort_stats, line.split()) else: print "Valid sort keys (unique prefixes are accepted):" ! for (key, value) in Stats.sort_arg_dict_default.iteritems(): print "%s -- %s" % (key, value[1]) return 0 *************** *** 608,612 **** print "(Typing `sort' without arguments lists valid keys.)" def complete_sort(self, text, *args): ! return [a for a in Stats.sort_arg_dict_default.keys() if a.startswith(text)] def do_stats(self, line): --- 605,609 ---- print "(Typing `sort' without arguments lists valid keys.)" def complete_sort(self, text, *args): ! return [a for a in Stats.sort_arg_dict_default if a.startswith(text)] def do_stats(self, line): Index: pyclbr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pyclbr.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** pyclbr.py 1 Jun 2002 14:18:46 -0000 1.24 --- pyclbr.py 2 Jun 2002 18:55:56 -0000 1.25 *************** *** 325,329 **** # also don't add names that # start with _ ! for n in d.keys(): if n[0] != '_' and \ not n in dict: --- 325,329 ---- # also don't add names that # start with _ ! for n in d: if n[0] != '_' and \ not n in dict: Index: rlcompleter.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/rlcompleter.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** rlcompleter.py 16 Apr 2002 01:38:39 -0000 1.11 --- rlcompleter.py 2 Jun 2002 18:55:56 -0000 1.12 *************** *** 105,110 **** n = len(text) for list in [keyword.kwlist, ! __builtin__.__dict__.keys(), ! self.namespace.keys()]: for word in list: if word[:n] == text and word != "__builtins__": --- 105,110 ---- n = len(text) for list in [keyword.kwlist, ! __builtin__.__dict__, ! self.namespace]: for word in list: if word[:n] == text and word != "__builtins__": Index: symtable.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/symtable.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** symtable.py 4 Apr 2002 22:55:58 -0000 1.6 --- symtable.py 2 Jun 2002 18:55:56 -0000 1.7 *************** *** 164,168 **** for st in self._table.children: d[st.name] = 1 ! self.__methods = tuple(d.keys()) return self.__methods --- 164,168 ---- for st in self._table.children: d[st.name] = 1 ! self.__methods = tuple(d) return self.__methods From bwarsaw@users.sourceforge.net Sun Jun 2 19:58:52 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Sun, 02 Jun 2002 11:58:52 -0700 Subject: [Python-checkins] python/dist/src/Lib/email _compat21.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email In directory usw-pr-cvs1:/tmp/cvs-serv23464 Modified Files: _compat21.py Log Message: _intdiv2() -> _floordiv(), merge of uncommitted changes. Index: _compat21.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/_compat21.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** _compat21.py 2 Jun 2002 16:38:14 -0000 1.2 --- _compat21.py 2 Jun 2002 18:58:49 -0000 1.3 *************** *** 25,32 **** ! # Used internally by the Header class ! def _floordiv(x, y): ! """Do integer division.""" ! return x / y --- 25,32 ---- ! # Python 2.2 spells floor division // ! def _floordiv(i, j): ! """Do a floor division, i/j.""" ! return i / j From bwarsaw@users.sourceforge.net Sun Jun 2 19:59:09 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Sun, 02 Jun 2002 11:59:09 -0700 Subject: [Python-checkins] python/dist/src/Lib/email _compat22.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email In directory usw-pr-cvs1:/tmp/cvs-serv23565 Modified Files: _compat22.py Log Message: _intdiv2() -> _floordiv(), merge of uncommitted changes. Index: _compat22.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/_compat22.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** _compat22.py 2 Jun 2002 16:38:14 -0000 1.2 --- _compat22.py 2 Jun 2002 18:59:06 -0000 1.3 *************** *** 26,33 **** ! # Used internally by the Header class ! def _floordiv(x, y): ! """Do integer division.""" ! return x // y --- 26,33 ---- ! # Python 2.2 spells floor division // ! def _floordiv(i, j): ! """Do a floor division, i/j.""" ! return i // j From bwarsaw@users.sourceforge.net Sun Jun 2 20:02:39 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Sun, 02 Jun 2002 12:02:39 -0700 Subject: [Python-checkins] python/dist/src/Lib/email Generator.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email In directory usw-pr-cvs1:/tmp/cvs-serv24576/email Modified Files: Generator.py Log Message: flatten(): Renamed from __call__() which is (silently) deprecated. __call__() can be 2-3x slower than the equivalent normal method. _handle_message(): The structure of message/rfc822 message has changed. Now parent's payload is a list of length 1, and the zeroth element is the Message sub-object. Adjust the printing of such message trees to reflect this change. Index: Generator.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/Generator.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Generator.py 10 Apr 2002 21:01:30 -0000 1.8 --- Generator.py 2 Jun 2002 19:02:37 -0000 1.9 *************** *** 61,65 **** self._fp.write(s) ! def __call__(self, msg, unixfrom=0): """Print the message object tree rooted at msg to the output file specified when the Generator instance was created. --- 61,65 ---- self._fp.write(s) ! def flatten(self, msg, unixfrom=0): """Print the message object tree rooted at msg to the output file specified when the Generator instance was created. *************** *** 79,82 **** --- 79,85 ---- self._write(msg) + # For backwards compatibility, but this is slower + __call__ = flatten + # # Protected interface - undocumented ;/ *************** *** 255,259 **** s = StringIO() g = self.__class__(s, self._mangle_from_, self.__maxheaderlen) ! g(part, unixfrom=0) msgtexts.append(s.getvalue()) # Now make sure the boundary we've selected doesn't appear in any of --- 258,262 ---- s = StringIO() g = self.__class__(s, self._mangle_from_, self.__maxheaderlen) ! g.flatten(part, unixfrom=0) msgtexts.append(s.getvalue()) # Now make sure the boundary we've selected doesn't appear in any of *************** *** 303,307 **** s = StringIO() g = self.__class__(s, self._mangle_from_, self.__maxheaderlen) ! g(part, unixfrom=0) text = s.getvalue() lines = text.split('\n') --- 306,310 ---- s = StringIO() g = self.__class__(s, self._mangle_from_, self.__maxheaderlen) ! g.flatten(part, unixfrom=0) text = s.getvalue() lines = text.split('\n') *************** *** 319,326 **** s = StringIO() g = self.__class__(s, self._mangle_from_, self.__maxheaderlen) ! # A message/rfc822 should contain a scalar payload which is another ! # Message object. Extract that object, stringify it, and write that ! # out. ! g(msg.get_payload(), unixfrom=0) self._fp.write(s.getvalue()) --- 322,330 ---- s = StringIO() g = self.__class__(s, self._mangle_from_, self.__maxheaderlen) ! # The payload of a message/rfc822 part should be a multipart sequence ! # of length 1. The zeroth element of the list should be the Message ! # object for the subpart.Extract that object, stringify it, and write ! # that out. ! g.flatten(msg.get_payload(0), unixfrom=0) self._fp.write(s.getvalue()) From bwarsaw@users.sourceforge.net Sun Jun 2 20:04:42 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Sun, 02 Jun 2002 12:04:42 -0700 Subject: [Python-checkins] python/dist/src/Lib/email MIMEAudio.py,1.2,1.3 MIMEBase.py,1.5,1.6 MIMEImage.py,1.4,1.5 MIMEText.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email In directory usw-pr-cvs1:/tmp/cvs-serv25227/email Modified Files: MIMEAudio.py MIMEBase.py MIMEImage.py MIMEText.py Log Message: Use absolute import paths for intrapackage imports. Use MIMENonMultipart as the base class so that you can't attach() to these non-multipart message types. Index: MIMEAudio.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/MIMEAudio.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MIMEAudio.py 24 Nov 2001 15:49:53 -0000 1.2 --- MIMEAudio.py 2 Jun 2002 19:04:39 -0000 1.3 *************** *** 7,13 **** from cStringIO import StringIO ! import MIMEBase ! import Errors ! import Encoders --- 7,13 ---- from cStringIO import StringIO ! from email import Errors ! from email import Encoders ! from email.MIMENonMultipart import MIMENonMultipart *************** *** 38,42 **** ! class MIMEAudio(MIMEBase.MIMEBase): """Class for generating audio/* MIME documents.""" --- 38,42 ---- ! class MIMEAudio(MIMENonMultipart): """Class for generating audio/* MIME documents.""" *************** *** 67,71 **** if _subtype is None: raise TypeError, 'Could not find audio MIME subtype' ! MIMEBase.MIMEBase.__init__(self, 'audio', _subtype, **_params) self.set_payload(_audiodata) _encoder(self) --- 67,71 ---- if _subtype is None: raise TypeError, 'Could not find audio MIME subtype' ! MIMENonMultipart.__init__(self, 'audio', _subtype, **_params) self.set_payload(_audiodata) _encoder(self) Index: MIMEBase.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/MIMEBase.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** MIMEBase.py 10 Apr 2002 21:01:30 -0000 1.5 --- MIMEBase.py 2 Jun 2002 19:04:39 -0000 1.6 *************** *** 5,9 **** """ ! import Message --- 5,9 ---- """ ! from email import Message Index: MIMEImage.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/MIMEImage.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** MIMEImage.py 10 Apr 2002 21:01:30 -0000 1.4 --- MIMEImage.py 2 Jun 2002 19:04:39 -0000 1.5 *************** *** 7,18 **** import imghdr ! # Intrapackage imports ! import MIMEBase ! import Errors ! import Encoders ! class MIMEImage(MIMEBase.MIMEBase): """Class for generating image/* type MIME documents.""" --- 7,17 ---- import imghdr ! from email import Errors ! from email import Encoders ! from email.MIMENonMultipart import MIMENonMultipart ! class MIMEImage(MIMENonMultipart): """Class for generating image/* type MIME documents.""" *************** *** 42,46 **** if _subtype is None: raise TypeError, 'Could not guess image MIME subtype' ! MIMEBase.MIMEBase.__init__(self, 'image', _subtype, **_params) self.set_payload(_imagedata) _encoder(self) --- 41,45 ---- if _subtype is None: raise TypeError, 'Could not guess image MIME subtype' ! MIMENonMultipart.__init__(self, 'image', _subtype, **_params) self.set_payload(_imagedata) _encoder(self) Index: MIMEText.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/MIMEText.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** MIMEText.py 10 Apr 2002 21:01:30 -0000 1.4 --- MIMEText.py 2 Jun 2002 19:04:39 -0000 1.5 *************** *** 6,15 **** import warnings ! import MIMEBase ! from Encoders import encode_7or8bit ! class MIMEText(MIMEBase.MIMEBase): """Class for generating text/* type MIME documents.""" --- 6,15 ---- import warnings ! from email.MIMENonMultipart import MIMENonMultipart ! from email.Encoders import encode_7or8bit ! class MIMEText(MIMENonMultipart): """Class for generating text/* type MIME documents.""" *************** *** 34,39 **** not what you want. """ ! MIMEBase.MIMEBase.__init__(self, 'text', _subtype, ! **{'charset': _charset}) if _text and _text[-1] <> '\n': _text += '\n' --- 34,39 ---- not what you want. """ ! MIMENonMultipart.__init__(self, 'text', _subtype, ! **{'charset': _charset}) if _text and _text[-1] <> '\n': _text += '\n' From bwarsaw@users.sourceforge.net Sun Jun 2 20:05:10 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Sun, 02 Jun 2002 12:05:10 -0700 Subject: [Python-checkins] python/dist/src/Lib/email MIMEMessage.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email In directory usw-pr-cvs1:/tmp/cvs-serv25401/email Modified Files: MIMEMessage.py Log Message: Use absolute import paths for intrapackage imports. Use MIMENonMultipart as the base class so that you can't attach() to these non-multipart message types. Index: MIMEMessage.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/MIMEMessage.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** MIMEMessage.py 10 Apr 2002 21:01:30 -0000 1.4 --- MIMEMessage.py 2 Jun 2002 19:05:08 -0000 1.5 *************** *** 5,14 **** """ ! import Message ! import MIMEBase ! class MIMEMessage(MIMEBase.MIMEBase): """Class representing message/* MIME documents.""" --- 5,14 ---- """ ! from email import Message ! from email.MIMENonMultipart import MIMENonMultipart ! class MIMEMessage(MIMENonMultipart): """Class representing message/* MIME documents.""" *************** *** 23,28 **** the term "rfc822" is technically outdated by RFC 2822). """ ! MIMEBase.MIMEBase.__init__(self, 'message', _subtype) if not isinstance(_msg, Message.Message): raise TypeError, 'Argument is not an instance of Message' ! self.set_payload(_msg) --- 23,30 ---- the term "rfc822" is technically outdated by RFC 2822). """ ! MIMENonMultipart.__init__(self, 'message', _subtype) if not isinstance(_msg, Message.Message): raise TypeError, 'Argument is not an instance of Message' ! # It's convenient to use this base class method. We need to do it ! # this way or we'll get an exception ! Message.Message.attach(self, _msg) From bwarsaw@users.sourceforge.net Sun Jun 2 20:05:53 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Sun, 02 Jun 2002 12:05:53 -0700 Subject: [Python-checkins] python/dist/src/Lib/email Message.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email In directory usw-pr-cvs1:/tmp/cvs-serv25555/email Modified Files: Message.py Log Message: Use absolute import paths for intrapackage imports. as_string(): Use Generator.flatten() for better performance. Index: Message.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/Message.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Message.py 23 May 2002 15:15:30 -0000 1.12 --- Message.py 2 Jun 2002 19:05:51 -0000 1.13 *************** *** 11,17 **** # Intrapackage imports ! import Errors ! import Utils ! import Charset SEMISPACE = '; ' --- 11,17 ---- # Intrapackage imports ! from email import Errors ! from email import Utils ! from email import Charset SEMISPACE = '; ' *************** *** 79,86 **** header. """ ! from Generator import Generator fp = StringIO() g = Generator(fp) ! g(self, unixfrom=unixfrom) return fp.getvalue() --- 79,86 ---- header. """ ! from email.Generator import Generator fp = StringIO() g = Generator(fp) ! g.flatten(self, unixfrom=unixfrom) return fp.getvalue() From bwarsaw@users.sourceforge.net Sun Jun 2 20:07:18 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Sun, 02 Jun 2002 12:07:18 -0700 Subject: [Python-checkins] python/dist/src/Lib/email Utils.py,1.15,1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email In directory usw-pr-cvs1:/tmp/cvs-serv25989/email Modified Files: Utils.py Log Message: Use absolute import paths for intrapackage imports. Index: Utils.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/Utils.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Utils.py 23 May 2002 15:15:30 -0000 1.15 --- Utils.py 2 Jun 2002 19:07:16 -0000 1.16 *************** *** 43,47 **** # Intrapackage imports ! from Encoders import _bencode, _qencode COMMASPACE = ', ' --- 43,47 ---- # Intrapackage imports ! from email.Encoders import _bencode, _qencode COMMASPACE = ', ' *************** *** 136,140 **** warnings.warn('Use Header.decode_header() instead.', DeprecationWarning, 2) # Intra-package import here to avoid circular import problems. ! from Header import decode_header L = decode_header(s) if not isinstance(L, ListType): --- 136,140 ---- warnings.warn('Use Header.decode_header() instead.', DeprecationWarning, 2) # Intra-package import here to avoid circular import problems. ! from email.Header import decode_header L = decode_header(s) if not isinstance(L, ListType): From bwarsaw@users.sourceforge.net Sun Jun 2 20:08:34 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Sun, 02 Jun 2002 12:08:34 -0700 Subject: [Python-checkins] python/dist/src/Lib/email base64MIME.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email In directory usw-pr-cvs1:/tmp/cvs-serv26448/email Modified Files: base64MIME.py Log Message: header_encode(), encode(): Use _floordiv() from the appropriate compatibility module. Index: base64MIME.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/base64MIME.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** base64MIME.py 29 May 2002 20:38:21 -0000 1.3 --- base64MIME.py 2 Jun 2002 19:08:31 -0000 1.4 *************** *** 28,31 **** --- 28,38 ---- from email.Utils import fix_eols + try: + from email._compat22 import _floordiv + except SyntaxError: + # Python 2.1 spells integer division differently + from email._compat21 import _floordiv + + CRLF = '\r\n' NL = '\n' *************** *** 88,92 **** base64ed = [] max_encoded = maxlinelen - len(charset) - MISC_LEN ! max_unencoded = max_encoded * 3 // 4 # BAW: Ben's original code used a step of max_unencoded, but I think it --- 95,99 ---- base64ed = [] max_encoded = maxlinelen - len(charset) - MISC_LEN ! max_unencoded = _floordiv(max_encoded * 3, 4) # BAW: Ben's original code used a step of max_unencoded, but I think it *************** *** 132,136 **** encvec = [] ! max_unencoded = maxlinelen * 3 // 4 for i in range(0, len(s), max_unencoded): # BAW: should encode() inherit b2a_base64()'s dubious behavior in --- 139,143 ---- encvec = [] ! max_unencoded = _floordiv(maxlinelen * 3, 4) for i in range(0, len(s), max_unencoded): # BAW: should encode() inherit b2a_base64()'s dubious behavior in From bwarsaw@users.sourceforge.net Sun Jun 2 20:09:29 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Sun, 02 Jun 2002 12:09:29 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_email.py,1.33,1.34 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv26681/test Modified Files: test_email.py Log Message: Generator.__call__() => Generator.flatten() Also, adjust to the new message/rfc822 tree layout. Index: test_email.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_email.py,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** test_email.py 22 May 2002 01:52:10 -0000 1.33 --- test_email.py 2 Jun 2002 19:09:27 -0000 1.34 *************** *** 8,12 **** import base64 from cStringIO import StringIO ! from types import StringType import warnings --- 8,12 ---- import base64 from cStringIO import StringIO ! from types import StringType, ListType import warnings *************** *** 192,196 **** s = StringIO() g = DecodedGenerator(s) ! g(msg) eq(s.getvalue(), text) --- 192,196 ---- s = StringIO() g = DecodedGenerator(s) ! g.flatten(msg) eq(s.getvalue(), text) *************** *** 404,408 **** sfp = StringIO() g = Generator(sfp) ! g(msg) self.assertEqual(sfp.getvalue(), '''\ Content-Type: text/plain; charset="us-ascii" --- 404,408 ---- sfp = StringIO() g = Generator(sfp) ! g.flatten(msg) self.assertEqual(sfp.getvalue(), '''\ Content-Type: text/plain; charset="us-ascii" *************** *** 424,428 **** sfp = StringIO() g = Generator(sfp) ! g(msg) self.assertEqual(sfp.getvalue(), """\ From: test@dom.ain --- 424,428 ---- sfp = StringIO() g = Generator(sfp) ! g.flatten(msg) self.assertEqual(sfp.getvalue(), """\ From: test@dom.ain *************** *** 440,444 **** sfp = StringIO() g = Generator(sfp) ! g(msg) self.assertEqual(sfp.getvalue(), """\ From: test@dom.ain --- 440,444 ---- sfp = StringIO() g = Generator(sfp) ! g.flatten(msg) self.assertEqual(sfp.getvalue(), """\ From: test@dom.ain *************** *** 478,482 **** self.msg = Message() self.msg['From'] = 'aaa@bbb.org' ! self.msg.add_payload("""\ From the desk of A.A.A.: Blah blah blah --- 478,482 ---- self.msg = Message() self.msg['From'] = 'aaa@bbb.org' ! self.msg.set_payload("""\ From the desk of A.A.A.: Blah blah blah *************** *** 486,490 **** s = StringIO() g = Generator(s, mangle_from_=1) ! g(self.msg) self.assertEqual(s.getvalue(), """\ From: aaa@bbb.org --- 486,490 ---- s = StringIO() g = Generator(s, mangle_from_=1) ! g.flatten(self.msg) self.assertEqual(s.getvalue(), """\ From: aaa@bbb.org *************** *** 497,501 **** s = StringIO() g = Generator(s, mangle_from_=0) ! g(self.msg) self.assertEqual(s.getvalue(), """\ From: aaa@bbb.org --- 497,501 ---- s = StringIO() g = Generator(s, mangle_from_=0) ! g.flatten(self.msg) self.assertEqual(s.getvalue(), """\ From: aaa@bbb.org *************** *** 659,664 **** This is the dingus fish. ''') ! container.add_payload(intro) ! container.add_payload(image) container['From'] = 'Barry ' container['To'] = 'Dingus Lovers ' --- 659,664 ---- This is the dingus fish. ''') ! container.attach(intro) ! container.attach(image) container['From'] = 'Barry ' container['To'] = 'Dingus Lovers ' *************** *** 852,855 **** --- 852,856 ---- def test_valid_argument(self): eq = self.assertEqual + unless = self.failUnless subject = 'A sub-message' m = Message() *************** *** 857,862 **** r = MIMEMessage(m) eq(r.get_type(), 'message/rfc822') ! self.failUnless(r.get_payload() is m) ! eq(r.get_payload()['subject'], subject) def test_generate(self): --- 858,876 ---- r = MIMEMessage(m) eq(r.get_type(), 'message/rfc822') ! payload = r.get_payload() ! unless(type(payload), ListType) ! eq(len(payload), 1) ! subpart = payload[0] ! unless(subpart is m) ! eq(subpart['subject'], subject) ! ! def test_bad_multipart(self): ! eq = self.assertEqual ! msg1 = Message() ! msg1['Subject'] = 'subpart 1' ! msg2 = Message() ! msg2['Subject'] = 'subpart 2' ! r = MIMEMessage(msg1) ! self.assertRaises(Errors.MultipartConversionError, r.attach, msg2) def test_generate(self): *************** *** 864,873 **** m = Message() m['Subject'] = 'An enclosed message' ! m.add_payload('Here is the body of the message.\n') r = MIMEMessage(m) r['Subject'] = 'The enclosing message' s = StringIO() g = Generator(s) ! g(r) self.assertEqual(s.getvalue(), """\ Content-Type: message/rfc822 --- 878,887 ---- m = Message() m['Subject'] = 'An enclosed message' ! m.set_payload('Here is the body of the message.\n') r = MIMEMessage(m) r['Subject'] = 'The enclosing message' s = StringIO() g = Generator(s) ! g.flatten(r) self.assertEqual(s.getvalue(), """\ Content-Type: message/rfc822 *************** *** 882,889 **** def test_parse_message_rfc822(self): eq = self.assertEqual msg = self._msgobj('msg_11.txt') eq(msg.get_type(), 'message/rfc822') ! eq(len(msg.get_payload()), 1) ! submsg = msg.get_payload() self.failUnless(isinstance(submsg, Message)) eq(submsg['subject'], 'An enclosed message') --- 896,906 ---- def test_parse_message_rfc822(self): eq = self.assertEqual + unless = self.failUnless msg = self._msgobj('msg_11.txt') eq(msg.get_type(), 'message/rfc822') ! payload = msg.get_payload() ! unless(isinstance(payload, ListType)) ! eq(len(payload), 1) ! submsg = payload[0] self.failUnless(isinstance(submsg, Message)) eq(submsg['subject'], 'An enclosed message') *************** *** 939,943 **** subpart = msg.get_payload(2) eq(subpart.get_type(), 'message/rfc822') ! subsubpart = subpart.get_payload() unless(isinstance(subsubpart, Message)) eq(subsubpart.get_type(), 'text/plain') --- 956,963 ---- subpart = msg.get_payload(2) eq(subpart.get_type(), 'message/rfc822') ! payload = subpart.get_payload() ! unless(isinstance(payload, ListType)) ! eq(len(payload), 1) ! subsubpart = payload[0] unless(isinstance(subsubpart, Message)) eq(subsubpart.get_type(), 'text/plain') *************** *** 960,968 **** msg2 = MIMEText('Two') msg.add_header('Content-Type', 'multipart/mixed', boundary='BOUNDARY') ! msg.add_payload(msg1) ! msg.add_payload(msg2) sfp = StringIO() g = Generator(sfp) ! g(msg) self.assertEqual(sfp.getvalue(), text) --- 980,988 ---- msg2 = MIMEText('Two') msg.add_header('Content-Type', 'multipart/mixed', boundary='BOUNDARY') ! msg.attach(msg1) ! msg.attach(msg2) sfp = StringIO() g = Generator(sfp) ! g.flatten(msg) self.assertEqual(sfp.getvalue(), text) *************** *** 988,992 **** s = StringIO() g = Generator(s, maxheaderlen=0) ! g(msg) eq(text, s.getvalue()) --- 1008,1012 ---- s = StringIO() g = Generator(s, maxheaderlen=0) ! g.flatten(msg) eq(text, s.getvalue()) *************** *** 1045,1048 **** --- 1065,1069 ---- def test_content_type(self): eq = self.assertEquals + unless = self.failUnless # Get a message object and reset the seek pointer for other tests msg, text = self._msgobj('msg_05.txt') *************** *** 1067,1082 **** eq(msg3.get_type(), 'message/rfc822') self.failUnless(isinstance(msg3, Message)) ! msg4 = msg3.get_payload() ! self.failUnless(isinstance(msg4, Message)) eq(msg4.get_payload(), 'Yadda yadda yadda\n') def test_parser(self): eq = self.assertEquals msg, text = self._msgobj('msg_06.txt') # Check some of the outer headers eq(msg.get_type(), 'message/rfc822') ! # Make sure there's exactly one thing in the payload and that's a ! # sub-Message object of type text/plain ! msg1 = msg.get_payload() self.failUnless(isinstance(msg1, Message)) eq(msg1.get_type(), 'text/plain') --- 1088,1110 ---- eq(msg3.get_type(), 'message/rfc822') self.failUnless(isinstance(msg3, Message)) ! payload = msg3.get_payload() ! unless(isinstance(payload, ListType)) ! eq(len(payload), 1) ! msg4 = payload[0] ! unless(isinstance(msg4, Message)) eq(msg4.get_payload(), 'Yadda yadda yadda\n') def test_parser(self): eq = self.assertEquals + unless = self.failUnless msg, text = self._msgobj('msg_06.txt') # Check some of the outer headers eq(msg.get_type(), 'message/rfc822') ! # Make sure the payload is a list of exactly one sub-Message, and that ! # that submessage has a type of text/plain ! payload = msg.get_payload() ! unless(isinstance(payload, ListType)) ! eq(len(payload), 1) ! msg1 = payload[0] self.failUnless(isinstance(msg1, Message)) eq(msg1.get_type(), 'text/plain') *************** *** 1098,1102 **** # idempotency. g = Generator(s, maxheaderlen=0) ! g(msg) self.assertEqual(text, s.getvalue()) --- 1126,1130 ---- # idempotency. g = Generator(s, maxheaderlen=0) ! g.flatten(msg) self.assertEqual(text, s.getvalue()) *************** *** 1111,1115 **** # idempotency. g = Generator(s, maxheaderlen=0) ! g(msg) self.assertEqual(text, s.getvalue()) finally: --- 1139,1143 ---- # idempotency. g = Generator(s, maxheaderlen=0) ! g.flatten(msg) self.assertEqual(text, s.getvalue()) finally: From andymac@bullseye.apana.org.au Sun Jun 2 06:18:25 2002 From: andymac@bullseye.apana.org.au (Andrew MacIntyre) Date: Sun, 2 Jun 2002 16:18:25 +1100 (edt) Subject: [Python-checkins] python/dist/src/Lib formatter.py,1.20,1.21 ftplib.py,1.69,1.70 gettext.py,1.13,1.14 hmac.py,1.5,1.6 In-Reply-To: Message-ID: On Fri, 31 May 2002 rhettinger@users.sourceforge.net wrote: > Update of /cvsroot/python/python/dist/src/Lib > In directory usw-pr-cvs1:/tmp/cvs-serv7374 > > Modified Files: > formatter.py ftplib.py gettext.py hmac.py > Log Message: > Replace boolean test with is None > > Index: formatter.py > =================================================================== > RCS file: /cvsroot/python/python/dist/src/Lib/formatter.py,v > retrieving revision 1.20 > retrieving revision 1.21 > diff -C2 -d -r1.20 -r1.21 > *** formatter.py 29 May 2002 16:18:42 -0000 1.20 > --- formatter.py 1 Jun 2002 01:29:16 -0000 1.21 {...} > *************** > *** 434,438 **** > w = DumbWriter() > f = AbstractFormatter(w) > ! if file: > fp = open(file) > elif sys.argv[1:]: > --- 434,438 ---- > w = DumbWriter() > f = AbstractFormatter(w) > ! if file is not None: > fp = open(file) > elif sys.argv[1:]: > You have in fact changed the semantics of this test with your change. In the case where file = '', the original would fall through to the elif, whereas with your change it won't. It concerns me that your extensive changes have introduced some unexpected traps which won't be sprung until 2.3 is released. -- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: andymac@bullseye.apana.org.au | Snail: PO Box 370 andymac@pcug.org.au | Belconnen ACT 2616 Web: http://www.andymac.org/ | Australia From bwarsaw@users.sourceforge.net Sun Jun 2 20:12:05 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Sun, 02 Jun 2002 12:12:05 -0700 Subject: [Python-checkins] python/dist/src/Lib/email Parser.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email In directory usw-pr-cvs1:/tmp/cvs-serv27847/email Modified Files: Parser.py Log Message: _parsebody(): Fix for the new message/rfc822 tree structure (the parent is now a multipart with one element, the sub-message object). Index: Parser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/Parser.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Parser.py 19 May 2002 23:51:50 -0000 1.8 --- Parser.py 2 Jun 2002 19:12:03 -0000 1.9 *************** *** 9,15 **** from types import ListType ! # Intrapackage imports ! import Errors ! import Message EMPTYSTRING = '' --- 9,14 ---- from types import ListType ! from email import Errors ! from email import Message EMPTYSTRING = '' *************** *** 177,181 **** msg = self._class() self._parsebody(msg, fp) ! container.set_payload(msg) else: container.set_payload(fp.read()) --- 176,180 ---- msg = self._class() self._parsebody(msg, fp) ! container.attach(msg) else: container.set_payload(fp.read()) From nas@python.ca Sun Jun 2 20:45:14 2002 From: nas@python.ca (Neil Schemenauer) Date: Sun, 2 Jun 2002 12:45:14 -0700 Subject: [Python-checkins] python/dist/src/Lib formatter.py,1.20,1.21 ftplib.py,1.69,1.70 gettext.py,1.13,1.14 hmac.py,1.5,1.6 In-Reply-To: ; from andymac@bullseye.apana.org.au on Sun, Jun 02, 2002 at 04:18:25PM +1100 References: Message-ID: <20020602124514.A31585@glacier.arctrix.com> Andrew MacIntyre wrote: > You have in fact changed the semantics of this test with your change. > > In the case where file = '', the original would fall through to the > elif, whereas with your change it won't. > > It concerns me that your extensive changes have introduced some unexpected > traps which won't be sprung until 2.3 is released. I'm worried too. What if someone passes their own class to one of these functions and they implement keys() but not iterkeys() (or has_key() but not __contains__)? Neil From tim_one@users.sourceforge.net Sun Jun 2 22:42:03 2002 From: tim_one@users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun, 02 Jun 2002 14:42:03 -0700 Subject: [Python-checkins] python/dist/src/Lib/test regrtest.py,1.83,1.84 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv31955 Modified Files: regrtest.py Log Message: regrtest has a new -f/--fromfile option. This runs all and only the tests named in the file, in the order given (although -x may weed that list, and -r may shuffle it). Lines starting with '#' are ignored. This goes a long way toward helping to automate the binary-search-like procedure I keep reinventing by hand when a test fails due to interaction among tests (no failure in isolation, and some unknown number of predecessor tests need to run first -- now you can stick all the test names in a file, and comment/uncomment blocks of lines until finding a minimal set of predecessors). Index: regrtest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v retrieving revision 1.83 retrieving revision 1.84 diff -C2 -d -r1.83 -r1.84 *** regrtest.py 30 Apr 2002 12:11:04 -0000 1.83 --- regrtest.py 2 Jun 2002 21:42:01 -0000 1.84 *************** *** 15,18 **** --- 15,19 ---- -s: single -- run only a single test (see below) -r: random -- randomize test execution order + -f: fromfile -- read names of tests to run from a file (see below) -l: findleaks -- if GC is available detect tests that leak memory -u: use -- specify which special resource intensive tests to run *************** *** 32,35 **** --- 33,41 ---- used instead of /tmp). + -f reads the names of tests from the file given as f's argument, one or more + test names per line. Whitespace is ignored. Blank lines and lines beginning + with '#' are ignored. This is especially useful for whittling down failures + involving interactions among tests. + -u is used to specify which special resource intensive tests to run, such as those requiring large file support or network connectivity. The argument is a *************** *** 70,74 **** def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, ! exclude=0, single=0, randomize=0, findleaks=0, use_resources=None): """Execute a test suite. --- 76,80 ---- def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, ! exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. *************** *** 97,103 **** test_support.record_original_stdout(sys.stdout) try: ! opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrlu:', ['help', 'verbose', 'quiet', 'generate', ! 'exclude', 'single', 'random', 'findleaks', 'use=']) except getopt.error, msg: --- 103,109 ---- test_support.record_original_stdout(sys.stdout) try: ! opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:', ['help', 'verbose', 'quiet', 'generate', ! 'exclude', 'single', 'random', 'fromfile', 'findleaks', 'use=']) except getopt.error, msg: *************** *** 123,126 **** --- 129,134 ---- elif o in ('-r', '--randomize'): randomize = 1 + elif o in ('-f', '--fromfile'): + fromfile = a elif o in ('-l', '--findleaks'): findleaks = 1 *************** *** 137,140 **** --- 145,150 ---- if generate and verbose: usage(2, "-g and -v don't go together!") + if single and fromfile: + usage(2, "-s and -f don't go together!") good = [] *************** *** 165,172 **** except IOError: pass ! for i in range(len(args)): ! # Strip trailing ".py" from arguments ! if args[i][-3:] == os.extsep+'py': ! args[i] = args[i][:-3] stdtests = STDTESTS[:] nottests = NOTTESTS[:] --- 175,194 ---- except IOError: pass ! ! if fromfile: ! tests = [] ! fp = open(fromfile) ! for line in fp: ! guts = line.split() # assuming no test has whitespace in its name ! if guts and not guts[0].startswith('#'): ! tests.extend(guts) ! fp.close() ! ! # Strip .py extensions. ! if args: ! args = map(removepy, args) ! if tests: ! tests = map(removepy, tests) ! stdtests = STDTESTS[:] nottests = NOTTESTS[:] *************** *** 418,421 **** --- 440,448 ---- testdir = os.path.dirname(file) or os.curdir return testdir + + def removepy(name): + if name.endswith(os.extsep + "py"): + name = name[:-3] + return name def count(n, word): From doerwalter@users.sourceforge.net Mon Jun 3 11:41:48 2002 From: doerwalter@users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Mon, 03 Jun 2002 03:41:48 -0700 Subject: [Python-checkins] python/dist/src/Lib ftplib.py,1.71,1.72 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv10423 Modified Files: ftplib.py Log Message: Fix a regression from the 1.68->1.69 checkin: string.split(foo, bar) must be foo.split(bar) instead of bar.split(foo). Index: ftplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ftplib.py,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** ftplib.py 1 Jun 2002 14:18:45 -0000 1.71 --- ftplib.py 3 Jun 2002 10:41:45 -0000 1.72 *************** *** 592,596 **** if resp[left + 1] <> resp[right - 1]: raise error_proto, resp ! parts = resp[left+1].split(resp[left + 1:right]) if len(parts) <> 5: raise error_proto, resp --- 592,596 ---- if resp[left + 1] <> resp[right - 1]: raise error_proto, resp ! parts = resp[left + 1:right].split(resp[left+1]) if len(parts) <> 5: raise error_proto, resp From doerwalter@users.sourceforge.net Mon Jun 3 16:58:35 2002 From: doerwalter@users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Mon, 03 Jun 2002 08:58:35 -0700 Subject: [Python-checkins] python/dist/src/Lib ConfigParser.py,1.43,1.44 StringIO.py,1.26,1.27 formatter.py,1.21,1.22 hmac.py,1.6,1.7 markupbase.py,1.5,1.6 nntplib.py,1.29,1.30 popen2.py,1.24,1.25 pyclbr.py,1.25,1.26 rlcompleter.py,1.12,1.13 smtplib.py,1.57,1.58 string.py,1.63,1.64 urllib.py,1.146,1.147 urllib2.py,1.29,1.30 warnings.py,1.15,1.16 zipfile.py,1.23,1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv7413a/Lib Modified Files: ConfigParser.py StringIO.py formatter.py hmac.py markupbase.py nntplib.py popen2.py pyclbr.py rlcompleter.py smtplib.py string.py urllib.py urllib2.py warnings.py zipfile.py Log Message: Remove uses of the string and types modules: x in string.whitespace => x.isspace() type(x) in types.StringTypes => isinstance(x, basestring) isinstance(x, types.StringTypes) => isinstance(x, basestring) type(x) is types.StringType => isinstance(x, str) type(x) == types.StringType => isinstance(x, str) string.split(x, ...) => x.split(...) string.join(x, y) => y.join(x) string.zfill(x, ...) => x.zfill(...) string.count(x, ...) => x.count(...) hasattr(types, "UnicodeType") => try: unicode except NameError: type(x) != types.TupleTuple => not isinstance(x, tuple) isinstance(x, types.TupleType) => isinstance(x, tuple) type(x) is types.IntType => isinstance(x, int) Do not mention the string module in the rlcompleter docstring. This partially applies SF patch http://www.python.org/sf/562373 (with basestring instead of string). (It excludes the changes to unittest.py and does not change the os.stat stuff.) Index: ConfigParser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ConfigParser.py,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** ConfigParser.py 1 Jun 2002 14:18:45 -0000 1.43 --- ConfigParser.py 3 Jun 2002 15:58:30 -0000 1.44 *************** *** 84,88 **** """ ! import string, types import re --- 84,88 ---- """ ! import types import re *************** *** 224,228 **** filename may also be given. """ ! if type(filenames) in types.StringTypes: filenames = [filenames] for filename in filenames: --- 224,228 ---- filename may also be given. """ ! if isinstance(filenames, basestring): filenames = [filenames] for filename in filenames: *************** *** 455,459 **** # a spacing character pos = optval.find(';') ! if pos and optval[pos-1] in string.whitespace: optval = optval[:pos] optval = optval.strip() --- 455,459 ---- # a spacing character pos = optval.find(';') ! if pos and optval[pos-1].isspace(): optval = optval[:pos] optval = optval.strip() Index: StringIO.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/StringIO.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** StringIO.py 23 May 2002 15:15:29 -0000 1.26 --- StringIO.py 3 Jun 2002 15:58:30 -0000 1.27 *************** *** 29,33 **** - There's a simple test set (see end of this file). """ - import types try: from errno import EINVAL --- 29,32 ---- *************** *** 51,55 **** def __init__(self, buf = ''): # Force self.buf to be a string or unicode ! if not isinstance(buf, types.StringTypes): buf = str(buf) self.buf = buf --- 50,54 ---- def __init__(self, buf = ''): # Force self.buf to be a string or unicode ! if not isinstance(buf, basestring): buf = str(buf) self.buf = buf *************** *** 152,156 **** if not s: return # Force s to be a string or unicode ! if not isinstance(s, types.StringTypes): s = str(s) if self.pos > self.len: --- 151,155 ---- if not s: return # Force s to be a string or unicode ! if not isinstance(s, basestring): s = str(s) if self.pos > self.len: Index: formatter.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/formatter.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** formatter.py 1 Jun 2002 01:29:16 -0000 1.21 --- formatter.py 3 Jun 2002 15:58:31 -0000 1.22 *************** *** 19,25 **** """ - import string import sys - from types import StringType --- 19,23 ---- *************** *** 120,124 **** if not self.para_end: self.writer.send_paragraph((blankline and 1) or 0) ! if type(format) is StringType: self.writer.send_label_data(self.format_counter(format, counter)) else: --- 118,122 ---- if not self.para_end: self.writer.send_paragraph((blankline and 1) or 0) ! if isinstance(format, str): self.writer.send_label_data(self.format_counter(format, counter)) else: *************** *** 177,190 **** return label ! def add_flowing_data(self, data, ! # These are only here to load them into locals: ! whitespace = string.whitespace, ! join = string.join, split = string.split): if not data: return # The following looks a bit convoluted but is a great improvement over # data = regsub.gsub('[' + string.whitespace + ']+', ' ', data) ! prespace = data[:1] in whitespace ! postspace = data[-1:] in whitespace ! data = join(split(data)) if self.nospace and not data: return --- 175,185 ---- return label ! def add_flowing_data(self, data): if not data: return # The following looks a bit convoluted but is a great improvement over # data = regsub.gsub('[' + string.whitespace + ']+', ' ', data) ! prespace = data[:1].isspace() ! postspace = data[-1:].isspace() ! data = " ".join(data.split()) if self.nospace and not data: return *************** *** 412,416 **** def send_flowing_data(self, data): if not data: return ! atbreak = self.atbreak or data[0] in string.whitespace col = self.col maxcol = self.maxcol --- 407,411 ---- def send_flowing_data(self, data): if not data: return ! atbreak = self.atbreak or data[0].isspace() col = self.col maxcol = self.maxcol *************** *** 428,432 **** atbreak = 1 self.col = col ! self.atbreak = data[-1] in string.whitespace --- 423,427 ---- atbreak = 1 self.col = col ! self.atbreak = data[-1].isspace() Index: hmac.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/hmac.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** hmac.py 1 Jun 2002 01:29:16 -0000 1.6 --- hmac.py 3 Jun 2002 15:58:31 -0000 1.7 *************** *** 4,9 **** """ - import string - def _strxor(s1, s2): """Utility method. XOR the two strings s1 and s2 (must have same length). --- 4,7 ---- *************** *** 83,87 **** """Like digest(), but returns a string of hexadecimal digits instead. """ ! return "".join([string.zfill(hex(ord(x))[2:], 2) for x in tuple(self.digest())]) --- 81,85 ---- """Like digest(), but returns a string of hexadecimal digits instead. """ ! return "".join([hex(ord(x))[2:].zfill(2) for x in tuple(self.digest())]) Index: markupbase.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/markupbase.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** markupbase.py 31 May 2002 14:13:03 -0000 1.5 --- markupbase.py 3 Jun 2002 15:58:31 -0000 1.6 *************** *** 2,6 **** import re - import string _declname_match = re.compile(r'[a-zA-Z][-_.a-zA-Z0-9]*\s*').match --- 2,5 ---- *************** *** 152,156 **** elif c == "]": j = j + 1 ! while j < n and rawdata[j] in string.whitespace: j = j + 1 if j < n: --- 151,155 ---- elif c == "]": j = j + 1 ! while j < n and rawdata[j].isspace(): j = j + 1 if j < n: *************** *** 161,165 **** else: return -1 ! elif c in string.whitespace: j = j + 1 else: --- 160,164 ---- else: return -1 ! elif c.isspace(): j = j + 1 else: *************** *** 204,208 **** else: return -1 ! while rawdata[j:j+1] in string.whitespace: j = j + 1 if not rawdata[j:]: --- 203,207 ---- else: return -1 ! while rawdata[j:j+1].isspace(): j = j + 1 if not rawdata[j:]: *************** *** 269,273 **** if not c: return -1 ! if c in string.whitespace: j = j + 1 else: --- 268,272 ---- if not c: return -1 ! if c.isspace(): j = j + 1 else: Index: nntplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/nntplib.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** nntplib.py 16 Feb 2002 23:06:17 -0000 1.29 --- nntplib.py 3 Jun 2002 15:58:31 -0000 1.30 *************** *** 32,36 **** import re import socket - import types __all__ = ["NNTP","NNTPReplyError","NNTPTemporaryError", --- 32,35 ---- *************** *** 219,223 **** try: # If a string was passed then open a file with that name ! if isinstance(file, types.StringType): openedFile = file = open(file, "w") --- 218,222 ---- try: # If a string was passed then open a file with that name ! if isinstance(file, str): openedFile = file = open(file, "w") Index: popen2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/popen2.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** popen2.py 24 Mar 2002 20:48:26 -0000 1.24 --- popen2.py 3 Jun 2002 15:58:31 -0000 1.25 *************** *** 9,13 **** import os import sys - import types __all__ = ["popen2", "popen3", "popen4"] --- 9,12 ---- *************** *** 58,62 **** def _run_child(self, cmd): ! if isinstance(cmd, types.StringTypes): cmd = ['/bin/sh', '-c', cmd] for i in range(3, MAXFD): --- 57,61 ---- def _run_child(self, cmd): ! if isinstance(cmd, basestring): cmd = ['/bin/sh', '-c', cmd] for i in range(3, MAXFD): Index: pyclbr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pyclbr.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** pyclbr.py 2 Jun 2002 18:55:56 -0000 1.25 --- pyclbr.py 3 Jun 2002 15:58:31 -0000 1.26 *************** *** 209,218 **** # To avoid having to stop the regexp at each newline, instead ! # when we need a line number we simply string.count the number of # newlines in the string since the last time we did this; i.e., ! # lineno = lineno + \ ! # string.count(src, '\n', last_lineno_pos, here) # last_lineno_pos = here - countnl = string.count lineno, last_lineno_pos = 1, 0 i = 0 --- 209,216 ---- # To avoid having to stop the regexp at each newline, instead ! # when we need a line number we simply count the number of # newlines in the string since the last time we did this; i.e., ! # lineno += src.count('\n', last_lineno_pos, here) # last_lineno_pos = here lineno, last_lineno_pos = 1, 0 i = 0 *************** *** 227,233 **** thisindent = _indent(m.group("MethodIndent")) meth_name = m.group("MethodName") ! lineno = lineno + \ ! countnl(src, '\n', ! last_lineno_pos, start) last_lineno_pos = start # close all classes indented at least as much --- 225,229 ---- thisindent = _indent(m.group("MethodIndent")) meth_name = m.group("MethodName") ! lineno += src.count('\n', last_lineno_pos, start) last_lineno_pos = start # close all classes indented at least as much *************** *** 255,260 **** classstack[-1][1] >= thisindent: del classstack[-1] ! lineno = lineno + \ ! countnl(src, '\n', last_lineno_pos, start) last_lineno_pos = start class_name = m.group("ClassName") --- 251,255 ---- classstack[-1][1] >= thisindent: del classstack[-1] ! lineno += src.count('\n', last_lineno_pos, start) last_lineno_pos = start class_name = m.group("ClassName") Index: rlcompleter.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/rlcompleter.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** rlcompleter.py 2 Jun 2002 18:55:56 -0000 1.12 --- rlcompleter.py 3 Jun 2002 15:58:31 -0000 1.13 *************** *** 6,12 **** expression up to the last dot and completes its attributes. ! It's very cool to do "import string" type "string.", hit the completion key (twice), and see the list of names defined by the ! string module! Tip: to use the tab key as the completion key, call --- 6,12 ---- expression up to the last dot and completes its attributes. ! It's very cool to do "import sys" type "sys.", hit the completion key (twice), and see the list of names defined by the ! sys module! Tip: to use the tab key as the completion key, call Index: smtplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/smtplib.py,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** smtplib.py 2 Jun 2002 12:33:22 -0000 1.57 --- smtplib.py 3 Jun 2002 15:58:32 -0000 1.58 *************** *** 45,49 **** import re import rfc822 - import types import base64 import hmac --- 45,48 ---- *************** *** 652,656 **** raise SMTPSenderRefused(code, resp, from_addr) senderrs={} ! if isinstance(to_addrs, types.StringTypes): to_addrs = [to_addrs] for each in to_addrs: --- 651,655 ---- raise SMTPSenderRefused(code, resp, from_addr) senderrs={} ! if isinstance(to_addrs, basestring): to_addrs = [to_addrs] for each in to_addrs: Index: string.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/string.py,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** string.py 15 Apr 2002 13:36:43 -0000 1.63 --- string.py 3 Jun 2002 15:58:32 -0000 1.64 *************** *** 191,198 **** _int = int _long = long - try: - _StringTypes = (str, unicode) - except NameError: - _StringTypes = (str,) # Convert string to float --- 191,194 ---- *************** *** 280,284 **** """ ! if not isinstance(x, _StringTypes): x = repr(x) return x.zfill(width) --- 276,280 ---- """ ! if not isinstance(x, basestring): x = repr(x) return x.zfill(width) Index: urllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib.py,v retrieving revision 1.146 retrieving revision 1.147 diff -C2 -d -r1.146 -r1.147 *** urllib.py 2 Jun 2002 03:04:51 -0000 1.146 --- urllib.py 3 Jun 2002 15:58:32 -0000 1.147 *************** *** 28,32 **** import time import sys - import types __all__ = ["urlopen", "URLopener", "FancyURLopener", "urlretrieve", --- 28,31 ---- *************** *** 255,259 **** import httplib user_passwd = None ! if type(url) is types.StringType: host, selector = splithost(url) if host: --- 254,258 ---- import httplib user_passwd = None ! if isinstance(url, str): host, selector = splithost(url) if host: *************** *** 333,337 **** import httplib user_passwd = None ! if type(url) is types.StringType: host, selector = splithost(url) if host: --- 332,336 ---- import httplib user_passwd = None ! if isinstance(url, str): host, selector = splithost(url) if host: *************** *** 907,916 **** # quote('abc def') -> 'abc%20def') ! if hasattr(types, "UnicodeType"): def _is_unicode(x): ! return isinstance(x, unicode) else: def _is_unicode(x): ! return 0 def toBytes(url): --- 906,917 ---- # quote('abc def') -> 'abc%20def') ! try: ! unicode ! except NameError: def _is_unicode(x): ! return 0 else: def _is_unicode(x): ! return isinstance(x, unicode) def toBytes(url): *************** *** 1174,1178 **** # non-sequence items should not work with len() # non-empty strings will fail this ! if len(query) and type(query[0]) != types.TupleType: raise TypeError # zero-length sequences of all types will get here and succeed, --- 1175,1179 ---- # non-sequence items should not work with len() # non-empty strings will fail this ! if len(query) and not isinstance(query[0], tuple): raise TypeError # zero-length sequences of all types will get here and succeed, *************** *** 1194,1198 **** for k, v in query: k = quote_plus(str(k)) ! if type(v) == types.StringType: v = quote_plus(v) l.append(k + '=' + v) --- 1195,1199 ---- for k, v in query: k = quote_plus(str(k)) ! if isinstance(v, str): v = quote_plus(v) l.append(k + '=' + v) Index: urllib2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib2.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** urllib2.py 1 Jun 2002 14:18:47 -0000 1.29 --- urllib2.py 3 Jun 2002 15:58:32 -0000 1.30 *************** *** 93,97 **** import re import base64 - import types import urlparse import md5 --- 93,96 ---- *************** *** 304,308 **** def open(self, fullurl, data=None): # accept a URL or a Request object ! if isinstance(fullurl, types.StringTypes): req = Request(fullurl, data) else: --- 303,307 ---- def open(self, fullurl, data=None): # accept a URL or a Request object ! if isinstance(fullurl, basestring): req = Request(fullurl, data) else: *************** *** 517,521 **** def add_password(self, realm, uri, user, passwd): # uri could be a single URI or a sequence ! if isinstance(uri, types.StringTypes): uri = [uri] uri = tuple(map(self.reduce_uri, uri)) --- 516,520 ---- def add_password(self, realm, uri, user, passwd): # uri could be a single URI or a sequence ! if isinstance(uri, basestring): uri = [uri] uri = tuple(map(self.reduce_uri, uri)) *************** *** 1085,1089 **** for url in urls: ! if isinstance(url, types.TupleType): url, req = url else: --- 1084,1088 ---- for url in urls: ! if isinstance(url, tuple): url, req = url else: Index: warnings.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/warnings.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** warnings.py 1 Jun 2002 14:18:47 -0000 1.15 --- warnings.py 3 Jun 2002 15:58:32 -0000 1.16 *************** *** 126,134 **** assert action in ("error", "ignore", "always", "default", "module", "once"), "invalid action: %s" % `action` ! assert isinstance(message, types.StringType), "message must be a string" assert isinstance(category, types.ClassType), "category must be a class" assert issubclass(category, Warning), "category must be a Warning subclass" ! assert type(module) is types.StringType, "module must be a string" ! assert type(lineno) is types.IntType and lineno >= 0, \ "lineno must be an int >= 0" item = (action, re.compile(message, re.I), category, --- 126,134 ---- assert action in ("error", "ignore", "always", "default", "module", "once"), "invalid action: %s" % `action` ! assert isinstance(message, str), "message must be a string" assert isinstance(category, types.ClassType), "category must be a class" assert issubclass(category, Warning), "category must be a Warning subclass" ! assert isinstance(module, str), "module must be a string" ! assert isinstance(lineno, int) and lineno >= 0, \ "lineno must be an int >= 0" item = (action, re.compile(message, re.I), category, Index: zipfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/zipfile.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** zipfile.py 1 Jun 2002 19:51:15 -0000 1.23 --- zipfile.py 3 Jun 2002 15:58:32 -0000 1.24 *************** *** 66,76 **** _FH_EXTRA_FIELD_LENGTH = 11 - # Used to compare file passed to ZipFile - import types - _STRING_TYPES = (types.StringType,) - if hasattr(types, "UnicodeType"): - _STRING_TYPES = _STRING_TYPES + (types.UnicodeType,) - - def is_zipfile(filename): """Quickly see if file is a ZIP file by checking the magic number. --- 66,69 ---- *************** *** 176,180 **** # Check if we were passed a file-like object ! if type(file) in _STRING_TYPES: self._filePassed = 0 self.filename = file --- 169,173 ---- # Check if we were passed a file-like object ! if isinstance(file, basestring): self._filePassed = 0 self.filename = file From jhylton@users.sourceforge.net Mon Jun 3 17:53:03 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Mon, 03 Jun 2002 09:53:03 -0700 Subject: [Python-checkins] python/dist/src/Lib urllib2.py,1.30,1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv26841 Modified Files: urllib2.py Log Message: Fix HTTPError __init__ for cases where fp is None. The HTTPError class tries to act as a regular response objects for HTTP protocol errors that include full responses. If the failure is more basic, like no valid response, the __init__ choked when it tried to initialize its superclasses in addinfourl hierarchy that requires a valid response. The solution isn't elegant but seems to be effective. Do not initialize the base classes if there isn't a file object containing the response. In this case, user code expecting to use the addinfourl methods will fail; but it was going to fail anyway. It might be cleaner to factor out HTTPError into two classes, only one of which inherits from addinfourl. Not sure that the extra complexity would lead to any improved functionality, though. Partial fix for SF bug # 563665. Bug fix candidate for 2.1 and 2.2. Index: urllib2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib2.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** urllib2.py 3 Jun 2002 15:58:32 -0000 1.30 --- urllib2.py 3 Jun 2002 16:53:00 -0000 1.31 *************** *** 158,168 **** def __init__(self, url, code, msg, hdrs, fp): - self.__super_init(fp, hdrs, url) self.code = code self.msg = msg self.hdrs = hdrs self.fp = fp - # XXX self.filename = url def __str__(self): --- 158,172 ---- def __init__(self, url, code, msg, hdrs, fp): self.code = code self.msg = msg self.hdrs = hdrs self.fp = fp self.filename = url + # The addinfourl classes depend on fp being a valid file + # object. In some cases, the HTTPError may not have a valid + # file object. If this happens, the simplest workaround is to + # not initialize the base classes. + if fp is not None: + self.__super_init(fp, hdrs, url) def __str__(self): From gvanrossum@users.sourceforge.net Mon Jun 3 20:06:43 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Mon, 03 Jun 2002 12:06:43 -0700 Subject: [Python-checkins] python/dist/src/Doc/ref ref3.tex,1.88,1.89 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv7320 Modified Files: ref3.tex Log Message: Addressed SF bug 421973 (finally). Rewrote the subsection on coercion rules (and made it a proper subsection, with a label). The new section is much less precise, because precise rules would be too hard to give (== I don't know what they are any more :-). OTOH, the new section gives much more up-to-date information. Also noted that __coerce__ may return NotImplemented, with the same meaning as None. I beg Fred forgiveness: my use of \code{} is probably naive. Please fix this and other markup nits. An index entry would be nice. This could be a 2.2 bugfix candidate, if we bother about old docs (Fred?) Index: ref3.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref3.tex,v retrieving revision 1.88 retrieving revision 1.89 diff -C2 -d -r1.88 -r1.89 *** ref3.tex 12 May 2002 03:09:25 -0000 1.88 --- ref3.tex 3 Jun 2002 19:06:41 -0000 1.89 *************** *** 1512,1584 **** object to attempt a coercion (but sometimes, if the implementation of the other type cannot be changed, it is useful to do the conversion to ! the other type here). \end{methoddesc} ! \strong{Coercion rules}: to evaluate \var{x} \var{op} \var{y}, the ! following steps are taken (where \method{__\var{op}__()} and ! \method{__r\var{op}__()} are the method names corresponding to ! \var{op}, e.g., if \var{op} is `\code{+}', \method{__add__()} and ! \method{__radd__()} are used). If an exception occurs at any point, ! the evaluation is abandoned and exception handling takes over. \begin{itemize} ! \item[0.] If \var{x} is a string object and \var{op} is the modulo ! operator (\%), the string formatting operation is invoked and ! the remaining steps are skipped. ! \item[1.] If \var{x} is a class instance: ! \begin{itemize} ! \item[1a.] If \var{x} has a \method{__coerce__()} method: ! replace \var{x} and \var{y} with the 2-tuple returned by ! \code{\var{x}.__coerce__(\var{y})}; skip to step 2 if the ! coercion returns \code{None}. ! \item[1b.] If neither \var{x} nor \var{y} is a class instance ! after coercion, go to step 3. ! \item[1c.] If \var{x} has a method \method{__\var{op}__()}, return ! \code{\var{x}.__\var{op}__(\var{y})}; otherwise, restore \var{x} and ! \var{y} to their value before step 1a. ! \end{itemize} ! \item[2.] If \var{y} is a class instance: ! \begin{itemize} ! \item[2a.] If \var{y} has a \method{__coerce__()} method: ! replace \var{y} and \var{x} with the 2-tuple returned by ! \code{\var{y}.__coerce__(\var{x})}; skip to step 3 if the ! coercion returns \code{None}. ! \item[2b.] If neither \var{x} nor \var{y} is a class instance ! after coercion, go to step 3. ! \item[2b.] If \var{y} has a method \method{__r\var{op}__()}, ! return \code{\var{y}.__r\var{op}__(\var{x})}; otherwise, ! restore \var{x} and \var{y} to their value before step 2a. ! \end{itemize} ! \item[3.] We only get here if neither \var{x} nor \var{y} is a class ! instance. ! \begin{itemize} ! \item[3a.] If \var{op} is `\code{+}' and \var{x} is a ! sequence, sequence concatenation is invoked. ! \item[3b.] If \var{op} is `\code{*}' and one operand is a ! sequence and the other an integer, sequence repetition is ! invoked. ! \item[3c.] Otherwise, both operands must be numbers; they are ! coerced to a common type if possible, and the numeric ! operation is invoked for that type. ! \end{itemize} \end{itemize} --- 1512,1626 ---- object to attempt a coercion (but sometimes, if the implementation of the other type cannot be changed, it is useful to do the conversion to ! the other type here). A return value of \code{NotImplemented} is ! equivalent to returning \code{None}. \end{methoddesc} ! \subsection{Coercion rules\label{coercion-rules}} ! ! This section used to document the rules for coercion. As the language ! has evolved, the coercion rules have become hard to document ! precisely; documenting what one version of one particular ! implementation does is undesirable. Instead, here are some informal ! guidelines regarding coercion. In Python 3.0, coercion will not be ! supported. \begin{itemize} ! \item ! If the left operand of a \% operator is a string or Unicode object, no ! coercion takes place and the string formatting operation is invoked ! instead. ! \item ! It is no longer recommended to define a coercion operation. ! Mixed-mode operations on types that don't define coercion pass the ! original arguments to the operation. ! \item ! New-style classes (those derived from \code{object}) never invoke the ! \code{__coerce__} method in response to a binary operator; the only ! time \code{__coerce__} is invoked is when the built-in function ! \code{coerce()} is called. ! \item ! For most intents and purposes, an operator that returns ! \code{NotImplemented} is treated the same as one that is not ! implemented at all. ! \item ! Below, \method{__op__()} and \method{__rop__()} are used to signify ! the generic method names corresponding to an operator; ! \method{__iop__} is used for the corresponding in-place operator. For ! example, for the operator `\code{+}', \method{__add__()} and ! \method{__radd__()} are used for the left and right variant of the ! binary operator, and \method{__iadd__} for the in-place variant. ! \item ! For objects \var{x} and \var{y}, first \code{\var{x}.__op__(\var{y})} ! is tried. If this is not implemented or returns \code{NotImplemented}, ! \code{\var{y}.__rop__(\var{x})} is tried. If this is also not ! implemented or returns \code{NotImplemented}, a \code{TypeError} ! exception is raised. But see the following exception: ! \item ! Exception to the previous item: if the left operand is an instance of ! a built-in type or a new-style class, and the right operand is an ! instance of a proper subclass of that type or class, the right ! operand's \code{__rop__} method is tried \emph{before} the left ! operand's \code{__op__} method. This is done so that a subclass can ! completely override binary operators. Otherwise, the left operand's ! __op__ method would always accept the right operand: when an instance ! of a given class is expected, an instance of a subclass of that class ! is always acceptable. ! \item ! When either operand type defines a coercion, this coercion is called ! before that type's \code{__op__} or \code{__rop__} method is called, ! but no sooner. If the coercion returns an object of a different type ! for the operand whose coercion is invoked, part of the process is ! redone using the new object. ! \item ! When an in-place operator (like `\code{+=}') is used, if the left ! operand implements \code{__iop__}, it is invoked without any coercion. ! When the operation falls back to \code{__op__} and/or \code{__rop__}, ! the normal coercion rules apply. ! \item ! ! In \var{x}\code{+}\var{y}, if \var{x} is a sequence that implements ! sequence concatenation, sequence concatenation is invoked. ! ! \item ! ! In \var{x}\code{*}\var{y}, if one operator is a sequence that ! implements sequence repetition, and the other is an integer ! (\code{int} or \code{long}), sequence repetition is invoked. ! ! \item ! ! Rich comparisons (implemented by methods \code{__eq__} and so on) ! never use coercion. Three-way comparison (implemented by ! \code{__cmp__}) does use coercion under the same conditions as ! other binary operations use it. ! ! \item ! ! In the current implementation, the built-in numeric types \code{int}, ! \code{long} and \code{float} do not use coercion; the type ! \code{complex} however does use it. The difference can become ! apparent when subclassing these types. Over time, the type ! \code{complex} may be fixed to avoid coercion. All these types ! implement a \code{__coerce__} method, for use by the built-in ! \code{coerce} function. \end{itemize} From gvanrossum@users.sourceforge.net Mon Jun 3 20:45:34 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Mon, 03 Jun 2002 12:45:34 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_descr.py,1.135,1.136 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv19356 Modified Files: test_descr.py Log Message: The warning filter was ineffective when this module was invoked as a script. Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.135 retrieving revision 1.136 diff -C2 -d -r1.135 -r1.136 *** test_descr.py 24 May 2002 21:40:08 -0000 1.135 --- test_descr.py 3 Jun 2002 19:45:32 -0000 1.136 *************** *** 7,11 **** warnings.filterwarnings("ignore", r'complex divmod\(\), // and % are deprecated$', ! DeprecationWarning, r'(|test_descr)$') def veris(a, b): --- 7,11 ---- warnings.filterwarnings("ignore", r'complex divmod\(\), // and % are deprecated$', ! DeprecationWarning, r'(|%s)$' % __name__) def veris(a, b): From gvanrossum@users.sourceforge.net Mon Jun 3 20:52:44 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Mon, 03 Jun 2002 12:52:44 -0700 Subject: [Python-checkins] python/dist/src/Objects typeobject.c,2.146,2.147 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv21708 Modified Files: typeobject.c Log Message: Address the residual issue with the fix for SF 551412 in _PyType_Lookup(). Decided to clear the error condition in the unfortunate but unlikely case that PyType_Ready() fails. Will fix in 2.2.x too. Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.146 retrieving revision 2.147 diff -C2 -d -r2.146 -r2.147 *** typeobject.c 24 May 2002 21:38:46 -0000 2.146 --- typeobject.c 3 Jun 2002 19:52:41 -0000 2.147 *************** *** 1223,1228 **** mro = type->tp_mro; if (mro == NULL) { ! if (PyType_Ready(type) < 0) return NULL; mro = type->tp_mro; assert(mro != NULL); --- 1223,1238 ---- mro = type->tp_mro; if (mro == NULL) { ! if (PyType_Ready(type) < 0) { ! /* It's not ideal to clear the error condition, ! but this function is documented as not setting ! an exception, and I don't want to change that. ! When PyType_Ready() can't proceed, it won't ! set the "ready" flag, so future attempts to ready ! the same type will call it again -- hopefully ! in a context that propagates the exception out. ! */ ! PyErr_Clear(); return NULL; + } mro = type->tp_mro; assert(mro != NULL); From gvanrossum@users.sourceforge.net Mon Jun 3 20:54:12 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Mon, 03 Jun 2002 12:54:12 -0700 Subject: [Python-checkins] python/dist/src/Objects typeobject.c,2.126.4.11,2.126.4.12 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv22214 Modified Files: Tag: release22-maint typeobject.c Log Message: Backport to 2.2.x: Address the residual issue with the fix for SF 551412 in _PyType_Lookup(). Decided to clear the error condition in the unfortunate but unlikely case that PyType_Ready() fails. Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.126.4.11 retrieving revision 2.126.4.12 diff -C2 -d -r2.126.4.11 -r2.126.4.12 *** typeobject.c 24 May 2002 21:41:26 -0000 2.126.4.11 --- typeobject.c 3 Jun 2002 19:54:10 -0000 2.126.4.12 *************** *** 1220,1225 **** mro = type->tp_mro; if (mro == NULL) { ! if (PyType_Ready(type) < 0) return NULL; mro = type->tp_mro; assert(mro != NULL); --- 1220,1235 ---- mro = type->tp_mro; if (mro == NULL) { ! if (PyType_Ready(type) < 0) { ! /* It's not ideal to clear the error condition, ! but this function is documented as not setting ! an exception, and I don't want to change that. ! When PyType_Ready() can't proceed, it won't ! set the "ready" flag, so future attempts to ready ! the same type will call it again -- hopefully ! in a context that propagates the exception out. ! */ ! PyErr_Clear(); return NULL; + } mro = type->tp_mro; assert(mro != NULL); From rhettinger@users.sourceforge.net Tue Jun 4 03:17:07 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon, 03 Jun 2002 19:17:07 -0700 Subject: [Python-checkins] python/dist/src/Lib mhlib.py,1.33,1.34 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv28953 Modified Files: mhlib.py Log Message: Replace .keys() with .iteritems(). Second review and test by Alex. Index: mhlib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mhlib.py,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** mhlib.py 2 Jun 2002 16:12:06 -0000 1.33 --- mhlib.py 4 Jun 2002 02:17:04 -0000 1.34 *************** *** 315,321 **** fullname = self.getsequencesfilename() f = None ! for key in sequences.keys(): s = IntSet('', ' ') ! s.fromlist(sequences[key]) if not f: f = open(fullname, 'w') f.write('%s: %s\n' % (key, s.tostring())) --- 315,321 ---- fullname = self.getsequencesfilename() f = None ! for key, seq in sequences.iteritems(): s = IntSet('', ' ') ! s.fromlist(seq) if not f: f = open(fullname, 'w') f.write('%s: %s\n' % (key, s.tostring())) From gvanrossum@users.sourceforge.net Tue Jun 4 06:52:08 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Mon, 03 Jun 2002 22:52:08 -0700 Subject: [Python-checkins] python/dist/src/Objects moduleobject.c,2.42,2.43 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv13899 Modified Files: moduleobject.c Log Message: Surprising fix for SF bug 563060: module can be used as base class. Change the module constructor (module_init) to have the signature __init__(name:str, doc=None); this prevents the call from type_new() to succeed. While we're at it, prevent repeated calling of module_init for the same module from leaking the dict, changing the semantics so that __dict__ is only initialized if NULL. Also adding a unittest, test_module.py. This is an incompatibility with 2.2, if anybody was instantiating the module class before, their argument list was probably empty; so this can't be backported to 2.2.x. Index: moduleobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/moduleobject.c,v retrieving revision 2.42 retrieving revision 2.43 diff -C2 -d -r2.42 -r2.43 *** moduleobject.c 12 Apr 2002 02:44:22 -0000 2.42 --- moduleobject.c 4 Jun 2002 05:52:06 -0000 2.43 *************** *** 148,155 **** static int ! module_init(PyModuleObject *m, PyObject *args, PyObject *kw) { ! m->md_dict = PyDict_New(); ! if (m->md_dict == NULL) return -1; return 0; --- 148,168 ---- static int ! module_init(PyModuleObject *m, PyObject *args, PyObject *kwds) { ! static char *kwlist[] = {"name", "doc", NULL}; ! PyObject *dict, *name = Py_None, *doc = Py_None; ! if (!PyArg_ParseTupleAndKeywords(args, kwds, "S|O", kwlist, ! &name, &doc)) ! return -1; ! dict = m->md_dict; ! if (dict == NULL) { ! dict = PyDict_New(); ! if (dict == NULL) ! return -1; ! m->md_dict = dict; ! } ! if (PyDict_SetItemString(dict, "__name__", name) < 0) ! return -1; ! if (PyDict_SetItemString(dict, "__doc__", doc) < 0) return -1; return 0; From gvanrossum@users.sourceforge.net Tue Jun 4 06:52:49 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Mon, 03 Jun 2002 22:52:49 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_module.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv14104 Added Files: test_module.py Log Message: Surprising fix for SF bug 563060: module can be used as base class. Change the module constructor (module_init) to have the signature __init__(name:str, doc=None); this prevents the call from type_new() to succeed. While we're at it, prevent repeated calling of module_init for the same module from leaking the dict, changing the semantics so that __dict__ is only initialized if NULL. Also adding a unittest, test_module.py. This is an incompatibility with 2.2, if anybody was instantiating the module class before, their argument list was probably empty; so this can't be backported to 2.2.x. --- NEW FILE: test_module.py --- # Test the module type from test_support import verify, vereq, verbose, TestFailed import sys module = type(sys) # An uninitialized module has no __dict__ or __name__, and __doc__ is None foo = module.__new__(module) verify(foo.__dict__ is None) try: s = foo.__name__ except AttributeError: pass else: raise TestFailed, "__name__ = %s" % repr(s) vereq(foo.__doc__, None) # Regularly initialized module, no docstring foo = module("foo") vereq(foo.__name__, "foo") vereq(foo.__doc__, None) vereq(foo.__dict__, {"__name__": "foo", "__doc__": None}) # ASCII docstring foo = module("foo", "foodoc") vereq(foo.__name__, "foo") vereq(foo.__doc__, "foodoc") vereq(foo.__dict__, {"__name__": "foo", "__doc__": "foodoc"}) # Unicode docstring foo = module("foo", u"foodoc\u1234") vereq(foo.__name__, "foo") vereq(foo.__doc__, u"foodoc\u1234") vereq(foo.__dict__, {"__name__": "foo", "__doc__": u"foodoc\u1234"}) # Reinitialization should not replace the __dict__ foo.bar = 42 d = foo.__dict__ foo.__init__("foo", "foodoc") vereq(foo.__name__, "foo") vereq(foo.__doc__, "foodoc") vereq(foo.bar, 42) vereq(foo.__dict__, {"__name__": "foo", "__doc__": "foodoc", "bar": 42}) verify(foo.__dict__ is d) if verbose: print "All OK" From gvanrossum@users.sourceforge.net Tue Jun 4 06:58:36 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Mon, 03 Jun 2002 22:58:36 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.412,1.413 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv15616 Modified Files: NEWS Log Message: Surprising fix for SF bug 563060: module can be used as base class. Change the module constructor (module_init) to have the signature __init__(name:str, doc=None); this prevents the call from type_new() to succeed. While we're at it, prevent repeated calling of module_init for the same module from leaking the dict, changing the semantics so that __dict__ is only initialized if NULL. Also adding a unittest, test_module.py. This is an incompatibility with 2.2, if anybody was instantiating the module class before, their argument list was probably empty; so this can't be backported to 2.2.x. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.412 retrieving revision 1.413 diff -C2 -d -r1.412 -r1.413 *** NEWS 31 May 2002 19:58:00 -0000 1.412 --- NEWS 4 Jun 2002 05:58:34 -0000 1.413 *************** *** 7,10 **** --- 7,17 ---- Core and builtins + - The constructor for the module type now requires a name argument and + takes an optional docstring argument. Previously, this constructor + ignored its arguments. As a consequence, deriving a class from a + module (not from the module type) is now illegal; previously this + created an unnamed module, just like invoking the module type did. + [SF bug 563060] + - A new warning PendingDeprecationWarning was added to provide direction on features which are in the process of being deprecated. From gvanrossum@users.sourceforge.net Tue Jun 4 07:02:37 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Mon, 03 Jun 2002 23:02:37 -0700 Subject: [Python-checkins] python/dist/src/Objects moduleobject.c,2.43,2.44 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv17493 Modified Files: moduleobject.c Log Message: Add a docstring to the module type. Index: moduleobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/moduleobject.c,v retrieving revision 2.43 retrieving revision 2.44 diff -C2 -d -r2.43 -r2.44 *** moduleobject.c 4 Jun 2002 05:52:06 -0000 2.43 --- moduleobject.c 4 Jun 2002 06:02:35 -0000 2.44 *************** *** 210,213 **** --- 210,219 ---- } + static char module_doc[] = + "module(name[, doc])\n\ + \n\ + Create a module object.\n\ + The name must be a string; the optional doc argument can have any type."; + PyTypeObject PyModule_Type = { PyObject_HEAD_INIT(&PyType_Type) *************** *** 233,237 **** Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /* tp_flags */ ! 0, /* tp_doc */ (traverseproc)module_traverse, /* tp_traverse */ 0, /* tp_clear */ --- 239,243 ---- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /* tp_flags */ ! module_doc, /* tp_doc */ (traverseproc)module_traverse, /* tp_traverse */ 0, /* tp_clear */ From gvanrossum@users.sourceforge.net Tue Jun 4 07:06:56 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Mon, 03 Jun 2002 23:06:56 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_module.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv18553 Modified Files: test_module.py Log Message: Repair the test (adding a docstring to the module type changed the docstring for an uninitialized module object). Index: test_module.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_module.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_module.py 4 Jun 2002 05:52:47 -0000 1.1 --- test_module.py 4 Jun 2002 06:06:54 -0000 1.2 *************** *** 15,19 **** else: raise TestFailed, "__name__ = %s" % repr(s) ! vereq(foo.__doc__, None) # Regularly initialized module, no docstring --- 15,19 ---- else: raise TestFailed, "__name__ = %s" % repr(s) ! vereq(foo.__doc__, module.__doc__) # Regularly initialized module, no docstring From gvanrossum@users.sourceforge.net Tue Jun 4 07:10:39 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Mon, 03 Jun 2002 23:10:39 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_descr.py,1.136,1.137 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv19384 Modified Files: test_descr.py Log Message: Test repair now that module.__init__ requires a name and initializes __name__ and __doc__. Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.136 retrieving revision 1.137 diff -C2 -d -r1.136 -r1.137 *** test_descr.py 3 Jun 2002 19:45:32 -0000 1.136 --- test_descr.py 4 Jun 2002 06:10:37 -0000 1.137 *************** *** 343,350 **** class M(type(sys)): pass ! minstance = M() minstance.b = 2 minstance.a = 1 ! vereq(dir(minstance), ['a', 'b']) class M2(M): --- 343,351 ---- class M(type(sys)): pass ! minstance = M("m") minstance.b = 2 minstance.a = 1 ! names = [x for x in dir(minstance) if x not in ["__name__", "__doc__"]] ! vereq(names, ['a', 'b']) class M2(M): *************** *** 353,357 **** __dict__ = property(getdict) ! m2instance = M2() m2instance.b = 2 m2instance.a = 1 --- 354,358 ---- __dict__ = property(getdict) ! m2instance = M2("m2") m2instance.b = 2 m2instance.a = 1 *************** *** 819,824 **** MT = type(sys) class MM(MT): ! def __init__(self): ! MT.__init__(self) def __getattribute__(self, name): log.append(("getattr", name)) --- 820,825 ---- MT = type(sys) class MM(MT): ! def __init__(self, name): ! MT.__init__(self, name) def __getattribute__(self, name): log.append(("getattr", name)) *************** *** 830,834 **** log.append(("delattr", name)) MT.__delattr__(self, name) ! a = MM() a.foo = 12 x = a.foo --- 831,835 ---- log.append(("delattr", name)) MT.__delattr__(self, name) ! a = MM("a") a.foo = 12 x = a.foo From jlt63@users.sourceforge.net Tue Jun 4 16:06:09 2002 From: jlt63@users.sourceforge.net (jlt63@users.sourceforge.net) Date: Tue, 04 Jun 2002 08:06:09 -0700 Subject: [Python-checkins] python/dist/src configure,1.309,1.310 configure.in,1.319,1.320 pyconfig.h.in,1.36,1.37 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv17908 Modified Files: configure configure.in pyconfig.h.in Log Message: Patch #555929: Cygwin AH_BOTTOM cleanup patch (*** version 2 ***) This patch complies with the following request found near the top of configure.in: # This is for stuff that absolutely must end up in pyconfig.h. # Please use pyport.h instead, if possible. I tested this patch under Cygwin, Win32, and Red Hat Linux. Python built and ran successfully on each of these platforms. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.309 retrieving revision 1.310 diff -C2 -d -r1.309 -r1.310 *** configure 1 Jun 2002 21:39:58 -0000 1.309 --- configure 4 Jun 2002 15:05:56 -0000 1.310 *************** *** 1,4 **** #! /bin/sh ! # From configure.in Revision: 1.318 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.53. --- 1,4 ---- #! /bin/sh ! # From configure.in Revision: 1.319 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.53. Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.319 retrieving revision 1.320 diff -C2 -d -r1.319 -r1.320 *** configure.in 1 Jun 2002 21:39:58 -0000 1.319 --- configure.in 4 Jun 2002 15:06:02 -0000 1.320 *************** *** 8,21 **** # Please use pyport.h instead, if possible. AH_BOTTOM([ - #ifdef __CYGWIN__ - #ifdef USE_DL_IMPORT - #define DL_IMPORT(RTYPE) __declspec(dllimport) RTYPE - #define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE - #else - #define DL_IMPORT(RTYPE) __declspec(dllexport) RTYPE - #define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE - #endif - #endif - /* Define the macros needed if on a UnixWare 7.x system. */ #if defined(__USLC__) && defined(__SCO_VERSION__) --- 8,11 ---- Index: pyconfig.h.in =================================================================== RCS file: /cvsroot/python/python/dist/src/pyconfig.h.in,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** pyconfig.h.in 27 May 2002 15:08:23 -0000 1.36 --- pyconfig.h.in 4 Jun 2002 15:06:05 -0000 1.37 *************** *** 829,842 **** - #ifdef __CYGWIN__ - #ifdef USE_DL_IMPORT - #define DL_IMPORT(RTYPE) __declspec(dllimport) RTYPE - #define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE - #else - #define DL_IMPORT(RTYPE) __declspec(dllexport) RTYPE - #define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE - #endif - #endif - /* Define the macros needed if on a UnixWare 7.x system. */ #if defined(__USLC__) && defined(__SCO_VERSION__) --- 829,832 ---- From jlt63@users.sourceforge.net Tue Jun 4 16:07:11 2002 From: jlt63@users.sourceforge.net (jlt63@users.sourceforge.net) Date: Tue, 04 Jun 2002 08:07:11 -0700 Subject: [Python-checkins] python/dist/src/Include Python.h,2.49,2.50 pyport.h,2.49,2.50 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv19794/Include Modified Files: Python.h pyport.h Log Message: Patch #555929: Cygwin AH_BOTTOM cleanup patch (*** version 2 ***) This patch complies with the following request found near the top of configure.in: # This is for stuff that absolutely must end up in pyconfig.h. # Please use pyport.h instead, if possible. I tested this patch under Cygwin, Win32, and Red Hat Linux. Python built and ran successfully on each of these platforms. Index: Python.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/Python.h,v retrieving revision 2.49 retrieving revision 2.50 diff -C2 -d -r2.49 -r2.50 *** Python.h 27 May 2002 14:05:31 -0000 2.49 --- Python.h 4 Jun 2002 15:07:08 -0000 2.50 *************** *** 28,39 **** #endif - /* pyconfig.h may or may not define DL_IMPORT */ - #ifndef DL_IMPORT /* declarations for DLL import/export */ - #define DL_IMPORT(RTYPE) RTYPE - #endif - #ifndef DL_EXPORT /* declarations for DLL import/export */ - #define DL_EXPORT(RTYPE) RTYPE - #endif - #if defined(__sgi) && defined(WITH_THREAD) && !defined(_SGI_MP_SOURCE) #define _SGI_MP_SOURCE --- 28,31 ---- *************** *** 61,64 **** --- 53,64 ---- #include "pyport.h" + + /* pyconfig.h or pyport.h may or may not define DL_IMPORT */ + #ifndef DL_IMPORT /* declarations for DLL import/export */ + #define DL_IMPORT(RTYPE) RTYPE + #endif + #ifndef DL_EXPORT /* declarations for DLL import/export */ + #define DL_EXPORT(RTYPE) RTYPE + #endif /* Debug-mode build with pymalloc implies PYMALLOC_DEBUG. Index: pyport.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pyport.h,v retrieving revision 2.49 retrieving revision 2.50 diff -C2 -d -r2.49 -r2.50 *** pyport.h 15 May 2002 18:24:06 -0000 2.49 --- pyport.h 4 Jun 2002 15:07:08 -0000 2.50 *************** *** 385,391 **** --- 385,401 ---- #endif + #ifndef __CYGWIN__ #ifndef DL_IMPORT /* declarations for DLL import */ #define DL_IMPORT(RTYPE) RTYPE #endif + #else /* __CYGWIN__ */ + #ifdef USE_DL_IMPORT + #define DL_IMPORT(RTYPE) __declspec(dllimport) RTYPE + #define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE + #else /* !USE_DL_IMPORT */ + #define DL_IMPORT(RTYPE) __declspec(dllexport) RTYPE + #define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE + #endif /* USE_DL_IMPORT */ + #endif /* __CYGWIN__ */ /* If the fd manipulation macros aren't defined, From doerwalter@users.sourceforge.net Tue Jun 4 16:16:31 2002 From: doerwalter@users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Tue, 04 Jun 2002 08:16:31 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.413,1.414 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv26774/Misc Modified Files: NEWS Log Message: Add constants BOM_UTF8, BOM_UTF16, BOM_UTF16_LE, BOM_UTF16_BE, BOM_UTF32, BOM_UTF32_LE and BOM_UTF32_BE that represent the Byte Order Mark in UTF-8, UTF-16 and UTF-32 encodings for little and big endian systems. The old names BOM32_* and BOM64_* were off by a factor of 2. This closes SF bug http://www.python.org/sf/555360 Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.413 retrieving revision 1.414 diff -C2 -d -r1.413 -r1.414 *** NEWS 4 Jun 2002 05:58:34 -0000 1.413 --- NEWS 4 Jun 2002 15:16:28 -0000 1.414 *************** *** 125,128 **** --- 125,134 ---- Library + - Constants BOM_UTF8, BOM_UTF16, BOM_UTF16_LE, BOM_UTF16_BE, + BOM_UTF32, BOM_UTF32_LE and BOM_UTF32_BE that represent the Byte + Order Mark in UTF-8, UTF-16 and UTF-32 encodings for little and + big endian systems were added to the codecs module. The old names + BOM32_* and BOM64_* were off by a factor of 2. + - added degree/radian conversion functions to the math module. From doerwalter@users.sourceforge.net Tue Jun 4 16:16:31 2002 From: doerwalter@users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Tue, 04 Jun 2002 08:16:31 -0700 Subject: [Python-checkins] python/dist/src/Lib codecs.py,1.25,1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv26774/Lib Modified Files: codecs.py Log Message: Add constants BOM_UTF8, BOM_UTF16, BOM_UTF16_LE, BOM_UTF16_BE, BOM_UTF32, BOM_UTF32_LE and BOM_UTF32_BE that represent the Byte Order Mark in UTF-8, UTF-16 and UTF-32 encodings for little and big endian systems. The old names BOM32_* and BOM64_* were off by a factor of 2. This closes SF bug http://www.python.org/sf/555360 Index: codecs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/codecs.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** codecs.py 1 Jun 2002 14:18:45 -0000 1.25 --- codecs.py 4 Jun 2002 15:16:29 -0000 1.26 *************** *** 19,45 **** __all__ = ["register", "lookup", "open", "EncodedFile", "BOM", "BOM_BE", ! "BOM_LE", "BOM32_BE", "BOM32_LE", "BOM64_BE", "BOM64_LE"] ### Constants # ! # Byte Order Mark (BOM) and its possible values (BOM_BE, BOM_LE) ! # ! BOM = struct.pack('=H', 0xFEFF) # - BOM_BE = BOM32_BE = '\376\377' - # corresponds to Unicode U+FEFF in UTF-16 on big endian - # platforms == ZERO WIDTH NO-BREAK SPACE - BOM_LE = BOM32_LE = '\377\376' - # corresponds to Unicode U+FFFE in UTF-16 on little endian - # platforms == defined as being an illegal Unicode character ! # ! # 64-bit Byte Order Marks ! # ! BOM64_BE = '\000\000\376\377' ! # corresponds to Unicode U+0000FEFF in UCS-4 ! BOM64_LE = '\377\376\000\000' ! # corresponds to Unicode U+0000FFFE in UCS-4 --- 19,60 ---- __all__ = ["register", "lookup", "open", "EncodedFile", "BOM", "BOM_BE", ! "BOM_LE", "BOM32_BE", "BOM32_LE", "BOM64_BE", "BOM64_LE", ! "BOM_UTF8", "BOM_UTF16", "BOM_UTF16_LE", "BOM_UTF16_BE", ! "BOM_UTF32", "BOM_UTF32_LE", "BOM_UTF32_BE"] ### Constants # ! # Byte Order Mark (BOM = ZERO WIDTH NO-BREAK SPACE = U+FEFF) ! # and its possible byte string values ! # for UTF8/UTF16/UTF32 output and little/big endian machines # ! # UTF-8 ! BOM_UTF8 = '\xef\xbb\xbf' ! ! # UTF-16, little endian ! BOM_LE = BOM_UTF16_LE = '\xff\xfe' ! ! # UTF-16, big endian ! BOM_BE = BOM_UTF16_BE = '\xfe\xff' ! ! # UTF-32, little endian ! BOM_UTF32_LE = '\xff\xfe\x00\x00' ! ! # UTF-32, big endian ! BOM_UTF32_BE = '\x00\x00\xfe\xff' ! ! # UTF-16, native endianness ! BOM = BOM_UTF16 = struct.pack('=H', 0xFEFF) ! ! # UTF-32, native endianness ! BOM_UTF32 = struct.pack('=L', 0x0000FEFF) ! ! # Old broken names (don't use in new code) ! BOM32_LE = BOM_UTF16_LE ! BOM32_BE = BOM_UTF16_BE ! BOM64_LE = BOM_UTF32_LE ! BOM64_BE = BOM_UTF32_BE From doerwalter@users.sourceforge.net Tue Jun 4 16:16:32 2002 From: doerwalter@users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Tue, 04 Jun 2002 08:16:32 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libcodecs.tex,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv26774/Doc/lib Modified Files: libcodecs.tex Log Message: Add constants BOM_UTF8, BOM_UTF16, BOM_UTF16_LE, BOM_UTF16_BE, BOM_UTF32, BOM_UTF32_LE and BOM_UTF32_BE that represent the Byte Order Mark in UTF-8, UTF-16 and UTF-32 encodings for little and big endian systems. The old names BOM32_* and BOM64_* were off by a factor of 2. This closes SF bug http://www.python.org/sf/555360 Index: libcodecs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcodecs.tex,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** libcodecs.tex 17 Apr 2002 19:33:06 -0000 1.9 --- libcodecs.tex 4 Jun 2002 15:16:29 -0000 1.10 *************** *** 143,156 **** \dataline{BOM_BE} \dataline{BOM_LE} ! \dataline{BOM32_BE} ! \dataline{BOM32_LE} ! \dataline{BOM64_BE} ! \dataline{BOM64_LE} ! These constants define the byte order marks (BOM) used in data ! streams to indicate the byte order used in the stream or file. ! \constant{BOM} is either \constant{BOM_BE} or \constant{BOM_LE} ! depending on the platform's native byte order, while the others ! represent big endian (\samp{_BE} suffix) and little endian ! (\samp{_LE} suffix) byte order using 32-bit and 64-bit encodings. \end{datadesc} --- 143,161 ---- \dataline{BOM_BE} \dataline{BOM_LE} ! \dataline{BOM_UTF8} ! \dataline{BOM_UTF16} ! \dataline{BOM_UTF16_BE} ! \dataline{BOM_UTF16_LE} ! \dataline{BOM_UTF32} ! \dataline{BOM_UTF32_BE} ! \dataline{BOM_UTF32_LE} ! These constants define various encodings of the Unicode byte order mark ! (BOM) used in UTF-16 and UTF-32 data streams to indicate the byte order ! used in the stream or file and in UTF-8 as a Unicode signature. ! \constant{BOM_UTF16} is either \constant{BOM_UTF16_BE} or ! \constant{BOM_UTF16_LE} depending on the platform's native byte order, ! \constant{BOM} is an alias for \constant{BOM_UTF16}, \constant{BOM_LE} ! for \constant{BOM_UTF16_LE} and \constant{BOM_BE} for \constant{BOM_UTF16_BE}. ! The others represent the BOM in UTF-8 and UTF-32 encodings. \end{datadesc} From fdrake@users.sourceforge.net Tue Jun 4 16:28:23 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 04 Jun 2002 08:28:23 -0700 Subject: [Python-checkins] python/dist/src setup.py,1.87,1.88 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv3286 Modified Files: setup.py Log Message: When using a Python that has not been installed to build 3rd-party modules, distutils does not understand that the build version of the source tree is needed. This patch fixes distutils.sysconfig to understand that the running Python is part of the build tree and needs to use the appropriate "shape" of the tree. This does not assume anything about the current directory, so can be used to build 3rd-party modules using Python's build tree as well. This is useful since it allows us to use a non-installed debug-mode Python with 3rd-party modules for testing. It as the side-effect that set_python_build() is no longer needed (the hack which was added to allow distutils to be used to build the "standard" extension modules). This closes SF patch #547734. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.87 retrieving revision 1.88 diff -C2 -d -r1.87 -r1.88 *** setup.py 22 May 2002 16:46:15 -0000 1.87 --- setup.py 4 Jun 2002 15:28:21 -0000 1.88 *************** *** 823,826 **** # --install-platlib if __name__ == '__main__': - sysconfig.set_python_build() main() --- 823,825 ---- From fdrake@users.sourceforge.net Tue Jun 4 16:28:24 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 04 Jun 2002 08:28:24 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils sysconfig.py,1.45,1.46 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv3286/Lib/distutils Modified Files: sysconfig.py Log Message: When using a Python that has not been installed to build 3rd-party modules, distutils does not understand that the build version of the source tree is needed. This patch fixes distutils.sysconfig to understand that the running Python is part of the build tree and needs to use the appropriate "shape" of the tree. This does not assume anything about the current directory, so can be used to build 3rd-party modules using Python's build tree as well. This is useful since it allows us to use a non-installed debug-mode Python with 3rd-party modules for testing. It as the side-effect that set_python_build() is no longer needed (the hack which was added to allow distutils to be used to build the "standard" extension modules). This closes SF patch #547734. Index: sysconfig.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/sysconfig.py,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** sysconfig.py 31 Jan 2002 18:55:33 -0000 1.45 --- sysconfig.py 4 Jun 2002 15:28:21 -0000 1.46 *************** *** 24,40 **** EXEC_PREFIX = os.path.normpath(sys.exec_prefix) ! # Boolean; if it's true, we're still building Python, so ! # we use different (hard-wired) directories. ! ! python_build = 0 ! ! def set_python_build(): ! """Set the python_build flag to true. ! This means that we're building Python itself. Only called from ! the setup.py script shipped with Python. ! """ ! global python_build python_build = 1 --- 24,41 ---- EXEC_PREFIX = os.path.normpath(sys.exec_prefix) ! # python_build: (Boolean) if true, we're either building Python or ! # building an extension with an un-installed Python, so we use ! # different (hard-wired) directories. ! argv0_path = os.path.dirname(os.path.abspath(sys.executable)) ! landmark = os.path.join(argv0_path, "Modules", "Setup") ! if not os.path.isfile(landmark): ! python_build = 0 ! elif os.path.isfile(os.path.join(argv0_path, "Lib", "os.py")): python_build = 1 + else: + python_build = os.path.isfile(os.path.join(os.path.dirname(argv0_path), + "Lib", "os.py")) + del argv0_path, landmark *************** *** 54,58 **** if os.name == "posix": if python_build: ! return "Include/" return os.path.join(prefix, "include", "python" + sys.version[:3]) elif os.name == "nt": --- 55,66 ---- if os.name == "posix": if python_build: ! base = os.path.dirname(os.path.abspath(sys.executable)) ! if plat_specific: ! inc_dir = base ! else: ! inc_dir = os.path.join(base, "Include") ! if not os.path.exists(inc_dir): ! inc_dir = os.path.join(os.path.dirname(base), "Include") ! return inc_dir return os.path.join(prefix, "include", "python" + sys.version[:3]) elif os.name == "nt": *************** *** 164,168 **** """Return full pathname of installed Makefile from the Python build.""" if python_build: ! return './Makefile' lib_dir = get_python_lib(plat_specific=1, standard_lib=1) return os.path.join(lib_dir, "config", "Makefile") --- 172,176 ---- """Return full pathname of installed Makefile from the Python build.""" if python_build: ! return os.path.join(os.path.dirname(sys.executable), "Makefile") lib_dir = get_python_lib(plat_specific=1, standard_lib=1) return os.path.join(lib_dir, "config", "Makefile") From fdrake@users.sourceforge.net Tue Jun 4 17:25:59 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 04 Jun 2002 09:25:59 -0700 Subject: [Python-checkins] python/dist/src/Doc/ref ref3.tex,1.89,1.90 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv5033/ref Modified Files: ref3.tex Log Message: Fix up Guido's markup. Index: ref3.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref3.tex,v retrieving revision 1.89 retrieving revision 1.90 diff -C2 -d -r1.89 -r1.90 *** ref3.tex 3 Jun 2002 19:06:41 -0000 1.89 --- ref3.tex 4 Jun 2002 16:25:57 -0000 1.90 *************** *** 13,17 **** Every object has an identity, a type and a value. An object's \emph{identity} never changes once it has been created; you may think ! of it as the object's address in memory. The `\code{is}' operator compares the identity of two objects; the \function{id()}\bifuncindex{id} function returns an integer --- 13,17 ---- Every object has an identity, a type and a value. An object's \emph{identity} never changes once it has been created; you may think ! of it as the object's address in memory. The `\keyword{is}' operator compares the identity of two objects; the \function{id()}\bifuncindex{id} function returns an integer *************** *** 1541,1548 **** \item ! New-style classes (those derived from \code{object}) never invoke the ! \code{__coerce__} method in response to a binary operator; the only ! time \code{__coerce__} is invoked is when the built-in function ! \code{coerce()} is called. \item --- 1541,1548 ---- \item ! New-style classes (those derived from \class{object}) never invoke the ! \method{__coerce__()} method in response to a binary operator; the only ! time \method{__coerce__()} is invoked is when the built-in function ! \function{coerce()} is called. \item *************** *** 1566,1570 **** is tried. If this is not implemented or returns \code{NotImplemented}, \code{\var{y}.__rop__(\var{x})} is tried. If this is also not ! implemented or returns \code{NotImplemented}, a \code{TypeError} exception is raised. But see the following exception: --- 1566,1570 ---- is tried. If this is not implemented or returns \code{NotImplemented}, \code{\var{y}.__rop__(\var{x})} is tried. If this is also not ! implemented or returns \code{NotImplemented}, a \exception{TypeError} exception is raised. But see the following exception: *************** *** 1574,1579 **** a built-in type or a new-style class, and the right operand is an instance of a proper subclass of that type or class, the right ! operand's \code{__rop__} method is tried \emph{before} the left ! operand's \code{__op__} method. This is done so that a subclass can completely override binary operators. Otherwise, the left operand's __op__ method would always accept the right operand: when an instance --- 1574,1579 ---- a built-in type or a new-style class, and the right operand is an instance of a proper subclass of that type or class, the right ! operand's \method{__rop__()} method is tried \emph{before} the left ! operand's \method{__op__()} method. This is done so that a subclass can completely override binary operators. Otherwise, the left operand's __op__ method would always accept the right operand: when an instance *************** *** 1584,1598 **** When either operand type defines a coercion, this coercion is called ! before that type's \code{__op__} or \code{__rop__} method is called, ! but no sooner. If the coercion returns an object of a different type ! for the operand whose coercion is invoked, part of the process is ! redone using the new object. \item When an in-place operator (like `\code{+=}') is used, if the left ! operand implements \code{__iop__}, it is invoked without any coercion. ! When the operation falls back to \code{__op__} and/or \code{__rop__}, ! the normal coercion rules apply. \item --- 1584,1598 ---- When either operand type defines a coercion, this coercion is called ! before that type's \method{__op__()} or \method{__rop__()} method is ! called, but no sooner. If the coercion returns an object of a ! different type for the operand whose coercion is invoked, part of the ! process is redone using the new object. \item When an in-place operator (like `\code{+=}') is used, if the left ! operand implements \method{__iop__()}, it is invoked without any ! coercion. When the operation falls back to \method{__op__()} and/or ! \method{__rop__()}, the normal coercion rules apply. \item *************** *** 1605,1626 **** In \var{x}\code{*}\var{y}, if one operator is a sequence that implements sequence repetition, and the other is an integer ! (\code{int} or \code{long}), sequence repetition is invoked. \item ! Rich comparisons (implemented by methods \code{__eq__} and so on) never use coercion. Three-way comparison (implemented by ! \code{__cmp__}) does use coercion under the same conditions as other binary operations use it. \item ! In the current implementation, the built-in numeric types \code{int}, ! \code{long} and \code{float} do not use coercion; the type ! \code{complex} however does use it. The difference can become apparent when subclassing these types. Over time, the type ! \code{complex} may be fixed to avoid coercion. All these types ! implement a \code{__coerce__} method, for use by the built-in ! \code{coerce} function. \end{itemize} --- 1605,1626 ---- In \var{x}\code{*}\var{y}, if one operator is a sequence that implements sequence repetition, and the other is an integer ! (\class{int} or \class{long}), sequence repetition is invoked. \item ! Rich comparisons (implemented by methods \method{__eq__()} and so on) never use coercion. Three-way comparison (implemented by ! \method{__cmp__()}) does use coercion under the same conditions as other binary operations use it. \item ! In the current implementation, the built-in numeric types \class{int}, ! \class{long} and \class{float} do not use coercion; the type ! \class{complex} however does use it. The difference can become apparent when subclassing these types. Over time, the type ! \class{complex} may be fixed to avoid coercion. All these types ! implement a \method{__coerce__()} method, for use by the built-in ! \function{coerce()} function. \end{itemize} From fdrake@users.sourceforge.net Tue Jun 4 17:29:26 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 04 Jun 2002 09:29:26 -0700 Subject: [Python-checkins] python/dist/src/Doc/ref ref3.tex,1.82.4.2,1.82.4.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv7379/ref Modified Files: Tag: release22-maint ref3.tex Log Message: Backport Guido's changes from revision 1.89: Addressed SF bug 421973 (finally). Rewrote the subsection on coercion rules (and made it a proper subsection, with a label). The new section is much less precise, because precise rules would be too hard to give (== I don't know what they are any more :-). OTOH, the new section gives much more up-to-date information. Also noted that __coerce__ may return NotImplemented, with the same meaning as None. FLD: My modifications to Guido's markup are included from revision 1.90. Index: ref3.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref3.tex,v retrieving revision 1.82.4.2 retrieving revision 1.82.4.3 diff -C2 -d -r1.82.4.2 -r1.82.4.3 *** ref3.tex 13 May 2002 07:55:24 -0000 1.82.4.2 --- ref3.tex 4 Jun 2002 16:29:24 -0000 1.82.4.3 *************** *** 13,17 **** Every object has an identity, a type and a value. An object's \emph{identity} never changes once it has been created; you may think ! of it as the object's address in memory. The `\code{is}' operator compares the identity of two objects; the \function{id()}\bifuncindex{id} function returns an integer --- 13,17 ---- Every object has an identity, a type and a value. An object's \emph{identity} never changes once it has been created; you may think ! of it as the object's address in memory. The `\keyword{is}' operator compares the identity of two objects; the \function{id()}\bifuncindex{id} function returns an integer *************** *** 1488,1560 **** object to attempt a coercion (but sometimes, if the implementation of the other type cannot be changed, it is useful to do the conversion to ! the other type here). \end{methoddesc} ! \strong{Coercion rules}: to evaluate \var{x} \var{op} \var{y}, the ! following steps are taken (where \method{__\var{op}__()} and ! \method{__r\var{op}__()} are the method names corresponding to ! \var{op}, e.g., if \var{op} is `\code{+}', \method{__add__()} and ! \method{__radd__()} are used). If an exception occurs at any point, ! the evaluation is abandoned and exception handling takes over. \begin{itemize} ! \item[0.] If \var{x} is a string object and \var{op} is the modulo ! operator (\%), the string formatting operation is invoked and ! the remaining steps are skipped. ! \item[1.] If \var{x} is a class instance: ! \begin{itemize} ! \item[1a.] If \var{x} has a \method{__coerce__()} method: ! replace \var{x} and \var{y} with the 2-tuple returned by ! \code{\var{x}.__coerce__(\var{y})}; skip to step 2 if the ! coercion returns \code{None}. ! \item[1b.] If neither \var{x} nor \var{y} is a class instance ! after coercion, go to step 3. ! \item[1c.] If \var{x} has a method \method{__\var{op}__()}, return ! \code{\var{x}.__\var{op}__(\var{y})}; otherwise, restore \var{x} and ! \var{y} to their value before step 1a. ! \end{itemize} ! \item[2.] If \var{y} is a class instance: ! \begin{itemize} ! \item[2a.] If \var{y} has a \method{__coerce__()} method: ! replace \var{y} and \var{x} with the 2-tuple returned by ! \code{\var{y}.__coerce__(\var{x})}; skip to step 3 if the ! coercion returns \code{None}. ! \item[2b.] If neither \var{x} nor \var{y} is a class instance ! after coercion, go to step 3. ! \item[2b.] If \var{y} has a method \method{__r\var{op}__()}, ! return \code{\var{y}.__r\var{op}__(\var{x})}; otherwise, ! restore \var{x} and \var{y} to their value before step 2a. ! \end{itemize} ! \item[3.] We only get here if neither \var{x} nor \var{y} is a class ! instance. ! \begin{itemize} ! \item[3a.] If \var{op} is `\code{+}' and \var{x} is a ! sequence, sequence concatenation is invoked. ! \item[3b.] If \var{op} is `\code{*}' and one operand is a ! sequence and the other an integer, sequence repetition is ! invoked. ! \item[3c.] Otherwise, both operands must be numbers; they are ! coerced to a common type if possible, and the numeric ! operation is invoked for that type. ! \end{itemize} \end{itemize} --- 1488,1602 ---- object to attempt a coercion (but sometimes, if the implementation of the other type cannot be changed, it is useful to do the conversion to ! the other type here). A return value of \code{NotImplemented} is ! equivalent to returning \code{None}. \end{methoddesc} ! \subsection{Coercion rules\label{coercion-rules}} ! ! This section used to document the rules for coercion. As the language ! has evolved, the coercion rules have become hard to document ! precisely; documenting what one version of one particular ! implementation does is undesirable. Instead, here are some informal ! guidelines regarding coercion. In Python 3.0, coercion will not be ! supported. \begin{itemize} ! \item ! If the left operand of a \% operator is a string or Unicode object, no ! coercion takes place and the string formatting operation is invoked ! instead. ! \item ! It is no longer recommended to define a coercion operation. ! Mixed-mode operations on types that don't define coercion pass the ! original arguments to the operation. ! \item ! New-style classes (those derived from \class{object}) never invoke the ! \method{__coerce__()} method in response to a binary operator; the only ! time \method{__coerce__()} is invoked is when the built-in function ! \function{coerce()} is called. ! \item ! For most intents and purposes, an operator that returns ! \code{NotImplemented} is treated the same as one that is not ! implemented at all. ! \item ! Below, \method{__op__()} and \method{__rop__()} are used to signify ! the generic method names corresponding to an operator; ! \method{__iop__} is used for the corresponding in-place operator. For ! example, for the operator `\code{+}', \method{__add__()} and ! \method{__radd__()} are used for the left and right variant of the ! binary operator, and \method{__iadd__} for the in-place variant. ! \item ! For objects \var{x} and \var{y}, first \code{\var{x}.__op__(\var{y})} ! is tried. If this is not implemented or returns \code{NotImplemented}, ! \code{\var{y}.__rop__(\var{x})} is tried. If this is also not ! implemented or returns \code{NotImplemented}, a \exception{TypeError} ! exception is raised. But see the following exception: ! \item ! Exception to the previous item: if the left operand is an instance of ! a built-in type or a new-style class, and the right operand is an ! instance of a proper subclass of that type or class, the right ! operand's \method{__rop__()} method is tried \emph{before} the left ! operand's \method{__op__()} method. This is done so that a subclass can ! completely override binary operators. Otherwise, the left operand's ! __op__ method would always accept the right operand: when an instance ! of a given class is expected, an instance of a subclass of that class ! is always acceptable. ! \item ! When either operand type defines a coercion, this coercion is called ! before that type's \method{__op__()} or \method{__rop__()} method is ! called, but no sooner. If the coercion returns an object of a ! different type for the operand whose coercion is invoked, part of the ! process is redone using the new object. ! \item ! When an in-place operator (like `\code{+=}') is used, if the left ! operand implements \method{__iop__()}, it is invoked without any ! coercion. When the operation falls back to \method{__op__()} and/or ! \method{__rop__()}, the normal coercion rules apply. ! \item ! ! In \var{x}\code{+}\var{y}, if \var{x} is a sequence that implements ! sequence concatenation, sequence concatenation is invoked. ! ! \item ! ! In \var{x}\code{*}\var{y}, if one operator is a sequence that ! implements sequence repetition, and the other is an integer ! (\class{int} or \class{long}), sequence repetition is invoked. ! ! \item ! ! Rich comparisons (implemented by methods \method{__eq__()} and so on) ! never use coercion. Three-way comparison (implemented by ! \method{__cmp__()}) does use coercion under the same conditions as ! other binary operations use it. ! ! \item ! ! In the current implementation, the built-in numeric types \class{int}, ! \class{long} and \class{float} do not use coercion; the type ! \class{complex} however does use it. The difference can become ! apparent when subclassing these types. Over time, the type ! \class{complex} may be fixed to avoid coercion. All these types ! implement a \method{__coerce__()} method, for use by the built-in ! \function{coerce()} function. \end{itemize} From nnorwitz@users.sourceforge.net Tue Jun 4 17:57:46 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Tue, 04 Jun 2002 09:57:46 -0700 Subject: [Python-checkins] python/nondist/peps pep-0008.txt,1.13,1.14 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv25304 Modified Files: pep-0008.txt Log Message: Update for all the various ways of checking for a string/unicode object in 2.3, 2.2, 2.1/2.0. Index: pep-0008.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0008.txt,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** pep-0008.txt 29 May 2002 16:07:27 -0000 1.13 --- pep-0008.txt 4 Jun 2002 16:57:44 -0000 1.14 *************** *** 541,549 **** When checking if an object is a string, keep in mind that it ! might be a unicode string too! In Python 2.2, the types module ! has the StringTypes type defined for that purpose, e.g.: ! from types import StringTypes: if isinstance(strorunicodeobj, StringTypes): - For sequences, (strings, lists, tuples), use the fact that empty --- 541,560 ---- When checking if an object is a string, keep in mind that it ! might be a unicode string too! In Python 2.3, str and unicode ! have a common base class, basestring, so you can do: ! if isinstance(strorunicodeobj, basestring): ! ! In Python 2.2, the types module has the StringTypes type defined ! for that purpose, e.g.: ! ! from string import StringTypes if isinstance(strorunicodeobj, StringTypes): + + In Python 2.0 and 2.1, you should do: + + from string import StringType, UnicodeType + if isinstance(strorunicodeobj, StringType) or \ + isinstance(strorunicodeobj, UnicodeType) : - For sequences, (strings, lists, tuples), use the fact that empty From gvanrossum@users.sourceforge.net Tue Jun 4 18:02:10 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue, 04 Jun 2002 10:02:10 -0700 Subject: [Python-checkins] python/nondist/peps pep-0008.txt,1.14,1.15 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv28278 Modified Files: pep-0008.txt Log Message: Don't use 'strorunicodeobj' as the generic object name. Use just 'obj' -- after all, you don't know that it's a string or unicode object just yet, that's what the test in these examples is for! Index: pep-0008.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0008.txt,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** pep-0008.txt 4 Jun 2002 16:57:44 -0000 1.14 --- pep-0008.txt 4 Jun 2002 17:02:07 -0000 1.15 *************** *** 544,548 **** have a common base class, basestring, so you can do: ! if isinstance(strorunicodeobj, basestring): In Python 2.2, the types module has the StringTypes type defined --- 544,548 ---- have a common base class, basestring, so you can do: ! if isinstance(obj, basestring): In Python 2.2, the types module has the StringTypes type defined *************** *** 550,560 **** from string import StringTypes ! if isinstance(strorunicodeobj, StringTypes): In Python 2.0 and 2.1, you should do: from string import StringType, UnicodeType ! if isinstance(strorunicodeobj, StringType) or \ ! isinstance(strorunicodeobj, UnicodeType) : - For sequences, (strings, lists, tuples), use the fact that empty --- 550,560 ---- from string import StringTypes ! if isinstance(obj, StringTypes): In Python 2.0 and 2.1, you should do: from string import StringType, UnicodeType ! if isinstance(obj, StringType) or \ ! isinstance(obj, UnicodeType) : - For sequences, (strings, lists, tuples), use the fact that empty From nnorwitz@users.sourceforge.net Tue Jun 4 18:14:09 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Tue, 04 Jun 2002 10:14:09 -0700 Subject: [Python-checkins] python/dist/src/Modules _tkinter.c,1.124,1.125 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv2033/Modules Modified Files: _tkinter.c Log Message: Fix SF bug #557436, TclError is a str should be an Exception Make Tkinter.TclError derive from Exception, it was a string. Index: _tkinter.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_tkinter.c,v retrieving revision 1.124 retrieving revision 1.125 diff -C2 -d -r1.124 -r1.125 *** _tkinter.c 31 Mar 2002 14:44:22 -0000 1.124 --- _tkinter.c 4 Jun 2002 17:14:07 -0000 1.125 *************** *** 2124,2128 **** d = PyModule_GetDict(m); ! Tkinter_TclError = Py_BuildValue("s", "TclError"); PyDict_SetItemString(d, "TclError", Tkinter_TclError); --- 2124,2128 ---- d = PyModule_GetDict(m); ! Tkinter_TclError = PyErr_NewException("_tkinter.TclError", NULL, NULL); PyDict_SetItemString(d, "TclError", Tkinter_TclError); From nnorwitz@users.sourceforge.net Tue Jun 4 18:14:09 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Tue, 04 Jun 2002 10:14:09 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.414,1.415 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv2033/Misc Modified Files: NEWS Log Message: Fix SF bug #557436, TclError is a str should be an Exception Make Tkinter.TclError derive from Exception, it was a string. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.414 retrieving revision 1.415 diff -C2 -d -r1.414 -r1.415 *** NEWS 4 Jun 2002 15:16:28 -0000 1.414 --- NEWS 4 Jun 2002 17:14:07 -0000 1.415 *************** *** 125,128 **** --- 125,132 ---- Library + - Stop using strings for exceptions. String objects used for exceptions + now derive from Exception. The objects changed were: Tkinter.TclError, + bdb.BdbQuit, macpath.norm_error, tabnanny.NannyNag, and xdrlib.Error. + - Constants BOM_UTF8, BOM_UTF16, BOM_UTF16_LE, BOM_UTF16_BE, BOM_UTF32, BOM_UTF32_LE and BOM_UTF32_BE that represent the Byte From mwh@users.sourceforge.net Tue Jun 4 19:27:38 2002 From: mwh@users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue, 04 Jun 2002 11:27:38 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.415,1.416 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv3809 Modified Files: NEWS Log Message: Fiddle wording. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.415 retrieving revision 1.416 diff -C2 -d -r1.415 -r1.416 *** NEWS 4 Jun 2002 17:14:07 -0000 1.415 --- NEWS 4 Jun 2002 18:27:35 -0000 1.416 *************** *** 125,131 **** Library ! - Stop using strings for exceptions. String objects used for exceptions ! now derive from Exception. The objects changed were: Tkinter.TclError, ! bdb.BdbQuit, macpath.norm_error, tabnanny.NannyNag, and xdrlib.Error. - Constants BOM_UTF8, BOM_UTF16, BOM_UTF16_LE, BOM_UTF16_BE, --- 125,132 ---- Library ! - Stop using strings for exceptions. String objects used for ! exceptions are now classes deriving from Exception. The objects ! changed were: Tkinter.TclError, bdb.BdbQuit, macpath.norm_error, ! tabnanny.NannyNag, and xdrlib.Error. - Constants BOM_UTF8, BOM_UTF16, BOM_UTF16_LE, BOM_UTF16_BE, From rhettinger@users.sourceforge.net Tue Jun 4 19:45:52 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue, 04 Jun 2002 11:45:52 -0700 Subject: [Python-checkins] python/dist/src/Objects rangeobject.c,2.36,2.37 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv9372 Modified Files: rangeobject.c Log Message: Inverted test for small speedup Index: rangeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/rangeobject.c,v retrieving revision 2.36 retrieving revision 2.37 diff -C2 -d -r2.36 -r2.37 *** rangeobject.c 8 May 2002 08:49:27 -0000 2.36 --- rangeobject.c 4 Jun 2002 18:45:50 -0000 2.37 *************** *** 117,125 **** range_next(rangeobject *r) { ! if (r->index >= r->len) { ! PyErr_SetObject(PyExc_StopIteration, Py_None); ! return NULL; ! } ! return PyInt_FromLong(r->start + (r->index++) * r->step); } --- 117,124 ---- range_next(rangeobject *r) { ! if (r->index < r->len) ! return PyInt_FromLong(r->start + (r->index++) * r->step); ! PyErr_SetObject(PyExc_StopIteration, Py_None); ! return NULL; } From jhylton@users.sourceforge.net Tue Jun 4 19:55:56 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 04 Jun 2002 11:55:56 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils dep_util.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv11844 Modified Files: dep_util.py Log Message: The comment said: # XXX this isn't used anywhere, and worse, it has the same name as a method # in Command with subtly different semantics. (This one just has one # source -> one dest; that one has many sources -> one dest.) Nuke it? Yes. Nuke it. Index: dep_util.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/dep_util.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** dep_util.py 6 Dec 2001 20:51:35 -0000 1.3 --- dep_util.py 4 Jun 2002 18:55:54 -0000 1.4 *************** *** 94,115 **** # newer_group () - - - # XXX this isn't used anywhere, and worse, it has the same name as a method - # in Command with subtly different semantics. (This one just has one - # source -> one dest; that one has many sources -> one dest.) Nuke it? - def make_file (src, dst, func, args, - verbose=0, update_message=None, noupdate_message=None): - """Makes 'dst' from 'src' (both filenames) by calling 'func' with - 'args', but only if it needs to: i.e. if 'dst' does not exist or 'src' - is newer than 'dst'. - """ - if newer(src, dst): - if verbose and update_message: - print update_message - apply(func, args) - else: - if verbose and noupdate_message: - print noupdate_message - - # make_file () --- 94,95 ---- From gvanrossum@users.sourceforge.net Tue Jun 4 20:52:55 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue, 04 Jun 2002 12:52:55 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.416,1.417 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv31651/Misc Modified Files: NEWS Log Message: Address SF bug 519621: slots weren't traversed by GC. While I was at it, I added a tp_clear handler and changed the tp_dealloc handler to use the clear_slots helper for the tp_clear handler. Also tightened the rules for slot names: they must now be proper identifiers (ignoring the dirty little fact that is locale sensitive). Also set mp->flags = READONLY for the __weakref__ pseudo-slot. Most of this is a 2.2 bugfix candidate; I'll apply it there myself. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.416 retrieving revision 1.417 diff -C2 -d -r1.416 -r1.417 *** NEWS 4 Jun 2002 18:27:35 -0000 1.416 --- NEWS 4 Jun 2002 19:52:48 -0000 1.417 *************** *** 7,10 **** --- 7,16 ---- Core and builtins + - Classes using __slots__ are now properly garbage collected. + [SF bug 519621] + + - Tightened the __slots__ rules: a slot name must be a valid Python + identifier. + - The constructor for the module type now requires a name argument and takes an optional docstring argument. Previously, this constructor From gvanrossum@users.sourceforge.net Tue Jun 4 20:52:55 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue, 04 Jun 2002 12:52:55 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_descr.py,1.137,1.138 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv31651/Lib/test Modified Files: test_descr.py Log Message: Address SF bug 519621: slots weren't traversed by GC. While I was at it, I added a tp_clear handler and changed the tp_dealloc handler to use the clear_slots helper for the tp_clear handler. Also tightened the rules for slot names: they must now be proper identifiers (ignoring the dirty little fact that is locale sensitive). Also set mp->flags = READONLY for the __weakref__ pseudo-slot. Most of this is a 2.2 bugfix candidate; I'll apply it there myself. Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.137 retrieving revision 1.138 diff -C2 -d -r1.137 -r1.138 *** test_descr.py 4 Jun 2002 06:10:37 -0000 1.137 --- test_descr.py 4 Jun 2002 19:52:53 -0000 1.138 *************** *** 1061,1064 **** --- 1061,1103 ---- vereq(x.c, 3) + # Make sure slot names are proper identifiers + try: + class C(object): + __slots__ = [None] + except TypeError: + pass + else: + raise TestFailed, "[None] slots not caught" + try: + class C(object): + __slots__ = ["foo bar"] + except TypeError: + pass + else: + raise TestFailed, "['foo bar'] slots not caught" + try: + class C(object): + __slots__ = ["foo\0bar"] + except TypeError: + pass + else: + raise TestFailed, "['foo\\0bar'] slots not caught" + try: + class C(object): + __slots__ = ["1"] + except TypeError: + pass + else: + raise TestFailed, "['1'] slots not caught" + try: + class C(object): + __slots__ = [""] + except TypeError: + pass + else: + raise TestFailed, "[''] slots not caught" + class C(object): + __slots__ = ["a", "a_b", "_a", "A0123456789Z"] + # Test leaks class Counted(object): *************** *** 1093,1096 **** --- 1132,1147 ---- vereq(Counted.counter, 3) del x + vereq(Counted.counter, 0) + + # Test cyclical leaks [SF bug 519621] + class F(object): + __slots__ = ['a', 'b'] + log = [] + s = F() + s.a = [Counted(), s] + vereq(Counted.counter, 1) + s = None + import gc + gc.collect() vereq(Counted.counter, 0) From gvanrossum@users.sourceforge.net Tue Jun 4 20:52:55 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue, 04 Jun 2002 12:52:55 -0700 Subject: [Python-checkins] python/dist/src/Objects typeobject.c,2.147,2.148 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv31651/Objects Modified Files: typeobject.c Log Message: Address SF bug 519621: slots weren't traversed by GC. While I was at it, I added a tp_clear handler and changed the tp_dealloc handler to use the clear_slots helper for the tp_clear handler. Also tightened the rules for slot names: they must now be proper identifiers (ignoring the dirty little fact that is locale sensitive). Also set mp->flags = READONLY for the __weakref__ pseudo-slot. Most of this is a 2.2 bugfix candidate; I'll apply it there myself. Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.147 retrieving revision 2.148 diff -C2 -d -r2.147 -r2.148 *** typeobject.c 3 Jun 2002 19:52:41 -0000 2.147 --- typeobject.c 4 Jun 2002 19:52:53 -0000 2.148 *************** *** 4,7 **** --- 4,21 ---- #include "structmember.h" + #include + + /* The *real* layout of a type object when allocated on the heap */ + /* XXX Should we publish this in a header file? */ + typedef struct { + PyTypeObject type; + PyNumberMethods as_number; + PySequenceMethods as_sequence; + PyMappingMethods as_mapping; + PyBufferProcs as_buffer; + PyObject *name, *slots; + PyMemberDef members[1]; + } etype; + static PyMemberDef type_members[] = { {"__basicsize__", T_INT, offsetof(PyTypeObject,tp_basicsize),READONLY}, *************** *** 227,240 **** static int subtype_traverse(PyObject *self, visitproc visit, void *arg) { PyTypeObject *type, *base; ! traverseproc f; ! int err; ! /* Find the nearest base with a different tp_traverse */ type = self->ob_type; ! base = type->tp_base; ! while ((f = base->tp_traverse) == subtype_traverse) { base = base->tp_base; assert(base); --- 241,281 ---- static int + traverse_slots(PyTypeObject *type, PyObject *self, visitproc visit, void *arg) + { + int i, n; + PyMemberDef *mp; + + n = type->ob_size; + mp = ((etype *)type)->members; + for (i = 0; i < n; i++, mp++) { + if (mp->type == T_OBJECT_EX) { + char *addr = (char *)self + mp->offset; + PyObject *obj = *(PyObject **)addr; + if (obj != NULL) { + int err = visit(obj, arg); + if (err) + return err; + } + } + } + return 0; + } + + static int subtype_traverse(PyObject *self, visitproc visit, void *arg) { PyTypeObject *type, *base; ! traverseproc basetraverse; ! /* Find the nearest base with a different tp_traverse, ! and traverse slots while we're at it */ type = self->ob_type; ! base = type; ! while ((basetraverse = base->tp_traverse) == subtype_traverse) { ! if (base->ob_size) { ! int err = traverse_slots(base, self, visit, arg); ! if (err) ! return err; ! } base = base->tp_base; assert(base); *************** *** 244,248 **** PyObject **dictptr = _PyObject_GetDictPtr(self); if (dictptr && *dictptr) { ! err = visit(*dictptr, arg); if (err) return err; --- 285,289 ---- PyObject **dictptr = _PyObject_GetDictPtr(self); if (dictptr && *dictptr) { ! int err = visit(*dictptr, arg); if (err) return err; *************** *** 250,255 **** } ! if (f) ! return f(self, visit, arg); return 0; } --- 291,345 ---- } ! if (basetraverse) ! return basetraverse(self, visit, arg); ! return 0; ! } ! ! static void ! clear_slots(PyTypeObject *type, PyObject *self) ! { ! int i, n; ! PyMemberDef *mp; ! ! n = type->ob_size; ! mp = ((etype *)type)->members; ! for (i = 0; i < n; i++, mp++) { ! if (mp->type == T_OBJECT_EX && !(mp->flags & READONLY)) { ! char *addr = (char *)self + mp->offset; ! PyObject *obj = *(PyObject **)addr; ! if (obj != NULL) { ! Py_DECREF(obj); ! *(PyObject **)addr = NULL; ! } ! } ! } ! } ! ! static int ! subtype_clear(PyObject *self) ! { ! PyTypeObject *type, *base; ! inquiry baseclear; ! ! /* Find the nearest base with a different tp_clear ! and clear slots while we're at it */ ! type = self->ob_type; ! base = type; ! while ((baseclear = base->tp_clear) == subtype_clear) { ! if (base->ob_size) ! clear_slots(base, self); ! base = base->tp_base; ! assert(base); ! } ! ! if (type->tp_dictoffset != base->tp_dictoffset) { ! PyObject **dictptr = _PyObject_GetDictPtr(self); ! if (dictptr && *dictptr) { ! PyDict_Clear(*dictptr); ! } ! } ! ! if (baseclear) ! return baseclear(self); return 0; } *************** *** 330,334 **** { PyTypeObject *type, *base; ! destructor f; /* This exists so we can DECREF self->ob_type */ --- 420,424 ---- { PyTypeObject *type, *base; ! destructor basedealloc; /* This exists so we can DECREF self->ob_type */ *************** *** 337,368 **** return; ! /* Find the nearest base with a different tp_dealloc */ type = self->ob_type; ! base = type->tp_base; ! while ((f = base->tp_dealloc) == subtype_dealloc) { base = base->tp_base; assert(base); } - /* Clear __slots__ variables */ - if (type->tp_basicsize != base->tp_basicsize && - type->tp_itemsize == 0) - { - char *addr = ((char *)self); - char *p = addr + base->tp_basicsize; - char *q = addr + type->tp_basicsize; - for (; p < q; p += sizeof(PyObject *)) { - PyObject **pp; - if (p == addr + type->tp_dictoffset || - p == addr + type->tp_weaklistoffset) - continue; - pp = (PyObject **)p; - if (*pp != NULL) { - Py_DECREF(*pp); - *pp = NULL; - } - } - } - /* If we added a dict, DECREF it */ if (type->tp_dictoffset && !base->tp_dictoffset) { --- 427,441 ---- return; ! /* Find the nearest base with a different tp_dealloc ! and clear slots while we're at it */ type = self->ob_type; ! base = type; ! while ((basedealloc = base->tp_dealloc) == subtype_dealloc) { ! if (base->ob_size) ! clear_slots(base, self); base = base->tp_base; assert(base); } /* If we added a dict, DECREF it */ if (type->tp_dictoffset && !base->tp_dictoffset) { *************** *** 386,391 **** /* Call the base tp_dealloc() */ ! assert(f); ! f(self); /* Can't reference self beyond this point */ --- 459,464 ---- /* Call the base tp_dealloc() */ ! assert(basedealloc); ! basedealloc(self); /* Can't reference self beyond this point */ *************** *** 397,410 **** staticforward PyTypeObject *solid_base(PyTypeObject *type); - typedef struct { - PyTypeObject type; - PyNumberMethods as_number; - PySequenceMethods as_sequence; - PyMappingMethods as_mapping; - PyBufferProcs as_buffer; - PyObject *name, *slots; - PyMemberDef members[1]; - } etype; - /* type test with subclassing support */ --- 470,473 ---- *************** *** 891,894 **** --- 954,984 ---- static PyObject *bozo_obj = NULL; + static int + valid_identifier(PyObject *s) + { + char *p; + int i, n; + + if (!PyString_Check(s)) { + PyErr_SetString(PyExc_TypeError, + "__slots__ must be strings"); + return 0; + } + p = PyString_AS_STRING(s); + n = PyString_GET_SIZE(s); + /* We must reject an empty name. As a hack, we bump the + length to 1 so that the loop will balk on the trailing \0. */ + if (n == 0) + n = 1; + for (i = 0; i < n; i++, p++) { + if (!(i == 0 ? isalpha(*p) : isalnum(*p)) && *p != '_') { + PyErr_SetString(PyExc_TypeError, + "__slots__ must be identifiers"); + return 0; + } + } + return 1; + } + static PyObject * type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds) *************** *** 1005,1015 **** } for (i = 0; i < nslots; i++) { ! if (!PyString_Check(PyTuple_GET_ITEM(slots, i))) { ! PyErr_SetString(PyExc_TypeError, ! "__slots__ must be a sequence of strings"); Py_DECREF(slots); return NULL; } - /* XXX Check against null bytes in name */ } } --- 1095,1102 ---- } for (i = 0; i < nslots; i++) { ! if (!valid_identifier(PyTuple_GET_ITEM(slots, i))) { Py_DECREF(slots); return NULL; } } } *************** *** 1146,1149 **** --- 1233,1237 ---- strcmp(mp->name, "__weakref__") == 0) { mp->type = T_OBJECT; + mp->flags = READONLY; type->tp_weaklistoffset = slotoffset; } *************** *** 1195,1199 **** type->tp_free = PyObject_GC_Del; type->tp_traverse = subtype_traverse; ! type->tp_clear = base->tp_clear; } else --- 1283,1287 ---- type->tp_free = PyObject_GC_Del; type->tp_traverse = subtype_traverse; ! type->tp_clear = subtype_clear; } else From jhylton@users.sourceforge.net Tue Jun 4 21:00:29 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 04 Jun 2002 13:00:29 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils log.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv1780 Added Files: log.py Log Message: A simple log mechanism styled after the proposed std library module --- NEW FILE: log.py --- """A simple log mechanism styled after PEP 282.""" # The class here is styled after PEP 282 so that it could later be # replaced with a standard Python logging implementation. DEBUG = 1 INFO = 2 WARN = 3 ERROR = 4 FATAL = 5 class Log: def __init__(self, threshold=WARN): self.threshold = threshold def _log(self, level, msg, args): if level >= self.threshold: print msg % args def log(self, level, msg, *args): self._log(level, msg, args) def debug(self, msg, *args): self._log(DEBUG, msg, args) def info(self, msg, *args): self._log(INFO, msg, args) def warn(self, msg, *args): self._log(WARN, msg, args) def error(self, msg, *args): self._log(ERROR, msg, args) def fatal(self, msg, *args): self._log(FATAL, msg, args) _global_log = Log() log = _global_log.log debug = _global_log.debug info = _global_log.info warn = _global_log.warn error = _global_log.error fatal = _global_log.fatal def set_threshold(level): _global_log.threshold = level def set_verbosity(v): if v == 0: set_threshold(WARN) if v == 1: set_threshold(INFO) if v == 2: set_threshold(DEBUG) From jhylton@users.sourceforge.net Tue Jun 4 21:14:45 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 04 Jun 2002 13:14:45 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils/command bdist_dumb.py,1.19,1.20 bdist_packager.py,1.2,1.3 bdist_pkgtool.py,1.2,1.3 bdist_rpm.py,1.28,1.29 bdist_sdux.py,1.1,1.2 bdist_wininst.py,1.31,1.32 build_clib.py,1.24,1.25 build_ext.py,1.80,1.81 build_py.py,1.37,1.38 build_scripts.py,1.15,1.16 clean.py,1.12,1.13 config.py,1.10,1.11 install_lib.py,1.39,1.40 install_scripts.py,1.11,1.12 sdist.py,1.53,1.54 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory usw-pr-cvs1:/tmp/cvs-serv6520/command Modified Files: bdist_dumb.py bdist_packager.py bdist_pkgtool.py bdist_rpm.py bdist_sdux.py bdist_wininst.py build_clib.py build_ext.py build_py.py build_scripts.py clean.py config.py install_lib.py install_scripts.py sdist.py Log Message: Make setup.py less chatty by default. This is a conservative version of SF patch 504889. It uses the log module instead of calling print in various places, and it ignores the verbose argument passed to many functions and set as an attribute on some objects. Instead, it uses the verbosity set on the logger via the command line. The log module is now preferred over announce() and warn() methods that exist only for backwards compatibility. XXX This checkin changes a lot of modules that have no test suite and aren't exercised by the Python build process. It will need substantial testing. Index: bdist_dumb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_dumb.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** bdist_dumb.py 9 Apr 2002 14:14:38 -0000 1.19 --- bdist_dumb.py 4 Jun 2002 20:14:42 -0000 1.20 *************** *** 14,17 **** --- 14,18 ---- from distutils.dir_util import create_tree, remove_tree from distutils.errors import * + from distutils import log class bdist_dumb (Command): *************** *** 84,88 **** install.warn_dir = 0 ! self.announce("installing to %s" % self.bdist_dir) self.run_command('install') --- 85,89 ---- install.warn_dir = 0 ! log.info("installing to %s" % self.bdist_dir) self.run_command('install') *************** *** 102,106 **** if not self.keep_temp: ! remove_tree(self.bdist_dir, self.verbose, self.dry_run) # run() --- 103,107 ---- if not self.keep_temp: ! remove_tree(self.bdist_dir, dry_run=self.dry_run) # run() Index: bdist_packager.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_packager.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** bdist_packager.py 23 Apr 2002 18:18:43 -0000 1.2 --- bdist_packager.py 4 Jun 2002 20:14:42 -0000 1.3 *************** *** 15,18 **** --- 15,19 ---- from distutils.file_util import write_file from distutils.errors import * + from distutils import log import string, sys *************** *** 103,108 **** setattr(self,attr,default) val = default ! if val!="": ! self.announce('Creating %s script', attr) self.execute(write_file, (path, self.get_script(attr)), --- 104,109 ---- setattr(self,attr,default) val = default ! if val != "": ! log.info('Creating %s script', attr) self.execute(write_file, (path, self.get_script(attr)), *************** *** 235,239 **** install.root = self.pkg_dir ! self.announce("installing to %s" % self.pkg_dir) self.run_command('install') --- 236,240 ---- install.root = self.pkg_dir ! log.info("installing to %s", self.pkg_dir) self.run_command('install') *************** *** 244,248 **** if not self.keep_temp: ! remove_tree(self.pkg_dir, self.verbose, self.dry_run) # run() --- 245,249 ---- if not self.keep_temp: ! remove_tree(self.pkg_dir, dry_run=self.dry_run) # run() Index: bdist_pkgtool.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_pkgtool.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** bdist_pkgtool.py 23 Apr 2002 18:18:43 -0000 1.2 --- bdist_pkgtool.py 4 Jun 2002 20:14:43 -0000 1.3 *************** *** 16,19 **** --- 16,20 ---- from distutils.command import bdist_packager from distutils import sysconfig + from distutils import log import compileall from commands import getoutput *************** *** 212,218 **** install = self.reinitialize_command('install', reinit_subcommands=1) # build package ! self.announce('Building package') self.run_command('build') ! self.announce('Creating pkginfo file') path = os.path.join(pkg_dir, "pkginfo") self.execute(write_file, --- 213,219 ---- install = self.reinitialize_command('install', reinit_subcommands=1) # build package ! log.info('Building package') self.run_command('build') ! log.info('Creating pkginfo file') path = os.path.join(pkg_dir, "pkginfo") self.execute(write_file, *************** *** 245,249 **** 'depend',None) ! self.announce('Creating prototype file') path = os.path.join(pkg_dir, "prototype") self.execute(write_file, --- 246,250 ---- 'depend',None) ! log.info('Creating prototype file') path = os.path.join(pkg_dir, "prototype") self.execute(write_file, *************** *** 257,261 **** ! self.announce('Creating package') pkg_cmd = ['pkgmk', '-o', '-f'] pkg_cmd.append(path) --- 258,262 ---- ! log.info('Creating package') pkg_cmd = ['pkgmk', '-o', '-f'] pkg_cmd.append(path) *************** *** 266,270 **** path = os.path.join(os.environ['PWD'],pkg_dir, self.get_binary_name() + ".pkg") ! self.announce('Transferring package to ' + pkg_dir) pkg_cmd.append(path) pkg_cmd.append(self.pkg_abrev) --- 267,271 ---- path = os.path.join(os.environ['PWD'],pkg_dir, self.get_binary_name() + ".pkg") ! log.info('Transferring package to ' + pkg_dir) pkg_cmd.append(path) pkg_cmd.append(self.pkg_abrev) *************** *** 327,331 **** request=string.split(DEFAULT_REQUEST,"\012") else: ! self.announce('Creating relocation request script') if self.request: users_request=self.get_script('request') --- 328,332 ---- request=string.split(DEFAULT_REQUEST,"\012") else: ! log.info('Creating relocation request script') if self.request: users_request=self.get_script('request') Index: bdist_rpm.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_rpm.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** bdist_rpm.py 21 Mar 2002 23:27:54 -0000 1.28 --- bdist_rpm.py 4 Jun 2002 20:14:43 -0000 1.29 *************** *** 15,18 **** --- 15,19 ---- from distutils.file_util import write_file from distutils.errors import * + from distutils import log class bdist_rpm (Command): *************** *** 279,283 **** # build package ! self.announce('building RPMs') rpm_cmd = ['rpm'] if self.source_only: # what kind of RPMs? --- 280,284 ---- # build package ! log.info("building RPMs") rpm_cmd = ['rpm'] if self.source_only: # what kind of RPMs? Index: bdist_sdux.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_sdux.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** bdist_sdux.py 17 Apr 2002 20:30:10 -0000 1.1 --- bdist_sdux.py 4 Jun 2002 20:14:43 -0000 1.2 *************** *** 15,18 **** --- 15,19 ---- from distutils.errors import * from distutils.command import bdist_packager + from distutils import log import sys from commands import getoutput *************** *** 186,192 **** "%s.psf" % self.get_binary_name()) # build package ! self.announce('Building package') self.run_command('build') ! self.announce('Creating psf file') self.execute(write_file, (psf_path, --- 187,193 ---- "%s.psf" % self.get_binary_name()) # build package ! log.info('Building package') self.run_command('build') ! log.info('Creating psf file') self.execute(write_file, (psf_path, *************** *** 196,200 **** return ! self.announce('Creating package') spawn_cmd = ['swpackage', '-s'] spawn_cmd.append(psf_path) --- 197,201 ---- return ! log.info('Creating package') spawn_cmd = ['swpackage', '-s'] spawn_cmd.append(psf_path) Index: bdist_wininst.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_wininst.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** bdist_wininst.py 9 Apr 2002 14:14:38 -0000 1.31 --- bdist_wininst.py 4 Jun 2002 20:14:43 -0000 1.32 *************** *** 13,16 **** --- 13,17 ---- from distutils.dir_util import create_tree, remove_tree from distutils.errors import * + from distutils import log class bdist_wininst (Command): *************** *** 116,120 **** value) ! self.announce("installing to %s" % self.bdist_dir) install.ensure_finalized() --- 117,121 ---- value) ! log.info("installing to %s", self.bdist_dir) install.ensure_finalized() *************** *** 137,145 **** self.create_exe(arcname, fullname, self.bitmap) # remove the zip-file again ! self.announce("removing temporary file '%s'" % arcname) os.remove(arcname) if not self.keep_temp: ! remove_tree(self.bdist_dir, self.verbose, self.dry_run) # run() --- 138,146 ---- self.create_exe(arcname, fullname, self.bitmap) # remove the zip-file again ! log.debug("removing temporary file '%s'", arcname) os.remove(arcname) if not self.keep_temp: ! remove_tree(self.bdist_dir, dry_run=self.dry_run) # run() Index: build_clib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/build_clib.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** build_clib.py 6 Dec 2001 20:59:17 -0000 1.24 --- build_clib.py 4 Jun 2002 20:14:43 -0000 1.25 *************** *** 25,29 **** from distutils.errors import * from distutils.sysconfig import customize_compiler ! def show_compilers (): --- 25,29 ---- from distutils.errors import * from distutils.sysconfig import customize_compiler ! from distutils import log def show_compilers (): *************** *** 112,116 **** from distutils.ccompiler import new_compiler self.compiler = new_compiler(compiler=self.compiler, - verbose=self.verbose, dry_run=self.dry_run, force=self.force) --- 112,115 ---- *************** *** 214,218 **** sources = list(sources) ! self.announce("building '%s' library" % lib_name) # First, compile the source code to object files in the library --- 213,217 ---- sources = list(sources) ! log.info("building '%s' library", lib_name) # First, compile the source code to object files in the library Index: build_ext.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/build_ext.py,v retrieving revision 1.80 retrieving revision 1.81 diff -C2 -d -r1.80 -r1.81 *** build_ext.py 25 Apr 2002 17:26:37 -0000 1.80 --- build_ext.py 4 Jun 2002 20:14:43 -0000 1.81 *************** *** 16,19 **** --- 16,20 ---- from distutils.dep_util import newer_group from distutils.extension import Extension + from distutils import log # An extension name is just a dot-separated list of Python NAMEs (ie. *************** *** 292,298 **** (ext_name, build_info) = ext ! self.warn(("old-style (ext_name, build_info) tuple found in " ! "ext_modules for extension '%s'" ! "-- please convert to Extension instance" % ext_name)) if type(ext) is not TupleType and len(ext) != 2: raise DistutilsSetupError, \ --- 293,299 ---- (ext_name, build_info) = ext ! log.warn(("old-style (ext_name, build_info) tuple found in " ! "ext_modules for extension '%s'" ! "-- please convert to Extension instance" % ext_name)) if type(ext) is not TupleType and len(ext) != 2: raise DistutilsSetupError, \ *************** *** 330,335 **** ext.runtime_library_dirs = build_info.get('rpath') if build_info.has_key('def_file'): ! self.warn("'def_file' element of build info dict " ! "no longer supported") # Non-trivial stuff: 'macros' split into 'define_macros' --- 331,336 ---- ext.runtime_library_dirs = build_info.get('rpath') if build_info.has_key('def_file'): ! log.warn("'def_file' element of build info dict " ! "no longer supported") # Non-trivial stuff: 'macros' split into 'define_macros' *************** *** 423,431 **** if not (self.force or newer_group(sources, ext_filename, 'newer')): ! self.announce("skipping '%s' extension (up-to-date)" % ! ext.name) return else: ! self.announce("building '%s' extension" % ext.name) # First, scan the sources for SWIG definition files (.i), run --- 424,431 ---- if not (self.force or newer_group(sources, ext_filename, 'newer')): ! log.debug("skipping '%s' extension (up-to-date)", ext.name) return else: ! log.info("building '%s' extension", ext.name) # First, scan the sources for SWIG definition files (.i), run *************** *** 540,544 **** for source in swig_sources: target = swig_targets[source] ! self.announce("swigging %s to %s" % (source, target)) self.spawn(swig_cmd + ["-o", target, source]) --- 540,544 ---- for source in swig_sources: target = swig_targets[source] ! log.info("swigging %s to %s", source, target) self.spawn(swig_cmd + ["-o", target, source]) Index: build_py.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/build_py.py,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** build_py.py 4 Apr 2002 23:17:31 -0000 1.37 --- build_py.py 4 Jun 2002 20:14:43 -0000 1.38 *************** *** 14,18 **** from distutils.errors import * from distutils.util import convert_path ! class build_py (Command): --- 14,18 ---- from distutils.errors import * from distutils.util import convert_path ! from distutils import log class build_py (Command): *************** *** 177,182 **** return init_py else: ! self.warn(("package init file '%s' not found " + ! "(or not a regular file)") % init_py) # Either not in a package at all (__init__.py not expected), or --- 177,182 ---- return init_py else: ! log.warn(("package init file '%s' not found " + ! "(or not a regular file)"), init_py) # Either not in a package at all (__init__.py not expected), or *************** *** 189,194 **** def check_module (self, module, module_file): if not os.path.isfile(module_file): ! self.warn("file %s (for module %s) not found" % ! (module_file, module)) return 0 else: --- 189,193 ---- def check_module (self, module, module_file): if not os.path.isfile(module_file): ! log.warn("file %s (for module %s) not found", module_file, module) return 0 else: *************** *** 390,401 **** if self.compile: byte_compile(files, optimize=0, ! force=self.force, ! prefix=prefix, ! verbose=self.verbose, dry_run=self.dry_run) if self.optimize > 0: byte_compile(files, optimize=self.optimize, ! force=self.force, ! prefix=prefix, ! verbose=self.verbose, dry_run=self.dry_run) # class build_py --- 389,396 ---- if self.compile: byte_compile(files, optimize=0, ! force=self.force, prefix=prefix, dry_run=self.dry_run) if self.optimize > 0: byte_compile(files, optimize=self.optimize, ! force=self.force, prefix=prefix, dry_run=self.dry_run) # class build_py Index: build_scripts.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/build_scripts.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** build_scripts.py 28 Feb 2002 09:16:21 -0000 1.15 --- build_scripts.py 4 Jun 2002 20:14:43 -0000 1.16 *************** *** 12,15 **** --- 12,16 ---- from distutils.dep_util import newer from distutils.util import convert_path + from distutils import log # check if Python is called on the first line with this expression *************** *** 60,64 **** if not self.force and not newer(script, outfile): ! self.announce("not copying %s (up-to-date)" % script) continue --- 61,65 ---- if not self.force and not newer(script, outfile): ! log.debug("not copying %s (up-to-date)", script) continue *************** *** 84,89 **** if adjust: ! self.announce("copying and adjusting %s -> %s" % ! (script, self.build_dir)) if not self.dry_run: outf = open(outfile, "w") --- 85,90 ---- if adjust: ! log.info("copying and adjusting %s -> %s", script, ! self.build_dir) if not self.dry_run: outf = open(outfile, "w") Index: clean.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/clean.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** clean.py 14 Oct 2000 04:06:40 -0000 1.12 --- clean.py 4 Jun 2002 20:14:43 -0000 1.13 *************** *** 10,13 **** --- 10,14 ---- from distutils.core import Command from distutils.dir_util import remove_tree + from distutils import log class clean (Command): *************** *** 52,59 **** # gone) if os.path.exists(self.build_temp): ! remove_tree(self.build_temp, self.verbose, self.dry_run) else: ! self.warn("'%s' does not exist -- can't clean it" % ! self.build_temp) if self.all: --- 53,60 ---- # gone) if os.path.exists(self.build_temp): ! remove_tree(self.build_temp, dry_run=self.dry_run) else: ! log.warn("'%s' does not exist -- can't clean it", ! self.build_temp) if self.all: *************** *** 63,70 **** self.build_scripts): if os.path.exists(directory): ! remove_tree(directory, self.verbose, self.dry_run) else: ! self.warn("'%s' does not exist -- can't clean it" % ! directory) # just for the heck of it, try to remove the base build directory: --- 64,71 ---- self.build_scripts): if os.path.exists(directory): ! remove_tree(directory, dry_run=self.dry_run) else: ! log.warn("'%s' does not exist -- can't clean it", ! directory) # just for the heck of it, try to remove the base build directory: *************** *** 73,77 **** try: os.rmdir(self.build_base) ! self.announce("removing '%s'" % self.build_base) except OSError: pass --- 74,78 ---- try: os.rmdir(self.build_base) ! log.info("removing '%s'", self.build_base) except OSError: pass Index: config.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/config.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** config.py 6 Dec 2001 20:57:12 -0000 1.10 --- config.py 4 Jun 2002 20:14:43 -0000 1.11 *************** *** 18,22 **** from distutils.core import Command from distutils.errors import DistutilsExecError ! LANG_EXT = {'c': '.c', --- 18,22 ---- from distutils.core import Command from distutils.errors import DistutilsExecError ! from distutils import log LANG_EXT = {'c': '.c', *************** *** 104,110 **** if not isinstance(self.compiler, CCompiler): self.compiler = new_compiler(compiler=self.compiler, ! verbose=self.noisy, ! dry_run=self.dry_run, ! force=1) if self.include_dirs: self.compiler.set_include_dirs(self.include_dirs) --- 104,108 ---- if not isinstance(self.compiler, CCompiler): self.compiler = new_compiler(compiler=self.compiler, ! dry_run=self.dry_run, force=1) if self.include_dirs: self.compiler.set_include_dirs(self.include_dirs) *************** *** 162,166 **** filenames = self.temp_files self.temp_files = [] ! self.announce("removing: " + string.join(filenames)) for filename in filenames: try: --- 160,164 ---- filenames = self.temp_files self.temp_files = [] ! log.info("removing: %s", string.join(filenames)) for filename in filenames: try: *************** *** 240,244 **** ok = 0 ! self.announce(ok and "success!" or "failure.") self._clean() return ok --- 238,242 ---- ok = 0 ! log.info(ok and "success!" or "failure.") self._clean() return ok *************** *** 261,265 **** ok = 0 ! self.announce(ok and "success!" or "failure.") self._clean() return ok --- 259,263 ---- ok = 0 ! log.info(ok and "success!" or "failure.") self._clean() return ok *************** *** 283,287 **** ok = 0 ! self.announce(ok and "success!" or "failure.") self._clean() return ok --- 281,285 ---- ok = 0 ! log.info(ok and "success!" or "failure.") self._clean() return ok Index: install_lib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/install_lib.py,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** install_lib.py 30 May 2002 19:15:16 -0000 1.39 --- install_lib.py 4 Jun 2002 20:14:43 -0000 1.40 *************** *** 125,135 **** if self.compile: byte_compile(files, optimize=0, ! force=self.force, ! prefix=install_root, ! verbose=self.verbose, dry_run=self.dry_run) if self.optimize > 0: byte_compile(files, optimize=self.optimize, ! force=self.force, ! prefix=install_root, verbose=self.verbose, dry_run=self.dry_run) --- 125,133 ---- if self.compile: byte_compile(files, optimize=0, ! force=self.force, prefix=install_root, ! dry_run=self.dry_run) if self.optimize > 0: byte_compile(files, optimize=self.optimize, ! force=self.force, prefix=install_root, verbose=self.verbose, dry_run=self.dry_run) Index: install_scripts.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/install_scripts.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** install_scripts.py 31 Jan 2002 22:08:38 -0000 1.11 --- install_scripts.py 4 Jun 2002 20:14:43 -0000 1.12 *************** *** 10,13 **** --- 10,14 ---- import os from distutils.core import Command + from distutils import log from stat import ST_MODE *************** *** 49,56 **** for file in self.get_outputs(): if self.dry_run: ! self.announce("changing mode of %s" % file) else: mode = ((os.stat(file)[ST_MODE]) | 0111) & 07777 ! self.announce("changing mode of %s to %o" % (file, mode)) os.chmod(file, mode) --- 50,57 ---- for file in self.get_outputs(): if self.dry_run: ! log.info("changing mode of %s to %o", file, mode) else: mode = ((os.stat(file)[ST_MODE]) | 0111) & 07777 ! log.info("changing mode of %s to %o", file, mode) os.chmod(file, mode) Index: sdist.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/sdist.py,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** sdist.py 6 Dec 2001 20:57:12 -0000 1.53 --- sdist.py 4 Jun 2002 20:14:43 -0000 1.54 *************** *** 15,18 **** --- 15,19 ---- from distutils.errors import * from distutils.filelist import FileList + from distutils import log *************** *** 234,262 **** "(using default file list)") % self.template) - self.filelist.findall() - # Add default file set to 'files' if self.use_defaults: self.add_defaults() - - # Read manifest template if it exists if template_exists: 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 - # come first self.filelist.sort() - - # Remove duplicates from the file list self.filelist.remove_duplicates() - - # And write complete file list (including default file set) to - # the manifest. self.write_manifest() --- 235,249 ---- *************** *** 322,332 **** def read_template (self): ! """Read and parse the manifest template file named by ! 'self.template' (usually "MANIFEST.in"). The parsing and ! processing is done by 'self.filelist', which updates itself ! accordingly. """ ! self.announce("reading manifest template '%s'" % self.template) template = TextFile(self.template, strip_comments=1, --- 309,318 ---- def read_template (self): + """Read and parse manifest template file named by self.template. ! (usually "MANIFEST.in") The parsing and processing is done by ! 'self.filelist', which updates itself accordingly. """ ! log.info("reading manifest template '%s'", self.template) template = TextFile(self.template, strip_comments=1, *************** *** 385,389 **** distribution. """ ! self.announce("reading manifest file '%s'" % self.manifest) manifest = open(self.manifest) while 1: --- 371,375 ---- distribution. """ ! log.info("reading manifest file '%s'", self.manifest) manifest = open(self.manifest) while 1: *************** *** 411,416 **** # if the manifest happens to be empty. self.mkpath(base_dir) ! dir_util.create_tree(base_dir, files, ! verbose=self.verbose, dry_run=self.dry_run) # And walk over the list of files, either making a hard link (if --- 397,401 ---- # if the manifest happens to be empty. self.mkpath(base_dir) ! dir_util.create_tree(base_dir, files, dry_run=self.dry_run) # And walk over the list of files, either making a hard link (if *************** *** 429,438 **** if not files: ! self.warn("no files to distribute -- empty manifest?") else: ! self.announce(msg) for file in files: if not os.path.isfile(file): ! self.warn("'%s' not a regular file -- skipping" % file) else: dest = os.path.join(base_dir, file) --- 414,423 ---- if not files: ! log.warn("no files to distribute -- empty manifest?") else: ! log.info(msg) for file in files: if not os.path.isfile(file): ! log.warn("'%s' not a regular file -- skipping" % file) else: dest = os.path.join(base_dir, file) *************** *** 465,469 **** if not self.keep_temp: ! dir_util.remove_tree(base_dir, self.verbose, self.dry_run) def get_archive_files (self): --- 450,454 ---- if not self.keep_temp: ! dir_util.remove_tree(base_dir, dry_run=self.dry_run) def get_archive_files (self): From jhylton@users.sourceforge.net Tue Jun 4 21:14:45 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 04 Jun 2002 13:14:45 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils archive_util.py,1.11,1.12 bcppcompiler.py,1.11,1.12 ccompiler.py,1.43,1.44 cmd.py,1.29,1.30 core.py,1.47,1.48 cygwinccompiler.py,1.14,1.15 dir_util.py,1.8,1.9 dist.py,1.53,1.54 emxccompiler.py,1.1,1.2 fancy_getopt.py,1.20,1.21 file_util.py,1.12,1.13 filelist.py,1.9,1.10 msvccompiler.py,1.46,1.47 mwerkscompiler.py,1.6,1.7 spawn.py,1.12,1.13 unixccompiler.py,1.39,1.40 util.py,1.67,1.68 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv6520 Modified Files: archive_util.py bcppcompiler.py ccompiler.py cmd.py core.py cygwinccompiler.py dir_util.py dist.py emxccompiler.py fancy_getopt.py file_util.py filelist.py msvccompiler.py mwerkscompiler.py spawn.py unixccompiler.py util.py Log Message: Make setup.py less chatty by default. This is a conservative version of SF patch 504889. It uses the log module instead of calling print in various places, and it ignores the verbose argument passed to many functions and set as an attribute on some objects. Instead, it uses the verbosity set on the logger via the command line. The log module is now preferred over announce() and warn() methods that exist only for backwards compatibility. XXX This checkin changes a lot of modules that have no test suite and aren't exercised by the Python build process. It will need substantial testing. Index: archive_util.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/archive_util.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** archive_util.py 6 Dec 2001 20:51:35 -0000 1.11 --- archive_util.py 4 Jun 2002 20:14:42 -0000 1.12 *************** *** 12,15 **** --- 12,16 ---- from distutils.spawn import spawn from distutils.dir_util import mkpath + from distutils import log def make_tarball (base_name, base_dir, compress="gzip", *************** *** 43,53 **** archive_name = base_name + ".tar" ! mkpath(os.path.dirname(archive_name), verbose=verbose, dry_run=dry_run) cmd = ["tar", "-cf", archive_name, base_dir] ! spawn(cmd, verbose=verbose, dry_run=dry_run) if compress: spawn([compress] + compress_flags[compress] + [archive_name], ! verbose=verbose, dry_run=dry_run) return archive_name + compress_ext[compress] else: --- 44,54 ---- archive_name = base_name + ".tar" ! mkpath(os.path.dirname(archive_name), dry_run=dry_run) cmd = ["tar", "-cf", archive_name, base_dir] ! spawn(cmd, dry_run=dry_run) if compress: spawn([compress] + compress_flags[compress] + [archive_name], ! dry_run=dry_run) return archive_name + compress_ext[compress] else: *************** *** 70,77 **** zip_filename = base_name + ".zip" ! mkpath(os.path.dirname(zip_filename), verbose=verbose, dry_run=dry_run) try: spawn(["zip", "-rq", zip_filename, base_dir], ! verbose=verbose, dry_run=dry_run) except DistutilsExecError: --- 71,78 ---- zip_filename = base_name + ".zip" ! mkpath(os.path.dirname(zip_filename), dry_run=dry_run) try: spawn(["zip", "-rq", zip_filename, base_dir], ! dry_run=dry_run) except DistutilsExecError: *************** *** 90,97 **** "import the 'zipfile' module") % zip_filename ! if verbose: ! print "creating '%s' and adding '%s' to it" % \ ! (zip_filename, base_dir) ! def visit (z, dirname, names): for name in names: --- 91,98 ---- "import the 'zipfile' module") % zip_filename ! ! log.info("creating '%s' and adding '%s' to it", ! zip_filename, base_dir) ! def visit (z, dirname, names): for name in names: *************** *** 142,147 **** save_cwd = os.getcwd() if root_dir is not None: ! if verbose: ! print "changing into '%s'" % root_dir base_name = os.path.abspath(base_name) if not dry_run: --- 143,147 ---- save_cwd = os.getcwd() if root_dir is not None: ! log.debug("changing into '%s'", root_dir) base_name = os.path.abspath(base_name) if not dry_run: *************** *** 151,156 **** base_dir = os.curdir ! kwargs = { 'verbose': verbose, ! 'dry_run': dry_run } try: --- 151,155 ---- base_dir = os.curdir ! kwargs = { 'dry_run': dry_run } try: *************** *** 165,170 **** if root_dir is not None: ! if verbose: ! print "changing back to '%s'" % save_cwd os.chdir(save_cwd) --- 164,168 ---- if root_dir is not None: ! log.debug("changing back to '%s'", save_cwd) os.chdir(save_cwd) Index: bcppcompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/bcppcompiler.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** bcppcompiler.py 6 Dec 2001 20:51:35 -0000 1.11 --- bcppcompiler.py 4 Jun 2002 20:14:42 -0000 1.12 *************** *** 23,26 **** --- 23,27 ---- from distutils.file_util import write_file from distutils.dep_util import newer + from distutils import log class BCPPCompiler(CCompiler) : *************** *** 109,113 **** if skip_sources[src]: ! self.announce ("skipping %s (%s up-to-date)" % (src, obj)) else: src = os.path.normpath(src) --- 110,114 ---- if skip_sources[src]: ! log.debug("skipping %s (%s up-to-date)", src, obj) else: src = os.path.normpath(src) *************** *** 179,183 **** raise LibError, msg else: ! self.announce ("skipping %s (up-to-date)" % output_filename) # create_static_lib () --- 180,184 ---- raise LibError, msg else: ! log.debug("skipping %s (up-to-date)", output_filename) # create_static_lib () *************** *** 206,211 **** if runtime_library_dirs: ! self.warn ("I don't know what to do with 'runtime_library_dirs': " ! + str (runtime_library_dirs)) if output_dir is not None: --- 207,212 ---- if runtime_library_dirs: ! log.warn("I don't know what to do with 'runtime_library_dirs': %s", ! str(runtime_library_dirs)) if output_dir is not None: *************** *** 286,290 **** ld_args.append(lib) # probably a BCPP internal library -- don't warn - # self.warn('library %s not found.' % lib) else: # full name which prefers bcpp_xxx.lib over xxx.lib --- 287,290 ---- *************** *** 314,318 **** else: ! self.announce ("skipping %s (up-to-date)" % output_filename) # link () --- 314,318 ---- else: ! log.debug("skipping %s (up-to-date)", output_filename) # link () Index: ccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/ccompiler.py,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** ccompiler.py 25 Apr 2002 17:03:30 -0000 1.43 --- ccompiler.py 4 Jun 2002 20:14:42 -0000 1.44 *************** *** 17,21 **** from distutils.dep_util import newer_pairwise, newer_group from distutils.util import split_quoted, execute ! class CCompiler: --- 17,21 ---- from distutils.dep_util import newer_pairwise, newer_group from distutils.util import split_quoted, execute ! from distutils import log class CCompiler: *************** *** 81,85 **** force=0): - self.verbose = verbose self.dry_run = dry_run self.force = force --- 81,84 ---- *************** *** 809,814 **** def announce (self, msg, level=1): ! if self.verbose >= level: ! print msg def debug_print (self, msg): --- 808,812 ---- def announce (self, msg, level=1): ! log.debug(msg) def debug_print (self, msg): *************** *** 821,834 **** def execute (self, func, args, msg=None, level=1): ! execute(func, args, msg, self.verbose >= level, self.dry_run) def spawn (self, cmd): ! spawn (cmd, verbose=self.verbose, dry_run=self.dry_run) def move_file (self, src, dst): ! return move_file (src, dst, verbose=self.verbose, dry_run=self.dry_run) def mkpath (self, name, mode=0777): ! mkpath (name, mode, self.verbose, self.dry_run) --- 819,832 ---- def execute (self, func, args, msg=None, level=1): ! execute(func, args, msg, self.dry_run) def spawn (self, cmd): ! spawn (cmd, dry_run=self.dry_run) def move_file (self, src, dst): ! return move_file (src, dst, dry_run=self.dry_run) def mkpath (self, name, mode=0777): ! mkpath (name, mode, self.dry_run) *************** *** 958,962 **** "in module '%s'") % (class_name, module_name) ! return klass (verbose, dry_run, force) --- 956,963 ---- "in module '%s'") % (class_name, module_name) ! # XXX The None is necessary to preserve backwards compatibility ! # with classes that expect verbose to be the first positional ! # argument. ! return klass (None, dry_run, force) Index: cmd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/cmd.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** cmd.py 6 Dec 2001 20:51:35 -0000 1.29 --- cmd.py 4 Jun 2002 20:14:42 -0000 1.30 *************** *** 14,18 **** from distutils.errors import * from distutils import util, dir_util, file_util, archive_util, dep_util ! class Command: --- 14,18 ---- from distutils.errors import * from distutils import util, dir_util, file_util, archive_util, dep_util ! from distutils import log class Command: *************** *** 73,81 **** # "not defined, check self.distribution's copy", while 0 or 1 mean # false and true (duh). Note that this means figuring out the real ! # value of each flag is a touch complicated -- hence "self.verbose" ! # (etc.) will be handled by __getattr__, below. ! self._verbose = None self._dry_run = None # Some commands define a 'self.force' option to ignore file # timestamps, but methods defined *here* assume that --- 73,85 ---- # "not defined, check self.distribution's copy", while 0 or 1 mean # false and true (duh). Note that this means figuring out the real ! # value of each flag is a touch complicated -- hence "self._dry_run" ! # will be handled by __getattr__, below. ! # XXX This needs to be fixed. self._dry_run = None + # verbose is largely ignored, but needs to be set for + # backwards compatibility (I think)? + self.verbose = dist.verbose + # Some commands define a 'self.force' option to ignore file # timestamps, but methods defined *here* assume that *************** *** 97,102 **** def __getattr__ (self, attr): ! if attr in ('verbose', 'dry_run'): myval = getattr(self, "_" + attr) if myval is None: --- 101,108 ---- + # XXX A more explicit way to customize dry_run would be better. + def __getattr__ (self, attr): ! if attr == 'dry_run': myval = getattr(self, "_" + attr) if myval is None: *************** *** 187,193 **** 'level' print 'msg' to stdout. """ ! if self.verbose >= level: ! print msg ! sys.stdout.flush() def debug_print (self, msg): --- 193,197 ---- 'level' print 'msg' to stdout. """ ! log.debug(msg) def debug_print (self, msg): *************** *** 353,362 **** def execute (self, func, args, msg=None, level=1): ! util.execute(func, args, msg, self.verbose >= level, self.dry_run) def mkpath (self, name, mode=0777): ! dir_util.mkpath(name, mode, ! self.verbose, self.dry_run) --- 357,365 ---- def execute (self, func, args, msg=None, level=1): ! util.execute(func, args, msg, dry_run=self.dry_run) def mkpath (self, name, mode=0777): ! dir_util.mkpath(name, mode, dry_run=self.dry_run) *************** *** 372,377 **** not self.force, link, ! self.verbose >= level, ! self.dry_run) --- 375,379 ---- not self.force, link, ! dry_run=self.dry_run) *************** *** 386,413 **** preserve_mode,preserve_times,preserve_symlinks, not self.force, ! self.verbose >= level, ! self.dry_run) ! def move_file (self, src, dst, level=1): ! """Move a file respecting verbose and dry-run flags.""" ! return file_util.move_file(src, dst, ! self.verbose >= level, ! self.dry_run) ! 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, ! self.verbose >= level, ! self.dry_run) ! def make_archive (self, base_name, format, root_dir=None, base_dir=None): return archive_util.make_archive( ! base_name, format, root_dir, base_dir, ! self.verbose, self.dry_run) --- 388,406 ---- preserve_mode,preserve_times,preserve_symlinks, not self.force, ! dry_run=self.dry_run) def move_file (self, src, dst, level=1): ! """Move a file respectin dry-run flag.""" ! return file_util.move_file(src, dst, dry_run = self.dry_run) def spawn (self, cmd, search_path=1, level=1): ! """Spawn an external command respecting dry-run flag.""" from distutils.spawn import spawn ! spawn(cmd, search_path, dry_run= self.dry_run) def make_archive (self, base_name, format, root_dir=None, base_dir=None): return archive_util.make_archive( ! base_name, format, root_dir, base_dir, dry_run=self.dry_run) *************** *** 444,448 **** # Otherwise, print the "skip" message else: ! self.announce(skip_msg, level) # make_file () --- 437,441 ---- # Otherwise, print the "skip" message else: ! log.debug(skip_msg) # make_file () Index: core.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/core.py,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** core.py 6 Dec 2001 20:51:35 -0000 1.47 --- core.py 4 Jun 2002 20:14:42 -0000 1.48 *************** *** 101,105 **** _setup_distribution = dist = klass(attrs) except DistutilsSetupError, msg: ! raise SystemExit, "error in setup script: %s" % msg if _setup_stop_after == "init": --- 101,109 ---- _setup_distribution = dist = klass(attrs) except DistutilsSetupError, msg: ! if attrs.has_key('name'): ! raise SystemExit, "error in %s setup command: %s" % \ ! (attrs['name'], msg) ! else: ! raise SystemExit, "error in setup command: %s" % msg if _setup_stop_after == "init": Index: cygwinccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/cygwinccompiler.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** cygwinccompiler.py 6 Dec 2001 20:51:35 -0000 1.14 --- cygwinccompiler.py 4 Jun 2002 20:14:42 -0000 1.15 *************** *** 51,54 **** --- 51,55 ---- from distutils.file_util import write_file from distutils.errors import DistutilsExecError, CompileError, UnknownFileError + from distutils import log class CygwinCCompiler (UnixCCompiler): *************** *** 149,153 **** ext = (os.path.splitext (src))[1] if skip_sources[src]: ! self.announce ("skipping %s (%s up-to-date)" % (src, obj)) else: self.mkpath (os.path.dirname (obj)) --- 150,154 ---- ext = (os.path.splitext (src))[1] if skip_sources[src]: ! log.debug("skipping %s (%s up-to-date)", src, obj) else: self.mkpath (os.path.dirname (obj)) Index: dir_util.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/dir_util.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** dir_util.py 6 Dec 2001 20:51:35 -0000 1.8 --- dir_util.py 4 Jun 2002 20:14:42 -0000 1.9 *************** *** 10,14 **** from types import * from distutils.errors import DistutilsFileError, DistutilsInternalError ! # cache for by mkpath() -- in addition to cheapening redundant calls, --- 10,14 ---- from types import * from distutils.errors import DistutilsFileError, DistutilsInternalError ! from distutils import log # cache for by mkpath() -- in addition to cheapening redundant calls, *************** *** 70,75 **** continue ! if verbose: ! print "creating", head if not dry_run: --- 70,74 ---- continue ! log.info("creating %s", head) if not dry_run: *************** *** 106,110 **** # Now create them for dir in need_dirs: ! mkpath(dir, mode, verbose, dry_run) # create_tree () --- 105,109 ---- # Now create them for dir in need_dirs: ! mkpath(dir, mode, dry_run=dry_run) # create_tree () *************** *** 152,156 **** if not dry_run: ! mkpath(dst, verbose=verbose) outputs = [] --- 151,155 ---- if not dry_run: ! mkpath(dst) outputs = [] *************** *** 162,167 **** if preserve_symlinks and os.path.islink(src_name): link_dest = os.readlink(src_name) ! if verbose: ! print "linking %s -> %s" % (dst_name, link_dest) if not dry_run: os.symlink(link_dest, dst_name) --- 161,165 ---- if preserve_symlinks and os.path.islink(src_name): link_dest = os.readlink(src_name) ! log.info("linking %s -> %s", dst_name, link_dest) if not dry_run: os.symlink(link_dest, dst_name) *************** *** 170,180 **** elif os.path.isdir(src_name): outputs.extend( ! copy_tree(src_name, dst_name, ! preserve_mode, preserve_times, preserve_symlinks, ! update, verbose, dry_run)) else: ! copy_file(src_name, dst_name, ! preserve_mode, preserve_times, ! update, None, verbose, dry_run) outputs.append(dst_name) --- 168,177 ---- elif os.path.isdir(src_name): outputs.extend( ! copy_tree(src_name, dst_name, preserve_mode, ! preserve_times, preserve_symlinks, update, ! dry_run=dry_run)) else: ! copy_file(src_name, dst_name, preserve_mode, ! preserve_times, update, dry_run=dry_run) outputs.append(dst_name) *************** *** 201,206 **** global _path_created ! if verbose: ! print "removing '%s' (and everything under it)" % directory if dry_run: return --- 198,202 ---- global _path_created ! log.info("removing '%s' (and everything under it)", directory) if dry_run: return *************** *** 215,219 **** del _path_created[abspath] except (IOError, OSError), exc: ! if verbose: ! print grok_environment_error( ! exc, "error removing %s: " % directory) --- 211,214 ---- del _path_created[abspath] except (IOError, OSError), exc: ! log.warn(grok_environment_error( ! exc, "error removing %s: " % directory)) Index: dist.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/dist.py,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** dist.py 6 Dec 2001 20:51:35 -0000 1.53 --- dist.py 4 Jun 2002 20:14:42 -0000 1.54 *************** *** 16,20 **** from distutils.fancy_getopt import FancyGetopt, translate_longopt from distutils.util import check_environ, strtobool, rfc822_escape ! # Regex to define acceptable Distutils command names. This is not *quite* --- 16,20 ---- from distutils.fancy_getopt import FancyGetopt, translate_longopt from distutils.util import check_environ, strtobool, rfc822_escape ! from distutils import log # Regex to define acceptable Distutils command names. This is not *quite* *************** *** 47,51 **** # don't want to pollute the commands with too many options that they # have minimal control over. ! global_options = [('verbose', 'v', "run verbosely (default)"), ('quiet', 'q', "run quietly (turns verbosity off)"), ('dry-run', 'n', "don't actually do anything"), --- 47,52 ---- # don't want to pollute the commands with too many options that they # have minimal control over. ! # The fourth entry for verbose means that it can be repeated. ! global_options = [('verbose', 'v', "run verbosely (default)", 1), ('quiet', 'q', "run quietly (turns verbosity off)"), ('dry-run', 'n', "don't actually do anything"), *************** *** 393,396 **** --- 394,398 ---- args = parser.getopt(args=self.script_args, object=self) option_order = parser.get_option_order() + log.set_verbosity(self.verbose) # for display options we return immediately *************** *** 877,887 **** def announce (self, msg, level=1): ! """Print 'msg' if 'level' is greater than or equal to the verbosity ! level recorded in the 'verbose' attribute (which, currently, can be ! only 0 or 1). ! """ ! if self.verbose >= level: ! print msg ! def run_commands (self): --- 879,883 ---- def announce (self, msg, level=1): ! log.debug(msg) def run_commands (self): *************** *** 908,912 **** return ! self.announce("running " + command) cmd_obj = self.get_command_obj(command) cmd_obj.ensure_finalized() --- 904,908 ---- return ! log.info("running %s", command) cmd_obj = self.get_command_obj(command) cmd_obj.ensure_finalized() Index: emxccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/emxccompiler.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** emxccompiler.py 6 Feb 2002 18:22:48 -0000 1.1 --- emxccompiler.py 4 Jun 2002 20:14:42 -0000 1.2 *************** *** 29,32 **** --- 29,33 ---- from distutils.file_util import write_file from distutils.errors import DistutilsExecError, CompileError, UnknownFileError + from distutils import log class EMXCCompiler (UnixCCompiler): *************** *** 110,114 **** ext = (os.path.splitext (src))[1] if skip_sources[src]: ! self.announce ("skipping %s (%s up-to-date)" % (src, obj)) else: self.mkpath (os.path.dirname (obj)) --- 111,115 ---- ext = (os.path.splitext (src))[1] if skip_sources[src]: ! log.debug("skipping %s (%s up-to-date)", src, obj) else: self.mkpath (os.path.dirname (obj)) Index: fancy_getopt.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/fancy_getopt.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** fancy_getopt.py 6 Dec 2001 20:51:35 -0000 1.20 --- fancy_getopt.py 4 Jun 2002 20:14:42 -0000 1.21 *************** *** 158,168 **** self.short_opts = [] self.short2long.clear() for option in self.option_table: ! try: ! (long, short, help) = option ! except ValueError: ! raise DistutilsGetoptError, \ ! "invalid option tuple " + str(option) # Type- and value-check the option names --- 158,173 ---- self.short_opts = [] self.short2long.clear() + self.repeat = {} for option in self.option_table: ! if len(option) == 3: ! long, short, help = option ! repeat = 0 ! elif len(option) == 4: ! long, short, help, repeat = option ! else: ! # the option table is part of the code, so simply ! # assert that it is correct ! assert "invalid option tuple: %s" % `option` # Type- and value-check the option names *************** *** 178,181 **** --- 183,187 ---- "must a single character or None") % short + self.repeat[long] = 1 self.long_opts.append(long) *************** *** 233,244 **** def getopt (self, args=None, object=None): ! """Parse the command-line options in 'args' and store the results ! as attributes of 'object'. If 'args' is None or not supplied, uses ! 'sys.argv[1:]'. If 'object' is None or not supplied, creates a new ! OptionDummy object, stores option values there, and returns a tuple ! (args, object). If 'object' is supplied, it is modified in place ! and 'getopt()' just returns 'args'; in both cases, the returned ! 'args' is a modified copy of the passed-in 'args' list, which is ! left untouched. """ if args is None: --- 239,251 ---- def getopt (self, args=None, object=None): ! """Parse command-line options in args. Store as attributes on object. ! ! If 'args' is None or not supplied, uses 'sys.argv[1:]'. If ! 'object' is None or not supplied, creates a new OptionDummy ! object, stores option values there, and returns a tuple (args, ! object). If 'object' is supplied, it is modified in place and ! 'getopt()' just returns 'args'; in both cases, the returned ! 'args' is a modified copy of the passed-in 'args' list, which ! is left untouched. """ if args is None: *************** *** 254,271 **** short_opts = string.join(self.short_opts) try: ! (opts, args) = getopt.getopt(args, short_opts, self.long_opts) except getopt.error, msg: raise DistutilsArgError, msg ! for (opt, val) in opts: if len(opt) == 2 and opt[0] == '-': # it's a short option opt = self.short2long[opt[1]] - - elif len(opt) > 2 and opt[0:2] == '--': - opt = opt[2:] - else: ! raise DistutilsInternalError, \ ! "this can't happen: bad option string '%s'" % opt alias = self.alias.get(opt) --- 261,274 ---- short_opts = string.join(self.short_opts) try: ! opts, args = getopt.getopt(args, short_opts, self.long_opts) except getopt.error, msg: raise DistutilsArgError, msg ! for opt, val in opts: if len(opt) == 2 and opt[0] == '-': # it's a short option opt = self.short2long[opt[1]] else: ! assert len(opt) > 2 and opt[:2] == '--' ! opt = opt[2:] alias = self.alias.get(opt) *************** *** 274,281 **** if not self.takes_arg[opt]: # boolean option? ! if val != '': # shouldn't have a value! ! raise DistutilsInternalError, \ ! "this can't happen: bad option value '%s'" % val ! alias = self.negative_alias.get(opt) if alias: --- 277,281 ---- if not self.takes_arg[opt]: # boolean option? ! assert val == '', "boolean option can't have value" alias = self.negative_alias.get(opt) if alias: *************** *** 286,296 **** attr = self.attr_name[opt] setattr(object, attr, val) self.option_order.append((opt, val)) # for opts - if created_object: ! return (args, object) else: return args --- 286,299 ---- attr = self.attr_name[opt] + # The only repeating option at the moment is 'verbose'. + # It has a negative option -q quiet, which should set verbose = 0. + if val and self.repeat.get(attr) is not None: + val = getattr(object, attr, 0) + 1 setattr(object, attr, val) self.option_order.append((opt, val)) # for opts if created_object: ! return args, object else: return args Index: file_util.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/file_util.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** file_util.py 1 Feb 2002 18:29:34 -0000 1.12 --- file_util.py 4 Jun 2002 20:14:42 -0000 1.13 *************** *** 10,14 **** import os from distutils.errors import DistutilsFileError ! # for generating verbose output in 'copy_file()' --- 10,14 ---- import os from distutils.errors import DistutilsFileError ! from distutils import log # for generating verbose output in 'copy_file()' *************** *** 74,78 **** # _copy_file_contents() - def copy_file (src, dst, preserve_mode=1, --- 74,77 ---- *************** *** 91,96 **** last-access times are copied as well. If 'update' is true, 'src' will only be copied if 'dst' does not exist, or if 'dst' does exist but is ! older than 'src'. If 'verbose' is true, then a one-line summary of the ! copy will be printed to stdout. 'link' allows you to make hard links (os.link) or symbolic links --- 90,94 ---- last-access times are copied as well. If 'update' is true, 'src' will only be copied if 'dst' does not exist, or if 'dst' does exist but is ! older than 'src'. 'link' allows you to make hard links (os.link) or symbolic links *************** *** 128,134 **** if update and not newer(src, dst): ! if verbose: ! print "not copying %s (output up-to-date)" % src ! return (dst, 0) try: --- 126,131 ---- if update and not newer(src, dst): ! log.debug("not copying %s (output up-to-date)", src) ! return dst, 0 try: *************** *** 137,145 **** raise ValueError, \ "invalid value '%s' for 'link' argument" % link ! if verbose: ! if os.path.basename(dst) == os.path.basename(src): ! print "%s %s -> %s" % (action, src, dir) ! else: ! print "%s %s -> %s" % (action, src, dst) if dry_run: --- 134,141 ---- raise ValueError, \ "invalid value '%s' for 'link' argument" % link ! if os.path.basename(dst) == os.path.basename(src): ! log.info("%s %s -> %s", action, src, dir) ! else: ! log.info("%s %s -> %s", action, src, dst) if dry_run: *************** *** 198,203 **** import errno ! if verbose: ! print "moving %s -> %s" % (src, dst) if dry_run: --- 194,198 ---- import errno ! log.info("moving %s -> %s", src, dst) if dry_run: Index: filelist.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/filelist.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** filelist.py 6 Dec 2001 20:51:35 -0000 1.9 --- filelist.py 4 Jun 2002 20:14:42 -0000 1.10 *************** *** 38,49 **** warn=None, debug_print=None): ! # use standard warning and debug functions if no other given ! self.warn = warn or self.__warn ! self.debug_print = debug_print or self.__debug_print self.allfiles = None self.files = [] - def set_allfiles (self, allfiles): self.allfiles = allfiles --- 38,47 ---- warn=None, debug_print=None): ! # ignore argument to FileList, but keep them for backwards ! # compatibility self.allfiles = None self.files = [] def set_allfiles (self, allfiles): self.allfiles = allfiles *************** *** 52,62 **** self.allfiles = findall(dir) ! ! # -- Fallback warning/debug functions ------------------------------ ! ! def __warn (self, msg): ! sys.stderr.write("warning: %s\n" % msg) ! ! def __debug_print (self, msg): """Print 'msg' to stdout if the global DEBUG (taken from the DISTUTILS_DEBUG environment variable) flag is true. --- 50,54 ---- self.allfiles = findall(dir) ! def debug_print (self, msg): """Print 'msg' to stdout if the global DEBUG (taken from the DISTUTILS_DEBUG environment variable) flag is true. *************** *** 66,70 **** print msg - # -- List-like methods --------------------------------------------- --- 58,61 ---- *************** *** 88,93 **** def remove_duplicates (self): # Assumes list has been sorted! ! for i in range(len(self.files)-1, 0, -1): ! if self.files[i] == self.files[i-1]: del self.files[i] --- 79,84 ---- def remove_duplicates (self): # Assumes list has been sorted! ! for i in range(len(self.files) - 1, 0, -1): ! if self.files[i] == self.files[i - 1]: del self.files[i] *************** *** 148,152 **** for pattern in patterns: if not self.include_pattern(pattern, anchor=1): ! self.warn("no files found matching '%s'" % pattern) elif action == 'exclude': --- 139,144 ---- for pattern in patterns: if not self.include_pattern(pattern, anchor=1): ! log.warn("warning: no files found matching '%s'", ! pattern) elif action == 'exclude': *************** *** 154,160 **** for pattern in patterns: if not self.exclude_pattern(pattern, anchor=1): ! self.warn( ! "no previously-included files found matching '%s'"% ! pattern) elif action == 'global-include': --- 146,151 ---- for pattern in patterns: if not self.exclude_pattern(pattern, anchor=1): ! log.warn(("warning: no previously-included files " ! "found matching '%s'"), pattern) elif action == 'global-include': *************** *** 162,168 **** for pattern in patterns: if not self.include_pattern(pattern, anchor=0): ! self.warn(("no files found matching '%s' " + ! "anywhere in distribution") % ! pattern) elif action == 'global-exclude': --- 153,158 ---- for pattern in patterns: if not self.include_pattern(pattern, anchor=0): ! log.warn(("warning: no files found matching '%s' " + ! "anywhere in distribution"), pattern) elif action == 'global-exclude': *************** *** 170,176 **** for pattern in patterns: if not self.exclude_pattern(pattern, anchor=0): ! self.warn(("no previously-included files matching '%s' " + ! "found anywhere in distribution") % ! pattern) elif action == 'recursive-include': --- 160,166 ---- for pattern in patterns: if not self.exclude_pattern(pattern, anchor=0): ! log.warn(("warning: no previously-included files matching " ! "'%s' found anywhere in distribution"), ! pattern) elif action == 'recursive-include': *************** *** 179,185 **** for pattern in patterns: if not self.include_pattern(pattern, prefix=dir): ! self.warn(("no files found matching '%s' " + ! "under directory '%s'") % ! (pattern, dir)) elif action == 'recursive-exclude': --- 169,175 ---- for pattern in patterns: if not self.include_pattern(pattern, prefix=dir): ! log.warn(("warngin: no files found matching '%s' " + ! "under directory '%s'"), ! pattern, dir) elif action == 'recursive-exclude': *************** *** 188,206 **** for pattern in patterns: if not self.exclude_pattern(pattern, prefix=dir): ! self.warn(("no previously-included files matching '%s' " + ! "found under directory '%s'") % ! (pattern, dir)) elif action == 'graft': self.debug_print("graft " + dir_pattern) if not self.include_pattern(None, prefix=dir_pattern): ! self.warn("no directories found matching '%s'" % dir_pattern) elif action == 'prune': self.debug_print("prune " + dir_pattern) if not self.exclude_pattern(None, prefix=dir_pattern): ! self.warn(("no previously-included directories found " + ! "matching '%s'") % ! dir_pattern) else: raise DistutilsInternalError, \ --- 178,196 ---- for pattern in patterns: if not self.exclude_pattern(pattern, prefix=dir): ! log.warn(("warning: no previously-included files matching " ! "'%s' found under directory '%s'"), ! pattern, dir) elif action == 'graft': self.debug_print("graft " + dir_pattern) if not self.include_pattern(None, prefix=dir_pattern): ! log.warn("warning: no directories found matching '%s'", ! dir_pattern) elif action == 'prune': self.debug_print("prune " + dir_pattern) if not self.exclude_pattern(None, prefix=dir_pattern): ! log.warn(("no previously-included directories found " + ! "matching '%s'"), dir_pattern) else: raise DistutilsInternalError, \ Index: msvccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/msvccompiler.py,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** msvccompiler.py 25 Apr 2002 17:29:45 -0000 1.46 --- msvccompiler.py 4 Jun 2002 20:14:42 -0000 1.47 *************** *** 18,21 **** --- 18,22 ---- from distutils.ccompiler import \ CCompiler, gen_preprocess_options, gen_lib_options + from distutils import log _can_read_reg = 0 *************** *** 306,310 **** if skip_sources[src]: ! self.announce ("skipping %s (%s up-to-date)" % (src, obj)) else: self.mkpath (os.path.dirname (obj)) --- 307,311 ---- if skip_sources[src]: ! log.debug("skipping %s (%s up-to-date)", src, obj) else: self.mkpath (os.path.dirname (obj)) *************** *** 404,408 **** else: ! self.announce ("skipping %s (up-to-date)" % output_filename) # create_static_lib () --- 405,409 ---- else: ! log.debug("skipping %s (up-to-date)", output_filename) # create_static_lib () *************** *** 481,485 **** else: ! self.announce ("skipping %s (up-to-date)" % output_filename) # link () --- 482,486 ---- else: ! log.debug("skipping %s (up-to-date)", output_filename) # link () Index: mwerkscompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/mwerkscompiler.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** mwerkscompiler.py 6 Dec 2001 20:51:35 -0000 1.6 --- mwerkscompiler.py 4 Jun 2002 20:14:42 -0000 1.7 *************** *** 14,17 **** --- 14,18 ---- import distutils.util import distutils.dir_util + from distutils import log import mkcwproject *************** *** 133,138 **** prefixname = 'mwerks_%s_config.h'%basename # Create the directories we need ! distutils.dir_util.mkpath(build_temp, self.verbose, self.dry_run) ! distutils.dir_util.mkpath(output_dir, self.verbose, self.dry_run) # And on to filling in the parameters for the project builder settings = {} --- 134,139 ---- prefixname = 'mwerks_%s_config.h'%basename # Create the directories we need ! distutils.dir_util.mkpath(build_temp, dry_run=self.dry_run) ! distutils.dir_util.mkpath(output_dir, dry_run=self.dry_run) # And on to filling in the parameters for the project builder settings = {} *************** *** 160,165 **** # Build the export file exportfilename = os.path.join(build_temp, exportname) ! if self.verbose: ! print '\tCreate export file', exportfilename fp = open(exportfilename, 'w') fp.write('%s\n'%export_symbols[0]) --- 161,165 ---- # Build the export file exportfilename = os.path.join(build_temp, exportname) ! log.debug("\tCreate export file", exportfilename) fp = open(exportfilename, 'w') fp.write('%s\n'%export_symbols[0]) *************** *** 182,187 **** # doesn't have a clue about our working directory. xmlfilename = os.path.join(os.getcwd(), os.path.join(build_temp, xmlname)) ! if self.verbose: ! print '\tCreate XML file', xmlfilename xmlbuilder = mkcwproject.cwxmlgen.ProjectBuilder(settings) xmlbuilder.generate() --- 182,186 ---- # doesn't have a clue about our working directory. xmlfilename = os.path.join(os.getcwd(), os.path.join(build_temp, xmlname)) ! log.debug("\tCreate XML file", xmlfilename) xmlbuilder = mkcwproject.cwxmlgen.ProjectBuilder(settings) xmlbuilder.generate() *************** *** 192,201 **** # Generate the project. Again a full pathname. projectfilename = os.path.join(os.getcwd(), os.path.join(build_temp, projectname)) ! if self.verbose: ! print '\tCreate project file', projectfilename mkcwproject.makeproject(xmlfilename, projectfilename) # And build it ! if self.verbose: ! print '\tBuild project' mkcwproject.buildproject(projectfilename) --- 191,198 ---- # Generate the project. Again a full pathname. projectfilename = os.path.join(os.getcwd(), os.path.join(build_temp, projectname)) ! log.debug('\tCreate project file', projectfilename) mkcwproject.makeproject(xmlfilename, projectfilename) # And build it ! log.debug('\tBuild project') mkcwproject.buildproject(projectfilename) Index: spawn.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/spawn.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** spawn.py 31 Jan 2002 18:55:32 -0000 1.12 --- spawn.py 4 Jun 2002 20:14:42 -0000 1.13 *************** *** 13,17 **** import sys, os, string from distutils.errors import * ! def spawn (cmd, --- 13,17 ---- import sys, os, string from distutils.errors import * ! from distutils import log def spawn (cmd, *************** *** 28,33 **** If 'search_path' is true (the default), the system's executable search path will be used to find the program; otherwise, cmd[0] must be the ! exact path to the executable. If 'verbose' is true, a one-line summary ! of the command will be printed before it is run. If 'dry_run' is true, the command will not actually be run. --- 28,32 ---- If 'search_path' is true (the default), the system's executable search path will be used to find the program; otherwise, cmd[0] must be the ! exact path to the executable.If 'dry_run' is true, the command will not actually be run. *************** *** 36,44 **** """ if os.name == 'posix': ! _spawn_posix(cmd, search_path, verbose, dry_run) elif os.name == 'nt': ! _spawn_nt(cmd, search_path, verbose, dry_run) elif os.name == 'os2': ! _spawn_os2(cmd, search_path, verbose, dry_run) else: raise DistutilsPlatformError, \ --- 35,43 ---- """ if os.name == 'posix': ! _spawn_posix(cmd, search_path, dry_run=dry_run) elif os.name == 'nt': ! _spawn_nt(cmd, search_path, dry_run=dry_run) elif os.name == 'os2': ! _spawn_os2(cmd, search_path, dry_run=dry_run) else: raise DistutilsPlatformError, \ *************** *** 75,80 **** # either we find one or it stays the same executable = find_executable(executable) or executable ! if verbose: ! print string.join([executable] + cmd[1:], ' ') if not dry_run: # spawn for NT requires a full path to the .exe --- 74,78 ---- # either we find one or it stays the same executable = find_executable(executable) or executable ! log.info(string.join([executable] + cmd[1:], ' ')) if not dry_run: # spawn for NT requires a full path to the .exe *************** *** 101,106 **** # either we find one or it stays the same executable = find_executable(executable) or executable ! if verbose: ! print string.join([executable] + cmd[1:], ' ') if not dry_run: # spawnv for OS/2 EMX requires a full path to the .exe --- 99,103 ---- # either we find one or it stays the same executable = find_executable(executable) or executable ! log.info(string.join([executable] + cmd[1:], ' ')) if not dry_run: # spawnv for OS/2 EMX requires a full path to the .exe *************** *** 123,128 **** dry_run=0): ! if verbose: ! print string.join(cmd, ' ') if dry_run: return --- 120,124 ---- dry_run=0): ! log.info(string.join(cmd, ' ')) if dry_run: return Index: unixccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/unixccompiler.py,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** unixccompiler.py 11 Feb 2002 15:31:50 -0000 1.39 --- unixccompiler.py 4 Jun 2002 20:14:42 -0000 1.40 *************** *** 27,30 **** --- 27,31 ---- from distutils.errors import \ DistutilsExecError, CompileError, LibError, LinkError + from distutils import log # XXX Things not currently handled: *************** *** 148,152 **** src = sources[i] ; obj = objects[i] if skip_sources[src]: ! self.announce("skipping %s (%s up-to-date)" % (src, obj)) else: self.mkpath(os.path.dirname(obj)) --- 149,153 ---- src = sources[i] ; obj = objects[i] if skip_sources[src]: ! log.debug("skipping %s (%s up-to-date)", src, obj) else: self.mkpath(os.path.dirname(obj)) *************** *** 192,196 **** raise LibError, msg else: ! self.announce("skipping %s (up-to-date)" % output_filename) # create_static_lib () --- 193,197 ---- raise LibError, msg else: ! log.debug("skipping %s (up-to-date)", output_filename) # create_static_lib () *************** *** 241,245 **** raise LinkError, msg else: ! self.announce("skipping %s (up-to-date)" % output_filename) # link () --- 242,246 ---- raise LinkError, msg else: ! log.debug("skipping %s (up-to-date)", output_filename) # link () Index: util.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/util.py,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** util.py 6 May 2002 13:57:19 -0000 1.67 --- util.py 4 Jun 2002 20:14:42 -0000 1.68 *************** *** 13,17 **** from distutils.dep_util import newer from distutils.spawn import spawn ! def get_platform (): --- 13,17 ---- from distutils.dep_util import newer from distutils.spawn import spawn ! from distutils import log def get_platform (): *************** *** 276,288 **** def execute (func, args, msg=None, verbose=0, dry_run=0): ! """Perform some action that affects the outside world (eg. by writing ! to the filesystem). Such actions are special because they are disabled ! by the 'dry_run' flag, and announce themselves if 'verbose' is true. ! 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), and an optional message ! to print. """ - # Generate a message if we weren't passed one if msg is None: msg = "%s%s" % (func.__name__, `args`) --- 276,287 ---- def execute (func, args, msg=None, verbose=0, dry_run=0): ! """Perform some action that affects the outside world (eg. by ! writing to the filesystem). Such actions are special because they ! are disabled by the 'dry_run' flag. 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), and an optional message to ! print. """ if msg is None: msg = "%s%s" % (func.__name__, `args`) *************** *** 290,306 **** msg = msg[0:-2] + ')' ! # Print it if verbosity level is high enough ! if verbose: ! print msg ! ! # And do it, as long as we're not in dry-run mode if not dry_run: apply(func, args) - # execute() - def strtobool (val): """Convert a string representation of truth to true (1) or false (0). True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if --- 289,300 ---- msg = msg[0:-2] + ')' ! log.info(msg) if not dry_run: apply(func, args) def strtobool (val): """Convert a string representation of truth to true (1) or false (0). + True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if *************** *** 338,343 **** (or neither) of 'prefix' and 'base_dir', as you wish. ! If 'verbose' is true, prints out a report of each file. If 'dry_run' ! is true, doesn't actually do anything that would affect the filesystem. Byte-compilation is either done directly in this interpreter process --- 332,337 ---- (or neither) of 'prefix' and 'base_dir', as you wish. ! If 'dry_run' is true, doesn't actually do anything that would ! affect the filesystem. Byte-compilation is either done directly in this interpreter process *************** *** 368,373 **** from tempfile import mktemp script_name = mktemp(".py") ! if verbose: ! print "writing byte-compilation script '%s'" % script_name if not dry_run: script = open(script_name, "w") --- 362,366 ---- from tempfile import mktemp script_name = mktemp(".py") ! log.info("writing byte-compilation script '%s'", script_name) if not dry_run: script = open(script_name, "w") *************** *** 407,413 **** elif optimize == 2: cmd.insert(1, "-OO") ! spawn(cmd, verbose=verbose, dry_run=dry_run) execute(os.remove, (script_name,), "removing %s" % script_name, ! verbose=verbose, dry_run=dry_run) # "Direct" byte-compilation: use the py_compile module to compile --- 400,406 ---- elif optimize == 2: cmd.insert(1, "-OO") ! spawn(cmd, dry_run=dry_run) execute(os.remove, (script_name,), "removing %s" % script_name, ! dry_run=dry_run) # "Direct" byte-compilation: use the py_compile module to compile *************** *** 441,452 **** if direct: if force or newer(file, cfile): ! if verbose: ! print "byte-compiling %s to %s" % (file, cfile_base) if not dry_run: compile(file, cfile, dfile) else: ! if verbose: ! print "skipping byte-compilation of %s to %s" % \ ! (file, cfile_base) # byte_compile () --- 434,443 ---- if direct: if force or newer(file, cfile): ! log.info("byte-compiling %s to %s", file, cfile_base) if not dry_run: compile(file, cfile, dfile) else: ! log.debug("skipping byte-compilation of %s to %s", ! file, cfile_base) # byte_compile () From jhylton@users.sourceforge.net Tue Jun 4 21:18:26 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 04 Jun 2002 13:18:26 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils/command bdist_pkgtool.py,1.3,1.4 bdist_sdux.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory usw-pr-cvs1:/tmp/cvs-serv7748/command Modified Files: bdist_pkgtool.py bdist_sdux.py Log Message: Remove unused imports caught by pychecker Index: bdist_pkgtool.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_pkgtool.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** bdist_pkgtool.py 4 Jun 2002 20:14:43 -0000 1.3 --- bdist_pkgtool.py 4 Jun 2002 20:18:24 -0000 1.4 *************** *** 8,12 **** import os, string, sys, pwd, grp - import glob from types import * from distutils.core import Command, DEBUG --- 8,11 ---- *************** *** 17,21 **** from distutils import sysconfig from distutils import log - import compileall from commands import getoutput --- 16,19 ---- Index: bdist_sdux.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_sdux.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** bdist_sdux.py 4 Jun 2002 20:14:43 -0000 1.2 --- bdist_sdux.py 4 Jun 2002 20:18:24 -0000 1.3 *************** *** 8,12 **** __revision__ = "$Id: bdist_sdux.py,v 0.2 " import os, string - import glob from types import * from distutils.core import Command, DEBUG --- 8,11 ---- From jhylton@users.sourceforge.net Tue Jun 4 21:18:26 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 04 Jun 2002 13:18:26 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils filelist.py,1.10,1.11 unixccompiler.py,1.40,1.41 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv7748 Modified Files: filelist.py unixccompiler.py Log Message: Remove unused imports caught by pychecker Index: filelist.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/filelist.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** filelist.py 4 Jun 2002 20:14:42 -0000 1.10 --- filelist.py 4 Jun 2002 20:18:24 -0000 1.11 *************** *** 12,16 **** __revision__ = "$Id$" ! import sys, os, string, re import fnmatch from types import * --- 12,16 ---- __revision__ = "$Id$" ! import os, string, re import fnmatch from types import * Index: unixccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/unixccompiler.py,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** unixccompiler.py 4 Jun 2002 20:14:42 -0000 1.40 --- unixccompiler.py 4 Jun 2002 20:18:24 -0000 1.41 *************** *** 18,22 **** __revision__ = "$Id$" ! import string, re, os, sys from types import * from copy import copy --- 18,22 ---- __revision__ = "$Id$" ! import os, sys from types import * from copy import copy From jhylton@users.sourceforge.net Tue Jun 4 21:24:07 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 04 Jun 2002 13:24:07 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils fancy_getopt.py,1.21,1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv9912 Modified Files: fancy_getopt.py Log Message: Set repeat metadata for an option based on repeat local var not constant. Index: fancy_getopt.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/fancy_getopt.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** fancy_getopt.py 4 Jun 2002 20:14:42 -0000 1.21 --- fancy_getopt.py 4 Jun 2002 20:24:05 -0000 1.22 *************** *** 183,187 **** "must a single character or None") % short ! self.repeat[long] = 1 self.long_opts.append(long) --- 183,187 ---- "must a single character or None") % short ! self.repeat[long] = repeat self.long_opts.append(long) From jhylton@users.sourceforge.net Tue Jun 4 21:26:46 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 04 Jun 2002 13:26:46 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils/command bdist_packager.py,1.3,1.4 bdist_pkgtool.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory usw-pr-cvs1:/tmp/cvs-serv11043/command Modified Files: bdist_packager.py bdist_pkgtool.py Log Message: Fix unused local variables caught by pychecker. Fixes a bug for Solaris pkgtool (bdist_pkgtool) that would have prevented it from building subpackages. Index: bdist_packager.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_packager.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** bdist_packager.py 4 Jun 2002 20:14:42 -0000 1.3 --- bdist_packager.py 4 Jun 2002 20:26:44 -0000 1.4 *************** *** 146,150 **** def initialize_options (self): - d = self.distribution self.keep_temp = 0 self.control_only = 0 --- 146,149 ---- *************** *** 188,193 **** if not self.plat_name: ! d = self.distribution ! self.plat = d.get_platforms() if self.distribution.has_ext_modules(): self.plat_name = [sys.platform,] --- 187,191 ---- if not self.plat_name: ! self.plat = self.distribution.get_platforms() if self.distribution.has_ext_modules(): self.plat_name = [sys.platform,] *************** *** 238,247 **** log.info("installing to %s", self.pkg_dir) self.run_command('install') - - # And make an archive relative to the root of the - # pseudo-installation tree. - archive_basename = "%s.%s" % (self.distribution.get_fullname(), - self.plat_name) - if not self.keep_temp: remove_tree(self.pkg_dir, dry_run=self.dry_run) --- 236,239 ---- Index: bdist_pkgtool.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_pkgtool.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** bdist_pkgtool.py 4 Jun 2002 20:18:24 -0000 1.4 --- bdist_pkgtool.py 4 Jun 2002 20:26:44 -0000 1.5 *************** *** 209,213 **** pkg_dir = self.pkg_dir ! install = self.reinitialize_command('install', reinit_subcommands=1) # build package log.info('Building package') --- 209,213 ---- pkg_dir = self.pkg_dir ! self.reinitialize_command('install', reinit_subcommands=1) # build package log.info('Building package') *************** *** 276,280 **** self.subpackages=string.split(self.subpackages,",") for pkg in self.subpackages: ! self.make_package(subpackage) else: self.make_package() --- 276,280 ---- self.subpackages=string.split(self.subpackages,",") for pkg in self.subpackages: ! self.make_package(pkg) else: self.make_package() From jhylton@users.sourceforge.net Tue Jun 4 21:26:46 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 04 Jun 2002 13:26:46 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils core.py,1.48,1.49 cygwinccompiler.py,1.15,1.16 emxccompiler.py,1.2,1.3 sysconfig.py,1.46,1.47 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv11043 Modified Files: core.py cygwinccompiler.py emxccompiler.py sysconfig.py Log Message: Fix unused local variables caught by pychecker. Fixes a bug for Solaris pkgtool (bdist_pkgtool) that would have prevented it from building subpackages. Index: core.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/core.py,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** core.py 4 Jun 2002 20:14:42 -0000 1.48 --- core.py 4 Jun 2002 20:26:44 -0000 1.49 *************** *** 126,132 **** ok = dist.parse_command_line() except DistutilsArgError, msg: ! script = os.path.basename(dist.script_name) ! raise SystemExit, \ ! gen_usage(dist.script_name) + "\nerror: %s" % msg if DEBUG: --- 126,130 ---- ok = dist.parse_command_line() except DistutilsArgError, msg: ! raise SystemExit, gen_usage(dist.script_name) + "\nerror: %s" % msg if DEBUG: Index: cygwinccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/cygwinccompiler.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** cygwinccompiler.py 4 Jun 2002 20:14:42 -0000 1.15 --- cygwinccompiler.py 4 Jun 2002 20:26:44 -0000 1.16 *************** *** 214,218 **** # generate the filenames for these files def_file = os.path.join(temp_dir, dll_name + ".def") - exp_file = os.path.join(temp_dir, dll_name + ".exp") lib_file = os.path.join(temp_dir, 'lib' + dll_name + ".a") --- 214,217 ---- *************** *** 230,236 **** # dllwrap uses different options than gcc/ld if self.linker_dll == "dllwrap": ! extra_preargs.extend([#"--output-exp",exp_file, ! "--output-lib",lib_file, ! ]) # for dllwrap we have to use a special option extra_preargs.extend(["--def", def_file]) --- 229,233 ---- # dllwrap uses different options than gcc/ld if self.linker_dll == "dllwrap": ! extra_preargs.extend(["--output-lib", lib_file]) # for dllwrap we have to use a special option extra_preargs.extend(["--def", def_file]) *************** *** 239,243 **** # doesn't work: bfd_close build\...\libfoo.a: Invalid operation #extra_preargs.extend(["-Wl,--out-implib,%s" % lib_file]) ! # for gcc/ld the def-file is specified as any other object files objects.append(def_file) --- 236,240 ---- # doesn't work: bfd_close build\...\libfoo.a: Invalid operation #extra_preargs.extend(["-Wl,--out-implib,%s" % lib_file]) ! # for gcc/ld the def-file is specified as any object files objects.append(def_file) Index: emxccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/emxccompiler.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** emxccompiler.py 4 Jun 2002 20:14:42 -0000 1.2 --- emxccompiler.py 4 Jun 2002 20:26:44 -0000 1.3 *************** *** 175,183 **** # generate the filenames for these files def_file = os.path.join(temp_dir, dll_name + ".def") - lib_file = os.path.join(temp_dir, dll_name + ".lib") # Generate .def file contents = [ ! "LIBRARY %s INITINSTANCE TERMINSTANCE" % os.path.splitext(os.path.basename(output_filename))[0], "DATA MULTIPLE NONSHARED", "EXPORTS"] --- 175,183 ---- # generate the filenames for these files def_file = os.path.join(temp_dir, dll_name + ".def") # Generate .def file contents = [ ! "LIBRARY %s INITINSTANCE TERMINSTANCE" % \ ! os.path.splitext(os.path.basename(output_filename))[0], "DATA MULTIPLE NONSHARED", "EXPORTS"] Index: sysconfig.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/sysconfig.py,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** sysconfig.py 4 Jun 2002 15:28:21 -0000 1.46 --- sysconfig.py 4 Jun 2002 20:26:44 -0000 1.47 *************** *** 306,310 **** m = _findvar1_rx.search(s) or _findvar2_rx.search(s) if m: - name = m.group(1) (beg, end) = m.span() s = s[0:beg] + vars.get(m.group(1)) + s[end:] --- 306,309 ---- From jhylton@users.sourceforge.net Tue Jun 4 21:30:13 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 04 Jun 2002 13:30:13 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils/command install_scripts.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory usw-pr-cvs1:/tmp/cvs-serv12243 Modified Files: install_scripts.py Log Message: Fix bug in recent change to logging code. mode is not computed in dry_run mode, so it can't be included in the log message. Index: install_scripts.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/install_scripts.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** install_scripts.py 4 Jun 2002 20:14:43 -0000 1.12 --- install_scripts.py 4 Jun 2002 20:30:10 -0000 1.13 *************** *** 50,54 **** for file in self.get_outputs(): if self.dry_run: ! log.info("changing mode of %s to %o", file, mode) else: mode = ((os.stat(file)[ST_MODE]) | 0111) & 07777 --- 50,54 ---- for file in self.get_outputs(): if self.dry_run: ! log.info("changing mode of %s", file) else: mode = ((os.stat(file)[ST_MODE]) | 0111) & 07777 From jhylton@users.sourceforge.net Tue Jun 4 21:35:12 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 04 Jun 2002 13:35:12 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils fancy_getopt.py,1.22,1.23 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv13607 Modified Files: fancy_getopt.py Log Message: global _option_order is not used Index: fancy_getopt.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/fancy_getopt.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** fancy_getopt.py 4 Jun 2002 20:24:05 -0000 1.22 --- fancy_getopt.py 4 Jun 2002 20:35:10 -0000 1.23 *************** *** 32,41 **** longopt_xlate = string.maketrans('-', '_') - # This records (option, value) pairs in the order seen on the command line; - # it's close to what getopt.getopt() returns, but with short options - # expanded. (Ugh, this module should be OO-ified.) - _option_order = None - - class FancyGetopt: """Wrapper around the standard 'getopt()' module that provides some --- 32,35 ---- From jhylton@users.sourceforge.net Tue Jun 4 21:39:36 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 04 Jun 2002 13:39:36 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils/command bdist_packager.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory usw-pr-cvs1:/tmp/cvs-serv14932 Modified Files: bdist_packager.py Log Message: get_script() implicitly returned None and also had explicit returns. Make all returns explicit and rearrange logic to avoid extra indentation. Index: bdist_packager.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_packager.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** bdist_packager.py 4 Jun 2002 20:26:44 -0000 1.4 --- bdist_packager.py 4 Jun 2002 20:39:34 -0000 1.5 *************** *** 4,9 **** Implements the Distutils 'bdist_packager' abstract command ! to be subclassed by binary package creation commands.""" ! __revision__ = "$Id: bdist_packager.py,v 0.1 2001/04/4 mwa" --- 4,9 ---- Implements the Distutils 'bdist_packager' abstract command ! to be subclassed by binary package creation commands. ! """ __revision__ = "$Id: bdist_packager.py,v 0.1 2001/04/4 mwa" *************** *** 115,146 **** self.revision + '-' + py_ver ! def get_script (self,attr): # accept a script as a string ("line\012line\012..."), # a filename, or a list # XXX We could probably get away with copy_file, but I'm # guessing this will be more flexible later on.... ! val = getattr(self,attr) ! ret=None ! if val: ! try: ! os.stat(val) ! # script is a file ! ret=[] ! f=open(val) ! ret=string.split(f.read(),"\012"); ! f.close() ! #return ret ! except: ! if type(val)==type(""): ! # script is a string ! ret = string.split(val,"\012") ! elif type(val)==type([]): ! # script is a list ! ret = val ! else: ! raise RuntimeError, \ ! "cannot figure out what to do with 'request' option (%s)" \ ! % val ! return ret --- 115,145 ---- self.revision + '-' + py_ver ! def get_script (self, attr): # accept a script as a string ("line\012line\012..."), # a filename, or a list # XXX We could probably get away with copy_file, but I'm # guessing this will be more flexible later on.... ! val = getattr(self, attr) ! if val is None: ! return None ! try: ! os.stat(val) ! # script is a file ! ret = [] ! f = open(val) ! ret = string.split(f.read(), "\012"); ! f.close() ! except: ! if type(val) == type(""): ! # script is a string ! ret = string.split(val, "\012") ! elif type(val) == type([]): ! # script is a list ! ret = val ! else: ! raise RuntimeError, \ ! "cannot figure out what to do with 'request' option (%s)" \ ! % val ! return ret From jhylton@users.sourceforge.net Tue Jun 4 21:40:05 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 04 Jun 2002 13:40:05 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils/command bdist_packager.py,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory usw-pr-cvs1:/tmp/cvs-serv15112 Modified Files: bdist_packager.py Log Message: Remove (commented out) options that have moved into the distribution. Index: bdist_packager.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_packager.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** bdist_packager.py 4 Jun 2002 20:39:34 -0000 1.5 --- bdist_packager.py 4 Jun 2002 20:40:03 -0000 1.6 *************** *** 35,51 **** ('revision=', None, "package revision number"), - # the following have moved into the distribution class - #('packager=', None, - #"Package maintainer"), - #('packager-mail=', None, - #"Package maintainer's email address"), - #('author=', None, - #"Package author"), - #('author-mail=', None, - #"Package author's email address"), - #('license=', None, - #"License code"), - #('licence=', None, - #"alias for license"), ('icon=', None, "Package icon"), --- 35,38 ---- From jhylton@users.sourceforge.net Tue Jun 4 21:42:43 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 04 Jun 2002 13:42:43 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils/command bdist_pkgtool.py,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory usw-pr-cvs1:/tmp/cvs-serv15937 Modified Files: bdist_pkgtool.py Log Message: Reindent lines to improve readability Index: bdist_pkgtool.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_pkgtool.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** bdist_pkgtool.py 4 Jun 2002 20:26:44 -0000 1.5 --- bdist_pkgtool.py 4 Jun 2002 20:42:41 -0000 1.6 *************** *** 304,310 **** self.distribution.packages[0] file_list=string.split( ! getoutput("pkgproto %s/%s=%s" % (build.build_lib, ! self.distribution.packages[0], ! self.distribution.packages[0])),"\012") except: file_list=string.split( --- 304,310 ---- self.distribution.packages[0] file_list=string.split( ! getoutput("pkgproto %s/%s=%s" % \ ! (build.build_lib, self.distribution.packages[0], ! self.distribution.packages[0])), "\012") except: file_list=string.split( From jhylton@users.sourceforge.net Tue Jun 4 21:45:20 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 04 Jun 2002 13:45:20 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils/command bdist_packager.py,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory usw-pr-cvs1:/tmp/cvs-serv16664 Modified Files: bdist_packager.py Log Message: ensure_filename() only takes one argument. Call ensure_string() with one arg too, since the second value passed was the default. Index: bdist_packager.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_packager.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** bdist_packager.py 4 Jun 2002 20:40:03 -0000 1.6 --- bdist_packager.py 4 Jun 2002 20:45:17 -0000 1.7 *************** *** 68,83 **** raise DistutilsOptionError, "'%s' must be provided" % option ! def ensure_script (self,arg): if not arg: return try: ! self.ensure_string(arg, None) except: try: ! self.ensure_filename(arg, None) except: ! raise RuntimeError, \ ! "cannot decipher script option (%s)" \ ! % arg def write_script (self,path,attr,default=None): --- 68,81 ---- raise DistutilsOptionError, "'%s' must be provided" % option ! def ensure_script(self, arg): if not arg: return try: ! self.ensure_string(arg) except: try: ! self.ensure_filename(arg) except: ! raise RuntimeError, "cannot decipher script option (%s)" % arg def write_script (self,path,attr,default=None): From jhylton@users.sourceforge.net Tue Jun 4 21:55:12 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 04 Jun 2002 13:55:12 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils/command bdist_wininst.py,1.32,1.33 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory usw-pr-cvs1:/tmp/cvs-serv19691 Modified Files: bdist_wininst.py Log Message: import base64 at the top to avoid two different imports at other times Index: bdist_wininst.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_wininst.py,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** bdist_wininst.py 4 Jun 2002 20:14:43 -0000 1.32 --- bdist_wininst.py 4 Jun 2002 20:55:10 -0000 1.33 *************** *** 9,12 **** --- 9,13 ---- import sys, os, string + import base64 from distutils.core import Command from distutils.util import get_platform *************** *** 232,236 **** def get_exe_bytes (self): - import base64 return base64.decodestring(EXEDATA) # class bdist_wininst --- 233,236 ---- *************** *** 249,253 **** # - Execute this file (distutils/distutils/command/bdist_wininst.py) ! import re, base64 moddata = open("bdist_wininst.py", "r").read() exedata = open("../../misc/wininst.exe", "rb").read() --- 249,253 ---- # - Execute this file (distutils/distutils/command/bdist_wininst.py) ! import re moddata = open("bdist_wininst.py", "r").read() exedata = open("../../misc/wininst.exe", "rb").read() From jhylton@users.sourceforge.net Tue Jun 4 22:00:29 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 04 Jun 2002 14:00:29 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils/command build_py.py,1.38,1.39 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory usw-pr-cvs1:/tmp/cvs-serv21475 Modified Files: build_py.py Log Message: Make None return explicit Index: build_py.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/build_py.py,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** build_py.py 4 Jun 2002 20:14:43 -0000 1.38 --- build_py.py 4 Jun 2002 21:00:20 -0000 1.39 *************** *** 182,186 **** # Either not in a package at all (__init__.py not expected), or # __init__.py doesn't exist -- so don't return the filename. ! return # check_package () --- 182,186 ---- # Either not in a package at all (__init__.py not expected), or # __init__.py doesn't exist -- so don't return the filename. ! return None # check_package () From jhylton@users.sourceforge.net Tue Jun 4 22:00:35 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 04 Jun 2002 14:00:35 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils/command bdist_pkgtool.py,1.6,1.7 bdist_sdux.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory usw-pr-cvs1:/tmp/cvs-serv21551 Modified Files: bdist_pkgtool.py bdist_sdux.py Log Message: Remove unused imports Index: bdist_pkgtool.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_pkgtool.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** bdist_pkgtool.py 4 Jun 2002 20:42:41 -0000 1.6 --- bdist_pkgtool.py 4 Jun 2002 21:00:33 -0000 1.7 *************** *** 9,13 **** import os, string, sys, pwd, grp from types import * - from distutils.core import Command, DEBUG from distutils.util import get_platform from distutils.file_util import write_file --- 9,12 ---- Index: bdist_sdux.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_sdux.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** bdist_sdux.py 4 Jun 2002 20:18:24 -0000 1.3 --- bdist_sdux.py 4 Jun 2002 21:00:33 -0000 1.4 *************** *** 9,13 **** import os, string from types import * - from distutils.core import Command, DEBUG from distutils.util import get_platform from distutils.file_util import write_file --- 9,12 ---- From jhylton@users.sourceforge.net Tue Jun 4 22:02:28 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 04 Jun 2002 14:02:28 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils dist.py,1.54,1.55 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv22466 Modified Files: dist.py Log Message: Use module-level import of DEBUG instead of many function-level imports. Index: dist.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/dist.py,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** dist.py 4 Jun 2002 20:14:42 -0000 1.54 --- dist.py 4 Jun 2002 21:02:26 -0000 1.55 *************** *** 17,20 **** --- 17,21 ---- from distutils.util import check_environ, strtobool, rfc822_escape from distutils import log + from distutils.core import DEBUG # Regex to define acceptable Distutils command names. This is not *quite* *************** *** 306,310 **** from ConfigParser import ConfigParser - from distutils.core import DEBUG if filenames is None: --- 307,310 ---- *************** *** 772,776 **** 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: --- 772,775 ---- *************** *** 803,808 **** (from 'self.command_options'). """ - from distutils.core import DEBUG - command_name = command_obj.get_command_name() if option_dict is None: --- 802,805 ---- From jhylton@users.sourceforge.net Tue Jun 4 22:04:06 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 04 Jun 2002 14:04:06 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils filelist.py,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv22986 Modified Files: filelist.py Log Message: Add missing import of log. Index: filelist.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/filelist.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** filelist.py 4 Jun 2002 20:18:24 -0000 1.11 --- filelist.py 4 Jun 2002 21:04:03 -0000 1.12 *************** *** 18,21 **** --- 18,22 ---- from distutils.util import convert_path from distutils.errors import DistutilsTemplateError, DistutilsInternalError + from distutils import log class FileList: From jhylton@users.sourceforge.net Tue Jun 4 22:05:08 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 04 Jun 2002 14:05:08 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils core.py,1.49,1.50 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv23377 Modified Files: core.py Log Message: Define DEBUG as early as possible to avoid import problems. Index: core.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/core.py,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** core.py 4 Jun 2002 20:26:44 -0000 1.49 --- core.py 4 Jun 2002 21:05:05 -0000 1.50 *************** *** 13,16 **** --- 13,21 ---- import sys, os from types import * + + # If DISTUTILS_DEBUG is anything other than the empty string, we run in + # debug mode. + DEBUG = os.environ.get('DISTUTILS_DEBUG') + from distutils.errors import * from distutils.util import grok_environment_error *************** *** 32,40 **** or: %(script)s cmd --help """ - - - # If DISTUTILS_DEBUG is anything other than the empty string, we run in - # debug mode. - DEBUG = os.environ.get('DISTUTILS_DEBUG') def gen_usage (script_name): --- 37,40 ---- From jhylton@users.sourceforge.net Tue Jun 4 22:06:19 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 04 Jun 2002 14:06:19 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils/command bdist_sdux.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory usw-pr-cvs1:/tmp/cvs-serv23861 Modified Files: bdist_sdux.py Log Message: Replace bogus bare variables with attribute access. Index: bdist_sdux.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_sdux.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** bdist_sdux.py 4 Jun 2002 21:00:33 -0000 1.4 --- bdist_sdux.py 4 Jun 2002 21:06:16 -0000 1.5 *************** *** 2,6 **** Implements the Distutils 'bdist_sdux' command to create HP-UX ! swinstall depot""" # Mark Alexander --- 2,7 ---- Implements the Distutils 'bdist_sdux' command to create HP-UX ! swinstall depot. ! """ # Mark Alexander *************** *** 266,274 **** if self.copyright: # XX make a copyright file XXX ! write_script('copyright') psf_file.extend([' copyright Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv24957 Modified Files: fancy_getopt.py Log Message: Track extra arg to option_table to all uses of it Index: fancy_getopt.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/fancy_getopt.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** fancy_getopt.py 4 Jun 2002 20:35:10 -0000 1.23 --- fancy_getopt.py 4 Jun 2002 21:10:35 -0000 1.24 *************** *** 359,364 **** lines = ['Option summary:'] ! for (long,short,help) in self.option_table: ! text = wrap_text(help, text_width) if long[-1] == '=': --- 359,364 ---- lines = ['Option summary:'] ! for option in self.option_table: ! long, short, help = option_table[:3] text = wrap_text(help, text_width) if long[-1] == '=': From jhylton@users.sourceforge.net Tue Jun 4 22:12:01 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 04 Jun 2002 14:12:01 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils fancy_getopt.py,1.24,1.25 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv25265 Modified Files: fancy_getopt.py Log Message: Test changes before checking them in. Index: fancy_getopt.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/fancy_getopt.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** fancy_getopt.py 4 Jun 2002 21:10:35 -0000 1.24 --- fancy_getopt.py 4 Jun 2002 21:11:56 -0000 1.25 *************** *** 360,364 **** for option in self.option_table: ! long, short, help = option_table[:3] text = wrap_text(help, text_width) if long[-1] == '=': --- 360,364 ---- for option in self.option_table: ! long, short, help = option[:3] text = wrap_text(help, text_width) if long[-1] == '=': From gvanrossum@users.sourceforge.net Tue Jun 4 22:19:57 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue, 04 Jun 2002 14:19:57 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_descr.py,1.113.4.15,1.113.4.16 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv27530/Lib/test Modified Files: Tag: release22-maint test_descr.py Log Message: Backport to 2.2.x: Address SF bug 519621: slots weren't traversed by GC. While I was at it, I added a tp_clear handler and changed the tp_dealloc handler to use the clear_slots helper for the tp_clear handler. Also set mp->flags = READONLY for the __weakref__ pseudo-slot. [Note that I am *not* backporting the part of that patch that tightened the __slot__ rules.] Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.113.4.15 retrieving revision 1.113.4.16 diff -C2 -d -r1.113.4.15 -r1.113.4.16 *** test_descr.py 13 May 2002 18:30:40 -0000 1.113.4.15 --- test_descr.py 4 Jun 2002 21:19:55 -0000 1.113.4.16 *************** *** 1094,1097 **** --- 1094,1109 ---- vereq(Counted.counter, 0) + # Test cyclical leaks [SF bug 519621] + class F(object): + __slots__ = ['a', 'b'] + log = [] + s = F() + s.a = [Counted(), s] + vereq(Counted.counter, 1) + s = None + import gc + gc.collect() + vereq(Counted.counter, 0) + def dynamics(): if verbose: print "Testing class attribute propagation..." From gvanrossum@users.sourceforge.net Tue Jun 4 22:19:57 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue, 04 Jun 2002 14:19:57 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.337.2.4.2.25,1.337.2.4.2.26 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv27530/Misc Modified Files: Tag: release22-maint NEWS Log Message: Backport to 2.2.x: Address SF bug 519621: slots weren't traversed by GC. While I was at it, I added a tp_clear handler and changed the tp_dealloc handler to use the clear_slots helper for the tp_clear handler. Also set mp->flags = READONLY for the __weakref__ pseudo-slot. [Note that I am *not* backporting the part of that patch that tightened the __slot__ rules.] Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.337.2.4.2.25 retrieving revision 1.337.2.4.2.26 diff -C2 -d -r1.337.2.4.2.25 -r1.337.2.4.2.26 *** NEWS 22 Apr 2002 11:57:05 -0000 1.337.2.4.2.25 --- NEWS 4 Jun 2002 21:19:55 -0000 1.337.2.4.2.26 *************** *** 5,8 **** --- 5,11 ---- Core and builtins + - Classes using __slots__ are now properly garbage collected. + [SF bug 519621] + - Repaired a slow memory leak possible only in programs creating a great many cyclic structures involving frames. Reported on From gvanrossum@users.sourceforge.net Tue Jun 4 22:19:58 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue, 04 Jun 2002 14:19:58 -0700 Subject: [Python-checkins] python/dist/src/Objects typeobject.c,2.126.4.12,2.126.4.13 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv27530/Objects Modified Files: Tag: release22-maint typeobject.c Log Message: Backport to 2.2.x: Address SF bug 519621: slots weren't traversed by GC. While I was at it, I added a tp_clear handler and changed the tp_dealloc handler to use the clear_slots helper for the tp_clear handler. Also set mp->flags = READONLY for the __weakref__ pseudo-slot. [Note that I am *not* backporting the part of that patch that tightened the __slot__ rules.] Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.126.4.12 retrieving revision 2.126.4.13 diff -C2 -d -r2.126.4.12 -r2.126.4.13 *** typeobject.c 3 Jun 2002 19:54:10 -0000 2.126.4.12 --- typeobject.c 4 Jun 2002 21:19:55 -0000 2.126.4.13 *************** *** 5,8 **** --- 5,22 ---- #include "structmember.h" + #include + + /* The *real* layout of a type object when allocated on the heap */ + /* XXX Should we publish this in a header file? */ + typedef struct { + PyTypeObject type; + PyNumberMethods as_number; + PySequenceMethods as_sequence; + PyMappingMethods as_mapping; + PyBufferProcs as_buffer; + PyObject *name, *slots; + PyMemberDef members[1]; + } etype; + static PyMemberDef type_members[] = { {"__basicsize__", T_INT, offsetof(PyTypeObject,tp_basicsize),READONLY}, *************** *** 224,237 **** static int subtype_traverse(PyObject *self, visitproc visit, void *arg) { PyTypeObject *type, *base; ! traverseproc f; ! int err; ! /* Find the nearest base with a different tp_traverse */ type = self->ob_type; ! base = type->tp_base; ! while ((f = base->tp_traverse) == subtype_traverse) { base = base->tp_base; assert(base); --- 238,278 ---- static int + traverse_slots(PyTypeObject *type, PyObject *self, visitproc visit, void *arg) + { + int i, n; + PyMemberDef *mp; + + n = type->ob_size; + mp = ((etype *)type)->members; + for (i = 0; i < n; i++, mp++) { + if (mp->type == T_OBJECT_EX) { + char *addr = (char *)self + mp->offset; + PyObject *obj = *(PyObject **)addr; + if (obj != NULL) { + int err = visit(obj, arg); + if (err) + return err; + } + } + } + return 0; + } + + static int subtype_traverse(PyObject *self, visitproc visit, void *arg) { PyTypeObject *type, *base; ! traverseproc basetraverse; ! /* Find the nearest base with a different tp_traverse, ! and traverse slots while we're at it */ type = self->ob_type; ! base = type; ! while ((basetraverse = base->tp_traverse) == subtype_traverse) { ! if (base->ob_size) { ! int err = traverse_slots(base, self, visit, arg); ! if (err) ! return err; ! } base = base->tp_base; assert(base); *************** *** 241,245 **** PyObject **dictptr = _PyObject_GetDictPtr(self); if (dictptr && *dictptr) { ! err = visit(*dictptr, arg); if (err) return err; --- 282,286 ---- PyObject **dictptr = _PyObject_GetDictPtr(self); if (dictptr && *dictptr) { ! int err = visit(*dictptr, arg); if (err) return err; *************** *** 247,252 **** } ! if (f) ! return f(self, visit, arg); return 0; } --- 288,342 ---- } ! if (basetraverse) ! return basetraverse(self, visit, arg); ! return 0; ! } ! ! static void ! clear_slots(PyTypeObject *type, PyObject *self) ! { ! int i, n; ! PyMemberDef *mp; ! ! n = type->ob_size; ! mp = ((etype *)type)->members; ! for (i = 0; i < n; i++, mp++) { ! if (mp->type == T_OBJECT_EX && !(mp->flags & READONLY)) { ! char *addr = (char *)self + mp->offset; ! PyObject *obj = *(PyObject **)addr; ! if (obj != NULL) { ! Py_DECREF(obj); ! *(PyObject **)addr = NULL; ! } ! } ! } ! } ! ! static int ! subtype_clear(PyObject *self) ! { ! PyTypeObject *type, *base; ! inquiry baseclear; ! ! /* Find the nearest base with a different tp_clear ! and clear slots while we're at it */ ! type = self->ob_type; ! base = type; ! while ((baseclear = base->tp_clear) == subtype_clear) { ! if (base->ob_size) ! clear_slots(base, self); ! base = base->tp_base; ! assert(base); ! } ! ! if (type->tp_dictoffset != base->tp_dictoffset) { ! PyObject **dictptr = _PyObject_GetDictPtr(self); ! if (dictptr && *dictptr) { ! PyDict_Clear(*dictptr); ! } ! } ! ! if (baseclear) ! return baseclear(self); return 0; } *************** *** 327,331 **** { PyTypeObject *type, *base; ! destructor f; /* This exists so we can DECREF self->ob_type */ --- 417,421 ---- { PyTypeObject *type, *base; ! destructor basedealloc; /* This exists so we can DECREF self->ob_type */ *************** *** 334,365 **** return; ! /* Find the nearest base with a different tp_dealloc */ type = self->ob_type; ! base = type->tp_base; ! while ((f = base->tp_dealloc) == subtype_dealloc) { base = base->tp_base; assert(base); } - /* Clear __slots__ variables */ - if (type->tp_basicsize != base->tp_basicsize && - type->tp_itemsize == 0) - { - char *addr = ((char *)self); - char *p = addr + base->tp_basicsize; - char *q = addr + type->tp_basicsize; - for (; p < q; p += sizeof(PyObject *)) { - PyObject **pp; - if (p == addr + type->tp_dictoffset || - p == addr + type->tp_weaklistoffset) - continue; - pp = (PyObject **)p; - if (*pp != NULL) { - Py_DECREF(*pp); - *pp = NULL; - } - } - } - /* If we added a dict, DECREF it */ if (type->tp_dictoffset && !base->tp_dictoffset) { --- 424,438 ---- return; ! /* Find the nearest base with a different tp_dealloc ! and clear slots while we're at it */ type = self->ob_type; ! base = type; ! while ((basedealloc = base->tp_dealloc) == subtype_dealloc) { ! if (base->ob_size) ! clear_slots(base, self); base = base->tp_base; assert(base); } /* If we added a dict, DECREF it */ if (type->tp_dictoffset && !base->tp_dictoffset) { *************** *** 383,388 **** /* Call the base tp_dealloc() */ ! assert(f); ! f(self); /* Can't reference self beyond this point */ --- 456,461 ---- /* Call the base tp_dealloc() */ ! assert(basedealloc); ! basedealloc(self); /* Can't reference self beyond this point */ *************** *** 394,407 **** staticforward PyTypeObject *solid_base(PyTypeObject *type); - typedef struct { - PyTypeObject type; - PyNumberMethods as_number; - PySequenceMethods as_sequence; - PyMappingMethods as_mapping; - PyBufferProcs as_buffer; - PyObject *name, *slots; - PyMemberDef members[1]; - } etype; - /* type test with subclassing support */ --- 467,470 ---- *************** *** 1143,1146 **** --- 1206,1210 ---- strcmp(mp->name, "__weakref__") == 0) { mp->type = T_OBJECT; + mp->flags = READONLY; type->tp_weaklistoffset = slotoffset; } *************** *** 1192,1196 **** type->tp_free = _PyObject_GC_Del; type->tp_traverse = subtype_traverse; ! type->tp_clear = base->tp_clear; } else --- 1256,1260 ---- type->tp_free = _PyObject_GC_Del; type->tp_traverse = subtype_traverse; ! type->tp_clear = subtype_clear; } else From jhylton@users.sourceforge.net Tue Jun 4 22:20:11 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 04 Jun 2002 14:20:11 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils/command install.py,1.63,1.64 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory usw-pr-cvs1:/tmp/cvs-serv27982 Modified Files: install.py Log Message: Move warning about directory not on sys.path to debug level. Fix a bunch of multiline string constants that used +. Index: install.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/install.py,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** install.py 22 Mar 2002 15:35:17 -0000 1.63 --- install.py 4 Jun 2002 21:20:08 -0000 1.64 *************** *** 3,6 **** --- 3,8 ---- Implements the Distutils 'install' command.""" + from distutils import log + # created 1999/03/13, Greg Ward *************** *** 369,374 **** self.install_data is None): raise DistutilsOptionError, \ ! "install-base or install-platbase supplied, but " + \ ! "installation scheme is incomplete" return --- 371,376 ---- self.install_data is None): raise DistutilsOptionError, \ ! ("install-base or install-platbase supplied, but " ! "installation scheme is incomplete") return *************** *** 465,470 **** else: raise DistutilsOptionError, \ ! "'extra_path' option must be a list, tuple, or " + \ ! "comma-separated string with 1 or 2 elements" # convert to local form in case Unix notation used (as it --- 467,472 ---- else: raise DistutilsOptionError, \ ! ("'extra_path' option must be a list, tuple, or " ! "comma-separated string with 1 or 2 elements") # convert to local form in case Unix notation used (as it *************** *** 523,530 **** not (self.path_file and self.install_path_file) and install_lib not in sys_path): ! self.warn(("modules installed to '%s', which is not in " + ! "Python's module search path (sys.path) -- " + ! "you'll have to change the search path yourself") % ! self.install_lib) # run () --- 525,532 ---- not (self.path_file and self.install_path_file) and install_lib not in sys_path): ! log.debug(("modules installed to '%s', which is not in " ! "Python's module search path (sys.path) -- " ! "you'll have to change the search path yourself"), ! self.install_lib) # run () From theller@users.sourceforge.net Wed Jun 5 13:55:22 2002 From: theller@users.sourceforge.net (theller@users.sourceforge.net) Date: Wed, 05 Jun 2002 05:55:22 -0700 Subject: [Python-checkins] python/dist/src/Objects abstract.c,2.101,2.102 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv24593 Modified Files: abstract.c Log Message: Better isinstance error message. Closes SF patch # 560250. Bugfix candidate IMO. Index: abstract.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/abstract.c,v retrieving revision 2.101 retrieving revision 2.102 diff -C2 -d -r2.101 -r2.102 *** abstract.c 23 Apr 2002 22:45:44 -0000 2.101 --- abstract.c 5 Jun 2002 12:55:19 -0000 2.102 *************** *** 1977,1981 **** if (!PyErr_Occurred()) PyErr_SetString(PyExc_TypeError, ! "isinstance() arg 2 must be a class or type"); return -1; } --- 1977,1982 ---- if (!PyErr_Occurred()) PyErr_SetString(PyExc_TypeError, ! "isinstance() arg 2 must be a class, type," ! " or tuple of classes and types"); return -1; } From jvr@users.sourceforge.net Wed Jun 5 18:41:11 2002 From: jvr@users.sourceforge.net (jvr@users.sourceforge.net) Date: Wed, 05 Jun 2002 10:41:11 -0700 Subject: [Python-checkins] python/dist/src/Mac/Modules/win _Winmodule.c,1.9,1.10 winscan.py,1.20,1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules/win In directory usw-pr-cvs1:/tmp/cvs-serv514 Modified Files: _Winmodule.c winscan.py Log Message: fixed refcount leak in CreateNewWindow() and CreateWindowFromResource(). Index: _Winmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/win/_Winmodule.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** _Winmodule.c 23 Apr 2002 22:42:40 -0000 1.9 --- _Winmodule.c 5 Jun 2002 17:41:03 -0000 1.10 *************** *** 3113,3117 **** if (_err != noErr) return PyMac_Error(_err); _res = Py_BuildValue("O&", ! WinObj_WhichWindow, outWindow); return _res; } --- 3113,3117 ---- if (_err != noErr) return PyMac_Error(_err); _res = Py_BuildValue("O&", ! WinObj_New, outWindow); return _res; } *************** *** 3133,3137 **** if (_err != noErr) return PyMac_Error(_err); _res = Py_BuildValue("O&", ! WinObj_WhichWindow, outWindow); return _res; } --- 3133,3137 ---- if (_err != noErr) return PyMac_Error(_err); _res = Py_BuildValue("O&", ! WinObj_New, outWindow); return _res; } Index: winscan.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/win/winscan.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** winscan.py 24 Mar 2002 23:01:16 -0000 1.20 --- winscan.py 5 Jun 2002 17:41:03 -0000 1.21 *************** *** 137,140 **** --- 137,147 ---- [("NullStorage", "*", "InMode")]), + # match FindWindowOfClass + ([("WindowRef", "outWindow", "OutMode"), ("WindowPartCode", "outWindowPart", "OutMode")], + [("ExistingWindowPtr", "*", "OutMode"), ("WindowPartCode", "outWindowPart", "OutMode")]), + # then match CreateNewWindow and CreateWindowFromResource + ([("WindowRef", "outWindow", "OutMode")], + [("WindowRef", "*", "*")]), + ([("WindowPtr", "*", "OutMode")], [("ExistingWindowPtr", "*", "*")]), From gvanrossum@users.sourceforge.net Wed Jun 5 20:07:41 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Wed, 05 Jun 2002 12:07:41 -0700 Subject: [Python-checkins] python/dist/src/Lib rfc822.py,1.71,1.72 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv32531 Modified Files: rfc822.py Log Message: SF bug 558179. Change default for get() back to None. Will backport to 2.2.1. Index: rfc822.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/rfc822.py,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** rfc822.py 1 Jun 2002 14:18:46 -0000 1.71 --- rfc822.py 5 Jun 2002 19:07:39 -0000 1.72 *************** *** 426,436 **** del self.headers[i] - def get(self, name, default=""): - name = name.lower() - if name in self.dict: - return self.dict[name] - else: - return default - def setdefault(self, name, default=""): lowername = name.lower() --- 426,429 ---- From gvanrossum@users.sourceforge.net Wed Jun 5 20:07:41 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Wed, 05 Jun 2002 12:07:41 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_pyclbr.py,1.8,1.9 test_rfc822.py,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv32531/test Modified Files: test_pyclbr.py test_rfc822.py Log Message: SF bug 558179. Change default for get() back to None. Will backport to 2.2.1. Index: test_pyclbr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pyclbr.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** test_pyclbr.py 11 Apr 2002 19:54:11 -0000 1.8 --- test_pyclbr.py 5 Jun 2002 19:07:39 -0000 1.9 *************** *** 106,110 **** '_ismodule', '_classify_class_attrs']) ! self.checkModule('rfc822') self.checkModule('difflib') --- 106,110 ---- '_ismodule', '_classify_class_attrs']) ! self.checkModule('rfc822', ignore=["get"]) self.checkModule('difflib') Index: test_rfc822.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_rfc822.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** test_rfc822.py 23 May 2002 03:21:01 -0000 1.17 --- test_rfc822.py 5 Jun 2002 19:07:39 -0000 1.18 *************** *** 19,23 **** self.assert_(msg.get("to") == '"last, first" ') self.assert_(msg.get("TO") == '"last, first" ') ! self.assert_(msg.get("No-Such-Header") == "") self.assert_(msg.get("No-Such-Header", "No-Such-Value") == "No-Such-Value") --- 19,23 ---- self.assert_(msg.get("to") == '"last, first" ') self.assert_(msg.get("TO") == '"last, first" ') ! self.assert_(msg.get("No-Such-Header") is None) self.assert_(msg.get("No-Such-Header", "No-Such-Value") == "No-Such-Value") From gvanrossum@users.sourceforge.net Wed Jun 5 20:10:21 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Wed, 05 Jun 2002 12:10:21 -0700 Subject: [Python-checkins] python/dist/src/Lib rfc822.py,1.66,1.66.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv1017 Modified Files: Tag: release22-maint rfc822.py Log Message: SF bug 558179. Change default for get() back to None. Index: rfc822.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/rfc822.py,v retrieving revision 1.66 retrieving revision 1.66.4.1 diff -C2 -d -r1.66 -r1.66.4.1 *** rfc822.py 20 Dec 2001 15:54:48 -0000 1.66 --- rfc822.py 5 Jun 2002 19:10:18 -0000 1.66.4.1 *************** *** 426,436 **** del self.headers[i] - def get(self, name, default=""): - name = name.lower() - if self.dict.has_key(name): - return self.dict[name] - else: - return default - def setdefault(self, name, default=""): lowername = name.lower() --- 426,429 ---- From gvanrossum@users.sourceforge.net Wed Jun 5 20:10:21 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Wed, 05 Jun 2002 12:10:21 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_pyclbr.py,1.6.10.1,1.6.10.2 test_rfc822.py,1.15,1.15.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv1017/test Modified Files: Tag: release22-maint test_pyclbr.py test_rfc822.py Log Message: SF bug 558179. Change default for get() back to None. Index: test_pyclbr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pyclbr.py,v retrieving revision 1.6.10.1 retrieving revision 1.6.10.2 diff -C2 -d -r1.6.10.1 -r1.6.10.2 *** test_pyclbr.py 14 Mar 2002 17:06:55 -0000 1.6.10.1 --- test_pyclbr.py 5 Jun 2002 19:10:19 -0000 1.6.10.2 *************** *** 106,110 **** '_ismodule', '_classify_class_attrs']) ! self.checkModule('rfc822') self.checkModule('xmllib') self.checkModule('difflib') --- 106,110 ---- '_ismodule', '_classify_class_attrs']) ! self.checkModule('rfc822', ignore=["get"]) self.checkModule('xmllib') self.checkModule('difflib') Index: test_rfc822.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_rfc822.py,v retrieving revision 1.15 retrieving revision 1.15.8.1 diff -C2 -d -r1.15 -r1.15.8.1 *** test_rfc822.py 13 Nov 2001 21:33:52 -0000 1.15 --- test_rfc822.py 5 Jun 2002 19:10:19 -0000 1.15.8.1 *************** *** 19,23 **** self.assert_(msg.get("to") == '"last, first" ') self.assert_(msg.get("TO") == '"last, first" ') ! self.assert_(msg.get("No-Such-Header") == "") self.assert_(msg.get("No-Such-Header", "No-Such-Value") == "No-Such-Value") --- 19,23 ---- self.assert_(msg.get("to") == '"last, first" ') self.assert_(msg.get("TO") == '"last, first" ') ! self.assert_(msg.get("No-Such-Header") is None) self.assert_(msg.get("No-Such-Header", "No-Such-Value") == "No-Such-Value") From rhettinger@users.sourceforge.net Wed Jun 5 21:08:50 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed, 05 Jun 2002 13:08:50 -0700 Subject: [Python-checkins] python/dist/src/Objects rangeobject.c,2.37,2.38 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv21219 Modified Files: rangeobject.c Log Message: SF 564601 adding rangeiterobject to make xrange() iterate like range(). Index: rangeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/rangeobject.c,v retrieving revision 2.37 retrieving revision 2.38 diff -C2 -d -r2.37 -r2.38 *** rangeobject.c 4 Jun 2002 18:45:50 -0000 2.37 --- rangeobject.c 5 Jun 2002 20:08:48 -0000 2.38 *************** *** 9,14 **** long step; long len; - long index; - int used; /* Set to 1 if called by range_getiter */ } rangeobject; --- 9,12 ---- *************** *** 46,51 **** obj->len = len; obj->step = step; - obj->index = 0; - obj->used = 0; return (PyObject *) obj; --- 44,47 ---- *************** *** 91,132 **** } - static PyObject * - range_getiter(rangeobject *r) - { - rangeobject *obj; - if (r->used == 0 || r->index >= r->len) { - Py_INCREF(r); - r->used = 1; - r->index = 0; - return (PyObject *)r; - } - - obj = PyObject_NEW(rangeobject, &PyRange_Type); - if (obj == NULL) - return NULL; - - obj->start = r->start; - obj->len = r->len; - obj->step = r->step; - obj->index = 0; - obj->used = 1; - return (PyObject *) obj; - } - - static PyObject * - range_next(rangeobject *r) - { - if (r->index < r->len) - return PyInt_FromLong(r->start + (r->index++) * r->step); - PyErr_SetObject(PyExc_StopIteration, Py_None); - return NULL; - } - - static PyMethodDef range_methods[] = { - {"next", (PyCFunction)range_next, METH_NOARGS, - "it.next() -- get the next value, or raise StopIteration"}, - {NULL, NULL} /* sentinel */ - }; - static PySequenceMethods range_as_sequence = { (inquiry)range_length, /* sq_length */ --- 87,90 ---- *************** *** 137,140 **** --- 95,100 ---- }; + staticforward PyObject * range_iter(PyObject *seq); + PyTypeObject PyRange_Type = { PyObject_HEAD_INIT(&PyType_Type) *************** *** 155,159 **** 0, /* tp_call */ 0, /* tp_str */ ! PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ --- 115,119 ---- 0, /* tp_call */ 0, /* tp_str */ ! 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ *************** *** 164,169 **** 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ ! (getiterfunc)range_getiter, /* tp_iter */ ! (iternextfunc)range_next, /* tp_iternext */ ! range_methods, /* tp_methods */ }; --- 124,214 ---- 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ ! (getiterfunc)range_iter, /* tp_iter */ }; + + /*********************** Xrange Iterator **************************/ + + typedef struct { + PyObject_HEAD + long index; + long start; + long step; + long len; + } rangeiterobject; + + PyTypeObject Pyrangeiter_Type; + + PyObject * + range_iter(PyObject *seq) + { + rangeiterobject *it; + + if (!PyRange_Check(seq)) { + PyErr_BadInternalCall(); + return NULL; + } + it = PyObject_New(rangeiterobject, &Pyrangeiter_Type); + if (it == NULL) + return NULL; + it->index = 0; + it->start = ((rangeobject *)seq)->start; + it->step = ((rangeobject *)seq)->step; + it->len = ((rangeobject *)seq)->len; + return (PyObject *)it; + } + + static PyObject * + rangeiter_getiter(PyObject *it) + { + Py_INCREF(it); + return it; + } + + static PyObject * + rangeiter_next(rangeiterobject *r) + { + if (r->index < r->len) + return PyInt_FromLong(r->start + (r->index++) * r->step); + PyErr_SetObject(PyExc_StopIteration, Py_None); + return NULL; + } + + static PyMethodDef rangeiter_methods[] = { + {"next", (PyCFunction)rangeiter_next, METH_NOARGS, + "it.next() -- get the next value, or raise StopIteration"}, + {NULL, NULL} /* sentinel */ + }; + + PyTypeObject Pyrangeiter_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, /* ob_size */ + "rangeiterator", /* tp_name */ + sizeof(rangeiterobject), /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + (destructor)PyObject_Del, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + 0, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + (getiterfunc)rangeiter_getiter, /* tp_iter */ + (iternextfunc)rangeiter_next, /* tp_iternext */ + rangeiter_methods, /* tp_methods */ + }; + From pierslauder@users.sourceforge.net Wed Jun 5 23:32:00 2002 From: pierslauder@users.sourceforge.net (pierslauder@users.sourceforge.net) Date: Wed, 05 Jun 2002 15:32:00 -0700 Subject: [Python-checkins] python/dist/src/Lib imaplib.py,1.48,1.49 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv19046/dist/src/Lib Modified Files: imaplib.py Log Message: open method changed to use arguments and set instance host/port values (instead of __init__) Index: imaplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/imaplib.py,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** imaplib.py 1 Jun 2002 14:18:45 -0000 1.48 --- imaplib.py 5 Jun 2002 22:31:57 -0000 1.49 *************** *** 134,139 **** def __init__(self, host = '', port = IMAP4_PORT): - self.host = host - self.port = port self.debug = Debug self.state = 'LOGOUT' --- 134,137 ---- *************** *** 206,216 **** ! def open(self, host, port): ! """Setup connection to remote server on "host:port". This connection will be used by the routines: read, readline, send, shutdown. """ self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ! self.sock.connect((self.host, self.port)) self.file = self.sock.makefile('rb') --- 204,217 ---- ! def open(self, host = '', port = IMAP4_PORT): ! """Setup connection to remote server on "host:port" ! (default: localhost:standard IMAP4 port). This connection will be used by the routines: read, readline, send, shutdown. """ + self.host = host + self.port = port self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ! self.sock.connect((host, port)) self.file = self.sock.makefile('rb') *************** *** 1006,1017 **** ! def open(self, host, port): """Setup connection to remote server on "host:port". This connection will be used by the routines: read, readline, send, shutdown. """ self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ! self.sock.connect((self.host, self.port)) ! self.sslobj = socket.ssl(self.sock,self.keyfile, self.certfile) --- 1007,1021 ---- ! def open(self, host = '', port = IMAP4_SSL_PORT): """Setup connection to remote server on "host:port". + (default: localhost:standard IMAP4 SSL port). This connection will be used by the routines: read, readline, send, shutdown. """ + self.host = host + self.port = port self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ! self.sock.connect((host, port)) ! self.sslobj = socket.ssl(self.sock, self.keyfile, self.certfile) From rhettinger@users.sourceforge.net Thu Jun 6 00:12:46 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed, 05 Jun 2002 16:12:46 -0700 Subject: [Python-checkins] python/dist/src/Lib types.py,1.27,1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv2645/Lib Modified Files: types.py Log Message: Skip Montanaro's patch, SF 559833, exposing xrange type in builtins. Also, added more regression tests to cover the new type and test its conformity with range(). Index: types.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/types.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** types.py 21 May 2002 23:17:12 -0000 1.27 --- types.py 5 Jun 2002 23:12:44 -0000 1.28 *************** *** 63,67 **** ModuleType = type(sys) FileType = file ! XRangeType = type(xrange(0)) try: --- 63,67 ---- ModuleType = type(sys) FileType = file ! XRangeType = xrange try: From rhettinger@users.sourceforge.net Thu Jun 6 00:12:47 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed, 05 Jun 2002 16:12:47 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_b2.py,1.34,1.35 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv2645/Lib/test Modified Files: test_b2.py Log Message: Skip Montanaro's patch, SF 559833, exposing xrange type in builtins. Also, added more regression tests to cover the new type and test its conformity with range(). Index: test_b2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_b2.py,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** test_b2.py 12 May 2002 07:19:37 -0000 1.34 --- test_b2.py 5 Jun 2002 23:12:44 -0000 1.35 *************** *** 296,299 **** --- 296,304 ---- if tuple(xrange(0,10,2)) != tuple(range(0,10,2)): raise TestFailed, 'xrange(0,10,2)' + x = xrange(10); a = iter(x); b = iter(a) # test clearing of SF bug 564601 + if id(x) == id(a): raise TestFailed, "xrange doesn't have a separate iterator" + if id(a) != id(b): raise TestFailed, "xrange iterator not behaving like range" + if type(x) != xrange: raise TestFailed, "xrange type not exposed" # SF 559833 + if list(x) != list(x): raise TestFailed, "xrange should be restartable" print 'zip' From rhettinger@users.sourceforge.net Thu Jun 6 00:12:47 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed, 05 Jun 2002 16:12:47 -0700 Subject: [Python-checkins] python/dist/src/Objects rangeobject.c,2.38,2.39 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv2645/Objects Modified Files: rangeobject.c Log Message: Skip Montanaro's patch, SF 559833, exposing xrange type in builtins. Also, added more regression tests to cover the new type and test its conformity with range(). Index: rangeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/rangeobject.c,v retrieving revision 2.38 retrieving revision 2.39 diff -C2 -d -r2.38 -r2.39 *** rangeobject.c 5 Jun 2002 20:08:48 -0000 2.38 --- rangeobject.c 5 Jun 2002 23:12:44 -0000 2.39 *************** *** 48,51 **** --- 48,121 ---- } + /* Return number of items in range/xrange (lo, hi, step). step > 0 + * required. Return a value < 0 if & only if the true value is too + * large to fit in a signed long. + */ + static long + get_len_of_range(long lo, long hi, long step) + { + /* ------------------------------------------------------------- + If lo >= hi, the range is empty. + Else if n values are in the range, the last one is + lo + (n-1)*step, which must be <= hi-1. Rearranging, + n <= (hi - lo - 1)/step + 1, so taking the floor of the RHS gives + the proper value. Since lo < hi in this case, hi-lo-1 >= 0, so + the RHS is non-negative and so truncation is the same as the + floor. Letting M be the largest positive long, the worst case + for the RHS numerator is hi=M, lo=-M-1, and then + hi-lo-1 = M-(-M-1)-1 = 2*M. Therefore unsigned long has enough + precision to compute the RHS exactly. + ---------------------------------------------------------------*/ + long n = 0; + if (lo < hi) { + unsigned long uhi = (unsigned long)hi; + unsigned long ulo = (unsigned long)lo; + unsigned long diff = uhi - ulo - 1; + n = (long)(diff / (unsigned long)step + 1); + } + return n; + } + + static PyObject * + range_new(PyTypeObject *type, PyObject *args, PyObject *kw) + { + long ilow = 0, ihigh = 0, istep = 1; + long n; + + if (PyTuple_Size(args) <= 1) { + if (!PyArg_ParseTuple(args, + "l;xrange() requires 1-3 int arguments", + &ihigh)) + return NULL; + } + else { + if (!PyArg_ParseTuple(args, + "ll|l;xrange() requires 1-3 int arguments", + &ilow, &ihigh, &istep)) + return NULL; + } + if (istep == 0) { + PyErr_SetString(PyExc_ValueError, "xrange() arg 3 must not be zero"); + return NULL; + } + if (istep > 0) + n = get_len_of_range(ilow, ihigh, istep); + else + n = get_len_of_range(ihigh, ilow, -istep); + if (n < 0) { + PyErr_SetString(PyExc_OverflowError, + "xrange() result has too many items"); + return NULL; + } + return PyRange_New(ilow, n, istep, 1); + } + + static char range_doc[] = + "xrange([start,] stop[, step]) -> xrange object\n\ + \n\ + Like range(), but instead of returning a list, returns an object that\n\ + generates the numbers in the range on demand. This is slightly slower\n\ + than range() but more memory efficient."; + static PyObject * range_item(rangeobject *r, int i) *************** *** 119,128 **** 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ ! 0, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ ! (getiterfunc)range_iter, /* tp_iter */ }; --- 189,210 ---- 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ ! range_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ ! (getiterfunc)range_iter, /* tp_iter */ ! 0, /* tp_iternext */ ! 0, /* tp_methods */ ! 0, /* tp_members */ ! 0, /* tp_getset */ ! 0, /* tp_base */ ! 0, /* tp_dict */ ! 0, /* tp_descr_get */ ! 0, /* tp_descr_set */ ! 0, /* tp_dictoffset */ ! 0, /* tp_init */ ! 0, /* tp_alloc */ ! range_new, /* tp_new */ }; From rhettinger@users.sourceforge.net Thu Jun 6 00:12:47 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed, 05 Jun 2002 16:12:47 -0700 Subject: [Python-checkins] python/dist/src/Python bltinmodule.c,2.257,2.258 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv2645/Python Modified Files: bltinmodule.c Log Message: Skip Montanaro's patch, SF 559833, exposing xrange type in builtins. Also, added more regression tests to cover the new type and test its conformity with range(). Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.257 retrieving revision 2.258 diff -C2 -d -r2.257 -r2.258 *** bltinmodule.c 31 May 2002 19:58:02 -0000 2.257 --- bltinmodule.c 5 Jun 2002 23:12:45 -0000 2.258 *************** *** 1366,1411 **** static PyObject * - builtin_xrange(PyObject *self, PyObject *args) - { - long ilow = 0, ihigh = 0, istep = 1; - long n; - - if (PyTuple_Size(args) <= 1) { - if (!PyArg_ParseTuple(args, - "l;xrange() requires 1-3 int arguments", - &ihigh)) - return NULL; - } - else { - if (!PyArg_ParseTuple(args, - "ll|l;xrange() requires 1-3 int arguments", - &ilow, &ihigh, &istep)) - return NULL; - } - if (istep == 0) { - PyErr_SetString(PyExc_ValueError, "xrange() arg 3 must not be zero"); - return NULL; - } - if (istep > 0) - n = get_len_of_range(ilow, ihigh, istep); - else - n = get_len_of_range(ihigh, ilow, -istep); - if (n < 0) { - PyErr_SetString(PyExc_OverflowError, - "xrange() result has too many items"); - return NULL; - } - return PyRange_New(ilow, n, istep, 1); - } - - static char xrange_doc[] = - "xrange([start,] stop[, step]) -> xrange object\n\ - \n\ - Like range(), but instead of returning a list, returns an object that\n\ - generates the numbers in the range on demand. This is slightly slower\n\ - than range() but more memory efficient."; - - - static PyObject * builtin_raw_input(PyObject *self, PyObject *args) { --- 1366,1369 ---- *************** *** 1861,1865 **** #endif {"vars", builtin_vars, METH_VARARGS, vars_doc}, - {"xrange", builtin_xrange, METH_VARARGS, xrange_doc}, {"zip", builtin_zip, METH_VARARGS, zip_doc}, {NULL, NULL}, --- 1819,1822 ---- *************** *** 1910,1913 **** --- 1867,1871 ---- SETBUILTIN("tuple", &PyTuple_Type); SETBUILTIN("type", &PyType_Type); + SETBUILTIN("xrange", &PyRange_Type); /* Note that open() is just an alias of file(). */ From doerwalter@users.sourceforge.net Thu Jun 6 10:48:18 2002 From: doerwalter@users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Thu, 06 Jun 2002 02:48:18 -0700 Subject: [Python-checkins] python/dist/src/Lib fileinput.py,1.13,1.14 shutil.py,1.21,1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv18451/Lib Modified Files: fileinput.py shutil.py Log Message: Replace obsolete stat module constants with equivalent attributes in a few more spots. This closes SF patch http://www.python.org/sf/562373 Index: fileinput.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/fileinput.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** fileinput.py 23 May 2002 15:15:29 -0000 1.13 --- fileinput.py 6 Jun 2002 09:48:12 -0000 1.14 *************** *** 80,84 **** """ ! import sys, os, stat __all__ = ["input","close","nextfile","filename","lineno","filelineno", --- 80,84 ---- """ ! import sys, os __all__ = ["input","close","nextfile","filename","lineno","filelineno", *************** *** 301,305 **** self._file = open(self._backupfilename, "r") try: ! perm = os.fstat(self._file.fileno())[stat.ST_MODE] except: self._output = open(self._filename, "w") --- 301,305 ---- self._file = open(self._backupfilename, "r") try: ! perm = os.fstat(self._file.fileno()).st_mode except: self._output = open(self._filename, "w") Index: shutil.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/shutil.py,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** shutil.py 2 Jun 2002 00:40:05 -0000 1.21 --- shutil.py 6 Jun 2002 09:48:13 -0000 1.22 *************** *** 39,43 **** if hasattr(os, 'chmod'): st = os.stat(src) ! mode = stat.S_IMODE(st[stat.ST_MODE]) os.chmod(dst, mode) --- 39,43 ---- if hasattr(os, 'chmod'): st = os.stat(src) ! mode = stat.S_IMODE(st.st_mode) os.chmod(dst, mode) *************** *** 45,51 **** """Copy all stat info (mode bits, atime and mtime) from src to dst""" st = os.stat(src) ! mode = stat.S_IMODE(st[stat.ST_MODE]) if hasattr(os, 'utime'): ! os.utime(dst, (st[stat.ST_ATIME], st[stat.ST_MTIME])) if hasattr(os, 'chmod'): os.chmod(dst, mode) --- 45,51 ---- """Copy all stat info (mode bits, atime and mtime) from src to dst""" st = os.stat(src) ! mode = stat.S_IMODE(st.st_mode) if hasattr(os, 'utime'): ! os.utime(dst, (st.st_atime, st.st_mtime)) if hasattr(os, 'chmod'): os.chmod(dst, mode) From loewis@users.sourceforge.net Thu Jun 6 10:52:51 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu, 06 Jun 2002 02:52:51 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_commands.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv19407 Modified Files: test_commands.py Log Message: Patch #551911: Escape . properly. Index: test_commands.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_commands.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_commands.py 1 Apr 2002 23:56:03 -0000 1.4 --- test_commands.py 6 Jun 2002 09:52:49 -0000 1.5 *************** *** 39,43 **** \s+\d+ # It has a size. [^/]* # Skip the date. ! /. # and end with the name of the file. ''' --- 39,43 ---- \s+\d+ # It has a size. [^/]* # Skip the date. ! /\. # and end with the name of the file. ''' From loewis@users.sourceforge.net Thu Jun 6 11:58:37 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu, 06 Jun 2002 03:58:37 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libgetopt.tex,1.19,1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv9636/Doc/lib Modified Files: libgetopt.tex Log Message: Patch 473512: add GNU style scanning as gnu_getopt. Index: libgetopt.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libgetopt.tex,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** libgetopt.tex 20 Oct 2001 04:24:09 -0000 1.19 --- libgetopt.tex 6 Jun 2002 10:58:35 -0000 1.20 *************** *** 56,59 **** --- 56,71 ---- \end{funcdesc} + \begin{funcdesc}{gnu_getopt}{args, options\optional{, long_options}} + This function works like \function{getopt()}, except that GNU style + scanning mode is used by default. This means that option and + non-option arguments may be intermixed. The \function{getopt()} + function stops processing options as soon as a non-option argument is + encountered. + + If the first character of the option string is `+', or if the + environment variable POSIXLY_CORRECT is set, then option processing + stops as soon as a non-option argument is encountered. + \end{funcdesc} + \begin{excdesc}{GetoptError} This is raised when an unrecognized option is found in the argument From loewis@users.sourceforge.net Thu Jun 6 11:58:38 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu, 06 Jun 2002 03:58:38 -0700 Subject: [Python-checkins] python/dist/src/Lib getopt.py,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv9636/Lib Modified Files: getopt.py Log Message: Patch 473512: add GNU style scanning as gnu_getopt. Index: getopt.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/getopt.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** getopt.py 4 Apr 2002 22:55:58 -0000 1.17 --- getopt.py 6 Jun 2002 10:58:35 -0000 1.18 *************** *** 6,12 **** and `--'). Long options similar to those supported by GNU software may be used as well via an optional third argument. This module ! provides a single function and an exception: getopt() -- Parse command line options GetoptError -- exception (class) raised with 'opt' attribute, which is the option involved with the exception. --- 6,14 ---- and `--'). Long options similar to those supported by GNU software may be used as well via an optional third argument. This module ! provides two functions and an exception: getopt() -- Parse command line options + gnu_getopt() -- Like getopt(), but allow option and non-option arguments + to be intermixed. GetoptError -- exception (class) raised with 'opt' attribute, which is the option involved with the exception. *************** *** 14,23 **** # Long option support added by Lars Wirzenius . ! # Gerrit Holl moved the string-based exceptions # to class-based exceptions. __all__ = ["GetoptError","error","getopt"] class GetoptError(Exception): opt = '' --- 16,39 ---- # Long option support added by Lars Wirzenius . ! # # Gerrit Holl moved the string-based exceptions # to class-based exceptions. + # + # Peter Åstrand added gnu_getopt(). + # + # TODO for gnu_getopt(): + # + # - GNU getopt_long_only mechanism + # - allow the caller to specify ordering + # - RETURN_IN_ORDER option + # - GNU extension with '-' as first character of option string + # - optional arguments, specified by double colons + # - a option string with a W followed by semicolon should + # treat "-W foo" as "--foo" __all__ = ["GetoptError","error","getopt"] + import os + class GetoptError(Exception): opt = '' *************** *** 75,78 **** --- 91,144 ---- return opts, args + + def gnu_getopt(args, shortopts, longopts = []): + """getopt(args, options[, long_options]) -> opts, args + + This function works like getopt(), except that GNU style scanning + mode is used by default. This means that option and non-option + arguments may be intermixed. The getopt() function stops + processing options as soon as a non-option argument is + encountered. + + If the first character of the option string is `+', or if the + environment variable POSIXLY_CORRECT is set, then option + processing stops as soon as a non-option argument is encountered. + + """ + + opts = [] + prog_args = [] + if type(longopts) == type(""): + longopts = [longopts] + else: + longopts = list(longopts) + + # Allow options after non-option arguments? + if shortopts.startswith('+'): + shortopts = shortopts[1:] + all_options_first = 1 + elif os.getenv("POSIXLY_CORRECT"): + all_options_first = 1 + else: + all_options_first = 0 + + while args: + if args[0] == '--': + prog_args += args[1:] + break + + if args[0][:2] == '--': + opts, args = do_longs(opts, args[0][2:], longopts, args[1:]) + elif args[0][:1] == '-': + opts, args = do_shorts(opts, args[0][1:], shortopts, args[1:]) + else: + if all_options_first: + prog_args += args + break + else: + prog_args.append(args[0]) + args = args[1:] + + return opts, prog_args def do_longs(opts, opt, longopts, args): From loewis@users.sourceforge.net Thu Jun 6 11:58:38 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu, 06 Jun 2002 03:58:38 -0700 Subject: [Python-checkins] python/dist/src/Misc ACKS,1.176,1.177 NEWS,1.417,1.418 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv9636/Misc Modified Files: ACKS NEWS Log Message: Patch 473512: add GNU style scanning as gnu_getopt. Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.176 retrieving revision 1.177 diff -C2 -d -r1.176 -r1.177 *** ACKS 30 May 2002 15:42:58 -0000 1.176 --- ACKS 6 Jun 2002 10:58:36 -0000 1.177 *************** *** 21,24 **** --- 21,25 ---- Jason Asbahr David Ascher + Peter Åstrand John Aycock Donovan Baarda Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.417 retrieving revision 1.418 diff -C2 -d -r1.417 -r1.418 *** NEWS 4 Jun 2002 19:52:48 -0000 1.417 --- NEWS 6 Jun 2002 10:58:36 -0000 1.418 *************** *** 131,134 **** --- 131,136 ---- Library + - getopt.gnu_getopt was added. + - Stop using strings for exceptions. String objects used for exceptions are now classes deriving from Exception. The objects From loewis@users.sourceforge.net Thu Jun 6 11:58:38 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu, 06 Jun 2002 03:58:38 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_getopt.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv9636/Lib/test Modified Files: test_getopt.py Log Message: Patch 473512: add GNU style scanning as gnu_getopt. Index: test_getopt.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_getopt.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_getopt.py 17 Jan 2001 19:11:13 -0000 1.4 --- test_getopt.py 6 Jun 2002 10:58:36 -0000 1.5 *************** *** 5,8 **** --- 5,9 ---- from getopt import GetoptError from test_support import verify, verbose + import os def expectException(teststr, expected, failure=AssertionError): *************** *** 106,109 **** --- 107,129 ---- "opts, args = getopt.getopt(cmdline, 'a:b', ['alpha', 'beta'])", GetoptError) + + # Test handling of GNU style scanning mode. + if verbose: + print 'Running tests on getopt.gnu_getopt' + cmdline = ['-a', 'arg1', '-b', '1', '--alpha', '--beta=2'] + # GNU style + opts, args = getopt.gnu_getopt(cmdline, 'ab:', ['alpha', 'beta=']) + verify(opts == [('-a', ''), ('-b', '1'), ('--alpha', ''), ('--beta', '2')]) + verify(args == ['arg1']) + # Posix style via + + opts, args = getopt.gnu_getopt(cmdline, '+ab:', ['alpha', 'beta=']) + verify(opts == [('-a', '')]) + verify(args == ['arg1', '-b', '1', '--alpha', '--beta=2']) + # Posix style via POSIXLY_CORRECT + os.environ["POSIXLY_CORRECT"] = "1" + opts, args = getopt.gnu_getopt(cmdline, 'ab:', ['alpha', 'beta=']) + verify(opts == [('-a', '')]) + verify(args == ['arg1', '-b', '1', '--alpha', '--beta=2']) + if verbose: From mwh@users.sourceforge.net Thu Jun 6 14:03:46 2002 From: mwh@users.sourceforge.net (mwh@users.sourceforge.net) Date: Thu, 06 Jun 2002 06:03:46 -0700 Subject: [Python-checkins] python/dist/src configure.in,1.320,1.321 configure,1.310,1.311 pyconfig.h.in,1.37,1.38 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv13620 Modified Files: configure.in configure pyconfig.h.in Log Message: Stop testing for sigprocmask. This is a stop gap measure until I work out how to just activate my code on platforms where I know it works (currently only linux/x86). Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.320 retrieving revision 1.321 diff -C2 -d -r1.320 -r1.321 *** configure.in 4 Jun 2002 15:06:02 -0000 1.320 --- configure.in 6 Jun 2002 13:03:40 -0000 1.321 *************** *** 1584,1588 **** select setegid seteuid setgid setgroups \ setlocale setregid setreuid setsid setpgid setuid setvbuf snprintf \ ! sigaction siginterrupt sigprocmask sigrelse strftime strptime symlink \ sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \ truncate uname unsetenv waitpid _getpty getpriority) --- 1584,1588 ---- select setegid seteuid setgid setgroups \ setlocale setregid setreuid setsid setpgid setuid setvbuf snprintf \ ! sigaction siginterrupt sigrelse strftime strptime symlink \ sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \ truncate uname unsetenv waitpid _getpty getpriority) Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.310 retrieving revision 1.311 diff -C2 -d -r1.310 -r1.311 *** configure 4 Jun 2002 15:05:56 -0000 1.310 --- configure 6 Jun 2002 13:03:40 -0000 1.311 *************** *** 1,4 **** #! /bin/sh ! # From configure.in Revision: 1.319 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.53. --- 1,4 ---- #! /bin/sh ! # From configure.in Revision: 1.320 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.53. *************** *** 11279,11283 **** - for ac_func in alarm chown chroot clock confstr ctermid ctermid_r execv \ fchdir flock fork fsync fdatasync fpathconf ftime ftruncate \ --- 11279,11282 ---- *************** *** 11288,11292 **** select setegid seteuid setgid setgroups \ setlocale setregid setreuid setsid setpgid setuid setvbuf snprintf \ ! sigaction siginterrupt sigprocmask sigrelse strftime strptime symlink \ sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \ truncate uname unsetenv waitpid _getpty getpriority --- 11287,11291 ---- select setegid seteuid setgid setgroups \ setlocale setregid setreuid setsid setpgid setuid setvbuf snprintf \ ! sigaction siginterrupt sigrelse strftime strptime symlink \ sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \ truncate uname unsetenv waitpid _getpty getpriority Index: pyconfig.h.in =================================================================== RCS file: /cvsroot/python/python/dist/src/pyconfig.h.in,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** pyconfig.h.in 4 Jun 2002 15:06:05 -0000 1.37 --- pyconfig.h.in 6 Jun 2002 13:03:44 -0000 1.38 *************** *** 384,390 **** #undef HAVE_SIGNAL_H - /* Define to 1 if you have the `sigprocmask' function. */ - #undef HAVE_SIGPROCMASK - /* Define to 1 if you have the `sigrelse' function. */ #undef HAVE_SIGRELSE --- 384,387 ---- From neal@metaslash.com Thu Jun 6 14:17:45 2002 From: neal@metaslash.com (Neal Norwitz) Date: Thu, 06 Jun 2002 09:17:45 -0400 Subject: [Python-checkins] python/dist/src/Lib getopt.py,1.17,1.18 References: Message-ID: <3CFF60F9.48B334FF@metaslash.com> loewis@users.sourceforge.net wrote: > > Modified Files: > getopt.py > Log Message: > Patch 473512: add GNU style scanning as gnu_getopt. > > Index: getopt.py > =================================================================== > RCS file: /cvsroot/python/python/dist/src/Lib/getopt.py,v > + > + def gnu_getopt(args, shortopts, longopts = []): > + opts = [] > + prog_args = [] > + if type(longopts) == type(""): > + longopts = [longopts] > + else: > + longopts = list(longopts) > + > + # Allow options after non-option arguments? > + if shortopts.startswith('+'): > + shortopts = shortopts[1:] > + all_options_first = 1 > + elif os.getenv("POSIXLY_CORRECT"): > + all_options_first = 1 > + else: > + all_options_first = 0 For additions to the stdlib, should we try to make sure new features are used? In the above code, type(longopts) ... -> isinstance(longopts, str) (or basestring?) and all_options_first could be a bool. Neal From barry@zope.com Thu Jun 6 15:40:42 2002 From: barry@zope.com (Barry A. Warsaw) Date: Thu, 6 Jun 2002 10:40:42 -0400 Subject: [Python-checkins] python/dist/src/Lib getopt.py,1.17,1.18 References: <3CFF60F9.48B334FF@metaslash.com> Message-ID: <15615.29802.971924.15804@anthem.wooz.org> >>>>> "NN" == Neal Norwitz writes: NN> For additions to the stdlib, should we try to make sure new NN> features are used? In the above code, type(longopts) ... -> NN> isinstance(longopts, str) (or basestring?) and NN> all_options_first could be a bool. +1, for new modules that have no intention of being backported. We might as well start setting a good example! -Barry From guido@python.org Thu Jun 6 15:51:02 2002 From: guido@python.org (Guido van Rossum) Date: Thu, 06 Jun 2002 10:51:02 -0400 Subject: [Python-checkins] python/dist/src/Lib getopt.py,1.17,1.18 In-Reply-To: Your message of "Thu, 06 Jun 2002 09:17:45 EDT." <3CFF60F9.48B334FF@metaslash.com> References: <3CFF60F9.48B334FF@metaslash.com> Message-ID: <200206061451.g56Ep2L02021@odiug.zope.com> > For additions to the stdlib, should we try to make sure new features > are used? Not gratuitously :-), but yes. > In the above code, type(longopts) ... -> isinstance(longopts, str) > (or basestring?) and all_options_first could be a bool. +1 --Guido van Rossum (home page: http://www.python.org/~guido/) From jhylton@users.sourceforge.net Thu Jun 6 15:55:35 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Thu, 06 Jun 2002 07:55:35 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils/command clean.py,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory usw-pr-cvs1:/tmp/cvs-serv27453 Modified Files: clean.py Log Message: Change warning to debug level; it's a very minor issue. The specific warning is that clean didn't find a directory that should be removed if it exists. Index: clean.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/clean.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** clean.py 4 Jun 2002 20:14:43 -0000 1.13 --- clean.py 6 Jun 2002 14:54:56 -0000 1.14 *************** *** 55,60 **** remove_tree(self.build_temp, dry_run=self.dry_run) else: ! log.warn("'%s' does not exist -- can't clean it", ! self.build_temp) if self.all: --- 55,60 ---- remove_tree(self.build_temp, dry_run=self.dry_run) else: ! log.debug("'%s' does not exist -- can't clean it", ! self.build_temp) if self.all: From nnorwitz@users.sourceforge.net Thu Jun 6 15:58:45 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu, 06 Jun 2002 07:58:45 -0700 Subject: [Python-checkins] python/dist/src/Objects rangeobject.c,2.39,2.40 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv28266/Objects Modified Files: rangeobject.c Log Message: Pyrangeiter_Type && range_iter should be static Index: rangeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/rangeobject.c,v retrieving revision 2.39 retrieving revision 2.40 diff -C2 -d -r2.39 -r2.40 *** rangeobject.c 5 Jun 2002 23:12:44 -0000 2.39 --- rangeobject.c 6 Jun 2002 14:58:21 -0000 2.40 *************** *** 219,225 **** } rangeiterobject; ! PyTypeObject Pyrangeiter_Type; ! PyObject * range_iter(PyObject *seq) { --- 219,225 ---- } rangeiterobject; ! staticforward PyTypeObject Pyrangeiter_Type; ! static PyObject * range_iter(PyObject *seq) { *************** *** 262,270 **** }; ! PyTypeObject Pyrangeiter_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, /* ob_size */ ! "rangeiterator", /* tp_name */ ! sizeof(rangeiterobject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ --- 262,270 ---- }; ! static PyTypeObject Pyrangeiter_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, /* ob_size */ ! "rangeiterator", /* tp_name */ ! sizeof(rangeiterobject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ From rhettinger@users.sourceforge.net Thu Jun 6 16:45:41 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu, 06 Jun 2002 08:45:41 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_b1.py,1.46,1.47 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv12040/Lib/test Modified Files: test_b1.py Log Message: Close SF bug 563740. complex() now finds __complex__() in new style classes. Made conversion failure error messages consistent between types. Added related unittests. Index: test_b1.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_b1.py,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** test_b1.py 22 May 2002 23:19:17 -0000 1.46 --- test_b1.py 6 Jun 2002 15:45:38 -0000 1.47 *************** *** 102,105 **** --- 102,116 ---- print 'complex' + class OS: + def __complex__(self): return 1+10j + class NS(object): + def __complex__(self): return 1+10j + if complex(OS()) != 1+10j: raise TestFailed, '__complex__ in old style class' + if complex(NS()) != 1+10j: raise TestFailed, '__complex__ in new style class' + if complex("1+10j") != 1+10j: raise TestFailed, 'complex("1+10j")' + if complex(10) != 10+0j: raise TestFailed, 'complex(10)' + if complex(10.0) != 10+0j: raise TestFailed, 'complex(10.0)' + if complex(10L) != 10+0j: raise TestFailed, 'complex(10L)' + if complex(10+0j) != 10+0j: raise TestFailed, 'complex(10+0j)' if complex(1,10) != 1+10j: raise TestFailed, 'complex(1,10)' if complex(1,10L) != 1+10j: raise TestFailed, 'complex(1,10L)' From rhettinger@users.sourceforge.net Thu Jun 6 16:45:41 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu, 06 Jun 2002 08:45:41 -0700 Subject: [Python-checkins] python/dist/src/Objects complexobject.c,2.59,2.60 abstract.c,2.102,2.103 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv12040/Objects Modified Files: complexobject.c abstract.c Log Message: Close SF bug 563740. complex() now finds __complex__() in new style classes. Made conversion failure error messages consistent between types. Added related unittests. Index: complexobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/complexobject.c,v retrieving revision 2.59 retrieving revision 2.60 diff -C2 -d -r2.59 -r2.60 *** complexobject.c 15 Apr 2002 12:39:12 -0000 2.59 --- complexobject.c 6 Jun 2002 15:45:38 -0000 2.60 *************** *** 812,819 **** complex_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { ! PyObject *r, *i, *tmp; PyNumberMethods *nbr, *nbi = NULL; Py_complex cr, ci; int own_r = 0; static char *kwlist[] = {"real", "imag", 0}; --- 812,820 ---- complex_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { ! PyObject *r, *i, *tmp, *f; PyNumberMethods *nbr, *nbi = NULL; Py_complex cr, ci; int own_r = 0; + static PyObject *complexstr; static char *kwlist[] = {"real", "imag", 0}; *************** *** 838,841 **** --- 839,862 ---- } + /* XXX Hack to support classes with __complex__ method */ + if (complexstr == NULL) { + complexstr = PyString_InternFromString("__complex__"); + if (complexstr == NULL) + return NULL; + } + f = PyObject_GetAttr(r, complexstr); + if (f == NULL) + PyErr_Clear(); + else { + PyObject *args = Py_BuildValue("()"); + if (args == NULL) + return NULL; + r = PyEval_CallObject(f, args); + Py_DECREF(args); + Py_DECREF(f); + if (r == NULL) + return NULL; + own_r = 1; + } nbr = r->ob_type->tp_as_number; if (i != NULL) *************** *** 844,873 **** ((i != NULL) && (nbi == NULL || nbi->nb_float == NULL))) { PyErr_SetString(PyExc_TypeError, ! "complex() arg can't be converted to complex"); return NULL; - } - /* XXX Hack to support classes with __complex__ method */ - if (PyInstance_Check(r)) { - static PyObject *complexstr; - PyObject *f; - if (complexstr == NULL) { - complexstr = PyString_InternFromString("__complex__"); - if (complexstr == NULL) - return NULL; - } - f = PyObject_GetAttr(r, complexstr); - if (f == NULL) - PyErr_Clear(); - else { - PyObject *args = Py_BuildValue("()"); - if (args == NULL) - return NULL; - r = PyEval_CallObject(f, args); - Py_DECREF(args); - Py_DECREF(f); - if (r == NULL) - return NULL; - own_r = 1; - } } if (PyComplex_Check(r)) { --- 865,870 ---- ((i != NULL) && (nbi == NULL || nbi->nb_float == NULL))) { PyErr_SetString(PyExc_TypeError, ! "complex() argument must be a string or a number"); return NULL; } if (PyComplex_Check(r)) { Index: abstract.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/abstract.c,v retrieving revision 2.102 retrieving revision 2.103 diff -C2 -d -r2.102 -r2.103 *** abstract.c 5 Jun 2002 12:55:19 -0000 2.102 --- abstract.c 6 Jun 2002 15:45:38 -0000 2.103 *************** *** 904,908 **** return int_from_string((char*)buffer, buffer_len); ! return type_error("object can't be converted to int"); } --- 904,908 ---- return int_from_string((char*)buffer, buffer_len); ! return type_error("int() argument must be a string or a number"); } *************** *** 961,965 **** return long_from_string(buffer, buffer_len); ! return type_error("object can't be converted to long"); } --- 961,965 ---- return long_from_string(buffer, buffer_len); ! return type_error("long() argument must be a string or a number"); } From doerwalter@users.sourceforge.net Thu Jun 6 18:01:24 2002 From: doerwalter@users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Thu, 06 Jun 2002 10:01:24 -0700 Subject: [Python-checkins] python/dist/src/Tools/webchecker webchecker.py,1.26,1.27 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/webchecker In directory usw-pr-cvs1:/tmp/cvs-serv6787/Tools/webchecker Modified Files: webchecker.py Log Message: Apply diff.txt from SF patch http://www.python.org/sf/561478 This uses cgi.parse_header() in Checker.checkforhtml(), so that webchecker recognises the mime type text/html even if options are specified. Index: webchecker.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/webchecker/webchecker.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** webchecker.py 8 Mar 2002 17:19:10 -0000 1.26 --- webchecker.py 6 Jun 2002 17:01:21 -0000 1.27 *************** *** 118,121 **** --- 118,122 ---- import urlparse import sgmllib + import cgi import mimetypes *************** *** 544,548 **** def checkforhtml(self, info, url): if info.has_key('content-type'): ! ctype = string.lower(info['content-type']) else: if url[-1:] == "/": --- 545,549 ---- def checkforhtml(self, info, url): if info.has_key('content-type'): ! ctype = string.lower(cgi.parse_header(info['content-type'])[0]) else: if url[-1:] == "/": From gvanrossum@users.sourceforge.net Thu Jun 6 18:41:24 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 06 Jun 2002 10:41:24 -0700 Subject: [Python-checkins] python/dist/src/Lib copy.py,1.26,1.27 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv19327 Modified Files: copy.py Log Message: Fix from SF patch 565085: copy._reduction doesn't __setstate__. Straightforward fix. Will backport to 2.2. If there's ever a new 2.1 release, this could be backported there too (since it's an issue with anything that's got both a __reduce__ and a __setstate__). Index: copy.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/copy.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** copy.py 2 Jun 2002 18:55:56 -0000 1.26 --- copy.py 6 Jun 2002 17:41:20 -0000 1.27 *************** *** 302,306 **** if deep: state = deepcopy(state, memo) ! y.__dict__.update(state) return y --- 302,309 ---- if deep: state = deepcopy(state, memo) ! if hasattr(y, '__setstate__'): ! y.__setstate__(state) ! else: ! y.__dict__.update(state) return y From gvanrossum@users.sourceforge.net Thu Jun 6 18:53:06 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 06 Jun 2002 10:53:06 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_descr.py,1.138,1.139 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv23305 Modified Files: test_descr.py Log Message: Fix from SF patch 565085: copy._reduction doesn't __setstate__. Straightforward fix. Will backport to 2.2. If there's ever a new 2.1 release, this could be backported there too (since it's an issue with anything that's got both a __reduce__ and a __setstate__). Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.138 retrieving revision 1.139 diff -C2 -d -r1.138 -r1.139 *** test_descr.py 4 Jun 2002 19:52:53 -0000 1.138 --- test_descr.py 6 Jun 2002 17:53:03 -0000 1.139 *************** *** 3072,3075 **** --- 3072,3103 ---- raise TestFailed, "string subclass allowed as exception" + def copy_setstate(): + if verbose: + print "Testing that copy.*copy() correctly uses __setstate__..." + import copy + class C(object): + def __init__(self, foo=None): + self.foo = foo + self.__foo = foo + def setfoo(self, foo=None): + self.foo = foo + def getfoo(self): + return self.__foo + def __getstate__(self): + return [self.foo] + def __setstate__(self, lst): + assert len(lst) == 1 + self.__foo = self.foo = lst[0] + a = C(42) + a.setfoo(24) + vereq(a.foo, 24) + vereq(a.getfoo(), 42) + b = copy.copy(a) + vereq(b.foo, 24) + vereq(b.getfoo(), 24) + b = copy.deepcopy(a) + vereq(b.foo, 24) + vereq(b.getfoo(), 24) + def do_this_first(): if verbose: *************** *** 3154,3157 **** --- 3182,3186 ---- docdescriptor() string_exceptions() + copy_setstate() if verbose: print "All OK" From gvanrossum@users.sourceforge.net Thu Jun 6 18:55:37 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 06 Jun 2002 10:55:37 -0700 Subject: [Python-checkins] python/dist/src/Lib copy.py,1.22.10.2,1.22.10.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv24145 Modified Files: Tag: release22-maint copy.py Log Message: Backport: Fix from SF patch 565085: copy._reduction doesn't __setstate__. Straightforward fix. Index: copy.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/copy.py,v retrieving revision 1.22.10.2 retrieving revision 1.22.10.3 diff -C2 -d -r1.22.10.2 -r1.22.10.3 *** copy.py 5 Mar 2002 13:58:42 -0000 1.22.10.2 --- copy.py 6 Jun 2002 17:55:35 -0000 1.22.10.3 *************** *** 302,306 **** if deep: state = deepcopy(state, memo) ! y.__dict__.update(state) return y --- 302,309 ---- if deep: state = deepcopy(state, memo) ! if hasattr(y, '__setstate__'): ! y.__setstate__(state) ! else: ! y.__dict__.update(state) return y From gvanrossum@users.sourceforge.net Thu Jun 6 18:55:38 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 06 Jun 2002 10:55:38 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_descr.py,1.113.4.16,1.113.4.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv24145/test Modified Files: Tag: release22-maint test_descr.py Log Message: Backport: Fix from SF patch 565085: copy._reduction doesn't __setstate__. Straightforward fix. Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.113.4.16 retrieving revision 1.113.4.17 diff -C2 -d -r1.113.4.16 -r1.113.4.17 *** test_descr.py 4 Jun 2002 21:19:55 -0000 1.113.4.16 --- test_descr.py 6 Jun 2002 17:55:35 -0000 1.113.4.17 *************** *** 2932,2935 **** --- 2932,2963 ---- vereq(y, (x, "foo")) + def copy_setstate(): + if verbose: + print "Testing that copy.*copy() correctly uses __setstate__..." + import copy + class C(object): + def __init__(self, foo=None): + self.foo = foo + self.__foo = foo + def setfoo(self, foo=None): + self.foo = foo + def getfoo(self): + return self.__foo + def __getstate__(self): + return [self.foo] + def __setstate__(self, lst): + assert len(lst) == 1 + self.__foo = self.foo = lst[0] + a = C(42) + a.setfoo(24) + vereq(a.foo, 24) + vereq(a.getfoo(), 42) + b = copy.copy(a) + vereq(b.foo, 24) + vereq(b.getfoo(), 24) + b = copy.deepcopy(a) + vereq(b.foo, 24) + vereq(b.getfoo(), 24) + def test_main(): class_docstrings() *************** *** 2991,2994 **** --- 3019,3023 ---- docdescriptor() imulbug() + copy_setstate() if verbose: print "All OK" From loewis@users.sourceforge.net Thu Jun 6 19:14:52 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu, 06 Jun 2002 11:14:52 -0700 Subject: [Python-checkins] python/dist/src/Lib getopt.py,1.18,1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv31329/Lib Modified Files: getopt.py Log Message: Use isinstance for the type check, use booleans. Index: getopt.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/getopt.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** getopt.py 6 Jun 2002 10:58:35 -0000 1.18 --- getopt.py 6 Jun 2002 18:14:50 -0000 1.19 *************** *** 109,113 **** opts = [] prog_args = [] ! if type(longopts) == type(""): longopts = [longopts] else: --- 109,113 ---- opts = [] prog_args = [] ! if isinstance(longopts, str): longopts = [longopts] else: *************** *** 117,125 **** if shortopts.startswith('+'): shortopts = shortopts[1:] ! all_options_first = 1 elif os.getenv("POSIXLY_CORRECT"): ! all_options_first = 1 else: ! all_options_first = 0 while args: --- 117,125 ---- if shortopts.startswith('+'): shortopts = shortopts[1:] ! all_options_first = True elif os.getenv("POSIXLY_CORRECT"): ! all_options_first = True else: ! all_options_first = False while args: From nnorwitz@users.sourceforge.net Thu Jun 6 19:16:16 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu, 06 Jun 2002 11:16:16 -0700 Subject: [Python-checkins] python/dist/src/Lib posixpath.py,1.50,1.51 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv31935/Lib Modified Files: posixpath.py Log Message: Remove another reference to stat.ST_MODE Index: posixpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/posixpath.py,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** posixpath.py 1 Jun 2002 19:51:15 -0000 1.50 --- posixpath.py 6 Jun 2002 18:16:14 -0000 1.51 *************** *** 281,285 **** except os.error: continue ! if stat.S_ISDIR(st[stat.ST_MODE]): walk(name, func, arg) --- 281,285 ---- except os.error: continue ! if stat.S_ISDIR(st.st_mode): walk(name, func, arg) From nnorwitz@users.sourceforge.net Thu Jun 6 19:30:13 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu, 06 Jun 2002 11:30:13 -0700 Subject: [Python-checkins] python/dist/src/Lib/compiler pyassem.py,1.29,1.30 pycodegen.py,1.60,1.61 transformer.py,1.33,1.34 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/compiler In directory usw-pr-cvs1:/tmp/cvs-serv3705 Modified Files: pyassem.py pycodegen.py transformer.py Log Message: Remove uses of string module and stat.ST_MODE Index: pyassem.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/compiler/pyassem.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** pyassem.py 18 Oct 2001 21:57:37 -0000 1.29 --- pyassem.py 6 Jun 2002 18:30:10 -0000 1.30 *************** *** 3,7 **** import dis import new - import string import sys import types --- 3,6 ---- *************** *** 247,251 **** insts = map(str, self.insts) return "" % (self.label, self.bid, ! string.join(insts, '\n')) def emit(self, inst): --- 246,250 ---- insts = map(str, self.insts) return "" % (self.label, self.bid, ! '\n'.join(insts)) def emit(self, inst): *************** *** 714,721 **** def getCode(self): ! return string.join(self.code, '') def getTable(self): ! return string.join(map(chr, self.lnotab), '') class StackDepthTracker: --- 713,720 ---- def getCode(self): ! return ''.join(self.code) def getTable(self): ! return ''.join(map(chr, self.lnotab)) class StackDepthTracker: Index: pycodegen.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/compiler/pycodegen.py,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** pycodegen.py 16 Feb 2002 07:34:19 -0000 1.60 --- pycodegen.py 6 Jun 2002 18:30:10 -0000 1.61 *************** *** 2,7 **** import os import marshal - import stat - import string import struct import sys --- 2,5 ---- *************** *** 136,140 **** # to indicate the type of the value. simplest way to get the # same effect is to call marshal and then skip the code. ! mtime = os.stat(self.filename)[stat.ST_MTIME] mtime = struct.pack('i', mtime) return self.MAGIC + mtime --- 134,138 ---- # to indicate the type of the value. simplest way to get the # same effect is to call marshal and then skip the code. ! mtime = os.path.getmtime(self.filename) mtime = struct.pack('i', mtime) return self.MAGIC + mtime *************** *** 765,769 **** self.emit('LOAD_CONST', None) self.emit('IMPORT_NAME', name) ! mod = string.split(name, ".")[0] self.storeName(alias or mod) --- 763,767 ---- self.emit('LOAD_CONST', None) self.emit('IMPORT_NAME', name) ! mod = name.split(".")[0] self.storeName(alias or mod) *************** *** 791,795 **** def _resolveDots(self, name): ! elts = string.split(name, ".") if len(elts) == 1: return --- 789,793 ---- def _resolveDots(self, name): ! elts = name.split(".") if len(elts) == 1: return Index: transformer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/compiler/transformer.py,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** transformer.py 19 Apr 2002 22:56:37 -0000 1.33 --- transformer.py 6 Jun 2002 18:30:10 -0000 1.34 *************** *** 29,33 **** import symbol import token - import string import sys --- 29,32 ---- *************** *** 112,116 **** """Return a modified parse tree for the given suite text.""" # Hack for handling non-native line endings on non-DOS like OSs. ! text = string.replace(text, '\x0d', '') return self.transform(parser.suite(text)) --- 111,115 ---- """Return a modified parse tree for the given suite text.""" # Hack for handling non-native line endings on non-DOS like OSs. ! text = text.replace('\x0d', '') return self.transform(parser.suite(text)) From nnorwitz@users.sourceforge.net Thu Jun 6 20:25:34 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu, 06 Jun 2002 12:25:34 -0700 Subject: [Python-checkins] python/nondist/peps pep-291.txt,NONE,1.1 pep-0000.txt,1.184,1.185 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv21267 Modified Files: pep-0000.txt Added Files: pep-291.txt Log Message: Add PEP 291 for backward compatibility --- NEW FILE: pep-291.txt --- PEP: 291 Title: Backward Compatibility for Standard Library Version: $Revision: 1.1 $ Last-Modified: $Date: 2002/06/06 19:25:31 $ Author: neal@metaslash.com (Neal Norwitz) Status: Active Type: Informational Created: 06-Jun-2002 Post-History: Python-Version: 2.3 Abstract This PEP describes the packages and modules in the standard library which should remain backward compatible with previous versions of Python. Rationale Authors have various reasons why packages and modules should continue to work with previous versions of Python. In order to maintain backward compatibility for these modules while moving the rest of the standard library forward, it is necessary to know which modules can be modified and which should use old and possibly deprecated features. Generally, authors should attempt to keep changes backward compatible with the previous released version of Python in order to make bug fixes easier to backport. Features to Avoid The following list contains common features to avoid in order to maintain backward compatibility with each version of Python. This list is not complete! It is only meant as a general guide. Note the features to avoid were implemented in the following version. For example, features listed next to 1.5.2 were implemented in 2.0. Version Features ------- -------- 1.5.2 string methods, Unicode, list comprehensions, augmented assignment (eg, +=), zip(), import x as y, dict.setdefault(), print >> f, calling f(*args, **kw), plus 2.0 features 2.0 nested scopes, rich comparisons, function attributes, plus 2.1 features 2.1 use of object or new-style classes, iterators, using generators, nested scopes, or // without from __future__ import ... statement, plus 2.2 features 2.2 bool, True, False, basestring, enumerate(), {}.pop(), PendingDeprecationWarning, Universal Newlines, plus 2.3 features Backward Compatible Packages, Modules, and Tools Package/Module Maintainer(s) Python Version -------------- ------------- -------------- compiler Jeremy Hylton 2.1 distutils Andrew Kuchling 1.5.2 email Barry Warsaw 2.1 sre Fredrik Lundh 1.5.2 xml (PyXML) Martin v. Loewis 2.0 xmlrpclib Fredrik Lundh 1.5.2 Tool Maintainer(s) Python Version ---- ------------- -------------- scripts/freeze/modulefinder Thomas Heller 1.5.2 Copyright This document has been placed in the public domain. Local Variables: mode: indented-text indent-tabs-mode: nil sentence-end-double-space: t fill-column: 70 End: Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.184 retrieving revision 1.185 diff -C2 -d -r1.184 -r1.185 *** pep-0000.txt 29 May 2002 21:17:42 -0000 1.184 --- pep-0000.txt 6 Jun 2002 19:25:31 -0000 1.185 *************** *** 94,97 **** --- 94,98 ---- S 286 Enhanced Argument Tuples von Loewis S 287 reStructuredText Standard Docstring Format Goodger + I 291 Backward Compatibility for Standard Library Norwitz Finished PEPs (done, implemented in CVS) *************** *** 268,271 **** --- 269,273 ---- SD 288 Generators Attributes and Exceptions Hettinger SR 289 Generator Comprehensions Hettinger + I 291 Backward Compatibility for Standard Library Norwitz SR 666 Reject Foolish Indentation Creighton *************** *** 315,318 **** --- 317,321 ---- Montanaro, Skip skip@pobox.com Moore, Paul gustav@morpheus.demon.co.uk + Norwitz, Neal neal@metaslash.com Oliphant, Travis oliphant@ee.byu.edu Pelletier, Michel michel@digicool.com From gvanrossum@users.sourceforge.net Thu Jun 6 21:08:29 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 06 Jun 2002 13:08:29 -0700 Subject: [Python-checkins] python/dist/src/Modules socketmodule.c,1.216,1.217 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv1284 Modified Files: socketmodule.c Log Message: The tp_new implementation should initialize the errorhandler field, otherwise this code could segfault: from socket import socket s = socket.__new__(socket) s.recv(100) Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.216 retrieving revision 1.217 diff -C2 -d -r1.216 -r1.217 *** socketmodule.c 27 Apr 2002 18:44:31 -0000 1.216 --- socketmodule.c 6 Jun 2002 20:08:25 -0000 1.217 *************** *** 1691,1696 **** new = type->tp_alloc(type, 0); ! if (new != NULL) ((PySocketSockObject *)new)->sock_fd = -1; return new; } --- 1691,1698 ---- new = type->tp_alloc(type, 0); ! if (new != NULL) { ((PySocketSockObject *)new)->sock_fd = -1; + ((PySocketSockObject *)new)->errorhandler = &PySocket_Err; + } return new; } From gvanrossum@users.sourceforge.net Thu Jun 6 21:10:19 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 06 Jun 2002 13:10:19 -0700 Subject: [Python-checkins] python/dist/src/Modules socketmodule.c,1.200.6.4,1.200.6.5 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv1805 Modified Files: Tag: release22-maint socketmodule.c Log Message: Backport: The tp_new implementation should initialize the errorhandler field, otherwise this code could segfault: from socket import socket s = socket.__new__(socket) s.recv(100) Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.200.6.4 retrieving revision 1.200.6.5 diff -C2 -d -r1.200.6.4 -r1.200.6.5 *** socketmodule.c 20 Apr 2002 07:45:25 -0000 1.200.6.4 --- socketmodule.c 6 Jun 2002 20:10:16 -0000 1.200.6.5 *************** *** 1801,1806 **** new = type->tp_alloc(type, 0); ! if (new != NULL) ((PySocketSockObject *)new)->sock_fd = -1; return new; } --- 1801,1808 ---- new = type->tp_alloc(type, 0); ! if (new != NULL) { ((PySocketSockObject *)new)->sock_fd = -1; + ((PySocketSockObject *)new)->errorhandler = &PySocket_Err; + } return new; } From gvanrossum@users.sourceforge.net Thu Jun 6 21:11:17 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 06 Jun 2002 13:11:17 -0700 Subject: [Python-checkins] python/dist/src/Modules socketmodule.c,1.200.6.5,1.200.6.6 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv2059 Modified Files: Tag: release22-maint socketmodule.c Log Message: Oops. That wasn't supposed to be backported. :-( Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.200.6.5 retrieving revision 1.200.6.6 diff -C2 -d -r1.200.6.5 -r1.200.6.6 *** socketmodule.c 6 Jun 2002 20:10:16 -0000 1.200.6.5 --- socketmodule.c 6 Jun 2002 20:11:15 -0000 1.200.6.6 *************** *** 1801,1808 **** new = type->tp_alloc(type, 0); ! if (new != NULL) { ((PySocketSockObject *)new)->sock_fd = -1; - ((PySocketSockObject *)new)->errorhandler = &PySocket_Err; - } return new; } --- 1801,1806 ---- new = type->tp_alloc(type, 0); ! if (new != NULL) ((PySocketSockObject *)new)->sock_fd = -1; return new; } From gvanrossum@users.sourceforge.net Thu Jun 6 21:41:13 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 06 Jun 2002 13:41:13 -0700 Subject: [Python-checkins] python/dist/src/Modules socketmodule.c,1.217,1.218 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv11671 Modified Files: socketmodule.c Log Message: The insint() function is not used. Nuke it. Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.217 retrieving revision 1.218 diff -C2 -d -r1.217 -r1.218 *** socketmodule.c 6 Jun 2002 20:08:25 -0000 1.217 --- socketmodule.c 6 Jun 2002 20:41:10 -0000 1.218 *************** *** 2561,2579 **** - /* Convenience routine to export an integer value. - * - * Errors are silently ignored, for better or for worse... - */ - static void - insint(PyObject *d, char *name, int value) - { - PyObject *v = PyInt_FromLong((long) value); - if (!v || PyDict_SetItemString(d, name, v)) - PyErr_Clear(); - - Py_XDECREF(v); - } - - #ifdef MS_WINDOWS --- 2561,2564 ---- From gvanrossum@users.sourceforge.net Thu Jun 6 22:08:18 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 06 Jun 2002 14:08:18 -0700 Subject: [Python-checkins] python/dist/src/Lib socket.py,1.19,1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv19155/Lib Modified Files: socket.py Log Message: SF patch 555085 (timeout socket implementation) by Michael Gilfix. I've made considerable changes to Michael's code, specifically to use the select() system call directly and to store the timeout as a C double instead of a Python object; internally, -1.0 (or anything negative) represents the None from the API. I'm not 100% sure that all corner cases are covered correctly, so please keep an eye on this. Next I'm going to try it Windows before Tim complains. No way is this a bugfix candidate. :-) Index: socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/socket.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** socket.py 17 Feb 2002 04:25:24 -0000 1.19 --- socket.py 6 Jun 2002 21:08:16 -0000 1.20 *************** *** 135,139 **** 'bind', 'connect', 'connect_ex', 'fileno', 'listen', 'getpeername', 'getsockname', 'getsockopt', 'setsockopt', ! 'recv', 'recvfrom', 'send', 'sendall', 'sendto', 'setblocking', 'shutdown') class _socketobject: --- 135,140 ---- 'bind', 'connect', 'connect_ex', 'fileno', 'listen', 'getpeername', 'getsockname', 'getsockopt', 'setsockopt', ! 'recv', 'recvfrom', 'send', 'sendall', 'sendto', 'setblocking', ! 'settimeout', 'gettimeout', 'shutdown') class _socketobject: *************** *** 169,181 **** class _fileobject: ! def __init__(self, sock, mode, bufsize): self._sock = sock self._mode = mode ! if bufsize < 0: bufsize = 512 ! self._rbufsize = max(1, bufsize) self._wbufsize = bufsize ! self._wbuf = self._rbuf = "" def close(self): --- 170,184 ---- class _fileobject: + """Implements a file object on top of a regular socket object.""" ! def __init__(self, sock, mode='rb', bufsize=8192): self._sock = sock self._mode = mode ! if bufsize <= 0: bufsize = 512 ! self._rbufsize = bufsize self._wbufsize = bufsize ! self._rbuf = [ ] ! self._wbuf = [ ] def close(self): *************** *** 184,188 **** self.flush() finally: ! self._sock = 0 def __del__(self): --- 187,191 ---- self.flush() finally: ! self._sock = None def __del__(self): *************** *** 191,208 **** def flush(self): if self._wbuf: ! self._sock.sendall(self._wbuf) ! self._wbuf = "" ! def fileno(self): return self._sock.fileno() def write(self, data): ! self._wbuf = self._wbuf + data if self._wbufsize == 1: if '\n' in data: ! self.flush() ! else: ! if len(self._wbuf) >= self._wbufsize: ! self.flush() def writelines(self, list): --- 194,213 ---- def flush(self): if self._wbuf: ! buffer = ''.join(self._wbuf) ! self._sock.sendall(buffer) ! self._wbuf = [ ] ! def fileno (self): return self._sock.fileno() def write(self, data): ! self._wbuf.append (data) ! # A _wbufsize of 1 means we're doing unbuffered IO. ! # Flush accordingly. if self._wbufsize == 1: if '\n' in data: ! self.flush () ! elif self.__get_wbuf_len() >= self._wbufsize: ! self.flush() def writelines(self, list): *************** *** 210,260 **** self.flush() ! def read(self, n=-1): ! if n >= 0: ! k = len(self._rbuf) ! if n <= k: ! data = self._rbuf[:n] ! self._rbuf = self._rbuf[n:] ! return data ! n = n - k ! L = [self._rbuf] ! self._rbuf = "" ! while n > 0: ! new = self._sock.recv(max(n, self._rbufsize)) ! if not new: break ! k = len(new) ! if k > n: ! L.append(new[:n]) ! self._rbuf = new[n:] ! break ! L.append(new) ! n = n - k ! return "".join(L) ! k = max(512, self._rbufsize) ! L = [self._rbuf] ! self._rbuf = "" ! while 1: ! new = self._sock.recv(k) ! if not new: break ! L.append(new) ! k = min(k*2, 1024**2) ! return "".join(L) ! def readline(self, limit=-1): ! data = "" ! i = self._rbuf.find('\n') ! while i < 0 and not (0 < limit <= len(self._rbuf)): ! new = self._sock.recv(self._rbufsize) ! if not new: break ! i = new.find('\n') ! if i >= 0: i = i + len(self._rbuf) ! self._rbuf = self._rbuf + new ! if i < 0: i = len(self._rbuf) ! else: i = i+1 ! if 0 <= limit < len(self._rbuf): i = limit ! data, self._rbuf = self._rbuf[:i], self._rbuf[i:] return data ! def readlines(self, sizehint = 0): total = 0 list = [] --- 215,275 ---- self.flush() ! def __get_wbuf_len (self): ! buf_len = 0 ! for i in [len(x) for x in self._wbuf]: ! buf_len += i ! return buf_len ! def __get_rbuf_len(self): ! buf_len = 0 ! for i in [len(x) for x in self._rbuf]: ! buf_len += i ! return buf_len ! ! def read(self, size=-1): ! buf_len = self.__get_rbuf_len() ! while size < 0 or buf_len < size: ! recv_size = max(self._rbufsize, size - buf_len) ! data = self._sock.recv(recv_size) ! if not data: ! break ! buf_len += len(data) ! self._rbuf.append(data) ! data = ''.join(self._rbuf) ! # Clear the rbuf at the end so we're not affected by ! # an exception during a recv ! self._rbuf = [ ] ! if buf_len > size and size >= 0: ! self._rbuf.append(data[size:]) ! data = data[:size] return data ! def readline(self, size=-1): ! index = -1 ! buf_len = self.__get_rbuf_len() ! if len (self._rbuf): ! index = min([x.find('\n') for x in self._rbuf]) ! while index < 0 and (size < 0 or buf_len < size): ! recv_size = max(self._rbufsize, size - buf_len) ! data = self._sock.recv(recv_size) ! if not data: ! break ! buf_len += len(data) ! self._rbuf.append(data) ! index = data.find('\n') ! data = ''.join(self._rbuf) ! self._rbuf = [ ] ! index = data.find('\n') ! if index >= 0: ! index += 1 ! elif buf_len > size: ! index = size ! else: ! index = buf_len ! self._rbuf.append(data[index:]) ! data = data[:index] ! return data ! ! def readlines(self, sizehint=0): total = 0 list = [] From gvanrossum@users.sourceforge.net Thu Jun 6 22:08:18 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 06 Jun 2002 14:08:18 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_timeout.py,NONE,1.1 test_socket.py,1.23,1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv19155/Lib/test Modified Files: test_socket.py Added Files: test_timeout.py Log Message: SF patch 555085 (timeout socket implementation) by Michael Gilfix. I've made considerable changes to Michael's code, specifically to use the select() system call directly and to store the timeout as a C double instead of a Python object; internally, -1.0 (or anything negative) represents the None from the API. I'm not 100% sure that all corner cases are covered correctly, so please keep an eye on this. Next I'm going to try it Windows before Tim complains. No way is this a bugfix candidate. :-) --- NEW FILE: test_timeout.py --- #!/home/bernie/src/python23/dist/src/python import unittest import time import socket class creationTestCase(unittest.TestCase): """Test Case for socket.gettimeout() and socket.settimeout()""" def setUp(self): self.__s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) def tearDown(self): self.__s.close() def testObjectCreation(self): "Test Socket creation" self.assertEqual(self.__s.gettimeout(), None, "Timeout socket not default to disable (None)") def testFloatReturnValue(self): "Test return value of getter/setter" self.__s.settimeout(7.345) self.assertEqual(self.__s.gettimeout(), 7.345, "settimeout() and gettimeout() return different result") self.__s.settimeout(3) self.assertEqual(self.__s.gettimeout(), 3, "settimeout() and gettimeout() return different result") def testReturnType(self): "Test return type of getter/setter" self.__s.settimeout(1) self.assertEqual(type(self.__s.gettimeout()), type(1.0), "return type of gettimeout() is not FloatType") self.__s.settimeout(3.9) self.assertEqual(type(self.__s.gettimeout()), type(1.0), "return type of gettimeout() is not FloatType") class timeoutTestCase(unittest.TestCase): """Test Case for socket.socket() timeout functions""" def setUp(self): self.__s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.__addr_remote = ('www.google.com', 80) self.__addr_local = ('127.0.0.1', 25339) def tearDown(self): self.__s.close() def testConnectTimeout(self): "Test connect() timeout" _timeout = 0.02 self.__s.settimeout(_timeout) _t1 = time.time() self.failUnlessRaises(socket.error, self.__s.connect, self.__addr_remote) _t2 = time.time() _delta = abs(_t1 - _t2) self.assert_(_delta < _timeout + 0.5, "timeout (%f) is 0.5 seconds more than required (%f)" %(_delta, _timeout)) def testRecvTimeout(self): "Test recv() timeout" _timeout = 0.02 self.__s.connect(self.__addr_remote) self.__s.settimeout(_timeout) _t1 = time.time() self.failUnlessRaises(socket.error, self.__s.recv, 1024) _t2 = time.time() _delta = abs(_t1 - _t2) self.assert_(_delta < _timeout + 0.5, "timeout (%f) is 0.5 seconds more than required (%f)" %(_delta, _timeout)) def testAcceptTimeout(self): "Test accept() timeout()" _timeout = 2 self.__s.settimeout(_timeout) self.__s.bind(self.__addr_local) self.__s.listen(5) _t1 = time.time() self.failUnlessRaises(socket.error, self.__s.accept) _t2 = time.time() _delta = abs(_t1 - _t2) self.assert_(_delta < _timeout + 0.5, "timeout (%f) is 0.5 seconds more than required (%f)" %(_delta, _timeout)) def testRecvfromTimeout(self): "Test recvfrom() timeout()" _timeout = 2 self.__s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.__s.settimeout(_timeout) self.__s.bind(self.__addr_local) _t1 = time.time() self.failUnlessRaises(socket.error, self.__s.recvfrom, 8192) _t2 = time.time() _delta = abs(_t1 - _t2) self.assert_(_delta < _timeout + 0.5, "timeout (%f) is 0.5 seconds more than required (%f)" %(_delta, _timeout)) def testSend(self): "Test send() timeout" # couldn't figure out how to test it pass def testSendto(self): "Test sendto() timeout" # couldn't figure out how to test it pass def testSendall(self): "Test sendall() timeout" # couldn't figure out how to test it pass def suite(): suite = unittest.TestSuite() return suite if __name__ == "__main__": unittest.main() Index: test_socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** test_socket.py 9 Dec 2001 08:57:46 -0000 1.23 --- test_socket.py 6 Jun 2002 21:08:16 -0000 1.24 *************** *** 110,113 **** --- 110,114 ---- try: PORT = 50007 + msg = 'socket test\n' if not canfork or os.fork(): # parent is server *************** *** 134,144 **** if verbose: print 'file obj:', f while 1: ! data = conn.recv(1024) ! if not data: break ! if verbose: ! print 'received:', data ! conn.sendall(data) conn.close() else: --- 135,184 ---- if verbose: print 'file obj:', f + data = conn.recv(1024) + if verbose: + print 'received:', data + conn.sendall(data) + + # Perform a few tests on the windows file object + if verbose: + print "Staring _fileobject tests..." + f = socket._fileobject (conn, 'rb', 8192) + first_seg = f.read(7) + second_seg = f.read(5) + if not first_seg == 'socket ' or not second_seg == 'test\n': + print "Error performing read with the python _fileobject class" + os._exit (1) + elif verbose: + print "_fileobject buffered read works" + f.write (data) + f.flush () + + buf = '' while 1: ! char = f.read(1) ! if not char: ! print "Error performing unbuffered read with the python ", \ ! "_fileobject class" ! os._exit (1) ! buf += char ! if buf == msg: ! if verbose: ! print "__fileobject unbuffered read works" break ! if verbose: ! # If we got this far, write() must work as well ! print "__fileobject write works" ! f.write(buf) ! f.flush() ! ! line = f.readline() ! if not line == msg: ! print "Error perferming readline with the python _fileobject class" ! os._exit (1) ! f.write(line) ! f.flush() ! if verbose: ! print "__fileobject readline works" ! conn.close() else: *************** *** 150,158 **** print 'child connecting' s.connect(("127.0.0.1", PORT)) ! msg = 'socket test' ! s.send(msg) ! data = s.recv(1024) ! if msg != data: ! print 'parent/client mismatch' s.close() finally: --- 190,205 ---- print 'child connecting' s.connect(("127.0.0.1", PORT)) ! ! iteration = 0 ! while 1: ! s.send(msg) ! data = s.recv(12) ! if not data: ! break ! if msg != data: ! print "parent/client mismatch. Failed in %s iteration. Received: [%s]" \ ! %(iteration, data) ! time.sleep (1) ! iteration += 1 s.close() finally: From gvanrossum@users.sourceforge.net Thu Jun 6 22:08:18 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 06 Jun 2002 14:08:18 -0700 Subject: [Python-checkins] python/dist/src/Modules socketmodule.c,1.218,1.219 socketmodule.h,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv19155/Modules Modified Files: socketmodule.c socketmodule.h Log Message: SF patch 555085 (timeout socket implementation) by Michael Gilfix. I've made considerable changes to Michael's code, specifically to use the select() system call directly and to store the timeout as a C double instead of a Python object; internally, -1.0 (or anything negative) represents the None from the API. I'm not 100% sure that all corner cases are covered correctly, so please keep an eye on this. Next I'm going to try it Windows before Tim complains. No way is this a bugfix candidate. :-) Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.218 retrieving revision 1.219 diff -C2 -d -r1.218 -r1.219 *** socketmodule.c 6 Jun 2002 20:41:10 -0000 1.218 --- socketmodule.c 6 Jun 2002 21:08:16 -0000 1.219 *************** *** 67,70 **** --- 67,72 ---- - s.sendto(string, [flags,] sockaddr) --> nbytes - s.setblocking(0 | 1) --> None + - s.settimeout(None | float) -> None # Argument in seconds + - s.gettimeout() -> None or float seconds - s.setsockopt(level, optname, value) --> None - s.shutdown(how) --> None *************** *** 422,425 **** --- 424,528 ---- } + /* For timeout errors */ + static PyObject * + timeout_err(void) + { + PyObject *v; + + #ifdef MS_WINDOWS + v = Py_BuildValue("(is)", WSAETIMEDOUT, "Socket operation timed out"); + #else + v = Py_BuildValue("(is)", ETIMEDOUT, "Socket operation timed out"); + #endif + + if (v != NULL) { + PyErr_SetObject(PySocket_Error, v); + Py_DECREF(v); + } + + return NULL; + } + + /* Function to perfrom the setting of socket blocking mode + * internally. block = (1 | 0). + */ + static int + internal_setblocking(PySocketSockObject *s, int block) + { + #ifndef RISCOS + #ifndef MS_WINDOWS + int delay_flag; + #endif + #endif + + Py_BEGIN_ALLOW_THREADS + #ifdef __BEOS__ + block = !block; + setsockopt( s->sock_fd, SOL_SOCKET, SO_NONBLOCK, + (void *)(&block), sizeof(int)); + #else + #ifndef RISCOS + #ifndef MS_WINDOWS + #if defined(PYOS_OS2) && !defined(PYCC_GCC) + block = !block; + ioctl(s->sock_fd, FIONBIO, (caddr_t)&block, sizeof(block)); + #else /* !PYOS_OS2 */ + delay_flag = fcntl(s->sock_fd, F_GETFL, 0); + if (block) + delay_flag &= (~O_NDELAY); + else + delay_flag |= O_NDELAY; + fcntl(s->sock_fd, F_SETFL, delay_flag); + #endif /* !PYOS_OS2 */ + #else /* MS_WINDOWS */ + block = !block; + ioctlsocket(s->sock_fd, FIONBIO, (u_long*)&block); + #endif /* MS_WINDOWS */ + #endif /* __BEOS__ */ + #endif /* RISCOS */ + Py_END_ALLOW_THREADS + + /* Since these don't return anything */ + return 1; + } + + /* For access to the select module to poll the socket for timeout + * functionality. If reading is: 1 poll as read, 0, poll as write. + * Return value: -1 if error, 0 if not ready, >= 1 if ready. + */ + static int + internal_select(PySocketSockObject *s, int reading) + { + fd_set fds; + struct timeval tv; + int count; + + /* Construct the arguments to select */ + tv.tv_sec = (int)s->sock_timeout; + tv.tv_usec = (int)(s->sock_timeout/1e6); + FD_ZERO(&fds); + FD_SET(s->sock_fd, &fds); + + /* See if the socket is ready */ + if (reading) + count = select(s->sock_fd, &fds, NULL, NULL, &tv); + else + count = select(s->sock_fd, NULL, &fds, NULL, &tv); + + /* Check for errors */ + if (count < 0) { + s->errorhandler(); + return -1; + } + + /* Set the error if the timeout has elapsed, i.e, we were not + * polled. + */ + if (count == 0) + timeout_err(); + + return count; + } + /* Initialize a new socket object. */ *************** *** 435,438 **** --- 538,544 ---- s->sock_type = type; s->sock_proto = proto; + s->sock_blocking = 1; /* Start in blocking mode */ + s->sock_timeout = -1.0; /* Start without timeout */ + s->errorhandler = &PySocket_Err; #ifdef RISCOS *************** *** 692,696 **** char *path; int len; ! addr = (struct sockaddr_un* )&(s->sock_addr).un; if (!PyArg_Parse(args, "t#", &path, &len)) return 0; --- 798,802 ---- char *path; int len; ! addr = (struct sockaddr_un*)&(s->sock_addr).un; if (!PyArg_Parse(args, "t#", &path, &len)) return 0; *************** *** 862,868 **** --- 968,1012 ---- return NULL; memset(addrbuf, 0, addrlen); + + errno = 0; /* Reset indicator for use with timeout behavior */ + Py_BEGIN_ALLOW_THREADS newfd = accept(s->sock_fd, (struct sockaddr *) addrbuf, &addrlen); Py_END_ALLOW_THREADS + + if (s->sock_timeout >= 0.0) { + #ifdef MS_WINDOWS + if (newfd == INVALID_SOCKET) + if (!s->sock_blocking) + return s->errorhandler(); + /* Check if we have a true failure + for a blocking socket */ + if (errno != WSAEWOULDBLOCK) + return s->errorhandler(); + #else + if (newfd < 0) { + if (!s->sock_blocking) + return s->errorhandler(); + /* Check if we have a true failure + for a blocking socket */ + if (errno != EAGAIN && errno != EWOULDBLOCK) + return s->errorhandler(); + } + #endif + + /* try waiting the timeout period */ + if (internal_select(s, 0) <= 0) + return NULL; + + Py_BEGIN_ALLOW_THREADS + newfd = accept(s->sock_fd, + (struct sockaddr *)addrbuf, + &addrlen); + Py_END_ALLOW_THREADS + } + + /* At this point, we really have an error, whether using timeout + * behavior or regular socket behavior + */ #ifdef MS_WINDOWS if (newfd == INVALID_SOCKET) *************** *** 878,881 **** --- 1022,1026 ---- s->sock_type, s->sock_proto); + if (sock == NULL) { SOCKETCLOSE(newfd); *************** *** 883,887 **** } addr = makesockaddr(s->sock_fd, (struct sockaddr *)addrbuf, ! addrlen); if (addr == NULL) goto finally; --- 1028,1032 ---- } addr = makesockaddr(s->sock_fd, (struct sockaddr *)addrbuf, ! addrlen); if (addr == NULL) goto finally; *************** *** 889,893 **** res = Py_BuildValue("OO", sock, addr); ! finally: Py_XDECREF(sock); Py_XDECREF(addr); --- 1034,1038 ---- res = Py_BuildValue("OO", sock, addr); ! finally: Py_XDECREF(sock); Py_XDECREF(addr); *************** *** 902,906 **** info is a pair (hostaddr, port)."; - /* s.setblocking(1 | 0) method */ --- 1047,1050 ---- *************** *** 909,946 **** { int block; ! #ifndef RISCOS ! #ifndef MS_WINDOWS ! int delay_flag; ! #endif ! #endif block = PyInt_AsLong(arg); if (block == -1 && PyErr_Occurred()) return NULL; ! Py_BEGIN_ALLOW_THREADS ! #ifdef __BEOS__ ! block = !block; ! setsockopt( s->sock_fd, SOL_SOCKET, SO_NONBLOCK, ! (void *)(&block), sizeof( int ) ); ! #else ! #ifndef RISCOS ! #ifndef MS_WINDOWS ! #if defined(PYOS_OS2) && !defined(PYCC_GCC) ! block = !block; ! ioctl(s->sock_fd, FIONBIO, (caddr_t)&block, sizeof(block)); ! #else /* !PYOS_OS2 */ ! delay_flag = fcntl (s->sock_fd, F_GETFL, 0); ! if (block) ! delay_flag &= (~O_NDELAY); ! else ! delay_flag |= O_NDELAY; ! fcntl (s->sock_fd, F_SETFL, delay_flag); ! #endif /* !PYOS_OS2 */ ! #else /* MS_WINDOWS */ ! block = !block; ! ioctlsocket(s->sock_fd, FIONBIO, (u_long*)&block); ! #endif /* MS_WINDOWS */ ! #endif /* __BEOS__ */ ! #endif /* RISCOS */ ! Py_END_ALLOW_THREADS Py_INCREF(Py_None); --- 1053,1068 ---- { int block; ! block = PyInt_AsLong(arg); if (block == -1 && PyErr_Occurred()) return NULL; ! ! s->sock_blocking = block; ! ! /* If we're not using timeouts, actually set the blocking to give ! * old python behavior. ! */ ! if (s->sock_timeout < 0.0) ! internal_setblocking(s, block); Py_INCREF(Py_None); *************** *** 954,957 **** --- 1076,1154 ---- This uses the FIONBIO ioctl with the O_NDELAY flag."; + /* s.settimeout (float | int | long) method. + * Causes an exception to be raised when the integer number of seconds + * has elapsed when performing a blocking socket operation. + */ + static PyObject * + PySocketSock_settimeout(PySocketSockObject *s, PyObject *arg) + { + double value; + + if (arg == Py_None) + value = -1.0; + else { + value = PyFloat_AsDouble(arg); + if (value < 0.0) { + if (!PyErr_Occurred()) + PyErr_SetString(PyExc_ValueError, + "Invalid timeout value"); + return NULL; + } + } + + s->sock_timeout = value; + + /* The semantics of setting socket timeouts are: + * If you settimeout(!=None): + * The actual socket gets put in non-blocking mode and the select + * is used to control timeouts. + * Else if you settimeout(None) [then value is -1.0]: + * The old behavior is used AND automatically, the socket is set + * to blocking mode. That means that someone who was doing + * non-blocking stuff before, sets a timeout, and then unsets + * one, will have to call setblocking(0) again if he wants + * non-blocking stuff. This makes sense because timeout stuff is + * blocking by nature. + */ + if (value < 0.0) + internal_setblocking(s, 0); + else + internal_setblocking(s, 1); + + s->sock_blocking = 1; /* Always negate setblocking() */ + + Py_INCREF(Py_None); + return Py_None; + } + + static char settimeout_doc[] = + "settimeout(seconds)\n\ + \n\ + Set a timeout on blocking socket operations. 'seconds' can be a floating,\n\ + integer, or long number of seconds, or the None value. Socket operations\n\ + will raise an exception if the timeout period has elapsed before the\n\ + operation has completed. Setting a timeout of None disables timeouts\n\ + on socket operations."; + + /* s.gettimeout () method. + * Returns the timeout associated with a socket. + */ + static PyObject * + PySocketSock_gettimeout(PySocketSockObject *s) + { + if (s->sock_timeout < 0.0) { + Py_INCREF(Py_None); + return Py_None; + } + else + return PyFloat_FromDouble(s->sock_timeout); + } + + static char gettimeout_doc[] = + "gettimeout()\n\ + \n\ + Returns the timeout in floating seconds associated with socket \n\ + operations. A timeout of None indicates that timeouts on socket \n\ + operations are disabled."; #ifdef RISCOS *************** *** 961,974 **** PySocketSock_sleeptaskw(PySocketSockObject *s,PyObject *args) { ! int block; ! int delay_flag; ! if (!PyArg_Parse(args, "i", &block)) ! return NULL; ! Py_BEGIN_ALLOW_THREADS ! socketioctl(s->sock_fd, 0x80046679, (u_long*)&block); ! Py_END_ALLOW_THREADS ! Py_INCREF(Py_None); ! return Py_None; } static char sleeptaskw_doc[] = --- 1158,1171 ---- PySocketSock_sleeptaskw(PySocketSockObject *s,PyObject *args) { ! int block; ! int delay_flag; ! if (!PyArg_Parse(args, "i", &block)) ! return NULL; ! Py_BEGIN_ALLOW_THREADS ! socketioctl(s->sock_fd, 0x80046679, (u_long*)&block); ! Py_END_ALLOW_THREADS ! Py_INCREF(Py_None); ! return Py_None; } static char sleeptaskw_doc[] = *************** *** 1143,1151 **** --- 1340,1387 ---- if (!getsockaddrarg(s, addro, &addr, &addrlen)) return NULL; + + errno = 0; /* Reset the err indicator for use with timeouts */ + Py_BEGIN_ALLOW_THREADS res = connect(s->sock_fd, addr, addrlen); Py_END_ALLOW_THREADS + + if (s->sock_timeout >= 0.0) { + if (res < 0) { + /* Return if we're already connected */ + #ifdef MS_WINDOWS + if (errno == WSAEINVAL || errno == WSAEISCONN) + #else + if (errno == EISCONN) + #endif + goto connected; + + /* Check if we have an error */ + if (!s->sock_blocking) + return s->errorhandler (); + /* Check if we have a true failure for a blocking socket */ + #ifdef MS_WINDOWS + if (errno != WSAEWOULDBLOCK) + #else + if (errno != EINPROGRESS && errno != EALREADY && + errno != EWOULDBLOCK) + #endif + return s->errorhandler(); + } + + /* Check if we're ready for the connect via select */ + if (internal_select(s, 1) <= 0) + return NULL; + + /* Complete the connection now */ + Py_BEGIN_ALLOW_THREADS + res = connect(s->sock_fd, addr, addrlen); + Py_END_ALLOW_THREADS + } + if (res < 0) return s->errorhandler(); + + connected: Py_INCREF(Py_None); return Py_None; *************** *** 1170,1176 **** --- 1406,1449 ---- if (!getsockaddrarg(s, addro, &addr, &addrlen)) return NULL; + + errno = 0; /* Reset the err indicator for use with timeouts */ + Py_BEGIN_ALLOW_THREADS res = connect(s->sock_fd, addr, addrlen); Py_END_ALLOW_THREADS + + if (s->sock_timeout >= 0.0) { + if (res < 0) { + /* Return if we're already connected */ + #ifdef MS_WINDOWS + if (errno == WSAEINVAL || errno == WSAEISCONN) + #else + if (errno == EISCONN) + #endif + goto conex_finally; + + /* Check if we have an error */ + if (!s->sock_blocking) + goto conex_finally; + /* Check if we have a true failure for a blocking socket */ + #ifdef MS_WINDOWS + if (errno != WSAEWOULDBLOCK) + #else + if (errno != EINPROGRESS && errno != EALREADY && + errno != EWOULDBLOCK) + #endif + goto conex_finally; + } + + /* Check if we're ready for the connect via select */ + if (internal_select(s, 1) <= 0) + return NULL; + + /* Complete the connection now */ + Py_BEGIN_ALLOW_THREADS + res = connect(s->sock_fd, addr, addrlen); + Py_END_ALLOW_THREADS + } + if (res != 0) { #ifdef MS_WINDOWS *************** *** 1180,1183 **** --- 1453,1458 ---- #endif } + + conex_finally: return PyInt_FromLong((long) res); } *************** *** 1361,1365 **** #ifdef USE_GUSI2 /* Workaround for bug in Metrowerks MSL vs. GUSI I/O library */ ! if (strchr(mode, 'b') != NULL ) bufsize = 0; #endif --- 1636,1640 ---- #ifdef USE_GUSI2 /* Workaround for bug in Metrowerks MSL vs. GUSI I/O library */ ! if (strchr(mode, 'b') != NULL) bufsize = 0; #endif *************** *** 1386,1402 **** int len, n, flags = 0; PyObject *buf; if (!PyArg_ParseTuple(args, "i|i:recv", &len, &flags)) return NULL; ! if (len < 0) { PyErr_SetString(PyExc_ValueError, "negative buffersize in connect"); return NULL; } buf = PyString_FromStringAndSize((char *) 0, len); if (buf == NULL) return NULL; Py_BEGIN_ALLOW_THREADS n = recv(s->sock_fd, PyString_AS_STRING(buf), len, flags); Py_END_ALLOW_THREADS if (n < 0) { Py_DECREF(buf); --- 1661,1689 ---- int len, n, flags = 0; PyObject *buf; + if (!PyArg_ParseTuple(args, "i|i:recv", &len, &flags)) return NULL; ! ! if (len < 0) { PyErr_SetString(PyExc_ValueError, "negative buffersize in connect"); return NULL; } + buf = PyString_FromStringAndSize((char *) 0, len); if (buf == NULL) return NULL; + + if (s->sock_timeout >= 0.0) { + if (s->sock_blocking) { + if (internal_select(s, 0) <= 0) + return NULL; + } + } + Py_BEGIN_ALLOW_THREADS n = recv(s->sock_fd, PyString_AS_STRING(buf), len, flags); Py_END_ALLOW_THREADS + if (n < 0) { Py_DECREF(buf); *************** *** 1426,1434 **** PyObject *addr = NULL; PyObject *ret = NULL; - int len, n, flags = 0; socklen_t addrlen; if (!PyArg_ParseTuple(args, "i|i:recvfrom", &len, &flags)) return NULL; if (!getsockaddrlen(s, &addrlen)) return NULL; --- 1713,1722 ---- PyObject *addr = NULL; PyObject *ret = NULL; int len, n, flags = 0; socklen_t addrlen; + if (!PyArg_ParseTuple(args, "i|i:recvfrom", &len, &flags)) return NULL; + if (!getsockaddrlen(s, &addrlen)) return NULL; *************** *** 1436,1439 **** --- 1724,1735 ---- if (buf == NULL) return NULL; + + if (s->sock_timeout >= 0.0) { + if (s->sock_blocking) { + if (internal_select(s, 0) <= 0) + return NULL; + } + } + Py_BEGIN_ALLOW_THREADS memset(addrbuf, 0, addrlen); *************** *** 1450,1465 **** ); Py_END_ALLOW_THREADS if (n < 0) { Py_DECREF(buf); return s->errorhandler(); } if (n != len && _PyString_Resize(&buf, n) < 0) return NULL; ! if (!(addr = makesockaddr(s->sock_fd, (struct sockaddr *)addrbuf, addrlen))) goto finally; ret = Py_BuildValue("OO", buf, addr); ! finally: Py_XDECREF(addr); Py_XDECREF(buf); --- 1746,1765 ---- ); Py_END_ALLOW_THREADS + if (n < 0) { Py_DECREF(buf); return s->errorhandler(); } + if (n != len && _PyString_Resize(&buf, n) < 0) return NULL; ! if (!(addr = makesockaddr(s->sock_fd, (struct sockaddr *)addrbuf, ! addrlen))) goto finally; ret = Py_BuildValue("OO", buf, addr); ! ! finally: Py_XDECREF(addr); Py_XDECREF(buf); *************** *** 1472,1476 **** Like recv(buffersize, flags) but also return the sender's address info."; - /* s.send(data [,flags]) method */ --- 1772,1775 ---- *************** *** 1480,1488 **** --- 1779,1797 ---- char *buf; int len, n, flags = 0; + if (!PyArg_ParseTuple(args, "s#|i:send", &buf, &len, &flags)) return NULL; + + if (s->sock_timeout >= 0.0) { + if (s->sock_blocking) { + if (internal_select(s, 1) <= 0) + return NULL; + } + } + Py_BEGIN_ALLOW_THREADS n = send(s->sock_fd, buf, len, flags); Py_END_ALLOW_THREADS + if (n < 0) return s->errorhandler(); *************** *** 1505,1510 **** --- 1814,1828 ---- char *buf; int len, n, flags = 0; + if (!PyArg_ParseTuple(args, "s#|i:sendall", &buf, &len, &flags)) return NULL; + + if (s->sock_timeout >= 0.0) { + if (s->sock_blocking) { + if (internal_select(s, 1) < 0) + return NULL; + } + } + Py_BEGIN_ALLOW_THREADS do { *************** *** 1516,1521 **** --- 1834,1841 ---- } while (len > 0); Py_END_ALLOW_THREADS + if (n < 0) return s->errorhandler(); + Py_INCREF(Py_None); return Py_None; *************** *** 1540,1543 **** --- 1860,1864 ---- struct sockaddr *addr; int addrlen, len, n, flags; + flags = 0; if (!PyArg_ParseTuple(args, "s#O:sendto", &buf, &len, &addro)) { *************** *** 1547,1555 **** --- 1868,1886 ---- return NULL; } + if (!getsockaddrarg(s, addro, &addr, &addrlen)) return NULL; + + if (s->sock_timeout >= 0.0) { + if (s->sock_blocking) { + if (internal_select(s, 1) <= 0) + return NULL; + } + } + Py_BEGIN_ALLOW_THREADS n = sendto(s->sock_fd, buf, len, flags, addr, addrlen); Py_END_ALLOW_THREADS + if (n < 0) return s->errorhandler(); *************** *** 1636,1639 **** --- 1967,1974 ---- {"setblocking", (PyCFunction)PySocketSock_setblocking, METH_O, setblocking_doc}, + {"settimeout", (PyCFunction)PySocketSock_settimeout, METH_O, + settimeout_doc}, + {"gettimeout", (PyCFunction)PySocketSock_gettimeout, METH_NOARGS, + gettimeout_doc}, {"setsockopt", (PyCFunction)PySocketSock_setsockopt, METH_VARARGS, setsockopt_doc}, *************** *** 1693,1696 **** --- 2028,2032 ---- if (new != NULL) { ((PySocketSockObject *)new)->sock_fd = -1; + ((PySocketSockObject *)new)->sock_timeout = -1.0; ((PySocketSockObject *)new)->errorhandler = &PySocket_Err; } *************** *** 1714,1720 **** --- 2050,2058 ---- &family, &type, &proto)) return -1; + Py_BEGIN_ALLOW_THREADS fd = socket(family, type, proto); Py_END_ALLOW_THREADS + #ifdef MS_WINDOWS if (fd == INVALID_SOCKET) *************** *** 1732,1736 **** --- 2070,2076 ---- (void) signal(SIGPIPE, SIG_IGN); #endif + return 0; + } *************** *** 1886,1889 **** --- 2226,2230 ---- return NULL; } + if (h->h_addrtype != af) { #ifdef HAVE_STRERROR *************** *** 1896,1904 **** --- 2237,2248 ---- return NULL; } + switch (af) { + case AF_INET: if (alen < sizeof(struct sockaddr_in)) return NULL; break; + #ifdef ENABLE_IPV6 case AF_INET6: *************** *** 1907,1915 **** --- 2251,2263 ---- break; #endif + } + if ((name_list = PyList_New(0)) == NULL) goto err; + if ((addr_list = PyList_New(0)) == NULL) goto err; + for (pch = h->h_aliases; *pch != NULL; pch++) { int status; *************** *** 1917,1928 **** --- 2265,2281 ---- if (tmp == NULL) goto err; + status = PyList_Append(name_list, tmp); Py_DECREF(tmp); + if (status) goto err; } + for (pch = h->h_addr_list; *pch != NULL; pch++) { int status; + switch (af) { + case AF_INET: { *************** *** 1935,1942 **** --- 2288,2297 ---- memcpy(&sin.sin_addr, *pch, sizeof(sin.sin_addr)); tmp = makeipaddr((struct sockaddr *)&sin, sizeof(sin)); + if (pch == h->h_addr_list && alen >= sizeof(sin)) memcpy((char *) addr, &sin, sizeof(sin)); break; } + #ifdef ENABLE_IPV6 case AF_INET6: *************** *** 1951,1954 **** --- 2306,2310 ---- tmp = makeipaddr((struct sockaddr *)&sin6, sizeof(sin6)); + if (pch == h->h_addr_list && alen >= sizeof(sin6)) memcpy((char *) addr, &sin6, sizeof(sin6)); *************** *** 1956,1959 **** --- 2312,2316 ---- } #endif + default: /* can't happen */ PyErr_SetString(PySocket_Error, *************** *** 1961,1972 **** --- 2318,2334 ---- return NULL; } + if (tmp == NULL) goto err; + status = PyList_Append(addr_list, tmp); Py_DECREF(tmp); + if (status) goto err; } + rtn_tuple = Py_BuildValue("sOO", h->h_name, name_list, addr_list); + err: Py_XDECREF(name_list); *************** *** 2023,2030 **** #endif /* HAVE_GETHOSTBYNAME_R */ Py_END_ALLOW_THREADS ! /* Some C libraries would require addr.__ss_family instead of addr.ss_family. ! Therefore, we cast the sockaddr_storage into sockaddr to access sa_family. */ sa = (struct sockaddr*)&addr; ! ret = gethost_common(h, (struct sockaddr *)&addr, sizeof(addr), sa->sa_family); #ifdef USE_GETHOSTBYNAME_LOCK PyThread_release_lock(gethostbyname_lock); --- 2385,2396 ---- #endif /* HAVE_GETHOSTBYNAME_R */ Py_END_ALLOW_THREADS ! /* Some C libraries would require addr.__ss_family instead of ! * addr.ss_family. ! * Therefore, we cast the sockaddr_storage into sockaddr to ! * access sa_family. ! */ sa = (struct sockaddr*)&addr; ! ret = gethost_common(h, (struct sockaddr *)&addr, sizeof(addr), ! sa->sa_family); #ifdef USE_GETHOSTBYNAME_LOCK PyThread_release_lock(gethostbyname_lock); *************** *** 2171,2175 **** #ifdef __BEOS__ /* Not available in BeOS yet. - [cjh] */ ! PyErr_SetString( PySocket_Error, "getprotobyname not supported" ); return NULL; #else --- 2537,2541 ---- #ifdef __BEOS__ /* Not available in BeOS yet. - [cjh] */ ! PyErr_SetString(PySocket_Error, "getprotobyname not supported"); return NULL; #else Index: socketmodule.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** socketmodule.h 1 Mar 2002 08:31:07 -0000 1.5 --- socketmodule.h 6 Jun 2002 21:08:16 -0000 1.6 *************** *** 84,87 **** --- 84,90 ---- errno, returns NULL and sets a Python exception */ + int sock_blocking; /* Flag indicated whether the + socket is in blocking mode */ + double sock_timeout; /* Operation timeout value */ } PySocketSockObject; From gvanrossum@users.sourceforge.net Thu Jun 6 22:08:49 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 06 Jun 2002 14:08:49 -0700 Subject: [Python-checkins] python/dist/src/Misc ACKS,1.177,1.178 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv20199 Modified Files: ACKS Log Message: Michael Gilfix of SF patch 555085 fame. Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.177 retrieving revision 1.178 diff -C2 -d -r1.177 -r1.178 *** ACKS 6 Jun 2002 10:58:36 -0000 1.177 --- ACKS 6 Jun 2002 21:08:46 -0000 1.178 *************** *** 166,169 **** --- 166,170 ---- Ben Gertzfield Jonathan Giddy + Michael Gilfix Chris Gonnerman David Goodger From gvanrossum@users.sourceforge.net Thu Jun 6 22:51:03 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 06 Jun 2002 14:51:03 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libsocket.tex,1.60,1.61 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv390 Modified Files: libsocket.tex Log Message: SF patch 555085 (timeout socket implementation) by Michael Gilfix. I've made considerable changes to Michael's code, specifically to use the select() system call directly and to store the timeout as a C double instead of a Python object; internally, -1.0 (or anything negative) represents the None from the API. I'm not 100% sure that all corner cases are covered correctly, so please keep an eye on this. Next I'm going to try it Windows before Tim complains. No way is this a bugfix candidate. :-) Index: libsocket.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsocket.tex,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** libsocket.tex 22 Dec 2001 19:07:58 -0000 1.60 --- libsocket.tex 6 Jun 2002 21:51:01 -0000 1.61 *************** *** 515,518 **** --- 515,541 ---- \end{methoddesc} + \begin{methoddesc}[socket]{settimeout}{value} + Set a timeout on blocking socket operations. Value can be any numeric value + or \var{None}. Socket operations will raise an \exception{error} exception + if the timeout period \var{value} has elapsed before the operation has + completed. Setting a timeout of \var{None} disables timeouts on socket + operations. + \end{methoddesc} + + \begin{methoddesc}[socket]{gettimeout}{} + Returns the timeout in floating seconds associated with socket operations. + A timeout of None indicates that timeouts on socket operations are + disabled. + \end{methoddesc} + + Some notes on the interaction between socket blocking and timeouts: + socket blocking mode takes precendence over timeouts. If a socket + if set to non-blocking mode, then timeouts set on sockets are never + don't mean anything. The timeout value associated with the socket + can still be set via settimeout and its value retrieved via gettimeout, + but the timeout is never enforced (i.e, an exception will never be + thrown). Otherwise, if the socket is in blocking mode, setting the + timeout will raise an exception as expected. + \begin{methoddesc}[socket]{setsockopt}{level, optname, value} Set the value of the given socket option (see the \UNIX{} manual page From fdrake@users.sourceforge.net Thu Jun 6 22:57:50 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu, 06 Jun 2002 14:57:50 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libsocket.tex,1.61,1.62 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv2224 Modified Files: libsocket.tex Log Message: Fix some markup errors and adjust wording slightly. Index: libsocket.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsocket.tex,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** libsocket.tex 6 Jun 2002 21:51:01 -0000 1.61 --- libsocket.tex 6 Jun 2002 21:57:48 -0000 1.62 *************** *** 516,540 **** \begin{methoddesc}[socket]{settimeout}{value} ! Set a timeout on blocking socket operations. Value can be any numeric value ! or \var{None}. Socket operations will raise an \exception{error} exception ! if the timeout period \var{value} has elapsed before the operation has ! completed. Setting a timeout of \var{None} disables timeouts on socket ! operations. \end{methoddesc} \begin{methoddesc}[socket]{gettimeout}{} ! Returns the timeout in floating seconds associated with socket operations. ! A timeout of None indicates that timeouts on socket operations are ! disabled. \end{methoddesc} Some notes on the interaction between socket blocking and timeouts: ! socket blocking mode takes precendence over timeouts. If a socket ! if set to non-blocking mode, then timeouts set on sockets are never ! don't mean anything. The timeout value associated with the socket ! can still be set via settimeout and its value retrieved via gettimeout, ! but the timeout is never enforced (i.e, an exception will never be ! thrown). Otherwise, if the socket is in blocking mode, setting the ! timeout will raise an exception as expected. \begin{methoddesc}[socket]{setsockopt}{level, optname, value} --- 516,540 ---- \begin{methoddesc}[socket]{settimeout}{value} ! Set a timeout on blocking socket operations. Value can be any numeric ! value or \code{None}. Socket operations will raise an ! \exception{error} exception if the timeout period \var{value} has ! elapsed before the operation has completed. Setting a timeout of ! \code{None} disables timeouts on socket operations. \end{methoddesc} \begin{methoddesc}[socket]{gettimeout}{} ! Returns the timeout in floating seconds associated with socket ! operations. A timeout of \code{None} indicates that timeouts on ! socket operations are disabled. \end{methoddesc} Some notes on the interaction between socket blocking and timeouts: ! socket blocking mode takes precendence over timeouts. If a socket if ! set to non-blocking mode, then timeouts set on sockets are not used. ! The timeout value associated with the socket can still be set using ! \method{settimeout()} and its value retrieved using ! \method{gettimeout()}, but the timeout is never enforced (an exception ! will never be thrown). Otherwise, if the socket is in blocking mode, ! setting the timeout will raise an exception as expected. \begin{methoddesc}[socket]{setsockopt}{level, optname, value} From fredrik@pythonware.com Thu Jun 6 22:59:29 2002 From: fredrik@pythonware.com (Fredrik Lundh) Date: Thu, 6 Jun 2002 23:59:29 +0200 Subject: [Python-checkins] python/dist/src/Doc/lib libsocket.tex,1.60,1.61 References: Message-ID: <051101c20da5$70284f10$ced241d5@hagrid> guido wrote: > + Some notes on the interaction between socket blocking and timeouts: > + socket blocking mode takes precendence over timeouts. If a socket > + if set to non-blocking mode, then timeouts set on sockets are never > + don't mean anything. it might be that I've been watching too much soccer, but I couldn't quite make sense of that paragraph... From fdrake@users.sourceforge.net Thu Jun 6 23:19:22 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu, 06 Jun 2002 15:19:22 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libsocket.tex,1.62,1.63 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv7895 Modified Files: libsocket.tex Log Message: Fix typo spotted by Fredrik Lundh. Index: libsocket.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsocket.tex,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** libsocket.tex 6 Jun 2002 21:57:48 -0000 1.62 --- libsocket.tex 6 Jun 2002 22:19:20 -0000 1.63 *************** *** 530,534 **** Some notes on the interaction between socket blocking and timeouts: ! socket blocking mode takes precendence over timeouts. If a socket if set to non-blocking mode, then timeouts set on sockets are not used. The timeout value associated with the socket can still be set using --- 530,534 ---- Some notes on the interaction between socket blocking and timeouts: ! socket blocking mode takes precedence over timeouts. If a socket if set to non-blocking mode, then timeouts set on sockets are not used. The timeout value associated with the socket can still be set using From nnorwitz@users.sourceforge.net Thu Jun 6 23:24:12 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu, 06 Jun 2002 15:24:12 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libsocket.tex,1.63,1.64 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv8904/Doc/lib Modified Files: libsocket.tex Log Message: Add version info, and fix another typo and wording spotted by /F. I think this is what he meant. :-) Index: libsocket.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsocket.tex,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** libsocket.tex 6 Jun 2002 22:19:20 -0000 1.63 --- libsocket.tex 6 Jun 2002 22:24:10 -0000 1.64 *************** *** 521,524 **** --- 521,525 ---- elapsed before the operation has completed. Setting a timeout of \code{None} disables timeouts on socket operations. + \versionadded{2.3} \end{methoddesc} *************** *** 527,535 **** operations. A timeout of \code{None} indicates that timeouts on socket operations are disabled. \end{methoddesc} Some notes on the interaction between socket blocking and timeouts: ! socket blocking mode takes precedence over timeouts. If a socket if ! set to non-blocking mode, then timeouts set on sockets are not used. The timeout value associated with the socket can still be set using \method{settimeout()} and its value retrieved using --- 528,537 ---- operations. A timeout of \code{None} indicates that timeouts on socket operations are disabled. + \versionadded{2.3} \end{methoddesc} Some notes on the interaction between socket blocking and timeouts: ! socket blocking mode takes precedence over timeouts. If a socket is ! set to non-blocking mode, then timeouts are not used. The timeout value associated with the socket can still be set using \method{settimeout()} and its value retrieved using From jhylton@users.sourceforge.net Fri Jun 7 00:23:57 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Thu, 06 Jun 2002 16:23:57 -0700 Subject: [Python-checkins] python/dist/src/Modules gcmodule.c,2.42,2.43 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv22164 Modified Files: gcmodule.c Log Message: Remove casts to PyObject * when declaration is for PyObject * Index: gcmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/gcmodule.c,v retrieving revision 2.42 retrieving revision 2.43 diff -C2 -d -r2.42 -r2.43 *** gcmodule.c 21 May 2002 15:53:24 -0000 2.42 --- gcmodule.c 6 Jun 2002 23:23:55 -0000 2.43 *************** *** 356,360 **** if ((clear = op->ob_type->tp_clear) != NULL) { Py_INCREF(op); ! clear((PyObject *)op); Py_DECREF(op); } --- 356,360 ---- if ((clear = op->ob_type->tp_clear) != NULL) { Py_INCREF(op); ! clear(op); Py_DECREF(op); } *************** *** 880,884 **** PyGC_Head *g = PyObject_MALLOC(sizeof(PyGC_Head) + basicsize); if (g == NULL) ! return (PyObject *)PyErr_NoMemory(); g->gc.gc_next = NULL; generations[0].count++; /* number of allocated GC objects */ --- 880,884 ---- PyGC_Head *g = PyObject_MALLOC(sizeof(PyGC_Head) + basicsize); if (g == NULL) ! return PyErr_NoMemory(); g->gc.gc_next = NULL; generations[0].count++; /* number of allocated GC objects */ *************** *** 896,900 **** op = PyObject_MALLOC(basicsize); if (op == NULL) ! return (PyObject *)PyErr_NoMemory(); #endif --- 896,900 ---- op = PyObject_MALLOC(basicsize); if (op == NULL) ! return PyErr_NoMemory(); #endif From guido@python.org Fri Jun 7 01:27:06 2002 From: guido@python.org (Guido van Rossum) Date: Thu, 06 Jun 2002 20:27:06 -0400 Subject: [Python-checkins] python/dist/src/Doc/lib libsocket.tex,1.60,1.61 In-Reply-To: Your message of "Thu, 06 Jun 2002 23:59:29 +0200." <051101c20da5$70284f10$ced241d5@hagrid> References: <051101c20da5$70284f10$ced241d5@hagrid> Message-ID: <200206070027.g570R6R07449@pcp02138704pcs.reston01.va.comcast.net> > guido wrote: (Actually, MIchael Gilfix) > > + Some notes on the interaction between socket blocking and timeouts: > > + socket blocking mode takes precendence over timeouts. If a socket > > + if set to non-blocking mode, then timeouts set on sockets are never > > + don't mean anything. > > it might be that I've been watching too much soccer, but > I couldn't quite make sense of that paragraph... What's soccer? I'll see if I can fix the mess. --Guido van Rossum (home page: http://www.python.org/~guido/) From gvanrossum@users.sourceforge.net Fri Jun 7 02:42:49 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 06 Jun 2002 18:42:49 -0700 Subject: [Python-checkins] python/dist/src/Modules socketmodule.c,1.219,1.220 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv17706 Modified Files: socketmodule.c Log Message: Correct several blunders in the timeout code, mostly my own fault (for not testing it -- apparently test_timeout.py doesn't test anything useful): In internal_select(): - The tv_usec part of the timeout for select() was calculated wrong. - The first argument to select() was one too low. - The sense of the direction argument to internal_select() was inverted. In PySocketSock_settimeout(): - The calls to internal_setblocking() were swapped. Also, repaired some comments and fixed the test for the return value of internal_select() in sendall -- this was in the original patch. Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.219 retrieving revision 1.220 diff -C2 -d -r1.219 -r1.220 *** socketmodule.c 6 Jun 2002 21:08:16 -0000 1.219 --- socketmodule.c 7 Jun 2002 01:42:47 -0000 1.220 *************** *** 488,496 **** /* For access to the select module to poll the socket for timeout ! * functionality. If reading is: 1 poll as read, 0, poll as write. * Return value: -1 if error, 0 if not ready, >= 1 if ready. */ static int ! internal_select(PySocketSockObject *s, int reading) { fd_set fds; --- 488,497 ---- /* For access to the select module to poll the socket for timeout ! * functionality. writing is 1 for writing, 0 for reading. * Return value: -1 if error, 0 if not ready, >= 1 if ready. + * An exception is set when the return value is <= 0 (!). */ static int ! internal_select(PySocketSockObject *s, int writing) { fd_set fds; *************** *** 500,512 **** /* Construct the arguments to select */ tv.tv_sec = (int)s->sock_timeout; ! tv.tv_usec = (int)(s->sock_timeout/1e6); FD_ZERO(&fds); FD_SET(s->sock_fd, &fds); /* See if the socket is ready */ ! if (reading) ! count = select(s->sock_fd, &fds, NULL, NULL, &tv); else ! count = select(s->sock_fd, NULL, &fds, NULL, &tv); /* Check for errors */ --- 501,513 ---- /* Construct the arguments to select */ tv.tv_sec = (int)s->sock_timeout; ! tv.tv_usec = (int)((s->sock_timeout - tv.tv_sec) * 1e6); FD_ZERO(&fds); FD_SET(s->sock_fd, &fds); /* See if the socket is ready */ ! if (writing) ! count = select(s->sock_fd+1, NULL, &fds, NULL, &tv); else ! count = select(s->sock_fd+1, &fds, NULL, NULL, &tv); /* Check for errors */ *************** *** 1076,1082 **** This uses the FIONBIO ioctl with the O_NDELAY flag."; ! /* s.settimeout (float | int | long) method. ! * Causes an exception to be raised when the integer number of seconds ! * has elapsed when performing a blocking socket operation. */ static PyObject * --- 1077,1083 ---- This uses the FIONBIO ioctl with the O_NDELAY flag."; ! /* s.settimeout(float | None) method. ! * Causes an exception to be raised when the given time has ! * elapsed when performing a blocking socket operation. */ static PyObject * *************** *** 1111,1118 **** * blocking by nature. */ ! if (value < 0.0) ! internal_setblocking(s, 0); ! else ! internal_setblocking(s, 1); s->sock_blocking = 1; /* Always negate setblocking() */ --- 1112,1116 ---- * blocking by nature. */ ! internal_setblocking(s, value < 0.0); s->sock_blocking = 1; /* Always negate setblocking() */ *************** *** 1820,1824 **** if (s->sock_timeout >= 0.0) { if (s->sock_blocking) { ! if (internal_select(s, 1) < 0) return NULL; } --- 1818,1822 ---- if (s->sock_timeout >= 0.0) { if (s->sock_blocking) { ! if (internal_select(s, 1) <= 0) return NULL; } From gvanrossum@users.sourceforge.net Fri Jun 7 03:08:37 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 06 Jun 2002 19:08:37 -0700 Subject: [Python-checkins] python/dist/src/Modules socketmodule.c,1.220,1.221 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv22693 Modified Files: socketmodule.c Log Message: Whitespace normalization, folding long lines, uniform comment delimiters. Also repaired some docstrings and comments. Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.220 retrieving revision 1.221 diff -C2 -d -r1.220 -r1.221 *** socketmodule.c 7 Jun 2002 01:42:47 -0000 1.220 --- socketmodule.c 7 Jun 2002 02:08:35 -0000 1.221 *************** *** 107,111 **** #endif ! #if !defined(HAVE_GETHOSTBYNAME_R) && defined(WITH_THREAD) && !defined(MS_WINDOWS) # define USE_GETHOSTBYNAME_LOCK #endif --- 107,112 ---- #endif ! #if !defined(HAVE_GETHOSTBYNAME_R) && defined(WITH_THREAD) && \ ! !defined(MS_WINDOWS) # define USE_GETHOSTBYNAME_LOCK #endif *************** *** 185,189 **** #ifndef HAVE_INET_PTON ! int inet_pton (int af, const char *src, void *dst); const char *inet_ntop(int af, const void *src, char *dst, socklen_t size); #endif --- 186,190 ---- #ifndef HAVE_INET_PTON ! int inet_pton(int af, const char *src, void *dst); const char *inet_ntop(int af, const void *src, char *dst, socklen_t size); #endif *************** *** 219,224 **** #ifdef MS_WIN32 ! # define EAFNOSUPPORT WSAEAFNOSUPPORT ! # define snprintf _snprintf #endif --- 220,225 ---- #ifdef MS_WIN32 ! #define EAFNOSUPPORT WSAEAFNOSUPPORT ! #define snprintf _snprintf #endif *************** *** 261,331 **** #ifdef MS_WINDOWS int err_no = WSAGetLastError(); if (err_no) { - static struct { int no; const char *msg; } *msgp, msgs[] = { - { WSAEINTR, "Interrupted system call" }, - { WSAEBADF, "Bad file descriptor" }, - { WSAEACCES, "Permission denied" }, - { WSAEFAULT, "Bad address" }, - { WSAEINVAL, "Invalid argument" }, - { WSAEMFILE, "Too many open files" }, - { WSAEWOULDBLOCK, - "The socket operation could not complete " - "without blocking" }, - { WSAEINPROGRESS, "Operation now in progress" }, - { WSAEALREADY, "Operation already in progress" }, - { WSAENOTSOCK, "Socket operation on non-socket" }, - { WSAEDESTADDRREQ, "Destination address required" }, - { WSAEMSGSIZE, "Message too long" }, - { WSAEPROTOTYPE, "Protocol wrong type for socket" }, - { WSAENOPROTOOPT, "Protocol not available" }, - { WSAEPROTONOSUPPORT, "Protocol not supported" }, - { WSAESOCKTNOSUPPORT, "Socket type not supported" }, - { WSAEOPNOTSUPP, "Operation not supported" }, - { WSAEPFNOSUPPORT, "Protocol family not supported" }, - { WSAEAFNOSUPPORT, "Address family not supported" }, - { WSAEADDRINUSE, "Address already in use" }, - { WSAEADDRNOTAVAIL, - "Can't assign requested address" }, - { WSAENETDOWN, "Network is down" }, - { WSAENETUNREACH, "Network is unreachable" }, - { WSAENETRESET, - "Network dropped connection on reset" }, - { WSAECONNABORTED, - "Software caused connection abort" }, - { WSAECONNRESET, "Connection reset by peer" }, - { WSAENOBUFS, "No buffer space available" }, - { WSAEISCONN, "Socket is already connected" }, - { WSAENOTCONN, "Socket is not connected" }, - { WSAESHUTDOWN, "Can't send after socket shutdown" }, - { WSAETOOMANYREFS, - "Too many references: can't splice" }, - { WSAETIMEDOUT, "Operation timed out" }, - { WSAECONNREFUSED, "Connection refused" }, - { WSAELOOP, "Too many levels of symbolic links" }, - { WSAENAMETOOLONG, "File name too long" }, - { WSAEHOSTDOWN, "Host is down" }, - { WSAEHOSTUNREACH, "No route to host" }, - { WSAENOTEMPTY, "Directory not empty" }, - { WSAEPROCLIM, "Too many processes" }, - { WSAEUSERS, "Too many users" }, - { WSAEDQUOT, "Disc quota exceeded" }, - { WSAESTALE, "Stale NFS file handle" }, - { WSAEREMOTE, "Too many levels of remote in path" }, - { WSASYSNOTREADY, - "Network subsystem is unvailable" }, - { WSAVERNOTSUPPORTED, - "WinSock version is not supported" }, - { WSANOTINITIALISED, - "Successful WSAStartup() not yet performed" }, - { WSAEDISCON, "Graceful shutdown in progress" }, - /* Resolver errors */ - { WSAHOST_NOT_FOUND, "No such host is known" }, - { WSATRY_AGAIN, "Host not found, or server failed" }, - { WSANO_RECOVERY, - "Unexpected server error encountered" }, - { WSANO_DATA, "Valid name without requested data" }, - { WSANO_ADDRESS, "No address, look for MX record" }, - { 0, NULL } - }; PyObject *v; const char *msg = "winsock error"; --- 262,328 ---- #ifdef MS_WINDOWS int err_no = WSAGetLastError(); + static struct { + int no; + const char *msg; + } *msgp, msgs[] = { + {WSAEINTR, "Interrupted system call"}, + {WSAEBADF, "Bad file descriptor"}, + {WSAEACCES, "Permission denied"}, + {WSAEFAULT, "Bad address"}, + {WSAEINVAL, "Invalid argument"}, + {WSAEMFILE, "Too many open files"}, + {WSAEWOULDBLOCK, + "The socket operation could not complete " + "without blocking"}, + {WSAEINPROGRESS, "Operation now in progress"}, + {WSAEALREADY, "Operation already in progress"}, + {WSAENOTSOCK, "Socket operation on non-socket"}, + {WSAEDESTADDRREQ, "Destination address required"}, + {WSAEMSGSIZE, "Message too long"}, + {WSAEPROTOTYPE, "Protocol wrong type for socket"}, + {WSAENOPROTOOPT, "Protocol not available"}, + {WSAEPROTONOSUPPORT, "Protocol not supported"}, + {WSAESOCKTNOSUPPORT, "Socket type not supported"}, + {WSAEOPNOTSUPP, "Operation not supported"}, + {WSAEPFNOSUPPORT, "Protocol family not supported"}, + {WSAEAFNOSUPPORT, "Address family not supported"}, + {WSAEADDRINUSE, "Address already in use"}, + {WSAEADDRNOTAVAIL, "Can't assign requested address"}, + {WSAENETDOWN, "Network is down"}, + {WSAENETUNREACH, "Network is unreachable"}, + {WSAENETRESET, "Network dropped connection on reset"}, + {WSAECONNABORTED, "Software caused connection abort"}, + {WSAECONNRESET, "Connection reset by peer"}, + {WSAENOBUFS, "No buffer space available"}, + {WSAEISCONN, "Socket is already connected"}, + {WSAENOTCONN, "Socket is not connected"}, + {WSAESHUTDOWN, "Can't send after socket shutdown"}, + {WSAETOOMANYREFS, "Too many references: can't splice"}, + {WSAETIMEDOUT, "Operation timed out"}, + {WSAECONNREFUSED, "Connection refused"}, + {WSAELOOP, "Too many levels of symbolic links"}, + {WSAENAMETOOLONG, "File name too long"}, + {WSAEHOSTDOWN, "Host is down"}, + {WSAEHOSTUNREACH, "No route to host"}, + {WSAENOTEMPTY, "Directory not empty"}, + {WSAEPROCLIM, "Too many processes"}, + {WSAEUSERS, "Too many users"}, + {WSAEDQUOT, "Disc quota exceeded"}, + {WSAESTALE, "Stale NFS file handle"}, + {WSAEREMOTE, "Too many levels of remote in path"}, + {WSASYSNOTREADY, "Network subsystem is unvailable"}, + {WSAVERNOTSUPPORTED, "WinSock version is not supported"}, + {WSANOTINITIALISED, + "Successful WSAStartup() not yet performed"}, + {WSAEDISCON, "Graceful shutdown in progress"}, + /* Resolver errors */ + {WSAHOST_NOT_FOUND, "No such host is known"}, + {WSATRY_AGAIN, "Host not found, or server failed"}, + {WSANO_RECOVERY, "Unexpected server error encountered"}, + {WSANO_DATA, "Valid name without requested data"}, + {WSANO_ADDRESS, "No address, look for MX record"}, + {0, NULL} + }; if (err_no) { PyObject *v; const char *msg = "winsock error"; *************** *** 349,378 **** #if defined(PYOS_OS2) && !defined(PYCC_GCC) ! if (sock_errno() != NO_ERROR) { ! APIRET rc; ! ULONG msglen; ! char outbuf[100]; ! int myerrorcode = sock_errno(); ! /* Retrieve Socket-Related Error Message from MPTN.MSG File */ ! rc = DosGetMessage(NULL, 0, outbuf, sizeof(outbuf), ! myerrorcode - SOCBASEERR + 26, "mptn.msg", &msglen); ! if (rc == NO_ERROR) { ! PyObject *v; ! outbuf[msglen] = '\0'; /* OS/2 Doesn't Guarantee a Terminator */ ! if (strlen(outbuf) > 0) { /* If Non-Empty Msg, Trim CRLF */ ! char *lastc = &outbuf[ strlen(outbuf)-1 ]; ! while (lastc > outbuf && isspace(*lastc)) ! *lastc-- = '\0'; /* Trim Trailing Whitespace (CRLF) */ ! } ! v = Py_BuildValue("(is)", myerrorcode, outbuf); ! if (v != NULL) { ! PyErr_SetObject(PySocket_Error, v); ! Py_DECREF(v); ! } ! return NULL; ! } ! } #endif --- 346,381 ---- #if defined(PYOS_OS2) && !defined(PYCC_GCC) ! if (sock_errno() != NO_ERROR) { ! APIRET rc; ! ULONG msglen; ! char outbuf[100]; ! int myerrorcode = sock_errno(); ! /* Retrieve socket-related error message from MPTN.MSG file */ ! rc = DosGetMessage(NULL, 0, outbuf, sizeof(outbuf), ! myerrorcode - SOCBASEERR + 26, ! "mptn.msg", ! &msglen); ! if (rc == NO_ERROR) { ! PyObject *v; ! /* OS/2 doesn't guarantee a terminator */ ! outbuf[msglen] = '\0'; ! if (strlen(outbuf) > 0) { ! /* If non-empty msg, trim CRLF */ ! char *lastc = &outbuf[ strlen(outbuf)-1 ]; ! while (lastc > outbuf && isspace(*lastc)) { ! /* Trim trailing whitespace (CRLF) */ ! *lastc-- = '\0'; ! } ! } ! v = Py_BuildValue("(is)", myerrorcode, outbuf); ! if (v != NULL) { ! PyErr_SetObject(PySocket_Error, v); ! Py_DECREF(v); ! } ! return NULL; ! } ! } #endif *************** *** 444,450 **** } ! /* Function to perfrom the setting of socket blocking mode ! * internally. block = (1 | 0). ! */ static int internal_setblocking(PySocketSockObject *s, int block) --- 447,452 ---- } ! /* Function to perform the setting of socket blocking mode ! internally. block = (1 | 0). */ static int internal_setblocking(PySocketSockObject *s, int block) *************** *** 459,464 **** #ifdef __BEOS__ block = !block; ! setsockopt( s->sock_fd, SOL_SOCKET, SO_NONBLOCK, ! (void *)(&block), sizeof(int)); #else #ifndef RISCOS --- 461,466 ---- #ifdef __BEOS__ block = !block; ! setsockopt(s->sock_fd, SOL_SOCKET, SO_NONBLOCK, ! (void *)(&block), sizeof(int)); #else #ifndef RISCOS *************** *** 488,495 **** /* For access to the select module to poll the socket for timeout ! * functionality. writing is 1 for writing, 0 for reading. ! * Return value: -1 if error, 0 if not ready, >= 1 if ready. ! * An exception is set when the return value is <= 0 (!). ! */ static int internal_select(PySocketSockObject *s, int writing) --- 490,496 ---- /* For access to the select module to poll the socket for timeout ! functionality. writing is 1 for writing, 0 for reading. ! Return value: -1 if error, 0 if not ready, >= 1 if ready. ! An exception is set when the return value is <= 0 (!). */ static int internal_select(PySocketSockObject *s, int writing) *************** *** 518,523 **** /* Set the error if the timeout has elapsed, i.e, we were not ! * polled. ! */ if (count == 0) timeout_err(); --- 519,523 ---- /* Set the error if the timeout has elapsed, i.e, we were not ! polled. */ if (count == 0) timeout_err(); *************** *** 544,550 **** s->errorhandler = &PySocket_Err; #ifdef RISCOS ! if(taskwindow) { socketioctl(s->sock_fd, 0x80046679, (u_long*)&block); - } #endif } --- 544,549 ---- s->errorhandler = &PySocket_Err; #ifdef RISCOS ! if (taskwindow) socketioctl(s->sock_fd, 0x80046679, (u_long*)&block); #endif } *************** *** 582,586 **** static int ! setipaddr(char* name, struct sockaddr * addr_ret, int af) { struct addrinfo hints, *res; --- 581,585 ---- static int ! setipaddr(char *name, struct sockaddr *addr_ret, int af) { struct addrinfo hints, *res; *************** *** 644,653 **** error = getaddrinfo(name, NULL, &hints, &res); #if defined(__digital__) && defined(__unix__) ! if (error == EAI_NONAME && af == AF_UNSPEC) { ! /* On Tru64 V5.1, numeric-to-addr conversion ! fails if no address family is given. Assume IPv4 for now.*/ ! hints.ai_family = AF_INET; ! error = getaddrinfo(name, NULL, &hints, &res); ! } #endif if (error) { --- 643,652 ---- error = getaddrinfo(name, NULL, &hints, &res); #if defined(__digital__) && defined(__unix__) ! if (error == EAI_NONAME && af == AF_UNSPEC) { ! /* On Tru64 V5.1, numeric-to-addr conversion fails ! if no address family is given. Assume IPv4 for now.*/ ! hints.ai_family = AF_INET; ! error = getaddrinfo(name, NULL, &hints, &res); ! } #endif if (error) { *************** *** 742,747 **** if (addrobj) { a = (struct sockaddr_in6 *)addr; ! ret = Py_BuildValue("Oiii", addrobj, ntohs(a->sin6_port), ! a->sin6_flowinfo, a->sin6_scope_id); Py_DECREF(addrobj); } --- 741,749 ---- if (addrobj) { a = (struct sockaddr_in6 *)addr; ! ret = Py_BuildValue("Oiii", ! addrobj, ! ntohs(a->sin6_port), ! a->sin6_flowinfo, ! a->sin6_scope_id); Py_DECREF(addrobj); } *************** *** 762,768 **** ifname = ifr.ifr_name; } ! return Py_BuildValue("shbhs#", ifname, ntohs(a->sll_protocol), ! a->sll_pkttype, a->sll_hatype, ! a->sll_addr, a->sll_halen); } #endif --- 764,774 ---- ifname = ifr.ifr_name; } ! return Py_BuildValue("shbhs#", ! ifname, ! ntohs(a->sll_protocol), ! a->sll_pkttype, ! a->sll_hatype, ! a->sll_addr, ! a->sll_halen); } #endif *************** *** 823,829 **** addr=(struct sockaddr_in*)&(s->sock_addr).in; if (!PyTuple_Check(args)) { ! PyErr_Format(PyExc_TypeError, ! "getsockaddrarg: AF_INET address must be tuple, not %.500s", ! args->ob_type->tp_name); return 0; } --- 829,837 ---- addr=(struct sockaddr_in*)&(s->sock_addr).in; if (!PyTuple_Check(args)) { ! PyErr_Format( ! PyExc_TypeError, ! "getsockaddrarg: " ! "AF_INET address must be tuple, not %.500s", ! args->ob_type->tp_name); return 0; } *************** *** 848,852 **** flowinfo = scope_id = 0; if (!PyArg_ParseTuple(args, "si|ii", &host, &port, &flowinfo, ! &scope_id)) { return 0; } --- 856,860 ---- flowinfo = scope_id = 0; if (!PyArg_ParseTuple(args, "si|ii", &host, &port, &flowinfo, ! &scope_id)) { return 0; } *************** *** 1008,1013 **** /* At this point, we really have an error, whether using timeout ! * behavior or regular socket behavior ! */ #ifdef MS_WINDOWS if (newfd == INVALID_SOCKET) --- 1016,1020 ---- /* At this point, we really have an error, whether using timeout ! behavior or regular socket behavior */ #ifdef MS_WINDOWS if (newfd == INVALID_SOCKET) *************** *** 1029,1033 **** } addr = makesockaddr(s->sock_fd, (struct sockaddr *)addrbuf, ! addrlen); if (addr == NULL) goto finally; --- 1036,1040 ---- } addr = makesockaddr(s->sock_fd, (struct sockaddr *)addrbuf, ! addrlen); if (addr == NULL) goto finally; *************** *** 1062,1067 **** /* If we're not using timeouts, actually set the blocking to give ! * old python behavior. ! */ if (s->sock_timeout < 0.0) internal_setblocking(s, block); --- 1069,1073 ---- /* If we're not using timeouts, actually set the blocking to give ! old python behavior. */ if (s->sock_timeout < 0.0) internal_setblocking(s, block); *************** *** 1077,1084 **** This uses the FIONBIO ioctl with the O_NDELAY flag."; ! /* s.settimeout(float | None) method. ! * Causes an exception to be raised when the given time has ! * elapsed when performing a blocking socket operation. ! */ static PyObject * PySocketSock_settimeout(PySocketSockObject *s, PyObject *arg) --- 1083,1089 ---- This uses the FIONBIO ioctl with the O_NDELAY flag."; ! /* s.settimeout(None | float) method. ! Causes an exception to be raised when the given time has ! elapsed when performing a blocking socket operation. */ static PyObject * PySocketSock_settimeout(PySocketSockObject *s, PyObject *arg) *************** *** 1101,1115 **** /* The semantics of setting socket timeouts are: ! * If you settimeout(!=None): ! * The actual socket gets put in non-blocking mode and the select ! * is used to control timeouts. ! * Else if you settimeout(None) [then value is -1.0]: ! * The old behavior is used AND automatically, the socket is set ! * to blocking mode. That means that someone who was doing ! * non-blocking stuff before, sets a timeout, and then unsets ! * one, will have to call setblocking(0) again if he wants ! * non-blocking stuff. This makes sense because timeout stuff is ! * blocking by nature. ! */ internal_setblocking(s, value < 0.0); --- 1106,1119 ---- /* The semantics of setting socket timeouts are: ! If you settimeout(!=None): ! The actual socket gets put in non-blocking mode and the select ! is used to control timeouts. ! Else if you settimeout(None) [then value is -1.0]: ! The old behavior is used AND automatically, the socket is set ! to blocking mode. That means that someone who was doing ! non-blocking stuff before, sets a timeout, and then unsets ! one, will have to call setblocking(0) again if he wants ! non-blocking stuff. This makes sense because timeout stuff is ! blocking by nature. */ internal_setblocking(s, value < 0.0); *************** *** 1121,1135 **** static char settimeout_doc[] = ! "settimeout(seconds)\n\ \n\ ! Set a timeout on blocking socket operations. 'seconds' can be a floating,\n\ ! integer, or long number of seconds, or the None value. Socket operations\n\ ! will raise an exception if the timeout period has elapsed before the\n\ ! operation has completed. Setting a timeout of None disables timeouts\n\ ! on socket operations."; ! /* s.gettimeout () method. ! * Returns the timeout associated with a socket. ! */ static PyObject * PySocketSock_gettimeout(PySocketSockObject *s) --- 1125,1135 ---- static char settimeout_doc[] = ! "settimeout(timeout)\n\ \n\ ! Set a timeout on blocking socket operations. 'timeout' can be a float,\n\ ! giving seconds, or None. Setting a timeout of None disables timeout."; ! /* s.gettimeout() method. ! Returns the timeout associated with a socket. */ static PyObject * PySocketSock_gettimeout(PySocketSockObject *s) *************** *** 1357,1362 **** /* Check if we have an error */ if (!s->sock_blocking) ! return s->errorhandler (); ! /* Check if we have a true failure for a blocking socket */ #ifdef MS_WINDOWS if (errno != WSAEWOULDBLOCK) --- 1357,1363 ---- /* Check if we have an error */ if (!s->sock_blocking) ! return s->errorhandler(); ! /* Check if we have a true failure ! for a blocking socket */ #ifdef MS_WINDOWS if (errno != WSAEWOULDBLOCK) *************** *** 1424,1428 **** if (!s->sock_blocking) goto conex_finally; ! /* Check if we have a true failure for a blocking socket */ #ifdef MS_WINDOWS if (errno != WSAEWOULDBLOCK) --- 1425,1430 ---- if (!s->sock_blocking) goto conex_finally; ! /* Check if we have a true failure ! for a blocking socket */ #ifdef MS_WINDOWS if (errno != WSAEWOULDBLOCK) *************** *** 1754,1758 **** if (!(addr = makesockaddr(s->sock_fd, (struct sockaddr *)addrbuf, ! addrlen))) goto finally; --- 1756,1760 ---- if (!(addr = makesockaddr(s->sock_fd, (struct sockaddr *)addrbuf, ! addrlen))) goto finally; *************** *** 1940,1948 **** fileno_doc}, #ifdef HAVE_GETPEERNAME ! {"getpeername", (PyCFunction)PySocketSock_getpeername, ! METH_NOARGS, getpeername_doc}, #endif {"getsockname", (PyCFunction)PySocketSock_getsockname, ! METH_NOARGS, getsockname_doc}, {"getsockopt", (PyCFunction)PySocketSock_getsockopt, METH_VARARGS, getsockopt_doc}, --- 1942,1950 ---- fileno_doc}, #ifdef HAVE_GETPEERNAME ! {"getpeername", (PyCFunction)PySocketSock_getpeername, ! METH_NOARGS, getpeername_doc}, #endif {"getsockname", (PyCFunction)PySocketSock_getsockname, ! METH_NOARGS, getsockname_doc}, {"getsockopt", (PyCFunction)PySocketSock_getsockopt, METH_VARARGS, getsockopt_doc}, *************** *** 2003,2015 **** printing, only bother if necessary*/ PyErr_SetString(PyExc_OverflowError, ! "no printf formatter to display the socket descriptor in decimal"); return NULL; } #endif ! PyOS_snprintf(buf, sizeof(buf), ! "", ! (long)s->sock_fd, s->sock_family, ! s->sock_type, ! s->sock_proto); return PyString_FromString(buf); } --- 2005,2019 ---- printing, only bother if necessary*/ PyErr_SetString(PyExc_OverflowError, ! "no printf formatter to display " ! "the socket descriptor in decimal"); return NULL; } #endif ! PyOS_snprintf( ! buf, sizeof(buf), ! "", ! (long)s->sock_fd, s->sock_family, ! s->sock_type, ! s->sock_proto); return PyString_FromString(buf); } *************** *** 2107,2110 **** --- 2111,2115 ---- sendto() -- send data to a given address\n\ setblocking() -- set or clear the blocking I/O flag\n\ + settimeout() -- set or clear the timeout\n\ setsockopt() -- set socket options\n\ shutdown() -- shut down traffic in one or both directions\n\ *************** *** 2227,2235 **** if (h->h_addrtype != af) { #ifdef HAVE_STRERROR ! /* Let's get real error message to return */ ! PyErr_SetString(PySocket_Error, (char *)strerror(EAFNOSUPPORT)); ! #else PyErr_SetString(PySocket_Error, ! "Address family not supported by protocol family"); #endif return NULL; --- 2232,2242 ---- if (h->h_addrtype != af) { #ifdef HAVE_STRERROR ! /* Let's get real error message to return */ PyErr_SetString(PySocket_Error, ! (char *)strerror(EAFNOSUPPORT)); ! #else ! PyErr_SetString( ! PySocket_Error, ! "Address family not supported by protocol family"); #endif return NULL; *************** *** 2313,2317 **** default: /* can't happen */ PyErr_SetString(PySocket_Error, ! "unsupported address family"); return NULL; } --- 2320,2324 ---- default: /* can't happen */ PyErr_SetString(PySocket_Error, ! "unsupported address family"); return NULL; } *************** *** 2368,2372 **** #ifdef HAVE_GETHOSTBYNAME_R #if defined(HAVE_GETHOSTBYNAME_R_6_ARG) ! result = gethostbyname_r(name, &hp_allocated, buf, buf_len, &h, &errnop); #elif defined(HAVE_GETHOSTBYNAME_R_5_ARG) h = gethostbyname_r(name, &hp_allocated, buf, buf_len, &errnop); --- 2375,2380 ---- #ifdef HAVE_GETHOSTBYNAME_R #if defined(HAVE_GETHOSTBYNAME_R_6_ARG) ! result = gethostbyname_r(name, &hp_allocated, buf, buf_len, ! &h, &errnop); #elif defined(HAVE_GETHOSTBYNAME_R_5_ARG) h = gethostbyname_r(name, &hp_allocated, buf, buf_len, &errnop); *************** *** 2384,2394 **** Py_END_ALLOW_THREADS /* Some C libraries would require addr.__ss_family instead of ! * addr.ss_family. ! * Therefore, we cast the sockaddr_storage into sockaddr to ! * access sa_family. ! */ sa = (struct sockaddr*)&addr; ret = gethost_common(h, (struct sockaddr *)&addr, sizeof(addr), ! sa->sa_family); #ifdef USE_GETHOSTBYNAME_LOCK PyThread_release_lock(gethostbyname_lock); --- 2392,2401 ---- Py_END_ALLOW_THREADS /* Some C libraries would require addr.__ss_family instead of ! addr.ss_family. ! Therefore, we cast the sockaddr_storage into sockaddr to ! access sa_family. */ sa = (struct sockaddr*)&addr; ret = gethost_common(h, (struct sockaddr *)&addr, sizeof(addr), ! sa->sa_family); #ifdef USE_GETHOSTBYNAME_LOCK PyThread_release_lock(gethostbyname_lock); *************** *** 2411,2415 **** { #ifdef ENABLE_IPV6 ! struct sockaddr_storage addr; #else struct sockaddr_in addr; --- 2418,2422 ---- { #ifdef ENABLE_IPV6 ! struct sockaddr_storage addr; #else struct sockaddr_in addr; *************** *** 2665,2674 **** Convert a 32-bit integer from host to network byte order."; ! /* ! * socket.inet_aton() and socket.inet_ntoa() functions ! * ! * written 20 Aug 1999 by Ben Gertzfield <- blame him! ! * ! */ static char inet_aton_doc[] = --- 2672,2676 ---- Convert a 32-bit integer from host to network byte order."; ! /* socket.inet_aton() and socket.inet_ntoa() functions. */ static char inet_aton_doc[] = *************** *** 2828,2832 **** if (!PyArg_ParseTuple(args, "Oi:getnameinfo", &sa, &flags)) return NULL; ! if (!PyArg_ParseTuple(sa, "si|ii", &hostp, &port, &flowinfo, &scope_id)) return NULL; PyOS_snprintf(pbuf, sizeof(pbuf), "%d", port); --- 2830,2835 ---- if (!PyArg_ParseTuple(args, "Oi:getnameinfo", &sa, &flags)) return NULL; ! if (!PyArg_ParseTuple(sa, "si|ii", ! &hostp, &port, &flowinfo, &scope_id)) return NULL; PyOS_snprintf(pbuf, sizeof(pbuf), "%d", port); *************** *** 2952,2957 **** case WSAVERNOTSUPPORTED: case WSAEINVAL: ! PyErr_SetString(PyExc_ImportError, ! "WSAStartup failed: requested version not supported"); break; default: --- 2955,2961 ---- case WSAVERNOTSUPPORTED: case WSAEINVAL: ! PyErr_SetString( ! PyExc_ImportError, ! "WSAStartup failed: requested version not supported"); break; default: *************** *** 2973,2977 **** OS2cleanup(void) { ! /* No cleanup is necessary for OS/2 Sockets */ } --- 2977,2981 ---- OS2cleanup(void) { ! /* No cleanup is necessary for OS/2 Sockets */ } *************** *** 2980,2999 **** { #if !defined(PYCC_GCC) ! char reason[64]; ! int rc = sock_init(); ! if (rc == 0) { ! atexit(OS2cleanup); ! return 1; /* Indicate Success */ ! } ! PyOS_snprintf(reason, sizeof(reason), ! "OS/2 TCP/IP Error# %d", sock_errno()); ! PyErr_SetString(PyExc_ImportError, reason); ! return 0; /* Indicate Failure */ #else ! /* no need to initialise sockets with GCC/EMX */ ! return 1; #endif } --- 2984,3003 ---- { #if !defined(PYCC_GCC) ! char reason[64]; ! int rc = sock_init(); ! if (rc == 0) { ! atexit(OS2cleanup); ! return 1; /* Indicate Success */ ! } ! PyOS_snprintf(reason, sizeof(reason), ! "OS/2 TCP/IP Error# %d", sock_errno()); ! PyErr_SetString(PyExc_ImportError, reason); ! return 0; /* Indicate Failure */ #else ! /* no need to initialise sockets with GCC/EMX */ ! return 1; #endif } *************** *** 3006,3029 **** PySocketModule_APIObject PySocketModuleAPI = { ! &PySocketSock_Type, }; /* Initialize this module. ! * This is called when the first 'import socket' is done, ! * via a table in config.c, if config.c is compiled with USE_SOCKET ! * defined. ! * ! * For MS_WINDOWS (which means any Windows variant), this module ! * is actually called "_socket", and there's a wrapper "socket.py" ! * which implements some missing functionality (such as makefile(), ! * dup() and fromfd()). The import of "_socket" may fail with an ! * ImportError exception if initialization of WINSOCK fails. When ! * WINSOCK is initialized succesfully, a call to WSACleanup() is ! * scheduled to be made at exit time. ! * ! * For OS/2, this module is also called "_socket" and uses a wrapper ! * "socket.py" which implements that functionality that is missing ! * when PC operating systems don't put socket descriptors in the ! * operating system's filesystem layer. */ --- 3010,3034 ---- PySocketModule_APIObject PySocketModuleAPI = { ! &PySocketSock_Type, }; /* Initialize this module. ! ! This is called when the first 'import socket' is done, ! via a table in config.c, if config.c is compiled with USE_SOCKET ! defined. ! ! For MS_WINDOWS (which means any Windows variant), this module ! is actually called "_socket", and there's a wrapper "socket.py" ! which implements some missing functionality (such as makefile(), ! dup() and fromfd()). The import of "_socket" may fail with an ! ImportError exception if initialization of WINSOCK fails. When ! WINSOCK is initialized succesfully, a call to WSACleanup() is ! scheduled to be made at exit time. ! ! For OS/2, this module is also called "_socket" and uses a wrapper ! "socket.py" which implements that functionality that is missing ! when PC operating systems don't put socket descriptors in the ! operating system's filesystem layer. */ *************** *** 3056,3061 **** PySocketSock_Type.tp_alloc = PyType_GenericAlloc; PySocketSock_Type.tp_free = PyObject_Del; ! m = Py_InitModule3(PySocket_MODULE_NAME, ! PySocket_methods, module_doc); --- 3061,3066 ---- PySocketSock_Type.tp_alloc = PyType_GenericAlloc; PySocketSock_Type.tp_free = PyObject_Del; ! m = Py_InitModule3(PySocket_MODULE_NAME, ! PySocket_methods, module_doc); *************** *** 3217,3221 **** PyModule_AddIntConstant(m, "SOMAXCONN", SOMAXCONN); #else ! PyModule_AddIntConstant(m, "SOMAXCONN", 5); /* Common value */ #endif --- 3222,3226 ---- PyModule_AddIntConstant(m, "SOMAXCONN", SOMAXCONN); #else ! PyModule_AddIntConstant(m, "SOMAXCONN", 5); /* Common value */ #endif *************** *** 3667,3674 **** /* Simplistic emulation code for inet_pton that only works for IPv4 */ #ifndef HAVE_INET_PTON ! int inet_pton (int af, const char *src, void *dst) { ! if(af == AF_INET){ long packed_addr; packed_addr = inet_addr(src); --- 3672,3679 ---- /* Simplistic emulation code for inet_pton that only works for IPv4 */ #ifndef HAVE_INET_PTON ! int inet_pton (int af, const char *src, void *dst) { ! if (af == AF_INET){ long packed_addr; packed_addr = inet_addr(src); From gvanrossum@users.sourceforge.net Fri Jun 7 03:27:52 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 06 Jun 2002 19:27:52 -0700 Subject: [Python-checkins] python/dist/src/Modules socketmodule.h,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv26650 Modified Files: socketmodule.h Log Message: Repair a comment. Index: socketmodule.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** socketmodule.h 6 Jun 2002 21:08:16 -0000 1.6 --- socketmodule.h 7 Jun 2002 02:27:50 -0000 1.7 *************** *** 157,161 **** /* Interfacestructure to C API for other modules. ! Call PySocket_ImportModuleAPI() to initialize this structure. After that usage is simple: --- 157,161 ---- /* Interfacestructure to C API for other modules. ! Call PySocketModule_ImportModuleAndAPI() to initialize this structure. After that usage is simple: From bwarsaw@users.sourceforge.net Fri Jun 7 03:47:15 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Thu, 06 Jun 2002 19:47:15 -0700 Subject: [Python-checkins] python/nondist/peps pep-0291.txt,NONE,1.1 pep-291.txt,1.1,NONE Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv32254 Added Files: pep-0291.txt Removed Files: pep-291.txt Log Message: The PEP file name was non-standard. pep-0291.txt is just a copy of pep-291.txt. Please use the former. --- NEW FILE: pep-0291.txt --- PEP: 291 Title: Backward Compatibility for Standard Library Version: $Revision: 1.1 $ Last-Modified: $Date: 2002/06/07 02:47:13 $ Author: neal@metaslash.com (Neal Norwitz) Status: Active Type: Informational Created: 06-Jun-2002 Post-History: Python-Version: 2.3 Abstract This PEP describes the packages and modules in the standard library which should remain backward compatible with previous versions of Python. Rationale Authors have various reasons why packages and modules should continue to work with previous versions of Python. In order to maintain backward compatibility for these modules while moving the rest of the standard library forward, it is necessary to know which modules can be modified and which should use old and possibly deprecated features. Generally, authors should attempt to keep changes backward compatible with the previous released version of Python in order to make bug fixes easier to backport. Features to Avoid The following list contains common features to avoid in order to maintain backward compatibility with each version of Python. This list is not complete! It is only meant as a general guide. Note the features to avoid were implemented in the following version. For example, features listed next to 1.5.2 were implemented in 2.0. Version Features ------- -------- 1.5.2 string methods, Unicode, list comprehensions, augmented assignment (eg, +=), zip(), import x as y, dict.setdefault(), print >> f, calling f(*args, **kw), plus 2.0 features 2.0 nested scopes, rich comparisons, function attributes, plus 2.1 features 2.1 use of object or new-style classes, iterators, using generators, nested scopes, or // without from __future__ import ... statement, plus 2.2 features 2.2 bool, True, False, basestring, enumerate(), {}.pop(), PendingDeprecationWarning, Universal Newlines, plus 2.3 features Backward Compatible Packages, Modules, and Tools Package/Module Maintainer(s) Python Version -------------- ------------- -------------- compiler Jeremy Hylton 2.1 distutils Andrew Kuchling 1.5.2 email Barry Warsaw 2.1 sre Fredrik Lundh 1.5.2 xml (PyXML) Martin v. Loewis 2.0 xmlrpclib Fredrik Lundh 1.5.2 Tool Maintainer(s) Python Version ---- ------------- -------------- scripts/freeze/modulefinder Thomas Heller 1.5.2 Copyright This document has been placed in the public domain. Local Variables: mode: indented-text indent-tabs-mode: nil sentence-end-double-space: t fill-column: 70 End: --- pep-291.txt DELETED --- From gvanrossum@users.sourceforge.net Fri Jun 7 04:19:40 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 06 Jun 2002 20:19:40 -0700 Subject: [Python-checkins] python/dist/src/Modules socketmodule.c,1.221,1.222 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv12522 Modified Files: socketmodule.c Log Message: Major cleanup. Renamed static methods to avoid Py prefix. Other misc cleanup as well, e.g. renamed NTinit to os_init. Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.221 retrieving revision 1.222 diff -C2 -d -r1.221 -r1.222 *** socketmodule.c 7 Jun 2002 02:08:35 -0000 1.221 --- socketmodule.c 7 Jun 2002 03:19:37 -0000 1.222 *************** *** 2,13 **** /* This module provides an interface to Berkeley socket IPC. Limitations: ! - only AF_INET, AF_INET6 and AF_UNIX address families are supported in a portable manner, though AF_PACKET is supported under Linux. ! - no read/write operations (use sendall/recv or makefile instead) ! - additional restrictions apply on Windows (compensated for by socket.py) [...1929 lines suppressed...] } ! #ifndef HAVE_INET_PTON + + /* Simplistic emulation code for inet_pton that only works for IPv4 */ + int ! inet_pton(int af, const char *src, void *dst) { ! if (af == AF_INET) { long packed_addr; packed_addr = inet_addr(src); *************** *** 3701,3703 **** --- 3694,3697 ---- return NULL; } + #endif From montanaro@users.sourceforge.net Fri Jun 7 04:26:45 2002 From: montanaro@users.sourceforge.net (montanaro@users.sourceforge.net) Date: Thu, 06 Jun 2002 20:26:45 -0700 Subject: [Python-checkins] python/dist/src/Lib getopt.py,1.19,1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv14189 Modified Files: getopt.py Log Message: gnu_getopt should be exported in __all__ Index: getopt.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/getopt.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** getopt.py 6 Jun 2002 18:14:50 -0000 1.19 --- getopt.py 7 Jun 2002 03:26:43 -0000 1.20 *************** *** 32,36 **** # treat "-W foo" as "--foo" ! __all__ = ["GetoptError","error","getopt"] import os --- 32,36 ---- # treat "-W foo" as "--foo" ! __all__ = ["GetoptError","error","getopt","gnu_getopt"] import os From gvanrossum@users.sourceforge.net Fri Jun 7 04:36:23 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 06 Jun 2002 20:36:23 -0700 Subject: [Python-checkins] python/dist/src/Modules socketmodule.c,1.222,1.223 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv16461 Modified Files: socketmodule.c Log Message: I decided to change the interaction between setblocking() and settimeout(). Already, settimeout() canceled non-blocking mode; now, setblocking() also cancels the timeout. This is easier to document. (XXX should settimeout(0) be an alias for setblocking(0)? They seem to have roughly the same effect. Also, I'm not sure that the code in connect() and accept() is correct in all cases. We'll sort this out soon enough.) Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.222 retrieving revision 1.223 diff -C2 -d -r1.222 -r1.223 *** socketmodule.c 7 Jun 2002 03:19:37 -0000 1.222 --- socketmodule.c 7 Jun 2002 03:36:20 -0000 1.223 *************** *** 1087,1095 **** s->sock_blocking = block; ! ! /* If we're not using timeouts, actually set the blocking to give ! old python behavior. */ ! if (s->sock_timeout < 0.0) ! internal_setblocking(s, block); Py_INCREF(Py_None); --- 1087,1092 ---- s->sock_blocking = block; ! s->sock_timeout = -1.0; /* Always clear the timeout */ ! internal_setblocking(s, block); Py_INCREF(Py_None); From gvanrossum@users.sourceforge.net Fri Jun 7 04:39:23 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 06 Jun 2002 20:39:23 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libsocket.tex,1.64,1.65 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv17141 Modified Files: libsocket.tex Log Message: Clarify the interaction between blocking and timeouts. Explain that fromfd() assumes a blocking non-timeout socket. Index: libsocket.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsocket.tex,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** libsocket.tex 6 Jun 2002 22:24:10 -0000 1.64 --- libsocket.tex 7 Jun 2002 03:39:21 -0000 1.65 *************** *** 285,289 **** used to get or set socket options on a socket passed to a program as standard input or output (such as a server started by the \UNIX{} inet ! daemon). Availability: \UNIX. \end{funcdesc} --- 285,290 ---- used to get or set socket options on a socket passed to a program as standard input or output (such as a server started by the \UNIX{} inet ! daemon). The socket is assumed to be created in blocking mode without ! a timeout. Availability: \UNIX. \end{funcdesc} *************** *** 516,524 **** \begin{methoddesc}[socket]{settimeout}{value} ! Set a timeout on blocking socket operations. Value can be any numeric ! value or \code{None}. Socket operations will raise an ! \exception{error} exception if the timeout period \var{value} has ! elapsed before the operation has completed. Setting a timeout of ! \code{None} disables timeouts on socket operations. \versionadded{2.3} \end{methoddesc} --- 517,526 ---- \begin{methoddesc}[socket]{settimeout}{value} ! Set a timeout on blocking socket operations. Value can be a ! nonnegative float expressing seconds, or \code{None}. If a float is ! give, subsequent socket operations will raise an \exception{error} ! exception if the timeout period \var{value} has elapsed before the ! operation has completed. Setting a timeout of \code{None} disables ! timeouts on socket operations. \versionadded{2.3} \end{methoddesc} *************** *** 526,542 **** \begin{methoddesc}[socket]{gettimeout}{} Returns the timeout in floating seconds associated with socket ! operations. A timeout of \code{None} indicates that timeouts on ! socket operations are disabled. \versionadded{2.3} \end{methoddesc} ! Some notes on the interaction between socket blocking and timeouts: ! socket blocking mode takes precedence over timeouts. If a socket is ! set to non-blocking mode, then timeouts are not used. ! The timeout value associated with the socket can still be set using ! \method{settimeout()} and its value retrieved using ! \method{gettimeout()}, but the timeout is never enforced (an exception ! will never be thrown). Otherwise, if the socket is in blocking mode, ! setting the timeout will raise an exception as expected. \begin{methoddesc}[socket]{setsockopt}{level, optname, value} --- 528,549 ---- \begin{methoddesc}[socket]{gettimeout}{} Returns the timeout in floating seconds associated with socket ! operations, or \code{None} if no timeout is set. \versionadded{2.3} \end{methoddesc} ! Some notes on the interaction between socket blocking and timeouts: A ! socket object can be in one of three modes: blocking, non-blocking, or ! timout. Sockets are always created in blocking mode. In blocking ! mode, operations block until complete. In non-blocking mode, ! operations fail (with an error that is unfortunately system-dependent) ! if they cannot be completed immediately. In timeout mode, operations ! fail if they cannot be completed within the timeout specified for the ! socket. ! ! Calling \method{settimeout()} cancels non-blocking mode as set by ! \method{setblocking()}; calling \method{setblocking()} cancels a ! previously set timeout. Setting the timeout to zero acts similarly ! but is implemented different than setting the socket in non-blocking ! mode (this could be considered a bug and may even be fixed). \begin{methoddesc}[socket]{setsockopt}{level, optname, value} From nnorwitz@users.sourceforge.net Fri Jun 7 13:36:46 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Fri, 07 Jun 2002 05:36:46 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libsocket.tex,1.65,1.66 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv11168/Doc/lib Modified Files: libsocket.tex Log Message: Fix typo Index: libsocket.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsocket.tex,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** libsocket.tex 7 Jun 2002 03:39:21 -0000 1.65 --- libsocket.tex 7 Jun 2002 12:36:44 -0000 1.66 *************** *** 519,523 **** Set a timeout on blocking socket operations. Value can be a nonnegative float expressing seconds, or \code{None}. If a float is ! give, subsequent socket operations will raise an \exception{error} exception if the timeout period \var{value} has elapsed before the operation has completed. Setting a timeout of \code{None} disables --- 519,523 ---- Set a timeout on blocking socket operations. Value can be a nonnegative float expressing seconds, or \code{None}. If a float is ! given, subsequent socket operations will raise an \exception{error} exception if the timeout period \var{value} has elapsed before the operation has completed. Setting a timeout of \code{None} disables From gvanrossum@users.sourceforge.net Fri Jun 7 13:38:25 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Fri, 07 Jun 2002 05:38:25 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libsocket.tex,1.66,1.67 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv11978 Modified Files: libsocket.tex Log Message: Clarify the interaction between timeout/non-blocking mode, makefile and fromfd. Index: libsocket.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsocket.tex,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** libsocket.tex 7 Jun 2002 12:36:44 -0000 1.66 --- libsocket.tex 7 Jun 2002 12:38:23 -0000 1.67 *************** *** 285,289 **** used to get or set socket options on a socket passed to a program as standard input or output (such as a server started by the \UNIX{} inet ! daemon). The socket is assumed to be created in blocking mode without a timeout. Availability: \UNIX. --- 285,289 ---- used to get or set socket options on a socket passed to a program as standard input or output (such as a server started by the \UNIX{} inet ! daemon). The socket is assumed to be in blocking mode without a timeout. Availability: \UNIX. *************** *** 456,459 **** --- 456,460 ---- socket file descriptor, so the file object and socket object may be closed or garbage-collected independently. + The socket should be in blocking mode. \index{I/O control!buffering}The optional \var{mode} and \var{bufsize} arguments are interpreted the same way as by the *************** *** 546,549 **** --- 547,558 ---- but is implemented different than setting the socket in non-blocking mode (this could be considered a bug and may even be fixed). + + Timeout mode internally sets the socket in non-blocking mode. The + blocking and timeout modes are shared between file descriptors and + socket objects that refer to the same network endpoint. A consequence + of this is that file objects returned by the \method{makefile()} + method should only be used when the socket is in blocking mode; in + timeout or non-blocking mode file operations that cannot be completed + immediately will fail. \begin{methoddesc}[socket]{setsockopt}{level, optname, value} From gvanrossum@users.sourceforge.net Fri Jun 7 13:40:54 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Fri, 07 Jun 2002 05:40:54 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.418,1.419 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv13033 Modified Files: NEWS Log Message: Add timeout mode. Clarify gnu_getopt. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.418 retrieving revision 1.419 diff -C2 -d -r1.418 -r1.419 *** NEWS 6 Jun 2002 10:58:36 -0000 1.418 --- NEWS 7 Jun 2002 12:40:52 -0000 1.419 *************** *** 131,135 **** Library ! - getopt.gnu_getopt was added. - Stop using strings for exceptions. String objects used for --- 131,141 ---- Library ! - Sockets now support timeout mode. After s.settimeout(T), where T is ! a float expressing seconds, subsequent operations raise an exception ! if they cannot be completed within T seconds. To disable timeout ! mode, use s.settimeout(None). ! ! - getopt.gnu_getopt was added. This supports GNU-style option ! processing, where options can be mixed with non-option arguments. - Stop using strings for exceptions. String objects used for From doerwalter@users.sourceforge.net Fri Jun 7 15:47:22 2002 From: doerwalter@users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Fri, 07 Jun 2002 07:47:22 -0700 Subject: [Python-checkins] python/dist/src/Tools/world world,3.13,3.14 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/world In directory usw-pr-cvs1:/tmp/cvs-serv27392/world Modified Files: world Log Message: Apply diff2.txt from SF patch http://www.python.org/sf/565471 This patch replaces string module functions with string methods in the Tools/world/world scripts. It also updates two outdated URLs and the countrycodes dictionary. It fixes a bug where result of string.find() was checked for truth instead of compared with -1. It also replaces <> with != in two spots. Index: world =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/world/world,v retrieving revision 3.13 retrieving revision 3.14 diff -C2 -d -r3.13 -r3.14 *** world 26 May 1999 04:02:18 -0000 3.13 --- world 7 Jun 2002 14:47:20 -0000 3.14 *************** *** 41,51 **** Country codes are maintained by the RIPE Network Coordination Centre, in coordination with the ISO 3166 Maintenance Agency at DIN Berlin. The ! authoritative source of counry code mappings is: ! The latest known change to this information was: ! Thu Aug 7 17:59:51 MET DST 1997 This script also knows about non-geographic top-level domains. --- 41,51 ---- Country codes are maintained by the RIPE Network Coordination Centre, in coordination with the ISO 3166 Maintenance Agency at DIN Berlin. The ! authoritative source of country code mappings is: ! The latest known change to this information was: ! Friday, 5 April 2002, 12.00 CET 2002 This script also knows about non-geographic top-level domains. *************** *** 89,93 **** import sys - import string import getopt try: --- 89,92 ---- *************** *** 110,114 **** def resolve(rawaddr): ! parts = string.splitfields(rawaddr, '.') if not len(parts): # no top level domain found, bounce it to the next step --- 109,113 ---- def resolve(rawaddr): ! parts = rawaddr.split('.') if not len(parts): # no top level domain found, bounce it to the next step *************** *** 116,120 **** addr = parts[-1] if nameorgs.has_key(addr): ! if string.lower(nameorgs[addr][0]) in 'aeiou': ana = 'an' else: --- 115,119 ---- addr = parts[-1] if nameorgs.has_key(addr): ! if nameorgs[addr][0].lower() in 'aeiou': ana = 'an' else: *************** *** 172,176 **** mo = cre.match(line) if not mo: ! line = string.strip(line) if not line: continue --- 171,175 ---- mo = cre.match(line) if not mo: ! line = line.strip() if not line: continue *************** *** 182,208 **** country, code = mo.group(1, 2) if normalize: ! words = string.split(country) for i in range(len(words)): w = words[i] # XXX special cases if w in ('AND', 'OF', 'OF)', 'name:', 'METROPOLITAN'): ! words[i] = string.lower(w) ! elif w == 'THE' and i <> 1: ! words[i] = string.lower(w) elif len(w) > 3 and w[1] == "'": ! words[i] = string.upper(w[0:3]) + \ ! string.lower(w[3:]) elif w == '(U.S.)': pass ! elif w[0] == '(' and w <> '(local': ! words[i] = '(' + string.capitalize(w[1:]) ! elif string.find(w, '-'): ! words[i] = string.join( ! map(string.capitalize, string.split(w, '-')), ! '-') else: ! words[i] = string.capitalize(w) ! code = string.lower(code) ! country = string.join(words) print ' "%s": "%s",' % (code, country) else: --- 181,204 ---- country, code = mo.group(1, 2) if normalize: ! words = country.split() for i in range(len(words)): w = words[i] # XXX special cases if w in ('AND', 'OF', 'OF)', 'name:', 'METROPOLITAN'): ! words[i] = w.lower() ! elif w == 'THE' and i != 1: ! words[i] = w.lower() elif len(w) > 3 and w[1] == "'": ! words[i] = w[0:3].upper() + w[3:].lower() elif w == '(U.S.)': pass ! elif w[0] == '(' and w != '(local': ! words[i] = '(' + w[1:].capitalize() ! elif w.find('-') != -1: ! words[i] = '-'.join([s.capitalize() for s in w.split('-')]) else: ! words[i] = w.capitalize() ! code = code.lower() ! country = ' '.join(words) print ' "%s": "%s",' % (code, country) else: *************** *** 290,294 **** # Book' protocols over X.25 to Internet protocols over IP. # ! # See "uk": "United Kingdom (common practice)", "su": "Soviet Union (still in limited use)", --- 286,290 ---- # Book' protocols over X.25 to Internet protocols over IP. # ! # See "uk": "United Kingdom (common practice)", "su": "Soviet Union (still in limited use)", *************** *** 351,355 **** "cr": "Costa Rica", "ci": "Cote D'Ivoire", ! "hr": "Croatia (local name: Hrvatska)", "cu": "Cuba", "cy": "Cyprus", --- 347,351 ---- "cr": "Costa Rica", "ci": "Cote D'Ivoire", ! "hr": "Croatia", "cu": "Cuba", "cy": "Cyprus", *************** *** 372,376 **** "fi": "Finland", "fr": "France", - "fx": "France, metropolitan", "gf": "French Guiana", "pf": "French Polynesia", --- 368,371 ---- *************** *** 392,396 **** "gy": "Guyana", "ht": "Haiti", ! "hm": "Heard and Mc Donald Islands", "va": "Holy See (Vatican City State)", "hn": "Honduras", --- 387,391 ---- "gy": "Guyana", "ht": "Haiti", ! "hm": "Heard Island and Mcdonald Islands", "va": "Holy See (Vatican City State)", "hn": "Honduras", *************** *** 400,404 **** "in": "India", "id": "Indonesia", ! "ir": "Iran (Islamic Republic of)", "iq": "Iraq", "ie": "Ireland", --- 395,399 ---- "in": "India", "id": "Indonesia", ! "ir": "Iran, Islamic Republic of", "iq": "Iraq", "ie": "Ireland", *************** *** 408,412 **** "jp": "Japan", "jo": "Jordan", ! "kz": "Kazakhstan", "ke": "Kenya", "ki": "Kiribati", --- 403,407 ---- "jp": "Japan", "jo": "Jordan", ! "kz": "Kazakstan", "ke": "Kenya", "ki": "Kiribati", *************** *** 463,466 **** --- 458,462 ---- "pk": "Pakistan", "pw": "Palau", + "ps": "Palestinian Territory, Occupied", "pa": "Panama", "pg": "Papua New Guinea", *************** *** 477,482 **** --- 473,480 ---- "ru": "Russian Federation", "rw": "Rwanda", + "sh": "Saint Helena", "kn": "Saint Kitts and Nevis", "lc": "Saint Lucia", + "pm": "Saint Pierre and Miquelon", "vc": "Saint Vincent and the Grenadines", "ws": "Samoa", *************** *** 488,492 **** "sl": "Sierra Leone", "sg": "Singapore", ! "sk": "Slovakia (Slovak Republic)", "si": "Slovenia", "sb": "Solomon Islands", --- 486,490 ---- "sl": "Sierra Leone", "sg": "Singapore", ! "sk": "Slovakia", "si": "Slovenia", "sb": "Solomon Islands", *************** *** 496,504 **** "es": "Spain", "lk": "Sri Lanka", - "sh": "St. Helena", - "pm": "St. Pierre and Miquelon", "sd": "Sudan", "sr": "Suriname", ! "sj": "Svalbard and Jan Mayen Islands", "sz": "Swaziland", "se": "Sweden", --- 494,500 ---- "es": "Spain", "lk": "Sri Lanka", "sd": "Sudan", "sr": "Suriname", ! "sj": "Svalbard and Jan Mayen", "sz": "Swaziland", "se": "Sweden", *************** *** 529,535 **** "ve": "Venezuela", "vn": "Viet Nam", ! "vg": "Virgin Islands (British)", ! "vi": "Virgin Islands (U.S.)", ! "wf": "Wallis and Futuna Islands", "eh": "Western Sahara", "ye": "Yemen", --- 525,531 ---- "ve": "Venezuela", "vn": "Viet Nam", ! "vg": "Virgin Islands, British", ! "vi": "Virgin Islands, U.s.", ! "wf": "Wallis and Futuna", "eh": "Western Sahara", "ye": "Yemen", From gvanrossum@users.sourceforge.net Fri Jun 7 16:17:06 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Fri, 07 Jun 2002 08:17:06 -0700 Subject: [Python-checkins] python/dist/src/Lib/test regrtest.py,1.84,1.85 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv6207 Modified Files: regrtest.py Log Message: Added -t (--threshold) option to call gc.set_threshold(N). Index: regrtest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v retrieving revision 1.84 retrieving revision 1.85 diff -C2 -d -r1.84 -r1.85 *** regrtest.py 2 Jun 2002 21:42:01 -0000 1.84 --- regrtest.py 7 Jun 2002 15:17:03 -0000 1.85 *************** *** 19,22 **** --- 19,23 ---- -u: use -- specify which special resource intensive tests to run -h: help -- print this text and exit + -t: threshold -- call gc.set_threshold(N) If non-option arguments are present, they are names for tests to run, *************** *** 26,45 **** -v is incompatible with -g and does not compare test output files. ! -s means to run only a single test and exit. This is useful when doing memory ! analysis on the Python interpreter (which tend to consume too many resources to ! run the full regression test non-stop). The file /tmp/pynexttest is read to ! find the next test to run. If this file is missing, the first test_*.py file ! in testdir or on the command line is used. (actually tempfile.gettempdir() is ! used instead of /tmp). ! -f reads the names of tests from the file given as f's argument, one or more ! test names per line. Whitespace is ignored. Blank lines and lines beginning ! with '#' are ignored. This is especially useful for whittling down failures ! involving interactions among tests. ! -u is used to specify which special resource intensive tests to run, such as ! those requiring large file support or network connectivity. The argument is a ! comma-separated list of words indicating the resources to test. Currently ! only the following are defined: all - Enable all special resources. --- 27,47 ---- -v is incompatible with -g and does not compare test output files. ! -s means to run only a single test and exit. This is useful when ! doing memory analysis on the Python interpreter (which tend to consume ! too many resources to run the full regression test non-stop). The ! file /tmp/pynexttest is read to find the next test to run. If this ! file is missing, the first test_*.py file in testdir or on the command ! line is used. (actually tempfile.gettempdir() is used instead of ! /tmp). ! -f reads the names of tests from the file given as f's argument, one ! or more test names per line. Whitespace is ignored. Blank lines and ! lines beginning with '#' are ignored. This is especially useful for ! whittling down failures involving interactions among tests. ! -u is used to specify which special resource intensive tests to run, ! such as those requiring large file support or network connectivity. ! The argument is a comma-separated list of words indicating the ! resources to test. Currently only the following are defined: all - Enable all special resources. *************** *** 48,57 **** state and output modes. ! largefile - It is okay to run some test that may create huge files. These ! tests can take a long time and may consume >2GB of disk space ! temporarily. ! network - It is okay to run tests that use external network resource, ! e.g. testing SSL support for sockets. """ --- 50,59 ---- state and output modes. ! largefile - It is okay to run some test that may create huge ! files. These tests can take a long time and may ! consume >2GB of disk space temporarily. ! network - It is okay to run tests that use external network ! resource, e.g. testing SSL support for sockets. """ *************** *** 94,101 **** files beginning with test_ will be used. ! The other default arguments (verbose, quiet, generate, exclude, single, ! randomize, findleaks, and use_resources) allow programmers calling main() ! directly to set the values that would normally be set by flags on the ! command line. """ --- 96,103 ---- files beginning with test_ will be used. ! The other default arguments (verbose, quiet, generate, exclude, ! single, randomize, findleaks, and use_resources) allow programmers ! calling main() directly to set the values that would normally be ! set by flags on the command line. """ *************** *** 103,110 **** test_support.record_original_stdout(sys.stdout) try: ! opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:', ['help', 'verbose', 'quiet', 'generate', 'exclude', 'single', 'random', 'fromfile', ! 'findleaks', 'use=']) except getopt.error, msg: usage(2, msg) --- 105,112 ---- test_support.record_original_stdout(sys.stdout) try: ! opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:', ['help', 'verbose', 'quiet', 'generate', 'exclude', 'single', 'random', 'fromfile', ! 'findleaks', 'use=', 'threshold=']) except getopt.error, msg: usage(2, msg) *************** *** 133,136 **** --- 135,141 ---- elif o in ('-l', '--findleaks'): findleaks = 1 + elif o in ('-t', '--threshold'): + import gc + gc.set_threshold(int(a)) elif o in ('-u', '--use'): u = [x.lower() for x in a.split(',')] From bwarsaw@users.sourceforge.net Fri Jun 7 16:48:55 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Fri, 07 Jun 2002 08:48:55 -0700 Subject: [Python-checkins] python/dist/src/Tools/world world,3.14,3.15 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/world In directory usw-pr-cvs1:/tmp/cvs-serv18434 Modified Files: world Log Message: Added the 7 new top level domains, and reworded the nameorgs output. Not sure this is better in all cases. parse(): Fixed a bug in the output; the dict is referred to in the code as `countries' not `country'. Also added no-case-fold for the string "U.S." since the Virgin Islands name no longer wraps those in parentheses. main(): Fixed the argument parsing to agree with the docstring, i.e. --outputdict instead of --output. In the module docstring: - updated my email address - we don't need to explain about Python 1.5 regexps We also don't need to wrap the import of re with a try/except. Other style fixes: - untabification - revert back to <> style everywhere (and consistently) Index: world =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/world/world,v retrieving revision 3.14 retrieving revision 3.15 diff -C2 -d -r3.14 -r3.15 *** world 7 Jun 2002 14:47:20 -0000 3.14 --- world 7 Jun 2002 15:48:52 -0000 3.15 *************** *** 4,8 **** Contact: Barry Warsaw ! Email: bwarsaw@python.org Version: %(__version__)s --- 4,8 ---- Contact: Barry Warsaw ! Email: barry@python.org Version: %(__version__)s *************** *** 15,21 **** somebody@where.xx -- an Internet email address ! If no match is found, the address is interpreted as a regular expression [*] ! and a reverse lookup is attempted. This script will search the country names ! and print a list of matching entries. You can force reverse mappings with the `-r' flag (see below). --- 15,21 ---- somebody@where.xx -- an Internet email address ! If no match is found, the address is interpreted as a regular expression and a ! reverse lookup is attempted. This script will search the country names and ! print a list of matching entries. You can force reverse mappings with the `-r' flag (see below). *************** *** 35,42 **** gb: United Kingdom - - [*] Note that regular expressions must conform to Python 1.5's re.py module - syntax. The comparison is done with the search() method. - Country codes are maintained by the RIPE Network Coordination Centre, in coordination with the ISO 3166 Maintenance Agency at DIN Berlin. The --- 35,38 ---- *************** *** 70,74 **** of a Python dictionary, and country names are normalized w.r.t. capitalization. This makes it appropriate for cutting and ! pasting back into this file. --reverse --- 66,70 ---- of a Python dictionary, and country names are normalized w.r.t. capitalization. This makes it appropriate for cutting and ! pasting back into this file. Output is always to standard out. --reverse *************** *** 83,87 **** --help Print this message. - """ __version__ = '$Revision$' --- 79,82 ---- *************** *** 90,98 **** import sys import getopt ! try: ! import re ! except ImportError: ! print sys.argv[0], 'requires Python 1.5' ! sys.exit(1) PROGRAM = sys.argv[0] --- 85,89 ---- import sys import getopt ! import re PROGRAM = sys.argv[0] *************** *** 111,130 **** parts = rawaddr.split('.') if not len(parts): ! # no top level domain found, bounce it to the next step ! return rawaddr addr = parts[-1] if nameorgs.has_key(addr): ! if nameorgs[addr][0].lower() in 'aeiou': ! ana = 'an' ! else: ! ana = 'a' ! print rawaddr, 'is from', ana, nameorgs[addr], 'organization' ! return None elif countries.has_key(addr): ! print rawaddr, 'originated from', countries[addr] ! return None else: ! # Not resolved, bounce it to the next step ! return rawaddr --- 102,117 ---- parts = rawaddr.split('.') if not len(parts): ! # no top level domain found, bounce it to the next step ! return rawaddr addr = parts[-1] if nameorgs.has_key(addr): ! print rawaddr, 'is in the', nameorgs[addr], 'top level domain' ! return None elif countries.has_key(addr): ! print rawaddr, 'originated from', countries[addr] ! return None else: ! # Not resolved, bounce it to the next step ! return rawaddr *************** *** 134,151 **** cre = re.compile(regexp, re.IGNORECASE) for code, country in all.items(): ! mo = cre.search(country) ! if mo: ! matches.append(code) # print results if not matches: ! # not resolved, bounce it to the next step ! return regexp if len(matches) == 1: ! code = matches[0] ! print regexp, "matches code `%s', %s" % (code, all[code]) else: ! print regexp, 'matches %d countries:' % len(matches) ! for code in matches: ! print " %s: %s" % (code, all[code]) return None --- 121,138 ---- cre = re.compile(regexp, re.IGNORECASE) for code, country in all.items(): ! mo = cre.search(country) ! if mo: ! matches.append(code) # print results if not matches: ! # not resolved, bounce it to the next step ! return regexp if len(matches) == 1: ! code = matches[0] ! print regexp, "matches code `%s', %s" % (code, all[code]) else: ! print regexp, 'matches %d countries:' % len(matches) ! for code in matches: ! print " %s: %s" % (code, all[code]) return None *************** *** 154,160 **** def parse(file, normalize): try: ! fp = open(file) except IOError, (err, msg): ! print msg, ':', file cre = re.compile('(.*?)[ \t]+([A-Z]{2})[ \t]+[A-Z]{3}[ \t]+[0-9]{3}') --- 141,147 ---- def parse(file, normalize): try: ! fp = open(file) except IOError, (err, msg): ! print msg, ':', file cre = re.compile('(.*?)[ \t]+([A-Z]{2})[ \t]+[A-Z]{3}[ \t]+[0-9]{3}') *************** *** 162,213 **** if normalize: ! print 'country = {' while 1: ! line = fp.readline() ! if line == '': ! break # EOF ! if scanning: ! mo = cre.match(line) ! if not mo: ! line = line.strip() ! if not line: ! continue ! elif line[0] == '-': ! break ! else: ! print 'Could not parse line:', line ! continue ! country, code = mo.group(1, 2) ! if normalize: ! words = country.split() ! for i in range(len(words)): ! w = words[i] ! # XXX special cases ! if w in ('AND', 'OF', 'OF)', 'name:', 'METROPOLITAN'): ! words[i] = w.lower() ! elif w == 'THE' and i != 1: ! words[i] = w.lower() ! elif len(w) > 3 and w[1] == "'": ! words[i] = w[0:3].upper() + w[3:].lower() ! elif w == '(U.S.)': ! pass ! elif w[0] == '(' and w != '(local': ! words[i] = '(' + w[1:].capitalize() ! elif w.find('-') != -1: ! words[i] = '-'.join([s.capitalize() for s in w.split('-')]) ! else: ! words[i] = w.capitalize() ! code = code.lower() ! country = ' '.join(words) ! print ' "%s": "%s",' % (code, country) ! else: ! print code, country ! ! elif line[0] == '-': ! scanning = 1 if normalize: ! print ' }' --- 149,201 ---- if normalize: ! print 'countries = {' while 1: ! line = fp.readline() ! if line == '': ! break # EOF ! if scanning: ! mo = cre.match(line) ! if not mo: ! line = line.strip() ! if not line: ! continue ! elif line[0] == '-': ! break ! else: ! print 'Could not parse line:', line ! continue ! country, code = mo.group(1, 2) ! if normalize: ! words = country.split() ! for i in range(len(words)): ! w = words[i] ! # XXX special cases ! if w in ('AND', 'OF', 'OF)', 'name:', 'METROPOLITAN'): ! words[i] = w.lower() ! elif w == 'THE' and i <> 1: ! words[i] = w.lower() ! elif len(w) > 3 and w[1] == "'": ! words[i] = w[0:3].upper() + w[3:].lower() ! elif w in ('(U.S.)', 'U.S.'): ! pass ! elif w[0] == '(' and w <> '(local': ! words[i] = '(' + w[1:].capitalize() ! elif w.find('-') <> -1: ! words[i] = '-'.join( ! [s.capitalize() for s in w.split('-')]) ! else: ! words[i] = w.capitalize() ! code = code.lower() ! country = ' '.join(words) ! print ' "%s": "%s",' % (code, country) ! else: ! print code, country ! ! elif line[0] == '-': ! scanning = 1 if normalize: ! print ' }' *************** *** 229,266 **** for opt, arg in opts: ! if opt in ('-h', '--help'): ! help = 1 ! elif opt in ('-d', '--dump'): ! dump = 1 ! elif opt in ('-p', '--parse'): ! parsefile = arg ! elif opt in ('-o', '--output'): ! normalize = 1 ! elif opt in ('-r', '--reverse'): ! forcerev = 1 if help: ! usage(status) if dump: ! print 'Non-geographic domains:' ! codes = nameorgs.keys() ! codes.sort() ! for code in codes: ! print ' %4s:' % code, nameorgs[code] ! print '\nCountry coded domains:' ! codes = countries.keys() ! codes.sort() ! for code in codes: ! print ' %2s:' % code, countries[code] elif parsefile: ! parse(parsefile, normalize) else: ! if not forcerev: ! args = filter(None, map(resolve, args)) ! args = filter(None, map(reverse, args)) ! for arg in args: ! print 'Where in the world is %s?' % arg --- 217,254 ---- for opt, arg in opts: ! if opt in ('-h', '--help'): ! help = 1 ! elif opt in ('-d', '--dump'): ! dump = 1 ! elif opt in ('-p', '--parse'): ! parsefile = arg ! elif opt in ('-o', '--outputdict'): ! normalize = 1 ! elif opt in ('-r', '--reverse'): ! forcerev = 1 if help: ! usage(status) if dump: ! print 'Non-geographic domains:' ! codes = nameorgs.keys() ! codes.sort() ! for code in codes: ! print ' %4s:' % code, nameorgs[code] ! print '\nCountry coded domains:' ! codes = countries.keys() ! codes.sort() ! for code in codes: ! print ' %2s:' % code, countries[code] elif parsefile: ! parse(parsefile, normalize) else: ! if not forcerev: ! args = filter(None, map(resolve, args)) ! args = filter(None, map(reverse, args)) ! for arg in args: ! print 'Where in the world is %s?' % arg *************** *** 268,279 **** # The mappings nameorgs = { "arpa": "Arpanet", "com": "commercial", "edu": "educational", "gov": "government", "mil": "military", "net": "networking", "org": "non-commercial", ! "int": "international", # This isn't in the same class as those above, but is included here # because `uk' is the common practice country code for the United Kingdom. --- 256,276 ---- # The mappings nameorgs = { + # New top level domains as described by ICANN + # http://www.icann.org/tlds/ + "aero": "air-transport industry", "arpa": "Arpanet", + "biz": "business", "com": "commercial", + "coop": "cooperatives", "edu": "educational", "gov": "government", + "info": "unrestricted `info'", + "int": "international", "mil": "military", + "museum": "museums", + "name": "`name' (for registration by individuals)", "net": "networking", "org": "non-commercial", ! "pro": "professionals", # This isn't in the same class as those above, but is included here # because `uk' is the common practice country code for the United Kingdom. *************** *** 526,530 **** "vn": "Viet Nam", "vg": "Virgin Islands, British", ! "vi": "Virgin Islands, U.s.", "wf": "Wallis and Futuna", "eh": "Western Sahara", --- 523,527 ---- "vn": "Viet Nam", "vg": "Virgin Islands, British", ! "vi": "Virgin Islands, U.S.", "wf": "Wallis and Futuna", "eh": "Western Sahara", From gvanrossum@users.sourceforge.net Fri Jun 7 16:58:57 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Fri, 07 Jun 2002 08:58:57 -0700 Subject: [Python-checkins] python/dist/src/Misc ACKS,1.178,1.179 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv22220 Modified Files: ACKS Log Message: Added Bernard Yue who wrote test_timeout.py and participated in the timeout socket patch design. Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.178 retrieving revision 1.179 diff -C2 -d -r1.178 -r1.179 *** ACKS 6 Jun 2002 21:08:46 -0000 1.178 --- ACKS 7 Jun 2002 15:58:53 -0000 1.179 *************** *** 513,516 **** --- 513,517 ---- Masazumi Yoshikawa Danny Yoo + Bernard Yue Moshe Zadka Milan Zamazal From gvanrossum@users.sourceforge.net Fri Jun 7 20:55:34 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Fri, 07 Jun 2002 12:55:34 -0700 Subject: [Python-checkins] python/dist/src/Modules socketmodule.c,1.223,1.224 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv4796 Modified Files: socketmodule.c Log Message: Move the conex_finally label up, so that the errno value is always returned. Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.223 retrieving revision 1.224 diff -C2 -d -r1.223 -r1.224 *** socketmodule.c 7 Jun 2002 03:36:20 -0000 1.223 --- socketmodule.c 7 Jun 2002 19:55:29 -0000 1.224 *************** *** 1463,1466 **** --- 1463,1467 ---- } + conex_finally: if (res != 0) { #ifdef MS_WINDOWS *************** *** 1471,1475 **** } - conex_finally: return PyInt_FromLong((long) res); } --- 1472,1475 ---- From gward@users.sourceforge.net Fri Jun 7 22:43:39 2002 From: gward@users.sourceforge.net (gward@users.sourceforge.net) Date: Fri, 07 Jun 2002 14:43:39 -0700 Subject: [Python-checkins] python/dist/src/Lib textwrap.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv2903 Added Files: textwrap.py Log Message: Initial revision. Currently biased towards English in a fixed-width font, according to the conventions that I (and Tim Peters) learned in school. --- NEW FILE: textwrap.py --- """ Utilities for wrapping text strings and filling text paragraphs. """ __revision__ = "$Id: textwrap.py,v 1.1 2002/06/07 21:43:37 gward Exp $" import string, re # XXX is this going to be implemented properly somewhere in 2.3? def islower (c): return c in string.lowercase class TextWrapper: """ Object for wrapping/filling text. The public interface consists of the wrap() and fill() methods; the other methods are just there for subclasses to override in order to tweak the default behaviour. If you want to completely replace the main wrapping algorithm, you'll probably have to override _wrap_chunks(). Several instance attributes control various aspects of wrapping: expand_tabs if true (default), tabs in input text will be expanded to spaces before further processing. Each tab will become 1 .. 8 spaces, depending on its position in its line. If false, each tab is treated as a single character. replace_whitespace if true (default), all whitespace characters in the input text are replaced by spaces after tab expansion. Note that expand_tabs is false and replace_whitespace is true, every tab will be converted to a single space! break_long_words if true (default), words longer than the line width constraint will be broken. If false, those words will not be broken, and some lines might be longer than the width constraint. """ whitespace_trans = string.maketrans(string.whitespace, ' ' * len(string.whitespace)) # This funky little regex is just the trick for splitting # text up into word-wrappable chunks. E.g. # "Hello there -- you goof-ball, use the -b option!" # splits into # Hello/ /there/ /--/ /you/ /goof-/ball,/ /use/ /the/ /-b/ /option! # (after stripping out empty strings). wordsep_re = re.compile(r'(\s+|' # any whitespace r'\w{2,}-(?=\w{2,})|' # hyphenated words r'(?<=\w)-{2,}(?=\w))') # em-dash def __init__ (self): self.expand_tabs = 1 self.replace_whitespace = 1 self.break_long_words = 1 # -- Private methods ----------------------------------------------- # (possibly useful for subclasses to override) def _munge_whitespace (self, text): """_munge_whitespace(text : string) -> string Munge whitespace in text: expand tabs and convert all other whitespace characters to spaces. Eg. " foo\tbar\n\nbaz" becomes " foo bar baz". """ if self.expand_tabs: text = text.expandtabs() if self.replace_whitespace: text = text.translate(self.whitespace_trans) return text def _split (self, text): """_split(text : string) -> [string] Split the text to wrap into indivisible chunks. Chunks are not quite the same as words; see wrap_chunks() for full details. As an example, the text Look, goof-ball -- use the -b option! breaks into the following chunks: 'Look,', ' ', 'goof-', 'ball', ' ', '--', ' ', 'use', ' ', 'the', ' ', '-b', ' ', 'option!' """ chunks = self.wordsep_re.split(text) chunks = filter(None, chunks) return chunks def _fix_sentence_endings (self, chunks): """_fix_sentence_endings(chunks : [string]) Correct for sentence endings buried in 'chunks'. Eg. when the original text contains "... foo.\nBar ...", munge_whitespace() and split() will convert that to [..., "foo.", " ", "Bar", ...] which has one too few spaces; this method simply changes the one space to two. """ i = 0 while i < len(chunks)-1: # chunks[i] looks like the last word of a sentence, # and it's followed by a single space. if (chunks[i][-1] == "." and chunks[i+1] == " " and islower(chunks[i][-2])): chunks[i+1] = " " i += 2 else: i += 1 def _handle_long_word (self, chunks, cur_line, cur_len, width): """_handle_long_word(chunks : [string], cur_line : [string], cur_len : int, width : int) Handle a chunk of text (most likely a word, not whitespace) that is too long to fit in any line. """ space_left = width - cur_len # If we're allowed to break long words, then do so: put as much # of the next chunk onto the current line as will fit. if self.break_long_words: cur_line.append(chunks[0][0:space_left]) chunks[0] = chunks[0][space_left:] # Otherwise, we have to preserve the long word intact. Only add # it to the current line if there's nothing already there -- # that minimizes how much we violate the width constraint. elif not cur_line: cur_line.append(chunks.pop(0)) # If we're not allowed to break long words, and there's already # text on the current line, do nothing. Next time through the # main loop of _wrap_chunks(), we'll wind up here again, but # cur_len will be zero, so the next line will be entirely # devoted to the long word that we can't handle right now. def _wrap_chunks (self, chunks, width): """_wrap_chunks(chunks : [string], width : int) -> [string] Wrap a sequence of text chunks and return a list of lines of length 'width' or less. (If 'break_long_words' is false, some lines may be longer than 'width'.) Chunks correspond roughly to words and the whitespace between them: each chunk is indivisible (modulo 'break_long_words'), but a line break can come between any two chunks. Chunks should not have internal whitespace; ie. a chunk is either all whitespace or a "word". Whitespace chunks will be removed from the beginning and end of lines, but apart from that whitespace is preserved. """ lines = [] while chunks: cur_line = [] # list of chunks (to-be-joined) cur_len = 0 # length of current line # First chunk on line is whitespace -- drop it. if chunks[0].strip() == '': del chunks[0] while chunks: l = len(chunks[0]) # Can at least squeeze this chunk onto the current line. if cur_len + l <= width: cur_line.append(chunks.pop(0)) cur_len += l # Nope, this line is full. else: break # The current line is full, and the next chunk is too big to # fit on *any* line (not just this one). if chunks and len(chunks[0]) > width: self._handle_long_word(chunks, cur_line, cur_len, width) # If the last chunk on this line is all whitespace, drop it. if cur_line and cur_line[-1].strip() == '': del cur_line[-1] # Convert current line back to a string and store it in list # of all lines (return value). if cur_line: lines.append(''.join(cur_line)) return lines # -- Public interface ---------------------------------------------- def wrap (self, text, width): """wrap(text : string, width : int) -> [string] Split 'text' into multiple lines of no more than 'width' characters each, and return the list of strings that results. Tabs in 'text' are expanded with string.expandtabs(), and all other whitespace characters (including newline) are converted to space. """ text = self._munge_whitespace(text) if len(text) <= width: return [text] chunks = self._split(text) self._fix_sentence_endings(chunks) return self._wrap_chunks(chunks, width) def fill (self, text, width, initial_tab="", subsequent_tab=""): """fill(text : string, width : int, initial_tab : string = "", subsequent_tab : string = "") -> string Reformat the paragraph in 'text' to fit in lines of no more than 'width' columns. The first line is prefixed with 'initial_tab', and subsequent lines are prefixed with 'subsequent_tab'; the lengths of the tab strings are accounted for when wrapping lines to fit in 'width' columns. """ lines = self.wrap(text, width) sep = "\n" + subsequent_tab return initial_tab + sep.join(lines) # Convenience interface _wrapper = TextWrapper() def wrap (text, width): return _wrapper.wrap(text, width) def fill (text, width, initial_tab="", subsequent_tab=""): return _wrapper.fill(text, width, initial_tab, subsequent_tab) From gward@users.sourceforge.net Fri Jun 7 22:56:18 2002 From: gward@users.sourceforge.net (gward@users.sourceforge.net) Date: Fri, 07 Jun 2002 14:56:18 -0700 Subject: [Python-checkins] python/dist/src/Lib textwrap.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv5767 Modified Files: textwrap.py Log Message: Add fix_sentence_endings option to control whether we ensure that sentences are separated by two spaces. Improve _fix_sentence_endings() a bit -- look for ".!?" instead of just ".", and factor out the list of sentence-ending punctuation characters to a class attribute. Index: textwrap.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/textwrap.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** textwrap.py 7 Jun 2002 21:43:37 -0000 1.1 --- textwrap.py 7 Jun 2002 21:56:16 -0000 1.2 *************** *** 23,40 **** Several instance attributes control various aspects of wrapping: ! expand_tabs ! if true (default), tabs in input text will be expanded ! to spaces before further processing. Each tab will ! become 1 .. 8 spaces, depending on its position in its line. ! If false, each tab is treated as a single character. ! replace_whitespace ! if true (default), all whitespace characters in the input ! text are replaced by spaces after tab expansion. Note ! that expand_tabs is false and replace_whitespace is true, ! every tab will be converted to a single space! ! break_long_words ! if true (default), words longer than the line width constraint ! will be broken. If false, those words will not be broken, ! and some lines might be longer than the width constraint. """ --- 23,43 ---- Several instance attributes control various aspects of wrapping: ! expand_tabs (default: true) ! Expand tabs in input text to spaces before further processing. ! Each tab will become 1 .. 8 spaces, depending on its position in ! its line. If false, each tab is treated as a single character. ! replace_whitespace (default: true) ! Replace all whitespace characters in the input text by spaces ! after tab expansion. Note that if expand_tabs is false and ! replace_whitespace is true, every tab will be converted to a ! single space! ! fix_sentence_endings (default: false) ! Ensure that sentence-ending punctuation is always followed ! by two spaces. Off by default becaus the algorithm is ! (unavoidably) imperfect. ! break_long_words (default: true) ! Break words longer than the line width constraint. If false, ! those words will not be broken, and some lines might be longer ! than the width constraint. """ *************** *** 52,59 **** --- 55,66 ---- r'(?<=\w)-{2,}(?=\w))') # em-dash + # Punctuation characters found at the end of a sentence. + sentence_end = ".?!" + def __init__ (self): self.expand_tabs = 1 self.replace_whitespace = 1 + self.fix_sentence_endings = 0 self.break_long_words = 1 *************** *** 101,108 **** """ i = 0 while i < len(chunks)-1: # chunks[i] looks like the last word of a sentence, # and it's followed by a single space. ! if (chunks[i][-1] == "." and chunks[i+1] == " " and islower(chunks[i][-2])): --- 108,116 ---- """ i = 0 + punct = self.sentence_end while i < len(chunks)-1: # chunks[i] looks like the last word of a sentence, # and it's followed by a single space. ! if (chunks[i][-1] in punct and chunks[i+1] == " " and islower(chunks[i][-2])): *************** *** 208,212 **** return [text] chunks = self._split(text) ! self._fix_sentence_endings(chunks) return self._wrap_chunks(chunks, width) --- 216,221 ---- return [text] chunks = self._split(text) ! if self.fix_sentence_endings: ! self._fix_sentence_endings(chunks) return self._wrap_chunks(chunks, width) From neal@metaslash.com Fri Jun 7 22:54:09 2002 From: neal@metaslash.com (Neal Norwitz) Date: Fri, 07 Jun 2002 17:54:09 -0400 Subject: [Python-checkins] python/dist/src/Lib textwrap.py,NONE,1.1 References: Message-ID: <3D012B81.1ED901C7@metaslash.com> gward@users.sourceforge.net wrote: > # XXX is this going to be implemented properly somewhere in 2.3? > def islower (c): > return c in string.lowercase **** >>> print ''.islower.__doc__ S.islower() -> bool Return True if all cased characters in S are lowercase and there is at least one cased character in S, False otherwise. **** > def __init__ (self): > self.expand_tabs = 1 > self.replace_whitespace = 1 > self.break_long_words = 1 Should use True? Neal From fdrake@acm.org Fri Jun 7 22:02:05 2002 From: fdrake@acm.org (Fred L. Drake, Jr.) Date: Fri, 7 Jun 2002 17:02:05 -0400 Subject: [Python-checkins] python/dist/src/Lib textwrap.py,NONE,1.1 In-Reply-To: <3D012B81.1ED901C7@metaslash.com> References: <3D012B81.1ED901C7@metaslash.com> Message-ID: <15617.8013.472407.193408@grendel.zope.com> gward@users.sourceforge.net wrote: > # XXX is this going to be implemented properly somewhere in 2.3? > def islower (c): > return c in string.lowercase ... > def __init__ (self): > self.expand_tabs = 1 > self.replace_whitespace = 1 > self.break_long_words = 1 Neal Norwitz writes: > Should use True? Definately! Function and method definitions should also be: def func(arg): pass rather than: def func (arg): pass (Note the extra space before the args list in Greg's code.) -Fred -- Fred L. Drake, Jr. PythonLabs at Zope Corporation From gward@users.sourceforge.net Fri Jun 7 23:04:17 2002 From: gward@users.sourceforge.net (gward@users.sourceforge.net) Date: Fri, 07 Jun 2002 15:04:17 -0700 Subject: [Python-checkins] python/dist/src/Lib textwrap.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv8618 Modified Files: textwrap.py Log Message: Convert _fix_sentence_endings() to use a regex, and augment it to handle sentences like this: And she said, "Go to hell!" Can you believe that? Index: textwrap.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/textwrap.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** textwrap.py 7 Jun 2002 21:56:16 -0000 1.2 --- textwrap.py 7 Jun 2002 22:04:15 -0000 1.3 *************** *** 55,60 **** r'(?<=\w)-{2,}(?=\w))') # em-dash ! # Punctuation characters found at the end of a sentence. ! sentence_end = ".?!" --- 55,64 ---- r'(?<=\w)-{2,}(?=\w))') # em-dash ! # XXX will there be a locale-or-charset-aware version of ! # string.lowercase in 2.3? ! sentence_end_re = re.compile(r'[%s]' # lowercase letter ! r'[\.\!\?]' # sentence-ending punct. ! r'[\"\']?' # optional end-of-quote ! % string.lowercase) *************** *** 108,118 **** """ i = 0 ! punct = self.sentence_end while i < len(chunks)-1: ! # chunks[i] looks like the last word of a sentence, ! # and it's followed by a single space. ! if (chunks[i][-1] in punct and ! chunks[i+1] == " " and ! islower(chunks[i][-2])): chunks[i+1] = " " i += 2 --- 112,118 ---- """ i = 0 ! pat = self.sentence_end_re while i < len(chunks)-1: ! if chunks[i+1] == " " and pat.search(chunks[i]): chunks[i+1] = " " i += 2 From gward@users.sourceforge.net Fri Jun 7 23:32:17 2002 From: gward@users.sourceforge.net (gward@users.sourceforge.net) Date: Fri, 07 Jun 2002 15:32:17 -0700 Subject: [Python-checkins] python/dist/src/Lib textwrap.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv18321 Modified Files: textwrap.py Log Message: Conform to the bloody coding standards: "def foo()" not "def foo ()". Yuck. Index: textwrap.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/textwrap.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** textwrap.py 7 Jun 2002 22:04:15 -0000 1.3 --- textwrap.py 7 Jun 2002 22:32:15 -0000 1.4 *************** *** 9,13 **** # XXX is this going to be implemented properly somewhere in 2.3? ! def islower (c): return c in string.lowercase --- 9,13 ---- # XXX is this going to be implemented properly somewhere in 2.3? ! def islower(c): return c in string.lowercase *************** *** 73,77 **** # (possibly useful for subclasses to override) ! def _munge_whitespace (self, text): """_munge_whitespace(text : string) -> string --- 73,77 ---- # (possibly useful for subclasses to override) ! def _munge_whitespace(self, text): """_munge_whitespace(text : string) -> string *************** *** 87,91 **** ! def _split (self, text): """_split(text : string) -> [string] --- 87,91 ---- ! def _split(self, text): """_split(text : string) -> [string] *************** *** 102,106 **** return chunks ! def _fix_sentence_endings (self, chunks): """_fix_sentence_endings(chunks : [string]) --- 102,106 ---- return chunks ! def _fix_sentence_endings(self, chunks): """_fix_sentence_endings(chunks : [string]) *************** *** 120,124 **** i += 1 ! def _handle_long_word (self, chunks, cur_line, cur_len, width): """_handle_long_word(chunks : [string], cur_line : [string], --- 120,124 ---- i += 1 ! def _handle_long_word(self, chunks, cur_line, cur_len, width): """_handle_long_word(chunks : [string], cur_line : [string], *************** *** 148,152 **** # devoted to the long word that we can't handle right now. ! def _wrap_chunks (self, chunks, width): """_wrap_chunks(chunks : [string], width : int) -> [string] --- 148,152 ---- # devoted to the long word that we can't handle right now. ! def _wrap_chunks(self, chunks, width): """_wrap_chunks(chunks : [string], width : int) -> [string] *************** *** 203,207 **** # -- Public interface ---------------------------------------------- ! def wrap (self, text, width): """wrap(text : string, width : int) -> [string] --- 203,207 ---- # -- Public interface ---------------------------------------------- ! def wrap(self, text, width): """wrap(text : string, width : int) -> [string] *************** *** 220,224 **** return self._wrap_chunks(chunks, width) ! def fill (self, text, width, initial_tab="", subsequent_tab=""): """fill(text : string, width : int, --- 220,224 ---- return self._wrap_chunks(chunks, width) ! def fill(self, text, width, initial_tab="", subsequent_tab=""): """fill(text : string, width : int, *************** *** 242,248 **** _wrapper = TextWrapper() ! def wrap (text, width): return _wrapper.wrap(text, width) ! def fill (text, width, initial_tab="", subsequent_tab=""): return _wrapper.fill(text, width, initial_tab, subsequent_tab) --- 242,248 ---- _wrapper = TextWrapper() ! def wrap(text, width): return _wrapper.wrap(text, width) ! def fill(text, width, initial_tab="", subsequent_tab=""): return _wrapper.fill(text, width, initial_tab, subsequent_tab) From gward@users.sourceforge.net Fri Jun 7 23:33:13 2002 From: gward@users.sourceforge.net (gward@users.sourceforge.net) Date: Fri, 07 Jun 2002 15:33:13 -0700 Subject: [Python-checkins] python/dist/src/Lib textwrap.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv18638 Modified Files: textwrap.py Log Message: Remove islower() -- not used anymore. Index: textwrap.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/textwrap.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** textwrap.py 7 Jun 2002 22:32:15 -0000 1.4 --- textwrap.py 7 Jun 2002 22:33:11 -0000 1.5 *************** *** 7,16 **** import string, re - - # XXX is this going to be implemented properly somewhere in 2.3? - def islower(c): - return c in string.lowercase - - class TextWrapper: """ --- 7,10 ---- From gward@users.sourceforge.net Fri Jun 7 23:35:43 2002 From: gward@users.sourceforge.net (gward@users.sourceforge.net) Date: Fri, 07 Jun 2002 15:35:43 -0700 Subject: [Python-checkins] python/dist/src/Lib textwrap.py,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv19303 Modified Files: textwrap.py Log Message: Use True/False instead of 1/0. Index: textwrap.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/textwrap.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** textwrap.py 7 Jun 2002 22:33:11 -0000 1.5 --- textwrap.py 7 Jun 2002 22:35:41 -0000 1.6 *************** *** 15,19 **** you'll probably have to override _wrap_chunks(). ! Several instance attributes control various aspects of wrapping: expand_tabs (default: true) --- 15,19 ---- you'll probably have to override _wrap_chunks(). ! Several boolean instance attributes control various aspects of wrapping: expand_tabs (default: true) *************** *** 58,65 **** def __init__ (self): ! self.expand_tabs = 1 ! self.replace_whitespace = 1 ! self.fix_sentence_endings = 0 ! self.break_long_words = 1 --- 58,65 ---- def __init__ (self): ! self.expand_tabs = True ! self.replace_whitespace = True ! self.fix_sentence_endings = False ! self.break_long_words = True From gward@users.sourceforge.net Fri Jun 7 23:40:26 2002 From: gward@users.sourceforge.net (gward@users.sourceforge.net) Date: Fri, 07 Jun 2002 15:40:26 -0700 Subject: [Python-checkins] python/dist/src/Lib textwrap.py,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv20517 Modified Files: textwrap.py Log Message: Record copyright and author. Index: textwrap.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/textwrap.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** textwrap.py 7 Jun 2002 22:35:41 -0000 1.6 --- textwrap.py 7 Jun 2002 22:40:23 -0000 1.7 *************** *** 3,6 **** --- 3,10 ---- """ + # Copyright (C) 2001 Gregory P. Ward. + # Copyright (C) 2002 Python Software Foundation. + # Written by Greg Ward + __revision__ = "$Id$" From jeremy@zope.com Fri Jun 7 22:06:54 2002 From: jeremy@zope.com (Jeremy Hylton) Date: Fri, 7 Jun 2002 17:06:54 -0400 Subject: [Python-checkins] python/dist/src/Lib textwrap.py,1.3,1.4 In-Reply-To: References: Message-ID: <15617.8302.524206.733550@slothrop.zope.com> BTW, there's the coding standard also says that the docstring should start with a short, one-line summary of the function/class/module. The type information is useful, but it shouldn't be the summary. Jeremy From gward@users.sourceforge.net Sun Jun 9 01:22:10 2002 From: gward@users.sourceforge.net (gward@users.sourceforge.net) Date: Sat, 08 Jun 2002 17:22:10 -0700 Subject: [Python-checkins] python/dist/src/Lib textwrap.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv3203 Modified Files: textwrap.py Log Message: Make all of TextWrapper's options keyword args to the constructor. Index: textwrap.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/textwrap.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** textwrap.py 7 Jun 2002 22:40:23 -0000 1.7 --- textwrap.py 9 Jun 2002 00:22:07 -0000 1.8 *************** *** 61,69 **** ! def __init__ (self): ! self.expand_tabs = True ! self.replace_whitespace = True ! self.fix_sentence_endings = False ! self.break_long_words = True --- 61,73 ---- ! def __init__ (self, ! expand_tabs=True, ! replace_whitespace=True, ! fix_sentence_endings=False, ! break_long_words=True): ! self.expand_tabs = expand_tabs ! self.replace_whitespace = replace_whitespace ! self.fix_sentence_endings = fix_sentence_endings ! self.break_long_words = break_long_words From jvr@users.sourceforge.net Sun Jun 9 10:08:56 2002 From: jvr@users.sourceforge.net (jvr@users.sourceforge.net) Date: Sun, 09 Jun 2002 02:08:56 -0700 Subject: [Python-checkins] python/dist/src/Tools/bgen/bgen scantools.py,1.27,1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/bgen/bgen In directory usw-pr-cvs1:/tmp/cvs-serv14712 Modified Files: scantools.py Log Message: escape 8-bit chars when generating .py files. fixes bug #566302 Index: scantools.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/scantools.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** scantools.py 23 Apr 2002 22:43:37 -0000 1.27 --- scantools.py 9 Jun 2002 09:08:53 -0000 1.28 *************** *** 434,437 **** --- 434,438 ---- def dosymdef(self, match): name, defn = match.group('name', 'defn') + defn = escape8bit(defn) if self.debug: self.report("\tsym: name=%s, defn=%s" % (`name`, `defn`)) *************** *** 639,643 **** self.sym_pat = "^[ \t]*(?P[a-zA-Z0-9_]+)[ \t]*=" + \ "[ \t]*(?P[-0-9_a-zA-Z'\"\(][^\t\n,;}]*),?" ! def test(): input = "D:Development:THINK C:Mac #includes:Apple #includes:AppleEvents.h" --- 640,658 ---- self.sym_pat = "^[ \t]*(?P[a-zA-Z0-9_]+)[ \t]*=" + \ "[ \t]*(?P[-0-9_a-zA-Z'\"\(][^\t\n,;}]*),?" ! ! _8bit = re.compile(r"[\200-\377]") ! ! def escape8bit(s): ! if _8bit.search(s) is not None: ! out = [] ! for c in s: ! o = ord(c) ! if o >= 128: ! out.append("\\" + hex(o)[1:]) ! else: ! out.append(c) ! s = "".join(out) ! return s ! def test(): input = "D:Development:THINK C:Mac #includes:Apple #includes:AppleEvents.h" From loewis@users.sourceforge.net Sun Jun 9 14:33:56 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun, 09 Jun 2002 06:33:56 -0700 Subject: [Python-checkins] python/dist/src/Include Python.h,2.50,2.51 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv2244/Include Modified Files: Python.h Log Message: Patch #505375: Make doc strings optional. Index: Python.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/Python.h,v retrieving revision 2.50 retrieving revision 2.51 diff -C2 -d -r2.50 -r2.51 *** Python.h 4 Jun 2002 15:07:08 -0000 2.50 --- Python.h 9 Jun 2002 13:33:54 -0000 2.51 *************** *** 147,149 **** --- 147,159 ---- #include #endif + + /* Define macros for inline documentation. */ + #define PyDoc_VAR(name) static char name[] + #define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str) + #ifdef WITH_DOC_STRINGS + #define PyDoc_STR(str) str + #else + #define PyDoc_STR(str) "" + #endif + #endif /* !Py_PYTHON_H */ From loewis@users.sourceforge.net Sun Jun 9 14:33:56 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun, 09 Jun 2002 06:33:56 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.419,1.420 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv2244/Misc Modified Files: NEWS Log Message: Patch #505375: Make doc strings optional. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.419 retrieving revision 1.420 diff -C2 -d -r1.419 -r1.420 *** NEWS 7 Jun 2002 12:40:52 -0000 1.419 --- NEWS 9 Jun 2002 13:33:54 -0000 1.420 *************** *** 241,244 **** --- 241,248 ---- Build + - The configure option --without-doc-strings can be used to remove the + doc strings from the builtin functions and modules; this reduces the + size of the executable. + - XXX WITH_UNIVERSAL_NEWLINES Somebody fill this in; the PEP doesn't say how or when to configure it, or how to turn it off. From loewis@users.sourceforge.net Sun Jun 9 14:33:56 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun, 09 Jun 2002 06:33:56 -0700 Subject: [Python-checkins] python/dist/src configure,1.311,1.312 configure.in,1.321,1.322 pyconfig.h.in,1.38,1.39 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv2244 Modified Files: configure configure.in pyconfig.h.in Log Message: Patch #505375: Make doc strings optional. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.311 retrieving revision 1.312 diff -C2 -d -r1.311 -r1.312 *** configure 6 Jun 2002 13:03:40 -0000 1.311 --- configure 9 Jun 2002 13:33:47 -0000 1.312 *************** *** 1,4 **** #! /bin/sh ! # From configure.in Revision: 1.320 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.53. --- 1,4 ---- #! /bin/sh ! # From configure.in Revision: 1.321 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.53. *************** *** 846,849 **** --- 846,850 ---- --with(out)-cycle-gc disable/enable garbage collection --with(out)-universal-newlines disable/enable foreign newlines + --with(out)-doc-strings disable/enable documentation strings --with(out)-pymalloc disable/enable specialized mallocs --with-wctype-functions use wctype.h functions *************** *** 10964,10967 **** --- 10965,10992 ---- echo "$as_me:$LINENO: result: $with_universal_newlines" >&5 echo "${ECHO_T}$with_universal_newlines" >&6 + + # Check for --with-doc-strings + echo "$as_me:$LINENO: checking for --with-doc-strings" >&5 + echo $ECHO_N "checking for --with-doc-strings... $ECHO_C" >&6 + + # Check whether --with-doc-strings or --without-doc-strings was given. + if test "${with_doc_strings+set}" = set; then + withval="$with_doc_strings" + + fi; + + if test -z "$with_doc_strings" + then with_doc_strings="yes" + fi + if test "$with_doc_strings" != "no" + then + + cat >>confdefs.h <<\_ACEOF + #define WITH_DOC_STRINGS 1 + _ACEOF + + fi + echo "$as_me:$LINENO: result: $with_doc_strings" >&5 + echo "${ECHO_T}$with_doc_strings" >&6 # Check for Python-specific malloc support Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.321 retrieving revision 1.322 diff -C2 -d -r1.321 -r1.322 *** configure.in 6 Jun 2002 13:03:40 -0000 1.321 --- configure.in 9 Jun 2002 13:33:53 -0000 1.322 *************** *** 1456,1459 **** --- 1456,1474 ---- AC_MSG_RESULT($with_universal_newlines) + # Check for --with-doc-strings + AC_MSG_CHECKING(for --with-doc-strings) + AC_ARG_WITH(doc-strings, + [ --with(out)-doc-strings disable/enable documentation strings]) + + if test -z "$with_doc_strings" + then with_doc_strings="yes" + fi + if test "$with_doc_strings" != "no" + then + AC_DEFINE(WITH_DOC_STRINGS, 1, + [Define if you want documentation strings in extension modules]) + fi + AC_MSG_RESULT($with_doc_strings) + # Check for Python-specific malloc support AC_MSG_CHECKING(for --with-pymalloc) Index: pyconfig.h.in =================================================================== RCS file: /cvsroot/python/python/dist/src/pyconfig.h.in,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** pyconfig.h.in 6 Jun 2002 13:03:44 -0000 1.38 --- pyconfig.h.in 9 Jun 2002 13:33:53 -0000 1.39 *************** *** 727,730 **** --- 727,733 ---- #undef WITH_DL_DLD + /* Define if you want documentation strings in extension modules */ + #undef WITH_DOC_STRINGS + /* Define if you want to use the new-style (Openstep, Rhapsody, MacOS) dynamic linker (dyld) instead of the old-style (NextStep) dynamic linker (rld). From loewis@users.sourceforge.net Sun Jun 9 14:33:56 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun, 09 Jun 2002 06:33:56 -0700 Subject: [Python-checkins] python/dist/src/Python sysmodule.c,2.103,2.104 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv2244/Python Modified Files: sysmodule.c Log Message: Patch #505375: Make doc strings optional. Index: sysmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v retrieving revision 2.103 retrieving revision 2.104 diff -C2 -d -r2.103 -r2.104 *** sysmodule.c 27 Mar 2002 13:03:09 -0000 2.103 --- sysmodule.c 9 Jun 2002 13:33:54 -0000 2.104 *************** *** 104,111 **** } ! static char displayhook_doc[] = "displayhook(object) -> None\n" "\n" ! "Print an object to sys.stdout and also save it in __builtin__._\n"; static PyObject * --- 104,112 ---- } ! PyDoc_STRVAR(displayhook_doc, "displayhook(object) -> None\n" "\n" ! "Print an object to sys.stdout and also save it in __builtin__._\n" ! ); static PyObject * *************** *** 120,127 **** } ! static char excepthook_doc[] = "excepthook(exctype, value, traceback) -> None\n" "\n" ! "Handle an exception by displaying it with a traceback on sys.stderr.\n"; static PyObject * --- 121,129 ---- } ! PyDoc_STRVAR(excepthook_doc, "excepthook(exctype, value, traceback) -> None\n" "\n" ! "Handle an exception by displaying it with a traceback on sys.stderr.\n" ! ); static PyObject * *************** *** 138,146 **** } ! static char exc_info_doc[] = "exc_info() -> (type, value, traceback)\n\ \n\ Return information about the exception that is currently being handled.\n\ ! This should be called from inside an except clause only."; static PyObject * --- 140,149 ---- } ! PyDoc_STRVAR(exc_info_doc, "exc_info() -> (type, value, traceback)\n\ \n\ Return information about the exception that is currently being handled.\n\ ! This should be called from inside an except clause only." ! ); static PyObject * *************** *** 155,159 **** } ! static char exit_doc[] = "exit([status])\n\ \n\ --- 158,162 ---- } ! PyDoc_STRVAR(exit_doc, "exit([status])\n\ \n\ *************** *** 162,166 **** If the status is numeric, it will be used as the system exit status.\n\ If it is another kind of object, it will be printed and the system\n\ ! exit status will be one (i.e., failure)."; #ifdef Py_USING_UNICODE --- 165,170 ---- If the status is numeric, it will be used as the system exit status.\n\ If it is another kind of object, it will be printed and the system\n\ ! exit status will be one (i.e., failure)." ! ); #ifdef Py_USING_UNICODE *************** *** 172,180 **** } ! static char getdefaultencoding_doc[] = "getdefaultencoding() -> string\n\ \n\ Return the current default string encoding used by the Unicode \n\ ! implementation."; static PyObject * --- 176,185 ---- } ! PyDoc_STRVAR(getdefaultencoding_doc, "getdefaultencoding() -> string\n\ \n\ Return the current default string encoding used by the Unicode \n\ ! implementation." ! ); static PyObject * *************** *** 190,197 **** } ! static char setdefaultencoding_doc[] = "setdefaultencoding(encoding)\n\ \n\ ! Set the current default string encoding used by the Unicode implementation."; #endif --- 195,203 ---- } ! PyDoc_STRVAR(setdefaultencoding_doc, "setdefaultencoding(encoding)\n\ \n\ ! Set the current default string encoding used by the Unicode implementation." ! ); #endif *************** *** 317,325 **** } ! static char settrace_doc[] = "settrace(function)\n\ \n\ Set the global debug tracing function. It will be called on each\n\ ! function call. See the debugger chapter in the library manual."; static PyObject * --- 323,332 ---- } ! PyDoc_STRVAR(settrace_doc, "settrace(function)\n\ \n\ Set the global debug tracing function. It will be called on each\n\ ! function call. See the debugger chapter in the library manual." ! ); static PyObject * *************** *** 336,344 **** } ! static char setprofile_doc[] = "setprofile(function)\n\ \n\ Set the profiling function. It will be called on each function call\n\ ! and return. See the profiler chapter in the library manual."; static PyObject * --- 343,352 ---- } ! PyDoc_STRVAR(setprofile_doc, "setprofile(function)\n\ \n\ Set the profiling function. It will be called on each function call\n\ ! and return. See the profiler chapter in the library manual." ! ); static PyObject * *************** *** 352,360 **** } ! static char setcheckinterval_doc[] = "setcheckinterval(n)\n\ \n\ Tell the Python interpreter to check for asynchronous events every\n\ ! n instructions. This also affects how often thread switches occur."; static PyObject * --- 360,369 ---- } ! PyDoc_STRVAR(setcheckinterval_doc, "setcheckinterval(n)\n\ \n\ Tell the Python interpreter to check for asynchronous events every\n\ ! n instructions. This also affects how often thread switches occur." ! ); static PyObject * *************** *** 374,378 **** } ! static char setrecursionlimit_doc[] = "setrecursionlimit(n)\n\ \n\ --- 383,387 ---- } ! PyDoc_STRVAR(setrecursionlimit_doc, "setrecursionlimit(n)\n\ \n\ *************** *** 380,384 **** limit prevents infinite recursion from causing an overflow of the C\n\ stack and crashing Python. The highest possible limit is platform-\n\ ! dependent."; static PyObject * --- 389,394 ---- limit prevents infinite recursion from causing an overflow of the C\n\ stack and crashing Python. The highest possible limit is platform-\n\ ! dependent." ! ); static PyObject * *************** *** 388,392 **** } ! static char getrecursionlimit_doc[] = "getrecursionlimit()\n\ \n\ --- 398,402 ---- } ! PyDoc_STRVAR(getrecursionlimit_doc, "getrecursionlimit()\n\ \n\ *************** *** 394,397 **** --- 404,408 ---- of the Python interpreter stack. This limit prevents infinite\n\ recursion from causing an overflow of the C stack and crashing Python."; + ); #ifdef HAVE_DLOPEN *************** *** 410,414 **** } ! static char setdlopenflags_doc[] = "setdlopenflags(n) -> None\n\ \n\ --- 421,425 ---- } ! PyDoc_STRVAR(setdlopenflags_doc, "setdlopenflags(n) -> None\n\ \n\ *************** *** 417,421 **** a module, if called as sys.setdlopenflags(0)\n\ To share symbols across extension modules, call as\n\ ! sys.setdlopenflags(dl.RTLD_NOW|dl.RTLD_GLOBAL)"; static PyObject * --- 428,433 ---- a module, if called as sys.setdlopenflags(0)\n\ To share symbols across extension modules, call as\n\ ! sys.setdlopenflags(dl.RTLD_NOW|dl.RTLD_GLOBAL)" ! ); static PyObject * *************** *** 428,436 **** } ! static char getdlopenflags_doc[] = "getdlopenflags() -> int\n\ \n\ Return the current value of the flags that are used for dlopen()\n\ ! calls. The flag constants are defined in the dl module."; #endif --- 440,449 ---- } ! PyDoc_STRVAR(getdlopenflags_doc, "getdlopenflags() -> int\n\ \n\ Return the current value of the flags that are used for dlopen()\n\ ! calls. The flag constants are defined in the dl module." ! ); #endif *************** *** 467,475 **** #endif /* Py_TRACE_REFS */ ! static char getrefcount_doc[] = "getrefcount(object) -> integer\n\ \n\ Return the current reference count for the object. This includes the\n\ ! temporary reference in the argument list, so it is at least 2."; #ifdef COUNT_ALLOCS --- 480,489 ---- #endif /* Py_TRACE_REFS */ ! PyDoc_STRVAR(getrefcount_doc, "getrefcount(object) -> integer\n\ \n\ Return the current reference count for the object. This includes the\n\ ! temporary reference in the argument list, so it is at least 2." ! ); #ifdef COUNT_ALLOCS *************** *** 483,487 **** #endif ! static char getframe_doc[] = "_getframe([depth]) -> frameobject\n\ \n\ --- 497,501 ---- #endif ! PyDoc_STRVAR(getframe_doc, "_getframe([depth]) -> frameobject\n\ \n\ *************** *** 492,496 **** \n\ This function should be used for internal and specialized\n\ ! purposes only."; static PyObject * --- 506,511 ---- \n\ This function should be used for internal and specialized\n\ ! purposes only." ! ); static PyObject * *************** *** 634,638 **** or other abomination that however *does* understand longer strings, get rid of the !!! comment in the middle and the quotes that surround it. */ ! static char sys_doc[] = "This module provides access to some objects used or maintained by the\n\ interpreter and to functions that interact strongly with the interpreter.\n\ --- 649,654 ---- or other abomination that however *does* understand longer strings, get rid of the !!! comment in the middle and the quotes that surround it. */ ! PyDoc_VAR(sys_doc) = ! PyDoc_STR( "This module provides access to some objects used or maintained by the\n\ interpreter and to functions that interact strongly with the interpreter.\n\ *************** *** 670,675 **** --- 686,693 ---- because it is thread-safe.\n\ " + ) #ifndef MS_WIN16 /* concatenating string here */ + PyDoc_STR( "\n\ Static objects:\n\ *************** *** 687,696 **** --- 705,718 ---- exec_prefix -- prefix used to find the machine-specific Python library\n\ " + ) #ifdef MS_WINDOWS /* concatenating string here */ + PyDoc_STR( "dllhandle -- [Windows only] integer handle of the Python DLL\n\ winver -- [Windows only] version number of the Python DLL\n\ " + ) #endif /* MS_WINDOWS */ + PyDoc_STR( "__stdin__ -- the original stdin; don't touch!\n\ __stdout__ -- the original stdout; don't touch!\n\ *************** *** 714,717 **** --- 736,740 ---- settrace() -- set the global debug tracing function\n\ " + ) #endif /* MS_WIN16 */ /* end of sys_doc */ ; From loewis@users.sourceforge.net Sun Jun 9 14:41:38 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun, 09 Jun 2002 06:41:38 -0700 Subject: [Python-checkins] python/dist/src/Mac/Include pyconfig.h,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Include In directory usw-pr-cvs1:/tmp/cvs-serv4220/Mac/Include Modified Files: pyconfig.h Log Message: Patch #505375: Make doc strings optional. Index: pyconfig.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Include/pyconfig.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** pyconfig.h 22 May 2002 14:31:10 -0000 1.8 --- pyconfig.h 9 Jun 2002 13:41:36 -0000 1.9 *************** *** 301,304 **** --- 301,307 ---- #undef WITH_DL_DLD + /* Define if you want documentation strings in extension modules */ + #define WITH_DOC_STRINGS 1 + /* Define if you want to use the new-style (Openstep, Rhapsody, MacOS) dynamic linker (dyld) instead of the old-style (NextStep) dynamic From loewis@users.sourceforge.net Sun Jun 9 14:41:39 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun, 09 Jun 2002 06:41:39 -0700 Subject: [Python-checkins] python/dist/src/PC pyconfig.h,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/PC In directory usw-pr-cvs1:/tmp/cvs-serv4220/PC Modified Files: pyconfig.h Log Message: Patch #505375: Make doc strings optional. Index: pyconfig.h =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/pyconfig.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** pyconfig.h 21 Apr 2002 07:30:30 -0000 1.9 --- pyconfig.h 9 Jun 2002 13:41:36 -0000 1.10 *************** *** 482,485 **** --- 482,488 ---- /* #undef WITH_DL_DLD */ + /* Define if you want documentation strings in extension modules */ + #define WITH_DOC_STRINGS 1 + /* Define if you want to compile in rudimentary thread support */ /* #undef WITH_THREAD */ From loewis@users.sourceforge.net Sun Jun 9 14:41:39 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun, 09 Jun 2002 06:41:39 -0700 Subject: [Python-checkins] python/dist/src/PC/os2emx pyconfig.h,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/PC/os2emx In directory usw-pr-cvs1:/tmp/cvs-serv4220/PC/os2emx Modified Files: pyconfig.h Log Message: Patch #505375: Make doc strings optional. Index: pyconfig.h =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/os2emx/pyconfig.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pyconfig.h 17 Feb 2002 05:23:30 -0000 1.1 --- pyconfig.h 9 Jun 2002 13:41:37 -0000 1.2 *************** *** 33,36 **** --- 33,39 ---- #define WITH_CYCLE_GC 1 + /* Define if you want documentation strings in extension modules */ + #define WITH_DOC_STRINGS 1 + /* Unicode related */ #define Py_USING_UNICODE From loewis@users.sourceforge.net Sun Jun 9 14:41:39 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun, 09 Jun 2002 06:41:39 -0700 Subject: [Python-checkins] python/dist/src/PC/os2vacpp pyconfig.h,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/PC/os2vacpp In directory usw-pr-cvs1:/tmp/cvs-serv4220/PC/os2vacpp Modified Files: pyconfig.h Log Message: Patch #505375: Make doc strings optional. Index: pyconfig.h =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/os2vacpp/pyconfig.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pyconfig.h 5 Nov 2001 02:45:58 -0000 1.3 --- pyconfig.h 9 Jun 2002 13:41:37 -0000 1.4 *************** *** 203,206 **** --- 203,209 ---- /* #define HAVE_UNAME 1 */ /* uname () */ + /* Define if you want documentation strings in extension modules */ + #define WITH_DOC_STRINGS 1 + #ifdef USE_DL_EXPORT #define DL_IMPORT(RTYPE) RTYPE _System From loewis@users.sourceforge.net Sun Jun 9 14:41:39 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun, 09 Jun 2002 06:41:39 -0700 Subject: [Python-checkins] python/dist/src/RISCOS pyconfig.h,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/RISCOS In directory usw-pr-cvs1:/tmp/cvs-serv4220/RISCOS Modified Files: pyconfig.h Log Message: Patch #505375: Make doc strings optional. Index: pyconfig.h =================================================================== RCS file: /cvsroot/python/python/dist/src/RISCOS/pyconfig.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pyconfig.h 24 Oct 2001 20:04:51 -0000 1.2 --- pyconfig.h 9 Jun 2002 13:41:37 -0000 1.3 *************** *** 251,254 **** --- 251,257 ---- #undef WITH_DL_DLD + /* Define if you want documentation strings in extension modules */ + #define WITH_DOC_STRINGS 1 + /* Define if you want to use the new-style (Openstep, Rhapsody, MacOS) dynamic linker (dyld) instead of the old-style (NextStep) dynamic From guido@python.org Sun Jun 9 14:47:57 2002 From: guido@python.org (Guido van Rossum) Date: Sun, 09 Jun 2002 09:47:57 -0400 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.419,1.420 In-Reply-To: Your message of "Sun, 09 Jun 2002 06:33:56 PDT." References: Message-ID: <200206091347.g59Dlvx13863@pcp02138704pcs.reston01.va.comcast.net> > + - The configure option --without-doc-strings can be used to remove the > + doc strings from the builtin functions and modules; this reduces the > + size of the executable. > + Shouldn't the news item mention that this is only partially implemented as yet? --Guido van Rossum (home page: http://www.python.org/~guido/) From jackjansen@users.sourceforge.net Sun Jun 9 23:08:54 2002 From: jackjansen@users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Sun, 09 Jun 2002 15:08:54 -0700 Subject: [Python-checkins] python/dist/src/Mac/OSXResources/app/Resources Applet-Info.plist,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSXResources/app/Resources In directory usw-pr-cvs1:/tmp/cvs-serv31258/Mac/OSXResources/app/Resources Modified Files: Applet-Info.plist Log Message: - Better commandline interface to BuildApplet, complete with options, verbose output to the console, etc. - Allow Cocoa applets to be built with BuildApplet. No full testing has been done yet to ensure OS9 operation hasn't suffered. Index: Applet-Info.plist =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSXResources/app/Resources/Applet-Info.plist,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Applet-Info.plist 29 Mar 2002 23:48:55 -0000 1.1 --- Applet-Info.plist 9 Jun 2002 22:08:52 -0000 1.2 *************** *** 23,26 **** --- 23,28 ---- CFBundleGetInfoString %(appletname)s, a Python applet + + %(cocoainfo)s CFBundleIconFile From jackjansen@users.sourceforge.net Sun Jun 9 23:08:54 2002 From: jackjansen@users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Sun, 09 Jun 2002 15:08:54 -0700 Subject: [Python-checkins] python/dist/src/Mac/scripts BuildApplet.py,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/scripts In directory usw-pr-cvs1:/tmp/cvs-serv31258/Mac/scripts Modified Files: BuildApplet.py Log Message: - Better commandline interface to BuildApplet, complete with options, verbose output to the console, etc. - Allow Cocoa applets to be built with BuildApplet. No full testing has been done yet to ensure OS9 operation hasn't suffered. Index: BuildApplet.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/scripts/BuildApplet.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** BuildApplet.py 31 Jul 1998 09:44:19 -0000 1.13 --- BuildApplet.py 9 Jun 2002 22:08:52 -0000 1.14 *************** *** 16,20 **** import EasyDialogs import buildtools ! def main(): --- 16,20 ---- import EasyDialogs import buildtools ! import getopt def main(): *************** *** 55,66 **** else: # Loop over all files to be processed ! for filename in sys.argv[1:]: cr, tp = MacOS.GetCreatorAndType(filename) if tp == 'APPL': ! buildtools.update(template, filename, '') else: ! buildtools.process(template, filename, '', 1) if __name__ == '__main__': --- 55,123 ---- else: + SHORTOPTS = "o:r:ne:v?" + LONGOPTS=("output=", "resource=", "noargv", "extra=", "verbose", "help") + try: + options, args = getopt.getopt(sys.argv[1:], SHORTOPTS, LONGOPTS) + except getopt.error: + usage() + if options and len(args) > 1: + sys.stderr.write("Cannot use options when specifying multiple input files") + sys.exit(1) + dstfilename = None + rsrcfilename = None + raw = 0 + extras = [] + verbose = None + for opt, arg in options: + if opt in ('-o', '--output'): + dstfilename = arg + elif opt in ('-r', '--resource'): + rsrcfilename = arg + elif opt in ('-n', '--noargv'): + raw = 1 + elif opt in ('-e', '--extra'): + extras.append(arg) + elif opt in ('-v', '--verbose'): + verbose = Verbose() + elif opt in ('-?', '--help'): + usage() # Loop over all files to be processed ! for filename in args: cr, tp = MacOS.GetCreatorAndType(filename) if tp == 'APPL': ! buildtools.update(template, filename, dstfilename) else: ! buildtools.process(template, filename, dstfilename, 1, ! rsrcname=rsrcfilename, others=extras, raw=raw, progress=verbose) ! ! def usage(): ! print "BuildApplet creates an application from a Python source file" ! print "Usage:" ! print " BuildApplet interactive, single file, no options" ! print " BuildApplet src1.py src2.py ... non-interactive multiple file" ! print " BuildApplet [options] src.py non-interactive single file" ! print "Options:" ! print " --output o Output file; default based on source filename, short -o" ! print " --resource r Resource file; default based on source filename, short -r" ! print " --noargv Build applet without drag-and-drop sys.argv emulation, short -n, OSX only" ! print " --extra f Extra file to put in .app bundle, short -e, OSX only" ! print " --verbose Verbose, short -v" ! print " --help This message, short -?" ! sys.exit(1) + class Verbose: + """This class mimics EasyDialogs.ProgressBar but prints to stderr""" + def __init__(self, *args): + if args and args[0]: + self.label(args[0]) + + def set(self, *args): + pass + + def inc(self, *args): + pass + + def label(self, str): + sys.stderr.write(str+'\n') if __name__ == '__main__': From jackjansen@users.sourceforge.net Sun Jun 9 23:08:54 2002 From: jackjansen@users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Sun, 09 Jun 2002 15:08:54 -0700 Subject: [Python-checkins] python/dist/src/Mac/Lib buildtools.py,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Lib In directory usw-pr-cvs1:/tmp/cvs-serv31258/Mac/Lib Modified Files: buildtools.py Log Message: - Better commandline interface to BuildApplet, complete with options, verbose output to the console, etc. - Allow Cocoa applets to be built with BuildApplet. No full testing has been done yet to ensure OS9 operation hasn't suffered. Index: buildtools.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Lib/buildtools.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** buildtools.py 29 Mar 2002 23:44:37 -0000 1.11 --- buildtools.py 9 Jun 2002 22:08:52 -0000 1.12 *************** *** 18,24 **** BuildError = "BuildError" - DEBUG=1 - - # .pyc file (and 'PYC ' resource magic number) MAGIC = imp.get_magic() --- 18,21 ---- *************** *** 71,81 **** ! def process(template, filename, output, copy_codefragment): ! if DEBUG: progress = EasyDialogs.ProgressBar("Processing %s..."%os.path.split(filename)[1], 120) progress.label("Compiling...") ! else: ! progress = None # Read the source and compile it --- 68,78 ---- ! def process(template, filename, destname, copy_codefragment, ! rsrcname=None, others=[], raw=0, progress="default"): ! if progress == "default": progress = EasyDialogs.ProgressBar("Processing %s..."%os.path.split(filename)[1], 120) progress.label("Compiling...") ! progress.inc(0) # Read the source and compile it *************** *** 90,108 **** raise BuildError, "Syntax error in script %s" % `filename` ! # Set the destination file name if string.lower(filename[-3:]) == ".py": ! destname = filename[:-3] ! rsrcname = destname + '.rsrc' else: if MacOS.runtimemodel == 'macho': ! destname = filename + '.app' else: ! destname = filename + ".applet" ! rsrcname = filename + '.rsrc' ! ! if output: ! destname = output ! # Try removing the output file. This fails in MachO, but it should # do any harm. --- 87,108 ---- raise BuildError, "Syntax error in script %s" % `filename` ! # Set the destination file name. Note that basename ! # does contain the whole filepath, only a .py is stripped. if string.lower(filename[-3:]) == ".py": ! basename = filename[:-3] ! if MacOS.runtimemodel != 'macho' and not destname: ! destname = basename else: + basename = filename + + if not destname: if MacOS.runtimemodel == 'macho': ! destname = basename + '.app' else: ! destname = basename + '.applet' ! if not rsrcname: ! rsrcname = basename + '.rsrc' ! # Try removing the output file. This fails in MachO, but it should # do any harm. *************** *** 111,115 **** except os.error: pass ! process_common(template, progress, code, rsrcname, destname, 0, copy_codefragment) --- 111,116 ---- except os.error: pass ! process_common(template, progress, code, rsrcname, destname, 0, ! copy_codefragment, raw, others) *************** *** 117,121 **** if MacOS.runtimemodel == 'macho': raise BuildError, "No updating yet for MachO applets" ! if DEBUG: progress = EasyDialogs.ProgressBar("Updating %s..."%os.path.split(filename)[1], 120) else: --- 118,122 ---- if MacOS.runtimemodel == 'macho': raise BuildError, "No updating yet for MachO applets" ! if progress: progress = EasyDialogs.ProgressBar("Updating %s..."%os.path.split(filename)[1], 120) else: *************** *** 132,138 **** ! def process_common(template, progress, code, rsrcname, destname, is_update, copy_codefragment): if MacOS.runtimemodel == 'macho': ! return process_common_macho(template, progress, code, rsrcname, destname, is_update) # Create FSSpecs for the various files template_fss = macfs.FSSpec(template) --- 133,143 ---- ! def process_common(template, progress, code, rsrcname, destname, is_update, ! copy_codefragment, raw=0, others=[]): if MacOS.runtimemodel == 'macho': ! return process_common_macho(template, progress, code, rsrcname, destname, ! is_update, raw, others) ! if others: ! raise BuildError, "Extra files only allowed for MachoPython applets" # Create FSSpecs for the various files template_fss = macfs.FSSpec(template) *************** *** 141,145 **** # Copy data (not resources, yet) from the template ! if DEBUG: progress.label("Copy data fork...") progress.set(10) --- 146,150 ---- # Copy data (not resources, yet) from the template ! if progress: progress.label("Copy data fork...") progress.set(10) *************** *** 158,162 **** # Open the output resource fork ! if DEBUG: progress.label("Copy resources...") progress.set(20) --- 163,167 ---- # Open the output resource fork ! if progress: progress.label("Copy resources...") progress.set(20) *************** *** 173,177 **** except (MacOS.Error, ValueError): pass ! if DEBUG: progress.inc(50) else: --- 178,182 ---- except (MacOS.Error, ValueError): pass ! if progress: progress.inc(50) else: *************** *** 223,227 **** # Create the raw data for the resource from the code object ! if DEBUG: progress.label("Write PYC resource...") progress.set(120) --- 228,232 ---- # Create the raw data for the resource from the code object ! if progress: progress.label("Write PYC resource...") progress.set(120) *************** *** 257,264 **** macostools.touched(dest_fss) ! if DEBUG: progress.label("Done.") ! def process_common_macho(template, progress, code, rsrcname, destname, is_update): # First make sure the name ends in ".app" if destname[-4:] != '.app': --- 262,270 ---- macostools.touched(dest_fss) ! if progress: progress.label("Done.") + progress.inc(0) ! def process_common_macho(template, progress, code, rsrcname, destname, is_update, raw=0, others=[]): # First make sure the name ends in ".app" if destname[-4:] != '.app': *************** *** 287,298 **** "Contents/Resources/python.rsrc", ] ! copyapptree(template, destname, exceptlist) # Now either use the .plist file or the default if plistname: ! shutil.copy2(plistname, os.path.join(destname, 'Contents/Info.plist')) if icnsname: icnsdest = os.path.split(icnsname)[1] icnsdest = os.path.join(destname, ! os.path.join('Contents/Resources', icnsdest)) shutil.copy2(icnsname, icnsdest) # XXXX Wrong. This should be parsed from plist file. Also a big hack:-) --- 293,307 ---- "Contents/Resources/python.rsrc", ] ! copyapptree(template, destname, exceptlist, progress) # Now either use the .plist file or the default + if progress: + progress.label('Create info.plist') + progress.inc(0) if plistname: ! shutil.copy2(plistname, os.path.join(destname, 'Contents', 'Info.plist')) if icnsname: icnsdest = os.path.split(icnsname)[1] icnsdest = os.path.join(destname, ! os.path.join('Contents', 'Resources', icnsdest)) shutil.copy2(icnsname, icnsdest) # XXXX Wrong. This should be parsed from plist file. Also a big hack:-) *************** *** 303,331 **** # XXXX Should copy .icns file else: ! plistname = os.path.join(template, 'Contents/Resources/Applet-Info.plist') plistdata = open(plistname).read() ! plistdata = plistdata % {'appletname':shortname} ! ofp = open(os.path.join(destname, 'Contents/Info.plist'), 'w') ofp.write(plistdata) ofp.close() ownertype = 'PytA' # Create the PkgInfo file ! ofp = open(os.path.join(destname, 'Contents/PkgInfo'), 'wb') ofp.write('APPL' + ownertype) ofp.close() ! if DEBUG: progress.label("Copy resources...") progress.set(20) resfilename = '%s.rsrc' % shortname - respartialpathname = 'Contents/Resources/%s' % resfilename try: output = Res.FSOpenResourceFile( ! os.path.join(destname, respartialpathname), u'', WRITE) except MacOS.Error: fsr, dummy = Res.FSCreateResourceFile( ! os.path.join(destname, 'Contents/Resources'), unicode(resfilename), '') output = Res.FSOpenResourceFile(fsr, u'', WRITE) --- 312,353 ---- # XXXX Should copy .icns file else: ! cocoainfo = '' ! for o in others: ! if o[-4:] == '.nib': ! nibname = os.path.split(o)[1][:-4] ! cocoainfo = """ ! NSMainNibFile ! %s ! NSPrincipalClass ! NSApplication""" % nibname ! ! ! plistname = os.path.join(template, 'Contents', 'Resources', 'Applet-Info.plist') plistdata = open(plistname).read() ! plistdata = plistdata % {'appletname':shortname, 'cocoainfo':cocoainfo} ! ofp = open(os.path.join(destname, 'Contents', 'Info.plist'), 'w') ofp.write(plistdata) ofp.close() ownertype = 'PytA' # Create the PkgInfo file ! if progress: ! progress.label('Create PkgInfo') ! progress.inc(0) ! ofp = open(os.path.join(destname, 'Contents', 'PkgInfo'), 'wb') ofp.write('APPL' + ownertype) ofp.close() ! if progress: progress.label("Copy resources...") progress.set(20) resfilename = '%s.rsrc' % shortname try: output = Res.FSOpenResourceFile( ! os.path.join(destname, 'Contents', 'Resources', resfilename), u'', WRITE) except MacOS.Error: fsr, dummy = Res.FSCreateResourceFile( ! os.path.join(destname, 'Contents', 'Resources'), unicode(resfilename), '') output = Res.FSOpenResourceFile(fsr, u'', WRITE) *************** *** 337,341 **** except (MacOS.Error, ValueError): pass ! if DEBUG: progress.inc(50) else: --- 359,363 ---- except (MacOS.Error, ValueError): pass ! if progress: progress.inc(50) else: *************** *** 356,361 **** input = Res.FSOpenResourceFile( ! os.path.join(template, 'Contents/Resources/python.rsrc'), u'', READ) ! dummy, tmplowner = copyres(input, output, skiptypes, 1, progress) Res.CloseResFile(input) --- 378,387 ---- input = Res.FSOpenResourceFile( ! os.path.join(template, 'Contents', 'Resources', 'python.rsrc'), u'', READ) ! if progress: ! progress.label("Copy standard resources...") ! progress.inc(0) ! ## dummy, tmplowner = copyres(input, output, skiptypes, 1, progress) ! dummy, tmplowner = copyres(input, output, skiptypes, 1, None) Res.CloseResFile(input) *************** *** 367,372 **** if code: ! outputfilename = os.path.join(destname, 'Contents/Resources/__main__.pyc') writepycfile(code, outputfilename) ## macostools.touched(dest_fss) --- 393,419 ---- if code: ! if raw: ! pycname = '__rawmain__.pyc' ! else: ! pycname = '__main__.pyc' ! outputfilename = os.path.join(destname, 'Contents', 'Resources', pycname) ! if progress: ! progress.label('Creating '+pycname) ! progress.inc(0) writepycfile(code, outputfilename) + # Copy other files the user asked for + for osrc in others: + oname = os.path.split(osrc)[1] + odst = os.path.join(destname, 'Contents', 'Resources', oname) + if progress: + progress.label('Copy ' + oname) + progress.inc(0) + if os.path.isdir(osrc): + copyapptree(osrc, odst) + else: + shutil.copy2(osrc, odst) + if progress: + progress.label('Done.') + progress.inc(0) ## macostools.touched(dest_fss) *************** *** 401,405 **** size = res.size attrs = res.GetResAttrs() ! if DEBUG and progress: progress.label("Copy %s %d %s"%(type, id, name)) progress.inc(progress_cur_inc) --- 448,452 ---- size = res.size attrs = res.GetResAttrs() ! if progress: progress.label("Copy %s %d %s"%(type, id, name)) progress.inc(progress_cur_inc) *************** *** 412,417 **** res2 = None if res2: ! if DEBUG and progress: progress.label("Overwrite %s %d %s"%(type, id, name)) res2.RemoveResource() res.AddResource(type, id, name) --- 459,465 ---- res2 = None if res2: ! if progress: progress.label("Overwrite %s %d %s"%(type, id, name)) + progress.inc(0) res2.RemoveResource() res.AddResource(type, id, name) *************** *** 422,426 **** return alltypes, ctor ! def copyapptree(srctree, dsttree, exceptlist=[]): names = [] if os.path.exists(dsttree): --- 470,474 ---- return alltypes, ctor ! def copyapptree(srctree, dsttree, exceptlist=[], progress=None): names = [] if os.path.exists(dsttree): *************** *** 444,447 **** --- 492,498 ---- os.mkdir(dstpath) else: + if progress: + progress.label('Copy '+this) + progress.inc(0) shutil.copy2(srcpath, dstpath) From aimacintyre@users.sourceforge.net Mon Jun 10 09:04:31 2002 From: aimacintyre@users.sourceforge.net (aimacintyre@users.sourceforge.net) Date: Mon, 10 Jun 2002 01:04:31 -0700 Subject: [Python-checkins] python/dist/src/PC/os2emx config.c,1.1,1.2 Makefile,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/PC/os2emx In directory usw-pr-cvs1:/tmp/cvs-serv17530 Modified Files: config.c Makefile Log Message: make _sre a dynamically loadable module and build xxsubtype Index: config.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/os2emx/config.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** config.c 17 Feb 2002 05:23:30 -0000 1.1 --- config.c 10 Jun 2002 08:04:29 -0000 1.2 *************** *** 81,84 **** --- 81,85 ---- extern void initunicodedata(); extern void initxreadlines(); + extern void initxxsubtype(); extern void initzlib(); *************** *** 92,96 **** {"gc", initgc}, {"os2", initos2}, - {"_sre", init_sre}, {"signal", initsignal}, #ifdef WITH_THREAD --- 93,96 ---- *************** *** 103,106 **** --- 103,107 ---- {"_hotshot", init_hotshot}, {"_locale", init_locale}, + {"_sre", init_sre}, {"_testcapi", init_testcapi}, {"_weakref", init_weakref}, *************** *** 135,138 **** --- 136,140 ---- {"unicodedata", initunicodedata}, {"xreadlines", initxreadlines}, + {"xxsubtype", initxxsubtype}, {"zlib", initzlib}, #ifdef USE_SOCKET Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/os2emx/Makefile,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Makefile 30 Apr 2002 13:06:32 -0000 1.3 --- Makefile 10 Jun 2002 08:04:29 -0000 1.4 *************** *** 253,258 **** Modules/signalmodule.c \ Modules/posixmodule.c \ ! Modules/threadmodule.c \ ! Modules/_sre.c) SRC.PARSER= $(addprefix $(TOP), \ Parser/acceler.c \ --- 253,257 ---- Modules/signalmodule.c \ Modules/posixmodule.c \ ! Modules/threadmodule.c) SRC.PARSER= $(addprefix $(TOP), \ Parser/acceler.c \ *************** *** 383,391 **** regex \ _socket \ termios \ _testcap \ unicoded \ _weakref \ ! xreadlin # Python external ($(MODULE.EXT)) modules - can be EASY or HARD --- 382,392 ---- regex \ _socket \ + _sre \ termios \ _testcap \ unicoded \ _weakref \ ! xreadlin \ ! xxsubtyp # Python external ($(MODULE.EXT)) modules - can be EASY or HARD *************** *** 514,517 **** --- 515,521 ---- $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) + _sre$(MODULE.EXT): $(OUT)_sre$O $(OUT)_sre_m.def $(PYTHON.IMPLIB) + $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) + # _symtable needs to be renamed to be useful _symtable$(MODULE.EXT): $(OUT)symtablemodule$O $(OUT)_symtable_m.def $(PYTHON.IMPLIB) *************** *** 546,549 **** --- 550,560 ---- xreadlin$(MODULE.EXT): xreadlines$(MODULE.EXT) + cp $^ $@ + + # xxsubtype needs to be renamed to be useful + xxsubtype$(MODULE.EXT): $(OUT)xxsubtype$O $(OUT)xxsubtype_m.def $(PYTHON.IMPLIB) + $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) + + xxsubtyp$(MODULE.EXT): xxsubtype$(MODULE.EXT) cp $^ $@ From aimacintyre@users.sourceforge.net Mon Jun 10 09:05:28 2002 From: aimacintyre@users.sourceforge.net (aimacintyre@users.sourceforge.net) Date: Mon, 10 Jun 2002 01:05:28 -0700 Subject: [Python-checkins] python/dist/src/PC/os2emx python23.def,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/PC/os2emx In directory usw-pr-cvs1:/tmp/cvs-serv17758 Modified Files: python23.def Log Message: refresh to pick up recent changes Index: python23.def =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/os2emx/python23.def,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** python23.def 30 Apr 2002 12:06:23 -0000 1.3 --- python23.def 10 Jun 2002 08:05:26 -0000 1.4 *************** *** 335,338 **** --- 335,339 ---- "PyList_AsTuple" "PyList_Type" + "PyListIter_Type" ; From python23_s.lib(longobject) *************** *** 466,469 **** --- 467,471 ---- "_Py_ReleaseInternedStrings" "PyString_Type" + "PyBaseString_Type" ; From python23_s.lib(structseq) *************** *** 616,619 **** --- 618,622 ---- "PyExc_UserWarning" "PyExc_DeprecationWarning" + "PyExc_PendingDeprecationWarning" "PyExc_SyntaxWarning" "PyExc_OverflowWarning" *************** *** 942,946 **** ; From python23_s.lib(threadmodule) ; "initthread" - - ; From python23_s.lib(_sre) - ; "init_sre" --- 945,946 ---- From mwh@users.sourceforge.net Mon Jun 10 14:19:45 2002 From: mwh@users.sourceforge.net (mwh@users.sourceforge.net) Date: Mon, 10 Jun 2002 06:19:45 -0700 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew23.tex,1.19,1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory usw-pr-cvs1:/tmp/cvs-serv12140 Modified Files: whatsnew23.tex Log Message: Tweak the description of pymalloc. Mention pymemcompat.h. Index: whatsnew23.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew23.tex,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** whatsnew23.tex 29 May 2002 19:20:57 -0000 1.19 --- whatsnew23.tex 10 Jun 2002 13:19:42 -0000 1.20 *************** *** 358,364 **** allocator called pymalloc, written by Vladimir Marangozov. Pymalloc was intended to be faster than the system \function{malloc()} and have ! less memory overhead. The allocator uses C's \function{malloc()} ! function to get large pools of memory, and then fulfills smaller ! memory requests from these pools. In 2.1 and 2.2, pymalloc was an experimental feature and wasn't --- 358,365 ---- allocator called pymalloc, written by Vladimir Marangozov. Pymalloc was intended to be faster than the system \function{malloc()} and have ! less memory overhead for typical allocation patterns of Python ! programs. The allocator uses C's \function{malloc()} function to get ! large pools of memory, and then fulfills smaller memory requests from ! these pools. In 2.1 and 2.2, pymalloc was an experimental feature and wasn't *************** *** 379,408 **** object allocator is enabled, these functions aren't aliases of \function{malloc()} and \function{free()} any more, and calling the ! wrong function to free memory will get you a core dump. For example, ! if memory was allocated using \function{PyMem_New()}, it has to be ! freed using \function{PyMem_Del()}, not \function{free()}. A few ! modules included with Python fell afoul of this and had to be fixed; ! doubtless there are more third-party modules that will have the same ! problem. As part of this change, the confusing multiple interfaces for ! allocating memory have been consolidated down into two APIs. ! Memory allocated with one API must not be freed with the other API. \begin{itemize} ! \item To allocate and free an undistinguished chunk of memory using ! Python's allocator, use ! \cfunction{PyMem_Malloc()}, \cfunction{PyMem_Realloc()}, and ! \cfunction{PyMem_Free()}. ! \item In rare cases you may want to avoid using Python's allocator ! in order to allocate a chunk of memory; ! use \cfunction{PyObject_Malloc}, \cfunction{PyObject_Realloc}, ! and \cfunction{PyObject_Free}. ! \item To allocate and free Python objects, ! use \cfunction{PyObject_New()}, \cfunction{PyObject_NewVar()}, and \cfunction{PyObject_Del()}. - \end{itemize} --- 380,411 ---- object allocator is enabled, these functions aren't aliases of \function{malloc()} and \function{free()} any more, and calling the ! wrong function to free memory may get you a core dump. For example, ! if memory was allocated using \function{PyObject_Malloc()}, it has to ! be freed using \function{PyObject_Free()}, not \function{free()}. A ! few modules included with Python fell afoul of this and had to be ! fixed; doubtless there are more third-party modules that will have the ! same problem. As part of this change, the confusing multiple interfaces for ! allocating memory have been consolidated down into two API families. ! Memory allocated with one family must not be manipulated with ! functions from the other family. ! ! There is another family of functions specifically for allocating ! Python \emph{objects} (as opposed to memory). \begin{itemize} ! \item To allocate and free an undistinguished chunk of memory use ! the ``raw memory'' family: \cfunction{PyMem_Malloc()}, ! \cfunction{PyMem_Realloc()}, and \cfunction{PyMem_Free()}. ! \item The ``object memory'' family is the interface to the pymalloc ! facility described above and is biased towards a large number of ! ``small'' allocations: \cfunction{PyObject_Malloc}, ! \cfunction{PyObject_Realloc}, and \cfunction{PyObject_Free}. ! \item To allocate and free Python objects, use the ``object'' family ! \cfunction{PyObject_New()}, \cfunction{PyObject_NewVar()}, and \cfunction{PyObject_Del()}. \end{itemize} *************** *** 412,415 **** --- 415,425 ---- support, turn on the Python interpreter's debugging code by running \program{configure} with \longprogramopt{with-pydebug}. + + To aid extension writers, a header file \file{Misc/pymemcompat.h} is + distributed with the source to Python 2.3 that allows Python + extensions to use the 2.3 interfaces to memory allocation and compile + against any version of Python since 1.5.2. (The idea is that you take + the file from Python's source distribution and bundle it with the + source of you extension). \begin{seealso} From akuchling@users.sourceforge.net Mon Jun 10 14:22:49 2002 From: akuchling@users.sourceforge.net (akuchling@users.sourceforge.net) Date: Mon, 10 Jun 2002 06:22:49 -0700 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew23.tex,1.20,1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory usw-pr-cvs1:/tmp/cvs-serv13543 Modified Files: whatsnew23.tex Log Message: Fix typo, and add some reminders Index: whatsnew23.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew23.tex,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** whatsnew23.tex 10 Jun 2002 13:19:42 -0000 1.20 --- whatsnew23.tex 10 Jun 2002 13:22:46 -0000 1.21 *************** *** 14,17 **** --- 14,28 ---- \tableofcontents + % Timeout sockets: + % Executive summary: after sock.settimeout(T), all methods of sock will + % block for at most T floating seconds and fail if they can't complete + % within that time. sock.settimeout(None) restores full blocking mode. + % + % Optik (or whatever it gets called) + % + % getopt.gnu_getopt + % + + %\section{Introduction \label{intro}} *************** *** 421,425 **** against any version of Python since 1.5.2. (The idea is that you take the file from Python's source distribution and bundle it with the ! source of you extension). \begin{seealso} --- 432,436 ---- against any version of Python since 1.5.2. (The idea is that you take the file from Python's source distribution and bundle it with the ! source of your extension). \begin{seealso} From gvanrossum@users.sourceforge.net Mon Jun 10 15:30:45 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Mon, 10 Jun 2002 07:30:45 -0700 Subject: [Python-checkins] python/dist/src/Objects typeobject.c,2.148,2.149 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv7832 Modified Files: typeobject.c Log Message: Three's a charm: yet another fix for SF bug 551412. Thinking again about the test case, slot_nb_power gets called on behalf of its second argument, but with a non-None modulus it wouldn't check this, and believes it is called on behalf of its first argument. Fix this properly, and get rid of the code in _PyType_Lookup() that tries to call _PyType_Ready(). But do leave a check for a NULL tp_mro there, because this can still legitimately occur. I'll fix this in 2.2.x too. Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.148 retrieving revision 2.149 diff -C2 -d -r2.148 -r2.149 *** typeobject.c 4 Jun 2002 19:52:53 -0000 2.148 --- typeobject.c 10 Jun 2002 14:30:43 -0000 2.149 *************** *** 1310,1329 **** /* Look in tp_dict of types in MRO */ mro = type->tp_mro; ! if (mro == NULL) { ! if (PyType_Ready(type) < 0) { ! /* It's not ideal to clear the error condition, ! but this function is documented as not setting ! an exception, and I don't want to change that. ! When PyType_Ready() can't proceed, it won't ! set the "ready" flag, so future attempts to ready ! the same type will call it again -- hopefully ! in a context that propagates the exception out. ! */ ! PyErr_Clear(); ! return NULL; ! } ! mro = type->tp_mro; ! assert(mro != NULL); ! } assert(PyTuple_Check(mro)); n = PyTuple_GET_SIZE(mro); --- 1310,1320 ---- /* Look in tp_dict of types in MRO */ mro = type->tp_mro; ! ! /* If mro is NULL, the type is either not yet initialized ! by PyType_Ready(), or already cleared by type_clear(). ! Either way the safest thing to do is to return NULL. */ ! if (mro == NULL) ! return NULL; ! assert(PyTuple_Check(mro)); n = PyTuple_GET_SIZE(mro); *************** *** 3100,3106 **** if (modulus == Py_None) return slot_nb_power_binary(self, other); ! /* Three-arg power doesn't use __rpow__ */ ! return call_method(self, "__pow__", &pow_str, ! "(OO)", other, modulus); } --- 3091,3104 ---- if (modulus == Py_None) return slot_nb_power_binary(self, other); ! /* Three-arg power doesn't use __rpow__. But ternary_op ! can call this when the second argument's type uses ! slot_nb_power, so check before calling self.__pow__. */ ! if (self->ob_type->tp_as_number != NULL && ! self->ob_type->tp_as_number->nb_power == slot_nb_power) { ! return call_method(self, "__pow__", &pow_str, ! "(OO)", other, modulus); ! } ! Py_INCREF(Py_NotImplemented); ! return Py_NotImplemented; } From gvanrossum@users.sourceforge.net Mon Jun 10 15:34:03 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Mon, 10 Jun 2002 07:34:03 -0700 Subject: [Python-checkins] python/dist/src/Objects typeobject.c,2.126.4.13,2.126.4.14 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv8958 Modified Files: Tag: release22-maint typeobject.c Log Message: Backport: Three's a charm: yet another fix for SF bug 551412. Thinking again about the test case, slot_nb_power gets called on behalf of its second argument, but with a non-None modulus it wouldn't check this, and believes it is called on behalf of its first argument. Fix this properly, and get rid of the code in _PyType_Lookup() that tries to call _PyType_Ready(). But do leave a check for a NULL tp_mro there, because this can still legitimately occur. Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.126.4.13 retrieving revision 2.126.4.14 diff -C2 -d -r2.126.4.13 -r2.126.4.14 *** typeobject.c 4 Jun 2002 21:19:55 -0000 2.126.4.13 --- typeobject.c 10 Jun 2002 14:34:01 -0000 2.126.4.14 *************** *** 1283,1302 **** /* Look in tp_dict of types in MRO */ mro = type->tp_mro; ! if (mro == NULL) { ! if (PyType_Ready(type) < 0) { ! /* It's not ideal to clear the error condition, ! but this function is documented as not setting ! an exception, and I don't want to change that. ! When PyType_Ready() can't proceed, it won't ! set the "ready" flag, so future attempts to ready ! the same type will call it again -- hopefully ! in a context that propagates the exception out. ! */ ! PyErr_Clear(); ! return NULL; ! } ! mro = type->tp_mro; ! assert(mro != NULL); ! } assert(PyTuple_Check(mro)); n = PyTuple_GET_SIZE(mro); --- 1283,1293 ---- /* Look in tp_dict of types in MRO */ mro = type->tp_mro; ! ! /* If mro is NULL, the type is either not yet initialized ! by PyType_Ready(), or already cleared by type_clear(). ! Either way the safest thing to do is to return NULL. */ ! if (mro == NULL) ! return NULL; ! assert(PyTuple_Check(mro)); n = PyTuple_GET_SIZE(mro); *************** *** 3017,3023 **** if (modulus == Py_None) return slot_nb_power_binary(self, other); ! /* Three-arg power doesn't use __rpow__ */ ! return call_method(self, "__pow__", &pow_str, ! "(OO)", other, modulus); } --- 3008,3021 ---- if (modulus == Py_None) return slot_nb_power_binary(self, other); ! /* Three-arg power doesn't use __rpow__. But ternary_op ! can call this when the second argument's type uses ! slot_nb_power, so check before calling self.__pow__. */ ! if (self->ob_type->tp_as_number != NULL && ! self->ob_type->tp_as_number->nb_power == slot_nb_power) { ! return call_method(self, "__pow__", &pow_str, ! "(OO)", other, modulus); ! } ! Py_INCREF(Py_NotImplemented); ! return Py_NotImplemented; } From gvanrossum@users.sourceforge.net Mon Jun 10 16:24:46 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Mon, 10 Jun 2002 08:24:46 -0700 Subject: [Python-checkins] python/dist/src/Objects typeobject.c,2.149,2.150 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv26343 Modified Files: typeobject.c Log Message: In the recent python-dev thread "Bizarre new test failure", we discovered that subtype_traverse must traverse the type if it is a heap type, because otherwise some cycles involving a type and its instance would not be collected. Simplest example: while 1: class C(object): pass C.ref = C() This program grows without bounds before this fix. (It grows ever slower since it spends ever more time in the collector.) Simply adding the right visit() call to subtype_traverse() revealed other problems. With MvL's help we re-learned that type_clear() doesn't have to clear *all* references, only the ones that may not be cleared by other means. Careful analysis (see comments in the code) revealed that only tp_mro needs to be cleared. (The previous checkin to this file adds a test for tp_mro==NULL to _PyType_Lookup() that's essential to prevent crashes due to tp_mro being NULL when subtype_dealloc() tries to look for a __del__ method.) The same kind of analysis also revealed that subtype_clear() doesn't need to clear the instance dict. With this fix, a useful property of the collector is once again guaranteed: a single gc.collect() call will clear out all garbage. (It didn't always before, which put us on the track of this bug.) Will backport to 2.2. Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.149 retrieving revision 2.150 diff -C2 -d -r2.149 -r2.150 *** typeobject.c 10 Jun 2002 14:30:43 -0000 2.149 --- typeobject.c 10 Jun 2002 15:24:42 -0000 2.150 *************** *** 291,294 **** --- 291,303 ---- } + if (type->tp_flags & Py_TPFLAGS_HEAPTYPE) { + /* For a heaptype, the instances count as references + to the type. Traverse the type so the collector + can find cycles involving this link. */ + int err = visit((PyObject *)type, arg); + if (err) + return err; + } + if (basetraverse) return basetraverse(self, visit, arg); *************** *** 333,342 **** } ! if (type->tp_dictoffset != base->tp_dictoffset) { ! PyObject **dictptr = _PyObject_GetDictPtr(self); ! if (dictptr && *dictptr) { ! PyDict_Clear(*dictptr); ! } ! } if (baseclear) --- 342,347 ---- } ! /* There's no need to clear the instance dict (if any); ! the collector will call its tp_clear handler. */ if (baseclear) *************** *** 1484,1494 **** type_traverse(PyTypeObject *type, visitproc visit, void *arg) { - etype *et; int err; ! if (!(type->tp_flags & Py_TPFLAGS_HEAPTYPE)) ! return 0; ! ! et = (etype *)type; #define VISIT(SLOT) \ --- 1489,1497 ---- type_traverse(PyTypeObject *type, visitproc visit, void *arg) { int err; ! /* Because of type_is_gc(), the collector only calls this ! for heaptypes. */ ! assert(type->tp_flags & Py_TPFLAGS_HEAPTYPE); #define VISIT(SLOT) \ *************** *** 1504,1509 **** VISIT(type->tp_bases); VISIT(type->tp_base); ! VISIT(type->tp_subclasses); ! VISIT(et->slots); #undef VISIT --- 1507,1515 ---- VISIT(type->tp_bases); VISIT(type->tp_base); ! ! /* There's no need to visit type->tp_subclasses or ! ((etype *)type)->slots, because they can't be involved ! in cycles; tp_subclasses is a list of weak references, ! and slots is a tuple of strings. */ #undef VISIT *************** *** 1515,1525 **** type_clear(PyTypeObject *type) { - etype *et; PyObject *tmp; ! if (!(type->tp_flags & Py_TPFLAGS_HEAPTYPE)) ! return 0; ! ! et = (etype *)type; #define CLEAR(SLOT) \ --- 1521,1529 ---- type_clear(PyTypeObject *type) { PyObject *tmp; ! /* Because of type_is_gc(), the collector only calls this ! for heaptypes. */ ! assert(type->tp_flags & Py_TPFLAGS_HEAPTYPE); #define CLEAR(SLOT) \ *************** *** 1530,1545 **** } ! CLEAR(type->tp_dict); ! CLEAR(type->tp_cache); ! CLEAR(type->tp_mro); ! CLEAR(type->tp_bases); ! CLEAR(type->tp_base); ! CLEAR(type->tp_subclasses); ! CLEAR(et->slots); ! if (type->tp_doc != NULL) { ! PyObject_FREE(type->tp_doc); ! type->tp_doc = NULL; ! } #undef CLEAR --- 1534,1563 ---- } ! /* The only field we need to clear is tp_mro, which is part of a ! hard cycle (its first element is the class itself) that won't ! be broken otherwise (it's a tuple and tuples don't have a ! tp_clear handler). None of the other fields need to be ! cleared, and here's why: ! tp_dict: ! It is a dict, so the collector will call its tp_clear. ! ! tp_cache: ! Not used; if it were, it would be a dict. ! ! tp_bases, tp_base: ! If these are involved in a cycle, there must be at least ! one other, mutable object in the cycle, e.g. a base ! class's dict; the cycle will be broken that way. ! ! tp_subclasses: ! A list of weak references can't be part of a cycle; and ! lists have their own tp_clear. ! ! slots (in etype): ! A tuple of strings can't be part of a cycle. ! */ ! ! CLEAR(type->tp_mro); #undef CLEAR *************** *** 2158,2165 **** int i, n; ! if (type->tp_flags & Py_TPFLAGS_READY) { ! assert(type->tp_dict != NULL); return 0; - } assert((type->tp_flags & Py_TPFLAGS_READYING) == 0); --- 2176,2181 ---- int i, n; ! if (type->tp_flags & Py_TPFLAGS_READY) return 0; assert((type->tp_flags & Py_TPFLAGS_READYING) == 0); From gvanrossum@users.sourceforge.net Mon Jun 10 16:29:10 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Mon, 10 Jun 2002 08:29:10 -0700 Subject: [Python-checkins] python/dist/src/Objects typeobject.c,2.150,2.151 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv27767 Modified Files: typeobject.c Log Message: Undo the last chunk of the previous patch, putting back a useful assert into PyType_Ready(): now that we're not clearing tp_dict, we can assert that it's non-NULL again. Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.150 retrieving revision 2.151 diff -C2 -d -r2.150 -r2.151 *** typeobject.c 10 Jun 2002 15:24:42 -0000 2.150 --- typeobject.c 10 Jun 2002 15:29:03 -0000 2.151 *************** *** 2176,2181 **** int i, n; ! if (type->tp_flags & Py_TPFLAGS_READY) return 0; assert((type->tp_flags & Py_TPFLAGS_READYING) == 0); --- 2176,2183 ---- int i, n; ! if (type->tp_flags & Py_TPFLAGS_READY) { ! assert(type->tp_dict != NULL); return 0; + } assert((type->tp_flags & Py_TPFLAGS_READYING) == 0); From akuchling@users.sourceforge.net Mon Jun 10 16:53:07 2002 From: akuchling@users.sourceforge.net (akuchling@users.sourceforge.net) Date: Mon, 10 Jun 2002 08:53:07 -0700 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew23.tex,1.21,1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory usw-pr-cvs1:/tmp/cvs-serv4421 Modified Files: whatsnew23.tex Log Message: Fix typo Index: whatsnew23.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew23.tex,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** whatsnew23.tex 10 Jun 2002 13:22:46 -0000 1.21 --- whatsnew23.tex 10 Jun 2002 15:53:05 -0000 1.22 *************** *** 503,507 **** \end{verbatim} ! \item Dictionaries have a new method, method{pop(\var{key})}, that returns the value corresponding to \var{key} and removes that key/value pair from the dictionary. \method{pop()} will raise a --- 503,507 ---- \end{verbatim} ! \item Dictionaries have a new method, \method{pop(\var{key})}, that returns the value corresponding to \var{key} and removes that key/value pair from the dictionary. \method{pop()} will raise a *************** *** 654,658 **** The author would like to thank the following people for offering suggestions, corrections and assistance with various drafts of this ! article: Fred~L. Drake, Jr., Detlef Lannert, Andrew MacIntyre. \end{document} --- 654,658 ---- The author would like to thank the following people for offering suggestions, corrections and assistance with various drafts of this ! article: Michael Chermside, Fred~L. Drake, Jr., Detlef Lannert, Andrew MacIntyre. \end{document} From gvanrossum@users.sourceforge.net Mon Jun 10 17:02:46 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Mon, 10 Jun 2002 09:02:46 -0700 Subject: [Python-checkins] python/dist/src/Objects typeobject.c,2.126.4.14,2.126.4.15 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv8527 Modified Files: Tag: release22-maint typeobject.c Log Message: Backport two patches that belong together: (2.150) In the recent python-dev thread "Bizarre new test failure", we discovered that subtype_traverse must traverse the type if it is a heap type, because otherwise some cycles involving a type and its instance would not be collected. Simplest example: while 1: class C(object): pass C.ref = C() This program grows without bounds before this fix. (It grows ever slower since it spends ever more time in the collector.) Simply adding the right visit() call to subtype_traverse() revealed other problems. With MvL's help we re-learned that type_clear() doesn't have to clear *all* references, only the ones that may not be cleared by other means. Careful analysis (see comments in the code) revealed that only tp_mro needs to be cleared. (The previous checkin to this file adds a test for tp_mro==NULL to _PyType_Lookup() that's essential to prevent crashes due to tp_mro being NULL when subtype_dealloc() tries to look for a __del__ method.) The same kind of analysis also revealed that subtype_clear() doesn't need to clear the instance dict. With this fix, a useful property of the collector is once again guaranteed: a single gc.collect() call will clear out all garbage. (It didn't always before, which put us on the track of this bug.) (2.151) Undo the last chunk of the previous patch, putting back a useful assert into PyType_Ready(): now that we're not clearing tp_dict, we can assert that it's non-NULL again. Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.126.4.14 retrieving revision 2.126.4.15 diff -C2 -d -r2.126.4.14 -r2.126.4.15 *** typeobject.c 10 Jun 2002 14:34:01 -0000 2.126.4.14 --- typeobject.c 10 Jun 2002 16:02:44 -0000 2.126.4.15 *************** *** 288,291 **** --- 288,300 ---- } + if (type->tp_flags & Py_TPFLAGS_HEAPTYPE) { + /* For a heaptype, the instances count as references + to the type. Traverse the type so the collector + can find cycles involving this link. */ + int err = visit((PyObject *)type, arg); + if (err) + return err; + } + if (basetraverse) return basetraverse(self, visit, arg); *************** *** 330,339 **** } ! if (type->tp_dictoffset != base->tp_dictoffset) { ! PyObject **dictptr = _PyObject_GetDictPtr(self); ! if (dictptr && *dictptr) { ! PyDict_Clear(*dictptr); ! } ! } if (baseclear) --- 339,344 ---- } ! /* There's no need to clear the instance dict (if any); ! the collector will call its tp_clear handler. */ if (baseclear) *************** *** 1439,1449 **** type_traverse(PyTypeObject *type, visitproc visit, void *arg) { - etype *et; int err; ! if (!(type->tp_flags & Py_TPFLAGS_HEAPTYPE)) ! return 0; ! ! et = (etype *)type; #define VISIT(SLOT) \ --- 1444,1452 ---- type_traverse(PyTypeObject *type, visitproc visit, void *arg) { int err; ! /* Because of type_is_gc(), the collector only calls this ! for heaptypes. */ ! assert(type->tp_flags & Py_TPFLAGS_HEAPTYPE); #define VISIT(SLOT) \ *************** *** 1459,1464 **** VISIT(type->tp_bases); VISIT(type->tp_base); ! VISIT(type->tp_subclasses); ! VISIT(et->slots); #undef VISIT --- 1462,1470 ---- VISIT(type->tp_bases); VISIT(type->tp_base); ! ! /* There's no need to visit type->tp_subclasses or ! ((etype *)type)->slots, because they can't be involved ! in cycles; tp_subclasses is a list of weak references, ! and slots is a tuple of strings. */ #undef VISIT *************** *** 1470,1480 **** type_clear(PyTypeObject *type) { - etype *et; PyObject *tmp; ! if (!(type->tp_flags & Py_TPFLAGS_HEAPTYPE)) ! return 0; ! ! et = (etype *)type; #define CLEAR(SLOT) \ --- 1476,1484 ---- type_clear(PyTypeObject *type) { PyObject *tmp; ! /* Because of type_is_gc(), the collector only calls this ! for heaptypes. */ ! assert(type->tp_flags & Py_TPFLAGS_HEAPTYPE); #define CLEAR(SLOT) \ *************** *** 1485,1500 **** } ! CLEAR(type->tp_dict); ! CLEAR(type->tp_cache); ! CLEAR(type->tp_mro); ! CLEAR(type->tp_bases); ! CLEAR(type->tp_base); ! CLEAR(type->tp_subclasses); ! CLEAR(et->slots); ! if (type->tp_doc != NULL) { ! PyObject_FREE(type->tp_doc); ! type->tp_doc = NULL; ! } #undef CLEAR --- 1489,1518 ---- } ! /* The only field we need to clear is tp_mro, which is part of a ! hard cycle (its first element is the class itself) that won't ! be broken otherwise (it's a tuple and tuples don't have a ! tp_clear handler). None of the other fields need to be ! cleared, and here's why: ! tp_dict: ! It is a dict, so the collector will call its tp_clear. ! ! tp_cache: ! Not used; if it were, it would be a dict. ! ! tp_bases, tp_base: ! If these are involved in a cycle, there must be at least ! one other, mutable object in the cycle, e.g. a base ! class's dict; the cycle will be broken that way. ! ! tp_subclasses: ! A list of weak references can't be part of a cycle; and ! lists have their own tp_clear. ! ! slots (in etype): ! A tuple of strings can't be part of a cycle. ! */ ! ! CLEAR(type->tp_mro); #undef CLEAR From gvanrossum@users.sourceforge.net Mon Jun 10 19:52:04 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Mon, 10 Jun 2002 11:52:04 -0700 Subject: [Python-checkins] python/dist/src/Tools/idle Bindings.py,1.14,1.15 IOBinding.py,1.6,1.7 config-unix.txt,1.2,1.3 config-win.txt,1.1,1.2 keydefs.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/idle In directory usw-pr-cvs1:/tmp/cvs-serv5462 Modified Files: Bindings.py IOBinding.py config-unix.txt config-win.txt keydefs.py Log Message: Add primitive printing support for Unix and Windows. Index: Bindings.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/idle/Bindings.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Bindings.py 26 Aug 1999 23:06:22 -0000 1.14 --- Bindings.py 10 Jun 2002 18:52:02 -0000 1.15 *************** *** 24,27 **** --- 24,29 ---- ('Save Co_py As...', '<>'), None, + ('_Print window', '<>'), + None, ('_Close', '<>'), ('E_xit', '<>'), Index: IOBinding.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/idle/IOBinding.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** IOBinding.py 15 Apr 2002 00:19:12 -0000 1.6 --- IOBinding.py 10 Jun 2002 18:52:02 -0000 1.7 *************** *** 1,5 **** --- 1,7 ---- import os + import tempfile import tkFileDialog import tkMessageBox + from IdleConf import idleconf #$ event <> *************** *** 19,22 **** --- 21,28 ---- #$ unix + #$ event <> + #$ win + #$ unix + class IOBinding: *************** *** 31,34 **** --- 37,41 ---- self.__id_savecopy = self.text.bind("<>", self.save_a_copy) + self.__id_print = self.text.bind("<>", self.print_window) def close(self): *************** *** 38,41 **** --- 45,49 ---- self.text.unbind("<>",self.__id_saveas) self.text.unbind("<>", self.__id_savecopy) + self.text.unbind("<>", self.__id_print) # Break cycles self.editwin = None *************** *** 145,148 **** --- 153,180 ---- self.writefile(filename) self.text.focus_set() + return "break" + + def print_window(self, event): + tempfilename = None + if self.get_saved(): + filename = self.filename + else: + filename = tempfilename = tempfile.mktemp() + if not self.writefile(filename): + os.unlink(tempfilename) + return "break" + edconf = idleconf.getsection('EditorWindow') + command = edconf.get('print-command') + command = command % filename + if os.name == 'posix': + command = command + " 2>&1" + pipe = os.popen(command, "r") + output = pipe.read().strip() + status = pipe.close() + if status: + output = "Printing failed (exit status 0x%x)\n" % status + output + if output: + output = "Printing command: %s\n" % repr(command) + output + tkMessageBox.showerror("Print status", output, master=self.text) return "break" Index: config-unix.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/idle/config-unix.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** config-unix.txt 7 Mar 2000 17:56:47 -0000 1.2 --- config-unix.txt 10 Jun 2002 18:52:02 -0000 1.3 *************** *** 2,3 **** --- 2,4 ---- font-name= courier font-size= 10 + print-command=lpr %s Index: config-win.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/idle/config-win.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** config-win.txt 3 Mar 2000 22:57:42 -0000 1.1 --- config-win.txt 10 Jun 2002 18:52:02 -0000 1.2 *************** *** 2,3 **** --- 2,4 ---- font-name: courier new font-size: 10 + print-command=start /min notepad /p %s Index: keydefs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/idle/keydefs.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** keydefs.py 21 May 2002 12:26:59 -0000 1.4 --- keydefs.py 10 Jun 2002 18:52:02 -0000 1.5 *************** *** 18,21 **** --- 18,22 ---- '<>': [''], '<>': [''], + '<>': [''], '<>': [''], '<>': [''], *************** *** 47,50 **** --- 48,52 ---- '<>': [''], '<>': [''], + '<>': [''], '<>': ['', ''], '<>': [''], From akuchling@users.sourceforge.net Mon Jun 10 19:58:22 2002 From: akuchling@users.sourceforge.net (akuchling@users.sourceforge.net) Date: Mon, 10 Jun 2002 11:58:22 -0700 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew23.tex,1.22,1.23 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory usw-pr-cvs1:/tmp/cvs-serv7481 Modified Files: whatsnew23.tex Log Message: Tweak traceback message to avoid LaTeX2HTML bug Add a reminder Index: whatsnew23.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew23.tex,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** whatsnew23.tex 10 Jun 2002 15:53:05 -0000 1.22 --- whatsnew23.tex 10 Jun 2002 18:58:19 -0000 1.23 *************** *** 23,27 **** % getopt.gnu_getopt % ! %\section{Introduction \label{intro}} --- 23,28 ---- % getopt.gnu_getopt % ! % Docstrings now optional (with --without-doc-strings) ! % %\section{Introduction \label{intro}} *************** *** 515,519 **** >>> d.pop(4) Traceback (most recent call last): ! File ``'', line 1, in ? KeyError: 4 >>> d.pop(1) --- 516,520 ---- >>> d.pop(4) Traceback (most recent call last): ! File ``stdin'', line 1, in ? KeyError: 4 >>> d.pop(1) *************** *** 654,658 **** The author would like to thank the following people for offering suggestions, corrections and assistance with various drafts of this ! article: Michael Chermside, Fred~L. Drake, Jr., Detlef Lannert, Andrew MacIntyre. \end{document} --- 655,660 ---- The author would like to thank the following people for offering suggestions, corrections and assistance with various drafts of this ! article: Michael Chermside, Scott David Daniels, Fred~L. Drake, Jr., ! Detlef Lannert, Andrew MacIntyre. \end{document} From gvanrossum@users.sourceforge.net Mon Jun 10 20:22:58 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Mon, 10 Jun 2002 12:22:58 -0700 Subject: [Python-checkins] python/dist/src/Modules posixmodule.c,2.233,2.234 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv15640 Modified Files: posixmodule.c Log Message: SF bug 563750 (Alex Martelli): posix_tmpfile(): The file returned by tmpfile() has mode w+b, so use that in the call to PyFile_FromFile(). Bugfix candidate. Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.233 retrieving revision 2.234 diff -C2 -d -r2.233 -r2.234 *** posixmodule.c 4 May 2002 13:13:41 -0000 2.233 --- posixmodule.c 10 Jun 2002 19:22:56 -0000 2.234 *************** *** 5195,5199 **** if (fp == NULL) return posix_error(); ! return PyFile_FromFile(fp, "", "w+", fclose); } #endif --- 5195,5199 ---- if (fp == NULL) return posix_error(); ! return PyFile_FromFile(fp, "", "w+b", fclose); } #endif From gvanrossum@users.sourceforge.net Mon Jun 10 20:23:24 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Mon, 10 Jun 2002 12:23:24 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libos.tex,1.85,1.86 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv15783 Modified Files: libos.tex Log Message: SF bug 563750 (Alex Martelli): posix_tmpfile(): The file returned by tmpfile() has mode w+b, so use that in the call to PyFile_FromFile(). Bugfix candidate. Index: libos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.85 retrieving revision 1.86 diff -C2 -d -r1.85 -r1.86 *** libos.tex 10 May 2002 12:37:56 -0000 1.85 --- libos.tex 10 Jun 2002 19:23:22 -0000 1.86 *************** *** 313,317 **** \begin{funcdesc}{tmpfile}{} ! Return a new file object opened in update mode (\samp{w+}). The file has no directory entries associated with it and will be automatically deleted once there are no file descriptors for the file. --- 313,317 ---- \begin{funcdesc}{tmpfile}{} ! Return a new file object opened in update mode (\samp{w+b}). The file has no directory entries associated with it and will be automatically deleted once there are no file descriptors for the file. From gvanrossum@users.sourceforge.net Mon Jun 10 20:42:46 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Mon, 10 Jun 2002 12:42:46 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib librotor.tex,1.18,1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv22326 Modified Files: librotor.tex Log Message: Document that the key should not contain null bytes. Index: librotor.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/librotor.tex,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** librotor.tex 24 Jan 2001 17:19:07 -0000 1.18 --- librotor.tex 10 Jun 2002 19:42:43 -0000 1.19 *************** *** 30,34 **** \begin{funcdesc}{newrotor}{key\optional{, numrotors}} Return a rotor object. \var{key} is a string containing the encryption key ! for the object; it can contain arbitrary binary data. The key will be used to randomly generate the rotor permutations and their initial positions. \var{numrotors} is the number of rotor permutations in the returned object; --- 30,35 ---- \begin{funcdesc}{newrotor}{key\optional{, numrotors}} Return a rotor object. \var{key} is a string containing the encryption key ! for the object; it can contain arbitrary binary data but not null bytes. ! The key will be used to randomly generate the rotor permutations and their initial positions. \var{numrotors} is the number of rotor permutations in the returned object; *************** *** 39,43 **** \begin{methoddesc}[rotor]{setkey}{key} ! Sets the rotor's key to \var{key}. \end{methoddesc} --- 40,44 ---- \begin{methoddesc}[rotor]{setkey}{key} ! Sets the rotor's key to \var{key}. The key should not contain null bytes. \end{methoddesc} From gvanrossum@users.sourceforge.net Mon Jun 10 20:46:26 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Mon, 10 Jun 2002 12:46:26 -0700 Subject: [Python-checkins] python/dist/src/Modules rotormodule.c,2.33,2.34 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv23969 Modified Files: rotormodule.c Log Message: Don't accept null bytes in the key. Index: rotormodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/rotormodule.c,v retrieving revision 2.33 retrieving revision 2.34 diff -C2 -d -r2.33 -r2.34 *** rotormodule.c 31 Mar 2002 15:27:00 -0000 2.33 --- rotormodule.c 10 Jun 2002 19:46:18 -0000 2.34 *************** *** 598,605 **** Rotorobj *r; char *string; - int len; int num_rotors = 6; ! if (!PyArg_ParseTuple(args, "s#|i:newrotor", &string, &len, &num_rotors)) return NULL; --- 598,604 ---- Rotorobj *r; char *string; int num_rotors = 6; ! if (!PyArg_ParseTuple(args, "s|i:newrotor", &string, &num_rotors)) return NULL; From gvanrossum@users.sourceforge.net Mon Jun 10 20:59:09 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Mon, 10 Jun 2002 12:59:09 -0700 Subject: [Python-checkins] python/dist/src/Lib weakref.py,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv29511 Modified Files: weakref.py Log Message: SF patch 564549 (Erik Andersén). The WeakKeyDictionary constructor didn't work when a dict arg was given. Fixed by moving a line. Also adding a unit test. Bugfix candidate. Index: weakref.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/weakref.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** weakref.py 1 Jun 2002 14:18:47 -0000 1.16 --- weakref.py 10 Jun 2002 19:59:04 -0000 1.17 *************** *** 145,149 **** def __init__(self, dict=None): self.data = {} - if dict is not None: self.update(dict) def remove(k, selfref=ref(self)): self = selfref() --- 145,148 ---- *************** *** 151,154 **** --- 150,154 ---- del self.data[k] self._remove = remove + if dict is not None: self.update(dict) def __delitem__(self, key): From gvanrossum@users.sourceforge.net Mon Jun 10 21:00:16 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Mon, 10 Jun 2002 13:00:16 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_weakref.py,1.18,1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv30086 Modified Files: test_weakref.py Log Message: SF patch 564549 (Erik Andersén). The WeakKeyDictionary constructor didn't work when a dict arg was given. Fixed by moving a line. Also adding a unit test. Bugfix candidate. Index: test_weakref.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_weakref.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** test_weakref.py 11 Apr 2002 03:59:42 -0000 1.18 --- test_weakref.py 10 Jun 2002 20:00:14 -0000 1.19 *************** *** 392,395 **** --- 392,406 ---- self.assert_(len(values) == 0, "itervalues() did not touch all values") + def test_make_weak_keyed_dict_from_dict(self): + o = Object(3) + dict = weakref.WeakKeyDictionary({o:364}) + self.assert_(dict[o] == 364) + + def test_make_weak_keyed_dict_from_weak_keyed_dict(self): + o = Object(3) + dict = weakref.WeakKeyDictionary({o:364}) + dict2 = weakref.WeakKeyDictionary(dict) + self.assert_(dict[o] == 364) + def make_weak_keyed_dict(self): dict = weakref.WeakKeyDictionary() From gvanrossum@users.sourceforge.net Mon Jun 10 21:00:55 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Mon, 10 Jun 2002 13:00:55 -0700 Subject: [Python-checkins] python/dist/src/Misc ACKS,1.179,1.180 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv30604 Modified Files: ACKS Log Message: SF patch 564549 (Erik Andersén). The WeakKeyDictionary constructor didn't work when a dict arg was given. Fixed by moving a line. Also adding a unit test. Bugfix candidate. Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.179 retrieving revision 1.180 diff -C2 -d -r1.179 -r1.180 *** ACKS 7 Jun 2002 15:58:53 -0000 1.179 --- ACKS 10 Jun 2002 20:00:52 -0000 1.180 *************** *** 17,20 **** --- 17,21 ---- Mark Anacker Anders Andersen + Erik Andersén Oliver Andrich Ross Andrus From theller@users.sourceforge.net Mon Jun 10 21:05:51 2002 From: theller@users.sourceforge.net (theller@users.sourceforge.net) Date: Mon, 10 Jun 2002 13:05:51 -0700 Subject: [Python-checkins] python/dist/src/Tools/freeze modulefinder.py,1.18,1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/freeze In directory usw-pr-cvs1:/tmp/cvs-serv434 Modified Files: modulefinder.py Log Message: Remove the only use of a string method. Fixes SF 564840. Index: modulefinder.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/freeze/modulefinder.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** modulefinder.py 18 Oct 2001 19:15:32 -0000 1.18 --- modulefinder.py 10 Jun 2002 20:05:48 -0000 1.19 *************** *** 358,362 **** def find_module(self, name, path): if path: ! fullname = '.'.join(path)+'.'+name else: fullname = name --- 358,362 ---- def find_module(self, name, path): if path: ! fullname = string.join(path, '.')+'.'+name else: fullname = name From gward@users.sourceforge.net Mon Jun 10 21:26:04 2002 From: gward@users.sourceforge.net (gward@users.sourceforge.net) Date: Mon, 10 Jun 2002 13:26:04 -0700 Subject: [Python-checkins] python/dist/src/Lib textwrap.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv9172 Modified Files: textwrap.py Log Message: Make 'width' an instance attribute rather than an argument to the wrap() and fill() methods. Keep interface of existing wrap() and fill() functions by going back to having them construct a new TextWrapper instance on each call, with the preferred width passed to the constructor. Index: textwrap.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/textwrap.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** textwrap.py 9 Jun 2002 00:22:07 -0000 1.8 --- textwrap.py 10 Jun 2002 20:26:02 -0000 1.9 *************** *** 19,24 **** you'll probably have to override _wrap_chunks(). ! Several boolean instance attributes control various aspects of ! wrapping: expand_tabs (default: true) Expand tabs in input text to spaces before further processing. --- 19,26 ---- you'll probably have to override _wrap_chunks(). ! Several instance attributes control various aspects of wrapping: ! width (default: 70) ! the maximum width of wrapped lines (unless break_long_words ! is false) expand_tabs (default: true) Expand tabs in input text to spaces before further processing. *************** *** 35,41 **** (unavoidably) imperfect. break_long_words (default: true) ! Break words longer than the line width constraint. If false, ! those words will not be broken, and some lines might be longer ! than the width constraint. """ --- 37,42 ---- (unavoidably) imperfect. break_long_words (default: true) ! Break words longer than 'width'. If false, those words will not ! be broken, and some lines might be longer than 'width'. """ *************** *** 62,69 **** --- 63,72 ---- def __init__ (self, + width=70, expand_tabs=True, replace_whitespace=True, fix_sentence_endings=False, break_long_words=True): + self.width = width self.expand_tabs = expand_tabs self.replace_whitespace = replace_whitespace *************** *** 122,134 **** i += 1 ! def _handle_long_word(self, chunks, cur_line, cur_len, width): """_handle_long_word(chunks : [string], cur_line : [string], ! cur_len : int, width : int) Handle a chunk of text (most likely a word, not whitespace) that is too long to fit in any line. """ ! space_left = width - cur_len # If we're allowed to break long words, then do so: put as much --- 125,137 ---- i += 1 ! def _handle_long_word(self, chunks, cur_line, cur_len): """_handle_long_word(chunks : [string], cur_line : [string], ! cur_len : int) Handle a chunk of text (most likely a word, not whitespace) that is too long to fit in any line. """ ! space_left = self.width - cur_len # If we're allowed to break long words, then do so: put as much *************** *** 150,167 **** # devoted to the long word that we can't handle right now. ! def _wrap_chunks(self, chunks, width): ! """_wrap_chunks(chunks : [string], width : int) -> [string] Wrap a sequence of text chunks and return a list of lines of ! length 'width' or less. (If 'break_long_words' is false, some ! lines may be longer than 'width'.) Chunks correspond roughly to ! words and the whitespace between them: each chunk is indivisible ! (modulo 'break_long_words'), but a line break can come between ! any two chunks. Chunks should not have internal whitespace; ! ie. a chunk is either all whitespace or a "word". Whitespace ! chunks will be removed from the beginning and end of lines, but ! apart from that whitespace is preserved. """ lines = [] while chunks: --- 153,171 ---- # devoted to the long word that we can't handle right now. ! def _wrap_chunks(self, chunks): ! """_wrap_chunks(chunks : [string]) -> [string] Wrap a sequence of text chunks and return a list of lines of ! length 'self.width' or less. (If 'break_long_words' is false, ! some lines may be longer than this.) Chunks correspond roughly ! to words and the whitespace between them: each chunk is ! indivisible (modulo 'break_long_words'), but a line break can ! come between any two chunks. Chunks should not have internal ! whitespace; ie. a chunk is either all whitespace or a "word". ! Whitespace chunks will be removed from the beginning and end of ! lines, but apart from that whitespace is preserved. """ lines = [] + width = self.width while chunks: *************** *** 189,193 **** # fit on *any* line (not just this one). if chunks and len(chunks[0]) > width: ! self._handle_long_word(chunks, cur_line, cur_len, width) # If the last chunk on this line is all whitespace, drop it. --- 193,197 ---- # fit on *any* line (not just this one). if chunks and len(chunks[0]) > width: ! self._handle_long_word(chunks, cur_line, cur_len) # If the last chunk on this line is all whitespace, drop it. *************** *** 205,212 **** # -- Public interface ---------------------------------------------- ! def wrap(self, text, width): ! """wrap(text : string, width : int) -> [string] ! Split 'text' into multiple lines of no more than 'width' characters each, and return the list of strings that results. Tabs in 'text' are expanded with string.expandtabs(), and all --- 209,216 ---- # -- Public interface ---------------------------------------------- ! def wrap(self, text): ! """wrap(text : string) -> [string] ! Split 'text' into multiple lines of no more than 'self.width' characters each, and return the list of strings that results. Tabs in 'text' are expanded with string.expandtabs(), and all *************** *** 215,228 **** """ text = self._munge_whitespace(text) ! if len(text) <= width: return [text] chunks = self._split(text) if self.fix_sentence_endings: self._fix_sentence_endings(chunks) ! return self._wrap_chunks(chunks, width) ! def fill(self, text, width, initial_tab="", subsequent_tab=""): """fill(text : string, - width : int, initial_tab : string = "", subsequent_tab : string = "") --- 219,231 ---- """ text = self._munge_whitespace(text) ! if len(text) <= self.width: return [text] chunks = self._split(text) if self.fix_sentence_endings: self._fix_sentence_endings(chunks) ! return self._wrap_chunks(chunks) ! def fill(self, text, initial_tab="", subsequent_tab=""): """fill(text : string, initial_tab : string = "", subsequent_tab : string = "") *************** *** 235,239 **** to fit in 'width' columns. """ ! lines = self.wrap(text, width) sep = "\n" + subsequent_tab return initial_tab + sep.join(lines) --- 238,242 ---- to fit in 'width' columns. """ ! lines = self.wrap(text) sep = "\n" + subsequent_tab return initial_tab + sep.join(lines) *************** *** 242,250 **** # Convenience interface - _wrapper = TextWrapper() - def wrap(text, width): ! return _wrapper.wrap(text, width) def fill(text, width, initial_tab="", subsequent_tab=""): ! return _wrapper.fill(text, width, initial_tab, subsequent_tab) --- 245,251 ---- # Convenience interface def wrap(text, width): ! return TextWrapper(width=width).wrap(text) def fill(text, width, initial_tab="", subsequent_tab=""): ! return TextWrapper(width=width).fill(text, initial_tab, subsequent_tab) From gward@users.sourceforge.net Mon Jun 10 21:36:10 2002 From: gward@users.sourceforge.net (gward@users.sourceforge.net) Date: Mon, 10 Jun 2002 13:36:10 -0700 Subject: [Python-checkins] python/dist/src/Lib textwrap.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv15481 Modified Files: textwrap.py Log Message: Allow the standalone wrap() and fill() functions to take arbitrary keyword args, which are passed directly to the TextWrapper constructor. Index: textwrap.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/textwrap.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** textwrap.py 10 Jun 2002 20:26:02 -0000 1.9 --- textwrap.py 10 Jun 2002 20:36:07 -0000 1.10 *************** *** 245,251 **** # Convenience interface ! def wrap(text, width): ! return TextWrapper(width=width).wrap(text) ! def fill(text, width, initial_tab="", subsequent_tab=""): ! return TextWrapper(width=width).fill(text, initial_tab, subsequent_tab) --- 245,253 ---- # Convenience interface ! def wrap(text, width=70, **kwargs): ! w = TextWrapper(width=width, **kwargs) ! return w.wrap(text) ! def fill(text, width=70, initial_tab="", subsequent_tab="", **kwargs): ! w = TextWrapper(width=width, **kwargs) ! return w.fill(text, initial_tab, subsequent_tab) From gvanrossum@users.sourceforge.net Mon Jun 10 22:10:30 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Mon, 10 Jun 2002 14:10:30 -0700 Subject: [Python-checkins] python/dist/src/Lib copy.py,1.27,1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv27967 Modified Files: copy.py Log Message: SF patch 560794 (Greg Chapman): deepcopy can't handle custom metaclasses. This is essentially the same problem as that reported in bug 494904 for pickle: deepcopy should treat instances of custom metaclasses the same way it treats instances of type 'type'. Bugfix candidate. Index: copy.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/copy.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** copy.py 6 Jun 2002 17:41:20 -0000 1.27 --- copy.py 10 Jun 2002 21:10:27 -0000 1.28 *************** *** 165,179 **** except KeyError: try: ! copier = x.__deepcopy__ ! except AttributeError: try: ! reductor = x.__reduce__ except AttributeError: ! raise error, \ ! "un-deep-copyable object of type %s" % type(x) else: ! y = _reconstruct(x, reductor(), 1, memo) ! else: ! y = copier(memo) else: y = copierfunction(x, memo) --- 165,186 ---- except KeyError: try: ! issc = issubclass(type(x), type) ! except TypeError: ! issc = 0 ! if issc: ! y = _deepcopy_dispatch[type](x, memo) ! else: try: ! copier = x.__deepcopy__ except AttributeError: ! try: ! reductor = x.__reduce__ ! except AttributeError: ! raise error, \ ! "un-deep-copyable object of type %s" % type(x) ! else: ! y = _reconstruct(x, reductor(), 1, memo) else: ! y = copier(memo) else: y = copierfunction(x, memo) From gvanrossum@users.sourceforge.net Mon Jun 10 22:24:31 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Mon, 10 Jun 2002 14:24:31 -0700 Subject: [Python-checkins] python/nondist/peps pep-0042.txt,1.58,1.59 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv32728 Modified Files: pep-0042.txt Log Message: Added another wish. Removed a bunch of fulfilled wishes (no guarantee that I caught all of 'em). Index: pep-0042.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0042.txt,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** pep-0042.txt 2 Apr 2002 23:13:08 -0000 1.58 --- pep-0042.txt 10 Jun 2002 21:24:27 -0000 1.59 *************** *** 59,72 **** http://www.python.org/sf/210835 - - Add C API functions to help Windows users who are building - embedded applications where the FILE * structure does not match - the FILE * the interpreter was compiled with. - - http://www.python.org/sf/210821 - - See this bug report for a specific suggestion that will allow a - Borland C++ builder application to interact with a python.dll - build with MSVC. - - The parser should handle more deeply nested parse trees. --- 59,62 ---- *************** *** 107,121 **** http://www.python.org/sf/210619 - - Use objects with attributes in place of tuples of values for - return values in several places in the library. Two specific - APIs which could use this treatment include os.stat() and - os.statvfs(); see SourceForge bug #111481: - - http://www.python.org/sf/211481 - - which shows very specifically why this approach is better than - the tuple approach: additional attributes can be added as needed - without having as detrimental an affect on existing code. - - os.rename() should be modified to handle EXDEV errors on platforms that don't allow rename() to operate across filesystem --- 97,100 ---- *************** *** 142,154 **** http://www.python.org/sf/214557 - - Port the Python SSL code to Windows. - - http://www.python.org/sf/210683 - - Extend Windows utime to accept directory paths. http://www.python.org/sf/214245 ! - Extend copy.py to class, module & function types. http://www.python.org/sf/214553 --- 121,129 ---- http://www.python.org/sf/214557 - Extend Windows utime to accept directory paths. http://www.python.org/sf/214245 ! - Extend copy.py to module & function types. http://www.python.org/sf/214553 *************** *** 168,171 **** --- 143,150 ---- http://www.python.org/sf/212244 + Possible solution: + + http://www.python.org/sf/474274 + - rfc822.py should be more lenient than the spec in the types of address fields it parses. Specifically, an invalid address of *************** *** 238,246 **** http://www.python.org/sf/210838 - - Could use a more comprehensive email module. (But then again, - that may be better done as a 3rd party project.) - - http://www.python.org/sf/221208 - - every built-in function or method (including all core extensions) that accepts a string, dict, or list, should also --- 217,220 ---- *************** *** 254,261 **** http://www.python.org/sf/426539 - - New math module radians() and degrees() functions. - - http://www.python.org/sf/426539 - - Jim Fulton suggested the following: --- 228,231 ---- *************** *** 291,328 **** ! Tools ! - IDLE should reload & recompile modules changed externally. To ! be done properly, scripts will have to be run in a separate ! process. ! http://www.python.org/sf/210841 ! - Python could use a GUI builder. ! http://www.python.org/sf/210820 ! - IDLE's key bindings should be revised. Some of the advertised ! bindings don't even work! ! http://www.python.org/sf/210659 ! - IDLE has deep problems running threaded programs. Re-architect. ! http://www.python.org/sf/221963 - - Would be nice if IDLE showed which structure was being closed upon - typing one of "})]". Heck, a string too, for that matter. - The bug report also says something about TAB I didn't grok. ! http://www.python.org/sf/404444 ! Building and Installing ! - You should be able to configure and build Python with a ! cross-compiler. ! http://www.python.org/sf/210836 - Modules/makesetup should make sure the 'config.c' file it --- 261,308 ---- ! C API wishes ! - Add C API functions to help Windows users who are building ! embedded applications where the FILE * structure does not match ! the FILE * the interpreter was compiled with. ! http://www.python.org/sf/210821 ! See this bug report for a specific suggestion that will allow a ! Borland C++ builder application to interact with a python.dll ! build with MSVC. ! - Add unsigneds to ParseTuple/BuildValue (due to David Beazley) ! Since "integers" can now have arbitrary precision and can ! represent large unsigned values, can you add three new format ! characters to PyArg_ParseTuple() and Py_BuildValue() for the C ! datatypes "unsigned int", "unsigned long", and "unsigned long ! long"? ! The "u" and "l" namespace is a little crowded (and I don't think ! you would want to break that). However, here's one idea: ! 'I' - unsigned int (consistent with H and B) ! 'p' - unsigned long ('p' is for positive) ! 'P' - unsigned long long ! http://www.python.org/sf/454896 ! Tools + - IDLE should reload & recompile modules changed externally. To + be done properly, scripts will have to be run in a separate + process. ! http://www.python.org/sf/210841 ! - Python could use a GUI builder. ! http://www.python.org/sf/210820 ! ! ! Building and Installing - Modules/makesetup should make sure the 'config.c' file it *************** *** 349,357 **** http://www.python.org/sf/219221 - - - There should be at least an option to build Python as a shared - library. - - http://www.python.org/sf/400938 --- 329,332 ---- From gvanrossum@users.sourceforge.net Mon Jun 10 22:37:02 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Mon, 10 Jun 2002 14:37:02 -0700 Subject: [Python-checkins] python/dist/src/Lib copy.py,1.22.10.3,1.22.10.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv5115 Modified Files: Tag: release22-maint copy.py Log Message: Backport: SF patch 560794 (Greg Chapman): deepcopy can't handle custom metaclasses. This is essentially the same problem as that reported in bug 494904 for pickle: deepcopy should treat instances of custom metaclasses the same way it treats instances of type 'type'. Index: copy.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/copy.py,v retrieving revision 1.22.10.3 retrieving revision 1.22.10.4 diff -C2 -d -r1.22.10.3 -r1.22.10.4 *** copy.py 6 Jun 2002 17:55:35 -0000 1.22.10.3 --- copy.py 10 Jun 2002 21:37:00 -0000 1.22.10.4 *************** *** 165,179 **** except KeyError: try: ! copier = x.__deepcopy__ ! except AttributeError: try: ! reductor = x.__reduce__ except AttributeError: ! raise error, \ ! "un-deep-copyable object of type %s" % type(x) else: ! y = _reconstruct(x, reductor(), 1, memo) ! else: ! y = copier(memo) else: y = copierfunction(x, memo) --- 165,186 ---- except KeyError: try: ! issc = issubclass(type(x), type) ! except TypeError: ! issc = 0 ! if issc: ! y = _deepcopy_dispatch[type](x, memo) ! else: try: ! copier = x.__deepcopy__ except AttributeError: ! try: ! reductor = x.__reduce__ ! except AttributeError: ! raise error, \ ! "un-deep-copyable object of type %s" % type(x) ! else: ! y = _reconstruct(x, reductor(), 1, memo) else: ! y = copier(memo) else: y = copierfunction(x, memo) From gward@users.sourceforge.net Mon Jun 10 22:37:14 2002 From: gward@users.sourceforge.net (gward@users.sourceforge.net) Date: Mon, 10 Jun 2002 14:37:14 -0700 Subject: [Python-checkins] python/dist/src/Lib textwrap.py,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv4540 Modified Files: textwrap.py Log Message: Took initial_tab and subsequent_tab away from the fill() method and transformed them into the initial_indent and subsequent_indent instance attributes. Now they actually work as advertised, ie. they are accounted for in the width of each output line. Plus you can use them with wrap() as well as fill(), and fill() went from simple-and-broken to trivial-and-working. Index: textwrap.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/textwrap.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** textwrap.py 10 Jun 2002 20:36:07 -0000 1.10 --- textwrap.py 10 Jun 2002 21:37:12 -0000 1.11 *************** *** 23,26 **** --- 23,32 ---- the maximum width of wrapped lines (unless break_long_words is false) + initial_indent (default: "") + string that will be prepended to the first line of wrapped + output. Counts towards the line's width. + subsequent_indent (default: "") + string that will be prepended to all lines save the first + of wrapped output; also counts towards each line's width. expand_tabs (default: true) Expand tabs in input text to spaces before further processing. *************** *** 64,67 **** --- 70,75 ---- def __init__ (self, width=70, + initial_indent="", + subsequent_indent="", expand_tabs=True, replace_whitespace=True, *************** *** 69,72 **** --- 77,82 ---- break_long_words=True): self.width = width + self.initial_indent = initial_indent + self.subsequent_indent = subsequent_indent self.expand_tabs = expand_tabs self.replace_whitespace = replace_whitespace *************** *** 125,137 **** i += 1 ! def _handle_long_word(self, chunks, cur_line, cur_len): """_handle_long_word(chunks : [string], cur_line : [string], ! cur_len : int) Handle a chunk of text (most likely a word, not whitespace) that is too long to fit in any line. """ ! space_left = self.width - cur_len # If we're allowed to break long words, then do so: put as much --- 135,147 ---- i += 1 ! def _handle_long_word(self, chunks, cur_line, cur_len, width): """_handle_long_word(chunks : [string], cur_line : [string], ! cur_len : int, width : int) Handle a chunk of text (most likely a word, not whitespace) that is too long to fit in any line. """ ! space_left = width - cur_len # If we're allowed to break long words, then do so: put as much *************** *** 167,176 **** """ lines = [] - width = self.width while chunks: ! cur_line = [] # list of chunks (to-be-joined) ! cur_len = 0 # length of current line # First chunk on line is whitespace -- drop it. --- 177,196 ---- """ lines = [] while chunks: ! # Start the list of chunks that will make up the current line. ! # cur_len is just the length of all the chunks in cur_line. ! cur_line = [] ! cur_len = 0 ! ! # Figure out which static string will prefix this line. ! if lines: ! indent = self.subsequent_indent ! else: ! indent = self.initial_indent ! ! # Maximum width for this line. ! width = self.width - len(indent) # First chunk on line is whitespace -- drop it. *************** *** 193,197 **** # fit on *any* line (not just this one). if chunks and len(chunks[0]) > width: ! self._handle_long_word(chunks, cur_line, cur_len) # If the last chunk on this line is all whitespace, drop it. --- 213,217 ---- # fit on *any* line (not just this one). if chunks and len(chunks[0]) > width: ! self._handle_long_word(chunks, cur_line, cur_len, width) # If the last chunk on this line is all whitespace, drop it. *************** *** 202,206 **** # of all lines (return value). if cur_line: ! lines.append(''.join(cur_line)) return lines --- 222,226 ---- # of all lines (return value). if cur_line: ! lines.append(indent + ''.join(cur_line)) return lines *************** *** 226,244 **** return self._wrap_chunks(chunks) ! def fill(self, text, initial_tab="", subsequent_tab=""): ! """fill(text : string, ! initial_tab : string = "", ! subsequent_tab : string = "") ! -> string Reformat the paragraph in 'text' to fit in lines of no more than ! 'width' columns. The first line is prefixed with 'initial_tab', ! and subsequent lines are prefixed with 'subsequent_tab'; the ! lengths of the tab strings are accounted for when wrapping lines ! to fit in 'width' columns. """ ! lines = self.wrap(text) ! sep = "\n" + subsequent_tab ! return initial_tab + sep.join(lines) --- 246,256 ---- return self._wrap_chunks(chunks) ! def fill(self, text): ! """fill(text : string) -> string Reformat the paragraph in 'text' to fit in lines of no more than ! 'width' columns. """ ! return "\n".join(self.wrap(text)) *************** *** 249,253 **** return w.wrap(text) ! def fill(text, width=70, initial_tab="", subsequent_tab="", **kwargs): w = TextWrapper(width=width, **kwargs) ! return w.fill(text, initial_tab, subsequent_tab) --- 261,265 ---- return w.wrap(text) ! def fill(text, width=70, **kwargs): w = TextWrapper(width=width, **kwargs) ! return w.fill(text) From gvanrossum@users.sourceforge.net Mon Jun 10 22:39:44 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Mon, 10 Jun 2002 14:39:44 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.420,1.421 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv6259 Modified Files: NEWS Log Message: Record the latest fixes. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.420 retrieving revision 1.421 diff -C2 -d -r1.420 -r1.421 *** NEWS 9 Jun 2002 13:33:54 -0000 1.420 --- NEWS 10 Jun 2002 21:39:42 -0000 1.421 *************** *** 7,10 **** --- 7,13 ---- Core and builtins + - Cycles going through the __class__ link of a new-style instance are + now detected by the garbage collector. + - Classes using __slots__ are now properly garbage collected. [SF bug 519621] *************** *** 130,133 **** --- 133,142 ---- Library + + - Some fixes in the copy module: when an object is copied through its + __reduce__ method, there was no check for a __setstate__ method on + the result [SF patch 565085]; deepcopy should treat instances of + custom metaclasses the same way it treats instances of type 'type' + [SF patch 560794]. - Sockets now support timeout mode. After s.settimeout(T), where T is From gvanrossum@users.sourceforge.net Mon Jun 10 22:40:04 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Mon, 10 Jun 2002 14:40:04 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.337.2.4.2.26,1.337.2.4.2.27 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv6397 Modified Files: Tag: release22-maint NEWS Log Message: Record the latest fixes. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.337.2.4.2.26 retrieving revision 1.337.2.4.2.27 diff -C2 -d -r1.337.2.4.2.26 -r1.337.2.4.2.27 *** NEWS 4 Jun 2002 21:19:55 -0000 1.337.2.4.2.26 --- NEWS 10 Jun 2002 21:40:01 -0000 1.337.2.4.2.27 *************** *** 5,8 **** --- 5,11 ---- Core and builtins + - Cycles going through the __class__ link of a new-style instance are + now detected by the garbage collector. + - Classes using __slots__ are now properly garbage collected. [SF bug 519621] *************** *** 27,30 **** --- 30,39 ---- Library + + - Some fixes in the copy module: when an object is copied through its + __reduce__ method, there was no check for a __setstate__ method on + the result [SF patch 565085]; deepcopy should treat instances of + custom metaclasses the same way it treats instances of type 'type' + [SF patch 560794]. From fdrake@users.sourceforge.net Tue Jun 11 03:57:34 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Mon, 10 Jun 2002 19:57:34 -0700 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.156.4.1.2.2,1.156.4.1.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory usw-pr-cvs1:/tmp/cvs-serv26570/tut Modified Files: Tag: release22-maint tut.tex Log Message: Completely revise markup for the list of list methods; the new markup matches the semantics and presentation used in the library reference. Added an explanation of the use of [...] to denote optional arguments, since this is the only use of this in a signature line. Closes SF bug #567127. Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.156.4.1.2.2 retrieving revision 1.156.4.1.2.3 diff -C2 -d -r1.156.4.1.2.2 -r1.156.4.1.2.3 *** tut.tex 8 Mar 2002 01:01:23 -0000 1.156.4.1.2.2 --- tut.tex 11 Jun 2002 02:57:32 -0000 1.156.4.1.2.3 *************** *** 1619,1661 **** of list objects: ! \begin{description} ! ! \item[\code{append(x)}] Add an item to the end of the list; ! equivalent to \code{a[len(a):] = [x]}. ! \item[\code{extend(L)}] Extend the list by appending all the items in the given list; ! equivalent to \code{a[len(a):] = L}. ! \item[\code{insert(i, x)}] ! Insert an item at a given position. The first argument is the index of ! the element before which to insert, so \code{a.insert(0, x)} inserts at ! the front of the list, and \code{a.insert(len(a), x)} is equivalent to ! \code{a.append(x)}. ! \item[\code{remove(x)}] ! Remove the first item from the list whose value is \code{x}. It is an error if there is no such item. ! \item[\code{pop(\optional{i})}] Remove the item at the given position in the list, and return it. If no index is specified, \code{a.pop()} returns the last item in the ! list. The item is also removed from the list. ! \item[\code{index(x)}] ! Return the index in the list of the first item whose value is \code{x}. It is an error if there is no such item. ! \item[\code{count(x)}] ! Return the number of times \code{x} appears in the list. ! \item[\code{sort()}] Sort the items of the list, in place. ! \item[\code{reverse()}] Reverse the elements of the list, in place. ! ! \end{description} An example that uses most of the list methods: --- 1619,1670 ---- of list objects: ! \begin{methoddesc}[list]{append}{x} Add an item to the end of the list; ! equivalent to \code{a[len(a):] = [\var{x}]}. ! \end{methoddesc} ! \begin{methoddesc}[list]{extend}{L} Extend the list by appending all the items in the given list; ! equivalent to \code{a[len(a):] = \var{L}}. ! \end{methoddesc} ! \begin{methoddesc}[list]{insert}{i, x} ! Insert an item at a given position. The first argument is the index ! of the element before which to insert, so \code{a.insert(0, \var{x})} ! inserts at the front of the list, and \code{a.insert(len(a), \var{x})} ! is equivalent to \code{a.append(\var{x})}. ! \end{methoddesc} ! \begin{methoddesc}[list]{remove}{x} ! Remove the first item from the list whose value is \var{x}. It is an error if there is no such item. + \end{methoddesc} ! \begin{methoddesc}[list]{pop}{\optional{i}} Remove the item at the given position in the list, and return it. If no index is specified, \code{a.pop()} returns the last item in the ! list. The item is also removed from the list. (The square brackets ! around the \var{i} in the method signature denote that the parameter ! is optional, not that you should type square brackets at that ! position. You will see this notation frequently in the ! \citetitle[../lib/lib.html]{Python Library Reference}.) ! \end{methoddesc} ! \begin{methoddesc}[list]{index}{x} ! Return the index in the list of the first item whose value is \var{x}. It is an error if there is no such item. + \end{methoddesc} ! \begin{methoddesc}[list]{count}{x} ! Return the number of times \var{x} appears in the list. ! \end{methoddesc} ! \begin{methoddesc}[list]{sort}{} Sort the items of the list, in place. + \end{methoddesc} ! \begin{methoddesc}[list]{reverse}{} Reverse the elements of the list, in place. ! \end{methoddesc} An example that uses most of the list methods: From fdrake@users.sourceforge.net Tue Jun 11 03:58:29 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Mon, 10 Jun 2002 19:58:29 -0700 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.133.2.6,1.133.2.7 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory usw-pr-cvs1:/tmp/cvs-serv26742/tut Modified Files: Tag: release21-maint tut.tex Log Message: Completely revise markup for the list of list methods; the new markup matches the semantics and presentation used in the library reference. Added an explanation of the use of [...] to denote optional arguments, since this is the only use of this in a signature line. Closes SF bug #567127. Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.133.2.6 retrieving revision 1.133.2.7 diff -C2 -d -r1.133.2.6 -r1.133.2.7 *** tut.tex 8 Mar 2002 01:01:50 -0000 1.133.2.6 --- tut.tex 11 Jun 2002 02:58:26 -0000 1.133.2.7 *************** *** 1582,1624 **** of list objects: ! \begin{description} ! ! \item[\code{append(x)}] Add an item to the end of the list; ! equivalent to \code{a[len(a):] = [x]}. ! \item[\code{extend(L)}] Extend the list by appending all the items in the given list; ! equivalent to \code{a[len(a):] = L}. ! \item[\code{insert(i, x)}] ! Insert an item at a given position. The first argument is the index of ! the element before which to insert, so \code{a.insert(0, x)} inserts at ! the front of the list, and \code{a.insert(len(a), x)} is equivalent to ! \code{a.append(x)}. ! \item[\code{remove(x)}] ! Remove the first item from the list whose value is \code{x}. It is an error if there is no such item. ! \item[\code{pop(\optional{i})}] Remove the item at the given position in the list, and return it. If no index is specified, \code{a.pop()} returns the last item in the ! list. The item is also removed from the list. ! \item[\code{index(x)}] ! Return the index in the list of the first item whose value is \code{x}. It is an error if there is no such item. ! \item[\code{count(x)}] ! Return the number of times \code{x} appears in the list. ! \item[\code{sort()}] Sort the items of the list, in place. ! \item[\code{reverse()}] Reverse the elements of the list, in place. ! ! \end{description} An example that uses most of the list methods: --- 1582,1633 ---- of list objects: ! \begin{methoddesc}[list]{append}{x} Add an item to the end of the list; ! equivalent to \code{a[len(a):] = [\var{x}]}. ! \end{methoddesc} ! \begin{methoddesc}[list]{extend}{L} Extend the list by appending all the items in the given list; ! equivalent to \code{a[len(a):] = \var{L}}. ! \end{methoddesc} ! \begin{methoddesc}[list]{insert}{i, x} ! Insert an item at a given position. The first argument is the index ! of the element before which to insert, so \code{a.insert(0, \var{x})} ! inserts at the front of the list, and \code{a.insert(len(a), \var{x})} ! is equivalent to \code{a.append(\var{x})}. ! \end{methoddesc} ! \begin{methoddesc}[list]{remove}{x} ! Remove the first item from the list whose value is \var{x}. It is an error if there is no such item. + \end{methoddesc} ! \begin{methoddesc}[list]{pop}{\optional{i}} Remove the item at the given position in the list, and return it. If no index is specified, \code{a.pop()} returns the last item in the ! list. The item is also removed from the list. (The square brackets ! around the \var{i} in the method signature denote that the parameter ! is optional, not that you should type square brackets at that ! position. You will see this notation frequently in the ! \citetitle[../lib/lib.html]{Python Library Reference}.) ! \end{methoddesc} ! \begin{methoddesc}[list]{index}{x} ! Return the index in the list of the first item whose value is \var{x}. It is an error if there is no such item. + \end{methoddesc} ! \begin{methoddesc}[list]{count}{x} ! Return the number of times \var{x} appears in the list. ! \end{methoddesc} ! \begin{methoddesc}[list]{sort}{} Sort the items of the list, in place. + \end{methoddesc} ! \begin{methoddesc}[list]{reverse}{} Reverse the elements of the list, in place. ! \end{methoddesc} An example that uses most of the list methods: From fdrake@users.sourceforge.net Tue Jun 11 03:56:20 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Mon, 10 Jun 2002 19:56:20 -0700 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.162,1.163 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory usw-pr-cvs1:/tmp/cvs-serv26266/tut Modified Files: tut.tex Log Message: Completely revise markup for the list of list methods; the new markup matches the semantics and presentation used in the library reference. Added an explanation of the use of [...] to denote optional arguments, since this is the only use of this in a signature line. Closes SF bug #567127. Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.162 retrieving revision 1.163 diff -C2 -d -r1.162 -r1.163 *** tut.tex 29 May 2002 15:54:55 -0000 1.162 --- tut.tex 11 Jun 2002 02:56:17 -0000 1.163 *************** *** 1619,1661 **** of list objects: ! \begin{description} ! ! \item[\code{append(x)}] Add an item to the end of the list; ! equivalent to \code{a[len(a):] = [x]}. ! \item[\code{extend(L)}] Extend the list by appending all the items in the given list; ! equivalent to \code{a[len(a):] = L}. ! \item[\code{insert(i, x)}] ! Insert an item at a given position. The first argument is the index of ! the element before which to insert, so \code{a.insert(0, x)} inserts at ! the front of the list, and \code{a.insert(len(a), x)} is equivalent to ! \code{a.append(x)}. ! \item[\code{remove(x)}] ! Remove the first item from the list whose value is \code{x}. It is an error if there is no such item. ! \item[\code{pop(\optional{i})}] Remove the item at the given position in the list, and return it. If no index is specified, \code{a.pop()} returns the last item in the ! list. The item is also removed from the list. ! \item[\code{index(x)}] ! Return the index in the list of the first item whose value is \code{x}. It is an error if there is no such item. ! \item[\code{count(x)}] ! Return the number of times \code{x} appears in the list. ! \item[\code{sort()}] Sort the items of the list, in place. ! \item[\code{reverse()}] Reverse the elements of the list, in place. ! ! \end{description} An example that uses most of the list methods: --- 1619,1670 ---- of list objects: ! \begin{methoddesc}[list]{append}{x} Add an item to the end of the list; ! equivalent to \code{a[len(a):] = [\var{x}]}. ! \end{methoddesc} ! \begin{methoddesc}[list]{extend}{L} Extend the list by appending all the items in the given list; ! equivalent to \code{a[len(a):] = \var{L}}. ! \end{methoddesc} ! \begin{methoddesc}[list]{insert}{i, x} ! Insert an item at a given position. The first argument is the index ! of the element before which to insert, so \code{a.insert(0, \var{x})} ! inserts at the front of the list, and \code{a.insert(len(a), \var{x})} ! is equivalent to \code{a.append(\var{x})}. ! \end{methoddesc} ! \begin{methoddesc}[list]{remove}{x} ! Remove the first item from the list whose value is \var{x}. It is an error if there is no such item. + \end{methoddesc} ! \begin{methoddesc}[list]{pop}{\optional{i}} Remove the item at the given position in the list, and return it. If no index is specified, \code{a.pop()} returns the last item in the ! list. The item is also removed from the list. (The square brackets ! around the \var{i} in the method signature denote that the parameter ! is optional, not that you should type square brackets at that ! position. You will see this notation frequently in the ! \citetitle[../lib/lib.html]{Python Library Reference}.) ! \end{methoddesc} ! \begin{methoddesc}[list]{index}{x} ! Return the index in the list of the first item whose value is \var{x}. It is an error if there is no such item. + \end{methoddesc} ! \begin{methoddesc}[list]{count}{x} ! Return the number of times \var{x} appears in the list. ! \end{methoddesc} ! \begin{methoddesc}[list]{sort}{} Sort the items of the list, in place. + \end{methoddesc} ! \begin{methoddesc}[list]{reverse}{} Reverse the elements of the list, in place. ! \end{methoddesc} An example that uses most of the list methods: From loewis@users.sourceforge.net Tue Jun 11 06:59:39 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon, 10 Jun 2002 22:59:39 -0700 Subject: [Python-checkins] python/dist/src/Lib/plat-atheos - New directory Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-atheos In directory usw-pr-cvs1:/tmp/cvs-serv5077/plat-atheos Log Message: Directory /cvsroot/python/python/dist/src/Lib/plat-atheos added to the repository From loewis@users.sourceforge.net Tue Jun 11 07:22:32 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon, 10 Jun 2002 23:22:32 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils/command build_ext.py,1.81,1.82 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory usw-pr-cvs1:/tmp/cvs-serv15074/Lib/distutils/command Modified Files: build_ext.py Log Message: Patch #488073: AtheOS port. Index: build_ext.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/build_ext.py,v retrieving revision 1.81 retrieving revision 1.82 diff -C2 -d -r1.81 -r1.82 *** build_ext.py 4 Jun 2002 20:14:43 -0000 1.81 --- build_ext.py 11 Jun 2002 06:22:30 -0000 1.82 *************** *** 179,185 **** self.library_dirs.append(os.path.join(sys.exec_prefix, 'Config')) ! # for extensions under Cygwin Python's library directory must be # appended to library_dirs ! if sys.platform[:6] == 'cygwin': if string.find(sys.executable, sys.exec_prefix) != -1: # building third party extensions --- 179,185 ---- self.library_dirs.append(os.path.join(sys.exec_prefix, 'Config')) ! # for extensions under Cygwin and AtheOS Python's library directory must be # appended to library_dirs ! if sys.platform[:6] == 'cygwin' or sys.platform[:6] == 'atheos': if string.find(sys.executable, sys.exec_prefix) != -1: # building third party extensions *************** *** 657,660 **** --- 657,676 ---- # extensions, it is a reference to the original list return ext.libraries + [pythonlib] + elif sys.platform[:6] == "atheos": + from distutils import sysconfig + + template = "python%d.%d" + pythonlib = (template % + (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff)) + # Get SHLIBS from Makefile + extra = [] + for lib in sysconfig.get_config_var('SHLIBS').split(): + if lib.startswith('-l'): + extra.append(lib[2:]) + else: + extra.append(lib) + # don't extend ext.libraries, it may be shared with other + # extensions, it is a reference to the original list + return ext.libraries + [pythonlib, "m"] + extra else: return ext.libraries From loewis@users.sourceforge.net Tue Jun 11 07:22:33 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon, 10 Jun 2002 23:22:33 -0700 Subject: [Python-checkins] python/dist/src/Tools/scripts h2py.py,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/scripts In directory usw-pr-cvs1:/tmp/cvs-serv15074/Tools/scripts Modified Files: h2py.py Log Message: Patch #488073: AtheOS port. Index: h2py.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/h2py.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** h2py.py 6 Dec 2001 03:28:17 -0000 1.16 --- h2py.py 11 Jun 2002 06:22:31 -0000 1.17 *************** *** 51,54 **** --- 51,56 ---- if sys.platform.find("beos") == 0: searchdirs=os.environ['BEINCLUDES'].split(';') + elif sys.platform.startswith("atheos"): + searchdirs=os.environ['C_INCLUDE_PATH'].split(':') else: raise KeyError From loewis@users.sourceforge.net Tue Jun 11 07:22:33 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon, 10 Jun 2002 23:22:33 -0700 Subject: [Python-checkins] python/dist/src/Lib/test regrtest.py,1.85,1.86 test_fcntl.py,1.22,1.23 test_file.py,1.8,1.9 test_mhlib.py,1.6,1.7 test_os.py,1.10,1.11 test_popen2.py,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv15074/Lib/test Modified Files: regrtest.py test_fcntl.py test_file.py test_mhlib.py test_os.py test_popen2.py Log Message: Patch #488073: AtheOS port. Index: regrtest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v retrieving revision 1.85 retrieving revision 1.86 diff -C2 -d -r1.85 -r1.86 *** regrtest.py 7 Jun 2002 15:17:03 -0000 1.85 --- regrtest.py 11 Jun 2002 06:22:30 -0000 1.86 *************** *** 722,725 **** --- 722,753 ---- test_zlib """, + 'atheos': + """ + test_al + test_cd + test_cl + test_curses + test_dl + test_email_codecs + test_gdbm + test_gl + test_imgfile + test_largefile + test_linuxaudiodev + test_locale + test_mhlib + test_mmap + test_mpz + test_nis + test_poll + test_popen2 + test_resource + test_socket_ssl + test_socketserver + test_sunaudiodev + test_unicode_file + test_winreg + test_winsound + """, } Index: test_fcntl.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_fcntl.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** test_fcntl.py 13 May 2002 14:58:02 -0000 1.22 --- test_fcntl.py 11 Jun 2002 06:22:30 -0000 1.23 *************** *** 18,21 **** --- 18,24 ---- start_len = "qq" + if sys.platform.startswith('atheos'): + start_len = "qq" + if sys.platform in ('netbsd1', 'Darwin1.2', 'darwin', 'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5', Index: test_file.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_file.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** test_file.py 1 Apr 2002 18:59:20 -0000 1.8 --- test_file.py 11 Jun 2002 06:22:30 -0000 1.9 *************** *** 1,2 **** --- 1,3 ---- + import sys import os from array import array *************** *** 89,93 **** raise TestFailed, 'file.closed should be true' ! for methodname in ['fileno', 'flush', 'isatty', 'read', 'readinto', 'readline', 'readlines', 'seek', 'tell', 'truncate', 'write', 'xreadlines' ]: method = getattr(f, methodname) try: --- 90,98 ---- raise TestFailed, 'file.closed should be true' ! methods = ['fileno', 'flush', 'isatty', 'read', 'readinto', 'readline', 'readlines', 'seek', 'tell', 'truncate', 'write', 'xreadlines' ] ! if sys.platform.startswith('atheos'): ! methods.remove('truncate') ! ! for methodname in methods: method = getattr(f, methodname) try: Index: test_mhlib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_mhlib.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test_mhlib.py 24 Oct 2001 20:32:02 -0000 1.6 --- test_mhlib.py 11 Jun 2002 06:22:30 -0000 1.7 *************** *** 13,17 **** import mhlib ! if sys.platform.startswith("win") or sys.platform=="riscos": raise TestSkipped("test_mhlib skipped on %s -- "%sys.platform + "too many Unix assumptions") --- 13,17 ---- import mhlib ! if sys.platform.startswith("win") or sys.platform=="riscos" or sys.platform.startswith("atheos"): raise TestSkipped("test_mhlib skipped on %s -- "%sys.platform + "too many Unix assumptions") Index: test_os.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_os.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** test_os.py 16 Apr 2002 01:27:44 -0000 1.10 --- test_os.py 11 Jun 2002 06:22:30 -0000 1.11 *************** *** 140,144 **** import statvfs ! result = os.statvfs(self.fname) # Make sure direct access works --- 140,150 ---- import statvfs ! try: ! result = os.statvfs(self.fname) ! except OSError, e: ! # On AtheOS, glibc always returns ENOSYS ! import errno ! if e.errno == errno.ENOSYS: ! return # Make sure direct access works Index: test_popen2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_popen2.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_popen2.py 30 Jan 2001 18:35:32 -0000 1.5 --- test_popen2.py 11 Jun 2002 06:22:30 -0000 1.6 *************** *** 15,23 **** def main(): print "Test popen2 module:" ! if sys.platform[:4] == 'beos' and __name__ != '__main__': # Locks get messed up or something. Generally we're supposed # to avoid mixing "posix" fork & exec with native threads, and # they may be right about that after all. ! raise TestSkipped, "popen2() doesn't work during import on BeOS" try: from os import popen --- 15,24 ---- def main(): print "Test popen2 module:" ! if (sys.platform[:4] == 'beos' or sys.platform[:6] == 'atheos') \ ! and __name__ != '__main__': # Locks get messed up or something. Generally we're supposed # to avoid mixing "posix" fork & exec with native threads, and # they may be right about that after all. ! raise TestSkipped, "popen2() doesn't work during import on " + sys.platform try: from os import popen From loewis@users.sourceforge.net Tue Jun 11 07:22:33 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon, 10 Jun 2002 23:22:33 -0700 Subject: [Python-checkins] python/dist/src/Misc AtheOS-NOTES,NONE,1.1 ACKS,1.180,1.181 NEWS,1.421,1.422 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv15074/Misc Modified Files: ACKS NEWS Added Files: AtheOS-NOTES Log Message: Patch #488073: AtheOS port. --- NEW FILE: AtheOS-NOTES --- Python for AtheOS Before building: Make sure you have shared versions of the libraries you want to use with Python. You will have to compile them yourself, or download precompiled packages. Recommended libraries: ncurses-4.2 readline-4.2a zlib-1.1.4 Build: $ ./configure --prefix=/usr/python $ make Python is always built as a shared library, otherwise dynamic loading would not work. Testing: $ make test Install: # make install # pkgmanager -a /usr/python AtheOS issues: - large file support: due to a stdio bug in glibc/libio, access to large files may not work correctly. fseeko() tries to seek to a negative offset. ftello() returns a negative offset, it looks like a 32->64bit sign-extension issue. The lowlevel functions (open, lseek, etc) are OK. - sockets: AF_UNIX is defined in the C library and in Python, but not implemented in the system. - select: poll is available in the C library, but does not work (It does not return POLLNVAL for bad fds and hangs). - posix: statvfs and fstatvfs always return ENOSYS. - - disabled modules: - mmap: not yet implemented in AtheOS - nis: broken (on an unconfigured system yp_get_default_domain() returns junk instead of error) - dl: dynamic loading doesn't work via dlopen() - resource: getrimit and setrlimit are not yet implemented - if you are getting segmentation faults, you probably are low on memory. AtheOS doesn't handle very well an out-of-memory condition and simply SEGVs the process. Tested on: AtheOS-0.3.7 gcc-2.95 binutils-2.10 make-3.78 -- Octavian Cerna Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.180 retrieving revision 1.181 diff -C2 -d -r1.180 -r1.181 *** ACKS 10 Jun 2002 20:00:52 -0000 1.180 --- ACKS 11 Jun 2002 06:22:31 -0000 1.181 *************** *** 79,82 **** --- 79,83 ---- Donn Cave Per Cederqvist + Octavian Cerna Jeffrey Chang Brad Chapman Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.421 retrieving revision 1.422 diff -C2 -d -r1.421 -r1.422 *** NEWS 10 Jun 2002 21:39:42 -0000 1.421 --- NEWS 11 Jun 2002 06:22:31 -0000 1.422 *************** *** 312,315 **** --- 312,317 ---- New platforms + - AtheOS is now supported. + - GNU/Hurd is now supported. From loewis@users.sourceforge.net Tue Jun 11 07:22:33 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon, 10 Jun 2002 23:22:33 -0700 Subject: [Python-checkins] python/dist/src/Modules cryptmodule.c,2.11,2.12 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv15074/Modules Modified Files: cryptmodule.c Log Message: Patch #488073: AtheOS port. Index: cryptmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cryptmodule.c,v retrieving revision 2.11 retrieving revision 2.12 diff -C2 -d -r2.11 -r2.12 *** cryptmodule.c 31 Mar 2002 15:27:00 -0000 2.11 --- cryptmodule.c 11 Jun 2002 06:22:31 -0000 2.12 *************** *** 18,22 **** return NULL; } ! return PyString_FromString( crypt( word, salt ) ); } --- 18,24 ---- return NULL; } ! /* On some platforms (AtheOS) crypt returns NULL for an invalid ! salt. Return None in that case. XXX Maybe raise an exception? */ ! return Py_BuildValue("s", crypt(word, salt)); } From loewis@users.sourceforge.net Tue Jun 11 07:22:33 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon, 10 Jun 2002 23:22:33 -0700 Subject: [Python-checkins] python/dist/src/Python dynload_atheos.c,NONE,2.1 thread_atheos.h,NONE,2.1 thread.c,2.42,2.43 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv15074/Python Modified Files: thread.c Added Files: dynload_atheos.c thread_atheos.h Log Message: Patch #488073: AtheOS port. --- NEW FILE: dynload_atheos.c --- /* Support for dynamic loading of extension modules */ #include #include #include "Python.h" #include "importdl.h" const struct filedescr _PyImport_DynLoadFiletab[] = { {".so", "rb", C_EXTENSION}, {"module.so", "rb", C_EXTENSION}, {0, 0} }; dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, const char *pathname, FILE *fp) { void *p; int lib; char funcname[258]; if (Py_VerboseFlag) printf("load_library %s\n", pathname); lib = load_library(pathname, 0); if (lib < 0) { char buf[512]; if (Py_VerboseFlag) perror(pathname); PyOS_snprintf(buf, sizeof(buf), "Failed to load %.200s: %.200s", pathname, strerror(errno)); PyErr_SetString(PyExc_ImportError, buf); return NULL; } PyOS_snprintf(funcname, sizeof(funcname), "init%.200s", shortname); if (Py_VerboseFlag) printf("get_symbol_address %s\n", funcname); if (get_symbol_address(lib, funcname, -1, &p) < 0) { p = NULL; if (Py_VerboseFlag) perror(funcname); } return (dl_funcptr) p; } --- NEW FILE: thread_atheos.h --- /* Threading for AtheOS. Based on thread_beos.h. */ #include #include #include #include #include /* Missing decl from threads.h */ extern int exit_thread(int); /* Undefine FASTLOCK to play with simple semaphores. */ #define FASTLOCK #ifdef FASTLOCK /* Use an atomic counter and a semaphore for maximum speed. */ typedef struct fastmutex { sem_id sem; atomic_t count; } fastmutex_t; static int fastmutex_create(const char *name, fastmutex_t * mutex); static int fastmutex_destroy(fastmutex_t * mutex); static int fastmutex_lock(fastmutex_t * mutex); static int fastmutex_timedlock(fastmutex_t * mutex, bigtime_t timeout); static int fastmutex_unlock(fastmutex_t * mutex); static int fastmutex_create(const char *name, fastmutex_t * mutex) { mutex->count = 0; mutex->sem = create_semaphore(name, 0, 0); return (mutex->sem < 0) ? -1 : 0; } static int fastmutex_destroy(fastmutex_t * mutex) { if (fastmutex_timedlock(mutex, 0) == 0 || errno == EWOULDBLOCK) { return delete_semaphore(mutex->sem); } return 0; } static int fastmutex_lock(fastmutex_t * mutex) { atomic_t prev = atomic_add(&mutex->count, 1); if (prev > 0) return lock_semaphore(mutex->sem); return 0; } static int fastmutex_timedlock(fastmutex_t * mutex, bigtime_t timeout) { atomic_t prev = atomic_add(&mutex->count, 1); if (prev > 0) return lock_semaphore_x(mutex->sem, 1, 0, timeout); return 0; } static int fastmutex_unlock(fastmutex_t * mutex) { atomic_t prev = atomic_add(&mutex->count, -1); if (prev > 1) return unlock_semaphore(mutex->sem); return 0; } #endif /* FASTLOCK */ /* * Initialization. * */ static void PyThread__init_thread(void) { /* Do nothing. */ return; } /* * Thread support. * */ static atomic_t thread_count = 0; long PyThread_start_new_thread(void (*func) (void *), void *arg) { status_t success = -1; thread_id tid; char name[OS_NAME_LENGTH]; atomic_t this_thread; dprintf(("PyThread_start_new_thread called\n")); this_thread = atomic_add(&thread_count, 1); PyOS_snprintf(name, sizeof(name), "python thread (%d)", this_thread); tid = spawn_thread(name, func, NORMAL_PRIORITY, 0, arg); if (tid < 0) { dprintf(("PyThread_start_new_thread spawn_thread failed: %s\n", strerror(errno))); } else { success = resume_thread(tid); if (success < 0) { dprintf(("PyThread_start_new_thread resume_thread failed: %s\n", strerror(errno))); } } return (success < 0 ? -1 : tid); } long PyThread_get_thread_ident(void) { return get_thread_id(NULL); } static void do_PyThread_exit_thread(int no_cleanup) { dprintf(("PyThread_exit_thread called\n")); /* Thread-safe way to read a variable without a mutex: */ if (atomic_add(&thread_count, 0) == 0) { /* No threads around, so exit main(). */ if (no_cleanup) _exit(0); else exit(0); } else { /* We're a thread */ exit_thread(0); } } void PyThread_exit_thread(void) { do_PyThread_exit_thread(0); } void PyThread__exit_thread(void) { do_PyThread_exit_thread(1); } #ifndef NO_EXIT_PROG static void do_PyThread_exit_prog(int status, int no_cleanup) { dprintf(("PyThread_exit_prog(%d) called\n", status)); /* No need to do anything, the threads get torn down if main()exits. */ if (no_cleanup) _exit(status); else exit(status); } void PyThread_exit_prog(int status) { do_PyThread_exit_prog(status, 0); } void PyThread__exit_prog(int status) { do_PyThread_exit_prog(status, 1); } #endif /* NO_EXIT_PROG */ /* * Lock support. * */ static atomic_t lock_count = 0; PyThread_type_lock PyThread_allocate_lock(void) { #ifdef FASTLOCK fastmutex_t *lock; #else sem_id sema; #endif char name[OS_NAME_LENGTH]; atomic_t this_lock; dprintf(("PyThread_allocate_lock called\n")); #ifdef FASTLOCK lock = (fastmutex_t *) malloc(sizeof(fastmutex_t)); if (lock == NULL) { dprintf(("PyThread_allocate_lock failed: out of memory\n")); return (PyThread_type_lock) NULL; } #endif this_lock = atomic_add(&lock_count, 1); PyOS_snprintf(name, sizeof(name), "python lock (%d)", this_lock); #ifdef FASTLOCK if (fastmutex_create(name, lock) < 0) { dprintf(("PyThread_allocate_lock failed: %s\n", strerror(errno))); free(lock); lock = NULL; } dprintf(("PyThread_allocate_lock()-> %p\n", lock)); return (PyThread_type_lock) lock; #else sema = create_semaphore(name, 1, 0); if (sema < 0) { dprintf(("PyThread_allocate_lock failed: %s\n", strerror(errno))); sema = 0; } dprintf(("PyThread_allocate_lock()-> %p\n", sema)); return (PyThread_type_lock) sema; #endif } void PyThread_free_lock(PyThread_type_lock lock) { dprintf(("PyThread_free_lock(%p) called\n", lock)); #ifdef FASTLOCK if (fastmutex_destroy((fastmutex_t *) lock) < 0) { dprintf(("PyThread_free_lock(%p) failed: %s\n", lock, strerror(errno))); } free(lock); #else if (delete_semaphore((sem_id) lock) < 0) { dprintf(("PyThread_free_lock(%p) failed: %s\n", lock, strerror(errno))); } #endif } int PyThread_acquire_lock(PyThread_type_lock lock, int waitflag) { int retval; dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag)); #ifdef FASTLOCK if (waitflag) retval = fastmutex_lock((fastmutex_t *) lock); else retval = fastmutex_timedlock((fastmutex_t *) lock, 0); #else if (waitflag) retval = lock_semaphore((sem_id) lock); else retval = lock_semaphore_x((sem_id) lock, 1, 0, 0); #endif if (retval < 0) { dprintf(("PyThread_acquire_lock(%p, %d) failed: %s\n", lock, waitflag, strerror(errno))); } dprintf(("PyThread_acquire_lock(%p, %d)-> %d\n", lock, waitflag, retval)); return retval < 0 ? 0 : 1; } void PyThread_release_lock(PyThread_type_lock lock) { dprintf(("PyThread_release_lock(%p) called\n", lock)); #ifdef FASTLOCK if (fastmutex_unlock((fastmutex_t *) lock) < 0) { dprintf(("PyThread_release_lock(%p) failed: %s\n", lock, strerror(errno))); } #else if (unlock_semaphore((sem_id) lock) < 0) { dprintf(("PyThread_release_lock(%p) failed: %s\n", lock, strerror(errno))); } #endif } Index: thread.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread.c,v retrieving revision 2.42 retrieving revision 2.43 diff -C2 -d -r2.42 -r2.43 *** thread.c 25 Mar 2002 06:49:10 -0000 2.42 --- thread.c 11 Jun 2002 06:22:31 -0000 2.43 *************** *** 134,137 **** --- 134,141 ---- #endif + #ifdef ATHEOS_THREADS + #include "thread_atheos.h" + #endif + /* #ifdef FOOBAR_THREADS From loewis@users.sourceforge.net Tue Jun 11 07:22:32 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon, 10 Jun 2002 23:22:32 -0700 Subject: [Python-checkins] python/dist/src Makefile.pre.in,1.84,1.85 configure,1.312,1.313 configure.in,1.322,1.323 pyconfig.h.in,1.39,1.40 setup.py,1.88,1.89 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv15074 Modified Files: Makefile.pre.in configure configure.in pyconfig.h.in setup.py Log Message: Patch #488073: AtheOS port. Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.pre.in,v retrieving revision 1.84 retrieving revision 1.85 diff -C2 -d -r1.84 -r1.85 *** Makefile.pre.in 15 May 2002 11:32:35 -0000 1.84 --- Makefile.pre.in 11 Jun 2002 06:22:30 -0000 1.85 *************** *** 147,150 **** --- 147,151 ---- LIBC= @LIBC@ SYSLIBS= $(LIBM) $(LIBC) + SHLIBS= @SHLIBS@ MAINOBJ= @MAINOBJ@ *************** *** 342,346 **** libpython$(VERSION).so: $(LIBRARY_OBJS) ! $(LDSHARED) -o $@ $(LIBRARY_OBJS) $(LIBC) $(LIBM) libpython$(VERSION).sl: $(LIBRARY_OBJS) --- 343,347 ---- libpython$(VERSION).so: $(LIBRARY_OBJS) ! $(LDSHARED) -o $@ $(LIBRARY_OBJS) $(SHLIBS) $(LIBC) $(LIBM) libpython$(VERSION).sl: $(LIBRARY_OBJS) Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.312 retrieving revision 1.313 diff -C2 -d -r1.312 -r1.313 *** configure 9 Jun 2002 13:33:47 -0000 1.312 --- configure 11 Jun 2002 06:22:30 -0000 1.313 *************** *** 1,4 **** #! /bin/sh ! # From configure.in Revision: 1.321 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.53. --- 1,4 ---- #! /bin/sh ! # From configure.in Revision: 1.322 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.53. *************** *** 1294,1297 **** --- 1294,1298 ---- cygwin*) MACHDEP="cygwin";; darwin*) MACHDEP="darwin";; + atheos*) MACHDEP="atheos";; '') MACHDEP="unknown";; esac *************** *** 3073,3077 **** then case $ac_sys_system in ! CYGWIN*) enable_shared="yes";; *) --- 3074,3078 ---- then case $ac_sys_system in ! CYGWIN* | atheos*) enable_shared="yes";; *) *************** *** 3132,3135 **** --- 3133,3141 ---- RUNSHARED=LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH ;; + atheos*) + LDLIBRARY='libpython$(VERSION).so' + BLDLIBRARY='-L. -lpython$(VERSION)' + RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib} + ;; esac # DG/UX requires some fancy ld contortions to produce a .so from an .a *************** *** 3385,3388 **** --- 3391,3395 ---- BeOS*) LN="ln -s";; CYGWIN*) LN="ln -s";; + atheos*) LN="ln -s";; *) LN=ln;; esac *************** *** 8780,8783 **** --- 8787,8791 ---- Monterey*) LDSHARED="cc -G -dy -Bdynamic -Bexport -L/usr/lib/ia64l64";; CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";; + atheos*) LDSHARED="gcc -shared";; *) LDSHARED="ld";; esac *************** *** 8815,8818 **** --- 8823,8827 ---- esac;; CYGWIN*) CCSHARED="-DUSE_DL_IMPORT";; + atheos*) CCSHARED="-fPIC";; esac fi *************** *** 8884,8887 **** --- 8893,8913 ---- echo "${ECHO_T}$CFLAGSFORSHARED" >&6 + # SHLIBS are libraries (except -lc and -lm) to link to the python shared + # library (with --enable-shared). + # For platforms on which shared libraries are not allowed to have unresolved + # symbols, this must be set to $(LIBS) (expanded by make). + + echo "$as_me:$LINENO: checking SHLIBS" >&5 + echo $ECHO_N "checking SHLIBS... $ECHO_C" >&6 + case "$ac_sys_system" in + atheos*) + SHLIBS='$(LIBS)';; + *) + SHLIBS='';; + esac + echo "$as_me:$LINENO: result: $SHLIBS" >&5 + echo "${ECHO_T}$SHLIBS" >&6 + + # checks for libraries *************** *** 9871,9874 **** --- 9897,10014 ---- else + if test "${ac_cv_header_atheos_threads_h+set}" = set; then + echo "$as_me:$LINENO: checking for atheos/threads.h" >&5 + echo $ECHO_N "checking for atheos/threads.h... $ECHO_C" >&6 + if test "${ac_cv_header_atheos_threads_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 + fi + echo "$as_me:$LINENO: result: $ac_cv_header_atheos_threads_h" >&5 + echo "${ECHO_T}$ac_cv_header_atheos_threads_h" >&6 + else + # Is the header compilable? + echo "$as_me:$LINENO: checking atheos/threads.h usability" >&5 + echo $ECHO_N "checking atheos/threads.h usability... $ECHO_C" >&6 + cat >conftest.$ac_ext <<_ACEOF + #line $LINENO "configure" + #include "confdefs.h" + $ac_includes_default + #include + _ACEOF + rm -f conftest.$ac_objext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes + else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_header_compiler=no + fi + rm -f conftest.$ac_objext conftest.$ac_ext + echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 + echo "${ECHO_T}$ac_header_compiler" >&6 + + # Is the header present? + echo "$as_me:$LINENO: checking atheos/threads.h presence" >&5 + echo $ECHO_N "checking atheos/threads.h presence... $ECHO_C" >&6 + cat >conftest.$ac_ext <<_ACEOF + #line $LINENO "configure" + #include "confdefs.h" + #include + _ACEOF + if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi + else + ac_cpp_err=yes + fi + if test -z "$ac_cpp_err"; then + ac_header_preproc=yes + else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_header_preproc=no + fi + rm -f conftest.err conftest.$ac_ext + echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 + echo "${ECHO_T}$ac_header_preproc" >&6 + + # So? What about this header? + case $ac_header_compiler:$ac_header_preproc in + yes:no ) + { echo "$as_me:$LINENO: WARNING: atheos/threads.h: accepted by the compiler, rejected by the preprocessor!" >&5 + echo "$as_me: WARNING: atheos/threads.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: atheos/threads.h: proceeding with the preprocessor's result" >&5 + echo "$as_me: WARNING: atheos/threads.h: proceeding with the preprocessor's result" >&2;};; + no:yes ) + { echo "$as_me:$LINENO: WARNING: atheos/threads.h: present but cannot be compiled" >&5 + echo "$as_me: WARNING: atheos/threads.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: atheos/threads.h: check for missing prerequisite headers?" >&5 + echo "$as_me: WARNING: atheos/threads.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: atheos/threads.h: proceeding with the preprocessor's result" >&5 + echo "$as_me: WARNING: atheos/threads.h: proceeding with the preprocessor's result" >&2;};; + esac + echo "$as_me:$LINENO: checking for atheos/threads.h" >&5 + echo $ECHO_N "checking for atheos/threads.h... $ECHO_C" >&6 + if test "${ac_cv_header_atheos_threads_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 + else + ac_cv_header_atheos_threads_h=$ac_header_preproc + fi + echo "$as_me:$LINENO: result: $ac_cv_header_atheos_threads_h" >&5 + echo "${ECHO_T}$ac_cv_header_atheos_threads_h" >&6 + + fi + if test $ac_cv_header_atheos_threads_h = yes; then + cat >>confdefs.h <<\_ACEOF + #define WITH_THREAD 1 + _ACEOF + + + cat >>confdefs.h <<\_ACEOF + #define ATHEOS_THREADS 1 + _ACEOF + + THREADOBJ="Python/thread.o" + else + if test "${ac_cv_header_kernel_OS_h+set}" = set; then echo "$as_me:$LINENO: checking for kernel/OS.h" >&5 *************** *** 10327,10330 **** --- 10467,10473 ---- fi + + fi + fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext *************** *** 11193,11196 **** --- 11336,11340 ---- hp*|HP*) DYNLOADFILE="dynload_hpux.o";; Darwin/*) DYNLOADFILE="dynload_next.o";; + atheos*) DYNLOADFILE="dynload_atheos.o";; *) # use dynload_shlib.c and dlopen() if we have it; otherwise stub *************** *** 16395,16398 **** --- 16539,16543 ---- s,@LINKFORSHARED@,$LINKFORSHARED,;t t s,@CFLAGSFORSHARED@,$CFLAGSFORSHARED,;t t + s,@SHLIBS@,$SHLIBS,;t t s,@USE_SIGNAL_MODULE@,$USE_SIGNAL_MODULE,;t t s,@SIGNAL_OBJS@,$SIGNAL_OBJS,;t t Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.322 retrieving revision 1.323 diff -C2 -d -r1.322 -r1.323 *** configure.in 9 Jun 2002 13:33:53 -0000 1.322 --- configure.in 11 Jun 2002 06:22:30 -0000 1.323 *************** *** 82,85 **** --- 82,86 ---- cygwin*) MACHDEP="cygwin";; darwin*) MACHDEP="darwin";; + atheos*) MACHDEP="atheos";; '') MACHDEP="unknown";; esac *************** *** 329,333 **** then case $ac_sys_system in ! CYGWIN*) enable_shared="yes";; *) --- 330,334 ---- then case $ac_sys_system in ! CYGWIN* | atheos*) enable_shared="yes";; *) *************** *** 386,389 **** --- 387,395 ---- RUNSHARED=LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH ;; + atheos*) + LDLIBRARY='libpython$(VERSION).so' + BLDLIBRARY='-L. -lpython$(VERSION)' + RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib} + ;; esac # DG/UX requires some fancy ld contortions to produce a .so from an .a *************** *** 418,421 **** --- 424,428 ---- BeOS*) LN="ln -s";; CYGWIN*) LN="ln -s";; + atheos*) LN="ln -s";; *) LN=ln;; esac *************** *** 907,910 **** --- 914,918 ---- Monterey*) LDSHARED="cc -G -dy -Bdynamic -Bexport -L/usr/lib/ia64l64";; CYGWIN*) LDSHARED="gcc -shared -Wl,--enable-auto-image-base";; + atheos*) LDSHARED="gcc -shared";; *) LDSHARED="ld";; esac *************** *** 940,943 **** --- 948,952 ---- esac;; CYGWIN*) CCSHARED="-DUSE_DL_IMPORT";; + atheos*) CCSHARED="-fPIC";; esac fi *************** *** 1004,1007 **** --- 1013,1031 ---- AC_MSG_RESULT($CFLAGSFORSHARED) + # SHLIBS are libraries (except -lc and -lm) to link to the python shared + # library (with --enable-shared). + # For platforms on which shared libraries are not allowed to have unresolved + # symbols, this must be set to $(LIBS) (expanded by make). + AC_SUBST(SHLIBS) + AC_MSG_CHECKING(SHLIBS) + case "$ac_sys_system" in + atheos*) + SHLIBS='$(LIBS)';; + *) + SHLIBS='';; + esac + AC_MSG_RESULT($SHLIBS) + + # checks for libraries AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV *************** *** 1178,1181 **** --- 1202,1209 ---- posix_threads=yes THREADOBJ="Python/thread.o"],[ + AC_CHECK_HEADER(atheos/threads.h, [AC_DEFINE(WITH_THREAD) + AC_DEFINE(ATHEOS_THREADS, 1, + [Define this if you have AtheOS threads.]) + THREADOBJ="Python/thread.o"],[ AC_CHECK_HEADER(kernel/OS.h, [AC_DEFINE(WITH_THREAD) AC_DEFINE(BEOS_THREADS, 1, *************** *** 1203,1207 **** THREADOBJ="Python/thread.o"],[ USE_THREAD_MODULE="#"]) ! ])])])])])])])])])]) if test "$posix_threads" = "yes"; then --- 1231,1235 ---- THREADOBJ="Python/thread.o"],[ USE_THREAD_MODULE="#"]) ! ])])])])])])])])])])]) if test "$posix_threads" = "yes"; then *************** *** 1561,1564 **** --- 1589,1593 ---- hp*|HP*) DYNLOADFILE="dynload_hpux.o";; Darwin/*) DYNLOADFILE="dynload_next.o";; + atheos*) DYNLOADFILE="dynload_atheos.o";; *) # use dynload_shlib.c and dlopen() if we have it; otherwise stub Index: pyconfig.h.in =================================================================== RCS file: /cvsroot/python/python/dist/src/pyconfig.h.in,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** pyconfig.h.in 9 Jun 2002 13:33:53 -0000 1.39 --- pyconfig.h.in 11 Jun 2002 06:22:30 -0000 1.40 *************** *** 5,8 **** --- 5,11 ---- #undef AIX_GENUINE_CPLUSPLUS + /* Define this if you have AtheOS threads. */ + #undef ATHEOS_THREADS + /* Define if your contains bad prototypes for exec*() (as it does on SGI IRIX 4.x) */ Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.88 retrieving revision 1.89 diff -C2 -d -r1.88 -r1.89 *** setup.py 4 Jun 2002 15:28:21 -0000 1.88 --- setup.py 11 Jun 2002 06:22:30 -0000 1.89 *************** *** 215,218 **** --- 215,220 ---- elif platform[:6] == 'darwin': platform = 'darwin' + elif platform[:6] == 'atheos': + platform = 'atheos' return platform *************** *** 243,246 **** --- 245,255 ---- (srcdir,) = sysconfig.get_config_vars('srcdir') + # Check for AtheOS which has libraries in non-standard locations + if platform == 'atheos': + lib_dirs += ['/system/libs', '/atheos/autolnk/lib'] + lib_dirs += os.getenv('LIBRARY_PATH', '').split(os.pathsep) + inc_dirs += ['/system/include', '/atheos/autolnk/include'] + inc_dirs += os.getenv('C_INCLUDE_PATH', '').split(os.pathsep) + # Check for MacOS X, which doesn't need libm.a at all math_libs = ['m'] *************** *** 324,328 **** # Memory-mapped files (also works on Win32). ! exts.append( Extension('mmap', ['mmapmodule.c']) ) # Lance Ellinghaus's modules: --- 333,338 ---- # Memory-mapped files (also works on Win32). ! if platform not in ['atheos']: ! exts.append( Extension('mmap', ['mmapmodule.c']) ) # Lance Ellinghaus's modules: *************** *** 480,487 **** exts.append( Extension('termios', ['termios.c']) ) # Jeremy Hylton's rlimit interface ! exts.append( Extension('resource', ['resource.c']) ) # Sun yellow pages. Some systems have the functions in libc. ! if platform not in ['cygwin']: if (self.compiler.find_library_file(lib_dirs, 'nsl')): libs = ['nsl'] --- 490,498 ---- exts.append( Extension('termios', ['termios.c']) ) # Jeremy Hylton's rlimit interface ! if platform not in ['atheos']: ! exts.append( Extension('resource', ['resource.c']) ) # Sun yellow pages. Some systems have the functions in libc. ! if platform not in ['cygwin', 'atheos']: if (self.compiler.find_library_file(lib_dirs, 'nsl')): libs = ['nsl'] *************** *** 594,598 **** # Dynamic loading module dl_inc = find_file('dlfcn.h', [], inc_dirs) ! if dl_inc is not None: exts.append( Extension('dl', ['dlmodule.c']) ) --- 605,609 ---- # Dynamic loading module dl_inc = find_file('dlfcn.h', [], inc_dirs) ! if (dl_inc is not None) and (platform not in ['atheos']): exts.append( Extension('dl', ['dlmodule.c']) ) From loewis@users.sourceforge.net Tue Jun 11 07:22:32 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon, 10 Jun 2002 23:22:32 -0700 Subject: [Python-checkins] python/dist/src/Lib/plat-atheos IN.py,NONE,1.1 TYPES.py,NONE,1.1 regen,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-atheos In directory usw-pr-cvs1:/tmp/cvs-serv15074/Lib/plat-atheos Added Files: IN.py TYPES.py regen Log Message: Patch #488073: AtheOS port. --- NEW FILE: IN.py --- # Generated by h2py from /include/netinet/in.h _NETINET_IN_H = 1 # Included from features.h _FEATURES_H = 1 __USE_ANSI = 1 __FAVOR_BSD = 1 _ISOC9X_SOURCE = 1 _POSIX_SOURCE = 1 _POSIX_C_SOURCE = 199506L _XOPEN_SOURCE = 500 _XOPEN_SOURCE_EXTENDED = 1 _LARGEFILE64_SOURCE = 1 _BSD_SOURCE = 1 _SVID_SOURCE = 1 _BSD_SOURCE = 1 _SVID_SOURCE = 1 __USE_ISOC9X = 1 _POSIX_SOURCE = 1 _POSIX_C_SOURCE = 2 _POSIX_C_SOURCE = 199506L __USE_POSIX = 1 __USE_POSIX2 = 1 __USE_POSIX199309 = 1 __USE_POSIX199506 = 1 __USE_XOPEN = 1 __USE_XOPEN_EXTENDED = 1 __USE_UNIX98 = 1 _LARGEFILE_SOURCE = 1 __USE_XOPEN_EXTENDED = 1 __USE_LARGEFILE = 1 __USE_LARGEFILE64 = 1 __USE_FILE_OFFSET64 = 1 __USE_MISC = 1 __USE_BSD = 1 __USE_SVID = 1 __USE_GNU = 1 __USE_REENTRANT = 1 __STDC_IEC_559__ = 1 __STDC_IEC_559_COMPLEX__ = 1 __GNU_LIBRARY__ = 6 __GLIBC__ = 2 __GLIBC_MINOR__ = 1 # Included from sys/cdefs.h _SYS_CDEFS_H = 1 def __PMT(args): return args def __P(args): return args def __PMT(args): return args def __P(args): return () def __PMT(args): return () def __STRING(x): return #x def __STRING(x): return "x" def __ASMNAME(cname): return __ASMNAME2 (__USER_LABEL_PREFIX__, cname) def __attribute__(xyz): return __USE_EXTERN_INLINES = 1 # Included from gnu/stubs.h # Included from limits.h _LIBC_LIMITS_H_ = 1 # Included from bits/posix1_lim.h _BITS_POSIX1_LIM_H = 1 _POSIX_AIO_LISTIO_MAX = 2 _POSIX_AIO_MAX = 1 _POSIX_ARG_MAX = 4096 _POSIX_CHILD_MAX = 6 _POSIX_DELAYTIMER_MAX = 32 _POSIX_LINK_MAX = 8 _POSIX_MAX_CANON = 255 _POSIX_MAX_INPUT = 255 _POSIX_MQ_OPEN_MAX = 8 _POSIX_MQ_PRIO_MAX = 32 _POSIX_NGROUPS_MAX = 0 _POSIX_OPEN_MAX = 16 _POSIX_FD_SETSIZE = _POSIX_OPEN_MAX _POSIX_NAME_MAX = 14 _POSIX_PATH_MAX = 255 _POSIX_PIPE_BUF = 512 _POSIX_RTSIG_MAX = 8 _POSIX_SEM_NSEMS_MAX = 256 _POSIX_SEM_VALUE_MAX = 32767 _POSIX_SIGQUEUE_MAX = 32 _POSIX_SSIZE_MAX = 32767 _POSIX_STREAM_MAX = 8 _POSIX_TZNAME_MAX = 3 _POSIX_QLIMIT = 1 _POSIX_HIWAT = _POSIX_PIPE_BUF _POSIX_UIO_MAXIOV = 16 _POSIX_TTY_NAME_MAX = 9 _POSIX_TIMER_MAX = 32 _POSIX_LOGIN_NAME_MAX = 9 _POSIX_CLOCKRES_MIN = 20000000 # Included from bits/local_lim.h # Included from posix/limits.h CHAR_BIT = 8 CHAR_MAX = 127 CHAR_MIN = (-128) INT_MAX = 2147483647 INT_MIN = (-2147483647-1) LONG_MAX = 2147483647L LONG_MIN = (-2147483647L-1L) SCHAR_MAX = 127 SCHAR_MIN = (-128) SHRT_MAX = 32767 SHRT_MIN = (-32768) UCHAR_MAX = 255 USHRT_MAX = 65535 _POSIX_ARG_MAX = 131072 _POSIX_CHILD_MAX = 4096 _POSIX_LINK_MAX = 1 _POSIX_MAX_CANON = 126 _POSIX_MAX_INPUT = 126 _POSIX_NAME_MAX = 256 _POSIX_NGROUPS_MAX = 32 _POSIX_OPEN_MAX = 256 _POSIX_PATH_MAX = 255 _POSIX_PIPE_BUF = 512 _POSIX_SSIZE_MAX = 2147483647 _POSIX_STREAM_MAX = 256 _POSIX_TZNAME_MAX = 5 NGROUPS_MAX = 32 ARG_MAX = 131072 CHILD_MAX = 4096 OPEN_MAX = 256 LINK_MAX = 1 MAX_CANON = 126 MAX_INPUT = 126 NAME_MAX = 255 PATH_MAX = 4096 PIPE_BUF = 4096 SSIZE_MAX = 2147483647 MAXSYMLINKS = 16 AIO_PRIO_DELTA_MAX = 20 SSIZE_MAX = INT_MAX NGROUPS_MAX = _POSIX_NGROUPS_MAX # Included from bits/posix2_lim.h _BITS_POSIX2_LIM_H = 1 _POSIX2_BC_BASE_MAX = 99 _POSIX2_BC_DIM_MAX = 2048 _POSIX2_BC_SCALE_MAX = 99 _POSIX2_BC_STRING_MAX = 1000 _POSIX2_COLL_WEIGHTS_MAX = 255 _POSIX2_EQUIV_CLASS_MAX = 255 _POSIX2_EXPR_NEST_MAX = 32 _POSIX2_LINE_MAX = 2048 _POSIX2_RE_DUP_MAX = 255 _POSIX2_CHARCLASS_NAME_MAX = 2048 BC_BASE_MAX = _POSIX2_BC_BASE_MAX BC_DIM_MAX = _POSIX2_BC_DIM_MAX BC_SCALE_MAX = _POSIX2_BC_SCALE_MAX BC_STRING_MAX = _POSIX2_BC_STRING_MAX COLL_WEIGHTS_MAX = _POSIX2_COLL_WEIGHTS_MAX EQUIV_CLASS_MAX = _POSIX2_EQUIV_CLASS_MAX EXPR_NEST_MAX = _POSIX2_EXPR_NEST_MAX LINE_MAX = _POSIX2_LINE_MAX RE_DUP_MAX = _POSIX2_RE_DUP_MAX CHARCLASS_NAME_MAX = _POSIX2_CHARCLASS_NAME_MAX # Included from bits/xopen_lim.h _XOPEN_LIM_H = 1 # Included from bits/stdio_lim.h L_tmpnam = 20 TMP_MAX = 238328 FILENAME_MAX = 4096 L_ctermid = 9 L_cuserid = 9 FOPEN_MAX = 256 STREAM_MAX = FOPEN_MAX TZNAME_MAX = _POSIX_TZNAME_MAX _XOPEN_IOV_MAX = _POSIX_UIO_MAXIOV NL_ARGMAX = _POSIX_ARG_MAX NL_LANGMAX = _POSIX2_LINE_MAX NL_MSGMAX = INT_MAX NL_NMAX = INT_MAX NL_SETMAX = INT_MAX NL_TEXTMAX = INT_MAX NZERO = 20 MB_LEN_MAX = 6 _LIMITS_H = 1 CHAR_BIT = 8 SCHAR_MIN = (-128) SCHAR_MAX = 127 UCHAR_MAX = 255 CHAR_MIN = 0 CHAR_MAX = UCHAR_MAX CHAR_MIN = SCHAR_MIN CHAR_MAX = SCHAR_MAX SHRT_MIN = (-32768) SHRT_MAX = 32767 USHRT_MAX = 65535 INT_MIN = (-INT_MAX - 1) INT_MAX = 2147483647 UINT_MAX = 4294967295 LONG_MAX = 9223372036854775807L LONG_MAX = 2147483647L LONG_MIN = (-LONG_MAX - 1L) ULONG_MAX = 4294967295L # Included from stdint.h _STDINT_H = 1 # Included from bits/wordsize.h __WORDSIZE = 32 def __INT64_C(c): return c ## L def __UINT64_C(c): return c ## UL def __INT64_C(c): return c ## LL def __UINT64_C(c): return c ## ULL INT8_MIN = (-128) INT16_MIN = (-32767-1) INT32_MIN = (-2147483647-1) INT64_MIN = (-__INT64_C(9223372036854775807)-1) INT8_MAX = (127) INT16_MAX = (32767) INT32_MAX = (2147483647) INT64_MAX = (__INT64_C(9223372036854775807)) UINT64_MAX = (__UINT64_C(18446744073709551615)) INT_LEAST8_MIN = (-128) INT_LEAST16_MIN = (-32767-1) INT_LEAST32_MIN = (-2147483647-1) INT_LEAST64_MIN = (-__INT64_C(9223372036854775807)-1) INT_LEAST8_MAX = (127) INT_LEAST16_MAX = (32767) INT_LEAST32_MAX = (2147483647) INT_LEAST64_MAX = (__INT64_C(9223372036854775807)) UINT_LEAST64_MAX = (__UINT64_C(18446744073709551615)) INT_FAST8_MIN = (-128) INT_FAST16_MIN = (-9223372036854775807L-1) INT_FAST32_MIN = (-9223372036854775807L-1) INT_FAST16_MIN = (-2147483647-1) INT_FAST32_MIN = (-2147483647-1) INT_FAST64_MIN = (-__INT64_C(9223372036854775807)-1) INT_FAST8_MAX = (127) INT_FAST16_MAX = (9223372036854775807L) INT_FAST32_MAX = (9223372036854775807L) INT_FAST16_MAX = (2147483647) INT_FAST32_MAX = (2147483647) INT_FAST64_MAX = (__INT64_C(9223372036854775807)) UINT_FAST64_MAX = (__UINT64_C(18446744073709551615)) INTPTR_MIN = (-9223372036854775807L-1) INTPTR_MAX = (9223372036854775807L) INTPTR_MIN = (-2147483647-1) INTPTR_MAX = (2147483647) INTMAX_MIN = (-__INT64_C(9223372036854775807)-1) INTMAX_MAX = (__INT64_C(9223372036854775807)) UINTMAX_MAX = (__UINT64_C(18446744073709551615)) PTRDIFF_MIN = (-9223372036854775807L-1) PTRDIFF_MAX = (9223372036854775807L) PTRDIFF_MIN = (-2147483647-1) PTRDIFF_MAX = (2147483647) SIG_ATOMIC_MIN = (-2147483647-1) SIG_ATOMIC_MAX = (2147483647) WCHAR_MIN = (-2147483647-1) WCHAR_MAX = (2147483647) WINT_MIN = (0) def INT8_C(c): return c def INT16_C(c): return c def INT32_C(c): return c def INT64_C(c): return c ## L def INT64_C(c): return c ## LL def UINT8_C(c): return c ## U def UINT16_C(c): return c ## U def UINT32_C(c): return c ## U def UINT64_C(c): return c ## UL def UINT64_C(c): return c ## ULL def INTMAX_C(c): return c ## L def UINTMAX_C(c): return c ## UL def INTMAX_C(c): return c ## LL def UINTMAX_C(c): return c ## ULL # Included from sys/types.h _SYS_TYPES_H = 1 # Included from bits/types.h _BITS_TYPES_H = 1 __FD_SETSIZE = 1024 def __FDELT(d): return ((d) / __NFDBITS) # Included from bits/pthreadtypes.h # Included from time.h _TIME_H = 1 # Included from bits/time.h # Included from posix/time.h # Included from posix/types.h MAXHOSTNAMELEN = 64 FD_SETSIZE = 1024 CLOCKS_PER_SEC = 1000000 _BITS_TIME_H = 1 CLOCKS_PER_SEC = 1000000 CLK_TCK = 100 _STRUCT_TIMEVAL = 1 CLK_TCK = CLOCKS_PER_SEC __clock_t_defined = 1 __time_t_defined = 1 __timespec_defined = 1 def __isleap(year): return \ __BIT_TYPES_DEFINED__ = 1 # Included from endian.h _ENDIAN_H = 1 __LITTLE_ENDIAN = 1234 __BIG_ENDIAN = 4321 __PDP_ENDIAN = 3412 # Included from bits/endian.h __BYTE_ORDER = __LITTLE_ENDIAN __FLOAT_WORD_ORDER = __BYTE_ORDER LITTLE_ENDIAN = __LITTLE_ENDIAN BIG_ENDIAN = __BIG_ENDIAN PDP_ENDIAN = __PDP_ENDIAN BYTE_ORDER = __BYTE_ORDER # Included from sys/select.h _SYS_SELECT_H = 1 # Included from bits/select.h def __FD_ZERO(fdsp): return \ def __FD_ZERO(set): return \ # Included from bits/sigset.h _SIGSET_H_types = 1 _SIGSET_H_fns = 1 def __sigmask(sig): return \ def __sigemptyset(set): return \ def __sigfillset(set): return \ def __sigisemptyset(set): return \ FD_SETSIZE = __FD_SETSIZE def FD_ZERO(fdsetp): return __FD_ZERO (fdsetp) # Included from sys/sysmacros.h _SYS_SYSMACROS_H = 1 def major(dev): return ( (( (dev) >> 8) & 0xff)) def minor(dev): return ( ((dev) & 0xff)) # Included from bits/socket.h PF_UNSPEC = 0 PF_LOCAL = 1 PF_UNIX = PF_LOCAL PF_FILE = PF_LOCAL PF_INET = 2 PF_AX25 = 3 PF_IPX = 4 PF_APPLETALK = 5 PF_NETROM = 6 PF_BRIDGE = 7 PF_ATMPVC = 8 PF_X25 = 9 PF_INET6 = 10 PF_ROSE = 11 PF_DECnet = 12 PF_NETBEUI = 13 PF_SECURITY = 14 PF_KEY = 15 PF_NETLINK = 16 PF_ROUTE = PF_NETLINK PF_PACKET = 17 PF_ASH = 18 PF_ECONET = 19 PF_ATMSVC = 20 PF_SNA = 22 PF_IRDA = 23 PF_MAX = 32 AF_UNSPEC = PF_UNSPEC AF_LOCAL = PF_LOCAL AF_UNIX = PF_UNIX AF_FILE = PF_FILE AF_INET = PF_INET AF_AX25 = PF_AX25 AF_IPX = PF_IPX AF_APPLETALK = PF_APPLETALK AF_NETROM = PF_NETROM AF_BRIDGE = PF_BRIDGE AF_ATMPVC = PF_ATMPVC AF_X25 = PF_X25 AF_INET6 = PF_INET6 AF_ROSE = PF_ROSE AF_DECnet = PF_DECnet AF_NETBEUI = PF_NETBEUI AF_SECURITY = PF_SECURITY AF_KEY = PF_KEY AF_NETLINK = PF_NETLINK AF_ROUTE = PF_ROUTE AF_PACKET = PF_PACKET AF_ASH = PF_ASH AF_ECONET = PF_ECONET AF_ATMSVC = PF_ATMSVC AF_SNA = PF_SNA AF_IRDA = PF_IRDA AF_MAX = PF_MAX SOL_RAW = 255 SOL_DECNET = 261 SOL_X25 = 262 SOL_PACKET = 263 SOL_ATM = 264 SOL_AAL = 265 SOL_IRDA = 266 SOMAXCONN = 128 # Included from bits/sockaddr.h _BITS_SOCKADDR_H = 1 def __SOCKADDR_COMMON(sa_prefix): return \ _SS_SIZE = 128 def CMSG_FIRSTHDR(mhdr): return \ # Included from atheos/socket.h # Included from atheos/types.h OS_NAME_LENGTH = 64 TRUE = 1 FALSE = 0 # Included from atheos/filesystem.h # Included from atheos/atomic.h # Included from atheos/typedefs.h # Included from atheos/fs_attribs.h # Included from atheos/kernel.h # Included from atheos/kdebug.h # Included from atheos/threads.h TF_DEADLOCK = 0x0001 DB_PACKET_SIZE = 128 DB_PORT_COUNT = 16 DBP_PRINTK = 0 DBP_DEBUGGER = 2 # Included from atheos/stdlib.h # Included from atheos/string.h def COMMON(x): return \ def COMMON(x): return \ # Included from atheos/schedule.h # Included from atheos/timer.h # Included from posix/resource.h RUSAGE_SELF = 0 RUSAGE_CHILDREN = -1 RLIMIT_CPU = 0 RLIMIT_FSIZE = 1 RLIMIT_DATA = 2 RLIMIT_STACK = 3 RLIMIT_CORE = 4 RLIMIT_RSS = 5 RLIMIT_MEMLOCK = 6 RLIMIT_NPROC = 7 RLIMIT_NOFILE = 8 RLIMIT_AS = 9 RLIM_NLIMITS = 10 # Included from atheos/v86.h # Included from atheos/areas.h MEMF_REAL = 0x00000002 MEMF_USER = 0x00000004 MEMF_BUFFER = 0x00000008 MEMF_KERNEL = 0x00000010 MEMF_OKTOFAILHACK = 0x00000020 MEMF_PRI_MASK = 0x000000ff MEMF_NOBLOCK = 0x00000100 MEMF_CLEAR = 0x00010000 MEMF_LOCKED = 0x10000000 PAGE_SHIFT = 12 PGDIR_SHIFT = 22 def PAGE_ALIGN(addr): return (((addr)+PAGE_SIZE-1)&PAGE_MASK) AREA_NO_LOCK = 0 AREA_LAZY_LOCK = 1 AREA_FULL_LOCK = 2 AREA_CONTIGUOUS = 3 AREA_READ = 0x00000001 AREA_WRITE = 0x00000002 AREA_EXEC = 0x00000004 AREA_FULL_ACCESS = (AREA_READ | AREA_WRITE | AREA_EXEC) AREA_KERNEL = 0x00000008 AREA_UNMAP_PHYS = 0x00000010 AREA_ANY_ADDRESS = 0x00000000 AREA_EXACT_ADDRESS = 0x00000100 AREA_BASE_ADDRESS = 0x00000200 AREA_CLONE_ADDRESS = 0x00000300 AREA_ADDR_SPEC_MASK = 0x00000f00 AREA_TOP_DOWN = 0x00001000 AREA_REMAPPED = 0x0020 AREA_SHARED = 0x0040 AREA_GROWSDOWN = 0x0080 AREA_FIRST_KERNEL_ADDRESS = 0x00100000 AREA_LAST_KERNEL_ADDRESS = 0x7fffffff AREA_FIRST_USER_ADDRESS = 0x80000000 AREA_LAST_USER_ADDRESS = 0xffffffff MAX_CPU_COUNT = 16 def kfree(p): return kassertw( __kfree(p) == 0 ) # Included from posix/dirent.h MAXNAMLEN = NAME_MAX MAXNAMLEN = 255 # Included from dirent.h _DIRENT_H = 1 # Included from bits/dirent.h def _D_ALLOC_NAMLEN(d): return (_D_EXACT_NAMLEN (d) + 1) def IFTODT(mode): return (((mode) & 0170000) >> 12) def DTTOIF(dirtype): return ((dirtype) << 12) def dirfd(dirp): return _DIR_dirfd (dirp) MAXNAMLEN = NAME_MAX MAXNAMLEN = 255 # Included from posix/stat.h S_IFMT = 00170000 S_IFSOCK = 0140000 S_IFLNK = 0120000 S_IFREG = 0100000 S_IFBLK = 0060000 S_IFDIR = 0040000 S_IFCHR = 0020000 S_IFIFO = 0010000 S_ISUID = 0004000 S_ISGID = 0002000 S_ISVTX = 0001000 def S_ISLNK(m): return (((m) & S_IFMT) == S_IFLNK) def S_ISREG(m): return (((m) & S_IFMT) == S_IFREG) def S_ISDIR(m): return (((m) & S_IFMT) == S_IFDIR) def S_ISCHR(m): return (((m) & S_IFMT) == S_IFCHR) def S_ISBLK(m): return (((m) & S_IFMT) == S_IFBLK) def S_ISFIFO(m): return (((m) & S_IFMT) == S_IFIFO) def S_ISSOCK(m): return (((m) & S_IFMT) == S_IFSOCK) S_IRWXU = 00700 S_IRUSR = 00400 S_IWUSR = 00200 S_IXUSR = 00100 S_IRWXG = 00070 S_IRGRP = 00040 S_IWGRP = 00020 S_IXGRP = 00010 S_IRWXO = 00007 S_IROTH = 00004 S_IWOTH = 00002 S_IXOTH = 00001 S_IRWXUGO = (S_IRWXU|S_IRWXG|S_IRWXO) S_IALLUGO = (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO) S_IRUGO = (S_IRUSR|S_IRGRP|S_IROTH) S_IWUGO = (S_IWUSR|S_IWGRP|S_IWOTH) S_IXUGO = (S_IXUSR|S_IXGRP|S_IXOTH) _STAT_VER_KERNEL = 0 # Included from posix/fcntl.h O_ACCMODE = 0003 O_RWMASK = O_ACCMODE O_RDONLY = 00 O_WRONLY = 01 O_RDWR = 02 O_CREAT = 0100 O_EXCL = 0200 O_NOCTTY = 0400 O_TRUNC = 01000 O_APPEND = 02000 O_NONBLOCK = 04000 O_NDELAY = O_NONBLOCK O_SYNC = 010000 O_FSYNC = O_SYNC O_ASYNC = 020000 FASYNC = O_ASYNC O_DIRECTORY = 040000 O_NOTRAVERSE = 0100000 O_NOFOLLOW = O_NOTRAVERSE F_DUPFD = 0 F_GETFD = 1 F_SETFD = 2 F_GETFL = 3 F_SETFL = 4 F_GETLK = 5 F_SETLK = 6 F_SETLKW = 7 F_SETOWN = 8 F_GETOWN = 9 F_SETSIG = 10 F_GETSIG = 11 F_COPYFD = 12 FD_CLOEXEC = 1 F_RDLCK = 0 F_WRLCK = 1 F_UNLCK = 2 F_EXLCK = 4 F_SHLCK = 8 LOCK_SH = 1 LOCK_EX = 2 LOCK_NB = 4 LOCK_UN = 8 # Included from posix/uio.h UIO_FASTIOV = 8 UIO_MAXIOV = 1024 MNTF_READONLY = 0x0001 FS_IS_READONLY = 0x00000001 FS_IS_REMOVABLE = 0x00000002 FS_IS_PERSISTENT = 0x00000004 FS_IS_SHARED = 0x00000008 FS_IS_BLOCKBASED = 0x00000010 FS_CAN_MOUNT = 0x00000020 FS_HAS_MIME = 0x00010000 FS_HAS_ATTR = 0x00020000 FS_HAS_QUERY = 0x00040000 FSINFO_VERSION = 1 WSTAT_MODE = 0x0001 WSTAT_UID = 0x0002 WSTAT_GID = 0x0004 WSTAT_SIZE = 0x0008 WSTAT_ATIME = 0x0010 WSTAT_MTIME = 0x0020 WSTAT_CTIME = 0x0040 WFSSTAT_NAME = 0x0001 FSDRIVER_API_VERSION = 1 # Included from net/nettypes.h IP_ADR_LEN = 4 INADDR_ANY = 0x00000000 INADDR_BROADCAST = 0xffffffff INADDR_LOOPBACK = 0x7f000001 def CMSG_ALIGN(len): return ( ((len)+sizeof(long)-1) & ~(sizeof(long)-1) ) PROT_SOCK = 1024 SHUTDOWN_MASK = 3 RCV_SHUTDOWN = 1 SEND_SHUTDOWN = 2 SOCK_STREAM = 1 SOCK_DGRAM = 2 SOCK_RAW = 3 SOCK_RDM = 4 SOCK_SEQPACKET = 5 SOCK_PACKET = 10 PF_UNSPEC = 0 PF_LOCAL = 1 PF_UNIX = PF_LOCAL PF_FILE = PF_LOCAL PF_INET = 2 PF_AX25 = 3 PF_IPX = 4 PF_APPLETALK = 5 PF_NETROM = 6 PF_BRIDGE = 7 PF_ATMPVC = 8 PF_X25 = 9 PF_INET6 = 10 PF_ROSE = 11 PF_DECnet = 12 PF_NETBEUI = 13 PF_SECURITY = 14 PF_KEY = 15 PF_NETLINK = 16 PF_ROUTE = PF_NETLINK PF_PACKET = 17 PF_ASH = 18 PF_ECONET = 19 PF_ATMSVC = 20 PF_SNA = 22 PF_IRDA = 23 PF_MAX = 32 AF_UNSPEC = PF_UNSPEC AF_LOCAL = PF_LOCAL AF_UNIX = PF_UNIX AF_FILE = PF_FILE AF_INET = PF_INET AF_AX25 = PF_AX25 AF_IPX = PF_IPX AF_APPLETALK = PF_APPLETALK AF_NETROM = PF_NETROM AF_BRIDGE = PF_BRIDGE AF_ATMPVC = PF_ATMPVC AF_X25 = PF_X25 AF_INET6 = PF_INET6 AF_ROSE = PF_ROSE AF_DECnet = PF_DECnet AF_NETBEUI = PF_NETBEUI AF_SECURITY = PF_SECURITY AF_KEY = PF_KEY AF_NETLINK = PF_NETLINK AF_ROUTE = PF_ROUTE AF_PACKET = PF_PACKET AF_ASH = PF_ASH AF_ECONET = PF_ECONET AF_ATMSVC = PF_ATMSVC AF_SNA = PF_SNA AF_IRDA = PF_IRDA AF_MAX = PF_MAX PF_UNIX = 1 AF_UNIX = PF_UNIX PF_INET = 2 AF_INET = PF_INET SOMAXCONN = 128 MSG_OOB = 1 MSG_PEEK = 2 MSG_DONTROUTE = 4 MSG_PROXY = 16 SOL_SOCKET = 1 SO_DEBUG = 1 SO_REUSEADDR = 2 SO_TYPE = 3 SO_ERROR = 4 SO_DONTROUTE = 5 SO_BROADCAST = 6 SO_SNDBUF = 7 SO_RCVBUF = 8 SO_KEEPALIVE = 9 SO_OOBINLINE = 10 SO_NO_CHECK = 11 SO_PRIORITY = 12 SO_LINGER = 13 SO_BSDCOMPAT = 14 SOL_IP = 0 SOL_IPX = 256 SOL_AX25 = 257 SOL_ATALK = 258 SOL_NETROM = 259 SOL_TCP = 6 SOL_UDP = 17 IP_TOS = 1 IPTOS_LOWDELAY = 0x10 IPTOS_THROUGHPUT = 0x08 IPTOS_RELIABILITY = 0x04 IPTOS_MINCOST = 0x02 IP_TTL = 2 IP_HDRINCL = 3 IP_OPTIONS = 4 IP_MULTICAST_IF = 32 IP_MULTICAST_TTL = 33 IP_MULTICAST_LOOP = 34 IP_ADD_MEMBERSHIP = 35 IP_DROP_MEMBERSHIP = 36 TCP_NODELAY = 0x01 TCP_MAXSEG = 0x02 def IN_CLASSA(a): return ((( (a)) & 0x80000000) == 0) IN_CLASSA_NET = 0xff000000 IN_CLASSA_NSHIFT = 24 IN_CLASSA_HOST = (0xffffffff & ~IN_CLASSA_NET) IN_CLASSA_MAX = 128 def IN_CLASSB(a): return ((( (a)) & 0xc0000000) == 0x80000000) IN_CLASSB_NET = 0xffff0000 IN_CLASSB_NSHIFT = 16 IN_CLASSB_HOST = (0xffffffff & ~IN_CLASSB_NET) IN_CLASSB_MAX = 65536 def IN_CLASSC(a): return ((( (a)) & 0xe0000000) == 0xc0000000) IN_CLASSC_NET = 0xffffff00 IN_CLASSC_NSHIFT = 8 IN_CLASSC_HOST = (0xffffffff & ~IN_CLASSC_NET) def IN_CLASSD(a): return ((( (a)) & 0xf0000000) == 0xe0000000) def IN_MULTICAST(a): return IN_CLASSD(a) def IN_EXPERIMENTAL(a): return ((( (a)) & 0xe0000000) == 0xe0000000) def IN_BADCLASS(a): return ((( (a)) & 0xf0000000) == 0xf0000000) INADDR_ANY = ( 0x00000000) INADDR_BROADCAST = ( 0xffffffff) INADDR_NONE = ( 0xffffffff) IN_LOOPBACKNET = 127 INADDR_LOOPBACK = ( 0x7f000001) INADDR_UNSPEC_GROUP = ( 0xe0000000) INADDR_ALLHOSTS_GROUP = ( 0xe0000001) INADDR_ALLRTRS_GROUP = ( 0xe0000002) INADDR_MAX_LOCAL_GROUP = ( 0xe00000ff) INET_ADDRSTRLEN = 16 INET6_ADDRSTRLEN = 46 # Included from bits/in.h IP_TOS = 1 IP_TTL = 2 IP_HDRINCL = 3 IP_OPTIONS = 4 IP_ROUTER_ALERT = 5 IP_RECVOPTS = 6 IP_RETOPTS = 7 IP_PKTINFO = 8 IP_PKTOPTIONS = 9 IP_PMTUDISC = 10 IP_MTU_DISCOVER = 10 IP_RECVERR = 11 IP_RECVTTL = 12 IP_RECVTOS = 13 IP_MULTICAST_IF = 32 IP_MULTICAST_TTL = 33 IP_MULTICAST_LOOP = 34 IP_ADD_MEMBERSHIP = 35 IP_DROP_MEMBERSHIP = 36 IP_RECVRETOPTS = IP_RETOPTS IP_PMTUDISC_DONT = 0 IP_PMTUDISC_WANT = 1 IP_PMTUDISC_DO = 2 SOL_IP = 0 SOL_SOCKET = 1 IP_DEFAULT_MULTICAST_TTL = 1 IP_DEFAULT_MULTICAST_LOOP = 1 IP_MAX_MEMBERSHIPS = 20 IPV6_ADDRFORM = 1 IPV6_PKTINFO = 2 IPV6_HOPOPTS = 3 IPV6_DSTOPTS = 4 IPV6_RXSRCRT = 5 IPV6_PKTOPTIONS = 6 IPV6_CHECKSUM = 7 IPV6_HOPLIMIT = 8 IPV6_NEXTHOP = 9 IPV6_AUTHHDR = 10 IPV6_UNICAST_HOPS = 16 IPV6_MULTICAST_IF = 17 IPV6_MULTICAST_HOPS = 18 IPV6_MULTICAST_LOOP = 19 IPV6_ADD_MEMBERSHIP = 20 IPV6_DROP_MEMBERSHIP = 21 IPV6_ROUTER_ALERT = 22 SCM_SRCRT = IPV6_RXSRCRT IPV6_RXHOPOPTS = IPV6_HOPOPTS IPV6_RXDSTOPTS = IPV6_DSTOPTS IPV6_PMTUDISC_DONT = 0 IPV6_PMTUDISC_WANT = 1 IPV6_PMTUDISC_DO = 2 SOL_IPV6 = 41 SOL_ICMPV6 = 58 # Included from bits/byteswap.h def __bswap_constant_16(x): return \ def __bswap_16(x): return \ def __bswap_16(x): return __bswap_constant_16 (x) def __bswap_constant_32(x): return \ def __bswap_32(x): return \ def __bswap_32(x): return \ def __bswap_32(x): return __bswap_constant_32 (x) def __bswap_64(x): return \ def ntohl(x): return (x) def ntohs(x): return (x) def htonl(x): return (x) def htons(x): return (x) def ntohl(x): return __bswap_32 (x) def ntohs(x): return __bswap_16 (x) def htonl(x): return __bswap_32 (x) def htons(x): return __bswap_16 (x) def IN6_IS_ADDR_UNSPECIFIED(a): return \ def IN6_IS_ADDR_LOOPBACK(a): return \ def IN6_IS_ADDR_LINKLOCAL(a): return \ def IN6_IS_ADDR_SITELOCAL(a): return \ def IN6_IS_ADDR_V4MAPPED(a): return \ def IN6_IS_ADDR_V4COMPAT(a): return \ def IN6_IS_ADDR_MC_NODELOCAL(a): return \ def IN6_IS_ADDR_MC_LINKLOCAL(a): return \ def IN6_IS_ADDR_MC_SITELOCAL(a): return \ def IN6_IS_ADDR_MC_ORGLOCAL(a): return \ def IN6_IS_ADDR_MC_GLOBAL(a): return \ --- NEW FILE: TYPES.py --- # Generated by h2py from /include/sys/types.h _SYS_TYPES_H = 1 # Included from features.h _FEATURES_H = 1 __USE_ANSI = 1 __FAVOR_BSD = 1 _ISOC9X_SOURCE = 1 _POSIX_SOURCE = 1 _POSIX_C_SOURCE = 199506L _XOPEN_SOURCE = 500 _XOPEN_SOURCE_EXTENDED = 1 _LARGEFILE64_SOURCE = 1 _BSD_SOURCE = 1 _SVID_SOURCE = 1 _BSD_SOURCE = 1 _SVID_SOURCE = 1 __USE_ISOC9X = 1 _POSIX_SOURCE = 1 _POSIX_C_SOURCE = 2 _POSIX_C_SOURCE = 199506L __USE_POSIX = 1 __USE_POSIX2 = 1 __USE_POSIX199309 = 1 __USE_POSIX199506 = 1 __USE_XOPEN = 1 __USE_XOPEN_EXTENDED = 1 __USE_UNIX98 = 1 _LARGEFILE_SOURCE = 1 __USE_XOPEN_EXTENDED = 1 __USE_LARGEFILE = 1 __USE_LARGEFILE64 = 1 __USE_FILE_OFFSET64 = 1 __USE_MISC = 1 __USE_BSD = 1 __USE_SVID = 1 __USE_GNU = 1 __USE_REENTRANT = 1 __STDC_IEC_559__ = 1 __STDC_IEC_559_COMPLEX__ = 1 __GNU_LIBRARY__ = 6 __GLIBC__ = 2 __GLIBC_MINOR__ = 1 # Included from sys/cdefs.h _SYS_CDEFS_H = 1 def __PMT(args): return args def __P(args): return args def __PMT(args): return args def __P(args): return () def __PMT(args): return () def __STRING(x): return #x def __STRING(x): return "x" def __ASMNAME(cname): return __ASMNAME2 (__USER_LABEL_PREFIX__, cname) def __attribute__(xyz): return __USE_EXTERN_INLINES = 1 # Included from gnu/stubs.h # Included from bits/types.h _BITS_TYPES_H = 1 __FD_SETSIZE = 1024 def __FDELT(d): return ((d) / __NFDBITS) # Included from bits/pthreadtypes.h # Included from time.h _TIME_H = 1 # Included from bits/time.h # Included from posix/time.h # Included from posix/types.h MAXHOSTNAMELEN = 64 FD_SETSIZE = 1024 CLOCKS_PER_SEC = 1000000 _BITS_TIME_H = 1 CLOCKS_PER_SEC = 1000000 CLK_TCK = 100 _STRUCT_TIMEVAL = 1 CLK_TCK = CLOCKS_PER_SEC __clock_t_defined = 1 __time_t_defined = 1 __timespec_defined = 1 def __isleap(year): return \ __BIT_TYPES_DEFINED__ = 1 # Included from endian.h _ENDIAN_H = 1 __LITTLE_ENDIAN = 1234 __BIG_ENDIAN = 4321 __PDP_ENDIAN = 3412 # Included from bits/endian.h __BYTE_ORDER = __LITTLE_ENDIAN __FLOAT_WORD_ORDER = __BYTE_ORDER LITTLE_ENDIAN = __LITTLE_ENDIAN BIG_ENDIAN = __BIG_ENDIAN PDP_ENDIAN = __PDP_ENDIAN BYTE_ORDER = __BYTE_ORDER # Included from sys/select.h _SYS_SELECT_H = 1 # Included from bits/select.h def __FD_ZERO(fdsp): return \ def __FD_ZERO(set): return \ # Included from bits/sigset.h _SIGSET_H_types = 1 _SIGSET_H_fns = 1 def __sigmask(sig): return \ def __sigemptyset(set): return \ def __sigfillset(set): return \ def __sigisemptyset(set): return \ FD_SETSIZE = __FD_SETSIZE def FD_ZERO(fdsetp): return __FD_ZERO (fdsetp) # Included from sys/sysmacros.h _SYS_SYSMACROS_H = 1 def major(dev): return ( (( (dev) >> 8) & 0xff)) def minor(dev): return ( ((dev) & 0xff)) --- NEW FILE: regen --- #! /bin/sh set -v python$EXE ../../Tools/scripts/h2py.py -i '\(u_long\)' -i '\(uint32_t\)' -i '\(int\)' -i '\(unsigned int\)' /include/netinet/in.h /include/sys/types.h From mwh@users.sourceforge.net Tue Jun 11 11:55:13 2002 From: mwh@users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue, 11 Jun 2002 03:55:13 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.422,1.423 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv9709/Misc Modified Files: NEWS Log Message: This is my nearly two year old patch [ 400998 ] experimental support for extended slicing on lists somewhat spruced up and better tested than it was when I wrote it. Includes docs & tests. The whatsnew section needs expanding, and arrays should support extended slices -- later. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.422 retrieving revision 1.423 diff -C2 -d -r1.422 -r1.423 *** NEWS 11 Jun 2002 06:22:31 -0000 1.422 --- NEWS 11 Jun 2002 10:55:10 -0000 1.423 *************** *** 7,10 **** --- 7,14 ---- Core and builtins + - Most builtin sequences now support "extended slices", i.e. slices + with a third "stride" parameter. For example, "range(10)[1:6:2]" + evaluates to [1, 3, 5]. + - Cycles going through the __class__ link of a new-style instance are now detected by the garbage collector. From mwh@users.sourceforge.net Tue Jun 11 11:55:14 2002 From: mwh@users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue, 11 Jun 2002 03:55:14 -0700 Subject: [Python-checkins] python/dist/src/Objects listobject.c,2.108,2.109 sliceobject.c,2.12,2.13 stringobject.c,2.165,2.166 tupleobject.c,2.64,2.65 unicodeobject.c,2.151,2.152 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv9709/Objects Modified Files: listobject.c sliceobject.c stringobject.c tupleobject.c unicodeobject.c Log Message: This is my nearly two year old patch [ 400998 ] experimental support for extended slicing on lists somewhat spruced up and better tested than it was when I wrote it. Includes docs & tests. The whatsnew section needs expanding, and arrays should support extended slices -- later. Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.108 retrieving revision 2.109 diff -C2 -d -r2.108 -r2.109 *** listobject.c 1 Jun 2002 05:22:55 -0000 2.108 --- listobject.c 11 Jun 2002 10:55:11 -0000 2.109 *************** *** 1685,1688 **** --- 1685,1874 ---- staticforward PyObject * list_iter(PyObject *seq); + static PyObject* + list_subscript(PyListObject* self, PyObject* item) + { + if (PyInt_Check(item)) { + long i = PyInt_AS_LONG(item); + if (i < 0) + i += PyList_GET_SIZE(self); + return list_item(self, i); + } + else if (PyLong_Check(item)) { + long i = PyLong_AsLong(item); + if (i == -1 && PyErr_Occurred()) + return NULL; + if (i < 0) + i += PyList_GET_SIZE(self); + return list_item(self, i); + } + else if (PySlice_Check(item)) { + int start, stop, step, slicelength, cur, i; + PyObject* result; + PyObject* it; + + if (PySlice_GetIndicesEx((PySliceObject*)item, self->ob_size, + &start, &stop, &step, &slicelength) < 0) { + return NULL; + } + + if (slicelength <= 0) { + return PyList_New(0); + } + else { + result = PyList_New(slicelength); + if (!result) return NULL; + + for (cur = start, i = 0; i < slicelength; + cur += step, i++) { + it = PyList_GET_ITEM(self, cur); + Py_INCREF(it); + PyList_SET_ITEM(result, i, it); + } + + return result; + } + } + else { + PyErr_SetString(PyExc_TypeError, + "list indices must be integers"); + return NULL; + } + } + + static int + list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value) + { + if (PyInt_Check(item)) { + long i = PyInt_AS_LONG(item); + if (i < 0) + i += PyList_GET_SIZE(self); + return list_ass_item(self, i, value); + } + else if (PyLong_Check(item)) { + long i = PyLong_AsLong(item); + if (i == -1 && PyErr_Occurred()) + return -1; + if (i < 0) + i += PyList_GET_SIZE(self); + return list_ass_item(self, i, value); + } + else if (PySlice_Check(item)) { + int start, stop, step, slicelength; + + if (PySlice_GetIndicesEx((PySliceObject*)item, self->ob_size, + &start, &stop, &step, &slicelength) < 0) { + return -1; + } + + if (value == NULL) { + /* delete slice */ + PyObject **garbage, **item; + int cur, i, j; + + if (slicelength <= 0) + return 0; + + if (step < 0) { + stop = start + 1; + start = stop + step*(slicelength - 1) - 1; + step = -step; + } + + garbage = (PyObject**) + PyMem_MALLOC(slicelength*sizeof(PyObject*)); + + /* drawing pictures might help + understand these for loops */ + for (cur = start, i = 0; cur < stop; cur += step, i++) { + garbage[i] = PyList_GET_ITEM(self, cur); + + for (j = 0; j < step; j++) { + PyList_SET_ITEM(self, cur + j - i, + PyList_GET_ITEM(self, cur + j + 1)); + } + } + for (cur = start + slicelength*step + 1; + cur < self->ob_size; cur++) { + PyList_SET_ITEM(self, cur - slicelength, + PyList_GET_ITEM(self, cur)); + } + self->ob_size -= slicelength; + item = self->ob_item; + NRESIZE(item, PyObject*, self->ob_size); + self->ob_item = item; + + for (i = 0; i < slicelength; i++) { + Py_DECREF(garbage[i]); + } + PyMem_FREE(garbage); + + return 0; + } + else { + /* assign slice */ + PyObject **garbage, *ins; + int cur, i; + + if (!PyList_Check(value)) { + PyErr_Format(PyExc_TypeError, + "must assign list (not \"%.200s\") to slice", + value->ob_type->tp_name); + return -1; + } + + if (PyList_GET_SIZE(value) != slicelength) { + PyErr_Format(PyExc_ValueError, + "attempt to assign list of size %d to extended slice of size %d", + PyList_Size(value), slicelength); + return -1; + } + + if (!slicelength) + return 0; + + /* protect against a[::-1] = a */ + if (self == (PyListObject*)value) { + value = list_slice((PyListObject*)value, 0, + PyList_GET_SIZE(value)); + } + else { + Py_INCREF(value); + } + + garbage = (PyObject**) + PyMem_MALLOC(slicelength*sizeof(PyObject*)); + + for (cur = start, i = 0; i < slicelength; + cur += step, i++) { + garbage[i] = PyList_GET_ITEM(self, cur); + + ins = PyList_GET_ITEM(value, i); + Py_INCREF(ins); + PyList_SET_ITEM(self, cur, ins); + } + + for (i = 0; i < slicelength; i++) { + Py_DECREF(garbage[i]); + } + + PyMem_FREE(garbage); + Py_DECREF(value); + + return 0; + } + } + else { + PyErr_SetString(PyExc_TypeError, + "list indices must be integers"); + return -1; + } + } + + static PyMappingMethods list_as_mapping = { + (inquiry)list_length, + (binaryfunc)list_subscript, + (objobjargproc)list_ass_subscript + }; + PyTypeObject PyList_Type = { PyObject_HEAD_INIT(&PyType_Type) *************** *** 1699,1703 **** 0, /* tp_as_number */ &list_as_sequence, /* tp_as_sequence */ ! 0, /* tp_as_mapping */ list_nohash, /* tp_hash */ 0, /* tp_call */ --- 1885,1889 ---- 0, /* tp_as_number */ &list_as_sequence, /* tp_as_sequence */ ! &list_as_mapping, /* tp_as_mapping */ list_nohash, /* tp_hash */ 0, /* tp_call */ Index: sliceobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/sliceobject.c,v retrieving revision 2.12 retrieving revision 2.13 diff -C2 -d -r2.12 -r2.13 *** sliceobject.c 12 Apr 2002 03:04:15 -0000 2.12 --- sliceobject.c 11 Jun 2002 10:55:11 -0000 2.13 *************** *** 110,113 **** --- 110,166 ---- } + int + PySlice_GetIndicesEx(PySliceObject *r, int length, + int *start, int *stop, int *step, int *slicelength) + { + /* this is harder to get right than you might think */ + int defstart, defstop; + + if (r->step == Py_None) { + *step = 1; + } else { + *step = PyInt_AsLong(r->step); + if (*step == -1 && PyErr_Occurred()) { + return -1; + } + else if (*step == 0) { + PyErr_SetString(PyExc_ValueError, + "slice step cannot be zero"); + return -1; + } + } + + defstart = *step < 0 ? length-1 : 0; + defstop = *step < 0 ? -1 : length; + + if (r->start == Py_None) { + *start = defstart; + } else { + if (!_PyEval_SliceIndex(r->start, start)) return -1; + if (*start < 0) *start += length; + if (*start < 0) *start = (*step < 0) ? -1 : 0; + if (*start >= length) + *start = (*step < 0) ? length - 1 : length; + } + + if (r->stop == Py_None) { + *stop = defstop; + } else { + if (!_PyEval_SliceIndex(r->stop, stop)) return -1; + if (*stop < 0) *stop += length; + if (*stop < 0) *stop = -1; + if (*stop > length) *stop = length; + } + + if (*step < 0) { + *slicelength = (*stop-*start+1)/(*step)+1; + } else { + *slicelength = (*stop-*start-1)/(*step)+1; + } + if (*slicelength < 0) *slicelength = 0; + + return 0; + } + static void slice_dealloc(PySliceObject *r) Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.165 retrieving revision 2.166 diff -C2 -d -r2.165 -r2.166 *** stringobject.c 31 May 2002 19:58:01 -0000 2.165 --- stringobject.c 11 Jun 2002 10:55:11 -0000 2.166 *************** *** 941,944 **** --- 941,998 ---- } + static PyObject* + string_subscript(PyStringObject* self, PyObject* item) + { + if (PyInt_Check(item)) { + long i = PyInt_AS_LONG(item); + if (i < 0) + i += PyString_GET_SIZE(self); + return string_item(self,i); + } + else if (PyLong_Check(item)) { + long i = PyLong_AsLong(item); + if (i == -1 && PyErr_Occurred()) + return NULL; + if (i < 0) + i += PyString_GET_SIZE(self); + return string_item(self,i); + } + else if (PySlice_Check(item)) { + int start, stop, step, slicelength, cur, i; + char* source_buf; + char* result_buf; + PyObject* result; + + if (PySlice_GetIndicesEx((PySliceObject*)item, + PyString_GET_SIZE(self), + &start, &stop, &step, &slicelength) < 0) { + return NULL; + } + + if (slicelength <= 0) { + return PyString_FromStringAndSize("", 0); + } + else { + source_buf = PyString_AsString((PyObject*)self); + result_buf = PyMem_Malloc(slicelength); + + for (cur = start, i = 0; i < slicelength; + cur += step, i++) { + result_buf[i] = source_buf[cur]; + } + + result = PyString_FromStringAndSize(result_buf, + slicelength); + PyMem_Free(result_buf); + return result; + } + } + else { + PyErr_SetString(PyExc_TypeError, + "string indices must be integers"); + return NULL; + } + } + static int string_buffer_getreadbuf(PyStringObject *self, int index, const void **ptr) *************** *** 992,995 **** --- 1046,1055 ---- }; + static PyMappingMethods string_as_mapping = { + (inquiry)string_length, + (binaryfunc)string_subscript, + 0, + }; + static PyBufferProcs string_as_buffer = { (getreadbufferproc)string_buffer_getreadbuf, *************** *** 2930,2934 **** 0, /* tp_as_number */ &string_as_sequence, /* tp_as_sequence */ ! 0, /* tp_as_mapping */ (hashfunc)string_hash, /* tp_hash */ 0, /* tp_call */ --- 2990,2994 ---- 0, /* tp_as_number */ &string_as_sequence, /* tp_as_sequence */ ! &string_as_mapping, /* tp_as_mapping */ (hashfunc)string_hash, /* tp_hash */ 0, /* tp_call */ *************** *** 3350,3354 **** argidx = -2; } ! if (args->ob_type->tp_as_mapping) dict = args; while (--fmtcnt >= 0) { --- 3410,3414 ---- argidx = -2; } ! if (args->ob_type->tp_as_mapping && !PyTuple_Check(args)) dict = args; while (--fmtcnt >= 0) { Index: tupleobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/tupleobject.c,v retrieving revision 2.64 retrieving revision 2.65 diff -C2 -d -r2.64 -r2.65 *** tupleobject.c 12 Apr 2002 03:05:52 -0000 2.64 --- tupleobject.c 11 Jun 2002 10:55:12 -0000 2.65 *************** *** 542,545 **** --- 542,602 ---- }; + static PyObject* + tuplesubscript(PyTupleObject* self, PyObject* item) + { + if (PyInt_Check(item)) { + long i = PyInt_AS_LONG(item); + if (i < 0) + i += PyTuple_GET_SIZE(self); + return tupleitem(self, i); + } + else if (PyLong_Check(item)) { + long i = PyLong_AsLong(item); + if (i == -1 && PyErr_Occurred()) + return NULL; + if (i < 0) + i += PyTuple_GET_SIZE(self); + return tupleitem(self, i); + } + else if (PySlice_Check(item)) { + int start, stop, step, slicelength, cur, i; + PyObject* result; + PyObject* it; + + if (PySlice_GetIndicesEx((PySliceObject*)item, + PyTuple_GET_SIZE(self), + &start, &stop, &step, &slicelength) < 0) { + return NULL; + } + + if (slicelength <= 0) { + return PyTuple_New(0); + } + else { + result = PyTuple_New(slicelength); + + for (cur = start, i = 0; i < slicelength; + cur += step, i++) { + it = PyTuple_GET_ITEM(self, cur); + Py_INCREF(it); + PyTuple_SET_ITEM(result, i, it); + } + + return result; + } + } + else { + PyErr_SetString(PyExc_TypeError, + "tuple indices must be integers"); + return NULL; + } + } + + static PyMappingMethods tuple_as_mapping = { + (inquiry)tuplelength, + (binaryfunc)tuplesubscript, + 0 + }; + PyTypeObject PyTuple_Type = { PyObject_HEAD_INIT(&PyType_Type) *************** *** 556,560 **** 0, /* tp_as_number */ &tuple_as_sequence, /* tp_as_sequence */ ! 0, /* tp_as_mapping */ (hashfunc)tuplehash, /* tp_hash */ 0, /* tp_call */ --- 613,617 ---- 0, /* tp_as_number */ &tuple_as_sequence, /* tp_as_sequence */ ! &tuple_as_mapping, /* tp_as_mapping */ (hashfunc)tuplehash, /* tp_hash */ 0, /* tp_call */ Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.151 retrieving revision 2.152 diff -C2 -d -r2.151 -r2.152 *** unicodeobject.c 29 May 2002 13:46:29 -0000 2.151 --- unicodeobject.c 11 Jun 2002 10:55:12 -0000 2.152 *************** *** 5062,5065 **** --- 5062,5117 ---- }; + static PyObject* + unicode_subscript(PyUnicodeObject* self, PyObject* item) + { + if (PyInt_Check(item)) { + long i = PyInt_AS_LONG(item); + if (i < 0) + i += PyString_GET_SIZE(self); + return unicode_getitem(self, i); + } else if (PyLong_Check(item)) { + long i = PyLong_AsLong(item); + if (i == -1 && PyErr_Occurred()) + return NULL; + if (i < 0) + i += PyString_GET_SIZE(self); + return unicode_getitem(self, i); + } else if (PySlice_Check(item)) { + int start, stop, step, slicelength, cur, i; + Py_UNICODE* source_buf; + Py_UNICODE* result_buf; + PyObject* result; + + if (PySlice_GetIndicesEx((PySliceObject*)item, PyString_GET_SIZE(self), + &start, &stop, &step, &slicelength) < 0) { + return NULL; + } + + if (slicelength <= 0) { + return PyUnicode_FromUnicode(NULL, 0); + } else { + source_buf = PyUnicode_AS_UNICODE((PyObject*)self); + result_buf = PyMem_MALLOC(slicelength*sizeof(Py_UNICODE)); + + for (cur = start, i = 0; i < slicelength; cur += step, i++) { + result_buf[i] = source_buf[cur]; + } + + result = PyUnicode_FromUnicode(result_buf, slicelength); + PyMem_FREE(result_buf); + return result; + } + } else { + PyErr_SetString(PyExc_TypeError, "string indices must be integers"); + return NULL; + } + } + + static PyMappingMethods unicode_as_mapping = { + (inquiry)unicode_length, /* mp_length */ + (binaryfunc)unicode_subscript, /* mp_subscript */ + (objobjargproc)0, /* mp_ass_subscript */ + }; + static int unicode_buffer_getreadbuf(PyUnicodeObject *self, *************** *** 5356,5360 **** argidx = -2; } ! if (args->ob_type->tp_as_mapping) dict = args; --- 5408,5412 ---- argidx = -2; } ! if (args->ob_type->tp_as_mapping && !PyTuple_Check(args)) dict = args; *************** *** 5818,5822 **** 0, /* tp_as_number */ &unicode_as_sequence, /* tp_as_sequence */ ! 0, /* tp_as_mapping */ (hashfunc) unicode_hash, /* tp_hash*/ 0, /* tp_call*/ --- 5870,5874 ---- 0, /* tp_as_number */ &unicode_as_sequence, /* tp_as_sequence */ ! &unicode_as_mapping, /* tp_as_mapping */ (hashfunc) unicode_hash, /* tp_hash*/ 0, /* tp_call*/ From mwh@users.sourceforge.net Tue Jun 11 11:55:41 2002 From: mwh@users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue, 11 Jun 2002 03:55:41 -0700 Subject: [Python-checkins] python/dist/src/Include sliceobject.h,2.5,2.6 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv9709/Include Modified Files: sliceobject.h Log Message: This is my nearly two year old patch [ 400998 ] experimental support for extended slicing on lists somewhat spruced up and better tested than it was when I wrote it. Includes docs & tests. The whatsnew section needs expanding, and arrays should support extended slices -- later. Index: sliceobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/sliceobject.h,v retrieving revision 2.5 retrieving revision 2.6 diff -C2 -d -r2.5 -r2.6 *** sliceobject.h 9 Jul 2000 00:55:06 -0000 2.5 --- sliceobject.h 11 Jun 2002 10:55:09 -0000 2.6 *************** *** 33,36 **** --- 33,39 ---- DL_IMPORT(int) PySlice_GetIndices(PySliceObject *r, int length, int *start, int *stop, int *step); + DL_IMPORT(int) PySlice_GetIndicesEx(PySliceObject *r, int length, + int *start, int *stop, + int *step, int *slicelength); #ifdef __cplusplus From mwh@users.sourceforge.net Tue Jun 11 11:55:41 2002 From: mwh@users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue, 11 Jun 2002 03:55:41 -0700 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew23.tex,1.23,1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory usw-pr-cvs1:/tmp/cvs-serv9709/Doc/whatsnew Modified Files: whatsnew23.tex Log Message: This is my nearly two year old patch [ 400998 ] experimental support for extended slicing on lists somewhat spruced up and better tested than it was when I wrote it. Includes docs & tests. The whatsnew section needs expanding, and arrays should support extended slices -- later. Index: whatsnew23.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew23.tex,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** whatsnew23.tex 10 Jun 2002 18:58:19 -0000 1.23 --- whatsnew23.tex 11 Jun 2002 10:55:09 -0000 1.24 *************** *** 337,340 **** --- 337,349 ---- \end{seealso} + \section{Extended Slices\label{extended-slices}} + + Ever since Python 1.4 the slice syntax has supported a third + ``stride'' argument, but the builtin sequence types have not supported + this feature (it was initially included at the behest of the + developers of the Numerical Python package). This changes with Python + 2.3. + + % XXX examples, etc. %====================================================================== From mwh@users.sourceforge.net Tue Jun 11 11:55:42 2002 From: mwh@users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue, 11 Jun 2002 03:55:42 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_bool.py,1.5,1.6 test_types.py,1.29,1.30 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv9709/Lib/test Modified Files: test_bool.py test_types.py Log Message: This is my nearly two year old patch [ 400998 ] experimental support for extended slicing on lists somewhat spruced up and better tested than it was when I wrote it. Includes docs & tests. The whatsnew section needs expanding, and arrays should support extended slices -- later. Index: test_bool.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_bool.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_bool.py 20 May 2002 14:22:28 -0000 1.5 --- test_bool.py 11 Jun 2002 10:55:09 -0000 1.6 *************** *** 220,224 **** veris(operator.contains([], 1), False) veris(operator.contains([1], 1), True) ! veris(operator.isMappingType([]), False) veris(operator.isMappingType({}), True) veris(operator.lt(0, 0), False) --- 220,224 ---- veris(operator.contains([], 1), False) veris(operator.contains([1], 1), True) ! veris(operator.isMappingType(1), False) veris(operator.isMappingType({}), True) veris(operator.lt(0, 0), False) Index: test_types.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_types.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** test_types.py 2 May 2002 04:27:20 -0000 1.29 --- test_types.py 11 Jun 2002 10:55:09 -0000 1.30 *************** *** 189,192 **** --- 189,217 ---- if '%s!'%x != x+'!': raise TestFailed, 'nasty string formatting bug' + #extended slices for strings + a = '0123456789' + vereq(a[::], a) + vereq(a[::2], '02468') + vereq(a[1::2], '13579') + vereq(a[::-1],'9876543210') + vereq(a[::-2], '97531') + vereq(a[3::-2], '31') + vereq(a[-100:100:], a) + vereq(a[100:-100:-1], a[::-1]) + vereq(a[-100L:100L:2L], '02468') + + if have_unicode: + a = unicode('0123456789', 'ascii') + vereq(a[::], a) + vereq(a[::2], unicode('02468', 'ascii')) + vereq(a[1::2], unicode('13579', 'ascii')) + vereq(a[::-1], unicode('9876543210', 'ascii')) + vereq(a[::-2], unicode('97531', 'ascii')) + vereq(a[3::-2], unicode('31', 'ascii')) + vereq(a[-100:100:], a) + vereq(a[100:-100:-1], a[::-1]) + vereq(a[-100L:100L:2L], unicode('02468', 'ascii')) + + print '6.5.2 Tuples' if len(()) != 0: raise TestFailed, 'len(())' *************** *** 208,211 **** --- 233,249 ---- if x != (1,): raise TestFailed, 'tuple resize from () failed' + # extended slicing - subscript only for tuples + a = (0,1,2,3,4) + vereq(a[::], a) + vereq(a[::2], (0,2,4)) + vereq(a[1::2], (1,3)) + vereq(a[::-1], (4,3,2,1,0)) + vereq(a[::-2], (4,2,0)) + vereq(a[3::-2], (3,1)) + vereq(a[-100:100:], a) + vereq(a[100:-100:-1], a[::-1]) + vereq(a[-100L:100L:2L], (0,2,4)) + + print '6.5.3 Lists' if len([]) != 0: raise TestFailed, 'len([])' *************** *** 322,325 **** --- 360,397 ---- if a[ 3: pow(2,145L) ] != [3,4]: raise TestFailed, "list slicing with too-large long integer" + + + # extended slicing + + # subscript + a = [0,1,2,3,4] + vereq(a[::], a) + vereq(a[::2], [0,2,4]) + vereq(a[1::2], [1,3]) + vereq(a[::-1], [4,3,2,1,0]) + vereq(a[::-2], [4,2,0]) + vereq(a[3::-2], [3,1]) + vereq(a[-100:100:], a) + vereq(a[100:-100:-1], a[::-1]) + vereq(a[-100L:100L:2L], [0,2,4]) + # deletion + del a[::2] + vereq(a, [1,3]) + a = range(5) + del a[1::2] + vereq(a, [0,2,4]) + a = range(5) + del a[1::-2] + vereq(a, [0,2,3,4]) + # assignment + a = range(10) + a[::2] = [-1]*5 + vereq(a, [-1, 1, -1, 3, -1, 5, -1, 7, -1, 9]) + a = range(10) + a[::-4] = [10]*3 + vereq(a, [0, 10, 2, 3, 4, 10, 6, 7, 8 ,10]) + a = range(4) + a[::-1] = a + vereq(a, [3, 2, 1, 0]) print '6.6 Mappings == Dictionaries' From mwh@users.sourceforge.net Tue Jun 11 11:55:41 2002 From: mwh@users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue, 11 Jun 2002 03:55:41 -0700 Subject: [Python-checkins] python/dist/src/Doc/ref ref3.tex,1.90,1.91 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv9709/Doc/ref Modified Files: ref3.tex Log Message: This is my nearly two year old patch [ 400998 ] experimental support for extended slicing on lists somewhat spruced up and better tested than it was when I wrote it. Includes docs & tests. The whatsnew section needs expanding, and arrays should support extended slices -- later. Index: ref3.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref3.tex,v retrieving revision 1.90 retrieving revision 1.91 diff -C2 -d -r1.90 -r1.91 *** ref3.tex 4 Jun 2002 16:25:57 -0000 1.90 --- ref3.tex 11 Jun 2002 10:55:08 -0000 1.91 *************** *** 253,256 **** --- 253,263 ---- \index{slicing} + Some sequences also support ``extended slicing'' with a third ``step'' + parameter: \code{\var{a}[\var{i}:\var{j}:\var{k}]} selects all items + of \var{a} with index \var{x} where \code{\var{x} = \var{i} + + \var{n}*\var{k}}, \var{n} \code{>=} \code{0} and \var{i} \code{<=} + \var{x} \code{<} \var{j}. + \index{extended slicing} + Sequences are distinguished according to their mutability: From mwh@users.sourceforge.net Tue Jun 11 11:55:41 2002 From: mwh@users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue, 11 Jun 2002 03:55:41 -0700 Subject: [Python-checkins] python/dist/src/Doc/api concrete.tex,1.15,1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory usw-pr-cvs1:/tmp/cvs-serv9709/Doc/api Modified Files: concrete.tex Log Message: This is my nearly two year old patch [ 400998 ] experimental support for extended slicing on lists somewhat spruced up and better tested than it was when I wrote it. Includes docs & tests. The whatsnew section needs expanding, and arrays should support extended slices -- later. Index: concrete.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/concrete.tex,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** concrete.tex 29 Apr 2002 17:28:43 -0000 1.15 --- concrete.tex 11 Jun 2002 10:55:08 -0000 1.16 *************** *** 2289,2292 **** --- 2289,2318 ---- \begin{cfuncdesc}{int}{PySlice_GetIndices}{PySliceObject *slice, int length, int *start, int *stop, int *step} + Retrieve the start, stop and step indices from the slice object + \var{slice}, assuming a sequence of length \var{length}. Treats + indices greater than \var{length} as errors. + + Returns 0 on success and -1 on error with no exception set (unless one + of the indices was not \constant{None} and failed to be converted to + an integer, in which case -1 is returned with an exception set). + + You probably do not want to use this function. If you want to use + slice objects in versions of Python prior to 2.3, you would probably + do well to incorporate the source of \cfunction{PySlice_GetIndicesEx}, + suitably renamed, in the source of your extension. + \end{cfuncdesc} + + \begin{cfuncdesc}{int}{PySlice_GetIndicesEx}{PySliceObject *slice, int length, + int *start, int *stop, int *step, + int *slicelength} + Usable replacement for \cfunction{PySlice_GetIndices}. Retrieve the + start, stop, and step indices from the slice object \var{slice} + assuming a sequence of length \var{length}, and store the length of + the slice in \var{slicelength}. Out of bounds indices are clipped in + a manner consistent with the handling of normal slices. + + Returns 0 on success and -1 on error with exception set. + + \versionadded{2.3} \end{cfuncdesc} From mwh@users.sourceforge.net Tue Jun 11 11:55:41 2002 From: mwh@users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue, 11 Jun 2002 03:55:41 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libstdtypes.tex,1.95,1.96 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv9709/Doc/lib Modified Files: libstdtypes.tex Log Message: This is my nearly two year old patch [ 400998 ] experimental support for extended slicing on lists somewhat spruced up and better tested than it was when I wrote it. Includes docs & tests. The whatsnew section needs expanding, and arrays should support extended slices -- later. Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.95 retrieving revision 1.96 diff -C2 -d -r1.95 -r1.96 *** libstdtypes.tex 22 May 2002 20:39:43 -0000 1.95 --- libstdtypes.tex 11 Jun 2002 10:55:08 -0000 1.96 *************** *** 434,437 **** --- 434,438 ---- \lineiii{\var{s}[\var{i}]}{\var{i}'th item of \var{s}, origin 0}{(2)} \lineiii{\var{s}[\var{i}:\var{j}]}{slice of \var{s} from \var{i} to \var{j}}{(2), (3)} + \lineiii{\var{s}[\var{i}:\var{j}:\var{k}]}{slice of \var{s} from \var{i} to \var{j} with step \var{k}}{(2), (4)} \hline \lineiii{len(\var{s})}{length of \var{s}}{} *************** *** 447,450 **** --- 448,452 ---- \indexii{subscript}{operation} \indexii{slice}{operation} + \indexii{extended slice}{operation} \opindex{in} \opindex{not in} *************** *** 493,496 **** --- 495,507 ---- use \code{0}. If \var{j} is omitted, use \code{len(\var{s})}. If \var{i} is greater than or equal to \var{j}, the slice is empty. + + \item[(4)] The slice of \var{s} from \var{i} to \var{j} with step \var{k} + is defined as the sequence of items with index \code{\var{x} = + \var{i} + \var{n}*\var{k}} such that \var{n} \code{>=} \code{0} and + \code{\var{i} <= \var{x} < \var{j}}. If \var{i} or \var{j} is + greater than \code{len(\var{s})}, use \code{len(\var{s})}. If + \var{i} or \var{j} are ommitted then they become ``end'' values + (which end depends on the sign of \var{k}). + \end{description} *************** *** 876,898 **** \lineiii{del \var{s}[\var{i}:\var{j}]} {same as \code{\var{s}[\var{i}:\var{j}] = []}}{} \lineiii{\var{s}.append(\var{x})} ! {same as \code{\var{s}[len(\var{s}):len(\var{s})] = [\var{x}]}}{(1)} \lineiii{\var{s}.extend(\var{x})} ! {same as \code{\var{s}[len(\var{s}):len(\var{s})] = \var{x}}}{(2)} \lineiii{\var{s}.count(\var{x})} {return number of \var{i}'s for which \code{\var{s}[\var{i}] == \var{x}}}{} \lineiii{\var{s}.index(\var{x})} ! {return smallest \var{i} such that \code{\var{s}[\var{i}] == \var{x}}}{(3)} \lineiii{\var{s}.insert(\var{i}, \var{x})} {same as \code{\var{s}[\var{i}:\var{i}] = [\var{x}]} ! if \code{\var{i} >= 0}}{(4)} \lineiii{\var{s}.pop(\optional{\var{i}})} ! {same as \code{\var{x} = \var{s}[\var{i}]; del \var{s}[\var{i}]; return \var{x}}}{(5)} \lineiii{\var{s}.remove(\var{x})} ! {same as \code{del \var{s}[\var{s}.index(\var{x})]}}{(3)} \lineiii{\var{s}.reverse()} ! {reverses the items of \var{s} in place}{(6)} \lineiii{\var{s}.sort(\optional{\var{cmpfunc}})} ! {sort the items of \var{s} in place}{(6), (7)} \end{tableiii} \indexiv{operations on}{mutable}{sequence}{types} --- 887,913 ---- \lineiii{del \var{s}[\var{i}:\var{j}]} {same as \code{\var{s}[\var{i}:\var{j}] = []}}{} + \lineiii{\var{s}[\var{i}:\var{j}:\var{k}] = \var{t}} + {the elements of \code{\var{s}[\var{i}:\var{j}:\var{k}]} are replaced by those of \var{t}}{(1)} + \lineiii{del \var{s}[\var{i}:\var{j}:\var{k}]} + {removes the elements of \code{\var{s}[\var{i}:\var{j}:\var{k}]} from the list}{} \lineiii{\var{s}.append(\var{x})} ! {same as \code{\var{s}[len(\var{s}):len(\var{s})] = [\var{x}]}}{(2)} \lineiii{\var{s}.extend(\var{x})} ! {same as \code{\var{s}[len(\var{s}):len(\var{s})] = \var{x}}}{(3)} \lineiii{\var{s}.count(\var{x})} {return number of \var{i}'s for which \code{\var{s}[\var{i}] == \var{x}}}{} \lineiii{\var{s}.index(\var{x})} ! {return smallest \var{i} such that \code{\var{s}[\var{i}] == \var{x}}}{(4)} \lineiii{\var{s}.insert(\var{i}, \var{x})} {same as \code{\var{s}[\var{i}:\var{i}] = [\var{x}]} ! if \code{\var{i} >= 0}}{(5)} \lineiii{\var{s}.pop(\optional{\var{i}})} ! {same as \code{\var{x} = \var{s}[\var{i}]; del \var{s}[\var{i}]; return \var{x}}}{(6)} \lineiii{\var{s}.remove(\var{x})} ! {same as \code{del \var{s}[\var{s}.index(\var{x})]}}{(4)} \lineiii{\var{s}.reverse()} ! {reverses the items of \var{s} in place}{(7)} \lineiii{\var{s}.sort(\optional{\var{cmpfunc}})} ! {sort the items of \var{s} in place}{(7), (8)} \end{tableiii} \indexiv{operations on}{mutable}{sequence}{types} *************** *** 901,904 **** --- 916,920 ---- \indexii{subscript}{assignment} \indexii{slice}{assignment} + \indexii{extended slice}{assignment} \stindex{del} \withsubitem{(list method)}{ *************** *** 909,938 **** Notes: \begin{description} ! \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. ! \item[(2)] Raises an exception when \var{x} is not a list object. The \method{extend()} method is experimental and not supported by mutable sequence types other than lists. ! \item[(3)] Raises \exception{ValueError} when \var{x} is not found in \var{s}. ! \item[(4)] When a negative index is passed as the first parameter to the \method{insert()} method, the new element is prepended to the sequence. ! \item[(5)] The \method{pop()} method is only supported by the list and array types. The optional argument \var{i} defaults to \code{-1}, so that by default the last item is removed and returned. ! \item[(6)] The \method{sort()} and \method{reverse()} methods modify the list in place for economy of space when sorting or reversing a large list. To remind you that they operate by side effect, they don't return the sorted or reversed list. ! \item[(7)] The \method{sort()} method takes an optional argument specifying a comparison function of two arguments (list items) which should return a negative, zero or positive number depending on whether --- 925,957 ---- Notes: \begin{description} ! \item[(1)] \var{t} must have the same length as the slice it is ! replacing. ! ! \item[(2)] 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. ! \item[(3)] Raises an exception when \var{x} is not a list object. The \method{extend()} method is experimental and not supported by mutable sequence types other than lists. ! \item[(4)] Raises \exception{ValueError} when \var{x} is not found in \var{s}. ! \item[(5)] When a negative index is passed as the first parameter to the \method{insert()} method, the new element is prepended to the sequence. ! \item[(6)] The \method{pop()} method is only supported by the list and array types. The optional argument \var{i} defaults to \code{-1}, so that by default the last item is removed and returned. ! \item[(7)] The \method{sort()} and \method{reverse()} methods modify the list in place for economy of space when sorting or reversing a large list. To remind you that they operate by side effect, they don't return the sorted or reversed list. ! \item[(8)] The \method{sort()} method takes an optional argument specifying a comparison function of two arguments (list items) which should return a negative, zero or positive number depending on whether From gvanrossum@users.sourceforge.net Tue Jun 11 13:22:31 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue, 11 Jun 2002 05:22:31 -0700 Subject: [Python-checkins] python/dist/src/Objects listobject.c,2.109,2.110 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv15921 Modified Files: listobject.c Log Message: Fold remaining long lines. Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.109 retrieving revision 2.110 diff -C2 -d -r2.109 -r2.110 *** listobject.c 11 Jun 2002 10:55:11 -0000 2.109 --- listobject.c 11 Jun 2002 12:22:28 -0000 2.110 *************** *** 1780,1789 **** /* drawing pictures might help understand these for loops */ ! for (cur = start, i = 0; cur < stop; cur += step, i++) { garbage[i] = PyList_GET_ITEM(self, cur); for (j = 0; j < step; j++) { PyList_SET_ITEM(self, cur + j - i, ! PyList_GET_ITEM(self, cur + j + 1)); } } --- 1780,1793 ---- /* drawing pictures might help understand these for loops */ ! for (cur = start, i = 0; ! cur < stop; ! cur += step, i++) ! { garbage[i] = PyList_GET_ITEM(self, cur); for (j = 0; j < step; j++) { PyList_SET_ITEM(self, cur + j - i, ! PyList_GET_ITEM(self, ! cur + j + 1)); } } From neal@metaslash.com Tue Jun 11 14:03:23 2002 From: neal@metaslash.com (Neal Norwitz) Date: Tue, 11 Jun 2002 09:03:23 -0400 Subject: [Python-checkins] python/dist/src/Objects listobject.c,2.108,2.109 sliceobject.c,2.12,2.13 stringobject.c,2.165,2.166 tupleobject.c,2.64,2.65 unicodeobject.c,2.151,2.152 References: Message-ID: <3D05F51B.3B30CF36@metaslash.com> Michael: There is a problem with the patch below. I think it is a general problem (for all types). I verified w/lists only. I'll describe the problem inline below. >>> n = [1, 2, 3] >>> n[10000:30000:2] Segmentation fault (core dumped) mwh@users.sourceforge.net wrote: > > Modified Files: > listobject.c sliceobject.c stringobject.c tupleobject.c > unicodeobject.c > Log Message: > This is my nearly two year old patch > > [ 400998 ] experimental support for extended slicing on lists > > somewhat spruced up and better tested than it was when I wrote it. > > Includes docs & tests. The whatsnew section needs expanding, and arrays > should support extended slices -- later. > > Index: listobject.c > =================================================================== > + else if (PySlice_Check(item)) { > + int start, stop, step, slicelength, cur, i; > + PyObject* result; > + PyObject* it; > + > + if (PySlice_GetIndicesEx((PySliceObject*)item, self->ob_size, > + &start, &stop, &step, &slicelength) < 0) { > + return NULL; > + } > + > + if (slicelength <= 0) { > + return PyList_New(0); > + } > + else { > + result = PyList_New(slicelength); > + if (!result) return NULL; > + > + for (cur = start, i = 0; i < slicelength; > + cur += step, i++) { > + it = PyList_GET_ITEM(self, cur); Here is where the problem is. You are referencing self list with cur, but cur is not guaranteed to be < list length. I think all you have to do is add another condition to the for loop && cur < PyList_Length(self) (or should that be PyList_Size(self)?). I suspect this is true of strings, unicode, tuples, and any other sequence types. Hopefully, this makes sense. Neal From mwh@python.net Tue Jun 11 14:33:42 2002 From: mwh@python.net (Michael Hudson) Date: Tue, 11 Jun 2002 14:33:42 +0100 (BST) Subject: [Python-checkins] python/dist/src/Objects listobject.c,2.108,2.109 sliceobject.c,2.12,2.13 stringobject.c,2.165,2.166 tupleobject.c,2.64,2.65 unicodeobject.c,2.151,2.152 In-Reply-To: <3D05F51B.3B30CF36@metaslash.com> Message-ID: On Tue, 11 Jun 2002, Neal Norwitz wrote: > Michael: > > There is a problem with the patch below. > I think it is a general problem (for all types). > I verified w/lists only. I'll describe the problem inline below. > > >>> n = [1, 2, 3] > >>> n[10000:30000:2] > Segmentation fault (core dumped) Ouch! [...] > Here is where the problem is. You are referencing self list > with cur, but cur is not guaranteed to be < list length. > I think all you have to do is add another condition to the for loop > && cur < PyList_Length(self) (or should that be PyList_Size(self)?). No, PySlice_GetIndicesEx was wrong. It was returning a slicelength of 1 when it should have been 0. Fix imminent. Cheers, M. From mwh@users.sourceforge.net Tue Jun 11 14:38:44 2002 From: mwh@users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue, 11 Jun 2002 06:38:44 -0700 Subject: [Python-checkins] python/dist/src/Objects sliceobject.c,2.13,2.14 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv11746/Objects Modified Files: sliceobject.c Log Message: Fix for problem reported by Neal Norwitz. Tighten up calculation of slicelength. Include his test case. Index: sliceobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/sliceobject.c,v retrieving revision 2.13 retrieving revision 2.14 diff -C2 -d -r2.13 -r2.14 *** sliceobject.c 11 Jun 2002 10:55:11 -0000 2.13 --- sliceobject.c 11 Jun 2002 13:38:42 -0000 2.14 *************** *** 152,162 **** if (*stop > length) *stop = length; } ! ! if (*step < 0) { *slicelength = (*stop-*start+1)/(*step)+1; } else { *slicelength = (*stop-*start-1)/(*step)+1; } - if (*slicelength < 0) *slicelength = 0; return 0; --- 152,164 ---- if (*stop > length) *stop = length; } ! ! if ((*stop - *start)*(*step) <= 0) { ! *slicelength = 0; ! } ! else if (*step < 0) { *slicelength = (*stop-*start+1)/(*step)+1; } else { *slicelength = (*stop-*start-1)/(*step)+1; } return 0; From mwh@users.sourceforge.net Tue Jun 11 14:38:45 2002 From: mwh@users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue, 11 Jun 2002 06:38:45 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_types.py,1.30,1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv11746/Lib/test Modified Files: test_types.py Log Message: Fix for problem reported by Neal Norwitz. Tighten up calculation of slicelength. Include his test case. Index: test_types.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_types.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** test_types.py 11 Jun 2002 10:55:09 -0000 1.30 --- test_types.py 11 Jun 2002 13:38:42 -0000 1.31 *************** *** 375,378 **** --- 375,380 ---- vereq(a[100:-100:-1], a[::-1]) vereq(a[-100L:100L:2L], [0,2,4]) + vereq(a[1000:2000:2], []) + vereq(a[-1000:-2000:-2], []) # deletion del a[::2] From nnorwitz@users.sourceforge.net Tue Jun 11 14:38:53 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Tue, 11 Jun 2002 06:38:53 -0700 Subject: [Python-checkins] python/dist/src/Lib urllib.py,1.147,1.148 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv11686/Lib Modified Files: urllib.py Log Message: Fix SF #565414, FancyURLopener() needs to support **kwargs since the URLopener base class does and **kwargs are used in urlopen. Index: urllib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib.py,v retrieving revision 1.147 retrieving revision 1.148 diff -C2 -d -r1.147 -r1.148 *** urllib.py 3 Jun 2002 15:58:32 -0000 1.147 --- urllib.py 11 Jun 2002 13:38:51 -0000 1.148 *************** *** 539,544 **** """Derived class with handlers for errors we can handle (perhaps).""" ! def __init__(self, *args): ! apply(URLopener.__init__, (self,) + args) self.auth_cache = {} self.tries = 0 --- 539,544 ---- """Derived class with handlers for errors we can handle (perhaps).""" ! def __init__(self, *args, **kwargs): ! apply(URLopener.__init__, (self,) + args, kwargs) self.auth_cache = {} self.tries = 0 From montanaro@users.sourceforge.net Tue Jun 11 15:32:50 2002 From: montanaro@users.sourceforge.net (montanaro@users.sourceforge.net) Date: Tue, 11 Jun 2002 07:32:50 -0700 Subject: [Python-checkins] python/dist/src/Modules readline.c,2.49,2.50 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv3072 Modified Files: readline.c Log Message: patch #562492 - prevent duplicate lines in history also call using_history() to properly initialize history variables Index: readline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v retrieving revision 2.49 retrieving revision 2.50 diff -C2 -d -r2.49 -r2.50 *** readline.c 30 May 2002 15:41:56 -0000 2.49 --- readline.c 11 Jun 2002 14:32:46 -0000 2.50 *************** *** 553,556 **** --- 553,558 ---- setup_readline(void) { + using_history(); + rl_readline_name = "python"; #if defined(PYOS_OS2) && defined(PYCC_GCC) *************** *** 629,634 **** } n = strlen(p); ! if (n > 0) ! add_history(p); /* Copy the malloc'ed buffer into a PyMem_Malloc'ed one and release the original. */ --- 631,651 ---- } n = strlen(p); ! if (n > 0) { ! char *line; ! HISTORY_STATE *state = history_get_history_state(); ! if (state->length > 0) ! line = history_get(state->length)->line; ! else ! line = ""; ! if (strcmp(p, line)) ! add_history(p); ! /* the history docs don't say so, but the address of state ! changes each time history_get_history_state is called ! which makes me think it's freshly malloc'd memory... ! on the other hand, the address of the last line stays the ! same as long as history isn't extended, so it appears to ! be malloc'd but managed by the history package... */ ! free(state); ! } /* Copy the malloc'ed buffer into a PyMem_Malloc'ed one and release the original. */ From gvanrossum@users.sourceforge.net Tue Jun 11 22:17:37 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue, 11 Jun 2002 14:17:37 -0700 Subject: [Python-checkins] python/dist/src/Lib dis.py,1.39,1.40 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv1275 Modified Files: dis.py Log Message: The opcode YIELD_STMT was accidentally called YIELD_VALUE here. Index: dis.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dis.py,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** dis.py 1 Jun 2002 00:57:55 -0000 1.39 --- dis.py 11 Jun 2002 21:17:35 -0000 1.40 *************** *** 229,233 **** def_op('IMPORT_STAR', 84) def_op('EXEC_STMT', 85) ! def_op('YIELD_STMT', 86) def_op('POP_BLOCK', 87) --- 229,233 ---- def_op('IMPORT_STAR', 84) def_op('EXEC_STMT', 85) ! def_op('YIELD_VALUE', 86) def_op('POP_BLOCK', 87) From gvanrossum@users.sourceforge.net Wed Jun 12 04:45:23 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue, 11 Jun 2002 20:45:23 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_generators.py,1.33,1.34 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv31088/Lib/test Modified Files: test_generators.py Log Message: SF bug 567538: Generator can crash the interpreter (Finn Bock). This was a simple typo. Strange that the compiler didn't catch it! Instead of WHY_CONTINUE, two tests used CONTINUE_LOOP, which isn't a why_code at all, but an opcode; but even though 'why' is declared as an enum, comparing it to an int is apparently not even worth a warning -- not in gcc, and not in VC++. :-( Will fix in 2.2 too. Index: test_generators.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_generators.py,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** test_generators.py 3 Apr 2002 22:41:50 -0000 1.33 --- test_generators.py 12 Jun 2002 03:45:20 -0000 1.34 *************** *** 806,809 **** --- 806,829 ---- Traceback (most recent call last): SyntaxError: 'return' with argument inside generator (, line 8) + + This one caused a crash (see SF bug 567538): + + >>> def f(): + ... for i in range(3): + ... try: + ... continue + ... finally: + ... yield i + ... + >>> g = f() + >>> print g.next() + 0 + >>> print g.next() + 1 + >>> print g.next() + 2 + >>> print g.next() + Traceback (most recent call last): + StopIteration """ From gvanrossum@users.sourceforge.net Wed Jun 12 04:45:23 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue, 11 Jun 2002 20:45:23 -0700 Subject: [Python-checkins] python/dist/src/Python ceval.c,2.311,2.312 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv31088/Python Modified Files: ceval.c Log Message: SF bug 567538: Generator can crash the interpreter (Finn Bock). This was a simple typo. Strange that the compiler didn't catch it! Instead of WHY_CONTINUE, two tests used CONTINUE_LOOP, which isn't a why_code at all, but an opcode; but even though 'why' is declared as an enum, comparing it to an int is apparently not even worth a warning -- not in gcc, and not in VC++. :-( Will fix in 2.2 too. Index: ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.311 retrieving revision 2.312 diff -C2 -d -r2.311 -r2.312 *** ceval.c 20 May 2002 13:56:11 -0000 2.311 --- ceval.c 12 Jun 2002 03:45:21 -0000 2.312 *************** *** 1544,1548 **** if (why == WHY_RETURN || why == WHY_YIELD || ! why == CONTINUE_LOOP) retval = POP(); } --- 1544,1548 ---- if (why == WHY_RETURN || why == WHY_YIELD || ! why == WHY_CONTINUE) retval = POP(); } *************** *** 2294,2298 **** else { if (why == WHY_RETURN || ! why == CONTINUE_LOOP) PUSH(retval); v = PyInt_FromLong((long)why); --- 2294,2298 ---- else { if (why == WHY_RETURN || ! why == WHY_CONTINUE) PUSH(retval); v = PyInt_FromLong((long)why); From gvanrossum@users.sourceforge.net Wed Jun 12 04:45:23 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue, 11 Jun 2002 20:45:23 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.423,1.424 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv31088/Misc Modified Files: NEWS Log Message: SF bug 567538: Generator can crash the interpreter (Finn Bock). This was a simple typo. Strange that the compiler didn't catch it! Instead of WHY_CONTINUE, two tests used CONTINUE_LOOP, which isn't a why_code at all, but an opcode; but even though 'why' is declared as an enum, comparing it to an int is apparently not even worth a warning -- not in gcc, and not in VC++. :-( Will fix in 2.2 too. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.423 retrieving revision 1.424 diff -C2 -d -r1.423 -r1.424 *** NEWS 11 Jun 2002 10:55:10 -0000 1.423 --- NEWS 12 Jun 2002 03:45:21 -0000 1.424 *************** *** 7,10 **** --- 7,13 ---- Core and builtins + - Fixed a bug with a continue inside a try block and a yield in the + finally clause. [SF bug 567538] + - Most builtin sequences now support "extended slices", i.e. slices with a third "stride" parameter. For example, "range(10)[1:6:2]" From gvanrossum@users.sourceforge.net Wed Jun 12 04:48:48 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue, 11 Jun 2002 20:48:48 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_generators.py,1.30,1.30.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv31925/Lib/test Modified Files: Tag: release22-maint test_generators.py Log Message: Backport: SF bug 567538: Generator can crash the interpreter (Finn Bock). This was a simple typo. Strange that the compiler didn't catch it! Instead of WHY_CONTINUE, two tests used CONTINUE_LOOP, which isn't a why_code at all, but an opcode; but even though 'why' is declared as an enum, comparing it to an int is apparently not even worth a warning -- not in gcc, and not in VC++. :-( Index: test_generators.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_generators.py,v retrieving revision 1.30 retrieving revision 1.30.6.1 diff -C2 -d -r1.30 -r1.30.6.1 *** test_generators.py 6 Dec 2001 06:23:25 -0000 1.30 --- test_generators.py 12 Jun 2002 03:48:46 -0000 1.30.6.1 *************** *** 808,811 **** --- 808,831 ---- Traceback (most recent call last): SyntaxError: 'return' with argument inside generator (, line 8) + + This one caused a crash (see SF bug 567538): + + >>> def f(): + ... for i in range(3): + ... try: + ... continue + ... finally: + ... yield i + ... + >>> g = f() + >>> print g.next() + 0 + >>> print g.next() + 1 + >>> print g.next() + 2 + >>> print g.next() + Traceback (most recent call last): + StopIteration """ From gvanrossum@users.sourceforge.net Wed Jun 12 04:48:48 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue, 11 Jun 2002 20:48:48 -0700 Subject: [Python-checkins] python/dist/src/Python ceval.c,2.301.4.2,2.301.4.3 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv31925/Python Modified Files: Tag: release22-maint ceval.c Log Message: Backport: SF bug 567538: Generator can crash the interpreter (Finn Bock). This was a simple typo. Strange that the compiler didn't catch it! Instead of WHY_CONTINUE, two tests used CONTINUE_LOOP, which isn't a why_code at all, but an opcode; but even though 'why' is declared as an enum, comparing it to an int is apparently not even worth a warning -- not in gcc, and not in VC++. :-( Index: ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.301.4.2 retrieving revision 2.301.4.3 diff -C2 -d -r2.301.4.2 -r2.301.4.3 *** ceval.c 28 Mar 2002 20:18:48 -0000 2.301.4.2 --- ceval.c 12 Jun 2002 03:48:46 -0000 2.301.4.3 *************** *** 1498,1502 **** if (why == WHY_RETURN || why == WHY_YIELD || ! why == CONTINUE_LOOP) retval = POP(); } --- 1498,1502 ---- if (why == WHY_RETURN || why == WHY_YIELD || ! why == WHY_CONTINUE) retval = POP(); } *************** *** 2294,2298 **** else { if (why == WHY_RETURN || ! why == CONTINUE_LOOP) PUSH(retval); v = PyInt_FromLong((long)why); --- 2294,2298 ---- else { if (why == WHY_RETURN || ! why == WHY_CONTINUE) PUSH(retval); v = PyInt_FromLong((long)why); From gvanrossum@users.sourceforge.net Wed Jun 12 04:48:48 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue, 11 Jun 2002 20:48:48 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.337.2.4.2.27,1.337.2.4.2.28 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv31925/Misc Modified Files: Tag: release22-maint NEWS Log Message: Backport: SF bug 567538: Generator can crash the interpreter (Finn Bock). This was a simple typo. Strange that the compiler didn't catch it! Instead of WHY_CONTINUE, two tests used CONTINUE_LOOP, which isn't a why_code at all, but an opcode; but even though 'why' is declared as an enum, comparing it to an int is apparently not even worth a warning -- not in gcc, and not in VC++. :-( Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.337.2.4.2.27 retrieving revision 1.337.2.4.2.28 diff -C2 -d -r1.337.2.4.2.27 -r1.337.2.4.2.28 *** NEWS 10 Jun 2002 21:40:01 -0000 1.337.2.4.2.27 --- NEWS 12 Jun 2002 03:48:46 -0000 1.337.2.4.2.28 *************** *** 5,8 **** --- 5,11 ---- Core and builtins + - Fixed a bug with a continue inside a try block and a yield in the + finally clause. [SF bug 567538] + - Cycles going through the __class__ link of a new-style instance are now detected by the garbage collector. From gvanrossum@users.sourceforge.net Wed Jun 12 15:38:06 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Wed, 12 Jun 2002 07:38:06 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_gc.py,1.14,1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv15310 Modified Files: test_gc.py Log Message: Add a testcase to ensure that cycles going through the __class__ link of a new-style instance are detected by the garbage collector. Index: test_gc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_gc.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** test_gc.py 28 Mar 2002 21:22:25 -0000 1.14 --- test_gc.py 12 Jun 2002 14:38:04 -0000 1.15 *************** *** 84,87 **** --- 84,93 ---- del a expect_nonzero(gc.collect(), "newinstance(2)") + del B, C + expect_nonzero(gc.collect(), "newinstance(3)") + A.a = A() + del A + expect_nonzero(gc.collect(), "newinstance(4)") + expect(gc.collect(), 0, "newinstance(5)") def test_method(): From gvanrossum@users.sourceforge.net Wed Jun 12 15:41:52 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Wed, 12 Jun 2002 07:41:52 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_gc.py,1.12.10.1,1.12.10.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv16673 Modified Files: Tag: release22-maint test_gc.py Log Message: Backport 1.15: Add a testcase to ensure that cycles going through the __class__ link of a new-style instance are detected by the garbage collector. Index: test_gc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_gc.py,v retrieving revision 1.12.10.1 retrieving revision 1.12.10.2 diff -C2 -d -r1.12.10.1 -r1.12.10.2 *** test_gc.py 28 Mar 2002 23:18:08 -0000 1.12.10.1 --- test_gc.py 12 Jun 2002 14:41:50 -0000 1.12.10.2 *************** *** 84,87 **** --- 84,93 ---- del a expect_nonzero(gc.collect(), "newinstance(2)") + del B, C + expect_nonzero(gc.collect(), "newinstance(3)") + A.a = A() + del A + expect_nonzero(gc.collect(), "newinstance(4)") + expect(gc.collect(), 0, "newinstance(5)") def test_method(): From gvanrossum@users.sourceforge.net Wed Jun 12 16:33:13 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Wed, 12 Jun 2002 08:33:13 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libdis.tex,1.34,1.35 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv2851 Modified Files: libdis.tex Log Message: SF bug 567826. Document new opcodes: ['BINARY_FLOOR_DIVIDE', 'BINARY_TRUE_DIVIDE', 'INPLACE_FLOOR_DIVIDE', 'INPLACE_TRUE_DIVIDE', 'GET_ITER', 'YIELD_VALUE', 'FOR_ITER', 'CONTINUE_LOOP'] Index: libdis.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdis.tex,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** libdis.tex 28 Mar 2002 19:34:53 -0000 1.34 --- libdis.tex 12 Jun 2002 15:33:08 -0000 1.35 *************** *** 167,170 **** --- 167,174 ---- \end{opcodedesc} + \begin{opcodedesc}{GET_ITER}{} + Implements \code{TOS = iter(TOS)}. + \end{opcodedesc} + Binary operations remove the top of the stack (TOS) and the second top-most stack item (TOS1) from the stack. They perform the operation, and put the *************** *** 180,184 **** \begin{opcodedesc}{BINARY_DIVIDE}{} ! Implements \code{TOS = TOS1 / TOS}. \end{opcodedesc} --- 184,198 ---- \begin{opcodedesc}{BINARY_DIVIDE}{} ! Implements \code{TOS = TOS1 / TOS} when ! \code{from __future__ import division} is not in effect. ! \end{opcodedesc} ! ! \begin{opcodedesc}{BINARY_FLOOR_DIVIDE}{} ! Implements \code{TOS = TOS1 // TOS}. ! \end{opcodedesc} ! ! \begin{opcodedesc}{BINARY_TRUE_DIVIDE}{} ! Implements \code{TOS = TOS1 / TOS} when ! \code{from __future__ import division} is in effect. \end{opcodedesc} *************** *** 233,237 **** \begin{opcodedesc}{INPLACE_DIVIDE}{} ! Implements in-place \code{TOS = TOS1 / TOS}. \end{opcodedesc} --- 247,261 ---- \begin{opcodedesc}{INPLACE_DIVIDE}{} ! Implements in-place \code{TOS = TOS1 / TOS} when ! \code{from __future__ import division} is not in effect. ! \end{opcodedesc} ! ! \begin{opcodedesc}{INPLACE_FLOOR_DIVIDE}{} ! Implements in-place \code{TOS = TOS1 // TOS}. ! \end{opcodedesc} ! ! \begin{opcodedesc}{INPLACE_TRUE_DIVIDE}{} ! Implements in-place \code{TOS = TOS1 / TOS} when ! \code{from __future__ import division} is in effect. \end{opcodedesc} *************** *** 329,332 **** --- 353,358 ---- \end{opcodedesc} + Miscellaneous opcodes. + \begin{opcodedesc}{PRINT_EXPR}{} Implements the expression statement for the interactive mode. TOS is *************** *** 360,363 **** --- 386,395 ---- \end{opcodedesc} + \begin{opcodedesc}{CONTINUE_LOOP}{target} + Continues a loop due to a \keyword{continue} statement. \var{target} + is the address to jump to (which should be a \code{FOR_ITER} + instruction). + \end{opcodedesc} + \begin{opcodedesc}{LOAD_LOCALS}{} Pushes a reference to the locals of the current scope on the stack. *************** *** 370,373 **** --- 402,409 ---- \end{opcodedesc} + \begin{opcodedesc}{YIELD_VALUE}{} + Pops \code{TOS} and yields it from a generator. + \end{opcodedesc} + \begin{opcodedesc}{IMPORT_STAR}{} Loads all symbols not starting with \character{_} directly from the module TOS *************** *** 514,522 **** \end{opcodedesc} \begin{opcodedesc}{FOR_LOOP}{delta} ! Iterate over a sequence. TOS is the current index, TOS1 the sequence. ! First, the next element is computed. If the sequence is exhausted, ! increment byte code counter by \var{delta}. Otherwise, push the ! sequence, the incremented counter, and the current item onto the stack. \end{opcodedesc} --- 550,566 ---- \end{opcodedesc} + \begin{opcodedesc}{FOR_ITER}{delta} + \code{TOS} is an iterator. Call its \method{next()} method. If this + yields a new value, push it on the stack (leaving the iterator below + it). If the iterator indicates it is exhausted \code{TOS} is + popped, and the byte code counter is incremented by \var{delta}. + \end{opcodedesc} + \begin{opcodedesc}{FOR_LOOP}{delta} ! This opcode is obsolete. ! %Iterate over a sequence. TOS is the current index, TOS1 the sequence. ! %First, the next element is computed. If the sequence is exhausted, ! %increment byte code counter by \var{delta}. Otherwise, push the ! %sequence, the incremented counter, and the current item onto the stack. \end{opcodedesc} From gvanrossum@users.sourceforge.net Wed Jun 12 20:18:10 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Wed, 12 Jun 2002 12:18:10 -0700 Subject: [Python-checkins] python/dist/src/Lib/test/output test_socket,1.2,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory usw-pr-cvs1:/tmp/cvs-serv27708/output Removed Files: test_socket Log Message: New test suite for the socket module by Michael Gilfix. Changed test_timeout.py to conform to the guidelines in Lib/test/README. --- test_socket DELETED --- From gvanrossum@users.sourceforge.net Wed Jun 12 20:18:10 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Wed, 12 Jun 2002 12:18:10 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_socket.py,1.24,1.25 test_timeout.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv27708 Modified Files: test_socket.py test_timeout.py Log Message: New test suite for the socket module by Michael Gilfix. Changed test_timeout.py to conform to the guidelines in Lib/test/README. Index: test_socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** test_socket.py 6 Jun 2002 21:08:16 -0000 1.24 --- test_socket.py 12 Jun 2002 19:18:08 -0000 1.25 *************** *** 1,35 **** ! # Not tested: ! # socket.fromfd() ! # sktobj.getsockopt() ! # sktobj.recvfrom() ! # sktobj.sendto() ! # sktobj.setblocking() ! # sktobj.setsockopt() ! # sktobj.shutdown() - from test_support import verbose, TestFailed import socket ! import os import time ! def missing_ok(str): ! try: ! getattr(socket, str) ! except AttributeError: ! pass ! try: raise socket.error ! except socket.error: print "socket.error" ! socket.AF_INET ! socket.SOCK_STREAM ! socket.SOCK_DGRAM ! socket.SOCK_RAW ! socket.SOCK_RDM ! socket.SOCK_SEQPACKET ! for optional in ("AF_UNIX", "SO_DEBUG", "SO_ACCEPTCONN", "SO_REUSEADDR", "SO_KEEPALIVE", --- 1,170 ---- ! #!/usr/bin/env python + import unittest + import test_support import socket ! import select import time + import thread, threading + import Queue ! PORT = 50007 ! HOST = 'localhost' ! MSG = 'Michael Gilfix was here\n' ! class SocketTCPTest(unittest.TestCase): ! def setUp(self): ! self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ! self.serv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) ! self.serv.bind((HOST, PORT)) ! self.serv.listen(1) ! def tearDown(self): ! self.serv.close() ! self.serv = None ! class SocketUDPTest(unittest.TestCase): ! ! def setUp(self): ! self.serv = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) ! self.serv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) ! self.serv.bind((HOST, PORT)) ! ! def tearDown(self): ! self.serv.close() ! self.serv = None ! ! class ThreadableTest: ! ! def __init__(self): ! # Swap the true setup function ! self.__setUp = self.setUp ! self.__tearDown = self.tearDown ! self.setUp = self._setUp ! self.tearDown = self._tearDown ! ! def _setUp(self): ! self.ready = threading.Event() ! self.done = threading.Event() ! self.queue = Queue.Queue(1) ! ! # Do some munging to start the client test. ! test_method = getattr(self, ''.join(('_', self._TestCase__testMethodName))) ! self.client_thread = thread.start_new_thread(self.clientRun, (test_method, )) ! ! self.__setUp() ! self.ready.wait() ! ! def _tearDown(self): ! self.__tearDown() ! self.done.wait() ! ! if not self.queue.empty(): ! msg = self.queue.get() ! self.fail(msg) ! ! def clientRun(self, test_func): ! self.ready.set() ! self.clientSetUp() ! if not callable(test_func): ! raise TypeError, "test_func must be a callable function" ! try: ! test_func() ! except Exception, strerror: ! self.queue.put(strerror) ! self.clientTearDown() ! ! def clientSetUp(self): ! raise NotImplementedError, "clientSetUp must be implemented." ! ! def clientTearDown(self): ! self.done.set() ! thread.exit() ! ! class ThreadedTCPSocketTest(SocketTCPTest, ThreadableTest): ! ! def __init__(self, methodName='runTest'): ! SocketTCPTest.__init__(self, methodName=methodName) ! ThreadableTest.__init__(self) ! ! def clientSetUp(self): ! self.cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ! ! def clientTearDown(self): ! self.cli.close() ! self.cli = None ! ThreadableTest.clientTearDown(self) ! ! class ThreadedUDPSocketTest(SocketUDPTest, ThreadableTest): ! ! def __init__(self, methodName='runTest'): ! SocketUDPTest.__init__(self, methodName=methodName) ! ThreadableTest.__init__(self) ! ! def clientSetUp(self): ! self.cli = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) ! ! class SocketConnectedTest(ThreadedTCPSocketTest): ! ! def __init__(self, methodName='runTest'): ! ThreadedTCPSocketTest.__init__(self, methodName=methodName) ! ! def setUp(self): ! ThreadedTCPSocketTest.setUp(self) ! conn, addr = self.serv.accept() ! self.cli_conn = conn ! ! def tearDown(self): ! self.cli_conn.close() ! self.cli_conn = None ! ThreadedTCPSocketTest.tearDown(self) ! ! def clientSetUp(self): ! ThreadedTCPSocketTest.clientSetUp(self) ! self.cli.connect((HOST, PORT)) ! self.serv_conn = self.cli ! ! def clientTearDown(self): ! self.serv_conn.close() ! self.serv_conn = None ! ThreadedTCPSocketTest.clientTearDown(self) ! ! ####################################################################### ! ## Begin Tests ! ! class GeneralModuleTests(unittest.TestCase): ! ! def testSocketError(self): ! """Testing that socket module exceptions.""" ! def raise_error(*args, **kwargs): ! raise socket.error ! def raise_herror(*args, **kwargs): ! raise socket.herror ! def raise_gaierror(*args, **kwargs): ! raise socket.gaierror ! self.failUnlessRaises(socket.error, raise_error, ! "Error raising socket exception.") ! self.failUnlessRaises(socket.error, raise_herror, ! "Error raising socket exception.") ! self.failUnlessRaises(socket.error, raise_gaierror, ! "Error raising socket exception.") ! ! def testCrucialConstants(self): ! """Testing for mission critical constants.""" ! socket.AF_INET ! socket.SOCK_STREAM ! socket.SOCK_DGRAM ! socket.SOCK_RAW ! socket.SOCK_RDM ! socket.SOCK_SEQPACKET ! socket.SOL_SOCKET ! socket.SO_REUSEADDR ! ! def testNonCrucialConstants(self): ! """Testing for existance of non-crucial constants.""" ! for const in ( ! "AF_UNIX", "SO_DEBUG", "SO_ACCEPTCONN", "SO_REUSEADDR", "SO_KEEPALIVE", *************** *** 63,208 **** "IP_MULTICAST_LOOP", "IP_ADD_MEMBERSHIP", "IP_DROP_MEMBERSHIP", ! ): ! missing_ok(optional) ! socktype = socket.SocketType ! hostname = socket.gethostname() ! ip = socket.gethostbyname(hostname) ! hname, aliases, ipaddrs = socket.gethostbyaddr(ip) ! all_host_names = [hname] + aliases ! if verbose: ! print hostname ! print ip ! print hname, aliases, ipaddrs ! print all_host_names ! for name in all_host_names: ! if name.find('.'): ! break ! else: ! print 'FQDN not found' ! if hasattr(socket, 'getservbyname'): ! print socket.getservbyname('telnet', 'tcp') ! try: ! socket.getservbyname('telnet', 'udp') ! except socket.error: ! pass ! import sys ! if not sys.platform.startswith('java'): ! try: ! # On some versions, this loses a reference ! orig = sys.getrefcount(__name__) ! socket.getnameinfo(__name__,0) ! except SystemError: ! if sys.getrefcount(__name__) <> orig: ! raise TestFailed,"socket.getnameinfo loses a reference" ! try: ! # On some versions, this crashes the interpreter. ! socket.getnameinfo(('x', 0, 0, 0), 0) ! except socket.error: ! pass ! canfork = hasattr(os, 'fork') ! try: ! PORT = 50007 ! msg = 'socket test\n' ! if not canfork or os.fork(): ! # parent is server ! s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ! s.bind(("127.0.0.1", PORT)) ! s.listen(1) ! if verbose: ! print 'parent accepting' ! if canfork: ! conn, addr = s.accept() ! if verbose: ! print 'connected by', addr ! # couple of interesting tests while we've got a live socket ! f = conn.fileno() ! if verbose: ! print 'fileno:', f ! p = conn.getpeername() ! if verbose: ! print 'peer:', p ! n = conn.getsockname() ! if verbose: ! print 'sockname:', n ! f = conn.makefile() ! if verbose: ! print 'file obj:', f ! data = conn.recv(1024) ! if verbose: ! print 'received:', data ! conn.sendall(data) ! # Perform a few tests on the windows file object ! if verbose: ! print "Staring _fileobject tests..." ! f = socket._fileobject (conn, 'rb', 8192) ! first_seg = f.read(7) ! second_seg = f.read(5) ! if not first_seg == 'socket ' or not second_seg == 'test\n': ! print "Error performing read with the python _fileobject class" ! os._exit (1) ! elif verbose: ! print "_fileobject buffered read works" ! f.write (data) ! f.flush () ! buf = '' ! while 1: ! char = f.read(1) ! if not char: ! print "Error performing unbuffered read with the python ", \ ! "_fileobject class" ! os._exit (1) ! buf += char ! if buf == msg: ! if verbose: ! print "__fileobject unbuffered read works" ! break ! if verbose: ! # If we got this far, write() must work as well ! print "__fileobject write works" ! f.write(buf) ! f.flush() ! line = f.readline() ! if not line == msg: ! print "Error perferming readline with the python _fileobject class" ! os._exit (1) ! f.write(line) ! f.flush() ! if verbose: ! print "__fileobject readline works" ! conn.close() ! else: try: ! # child is client ! time.sleep(5) ! s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ! if verbose: ! print 'child connecting' ! s.connect(("127.0.0.1", PORT)) ! iteration = 0 ! while 1: ! s.send(msg) ! data = s.recv(12) ! if not data: ! break ! if msg != data: ! print "parent/client mismatch. Failed in %s iteration. Received: [%s]" \ ! %(iteration, data) ! time.sleep (1) ! iteration += 1 ! s.close() ! finally: ! os._exit(1) ! except socket.error, msg: ! raise TestFailed, msg --- 198,515 ---- "IP_MULTICAST_LOOP", "IP_ADD_MEMBERSHIP", "IP_DROP_MEMBERSHIP", ! ): ! try: ! getattr(socket, const) ! except AttributeError: ! pass ! def testHostnameRes(self): ! """Testing hostname resolution mechanisms.""" ! hostname = socket.gethostname() ! ip = socket.gethostbyname(hostname) ! self.assert_(ip.find('.') >= 0, "Error resolving host to ip.") ! hname, aliases, ipaddrs = socket.gethostbyaddr(ip) ! all_host_names = [hname] + aliases ! fqhn = socket.getfqdn() ! if not fqhn in all_host_names: ! self.fail("Error testing host resolution mechanisms.") ! def testJavaRef(self): ! """Testing reference count for getnameinfo.""" ! import sys ! if not sys.platform.startswith('java'): ! try: ! # On some versions, this loses a reference ! orig = sys.getrefcount(__name__) ! socket.getnameinfo(__name__,0) ! except SystemError: ! if sys.getrefcount(__name__) <> orig: ! self.fail("socket.getnameinfo loses a reference") ! def testInterpreterCrash(self): ! """Making sure getnameinfo doesn't crash the interpreter.""" ! try: ! # On some versions, this crashes the interpreter. ! socket.getnameinfo(('x', 0, 0, 0), 0) ! except socket.error: ! pass ! def testGetServByName(self): ! """Testing getservbyname.""" ! if hasattr(socket, 'getservbyname'): ! socket.getservbyname('telnet', 'tcp') ! try: ! socket.getservbyname('telnet', 'udp') ! except socket.error: ! pass ! def testSockName(self): ! """Testing getsockname().""" ! sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ! name = sock.getsockname() ! def testGetSockOpt(self): ! """Testing getsockopt().""" ! # We know a socket should start without reuse==0 ! sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ! reuse = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR) ! self.assert_(reuse == 0, "Error performing getsockopt.") ! def testSetSockOpt(self): ! """Testing setsockopt().""" ! sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ! sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) ! reuse = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR) ! self.assert_(reuse == 1, "Error performing setsockopt.") ! class BasicTCPTest(SocketConnectedTest): ! def __init__(self, methodName='runTest'): ! SocketConnectedTest.__init__(self, methodName=methodName) ! def testRecv(self): ! """Testing large receive over TCP.""" ! msg = self.cli_conn.recv(1024) ! self.assertEqual(msg, MSG, "Error performing recv.") ! def _testRecv(self): ! self.serv_conn.send(MSG) ! ! def testOverFlowRecv(self): ! """Testing receive in chunks over TCP.""" ! seg1 = self.cli_conn.recv(len(MSG) - 3) ! seg2 = self.cli_conn.recv(1024) ! msg = ''.join ((seg1, seg2)) ! self.assertEqual(msg, MSG, "Error performing recv in chunks.") ! ! def _testOverFlowRecv(self): ! self.serv_conn.send(MSG) ! ! def testRecvFrom(self): ! """Testing large recvfrom() over TCP.""" ! msg, addr = self.cli_conn.recvfrom(1024) ! hostname, port = addr ! self.assertEqual (hostname, socket.gethostbyname('localhost'), ! "Wrong address from recvfrom.") ! self.assertEqual(msg, MSG, "Error performing recvfrom.") ! ! def _testRecvFrom(self): ! self.serv_conn.send(MSG) ! ! def testOverFlowRecvFrom(self): ! """Testing recvfrom() in chunks over TCP.""" ! seg1, addr = self.cli_conn.recvfrom(len(MSG)-3) ! seg2, addr = self.cli_conn.recvfrom(1024) ! msg = ''.join((seg1, seg2)) ! hostname, port = addr ! self.assertEqual(hostname, socket.gethostbyname('localhost'), ! "Wrong address from recvfrom.") ! self.assertEqual(msg, MSG, "Error performing recvfrom in chunks.") ! ! def _testOverFlowRecvFrom(self): ! self.serv_conn.send(MSG) ! ! def testSendAll(self): ! """Testing sendall() with a 2048 byte string over TCP.""" ! while 1: ! read = self.cli_conn.recv(1024) ! if not read: ! break ! self.assert_(len(read) == 1024, "Error performing sendall.") ! read = filter(lambda x: x == 'f', read) ! self.assert_(len(read) == 1024, "Error performing sendall.") ! ! def _testSendAll(self): ! big_chunk = ''.join([ 'f' ] * 2048) ! self.serv_conn.sendall(big_chunk) ! ! def testFromFd(self): ! """Testing fromfd().""" ! fd = self.cli_conn.fileno() ! sock = socket.fromfd(fd, socket.AF_INET, socket.SOCK_STREAM) ! msg = sock.recv(1024) ! self.assertEqual(msg, MSG, "Error creating socket using fromfd.") ! ! def _testFromFd(self): ! self.serv_conn.send(MSG) ! ! def testShutdown(self): ! """Testing shutdown().""" ! msg = self.cli_conn.recv(1024) ! self.assertEqual(msg, MSG, "Error testing shutdown.") ! ! def _testShutdown(self): ! self.serv_conn.send(MSG) ! self.serv_conn.shutdown(2) ! ! class BasicUDPTest(ThreadedUDPSocketTest): ! ! def __init__(self, methodName='runTest'): ! ThreadedUDPSocketTest.__init__(self, methodName=methodName) ! ! def testSendtoAndRecv(self): ! """Testing sendto() and Recv() over UDP.""" ! msg = self.serv.recv(len(MSG)) ! self.assertEqual(msg, MSG, "Error performing sendto") ! ! def _testSendtoAndRecv(self): ! self.cli.sendto(MSG, 0, (HOST, PORT)) ! ! def testRecvfrom(self): ! """Testing recfrom() over UDP.""" ! msg, addr = self.serv.recvfrom(len(MSG)) ! hostname, port = addr ! self.assertEqual(hostname, socket.gethostbyname('localhost'), ! "Wrong address from recvfrom.") ! self.assertEqual(msg, MSG, "Error performing recvfrom in chunks.") ! ! def _testRecvfrom(self): ! self.cli.sendto(MSG, 0, (HOST, PORT)) ! ! class NonBlockingTCPTests(ThreadedTCPSocketTest): ! ! def __init__(self, methodName='runTest'): ! ThreadedTCPSocketTest.__init__(self, methodName=methodName) ! ! def testSetBlocking(self): ! """Testing whether set blocking works.""" ! self.serv.setblocking(0) ! start = time.time() try: ! self.serv.accept() ! except socket.error: ! pass ! end = time.time() ! self.assert_((end - start) < 1.0, "Error setting non-blocking mode.") ! def _testSetBlocking(self): ! pass ! ! def testAccept(self): ! """Testing non-blocking accept.""" ! self.serv.setblocking(0) ! try: ! conn, addr = self.serv.accept() ! except socket.error: ! pass ! else: ! self.fail("Error trying to do non-blocking accept.") ! read, write, err = select.select([self.serv], [], []) ! if self.serv in read: ! conn, addr = self.serv.accept() ! else: ! self.fail("Error trying to do accept after select.") ! ! def _testAccept(self): ! time.sleep(1) ! self.cli.connect((HOST, PORT)) ! ! def testConnect(self): ! """Testing non-blocking connect.""" ! time.sleep(1) ! conn, addr = self.serv.accept() ! ! def _testConnect(self): ! self.cli.setblocking(0) ! try: ! self.cli.connect((HOST, PORT)) ! except socket.error: ! pass ! else: ! self.fail("Error trying to do non-blocking connect.") ! read, write, err = select.select([self.cli], [], []) ! if self.cli in read: ! self.cli.connect((HOST, PORT)) ! else: ! self.fail("Error trying to do connect after select.") ! ! def testRecv(self): ! """Testing non-blocking recv.""" ! conn, addr = self.serv.accept() ! conn.setblocking(0) ! try: ! msg = conn.recv(len(MSG)) ! except socket.error: ! pass ! else: ! self.fail("Error trying to do non-blocking recv.") ! read, write, err = select.select([conn], [], []) ! if conn in read: ! msg = conn.recv(len(MSG)) ! self.assertEqual(msg, MSG, "Error performing non-blocking recv.") ! else: ! self.fail("Error during select call to non-blocking socket.") ! ! def _testRecv(self): ! self.cli.connect((HOST, PORT)) ! time.sleep(1) ! self.cli.send(MSG) ! ! class FileObjectClassTestCase(SocketConnectedTest): ! ! def __init__(self, methodName='runTest'): ! SocketConnectedTest.__init__(self, methodName=methodName) ! ! def setUp(self): ! SocketConnectedTest.setUp(self) ! self.serv_file = socket._fileobject(self.cli_conn, 'rb', 8192) ! ! def tearDown(self): ! self.serv_file.close() ! self.serv_file = None ! SocketConnectedTest.tearDown(self) ! ! def clientSetUp(self): ! SocketConnectedTest.clientSetUp(self) ! self.cli_file = socket._fileobject(self.serv_conn, 'rb', 8192) ! ! def clientTearDown(self): ! self.cli_file.close() ! self.cli_file = None ! SocketConnectedTest.clientTearDown(self) ! ! def testSmallRead(self): ! """Performing small file read test.""" ! first_seg = self.serv_file.read(len(MSG)-3) ! second_seg = self.serv_file.read(3) ! msg = ''.join((first_seg, second_seg)) ! self.assertEqual(msg, MSG, "Error performing small read.") ! ! def _testSmallRead(self): ! self.cli_file.write(MSG) ! self.cli_file.flush() ! ! def testUnbufferedRead(self): ! """Performing unbuffered file read test.""" ! buf = '' ! while 1: ! char = self.serv_file.read(1) ! self.failIf(not char, "Error performing unbuffered read.") ! buf += char ! if buf == MSG: ! break ! ! def _testUnbufferedRead(self): ! self.cli_file.write(MSG) ! self.cli_file.flush() ! ! def testReadline(self): ! """Performing file readline test.""" ! line = self.serv_file.readline() ! self.assertEqual(line, MSG, "Error performing readline.") ! ! def _testReadline(self): ! self.cli_file.write(MSG) ! self.cli_file.flush() ! ! def test_main(): ! suite = unittest.TestSuite() ! suite.addTest(unittest.makeSuite(GeneralModuleTests)) ! suite.addTest(unittest.makeSuite(BasicTCPTest)) ! suite.addTest(unittest.makeSuite(BasicUDPTest)) ! suite.addTest(unittest.makeSuite(NonBlockingTCPTests)) ! suite.addTest(unittest.makeSuite(FileObjectClassTestCase)) ! test_support.run_suite(suite) ! ! if __name__ == "__main__": ! test_main() Index: test_timeout.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_timeout.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_timeout.py 6 Jun 2002 21:08:16 -0000 1.1 --- test_timeout.py 12 Jun 2002 19:18:08 -0000 1.2 *************** *** 2,10 **** import unittest import time import socket ! class creationTestCase(unittest.TestCase): """Test Case for socket.gettimeout() and socket.settimeout()""" def setUp(self): --- 2,11 ---- import unittest + import test_support import time import socket ! class CreationTestCase(unittest.TestCase): """Test Case for socket.gettimeout() and socket.settimeout()""" def setUp(self): *************** *** 16,20 **** def testObjectCreation(self): "Test Socket creation" ! self.assertEqual(self.__s.gettimeout(), None, "Timeout socket not default to disable (None)") --- 17,21 ---- def testObjectCreation(self): "Test Socket creation" ! self.assertEqual(self.__s.gettimeout(), None, "Timeout socket not default to disable (None)") *************** *** 22,30 **** "Test return value of getter/setter" self.__s.settimeout(7.345) ! self.assertEqual(self.__s.gettimeout(), 7.345, "settimeout() and gettimeout() return different result") self.__s.settimeout(3) ! self.assertEqual(self.__s.gettimeout(), 3, "settimeout() and gettimeout() return different result") --- 23,31 ---- "Test return value of getter/setter" self.__s.settimeout(7.345) ! self.assertEqual(self.__s.gettimeout(), 7.345, "settimeout() and gettimeout() return different result") self.__s.settimeout(3) ! self.assertEqual(self.__s.gettimeout(), 3, "settimeout() and gettimeout() return different result") *************** *** 40,44 **** ! class timeoutTestCase(unittest.TestCase): """Test Case for socket.socket() timeout functions""" def setUp(self): --- 41,45 ---- ! class TimeoutTestCase(unittest.TestCase): """Test Case for socket.socket() timeout functions""" def setUp(self): *************** *** 77,81 **** _delta = abs(_t1 - _t2) self.assert_(_delta < _timeout + 0.5, ! "timeout (%f) is 0.5 seconds more than required (%f)" %(_delta, _timeout)) --- 78,82 ---- _delta = abs(_t1 - _t2) self.assert_(_delta < _timeout + 0.5, ! "timeout (%f) is 0.5 seconds more than required (%f)" %(_delta, _timeout)) *************** *** 93,97 **** _delta = abs(_t1 - _t2) self.assert_(_delta < _timeout + 0.5, ! "timeout (%f) is 0.5 seconds more than required (%f)" %(_delta, _timeout)) --- 94,98 ---- _delta = abs(_t1 - _t2) self.assert_(_delta < _timeout + 0.5, ! "timeout (%f) is 0.5 seconds more than required (%f)" %(_delta, _timeout)) *************** *** 109,113 **** _delta = abs(_t1 - _t2) self.assert_(_delta < _timeout + 0.5, ! "timeout (%f) is 0.5 seconds more than required (%f)" %(_delta, _timeout)) --- 110,114 ---- _delta = abs(_t1 - _t2) self.assert_(_delta < _timeout + 0.5, ! "timeout (%f) is 0.5 seconds more than required (%f)" %(_delta, _timeout)) *************** *** 128,136 **** ! def suite(): suite = unittest.TestSuite() ! ! return suite if __name__ == "__main__": ! unittest.main() --- 129,138 ---- ! def test_main(): suite = unittest.TestSuite() ! suite.addTest(unittest.makeSuite(CreationTestCase)) ! suite.addTest(unittest.makeSuite(TimeoutTestCase)) ! test_support.run_suite(suite) if __name__ == "__main__": ! test_main() From gvanrossum@users.sourceforge.net Wed Jun 12 20:57:20 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Wed, 12 Jun 2002 12:57:20 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_timeout.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv10355 Modified Files: test_timeout.py Log Message: Add some more basic tests to validate the argument checking of settimeout(), test settimeout(None), and the interaction between settimeout() and setblocking(). Index: test_timeout.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_timeout.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_timeout.py 12 Jun 2002 19:18:08 -0000 1.2 --- test_timeout.py 12 Jun 2002 19:57:18 -0000 1.3 *************** *** 1,3 **** ! #!/home/bernie/src/python23/dist/src/python import unittest --- 1,3 ---- ! """Unit tests for socket timeout feature.""" import unittest *************** *** 7,12 **** --- 7,14 ---- import socket + class CreationTestCase(unittest.TestCase): """Test Case for socket.gettimeout() and socket.settimeout()""" + def setUp(self): self.__s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) *************** *** 40,46 **** --- 42,96 ---- "return type of gettimeout() is not FloatType") + self.__s.settimeout(None) + self.assertEqual(type(self.__s.gettimeout()), type(None), + "return type of gettimeout() is not None") + + def testTypeCheck(self): + "Test type checking by settimeout" + self.__s.settimeout(0) + self.__s.settimeout(0L) + self.__s.settimeout(0.0) + self.__s.settimeout(None) + self.assertRaises(TypeError, self.__s.settimeout, "") + self.assertRaises(TypeError, self.__s.settimeout, u"") + self.assertRaises(TypeError, self.__s.settimeout, ()) + self.assertRaises(TypeError, self.__s.settimeout, []) + self.assertRaises(TypeError, self.__s.settimeout, {}) + self.assertRaises(TypeError, self.__s.settimeout, 0j) + + def testRangeCheck(self): + "Test range checking by settimeout" + self.assertRaises(ValueError, self.__s.settimeout, -1) + self.assertRaises(ValueError, self.__s.settimeout, -1L) + self.assertRaises(ValueError, self.__s.settimeout, -1.0) + + def testTimeoutThenoBlocking(self): + "Test settimeout followed by setblocking" + self.__s.settimeout(10) + self.__s.setblocking(1) + self.assertEqual(self.__s.gettimeout(), None) + self.__s.setblocking(0) + self.assertEqual(self.__s.gettimeout(), None) + + self.__s.settimeout(10) + self.__s.setblocking(0) + self.assertEqual(self.__s.gettimeout(), None) + self.__s.setblocking(1) + self.assertEqual(self.__s.gettimeout(), None) + + def testBlockingThenTimeout(self): + "Test setblocking followed by settimeout" + self.__s.setblocking(0) + self.__s.settimeout(1) + self.assertEqual(self.__s.gettimeout(), 1) + + self.__s.setblocking(1) + self.__s.settimeout(1) + self.assertEqual(self.__s.gettimeout(), 1) + class TimeoutTestCase(unittest.TestCase): """Test Case for socket.socket() timeout functions""" + def setUp(self): self.__s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) From jhylton@users.sourceforge.net Wed Jun 12 21:08:58 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Wed, 12 Jun 2002 13:08:58 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils extension.py,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv15688 Modified Files: extension.py Log Message: Add a new definition to Extension objects: depends. depends is a list of files that the target depends, but aren't direct sources of the target. think .h files. Index: extension.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/extension.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** extension.py 29 Mar 2002 18:00:19 -0000 1.11 --- extension.py 12 Jun 2002 20:08:56 -0000 1.12 *************** *** 74,77 **** --- 74,79 ---- extensions, which typically export exactly one symbol: "init" + extension_name. + depends : [string] + list of files that the extension depends on """ *************** *** 87,90 **** --- 89,93 ---- extra_link_args=None, export_symbols=None, + depends=None, ): *************** *** 106,109 **** --- 109,113 ---- self.extra_link_args = extra_link_args or [] self.export_symbols = export_symbols or [] + self.depends = depends or [] # class Extension From jhylton@users.sourceforge.net Wed Jun 12 21:08:58 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Wed, 12 Jun 2002 13:08:58 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils/command build_ext.py,1.82,1.83 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory usw-pr-cvs1:/tmp/cvs-serv15688/command Modified Files: build_ext.py Log Message: Add a new definition to Extension objects: depends. depends is a list of files that the target depends, but aren't direct sources of the target. think .h files. Index: build_ext.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/build_ext.py,v retrieving revision 1.82 retrieving revision 1.83 diff -C2 -d -r1.82 -r1.83 *** build_ext.py 11 Jun 2002 06:22:30 -0000 1.82 --- build_ext.py 12 Jun 2002 20:08:56 -0000 1.83 *************** *** 423,427 **** self.get_ext_filename(fullname)) ! if not (self.force or newer_group(sources, ext_filename, 'newer')): log.debug("skipping '%s' extension (up-to-date)", ext.name) return --- 423,428 ---- self.get_ext_filename(fullname)) ! depends = sources + ext.depends ! if not (self.force or newer_group(depends, ext_filename, 'newer')): log.debug("skipping '%s' extension (up-to-date)", ext.name) return From gvanrossum@users.sourceforge.net Wed Jun 12 21:22:51 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Wed, 12 Jun 2002 13:22:51 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_timeout.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv21373 Modified Files: test_timeout.py Log Message: Docstring, layout and style tweaking. Increase fuzz to 1 second. Index: test_timeout.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_timeout.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_timeout.py 12 Jun 2002 19:57:18 -0000 1.3 --- test_timeout.py 12 Jun 2002 20:22:49 -0000 1.4 *************** *** 9,165 **** class CreationTestCase(unittest.TestCase): ! """Test Case for socket.gettimeout() and socket.settimeout()""" def setUp(self): ! self.__s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) def tearDown(self): ! self.__s.close() def testObjectCreation(self): "Test Socket creation" ! self.assertEqual(self.__s.gettimeout(), None, ! "Timeout socket not default to disable (None)") def testFloatReturnValue(self): ! "Test return value of getter/setter" ! self.__s.settimeout(7.345) ! self.assertEqual(self.__s.gettimeout(), 7.345, ! "settimeout() and gettimeout() return different result") ! self.__s.settimeout(3) ! self.assertEqual(self.__s.gettimeout(), 3, ! "settimeout() and gettimeout() return different result") ! def testReturnType(self): ! "Test return type of getter/setter" ! self.__s.settimeout(1) ! self.assertEqual(type(self.__s.gettimeout()), type(1.0), ! "return type of gettimeout() is not FloatType") ! self.__s.settimeout(3.9) ! self.assertEqual(type(self.__s.gettimeout()), type(1.0), ! "return type of gettimeout() is not FloatType") ! self.__s.settimeout(None) ! self.assertEqual(type(self.__s.gettimeout()), type(None), ! "return type of gettimeout() is not None") def testTypeCheck(self): ! "Test type checking by settimeout" ! self.__s.settimeout(0) ! self.__s.settimeout(0L) ! self.__s.settimeout(0.0) ! self.__s.settimeout(None) ! self.assertRaises(TypeError, self.__s.settimeout, "") ! self.assertRaises(TypeError, self.__s.settimeout, u"") ! self.assertRaises(TypeError, self.__s.settimeout, ()) ! self.assertRaises(TypeError, self.__s.settimeout, []) ! self.assertRaises(TypeError, self.__s.settimeout, {}) ! self.assertRaises(TypeError, self.__s.settimeout, 0j) def testRangeCheck(self): ! "Test range checking by settimeout" ! self.assertRaises(ValueError, self.__s.settimeout, -1) ! self.assertRaises(ValueError, self.__s.settimeout, -1L) ! self.assertRaises(ValueError, self.__s.settimeout, -1.0) def testTimeoutThenoBlocking(self): ! "Test settimeout followed by setblocking" ! self.__s.settimeout(10) ! self.__s.setblocking(1) ! self.assertEqual(self.__s.gettimeout(), None) ! self.__s.setblocking(0) ! self.assertEqual(self.__s.gettimeout(), None) ! self.__s.settimeout(10) ! self.__s.setblocking(0) ! self.assertEqual(self.__s.gettimeout(), None) ! self.__s.setblocking(1) ! self.assertEqual(self.__s.gettimeout(), None) def testBlockingThenTimeout(self): ! "Test setblocking followed by settimeout" ! self.__s.setblocking(0) ! self.__s.settimeout(1) ! self.assertEqual(self.__s.gettimeout(), 1) ! self.__s.setblocking(1) ! self.__s.settimeout(1) ! self.assertEqual(self.__s.gettimeout(), 1) class TimeoutTestCase(unittest.TestCase): ! """Test Case for socket.socket() timeout functions""" def setUp(self): ! self.__s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ! self.__addr_remote = ('www.google.com', 80) ! self.__addr_local = ('127.0.0.1', 25339) def tearDown(self): ! self.__s.close() def testConnectTimeout(self): "Test connect() timeout" _timeout = 0.02 ! self.__s.settimeout(_timeout) _t1 = time.time() ! self.failUnlessRaises(socket.error, self.__s.connect, ! self.__addr_remote) _t2 = time.time() _delta = abs(_t1 - _t2) ! self.assert_(_delta < _timeout + 0.5, ! "timeout (%f) is 0.5 seconds more than required (%f)" ! %(_delta, _timeout)) def testRecvTimeout(self): "Test recv() timeout" _timeout = 0.02 ! self.__s.connect(self.__addr_remote) ! self.__s.settimeout(_timeout) _t1 = time.time() ! self.failUnlessRaises(socket.error, self.__s.recv, 1024) _t2 = time.time() _delta = abs(_t1 - _t2) ! self.assert_(_delta < _timeout + 0.5, ! "timeout (%f) is 0.5 seconds more than required (%f)" ! %(_delta, _timeout)) def testAcceptTimeout(self): ! "Test accept() timeout()" _timeout = 2 ! self.__s.settimeout(_timeout) ! self.__s.bind(self.__addr_local) ! self.__s.listen(5) _t1 = time.time() ! self.failUnlessRaises(socket.error, self.__s.accept) _t2 = time.time() _delta = abs(_t1 - _t2) ! self.assert_(_delta < _timeout + 0.5, ! "timeout (%f) is 0.5 seconds more than required (%f)" ! %(_delta, _timeout)) def testRecvfromTimeout(self): ! "Test recvfrom() timeout()" _timeout = 2 ! self.__s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) ! self.__s.settimeout(_timeout) ! self.__s.bind(self.__addr_local) _t1 = time.time() ! self.failUnlessRaises(socket.error, self.__s.recvfrom, 8192) _t2 = time.time() _delta = abs(_t1 - _t2) ! self.assert_(_delta < _timeout + 0.5, ! "timeout (%f) is 0.5 seconds more than required (%f)" ! %(_delta, _timeout)) def testSend(self): --- 9,162 ---- class CreationTestCase(unittest.TestCase): ! """Test case for socket.gettimeout() and socket.settimeout()""" def setUp(self): ! self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) def tearDown(self): ! self.sock.close() def testObjectCreation(self): "Test Socket creation" ! self.assertEqual(self.sock.gettimeout(), None, ! "timeout not disabled by default") def testFloatReturnValue(self): ! "Test return value of gettimeout()" ! self.sock.settimeout(7.345) ! self.assertEqual(self.sock.gettimeout(), 7.345) ! self.sock.settimeout(3) ! self.assertEqual(self.sock.gettimeout(), 3) ! self.sock.settimeout(None) ! self.assertEqual(self.sock.gettimeout(), None) ! def testReturnType(self): ! "Test return type of gettimeout()" ! self.sock.settimeout(1) ! self.assertEqual(type(self.sock.gettimeout()), type(1.0)) ! self.sock.settimeout(3.9) ! self.assertEqual(type(self.sock.gettimeout()), type(1.0)) def testTypeCheck(self): ! "Test type checking by settimeout()" ! self.sock.settimeout(0) ! self.sock.settimeout(0L) ! self.sock.settimeout(0.0) ! self.sock.settimeout(None) ! self.assertRaises(TypeError, self.sock.settimeout, "") ! self.assertRaises(TypeError, self.sock.settimeout, u"") ! self.assertRaises(TypeError, self.sock.settimeout, ()) ! self.assertRaises(TypeError, self.sock.settimeout, []) ! self.assertRaises(TypeError, self.sock.settimeout, {}) ! self.assertRaises(TypeError, self.sock.settimeout, 0j) def testRangeCheck(self): ! "Test range checking by settimeout()" ! self.assertRaises(ValueError, self.sock.settimeout, -1) ! self.assertRaises(ValueError, self.sock.settimeout, -1L) ! self.assertRaises(ValueError, self.sock.settimeout, -1.0) def testTimeoutThenoBlocking(self): ! "Test settimeout() followed by setblocking()" ! self.sock.settimeout(10) ! self.sock.setblocking(1) ! self.assertEqual(self.sock.gettimeout(), None) ! self.sock.setblocking(0) ! self.assertEqual(self.sock.gettimeout(), None) ! self.sock.settimeout(10) ! self.sock.setblocking(0) ! self.assertEqual(self.sock.gettimeout(), None) ! self.sock.setblocking(1) ! self.assertEqual(self.sock.gettimeout(), None) def testBlockingThenTimeout(self): ! "Test setblocking() followed by settimeout()" ! self.sock.setblocking(0) ! self.sock.settimeout(1) ! self.assertEqual(self.sock.gettimeout(), 1) ! self.sock.setblocking(1) ! self.sock.settimeout(1) ! self.assertEqual(self.sock.gettimeout(), 1) class TimeoutTestCase(unittest.TestCase): ! """Test case for socket.socket() timeout functions""" ! ! fuzz = 1.0 def setUp(self): ! self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ! self.addr_remote = ('www.google.com', 80) ! self.addr_local = ('127.0.0.1', 25339) def tearDown(self): ! self.sock.close() def testConnectTimeout(self): "Test connect() timeout" _timeout = 0.02 ! self.sock.settimeout(_timeout) _t1 = time.time() ! self.failUnlessRaises(socket.error, self.sock.connect, ! self.addr_remote) _t2 = time.time() _delta = abs(_t1 - _t2) ! self.assert_(_delta < _timeout + self.fuzz, ! "timeout (%g) is %g seconds more than expected (%g)" ! %(_delta, self.fuzz, _timeout)) def testRecvTimeout(self): "Test recv() timeout" _timeout = 0.02 ! self.sock.connect(self.addr_remote) ! self.sock.settimeout(_timeout) _t1 = time.time() ! self.failUnlessRaises(socket.error, self.sock.recv, 1024) _t2 = time.time() _delta = abs(_t1 - _t2) ! self.assert_(_delta < _timeout + self.fuzz, ! "timeout (%g) is %g seconds more than expected (%g)" ! %(_delta, self.fuzz, _timeout)) def testAcceptTimeout(self): ! "Test accept() timeout" _timeout = 2 ! self.sock.settimeout(_timeout) ! self.sock.bind(self.addr_local) ! self.sock.listen(5) _t1 = time.time() ! self.failUnlessRaises(socket.error, self.sock.accept) _t2 = time.time() _delta = abs(_t1 - _t2) ! self.assert_(_delta < _timeout + self.fuzz, ! "timeout (%g) is %g seconds more than expected (%g)" ! %(_delta, self.fuzz, _timeout)) def testRecvfromTimeout(self): ! "Test recvfrom() timeout" _timeout = 2 ! self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) ! self.sock.settimeout(_timeout) ! self.sock.bind(self.addr_local) _t1 = time.time() ! self.failUnlessRaises(socket.error, self.sock.recvfrom, 8192) _t2 = time.time() _delta = abs(_t1 - _t2) ! self.assert_(_delta < _timeout + self.fuzz, ! "timeout (%g) is %g seconds more than expected (%g)" ! %(_delta, self.fuzz, _timeout)) def testSend(self): From gvanrossum@users.sourceforge.net Wed Jun 12 21:46:52 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Wed, 12 Jun 2002 13:46:52 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_socket.py,1.26,1.27 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv603 Modified Files: test_socket.py Log Message: testSetSockOpt() should not require the reuse flag to be 1 -- any nonzero value is OK. Also fixed the error message for this and for testGetSockOpt(). Index: test_socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** test_socket.py 12 Jun 2002 20:38:30 -0000 1.26 --- test_socket.py 12 Jun 2002 20:46:49 -0000 1.27 *************** *** 254,258 **** sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) reuse = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR) ! self.assert_(reuse == 0, "Error performing getsockopt.") def testSetSockOpt(self): --- 254,258 ---- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) reuse = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR) ! self.failIf(reuse != 0, "initial mode is reuse") def testSetSockOpt(self): *************** *** 261,265 **** sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) reuse = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR) ! self.assert_(reuse == 1, "Error performing setsockopt.") class BasicTCPTest(SocketConnectedTest): --- 261,265 ---- sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) reuse = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR) ! self.failIf(reuse == 0, "failed to set reuse mode") class BasicTCPTest(SocketConnectedTest): From gvanrossum@users.sourceforge.net Wed Jun 12 21:49:01 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Wed, 12 Jun 2002 13:49:01 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_socket.py,1.27,1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv1739 Modified Files: test_socket.py Log Message: Allow absent fromfd(), for Windows. Index: test_socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** test_socket.py 12 Jun 2002 20:46:49 -0000 1.27 --- test_socket.py 12 Jun 2002 20:48:59 -0000 1.28 *************** *** 324,327 **** --- 324,329 ---- def testFromFd(self): """Testing fromfd().""" + if not hasattr(socket, fromfd): + return # On Windows, this doesn't exist fd = self.cli_conn.fileno() sock = socket.fromfd(fd, socket.AF_INET, socket.SOCK_STREAM) From gvanrossum@users.sourceforge.net Wed Jun 12 21:38:32 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Wed, 12 Jun 2002 13:38:32 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_socket.py,1.25,1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv28648 Modified Files: test_socket.py Log Message: Lose the message on assertEqual calls -- they actually hide information on what went wrong. Index: test_socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** test_socket.py 12 Jun 2002 19:18:08 -0000 1.25 --- test_socket.py 12 Jun 2002 20:38:30 -0000 1.26 *************** *** 271,275 **** """Testing large receive over TCP.""" msg = self.cli_conn.recv(1024) ! self.assertEqual(msg, MSG, "Error performing recv.") def _testRecv(self): --- 271,275 ---- """Testing large receive over TCP.""" msg = self.cli_conn.recv(1024) ! self.assertEqual(msg, MSG) def _testRecv(self): *************** *** 281,285 **** seg2 = self.cli_conn.recv(1024) msg = ''.join ((seg1, seg2)) ! self.assertEqual(msg, MSG, "Error performing recv in chunks.") def _testOverFlowRecv(self): --- 281,285 ---- seg2 = self.cli_conn.recv(1024) msg = ''.join ((seg1, seg2)) ! self.assertEqual(msg, MSG) def _testOverFlowRecv(self): *************** *** 290,296 **** msg, addr = self.cli_conn.recvfrom(1024) hostname, port = addr ! self.assertEqual (hostname, socket.gethostbyname('localhost'), ! "Wrong address from recvfrom.") ! self.assertEqual(msg, MSG, "Error performing recvfrom.") def _testRecvFrom(self): --- 290,295 ---- msg, addr = self.cli_conn.recvfrom(1024) hostname, port = addr ! self.assertEqual(hostname, socket.gethostbyname('localhost')) ! self.assertEqual(msg, MSG) def _testRecvFrom(self): *************** *** 303,309 **** msg = ''.join((seg1, seg2)) hostname, port = addr ! self.assertEqual(hostname, socket.gethostbyname('localhost'), ! "Wrong address from recvfrom.") ! self.assertEqual(msg, MSG, "Error performing recvfrom in chunks.") def _testOverFlowRecvFrom(self): --- 302,307 ---- msg = ''.join((seg1, seg2)) hostname, port = addr ! self.assertEqual(hostname, socket.gethostbyname('localhost')) ! self.assertEqual(msg, MSG) def _testOverFlowRecvFrom(self): *************** *** 329,333 **** sock = socket.fromfd(fd, socket.AF_INET, socket.SOCK_STREAM) msg = sock.recv(1024) ! self.assertEqual(msg, MSG, "Error creating socket using fromfd.") def _testFromFd(self): --- 327,331 ---- sock = socket.fromfd(fd, socket.AF_INET, socket.SOCK_STREAM) msg = sock.recv(1024) ! self.assertEqual(msg, MSG) def _testFromFd(self): *************** *** 337,341 **** """Testing shutdown().""" msg = self.cli_conn.recv(1024) ! self.assertEqual(msg, MSG, "Error testing shutdown.") def _testShutdown(self): --- 335,339 ---- """Testing shutdown().""" msg = self.cli_conn.recv(1024) ! self.assertEqual(msg, MSG) def _testShutdown(self): *************** *** 351,355 **** """Testing sendto() and Recv() over UDP.""" msg = self.serv.recv(len(MSG)) ! self.assertEqual(msg, MSG, "Error performing sendto") def _testSendtoAndRecv(self): --- 349,353 ---- """Testing sendto() and Recv() over UDP.""" msg = self.serv.recv(len(MSG)) ! self.assertEqual(msg, MSG) def _testSendtoAndRecv(self): *************** *** 360,366 **** msg, addr = self.serv.recvfrom(len(MSG)) hostname, port = addr ! self.assertEqual(hostname, socket.gethostbyname('localhost'), ! "Wrong address from recvfrom.") ! self.assertEqual(msg, MSG, "Error performing recvfrom in chunks.") def _testRecvfrom(self): --- 358,363 ---- msg, addr = self.serv.recvfrom(len(MSG)) hostname, port = addr ! self.assertEqual(hostname, socket.gethostbyname('localhost')) ! self.assertEqual(msg, MSG) def _testRecvfrom(self): *************** *** 437,441 **** if conn in read: msg = conn.recv(len(MSG)) ! self.assertEqual(msg, MSG, "Error performing non-blocking recv.") else: self.fail("Error during select call to non-blocking socket.") --- 434,438 ---- if conn in read: msg = conn.recv(len(MSG)) ! self.assertEqual(msg, MSG) else: self.fail("Error during select call to non-blocking socket.") *************** *** 474,478 **** second_seg = self.serv_file.read(3) msg = ''.join((first_seg, second_seg)) ! self.assertEqual(msg, MSG, "Error performing small read.") def _testSmallRead(self): --- 471,475 ---- second_seg = self.serv_file.read(3) msg = ''.join((first_seg, second_seg)) ! self.assertEqual(msg, MSG) def _testSmallRead(self): *************** *** 485,489 **** while 1: char = self.serv_file.read(1) ! self.failIf(not char, "Error performing unbuffered read.") buf += char if buf == MSG: --- 482,486 ---- while 1: char = self.serv_file.read(1) ! self.failIf(not char) buf += char if buf == MSG: *************** *** 497,501 **** """Performing file readline test.""" line = self.serv_file.readline() ! self.assertEqual(line, MSG, "Error performing readline.") def _testReadline(self): --- 494,498 ---- """Performing file readline test.""" line = self.serv_file.readline() ! self.assertEqual(line, MSG) def _testReadline(self): From gvanrossum@users.sourceforge.net Wed Jun 12 21:55:20 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Wed, 12 Jun 2002 13:55:20 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_socket.py,1.28,1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv4602 Modified Files: test_socket.py Log Message: Argh. Typo. :-( Index: test_socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** test_socket.py 12 Jun 2002 20:48:59 -0000 1.28 --- test_socket.py 12 Jun 2002 20:55:17 -0000 1.29 *************** *** 324,328 **** def testFromFd(self): """Testing fromfd().""" ! if not hasattr(socket, fromfd): return # On Windows, this doesn't exist fd = self.cli_conn.fileno() --- 324,328 ---- def testFromFd(self): """Testing fromfd().""" ! if not hasattr(socket, "fromfd"): return # On Windows, this doesn't exist fd = self.cli_conn.fileno() From gvanrossum@users.sourceforge.net Wed Jun 12 22:17:22 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Wed, 12 Jun 2002 14:17:22 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_socket.py,1.29,1.30 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv14753 Modified Files: test_socket.py Log Message: Some provisional changes to get more tests to run on Windows (I hope). Index: test_socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** test_socket.py 12 Jun 2002 20:55:17 -0000 1.29 --- test_socket.py 12 Jun 2002 21:17:20 -0000 1.30 *************** *** 236,240 **** def testGetServByName(self): ! """Testing getservbyname.""" if hasattr(socket, 'getservbyname'): socket.getservbyname('telnet', 'tcp') --- 236,240 ---- def testGetServByName(self): ! """Testing getservbyname().""" if hasattr(socket, 'getservbyname'): socket.getservbyname('telnet', 'tcp') *************** *** 247,251 **** --- 247,253 ---- """Testing getsockname().""" sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.bind(("0.0.0.0", PORT+1)) name = sock.getsockname() + self.assertEqual(name, ("0.0.0.0", PORT+1)) def testGetSockOpt(self): *************** *** 290,294 **** msg, addr = self.cli_conn.recvfrom(1024) hostname, port = addr ! self.assertEqual(hostname, socket.gethostbyname('localhost')) self.assertEqual(msg, MSG) --- 292,296 ---- msg, addr = self.cli_conn.recvfrom(1024) hostname, port = addr ! ##self.assertEqual(hostname, socket.gethostbyname('localhost')) self.assertEqual(msg, MSG) *************** *** 302,306 **** msg = ''.join((seg1, seg2)) hostname, port = addr ! self.assertEqual(hostname, socket.gethostbyname('localhost')) self.assertEqual(msg, MSG) --- 304,308 ---- msg = ''.join((seg1, seg2)) hostname, port = addr ! ##self.assertEqual(hostname, socket.gethostbyname('localhost')) self.assertEqual(msg, MSG) *************** *** 356,367 **** self.cli.sendto(MSG, 0, (HOST, PORT)) ! def testRecvfrom(self): """Testing recfrom() over UDP.""" msg, addr = self.serv.recvfrom(len(MSG)) hostname, port = addr ! self.assertEqual(hostname, socket.gethostbyname('localhost')) self.assertEqual(msg, MSG) ! def _testRecvfrom(self): self.cli.sendto(MSG, 0, (HOST, PORT)) --- 358,369 ---- self.cli.sendto(MSG, 0, (HOST, PORT)) ! def testRecvFrom(self): """Testing recfrom() over UDP.""" msg, addr = self.serv.recvfrom(len(MSG)) hostname, port = addr ! ##self.assertEqual(hostname, socket.gethostbyname('localhost')) self.assertEqual(msg, MSG) ! def _testRecvFrom(self): self.cli.sendto(MSG, 0, (HOST, PORT)) From gvanrossum@users.sourceforge.net Wed Jun 12 22:19:42 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Wed, 12 Jun 2002 14:19:42 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_socket.py,1.30,1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv15558 Modified Files: test_socket.py Log Message: Don't test for Java, test for sys.getrefcount. Index: test_socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** test_socket.py 12 Jun 2002 21:17:20 -0000 1.30 --- test_socket.py 12 Jun 2002 21:19:40 -0000 1.31 *************** *** 215,222 **** self.fail("Error testing host resolution mechanisms.") ! def testJavaRef(self): """Testing reference count for getnameinfo.""" import sys ! if not sys.platform.startswith('java'): try: # On some versions, this loses a reference --- 215,222 ---- self.fail("Error testing host resolution mechanisms.") ! def testRefCountGetNameInfo(self): """Testing reference count for getnameinfo.""" import sys ! if hasattr(sys, "getrefcount"): try: # On some versions, this loses a reference From gvanrossum@users.sourceforge.net Wed Jun 12 22:29:45 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Wed, 12 Jun 2002 14:29:45 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_socket.py,1.31,1.32 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv19333 Modified Files: test_socket.py Log Message: Remove some overly complicated ways to concatenate and repeat strings using "".join(). Fold a long line. Index: test_socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** test_socket.py 12 Jun 2002 21:19:40 -0000 1.31 --- test_socket.py 12 Jun 2002 21:29:43 -0000 1.32 *************** *** 52,57 **** # Do some munging to start the client test. ! test_method = getattr(self, ''.join(('_', self._TestCase__testMethodName))) ! self.client_thread = thread.start_new_thread(self.clientRun, (test_method, )) self.__setUp() --- 52,58 ---- # Do some munging to start the client test. ! test_method = getattr(self, '_' + self._TestCase__testMethodName) ! self.client_thread = thread.start_new_thread( ! self.clientRun, (test_method,)) self.__setUp() *************** *** 282,286 **** seg1 = self.cli_conn.recv(len(MSG) - 3) seg2 = self.cli_conn.recv(1024) ! msg = ''.join ((seg1, seg2)) self.assertEqual(msg, MSG) --- 283,287 ---- seg1 = self.cli_conn.recv(len(MSG) - 3) seg2 = self.cli_conn.recv(1024) ! msg = seg1 + seg2 self.assertEqual(msg, MSG) *************** *** 302,306 **** seg1, addr = self.cli_conn.recvfrom(len(MSG)-3) seg2, addr = self.cli_conn.recvfrom(1024) ! msg = ''.join((seg1, seg2)) hostname, port = addr ##self.assertEqual(hostname, socket.gethostbyname('localhost')) --- 303,307 ---- seg1, addr = self.cli_conn.recvfrom(len(MSG)-3) seg2, addr = self.cli_conn.recvfrom(1024) ! msg = seg1 + seg2 hostname, port = addr ##self.assertEqual(hostname, socket.gethostbyname('localhost')) *************** *** 321,325 **** def _testSendAll(self): ! big_chunk = ''.join([ 'f' ] * 2048) self.serv_conn.sendall(big_chunk) --- 322,326 ---- def _testSendAll(self): ! big_chunk = 'f' * 2048 self.serv_conn.sendall(big_chunk) *************** *** 474,478 **** first_seg = self.serv_file.read(len(MSG)-3) second_seg = self.serv_file.read(3) ! msg = ''.join((first_seg, second_seg)) self.assertEqual(msg, MSG) --- 475,479 ---- first_seg = self.serv_file.read(len(MSG)-3) second_seg = self.serv_file.read(3) ! msg = first_seg + second_seg self.assertEqual(msg, MSG) From fdrake@users.sourceforge.net Thu Jun 13 02:34:52 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed, 12 Jun 2002 18:34:52 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libcalendar.tex,1.14,1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv9210/lib Modified Files: libcalendar.tex Log Message: Add version annotations for some older changes to the calendar module. Closes SF patch #567867. Index: libcalendar.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcalendar.tex,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** libcalendar.tex 12 Dec 2001 05:40:46 -0000 1.14 --- libcalendar.tex 13 Jun 2002 01:34:50 -0000 1.15 *************** *** 27,34 **** --- 27,36 ---- calendar.setfirstweekday(calendar.SUNDAY) \end{verbatim} + \versionadded{2.0} \end{funcdesc} \begin{funcdesc}{firstweekday}{} Returns the current setting for the weekday to start each week. + \versionadded{2.0} \end{funcdesc} *************** *** 40,43 **** --- 42,47 ---- Returns the number of leap years in the range [\var{y1}\ldots\var{y2}), where \var{y1} and \var{y2} are years. + \versionchanged[This function didn't work for ranges spanning + a century change in Python 1.5.2]{2.0} \end{funcdesc} *************** *** 69,72 **** --- 73,77 ---- each week will use. Depends on the first weekday as set by \function{setfirstweekday()}. + \versionadded{2.0} \end{funcdesc} *************** *** 83,86 **** --- 88,92 ---- \function{setfirstweekday()}. The earliest year for which a calendar can be generated is platform-dependent. + \versionadded{2.0} \end{funcdesc} *************** *** 91,94 **** --- 97,101 ---- an epoch of 1970, and the POSIX encoding. In fact, \function{time.gmtime()} and \function{timegm()} are each others' inverse. + \versionadded{2.0} \end{funcdesc} From fdrake@users.sourceforge.net Thu Jun 13 02:35:21 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed, 12 Jun 2002 18:35:21 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libcalendar.tex,1.14,1.14.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv9330/lib Modified Files: Tag: release22-maint libcalendar.tex Log Message: Add version annotations for some older changes to the calendar module. Closes SF patch #567867. Index: libcalendar.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcalendar.tex,v retrieving revision 1.14 retrieving revision 1.14.6.1 diff -C2 -d -r1.14 -r1.14.6.1 *** libcalendar.tex 12 Dec 2001 05:40:46 -0000 1.14 --- libcalendar.tex 13 Jun 2002 01:35:19 -0000 1.14.6.1 *************** *** 27,34 **** --- 27,36 ---- calendar.setfirstweekday(calendar.SUNDAY) \end{verbatim} + \versionadded{2.0} \end{funcdesc} \begin{funcdesc}{firstweekday}{} Returns the current setting for the weekday to start each week. + \versionadded{2.0} \end{funcdesc} *************** *** 40,43 **** --- 42,47 ---- Returns the number of leap years in the range [\var{y1}\ldots\var{y2}), where \var{y1} and \var{y2} are years. + \versionchanged[This function didn't work for ranges spanning + a century change in Python 1.5.2]{2.0} \end{funcdesc} *************** *** 69,72 **** --- 73,77 ---- each week will use. Depends on the first weekday as set by \function{setfirstweekday()}. + \versionadded{2.0} \end{funcdesc} *************** *** 83,86 **** --- 88,92 ---- \function{setfirstweekday()}. The earliest year for which a calendar can be generated is platform-dependent. + \versionadded{2.0} \end{funcdesc} *************** *** 91,94 **** --- 97,101 ---- an epoch of 1970, and the POSIX encoding. In fact, \function{time.gmtime()} and \function{timegm()} are each others' inverse. + \versionadded{2.0} \end{funcdesc} From fdrake@users.sourceforge.net Thu Jun 13 02:36:44 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed, 12 Jun 2002 18:36:44 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libcalendar.tex,1.9.6.1,1.9.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv9683/lib Modified Files: Tag: release21-maint libcalendar.tex Log Message: Add version annotations for some older changes to the calendar module. Closes SF patch #567867. Added a couple of minor clarifications present in the 2.2.x and 2.3 version of the documentation which also apply to 2.1.x. Index: libcalendar.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcalendar.tex,v retrieving revision 1.9.6.1 retrieving revision 1.9.6.2 diff -C2 -d -r1.9.6.1 -r1.9.6.2 *** libcalendar.tex 9 May 2001 15:52:56 -0000 1.9.6.1 --- libcalendar.tex 13 Jun 2002 01:36:42 -0000 1.9.6.2 *************** *** 26,33 **** --- 26,35 ---- calendar.setfirstweekday(calendar.SUNDAY) \end{verbatim} + \versionadded{2.0} \end{funcdesc} \begin{funcdesc}{firstweekday}{} Returns the current setting for the weekday to start each week. + \versionadded{2.0} \end{funcdesc} *************** *** 38,42 **** \begin{funcdesc}{leapdays}{y1, y2} Returns the number of leap years in the range ! [\var{y1}\ldots\var{y2}). \end{funcdesc} --- 40,46 ---- \begin{funcdesc}{leapdays}{y1, y2} Returns the number of leap years in the range ! [\var{y1}\ldots\var{y2}), where \var{y1} and \var{y2} are years. ! \versionchanged[This function didn't work for ranges spanning ! a century change in Python 1.5.2]{2.0} \end{funcdesc} *************** *** 68,71 **** --- 72,76 ---- each week will use. Depends on the first weekday as set by \function{setfirstweekday()}. + \versionadded{2.0} \end{funcdesc} *************** *** 80,84 **** width, lines per week, and number of spaces between month columns, respectively. Depends on the first weekday as set by ! \function{setfirstweekday()}. \end{funcdesc} --- 85,91 ---- width, lines per week, and number of spaces between month columns, respectively. Depends on the first weekday as set by ! \function{setfirstweekday()}. The earliest year for which a calendar can ! be generated is platform-dependent. ! \versionadded{2.0} \end{funcdesc} *************** *** 89,92 **** --- 96,100 ---- an epoch of 1970, and the POSIX encoding. In fact, \function{time.gmtime()} and \function{timegm()} are each others' inverse. + \versionadded{2.0} \end{funcdesc} From gvanrossum@users.sourceforge.net Thu Jun 13 12:41:09 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 13 Jun 2002 04:41:09 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.424,1.425 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv16945 Modified Files: NEWS Log Message: Changed the extended slice example to show that you can reverse a string with a [::-1] slice. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.424 retrieving revision 1.425 diff -C2 -d -r1.424 -r1.425 *** NEWS 12 Jun 2002 03:45:21 -0000 1.424 --- NEWS 13 Jun 2002 11:41:07 -0000 1.425 *************** *** 11,16 **** - Most builtin sequences now support "extended slices", i.e. slices ! with a third "stride" parameter. For example, "range(10)[1:6:2]" ! evaluates to [1, 3, 5]. - Cycles going through the __class__ link of a new-style instance are --- 11,16 ---- - Most builtin sequences now support "extended slices", i.e. slices ! with a third "stride" parameter. For example, "hello world"[::-1] ! gives "dlrow olleh". - Cycles going through the __class__ link of a new-style instance are From fdrake@users.sourceforge.net Thu Jun 13 12:51:50 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu, 13 Jun 2002 04:51:50 -0700 Subject: [Python-checkins] python/dist/src/Doc/api abstract.tex,1.15,1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory usw-pr-cvs1:/tmp/cvs-serv19515/api Modified Files: abstract.tex Log Message: Add documentation for PyObject_RichCompare() and PyObject_RichCompareBool(), constributed by David Abrahams. This closes SF patch #568081. Index: abstract.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/abstract.tex,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** abstract.tex 23 May 2002 16:02:28 -0000 1.15 --- abstract.tex 13 Jun 2002 11:51:48 -0000 1.16 *************** *** 82,85 **** --- 82,127 ---- + \begin{cfuncdesc}{PyObject*}{PyObject_RichCompare}{PyObject *o1, + PyObject *o2, int op} + Compare the values of \var{o1} and \var{o2} using the operation + specified by \var{op}, which must be one of + \constant{Py_LT}, + \constant{Py_LE}, + \constant{Py_EQ}, + \constant{Py_NE}, + \constant{Py_GT}, or + \constant{Py_GE}, corresponding to + \code{<}, + \code{<=}, + \code{==}, + \code{!=}, + \code{>}, or + \code{>=} respectively. This is the equivalent of the Python expression + \samp{\var{o1} \emph{op} \var{o2}}, where \emph{op} is the operator + corresponding to \var{op}. Returns the value of the comparison on + success, or \NULL{} on failure. + \end{cfuncdesc} + + \begin{cfuncdesc}{int}{PyObject_RichCompareBool}{PyObject *o1, + PyObject *o2, int op} + Compare the values of \var{o1} and \var{o2} using the operation + specified by \var{op}, which must be one of + \constant{Py_LT}, + \constant{Py_LE}, + \constant{Py_EQ}, + \constant{Py_NE}, + \constant{Py_GT}, or + \constant{Py_GE}, corresponding to + \code{<}, + \code{<=}, + \code{==}, + \code{!=}, + \code{>}, or + \code{>=} respectively. Returns \code{-1} on error, \code{0} if the + result is false, \code{1} otherwise. This is the equivalent of the + Python expression \samp{\var{o1} \emph{op} \var{o2}}, where + \emph{op} is the operator corresponding to \var{op}. + \end{cfuncdesc} + \begin{cfuncdesc}{int}{PyObject_Cmp}{PyObject *o1, PyObject *o2, int *result} Compare the values of \var{o1} and \var{o2} using a routine provided From fdrake@users.sourceforge.net Thu Jun 13 12:52:23 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu, 13 Jun 2002 04:52:23 -0700 Subject: [Python-checkins] python/dist/src/Doc/api abstract.tex,1.8.6.3,1.8.6.4 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory usw-pr-cvs1:/tmp/cvs-serv19699/api Modified Files: Tag: release22-maint abstract.tex Log Message: Add documentation for PyObject_RichCompare() and PyObject_RichCompareBool(), constributed by David Abrahams. This closes SF patch #568081. Index: abstract.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/abstract.tex,v retrieving revision 1.8.6.3 retrieving revision 1.8.6.4 diff -C2 -d -r1.8.6.3 -r1.8.6.4 *** abstract.tex 4 Apr 2002 04:11:48 -0000 1.8.6.3 --- abstract.tex 13 Jun 2002 11:52:21 -0000 1.8.6.4 *************** *** 82,85 **** --- 82,127 ---- + \begin{cfuncdesc}{PyObject*}{PyObject_RichCompare}{PyObject *o1, + PyObject *o2, int op} + Compare the values of \var{o1} and \var{o2} using the operation + specified by \var{op}, which must be one of + \constant{Py_LT}, + \constant{Py_LE}, + \constant{Py_EQ}, + \constant{Py_NE}, + \constant{Py_GT}, or + \constant{Py_GE}, corresponding to + \code{<}, + \code{<=}, + \code{==}, + \code{!=}, + \code{>}, or + \code{>=} respectively. This is the equivalent of the Python expression + \samp{\var{o1} \emph{op} \var{o2}}, where \emph{op} is the operator + corresponding to \var{op}. Returns the value of the comparison on + success, or \NULL{} on failure. + \end{cfuncdesc} + + \begin{cfuncdesc}{int}{PyObject_RichCompareBool}{PyObject *o1, + PyObject *o2, int op} + Compare the values of \var{o1} and \var{o2} using the operation + specified by \var{op}, which must be one of + \constant{Py_LT}, + \constant{Py_LE}, + \constant{Py_EQ}, + \constant{Py_NE}, + \constant{Py_GT}, or + \constant{Py_GE}, corresponding to + \code{<}, + \code{<=}, + \code{==}, + \code{!=}, + \code{>}, or + \code{>=} respectively. Returns \code{-1} on error, \code{0} if the + result is false, \code{1} otherwise. This is the equivalent of the + Python expression \samp{\var{o1} \emph{op} \var{o2}}, where + \emph{op} is the operator corresponding to \var{op}. + \end{cfuncdesc} + \begin{cfuncdesc}{int}{PyObject_Cmp}{PyObject *o1, PyObject *o2, int *result} Compare the values of \var{o1} and \var{o2} using a routine provided From gvanrossum@users.sourceforge.net Thu Jun 13 12:53:14 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 13 Jun 2002 04:53:14 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_gc.py,1.15,1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv19922 Modified Files: test_gc.py Log Message: Whitespace nit. Index: test_gc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_gc.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** test_gc.py 12 Jun 2002 14:38:04 -0000 1.15 --- test_gc.py 13 Jun 2002 11:53:12 -0000 1.16 *************** *** 229,233 **** enabled = gc.isenabled() gc.disable() ! verify(not gc.isenabled() ) debug = gc.get_debug() gc.set_debug(debug & ~gc.DEBUG_LEAK) # this test is supposed to leak --- 229,233 ---- enabled = gc.isenabled() gc.disable() ! verify(not gc.isenabled()) debug = gc.get_debug() gc.set_debug(debug & ~gc.DEBUG_LEAK) # this test is supposed to leak From aimacintyre@users.sourceforge.net Thu Jun 13 12:53:54 2002 From: aimacintyre@users.sourceforge.net (aimacintyre@users.sourceforge.net) Date: Thu, 13 Jun 2002 04:53:54 -0700 Subject: [Python-checkins] python/dist/src/Modules socketmodule.c,1.224,1.225 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv20032 Modified Files: socketmodule.c Log Message: work around name clash with OS/2 TCPIP routine sock_init() Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.224 retrieving revision 1.225 diff -C2 -d -r1.224 -r1.225 *** socketmodule.c 7 Jun 2002 19:55:29 -0000 1.224 --- socketmodule.c 13 Jun 2002 11:53:52 -0000 1.225 *************** *** 2058,2062 **** /*ARGSUSED*/ static int ! sock_init(PyObject *self, PyObject *args, PyObject *kwds) { PySocketSockObject *s = (PySocketSockObject *)self; --- 2058,2062 ---- /*ARGSUSED*/ static int ! sock_initobj(PyObject *self, PyObject *args, PyObject *kwds) { PySocketSockObject *s = (PySocketSockObject *)self; *************** *** 2134,2138 **** 0, /* tp_descr_set */ 0, /* tp_dictoffset */ ! sock_init, /* tp_init */ 0, /* set below */ /* tp_alloc */ sock_new, /* tp_new */ --- 2134,2138 ---- 0, /* tp_descr_set */ 0, /* tp_dictoffset */ ! sock_initobj, /* tp_init */ 0, /* set below */ /* tp_alloc */ sock_new, /* tp_new */ From fdrake@users.sourceforge.net Thu Jun 13 12:53:57 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu, 13 Jun 2002 04:53:57 -0700 Subject: [Python-checkins] python/dist/src/Doc/api api.tex,1.117.2.14,1.117.2.15 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory usw-pr-cvs1:/tmp/cvs-serv20057/api Modified Files: Tag: release21-maint api.tex Log Message: Add documentation for PyObject_RichCompare() and PyObject_RichCompareBool(), constributed by David Abrahams. This closes SF patch #568081. Index: api.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/api.tex,v retrieving revision 1.117.2.14 retrieving revision 1.117.2.15 diff -C2 -d -r1.117.2.14 -r1.117.2.15 *** api.tex 10 Apr 2002 18:16:32 -0000 1.117.2.14 --- api.tex 13 Jun 2002 11:53:54 -0000 1.117.2.15 *************** *** 1478,1481 **** --- 1478,1523 ---- + \begin{cfuncdesc}{PyObject*}{PyObject_RichCompare}{PyObject *o1, + PyObject *o2, int op} + Compare the values of \var{o1} and \var{o2} using the operation + specified by \var{op}, which must be one of + \constant{Py_LT}, + \constant{Py_LE}, + \constant{Py_EQ}, + \constant{Py_NE}, + \constant{Py_GT}, or + \constant{Py_GE}, corresponding to + \code{<}, + \code{<=}, + \code{==}, + \code{!=}, + \code{>}, or + \code{>=} respectively. This is the equivalent of the Python expression + \samp{\var{o1} \emph{op} \var{o2}}, where \emph{op} is the operator + corresponding to \var{op}. Returns the value of the comparison on + success, or \NULL{} on failure. + \end{cfuncdesc} + + \begin{cfuncdesc}{int}{PyObject_RichCompareBool}{PyObject *o1, + PyObject *o2, int op} + Compare the values of \var{o1} and \var{o2} using the operation + specified by \var{op}, which must be one of + \constant{Py_LT}, + \constant{Py_LE}, + \constant{Py_EQ}, + \constant{Py_NE}, + \constant{Py_GT}, or + \constant{Py_GE}, corresponding to + \code{<}, + \code{<=}, + \code{==}, + \code{!=}, + \code{>}, or + \code{>=} respectively. Returns \code{-1} on error, \code{0} if the + result is false, \code{1} otherwise. This is the equivalent of the + Python expression \samp{\var{o1} \emph{op} \var{o2}}, where + \emph{op} is the operator corresponding to \var{op}. + \end{cfuncdesc} + \begin{cfuncdesc}{int}{PyObject_Cmp}{PyObject *o1, PyObject *o2, int *result} Compare the values of \var{o1} and \var{o2} using a routine provided From aimacintyre@users.sourceforge.net Thu Jun 13 12:55:16 2002 From: aimacintyre@users.sourceforge.net (aimacintyre@users.sourceforge.net) Date: Thu, 13 Jun 2002 04:55:16 -0700 Subject: [Python-checkins] python/dist/src/Modules unicodedata.c,2.16,2.17 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv20429 Modified Files: unicodedata.c Log Message: _Py prefix is verboten for static entry points Index: unicodedata.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/unicodedata.c,v retrieving revision 2.16 retrieving revision 2.17 diff -C2 -d -r2.16 -r2.17 *** unicodedata.c 3 Apr 2002 21:39:26 -0000 2.16 --- unicodedata.c 13 Jun 2002 11:55:14 -0000 2.17 *************** *** 278,282 **** static int ! _Py_getname(Py_UCS4 code, char* buffer, int buflen) { int offset; --- 278,282 ---- static int ! _getucname(Py_UCS4 code, char* buffer, int buflen) { int offset; *************** *** 335,339 **** int i; char buffer[NAME_MAXLEN]; ! if (!_Py_getname(code, buffer, sizeof(buffer))) return 0; for (i = 0; i < namelen; i++) { --- 335,339 ---- int i; char buffer[NAME_MAXLEN]; ! if (!_getucname(code, buffer, sizeof(buffer))) return 0; for (i = 0; i < namelen; i++) { *************** *** 385,389 **** { sizeof(_PyUnicode_Name_CAPI), ! _Py_getname, _getcode }; --- 385,389 ---- { sizeof(_PyUnicode_Name_CAPI), ! _getucname, _getcode }; *************** *** 408,412 **** } ! if (!_Py_getname((Py_UCS4) *PyUnicode_AS_UNICODE(v), name, sizeof(name))) { if (defobj == NULL) { --- 408,412 ---- } ! if (!_getucname((Py_UCS4) *PyUnicode_AS_UNICODE(v), name, sizeof(name))) { if (defobj == NULL) { From mal@lemburg.com Thu Jun 13 13:15:36 2002 From: mal@lemburg.com (M.-A. Lemburg) Date: Thu, 13 Jun 2002 14:15:36 +0200 Subject: [Python-checkins] python/dist/src/Modules unicodedata.c,2.16,2.17 References: Message-ID: <3D088CE8.1060100@lemburg.com> aimacintyre@users.sourceforge.net wrote: > Update of /cvsroot/python/python/dist/src/Modules > In directory usw-pr-cvs1:/tmp/cvs-serv20429 > > Modified Files: > unicodedata.c > Log Message: > _Py prefix is verboten for static entry points That's fine, but please mangle the names in a different way then, since the _Py was added to avoid compiler problems on some platform (don't remember which) where e.g. getname() is a system API. Thanks. > Index: unicodedata.c > =================================================================== > RCS file: /cvsroot/python/python/dist/src/Modules/unicodedata.c,v > retrieving revision 2.16 > retrieving revision 2.17 > diff -C2 -d -r2.16 -r2.17 > *** unicodedata.c 3 Apr 2002 21:39:26 -0000 2.16 > --- unicodedata.c 13 Jun 2002 11:55:14 -0000 2.17 > *************** > *** 278,282 **** > > static int > ! _Py_getname(Py_UCS4 code, char* buffer, int buflen) > { > int offset; > --- 278,282 ---- > > static int > ! _getucname(Py_UCS4 code, char* buffer, int buflen) > { > int offset; > *************** > *** 335,339 **** > int i; > char buffer[NAME_MAXLEN]; > ! if (!_Py_getname(code, buffer, sizeof(buffer))) > return 0; > for (i = 0; i < namelen; i++) { > --- 335,339 ---- > int i; > char buffer[NAME_MAXLEN]; > ! if (!_getucname(code, buffer, sizeof(buffer))) > return 0; > for (i = 0; i < namelen; i++) { > *************** > *** 385,389 **** > { > sizeof(_PyUnicode_Name_CAPI), > ! _Py_getname, > _getcode > }; > --- 385,389 ---- > { > sizeof(_PyUnicode_Name_CAPI), > ! _getucname, > _getcode > }; > *************** > *** 408,412 **** > } > > ! if (!_Py_getname((Py_UCS4) *PyUnicode_AS_UNICODE(v), > name, sizeof(name))) { > if (defobj == NULL) { > --- 408,412 ---- > } > > ! if (!_getucname((Py_UCS4) *PyUnicode_AS_UNICODE(v), > name, sizeof(name))) { > if (defobj == NULL) { > > > > > _______________________________________________ > Python-checkins mailing list > Python-checkins@python.org > http://mail.python.org/mailman/listinfo/python-checkins -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.egenix.com/files/python/ Meet us at EuroPython 2002: http://www.europython.org/ From guido@python.org Thu Jun 13 13:23:34 2002 From: guido@python.org (Guido van Rossum) Date: Thu, 13 Jun 2002 08:23:34 -0400 Subject: [Python-checkins] python/dist/src/Modules unicodedata.c,2.16,2.17 In-Reply-To: Your message of "Thu, 13 Jun 2002 14:15:36 +0200." <3D088CE8.1060100@lemburg.com> References: <3D088CE8.1060100@lemburg.com> Message-ID: <200206131223.g5DCNYc12507@pcp02138704pcs.reston01.va.comcast.net> > > Modified Files: > > unicodedata.c > > Log Message: > > _Py prefix is verboten for static entry points > > That's fine, but please mangle the names in a different way then, > since the _Py was added to avoid compiler problems on some > platform (don't remember which) where e.g. getname() is a system > API. Look carefully -- he called it _getucname. (Generally I don't think static function names should with an underscore though.) --Guido van Rossum (home page: http://www.python.org/~guido/) From mal@lemburg.com Thu Jun 13 13:25:06 2002 From: mal@lemburg.com (M.-A. Lemburg) Date: Thu, 13 Jun 2002 14:25:06 +0200 Subject: [Python-checkins] python/dist/src/Modules unicodedata.c,2.16,2.17 References: <3D088CE8.1060100@lemburg.com> <200206131223.g5DCNYc12507@pcp02138704pcs.reston01.va.comcast.net> Message-ID: <3D088F22.50703@lemburg.com> Guido van Rossum wrote: >>>Modified Files: >>> unicodedata.c >>>Log Message: >>>_Py prefix is verboten for static entry points >> >>That's fine, but please mangle the names in a different way then, >>since the _Py was added to avoid compiler problems on some >>platform (don't remember which) where e.g. getname() is a system >>API. > > > Look carefully -- he called it _getucname. (Generally I don't think > static function names should with an underscore though.) Even worse... that's not even allowed by ISO/ANSI C ;-) Seriously, I don't care what you name them, as long as they don't stir up compiler noises. How about using "unicode_" as prefix ? -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.egenix.com/files/python/ Meet us at EuroPython 2002: http://www.europython.org/ From gvanrossum@users.sourceforge.net Thu Jun 13 15:41:38 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 13 Jun 2002 07:41:38 -0700 Subject: [Python-checkins] python/dist/src setup.py,1.89,1.90 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv12365 Modified Files: setup.py Log Message: Add dependencies on socketmodule.h. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.89 retrieving revision 1.90 diff -C2 -d -r1.89 -r1.90 *** setup.py 11 Jun 2002 06:22:30 -0000 1.89 --- setup.py 13 Jun 2002 14:41:32 -0000 1.90 *************** *** 272,275 **** --- 272,277 ---- exts.append( Extension('xreadlines', ['xreadlinesmodule.c']) ) + exts.append( Extension("bits", ["bits.c"]) ) + # array objects exts.append( Extension('array', ['arraymodule.c']) ) *************** *** 386,390 **** # socket(2) ! exts.append( Extension('_socket', ['socketmodule.c']) ) # Detect SSL support for the socket module (via _ssl) ssl_incs = find_file('openssl/ssl.h', inc_dirs, --- 388,393 ---- # socket(2) ! exts.append( Extension('_socket', ['socketmodule.c'], ! depends = ['Modules/socketmodule.h']) ) # Detect SSL support for the socket module (via _ssl) ssl_incs = find_file('openssl/ssl.h', inc_dirs, *************** *** 403,407 **** include_dirs = ssl_incs, library_dirs = ssl_libs, ! libraries = ['ssl', 'crypto']) ) # Modules that provide persistent dictionary-like semantics. You will --- 406,411 ---- include_dirs = ssl_incs, library_dirs = ssl_libs, ! libraries = ['ssl', 'crypto'], ! depends = ['Modules/socketmodule.h']), ) # Modules that provide persistent dictionary-like semantics. You will From jhylton@users.sourceforge.net Thu Jun 13 15:58:34 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Thu, 13 Jun 2002 07:58:34 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils unixccompiler.py,1.41,1.42 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv18219 Modified Files: unixccompiler.py Log Message: Python style conformance: Delete spaces between name of function and arglist. Making the world better a little bit at a time . Index: unixccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/unixccompiler.py,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** unixccompiler.py 4 Jun 2002 20:18:24 -0000 1.41 --- unixccompiler.py 13 Jun 2002 14:58:30 -0000 1.42 *************** *** 82,99 **** ! def __init__ (self, ! verbose=0, ! dry_run=0, ! force=0): CCompiler.__init__ (self, verbose, dry_run, force) ! def preprocess (self, ! source, ! output_file=None, ! macros=None, ! include_dirs=None, ! extra_preargs=None, ! extra_postargs=None): (_, macros, include_dirs) = \ --- 82,99 ---- ! def __init__(self, ! verbose=0, ! dry_run=0, ! force=0): CCompiler.__init__ (self, verbose, dry_run, force) ! def preprocess(self, ! source, ! output_file=None, ! macros=None, ! include_dirs=None, ! extra_preargs=None, ! extra_postargs=None): (_, macros, include_dirs) = \ *************** *** 121,132 **** ! def compile (self, ! sources, ! output_dir=None, ! macros=None, ! include_dirs=None, ! debug=0, ! extra_preargs=None, ! extra_postargs=None): (output_dir, macros, include_dirs) = \ --- 121,132 ---- ! def compile(self, ! sources, ! output_dir=None, ! macros=None, ! include_dirs=None, ! debug=0, ! extra_preargs=None, ! extra_postargs=None): (output_dir, macros, include_dirs) = \ *************** *** 165,173 **** ! def create_static_lib (self, ! objects, ! output_libname, ! output_dir=None, ! debug=0): (objects, output_dir) = self._fix_object_args(objects, output_dir) --- 165,173 ---- ! def create_static_lib(self, ! objects, ! output_libname, ! output_dir=None, ! debug=0): (objects, output_dir) = self._fix_object_args(objects, output_dir) *************** *** 198,214 **** ! def link (self, ! target_desc, ! objects, ! output_filename, ! output_dir=None, ! libraries=None, ! library_dirs=None, ! runtime_library_dirs=None, ! export_symbols=None, ! debug=0, ! extra_preargs=None, ! extra_postargs=None, ! build_temp=None): (objects, output_dir) = self._fix_object_args(objects, output_dir) --- 198,214 ---- ! def link(self, ! target_desc, ! objects, ! output_filename, ! output_dir=None, ! libraries=None, ! library_dirs=None, ! runtime_library_dirs=None, ! export_symbols=None, ! debug=0, ! extra_preargs=None, ! extra_postargs=None, ! build_temp=None): (objects, output_dir) = self._fix_object_args(objects, output_dir) *************** *** 251,258 **** # ccompiler.py. ! def library_dir_option (self, dir): return "-L" + dir ! def runtime_library_dir_option (self, dir): # XXX Hackish, at the very least. See Python bug #445902: # http://sourceforge.net/tracker/index.php --- 251,258 ---- # ccompiler.py. ! def library_dir_option(self, dir): return "-L" + dir ! def runtime_library_dir_option(self, dir): # XXX Hackish, at the very least. See Python bug #445902: # http://sourceforge.net/tracker/index.php *************** *** 273,281 **** return "-R" + dir ! def library_option (self, lib): return "-l" + lib ! def find_library_file (self, dirs, lib, debug=0): for dir in dirs: --- 273,281 ---- return "-R" + dir ! def library_option(self, lib): return "-l" + lib ! def find_library_file(self, dirs, lib, debug=0): for dir in dirs: From jhylton@users.sourceforge.net Thu Jun 13 16:01:41 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Thu, 13 Jun 2002 08:01:41 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils unixccompiler.py,1.42,1.43 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv19787 Modified Files: unixccompiler.py Log Message: Some more style improvements Index: unixccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/unixccompiler.py,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** unixccompiler.py 13 Jun 2002 14:58:30 -0000 1.42 --- unixccompiler.py 13 Jun 2002 15:01:38 -0000 1.43 *************** *** 19,24 **** import os, sys ! from types import * from copy import copy from distutils import sysconfig from distutils.dep_util import newer --- 19,25 ---- import os, sys ! from types import StringType, NoneType from copy import copy + from distutils import sysconfig from distutils.dep_util import newer *************** *** 44,49 **** # options and carry on. ! ! class UnixCCompiler (CCompiler): compiler_type = 'unix' --- 45,49 ---- # options and carry on. ! class UnixCCompiler(CCompiler): compiler_type = 'unix' *************** *** 86,91 **** dry_run=0, force=0): ! CCompiler.__init__ (self, verbose, dry_run, force) ! def preprocess(self, --- 86,90 ---- dry_run=0, force=0): ! CCompiler.__init__(self, verbose, dry_run, force) def preprocess(self, *************** *** 96,100 **** extra_preargs=None, extra_postargs=None): - (_, macros, include_dirs) = \ self._fix_compile_args(None, macros, include_dirs) --- 95,98 ---- *************** *** 120,124 **** raise CompileError, msg - def compile(self, sources, --- 118,121 ---- *************** *** 129,133 **** extra_preargs=None, extra_postargs=None): - (output_dir, macros, include_dirs) = \ self._fix_compile_args(output_dir, macros, include_dirs) --- 126,129 ---- *************** *** 162,168 **** return objects - # compile () - - def create_static_lib(self, objects, --- 158,161 ---- *************** *** 170,174 **** output_dir=None, debug=0): - (objects, output_dir) = self._fix_object_args(objects, output_dir) --- 163,166 ---- *************** *** 195,201 **** log.debug("skipping %s (up-to-date)", output_filename) - # create_static_lib () - - def link(self, target_desc, --- 187,190 ---- *************** *** 211,215 **** extra_postargs=None, build_temp=None): - (objects, output_dir) = self._fix_object_args(objects, output_dir) (libraries, library_dirs, runtime_library_dirs) = \ --- 200,203 ---- *************** *** 244,250 **** log.debug("skipping %s (up-to-date)", output_filename) - # link () - - # -- Miscellaneous methods ----------------------------------------- # These are all used by the 'gen_lib_options() function, in --- 232,235 ---- *************** *** 276,282 **** return "-l" + lib - def find_library_file(self, dirs, lib, debug=0): - for dir in dirs: shared = os.path.join( --- 261,265 ---- *************** *** 301,306 **** # Oops, didn't find it in *any* of 'dirs' return None - - # find_library_file () - - # class UnixCCompiler --- 284,285 ---- From gvanrossum@users.sourceforge.net Thu Jun 13 16:03:05 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 13 Jun 2002 08:03:05 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_socket.py,1.32,1.33 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv19912/Lib/test Modified Files: test_socket.py Log Message: Fix a typo. Add a sleep (yuck!) to _testRecvFrom() so the server can set up first. Index: test_socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** test_socket.py 12 Jun 2002 21:29:43 -0000 1.32 --- test_socket.py 13 Jun 2002 15:03:01 -0000 1.33 *************** *** 360,364 **** def testRecvFrom(self): ! """Testing recfrom() over UDP.""" msg, addr = self.serv.recvfrom(len(MSG)) hostname, port = addr --- 360,364 ---- def testRecvFrom(self): ! """Testing recvfrom() over UDP.""" msg, addr = self.serv.recvfrom(len(MSG)) hostname, port = addr *************** *** 367,370 **** --- 367,371 ---- def _testRecvFrom(self): + time.sleep(1) # Give server a chance to set up self.cli.sendto(MSG, 0, (HOST, PORT)) From gvanrossum@users.sourceforge.net Thu Jun 13 16:07:45 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 13 Jun 2002 08:07:45 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libsocket.tex,1.67,1.68 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv22620/Doc/lib Modified Files: libsocket.tex Log Message: Major overhaul of timeout sockets: - setblocking(0) and settimeout(0) are now equivalent, and ditto for setblocking(1) and settimeout(None). - Don't raise an exception from internal_select(); let the final call report the error (this means you will get an EAGAIN error instead of an ETIMEDOUT error -- I don't care). - Move the select to inside the Py_{BEGIN,END}_ALLOW_THREADS brackets, so other theads can run (this was a bug in the original code). - Redid the retry logic in connect() and connect_ex() to avoid masking errors. This probably doesn't work for Windows yet; I'll fix that next. It may also fail on other platforms, depending on what retrying a connect does; I need help with this. - Get rid of the retry logic in accept(). I don't think it was needed at all. But I may be wrong. Index: libsocket.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsocket.tex,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** libsocket.tex 7 Jun 2002 12:38:23 -0000 1.67 --- libsocket.tex 13 Jun 2002 15:07:43 -0000 1.68 *************** *** 73,78 **** \exception{socket.error}. ! Non-blocking mode is supported through the ! \method{setblocking()} method. The module \module{socket} exports the following constants and functions: --- 73,79 ---- \exception{socket.error}. ! Non-blocking mode is supported through ! \method{setblocking()}. A generalization of this based on timeouts ! is supported through \method{settimeout()}. The module \module{socket} exports the following constants and functions: *************** *** 285,290 **** used to get or set socket options on a socket passed to a program as standard input or output (such as a server started by the \UNIX{} inet ! daemon). The socket is assumed to be in blocking mode without ! a timeout. Availability: \UNIX. \end{funcdesc} --- 286,290 ---- used to get or set socket options on a socket passed to a program as standard input or output (such as a server started by the \UNIX{} inet ! daemon). The socket is assumed to be in blocking mode. Availability: \UNIX. \end{funcdesc} *************** *** 515,527 **** \exception{error} exception is raised; in blocking mode, the calls block until they can proceed. \end{methoddesc} \begin{methoddesc}[socket]{settimeout}{value} ! Set a timeout on blocking socket operations. Value can be a ! nonnegative float expressing seconds, or \code{None}. If a float is given, subsequent socket operations will raise an \exception{error} exception if the timeout period \var{value} has elapsed before the operation has completed. Setting a timeout of \code{None} disables timeouts on socket operations. \versionadded{2.3} \end{methoddesc} --- 515,532 ---- \exception{error} exception is raised; in blocking mode, the calls block until they can proceed. + \code{s.setblocking(0)} is equivalent to \code{s.settimeout(0)}; + \code{s.setblocking(1)} is equivalent to \code{s.settimeout(None)}. \end{methoddesc} \begin{methoddesc}[socket]{settimeout}{value} ! Set a timeout on blocking socket operations. The \var{value} argument ! can be a nonnegative float expressing seconds, or \code{None}. ! If a float is given, subsequent socket operations will raise an \exception{error} exception if the timeout period \var{value} has elapsed before the operation has completed. Setting a timeout of \code{None} disables timeouts on socket operations. + \code{s.settimeout(0.0)} is equivalent to \code{s.blocking(0)}; + \code{s.settimeout(None)} is equivalent to \code{s.setblocking(1)}. \versionadded{2.3} \end{methoddesc} *************** *** 529,550 **** \begin{methoddesc}[socket]{gettimeout}{} Returns the timeout in floating seconds associated with socket ! operations, or \code{None} if no timeout is set. \versionadded{2.3} \end{methoddesc} ! Some notes on the interaction between socket blocking and timeouts: A ! socket object can be in one of three modes: blocking, non-blocking, or ! timout. Sockets are always created in blocking mode. In blocking ! mode, operations block until complete. In non-blocking mode, ! operations fail (with an error that is unfortunately system-dependent) ! if they cannot be completed immediately. In timeout mode, operations ! fail if they cannot be completed within the timeout specified for the ! socket. ! ! Calling \method{settimeout()} cancels non-blocking mode as set by ! \method{setblocking()}; calling \method{setblocking()} cancels a ! previously set timeout. Setting the timeout to zero acts similarly ! but is implemented different than setting the socket in non-blocking ! mode (this could be considered a bug and may even be fixed). Timeout mode internally sets the socket in non-blocking mode. The --- 534,551 ---- \begin{methoddesc}[socket]{gettimeout}{} Returns the timeout in floating seconds associated with socket ! operations, or \code{None} if no timeout is set. This reflects ! the last call to \method{setblocking()} or \method{settimeout()}. \versionadded{2.3} \end{methoddesc} ! Some notes on socket blocking and timeouts: A socket object can be in ! one of three modes: blocking, non-blocking, or timout. Sockets are ! always created in blocking mode. In blocking mode, operations block ! until complete. In non-blocking mode, operations fail (with an error ! that is unfortunately system-dependent) if they cannot be completed ! immediately. In timeout mode, operations fail if they cannot be ! completed within the timeout specified for the socket. The ! \method{setblocking()} method is simply a shorthand for certain ! \method{settimeout()} calls. Timeout mode internally sets the socket in non-blocking mode. The From gvanrossum@users.sourceforge.net Thu Jun 13 16:07:46 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 13 Jun 2002 08:07:46 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_socket.py,1.33,1.34 test_timeout.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv22620/Lib/test Modified Files: test_socket.py test_timeout.py Log Message: Major overhaul of timeout sockets: - setblocking(0) and settimeout(0) are now equivalent, and ditto for setblocking(1) and settimeout(None). - Don't raise an exception from internal_select(); let the final call report the error (this means you will get an EAGAIN error instead of an ETIMEDOUT error -- I don't care). - Move the select to inside the Py_{BEGIN,END}_ALLOW_THREADS brackets, so other theads can run (this was a bug in the original code). - Redid the retry logic in connect() and connect_ex() to avoid masking errors. This probably doesn't work for Windows yet; I'll fix that next. It may also fail on other platforms, depending on what retrying a connect does; I need help with this. - Get rid of the retry logic in accept(). I don't think it was needed at all. But I may be wrong. Index: test_socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** test_socket.py 13 Jun 2002 15:03:01 -0000 1.33 --- test_socket.py 13 Jun 2002 15:07:43 -0000 1.34 *************** *** 52,56 **** # Do some munging to start the client test. ! test_method = getattr(self, '_' + self._TestCase__testMethodName) self.client_thread = thread.start_new_thread( self.clientRun, (test_method,)) --- 52,59 ---- # Do some munging to start the client test. ! methodname = self.id() ! i = methodname.rfind('.') ! methodname = methodname[i+1:] ! test_method = getattr(self, '_' + methodname) self.client_thread = thread.start_new_thread( self.clientRun, (test_method,)) Index: test_timeout.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_timeout.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_timeout.py 12 Jun 2002 20:22:49 -0000 1.4 --- test_timeout.py 13 Jun 2002 15:07:44 -0000 1.5 *************** *** 60,64 **** self.assertRaises(ValueError, self.sock.settimeout, -1.0) ! def testTimeoutThenoBlocking(self): "Test settimeout() followed by setblocking()" self.sock.settimeout(10) --- 60,64 ---- self.assertRaises(ValueError, self.sock.settimeout, -1.0) ! def testTimeoutThenBlocking(self): "Test settimeout() followed by setblocking()" self.sock.settimeout(10) *************** *** 66,74 **** self.assertEqual(self.sock.gettimeout(), None) self.sock.setblocking(0) ! self.assertEqual(self.sock.gettimeout(), None) self.sock.settimeout(10) self.sock.setblocking(0) ! self.assertEqual(self.sock.gettimeout(), None) self.sock.setblocking(1) self.assertEqual(self.sock.gettimeout(), None) --- 66,74 ---- self.assertEqual(self.sock.gettimeout(), None) self.sock.setblocking(0) ! self.assertEqual(self.sock.gettimeout(), 0.0) self.sock.settimeout(10) self.sock.setblocking(0) ! self.assertEqual(self.sock.gettimeout(), 0.0) self.sock.setblocking(1) self.assertEqual(self.sock.gettimeout(), None) From gvanrossum@users.sourceforge.net Thu Jun 13 16:07:46 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 13 Jun 2002 08:07:46 -0700 Subject: [Python-checkins] python/dist/src/Modules socketmodule.c,1.225,1.226 socketmodule.h,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv22620/Modules Modified Files: socketmodule.c socketmodule.h Log Message: Major overhaul of timeout sockets: - setblocking(0) and settimeout(0) are now equivalent, and ditto for setblocking(1) and settimeout(None). - Don't raise an exception from internal_select(); let the final call report the error (this means you will get an EAGAIN error instead of an ETIMEDOUT error -- I don't care). - Move the select to inside the Py_{BEGIN,END}_ALLOW_THREADS brackets, so other theads can run (this was a bug in the original code). - Redid the retry logic in connect() and connect_ex() to avoid masking errors. This probably doesn't work for Windows yet; I'll fix that next. It may also fail on other platforms, depending on what retrying a connect does; I need help with this. - Get rid of the retry logic in accept(). I don't think it was needed at all. But I may be wrong. Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.225 retrieving revision 1.226 diff -C2 -d -r1.225 -r1.226 *** socketmodule.c 13 Jun 2002 11:53:52 -0000 1.225 --- socketmodule.c 13 Jun 2002 15:07:44 -0000 1.226 *************** *** 447,470 **** } - /* For timeout errors */ - static PyObject * - timeout_err(void) - { - PyObject *v; - - #ifdef MS_WINDOWS - v = Py_BuildValue("(is)", WSAETIMEDOUT, "Socket operation timed out"); - #else - v = Py_BuildValue("(is)", ETIMEDOUT, "Socket operation timed out"); - #endif - - if (v != NULL) { - PyErr_SetObject(socket_error, v); - Py_DECREF(v); - } - - return NULL; - } - /* Function to perform the setting of socket blocking mode internally. block = (1 | 0). */ --- 447,450 ---- *************** *** 509,522 **** } ! /* For access to the select module to poll the socket for timeout ! functionality. writing is 1 for writing, 0 for reading. ! Return value: -1 if error, 0 if not ready, >= 1 if ready. ! An exception is set when the return value is <= 0 (!). */ ! static int internal_select(PySocketSockObject *s, int writing) { fd_set fds; struct timeval tv; ! int count; /* Construct the arguments to select */ --- 489,504 ---- } ! /* Do a select() on the socket, if necessary (sock_timeout > 0). ! The argument writing indicates the direction. ! This does not raise an exception or return a success indicator; ! we'll let the actual socket call do that. */ ! static void internal_select(PySocketSockObject *s, int writing) { fd_set fds; struct timeval tv; ! ! if (s->sock_timeout <= 0.0) ! return; /* Construct the arguments to select */ *************** *** 528,547 **** /* See if the socket is ready */ if (writing) ! count = select(s->sock_fd+1, NULL, &fds, NULL, &tv); else ! count = select(s->sock_fd+1, &fds, NULL, NULL, &tv); ! ! /* Check for errors */ ! if (count < 0) { ! s->errorhandler(); ! return -1; ! } ! ! /* Set the error if the timeout has elapsed, i.e, we were not ! polled. */ ! if (count == 0) ! timeout_err(); ! ! return count; } --- 510,516 ---- /* See if the socket is ready */ if (writing) ! select(s->sock_fd+1, NULL, &fds, NULL, &tv); else ! select(s->sock_fd+1, &fds, NULL, NULL, &tv); } *************** *** 559,563 **** s->sock_type = type; s->sock_proto = proto; - s->sock_blocking = 1; /* Start in blocking mode */ s->sock_timeout = -1.0; /* Start without timeout */ --- 528,531 ---- *************** *** 998,1040 **** memset(addrbuf, 0, addrlen); - errno = 0; /* Reset indicator for use with timeout behavior */ - Py_BEGIN_ALLOW_THREADS newfd = accept(s->sock_fd, (struct sockaddr *) addrbuf, &addrlen); Py_END_ALLOW_THREADS - if (s->sock_timeout >= 0.0) { - #ifdef MS_WINDOWS - if (newfd == INVALID_SOCKET) - if (!s->sock_blocking) - return s->errorhandler(); - /* Check if we have a true failure - for a blocking socket */ - if (errno != WSAEWOULDBLOCK) - return s->errorhandler(); - #else - if (newfd < 0) { - if (!s->sock_blocking) - return s->errorhandler(); - /* Check if we have a true failure - for a blocking socket */ - if (errno != EAGAIN && errno != EWOULDBLOCK) - return s->errorhandler(); - } - #endif - - /* try waiting the timeout period */ - if (internal_select(s, 0) <= 0) - return NULL; - - Py_BEGIN_ALLOW_THREADS - newfd = accept(s->sock_fd, - (struct sockaddr *)addrbuf, - &addrlen); - Py_END_ALLOW_THREADS - } - - /* At this point, we really have an error, whether using timeout - behavior or regular socket behavior */ #ifdef MS_WINDOWS if (newfd == INVALID_SOCKET) --- 966,974 ---- memset(addrbuf, 0, addrlen); Py_BEGIN_ALLOW_THREADS + internal_select(s, 0); newfd = accept(s->sock_fd, (struct sockaddr *) addrbuf, &addrlen); Py_END_ALLOW_THREADS #ifdef MS_WINDOWS if (newfd == INVALID_SOCKET) *************** *** 1075,1079 **** info is a pair (hostaddr, port)."; ! /* s.setblocking(1 | 0) method */ static PyObject * --- 1009,1016 ---- info is a pair (hostaddr, port)."; ! /* s.setblocking(flag) method. Argument: ! False -- non-blocking mode; same as settimeout(0) ! True -- blocking mode; same as settimeout(None) ! */ static PyObject * *************** *** 1086,1091 **** return NULL; ! s->sock_blocking = block; ! s->sock_timeout = -1.0; /* Always clear the timeout */ internal_setblocking(s, block); --- 1023,1027 ---- return NULL; ! s->sock_timeout = block ? -1.0 : 0.0; internal_setblocking(s, block); *************** *** 1098,1139 **** \n\ Set the socket to blocking (flag is true) or non-blocking (false).\n\ ! This uses the FIONBIO ioctl with the O_NDELAY flag."; ! /* s.settimeout(None | float) method. ! Causes an exception to be raised when the given time has ! elapsed when performing a blocking socket operation. */ static PyObject * sock_settimeout(PySocketSockObject *s, PyObject *arg) { ! double value; if (arg == Py_None) ! value = -1.0; else { ! value = PyFloat_AsDouble(arg); ! if (value < 0.0) { if (!PyErr_Occurred()) PyErr_SetString(PyExc_ValueError, ! "Invalid timeout value"); return NULL; } } ! s->sock_timeout = value; ! ! /* The semantics of setting socket timeouts are: ! If you settimeout(!=None): ! The actual socket gets put in non-blocking mode and the select ! is used to control timeouts. ! Else if you settimeout(None) [then value is -1.0]: ! The old behavior is used AND automatically, the socket is set ! to blocking mode. That means that someone who was doing ! non-blocking stuff before, sets a timeout, and then unsets ! one, will have to call setblocking(0) again if he wants ! non-blocking stuff. This makes sense because timeout stuff is ! blocking by nature. */ ! internal_setblocking(s, value < 0.0); ! ! s->sock_blocking = 1; /* Always negate setblocking() */ Py_INCREF(Py_None); --- 1034,1065 ---- \n\ Set the socket to blocking (flag is true) or non-blocking (false).\n\ ! setblocking(True) is equivalent to settimeout(None);\n\ ! setblocking(False) is equivalent to settimeout(0.0)."; ! /* s.settimeout(timeout) method. Argument: ! None -- no timeout, blocking mode; same as setblocking(True) ! 0.0 -- non-blocking mode; same as setblocking(False) ! > 0 -- timeout mode; operations time out after timeout seconds ! < 0 -- illegal; raises an exception ! */ static PyObject * sock_settimeout(PySocketSockObject *s, PyObject *arg) { ! double timeout; if (arg == Py_None) ! timeout = -1.0; else { ! timeout = PyFloat_AsDouble(arg); ! if (timeout < 0.0) { if (!PyErr_Occurred()) PyErr_SetString(PyExc_ValueError, ! "Timeout value out of range"); return NULL; } } ! s->sock_timeout = timeout; ! internal_setblocking(s, timeout < 0.0); Py_INCREF(Py_None); *************** *** 1144,1149 **** "settimeout(timeout)\n\ \n\ ! Set a timeout on blocking socket operations. 'timeout' can be a float,\n\ ! giving seconds, or None. Setting a timeout of None disables timeout."; /* s.gettimeout() method. --- 1070,1077 ---- "settimeout(timeout)\n\ \n\ ! Set a timeout on socket operations. 'timeout' can be a float,\n\ ! giving in seconds, or None. Setting a timeout of None disables\n\ ! the timeout feature and is equivalent to setblocking(1).\n\ ! Setting a timeout of zero is the same as setblocking(0)."; /* s.gettimeout() method. *************** *** 1356,1403 **** return NULL; - errno = 0; /* Reset the err indicator for use with timeouts */ - Py_BEGIN_ALLOW_THREADS ! res = connect(s->sock_fd, addr, addrlen); ! Py_END_ALLOW_THREADS ! ! if (s->sock_timeout >= 0.0) { ! if (res < 0) { ! /* Return if we're already connected */ ! #ifdef MS_WINDOWS ! if (errno == WSAEINVAL || errno == WSAEISCONN) ! #else ! if (errno == EISCONN) ! #endif ! goto connected; ! ! /* Check if we have an error */ ! if (!s->sock_blocking) ! return s->errorhandler(); ! /* Check if we have a true failure ! for a blocking socket */ ! #ifdef MS_WINDOWS ! if (errno != WSAEWOULDBLOCK) ! #else ! if (errno != EINPROGRESS && errno != EALREADY && ! errno != EWOULDBLOCK) ! #endif ! return s->errorhandler(); ! } ! ! /* Check if we're ready for the connect via select */ ! if (internal_select(s, 1) <= 0) ! return NULL; ! ! /* Complete the connection now */ ! Py_BEGIN_ALLOW_THREADS res = connect(s->sock_fd, addr, addrlen); ! Py_END_ALLOW_THREADS } if (res < 0) return s->errorhandler(); - - connected: Py_INCREF(Py_None); return Py_None; --- 1284,1301 ---- return NULL; Py_BEGIN_ALLOW_THREADS ! if (s->sock_timeout > 0.0) { res = connect(s->sock_fd, addr, addrlen); ! if (res == EINPROGRESS) { ! internal_select(s, 1); ! res = connect(s->sock_fd, addr, addrlen); ! } } + else + res = connect(s->sock_fd, addr, addrlen); + Py_END_ALLOW_THREADS if (res < 0) return s->errorhandler(); Py_INCREF(Py_None); return Py_None; *************** *** 1423,1467 **** return NULL; - errno = 0; /* Reset the err indicator for use with timeouts */ - Py_BEGIN_ALLOW_THREADS ! res = connect(s->sock_fd, addr, addrlen); ! Py_END_ALLOW_THREADS ! ! if (s->sock_timeout >= 0.0) { ! if (res < 0) { ! /* Return if we're already connected */ ! #ifdef MS_WINDOWS ! if (errno == WSAEINVAL || errno == WSAEISCONN) ! #else ! if (errno == EISCONN) ! #endif ! goto conex_finally; ! ! /* Check if we have an error */ ! if (!s->sock_blocking) ! goto conex_finally; ! /* Check if we have a true failure ! for a blocking socket */ ! #ifdef MS_WINDOWS ! if (errno != WSAEWOULDBLOCK) ! #else ! if (errno != EINPROGRESS && errno != EALREADY && ! errno != EWOULDBLOCK) ! #endif ! goto conex_finally; ! } ! ! /* Check if we're ready for the connect via select */ ! if (internal_select(s, 1) <= 0) ! return NULL; ! ! /* Complete the connection now */ ! Py_BEGIN_ALLOW_THREADS res = connect(s->sock_fd, addr, addrlen); ! Py_END_ALLOW_THREADS } - conex_finally: if (res != 0) { #ifdef MS_WINDOWS --- 1321,1336 ---- return NULL; Py_BEGIN_ALLOW_THREADS ! if (s->sock_timeout > 0.0) { res = connect(s->sock_fd, addr, addrlen); ! if (res == EINPROGRESS) { ! internal_select(s, 1); ! res = connect(s->sock_fd, addr, addrlen); ! } } + else + res = connect(s->sock_fd, addr, addrlen); + Py_END_ALLOW_THREADS if (res != 0) { #ifdef MS_WINDOWS *************** *** 1684,1688 **** if (len < 0) { PyErr_SetString(PyExc_ValueError, ! "negative buffersize in connect"); return NULL; } --- 1553,1557 ---- if (len < 0) { PyErr_SetString(PyExc_ValueError, ! "negative buffersize in recv"); return NULL; } *************** *** 1692,1703 **** return NULL; - if (s->sock_timeout >= 0.0) { - if (s->sock_blocking) { - if (internal_select(s, 0) <= 0) - return NULL; - } - } - Py_BEGIN_ALLOW_THREADS n = recv(s->sock_fd, PyString_AS_STRING(buf), len, flags); Py_END_ALLOW_THREADS --- 1561,1566 ---- return NULL; Py_BEGIN_ALLOW_THREADS + internal_select(s, 0); n = recv(s->sock_fd, PyString_AS_STRING(buf), len, flags); Py_END_ALLOW_THREADS *************** *** 1742,1754 **** return NULL; - if (s->sock_timeout >= 0.0) { - if (s->sock_blocking) { - if (internal_select(s, 0) <= 0) - return NULL; - } - } - Py_BEGIN_ALLOW_THREADS memset(addrbuf, 0, addrlen); n = recvfrom(s->sock_fd, PyString_AS_STRING(buf), len, flags, #ifndef MS_WINDOWS --- 1605,1611 ---- return NULL; Py_BEGIN_ALLOW_THREADS memset(addrbuf, 0, addrlen); + internal_select(s, 0); n = recvfrom(s->sock_fd, PyString_AS_STRING(buf), len, flags, #ifndef MS_WINDOWS *************** *** 1800,1811 **** return NULL; - if (s->sock_timeout >= 0.0) { - if (s->sock_blocking) { - if (internal_select(s, 1) <= 0) - return NULL; - } - } - Py_BEGIN_ALLOW_THREADS n = send(s->sock_fd, buf, len, flags); Py_END_ALLOW_THREADS --- 1657,1662 ---- return NULL; Py_BEGIN_ALLOW_THREADS + internal_select(s, 1); n = send(s->sock_fd, buf, len, flags); Py_END_ALLOW_THREADS *************** *** 1835,1846 **** return NULL; - if (s->sock_timeout >= 0.0) { - if (s->sock_blocking) { - if (internal_select(s, 1) <= 0) - return NULL; - } - } - Py_BEGIN_ALLOW_THREADS do { n = send(s->sock_fd, buf, len, flags); --- 1686,1691 ---- return NULL; Py_BEGIN_ALLOW_THREADS + internal_select(s, 1); do { n = send(s->sock_fd, buf, len, flags); *************** *** 1889,1900 **** return NULL; - if (s->sock_timeout >= 0.0) { - if (s->sock_blocking) { - if (internal_select(s, 1) <= 0) - return NULL; - } - } - Py_BEGIN_ALLOW_THREADS n = sendto(s->sock_fd, buf, len, flags, addr, addrlen); Py_END_ALLOW_THREADS --- 1734,1739 ---- return NULL; Py_BEGIN_ALLOW_THREADS + internal_select(s, 1); n = sendto(s->sock_fd, buf, len, flags, addr, addrlen); Py_END_ALLOW_THREADS Index: socketmodule.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** socketmodule.h 7 Jun 2002 02:27:50 -0000 1.7 --- socketmodule.h 13 Jun 2002 15:07:44 -0000 1.8 *************** *** 84,90 **** errno, returns NULL and sets a Python exception */ ! int sock_blocking; /* Flag indicated whether the ! socket is in blocking mode */ ! double sock_timeout; /* Operation timeout value */ } PySocketSockObject; --- 84,89 ---- errno, returns NULL and sets a Python exception */ ! double sock_timeout; /* Operation timeout in seconds; ! 0.0 means non-blocking */ } PySocketSockObject; From gvanrossum@users.sourceforge.net Thu Jun 13 16:08:39 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 13 Jun 2002 08:08:39 -0700 Subject: [Python-checkins] python/dist/src setup.py,1.90,1.91 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv23031 Modified Files: setup.py Log Message: Get rid of accidentally checked-in reference to "bits". Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.90 retrieving revision 1.91 diff -C2 -d -r1.90 -r1.91 *** setup.py 13 Jun 2002 14:41:32 -0000 1.90 --- setup.py 13 Jun 2002 15:08:35 -0000 1.91 *************** *** 272,277 **** exts.append( Extension('xreadlines', ['xreadlinesmodule.c']) ) - exts.append( Extension("bits", ["bits.c"]) ) - # array objects exts.append( Extension('array', ['arraymodule.c']) ) --- 272,275 ---- From jhylton@users.sourceforge.net Thu Jun 13 16:14:15 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Thu, 13 Jun 2002 08:14:15 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils unixccompiler.py,1.43,1.44 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv25367 Modified Files: unixccompiler.py Log Message: More style changes and little cleanups. Remove __init__ that just called base class __init__ with same args. Fold long argument lists into fewer, shorter lines. Remove parens in tuple unpacks. Don't put multiple statements on one line with a semicolon. In find_library_file() compute the library_filename() upfront. Index: unixccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/unixccompiler.py,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** unixccompiler.py 13 Jun 2002 15:01:38 -0000 1.43 --- unixccompiler.py 13 Jun 2002 15:14:10 -0000 1.44 *************** *** 80,99 **** static_lib_format = shared_lib_format = dylib_lib_format = "lib%s%s" ! ! ! def __init__(self, ! verbose=0, ! dry_run=0, ! force=0): ! CCompiler.__init__(self, verbose, dry_run, force) ! ! 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) --- 80,87 ---- static_lib_format = shared_lib_format = dylib_lib_format = "lib%s%s" ! def preprocess(self, source, ! output_file=None, macros=None, include_dirs=None, ! extra_preargs=None, extra_postargs=None): ! ignore, macros, include_dirs = \ self._fix_compile_args(None, macros, include_dirs) pp_opts = gen_preprocess_options(macros, include_dirs) *************** *** 118,132 **** raise CompileError, msg ! def compile(self, ! sources, ! output_dir=None, ! macros=None, ! include_dirs=None, ! debug=0, ! extra_preargs=None, ! extra_postargs=None): ! (output_dir, macros, include_dirs) = \ self._fix_compile_args(output_dir, macros, include_dirs) ! (objects, skip_sources) = self._prep_compile(sources, output_dir) # Figure out the options for the compiler command line. --- 106,115 ---- raise CompileError, msg ! def compile(self, sources, ! output_dir=None, macros=None, include_dirs=None, debug=0, ! extra_preargs=None, extra_postargs=None): ! output_dir, macros, include_dirs = \ self._fix_compile_args(output_dir, macros, include_dirs) ! objects, skip_sources = self._prep_compile(sources, output_dir) # Figure out the options for the compiler command line. *************** *** 143,147 **** # '_prep_compile()'. for i in range(len(sources)): ! src = sources[i] ; obj = objects[i] if skip_sources[src]: log.debug("skipping %s (%s up-to-date)", src, obj) --- 126,131 ---- # '_prep_compile()'. for i in range(len(sources)): ! src = sources[i] ! obj = objects[i] if skip_sources[src]: log.debug("skipping %s (%s up-to-date)", src, obj) *************** *** 150,155 **** try: self.spawn(self.compiler_so + cc_args + ! [src, '-o', obj] + ! extra_postargs) except DistutilsExecError, msg: raise CompileError, msg --- 134,138 ---- try: self.spawn(self.compiler_so + cc_args + ! [src, '-o', obj] + extra_postargs) except DistutilsExecError, msg: raise CompileError, msg *************** *** 158,167 **** return objects ! def create_static_lib(self, ! objects, ! output_libname, ! output_dir=None, ! debug=0): ! (objects, output_dir) = self._fix_object_args(objects, output_dir) output_filename = \ --- 141,147 ---- return objects ! def create_static_lib(self, objects, output_libname, ! output_dir=None, debug=0): ! objects, output_dir = self._fix_object_args(objects, output_dir) output_filename = \ *************** *** 187,209 **** log.debug("skipping %s (up-to-date)", output_filename) ! def link(self, ! target_desc, ! objects, ! output_filename, ! output_dir=None, ! libraries=None, ! library_dirs=None, ! runtime_library_dirs=None, ! export_symbols=None, ! debug=0, ! extra_preargs=None, ! extra_postargs=None, ! build_temp=None): ! (objects, output_dir) = self._fix_object_args(objects, output_dir) ! (libraries, library_dirs, runtime_library_dirs) = \ self._fix_lib_args(libraries, library_dirs, runtime_library_dirs) ! lib_opts = gen_lib_options(self, ! library_dirs, runtime_library_dirs, libraries) if type(output_dir) not in (StringType, NoneType): --- 167,180 ---- log.debug("skipping %s (up-to-date)", output_filename) ! def link(self, target_desc, objects, ! output_filename, output_dir=None, libraries=None, ! library_dirs=None, runtime_library_dirs=None, ! export_symbols=None, debug=0, extra_preargs=None, ! extra_postargs=None, build_temp=None): ! objects, output_dir = self._fix_object_args(objects, output_dir) ! libraries, library_dirs, runtime_library_dirs = \ self._fix_lib_args(libraries, library_dirs, runtime_library_dirs) ! lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs, libraries) if type(output_dir) not in (StringType, NoneType): *************** *** 262,273 **** def find_library_file(self, dirs, lib, debug=0): for dir in dirs: ! shared = os.path.join( ! dir, self.library_filename(lib, lib_type='shared')) ! dylib = os.path.join( ! dir, self.library_filename(lib, lib_type='dylib')) ! static = os.path.join( ! dir, self.library_filename(lib, lib_type='static')) ! # We're second-guessing the linker here, with not much hard # data to go on: GCC seems to prefer the shared library, so I'm --- 233,244 ---- def find_library_file(self, dirs, lib, debug=0): + shared_f = self.library_filename(lib, lib_type='shared') + dylib_f = self.library_filename(lib, lib_type='dylib') + static_f = self.library_filename(lib, lib_type='static') + for dir in dirs: ! shared = os.path.join(dir, shared_f) ! dylib = os.path.join(dir, dylib_f) ! static = os.path.join(dir, static_f) # We're second-guessing the linker here, with not much hard # data to go on: GCC seems to prefer the shared library, so I'm *************** *** 280,285 **** elif os.path.exists(static): return static ! ! else: ! # Oops, didn't find it in *any* of 'dirs' ! return None --- 251,255 ---- elif os.path.exists(static): return static ! ! # Oops, didn't find it in *any* of 'dirs' ! return None From gvanrossum@users.sourceforge.net Thu Jun 13 17:07:06 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 13 Jun 2002 09:07:06 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_socket.py,1.34,1.35 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv17318/Lib/test Modified Files: test_socket.py Log Message: Fix non-blocking connect() for Windows. Refactored the code that retries the connect() call in timeout mode so it can be shared between connect() and connect_ex(), and needs only a single #ifdef. The test for this was doing funky stuff I don't approve of, so I removed it in favor of a simpler test. This allowed me to implement a simpler, "purer" form of the timeout retry code. Hopefully that's enough (if you want to be fancy, use non-blocking mode and decode the errors yourself, like before). Index: test_socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** test_socket.py 13 Jun 2002 15:07:43 -0000 1.34 --- test_socket.py 13 Jun 2002 16:07:03 -0000 1.35 *************** *** 417,432 **** def _testConnect(self): ! self.cli.setblocking(0) ! try: ! self.cli.connect((HOST, PORT)) ! except socket.error: ! pass ! else: ! self.fail("Error trying to do non-blocking connect.") ! read, write, err = select.select([self.cli], [], []) ! if self.cli in read: ! self.cli.connect((HOST, PORT)) ! else: ! self.fail("Error trying to do connect after select.") def testRecv(self): --- 417,422 ---- def _testConnect(self): ! self.cli.settimeout(10) ! self.cli.connect((HOST, PORT)) def testRecv(self): From gvanrossum@users.sourceforge.net Thu Jun 13 17:07:08 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 13 Jun 2002 09:07:08 -0700 Subject: [Python-checkins] python/dist/src/Modules socketmodule.c,1.226,1.227 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv17318/Modules Modified Files: socketmodule.c Log Message: Fix non-blocking connect() for Windows. Refactored the code that retries the connect() call in timeout mode so it can be shared between connect() and connect_ex(), and needs only a single #ifdef. The test for this was doing funky stuff I don't approve of, so I removed it in favor of a simpler test. This allowed me to implement a simpler, "purer" form of the timeout retry code. Hopefully that's enough (if you want to be fancy, use non-blocking mode and decode the errors yourself, like before). Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.226 retrieving revision 1.227 diff -C2 -d -r1.226 -r1.227 *** socketmodule.c 13 Jun 2002 15:07:44 -0000 1.226 --- socketmodule.c 13 Jun 2002 16:07:04 -0000 1.227 *************** *** 1271,1274 **** --- 1271,1311 ---- Close the socket. It cannot be used after this call."; + static int + internal_connect(PySocketSockObject *s, struct sockaddr *addr, int addrlen) + { + int res; + + res = connect(s->sock_fd, addr, addrlen); + + #ifdef MS_WINDOWS + + if (s->sock_timeout > 0.0) { + if (res < 0 && WSAGetLastError() == WSAEWOULDBLOCK) { + internal_select(s, 1); + res = connect(s->sock_fd, addr, addrlen); + if (res < 0 && WSAGetLastError() == WSAEISCONN) + res = 0; + } + } + + if (res < 0) + res = WSAGetLastError(); + + #else + + if (s->sock_timeout > 0.0) { + if (res < 0 && errno == EINPROGRESS) { + internal_select(s, 1); + res = connect(s->sock_fd, addr, addrlen); + } + } + + if (res < 0) + res = errno; + + #endif + + return res; + } /* s.connect(sockaddr) method */ *************** *** 1285,1300 **** Py_BEGIN_ALLOW_THREADS ! if (s->sock_timeout > 0.0) { ! res = connect(s->sock_fd, addr, addrlen); ! if (res == EINPROGRESS) { ! internal_select(s, 1); ! res = connect(s->sock_fd, addr, addrlen); ! } ! } ! else ! res = connect(s->sock_fd, addr, addrlen); Py_END_ALLOW_THREADS ! if (res < 0) return s->errorhandler(); Py_INCREF(Py_None); --- 1322,1329 ---- Py_BEGIN_ALLOW_THREADS ! res = internal_connect(s, addr, addrlen); Py_END_ALLOW_THREADS ! if (res != 0) return s->errorhandler(); Py_INCREF(Py_None); *************** *** 1322,1343 **** Py_BEGIN_ALLOW_THREADS ! if (s->sock_timeout > 0.0) { ! res = connect(s->sock_fd, addr, addrlen); ! if (res == EINPROGRESS) { ! internal_select(s, 1); ! res = connect(s->sock_fd, addr, addrlen); ! } ! } ! else ! res = connect(s->sock_fd, addr, addrlen); Py_END_ALLOW_THREADS - - if (res != 0) { - #ifdef MS_WINDOWS - res = WSAGetLastError(); - #else - res = errno; - #endif - } return PyInt_FromLong((long) res); --- 1351,1356 ---- Py_BEGIN_ALLOW_THREADS ! res = internal_connect(s, addr, addrlen); Py_END_ALLOW_THREADS return PyInt_FromLong((long) res); From gvanrossum@users.sourceforge.net Thu Jun 13 17:54:40 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 13 Jun 2002 09:54:40 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_socket.py,1.35,1.36 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv12055 Modified Files: test_socket.py Log Message: Comment out testHostnameRes() -- it depends on a correctly working DNS, and we can't assume that. Index: test_socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** test_socket.py 13 Jun 2002 16:07:03 -0000 1.35 --- test_socket.py 13 Jun 2002 16:54:38 -0000 1.36 *************** *** 208,221 **** pass ! def testHostnameRes(self): ! """Testing hostname resolution mechanisms.""" ! hostname = socket.gethostname() ! ip = socket.gethostbyname(hostname) ! self.assert_(ip.find('.') >= 0, "Error resolving host to ip.") ! hname, aliases, ipaddrs = socket.gethostbyaddr(ip) ! all_host_names = [hname] + aliases ! fqhn = socket.getfqdn() ! if not fqhn in all_host_names: ! self.fail("Error testing host resolution mechanisms.") def testRefCountGetNameInfo(self): --- 208,221 ---- pass ! ## def testHostnameRes(self): ! ## """Testing hostname resolution mechanisms.""" ! ## hostname = socket.gethostname() ! ## ip = socket.gethostbyname(hostname) ! ## self.assert_(ip.find('.') >= 0, "Error resolving host to ip.") ! ## hname, aliases, ipaddrs = socket.gethostbyaddr(ip) ! ## all_host_names = [hname] + aliases ! ## fqhn = socket.getfqdn() ! ## if not fqhn in all_host_names: ! ## self.fail("Error testing host resolution mechanisms.") def testRefCountGetNameInfo(self): From gvanrossum@users.sourceforge.net Thu Jun 13 18:07:51 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 13 Jun 2002 10:07:51 -0700 Subject: [Python-checkins] python/dist/src/Objects complexobject.c,2.60,2.61 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv18004 Modified Files: complexobject.c Log Message: Rearrange the #ifndef WITHOUT_COMPLEX so it can be picked up from pyconfig.h. Index: complexobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/complexobject.c,v retrieving revision 2.60 retrieving revision 2.61 diff -C2 -d -r2.60 -r2.61 *** complexobject.c 6 Jun 2002 15:45:38 -0000 2.60 --- complexobject.c 13 Jun 2002 17:07:07 -0000 2.61 *************** *** 6,13 **** /* Submitted by Jim Hugunin */ - #ifndef WITHOUT_COMPLEX - #include "Python.h" #include "structmember.h" /* Precisions used by repr() and str(), respectively. --- 6,13 ---- /* Submitted by Jim Hugunin */ #include "Python.h" #include "structmember.h" + + #ifndef WITHOUT_COMPLEX /* Precisions used by repr() and str(), respectively. From jhylton@users.sourceforge.net Thu Jun 13 18:27:16 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Thu, 13 Jun 2002 10:27:16 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils mwerkscompiler.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv28965 Modified Files: mwerkscompiler.py Log Message: Add depends=None to the arglist for compile(). Index: mwerkscompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/mwerkscompiler.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** mwerkscompiler.py 4 Jun 2002 20:14:42 -0000 1.7 --- mwerkscompiler.py 13 Jun 2002 17:27:13 -0000 1.8 *************** *** 63,67 **** debug=0, extra_preargs=None, ! extra_postargs=None): (output_dir, macros, include_dirs) = \ self._fix_compile_args (output_dir, macros, include_dirs) --- 63,68 ---- debug=0, extra_preargs=None, ! extra_postargs=None, ! depends=None): (output_dir, macros, include_dirs) = \ self._fix_compile_args (output_dir, macros, include_dirs) From jhylton@users.sourceforge.net Thu Jun 13 18:26:33 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Thu, 13 Jun 2002 10:26:33 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils ccompiler.py,1.44,1.45 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv28656 Modified Files: ccompiler.py Log Message: Extend compiler() method with optional depends argument. This change is not backwards compatible. If a compiler subclass exists outside the distutils package, it may get called with the unexpected keyword arg. It's easy to extend that compiler by having it ignore the argument, and not much harder to do the right thing. If this ends up being burdensome, we can change it before 2.3 final to work harder at compatibility. Also add _setup_compile() and _get_cc_args() helper functions that factor out much of the boilerplate for each concrete compiler class. Index: ccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/ccompiler.py,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** ccompiler.py 4 Jun 2002 20:14:42 -0000 1.44 --- ccompiler.py 13 Jun 2002 17:26:30 -0000 1.45 *************** *** 161,165 **** - def _find_macro (self, name): i = 0 --- 161,164 ---- *************** *** 322,325 **** --- 321,418 ---- # (here for the convenience of subclasses) + # Helper method to prep compiler in subclass compile() methods + + def _setup_compile(self, outdir, macros, incdirs, sources, depends, + extra): + """Process arguments and decide which source files to compile. + + Merges _fix_compile_args() and _prep_compile(). + """ + if outdir is None: + outdir = self.output_dir + elif type(outdir) is not StringType: + raise TypeError, "'output_dir' must be a string or None" + + if macros is None: + macros = self.macros + elif type(macros) is ListType: + macros = macros + (self.macros or []) + else: + raise TypeError, "'macros' (if supplied) must be a list of tuples" + + if incdirs is None: + incdirs = self.include_dirs + elif type(incdirs) in (ListType, TupleType): + incdirs = list(incdirs) + (self.include_dirs or []) + else: + raise TypeError, \ + "'include_dirs' (if supplied) must be a list of strings" + + if extra is None: + extra = [] + + # Get the list of expected output (object) files + objects = self.object_filenames(sources, 1, outdir) + assert len(objects) == len(sources) + + # XXX should redo this code to eliminate skip_source entirely. + # XXX instead create build and issue skip messages inline + + if self.force: + skip_source = {} # rebuild everything + for source in sources: + skip_source[source] = 0 + elif depends is None: + # If depends is None, figure out which source files we + # have to recompile according to a simplistic check. We + # just compare the source and object file, no deep + # dependency checking involving header files. + skip_source = {} # rebuild everything + for source in sources: # no wait, rebuild nothing + skip_source[source] = 1 + + 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 + else: + # If depends is a list of files, then do a different + # simplistic check. Assume that each object depends on + # its source and all files in the depends list. + skip_source = {} + # L contains all the depends plus a spot at the end for a + # particular source file + L = depends[:] + [None] + for i in range(len(objects)): + source = sources[i] + L[-1] = source + if newer_group(L, objects[i]): + skip_source[source] = 0 + else: + skip_source[source] = 1 + + pp_opts = gen_preprocess_options(macros, incdirs) + + build = {} + for i in range(len(sources)): + src = sources[i] + obj = objects[i] + ext = os.path.splitext(src)[1] + self.mkpath(os.path.dirname(obj)) + if skip_source[src]: + log.debug("skipping %s (%s up-to-date)", src, obj) + else: + build[obj] = src, ext + + return macros, objects, extra, pp_opts, build + + def _get_cc_args(self, pp_opts, debug, before): + # works for unixccompiler, emxccompiler, cygwinccompiler + cc_args = pp_opts + ['-c'] + if debug: + cc_args[:0] = ['-g'] + if before: + cc_args[:0] = before + return cc_args + def _fix_compile_args (self, output_dir, macros, include_dirs): """Typecheck and fix-up some of the arguments to the 'compile()' *************** *** 342,347 **** macros = macros + (self.macros or []) else: ! raise TypeError, \ ! "'macros' (if supplied) must be a list of tuples" if include_dirs is None: --- 435,439 ---- macros = macros + (self.macros or []) else: ! raise TypeError, "'macros' (if supplied) must be a list of tuples" if include_dirs is None: *************** *** 353,371 **** "'include_dirs' (if supplied) must be a list of strings" ! return (output_dir, macros, include_dirs) # _fix_compile_args () ! 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, ! strip_dir=1, ! output_dir=output_dir) if self.force: --- 445,465 ---- "'include_dirs' (if supplied) must be a list of strings" ! return output_dir, macros, include_dirs # _fix_compile_args () ! def _prep_compile(self, sources, output_dir, depends=None): ! """Decide which souce files must be recompiled. ! ! 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, strip_dir=1, ! output_dir=output_dir) ! assert len(objects) == len(sources) if self.force: *************** *** 373,390 **** for source in sources: skip_source[source] = 0 ! else: ! # Figure out which source files we have to recompile according ! # to a simplistic check -- we just compare the source and ! # object file, no deep dependency checking involving header ! # files. skip_source = {} # rebuild everything for source in sources: # no wait, rebuild nothing skip_source[source] = 1 ! (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) # _prep_compile () --- 467,499 ---- for source in sources: skip_source[source] = 0 ! elif depends is None: ! # If depends is None, figure out which source files we ! # have to recompile according to a simplistic check. We ! # just compare the source and object file, no deep ! # dependency checking involving header files. skip_source = {} # rebuild everything for source in sources: # no wait, rebuild nothing skip_source[source] = 1 ! 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 + else: + # If depends is a list of files, then do a different + # simplistic check. Assume that each object depends on + # its source and all files in the depends list. + skip_source = {} + # L contains all the depends plus a spot at the end for a + # particular source file + L = depends[:] + [None] + for i in range(len(objects)): + source = sources[i] + L[-1] = source + if newer_group(L, objects[i]): + skip_source[source] = 0 + else: + skip_source[source] = 1 ! return objects, skip_source # _prep_compile () *************** *** 485,504 **** pass ! def compile (self, ! sources, ! output_dir=None, ! macros=None, ! include_dirs=None, ! debug=0, ! 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 ! necessarily be compiled, but all corresponding object filenames ! will be returned. If 'output_dir' is given, object files will be put under it, while --- 594,610 ---- pass ! def compile(self, sources, output_dir=None, macros=None, ! include_dirs=None, debug=0, extra_preargs=None, ! extra_postargs=None, depends=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 necessarily be ! compiled, but all corresponding object filenames will be ! returned. If 'output_dir' is given, object files will be put under it, while *************** *** 531,534 **** --- 637,646 ---- cut the mustard. + 'depends', if given, is a list of filenames that all targets + depend on. If a source file is older than any file in + depends, then the source file will be recompiled. This + supports dependency tracking, but only at a coarse + granularity. + Raises CompileError on failure. """ *************** *** 711,715 **** raise NotImplementedError - # -- Filename generation methods ----------------------------------- --- 823,826 ---- *************** *** 746,806 **** # extension for executable files, eg. '' or '.exe' ! def object_filenames (self, ! source_filenames, ! strip_dir=0, ! output_dir=''): ! if output_dir is None: output_dir = '' obj_names = [] for src_name in source_filenames: ! (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) ! obj_names.append (os.path.join (output_dir, ! base + self.obj_extension)) return obj_names ! # object_filenames () ! ! ! def shared_object_filename (self, ! basename, ! strip_dir=0, ! output_dir=''): ! if output_dir is None: output_dir = '' if strip_dir: basename = os.path.basename (basename) ! return os.path.join (output_dir, basename + self.shared_lib_extension) ! def executable_filename (self, ! basename, ! strip_dir=0, ! output_dir=''): ! if output_dir is None: output_dir = '' if strip_dir: basename = os.path.basename (basename) return os.path.join(output_dir, basename + (self.exe_extension or '')) ! def library_filename (self, ! libname, ! lib_type='static', # or 'shared' ! strip_dir=0, ! output_dir=''): ! ! if output_dir is None: output_dir = '' ! if lib_type not in ("static","shared","dylib"): raise ValueError, "'lib_type' must be \"static\", \"shared\" or \"dylib\"" ! fmt = getattr (self, lib_type + "_lib_format") ! ext = getattr (self, lib_type + "_lib_extension") ! (dir, base) = os.path.split (libname) filename = fmt % (base, ext) if strip_dir: dir = '' ! return os.path.join (output_dir, dir, filename) --- 857,900 ---- # extension for executable files, eg. '' or '.exe' ! def object_filenames(self, source_filenames, strip_dir=0, output_dir=''): ! assert output_dir is not None obj_names = [] for src_name in source_filenames: ! 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) ! obj_names.append(os.path.join(output_dir, ! base + self.obj_extension)) return obj_names ! def shared_object_filename(self, basename, strip_dir=0, output_dir=''): ! assert output_dir is not None if strip_dir: basename = os.path.basename (basename) ! return os.path.join(output_dir, basename + self.shared_lib_extension) ! def executable_filename(self, basename, strip_dir=0, output_dir=''): ! assert output_dir is not None if strip_dir: basename = os.path.basename (basename) return os.path.join(output_dir, basename + (self.exe_extension or '')) ! def library_filename(self, libname, lib_type='static', # or 'shared' ! strip_dir=0, output_dir=''): ! assert output_dir is not None ! if lib_type not in ("static", "shared", "dylib"): raise ValueError, "'lib_type' must be \"static\", \"shared\" or \"dylib\"" ! fmt = getattr(self, lib_type + "_lib_format") ! ext = getattr(self, lib_type + "_lib_extension") ! dir, base = os.path.split (libname) filename = fmt % (base, ext) if strip_dir: dir = '' ! return os.path.join(output_dir, dir, filename) From jhylton@users.sourceforge.net Thu Jun 13 18:28:20 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Thu, 13 Jun 2002 10:28:20 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils bcppcompiler.py,1.12,1.13 cygwinccompiler.py,1.16,1.17 emxccompiler.py,1.3,1.4 msvccompiler.py,1.47,1.48 unixccompiler.py,1.44,1.45 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv29397a Modified Files: bcppcompiler.py cygwinccompiler.py emxccompiler.py msvccompiler.py unixccompiler.py Log Message: Refactor compile() method implementations. Always use _setup_compile() to do the grunt work of processing arguments, figuring out which files to compile, and emitting debug messages for files that are up-to-date. Use _get_cc_args() when possible. Index: bcppcompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/bcppcompiler.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** bcppcompiler.py 4 Jun 2002 20:14:42 -0000 1.12 --- bcppcompiler.py 13 Jun 2002 17:28:18 -0000 1.13 *************** *** 81,101 **** # -- Worker methods ------------------------------------------------ ! def compile (self, ! sources, ! output_dir=None, ! macros=None, ! include_dirs=None, ! debug=0, ! extra_preargs=None, ! extra_postargs=None): ! ! (output_dir, macros, include_dirs) = \ ! self._fix_compile_args (output_dir, macros, include_dirs) ! (objects, skip_sources) = self._prep_compile (sources, output_dir) ! ! if extra_postargs is None: ! extra_postargs = [] ! ! pp_opts = gen_preprocess_options (macros, include_dirs) compile_opts = extra_preargs or [] compile_opts.append ('-c') --- 81,91 ---- # -- Worker methods ------------------------------------------------ ! def compile(self, sources, ! output_dir=None, macros=None, include_dirs=None, debug=0, ! extra_preargs=None, extra_postargs=None, depends=None): ! ! macros, objects, extra_postargs, pp_opts, build = \ ! self._setup_compile(output_dir, macros, include_dirs, sources, ! depends, extra_postargs) compile_opts = extra_preargs or [] compile_opts.append ('-c') *************** *** 105,152 **** compile_opts.extend (self.compile_options) ! for i in range (len (sources)): ! src = sources[i] ; obj = objects[i] ! ext = (os.path.splitext (src))[1] ! ! if skip_sources[src]: ! log.debug("skipping %s (%s up-to-date)", src, obj) ! else: ! src = os.path.normpath(src) ! obj = os.path.normpath(obj) ! self.mkpath(os.path.dirname(obj)) ! ! if ext == '.res': ! # This is already a binary file -- skip it. ! continue # the 'for' loop ! if ext == '.rc': ! # This needs to be compiled to a .res file -- do it now. ! try: ! self.spawn (["brcc32", "-fo", obj, src]) ! except DistutilsExecError, msg: ! raise CompileError, msg ! continue # the 'for' loop ! ! # The next two are both for the real compiler. ! if ext in self._c_extensions: ! input_opt = "" ! elif ext in self._cpp_extensions: ! input_opt = "-P" ! else: ! # Unknown file type -- no extra options. The compiler ! # will probably fail, but let it just in case this is a ! # file the compiler recognizes even if we don't. ! input_opt = "" ! ! output_opt = "-o" + obj ! # Compiler command line syntax is: "bcc32 [options] file(s)". ! # Note that the source file names must appear at the end of ! # the command line. try: ! self.spawn ([self.cc] + compile_opts + pp_opts + ! [input_opt, output_opt] + ! extra_postargs + [src]) except DistutilsExecError, msg: raise CompileError, msg return objects --- 95,139 ---- compile_opts.extend (self.compile_options) ! for obj, (src, ext) in build.items(): ! # XXX why do the normpath here? ! src = os.path.normpath(src) ! obj = os.path.normpath(obj) ! # XXX _setup_compile() did a mkpath() too but before the normpath. ! # Is it possible to skip the normpath? ! self.mkpath(os.path.dirname(obj)) ! if ext == '.res': ! # This is already a binary file -- skip it. ! continue # the 'for' loop ! if ext == '.rc': ! # This needs to be compiled to a .res file -- do it now. try: ! self.spawn (["brcc32", "-fo", obj, src]) except DistutilsExecError, msg: raise CompileError, msg + continue # the 'for' loop + + # The next two are both for the real compiler. + if ext in self._c_extensions: + input_opt = "" + elif ext in self._cpp_extensions: + input_opt = "-P" + else: + # Unknown file type -- no extra options. The compiler + # will probably fail, but let it just in case this is a + # file the compiler recognizes even if we don't. + input_opt = "" + + output_opt = "-o" + obj + + # Compiler command line syntax is: "bcc32 [options] file(s)". + # Note that the source file names must appear at the end of + # the command line. + try: + self.spawn ([self.cc] + compile_opts + pp_opts + + [input_opt, output_opt] + + extra_postargs + [src]) + except DistutilsExecError, msg: + raise CompileError, msg return objects Index: cygwinccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/cygwinccompiler.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** cygwinccompiler.py 4 Jun 2002 20:26:44 -0000 1.16 --- cygwinccompiler.py 13 Jun 2002 17:28:18 -0000 1.17 *************** *** 63,70 **** exe_extension = ".exe" ! def __init__ (self, ! verbose=0, ! dry_run=0, ! force=0): UnixCCompiler.__init__ (self, verbose, dry_run, force) --- 63,67 ---- exe_extension = ".exe" ! def __init__ (self, verbose=0, dry_run=0, force=0): UnixCCompiler.__init__ (self, verbose, dry_run, force) *************** *** 75,83 **** if status is not CONFIG_H_OK: self.warn( ! "Python's pyconfig.h doesn't seem to support your compiler. " + ! ("Reason: %s." % details) + ! "Compiling may fail because of undefined preprocessor macros.") ! (self.gcc_version, self.ld_version, self.dllwrap_version) = \ get_versions() self.debug_print(self.compiler_type + ": gcc %s, ld %s, dllwrap %s\n" % --- 72,81 ---- if status is not CONFIG_H_OK: self.warn( ! "Python's pyconfig.h doesn't seem to support your compiler. " ! "Reason: %s. " ! "Compiling may fail because of undefined preprocessor macros." ! % details) ! self.gcc_version, self.ld_version, self.dllwrap_version = \ get_versions() self.debug_print(self.compiler_type + ": gcc %s, ld %s, dllwrap %s\n" % *************** *** 121,175 **** # (If we would call compile() in the base class, it would do some # initializations a second time, this is why all is done here.) ! def compile (self, ! sources, ! output_dir=None, ! macros=None, ! include_dirs=None, ! debug=0, ! extra_preargs=None, ! extra_postargs=None): ! ! (output_dir, macros, include_dirs) = \ ! self._fix_compile_args (output_dir, macros, include_dirs) ! (objects, skip_sources) = self._prep_compile (sources, output_dir) ! ! # 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'] ! if extra_preargs: ! cc_args[:0] = extra_preargs ! if extra_postargs is None: ! extra_postargs = [] ! # Compile all source files that weren't eliminated by ! # '_prep_compile()'. ! for i in range (len (sources)): ! src = sources[i] ; obj = objects[i] ! ext = (os.path.splitext (src))[1] ! if skip_sources[src]: ! log.debug("skipping %s (%s up-to-date)", src, obj) ! else: ! self.mkpath (os.path.dirname (obj)) ! if ext == '.rc' or ext == '.res': ! # gcc needs '.res' and '.rc' compiled to object files !!! ! try: ! self.spawn (["windres","-i",src,"-o",obj]) ! except DistutilsExecError, msg: ! raise CompileError, msg ! else: # for other files use the C-compiler ! try: ! self.spawn (self.compiler_so + cc_args + ! [src, '-o', obj] + ! extra_postargs) ! except DistutilsExecError, msg: ! raise CompileError, msg # Return *all* object filenames, not just the ones we just built. return objects - - # compile () - def link (self, --- 119,148 ---- # (If we would call compile() in the base class, it would do some # initializations a second time, this is why all is done here.) ! def compile(self, sources, ! output_dir=None, macros=None, include_dirs=None, debug=0, ! extra_preargs=None, extra_postargs=None, depends=None): ! ! macros, objects, extra_postargs, pp_opts, build = \ ! self._setup_compile(output_dir, macros, include_dirs, sources, ! depends, extra_postargs) ! cc_args = self._get_cc_args(pp_opts, debug, extra_preargs) ! for obj, (src, ext) in build.items(): ! if ext == '.rc' or ext == '.res': ! # gcc needs '.res' and '.rc' compiled to object files !!! ! try: ! self.spawn (["windres","-i",src,"-o",obj]) ! except DistutilsExecError, msg: ! raise CompileError, msg ! else: # for other files use the C-compiler ! try: ! self.spawn (self.compiler_so + cc_args + ! [src, '-o', obj] + ! extra_postargs) ! except DistutilsExecError, msg: ! raise CompileError, msg # Return *all* object filenames, not just the ones we just built. return objects def link (self, Index: emxccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/emxccompiler.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** emxccompiler.py 4 Jun 2002 20:26:44 -0000 1.3 --- emxccompiler.py 13 Jun 2002 17:28:18 -0000 1.4 *************** *** 82,130 **** # (If we would call compile() in the base class, it would do some # initializations a second time, this is why all is done here.) - def compile (self, - sources, - output_dir=None, - macros=None, - include_dirs=None, - debug=0, - extra_preargs=None, - extra_postargs=None): ! (output_dir, macros, include_dirs) = \ ! self._fix_compile_args (output_dir, macros, include_dirs) ! (objects, skip_sources) = self._prep_compile (sources, output_dir) ! ! # 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'] ! if extra_preargs: ! cc_args[:0] = extra_preargs ! if extra_postargs is None: ! extra_postargs = [] ! # Compile all source files that weren't eliminated by ! # '_prep_compile()'. ! for i in range (len (sources)): ! src = sources[i] ; obj = objects[i] ! ext = (os.path.splitext (src))[1] ! if skip_sources[src]: ! log.debug("skipping %s (%s up-to-date)", src, obj) ! else: ! self.mkpath (os.path.dirname (obj)) ! if ext == '.rc': ! # gcc requires '.rc' compiled to binary ('.res') files !!! ! try: ! self.spawn (["rc","-r",src]) ! except DistutilsExecError, msg: ! raise CompileError, msg ! else: # for other files use the C-compiler ! try: ! self.spawn (self.compiler_so + cc_args + ! [src, '-o', obj] + ! extra_postargs) ! except DistutilsExecError, msg: ! raise CompileError, msg # Return *all* object filenames, not just the ones we just built. --- 82,109 ---- # (If we would call compile() in the base class, it would do some # initializations a second time, this is why all is done here.) ! def compile(self, sources, ! output_dir=None, macros=None, include_dirs=None, debug=0, ! extra_preargs=None, extra_postargs=None, depends=None): ! ! macros, objects, extra_postargs, pp_opts, build = \ ! self._setup_compile(output_dir, macros, include_dirs, sources, ! depends, extra_postargs) ! cc_args = self._get_cc_args(pp_opts, debug, extra_preargs) ! for obj, (src, ext) in build.items(): ! if ext == '.rc': ! # gcc requires '.rc' compiled to binary ('.res') files !!! ! try: ! self.spawn (["rc","-r",src]) ! except DistutilsExecError, msg: ! raise CompileError, msg ! else: # for other files use the C-compiler ! try: ! self.spawn (self.compiler_so + cc_args + ! [src, '-o', obj] + ! extra_postargs) ! except DistutilsExecError, msg: ! raise CompileError, msg # Return *all* object filenames, not just the ones we just built. Index: msvccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/msvccompiler.py,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** msvccompiler.py 4 Jun 2002 20:14:42 -0000 1.47 --- msvccompiler.py 13 Jun 2002 17:28:18 -0000 1.48 *************** *** 278,376 **** ! def compile (self, ! sources, ! output_dir=None, ! macros=None, ! include_dirs=None, ! debug=0, ! extra_preargs=None, ! extra_postargs=None): ! ! (output_dir, macros, include_dirs) = \ ! self._fix_compile_args (output_dir, macros, include_dirs) ! (objects, skip_sources) = self._prep_compile (sources, output_dir) ! if extra_postargs is None: ! extra_postargs = [] - pp_opts = gen_preprocess_options (macros, include_dirs) compile_opts = extra_preargs or [] compile_opts.append ('/c') if debug: ! compile_opts.extend (self.compile_options_debug) else: ! compile_opts.extend (self.compile_options) ! ! for i in range (len (sources)): ! src = sources[i] ; obj = objects[i] ! ext = (os.path.splitext (src))[1] ! ! if skip_sources[src]: ! log.debug("skipping %s (%s up-to-date)", src, obj) ! else: ! self.mkpath (os.path.dirname (obj)) ! ! if debug: ! # pass the full pathname to MSVC in debug mode, ! # this allows the debugger to find the source file ! # without asking the user to browse for it ! src = os.path.abspath(src) ! ! if ext in self._c_extensions: ! input_opt = "/Tc" + src ! elif ext in self._cpp_extensions: ! input_opt = "/Tp" + src ! elif ext in self._rc_extensions: ! # compile .RC to .RES file ! input_opt = src ! output_opt = "/fo" + obj ! try: ! self.spawn ([self.rc] + ! [output_opt] + [input_opt]) ! except DistutilsExecError, msg: ! raise CompileError, msg ! continue ! elif ext in self._mc_extensions: ! # Compile .MC to .RC file to .RES file. ! # * '-h dir' specifies the directory for the ! # generated include file ! # * '-r dir' specifies the target directory of the ! # generated RC file and the binary message resource ! # it includes ! # ! # For now (since there are no options to change this), ! # we use the source-directory for the include file and ! # the build directory for the RC file and message ! # resources. This works at least for win32all. ! h_dir = os.path.dirname (src) ! rc_dir = os.path.dirname (obj) ! try: ! # first compile .MC to .RC and .H file ! self.spawn ([self.mc] + ! ['-h', h_dir, '-r', rc_dir] + [src]) ! base, _ = os.path.splitext (os.path.basename (src)) ! rc_file = os.path.join (rc_dir, base + '.rc') ! # then compile .RC to .RES file ! self.spawn ([self.rc] + ! ["/fo" + obj] + [rc_file]) ! except DistutilsExecError, msg: ! raise CompileError, msg ! continue ! else: ! # how to handle this file? ! raise CompileError ( ! "Don't know how to compile %s to %s" % \ ! (src, obj)) ! output_opt = "/Fo" + obj try: ! self.spawn ([self.cc] + compile_opts + pp_opts + ! [input_opt, output_opt] + ! extra_postargs) except DistutilsExecError, msg: raise CompileError, msg return objects --- 278,359 ---- ! def compile(self, sources, ! output_dir=None, macros=None, include_dirs=None, debug=0, ! extra_preargs=None, extra_postargs=None, depends=None): ! macros, objects, extra_postargs, pp_opts, build = \ ! self._setup_compile(output_dir, macros, include_dirs, sources, ! depends, extra_postargs) compile_opts = extra_preargs or [] compile_opts.append ('/c') if debug: ! compile_opts.extend(self.compile_options_debug) else: ! compile_opts.extend(self.compile_options) ! for obj, (src, ext) in build.items(): ! if debug: ! # pass the full pathname to MSVC in debug mode, ! # this allows the debugger to find the source file ! # without asking the user to browse for it ! src = os.path.abspath(src) ! if ext in self._c_extensions: ! input_opt = "/Tc" + src ! elif ext in self._cpp_extensions: ! input_opt = "/Tp" + src ! elif ext in self._rc_extensions: ! # compile .RC to .RES file ! input_opt = src ! output_opt = "/fo" + obj ! try: ! self.spawn ([self.rc] + ! [output_opt] + [input_opt]) ! except DistutilsExecError, msg: ! raise CompileError, msg ! continue ! elif ext in self._mc_extensions: ! # Compile .MC to .RC file to .RES file. ! # * '-h dir' specifies the directory for the ! # generated include file ! # * '-r dir' specifies the target directory of the ! # generated RC file and the binary message resource ! # it includes ! # ! # For now (since there are no options to change this), ! # we use the source-directory for the include file and ! # the build directory for the RC file and message ! # resources. This works at least for win32all. ! h_dir = os.path.dirname (src) ! rc_dir = os.path.dirname (obj) try: ! # first compile .MC to .RC and .H file ! self.spawn ([self.mc] + ! ['-h', h_dir, '-r', rc_dir] + [src]) ! base, _ = os.path.splitext (os.path.basename (src)) ! rc_file = os.path.join (rc_dir, base + '.rc') ! # then compile .RC to .RES file ! self.spawn ([self.rc] + ! ["/fo" + obj] + [rc_file]) ! except DistutilsExecError, msg: raise CompileError, msg + continue + else: + # how to handle this file? + raise CompileError ( + "Don't know how to compile %s to %s" % \ + (src, obj)) + + output_opt = "/Fo" + obj + try: + self.spawn ([self.cc] + compile_opts + pp_opts + + [input_opt, output_opt] + + extra_postargs) + except DistutilsExecError, msg: + raise CompileError, msg return objects Index: unixccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/unixccompiler.py,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** unixccompiler.py 13 Jun 2002 15:14:10 -0000 1.44 --- unixccompiler.py 13 Jun 2002 17:28:18 -0000 1.45 *************** *** 108,140 **** def compile(self, sources, output_dir=None, macros=None, include_dirs=None, debug=0, ! extra_preargs=None, extra_postargs=None): ! output_dir, macros, include_dirs = \ ! self._fix_compile_args(output_dir, macros, include_dirs) ! objects, skip_sources = self._prep_compile(sources, output_dir) ! ! # 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'] ! if extra_preargs: ! cc_args[:0] = extra_preargs ! if extra_postargs is None: ! extra_postargs = [] ! # Compile all source files that weren't eliminated by ! # '_prep_compile()'. ! for i in range(len(sources)): ! src = sources[i] ! obj = objects[i] ! if skip_sources[src]: ! log.debug("skipping %s (%s up-to-date)", src, obj) ! else: ! self.mkpath(os.path.dirname(obj)) ! try: ! self.spawn(self.compiler_so + cc_args + ! [src, '-o', obj] + extra_postargs) ! except DistutilsExecError, msg: ! raise CompileError, msg # Return *all* object filenames, not just the ones we just built. --- 108,124 ---- def compile(self, sources, output_dir=None, macros=None, include_dirs=None, debug=0, ! extra_preargs=None, extra_postargs=None, depends=None): ! ! macros, objects, extra_postargs, pp_opts, build = \ ! self._setup_compile(output_dir, macros, include_dirs, sources, ! depends, extra_postargs) ! cc_args = self._get_cc_args(pp_opts, debug, extra_preargs) ! for obj, (src, ext) in build.items(): ! try: ! self.spawn(self.compiler_so + cc_args + ! [src, '-o', obj] + extra_postargs) ! except DistutilsExecError, msg: ! raise CompileError, msg # Return *all* object filenames, not just the ones we just built. From jhylton@users.sourceforge.net Thu Jun 13 18:38:15 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Thu, 13 Jun 2002 10:38:15 -0700 Subject: [Python-checkins] python/dist/src setup.py,1.91,1.92 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv1343 Modified Files: setup.py Log Message: Munge depends files to have absolute paths. Look in both moddirlist and incdirlist, since a .h could be in either. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.91 retrieving revision 1.92 diff -C2 -d -r1.91 -r1.92 *** setup.py 13 Jun 2002 15:08:35 -0000 1.91 --- setup.py 13 Jun 2002 17:38:11 -0000 1.92 *************** *** 106,109 **** --- 106,111 ---- incdirlist.append('./Mac/Include') + alldirlist = moddirlist + incdirlist + # Fix up the paths for scripts, too self.distribution.scripts = [os.path.join(srcdir, filename) *************** *** 113,116 **** --- 115,121 ---- ext.sources = [ find_module_file(filename, moddirlist) for filename in ext.sources ] + if ext.depends is not None: + ext.depends = [find_module_file(filename, alldirlist) + for filename in ext.depends] ext.include_dirs.append( '.' ) # to get config.h for incdir in incdirlist: *************** *** 387,391 **** # socket(2) exts.append( Extension('_socket', ['socketmodule.c'], ! depends = ['Modules/socketmodule.h']) ) # Detect SSL support for the socket module (via _ssl) ssl_incs = find_file('openssl/ssl.h', inc_dirs, --- 392,396 ---- # socket(2) exts.append( Extension('_socket', ['socketmodule.c'], ! depends = ['socketmodule.h']) ) # Detect SSL support for the socket module (via _ssl) ssl_incs = find_file('openssl/ssl.h', inc_dirs, *************** *** 405,409 **** library_dirs = ssl_libs, libraries = ['ssl', 'crypto'], ! depends = ['Modules/socketmodule.h']), ) # Modules that provide persistent dictionary-like semantics. You will --- 410,414 ---- library_dirs = ssl_libs, libraries = ['ssl', 'crypto'], ! depends = ['socketmodule.h']), ) # Modules that provide persistent dictionary-like semantics. You will From fdrake@users.sourceforge.net Thu Jun 13 18:54:08 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu, 13 Jun 2002 10:54:08 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib liblocale.tex,1.29,1.30 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv8012/lib Modified Files: liblocale.tex Log Message: Do not claim that getlocale() returns a tulpe; that is not always true. Closes SF bug #568577. Index: liblocale.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liblocale.tex,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** liblocale.tex 28 Mar 2002 12:40:45 -0000 1.29 --- liblocale.tex 13 Jun 2002 17:54:06 -0000 1.30 *************** *** 146,152 **** \begin{funcdesc}{getlocale}{\optional{category}} Returns the current setting for the given locale category as ! tuple (language code, encoding). \var{category} may be one of the ! \constant{LC_*} values except \constant{LC_ALL}. It defaults to ! \constant{LC_CTYPE}. Except for the code \code{'C'}, the language code corresponds to --- 146,152 ---- \begin{funcdesc}{getlocale}{\optional{category}} Returns the current setting for the given locale category as ! sequence containing \var{language code}, \var{encoding}. ! \var{category} may be one of the \constant{LC_*} values except ! \constant{LC_ALL}. It defaults to \constant{LC_CTYPE}. Except for the code \code{'C'}, the language code corresponds to From fdrake@users.sourceforge.net Thu Jun 13 18:54:47 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu, 13 Jun 2002 10:54:47 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib liblocale.tex,1.27,1.27.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv8288/lib Modified Files: Tag: release22-maint liblocale.tex Log Message: Do not claim that getlocale() returns a tulpe; that is not always true. Closes SF bug #568577. Index: liblocale.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liblocale.tex,v retrieving revision 1.27 retrieving revision 1.27.8.1 diff -C2 -d -r1.27 -r1.27.8.1 *** liblocale.tex 20 Oct 2001 04:24:09 -0000 1.27 --- liblocale.tex 13 Jun 2002 17:54:44 -0000 1.27.8.1 *************** *** 146,152 **** \begin{funcdesc}{getlocale}{\optional{category}} Returns the current setting for the given locale category as ! tuple (language code, encoding). \var{category} may be one of the ! \constant{LC_*} values except \constant{LC_ALL}. It defaults to ! \constant{LC_CTYPE}. Except for the code \code{'C'}, the language code corresponds to --- 146,152 ---- \begin{funcdesc}{getlocale}{\optional{category}} Returns the current setting for the given locale category as ! sequence containing \var{language code}, \var{encoding}. ! \var{category} may be one of the \constant{LC_*} values except ! \constant{LC_ALL}. It defaults to \constant{LC_CTYPE}. Except for the code \code{'C'}, the language code corresponds to From jhylton@users.sourceforge.net Thu Jun 13 18:32:29 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Thu, 13 Jun 2002 10:32:29 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils/command build_ext.py,1.83,1.84 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory usw-pr-cvs1:/tmp/cvs-serv31001 Modified Files: build_ext.py Log Message: Extend dependency tracking so that .o files are rebuilt. Two new tests are needed: Don't skip building an extension if any of the depends files are newer than the target. Pass ext.depends to compiler.compile() so that it can track individual files. Index: build_ext.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/build_ext.py,v retrieving revision 1.83 retrieving revision 1.84 diff -C2 -d -r1.83 -r1.84 *** build_ext.py 12 Jun 2002 20:08:56 -0000 1.83 --- build_ext.py 13 Jun 2002 17:32:20 -0000 1.84 *************** *** 389,393 **** def build_extensions(self): - # First, sanity-check the 'extensions' list self.check_extensions_list(self.extensions) --- 389,392 ---- *************** *** 397,401 **** def build_extension(self, ext): - sources = ext.sources if sources is None or type(sources) not in (ListType, TupleType): --- 396,399 ---- *************** *** 422,426 **** ext_filename = os.path.join(self.build_lib, self.get_ext_filename(fullname)) - depends = sources + ext.depends if not (self.force or newer_group(depends, ext_filename, 'newer')): --- 420,423 ---- *************** *** 468,472 **** include_dirs=ext.include_dirs, debug=self.debug, ! extra_postargs=extra_args) # XXX -- this is a Vile HACK! --- 465,470 ---- include_dirs=ext.include_dirs, debug=self.debug, ! extra_postargs=extra_args, ! depends=ext.depends) # XXX -- this is a Vile HACK! From fdrake@users.sourceforge.net Thu Jun 13 18:55:44 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu, 13 Jun 2002 10:55:44 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib liblocale.tex,1.22.4.1,1.22.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv8589/lib Modified Files: Tag: release21-maint liblocale.tex Log Message: Do not claim that getlocale() returns a tulpe; that is not always true. Closes SF bug #568577. Index: liblocale.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liblocale.tex,v retrieving revision 1.22.4.1 retrieving revision 1.22.4.2 diff -C2 -d -r1.22.4.1 -r1.22.4.2 *** liblocale.tex 10 May 2001 15:13:39 -0000 1.22.4.1 --- liblocale.tex 13 Jun 2002 17:55:42 -0000 1.22.4.2 *************** *** 137,143 **** \begin{funcdesc}{getlocale}{\optional{category}} Returns the current setting for the given locale category as ! tuple (language code, encoding). \var{category} may be one of the ! \constant{LC_*} values except \constant{LC_ALL}. It defaults to ! \constant{LC_CTYPE}. Except for the code \code{'C'}, the language code corresponds to --- 137,143 ---- \begin{funcdesc}{getlocale}{\optional{category}} Returns the current setting for the given locale category as ! sequence containing \var{language code}, \var{encoding}. ! \var{category} may be one of the \constant{LC_*} values except ! \constant{LC_ALL}. It defaults to \constant{LC_CTYPE}. Except for the code \code{'C'}, the language code corresponds to From gvanrossum@users.sourceforge.net Thu Jun 13 18:59:53 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 13 Jun 2002 10:59:53 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libdis.tex,1.35,1.36 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv10481/Doc/lib Modified Files: libdis.tex Log Message: The opcode FOR_LOOP no longer exists. Index: libdis.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdis.tex,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** libdis.tex 12 Jun 2002 15:33:08 -0000 1.35 --- libdis.tex 13 Jun 2002 17:59:51 -0000 1.36 *************** *** 557,567 **** \end{opcodedesc} ! \begin{opcodedesc}{FOR_LOOP}{delta} ! This opcode is obsolete. ! %Iterate over a sequence. TOS is the current index, TOS1 the sequence. ! %First, the next element is computed. If the sequence is exhausted, ! %increment byte code counter by \var{delta}. Otherwise, push the ! %sequence, the incremented counter, and the current item onto the stack. ! \end{opcodedesc} %\begin{opcodedesc}{LOAD_LOCAL}{namei} --- 557,563 ---- \end{opcodedesc} ! %\begin{opcodedesc}{FOR_LOOP}{delta} ! %This opcode is obsolete. ! %\end{opcodedesc} %\begin{opcodedesc}{LOAD_LOCAL}{namei} From gvanrossum@users.sourceforge.net Thu Jun 13 18:59:53 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 13 Jun 2002 10:59:53 -0700 Subject: [Python-checkins] python/dist/src/Lib dis.py,1.40,1.41 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv10481/Lib Modified Files: dis.py Log Message: The opcode FOR_LOOP no longer exists. Index: dis.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dis.py,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** dis.py 11 Jun 2002 21:17:35 -0000 1.40 --- dis.py 13 Jun 2002 17:59:51 -0000 1.41 *************** *** 263,267 **** jrel_op('JUMP_IF_TRUE', 112) # "" jabs_op('JUMP_ABSOLUTE', 113) # Target byte offset from beginning of code - jrel_op('FOR_LOOP', 114) # Number of bytes to skip name_op('LOAD_GLOBAL', 116) # Index in name list --- 263,266 ---- From gvanrossum@users.sourceforge.net Thu Jun 13 18:59:53 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 13 Jun 2002 10:59:53 -0700 Subject: [Python-checkins] python/dist/src/Python ceval.c,2.312,2.313 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv10481/Python Modified Files: ceval.c Log Message: The opcode FOR_LOOP no longer exists. Index: ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.312 retrieving revision 2.313 diff -C2 -d -r2.312 -r2.313 *** ceval.c 12 Jun 2002 03:45:21 -0000 2.312 --- ceval.c 13 Jun 2002 17:59:51 -0000 2.313 *************** *** 1943,1977 **** break; - case FOR_LOOP: - /* for v in s: ... - On entry: stack contains s, i. - On exit: stack contains s, i+1, s[i]; - but if loop exhausted: - s, i are popped, and we jump */ - w = POP(); /* Loop index */ - v = POP(); /* Sequence object */ - u = loop_subscript(v, w); - if (u != NULL) { - PUSH(v); - x = PyInt_FromLong(PyInt_AsLong(w)+1); - PUSH(x); - Py_DECREF(w); - PUSH(u); - if (x != NULL) continue; - } - else { - Py_DECREF(v); - Py_DECREF(w); - /* A NULL can mean "s exhausted" - but also an error: */ - if (PyErr_Occurred()) - why = WHY_EXCEPTION; - else { - JUMPBY(oparg); - continue; - } - } - break; - case SETUP_LOOP: case SETUP_EXCEPT: --- 1943,1946 ---- From gvanrossum@users.sourceforge.net Thu Jun 13 18:59:53 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 13 Jun 2002 10:59:53 -0700 Subject: [Python-checkins] python/dist/src/Include opcode.h,2.38,2.39 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv10481/Include Modified Files: opcode.h Log Message: The opcode FOR_LOOP no longer exists. Index: opcode.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/opcode.h,v retrieving revision 2.38 retrieving revision 2.39 diff -C2 -d -r2.38 -r2.39 *** opcode.h 1 Jan 2002 19:59:10 -0000 2.38 --- opcode.h 13 Jun 2002 17:59:51 -0000 2.39 *************** *** 108,112 **** #define JUMP_IF_TRUE 112 /* "" */ #define JUMP_ABSOLUTE 113 /* Target byte offset from beginning of code */ - #define FOR_LOOP 114 /* Number of bytes to skip */ #define LOAD_GLOBAL 116 /* Index in name list */ --- 108,111 ---- From gvanrossum@users.sourceforge.net Thu Jun 13 20:17:51 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 13 Jun 2002 12:17:51 -0700 Subject: [Python-checkins] python/dist/src/Objects typeobject.c,2.151,2.152 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv11967/Objects Modified Files: typeobject.c Log Message: Hopefully this addresses the remaining issues of SF bugs 459235 and 473985. Through a subtle rearrangement of some members in the etype struct (!), mapping methods are now preferred over sequence methods, which is necessary to support str.__getitem__("hello", slice(4)) etc. Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.151 retrieving revision 2.152 diff -C2 -d -r2.151 -r2.152 *** typeobject.c 10 Jun 2002 15:29:03 -0000 2.151 --- typeobject.c 13 Jun 2002 19:17:45 -0000 2.152 *************** *** 9,16 **** /* XXX Should we publish this in a header file? */ typedef struct { PyTypeObject type; PyNumberMethods as_number; - PySequenceMethods as_sequence; PyMappingMethods as_mapping; PyBufferProcs as_buffer; PyObject *name, *slots; --- 9,22 ---- /* XXX Should we publish this in a header file? */ typedef struct { + /* Note: there's a dependency on the order of these members + in slotptr() below. */ PyTypeObject type; PyNumberMethods as_number; PyMappingMethods as_mapping; + PySequenceMethods as_sequence; /* as_sequence comes after as_mapping, + so that the mapping wins when both + the mapping and the sequence define + a given operator (e.g. __getitem__). + see add_operators() below. */ PyBufferProcs as_buffer; PyObject *name, *slots; *************** *** 3871,3884 **** char *ptr; assert(offset >= 0); assert(offset < offsetof(etype, as_buffer)); ! if (offset >= offsetof(etype, as_mapping)) { ! ptr = (void *)type->tp_as_mapping; ! offset -= offsetof(etype, as_mapping); ! } ! else if (offset >= offsetof(etype, as_sequence)) { ptr = (void *)type->tp_as_sequence; offset -= offsetof(etype, as_sequence); } else if (offset >= offsetof(etype, as_number)) { ptr = (void *)type->tp_as_number; --- 3877,3891 ---- char *ptr; + /* Note: this depends on the order of the members of etype! */ assert(offset >= 0); assert(offset < offsetof(etype, as_buffer)); ! if (offset >= offsetof(etype, as_sequence)) { ptr = (void *)type->tp_as_sequence; offset -= offsetof(etype, as_sequence); } + else if (offset >= offsetof(etype, as_mapping)) { + ptr = (void *)type->tp_as_mapping; + offset -= offsetof(etype, as_mapping); + } else if (offset >= offsetof(etype, as_number)) { ptr = (void *)type->tp_as_number; *************** *** 4114,4135 **** /* This function is called by PyType_Ready() to populate the type's dictionary with method descriptors for function slots. For each ! function slot (like tp_repr) that's defined in the type, one or ! more corresponding descriptors are added in the type's tp_dict ! dictionary under the appropriate name (like __repr__). Some ! function slots cause more than one descriptor to be added (for ! example, the nb_add slot adds both __add__ and __radd__ ! descriptors) and some function slots compete for the same ! descriptor (for example both sq_item and mp_subscript generate a ! __getitem__ descriptor). This only adds new descriptors and ! doesn't overwrite entries in tp_dict that were previously ! defined. The descriptors contain a reference to the C function ! they must call, so that it's safe if they are copied into a ! subtype's __dict__ and the subtype has a different C function in ! its slot -- calling the method defined by the descriptor will call ! the C function that was used to create it, rather than the C ! function present in the slot when it is called. (This is important ! because a subtype may have a C function in the slot that calls the ! method from the dictionary, and we want to avoid infinite recursion ! here.) */ static int --- 4121,4150 ---- /* This function is called by PyType_Ready() to populate the type's dictionary with method descriptors for function slots. For each ! function slot (like tp_repr) that's defined in the type, one or more ! corresponding descriptors are added in the type's tp_dict dictionary ! under the appropriate name (like __repr__). Some function slots ! cause more than one descriptor to be added (for example, the nb_add ! slot adds both __add__ and __radd__ descriptors) and some function ! slots compete for the same descriptor (for example both sq_item and ! mp_subscript generate a __getitem__ descriptor). ! ! In the latter case, the first slotdef entry encoutered wins. Since ! slotdef entries are sorted by the offset of the slot in the etype ! struct, this gives us some control over disambiguating between ! competing slots: the members of struct etype are listed from most ! general to least general, so the most general slot is preferred. In ! particular, because as_mapping comes before as_sequence, for a type ! that defines both mp_subscript and sq_item, mp_subscript wins. ! ! This only adds new descriptors and doesn't overwrite entries in ! tp_dict that were previously defined. The descriptors contain a ! reference to the C function they must call, so that it's safe if they ! are copied into a subtype's __dict__ and the subtype has a different ! C function in its slot -- calling the method defined by the ! descriptor will call the C function that was used to create it, ! rather than the C function present in the slot when it is called. ! (This is important because a subtype may have a C function in the ! slot that calls the method from the dictionary, and we want to avoid ! infinite recursion here.) */ static int From gvanrossum@users.sourceforge.net Thu Jun 13 20:18:07 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 13 Jun 2002 12:18:07 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_descr.py,1.139,1.140 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv11967/Lib/test Modified Files: test_descr.py Log Message: Hopefully this addresses the remaining issues of SF bugs 459235 and 473985. Through a subtle rearrangement of some members in the etype struct (!), mapping methods are now preferred over sequence methods, which is necessary to support str.__getitem__("hello", slice(4)) etc. Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.139 retrieving revision 1.140 diff -C2 -d -r1.139 -r1.140 *** test_descr.py 6 Jun 2002 17:53:03 -0000 1.139 --- test_descr.py 13 Jun 2002 19:17:46 -0000 1.140 *************** *** 3100,3103 **** --- 3100,3148 ---- vereq(b.getfoo(), 24) + def slices(): + if verbose: + print "Testing cases with slices and overridden __getitem__ ..." + # Strings + vereq("hello"[:4], "hell") + vereq("hello"[slice(4)], "hell") + vereq(str.__getitem__("hello", slice(4)), "hell") + class S(str): + def __getitem__(self, x): + return str.__getitem__(self, x) + vereq(S("hello")[:4], "hell") + vereq(S("hello")[slice(4)], "hell") + vereq(S("hello").__getitem__(slice(4)), "hell") + # Tuples + vereq((1,2,3)[:2], (1,2)) + vereq((1,2,3)[slice(2)], (1,2)) + vereq(tuple.__getitem__((1,2,3), slice(2)), (1,2)) + class T(tuple): + def __getitem__(self, x): + return tuple.__getitem__(self, x) + vereq(T((1,2,3))[:2], (1,2)) + vereq(T((1,2,3))[slice(2)], (1,2)) + vereq(T((1,2,3)).__getitem__(slice(2)), (1,2)) + # Lists + vereq([1,2,3][:2], [1,2]) + vereq([1,2,3][slice(2)], [1,2]) + vereq(list.__getitem__([1,2,3], slice(2)), [1,2]) + class L(list): + def __getitem__(self, x): + return list.__getitem__(self, x) + vereq(L([1,2,3])[:2], [1,2]) + vereq(L([1,2,3])[slice(2)], [1,2]) + vereq(L([1,2,3]).__getitem__(slice(2)), [1,2]) + # Now do lists and __setitem__ + a = L([1,2,3]) + a[slice(1, 3)] = [3,2] + vereq(a, [1,3,2]) + a[slice(0, 2, 1)] = [3,1] + vereq(a, [3,1,2]) + a.__setitem__(slice(1, 3), [2,1]) + vereq(a, [3,2,1]) + a.__setitem__(slice(0, 2, 1), [2,3]) + vereq(a, [2,3,1]) + + def do_this_first(): if verbose: *************** *** 3183,3186 **** --- 3228,3232 ---- string_exceptions() copy_setstate() + slices() if verbose: print "All OK" From gvanrossum@users.sourceforge.net Thu Jun 13 21:24:20 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 13 Jun 2002 13:24:20 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_socket.py,1.36,1.37 test_timeout.py,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv11007 Modified Files: test_socket.py test_timeout.py Log Message: Temporarily disable the timeout and socket tests. They still run as standalone scripts, but when used as part of the regression test suite, they are effectively no-ops. (This is done by renaming test_main to main.) Index: test_socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** test_socket.py 13 Jun 2002 16:54:38 -0000 1.36 --- test_socket.py 13 Jun 2002 20:24:17 -0000 1.37 *************** *** 208,221 **** pass ! ## def testHostnameRes(self): ! ## """Testing hostname resolution mechanisms.""" ! ## hostname = socket.gethostname() ! ## ip = socket.gethostbyname(hostname) ! ## self.assert_(ip.find('.') >= 0, "Error resolving host to ip.") ! ## hname, aliases, ipaddrs = socket.gethostbyaddr(ip) ! ## all_host_names = [hname] + aliases ! ## fqhn = socket.getfqdn() ! ## if not fqhn in all_host_names: ! ## self.fail("Error testing host resolution mechanisms.") def testRefCountGetNameInfo(self): --- 208,221 ---- pass ! def testHostnameRes(self): ! """Testing hostname resolution mechanisms.""" ! hostname = socket.gethostname() ! ip = socket.gethostbyname(hostname) ! self.assert_(ip.find('.') >= 0, "Error resolving host to ip.") ! hname, aliases, ipaddrs = socket.gethostbyaddr(ip) ! all_host_names = [hname] + aliases ! fqhn = socket.getfqdn() ! if not fqhn in all_host_names: ! self.fail("Error testing host resolution mechanisms.") def testRefCountGetNameInfo(self): *************** *** 499,503 **** self.cli_file.flush() ! def test_main(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(GeneralModuleTests)) --- 499,503 ---- self.cli_file.flush() ! def main(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(GeneralModuleTests)) *************** *** 509,511 **** if __name__ == "__main__": ! test_main() --- 509,511 ---- if __name__ == "__main__": ! main() Index: test_timeout.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_timeout.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_timeout.py 13 Jun 2002 15:07:44 -0000 1.5 --- test_timeout.py 13 Jun 2002 20:24:17 -0000 1.6 *************** *** 176,180 **** ! def test_main(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(CreationTestCase)) --- 176,180 ---- ! def main(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(CreationTestCase)) *************** *** 183,185 **** if __name__ == "__main__": ! test_main() --- 183,185 ---- if __name__ == "__main__": ! main() From loewis@users.sourceforge.net Thu Jun 13 21:33:04 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu, 13 Jun 2002 13:33:04 -0700 Subject: [Python-checkins] python/dist/src/RISCOS/Modules riscosmodule.c,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/RISCOS/Modules In directory usw-pr-cvs1:/tmp/cvs-serv14210/RISCOS/Modules Modified Files: riscosmodule.c Log Message: Patch #568124: Add doc string macros. Index: riscosmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/RISCOS/Modules/riscosmodule.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** riscosmodule.c 8 Dec 2001 18:02:58 -0000 1.5 --- riscosmodule.c 13 Jun 2002 20:33:02 -0000 1.6 *************** *** 121,125 **** } ! static char stat_result__doc__[] = "stat_result: Result from stat or lstat.\n\n\ This object may be accessed either as a tuple of\n\ --- 121,125 ---- } ! PyDoc_STRVAR(stat_result__doc__, "stat_result: Result from stat or lstat.\n\n\ This object may be accessed either as a tuple of\n\ *************** *** 129,133 **** RiscOS: The fields st_ftype, st_attrs, and st_obtype are also available.\n\ \n\ ! See os.stat for more information.\n"; static PyStructSequence_Field stat_result_fields[] = { --- 129,133 ---- RiscOS: The fields st_ftype, st_attrs, and st_obtype are also available.\n\ \n\ ! See os.stat for more information."); static PyStructSequence_Field stat_result_fields[] = { From loewis@users.sourceforge.net Thu Jun 13 21:33:04 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu, 13 Jun 2002 13:33:04 -0700 Subject: [Python-checkins] python/dist/src/Python bltinmodule.c,2.258,2.259 exceptions.c,1.31,1.32 import.c,2.204,2.205 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv14210/Python Modified Files: bltinmodule.c exceptions.c import.c Log Message: Patch #568124: Add doc string macros. Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.258 retrieving revision 2.259 diff -C2 -d -r2.258 -r2.259 *** bltinmodule.c 5 Jun 2002 23:12:45 -0000 2.258 --- bltinmodule.c 13 Jun 2002 20:33:02 -0000 2.259 *************** *** 41,45 **** } ! static char import_doc[] = "__import__(name, globals, locals, fromlist) -> module\n\ \n\ --- 41,45 ---- } ! PyDoc_STRVAR(import_doc, "__import__(name, globals, locals, fromlist) -> module\n\ [...976 lines suppressed...] *************** *** 1823,1830 **** }; ! static char builtin_doc[] = "Built-in functions, exceptions, and other objects.\n\ \n\ ! Noteworthy: None is the `nil' object; Ellipsis represents `...' in slices."; PyObject * --- 1823,1830 ---- }; ! PyDoc_STRVAR(builtin_doc, "Built-in functions, exceptions, and other objects.\n\ \n\ ! Noteworthy: None is the `nil' object; Ellipsis represents `...' in slices."); PyObject * Index: exceptions.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/exceptions.c,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** exceptions.c 29 May 2002 15:54:54 -0000 1.31 --- exceptions.c 13 Jun 2002 20:33:02 -0000 1.32 *************** *** 31,36 **** */ ! static char ! module__doc__[] = "Python's standard exception class hierarchy.\n\ \n\ --- 31,35 ---- */ ! PyDoc_STRVAR(module__doc__, "Python's standard exception class hierarchy.\n\ \n\ *************** *** 114,118 **** +-- SyntaxWarning\n\ +-- OverflowWarning\n\ ! +-- RuntimeWarning"; --- 113,118 ---- +-- SyntaxWarning\n\ +-- OverflowWarning\n\ ! +-- RuntimeWarning" ! ); *************** *** 231,236 **** */ ! static char ! Exception__doc__[] = "Common base class for all exceptions."; --- 231,235 ---- */ ! PyDoc_STRVAR(Exception__doc__, "Common base class for all exceptions."); *************** *** 373,389 **** ! static char ! StandardError__doc__[] = "Base class for all standard Python exceptions."; ! static char ! TypeError__doc__[] = "Inappropriate argument type."; ! static char ! StopIteration__doc__[] = "Signal the end from iterator.next()."; ! static char ! SystemExit__doc__[] = "Request to exit from the interpreter."; --- 372,385 ---- ! PyDoc_STRVAR(StandardError__doc__, ! "Base class for all standard Python exceptions."); ! PyDoc_STRVAR(TypeError__doc__, "Inappropriate argument type."); ! PyDoc_STRVAR(StopIteration__doc__, "Signal the end from iterator.next()."); ! PyDoc_STRVAR(SystemExit__doc__, "Request to exit from the interpreter."); *************** *** 440,454 **** ! static char ! KeyboardInterrupt__doc__[] = "Program interrupted by user."; ! static char ! ImportError__doc__[] = ! "Import can't find module, or can't find name in module."; ! static char ! EnvironmentError__doc__[] = "Base class for I/O related errors."; --- 436,447 ---- ! PyDoc_STRVAR(KeyboardInterrupt__doc__, "Program interrupted by user."); ! PyDoc_STRVAR(ImportError__doc__, ! "Import can't find module, or can't find name in module."); ! PyDoc_STRVAR(EnvironmentError__doc__, "Base class for I/O related errors."); *************** *** 628,666 **** ! static char ! IOError__doc__[] = "I/O operation failed."; ! static char ! OSError__doc__[] = "OS system call failed."; #ifdef MS_WINDOWS ! static char ! WindowsError__doc__[] = "MS-Windows OS system call failed."; #endif /* MS_WINDOWS */ ! static char ! EOFError__doc__[] = "Read beyond end of file."; ! static char ! RuntimeError__doc__[] = "Unspecified run-time error."; ! static char ! NotImplementedError__doc__[] = ! "Method or function hasn't been implemented yet."; ! static char ! NameError__doc__[] = "Name not found globally."; ! static char ! UnboundLocalError__doc__[] = ! "Local name referenced but not bound to a value."; ! static char ! AttributeError__doc__[] = "Attribute not found."; ! static char ! SyntaxError__doc__[] = "Invalid syntax."; --- 621,649 ---- ! PyDoc_STRVAR(IOError__doc__, "I/O operation failed."); ! PyDoc_STRVAR(OSError__doc__, "OS system call failed."); #ifdef MS_WINDOWS ! PyDoc_STRVAR(WindowsError__doc__, "MS-Windows OS system call failed."); #endif /* MS_WINDOWS */ ! PyDoc_STRVAR(EOFError__doc__, "Read beyond end of file."); ! PyDoc_STRVAR(RuntimeError__doc__, "Unspecified run-time error."); ! PyDoc_STRVAR(NotImplementedError__doc__, ! "Method or function hasn't been implemented yet."); ! PyDoc_STRVAR(NameError__doc__, "Name not found globally."); ! PyDoc_STRVAR(UnboundLocalError__doc__, ! "Local name referenced but not bound to a value."); ! PyDoc_STRVAR(AttributeError__doc__, "Attribute not found."); ! PyDoc_STRVAR(SyntaxError__doc__, "Invalid syntax."); *************** *** 860,938 **** /* Exception doc strings */ ! static char ! AssertionError__doc__[] = "Assertion failed."; ! static char ! LookupError__doc__[] = "Base class for lookup errors."; ! static char ! IndexError__doc__[] = "Sequence index out of range."; ! static char ! KeyError__doc__[] = "Mapping key not found."; ! static char ! ArithmeticError__doc__[] = "Base class for arithmetic errors."; ! static char ! OverflowError__doc__[] = "Result too large to be represented."; ! static char ! ZeroDivisionError__doc__[] = ! "Second argument to a division or modulo operation was zero."; ! static char ! FloatingPointError__doc__[] = "Floating point operation failed."; ! static char ! ValueError__doc__[] = "Inappropriate argument value (of correct type)."; ! static char ! UnicodeError__doc__[] = "Unicode related error."; ! static char ! SystemError__doc__[] = "Internal error in the Python interpreter.\n\ \n\ Please report this to the Python maintainer, along with the traceback,\n\ ! the Python version, and the hardware/OS platform and version."; ! static char ! ReferenceError__doc__[] = "Weak ref proxy used after referent went away."; ! static char ! MemoryError__doc__[] = "Out of memory."; ! static char ! IndentationError__doc__[] = "Improper indentation."; ! static char ! TabError__doc__[] = "Improper mixture of spaces and tabs."; /* Warning category docstrings */ ! static char ! Warning__doc__[] = "Base class for warning categories."; ! static char ! UserWarning__doc__[] = "Base class for warnings generated by user code."; ! static char ! DeprecationWarning__doc__[] = ! "Base class for warnings about deprecated features."; ! static char ! PendingDeprecationWarning__doc__[] = "Base class for warnings about features which will be deprecated " ! "in the future."; ! static char ! SyntaxWarning__doc__[] = "Base class for warnings about dubious syntax."; ! static char ! OverflowWarning__doc__[] = "Base class for warnings about numeric overflow."; ! static char ! RuntimeWarning__doc__[] = ! "Base class for warnings about dubious runtime behavior."; --- 843,905 ---- /* Exception doc strings */ ! PyDoc_STRVAR(AssertionError__doc__, "Assertion failed."); ! PyDoc_STRVAR(LookupError__doc__, "Base class for lookup errors."); ! PyDoc_STRVAR(IndexError__doc__, "Sequence index out of range."); ! PyDoc_STRVAR(KeyError__doc__, "Mapping key not found."); ! PyDoc_STRVAR(ArithmeticError__doc__, "Base class for arithmetic errors."); ! PyDoc_STRVAR(OverflowError__doc__, "Result too large to be represented."); ! PyDoc_STRVAR(ZeroDivisionError__doc__, ! "Second argument to a division or modulo operation was zero."); ! PyDoc_STRVAR(FloatingPointError__doc__, "Floating point operation failed."); ! PyDoc_STRVAR(ValueError__doc__, ! "Inappropriate argument value (of correct type)."); ! PyDoc_STRVAR(UnicodeError__doc__, "Unicode related error."); ! PyDoc_STRVAR(SystemError__doc__, ! "Internal error in the Python interpreter.\n\ \n\ Please report this to the Python maintainer, along with the traceback,\n\ ! the Python version, and the hardware/OS platform and version."); ! PyDoc_STRVAR(ReferenceError__doc__, ! "Weak ref proxy used after referent went away."); ! PyDoc_STRVAR(MemoryError__doc__, "Out of memory."); ! PyDoc_STRVAR(IndentationError__doc__, "Improper indentation."); ! PyDoc_STRVAR(TabError__doc__, "Improper mixture of spaces and tabs."); /* Warning category docstrings */ ! PyDoc_STRVAR(Warning__doc__, "Base class for warning categories."); ! PyDoc_STRVAR(UserWarning__doc__, ! "Base class for warnings generated by user code."); ! PyDoc_STRVAR(DeprecationWarning__doc__, ! "Base class for warnings about deprecated features."); ! PyDoc_STRVAR(PendingDeprecationWarning__doc__, "Base class for warnings about features which will be deprecated " ! "in the future."); ! PyDoc_STRVAR(SyntaxWarning__doc__, ! "Base class for warnings about dubious syntax."); ! PyDoc_STRVAR(OverflowWarning__doc__, ! "Base class for warnings about numeric overflow."); ! PyDoc_STRVAR(RuntimeWarning__doc__, ! "Base class for warnings about dubious runtime behavior."); Index: import.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/import.c,v retrieving revision 2.204 retrieving revision 2.205 diff -C2 -d -r2.204 -r2.205 *** import.c 30 May 2002 17:33:07 -0000 2.204 --- import.c 13 Jun 2002 20:33:02 -0000 2.205 *************** *** 2456,2500 **** /* Doc strings */ ! static char doc_imp[] = "\ ! This module provides the components needed to build your own\n\ ! __import__ function. Undocumented functions are obsolete.\n\ ! "; ! static char doc_find_module[] = "\ ! find_module(name, [path]) -> (file, filename, (suffix, mode, type))\n\ Search for a module. If path is omitted or None, search for a\n\ built-in, frozen or special module and continue search in sys.path.\n\ The module name cannot contain '.'; to search for a submodule of a\n\ ! package, pass the submodule name and the package's __path__.\ ! "; ! static char doc_load_module[] = "\ ! load_module(name, file, filename, (suffix, mode, type)) -> module\n\ Load a module, given information returned by find_module().\n\ ! The module name must include the full package name, if any.\ ! "; ! static char doc_get_magic[] = "\ ! get_magic() -> string\n\ ! Return the magic number for .pyc or .pyo files.\ ! "; ! static char doc_get_suffixes[] = "\ ! get_suffixes() -> [(suffix, mode, type), ...]\n\ Return a list of (suffix, mode, type) tuples describing the files\n\ ! that find_module() looks for.\ ! "; ! static char doc_new_module[] = "\ ! new_module(name) -> module\n\ Create a new module. Do not enter it in sys.modules.\n\ ! The module name must include the full package name, if any.\ ! "; ! static char doc_lock_held[] = "\ ! lock_held() -> 0 or 1\n\ Return 1 if the import lock is currently held.\n\ ! On platforms without threads, return 0.\ ! "; static PyMethodDef imp_methods[] = { --- 2456,2493 ---- /* Doc strings */ ! PyDoc_STRVAR(doc_imp, ! "This module provides the components needed to build your own\n\ ! __import__ function. Undocumented functions are obsolete."); ! PyDoc_STRVAR(doc_find_module, ! "find_module(name, [path]) -> (file, filename, (suffix, mode, type))\n\ Search for a module. If path is omitted or None, search for a\n\ built-in, frozen or special module and continue search in sys.path.\n\ The module name cannot contain '.'; to search for a submodule of a\n\ ! package, pass the submodule name and the package's __path__."); ! PyDoc_STRVAR(doc_load_module, ! "load_module(name, file, filename, (suffix, mode, type)) -> module\n\ Load a module, given information returned by find_module().\n\ ! The module name must include the full package name, if any."); ! PyDoc_STRVAR(doc_get_magic, ! "get_magic() -> string\n\ ! Return the magic number for .pyc or .pyo files."); ! PyDoc_STRVAR(doc_get_suffixes, ! "get_suffixes() -> [(suffix, mode, type), ...]\n\ Return a list of (suffix, mode, type) tuples describing the files\n\ ! that find_module() looks for."); ! PyDoc_STRVAR(doc_new_module, ! "new_module(name) -> module\n\ Create a new module. Do not enter it in sys.modules.\n\ ! The module name must include the full package name, if any."); ! PyDoc_STRVAR(doc_lock_held, ! "lock_held() -> 0 or 1\n\ Return 1 if the import lock is currently held.\n\ ! On platforms without threads, return 0."); static PyMethodDef imp_methods[] = { From loewis@users.sourceforge.net Thu Jun 13 21:33:04 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu, 13 Jun 2002 13:33:04 -0700 Subject: [Python-checkins] python/dist/src/Objects boolobject.c,1.3,1.4 cobject.c,2.13,2.14 complexobject.c,2.61,2.62 descrobject.c,2.25,2.26 dictobject.c,2.125,2.126 enumobject.c,1.1,1.2 fileobject.c,2.162,2.163 floatobject.c,2.112,2.113 funcobject.c,2.53,2.54 intobject.c,2.83,2.84 listobject.c,2.110,2.111 longobject.c,1.117,1.118 moduleobject.c,2.44,2.45 rangeobject.c,2.40,2.41 stringobject.c,2.166,2.167 tupleobject.c,2.65,2.66 typeobject.c,2.152,2.153 unicodeobject.c,2.152,2.153 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv14210/Objects Modified Files: boolobject.c cobject.c complexobject.c descrobject.c dictobject.c enumobject.c fileobject.c floatobject.c funcobject.c intobject.c listobject.c longobject.c moduleobject.c rangeobject.c stringobject.c tupleobject.c typeobject.c unicodeobject.c Log Message: Patch #568124: Add doc string macros. Index: boolobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/boolobject.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** boolobject.c 25 Apr 2002 20:01:10 -0000 1.3 --- boolobject.c 13 Jun 2002 20:32:55 -0000 1.4 *************** *** 94,103 **** /* Doc string */ ! static char bool_doc[] = "bool(x) -> bool\n\ \n\ Returns True when the argument x is true, False otherwise.\n\ The builtins True and False are the only two instances of the class bool.\n\ ! The class bool is a subclass of the class int, and cannot be subclassed."; /* Arithmetic methods -- only so we can override &, |, ^. */ --- 94,103 ---- /* Doc string */ ! PyDoc_STRVAR(bool_doc, "bool(x) -> bool\n\ \n\ Returns True when the argument x is true, False otherwise.\n\ The builtins True and False are the only two instances of the class bool.\n\ ! The class bool is a subclass of the class int, and cannot be subclassed."); /* Arithmetic methods -- only so we can override &, |, ^. */ Index: cobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/cobject.c,v retrieving revision 2.13 retrieving revision 2.14 diff -C2 -d -r2.13 -r2.14 *** cobject.c 1 Sep 2000 23:29:27 -0000 2.13 --- cobject.c 13 Jun 2002 20:32:56 -0000 2.14 *************** *** 113,117 **** ! static char PyCObject_Type__doc__[] = "C objects to be exported from one extension module to another\n\ \n\ --- 113,117 ---- ! PyDoc_STRVAR(PyCObject_Type__doc__, "C objects to be exported from one extension module to another\n\ \n\ *************** *** 119,123 **** provide a way for an extension module to export a C interface to other\n\ extension modules, so that extension modules can use the Python import\n\ ! mechanism to link to one another."; PyTypeObject PyCObject_Type = { --- 119,123 ---- provide a way for an extension module to export a C interface to other\n\ extension modules, so that extension modules can use the Python import\n\ ! mechanism to link to one another."); PyTypeObject PyCObject_Type = { Index: complexobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/complexobject.c,v retrieving revision 2.61 retrieving revision 2.62 diff -C2 -d -r2.61 -r2.62 *** complexobject.c 13 Jun 2002 17:07:07 -0000 2.61 --- complexobject.c 13 Jun 2002 20:32:56 -0000 2.62 *************** *** 913,921 **** } ! static char complex_doc[] = "complex(real[, imag]) -> complex number\n" "\n" "Create a complex number from a real part and an optional imaginary part.\n" ! "This is equivalent to (real + imag*1j) where imag defaults to 0."; static PyNumberMethods complex_as_number = { --- 913,921 ---- } ! PyDoc_STRVAR(complex_doc, "complex(real[, imag]) -> complex number\n" "\n" "Create a complex number from a real part and an optional imaginary part.\n" ! "This is equivalent to (real + imag*1j) where imag defaults to 0."); static PyNumberMethods complex_as_number = { Index: descrobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/descrobject.c,v retrieving revision 2.25 retrieving revision 2.26 diff -C2 -d -r2.25 -r2.26 *** descrobject.c 13 Apr 2002 14:06:36 -0000 2.25 --- descrobject.c 13 Jun 2002 20:32:56 -0000 2.26 *************** *** 1063,1067 **** } ! static char property_doc[] = "property(fget=None, fset=None, fdel=None, doc=None) -> property attribute\n" "\n" --- 1063,1067 ---- } ! PyDoc_STRVAR(property_doc, "property(fget=None, fset=None, fdel=None, doc=None) -> property attribute\n" "\n" *************** *** 1073,1077 **** " def setx(self, value): self.__x = value\n" " def delx(self): del self.__x\n" ! " x = property(getx, setx, delx, \"I'm the 'x' property.\")"; static int --- 1073,1077 ---- " def setx(self, value): self.__x = value\n" " def delx(self): del self.__x\n" ! " x = property(getx, setx, delx, \"I'm the 'x' property.\")"); static int Index: dictobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/dictobject.c,v retrieving revision 2.125 retrieving revision 2.126 diff -C2 -d -r2.125 -r2.126 *** dictobject.c 12 Apr 2002 15:11:58 -0000 2.125 --- dictobject.c 13 Jun 2002 20:32:57 -0000 2.126 *************** *** 1661,1706 **** ! static char has_key__doc__[] = ! "D.has_key(k) -> 1 if D has a key k, else 0"; ! static char get__doc__[] = ! "D.get(k[,d]) -> D[k] if D.has_key(k), else d. d defaults to None."; ! static char setdefault_doc__[] = ! "D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if not D.has_key(k)"; ! static char pop__doc__[] = ! "D.pop(k) -> v, remove specified key and return the corresponding value"; ! static char popitem__doc__[] = "D.popitem() -> (k, v), remove and return some (key, value) pair as a\n\ ! 2-tuple; but raise KeyError if D is empty"; ! static char keys__doc__[] = ! "D.keys() -> list of D's keys"; ! static char items__doc__[] = ! "D.items() -> list of D's (key, value) pairs, as 2-tuples"; ! static char values__doc__[] = ! "D.values() -> list of D's values"; ! static char update__doc__[] = ! "D.update(E) -> None. Update D from E: for k in E.keys(): D[k] = E[k]"; ! static char clear__doc__[] = ! "D.clear() -> None. Remove all items from D."; ! static char copy__doc__[] = ! "D.copy() -> a shallow copy of D"; ! static char iterkeys__doc__[] = ! "D.iterkeys() -> an iterator over the keys of D"; ! static char itervalues__doc__[] = ! "D.itervalues() -> an iterator over the values of D"; ! static char iteritems__doc__[] = ! "D.iteritems() -> an iterator over the (key, value) items of D"; static PyMethodDef mapp_methods[] = { --- 1661,1706 ---- ! PyDoc_STRVAR(has_key__doc__, ! "D.has_key(k) -> 1 if D has a key k, else 0"); ! PyDoc_STRVAR(get__doc__, ! "D.get(k[,d]) -> D[k] if D.has_key(k), else d. d defaults to None."); ! PyDoc_STRVAR(setdefault_doc__, ! "D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if not D.has_key(k)"); ! PyDoc_STRVAR(pop__doc__, ! "D.pop(k) -> v, remove specified key and return the corresponding value"); ! PyDoc_STRVAR(popitem__doc__, "D.popitem() -> (k, v), remove and return some (key, value) pair as a\n\ ! 2-tuple; but raise KeyError if D is empty"); ! PyDoc_STRVAR(keys__doc__, ! "D.keys() -> list of D's keys"); ! PyDoc_STRVAR(items__doc__, ! "D.items() -> list of D's (key, value) pairs, as 2-tuples"); ! PyDoc_STRVAR(values__doc__, ! "D.values() -> list of D's values"); ! PyDoc_STRVAR(update__doc__, ! "D.update(E) -> None. Update D from E: for k in E.keys(): D[k] = E[k]"); ! PyDoc_STRVAR(clear__doc__, ! "D.clear() -> None. Remove all items from D."); ! PyDoc_STRVAR(copy__doc__, ! "D.copy() -> a shallow copy of D"); ! PyDoc_STRVAR(iterkeys__doc__, ! "D.iterkeys() -> an iterator over the keys of D"); ! PyDoc_STRVAR(itervalues__doc__, ! "D.itervalues() -> an iterator over the values of D"); ! PyDoc_STRVAR(iteritems__doc__, ! "D.iteritems() -> an iterator over the (key, value) items of D"); static PyMethodDef mapp_methods[] = { *************** *** 1817,1821 **** } ! static char dictionary_doc[] = "dict() -> new empty dictionary.\n" "dict(mapping) -> new dictionary initialized from a mapping object's\n" --- 1817,1821 ---- } ! PyDoc_STRVAR(dictionary_doc, "dict() -> new empty dictionary.\n" "dict(mapping) -> new dictionary initialized from a mapping object's\n" *************** *** 1824,1828 **** " d = {}\n" " for k, v in seq:\n" ! " d[k] = v"; PyTypeObject PyDict_Type = { --- 1824,1828 ---- " d = {}\n" " for k, v in seq:\n" ! " d[k] = v"); PyTypeObject PyDict_Type = { Index: enumobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/enumobject.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** enumobject.c 26 Apr 2002 19:40:54 -0000 1.1 --- enumobject.c 13 Jun 2002 20:32:59 -0000 1.2 *************** *** 91,96 **** }; ! static char enum_doc[] = ! "enumerate(iterable) -> create an enumerating-iterator"; PyTypeObject PyEnum_Type = { --- 91,96 ---- }; ! PyDoc_STRVAR(enum_doc, ! "enumerate(iterable) -> create an enumerating-iterator"); PyTypeObject PyEnum_Type = { Index: fileobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/fileobject.c,v retrieving revision 2.162 retrieving revision 2.163 diff -C2 -d -r2.162 -r2.163 *** fileobject.c 22 May 2002 20:37:53 -0000 2.162 --- fileobject.c 13 Jun 2002 20:32:59 -0000 2.163 *************** *** 1463,1490 **** } ! static char readline_doc[] = "readline([size]) -> next line from the file, as a string.\n" "\n" "Retain newline. A non-negative size argument limits the maximum\n" "number of bytes to return (an incomplete line may be returned then).\n" ! "Return an empty string at EOF."; ! static char read_doc[] = "read([size]) -> read at most size bytes, returned as a string.\n" "\n" ! "If the size argument is negative or omitted, read until EOF is reached."; ! static char write_doc[] = "write(str) -> None. Write string str to file.\n" "\n" "Note that due to buffering, flush() or close() may be needed before\n" ! "the file on disk reflects the data written."; ! static char fileno_doc[] = "fileno() -> integer \"file descriptor\".\n" "\n" ! "This is needed for lower-level file interfaces, such os.read()."; ! static char seek_doc[] = "seek(offset[, whence]) -> None. Move to new file position.\n" "\n" --- 1463,1490 ---- } ! PyDoc_STRVAR(readline_doc, "readline([size]) -> next line from the file, as a string.\n" "\n" "Retain newline. A non-negative size argument limits the maximum\n" "number of bytes to return (an incomplete line may be returned then).\n" ! "Return an empty string at EOF."); ! PyDoc_STRVAR(read_doc, "read([size]) -> read at most size bytes, returned as a string.\n" "\n" ! "If the size argument is negative or omitted, read until EOF is reached."); ! PyDoc_STRVAR(write_doc, "write(str) -> None. Write string str to file.\n" "\n" "Note that due to buffering, flush() or close() may be needed before\n" ! "the file on disk reflects the data written."); ! PyDoc_STRVAR(fileno_doc, "fileno() -> integer \"file descriptor\".\n" "\n" ! "This is needed for lower-level file interfaces, such os.read()."); ! PyDoc_STRVAR(seek_doc, "seek(offset[, whence]) -> None. Move to new file position.\n" "\n" *************** *** 1495,1536 **** "seeking beyond the end of a file).\n" "\n" ! "Note that not all file objects are seekable."; #ifdef HAVE_FTRUNCATE ! static char truncate_doc[] = "truncate([size]) -> None. Truncate the file to at most size bytes.\n" "\n" ! "Size defaults to the current file position, as returned by tell()."; #endif ! static char tell_doc[] = ! "tell() -> current file position, an integer (may be a long integer)."; ! static char readinto_doc[] = ! "readinto() -> Undocumented. Don't use this; it may go away."; ! static char readlines_doc[] = "readlines([size]) -> list of strings, each a line from the file.\n" "\n" "Call readline() repeatedly and return a list of the lines so read.\n" "The optional size argument, if given, is an approximate bound on the\n" ! "total number of bytes in the lines returned."; ! static char xreadlines_doc[] = "xreadlines() -> next line from the file, as a string.\n" "\n" "Equivalent to xreadlines.xreadlines(file). This is like readline(), but\n" ! "often quicker, due to reading ahead internally."; ! static char writelines_doc[] = "writelines(sequence_of_strings) -> None. Write the strings to the file.\n" "\n" "Note that newlines are not added. The sequence can be any iterable object\n" ! "producing strings. This is equivalent to calling write() for each string."; ! static char flush_doc[] = ! "flush() -> None. Flush the internal I/O buffer."; ! static char close_doc[] = "close() -> None or (perhaps) an integer. Close the file.\n" "\n" --- 1495,1536 ---- "seeking beyond the end of a file).\n" "\n" ! "Note that not all file objects are seekable."); #ifdef HAVE_FTRUNCATE ! PyDoc_STRVAR(truncate_doc, "truncate([size]) -> None. Truncate the file to at most size bytes.\n" "\n" ! "Size defaults to the current file position, as returned by tell()."); #endif ! PyDoc_STRVAR(tell_doc, ! "tell() -> current file position, an integer (may be a long integer)."); ! PyDoc_STRVAR(readinto_doc, ! "readinto() -> Undocumented. Don't use this; it may go away."); ! PyDoc_STRVAR(readlines_doc, "readlines([size]) -> list of strings, each a line from the file.\n" "\n" "Call readline() repeatedly and return a list of the lines so read.\n" "The optional size argument, if given, is an approximate bound on the\n" ! "total number of bytes in the lines returned."); ! PyDoc_STRVAR(xreadlines_doc, "xreadlines() -> next line from the file, as a string.\n" "\n" "Equivalent to xreadlines.xreadlines(file). This is like readline(), but\n" ! "often quicker, due to reading ahead internally."); ! PyDoc_STRVAR(writelines_doc, "writelines(sequence_of_strings) -> None. Write the strings to the file.\n" "\n" "Note that newlines are not added. The sequence can be any iterable object\n" ! "producing strings. This is equivalent to calling write() for each string."); ! PyDoc_STRVAR(flush_doc, ! "flush() -> None. Flush the internal I/O buffer."); ! PyDoc_STRVAR(close_doc, "close() -> None or (perhaps) an integer. Close the file.\n" "\n" *************** *** 1538,1545 **** "further I/O operations. close() may be called more than once without\n" "error. Some kinds of file objects (for example, opened by popen())\n" ! "may return an exit status upon closing."; ! static char isatty_doc[] = ! "isatty() -> true or false. True if the file is connected to a tty device."; static PyMethodDef file_methods[] = { --- 1538,1545 ---- "further I/O operations. close() may be called more than once without\n" "error. Some kinds of file objects (for example, opened by popen())\n" ! "may return an exit status upon closing."); ! PyDoc_STRVAR(isatty_doc, ! "isatty() -> true or false. True if the file is connected to a tty device."); static PyMethodDef file_methods[] = { *************** *** 1688,1692 **** } ! static char file_doc[] = "file(name[, mode[, buffering]]) -> file object\n" "\n" --- 1688,1693 ---- } ! PyDoc_VAR(file_doc) = ! PyDoc_STR( "file(name[, mode[, buffering]]) -> file object\n" "\n" *************** *** 1698,1702 **** --- 1699,1705 ---- "If the buffering argument is given, 0 means unbuffered, 1 means line\n" "buffered, and larger numbers specify the buffer size.\n" + ) #ifdef WITH_UNIVERSAL_NEWLINES + PyDoc_STR( "Add a 'U' to mode to open the file for input with universal newline\n" "support. Any line ending in the input file will be seen as a '\\n'\n" *************** *** 1706,1712 **** "\n" "'U' cannot be combined with 'w' or '+' mode.\n" #endif /* WITH_UNIVERSAL_NEWLINES */ "\n" ! "Note: open() is an alias for file().\n"; PyTypeObject PyFile_Type = { --- 1709,1718 ---- "\n" "'U' cannot be combined with 'w' or '+' mode.\n" + ) #endif /* WITH_UNIVERSAL_NEWLINES */ + PyDoc_STR( "\n" ! "Note: open() is an alias for file()." ! ); PyTypeObject PyFile_Type = { Index: floatobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/floatobject.c,v retrieving revision 2.112 retrieving revision 2.113 diff -C2 -d -r2.112 -r2.113 *** floatobject.c 2 May 2002 13:03:22 -0000 2.112 --- floatobject.c 13 Jun 2002 20:33:00 -0000 2.113 *************** *** 720,727 **** } ! static char float_doc[] = "float(x) -> floating point number\n\ \n\ ! Convert a string or number to a floating point number, if possible."; --- 720,727 ---- } ! PyDoc_STRVAR(float_doc, "float(x) -> floating point number\n\ \n\ ! Convert a string or number to a floating point number, if possible."); Index: funcobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/funcobject.c,v retrieving revision 2.53 retrieving revision 2.54 diff -C2 -d -r2.53 -r2.54 *** funcobject.c 12 Apr 2002 02:43:44 -0000 2.53 --- funcobject.c 13 Jun 2002 20:33:00 -0000 2.54 *************** *** 494,498 **** } ! static char classmethod_doc[] = "classmethod(function) -> method\n\ \n\ --- 494,498 ---- } ! PyDoc_STRVAR(classmethod_doc, "classmethod(function) -> method\n\ \n\ *************** *** 513,517 **** \n\ Class methods are different than C++ or Java static methods.\n\ ! If you want those, see the staticmethod builtin."; PyTypeObject PyClassMethod_Type = { --- 513,517 ---- \n\ Class methods are different than C++ or Java static methods.\n\ ! If you want those, see the staticmethod builtin."); PyTypeObject PyClassMethod_Type = { *************** *** 626,630 **** } ! static char staticmethod_doc[] = "staticmethod(function) -> method\n\ \n\ --- 626,630 ---- } ! PyDoc_STRVAR(staticmethod_doc, "staticmethod(function) -> method\n\ \n\ *************** *** 642,646 **** \n\ Static methods in Python are similar to those found in Java or C++.\n\ ! For a more advanced concept, see the classmethod builtin."; PyTypeObject PyStaticMethod_Type = { --- 642,646 ---- \n\ Static methods in Python are similar to those found in Java or C++.\n\ ! For a more advanced concept, see the classmethod builtin."); PyTypeObject PyStaticMethod_Type = { Index: intobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/intobject.c,v retrieving revision 2.83 retrieving revision 2.84 diff -C2 -d -r2.83 -r2.84 *** intobject.c 28 Apr 2002 16:57:34 -0000 2.83 --- intobject.c 13 Jun 2002 20:33:00 -0000 2.84 *************** *** 831,835 **** } ! static char int_doc[] = "int(x[, base]) -> integer\n\ \n\ --- 831,835 ---- } ! PyDoc_STRVAR(int_doc, "int(x[, base]) -> integer\n\ \n\ *************** *** 838,842 **** representation of a floating point number!) When converting a string, use\n\ the optional base. It is an error to supply a base when converting a\n\ ! non-string."; static PyNumberMethods int_as_number = { --- 838,842 ---- representation of a floating point number!) When converting a string, use\n\ the optional base. It is an error to supply a base when converting a\n\ ! non-string."); static PyNumberMethods int_as_number = { Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.110 retrieving revision 2.111 diff -C2 -d -r2.110 -r2.111 *** listobject.c 11 Jun 2002 12:22:28 -0000 2.110 --- listobject.c 13 Jun 2002 20:33:00 -0000 2.111 *************** *** 1634,1655 **** } ! static char append_doc[] = ! "L.append(object) -- append object to end"; ! static char extend_doc[] = ! "L.extend(list) -- extend list by appending list elements"; ! static char insert_doc[] = ! "L.insert(index, object) -- insert object before index"; ! static char pop_doc[] = ! "L.pop([index]) -> item -- remove and return item at index (default last)"; ! static char remove_doc[] = ! "L.remove(value) -- remove first occurrence of value"; ! static char index_doc[] = ! "L.index(value) -> integer -- return index of first occurrence of value"; ! static char count_doc[] = ! "L.count(value) -> integer -- return number of occurrences of value"; ! static char reverse_doc[] = ! "L.reverse() -- reverse *IN PLACE*"; ! static char sort_doc[] = ! "L.sort([cmpfunc]) -- sort *IN PLACE*; if given, cmpfunc(x, y) -> -1, 0, 1"; static PyMethodDef list_methods[] = { --- 1634,1655 ---- } ! PyDoc_STRVAR(append_doc, ! "L.append(object) -- append object to end"); ! PyDoc_STRVAR(extend_doc, ! "L.extend(list) -- extend list by appending list elements"); ! PyDoc_STRVAR(insert_doc, ! "L.insert(index, object) -- insert object before index"); ! PyDoc_STRVAR(pop_doc, ! "L.pop([index]) -> item -- remove and return item at index (default last)"); ! PyDoc_STRVAR(remove_doc, ! "L.remove(value) -- remove first occurrence of value"); ! PyDoc_STRVAR(index_doc, ! "L.index(value) -> integer -- return index of first occurrence of value"); ! PyDoc_STRVAR(count_doc, ! "L.count(value) -> integer -- return number of occurrences of value"); ! PyDoc_STRVAR(reverse_doc, ! "L.reverse() -- reverse *IN PLACE*"); ! PyDoc_STRVAR(sort_doc, ! "L.sort([cmpfunc]) -- sort *IN PLACE*; if given, cmpfunc(x, y) -> -1, 0, 1"); static PyMethodDef list_methods[] = { Index: longobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/longobject.c,v retrieving revision 1.117 retrieving revision 1.118 diff -C2 -d -r1.117 -r1.118 *** longobject.c 23 Apr 2002 20:01:20 -0000 1.117 --- longobject.c 13 Jun 2002 20:33:01 -0000 1.118 *************** *** 2262,2266 **** } ! static char long_doc[] = "long(x[, base]) -> integer\n\ \n\ --- 2262,2266 ---- } ! PyDoc_STRVAR(long_doc, "long(x[, base]) -> integer\n\ \n\ *************** *** 2269,2273 **** string representation of a floating point number!) When converting a\n\ string, use the optional base. It is an error to supply a base when\n\ ! converting a non-string."; static PyNumberMethods long_as_number = { --- 2269,2273 ---- string representation of a floating point number!) When converting a\n\ string, use the optional base. It is an error to supply a base when\n\ ! converting a non-string."); static PyNumberMethods long_as_number = { Index: moduleobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/moduleobject.c,v retrieving revision 2.44 retrieving revision 2.45 diff -C2 -d -r2.44 -r2.45 *** moduleobject.c 4 Jun 2002 06:02:35 -0000 2.44 --- moduleobject.c 13 Jun 2002 20:33:01 -0000 2.45 *************** *** 210,218 **** } ! static char module_doc[] = "module(name[, doc])\n\ \n\ Create a module object.\n\ ! The name must be a string; the optional doc argument can have any type."; PyTypeObject PyModule_Type = { --- 210,218 ---- } ! PyDoc_STRVAR(module_doc, "module(name[, doc])\n\ \n\ Create a module object.\n\ ! The name must be a string; the optional doc argument can have any type."); PyTypeObject PyModule_Type = { Index: rangeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/rangeobject.c,v retrieving revision 2.40 retrieving revision 2.41 diff -C2 -d -r2.40 -r2.41 *** rangeobject.c 6 Jun 2002 14:58:21 -0000 2.40 --- rangeobject.c 13 Jun 2002 20:33:01 -0000 2.41 *************** *** 111,120 **** } ! static char range_doc[] = "xrange([start,] stop[, step]) -> xrange object\n\ \n\ Like range(), but instead of returning a list, returns an object that\n\ generates the numbers in the range on demand. This is slightly slower\n\ ! than range() but more memory efficient."; static PyObject * --- 111,120 ---- } ! PyDoc_STRVAR(range_doc, "xrange([start,] stop[, step]) -> xrange object\n\ \n\ Like range(), but instead of returning a list, returns an object that\n\ generates the numbers in the range on demand. This is slightly slower\n\ ! than range() but more memory efficient."); static PyObject * Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.166 retrieving revision 2.167 diff -C2 -d -r2.166 -r2.167 *** stringobject.c 11 Jun 2002 10:55:11 -0000 2.166 --- stringobject.c 13 Jun 2002 20:33:01 -0000 2.167 *************** *** 1118,1122 **** ! static char split__doc__[] = "S.split([sep [,maxsplit]]) -> list of strings\n\ \n\ --- 1118,1122 ---- ! PyDoc_STRVAR(split__doc__, "S.split([sep [,maxsplit]]) -> list of strings\n\ \n\ *************** *** 1124,1128 **** delimiter string. If maxsplit is given, at most maxsplit\n\ splits are done. If sep is not specified, any whitespace string\n\ ! is a separator."; static PyObject * --- 1124,1128 ---- delimiter string. If maxsplit is given, at most maxsplit\n\ splits are done. If sep is not specified, any whitespace string\n\ ! is a separator."); static PyObject * *************** *** 1192,1200 **** ! static char join__doc__[] = "S.join(sequence) -> string\n\ \n\ Return a string which is the concatenation of the strings in the\n\ ! sequence. The separator between elements is S."; static PyObject * --- 1192,1200 ---- ! PyDoc_STRVAR(join__doc__, "S.join(sequence) -> string\n\ \n\ Return a string which is the concatenation of the strings in the\n\ ! sequence. The separator between elements is S."); static PyObject * *************** *** 1366,1370 **** ! static char find__doc__[] = "S.find(sub [,start [,end]]) -> int\n\ \n\ --- 1366,1370 ---- ! PyDoc_STRVAR(find__doc__, "S.find(sub [,start [,end]]) -> int\n\ \n\ *************** *** 1373,1377 **** arguments start and end are interpreted as in slice notation.\n\ \n\ ! Return -1 on failure."; static PyObject * --- 1373,1377 ---- arguments start and end are interpreted as in slice notation.\n\ \n\ ! Return -1 on failure."); static PyObject * *************** *** 1385,1392 **** ! static char index__doc__[] = "S.index(sub [,start [,end]]) -> int\n\ \n\ ! Like S.find() but raise ValueError when the substring is not found."; static PyObject * --- 1385,1392 ---- ! PyDoc_STRVAR(index__doc__, "S.index(sub [,start [,end]]) -> int\n\ \n\ ! Like S.find() but raise ValueError when the substring is not found."); static PyObject * *************** *** 1405,1409 **** ! static char rfind__doc__[] = "S.rfind(sub [,start [,end]]) -> int\n\ \n\ --- 1405,1409 ---- ! PyDoc_STRVAR(rfind__doc__, "S.rfind(sub [,start [,end]]) -> int\n\ \n\ *************** *** 1412,1416 **** arguments start and end are interpreted as in slice notation.\n\ \n\ ! Return -1 on failure."; static PyObject * --- 1412,1416 ---- arguments start and end are interpreted as in slice notation.\n\ \n\ ! Return -1 on failure."); static PyObject * *************** *** 1424,1431 **** ! static char rindex__doc__[] = "S.rindex(sub [,start [,end]]) -> int\n\ \n\ ! Like S.rfind() but raise ValueError when the substring is not found."; static PyObject * --- 1424,1431 ---- ! PyDoc_STRVAR(rindex__doc__, "S.rindex(sub [,start [,end]]) -> int\n\ \n\ ! Like S.rfind() but raise ValueError when the substring is not found."); static PyObject * *************** *** 1547,1551 **** ! static char strip__doc__[] = "S.strip([sep]) -> string or unicode\n\ \n\ --- 1547,1551 ---- ! PyDoc_STRVAR(strip__doc__, "S.strip([sep]) -> string or unicode\n\ \n\ *************** *** 1553,1557 **** whitespace removed.\n\ If sep is given and not None, remove characters in sep instead.\n\ ! If sep is unicode, S will be converted to unicode before stripping"; static PyObject * --- 1553,1557 ---- whitespace removed.\n\ If sep is given and not None, remove characters in sep instead.\n\ ! If sep is unicode, S will be converted to unicode before stripping"); static PyObject * *************** *** 1565,1574 **** ! static char lstrip__doc__[] = "S.lstrip([sep]) -> string or unicode\n\ \n\ Return a copy of the string S with leading whitespace removed.\n\ If sep is given and not None, remove characters in sep instead.\n\ ! If sep is unicode, S will be converted to unicode before stripping"; static PyObject * --- 1565,1574 ---- ! PyDoc_STRVAR(lstrip__doc__, "S.lstrip([sep]) -> string or unicode\n\ \n\ Return a copy of the string S with leading whitespace removed.\n\ If sep is given and not None, remove characters in sep instead.\n\ ! If sep is unicode, S will be converted to unicode before stripping"); static PyObject * *************** *** 1582,1591 **** ! static char rstrip__doc__[] = "S.rstrip([sep]) -> string or unicode\n\ \n\ Return a copy of the string S with trailing whitespace removed.\n\ If sep is given and not None, remove characters in sep instead.\n\ ! If sep is unicode, S will be converted to unicode before stripping"; static PyObject * --- 1582,1591 ---- ! PyDoc_STRVAR(rstrip__doc__, "S.rstrip([sep]) -> string or unicode\n\ \n\ Return a copy of the string S with trailing whitespace removed.\n\ If sep is given and not None, remove characters in sep instead.\n\ ! If sep is unicode, S will be converted to unicode before stripping"); static PyObject * *************** *** 1599,1606 **** ! static char lower__doc__[] = "S.lower() -> string\n\ \n\ ! Return a copy of the string S converted to lowercase."; static PyObject * --- 1599,1606 ---- ! PyDoc_STRVAR(lower__doc__, "S.lower() -> string\n\ \n\ ! Return a copy of the string S converted to lowercase."); static PyObject * *************** *** 1627,1634 **** ! static char upper__doc__[] = "S.upper() -> string\n\ \n\ ! Return a copy of the string S converted to uppercase."; static PyObject * --- 1627,1634 ---- ! PyDoc_STRVAR(upper__doc__, "S.upper() -> string\n\ \n\ ! Return a copy of the string S converted to uppercase."); static PyObject * *************** *** 1655,1663 **** ! static char title__doc__[] = "S.title() -> string\n\ \n\ Return a titlecased version of S, i.e. words start with uppercase\n\ ! characters, all remaining cased characters have lowercase."; static PyObject* --- 1655,1663 ---- ! PyDoc_STRVAR(title__doc__, "S.title() -> string\n\ \n\ Return a titlecased version of S, i.e. words start with uppercase\n\ ! characters, all remaining cased characters have lowercase."); static PyObject* *************** *** 1690,1698 **** } ! static char capitalize__doc__[] = "S.capitalize() -> string\n\ \n\ Return a copy of the string S with only its first character\n\ ! capitalized."; static PyObject * --- 1690,1698 ---- } ! PyDoc_STRVAR(capitalize__doc__, "S.capitalize() -> string\n\ \n\ Return a copy of the string S with only its first character\n\ ! capitalized."); static PyObject * *************** *** 1727,1736 **** ! static char count__doc__[] = "S.count(sub[, start[, end]]) -> int\n\ \n\ Return the number of occurrences of substring sub in string\n\ S[start:end]. Optional arguments start and end are\n\ ! interpreted as in slice notation."; static PyObject * --- 1727,1736 ---- ! PyDoc_STRVAR(count__doc__, "S.count(sub[, start[, end]]) -> int\n\ \n\ Return the number of occurrences of substring sub in string\n\ S[start:end]. Optional arguments start and end are\n\ ! interpreted as in slice notation."); static PyObject * *************** *** 1791,1799 **** ! static char swapcase__doc__[] = "S.swapcase() -> string\n\ \n\ Return a copy of the string S with uppercase characters\n\ ! converted to lowercase and vice versa."; static PyObject * --- 1791,1799 ---- ! PyDoc_STRVAR(swapcase__doc__, "S.swapcase() -> string\n\ \n\ Return a copy of the string S with uppercase characters\n\ ! converted to lowercase and vice versa."); static PyObject * *************** *** 1824,1828 **** ! static char translate__doc__[] = "S.translate(table [,deletechars]) -> string\n\ \n\ --- 1824,1828 ---- ! PyDoc_STRVAR(translate__doc__, "S.translate(table [,deletechars]) -> string\n\ \n\ *************** *** 1830,1834 **** in the optional argument deletechars are removed, and the\n\ remaining characters have been mapped through the given\n\ ! translation table, which must be a string of length 256."; static PyObject * --- 1830,1834 ---- in the optional argument deletechars are removed, and the\n\ remaining characters have been mapped through the given\n\ ! translation table, which must be a string of length 256."); static PyObject * *************** *** 2080,2089 **** ! static char replace__doc__[] = "S.replace (old, new[, maxsplit]) -> string\n\ \n\ Return a copy of string S with all occurrences of substring\n\ old replaced by new. If the optional argument maxsplit is\n\ ! given, only the first maxsplit occurrences are replaced."; static PyObject * --- 2080,2089 ---- ! PyDoc_STRVAR(replace__doc__, "S.replace (old, new[, maxsplit]) -> string\n\ \n\ Return a copy of string S with all occurrences of substring\n\ old replaced by new. If the optional argument maxsplit is\n\ ! given, only the first maxsplit occurrences are replaced."); static PyObject * *************** *** 2155,2164 **** ! static char startswith__doc__[] = "S.startswith(prefix[, start[, end]]) -> bool\n\ \n\ Return True if S starts with the specified prefix, False otherwise. With\n\ optional start, test S beginning at that position. With optional end, stop\n\ ! comparing S at that position."; static PyObject * --- 2155,2164 ---- ! PyDoc_STRVAR(startswith__doc__, "S.startswith(prefix[, start[, end]]) -> bool\n\ \n\ Return True if S starts with the specified prefix, False otherwise. With\n\ optional start, test S beginning at that position. With optional end, stop\n\ ! comparing S at that position."); static PyObject * *************** *** 2214,2223 **** ! static char endswith__doc__[] = "S.endswith(suffix[, start[, end]]) -> bool\n\ \n\ Return True if S ends with the specified suffix, False otherwise. With\n\ optional start, test S beginning at that position. With optional end, stop\n\ ! comparing S at that position."; static PyObject * --- 2214,2223 ---- ! PyDoc_STRVAR(endswith__doc__, "S.endswith(suffix[, start[, end]]) -> bool\n\ \n\ Return True if S ends with the specified suffix, False otherwise. With\n\ optional start, test S beginning at that position. With optional end, stop\n\ ! comparing S at that position."); static PyObject * *************** *** 2266,2270 **** ! static char encode__doc__[] = "S.encode([encoding[,errors]]) -> object\n\ \n\ --- 2266,2270 ---- ! PyDoc_STRVAR(encode__doc__, "S.encode([encoding[,errors]]) -> object\n\ \n\ *************** *** 2272,2276 **** to the default encoding. errors may be given to set a different error\n\ handling scheme. Default is 'strict' meaning that encoding errors raise\n\ ! a ValueError. Other possible values are 'ignore' and 'replace'."; static PyObject * --- 2272,2276 ---- to the default encoding. errors may be given to set a different error\n\ handling scheme. Default is 'strict' meaning that encoding errors raise\n\ ! a ValueError. Other possible values are 'ignore' and 'replace'."); static PyObject * *************** *** 2285,2289 **** ! static char decode__doc__[] = "S.decode([encoding[,errors]]) -> object\n\ \n\ --- 2285,2289 ---- ! PyDoc_STRVAR(decode__doc__, "S.decode([encoding[,errors]]) -> object\n\ \n\ *************** *** 2291,2295 **** to the default encoding. errors may be given to set a different error\n\ handling scheme. Default is 'strict' meaning that encoding errors raise\n\ ! a ValueError. Other possible values are 'ignore' and 'replace'."; static PyObject * --- 2291,2295 ---- to the default encoding. errors may be given to set a different error\n\ handling scheme. Default is 'strict' meaning that encoding errors raise\n\ ! a ValueError. Other possible values are 'ignore' and 'replace'."); static PyObject * *************** *** 2304,2312 **** ! static char expandtabs__doc__[] = "S.expandtabs([tabsize]) -> string\n\ \n\ Return a copy of S where all tab characters are expanded using spaces.\n\ ! If tabsize is not given, a tab size of 8 characters is assumed."; static PyObject* --- 2304,2312 ---- ! PyDoc_STRVAR(expandtabs__doc__, "S.expandtabs([tabsize]) -> string\n\ \n\ Return a copy of S where all tab characters are expanded using spaces.\n\ ! If tabsize is not given, a tab size of 8 characters is assumed."); static PyObject* *************** *** 2396,2404 **** } ! static char ljust__doc__[] = "S.ljust(width) -> string\n" "\n" "Return S left justified in a string of length width. Padding is\n" ! "done using spaces."; static PyObject * --- 2396,2404 ---- } ! PyDoc_STRVAR(ljust__doc__, "S.ljust(width) -> string\n" "\n" "Return S left justified in a string of length width. Padding is\n" ! "done using spaces."); static PyObject * *************** *** 2418,2426 **** ! static char rjust__doc__[] = "S.rjust(width) -> string\n" "\n" "Return S right justified in a string of length width. Padding is\n" ! "done using spaces."; static PyObject * --- 2418,2426 ---- ! PyDoc_STRVAR(rjust__doc__, "S.rjust(width) -> string\n" "\n" "Return S right justified in a string of length width. Padding is\n" ! "done using spaces."); static PyObject * *************** *** 2440,2448 **** ! static char center__doc__[] = "S.center(width) -> string\n" "\n" "Return S centered in a string of length width. Padding is done\n" ! "using spaces."; static PyObject * --- 2440,2448 ---- ! PyDoc_STRVAR(center__doc__, "S.center(width) -> string\n" "\n" "Return S centered in a string of length width. Padding is done\n" ! "using spaces."); static PyObject * *************** *** 2466,2474 **** } ! static char zfill__doc__[] = "S.zfill(width) -> string\n" "\n" "Pad a numeric string S with zeros on the left, to fill a field\n" ! "of the specified width. The string S is never truncated."; static PyObject * --- 2466,2474 ---- } ! PyDoc_STRVAR(zfill__doc__, "S.zfill(width) -> string\n" "\n" "Pad a numeric string S with zeros on the left, to fill a field\n" ! "of the specified width. The string S is never truncated."); static PyObject * *************** *** 2512,2520 **** } ! static char isspace__doc__[] = "S.isspace() -> bool\n" "\n" "Return True if there are only whitespace characters in S,\n" ! "False otherwise."; static PyObject* --- 2512,2520 ---- } ! PyDoc_STRVAR(isspace__doc__, "S.isspace() -> bool\n" "\n" "Return True if there are only whitespace characters in S,\n" ! "False otherwise."); static PyObject* *************** *** 2543,2551 **** ! static char isalpha__doc__[] = "S.isalpha() -> bool\n\ \n\ Return True if all characters in S are alphabetic\n\ ! and there is at least one character in S, False otherwise."; static PyObject* --- 2543,2551 ---- ! PyDoc_STRVAR(isalpha__doc__, "S.isalpha() -> bool\n\ \n\ Return True if all characters in S are alphabetic\n\ ! and there is at least one character in S, False otherwise."); static PyObject* *************** *** 2574,2582 **** ! static char isalnum__doc__[] = "S.isalnum() -> bool\n\ \n\ Return True if all characters in S are alphanumeric\n\ ! and there is at least one character in S, False otherwise."; static PyObject* --- 2574,2582 ---- ! PyDoc_STRVAR(isalnum__doc__, "S.isalnum() -> bool\n\ \n\ Return True if all characters in S are alphanumeric\n\ ! and there is at least one character in S, False otherwise."); static PyObject* *************** *** 2605,2613 **** ! static char isdigit__doc__[] = "S.isdigit() -> bool\n\ \n\ Return True if there are only digit characters in S,\n\ ! False otherwise."; static PyObject* --- 2605,2613 ---- ! PyDoc_STRVAR(isdigit__doc__, "S.isdigit() -> bool\n\ \n\ Return True if there are only digit characters in S,\n\ ! False otherwise."); static PyObject* *************** *** 2636,2644 **** ! static char islower__doc__[] = "S.islower() -> bool\n\ \n\ Return True if all cased characters in S are lowercase and there is\n\ ! at least one cased character in S, False otherwise."; static PyObject* --- 2636,2644 ---- ! PyDoc_STRVAR(islower__doc__, "S.islower() -> bool\n\ \n\ Return True if all cased characters in S are lowercase and there is\n\ ! at least one cased character in S, False otherwise."); static PyObject* *************** *** 2670,2678 **** ! static char isupper__doc__[] = "S.isupper() -> bool\n\ \n\ Return True if all cased characters in S are uppercase and there is\n\ ! at least one cased character in S, False otherwise."; static PyObject* --- 2670,2678 ---- ! PyDoc_STRVAR(isupper__doc__, "S.isupper() -> bool\n\ \n\ Return True if all cased characters in S are uppercase and there is\n\ ! at least one cased character in S, False otherwise."); static PyObject* *************** *** 2704,2713 **** ! static char istitle__doc__[] = "S.istitle() -> bool\n\ \n\ Return True if S is a titlecased string, i.e. uppercase characters\n\ may only follow uncased characters and lowercase characters only cased\n\ ! ones. Return False otherwise."; static PyObject* --- 2704,2713 ---- ! PyDoc_STRVAR(istitle__doc__, "S.istitle() -> bool\n\ \n\ Return True if S is a titlecased string, i.e. uppercase characters\n\ may only follow uncased characters and lowercase characters only cased\n\ ! ones. Return False otherwise."); static PyObject* *************** *** 2752,2761 **** ! static char splitlines__doc__[] = "S.splitlines([keepends]) -> list of strings\n\ \n\ Return a list of the lines in S, breaking at line boundaries.\n\ Line breaks are not included in the resulting list unless keepends\n\ ! is given and true."; #define SPLIT_APPEND(data, left, right) \ --- 2752,2761 ---- ! PyDoc_STRVAR(splitlines__doc__, "S.splitlines([keepends]) -> list of strings\n\ \n\ Return a list of the lines in S, breaking at line boundaries.\n\ Line breaks are not included in the resulting list unless keepends\n\ ! is given and true."); #define SPLIT_APPEND(data, left, right) \ *************** *** 2924,2929 **** } ! static char basestring_doc[] = ! "Type basestring cannot be instantiated; it is the base for str and unicode."; PyTypeObject PyBaseString_Type = { --- 2924,2929 ---- } ! PyDoc_STRVAR(basestring_doc, ! "Type basestring cannot be instantiated; it is the base for str and unicode."); PyTypeObject PyBaseString_Type = { *************** *** 2970,2978 **** }; ! static char string_doc[] = "str(object) -> string\n\ \n\ Return a nice string representation of the object.\n\ ! If the argument is a string, the return value is the same object."; PyTypeObject PyString_Type = { --- 2970,2978 ---- }; ! PyDoc_STRVAR(string_doc, "str(object) -> string\n\ \n\ Return a nice string representation of the object.\n\ ! If the argument is a string, the return value is the same object."); PyTypeObject PyString_Type = { Index: tupleobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/tupleobject.c,v retrieving revision 2.65 retrieving revision 2.66 diff -C2 -d -r2.65 -r2.66 *** tupleobject.c 11 Jun 2002 10:55:12 -0000 2.65 --- tupleobject.c 13 Jun 2002 20:33:01 -0000 2.66 *************** *** 525,533 **** } ! static char tuple_doc[] = "tuple() -> an empty tuple\n" "tuple(sequence) -> tuple initialized from sequence's items\n" "\n" ! "If the argument is a tuple, the return value is the same object."; static PySequenceMethods tuple_as_sequence = { --- 525,533 ---- } ! PyDoc_STRVAR(tuple_doc, "tuple() -> an empty tuple\n" "tuple(sequence) -> tuple initialized from sequence's items\n" "\n" ! "If the argument is a tuple, the return value is the same object."); static PySequenceMethods tuple_as_sequence = { Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.152 retrieving revision 2.153 diff -C2 -d -r2.152 -r2.153 *** typeobject.c 13 Jun 2002 19:17:45 -0000 2.152 --- typeobject.c 13 Jun 2002 20:33:01 -0000 2.153 *************** *** 1488,1494 **** }; ! static char type_doc[] = "type(object) -> the object's type\n" ! "type(name, bases, dict) -> a new type"; static int --- 1488,1494 ---- }; ! PyDoc_STRVAR(type_doc, "type(object) -> the object's type\n" ! "type(name, bases, dict) -> a new type"); static int *************** *** 4356,4360 **** } ! static char super_doc[] = "super(type) -> unbound super object\n" "super(type, obj) -> bound super object; requires isinstance(obj, type)\n" --- 4356,4360 ---- } ! PyDoc_STRVAR(super_doc, "super(type) -> unbound super object\n" "super(type, obj) -> bound super object; requires isinstance(obj, type)\n" *************** *** 4363,4367 **** "class C(B):\n" " def meth(self, arg):\n" ! " super(C, self).meth(arg)"; static int --- 4363,4367 ---- "class C(B):\n" " def meth(self, arg):\n" ! " super(C, self).meth(arg)"); static int Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.152 retrieving revision 2.153 diff -C2 -d -r2.152 -r2.153 *** unicodeobject.c 11 Jun 2002 10:55:12 -0000 2.152 --- unicodeobject.c 13 Jun 2002 20:33:01 -0000 2.153 *************** *** 3528,3536 **** /* --- Unicode Object Methods --------------------------------------------- */ ! static char title__doc__[] = "S.title() -> unicode\n\ \n\ Return a titlecased version of S, i.e. words start with title case\n\ ! characters, all remaining cased characters have lower case."; static PyObject* --- 3528,3536 ---- /* --- Unicode Object Methods --------------------------------------------- */ ! PyDoc_STRVAR(title__doc__, "S.title() -> unicode\n\ \n\ Return a titlecased version of S, i.e. words start with title case\n\ ! characters, all remaining cased characters have lower case."); static PyObject* *************** *** 3540,3548 **** } ! static char capitalize__doc__[] = "S.capitalize() -> unicode\n\ \n\ Return a capitalized version of S, i.e. make the first character\n\ ! have upper case."; static PyObject* --- 3540,3548 ---- } ! PyDoc_STRVAR(capitalize__doc__, "S.capitalize() -> unicode\n\ \n\ Return a capitalized version of S, i.e. make the first character\n\ ! have upper case."); static PyObject* *************** *** 3553,3561 **** #if 0 ! static char capwords__doc__[] = "S.capwords() -> unicode\n\ \n\ Apply .capitalize() to all words in S and return the result with\n\ ! normalized whitespace (all whitespace strings are replaced by ' ')."; static PyObject* --- 3553,3561 ---- #if 0 ! PyDoc_STRVAR(capwords__doc__, "S.capwords() -> unicode\n\ \n\ Apply .capitalize() to all words in S and return the result with\n\ ! normalized whitespace (all whitespace strings are replaced by ' ')."); static PyObject* *************** *** 3590,3598 **** #endif ! static char center__doc__[] = "S.center(width) -> unicode\n\ \n\ Return S centered in a Unicode string of length width. Padding is done\n\ ! using spaces."; static PyObject * --- 3590,3598 ---- #endif ! PyDoc_STRVAR(center__doc__, "S.center(width) -> unicode\n\ \n\ Return S centered in a Unicode string of length width. Padding is done\n\ ! using spaces."); static PyObject * *************** *** 3819,3828 **** } ! static char count__doc__[] = "S.count(sub[, start[, end]]) -> int\n\ \n\ Return the number of occurrences of substring sub in Unicode string\n\ S[start:end]. Optional arguments start and end are\n\ ! interpreted as in slice notation."; static PyObject * --- 3819,3828 ---- } ! PyDoc_STRVAR(count__doc__, "S.count(sub[, start[, end]]) -> int\n\ \n\ Return the number of occurrences of substring sub in Unicode string\n\ S[start:end]. Optional arguments start and end are\n\ ! interpreted as in slice notation."); static PyObject * *************** *** 3860,3864 **** } ! static char encode__doc__[] = "S.encode([encoding[,errors]]) -> string\n\ \n\ --- 3860,3864 ---- } ! PyDoc_STRVAR(encode__doc__, "S.encode([encoding[,errors]]) -> string\n\ \n\ *************** *** 3866,3870 **** default string encoding. errors may be given to set a different error\n\ handling scheme. Default is 'strict' meaning that encoding errors raise\n\ ! a ValueError. Other possible values are 'ignore' and 'replace'."; static PyObject * --- 3866,3870 ---- default string encoding. errors may be given to set a different error\n\ handling scheme. Default is 'strict' meaning that encoding errors raise\n\ ! a ValueError. Other possible values are 'ignore' and 'replace'."); static PyObject * *************** *** 3878,3886 **** } ! static char expandtabs__doc__[] = "S.expandtabs([tabsize]) -> unicode\n\ \n\ Return a copy of S where all tab characters are expanded using spaces.\n\ ! If tabsize is not given, a tab size of 8 characters is assumed."; static PyObject* --- 3878,3886 ---- } ! PyDoc_STRVAR(expandtabs__doc__, "S.expandtabs([tabsize]) -> unicode\n\ \n\ Return a copy of S where all tab characters are expanded using spaces.\n\ ! If tabsize is not given, a tab size of 8 characters is assumed."); static PyObject* *************** *** 3940,3944 **** } ! static char find__doc__[] = "S.find(sub [,start [,end]]) -> int\n\ \n\ --- 3940,3944 ---- } ! PyDoc_STRVAR(find__doc__, "S.find(sub [,start [,end]]) -> int\n\ \n\ *************** *** 3947,3951 **** arguments start and end are interpreted as in slice notation.\n\ \n\ ! Return -1 on failure."; static PyObject * --- 3947,3951 ---- arguments start and end are interpreted as in slice notation.\n\ \n\ ! Return -1 on failure."); static PyObject * *************** *** 4009,4016 **** } ! static char index__doc__[] = "S.index(sub [,start [,end]]) -> int\n\ \n\ ! Like S.find() but raise ValueError when the substring is not found."; static PyObject * --- 4009,4016 ---- } ! PyDoc_STRVAR(index__doc__, "S.index(sub [,start [,end]]) -> int\n\ \n\ ! Like S.find() but raise ValueError when the substring is not found."); static PyObject * *************** *** 4041,4049 **** } ! static char islower__doc__[] = "S.islower() -> bool\n\ \n\ Return True if all cased characters in S are lowercase and there is\n\ ! at least one cased character in S, False otherwise."; static PyObject* --- 4041,4049 ---- } ! PyDoc_STRVAR(islower__doc__, "S.islower() -> bool\n\ \n\ Return True if all cased characters in S are lowercase and there is\n\ ! at least one cased character in S, False otherwise."); static PyObject* *************** *** 4075,4083 **** } ! static char isupper__doc__[] = "S.isupper() -> bool\n\ \n\ Return True if all cased characters in S are uppercase and there is\n\ ! at least one cased character in S, False otherwise."; static PyObject* --- 4075,4083 ---- } ! PyDoc_STRVAR(isupper__doc__, "S.isupper() -> bool\n\ \n\ Return True if all cased characters in S are uppercase and there is\n\ ! at least one cased character in S, False otherwise."); static PyObject* *************** *** 4109,4118 **** } ! static char istitle__doc__[] = "S.istitle() -> bool\n\ \n\ Return True if S is a titlecased string, i.e. upper- and titlecase\n\ characters may only follow uncased characters and lowercase characters\n\ ! only cased ones. Return False otherwise."; static PyObject* --- 4109,4118 ---- } ! PyDoc_STRVAR(istitle__doc__, "S.istitle() -> bool\n\ \n\ Return True if S is a titlecased string, i.e. upper- and titlecase\n\ characters may only follow uncased characters and lowercase characters\n\ ! only cased ones. Return False otherwise."); static PyObject* *************** *** 4156,4164 **** } ! static char isspace__doc__[] = "S.isspace() -> bool\n\ \n\ Return True if there are only whitespace characters in S,\n\ ! False otherwise."; static PyObject* --- 4156,4164 ---- } ! PyDoc_STRVAR(isspace__doc__, "S.isspace() -> bool\n\ \n\ Return True if there are only whitespace characters in S,\n\ ! False otherwise."); static PyObject* *************** *** 4185,4193 **** } ! static char isalpha__doc__[] = "S.isalpha() -> bool\n\ \n\ Return True if all characters in S are alphabetic\n\ ! and there is at least one character in S, False otherwise."; static PyObject* --- 4185,4193 ---- } ! PyDoc_STRVAR(isalpha__doc__, "S.isalpha() -> bool\n\ \n\ Return True if all characters in S are alphabetic\n\ ! and there is at least one character in S, False otherwise."); static PyObject* *************** *** 4214,4222 **** } ! static char isalnum__doc__[] = "S.isalnum() -> bool\n\ \n\ Return True if all characters in S are alphanumeric\n\ ! and there is at least one character in S, False otherwise."; static PyObject* --- 4214,4222 ---- } ! PyDoc_STRVAR(isalnum__doc__, "S.isalnum() -> bool\n\ \n\ Return True if all characters in S are alphanumeric\n\ ! and there is at least one character in S, False otherwise."); static PyObject* *************** *** 4243,4251 **** } ! static char isdecimal__doc__[] = "S.isdecimal() -> bool\n\ \n\ Return True if there are only decimal characters in S,\n\ ! False otherwise."; static PyObject* --- 4243,4251 ---- } ! PyDoc_STRVAR(isdecimal__doc__, "S.isdecimal() -> bool\n\ \n\ Return True if there are only decimal characters in S,\n\ ! False otherwise."); static PyObject* *************** *** 4272,4280 **** } ! static char isdigit__doc__[] = "S.isdigit() -> bool\n\ \n\ Return True if there are only digit characters in S,\n\ ! False otherwise."; static PyObject* --- 4272,4280 ---- } ! PyDoc_STRVAR(isdigit__doc__, "S.isdigit() -> bool\n\ \n\ Return True if there are only digit characters in S,\n\ ! False otherwise."); static PyObject* *************** *** 4301,4309 **** } ! static char isnumeric__doc__[] = "S.isnumeric() -> bool\n\ \n\ Return True if there are only numeric characters in S,\n\ ! False otherwise."; static PyObject* --- 4301,4309 ---- } ! PyDoc_STRVAR(isnumeric__doc__, "S.isnumeric() -> bool\n\ \n\ Return True if there are only numeric characters in S,\n\ ! False otherwise."); static PyObject* *************** *** 4330,4338 **** } ! static char join__doc__[] = "S.join(sequence) -> unicode\n\ \n\ Return a string which is the concatenation of the strings in the\n\ ! sequence. The separator between elements is S."; static PyObject* --- 4330,4338 ---- } ! PyDoc_STRVAR(join__doc__, "S.join(sequence) -> unicode\n\ \n\ Return a string which is the concatenation of the strings in the\n\ ! sequence. The separator between elements is S."); static PyObject* *************** *** 4348,4356 **** } ! static char ljust__doc__[] = "S.ljust(width) -> unicode\n\ \n\ Return S left justified in a Unicode string of length width. Padding is\n\ ! done using spaces."; static PyObject * --- 4348,4356 ---- } ! PyDoc_STRVAR(ljust__doc__, "S.ljust(width) -> unicode\n\ \n\ Return S left justified in a Unicode string of length width. Padding is\n\ ! done using spaces."); static PyObject * *************** *** 4369,4376 **** } ! static char lower__doc__[] = "S.lower() -> unicode\n\ \n\ ! Return a copy of the string S converted to lowercase."; static PyObject* --- 4369,4376 ---- } ! PyDoc_STRVAR(lower__doc__, "S.lower() -> unicode\n\ \n\ ! Return a copy of the string S converted to lowercase."); static PyObject* *************** *** 4495,4499 **** ! static char strip__doc__[] = "S.strip([sep]) -> unicode\n\ \n\ --- 4495,4499 ---- ! PyDoc_STRVAR(strip__doc__, "S.strip([sep]) -> unicode\n\ \n\ *************** *** 4501,4505 **** whitespace removed.\n\ If sep is given and not None, remove characters in sep instead.\n\ ! If sep is a str, it will be converted to unicode before stripping"; static PyObject * --- 4501,4505 ---- whitespace removed.\n\ If sep is given and not None, remove characters in sep instead.\n\ ! If sep is a str, it will be converted to unicode before stripping"); static PyObject * *************** *** 4513,4522 **** ! static char lstrip__doc__[] = "S.lstrip([sep]) -> unicode\n\ \n\ Return a copy of the string S with leading whitespace removed.\n\ If sep is given and not None, remove characters in sep instead.\n\ ! If sep is a str, it will be converted to unicode before stripping"; static PyObject * --- 4513,4522 ---- ! PyDoc_STRVAR(lstrip__doc__, "S.lstrip([sep]) -> unicode\n\ \n\ Return a copy of the string S with leading whitespace removed.\n\ If sep is given and not None, remove characters in sep instead.\n\ ! If sep is a str, it will be converted to unicode before stripping"); static PyObject * *************** *** 4530,4539 **** ! static char rstrip__doc__[] = "S.rstrip([sep]) -> unicode\n\ \n\ Return a copy of the string S with trailing whitespace removed.\n\ If sep is given and not None, remove characters in sep instead.\n\ ! If sep is a str, it will be converted to unicode before stripping"; static PyObject * --- 4530,4539 ---- ! PyDoc_STRVAR(rstrip__doc__, "S.rstrip([sep]) -> unicode\n\ \n\ Return a copy of the string S with trailing whitespace removed.\n\ If sep is given and not None, remove characters in sep instead.\n\ ! If sep is a str, it will be converted to unicode before stripping"); static PyObject * *************** *** 4627,4636 **** } ! static char replace__doc__[] = "S.replace (old, new[, maxsplit]) -> unicode\n\ \n\ Return a copy of S with all occurrences of substring\n\ old replaced by new. If the optional argument maxsplit is\n\ ! given, only the first maxsplit occurrences are replaced."; static PyObject* --- 4627,4636 ---- } ! PyDoc_STRVAR(replace__doc__, "S.replace (old, new[, maxsplit]) -> unicode\n\ \n\ Return a copy of S with all occurrences of substring\n\ old replaced by new. If the optional argument maxsplit is\n\ ! given, only the first maxsplit occurrences are replaced."); static PyObject* *************** *** 4666,4670 **** } ! static char rfind__doc__[] = "S.rfind(sub [,start [,end]]) -> int\n\ \n\ --- 4666,4670 ---- } ! PyDoc_STRVAR(rfind__doc__, "S.rfind(sub [,start [,end]]) -> int\n\ \n\ *************** *** 4673,4677 **** arguments start and end are interpreted as in slice notation.\n\ \n\ ! Return -1 on failure."; static PyObject * --- 4673,4677 ---- arguments start and end are interpreted as in slice notation.\n\ \n\ ! Return -1 on failure."); static PyObject * *************** *** 4697,4704 **** } ! static char rindex__doc__[] = "S.rindex(sub [,start [,end]]) -> int\n\ \n\ ! Like S.rfind() but raise ValueError when the substring is not found."; static PyObject * --- 4697,4704 ---- } ! PyDoc_STRVAR(rindex__doc__, "S.rindex(sub [,start [,end]]) -> int\n\ \n\ ! Like S.rfind() but raise ValueError when the substring is not found."); static PyObject * *************** *** 4728,4736 **** } ! static char rjust__doc__[] = "S.rjust(width) -> unicode\n\ \n\ Return S right justified in a Unicode string of length width. Padding is\n\ ! done using spaces."; static PyObject * --- 4728,4736 ---- } ! PyDoc_STRVAR(rjust__doc__, "S.rjust(width) -> unicode\n\ \n\ Return S right justified in a Unicode string of length width. Padding is\n\ ! done using spaces."); static PyObject * *************** *** 4795,4799 **** } ! static char split__doc__[] = "S.split([sep [,maxsplit]]) -> list of strings\n\ \n\ --- 4795,4799 ---- } ! PyDoc_STRVAR(split__doc__, "S.split([sep [,maxsplit]]) -> list of strings\n\ \n\ *************** *** 4801,4805 **** delimiter string. If maxsplit is given, at most maxsplit\n\ splits are done. If sep is not specified, any whitespace string\n\ ! is a separator."; static PyObject* --- 4801,4805 ---- delimiter string. If maxsplit is given, at most maxsplit\n\ splits are done. If sep is not specified, any whitespace string\n\ ! is a separator."); static PyObject* *************** *** 4820,4829 **** } ! static char splitlines__doc__[] = "S.splitlines([keepends]]) -> list of strings\n\ \n\ Return a list of the lines in S, breaking at line boundaries.\n\ Line breaks are not included in the resulting list unless keepends\n\ ! is given and true."; static PyObject* --- 4820,4829 ---- } ! PyDoc_STRVAR(splitlines__doc__, "S.splitlines([keepends]]) -> list of strings\n\ \n\ Return a list of the lines in S, breaking at line boundaries.\n\ Line breaks are not included in the resulting list unless keepends\n\ ! is given and true."); static PyObject* *************** *** 4844,4852 **** } ! static char swapcase__doc__[] = "S.swapcase() -> unicode\n\ \n\ Return a copy of S with uppercase characters converted to lowercase\n\ ! and vice versa."; static PyObject* --- 4844,4852 ---- } ! PyDoc_STRVAR(swapcase__doc__, "S.swapcase() -> unicode\n\ \n\ Return a copy of S with uppercase characters converted to lowercase\n\ ! and vice versa."); static PyObject* *************** *** 4856,4860 **** } ! static char translate__doc__[] = "S.translate(table) -> unicode\n\ \n\ --- 4856,4860 ---- } ! PyDoc_STRVAR(translate__doc__, "S.translate(table) -> unicode\n\ \n\ *************** *** 4862,4866 **** through the given translation table, which must be a mapping of\n\ Unicode ordinals to Unicode ordinals or None. Unmapped characters\n\ ! are left untouched. Characters mapped to None are deleted."; static PyObject* --- 4862,4866 ---- through the given translation table, which must be a mapping of\n\ Unicode ordinals to Unicode ordinals or None. Unmapped characters\n\ ! are left untouched. Characters mapped to None are deleted."); static PyObject* *************** *** 4873,4880 **** } ! static char upper__doc__[] = "S.upper() -> unicode\n\ \n\ ! Return a copy of S converted to uppercase."; static PyObject* --- 4873,4880 ---- } ! PyDoc_STRVAR(upper__doc__, "S.upper() -> unicode\n\ \n\ ! Return a copy of S converted to uppercase."); static PyObject* *************** *** 4884,4892 **** } ! static char zfill__doc__[] = "S.zfill(width) -> unicode\n\ \n\ Pad a numeric string x with zeros on the left, to fill a field\n\ ! of the specified width. The string x is never truncated."; static PyObject * --- 4884,4892 ---- } ! PyDoc_STRVAR(zfill__doc__, "S.zfill(width) -> unicode\n\ \n\ Pad a numeric string x with zeros on the left, to fill a field\n\ ! of the specified width. The string x is never truncated."); static PyObject * *************** *** 4936,4945 **** #endif ! static char startswith__doc__[] = "S.startswith(prefix[, start[, end]]) -> bool\n\ \n\ Return True if S starts with the specified prefix, False otherwise. With\n\ optional start, test S beginning at that position. With optional end, stop\n\ ! comparing S at that position."; static PyObject * --- 4936,4945 ---- #endif ! PyDoc_STRVAR(startswith__doc__, "S.startswith(prefix[, start[, end]]) -> bool\n\ \n\ Return True if S starts with the specified prefix, False otherwise. With\n\ optional start, test S beginning at that position. With optional end, stop\n\ ! comparing S at that position."); static PyObject * *************** *** 4967,4976 **** ! static char endswith__doc__[] = "S.endswith(suffix[, start[, end]]) -> bool\n\ \n\ Return True if S ends with the specified suffix, False otherwise. With\n\ optional start, test S beginning at that position. With optional end, stop\n\ ! comparing S at that position."; static PyObject * --- 4967,4976 ---- ! PyDoc_STRVAR(endswith__doc__, "S.endswith(suffix[, start[, end]]) -> bool\n\ \n\ Return True if S ends with the specified suffix, False otherwise. With\n\ optional start, test S beginning at that position. With optional end, stop\n\ ! comparing S at that position."); static PyObject * *************** *** 5848,5857 **** } ! static char unicode_doc[] = "unicode(string [, encoding[, errors]]) -> object\n\ \n\ Create a new Unicode object from the given encoded string.\n\ encoding defaults to the current default string encoding and \n\ ! errors, defining the error handling, to 'strict'."; PyTypeObject PyUnicode_Type = { --- 5848,5857 ---- } ! PyDoc_STRVAR(unicode_doc, "unicode(string [, encoding[, errors]]) -> object\n\ \n\ Create a new Unicode object from the given encoded string.\n\ encoding defaults to the current default string encoding and \n\ ! errors, defining the error handling, to 'strict'."); PyTypeObject PyUnicode_Type = { From loewis@users.sourceforge.net Thu Jun 13 21:33:04 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu, 13 Jun 2002 13:33:04 -0700 Subject: [Python-checkins] python/dist/src/PC _winreg.c,1.9,1.10 winsound.c,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/PC In directory usw-pr-cvs1:/tmp/cvs-serv14210/PC Modified Files: _winreg.c winsound.c Log Message: Patch #568124: Add doc string macros. Index: _winreg.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/_winreg.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** _winreg.c 31 Mar 2002 14:37:44 -0000 1.9 --- _winreg.c 13 Jun 2002 20:33:01 -0000 1.10 *************** *** 35,39 **** /* Doc strings */ ! static char module_doc[] = "This module provides access to the Windows registry API.\n" "\n" --- 35,39 ---- /* Doc strings */ ! PyDoc_STRVAR(module_doc, "This module provides access to the Windows registry API.\n" "\n" *************** *** 69,76 **** "Integer constants:\n" "Many constants are defined - see the documentation for each function\n" ! "to see what constants are used, and where."; ! static char CloseKey_doc[] = "CloseKey(hkey) - Closes a previously opened registry key.\n" "\n" --- 69,76 ---- "Integer constants:\n" "Many constants are defined - see the documentation for each function\n" ! "to see what constants are used, and where."); ! PyDoc_STRVAR(CloseKey_doc, "CloseKey(hkey) - Closes a previously opened registry key.\n" "\n" *************** *** 78,84 **** "\n" "Note that if the key is not closed using this method, it will be\n" ! "closed when the hkey object is destroyed by Python."; ! static char ConnectRegistry_doc[] = "key = ConnectRegistry(computer_name, key) - " "Establishes a connection to a predefined registry handle on another computer.\n" --- 78,84 ---- "\n" "Note that if the key is not closed using this method, it will be\n" ! "closed when the hkey object is destroyed by Python."); ! PyDoc_STRVAR(ConnectRegistry_doc, "key = ConnectRegistry(computer_name, key) - " "Establishes a connection to a predefined registry handle on another computer.\n" *************** *** 89,95 **** "\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[] = "key = CreateKey(key, sub_key) - Creates or opens the specified key.\n" "\n" --- 89,95 ---- "\n" "The return value is the handle of the opened key.\n" ! "If the function fails, an EnvironmentError exception is raised."); ! PyDoc_STRVAR(CreateKey_doc, "key = CreateKey(key, sub_key) - Creates or opens the specified key.\n" "\n" *************** *** 102,108 **** "\n" "The return value is the handle of the opened key.\n" ! "If the function fails, an exception is raised."; ! static char DeleteKey_doc[] = "DeleteKey(key, sub_key) - Deletes the specified key.\n" "\n" --- 102,108 ---- "\n" "The return value is the handle of the opened key.\n" ! "If the function fails, an exception is raised."); ! PyDoc_STRVAR(DeleteKey_doc, "DeleteKey(key, sub_key) - Deletes the specified key.\n" "\n" *************** *** 114,126 **** "\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[] = "DeleteValue(key, value) - Removes a named value from a registry key.\n" "\n" "key is an already open key, or any one of the predefined HKEY_* constants.\n" ! "value is a string that identifies the value to remove."; ! static char EnumKey_doc[] = "string = EnumKey(key, index) - Enumerates subkeys of an open registry key.\n" "\n" --- 114,126 ---- "\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."); ! PyDoc_STRVAR(DeleteValue_doc, "DeleteValue(key, value) - Removes a named value from a registry key.\n" "\n" "key is an already open key, or any one of the predefined HKEY_* constants.\n" ! "value is a string that identifies the value to remove."); ! PyDoc_STRVAR(EnumKey_doc, "string = EnumKey(key, index) - Enumerates subkeys of an open registry key.\n" "\n" *************** *** 130,136 **** "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[] = "tuple = EnumValue(key, index) - Enumerates values of an open registry key.\n" "key is an already open key, or any one of the predefined HKEY_* constants.\n" --- 130,136 ---- "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."); ! PyDoc_STRVAR(EnumValue_doc, "tuple = EnumValue(key, index) - Enumerates values of an open registry key.\n" "key is an already open key, or any one of the predefined HKEY_* constants.\n" *************** *** 145,151 **** "value_data is an object that holds the value data, and whose type depends\n" " on the underlying registry type.\n" ! "data_type is an integer that identifies the type of the value data."; ! static char FlushKey_doc[] = "FlushKey(key) - Writes all the attributes of a key to the registry.\n" "\n" --- 145,151 ---- "value_data is an object that holds the value data, and whose type depends\n" " on the underlying registry type.\n" ! "data_type is an integer that identifies the type of the value data."); ! PyDoc_STRVAR(FlushKey_doc, "FlushKey(key) - Writes all the attributes of a key to the registry.\n" "\n" *************** *** 158,164 **** "been written to the registry.\n" "An application should only call FlushKey() if it requires absolute certainty that registry changes are on disk.\n" ! "If you don't know whether a FlushKey() call is required, it probably isn't.\n"; ! 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" --- 158,164 ---- "been written to the registry.\n" "An application should only call FlushKey() if it requires absolute certainty that registry changes are on disk.\n" ! "If you don't know whether a FlushKey() call is required, it probably isn't."); ! PyDoc_STRVAR(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" *************** *** 177,183 **** "in fileName is relative to the remote computer.\n" "\n" ! "The docs imply key must be in the HKEY_USER or HKEY_LOCAL_MACHINE tree"; ! static char OpenKey_doc[] = "key = OpenKey(key, sub_key, res = 0, sam = KEY_READ) - Opens the specified key.\n" "\n" --- 177,183 ---- "in fileName is relative to the remote computer.\n" "\n" ! "The docs imply key must be in the HKEY_USER or HKEY_LOCAL_MACHINE tree"); ! PyDoc_STRVAR(OpenKey_doc, "key = OpenKey(key, sub_key, res = 0, sam = KEY_READ) - Opens the specified key.\n" "\n" *************** *** 189,198 **** "\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[] = ! "See OpenKey()"; ! static char QueryInfoKey_doc[] = "tuple = QueryInfoKey(key) - Returns information about a key.\n" "\n" --- 189,197 ---- "\n" "The result is a new handle to the specified key\n" ! "If the function fails, an EnvironmentError exception is raised."); ! PyDoc_STRVAR(OpenKeyEx_doc, "See OpenKey()"); ! PyDoc_STRVAR(QueryInfoKey_doc, "tuple = QueryInfoKey(key) - Returns information about a key.\n" "\n" *************** *** 203,209 **** "An integer that identifies the number of values this key has.\n" "A long integer that identifies when the key was last modified (if available)\n" ! " as 100's of nanoseconds since Jan 1, 1600.\n"; ! static char QueryValue_doc[] = "string = QueryValue(key, sub_key) - retrieves the unnamed value for a key.\n" "\n" --- 202,208 ---- "An integer that identifies the number of values this key has.\n" "A long integer that identifies when the key was last modified (if available)\n" ! " as 100's of nanoseconds since Jan 1, 1600."); ! PyDoc_STRVAR(QueryValue_doc, "string = QueryValue(key, sub_key) - retrieves the unnamed value for a key.\n" "\n" *************** *** 215,227 **** "Values in the registry have name, type, and data components. This method\n" "retrieves the data for a key's first value that has a NULL name.\n" ! "But the underlying API call doesn't return the type, Lame Lame Lame, DONT USE THIS!!!"; ! static char QueryValueEx_doc[] = "value,type_id = QueryValueEx(key, value_name) - Retrieves the type and data for a specified value name associated with an open registry key.\n" "\n" "key is an already open key, or any one of the predefined HKEY_* constants.\n" ! "value_name is a string indicating the value to query"; ! static char SaveKey_doc[] = "SaveKey(key, file_name) - Saves the specified key, and all its subkeys to the specified file.\n" "\n" --- 214,226 ---- "Values in the registry have name, type, and data components. This method\n" "retrieves the data for a key's first value that has a NULL name.\n" ! "But the underlying API call doesn't return the type, Lame Lame Lame, DONT USE THIS!!!"); ! PyDoc_STRVAR(QueryValueEx_doc, "value,type_id = QueryValueEx(key, value_name) - Retrieves the type and data for a specified value name associated with an open registry key.\n" "\n" "key is an already open key, or any one of the predefined HKEY_* constants.\n" ! "value_name is a string indicating the value to query"); ! PyDoc_STRVAR(SaveKey_doc, "SaveKey(key, file_name) - Saves the specified key, and all its subkeys to the specified file.\n" "\n" *************** *** 235,241 **** "file_name is relative to the remote computer.\n" "The caller of this method must possess the SeBackupPrivilege security privilege.\n" ! "This function passes NULL for security_attributes to the API."; ! static char SetValue_doc[] = "SetValue(key, sub_key, type, value) - Associates a value with a specified key.\n" "\n" --- 234,240 ---- "file_name is relative to the remote computer.\n" "The caller of this method must possess the SeBackupPrivilege security privilege.\n" ! "This function passes NULL for security_attributes to the API."); ! PyDoc_STRVAR(SetValue_doc, "SetValue(key, sub_key, type, value) - Associates a value with a specified key.\n" "\n" *************** *** 254,260 **** "\n" "The key identified by the key parameter must have been opened with\n" ! "KEY_SET_VALUE access."; ! static char SetValueEx_doc[] = "SetValueEx(key, value_name, reserved, type, value) - Stores data in the value field of an open registry key.\n" "\n" --- 253,259 ---- "\n" "The key identified by the key parameter must have been opened with\n" ! "KEY_SET_VALUE access."); ! PyDoc_STRVAR(SetValueEx_doc, "SetValueEx(key, value_name, reserved, type, value) - Stores data in the value field of an open registry key.\n" "\n" *************** *** 286,293 **** "Value lengths are limited by available memory. Long values (more than\n" "2048 bytes) should be stored as files with the filenames stored in \n" ! "the configuration registry. This helps the registry perform efficiently.\n"; /* PyHKEY docstrings */ ! static char PyHKEY_doc[] = "PyHKEY Object - A Python object, representing a win32 registry key.\n" "\n" --- 285,292 ---- "Value lengths are limited by available memory. Long values (more than\n" "2048 bytes) should be stored as files with the filenames stored in \n" ! "the configuration registry. This helps the registry perform efficiently."); /* PyHKEY docstrings */ ! PyDoc_STRVAR(PyHKEY_doc, "PyHKEY Object - A Python object, representing a win32 registry key.\n" "\n" *************** *** 309,321 **** "__nonzero__ - Handles with an open object return true, otherwise false.\n" "__int__ - Converting a handle to an integer returns the Win32 handle.\n" ! "__cmp__ - Handle objects are compared using the handle value.\n"; ! 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" --- 308,320 ---- "__nonzero__ - Handles with an open object return true, otherwise false.\n" "__int__ - Converting a handle to an integer returns the Win32 handle.\n" ! "__cmp__ - Handle objects are compared using the handle value."); ! PyDoc_STRVAR(PyHKEY_Close_doc, "key.Close() - Closes the underlying Windows handle.\n" "\n" ! "If the handle is already closed, no error is raised."); ! PyDoc_STRVAR(PyHKEY_Detach_doc, "int = key.Detach() - Detaches the Windows handle from the handle object.\n" "\n" *************** *** 327,331 **** "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"; --- 326,330 ---- "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"); Index: winsound.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/winsound.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** winsound.c 31 Mar 2002 14:37:44 -0000 1.9 --- winsound.c 13 Jun 2002 20:33:02 -0000 1.10 *************** *** 41,51 **** #include ! static char sound_playsound_doc[] = "PlaySound(sound, flags) - a wrapper around the Windows PlaySound API\n" "\n" "The sound argument can be a filename, data, or None.\n" ! "For flag values, ored together, see module documentation.\n"; ! static char sound_beep_doc[] = "Beep(frequency, duration) - a wrapper around the Windows Beep API\n" "\n" --- 41,51 ---- #include ! PyDoc_STRVAR(sound_playsound_doc, "PlaySound(sound, flags) - a wrapper around the Windows PlaySound API\n" "\n" "The sound argument can be a filename, data, or None.\n" ! "For flag values, ored together, see module documentation."); ! PyDoc_STRVAR(sound_beep_doc, "Beep(frequency, duration) - a wrapper around the Windows Beep API\n" "\n" *************** *** 55,61 **** "On WinNT and 2000, the platform Beep API is used directly. Else funky\n" "code doing direct port manipulation is used; it's unknown whether that\n" ! "will work on all systems.\n"; ! static char sound_module_doc[] = "PlaySound(sound, flags) - play a sound\n" "SND_FILENAME - sound is a wav file name\n" --- 55,61 ---- "On WinNT and 2000, the platform Beep API is used directly. Else funky\n" "code doing direct port manipulation is used; it's unknown whether that\n" ! "will work on all systems."); ! PyDoc_STRVAR(sound_module_doc, "PlaySound(sound, flags) - play a sound\n" "SND_FILENAME - sound is a wav file name\n" *************** *** 69,73 **** "SND_NOWAIT - Return immediately if the sound driver is busy\n" // Without any errors "\n" ! "Beep(frequency, duration) - Make a beep through the PC speaker.\n"; PyObject * --- 69,73 ---- "SND_NOWAIT - Return immediately if the sound driver is busy\n" // Without any errors "\n" ! "Beep(frequency, duration) - Make a beep through the PC speaker."); PyObject * From loewis@users.sourceforge.net Thu Jun 13 21:33:43 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu, 13 Jun 2002 13:33:43 -0700 Subject: [Python-checkins] python/dist/src/Modules _hotshot.c,1.17,1.18 _localemodule.c,2.31,2.32 _ssl.c,1.3,1.4 _weakref.c,1.15,1.16 almodule.c,1.35,1.36 arraymodule.c,2.73,2.74 binascii.c,2.33,2.34 cPickle.c,2.84,2.85 cStringIO.c,2.35,2.36 cmathmodule.c,2.29,2.30 cryptmodule.c,2.12,2.13 errnomodule.c,2.16,2.17 fcntlmodule.c,2.34,2.35 gcmodule.c,2.43,2.44 gdbmmodule.c,2.32,2.33 grpmodule.c,2.17,2.18 mathmodule.c,2.67,2.68 md5module.c,2.29,2.30 newmodule.c,2.38,2.39 operator.c,2.20,2.21 parsermodule.c,2.69,2.70 posixmodule.c,2.234,2.235 pwdmodule.c,1.33,1.34 pyexpat.c,2.59,2.60 readline.c,2.50,2.51 resource.c,2.25,2.26 selectmodule.c,2.63,2.64 shamodule.c,2.18,2.19 signalmodule.c,2.67,2.68 socketmodule.c,1.227,1.228 stropmodule.c,2.88,2.89 structmodule.c,2.54,2.55 termios.c,2.34,2.35 threadmodule.c,2.49,2.50 timemodule.c,2.126,2.127 unicodedata.c,2.17,2.18 xreadlinesmodule.c,1.9,1.10 xxsubtype.c,2.14,2.15 zlibmodule.c,2.61,2.62 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv14210/Modules Modified Files: _hotshot.c _localemodule.c _ssl.c _weakref.c almodule.c arraymodule.c binascii.c cPickle.c cStringIO.c cmathmodule.c cryptmodule.c errnomodule.c fcntlmodule.c gcmodule.c gdbmmodule.c grpmodule.c mathmodule.c md5module.c newmodule.c operator.c parsermodule.c posixmodule.c pwdmodule.c pyexpat.c readline.c resource.c selectmodule.c shamodule.c signalmodule.c socketmodule.c stropmodule.c structmodule.c termios.c threadmodule.c timemodule.c unicodedata.c xreadlinesmodule.c xxsubtype.c zlibmodule.c Log Message: Patch #568124: Add doc string macros. Index: _hotshot.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_hotshot.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** _hotshot.c 29 May 2002 18:19:14 -0000 1.17 --- _hotshot.c 13 Jun 2002 20:32:45 -0000 1.18 *************** *** 102,108 **** /* The log reader... */ ! static char logreader_close__doc__[] = "close()\n" ! "Close the log file, preventing additional records from being read."; static PyObject * --- 102,108 ---- /* The log reader... */ ! PyDoc_STRVAR(logreader_close__doc__, "close()\n" ! "Close the log file, preventing additional records from being read."); static PyObject * *************** *** 523,529 **** } ! static char next__doc__[] = "next() -> event-info\n" ! "Return the next event record from the log file."; static PyObject * --- 523,529 ---- } ! PyDoc_STRVAR(next__doc__, "next() -> event-info\n" ! "Return the next event record from the log file."); static PyObject * *************** *** 1022,1028 **** /* Profiler object interface methods. */ ! static char addinfo__doc__[] = "addinfo(key, value)\n" ! "Insert an ADD_INFO record into the log."; static PyObject * --- 1022,1028 ---- /* Profiler object interface methods. */ ! PyDoc_STRVAR(addinfo__doc__, "addinfo(key, value)\n" ! "Insert an ADD_INFO record into the log."); static PyObject * *************** *** 1045,1051 **** } ! static char close__doc__[] = "close()\n" ! "Shut down this profiler and close the log files, even if its active."; static PyObject * --- 1045,1051 ---- } ! PyDoc_STRVAR(close__doc__, "close()\n" ! "Shut down this profiler and close the log files, even if its active."); static PyObject * *************** *** 1066,1072 **** } ! static char runcall__doc__[] = "runcall(callable[, args[, kw]]) -> callable()\n" ! "Profile a specific function call, returning the result of that call."; static PyObject * --- 1066,1072 ---- } ! PyDoc_STRVAR(runcall__doc__, "runcall(callable[, args[, kw]]) -> callable()\n" ! "Profile a specific function call, returning the result of that call."); static PyObject * *************** *** 1089,1096 **** } ! static char runcode__doc__[] = "runcode(code, globals[, locals])\n" "Execute a code object while collecting profile data. If locals is\n" ! "omitted, globals is used for the locals as well."; static PyObject * --- 1089,1096 ---- } ! PyDoc_STRVAR(runcode__doc__, "runcode(code, globals[, locals])\n" "Execute a code object while collecting profile data. If locals is\n" ! "omitted, globals is used for the locals as well."); static PyObject * *************** *** 1128,1134 **** } ! static char start__doc__[] = "start()\n" ! "Install this profiler for the current thread."; static PyObject * --- 1128,1134 ---- } ! PyDoc_STRVAR(start__doc__, "start()\n" ! "Install this profiler for the current thread."); static PyObject * *************** *** 1147,1153 **** } ! static char stop__doc__[] = "stop()\n" ! "Remove this profiler from the current thread."; static PyObject * --- 1147,1153 ---- } ! PyDoc_STRVAR(stop__doc__, "stop()\n" ! "Remove this profiler from the current thread."); static PyObject * *************** *** 1226,1230 **** ! static char profiler_object__doc__[] = "High-performance profiler object.\n" "\n" --- 1226,1230 ---- ! PyDoc_STRVAR(profiler_object__doc__, "High-performance profiler object.\n" "\n" *************** *** 1242,1246 **** "frametimings: True if ENTER/EXIT events collect timing information.\n" "lineevents: True if SET_LINENO events are reported to the profiler.\n" ! "linetimings: True if SET_LINENO events collect timing information."; static PyTypeObject ProfilerType = { --- 1242,1246 ---- "frametimings: True if ENTER/EXIT events collect timing information.\n" "lineevents: True if SET_LINENO events are reported to the profiler.\n" ! "linetimings: True if SET_LINENO events collect timing information."); static PyTypeObject ProfilerType = { *************** *** 1289,1295 **** ! static char logreader__doc__[] = "\ ! logreader(filename) --> log-iterator\n\ ! Create a log-reader for the timing information file."; static PySequenceMethods logreader_as_sequence = { --- 1289,1295 ---- ! PyDoc_STRVAR(logreader__doc__, ! "logreader(filename) --> log-iterator\n\ ! Create a log-reader for the timing information file."); static PySequenceMethods logreader_as_sequence = { *************** *** 1477,1483 **** } ! static char profiler__doc__[] = "\ ! profiler(logfilename[, lineevents[, linetimes]]) -> profiler\n\ ! Create a new profiler object."; static PyObject * --- 1477,1483 ---- } ! PyDoc_STRVAR(profiler__doc__, ! "profiler(logfilename[, lineevents[, linetimes]]) -> profiler\n\ ! Create a new profiler object."); static PyObject * *************** *** 1530,1537 **** } ! static char coverage__doc__[] = "\ ! coverage(logfilename) -> profiler\n\ Returns a profiler that doesn't collect any timing information, which is\n\ ! useful in building a coverage analysis tool."; static PyObject * --- 1530,1537 ---- } ! PyDoc_STRVAR(coverage__doc__, ! "coverage(logfilename) -> profiler\n\ Returns a profiler that doesn't collect any timing information, which is\n\ ! useful in building a coverage analysis tool."); static PyObject * *************** *** 1553,1567 **** } ! static char resolution__doc__[] = #ifdef MS_WIN32 "resolution() -> (performance-counter-ticks, update-frequency)\n" "Return the resolution of the timer provided by the QueryPerformanceCounter()\n" "function. The first value is the smallest observed change, and the second\n" ! "is the result of QueryPerformanceFrequency()."; #else "resolution() -> (gettimeofday-usecs, getrusage-usecs)\n" "Return the resolution of the timers provided by the gettimeofday() and\n" ! "getrusage() system calls, or -1 if the call is not supported."; #endif static PyObject * --- 1553,1572 ---- } ! PyDoc_VAR(resolution__doc__) = #ifdef MS_WIN32 + PyDoc_STR( "resolution() -> (performance-counter-ticks, update-frequency)\n" "Return the resolution of the timer provided by the QueryPerformanceCounter()\n" "function. The first value is the smallest observed change, and the second\n" ! "is the result of QueryPerformanceFrequency()." ! ) #else + PyDoc_STR( "resolution() -> (gettimeofday-usecs, getrusage-usecs)\n" "Return the resolution of the timers provided by the gettimeofday() and\n" ! "getrusage() system calls, or -1 if the call is not supported." ! ) #endif + ; static PyObject * Index: _localemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_localemodule.c,v retrieving revision 2.31 retrieving revision 2.32 diff -C2 -d -r2.31 -r2.32 *** _localemodule.c 2 May 2002 12:16:29 -0000 2.31 --- _localemodule.c 13 Jun 2002 20:32:45 -0000 2.32 *************** *** 39,43 **** #endif ! static char locale__doc__[] = "Support for POSIX locales."; static PyObject *Error; --- 39,43 ---- #endif ! PyDoc_STRVAR(locale__doc__, "Support for POSIX locales."); static PyObject *Error; *************** *** 45,51 **** /* support functions for formatting floating point numbers */ ! static char setlocale__doc__[] = ! "(integer,string=None) -> string. Activates/queries locale processing." ! ; /* to record the LC_NUMERIC settings */ --- 45,50 ---- /* support functions for formatting floating point numbers */ ! PyDoc_STRVAR(setlocale__doc__, ! "(integer,string=None) -> string. Activates/queries locale processing."); /* to record the LC_NUMERIC settings */ *************** *** 245,251 **** } ! static char localeconv__doc__[] = ! "() -> dict. Returns numeric and monetary locale-specific parameters." ! ; static PyObject* --- 244,249 ---- } ! PyDoc_STRVAR(localeconv__doc__, ! "() -> dict. Returns numeric and monetary locale-specific parameters."); static PyObject* *************** *** 322,328 **** } ! static char strcoll__doc__[] = ! "string,string -> int. Compares two strings according to the locale." ! ; static PyObject* --- 320,325 ---- } ! PyDoc_STRVAR(strcoll__doc__, ! "string,string -> int. Compares two strings according to the locale."); static PyObject* *************** *** 336,342 **** } ! static char strxfrm__doc__[] = ! "string -> string. Returns a string that behaves for cmp locale-aware." ! ; static PyObject* --- 333,338 ---- } ! PyDoc_STRVAR(strxfrm__doc__, ! "string -> string. Returns a string that behaves for cmp locale-aware."); static PyObject* *************** *** 522,529 **** }; ! static char nl_langinfo__doc__[] = "nl_langinfo(key) -> string\n" ! "Return the value for the locale information associated with key." ! ; static PyObject* --- 518,524 ---- }; ! PyDoc_STRVAR(nl_langinfo__doc__, "nl_langinfo(key) -> string\n" ! "Return the value for the locale information associated with key."); static PyObject* *************** *** 546,552 **** #ifdef HAVE_LIBINTL_H ! static char gettext__doc__[]= "gettext(msg) -> string\n" ! "Return translation of msg."; static PyObject* --- 541,547 ---- #ifdef HAVE_LIBINTL_H ! PyDoc_STRVAR(gettext__doc__, "gettext(msg) -> string\n" ! "Return translation of msg."); static PyObject* *************** *** 559,565 **** } ! static char dgettext__doc__[]= "dgettext(domain, msg) -> string\n" ! "Return translation of msg in domain."; static PyObject* --- 554,560 ---- } ! PyDoc_STRVAR(dgettext__doc__, "dgettext(domain, msg) -> string\n" ! "Return translation of msg in domain."); static PyObject* *************** *** 572,578 **** } ! static char dcgettext__doc__[]= "dcgettext(domain, msg, category) -> string\n" ! "Return translation of msg in domain and category."; static PyObject* --- 567,573 ---- } ! PyDoc_STRVAR(dcgettext__doc__, "dcgettext(domain, msg, category) -> string\n" ! "Return translation of msg in domain and category."); static PyObject* *************** *** 586,592 **** } ! static char textdomain__doc__[]= "textdomain(domain) -> string\n" ! "Set the C library's textdmain to domain, returning the new domain."; static PyObject* --- 581,587 ---- } ! PyDoc_STRVAR(textdomain__doc__, "textdomain(domain) -> string\n" ! "Set the C library's textdmain to domain, returning the new domain."); static PyObject* *************** *** 604,610 **** } ! static char bindtextdomain__doc__[]= "bindtextdomain(domain, dir) -> string\n" ! "Bind the C library's domain to dir."; static PyObject* --- 599,605 ---- } ! PyDoc_STRVAR(bindtextdomain__doc__, "bindtextdomain(domain, dir) -> string\n" ! "Bind the C library's domain to dir."); static PyObject* Index: _ssl.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_ssl.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** _ssl.c 27 Apr 2002 18:44:29 -0000 1.3 --- _ssl.c 13 Jun 2002 20:32:47 -0000 1.4 *************** *** 260,265 **** } ! static char ssl_doc[] = ! "ssl(socket, [keyfile, certfile]) -> sslobject"; /* SSL object methods */ --- 260,265 ---- } ! PyDoc_STRVAR(ssl_doc, ! "ssl(socket, [keyfile, certfile]) -> sslobject"); /* SSL object methods */ *************** *** 307,315 **** } ! static char PySSL_SSLwrite_doc[] = "write(s) -> len\n\ \n\ Writes the string s into the SSL object. Returns the number\n\ ! of bytes written."; static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args) --- 307,315 ---- } ! PyDoc_STRVAR(PySSL_SSLwrite_doc, "write(s) -> len\n\ \n\ Writes the string s into the SSL object. Returns the number\n\ ! of bytes written."); static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args) *************** *** 337,344 **** } ! static char PySSL_SSLread_doc[] = "read([len]) -> string\n\ \n\ ! Read up to len bytes from the SSL socket."; static PyMethodDef PySSLMethods[] = { --- 337,344 ---- } ! PyDoc_STRVAR(PySSL_SSLread_doc, "read([len]) -> string\n\ \n\ ! Read up to len bytes from the SSL socket."); static PyMethodDef PySSLMethods[] = { *************** *** 393,401 **** } ! static char PySSL_RAND_add_doc[] = "RAND_add(string, entropy)\n\ \n\ Mix string into the OpenSSL PRNG state. entropy (a float) is a lower\n\ ! bound on the entropy contained in string."; static PyObject * --- 393,401 ---- } ! PyDoc_STRVAR(PySSL_RAND_add_doc, "RAND_add(string, entropy)\n\ \n\ Mix string into the OpenSSL PRNG state. entropy (a float) is a lower\n\ ! bound on the entropy contained in string."); static PyObject * *************** *** 405,414 **** } ! static char PySSL_RAND_status_doc[] = "RAND_status() -> 0 or 1\n\ \n\ Returns 1 if the OpenSSL PRNG has been seeded with enough data and 0 if not.\n\ It is necessary to seed the PRNG with RAND_add() on some platforms before\n\ ! using the ssl() function."; static PyObject * --- 405,414 ---- } ! PyDoc_STRVAR(PySSL_RAND_status_doc, "RAND_status() -> 0 or 1\n\ \n\ Returns 1 if the OpenSSL PRNG has been seeded with enough data and 0 if not.\n\ It is necessary to seed the PRNG with RAND_add() on some platforms before\n\ ! using the ssl() function."); static PyObject * *************** *** 431,440 **** } ! static char PySSL_RAND_egd_doc[] = "RAND_egd(path) -> bytes\n\ \n\ Queries the entropy gather daemon (EGD) on socket path. Returns number\n\ of bytes read. Raises socket.sslerror if connection to EGD fails or\n\ ! if it does provide enough data to seed PRNG."; #endif --- 431,440 ---- } ! PyDoc_STRVAR(PySSL_RAND_egd_doc, "RAND_egd(path) -> bytes\n\ \n\ Queries the entropy gather daemon (EGD) on socket path. Returns number\n\ of bytes read. Raises socket.sslerror if connection to EGD fails or\n\ ! if it does provide enough data to seed PRNG."); #endif *************** *** 457,463 **** ! static char module_doc[] = "Implementation module for SSL socket operations. See the socket module\n\ ! for documentation."; DL_EXPORT(void) --- 457,463 ---- ! PyDoc_STRVAR(module_doc, "Implementation module for SSL socket operations. See the socket module\n\ ! for documentation."); DL_EXPORT(void) Index: _weakref.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_weakref.c,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** _weakref.c 23 Oct 2001 21:12:47 -0000 1.15 --- _weakref.c 13 Jun 2002 20:32:47 -0000 1.16 *************** *** 6,12 **** ! static char weakref_getweakrefcount__doc__[] = "getweakrefcount(object) -- return the number of weak references\n" ! "to 'object'."; static PyObject * --- 6,12 ---- ! PyDoc_STRVAR(weakref_getweakrefcount__doc__, "getweakrefcount(object) -- return the number of weak references\n" ! "to 'object'."); static PyObject * *************** *** 27,33 **** ! static char weakref_getweakrefs__doc__[] = "getweakrefs(object) -- return a list of all weak reference objects\n" ! "that point to 'object'."; static PyObject * --- 27,33 ---- ! PyDoc_STRVAR(weakref_getweakrefs__doc__, "getweakrefs(object) -- return a list of all weak reference objects\n" ! "that point to 'object'."); static PyObject * *************** *** 58,65 **** ! static char weakref_ref__doc__[] = "new(object[, callback]) -- create a weak reference to 'object';\n" "when 'object' is finalized, 'callback' will be called and passed\n" ! "a reference to 'object'."; static PyObject * --- 58,65 ---- ! PyDoc_STRVAR(weakref_ref__doc__, "new(object[, callback]) -- create a weak reference to 'object';\n" "when 'object' is finalized, 'callback' will be called and passed\n" ! "a reference to 'object'."); static PyObject * *************** *** 77,84 **** ! static char weakref_proxy__doc__[] = "proxy(object[, callback]) -- create a proxy object that weakly\n" "references 'object'. 'callback', if given, is called with a\n" ! "reference to the proxy when it is about to be finalized."; static PyObject * --- 77,84 ---- ! PyDoc_STRVAR(weakref_proxy__doc__, "proxy(object[, callback]) -- create a proxy object that weakly\n" "references 'object'. 'callback', if given, is called with a\n" ! "reference to the proxy when it is about to be finalized."); static PyObject * Index: almodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/almodule.c,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** almodule.c 8 Dec 2001 18:02:55 -0000 1.35 --- almodule.c 13 Jun 2002 20:32:48 -0000 1.36 *************** *** 273,279 **** } ! static char alc_SetWidth__doc__[] = ! "alSetWidth: set the wordsize for integer audio data." ! ; static PyObject * --- 273,278 ---- } ! PyDoc_STRVAR(alc_SetWidth__doc__, ! "alSetWidth: set the wordsize for integer audio data."); static PyObject * *************** *** 284,290 **** ! static char alc_GetWidth__doc__[] = ! "alGetWidth: get the wordsize for integer audio data." ! ; static PyObject * --- 283,288 ---- ! PyDoc_STRVAR(alc_GetWidth__doc__, ! "alGetWidth: get the wordsize for integer audio data."); static PyObject * *************** *** 295,301 **** ! static char alc_SetSampFmt__doc__[] = ! "alSetSampFmt: set the sample format setting in an audio ALconfig structure." ! ; static PyObject * --- 293,299 ---- ! PyDoc_STRVAR(alc_SetSampFmt__doc__, ! "alSetSampFmt: set the sample format setting in an audio ALconfig " ! "structure."); static PyObject * *************** *** 306,312 **** ! static char alc_GetSampFmt__doc__[] = ! "alGetSampFmt: get the sample format setting in an audio ALconfig structure." ! ; static PyObject * --- 304,310 ---- ! PyDoc_STRVAR(alc_GetSampFmt__doc__, ! "alGetSampFmt: get the sample format setting in an audio ALconfig " ! "structure."); static PyObject * *************** *** 317,323 **** ! static char alc_SetChannels__doc__[] = ! "alSetChannels: set the channel settings in an audio ALconfig." ! ; static PyObject * --- 315,320 ---- ! PyDoc_STRVAR(alc_SetChannels__doc__, ! "alSetChannels: set the channel settings in an audio ALconfig."); static PyObject * *************** *** 328,334 **** ! static char alc_GetChannels__doc__[] = ! "alGetChannels: get the channel settings in an audio ALconfig." ! ; static PyObject * --- 325,330 ---- ! PyDoc_STRVAR(alc_GetChannels__doc__, ! "alGetChannels: get the channel settings in an audio ALconfig."); static PyObject * *************** *** 339,345 **** ! static char alc_SetFloatMax__doc__[] = ! "alSetFloatMax: set the maximum value of floating point sample data." ! ; static PyObject * --- 335,340 ---- ! PyDoc_STRVAR(alc_SetFloatMax__doc__, ! "alSetFloatMax: set the maximum value of floating point sample data."); static PyObject * *************** *** 357,363 **** ! static char alc_GetFloatMax__doc__[] = ! "alGetFloatMax: get the maximum value of floating point sample data." ! ; static PyObject * --- 352,357 ---- ! PyDoc_STRVAR(alc_GetFloatMax__doc__, ! "alGetFloatMax: get the maximum value of floating point sample data."); static PyObject * *************** *** 374,380 **** ! static char alc_SetDevice__doc__[] = ! "alSetDevice: set the device setting in an audio ALconfig structure." ! ; static PyObject * --- 368,373 ---- ! PyDoc_STRVAR(alc_SetDevice__doc__, ! "alSetDevice: set the device setting in an audio ALconfig structure."); static PyObject * *************** *** 385,391 **** ! static char alc_GetDevice__doc__[] = ! "alGetDevice: get the device setting in an audio ALconfig structure." ! ; static PyObject * --- 378,383 ---- ! PyDoc_STRVAR(alc_GetDevice__doc__, ! "alGetDevice: get the device setting in an audio ALconfig structure."); static PyObject * *************** *** 396,402 **** ! static char alc_SetQueueSize__doc__[] = ! "alSetQueueSize: set audio port buffer size." ! ; static PyObject * --- 388,393 ---- ! PyDoc_STRVAR(alc_SetQueueSize__doc__, ! "alSetQueueSize: set audio port buffer size."); static PyObject * *************** *** 407,413 **** ! static char alc_GetQueueSize__doc__[] = ! "alGetQueueSize: get audio port buffer size." ! ; static PyObject * --- 398,403 ---- ! PyDoc_STRVAR(alc_GetQueueSize__doc__, ! "alGetQueueSize: get audio port buffer size."); static PyObject * *************** *** 591,597 **** } ! static char Alctype__doc__[] = ! "" ! ; static PyTypeObject Alctype = { --- 581,585 ---- } ! PyDoc_STRVAR(Alctype__doc__, ""); static PyTypeObject Alctype = { *************** *** 625,631 **** #ifdef AL_NO_ELEM /* IRIX 6 */ ! static char alp_SetConfig__doc__[] = ! "alSetConfig: set the ALconfig of an audio ALport." ! ; static PyObject * --- 613,618 ---- #ifdef AL_NO_ELEM /* IRIX 6 */ ! PyDoc_STRVAR(alp_SetConfig__doc__, ! "alSetConfig: set the ALconfig of an audio ALport."); static PyObject * *************** *** 642,648 **** ! static char alp_GetConfig__doc__[] = ! "alGetConfig: get the ALconfig of an audio ALport." ! ; static PyObject * --- 629,634 ---- ! PyDoc_STRVAR(alp_GetConfig__doc__, ! "alGetConfig: get the ALconfig of an audio ALport."); static PyObject * *************** *** 658,664 **** ! static char alp_GetResource__doc__[] = ! "alGetResource: get the resource associated with an audio port." ! ; static PyObject * --- 644,649 ---- ! PyDoc_STRVAR(alp_GetResource__doc__, ! "alGetResource: get the resource associated with an audio port."); static PyObject * *************** *** 675,681 **** ! static char alp_GetFD__doc__[] = ! "alGetFD: get the file descriptor for an audio port." ! ; static PyObject * --- 660,665 ---- ! PyDoc_STRVAR(alp_GetFD__doc__, ! "alGetFD: get the file descriptor for an audio port."); static PyObject * *************** *** 694,700 **** ! static char alp_GetFilled__doc__[] = ! "alGetFilled: return the number of filled sample frames in an audio port." ! ; static PyObject * --- 678,684 ---- ! PyDoc_STRVAR(alp_GetFilled__doc__, ! "alGetFilled: return the number of filled sample frames in " ! "an audio port."); static PyObject * *************** *** 711,717 **** ! static char alp_GetFillable__doc__[] = ! "alGetFillable: report the number of unfilled sample frames in an audio port." ! ; static PyObject * --- 695,701 ---- ! PyDoc_STRVAR(alp_GetFillable__doc__, ! "alGetFillable: report the number of unfilled sample frames " ! "in an audio port."); static PyObject * *************** *** 728,734 **** ! static char alp_ReadFrames__doc__[] = ! "alReadFrames: read sample frames from an audio port." ! ; static PyObject * --- 712,717 ---- ! PyDoc_STRVAR(alp_ReadFrames__doc__, ! "alReadFrames: read sample frames from an audio port."); static PyObject * *************** *** 797,803 **** ! static char alp_DiscardFrames__doc__[] = ! "alDiscardFrames: discard audio from an audio port." ! ; static PyObject * --- 780,785 ---- ! PyDoc_STRVAR(alp_DiscardFrames__doc__, ! "alDiscardFrames: discard audio from an audio port."); static PyObject * *************** *** 820,826 **** ! static char alp_ZeroFrames__doc__[] = ! "alZeroFrames: write zero-valued sample frames to an audio port." ! ; static PyObject * --- 802,807 ---- ! PyDoc_STRVAR(alp_ZeroFrames__doc__, ! "alZeroFrames: write zero-valued sample frames to an audio port."); static PyObject * *************** *** 846,852 **** ! static char alp_SetFillPoint__doc__[] = ! "alSetFillPoint: set low- or high-water mark for an audio port." ! ; static PyObject * --- 827,832 ---- ! PyDoc_STRVAR(alp_SetFillPoint__doc__, ! "alSetFillPoint: set low- or high-water mark for an audio port."); static PyObject * *************** *** 866,872 **** ! static char alp_GetFillPoint__doc__[] = ! "alGetFillPoint: get low- or high-water mark for an audio port." ! ; static PyObject * --- 846,851 ---- ! PyDoc_STRVAR(alp_GetFillPoint__doc__, ! "alGetFillPoint: get low- or high-water mark for an audio port."); static PyObject * *************** *** 885,891 **** ! static char alp_GetFrameNumber__doc__[] = ! "alGetFrameNumber: get the absolute sample frame number associated with a port." ! ; static PyObject * --- 864,870 ---- ! PyDoc_STRVAR(alp_GetFrameNumber__doc__, ! "alGetFrameNumber: get the absolute sample frame number " ! "associated with a port."); static PyObject * *************** *** 904,910 **** ! static char alp_GetFrameTime__doc__[] = ! "alGetFrameTime: get the time at which a sample frame came in or will go out." ! ; static PyObject * --- 883,889 ---- ! PyDoc_STRVAR(alp_GetFrameTime__doc__, ! "alGetFrameTime: get the time at which a sample frame came " ! "in or will go out."); static PyObject * *************** *** 932,938 **** ! static char alp_WriteFrames__doc__[] = ! "alWriteFrames: write sample frames to an audio port." ! ; static PyObject * --- 911,916 ---- ! PyDoc_STRVAR(alp_WriteFrames__doc__, ! "alWriteFrames: write sample frames to an audio port."); static PyObject * *************** *** 998,1004 **** ! static char alp_ClosePort__doc__[] = ! "alClosePort: close an audio port." ! ; static PyObject * --- 976,980 ---- ! PyDoc_STRVAR(alp_ClosePort__doc__, "alClosePort: close an audio port."); static PyObject * *************** *** 1315,1321 **** } ! static char Alptype__doc__[] = ! "" ! ; static PyTypeObject Alptype = { --- 1291,1295 ---- } ! PyDoc_STRVAR(Alptype__doc__, ""); static PyTypeObject Alptype = { *************** *** 1350,1356 **** #ifdef AL_NO_ELEM /* IRIX 6 */ ! static char al_NewConfig__doc__[] = ! "alNewConfig: create and initialize an audio ALconfig structure." ! ; static PyObject * --- 1324,1329 ---- #ifdef AL_NO_ELEM /* IRIX 6 */ ! PyDoc_STRVAR(al_NewConfig__doc__, ! "alNewConfig: create and initialize an audio ALconfig structure."); static PyObject * *************** *** 1366,1372 **** } ! static char al_OpenPort__doc__[] = ! "alOpenPort: open an audio port." ! ; static PyObject * --- 1339,1344 ---- } ! PyDoc_STRVAR(al_OpenPort__doc__, ! "alOpenPort: open an audio port."); static PyObject * *************** *** 1384,1390 **** } ! static char al_Connect__doc__[] = ! "alConnect: connect two audio I/O resources." ! ; static PyObject * --- 1356,1361 ---- } ! PyDoc_STRVAR(al_Connect__doc__, ! "alConnect: connect two audio I/O resources."); static PyObject * *************** *** 1424,1430 **** } ! static char al_Disconnect__doc__[] = ! "alDisconnect: delete a connection between two audio I/O resources." ! ; static PyObject * --- 1395,1400 ---- } ! PyDoc_STRVAR(al_Disconnect__doc__, ! "alDisconnect: delete a connection between two audio I/O resources."); static PyObject * *************** *** 1441,1447 **** } ! static char al_GetParams__doc__[] = ! "alGetParams: get the values of audio resource parameters." ! ; static PyObject * --- 1411,1416 ---- } ! PyDoc_STRVAR(al_GetParams__doc__, ! "alGetParams: get the values of audio resource parameters."); static PyObject * *************** *** 1586,1592 **** } ! static char al_SetParams__doc__[] = ! "alSetParams: set the values of audio resource parameters." ! ; static PyObject * --- 1555,1560 ---- } ! PyDoc_STRVAR(al_SetParams__doc__, ! "alSetParams: set the values of audio resource parameters."); static PyObject * *************** *** 1632,1638 **** } ! static char al_QueryValues__doc__[] = ! "alQueryValues: get the set of possible values for a parameter." ! ; static PyObject * --- 1600,1605 ---- } ! PyDoc_STRVAR(al_QueryValues__doc__, ! "alQueryValues: get the set of possible values for a parameter."); static PyObject * *************** *** 1712,1718 **** } ! static char al_GetParamInfo__doc__[] = ! "alGetParamInfo: get information about a parameter on a particular audio resource." ! ; static PyObject * --- 1679,1685 ---- } ! PyDoc_STRVAR(al_GetParamInfo__doc__, ! "alGetParamInfo: get information about a parameter on " ! "a particular audio resource."); static PyObject * *************** *** 1795,1801 **** } ! static char al_GetResourceByName__doc__[] = ! "alGetResourceByName: find an audio resource by name." ! ; static PyObject * --- 1762,1767 ---- } ! PyDoc_STRVAR(al_GetResourceByName__doc__, ! "alGetResourceByName: find an audio resource by name."); static PyObject * *************** *** 1812,1818 **** } ! static char al_IsSubtype__doc__[] = ! "alIsSubtype: indicate if one resource type is a subtype of another." ! ; static PyObject * --- 1778,1783 ---- } ! PyDoc_STRVAR(al_IsSubtype__doc__, ! "alIsSubtype: indicate if one resource type is a subtype of another."); static PyObject * *************** *** 1826,1832 **** } ! static char al_SetErrorHandler__doc__[] = ! "" ! ; static PyObject * --- 1791,1795 ---- } ! PyDoc_STRVAR(al_SetErrorHandler__doc__, ""); static PyObject * *************** *** 2025,2031 **** /* Initialization function for the module (*must* be called inital) */ ! static char al_module_documentation[] = ! "" ! ; void --- 1988,1992 ---- /* Initialization function for the module (*must* be called inital) */ ! PyDoc_STRVAR(al_module_documentation, ""); void Index: arraymodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/arraymodule.c,v retrieving revision 2.73 retrieving revision 2.74 diff -C2 -d -r2.73 -r2.74 *** arraymodule.c 13 May 2002 10:14:59 -0000 2.73 --- arraymodule.c 13 Jun 2002 20:32:48 -0000 2.74 *************** *** 821,828 **** } ! static char count_doc [] = "count(x)\n\ \n\ ! Return number of occurences of x in the array."; static PyObject * --- 821,828 ---- } ! PyDoc_STRVAR(count_doc, "count(x)\n\ \n\ ! Return number of occurences of x in the array."); static PyObject * *************** *** 848,855 **** } ! static char index_doc [] = "index(x)\n\ \n\ ! Return index of first occurence of x in the array."; static PyObject * --- 848,855 ---- } ! PyDoc_STRVAR(index_doc, "index(x)\n\ \n\ ! Return index of first occurence of x in the array."); static PyObject * *************** *** 879,886 **** } ! static char remove_doc [] = "remove(x)\n\ \n\ ! Remove the first occurence of x in the array."; static PyObject * --- 879,886 ---- } ! PyDoc_STRVAR(remove_doc, "remove(x)\n\ \n\ ! Remove the first occurence of x in the array."); static PyObject * *************** *** 910,917 **** } ! static char pop_doc [] = "pop([i])\n\ \n\ ! Return the i-th element and delete it from the array. i defaults to -1."; static PyObject * --- 910,917 ---- } ! PyDoc_STRVAR(pop_doc, "pop([i])\n\ \n\ ! Return the i-th element and delete it from the array. i defaults to -1."); static PyObject * *************** *** 928,935 **** } ! static char extend_doc [] = "extend(array)\n\ \n\ ! Append array items to the end of the array."; static PyObject * --- 928,935 ---- } ! PyDoc_STRVAR(extend_doc, "extend(array)\n\ \n\ ! Append array items to the end of the array."); static PyObject * *************** *** 943,950 **** } ! static char insert_doc [] = "insert(i,x)\n\ \n\ ! Insert a new item x into the array before position i."; --- 943,950 ---- } ! PyDoc_STRVAR(insert_doc, "insert(i,x)\n\ \n\ ! Insert a new item x into the array before position i."); *************** *** 965,969 **** } ! static char buffer_info_doc [] = "buffer_info() -> (address, length)\n\ \n\ --- 965,969 ---- } ! PyDoc_STRVAR(buffer_info_doc, "buffer_info() -> (address, length)\n\ \n\ *************** *** 971,975 **** the length in items of the buffer used to hold array's contents\n\ The length should be multiplied by the itemsize attribute to calculate\n\ ! the buffer length in bytes."; --- 971,975 ---- the length in items of the buffer used to hold array's contents\n\ The length should be multiplied by the itemsize attribute to calculate\n\ ! the buffer length in bytes."); *************** *** 983,990 **** } ! static char append_doc [] = "append(x)\n\ \n\ ! Append new value x to the end of the array."; --- 983,990 ---- } ! PyDoc_STRVAR(append_doc, "append(x)\n\ \n\ ! Append new value x to the end of the array."); *************** *** 1043,1051 **** } ! static char byteswap_doc [] = "byteswap()\n\ \n\ Byteswap all items of the array. If the items in the array are not 1, 2,\n\ ! 4, or 8 bytes in size, RuntimeError is raised."; static PyObject * --- 1043,1051 ---- } ! PyDoc_STRVAR(byteswap_doc, "byteswap()\n\ \n\ Byteswap all items of the array. If the items in the array are not 1, 2,\n\ ! 4, or 8 bytes in size, RuntimeError is raised."); static PyObject * *************** *** 1079,1086 **** } ! static char reverse_doc [] = "reverse()\n\ \n\ ! Reverse the order of the items in the array."; static PyObject * --- 1079,1086 ---- } ! PyDoc_STRVAR(reverse_doc, "reverse()\n\ \n\ ! Reverse the order of the items in the array."); static PyObject * *************** *** 1131,1139 **** } ! static char fromfile_doc [] = "fromfile(f, n)\n\ \n\ Read n objects from the file object f and append them to the end of the\n\ ! array. Also called as read."; --- 1131,1139 ---- } ! PyDoc_STRVAR(fromfile_doc, "fromfile(f, n)\n\ \n\ Read n objects from the file object f and append them to the end of the\n\ ! array. Also called as read."); *************** *** 1162,1170 **** } ! static char tofile_doc [] = "tofile(f)\n\ \n\ Write all items (as machine values) to the file object f. Also called as\n\ ! write."; --- 1162,1170 ---- } ! PyDoc_STRVAR(tofile_doc, "tofile(f)\n\ \n\ Write all items (as machine values) to the file object f. Also called as\n\ ! write."); *************** *** 1208,1215 **** } ! static char fromlist_doc [] = "fromlist(list)\n\ \n\ ! Append items to array from list."; --- 1208,1215 ---- } ! PyDoc_STRVAR(fromlist_doc, "fromlist(list)\n\ \n\ ! Append items to array from list."); *************** *** 1234,1241 **** } ! static char tolist_doc [] = "tolist() -> list\n\ \n\ ! Convert array to an ordinary list with the same items."; --- 1234,1241 ---- } ! PyDoc_STRVAR(tolist_doc, "tolist() -> list\n\ \n\ ! Convert array to an ordinary list with the same items."); *************** *** 1270,1278 **** } ! static char fromstring_doc [] = "fromstring(string)\n\ \n\ Appends items from the string, interpreting it as an array of machine\n\ ! values,as if it had been read from a file using the fromfile() method)."; --- 1270,1278 ---- } ! PyDoc_STRVAR(fromstring_doc, "fromstring(string)\n\ \n\ Appends items from the string, interpreting it as an array of machine\n\ ! values,as if it had been read from a file using the fromfile() method)."); *************** *** 1286,1294 **** } ! static char tostring_doc [] = "tostring() -> string\n\ \n\ Convert the array to an array of machine values and return the string\n\ ! representation."; --- 1286,1294 ---- } ! PyDoc_STRVAR(tostring_doc, "tostring() -> string\n\ \n\ Convert the array to an array of machine values and return the string\n\ ! representation."); *************** *** 1326,1330 **** } ! static char fromunicode_doc[] = "fromunicode(ustr)\n\ \n\ --- 1326,1330 ---- } ! PyDoc_STRVAR(fromunicode_doc, "fromunicode(ustr)\n\ \n\ *************** *** 1332,1336 **** The array must be a type 'u' array; otherwise a ValueError\n\ is raised. Use array.fromstring(ustr.decode(...)) to\n\ ! append Unicode data to an array of some other type."; --- 1332,1336 ---- The array must be a type 'u' array; otherwise a ValueError\n\ is raised. Use array.fromstring(ustr.decode(...)) to\n\ ! append Unicode data to an array of some other type."); *************** *** 1348,1352 **** } ! static char tounicode_doc [] = "tounicode() -> unicode\n\ \n\ --- 1348,1352 ---- } ! PyDoc_STRVAR(tounicode_doc, "tounicode() -> unicode\n\ \n\ *************** *** 1354,1358 **** a type 'u' array; otherwise a ValueError is raised. Use\n\ array.tostring().decode() to obtain a unicode string from\n\ ! an array of some other type."; #endif /* Py_USING_UNICODE */ --- 1354,1358 ---- a type 'u' array; otherwise a ValueError is raised. Use\n\ array.tostring().decode() to obtain a unicode string from\n\ ! an array of some other type."); #endif /* Py_USING_UNICODE */ *************** *** 1622,1626 **** ! static char module_doc [] = "This module defines an object type which can efficiently represent\n\ an array of basic values: characters, integers, floating point\n\ --- 1622,1626 ---- ! PyDoc_STRVAR(module_doc, "This module defines an object type which can efficiently represent\n\ an array of basic values: characters, integers, floating point\n\ *************** *** 1647,1653 **** \n\ array(typecode [, initializer]) -- create a new array\n\ ! "; ! static char arraytype_doc [] = "array(typecode [, initializer]) -> array\n\ \n\ --- 1647,1653 ---- \n\ array(typecode [, initializer]) -- create a new array\n\ ! "); ! PyDoc_STRVAR(arraytype_doc, "array(typecode [, initializer]) -> array\n\ \n\ *************** *** 1684,1688 **** typecode -- the typecode character used to create the array\n\ itemsize -- the length in bytes of one array item\n\ ! "; statichere PyTypeObject Arraytype = { --- 1684,1688 ---- typecode -- the typecode character used to create the array\n\ itemsize -- the length in bytes of one array item\n\ ! "); statichere PyTypeObject Arraytype = { Index: binascii.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/binascii.c,v retrieving revision 2.33 retrieving revision 2.34 diff -C2 -d -r2.33 -r2.34 *** binascii.c 19 Dec 2001 04:41:35 -0000 2.33 --- binascii.c 13 Jun 2002 20:32:48 -0000 2.34 *************** *** 180,184 **** }; ! static char doc_a2b_uu[] = "(ascii) -> bin. Decode a line of uuencoded data"; static PyObject * --- 180,184 ---- }; ! PyDoc_STRVAR(doc_a2b_uu, "(ascii) -> bin. Decode a line of uuencoded data"); static PyObject * *************** *** 255,259 **** } ! static char doc_b2a_uu[] = "(bin) -> ascii. Uuencode line of data"; static PyObject * --- 255,259 ---- } ! PyDoc_STRVAR(doc_b2a_uu, "(bin) -> ascii. Uuencode line of data"); static PyObject * *************** *** 331,335 **** } ! static char doc_a2b_base64[] = "(ascii) -> bin. Decode a line of base64 data"; static PyObject * --- 331,335 ---- } ! PyDoc_STRVAR(doc_a2b_base64, "(ascii) -> bin. Decode a line of base64 data"); static PyObject * *************** *** 418,422 **** } ! static char doc_b2a_base64[] = "(bin) -> ascii. Base64-code line of data"; static PyObject * --- 418,422 ---- } ! PyDoc_STRVAR(doc_b2a_base64, "(bin) -> ascii. Base64-code line of data"); static PyObject * *************** *** 471,475 **** } ! static char doc_a2b_hqx[] = "ascii -> bin, done. Decode .hqx coding"; static PyObject * --- 471,475 ---- } ! PyDoc_STRVAR(doc_a2b_hqx, "ascii -> bin, done. Decode .hqx coding"); static PyObject * *************** *** 535,539 **** } ! static char doc_rlecode_hqx[] = "Binhex RLE-code binary data"; static PyObject * --- 535,539 ---- } ! PyDoc_STRVAR(doc_rlecode_hqx, "Binhex RLE-code binary data"); static PyObject * *************** *** 582,586 **** } ! static char doc_b2a_hqx[] = "Encode .hqx data"; static PyObject * --- 582,586 ---- } ! PyDoc_STRVAR(doc_b2a_hqx, "Encode .hqx data"); static PyObject * *************** *** 622,626 **** } ! static char doc_rledecode_hqx[] = "Decode hexbin RLE-coded string"; static PyObject * --- 622,626 ---- } ! PyDoc_STRVAR(doc_rledecode_hqx, "Decode hexbin RLE-coded string"); static PyObject * *************** *** 718,723 **** } ! static char doc_crc_hqx[] = ! "(data, oldcrc) -> newcrc. Compute hqx CRC incrementally"; static PyObject * --- 718,723 ---- } ! PyDoc_STRVAR(doc_crc_hqx, ! "(data, oldcrc) -> newcrc. Compute hqx CRC incrementally"); static PyObject * *************** *** 738,743 **** } ! static char doc_crc32[] = ! "(data, oldcrc = 0) -> newcrc. Compute CRC-32 incrementally"; /* Crc - 32 BIT ANSI X3.66 CRC checksum files --- 738,743 ---- } ! PyDoc_STRVAR(doc_crc32, ! "(data, oldcrc = 0) -> newcrc. Compute CRC-32 incrementally"); /* Crc - 32 BIT ANSI X3.66 CRC checksum files *************** *** 913,920 **** } ! static char doc_hexlify[] = "b2a_hex(data) -> s; Hexadecimal representation of binary data.\n\ \n\ ! This function is also available as \"hexlify()\"."; --- 913,920 ---- } ! PyDoc_STRVAR(doc_hexlify, "b2a_hex(data) -> s; Hexadecimal representation of binary data.\n\ \n\ ! This function is also available as \"hexlify()\"."); *************** *** 979,987 **** } ! static char doc_unhexlify[] = "a2b_hex(hexstr) -> s; Binary data of hexadecimal representation.\n\ \n\ hexstr must contain an even number of hex digits (upper or lower case).\n\ ! This function is also available as \"unhexlify()\""; static int table_hex[128] = { --- 979,987 ---- } ! PyDoc_STRVAR(doc_unhexlify, "a2b_hex(hexstr) -> s; Binary data of hexadecimal representation.\n\ \n\ hexstr must contain an even number of hex digits (upper or lower case).\n\ ! This function is also available as \"unhexlify()\""); static int table_hex[128] = { *************** *** 1000,1004 **** #define MAXLINESIZE 76 ! static char doc_a2b_qp[] = "Decode a string of qp-encoded data"; static PyObject* --- 1000,1004 ---- #define MAXLINESIZE 76 ! PyDoc_STRVAR(doc_a2b_qp, "Decode a string of qp-encoded data"); static PyObject* *************** *** 1089,1093 **** } ! static char doc_b2a_qp[] = "b2a_qp(data, quotetabs=0, istext=1, header=0) -> s; \n\ Encode a string using quoted-printable encoding. \n\ --- 1089,1093 ---- } ! PyDoc_STRVAR(doc_b2a_qp, "b2a_qp(data, quotetabs=0, istext=1, header=0) -> s; \n\ Encode a string using quoted-printable encoding. \n\ *************** *** 1095,1099 **** On encoding, when istext is set, newlines are not encoded, and white \n\ space at end of lines is. When istext is not set, \\r and \\n (CR/LF) are \n\ ! both encoded. When quotetabs is set, space and tabs are encoded."; /* XXX: This is ridiculously complicated to be backward compatible --- 1095,1099 ---- On encoding, when istext is set, newlines are not encoded, and white \n\ space at end of lines is. When istext is not set, \\r and \\n (CR/LF) are \n\ ! both encoded. When quotetabs is set, space and tabs are encoded."); /* XXX: This is ridiculously complicated to be backward compatible *************** *** 1296,1300 **** /* Initialization function for the module (*must* be called initbinascii) */ ! static char doc_binascii[] = "Conversion between binary data and ASCII"; DL_EXPORT(void) --- 1296,1300 ---- /* Initialization function for the module (*must* be called initbinascii) */ ! PyDoc_STRVAR(doc_binascii, "Conversion between binary data and ASCII"); DL_EXPORT(void) Index: cPickle.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cPickle.c,v retrieving revision 2.84 retrieving revision 2.85 diff -C2 -d -r2.84 -r2.85 *** cPickle.c 1 May 2002 20:36:39 -0000 2.84 --- cPickle.c 13 Jun 2002 20:32:48 -0000 2.85 *************** *** 1,12 **** - static char cPickle_module_documentation[] = - "C implementation and optimization of the Python pickle module\n" - "\n" - "cPickle.c,v 1.71 1999/07/11 13:30:34 jim Exp\n" - ; - #include "Python.h" #include "cStringIO.h" #include "structmember.h" #ifndef Py_eval_input #include --- 1,11 ---- #include "Python.h" #include "cStringIO.h" #include "structmember.h" + PyDoc_STRVAR(cPickle_module_documentation, + "C implementation and optimization of the Python pickle module\n" + "\n" + "cPickle.c,v 1.71 1999/07/11 13:30:34 jim Exp\n"); + #ifndef Py_eval_input #include *************** *** 2512,2517 **** }; ! static char Picklertype__doc__[] = ! "Objects that know how to pickle objects\n"; static PyTypeObject Picklertype = { --- 2511,2516 ---- }; ! PyDoc_STRVAR(Picklertype__doc__, ! "Objects that know how to pickle objects\n"); static PyTypeObject Picklertype = { *************** *** 4610,4615 **** ! static char Unpicklertype__doc__[] = ! "Objects that know how to unpickle"; static PyTypeObject Unpicklertype = { --- 4609,4614 ---- ! PyDoc_STRVAR(Unpicklertype__doc__, ! "Objects that know how to unpickle"); static PyTypeObject Unpicklertype = { Index: cStringIO.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cStringIO.c,v retrieving revision 2.35 retrieving revision 2.36 diff -C2 -d -r2.35 -r2.36 *** cStringIO.c 29 Apr 2002 13:54:48 -0000 2.35 --- cStringIO.c 13 Jun 2002 20:32:48 -0000 2.36 *************** *** 1,3 **** ! static char cStringIO_module_documentation[] = "A simple fast partial StringIO replacement.\n" "\n" --- 1,8 ---- ! ! #include "Python.h" ! #include "import.h" ! #include "cStringIO.h" ! ! PyDoc_STRVAR(cStringIO_module_documentation, "A simple fast partial StringIO replacement.\n" "\n" *************** *** 26,35 **** "go for it. :-) \n" "\n" ! "cStringIO.c,v 1.29 1999/06/15 14:10:27 jim Exp\n" ! ; ! ! #include "Python.h" ! #include "import.h" ! #include "cStringIO.h" #define UNLESS(E) if (!(E)) --- 31,35 ---- "go for it. :-) \n" "\n" ! "cStringIO.c,v 1.29 1999/06/15 14:10:27 jim Exp\n"); #define UNLESS(E) if (!(E)) *************** *** 75,79 **** /* IOobject (common) methods */ ! static char IO_flush__doc__[] = "flush(): does nothing."; static int --- 75,79 ---- /* IOobject (common) methods */ ! PyDoc_STRVAR(IO_flush__doc__, "flush(): does nothing."); static int *************** *** 97,106 **** } ! static char IO_getval__doc__[] = ! "getvalue([use_pos]) -- Get the string value." ! "\n" ! "If use_pos is specified and is a true value, then the string returned\n" ! "will include only the text up to the current file position.\n" ! ; static PyObject * --- 97,105 ---- } ! PyDoc_STRVAR(IO_getval__doc__, ! "getvalue([use_pos]) -- Get the string value." ! "\n" ! "If use_pos is specified and is a true value, then the string returned\n" ! "will include only the text up to the current file position.\n"); static PyObject * *************** *** 128,132 **** } ! static char IO_isatty__doc__[] = "isatty(): always returns 0"; static PyObject * --- 127,131 ---- } ! PyDoc_STRVAR(IO_isatty__doc__, "isatty(): always returns 0"); static PyObject * *************** *** 138,144 **** } ! static char IO_read__doc__[] = ! "read([s]) -- Read s characters, or the rest of the string" ! ; static int --- 137,142 ---- } ! PyDoc_STRVAR(IO_read__doc__, ! "read([s]) -- Read s characters, or the rest of the string"); static int *************** *** 170,176 **** } ! static char IO_readline__doc__[] = ! "readline() -- Read one line" ! ; static int --- 168,172 ---- } ! PyDoc_STRVAR(IO_readline__doc__, "readline() -- Read one line"); static int *************** *** 208,214 **** } ! static char IO_readlines__doc__[] = ! "readlines() -- Read all lines" ! ; static PyObject * --- 204,208 ---- } ! PyDoc_STRVAR(IO_readlines__doc__, "readlines() -- Read all lines"); static PyObject * *************** *** 245,251 **** } ! static char IO_reset__doc__[] = ! "reset() -- Reset the file position to the beginning" ! ; static PyObject * --- 239,244 ---- } ! PyDoc_STRVAR(IO_reset__doc__, ! "reset() -- Reset the file position to the beginning"); static PyObject * *************** *** 261,266 **** } ! static char IO_tell__doc__[] = ! "tell() -- get the current position."; static PyObject * --- 254,258 ---- } ! PyDoc_STRVAR(IO_tell__doc__, "tell() -- get the current position."); static PyObject * *************** *** 273,278 **** } ! static char IO_truncate__doc__[] = ! "truncate(): truncate the file at the current position."; static PyObject * --- 265,270 ---- } ! PyDoc_STRVAR(IO_truncate__doc__, ! "truncate(): truncate the file at the current position."); static PyObject * *************** *** 295,301 **** /* Read-write object methods */ ! static char O_seek__doc__[] = "seek(position) -- set the current position\n" ! "seek(position, mode) -- mode 0: absolute; 1: relative; 2: relative to EOF"; static PyObject * --- 287,293 ---- /* Read-write object methods */ ! PyDoc_STRVAR(O_seek__doc__, "seek(position) -- set the current position\n" ! "seek(position, mode) -- mode 0: absolute; 1: relative; 2: relative to EOF"); static PyObject * *************** *** 333,340 **** } ! static char O_write__doc__[] = "write(s) -- Write a string to the file" ! "\n\nNote (hack:) writing None resets the buffer" ! ; --- 325,331 ---- } ! PyDoc_STRVAR(O_write__doc__, "write(s) -- Write a string to the file" ! "\n\nNote (hack:) writing None resets the buffer"); *************** *** 385,389 **** } ! static char O_close__doc__[] = "close(): explicitly release resources held."; static PyObject * --- 376,380 ---- } ! PyDoc_STRVAR(O_close__doc__, "close(): explicitly release resources held."); static PyObject * *************** *** 402,407 **** ! static char O_writelines__doc__[] = ! "writelines(sequence_of_strings): write each string"; static PyObject * O_writelines(Oobject *self, PyObject *args) { --- 393,398 ---- ! PyDoc_STRVAR(O_writelines__doc__, ! "writelines(sequence_of_strings): write each string"); static PyObject * O_writelines(Oobject *self, PyObject *args) { *************** *** 484,490 **** } ! static char Otype__doc__[] = ! "Simple type for output to strings." ! ; static PyTypeObject Otype = { --- 475,479 ---- } ! PyDoc_STRVAR(Otype__doc__, "Simple type for output to strings."); static PyTypeObject Otype = { *************** *** 618,624 **** ! static char Itype__doc__[] = ! "Simple type for treating strings as input file streams" ! ; static PyTypeObject Itype = { --- 607,612 ---- ! PyDoc_STRVAR(Itype__doc__, ! "Simple type for treating strings as input file streams"); static PyTypeObject Itype = { *************** *** 679,685 **** ! static char IO_StringIO__doc__[] = ! "StringIO([s]) -- Return a StringIO-like stream for reading or writing" ! ; static PyObject * --- 667,672 ---- ! PyDoc_STRVAR(IO_StringIO__doc__, ! "StringIO([s]) -- Return a StringIO-like stream for reading or writing"); static PyObject * Index: cmathmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cmathmodule.c,v retrieving revision 2.29 retrieving revision 2.30 diff -C2 -d -r2.29 -r2.30 *** cmathmodule.c 1 Apr 2002 03:45:06 -0000 2.29 --- cmathmodule.c 13 Jun 2002 20:32:49 -0000 2.30 *************** *** 30,37 **** } ! static char c_acos_doc[] = "acos(x)\n" "\n" ! "Return the arc cosine of x."; --- 30,37 ---- } ! PyDoc_STRVAR(c_acos_doc, "acos(x)\n" "\n" ! "Return the arc cosine of x."); *************** *** 46,53 **** } ! static char c_acosh_doc[] = "acosh(x)\n" "\n" ! "Return the hyperbolic arccosine of x."; --- 46,53 ---- } ! PyDoc_STRVAR(c_acosh_doc, "acosh(x)\n" "\n" ! "Return the hyperbolic arccosine of x."); *************** *** 63,70 **** } ! static char c_asin_doc[] = "asin(x)\n" "\n" ! "Return the arc sine of x."; --- 63,70 ---- } ! PyDoc_STRVAR(c_asin_doc, "asin(x)\n" "\n" ! "Return the arc sine of x."); *************** *** 79,86 **** } ! static char c_asinh_doc[] = "asinh(x)\n" "\n" ! "Return the hyperbolic arc sine of x."; --- 79,86 ---- } ! PyDoc_STRVAR(c_asinh_doc, "asinh(x)\n" "\n" ! "Return the hyperbolic arc sine of x."); *************** *** 91,98 **** } ! static char c_atan_doc[] = "atan(x)\n" "\n" ! "Return the arc tangent of x."; --- 91,98 ---- } ! PyDoc_STRVAR(c_atan_doc, "atan(x)\n" "\n" ! "Return the arc tangent of x."); *************** *** 103,110 **** } ! static char c_atanh_doc[] = "atanh(x)\n" "\n" ! "Return the hyperbolic arc tangent of x."; --- 103,110 ---- } ! PyDoc_STRVAR(c_atanh_doc, "atanh(x)\n" "\n" ! "Return the hyperbolic arc tangent of x."); *************** *** 118,125 **** } ! static char c_cos_doc[] = "cos(x)\n" "n" ! "Return the cosine of x."; --- 118,125 ---- } ! PyDoc_STRVAR(c_cos_doc, "cos(x)\n" "n" ! "Return the cosine of x."); *************** *** 133,140 **** } ! static char c_cosh_doc[] = "cosh(x)\n" "n" ! "Return the hyperbolic cosine of x."; --- 133,140 ---- } ! PyDoc_STRVAR(c_cosh_doc, "cosh(x)\n" "n" ! "Return the hyperbolic cosine of x."); *************** *** 149,156 **** } ! static char c_exp_doc[] = "exp(x)\n" "\n" ! "Return the exponential value e**x."; --- 149,156 ---- } ! PyDoc_STRVAR(c_exp_doc, "exp(x)\n" "\n" ! "Return the exponential value e**x."); *************** *** 165,172 **** } ! static char c_log_doc[] = "log(x)\n" "\n" ! "Return the natural logarithm of x."; --- 165,172 ---- } ! PyDoc_STRVAR(c_log_doc, "log(x)\n" "\n" ! "Return the natural logarithm of x."); *************** *** 181,188 **** } ! static char c_log10_doc[] = "log10(x)\n" "\n" ! "Return the base-10 logarithm of x."; --- 181,188 ---- } ! PyDoc_STRVAR(c_log10_doc, "log10(x)\n" "\n" ! "Return the base-10 logarithm of x."); *************** *** 207,214 **** } ! static char c_sin_doc[] = "sin(x)\n" "\n" ! "Return the sine of x."; --- 207,214 ---- } ! PyDoc_STRVAR(c_sin_doc, "sin(x)\n" "\n" ! "Return the sine of x."); *************** *** 222,229 **** } ! static char c_sinh_doc[] = "sinh(x)\n" "\n" ! "Return the hyperbolic sine of x."; --- 222,229 ---- } ! PyDoc_STRVAR(c_sinh_doc, "sinh(x)\n" "\n" ! "Return the hyperbolic sine of x."); *************** *** 254,261 **** } ! static char c_sqrt_doc[] = "sqrt(x)\n" "\n" ! "Return the square root of x."; --- 254,261 ---- } ! PyDoc_STRVAR(c_sqrt_doc, "sqrt(x)\n" "\n" ! "Return the square root of x."); *************** *** 281,288 **** } ! static char c_tan_doc[] = "tan(x)\n" "\n" ! "Return the tangent of x."; --- 281,288 ---- } ! PyDoc_STRVAR(c_tan_doc, "tan(x)\n" "\n" ! "Return the tangent of x."); *************** *** 308,315 **** } ! static char c_tanh_doc[] = "tanh(x)\n" "\n" ! "Return the hyperbolic tangent of x."; --- 308,315 ---- } ! PyDoc_STRVAR(c_tanh_doc, "tanh(x)\n" "\n" ! "Return the hyperbolic tangent of x."); *************** *** 368,374 **** ! static char module_doc[] = "This module is always available. It provides access to mathematical\n" ! "functions for complex numbers."; static PyMethodDef cmath_methods[] = { --- 368,374 ---- ! PyDoc_STRVAR(module_doc, "This module is always available. It provides access to mathematical\n" ! "functions for complex numbers."); static PyMethodDef cmath_methods[] = { Index: cryptmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cryptmodule.c,v retrieving revision 2.12 retrieving revision 2.13 diff -C2 -d -r2.12 -r2.13 *** cryptmodule.c 11 Jun 2002 06:22:31 -0000 2.12 --- cryptmodule.c 13 Jun 2002 20:32:49 -0000 2.13 *************** *** 24,34 **** } ! static char crypt_crypt__doc__[] = "\ ! crypt(word, salt) -> string\n\ word will usually be a user's password. salt is a 2-character string\n\ which will be used to select one of 4096 variations of DES. The characters\n\ in salt must be either \".\", \"/\", or an alphanumeric character. Returns\n\ the hashed password as a string, which will be composed of characters from\n\ ! the same alphabet as the salt."; --- 24,34 ---- } ! PyDoc_STRVAR(crypt_crypt__doc__, ! "crypt(word, salt) -> string\n\ word will usually be a user's password. salt is a 2-character string\n\ which will be used to select one of 4096 variations of DES. The characters\n\ in salt must be either \".\", \"/\", or an alphanumeric character. Returns\n\ the hashed password as a string, which will be composed of characters from\n\ ! the same alphabet as the salt."); Index: errnomodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/errnomodule.c,v retrieving revision 2.16 retrieving revision 2.17 diff -C2 -d -r2.16 -r2.17 *** errnomodule.c 26 Jan 2002 17:58:02 -0000 2.16 --- errnomodule.c 13 Jun 2002 20:32:49 -0000 2.17 *************** *** 44,48 **** } ! static char errno__doc__ [] = "This module makes available standard errno system symbols.\n\ \n\ --- 44,48 ---- } ! PyDoc_STRVAR(errno__doc__, "This module makes available standard errno system symbols.\n\ \n\ *************** *** 56,60 **** \n\ To map error codes to error messages, use the function os.strerror(),\n\ ! e.g. os.strerror(2) could return 'No such file or directory'."; DL_EXPORT(void) --- 56,60 ---- \n\ To map error codes to error messages, use the function os.strerror(),\n\ ! e.g. os.strerror(2) could return 'No such file or directory'."); DL_EXPORT(void) Index: fcntlmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/fcntlmodule.c,v retrieving revision 2.34 retrieving revision 2.35 diff -C2 -d -r2.34 -r2.35 *** fcntlmodule.c 3 Mar 2002 02:59:15 -0000 2.34 --- fcntlmodule.c 13 Jun 2002 20:32:49 -0000 2.35 *************** *** 73,78 **** } ! static char fcntl_doc [] = ! "fcntl(fd, opt, [arg])\n\ \n\ --- 73,77 ---- } ! PyDoc_STRVAR(fcntl_doc, "fcntl(fd, opt, [arg])\n\ \n\ *************** *** 85,89 **** of the arg string is not allowed to exceed 1024 bytes. If the arg given\n\ is an integer or if none is specified, the result value is an integer\n\ ! corresponding to the return value of the fcntl call in the C code."; --- 84,88 ---- of the arg string is not allowed to exceed 1024 bytes. If the arg given\n\ is an integer or if none is specified, the result value is an integer\n\ ! corresponding to the return value of the fcntl call in the C code."); *************** *** 137,141 **** } ! static char ioctl_doc [] = "ioctl(fd, opt, [arg])\n\ \n\ --- 136,140 ---- } ! PyDoc_STRVAR(ioctl_doc, "ioctl(fd, opt, [arg])\n\ \n\ *************** *** 148,152 **** The length of the arg string is not allowed to exceed 1024 bytes. If the arg\n\ given is an integer or if none is specified, the result value is an integer\n\ ! corresponding to the return value of the ioctl call in the C code."; --- 147,151 ---- The length of the arg string is not allowed to exceed 1024 bytes. If the arg\n\ given is an integer or if none is specified, the result value is an integer\n\ ! corresponding to the return value of the ioctl call in the C code."); *************** *** 203,212 **** } ! static char flock_doc [] = "flock(fd, operation)\n\ \n\ Perform the lock operation op on file descriptor fd. See the Unix \n\ manual flock(3) for details. (On some systems, this function is\n\ ! emulated using fcntl().)"; --- 202,211 ---- } ! PyDoc_STRVAR(flock_doc, "flock(fd, operation)\n\ \n\ Perform the lock operation op on file descriptor fd. See the Unix \n\ manual flock(3) for details. (On some systems, this function is\n\ ! emulated using fcntl().)"); *************** *** 284,288 **** } ! static char lockf_doc [] = "lockf (fd, operation, length=0, start=0, whence=0)\n\ \n\ --- 283,287 ---- } ! PyDoc_STRVAR(lockf_doc, "lockf (fd, operation, length=0, start=0, whence=0)\n\ \n\ *************** *** 307,311 **** 0 - relative to the start of the file (SEEK_SET)\n\ 1 - relative to the current buffer position (SEEK_CUR)\n\ ! 2 - relative to the end of the file (SEEK_END)"; /* List of functions */ --- 306,310 ---- 0 - relative to the start of the file (SEEK_SET)\n\ 1 - relative to the current buffer position (SEEK_CUR)\n\ ! 2 - relative to the end of the file (SEEK_END)"); /* List of functions */ *************** *** 320,329 **** ! static char module_doc [] = ! "This module performs file control and I/O control on file \n\ descriptors. It is an interface to the fcntl() and ioctl() Unix\n\ routines. File descriptors can be obtained with the fileno() method of\n\ ! a file or socket object."; /* Module initialisation */ --- 319,327 ---- ! PyDoc_STRVAR(module_doc, "This module performs file control and I/O control on file \n\ descriptors. It is an interface to the fcntl() and ioctl() Unix\n\ routines. File descriptors can be obtained with the fileno() method of\n\ ! a file or socket object."); /* Module initialisation */ Index: gcmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/gcmodule.c,v retrieving revision 2.43 retrieving revision 2.44 diff -C2 -d -r2.43 -r2.44 *** gcmodule.c 6 Jun 2002 23:23:55 -0000 2.43 --- gcmodule.c 13 Jun 2002 20:32:49 -0000 2.44 *************** *** 509,517 **** } ! static char gc_enable__doc__[] = "enable() -> None\n" "\n" ! "Enable automatic garbage collection.\n" ! ; static PyObject * --- 509,516 ---- } ! PyDoc_STRVAR(gc_enable__doc__, "enable() -> None\n" "\n" ! "Enable automatic garbage collection.\n"); static PyObject * *************** *** 528,536 **** } ! static char gc_disable__doc__[] = "disable() -> None\n" "\n" ! "Disable automatic garbage collection.\n" ! ; static PyObject * --- 527,534 ---- } ! PyDoc_STRVAR(gc_disable__doc__, "disable() -> None\n" "\n" ! "Disable automatic garbage collection.\n"); static PyObject * *************** *** 547,555 **** } ! static char gc_isenabled__doc__[] = "isenabled() -> status\n" "\n" ! "Returns true if automatic garbage collection is enabled.\n" ! ; static PyObject * --- 545,552 ---- } ! PyDoc_STRVAR(gc_isenabled__doc__, "isenabled() -> status\n" "\n" ! "Returns true if automatic garbage collection is enabled.\n"); static PyObject * *************** *** 563,571 **** } ! static char gc_collect__doc__[] = "collect() -> n\n" "\n" ! "Run a full collection. The number of unreachable objects is returned.\n" ! ; static PyObject * --- 560,567 ---- } ! PyDoc_STRVAR(gc_collect__doc__, "collect() -> n\n" "\n" ! "Run a full collection. The number of unreachable objects is returned.\n"); static PyObject * *************** *** 589,593 **** } ! static char gc_set_debug__doc__[] = "set_debug(flags) -> None\n" "\n" --- 585,589 ---- } ! PyDoc_STRVAR(gc_set_debug__doc__, "set_debug(flags) -> None\n" "\n" *************** *** 603,608 **** " DEBUG_OBJECTS - Print objects other than instances.\n" " DEBUG_SAVEALL - Save objects to gc.garbage rather than freeing them.\n" ! " DEBUG_LEAK - Debug leaking programs (everything but STATS).\n" ! ; static PyObject * --- 599,603 ---- " DEBUG_OBJECTS - Print objects other than instances.\n" " DEBUG_SAVEALL - Save objects to gc.garbage rather than freeing them.\n" ! " DEBUG_LEAK - Debug leaking programs (everything but STATS).\n"); static PyObject * *************** *** 616,624 **** } ! static char gc_get_debug__doc__[] = "get_debug() -> flags\n" "\n" ! "Get the garbage collection debugging flags.\n" ! ; static PyObject * --- 611,618 ---- } ! PyDoc_STRVAR(gc_get_debug__doc__, "get_debug() -> flags\n" "\n" ! "Get the garbage collection debugging flags.\n"); static PyObject * *************** *** 631,640 **** } ! static char gc_set_thresh__doc__[] = "set_threshold(threshold0, [threshold1, threshold2]) -> None\n" "\n" "Sets the collection thresholds. Setting threshold0 to zero disables\n" ! "collection.\n" ! ; static PyObject * --- 625,633 ---- } ! PyDoc_STRVAR(gc_set_thresh__doc__, "set_threshold(threshold0, [threshold1, threshold2]) -> None\n" "\n" "Sets the collection thresholds. Setting threshold0 to zero disables\n" ! "collection.\n"); static PyObject * *************** *** 656,664 **** } ! static char gc_get_thresh__doc__[] = "get_threshold() -> (threshold0, threshold1, threshold2)\n" "\n" ! "Return the current collection thresholds\n" ! ; static PyObject * --- 649,656 ---- } ! PyDoc_STRVAR(gc_get_thresh__doc__, "get_threshold() -> (threshold0, threshold1, threshold2)\n" "\n" ! "Return the current collection thresholds\n"); static PyObject * *************** *** 703,709 **** } ! static char gc_get_referrers__doc__[]= "get_referrers(*objs) -> list\n\ ! Return the list of objects that directly refer to any of objs."; static PyObject * --- 695,701 ---- } ! PyDoc_STRVAR(gc_get_referrers__doc__, "get_referrers(*objs) -> list\n\ ! Return the list of objects that directly refer to any of objs."); static PyObject * *************** *** 721,730 **** } ! static char gc_get_objects__doc__[] = "get_objects() -> [...]\n" "\n" "Return a list of objects tracked by the collector (excluding the list\n" ! "returned).\n" ! ; /* appending objects in a GC list to a Python list */ --- 713,721 ---- } ! PyDoc_STRVAR(gc_get_objects__doc__, "get_objects() -> [...]\n" "\n" "Return a list of objects tracked by the collector (excluding the list\n" ! "returned).\n"); /* appending objects in a GC list to a Python list */ *************** *** 766,770 **** ! static char gc__doc__ [] = "This module provides access to the garbage collector for reference cycles.\n" "\n" --- 757,761 ---- ! PyDoc_STRVAR(gc__doc__, "This module provides access to the garbage collector for reference cycles.\n" "\n" *************** *** 778,783 **** "get_threshold() -- Return the current the collection thresholds.\n" "get_objects() -- Return a list of all objects tracked by the collector.\n" ! "get_referrers() -- Return the list of objects that refer to an object.\n" ! ; static PyMethodDef GcMethods[] = { --- 769,773 ---- "get_threshold() -- Return the current the collection thresholds.\n" "get_objects() -- Return a list of all objects tracked by the collector.\n" ! "get_referrers() -- Return the list of objects that refer to an object.\n"); static PyMethodDef GcMethods[] = { Index: gdbmmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/gdbmmodule.c,v retrieving revision 2.32 retrieving revision 2.33 diff -C2 -d -r2.32 -r2.33 *** gdbmmodule.c 8 Dec 2001 18:02:56 -0000 2.32 --- gdbmmodule.c 13 Jun 2002 20:32:49 -0000 2.33 *************** *** 17,22 **** #endif ! static char gdbmmodule__doc__[] = "\ ! This module provides an interface to the GNU DBM (GDBM) library.\n\ \n\ This module is quite similar to the dbm module, but uses GDBM instead to\n\ --- 17,22 ---- #endif ! PyDoc_STRVAR(gdbmmodule__doc__, ! "This module provides an interface to the GNU DBM (GDBM) library.\n\ \n\ This module is quite similar to the dbm module, but uses GDBM instead to\n\ *************** *** 27,31 **** values are always strings. Printing a GDBM object doesn't print the\n\ keys and values, and the items() and values() methods are not\n\ ! supported."; typedef struct { --- 27,31 ---- values are always strings. Printing a GDBM object doesn't print the\n\ keys and values, and the items() and values() methods are not\n\ ! supported."); typedef struct { *************** *** 46,51 **** static PyObject *DbmError; ! static char gdbm_object__doc__[] = "\ ! This object represents a GDBM database.\n\ GDBM objects behave like mappings (dictionaries), except that keys and\n\ values are always strings. Printing a GDBM object doesn't print the\n\ --- 46,51 ---- static PyObject *DbmError; ! PyDoc_STRVAR(gdbm_object__doc__, ! "This object represents a GDBM database.\n\ GDBM objects behave like mappings (dictionaries), except that keys and\n\ values are always strings. Printing a GDBM object doesn't print the\n\ *************** *** 54,58 **** \n\ GDBM objects also support additional operations such as firstkey,\n\ ! nextkey, reorganize, and sync."; static PyObject * --- 54,58 ---- \n\ GDBM objects also support additional operations such as firstkey,\n\ ! nextkey, reorganize, and sync."); static PyObject * *************** *** 184,190 **** }; ! static char dbm_close__doc__[] = "\ ! close() -> None\n\ ! Closes the database."; static PyObject * --- 184,190 ---- }; ! PyDoc_STRVAR(dbm_close__doc__, ! "close() -> None\n\ ! Closes the database."); static PyObject * *************** *** 200,206 **** } ! static char dbm_keys__doc__[] = "\ ! keys() -> list_of_keys\n\ ! Get a list of all keys in the database."; static PyObject * --- 200,206 ---- } ! PyDoc_STRVAR(dbm_keys__doc__, ! "keys() -> list_of_keys\n\ ! Get a list of all keys in the database."); static PyObject * *************** *** 246,252 **** } ! static char dbm_has_key__doc__[] = "\ ! has_key(key) -> boolean\n\ ! Find out whether or not the database contains a given key."; static PyObject * --- 246,252 ---- } ! PyDoc_STRVAR(dbm_has_key__doc__, ! "has_key(key) -> boolean\n\ ! Find out whether or not the database contains a given key."); static PyObject * *************** *** 261,270 **** } ! static char dbm_firstkey__doc__[] = "\ ! firstkey() -> key\n\ It's possible to loop over every key in the database using this method\n\ and the nextkey() method. The traversal is ordered by GDBM's internal\n\ hash values, and won't be sorted by the key values. This method\n\ ! returns the starting key."; static PyObject * --- 261,270 ---- } ! PyDoc_STRVAR(dbm_firstkey__doc__, ! "firstkey() -> key\n\ It's possible to loop over every key in the database using this method\n\ and the nextkey() method. The traversal is ordered by GDBM's internal\n\ hash values, and won't be sorted by the key values. This method\n\ ! returns the starting key."); static PyObject * *************** *** 289,294 **** } ! static char dbm_nextkey__doc__[] = "\ ! nextkey(key) -> next_key\n\ Returns the key that follows key in the traversal.\n\ The following code prints every key in the database db, without having\n\ --- 289,294 ---- } ! PyDoc_STRVAR(dbm_nextkey__doc__, ! "nextkey(key) -> next_key\n\ Returns the key that follows key in the traversal.\n\ The following code prints every key in the database db, without having\n\ *************** *** 298,302 **** while k != None:\n\ print k\n\ ! k = db.nextkey(k)"; static PyObject * --- 298,302 ---- while k != None:\n\ print k\n\ ! k = db.nextkey(k)"); static PyObject * *************** *** 321,331 **** } ! static char dbm_reorganize__doc__[] = "\ ! reorganize() -> None\n\ If you have carried out a lot of deletions and would like to shrink\n\ the space used by the GDBM file, this routine will reorganize the\n\ database. GDBM will not shorten the length of a database file except\n\ by using this reorganization; otherwise, deleted file space will be\n\ ! kept and reused as new (key,value) pairs are added."; static PyObject * --- 321,331 ---- } ! PyDoc_STRVAR(dbm_reorganize__doc__, ! "reorganize() -> None\n\ If you have carried out a lot of deletions and would like to shrink\n\ the space used by the GDBM file, this routine will reorganize the\n\ database. GDBM will not shorten the length of a database file except\n\ by using this reorganization; otherwise, deleted file space will be\n\ ! kept and reused as new (key,value) pairs are added."); static PyObject * *************** *** 347,354 **** } ! static char dbm_sync__doc__[] = "\ ! sync() -> None\n\ When the database has been opened in fast mode, this method forces\n\ ! any unwritten data to be written to the disk."; static PyObject * --- 347,354 ---- } ! PyDoc_STRVAR(dbm_sync__doc__, ! "sync() -> None\n\ When the database has been opened in fast mode, this method forces\n\ ! any unwritten data to be written to the disk."); static PyObject * *************** *** 407,412 **** /* ----------------------------------------------------------------- */ ! static char dbmopen__doc__[] = "\ ! open(filename, [flags, [mode]]) -> dbm_object\n\ Open a dbm database and return a dbm object. The filename argument is\n\ the name of the database file.\n\ --- 407,412 ---- /* ----------------------------------------------------------------- */ ! PyDoc_STRVAR(dbmopen__doc__, ! "open(filename, [flags, [mode]]) -> dbm_object\n\ Open a dbm database and return a dbm object. The filename argument is\n\ the name of the database file.\n\ *************** *** 429,433 **** \n\ The optional mode argument is the Unix mode of the file, used only\n\ ! when the database has to be created. It defaults to octal 0666. "; static PyObject * --- 429,433 ---- \n\ The optional mode argument is the Unix mode of the file, used only\n\ ! when the database has to be created. It defaults to octal 0666. "); static PyObject * Index: grpmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/grpmodule.c,v retrieving revision 2.17 retrieving revision 2.18 diff -C2 -d -r2.17 -r2.18 *** grpmodule.c 1 Mar 2002 10:38:44 -0000 2.17 --- grpmodule.c 13 Jun 2002 20:32:49 -0000 2.18 *************** *** 16,24 **** }; ! static char struct_group__doc__[] = "grp.struct_group: Results from getgr*() routines.\n\n\ This object may be accessed either as a tuple of\n\ (gr_name,gr_passwd,gr_gid,gr_mem)\n\ ! or via the object attributes as named in the above tuple.\n"; static PyStructSequence_Desc struct_group_type_desc = { --- 16,24 ---- }; ! PyDoc_STRVAR(struct_group__doc__, "grp.struct_group: Results from getgr*() routines.\n\n\ This object may be accessed either as a tuple of\n\ (gr_name,gr_passwd,gr_gid,gr_mem)\n\ ! or via the object attributes as named in the above tuple.\n"); static PyStructSequence_Desc struct_group_type_desc = { *************** *** 140,144 **** }; ! static char grp__doc__[] = "Access to the Unix group database.\n\ \n\ --- 140,144 ---- }; ! PyDoc_STRVAR(grp__doc__, "Access to the Unix group database.\n\ \n\ *************** *** 154,158 **** users are not explicitly listed as members of the groups they are in\n\ according to the password database. Check both databases to get\n\ ! complete membership information.)"; --- 154,158 ---- users are not explicitly listed as members of the groups they are in\n\ according to the password database. Check both databases to get\n\ ! complete membership information.)"); Index: mathmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/mathmodule.c,v retrieving revision 2.67 retrieving revision 2.68 diff -C2 -d -r2.67 -r2.68 *** mathmodule.c 13 May 2002 03:56:10 -0000 2.67 --- mathmodule.c 13 Jun 2002 20:32:50 -0000 2.68 *************** *** 86,90 **** return math_1(args, func, "d:" #funcname); \ }\ ! static char math_##funcname##_doc [] = docstring; #define FUNC2(funcname, func, docstring) \ --- 86,90 ---- return math_1(args, func, "d:" #funcname); \ }\ ! PyDoc_STRVAR(math_##funcname##_doc, docstring); #define FUNC2(funcname, func, docstring) \ *************** *** 92,96 **** return math_2(args, func, "dd:" #funcname); \ }\ ! static char math_##funcname##_doc [] = docstring; FUNC1(acos, acos, --- 92,96 ---- return math_2(args, func, "dd:" #funcname); \ }\ ! PyDoc_STRVAR(math_##funcname##_doc, docstring); FUNC1(acos, acos, *************** *** 156,165 **** } ! static char math_frexp_doc [] = "frexp(x)\n" "\n" "Return the mantissa and exponent of x, as pair (m, e).\n" "m is a float and e is an int, such that x = m * 2.**e.\n" ! "If x is 0, m and e are both 0. Else 0.5 <= abs(m) < 1.0."; static PyObject * --- 156,165 ---- } ! PyDoc_STRVAR(math_frexp_doc, "frexp(x)\n" "\n" "Return the mantissa and exponent of x, as pair (m, e).\n" "m is a float and e is an int, such that x = m * 2.**e.\n" ! "If x is 0, m and e are both 0. Else 0.5 <= abs(m) < 1.0."); static PyObject * *************** *** 181,186 **** } ! static char math_ldexp_doc [] = ! "ldexp(x, i) -> x * (2**i)"; static PyObject * --- 181,186 ---- } ! PyDoc_STRVAR(math_ldexp_doc, ! "ldexp(x, i) -> x * (2**i)"); static PyObject * *************** *** 207,215 **** } ! static char math_modf_doc [] = "modf(x)\n" "\n" "Return the fractional and integer parts of x. Both results carry the sign\n" ! "of x. The integer part is returned as a real."; /* A decent logarithm is easy to compute even for huge longs, but libm can't --- 207,215 ---- } ! PyDoc_STRVAR(math_modf_doc, "modf(x)\n" "\n" "Return the fractional and integer parts of x. Both results carry the sign\n" ! "of x. The integer part is returned as a real."); /* A decent logarithm is easy to compute even for huge longs, but libm can't *************** *** 263,268 **** } ! static char math_log_doc[] = ! "log(x) -> the natural logarithm (base e) of x."; static PyObject * --- 263,268 ---- } ! PyDoc_STRVAR(math_log_doc, ! "log(x) -> the natural logarithm (base e) of x."); static PyObject * *************** *** 272,277 **** } ! static char math_log10_doc[] = ! "log10(x) -> the base 10 logarithm of x."; static const double degToRad = 3.141592653589793238462643383 / 180.0; --- 272,277 ---- } ! PyDoc_STRVAR(math_log10_doc, ! "log10(x) -> the base 10 logarithm of x."); static const double degToRad = 3.141592653589793238462643383 / 180.0; *************** *** 286,291 **** } ! static char math_degrees_doc[] = ! "degrees(x) -> converts angle x from radians to degrees"; static PyObject * --- 286,291 ---- } ! PyDoc_STRVAR(math_degrees_doc, ! "degrees(x) -> converts angle x from radians to degrees"); static PyObject * *************** *** 298,303 **** } ! static char math_radians_doc[] = ! "radians(x) -> converts angle x from degrees to radians"; static PyMethodDef math_methods[] = { --- 298,303 ---- } ! PyDoc_STRVAR(math_radians_doc, ! "radians(x) -> converts angle x from degrees to radians"); static PyMethodDef math_methods[] = { *************** *** 331,337 **** ! static char module_doc [] = "This module is always available. It provides access to the\n" ! "mathematical functions defined by the C standard."; DL_EXPORT(void) --- 331,337 ---- ! PyDoc_STRVAR(module_doc, "This module is always available. It provides access to the\n" ! "mathematical functions defined by the C standard."); DL_EXPORT(void) Index: md5module.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/md5module.c,v retrieving revision 2.29 retrieving revision 2.30 diff -C2 -d -r2.29 -r2.30 *** md5module.c 31 Mar 2002 15:27:00 -0000 2.29 --- md5module.c 13 Jun 2002 20:32:50 -0000 2.30 *************** *** 62,71 **** } ! static char update_doc [] = "update (arg)\n\ \n\ Update the md5 object with the string arg. Repeated calls are\n\ equivalent to a single call with the concatenation of all the\n\ ! arguments."; --- 62,71 ---- } ! PyDoc_STRVAR(update_doc, "update (arg)\n\ \n\ Update the md5 object with the string arg. Repeated calls are\n\ equivalent to a single call with the concatenation of all the\n\ ! arguments."); *************** *** 83,92 **** } ! static char digest_doc [] = "digest() -> string\n\ \n\ Return the digest of the strings passed to the update() method so\n\ far. This is an 16-byte string which may contain non-ASCII characters,\n\ ! including null bytes."; --- 83,92 ---- } ! PyDoc_STRVAR(digest_doc, "digest() -> string\n\ \n\ Return the digest of the strings passed to the update() method so\n\ far. This is an 16-byte string which may contain non-ASCII characters,\n\ ! including null bytes."); *************** *** 117,124 **** ! static char hexdigest_doc [] = "hexdigest() -> string\n\ \n\ ! Like digest(), but returns the digest as a string of hexadecimal digits."; --- 117,124 ---- ! PyDoc_STRVAR(hexdigest_doc, "hexdigest() -> string\n\ \n\ ! Like digest(), but returns the digest as a string of hexadecimal digits."); *************** *** 136,143 **** } ! static char copy_doc [] = "copy() -> md5 object\n\ \n\ ! Return a copy (``clone'') of the md5 object."; --- 136,143 ---- } ! PyDoc_STRVAR(copy_doc, "copy() -> md5 object\n\ \n\ ! Return a copy (``clone'') of the md5 object."); *************** *** 160,165 **** } ! static char module_doc [] = ! "This module implements the interface to RSA's MD5 message digest\n\ algorithm (see also Internet RFC 1321). Its use is quite\n\ --- 160,164 ---- } ! PyDoc_STRVAR(module_doc, "This module implements the interface to RSA's MD5 message digest\n\ algorithm (see also Internet RFC 1321). Its use is quite\n\ *************** *** 177,184 **** Special Objects:\n\ \n\ ! MD5Type -- type object for md5 objects\n\ ! "; ! static char md5type_doc [] = "An md5 represents the object used to calculate the MD5 checksum of a\n\ string of information.\n\ --- 176,182 ---- Special Objects:\n\ \n\ ! MD5Type -- type object for md5 objects"); ! PyDoc_STRVAR(md5type_doc, "An md5 represents the object used to calculate the MD5 checksum of a\n\ string of information.\n\ *************** *** 188,193 **** update() -- updates the current digest with an additional string\n\ digest() -- return the current digest value\n\ ! copy() -- return a copy of the current md5 object\n\ ! "; statichere PyTypeObject MD5type = { --- 186,190 ---- update() -- updates the current digest with an additional string\n\ digest() -- return the current digest value\n\ ! copy() -- return a copy of the current md5 object"); statichere PyTypeObject MD5type = { *************** *** 239,247 **** } ! static char new_doc [] = "new([arg]) -> md5 object\n\ \n\ Return a new md5 object. If arg is present, the method call update(arg)\n\ ! is made."; --- 236,244 ---- } ! PyDoc_STRVAR(new_doc, "new([arg]) -> md5 object\n\ \n\ Return a new md5 object. If arg is present, the method call update(arg)\n\ ! is made."); Index: newmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/newmodule.c,v retrieving revision 2.38 retrieving revision 2.39 diff -C2 -d -r2.38 -r2.39 *** newmodule.c 15 Jan 2002 19:20:03 -0000 2.38 --- newmodule.c 13 Jun 2002 20:32:50 -0000 2.39 *************** *** 5,11 **** #include "compile.h" ! static char new_instance_doc[] = "Create an instance object from (CLASS [, DICT]) without calling its\n\ ! __init__() method. DICT must be a dictionary or None."; static PyObject * --- 5,11 ---- #include "compile.h" ! PyDoc_STRVAR(new_instance_doc, "Create an instance object from (CLASS [, DICT]) without calling its\n\ ! __init__() method. DICT must be a dictionary or None."); static PyObject * *************** *** 31,36 **** } ! static char new_im_doc[] = ! "Create a instance method object from (FUNCTION, INSTANCE, CLASS)."; static PyObject * --- 31,36 ---- } ! PyDoc_STRVAR(new_im_doc, ! "Create a instance method object from (FUNCTION, INSTANCE, CLASS)."); static PyObject * *************** *** 54,59 **** } ! static char new_function_doc[] = ! "Create a function object from (CODE, GLOBALS, [NAME [, ARGDEFS]])."; static PyObject * --- 54,59 ---- } ! PyDoc_STRVAR(new_function_doc, ! "Create a function object from (CODE, GLOBALS, [NAME [, ARGDEFS]])."); static PyObject * *************** *** 96,103 **** } ! static char new_code_doc[] = "Create a code object from (ARGCOUNT, NLOCALS, STACKSIZE, FLAGS, CODESTRING,\n" "CONSTANTS, NAMES, VARNAMES, FILENAME, NAME, FIRSTLINENO, LNOTAB, FREEVARS,\n" ! "CELLVARS)."; static PyObject * --- 96,103 ---- } ! PyDoc_STRVAR(new_code_doc, "Create a code object from (ARGCOUNT, NLOCALS, STACKSIZE, FLAGS, CODESTRING,\n" "CONSTANTS, NAMES, VARNAMES, FILENAME, NAME, FIRSTLINENO, LNOTAB, FREEVARS,\n" ! "CELLVARS)."); static PyObject * *************** *** 158,163 **** } ! static char new_module_doc[] = ! "Create a module object from (NAME)."; static PyObject * --- 158,163 ---- } ! PyDoc_STRVAR(new_module_doc, ! "Create a module object from (NAME)."); static PyObject * *************** *** 171,176 **** } ! static char new_class_doc[] = ! "Create a class object from (NAME, BASE_CLASSES, DICT)."; static PyObject * --- 171,176 ---- } ! PyDoc_STRVAR(new_class_doc, ! "Create a class object from (NAME, BASE_CLASSES, DICT)."); static PyObject * *************** *** 203,210 **** }; ! static char new_doc[] = "Functions to create new objects used by the interpreter.\n\ \n\ ! You need to know a great deal about the interpreter to use this!"; DL_EXPORT(void) --- 203,210 ---- }; ! PyDoc_STRVAR(new_doc, "Functions to create new objects used by the interpreter.\n\ \n\ ! You need to know a great deal about the interpreter to use this!"); DL_EXPORT(void) Index: operator.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/operator.c,v retrieving revision 2.20 retrieving revision 2.21 diff -C2 -d -r2.20 -r2.21 *** operator.c 4 Apr 2002 17:52:50 -0000 2.20 --- operator.c 13 Jun 2002 20:32:50 -0000 2.21 *************** *** 1,4 **** ! static char operator_doc[] = "\ ! Operator interface.\n\ \n\ This module exports a set of functions implemented in C corresponding\n\ --- 1,7 ---- ! ! #include "Python.h" ! ! PyDoc_STRVAR(operator_doc, ! "Operator interface.\n\ \n\ This module exports a set of functions implemented in C corresponding\n\ *************** *** 6,13 **** is equivalent to the expression x+y. The function names are those\n\ used for special class methods; variants without leading and trailing\n\ ! '__' are also provided for convenience.\n\ ! "; ! ! #include "Python.h" #define spam1(OP,AOP) static PyObject *OP(PyObject *s, PyObject *a) { \ --- 9,13 ---- is equivalent to the expression x+y. The function names are those\n\ used for special class methods; variants without leading and trailing\n\ ! '__' are also provided for convenience."); #define spam1(OP,AOP) static PyObject *OP(PyObject *s, PyObject *a) { \ Index: parsermodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/parsermodule.c,v retrieving revision 2.69 retrieving revision 2.70 diff -C2 -d -r2.69 -r2.70 *** parsermodule.c 24 May 2002 15:47:06 -0000 2.69 --- parsermodule.c 13 Jun 2002 20:32:50 -0000 2.70 *************** *** 47,53 **** * */ ! static char* ! parser_copyright_string ! = "Copyright 1995-1996 by Virginia Polytechnic Institute & State\n\ University, Blacksburg, Virginia, USA, and Fred L. Drake, Jr., Reston,\n\ Virginia, USA. Portions copyright 1991-1995 by Stichting Mathematisch\n\ --- 47,52 ---- * */ ! static char parser_copyright_string[] = ! "Copyright 1995-1996 by Virginia Polytechnic Institute & State\n\ University, Blacksburg, Virginia, USA, and Fred L. Drake, Jr., Reston,\n\ Virginia, USA. Portions copyright 1991-1995 by Stichting Mathematisch\n\ *************** *** 55,64 **** ! static char* ! parser_doc_string ! = "This is an interface to Python's internal parser."; ! static char* ! parser_version_string = "0.5"; --- 54,61 ---- ! PyDoc_STRVAR(parser_doc_string, ! "This is an interface to Python's internal parser."); ! static char parser_version_string[] = "0.5"; Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.234 retrieving revision 2.235 diff -C2 -d -r2.234 -r2.235 *** posixmodule.c 10 Jun 2002 19:22:56 -0000 2.234 --- posixmodule.c 13 Jun 2002 20:32:50 -0000 2.235 *************** *** 14,25 **** /* See also ../Dos/dosmodule.c */ ! static char posix__doc__ [] = "This module provides access to operating system functionality that is\n\ standardized by the C Standard and the POSIX standard (a thinly\n\ disguised Unix interface). Refer to the library manual and\n\ ! corresponding Unix manual entries for more information on calls."; ! ! #include "Python.h" ! #include "structseq.h" [...1866 lines suppressed...] --- 6234,6239 ---- #ifdef MS_WIN32 ! PyDoc_STRVAR(win32_startfile__doc__, ! "startfile(filepath) - Start a file with its associated application.\n\ \n\ This acts like double-clicking the file in Explorer, or giving the file\n\ *************** *** 6241,6245 **** The filepath is relative to the current directory. If you want to use\n\ an absolute path, make sure the first character is not a slash (\"/\");\n\ ! the underlying Win32 ShellExecute function doesn't work if it is."; static PyObject * --- 6247,6251 ---- The filepath is relative to the current directory. If you want to use\n\ an absolute path, make sure the first character is not a slash (\"/\");\n\ ! the underlying Win32 ShellExecute function doesn't work if it is."); static PyObject * Index: pwdmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/pwdmodule.c,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** pwdmodule.c 15 Apr 2002 16:29:00 -0000 1.33 --- pwdmodule.c 13 Jun 2002 20:32:51 -0000 1.34 *************** *** 19,27 **** }; ! static char struct_passwd__doc__[] = "pwd.struct_passwd: Results from getpw*() routines.\n\n\ This object may be accessed either as a tuple of\n\ (pw_name,pw_passwd,pw_uid,pw_gid,pw_gecos,pw_dir,pw_shell)\n\ ! or via the object attributes as named in the above tuple.\n"; static PyStructSequence_Desc struct_pwd_type_desc = { --- 19,27 ---- }; ! PyDoc_STRVAR(struct_passwd__doc__, "pwd.struct_passwd: Results from getpw*() routines.\n\n\ This object may be accessed either as a tuple of\n\ (pw_name,pw_passwd,pw_uid,pw_gid,pw_gecos,pw_dir,pw_shell)\n\ ! or via the object attributes as named in the above tuple."); static PyStructSequence_Desc struct_pwd_type_desc = { *************** *** 32,37 **** }; ! static char pwd__doc__ [] = "\ ! This module provides access to the Unix password database.\n\ It is available on all Unix versions.\n\ \n\ --- 32,37 ---- }; ! PyDoc_STRVAR(pwd__doc__, ! "This module provides access to the Unix password database.\n\ It is available on all Unix versions.\n\ \n\ *************** *** 40,44 **** pw_name, pw_passwd, pw_uid, pw_gid, pw_gecos, pw_dir, pw_shell.\n\ The uid and gid items are integers, all others are strings. An\n\ ! exception is raised if the entry asked for cannot be found."; --- 40,44 ---- pw_name, pw_passwd, pw_uid, pw_gid, pw_gecos, pw_dir, pw_shell.\n\ The uid and gid items are integers, all others are strings. An\n\ ! exception is raised if the entry asked for cannot be found."); *************** *** 75,82 **** } ! static char pwd_getpwuid__doc__[] = "\ ! getpwuid(uid) -> (pw_name,pw_passwd,pw_uid,pw_gid,pw_gecos,pw_dir,pw_shell)\n\ Return the password database entry for the given numeric user ID.\n\ ! See pwd.__doc__ for more on password database entries."; static PyObject * --- 75,83 ---- } ! PyDoc_STRVAR(pwd_getpwuid__doc__, ! "getpwuid(uid) -> (pw_name,pw_passwd,pw_uid,\n\ ! pw_gid,pw_gecos,pw_dir,pw_shell)\n\ Return the password database entry for the given numeric user ID.\n\ ! See pwd.__doc__ for more on password database entries."); static PyObject * *************** *** 94,101 **** } ! static char pwd_getpwnam__doc__[] = "\ ! getpwnam(name) -> (pw_name,pw_passwd,pw_uid,pw_gid,pw_gecos,pw_dir,pw_shell)\n\ Return the password database entry for the given user name.\n\ ! See pwd.__doc__ for more on password database entries."; static PyObject * --- 95,103 ---- } ! PyDoc_STRVAR(pwd_getpwnam__doc__, ! "getpwnam(name) -> (pw_name,pw_passwd,pw_uid,\n\ ! pw_gid,pw_gecos,pw_dir,pw_shell)\n\ Return the password database entry for the given user name.\n\ ! See pwd.__doc__ for more on password database entries."); static PyObject * *************** *** 114,122 **** #ifdef HAVE_GETPWENT ! static char pwd_getpwall__doc__[] = "\ ! getpwall() -> list_of_entries\n\ Return a list of all available password database entries, \ in arbitrary order.\n\ ! See pwd.__doc__ for more on password database entries."; static PyObject * --- 116,124 ---- #ifdef HAVE_GETPWENT ! PyDoc_STRVAR(pwd_getpwall__doc__, ! "getpwall() -> list_of_entries\n\ Return a list of all available password database entries, \ in arbitrary order.\n\ ! See pwd.__doc__ for more on password database entries."); static PyObject * Index: pyexpat.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/pyexpat.c,v retrieving revision 2.59 retrieving revision 2.60 diff -C2 -d -r2.59 -r2.60 *** pyexpat.c 20 Mar 2002 21:32:07 -0000 2.59 --- pyexpat.c 13 Jun 2002 20:32:52 -0000 2.60 *************** *** 626,632 **** /* ---------------------------------------------------------------- */ ! static char xmlparse_Parse__doc__[] = "Parse(data[, isfinal])\n\ ! Parse XML data. `isfinal' should be true at end of input."; static PyObject * --- 626,632 ---- /* ---------------------------------------------------------------- */ ! PyDoc_STRVAR(xmlparse_Parse__doc__, "Parse(data[, isfinal])\n\ ! Parse XML data. `isfinal' should be true at end of input."); static PyObject * *************** *** 696,702 **** } ! static char xmlparse_ParseFile__doc__[] = "ParseFile(file)\n\ ! Parse XML data from file-like object."; static PyObject * --- 696,702 ---- } ! PyDoc_STRVAR(xmlparse_ParseFile__doc__, "ParseFile(file)\n\ ! Parse XML data from file-like object."); static PyObject * *************** *** 755,761 **** } ! static char xmlparse_SetBase__doc__[] = "SetBase(base_url)\n\ ! Set the base URL for the parser."; static PyObject * --- 755,761 ---- } ! PyDoc_STRVAR(xmlparse_SetBase__doc__, "SetBase(base_url)\n\ ! Set the base URL for the parser."); static PyObject * *************** *** 773,779 **** } ! static char xmlparse_GetBase__doc__[] = "GetBase() -> url\n\ ! Return base URL string for the parser."; static PyObject * --- 773,779 ---- } ! PyDoc_STRVAR(xmlparse_GetBase__doc__, "GetBase() -> url\n\ ! Return base URL string for the parser."); static PyObject * *************** *** 786,794 **** } ! static char xmlparse_GetInputContext__doc__[] = "GetInputContext() -> string\n\ Return the untranslated text of the input that caused the current event.\n\ If the event was generated by a large amount of text (such as a start tag\n\ ! for an element with many attributes), not all of the text may be available."; static PyObject * --- 786,794 ---- } ! PyDoc_STRVAR(xmlparse_GetInputContext__doc__, "GetInputContext() -> string\n\ Return the untranslated text of the input that caused the current event.\n\ If the event was generated by a large amount of text (such as a start tag\n\ ! for an element with many attributes), not all of the text may be available."); static PyObject * *************** *** 818,825 **** } ! static char xmlparse_ExternalEntityParserCreate__doc__[] = "ExternalEntityParserCreate(context[, encoding])\n\ Create a parser for parsing an external entity based on the\n\ ! information passed to the ExternalEntityRefHandler."; static PyObject * --- 818,825 ---- } ! PyDoc_STRVAR(xmlparse_ExternalEntityParserCreate__doc__, "ExternalEntityParserCreate(context[, encoding])\n\ Create a parser for parsing an external entity based on the\n\ ! information passed to the ExternalEntityRefHandler."); static PyObject * *************** *** 893,897 **** } ! static char xmlparse_SetParamEntityParsing__doc__[] = "SetParamEntityParsing(flag) -> success\n\ Controls parsing of parameter entities (including the external DTD\n\ --- 893,897 ---- } ! PyDoc_STRVAR(xmlparse_SetParamEntityParsing__doc__, "SetParamEntityParsing(flag) -> success\n\ Controls parsing of parameter entities (including the external DTD\n\ *************** *** 899,903 **** XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE and\n\ XML_PARAM_ENTITY_PARSING_ALWAYS. Returns true if setting the flag\n\ ! was successful."; static PyObject* --- 899,903 ---- XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE and\n\ XML_PARAM_ENTITY_PARSING_ALWAYS. Returns true if setting the flag\n\ ! was successful."); static PyObject* *************** *** 1226,1231 **** #endif ! static char Xmlparsetype__doc__[] = ! "XML parser"; static PyTypeObject Xmlparsetype = { --- 1226,1230 ---- #endif ! PyDoc_STRVAR(Xmlparsetype__doc__, "XML parser"); static PyTypeObject Xmlparsetype = { *************** *** 1268,1274 **** /* -------------------------------------------------------- */ ! static char pyexpat_ParserCreate__doc__[] = "ParserCreate([encoding[, namespace_separator]]) -> parser\n\ ! Return a new XML parser object."; static PyObject * --- 1267,1273 ---- /* -------------------------------------------------------- */ ! PyDoc_STRVAR(pyexpat_ParserCreate__doc__, "ParserCreate([encoding[, namespace_separator]]) -> parser\n\ ! Return a new XML parser object."); static PyObject * *************** *** 1292,1298 **** } ! static char pyexpat_ErrorString__doc__[] = "ErrorString(errno) -> string\n\ ! Returns string error for given number."; static PyObject * --- 1291,1297 ---- } ! PyDoc_STRVAR(pyexpat_ErrorString__doc__, "ErrorString(errno) -> string\n\ ! Returns string error for given number."); static PyObject * *************** *** 1319,1324 **** /* Module docstring */ ! static char pyexpat_module_documentation[] = ! "Python wrapper for Expat parser."; #if PY_VERSION_HEX < 0x20000F0 --- 1318,1323 ---- /* Module docstring */ ! PyDoc_STRVAR(pyexpat_module_documentation, ! "Python wrapper for Expat parser."); #if PY_VERSION_HEX < 0x20000F0 Index: readline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v retrieving revision 2.50 retrieving revision 2.51 diff -C2 -d -r2.50 -r2.51 *** readline.c 11 Jun 2002 14:32:46 -0000 2.50 --- readline.c 13 Jun 2002 20:32:52 -0000 2.51 *************** *** 47,54 **** } ! static char doc_parse_and_bind[] = "\ ! parse_and_bind(string) -> None\n\ ! Parse and execute single line of a readline init file.\ ! "; --- 47,53 ---- } ! PyDoc_STRVAR(doc_parse_and_bind, ! "parse_and_bind(string) -> None\n\ ! Parse and execute single line of a readline init file."); *************** *** 68,76 **** } ! static char doc_read_init_file[] = "\ ! read_init_file([filename]) -> None\n\ Parse a readline initialization file.\n\ ! The default filename is the last filename used.\ ! "; --- 67,74 ---- } ! PyDoc_STRVAR(doc_read_init_file, ! "read_init_file([filename]) -> None\n\ Parse a readline initialization file.\n\ ! The default filename is the last filename used."); *************** *** 91,99 **** static int history_length = -1; /* do not truncate history by default */ ! static char doc_read_history_file[] = "\ ! read_history_file([filename]) -> None\n\ Load a readline history file.\n\ ! The default filename is ~/.history.\ ! "; --- 89,96 ---- static int history_length = -1; /* do not truncate history by default */ ! PyDoc_STRVAR(doc_read_history_file, ! "read_history_file([filename]) -> None\n\ Load a readline history file.\n\ ! The default filename is ~/.history."); *************** *** 115,131 **** } ! static char doc_write_history_file[] = "\ ! write_history_file([filename]) -> None\n\ Save a readline history file.\n\ ! The default filename is ~/.history.\ ! "; ! static char set_history_length_doc[] = "\ ! set_history_length(length) -> None\n\ set the maximal number of items which will be written to\n\ the history file. A negative length is used to inhibit\n\ ! history truncation.\n\ ! "; static PyObject* --- 112,126 ---- } ! PyDoc_STRVAR(doc_write_history_file, ! "write_history_file([filename]) -> None\n\ Save a readline history file.\n\ ! The default filename is ~/.history."); ! PyDoc_STRVAR(set_history_length_doc, ! "set_history_length(length) -> None\n\ set the maximal number of items which will be written to\n\ the history file. A negative length is used to inhibit\n\ ! history truncation."); static PyObject* *************** *** 142,150 **** ! static char get_history_length_doc[] = "\ ! get_history_length() -> int\n\ return the maximum number of items that will be written to\n\ ! the history file.\n\ ! "; static PyObject* --- 137,144 ---- ! PyDoc_STRVAR(get_history_length_doc, ! "get_history_length() -> int\n\ return the maximum number of items that will be written to\n\ ! the history file."); static PyObject* *************** *** 205,214 **** } ! static char doc_set_startup_hook[] = "\ ! set_startup_hook([function]) -> None\n\ Set or remove the startup_hook function.\n\ The function is called with no arguments just\n\ ! before readline prints the first prompt.\n\ ! "; #ifdef HAVE_RL_PRE_INPUT_HOOK --- 199,207 ---- } ! PyDoc_STRVAR(doc_set_startup_hook, ! "set_startup_hook([function]) -> None\n\ Set or remove the startup_hook function.\n\ The function is called with no arguments just\n\ ! before readline prints the first prompt."); #ifdef HAVE_RL_PRE_INPUT_HOOK *************** *** 219,229 **** } ! static char doc_set_pre_input_hook[] = "\ ! set_pre_input_hook([function]) -> None\n\ Set or remove the pre_input_hook function.\n\ The function is called with no arguments after the first prompt\n\ has been printed and just before readline starts reading input\n\ ! characters.\n\ ! "; #endif --- 212,221 ---- } ! PyDoc_STRVAR(doc_set_pre_input_hook, ! "set_pre_input_hook([function]) -> None\n\ Set or remove the pre_input_hook function.\n\ The function is called with no arguments after the first prompt\n\ has been printed and just before readline starts reading input\n\ ! characters."); #endif *************** *** 244,250 **** } ! static char doc_get_begidx[] = "\ ! get_begidx() -> int\n\ ! get the beginning index of the readline tab-completion scope"; /* get the ending index for the scope of the tab-completion */ --- 236,242 ---- } ! PyDoc_STRVAR(doc_get_begidx, ! "get_begidx() -> int\n\ ! get the beginning index of the readline tab-completion scope"); /* get the ending index for the scope of the tab-completion */ *************** *** 256,262 **** } ! static char doc_get_endidx[] = "\ ! get_endidx() -> int\n\ ! get the ending index of the readline tab-completion scope"; --- 248,254 ---- } ! PyDoc_STRVAR(doc_get_endidx, ! "get_endidx() -> int\n\ ! get the ending index of the readline tab-completion scope"); *************** *** 277,283 **** } ! static char doc_set_completer_delims[] = "\ ! set_completer_delims(string) -> None\n\ ! set the readline word delimiters for tab-completion"; static PyObject * --- 269,275 ---- } ! PyDoc_STRVAR(doc_set_completer_delims, ! "set_completer_delims(string) -> None\n\ ! set the readline word delimiters for tab-completion"); static PyObject * *************** *** 294,300 **** } ! static char doc_add_history[] = "\ ! add_history(string) -> None\n\ ! add a line to the history buffer"; --- 286,292 ---- } ! PyDoc_STRVAR(doc_add_history, ! "add_history(string) -> None\n\ ! add a line to the history buffer"); *************** *** 307,313 **** } ! static char doc_get_completer_delims[] = "\ ! get_completer_delims() -> string\n\ ! get the readline word delimiters for tab-completion"; static PyObject * --- 299,305 ---- } ! PyDoc_STRVAR(doc_get_completer_delims, ! "get_completer_delims() -> string\n\ ! get the readline word delimiters for tab-completion"); static PyObject * *************** *** 317,327 **** } ! static char doc_set_completer[] = "\ ! set_completer([function]) -> None\n\ Set or remove the completer function.\n\ The function is called as function(text, state),\n\ for state in 0, 1, 2, ..., until it returns a non-string.\n\ ! It should return the next possible completion starting with 'text'.\ ! "; /* Exported function to get any element of history */ --- 309,318 ---- } ! PyDoc_STRVAR(doc_set_completer, ! "set_completer([function]) -> None\n\ Set or remove the completer function.\n\ The function is called as function(text, state),\n\ for state in 0, 1, 2, ..., until it returns a non-string.\n\ ! It should return the next possible completion starting with 'text'."); /* Exported function to get any element of history */ *************** *** 343,350 **** } ! static char doc_get_history_item[] = "\ ! get_history_item() -> string\n\ ! return the current contents of history item at index.\ ! "; /* Exported function to get current length of history */ --- 334,340 ---- } ! PyDoc_STRVAR(doc_get_history_item, ! "get_history_item() -> string\n\ ! return the current contents of history item at index."); /* Exported function to get current length of history */ *************** *** 359,366 **** } ! static char doc_get_current_history_length[] = "\ ! get_current_history_length() -> integer\n\ ! return the current (not the maximum) length of history.\ ! "; /* Exported function to read the current line buffer */ --- 349,355 ---- } ! PyDoc_STRVAR(doc_get_current_history_length, ! "get_current_history_length() -> integer\n\ ! return the current (not the maximum) length of history."); /* Exported function to read the current line buffer */ *************** *** 372,379 **** } ! static char doc_get_line_buffer[] = "\ ! get_line_buffer() -> string\n\ ! return the current contents of the line buffer.\ ! "; /* Exported function to insert text into the line buffer */ --- 361,367 ---- } ! PyDoc_STRVAR(doc_get_line_buffer, ! "get_line_buffer() -> string\n\ ! return the current contents of the line buffer."); /* Exported function to insert text into the line buffer */ *************** *** 390,397 **** } ! static char doc_insert_text[] = "\ ! insert_text(string) -> None\n\ ! Insert text into the command line.\ ! "; static PyObject * --- 378,384 ---- } ! PyDoc_STRVAR(doc_insert_text, ! "insert_text(string) -> None\n\ ! Insert text into the command line."); static PyObject * *************** *** 403,411 **** } ! static char doc_redisplay[] = "\ ! redisplay() -> None\n\ Change what's displayed on the screen to reflect the current\n\ ! contents of the line buffer.\ ! "; /* Table of functions exported by the module */ --- 390,397 ---- } ! PyDoc_STRVAR(doc_redisplay, ! "redisplay() -> None\n\ Change what's displayed on the screen to reflect the current\n\ ! contents of the line buffer."); /* Table of functions exported by the module */ *************** *** 664,669 **** /* Initialize the module */ ! static char doc_module[] = ! "Importing this module enables command line editing using GNU readline."; DL_EXPORT(void) --- 650,655 ---- /* Initialize the module */ ! PyDoc_STRVAR(doc_module, ! "Importing this module enables command line editing using GNU readline."); DL_EXPORT(void) Index: resource.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/resource.c,v retrieving revision 2.25 retrieving revision 2.26 diff -C2 -d -r2.25 -r2.26 *** resource.c 23 Apr 2002 20:15:04 -0000 2.25 --- resource.c 13 Jun 2002 20:32:52 -0000 2.26 *************** *** 18,27 **** static PyObject *ResourceError; ! static char struct_rusage__doc__[] = ! "struct_rusage: Result from getrusage.\n\n" ! "This object may be accessed either as a tuple of\n" ! " (utime,stime,maxrss,ixrss,idrss,isrss,minflt,majflt,\n" ! " nswap,inblock,oublock,msgsnd,msgrcv,nsignals,nvcsw,nivcsw)\n" ! "or via the attributes ru_utime, ru_stime, ru_maxrss, and so on.\n"; static PyStructSequence_Field struct_rusage_fields[] = { --- 18,27 ---- static PyObject *ResourceError; ! PyDoc_STRVAR(struct_rusage__doc__, ! "struct_rusage: Result from getrusage.\n\n" ! "This object may be accessed either as a tuple of\n" ! " (utime,stime,maxrss,ixrss,idrss,isrss,minflt,majflt,\n" ! " nswap,inblock,oublock,msgsnd,msgrcv,nsignals,nvcsw,nivcsw)\n" ! "or via the attributes ru_utime, ru_stime, ru_maxrss, and so on."); static PyStructSequence_Field struct_rusage_fields[] = { Index: selectmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/selectmodule.c,v retrieving revision 2.63 retrieving revision 2.64 diff -C2 -d -r2.63 -r2.64 *** selectmodule.c 31 May 2002 21:47:02 -0000 2.63 --- selectmodule.c 13 Jun 2002 20:32:52 -0000 2.64 *************** *** 352,361 **** } ! static char poll_register_doc[] = "register(fd [, eventmask] ) -> None\n\n\ Register a file descriptor with the polling object.\n\ fd -- either an integer, or an object with a fileno() method returning an\n\ int.\n\ ! events -- an optional bitmask describing the type of events to check for"; static PyObject * --- 352,361 ---- } ! PyDoc_STRVAR(poll_register_doc, "register(fd [, eventmask] ) -> None\n\n\ Register a file descriptor with the polling object.\n\ fd -- either an integer, or an object with a fileno() method returning an\n\ int.\n\ ! events -- an optional bitmask describing the type of events to check for"); static PyObject * *************** *** 395,401 **** } ! static char poll_unregister_doc[] = "unregister(fd) -> None\n\n\ ! Remove a file descriptor being tracked by the polling object."; static PyObject * --- 395,401 ---- } ! PyDoc_STRVAR(poll_unregister_doc, "unregister(fd) -> None\n\n\ ! Remove a file descriptor being tracked by the polling object."); static PyObject * *************** *** 432,439 **** } ! static char poll_poll_doc[] = "poll( [timeout] ) -> list of (fd, event) 2-tuples\n\n\ Polls the set of registered file descriptors, returning a list containing \n\ ! any descriptors that have events or errors to report."; static PyObject * --- 432,439 ---- } ! PyDoc_STRVAR(poll_poll_doc, "poll( [timeout] ) -> list of (fd, event) 2-tuples\n\n\ Polls the set of registered file descriptors, returning a list containing \n\ ! any descriptors that have events or errors to report."); static PyObject * *************** *** 581,587 **** }; ! static char poll_doc[] = "Returns a polling object, which supports registering and\n\ ! unregistering file descriptors, and then polling them for I/O events."; static PyObject * --- 581,587 ---- }; ! PyDoc_STRVAR(poll_doc, "Returns a polling object, which supports registering and\n\ ! unregistering file descriptors, and then polling them for I/O events."); static PyObject * *************** *** 599,603 **** #endif /* HAVE_POLL */ ! static char select_doc[] = "select(rlist, wlist, xlist[, timeout]) -> (rlist, wlist, xlist)\n\ \n\ --- 599,603 ---- #endif /* HAVE_POLL */ ! PyDoc_STRVAR(select_doc, "select(rlist, wlist, xlist[, timeout]) -> (rlist, wlist, xlist)\n\ \n\ *************** *** 620,624 **** \n\ *** IMPORTANT NOTICE ***\n\ ! On Windows, only sockets are supported; on Unix, all file descriptors."; static PyMethodDef select_methods[] = { --- 620,624 ---- \n\ *** IMPORTANT NOTICE ***\n\ ! On Windows, only sockets are supported; on Unix, all file descriptors."); static PyMethodDef select_methods[] = { *************** *** 630,638 **** }; ! static char module_doc[] = "This module supports asynchronous I/O on multiple file descriptors.\n\ \n\ *** IMPORTANT NOTICE ***\n\ ! On Windows, only sockets are supported; on Unix, all file descriptors."; DL_EXPORT(void) --- 630,638 ---- }; ! PyDoc_STRVAR(module_doc, "This module supports asynchronous I/O on multiple file descriptors.\n\ \n\ *** IMPORTANT NOTICE ***\n\ ! On Windows, only sockets are supported; on Unix, all file descriptors."); DL_EXPORT(void) Index: shamodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/shamodule.c,v retrieving revision 2.18 retrieving revision 2.19 diff -C2 -d -r2.18 -r2.19 *** shamodule.c 1 Apr 2002 14:30:50 -0000 2.18 --- shamodule.c 13 Jun 2002 20:32:52 -0000 2.19 *************** *** 351,356 **** /* External methods for a hashing object */ ! static char SHA_copy__doc__[] = ! "Return a copy of the hashing object."; static PyObject * --- 351,355 ---- /* External methods for a hashing object */ ! PyDoc_STRVAR(SHA_copy__doc__, "Return a copy of the hashing object."); static PyObject * *************** *** 369,374 **** } ! static char SHA_digest__doc__[] = ! "Return the digest value as a string of binary data."; static PyObject * --- 368,373 ---- } ! PyDoc_STRVAR(SHA_digest__doc__, ! "Return the digest value as a string of binary data."); static PyObject * *************** *** 386,391 **** } ! static char SHA_hexdigest__doc__[] = ! "Return the digest value as a string of hexadecimal digits."; static PyObject * --- 385,390 ---- } ! PyDoc_STRVAR(SHA_hexdigest__doc__, ! "Return the digest value as a string of hexadecimal digits."); static PyObject * *************** *** 428,433 **** } ! static char SHA_update__doc__[] = ! "Update this hashing object's state with the provided string."; static PyObject * --- 427,432 ---- } ! PyDoc_STRVAR(SHA_update__doc__, ! "Update this hashing object's state with the provided string."); static PyObject * *************** *** 480,487 **** /* The single module-level function: new() */ ! static char SHA_new__doc__[] = ! "Return a new SHA hashing object. An optional string " ! "argument may be provided; if present, this string will be " ! " automatically hashed."; static PyObject * --- 479,486 ---- /* The single module-level function: new() */ ! PyDoc_STRVAR(SHA_new__doc__, ! "Return a new SHA hashing object. An optional string argument\n\ ! may be provided; if present, this string will be automatically\n\ ! hashed."); static PyObject * Index: signalmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/signalmodule.c,v retrieving revision 2.67 retrieving revision 2.68 diff -C2 -d -r2.67 -r2.68 *** signalmodule.c 27 May 2002 15:08:23 -0000 2.67 --- signalmodule.c 13 Jun 2002 20:32:52 -0000 2.68 *************** *** 97,105 **** } ! static char default_int_handler_doc[] = "default_int_handler(...)\n\ \n\ The default handler for SIGINT instated by Python.\n\ ! It raises KeyboardInterrupt."; --- 97,105 ---- } ! PyDoc_STRVAR(default_int_handler_doc, "default_int_handler(...)\n\ \n\ The default handler for SIGINT instated by Python.\n\ ! It raises KeyboardInterrupt."); *************** *** 156,163 **** } ! static char alarm_doc[] = "alarm(seconds)\n\ \n\ ! Arrange for SIGALRM to arrive after the given number of seconds."; #endif --- 156,163 ---- } ! PyDoc_STRVAR(alarm_doc, "alarm(seconds)\n\ \n\ ! Arrange for SIGALRM to arrive after the given number of seconds."); #endif *************** *** 178,185 **** return Py_None; } ! static char pause_doc[] = "pause()\n\ \n\ ! Wait until a signal arrives."; #endif --- 178,185 ---- return Py_None; } ! PyDoc_STRVAR(pause_doc, "pause()\n\ \n\ ! Wait until a signal arrives."); #endif *************** *** 232,236 **** } ! static char signal_doc[] = "signal(sig, action) -> action\n\ \n\ --- 232,236 ---- } ! PyDoc_STRVAR(signal_doc, "signal(sig, action) -> action\n\ \n\ *************** *** 241,245 **** *** IMPORTANT NOTICE ***\n\ A signal handler function is called with two arguments:\n\ ! the first is the signal number, the second is the interrupted stack frame."; --- 241,245 ---- *** IMPORTANT NOTICE ***\n\ A signal handler function is called with two arguments:\n\ ! the first is the signal number, the second is the interrupted stack frame."); *************** *** 261,265 **** } ! static char getsignal_doc[] = "getsignal(sig) -> action\n\ \n\ --- 261,265 ---- } ! PyDoc_STRVAR(getsignal_doc, "getsignal(sig) -> action\n\ \n\ *************** *** 268,273 **** SIG_DFL -- if the default action for the signal is in effect\n\ None -- if an unknown handler is in effect\n\ ! anything else -- the callable Python object used as a handler\n\ ! "; #ifdef HAVE_SIGPROCMASK /* we assume that having SIGPROCMASK is enough --- 268,272 ---- SIG_DFL -- if the default action for the signal is in effect\n\ None -- if an unknown handler is in effect\n\ ! anything else -- the callable Python object used as a handler"); #ifdef HAVE_SIGPROCMASK /* we assume that having SIGPROCMASK is enough *************** *** 354,358 **** } ! static char sigprocmask_doc[] = "sigprocmask(how, sigset) -> sigset\n\ \n\ --- 353,357 ---- } ! PyDoc_STRVAR(sigprocmask_doc, "sigprocmask(how, sigset) -> sigset\n\ \n\ *************** *** 372,376 **** The set of blocked signals is set to the argument set.\n\ \n\ ! A list contating the numbers of the previously blocked signals is returned."; static PyObject* --- 371,375 ---- The set of blocked signals is set to the argument set.\n\ \n\ ! A list contating the numbers of the previously blocked signals is returned."); static PyObject* *************** *** 386,394 **** } ! static char sigpending_doc[] = "sigpending() -> sigset\n\ \n\ Return the set of pending signals, i.e. a list containing the numbers of\n\ ! those signals that have been raised while blocked."; static PyObject* --- 385,393 ---- } ! PyDoc_STRVAR(sigpending_doc, "sigpending() -> sigset\n\ \n\ Return the set of pending signals, i.e. a list containing the numbers of\n\ ! those signals that have been raised while blocked."); static PyObject* *************** *** 412,420 **** } ! static char sigsuspend_doc[] = "sigsuspend(sigset) -> None\n\ \n\ Temporarily replace the signal mask with sigset (which should be a sequence\n\ ! of signal numbers) and suspend the process until a signal is received."; #endif --- 411,419 ---- } ! PyDoc_STRVAR(sigsuspend_doc, "sigsuspend(sigset) -> None\n\ \n\ Temporarily replace the signal mask with sigset (which should be a sequence\n\ ! of signal numbers) and suspend the process until a signal is received."); #endif *************** *** 444,448 **** ! static char module_doc[] = "This module provides mechanisms to use signal handlers in Python.\n\ \n\ --- 443,447 ---- ! PyDoc_STRVAR(module_doc, "This module provides mechanisms to use signal handlers in Python.\n\ \n\ *************** *** 469,473 **** *** IMPORTANT NOTICE ***\n\ A signal handler function is called with two arguments:\n\ ! the first is the signal number, the second is the interrupted stack frame."; DL_EXPORT(void) --- 468,472 ---- *** IMPORTANT NOTICE ***\n\ A signal handler function is called with two arguments:\n\ ! the first is the signal number, the second is the interrupted stack frame."); DL_EXPORT(void) Index: socketmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/socketmodule.c,v retrieving revision 1.227 retrieving revision 1.228 diff -C2 -d -r1.227 -r1.228 *** socketmodule.c 13 Jun 2002 16:07:04 -0000 1.227 --- socketmodule.c 13 Jun 2002 20:32:52 -0000 1.228 *************** *** 57,62 **** */ /* Socket object documentation */ ! static char sock_doc[] = "socket([family[, type[, proto]]]) -> socket object\n\ \n\ --- 57,64 ---- */ + #include "Python.h" + /* Socket object documentation */ ! PyDoc_STRVAR(sock_doc, "socket([family[, type[, proto]]]) -> socket object\n\ \n\ *************** *** 94,100 **** shutdown(how) -- shut down traffic in one or both directions\n\ \n\ ! [*] not available on all platforms!"; ! ! #include "Python.h" /* XXX This is a terrible mess of of platform-dependent preprocessor hacks. --- 96,100 ---- shutdown(how) -- shut down traffic in one or both directions\n\ \n\ ! [*] not available on all platforms!"); /* XXX This is a terrible mess of of platform-dependent preprocessor hacks. *************** *** 1002,1011 **** } ! static char accept_doc[] = "accept() -> (socket object, address info)\n\ \n\ Wait for an incoming connection. Return a new socket representing the\n\ connection, and the address of the client. For IP sockets, the address\n\ ! info is a pair (hostaddr, port)."; /* s.setblocking(flag) method. Argument: --- 1002,1011 ---- } ! PyDoc_STRVAR(accept_doc, "accept() -> (socket object, address info)\n\ \n\ Wait for an incoming connection. Return a new socket representing the\n\ connection, and the address of the client. For IP sockets, the address\n\ ! info is a pair (hostaddr, port)."); /* s.setblocking(flag) method. Argument: *************** *** 1030,1039 **** } ! static char setblocking_doc[] = "setblocking(flag)\n\ \n\ Set the socket to blocking (flag is true) or non-blocking (false).\n\ setblocking(True) is equivalent to settimeout(None);\n\ ! setblocking(False) is equivalent to settimeout(0.0)."; /* s.settimeout(timeout) method. Argument: --- 1030,1039 ---- } ! PyDoc_STRVAR(setblocking_doc, "setblocking(flag)\n\ \n\ Set the socket to blocking (flag is true) or non-blocking (false).\n\ setblocking(True) is equivalent to settimeout(None);\n\ ! setblocking(False) is equivalent to settimeout(0.0)."); /* s.settimeout(timeout) method. Argument: *************** *** 1067,1071 **** } ! static char settimeout_doc[] = "settimeout(timeout)\n\ \n\ --- 1067,1071 ---- } ! PyDoc_STRVAR(settimeout_doc, "settimeout(timeout)\n\ \n\ *************** *** 1073,1077 **** giving in seconds, or None. Setting a timeout of None disables\n\ the timeout feature and is equivalent to setblocking(1).\n\ ! Setting a timeout of zero is the same as setblocking(0)."; /* s.gettimeout() method. --- 1073,1077 ---- giving in seconds, or None. Setting a timeout of None disables\n\ the timeout feature and is equivalent to setblocking(1).\n\ ! Setting a timeout of zero is the same as setblocking(0)."); /* s.gettimeout() method. *************** *** 1088,1097 **** } ! static char gettimeout_doc[] = "gettimeout()\n\ \n\ Returns the timeout in floating seconds associated with socket \n\ operations. A timeout of None indicates that timeouts on socket \n\ ! operations are disabled."; #ifdef RISCOS --- 1088,1097 ---- } ! PyDoc_STRVAR(gettimeout_doc, "gettimeout()\n\ \n\ Returns the timeout in floating seconds associated with socket \n\ operations. A timeout of None indicates that timeouts on socket \n\ ! operations are disabled."); #ifdef RISCOS *************** *** 1112,1119 **** return Py_None; } ! static char sleeptaskw_doc[] = "sleeptaskw(flag)\n\ \n\ ! Allow sleeps in taskwindows."; #endif --- 1112,1119 ---- return Py_None; } ! PyDoc_STRVAR(sleeptaskw_doc, "sleeptaskw(flag)\n\ \n\ ! Allow sleeps in taskwindows."); #endif *************** *** 1152,1160 **** } ! static char setsockopt_doc[] = "setsockopt(level, option, value)\n\ \n\ Set a socket option. See the Unix manual for level and option.\n\ ! The value argument can either be an integer or a string."; --- 1152,1160 ---- } ! PyDoc_STRVAR(setsockopt_doc, "setsockopt(level, option, value)\n\ \n\ Set a socket option. See the Unix manual for level and option.\n\ ! The value argument can either be an integer or a string."); *************** *** 1211,1220 **** } ! static char getsockopt_doc[] = "getsockopt(level, option[, buffersize]) -> value\n\ \n\ Get a socket option. See the Unix manual for level and option.\n\ If a nonzero buffersize argument is given, the return value is a\n\ ! string of that length; otherwise it is an integer."; --- 1211,1220 ---- } ! PyDoc_STRVAR(getsockopt_doc, "getsockopt(level, option[, buffersize]) -> value\n\ \n\ Get a socket option. See the Unix manual for level and option.\n\ If a nonzero buffersize argument is given, the return value is a\n\ ! string of that length; otherwise it is an integer."); *************** *** 1239,1248 **** } ! static char bind_doc[] = "bind(address)\n\ \n\ Bind the socket to a local address. For IP sockets, the address is a\n\ pair (host, port); the host must refer to the local host. For raw packet\n\ ! sockets the address is a tuple (ifname, proto [,pkttype [,hatype]])"; --- 1239,1248 ---- } ! PyDoc_STRVAR(bind_doc, "bind(address)\n\ \n\ Bind the socket to a local address. For IP sockets, the address is a\n\ pair (host, port); the host must refer to the local host. For raw packet\n\ ! sockets the address is a tuple (ifname, proto [,pkttype [,hatype]])"); *************** *** 1266,1273 **** } ! static char close_doc[] = "close()\n\ \n\ ! Close the socket. It cannot be used after this call."; static int --- 1266,1273 ---- } ! PyDoc_STRVAR(close_doc, "close()\n\ \n\ ! Close the socket. It cannot be used after this call."); static int *************** *** 1331,1339 **** } ! static char connect_doc[] = "connect(address)\n\ \n\ Connect the socket to a remote address. For IP sockets, the address\n\ ! is a pair (host, port)."; --- 1331,1339 ---- } ! PyDoc_STRVAR(connect_doc, "connect(address)\n\ \n\ Connect the socket to a remote address. For IP sockets, the address\n\ ! is a pair (host, port)."); *************** *** 1357,1365 **** } ! static char connect_ex_doc[] = "connect_ex(address)\n\ \n\ This is like connect(address), but returns an error code (the errno value)\n\ ! instead of raising an exception when an error occurs."; --- 1357,1365 ---- } ! PyDoc_STRVAR(connect_ex_doc, "connect_ex(address)\n\ \n\ This is like connect(address), but returns an error code (the errno value)\n\ ! instead of raising an exception when an error occurs."); *************** *** 1376,1383 **** } ! static char fileno_doc[] = "fileno() -> integer\n\ \n\ ! Return the integer file descriptor of the socket."; --- 1376,1383 ---- } ! PyDoc_STRVAR(fileno_doc, "fileno() -> integer\n\ \n\ ! Return the integer file descriptor of the socket."); *************** *** 1403,1410 **** } ! static char dup_doc[] = "dup() -> socket object\n\ \n\ ! Return a new socket object connected to the same system resource."; #endif --- 1403,1410 ---- } ! PyDoc_STRVAR(dup_doc, "dup() -> socket object\n\ \n\ ! Return a new socket object connected to the same system resource."); #endif *************** *** 1431,1439 **** } ! static char getsockname_doc[] = "getsockname() -> address info\n\ \n\ Return the address of the local endpoint. For IP sockets, the address\n\ ! info is a pair (hostaddr, port)."; --- 1431,1439 ---- } ! PyDoc_STRVAR(getsockname_doc, "getsockname() -> address info\n\ \n\ Return the address of the local endpoint. For IP sockets, the address\n\ ! info is a pair (hostaddr, port)."); *************** *** 1459,1467 **** } ! static char getpeername_doc[] = "getpeername() -> address info\n\ \n\ Return the address of the remote endpoint. For IP sockets, the address\n\ ! info is a pair (hostaddr, port)."; #endif /* HAVE_GETPEERNAME */ --- 1459,1467 ---- } ! PyDoc_STRVAR(getpeername_doc, "getpeername() -> address info\n\ \n\ Return the address of the remote endpoint. For IP sockets, the address\n\ ! info is a pair (hostaddr, port)."); #endif /* HAVE_GETPEERNAME */ *************** *** 1490,1499 **** } ! static char listen_doc[] = "listen(backlog)\n\ \n\ Enable a server to accept connections. The backlog argument must be at\n\ least 1; it specifies the number of unaccepted connection that the system\n\ ! will allow before refusing new connections."; --- 1490,1499 ---- } ! PyDoc_STRVAR(listen_doc, "listen(backlog)\n\ \n\ Enable a server to accept connections. The backlog argument must be at\n\ least 1; it specifies the number of unaccepted connection that the system\n\ ! will allow before refusing new connections."); *************** *** 1544,1552 **** } ! static char makefile_doc[] = "makefile([mode[, buffersize]]) -> file object\n\ \n\ Return a regular file object corresponding to the socket.\n\ ! The mode and buffersize arguments are as for the built-in open() function."; #endif /* NO_DUP */ --- 1544,1552 ---- } ! PyDoc_STRVAR(makefile_doc, "makefile([mode[, buffersize]]) -> file object\n\ \n\ Return a regular file object corresponding to the socket.\n\ ! The mode and buffersize arguments are as for the built-in open() function."); #endif /* NO_DUP */ *************** *** 1588,1592 **** } ! static char recv_doc[] = "recv(buffersize[, flags]) -> data\n\ \n\ --- 1588,1592 ---- } ! PyDoc_STRVAR(recv_doc, "recv(buffersize[, flags]) -> data\n\ \n\ *************** *** 1594,1598 **** argument, see the Unix manual. When no data is available, block until\n\ at least one byte is available or until the remote end is closed. When\n\ ! the remote end is closed and all data is read, return the empty string."; --- 1594,1598 ---- argument, see the Unix manual. When no data is available, block until\n\ at least one byte is available or until the remote end is closed. When\n\ ! the remote end is closed and all data is read, return the empty string."); *************** *** 1654,1661 **** } ! static char recvfrom_doc[] = "recvfrom(buffersize[, flags]) -> (data, address info)\n\ \n\ ! Like recv(buffersize, flags) but also return the sender's address info."; /* s.send(data [,flags]) method */ --- 1654,1661 ---- } ! PyDoc_STRVAR(recvfrom_doc, "recvfrom(buffersize[, flags]) -> (data, address info)\n\ \n\ ! Like recv(buffersize, flags) but also return the sender's address info."); /* s.send(data [,flags]) method */ *************** *** 1680,1689 **** } ! static char send_doc[] = "send(data[, flags]) -> count\n\ \n\ Send a data string to the socket. For the optional flags\n\ argument, see the Unix manual. Return the number of bytes\n\ ! sent; this may be less than len(data) if the network is busy."; --- 1680,1689 ---- } ! PyDoc_STRVAR(send_doc, "send(data[, flags]) -> count\n\ \n\ Send a data string to the socket. For the optional flags\n\ argument, see the Unix manual. Return the number of bytes\n\ ! sent; this may be less than len(data) if the network is busy."); *************** *** 1717,1721 **** } ! static char sendall_doc[] = "sendall(data[, flags])\n\ \n\ --- 1717,1721 ---- } ! PyDoc_STRVAR(sendall_doc, "sendall(data[, flags])\n\ \n\ *************** *** 1723,1727 **** argument, see the Unix manual. This calls send() repeatedly\n\ until all data is sent. If an error occurs, it's impossible\n\ ! to tell how much data has been sent."; --- 1723,1727 ---- argument, see the Unix manual. This calls send() repeatedly\n\ until all data is sent. If an error occurs, it's impossible\n\ ! to tell how much data has been sent."); *************** *** 1757,1765 **** } ! static char sendto_doc[] = "sendto(data[, flags], address)\n\ \n\ Like send(data, flags) but allows specifying the destination address.\n\ ! For IP sockets, the address is a pair (hostaddr, port)."; --- 1757,1765 ---- } ! PyDoc_STRVAR(sendto_doc, "sendto(data[, flags], address)\n\ \n\ Like send(data, flags) but allows specifying the destination address.\n\ ! For IP sockets, the address is a pair (hostaddr, port)."); *************** *** 1784,1792 **** } ! static char shutdown_doc[] = "shutdown(flag)\n\ \n\ Shut down the reading side of the socket (flag == 0), the writing side\n\ ! of the socket (flag == 1), or both ends (flag == 2)."; --- 1784,1792 ---- } ! PyDoc_STRVAR(shutdown_doc, "shutdown(flag)\n\ \n\ Shut down the reading side of the socket (flag == 0), the writing side\n\ ! of the socket (flag == 1), or both ends (flag == 2)."); *************** *** 2012,2019 **** } ! static char gethostname_doc[] = "gethostname() -> string\n\ \n\ ! Return the current host name."; --- 2012,2019 ---- } ! PyDoc_STRVAR(gethostname_doc, "gethostname() -> string\n\ \n\ ! Return the current host name."); *************** *** 2035,2042 **** } ! static char gethostbyname_doc[] = "gethostbyname(host) -> address\n\ \n\ ! Return the IP address (a string of the form '255.255.255.255') for a host."; --- 2035,2042 ---- } ! PyDoc_STRVAR(gethostbyname_doc, "gethostbyname(host) -> address\n\ \n\ ! Return the IP address (a string of the form '255.255.255.255') for a host."); *************** *** 2236,2244 **** } ! static char ghbn_ex_doc[] = "gethostbyname_ex(host) -> (name, aliaslist, addresslist)\n\ \n\ Return the true host name, a list of aliases, and a list of IP addresses,\n\ ! for a host. The host argument is a string giving a host name or IP number."; --- 2236,2244 ---- } ! PyDoc_STRVAR(ghbn_ex_doc, "gethostbyname_ex(host) -> (name, aliaslist, addresslist)\n\ \n\ Return the true host name, a list of aliases, and a list of IP addresses,\n\ ! for a host. The host argument is a string giving a host name or IP number."); *************** *** 2326,2334 **** } ! static char gethostbyaddr_doc[] = "gethostbyaddr(host) -> (name, aliaslist, addresslist)\n\ \n\ Return the true host name, a list of aliases, and a list of IP addresses,\n\ ! for a host. The host argument is a string giving a host name or IP number."; --- 2326,2334 ---- } ! PyDoc_STRVAR(gethostbyaddr_doc, "gethostbyaddr(host) -> (name, aliaslist, addresslist)\n\ \n\ Return the true host name, a list of aliases, and a list of IP addresses,\n\ ! for a host. The host argument is a string giving a host name or IP number."); *************** *** 2355,2363 **** } ! static char getservbyname_doc[] = "getservbyname(servicename, protocolname) -> integer\n\ \n\ Return a port number from a service name and protocol name.\n\ ! The protocol name should be 'tcp' or 'udp'."; --- 2355,2363 ---- } ! PyDoc_STRVAR(getservbyname_doc, "getservbyname(servicename, protocolname) -> integer\n\ \n\ Return a port number from a service name and protocol name.\n\ ! The protocol name should be 'tcp' or 'udp'."); *************** *** 2390,2397 **** } ! static char getprotobyname_doc[] = "getprotobyname(name) -> integer\n\ \n\ ! Return the protocol number for the named protocol. (Rarely used.)"; --- 2390,2397 ---- } ! PyDoc_STRVAR(getprotobyname_doc, "getprotobyname(name) -> integer\n\ \n\ ! Return the protocol number for the named protocol. (Rarely used.)"); *************** *** 2424,2432 **** } ! static char fromfd_doc[] = "fromfd(fd, family, type[, proto]) -> socket object\n\ \n\ Create a socket object from the given file descriptor.\n\ ! The remaining arguments are the same as for socket()."; #endif /* NO_DUP */ --- 2424,2432 ---- } ! PyDoc_STRVAR(fromfd_doc, "fromfd(fd, family, type[, proto]) -> socket object\n\ \n\ Create a socket object from the given file descriptor.\n\ ! The remaining arguments are the same as for socket()."); #endif /* NO_DUP */ *************** *** 2445,2452 **** } ! static char ntohs_doc[] = "ntohs(integer) -> integer\n\ \n\ ! Convert a 16-bit integer from network to host byte order."; --- 2445,2452 ---- } ! PyDoc_STRVAR(ntohs_doc, "ntohs(integer) -> integer\n\ \n\ ! Convert a 16-bit integer from network to host byte order."); *************** *** 2463,2470 **** } ! static char ntohl_doc[] = "ntohl(integer) -> integer\n\ \n\ ! Convert a 32-bit integer from network to host byte order."; --- 2463,2470 ---- } ! PyDoc_STRVAR(ntohl_doc, "ntohl(integer) -> integer\n\ \n\ ! Convert a 32-bit integer from network to host byte order."); *************** *** 2481,2488 **** } ! static char htons_doc[] = "htons(integer) -> integer\n\ \n\ ! Convert a 16-bit integer from host to network byte order."; --- 2481,2488 ---- } ! PyDoc_STRVAR(htons_doc, "htons(integer) -> integer\n\ \n\ ! Convert a 16-bit integer from host to network byte order."); *************** *** 2499,2514 **** } ! static char htonl_doc[] = "htonl(integer) -> integer\n\ \n\ ! Convert a 32-bit integer from host to network byte order."; /* socket.inet_aton() and socket.inet_ntoa() functions. */ ! static char inet_aton_doc[] = "inet_aton(string) -> packed 32-bit IP representation\n\ \n\ Convert an IP address in string format (123.45.67.89) to the 32-bit packed\n\ ! binary format used in low-level network functions."; static PyObject* --- 2499,2514 ---- } ! PyDoc_STRVAR(htonl_doc, "htonl(integer) -> integer\n\ \n\ ! Convert a 32-bit integer from host to network byte order."); /* socket.inet_aton() and socket.inet_ntoa() functions. */ ! PyDoc_STRVAR(inet_aton_doc, "inet_aton(string) -> packed 32-bit IP representation\n\ \n\ Convert an IP address in string format (123.45.67.89) to the 32-bit packed\n\ ! binary format used in low-level network functions."); static PyObject* *************** *** 2538,2545 **** } ! static char inet_ntoa_doc[] = "inet_ntoa(packed_ip) -> ip_address_string\n\ \n\ ! Convert an IP address from 32-bit packed binary format to string format"; static PyObject* --- 2538,2545 ---- } ! PyDoc_STRVAR(inet_ntoa_doc, "inet_ntoa(packed_ip) -> ip_address_string\n\ \n\ ! Convert an IP address from 32-bit packed binary format to string format"); static PyObject* *************** *** 2638,2646 **** } ! static char getaddrinfo_doc[] = "socket.getaddrinfo(host, port [, family, socktype, proto, flags])\n\ --> List of (family, socktype, proto, canonname, sockaddr)\n\ \n\ ! Resolve host and port into addrinfo struct."; /* Python interface to getnameinfo(sa, flags). */ --- 2638,2646 ---- } ! PyDoc_STRVAR(getaddrinfo_doc, "socket.getaddrinfo(host, port [, family, socktype, proto, flags])\n\ --> List of (family, socktype, proto, canonname, sockaddr)\n\ \n\ ! Resolve host and port into addrinfo struct."); /* Python interface to getnameinfo(sa, flags). */ *************** *** 2716,2723 **** } ! static char getnameinfo_doc[] = "socket.getnameinfo(sockaddr, flags) --> (host, port)\n\ \n\ ! Get host and port for a sockaddr."; /* List of functions exported by this module. */ --- 2716,2723 ---- } ! PyDoc_STRVAR(getnameinfo_doc, "socket.getnameinfo(sockaddr, flags) --> (host, port)\n\ \n\ ! Get host and port for a sockaddr."); /* List of functions exported by this module. */ *************** *** 2883,2889 **** */ ! static char socket_doc[] = "Implementation module for socket operations. See the socket module\n\ ! for documentation."; DL_EXPORT(void) --- 2883,2889 ---- */ ! PyDoc_STRVAR(socket_doc, "Implementation module for socket operations. See the socket module\n\ ! for documentation."); DL_EXPORT(void) Index: stropmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/stropmodule.c,v retrieving revision 2.88 retrieving revision 2.89 diff -C2 -d -r2.88 -r2.89 *** stropmodule.c 27 Apr 2002 18:44:31 -0000 2.88 --- stropmodule.c 13 Jun 2002 20:32:53 -0000 2.89 *************** *** 1,13 **** /* strop module */ ! static char strop_module__doc__[] = "Common string manipulations, optimized for speed.\n" "\n" "Always use \"import string\" rather than referencing\n" ! "this module directly."; ! ! #include "Python.h" - #include /* XXX This file assumes that the is*() functions XXX are defined for all 8-bit characters! */ --- 1,13 ---- /* strop module */ ! #include "Python.h" ! #include ! ! PyDoc_STRVAR(strop_module__doc__, "Common string manipulations, optimized for speed.\n" "\n" "Always use \"import string\" rather than referencing\n" ! "this module directly."); /* XXX This file assumes that the is*() functions XXX are defined for all 8-bit characters! */ *************** *** 81,85 **** ! static char splitfields__doc__[] = "split(s [,sep [,maxsplit]]) -> list of strings\n" "splitfields(s [,sep [,maxsplit]]) -> list of strings\n" --- 81,85 ---- ! PyDoc_STRVAR(splitfields__doc__, "split(s [,sep [,maxsplit]]) -> list of strings\n" "splitfields(s [,sep [,maxsplit]]) -> list of strings\n" *************** *** 90,94 **** "is a separator. Maxsplit defaults to 0.\n" "\n" ! "(split and splitfields are synonymous)"; static PyObject * --- 90,94 ---- "is a separator. Maxsplit defaults to 0.\n" "\n" ! "(split and splitfields are synonymous)"); static PyObject * *************** *** 152,156 **** ! static char joinfields__doc__[] = "join(list [,sep]) -> string\n" "joinfields(list [,sep]) -> string\n" --- 152,156 ---- ! PyDoc_STRVAR(joinfields__doc__, "join(list [,sep]) -> string\n" "joinfields(list [,sep]) -> string\n" *************** *** 160,164 **** "space.\n" "\n" ! "(join and joinfields are synonymous)"; static PyObject * --- 160,164 ---- "space.\n" "\n" ! "(join and joinfields are synonymous)"); static PyObject * *************** *** 275,279 **** ! static char find__doc__[] = "find(s, sub [,start [,end]]) -> in\n" "\n" --- 275,279 ---- ! PyDoc_STRVAR(find__doc__, "find(s, sub [,start [,end]]) -> in\n" "\n" *************** *** 282,286 **** "arguments start and end are interpreted as in slice notation.\n" "\n" ! "Return -1 on failure."; static PyObject * --- 282,286 ---- "arguments start and end are interpreted as in slice notation.\n" "\n" ! "Return -1 on failure."); static PyObject * *************** *** 318,322 **** ! static char rfind__doc__[] = "rfind(s, sub [,start [,end]]) -> int\n" "\n" --- 318,322 ---- ! PyDoc_STRVAR(rfind__doc__, "rfind(s, sub [,start [,end]]) -> int\n" "\n" *************** *** 325,329 **** "arguments start and end are interpreted as in slice notation.\n" "\n" ! "Return -1 on failure."; static PyObject * --- 325,329 ---- "arguments start and end are interpreted as in slice notation.\n" "\n" ! "Return -1 on failure."); static PyObject * *************** *** 395,403 **** ! static char strip__doc__[] = "strip(s) -> string\n" "\n" "Return a copy of the string s with leading and trailing\n" ! "whitespace removed."; static PyObject * --- 395,403 ---- ! PyDoc_STRVAR(strip__doc__, "strip(s) -> string\n" "\n" "Return a copy of the string s with leading and trailing\n" ! "whitespace removed."); static PyObject * *************** *** 409,416 **** ! static char lstrip__doc__[] = "lstrip(s) -> string\n" "\n" ! "Return a copy of the string s with leading whitespace removed."; static PyObject * --- 409,416 ---- ! PyDoc_STRVAR(lstrip__doc__, "lstrip(s) -> string\n" "\n" ! "Return a copy of the string s with leading whitespace removed."); static PyObject * *************** *** 422,429 **** ! static char rstrip__doc__[] = "rstrip(s) -> string\n" "\n" ! "Return a copy of the string s with trailing whitespace removed."; static PyObject * --- 422,429 ---- ! PyDoc_STRVAR(rstrip__doc__, "rstrip(s) -> string\n" "\n" ! "Return a copy of the string s with trailing whitespace removed."); static PyObject * *************** *** 435,442 **** ! static char lower__doc__[] = "lower(s) -> string\n" "\n" ! "Return a copy of the string s converted to lowercase."; static PyObject * --- 435,442 ---- ! PyDoc_STRVAR(lower__doc__, "lower(s) -> string\n" "\n" ! "Return a copy of the string s converted to lowercase."); static PyObject * *************** *** 474,481 **** ! static char upper__doc__[] = "upper(s) -> string\n" "\n" ! "Return a copy of the string s converted to uppercase."; static PyObject * --- 474,481 ---- ! PyDoc_STRVAR(upper__doc__, "upper(s) -> string\n" "\n" ! "Return a copy of the string s converted to uppercase."); static PyObject * *************** *** 513,521 **** ! static char capitalize__doc__[] = "capitalize(s) -> string\n" "\n" "Return a copy of the string s with only its first character\n" ! "capitalized."; static PyObject * --- 513,521 ---- ! PyDoc_STRVAR(capitalize__doc__, "capitalize(s) -> string\n" "\n" "Return a copy of the string s with only its first character\n" ! "capitalized."); static PyObject * *************** *** 562,566 **** ! static char expandtabs__doc__[] = "expandtabs(string, [tabsize]) -> string\n" "\n" --- 562,566 ---- ! PyDoc_STRVAR(expandtabs__doc__, "expandtabs(string, [tabsize]) -> string\n" "\n" *************** *** 568,572 **** "depending on the current column and the given tab size (default 8).\n" "The column number is reset to zero after each newline occurring in the\n" ! "string. This doesn't understand other non-printing characters."; static PyObject * --- 568,572 ---- "depending on the current column and the given tab size (default 8).\n" "The column number is reset to zero after each newline occurring in the\n" ! "string. This doesn't understand other non-printing characters."); static PyObject * *************** *** 634,643 **** ! static char count__doc__[] = "count(s, sub[, start[, end]]) -> int\n" "\n" "Return the number of occurrences of substring sub in string\n" "s[start:end]. Optional arguments start and end are\n" ! "interpreted as in slice notation."; static PyObject * --- 634,643 ---- ! PyDoc_STRVAR(count__doc__, "count(s, sub[, start[, end]]) -> int\n" "\n" "Return the number of occurrences of substring sub in string\n" "s[start:end]. Optional arguments start and end are\n" ! "interpreted as in slice notation."); static PyObject * *************** *** 679,687 **** ! static char swapcase__doc__[] = "swapcase(s) -> string\n" "\n" "Return a copy of the string s with upper case characters\n" ! "converted to lowercase and vice versa."; static PyObject * --- 679,687 ---- ! PyDoc_STRVAR(swapcase__doc__, "swapcase(s) -> string\n" "\n" "Return a copy of the string s with upper case characters\n" ! "converted to lowercase and vice versa."); static PyObject * *************** *** 724,728 **** ! static char atoi__doc__[] = "atoi(s [,base]) -> int\n" "\n" --- 724,728 ---- ! PyDoc_STRVAR(atoi__doc__, "atoi(s [,base]) -> int\n" "\n" *************** *** 732,736 **** "is chosen from the leading characters of s, 0 for octal, 0x or\n" "0X for hexadecimal. If base is 16, a preceding 0x or 0X is\n" ! "accepted."; static PyObject * --- 732,736 ---- "is chosen from the leading characters of s, 0 for octal, 0x or\n" "0X for hexadecimal. If base is 16, a preceding 0x or 0X is\n" ! "accepted."); static PyObject * *************** *** 779,783 **** ! static char atol__doc__[] = "atol(s [,base]) -> long\n" "\n" --- 779,783 ---- ! PyDoc_STRVAR(atol__doc__, "atol(s [,base]) -> long\n" "\n" *************** *** 788,792 **** "octal, 0x or 0X for hexadecimal. If base is 16, a preceding\n" "0x or 0X is accepted. A trailing L or l is not accepted,\n" ! "unless base is 0."; static PyObject * --- 788,792 ---- "octal, 0x or 0X for hexadecimal. If base is 16, a preceding\n" "0x or 0X is accepted. A trailing L or l is not accepted,\n" ! "unless base is 0."); static PyObject * *************** *** 831,838 **** ! static char atof__doc__[] = "atof(s) -> float\n" "\n" ! "Return the floating point number represented by the string s."; static PyObject * --- 831,838 ---- ! PyDoc_STRVAR(atof__doc__, "atof(s) -> float\n" "\n" ! "Return the floating point number represented by the string s."); static PyObject * *************** *** 875,884 **** ! static char maketrans__doc__[] = "maketrans(frm, to) -> string\n" "\n" "Return a translation table (a string of 256 bytes long)\n" "suitable for use in string.translate. The strings frm and to\n" ! "must be of the same length."; static PyObject * --- 875,884 ---- ! PyDoc_STRVAR(maketrans__doc__, "maketrans(frm, to) -> string\n" "\n" "Return a translation table (a string of 256 bytes long)\n" "suitable for use in string.translate. The strings frm and to\n" ! "must be of the same length."); static PyObject * *************** *** 911,915 **** ! static char translate__doc__[] = "translate(s,table [,deletechars]) -> string\n" "\n" --- 911,915 ---- ! PyDoc_STRVAR(translate__doc__, "translate(s,table [,deletechars]) -> string\n" "\n" *************** *** 917,921 **** "in the optional argument deletechars are removed, and the\n" "remaining characters have been mapped through the given\n" ! "translation table, which must be a string of length 256."; static PyObject * --- 917,921 ---- "in the optional argument deletechars are removed, and the\n" "remaining characters have been mapped through the given\n" ! "translation table, which must be a string of length 256."); static PyObject * *************** *** 1127,1136 **** ! static char replace__doc__[] = "replace (str, old, new[, maxsplit]) -> string\n" "\n" "Return a copy of string str with all occurrences of substring\n" "old replaced by new. If the optional argument maxsplit is\n" ! "given, only the first maxsplit occurrences are replaced."; static PyObject * --- 1127,1136 ---- ! PyDoc_STRVAR(replace__doc__, "replace (str, old, new[, maxsplit]) -> string\n" "\n" "Return a copy of string str with all occurrences of substring\n" "old replaced by new. If the optional argument maxsplit is\n" ! "given, only the first maxsplit occurrences are replaced."); static PyObject * Index: structmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/structmodule.c,v retrieving revision 2.54 retrieving revision 2.55 diff -C2 -d -r2.54 -r2.55 *** structmodule.c 2 Apr 2002 18:17:55 -0000 2.54 --- structmodule.c 13 Jun 2002 20:32:53 -0000 2.55 *************** *** 5,10 **** character strings, and unsigned numbers */ ! static char struct__doc__[] = "\ ! Functions to convert between Python values and C structs.\n\ Python strings are used to hold the data representing the C struct\n\ and also as format strings to describe the layout of data in the C struct.\n\ --- 5,13 ---- character strings, and unsigned numbers */ ! #include "Python.h" ! #include ! ! PyDoc_STRVAR(struct__doc__, ! "Functions to convert between Python values and C structs.\n\ Python strings are used to hold the data representing the C struct\n\ and also as format strings to describe the layout of data in the C struct.\n\ *************** *** 30,38 **** Whitespace between formats is ignored.\n\ \n\ ! The variable struct.error is an exception raised on errors."; ! ! #include "Python.h" ! ! #include --- 33,37 ---- Whitespace between formats is ignored.\n\ \n\ ! The variable struct.error is an exception raised on errors."); *************** *** 1228,1235 **** ! static char calcsize__doc__[] = "\ ! calcsize(fmt) -> int\n\ Return size of C struct described by format string fmt.\n\ ! See struct.__doc__ for more on format strings."; static PyObject * --- 1227,1234 ---- ! PyDoc_STRVAR(calcsize__doc__, ! "calcsize(fmt) -> int\n\ Return size of C struct described by format string fmt.\n\ ! See struct.__doc__ for more on format strings."); static PyObject * *************** *** 1250,1257 **** ! static char pack__doc__[] = "\ ! pack(fmt, v1, v2, ...) -> string\n\ Return string containing values v1, v2, ... packed according to fmt.\n\ ! See struct.__doc__ for more on format strings."; static PyObject * --- 1249,1256 ---- ! PyDoc_STRVAR(pack__doc__, ! "pack(fmt, v1, v2, ...) -> string\n\ Return string containing values v1, v2, ... packed according to fmt.\n\ ! See struct.__doc__ for more on format strings."); static PyObject * *************** *** 1390,1398 **** ! static char unpack__doc__[] = "\ ! unpack(fmt, string) -> (v1, v2, ...)\n\ Unpack the string, containing packed C structure data, according\n\ to fmt. Requires len(string)==calcsize(fmt).\n\ ! See struct.__doc__ for more on format strings."; static PyObject * --- 1389,1397 ---- ! PyDoc_STRVAR(unpack__doc__, ! "unpack(fmt, string) -> (v1, v2, ...)\n\ Unpack the string, containing packed C structure data, according\n\ to fmt. Requires len(string)==calcsize(fmt).\n\ ! See struct.__doc__ for more on format strings."); static PyObject * Index: termios.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/termios.c,v retrieving revision 2.34 retrieving revision 2.35 diff -C2 -d -r2.34 -r2.35 *** termios.c 3 Mar 2002 02:59:16 -0000 2.34 --- termios.c 13 Jun 2002 20:32:53 -0000 2.35 *************** *** 21,26 **** #endif ! static char termios__doc__[] = "\ ! This module provides an interface to the Posix calls for tty I/O control.\n\ For a complete description of these calls, see the Posix or Unix manual\n\ pages. It is only available for those Unix versions that support Posix\n\ --- 21,26 ---- #endif ! PyDoc_STRVAR(termios__doc__, ! "This module provides an interface to the Posix calls for tty I/O control.\n\ For a complete description of these calls, see the Posix or Unix manual\n\ pages. It is only available for those Unix versions that support Posix\n\ *************** *** 29,33 **** All functions in this module take a file descriptor fd as their first\n\ argument. This can be an integer file descriptor, such as returned by\n\ ! sys.stdin.fileno(), or a file object, such as sys.stdin itself."; static PyObject *TermiosError; --- 29,33 ---- All functions in this module take a file descriptor fd as their first\n\ argument. This can be an integer file descriptor, such as returned by\n\ ! sys.stdin.fileno(), or a file object, such as sys.stdin itself."); static PyObject *TermiosError; *************** *** 45,50 **** } ! static char termios_tcgetattr__doc__[] = "\ ! tcgetattr(fd) -> list_of_attrs\n\ \n\ Get the tty attributes for file descriptor fd, as follows:\n\ --- 45,50 ---- } ! PyDoc_STRVAR(termios_tcgetattr__doc__, ! "tcgetattr(fd) -> list_of_attrs\n\ \n\ Get the tty attributes for file descriptor fd, as follows:\n\ *************** *** 54,58 **** defined). The interpretation of the flags and the speeds as well as the\n\ indexing in the cc array must be done using the symbolic constants defined\n\ ! in this module."; static PyObject * --- 54,58 ---- defined). The interpretation of the flags and the speeds as well as the\n\ indexing in the cc array must be done using the symbolic constants defined\n\ ! in this module."); static PyObject * *************** *** 122,127 **** } ! static char termios_tcsetattr__doc__[] = "\ ! tcsetattr(fd, when, attributes) -> None\n\ \n\ Set the tty attributes for file descriptor fd.\n\ --- 122,127 ---- } ! PyDoc_STRVAR(termios_tcsetattr__doc__, ! "tcsetattr(fd, when, attributes) -> None\n\ \n\ Set the tty attributes for file descriptor fd.\n\ *************** *** 131,135 **** change immediately, termios.TCSADRAIN to change after transmitting all\n\ queued output, or termios.TCSAFLUSH to change after transmitting all\n\ ! queued output and discarding all queued input. "; static PyObject * --- 131,135 ---- change immediately, termios.TCSADRAIN to change after transmitting all\n\ queued output, or termios.TCSAFLUSH to change after transmitting all\n\ ! queued output and discarding all queued input. "); static PyObject * *************** *** 196,205 **** } ! static char termios_tcsendbreak__doc__[] = "\ ! tcsendbreak(fd, duration) -> None\n\ \n\ Send a break on file descriptor fd.\n\ A zero duration sends a break for 0.25-0.5 seconds; a nonzero duration\n\ ! has a system dependent meaning."; static PyObject * --- 196,205 ---- } ! PyDoc_STRVAR(termios_tcsendbreak__doc__, ! "tcsendbreak(fd, duration) -> None\n\ \n\ Send a break on file descriptor fd.\n\ A zero duration sends a break for 0.25-0.5 seconds; a nonzero duration\n\ ! has a system dependent meaning."); static PyObject * *************** *** 218,225 **** } ! static char termios_tcdrain__doc__[] = "\ ! tcdrain(fd) -> None\n\ \n\ ! Wait until all output written to file descriptor fd has been transmitted."; static PyObject * --- 218,225 ---- } ! PyDoc_STRVAR(termios_tcdrain__doc__, ! "tcdrain(fd) -> None\n\ \n\ ! Wait until all output written to file descriptor fd has been transmitted."); static PyObject * *************** *** 238,248 **** } ! static char termios_tcflush__doc__[] = "\ ! tcflush(fd, queue) -> None\n\ \n\ Discard queued data on file descriptor fd.\n\ The queue selector specifies which queue: termios.TCIFLUSH for the input\n\ queue, termios.TCOFLUSH for the output queue, or termios.TCIOFLUSH for\n\ ! both queues. "; static PyObject * --- 238,248 ---- } ! PyDoc_STRVAR(termios_tcflush__doc__, ! "tcflush(fd, queue) -> None\n\ \n\ Discard queued data on file descriptor fd.\n\ The queue selector specifies which queue: termios.TCIFLUSH for the input\n\ queue, termios.TCOFLUSH for the output queue, or termios.TCIOFLUSH for\n\ ! both queues. "); static PyObject * *************** *** 261,271 **** } ! static char termios_tcflow__doc__[] = "\ ! tcflow(fd, action) -> None\n\ \n\ Suspend or resume input or output on file descriptor fd.\n\ The action argument can be termios.TCOOFF to suspend output,\n\ termios.TCOON to restart output, termios.TCIOFF to suspend input,\n\ ! or termios.TCION to restart input."; static PyObject * --- 261,271 ---- } ! PyDoc_STRVAR(termios_tcflow__doc__, ! "tcflow(fd, action) -> None\n\ \n\ Suspend or resume input or output on file descriptor fd.\n\ The action argument can be termios.TCOOFF to suspend output,\n\ termios.TCOON to restart output, termios.TCIOFF to suspend input,\n\ ! or termios.TCION to restart input."); static PyObject * Index: threadmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/threadmodule.c,v retrieving revision 2.49 retrieving revision 2.50 diff -C2 -d -r2.49 -r2.50 *** threadmodule.c 7 Apr 2002 06:32:21 -0000 2.49 --- threadmodule.c 13 Jun 2002 20:32:53 -0000 2.50 *************** *** 72,76 **** } ! static char acquire_doc[] = "acquire([wait]) -> None or bool\n\ (PyThread_acquire_lock() is an obsolete synonym)\n\ --- 72,76 ---- } ! PyDoc_STRVAR(acquire_doc, "acquire([wait]) -> None or bool\n\ (PyThread_acquire_lock() is an obsolete synonym)\n\ *************** *** 81,85 **** With an argument, this will only block if the argument is true,\n\ and the return value reflects whether the lock is acquired.\n\ ! The blocking operation is not interruptible."; static PyObject * --- 81,85 ---- With an argument, this will only block if the argument is true,\n\ and the return value reflects whether the lock is acquired.\n\ ! The blocking operation is not interruptible."); static PyObject * *************** *** 98,102 **** } ! static char release_doc[] = "release()\n\ (PyThread_release_lock() is an obsolete synonym)\n\ --- 98,102 ---- } ! PyDoc_STRVAR(release_doc, "release()\n\ (PyThread_release_lock() is an obsolete synonym)\n\ *************** *** 104,108 **** Release the lock, allowing another thread that is blocked waiting for\n\ the lock to acquire the lock. The lock must be in the locked state,\n\ ! but it needn't be locked by the same thread that unlocks it."; static PyObject * --- 104,108 ---- Release the lock, allowing another thread that is blocked waiting for\n\ the lock to acquire the lock. The lock must be in the locked state,\n\ ! but it needn't be locked by the same thread that unlocks it."); static PyObject * *************** *** 116,124 **** } ! static char locked_doc[] = "locked() -> bool\n\ (locked_lock() is an obsolete synonym)\n\ \n\ ! Return whether the lock is in the locked state."; static PyMethodDef lock_methods[] = { --- 116,124 ---- } ! PyDoc_STRVAR(locked_doc, "locked() -> bool\n\ (locked_lock() is an obsolete synonym)\n\ \n\ ! Return whether the lock is in the locked state."); static PyMethodDef lock_methods[] = { *************** *** 246,250 **** } ! static char start_new_doc[] = "start_new_thread(function, args[, kwargs])\n\ (start_new() is an obsolete synonym)\n\ --- 246,250 ---- } ! PyDoc_STRVAR(start_new_doc, "start_new_thread(function, args[, kwargs])\n\ (start_new() is an obsolete synonym)\n\ *************** *** 255,259 **** function returns; the return value is ignored. The thread will also exit\n\ when the function raises an unhandled exception; a stack trace will be\n\ ! printed unless the exception is SystemExit.\n"; static PyObject * --- 255,259 ---- function returns; the return value is ignored. The thread will also exit\n\ when the function raises an unhandled exception; a stack trace will be\n\ ! printed unless the exception is SystemExit.\n"); static PyObject * *************** *** 264,273 **** } ! static char exit_doc[] = "exit()\n\ (PyThread_exit_thread() is an obsolete synonym)\n\ \n\ This is synonymous to ``raise SystemExit''. It will cause the current\n\ ! thread to exit silently unless the exception is caught."; #ifndef NO_EXIT_PROG --- 264,273 ---- } ! PyDoc_STRVAR(exit_doc, "exit()\n\ (PyThread_exit_thread() is an obsolete synonym)\n\ \n\ This is synonymous to ``raise SystemExit''. It will cause the current\n\ ! thread to exit silently unless the exception is caught."); #ifndef NO_EXIT_PROG *************** *** 289,297 **** } ! static char allocate_doc[] = "allocate_lock() -> lock object\n\ (allocate() is an obsolete synonym)\n\ \n\ ! Create a new lock object. See LockType.__doc__ for information about locks."; static PyObject * --- 289,297 ---- } ! PyDoc_STRVAR(allocate_doc, "allocate_lock() -> lock object\n\ (allocate() is an obsolete synonym)\n\ \n\ ! Create a new lock object. See LockType.__doc__ for information about locks."); static PyObject * *************** *** 307,311 **** } ! static char get_ident_doc[] = "get_ident() -> integer\n\ \n\ --- 307,311 ---- } ! PyDoc_STRVAR(get_ident_doc, "get_ident() -> integer\n\ \n\ *************** *** 316,320 **** allocated consecutive numbers starting at 1, this behavior should not\n\ be relied upon, and the number should be seen purely as a magic cookie.\n\ ! A thread's identity may be reused for another thread after it exits."; static PyMethodDef thread_methods[] = { --- 316,320 ---- allocated consecutive numbers starting at 1, this behavior should not\n\ be relied upon, and the number should be seen purely as a magic cookie.\n\ ! A thread's identity may be reused for another thread after it exits."); static PyMethodDef thread_methods[] = { *************** *** 345,353 **** /* Initialization function */ ! static char thread_doc[] = "This module provides primitive operations to write multi-threaded programs.\n\ ! The 'threading' module provides a more convenient interface."; ! static char lock_doc[] = "A lock object is a synchronization primitive. To create a lock,\n\ call the PyThread_allocate_lock() function. Methods are:\n\ --- 345,353 ---- /* Initialization function */ ! PyDoc_STRVAR(thread_doc, "This module provides primitive operations to write multi-threaded programs.\n\ ! The 'threading' module provides a more convenient interface."); ! PyDoc_STRVAR(lock_doc, "A lock object is a synchronization primitive. To create a lock,\n\ call the PyThread_allocate_lock() function. Methods are:\n\ *************** *** 359,363 **** A lock is not owned by the thread that locked it; another thread may\n\ unlock it. A thread attempting to lock a lock that it has already locked\n\ ! will block until another thread unlocks it. Deadlocks may ensue."; DL_EXPORT(void) --- 359,363 ---- A lock is not owned by the thread that locked it; another thread may\n\ unlock it. A thread attempting to lock a lock that it has already locked\n\ ! will block until another thread unlocks it. Deadlocks may ensue."); DL_EXPORT(void) Index: timemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/timemodule.c,v retrieving revision 2.126 retrieving revision 2.127 diff -C2 -d -r2.126 -r2.127 *** timemodule.c 11 Apr 2002 20:44:06 -0000 2.126 --- timemodule.c 13 Jun 2002 20:32:53 -0000 2.127 *************** *** 117,125 **** } ! static char time_doc[] = "time() -> floating point number\n\ \n\ Return the current time in seconds since the Epoch.\n\ ! Fractions of a second may be present if the system clock provides them."; #ifdef HAVE_CLOCK --- 117,125 ---- } ! PyDoc_STRVAR(time_doc, "time() -> floating point number\n\ \n\ Return the current time in seconds since the Epoch.\n\ ! Fractions of a second may be present if the system clock provides them."); #ifdef HAVE_CLOCK *************** *** 174,182 **** #ifdef HAVE_CLOCK ! static char clock_doc[] = "clock() -> floating point number\n\ \n\ Return the CPU time or real time since the start of the process or since\n\ ! the first call to clock(). This has as much precision as the system records."; #endif --- 174,183 ---- #ifdef HAVE_CLOCK ! PyDoc_STRVAR(clock_doc, "clock() -> floating point number\n\ \n\ Return the CPU time or real time since the start of the process or since\n\ ! the first call to clock(). This has as much precision as the system\n\ ! records."); #endif *************** *** 193,201 **** } ! static char sleep_doc[] = "sleep(seconds)\n\ \n\ Delay execution for a given number of seconds. The argument may be\n\ ! a floating point number for subsecond precision."; static PyStructSequence_Field struct_time_type_fields[] = { --- 194,202 ---- } ! PyDoc_STRVAR(sleep_doc, "sleep(seconds)\n\ \n\ Delay execution for a given number of seconds. The argument may be\n\ ! a floating point number for subsecond precision."); static PyStructSequence_Field struct_time_type_fields[] = { *************** *** 275,284 **** } ! static char gmtime_doc[] = "gmtime([seconds]) -> (tm_year, tm_mon, tm_day, tm_hour, tm_min,\n\ tm_sec, tm_wday, tm_yday, tm_isdst)\n\ \n\ Convert seconds since the Epoch to a time tuple expressing UTC (a.k.a.\n\ ! GMT). When 'seconds' is not passed in, convert the current time instead."; static PyObject * --- 276,285 ---- } ! PyDoc_STRVAR(gmtime_doc, "gmtime([seconds]) -> (tm_year, tm_mon, tm_day, tm_hour, tm_min,\n\ tm_sec, tm_wday, tm_yday, tm_isdst)\n\ \n\ Convert seconds since the Epoch to a time tuple expressing UTC (a.k.a.\n\ ! GMT). When 'seconds' is not passed in, convert the current time instead."); static PyObject * *************** *** 293,301 **** } ! static char localtime_doc[] = "localtime([seconds]) -> (tm_year,tm_mon,tm_day,tm_hour,tm_min,tm_sec,tm_wday,tm_yday,tm_isdst)\n\ \n\ Convert seconds since the Epoch to a time tuple expressing local time.\n\ ! When 'seconds' is not passed in, convert the current time instead."; static int --- 294,302 ---- } ! PyDoc_STRVAR(localtime_doc, "localtime([seconds]) -> (tm_year,tm_mon,tm_day,tm_hour,tm_min,tm_sec,tm_wday,tm_yday,tm_isdst)\n\ \n\ Convert seconds since the Epoch to a time tuple expressing local time.\n\ ! When 'seconds' is not passed in, convert the current time instead."); static int *************** *** 390,399 **** } ! static char strftime_doc[] = "strftime(format[, tuple]) -> string\n\ \n\ Convert a time tuple to a string according to a format specification.\n\ See the library reference manual for formatting codes. When the time tuple\n\ ! is not present, current time as returned by localtime() is used."; #endif /* HAVE_STRFTIME */ --- 391,400 ---- } ! PyDoc_STRVAR(strftime_doc, "strftime(format[, tuple]) -> string\n\ \n\ Convert a time tuple to a string according to a format specification.\n\ See the library reference manual for formatting codes. When the time tuple\n\ ! is not present, current time as returned by localtime() is used."); #endif /* HAVE_STRFTIME */ *************** *** 431,439 **** } ! static char strptime_doc[] = "strptime(string, format) -> tuple\n\ \n\ Parse a string to a time tuple according to a format specification.\n\ ! See the library reference manual for formatting codes (same as strftime())."; #endif /* HAVE_STRPTIME */ --- 432,440 ---- } ! PyDoc_STRVAR(strptime_doc, "strptime(string, format) -> tuple\n\ \n\ Parse a string to a time tuple according to a format specification.\n\ ! See the library reference manual for formatting codes (same as strftime())."); #endif /* HAVE_STRPTIME */ *************** *** 457,466 **** } ! static char asctime_doc[] = "asctime([tuple]) -> string\n\ \n\ Convert a time tuple to a string, e.g. 'Sat Jun 06 16:26:11 1998'.\n\ When the time tuple is not present, current time as returned by localtime()\n\ ! is used."; static PyObject * --- 458,467 ---- } ! PyDoc_STRVAR(asctime_doc, "asctime([tuple]) -> string\n\ \n\ Convert a time tuple to a string, e.g. 'Sat Jun 06 16:26:11 1998'.\n\ When the time tuple is not present, current time as returned by localtime()\n\ ! is used."); static PyObject * *************** *** 488,497 **** } ! static char ctime_doc[] = "ctime(seconds) -> string\n\ \n\ Convert a time in seconds since the Epoch to a string in local time.\n\ This is equivalent to asctime(localtime(seconds)). When the time tuple is\n\ ! not present, current time as returned by localtime() is used."; #ifdef HAVE_MKTIME --- 489,498 ---- } ! PyDoc_STRVAR(ctime_doc, "ctime(seconds) -> string\n\ \n\ Convert a time in seconds since the Epoch to a string in local time.\n\ This is equivalent to asctime(localtime(seconds)). When the time tuple is\n\ ! not present, current time as returned by localtime() is used."); #ifdef HAVE_MKTIME *************** *** 517,524 **** } ! static char mktime_doc[] = "mktime(tuple) -> floating point number\n\ \n\ ! Convert a time tuple in local time to seconds since the Epoch."; #endif /* HAVE_MKTIME */ --- 518,525 ---- } ! PyDoc_STRVAR(mktime_doc, "mktime(tuple) -> floating point number\n\ \n\ ! Convert a time tuple in local time to seconds since the Epoch."); #endif /* HAVE_MKTIME */ *************** *** 546,550 **** ! static char module_doc[] = "This module provides various functions to manipulate time values.\n\ \n\ --- 547,551 ---- ! PyDoc_STRVAR(module_doc, "This module provides various functions to manipulate time values.\n\ \n\ *************** *** 588,593 **** mktime() -- convert local time tuple to seconds since Epoch\n\ strftime() -- convert time tuple to string according to format specification\n\ ! strptime() -- parse string to time tuple according to format specification\n\ ! "; --- 589,593 ---- mktime() -- convert local time tuple to seconds since Epoch\n\ strftime() -- convert time tuple to string according to format specification\n\ ! strptime() -- parse string to time tuple according to format specification"); Index: unicodedata.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/unicodedata.c,v retrieving revision 2.17 retrieving revision 2.18 diff -C2 -d -r2.17 -r2.18 *** unicodedata.c 13 Jun 2002 11:55:14 -0000 2.17 --- unicodedata.c 13 Jun 2002 20:32:53 -0000 2.18 *************** *** 459,463 **** }; ! static char *unicodedata_docstring = "unicode character database"; DL_EXPORT(void) --- 459,463 ---- }; ! PyDoc_STRVAR(unicodedata_docstring, "unicode character database"); DL_EXPORT(void) Index: xreadlinesmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/xreadlinesmodule.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** xreadlinesmodule.c 8 Dec 2001 18:02:58 -0000 1.9 --- xreadlinesmodule.c 13 Jun 2002 20:32:53 -0000 1.10 *************** *** 1,8 **** #include "Python.h" ! static char xreadlines_doc [] = "xreadlines(f)\n\ \n\ ! Return an xreadlines object for the file f."; typedef struct { --- 1,8 ---- #include "Python.h" ! PyDoc_STRVAR(xreadlines_doc, "xreadlines(f)\n\ \n\ ! Return an xreadlines object for the file f."); typedef struct { *************** *** 113,117 **** } ! static char next_doc[] = "x.next() -> the next line or raise StopIteration"; static PyMethodDef xreadlines_methods[] = { --- 113,117 ---- } ! PyDoc_STRVAR(next_doc, "x.next() -> the next line or raise StopIteration"); static PyMethodDef xreadlines_methods[] = { Index: xxsubtype.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/xxsubtype.c,v retrieving revision 2.14 retrieving revision 2.15 diff -C2 -d -r2.14 -r2.15 *** xxsubtype.c 28 Mar 2002 15:49:54 -0000 2.14 --- xxsubtype.c 13 Jun 2002 20:32:54 -0000 2.15 *************** *** 2,10 **** #include "structmember.h" ! static char xxsubtype__doc__[] = "xxsubtype is an example module showing how to subtype builtin types from C.\n" "test_descr.py in the standard test suite requires it in order to complete.\n" "If you don't care about the examples, and don't intend to run the Python\n" ! "test suite, you can recompile Python without Modules/xxsubtype.c."; /* We link this module statically for convenience. If compiled as a shared --- 2,10 ---- #include "structmember.h" ! PyDoc_STRVAR(xxsubtype__doc__, "xxsubtype is an example module showing how to subtype builtin types from C.\n" "test_descr.py in the standard test suite requires it in order to complete.\n" "If you don't care about the examples, and don't intend to run the Python\n" ! "test suite, you can recompile Python without Modules/xxsubtype.c."); /* We link this module statically for convenience. If compiled as a shared Index: zlibmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/zlibmodule.c,v retrieving revision 2.61 retrieving revision 2.62 diff -C2 -d -r2.61 -r2.62 *** zlibmodule.c 27 Apr 2002 18:44:31 -0000 2.61 --- zlibmodule.c 13 Jun 2002 20:32:54 -0000 2.62 *************** *** 79,91 **** } ! static char compressobj__doc__[] = "compressobj([level]) -- Return a compressor object.\n" "\n" ! "Optional arg level is the compression level, in 1-9."; ! static char decompressobj__doc__[] = "decompressobj([wbits]) -- Return a decompressor object.\n" "\n" ! "Optional arg wbits is the window buffer size."; static compobject * --- 79,91 ---- } ! PyDoc_STRVAR(compressobj__doc__, "compressobj([level]) -- Return a compressor object.\n" "\n" ! "Optional arg level is the compression level, in 1-9."); ! PyDoc_STRVAR(decompressobj__doc__, "decompressobj([wbits]) -- Return a decompressor object.\n" "\n" ! "Optional arg wbits is the window buffer size."); static compobject * *************** *** 110,117 **** } ! static char compress__doc__[] = "compress(string[, level]) -- Returned compressed string.\n" "\n" ! "Optional arg level is the compression level, in 1-9."; static PyObject * --- 110,117 ---- } ! PyDoc_STRVAR(compress__doc__, "compress(string[, level]) -- Returned compressed string.\n" "\n" ! "Optional arg level is the compression level, in 1-9."); static PyObject * *************** *** 186,194 **** } ! static char decompress__doc__[] = "decompress(string[, wbits[, bufsize]]) -- Return decompressed string.\n" "\n" "Optional arg wbits is the window buffer size. Optional arg bufsize is\n" ! "the initial output buffer size."; static PyObject * --- 186,194 ---- } ! PyDoc_STRVAR(decompress__doc__, "decompress(string[, wbits[, bufsize]]) -- Return decompressed string.\n" "\n" "Optional arg wbits is the window buffer size. Optional arg bufsize is\n" ! "the initial output buffer size."); static PyObject * *************** *** 377,386 **** } ! static char comp_compress__doc__[] = "compress(data) -- Return a string containing data compressed.\n" "\n" "After calling this function, some of the input data may still\n" "be stored in internal buffers for later processing.\n" ! "Call the flush() method to clear these buffers."; --- 377,386 ---- } ! PyDoc_STRVAR(comp_compress__doc__, "compress(data) -- Return a string containing data compressed.\n" "\n" "After calling this function, some of the input data may still\n" "be stored in internal buffers for later processing.\n" ! "Call the flush() method to clear these buffers."); *************** *** 443,447 **** } ! static char decomp_decompress__doc__[] = "decompress(data, max_length) -- Return a string containing the decompressed\n" "version of the data.\n" --- 443,447 ---- } ! PyDoc_STRVAR(decomp_decompress__doc__, "decompress(data, max_length) -- Return a string containing the decompressed\n" "version of the data.\n" *************** *** 452,456 **** "If the max_length parameter is specified then the return value will be\n" "no longer than max_length. Unconsumed input data will be stored in\n" ! "the unconsumed_tail attribute."; static PyObject * --- 452,456 ---- "If the max_length parameter is specified then the return value will be\n" "no longer than max_length. Unconsumed input data will be stored in\n" ! "the unconsumed_tail attribute."); static PyObject * *************** *** 563,567 **** } ! static char comp_flush__doc__[] = "flush( [mode] ) -- Return a string containing any remaining compressed data.\n" "\n" --- 563,567 ---- } ! PyDoc_STRVAR(comp_flush__doc__, "flush( [mode] ) -- Return a string containing any remaining compressed data.\n" "\n" *************** *** 569,573 **** "default value used when mode is not specified is Z_FINISH.\n" "If mode == Z_FINISH, the compressor object can no longer be used after\n" ! "calling the flush() method. Otherwise, more data can still be compressed.\n"; static PyObject * --- 569,573 ---- "default value used when mode is not specified is Z_FINISH.\n" "If mode == Z_FINISH, the compressor object can no longer be used after\n" ! "calling the flush() method. Otherwise, more data can still be compressed."); static PyObject * *************** *** 650,657 **** } ! static char decomp_flush__doc__[] = "flush() -- Return a string containing any remaining decompressed data.\n" "\n" ! "The decompressor object can no longer be used after this call."; static PyObject * --- 650,657 ---- } ! PyDoc_STRVAR(decomp_flush__doc__, "flush() -- Return a string containing any remaining decompressed data.\n" "\n" ! "The decompressor object can no longer be used after this call."); static PyObject * *************** *** 731,739 **** } ! static char adler32__doc__[] = "adler32(string[, start]) -- Compute an Adler-32 checksum of string.\n" "\n" "An optional starting value can be specified. The returned checksum is\n" ! "an integer."; static PyObject * --- 731,739 ---- } ! PyDoc_STRVAR(adler32__doc__, "adler32(string[, start]) -- Compute an Adler-32 checksum of string.\n" "\n" "An optional starting value can be specified. The returned checksum is\n" ! "an integer."); static PyObject * *************** *** 750,758 **** } ! static char crc32__doc__[] = "crc32(string[, start]) -- Compute a CRC-32 checksum of string.\n" "\n" "An optional starting value can be specified. The returned checksum is\n" ! "an integer."; static PyObject * --- 750,758 ---- } ! PyDoc_STRVAR(crc32__doc__, "crc32(string[, start]) -- Compute a CRC-32 checksum of string.\n" "\n" "An optional starting value can be specified. The returned checksum is\n" ! "an integer."); static PyObject * *************** *** 820,824 **** }; ! static char zlib_module_documentation[]= "The functions in this module allow compression and decompression using the\n" "zlib library, which is based on GNU zip.\n" --- 820,824 ---- }; ! PyDoc_STRVAR(zlib_module_documentation, "The functions in this module allow compression and decompression using the\n" "zlib library, which is based on GNU zip.\n" *************** *** 833,837 **** "'wbits' is window buffer size.\n" "Compressor objects support compress() and flush() methods; decompressor\n" ! "objects support decompress() and flush()."; DL_EXPORT(void) --- 833,837 ---- "'wbits' is window buffer size.\n" "Compressor objects support compress() and flush() methods; decompressor\n" ! "objects support decompress() and flush()."); DL_EXPORT(void) From loewis@users.sourceforge.net Thu Jun 13 22:09:14 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu, 13 Jun 2002 14:09:14 -0700 Subject: [Python-checkins] python/dist/src/RISCOS pyconfig.h,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/RISCOS In directory usw-pr-cvs1:/tmp/cvs-serv30598/RISCOS Modified Files: pyconfig.h Log Message: Patch #568235: Add posix.setpgid. Index: pyconfig.h =================================================================== RCS file: /cvsroot/python/python/dist/src/RISCOS/pyconfig.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pyconfig.h 9 Jun 2002 13:41:37 -0000 1.3 --- pyconfig.h 13 Jun 2002 21:09:11 -0000 1.4 *************** *** 405,408 **** --- 405,411 ---- #undef HAVE_GETPEERNAME + /* Define if you have the getpgid function. */ + #undef HAVE_GETPGID + /* Define if you have the getpgrp function. */ #undef HAVE_GETPGRP From loewis@users.sourceforge.net Thu Jun 13 22:09:14 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu, 13 Jun 2002 14:09:14 -0700 Subject: [Python-checkins] python/dist/src/Modules posixmodule.c,2.235,2.236 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv30598/Modules Modified Files: posixmodule.c Log Message: Patch #568235: Add posix.setpgid. Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.235 retrieving revision 2.236 diff -C2 -d -r2.235 -r2.236 *** posixmodule.c 13 Jun 2002 20:32:50 -0000 2.235 --- posixmodule.c 13 Jun 2002 21:09:08 -0000 2.236 *************** *** 2118,2121 **** --- 2118,2140 ---- #endif + #ifdef HAVE_GETPGID + static char posix_getpgid__doc__[] = + "getpgid(pid) -> pgid\n\ + Call the system call getpgid()."; + + static PyObject * + posix_getpgid(PyObject *self, PyObject *args) + { + int pid, pgid; + if (!PyArg_ParseTuple(args, "i:getpgid", &pid)) + return NULL; + pgid = getpgid(pid); + if (pgid < 0) + return posix_error(); + return PyInt_FromLong((long)pgid); + } + #endif /* HAVE_GETPGID */ + + #ifdef HAVE_GETPGRP PyDoc_STRVAR(posix_getpgrp__doc__, *************** *** 6407,6410 **** --- 6426,6432 ---- {"setgroups", posix_setgroups, METH_VARARGS, posix_setgroups__doc__}, #endif /* HAVE_SETGROUPS */ + #ifdef HAVE_GETPGID + {"getpgid", posix_getpgid, METH_VARARGS, posix_getpgid__doc__}, + #endif /* HAVE_GETPGID */ #ifdef HAVE_SETPGRP {"setpgrp", posix_setpgrp, METH_VARARGS, posix_setpgrp__doc__}, From loewis@users.sourceforge.net Thu Jun 13 22:09:36 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu, 13 Jun 2002 14:09:36 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libos.tex,1.86,1.87 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv30598/Doc/lib Modified Files: libos.tex Log Message: Patch #568235: Add posix.setpgid. Index: libos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.86 retrieving revision 1.87 diff -C2 -d -r1.86 -r1.87 *** libos.tex 10 Jun 2002 19:23:22 -0000 1.86 --- libos.tex 13 Jun 2002 21:09:03 -0000 1.87 *************** *** 145,148 **** --- 145,154 ---- \end{funcdesc} + \begin{funcdesc}{getpgid}{pid} + Return the process group id of the process with process id \var{pid}. + If \var{pid} is 0, the process group id of the current process is + returned. Availability: \UNIX. + \end{funcdesc} + \begin{funcdesc}{getpgrp}{} \index{process!group} From loewis@users.sourceforge.net Thu Jun 13 22:09:36 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu, 13 Jun 2002 14:09:36 -0700 Subject: [Python-checkins] python/dist/src configure,1.313,1.314 configure.in,1.323,1.324 pyconfig.h.in,1.40,1.41 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv30598 Modified Files: configure configure.in pyconfig.h.in Log Message: Patch #568235: Add posix.setpgid. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.313 retrieving revision 1.314 diff -C2 -d -r1.313 -r1.314 *** configure 11 Jun 2002 06:22:30 -0000 1.313 --- configure 13 Jun 2002 21:08:49 -0000 1.314 *************** *** 11450,11454 **** for ac_func in alarm chown chroot clock confstr ctermid ctermid_r execv \ fchdir flock fork fsync fdatasync fpathconf ftime ftruncate \ ! gai_strerror getgroups getlogin getpeername getpid getpwent getwd \ hstrerror inet_pton kill killpg link lstat mkfifo mknod mktime mremap \ nice pathconf pause plock poll pthread_init \ --- 11450,11454 ---- for ac_func in alarm chown chroot clock confstr ctermid ctermid_r execv \ fchdir flock fork fsync fdatasync fpathconf ftime ftruncate \ ! gai_strerror getgroups getlogin getpeername getpgid getpid getpwent getwd \ hstrerror inet_pton kill killpg link lstat mkfifo mknod mktime mremap \ nice pathconf pause plock poll pthread_init \ Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.323 retrieving revision 1.324 diff -C2 -d -r1.323 -r1.324 *** configure.in 11 Jun 2002 06:22:30 -0000 1.323 --- configure.in 13 Jun 2002 21:08:57 -0000 1.324 *************** *** 1622,1626 **** AC_CHECK_FUNCS(alarm chown chroot clock confstr ctermid ctermid_r execv \ fchdir flock fork fsync fdatasync fpathconf ftime ftruncate \ ! gai_strerror getgroups getlogin getpeername getpid getpwent getwd \ hstrerror inet_pton kill killpg link lstat mkfifo mknod mktime mremap \ nice pathconf pause plock poll pthread_init \ --- 1622,1626 ---- AC_CHECK_FUNCS(alarm chown chroot clock confstr ctermid ctermid_r execv \ fchdir flock fork fsync fdatasync fpathconf ftime ftruncate \ ! gai_strerror getgroups getlogin getpeername getpgid getpid getpwent getwd \ hstrerror inet_pton kill killpg link lstat mkfifo mknod mktime mremap \ nice pathconf pause plock poll pthread_init \ Index: pyconfig.h.in =================================================================== RCS file: /cvsroot/python/python/dist/src/pyconfig.h.in,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** pyconfig.h.in 11 Jun 2002 06:22:30 -0000 1.40 --- pyconfig.h.in 13 Jun 2002 21:09:00 -0000 1.41 *************** *** 177,180 **** --- 177,183 ---- #undef HAVE_GETPEERNAME + /* Define to 1 if you have the `getpgid' function. */ + #undef HAVE_GETPGID + /* Define to 1 if you have the `getpgrp' function. */ #undef HAVE_GETPGRP From loewis@users.sourceforge.net Thu Jun 13 22:09:38 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu, 13 Jun 2002 14:09:38 -0700 Subject: [Python-checkins] python/dist/src/Mac/Include pyconfig.h,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Include In directory usw-pr-cvs1:/tmp/cvs-serv30598/Mac/Include Modified Files: pyconfig.h Log Message: Patch #568235: Add posix.setpgid. Index: pyconfig.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Include/pyconfig.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** pyconfig.h 9 Jun 2002 13:41:36 -0000 1.9 --- pyconfig.h 13 Jun 2002 21:09:04 -0000 1.10 *************** *** 452,455 **** --- 452,458 ---- #endif + /* Define if you have the getpgid function. */ + #undef HAVE_GETPGID + /* Define if you have the getpgrp function. */ #undef HAVE_GETPGRP From loewis@users.sourceforge.net Thu Jun 13 22:09:40 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu, 13 Jun 2002 14:09:40 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.425,1.426 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv30598/Misc Modified Files: NEWS Log Message: Patch #568235: Add posix.setpgid. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.425 retrieving revision 1.426 diff -C2 -d -r1.425 -r1.426 *** NEWS 13 Jun 2002 11:41:07 -0000 1.425 --- NEWS 13 Jun 2002 21:09:06 -0000 1.426 *************** *** 115,119 **** written to disk. ! - posix.killpg and posix.mknod have been added where available. - The locale module now exposes the C library's gettext interface. --- 115,120 ---- written to disk. ! - posix.killpg, posix.mknod, and posix.getpgid have been added where ! available. - The locale module now exposes the C library's gettext interface. From nnorwitz@users.sourceforge.net Thu Jun 13 22:11:13 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu, 13 Jun 2002 14:11:13 -0700 Subject: [Python-checkins] python/dist/src/Objects listobject.c,2.111,2.112 tupleobject.c,2.66,2.67 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv31788/Objects Modified Files: listobject.c tupleobject.c Log Message: SF #561244 Micro optimizations Convert loops to memset()s. Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.111 retrieving revision 2.112 diff -C2 -d -r2.111 -r2.112 *** listobject.c 13 Jun 2002 20:33:00 -0000 2.111 --- listobject.c 13 Jun 2002 21:11:08 -0000 2.112 *************** *** 57,61 **** PyList_New(int size) { - int i; PyListObject *op; size_t nbytes; --- 57,60 ---- *************** *** 81,88 **** return PyErr_NoMemory(); } } op->ob_size = size; - for (i = 0; i < size; i++) - op->ob_item[i] = NULL; _PyObject_GC_TRACK(op); return (PyObject *) op; --- 80,86 ---- return PyErr_NoMemory(); } + memset(op->ob_item, 0, sizeof(*op->ob_item) * size); } op->ob_size = size; _PyObject_GC_TRACK(op); return (PyObject *) op; *************** *** 1577,1582 **** goto error; } ! for (i = 0; i < n; i++) ! result->ob_item[i] = NULL; result->ob_size = n; --- 1575,1579 ---- goto error; } ! memset(result->ob_item, 0, sizeof(*result->ob_item) * n); result->ob_size = n; Index: tupleobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/tupleobject.c,v retrieving revision 2.66 retrieving revision 2.67 diff -C2 -d -r2.66 -r2.67 *** tupleobject.c 13 Jun 2002 20:33:01 -0000 2.66 --- tupleobject.c 13 Jun 2002 21:11:09 -0000 2.67 *************** *** 27,31 **** PyTuple_New(register int size) { - register int i; register PyTupleObject *op; if (size < 0) { --- 27,30 ---- *************** *** 72,77 **** return NULL; } ! for (i = 0; i < size; i++) ! op->ob_item[i] = NULL; #if MAXSAVESIZE > 0 if (size == 0) { --- 71,75 ---- return NULL; } ! memset(op->ob_item, 0, sizeof(*op->ob_item) * size); #if MAXSAVESIZE > 0 if (size == 0) { *************** *** 698,703 **** _Py_NewReference((PyObject *) sv); /* Zero out items added by growing */ ! for (i = oldsize; i < newsize; i++) ! sv->ob_item[i] = NULL; *pv = (PyObject *) sv; _PyObject_GC_TRACK(sv); --- 696,702 ---- _Py_NewReference((PyObject *) sv); /* Zero out items added by growing */ ! if (newsize > oldsize) ! memset(sv->ob_item, 0, ! sizeof(*sv->ob_item) * (newsize - oldsize)); *pv = (PyObject *) sv; _PyObject_GC_TRACK(sv); From nnorwitz@users.sourceforge.net Thu Jun 13 22:11:16 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu, 13 Jun 2002 14:11:16 -0700 Subject: [Python-checkins] python/dist/src/Modules _sre.c,2.79,2.80 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv31788/Modules Modified Files: _sre.c Log Message: SF #561244 Micro optimizations Convert loops to memset()s. Index: _sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.79 retrieving revision 2.80 diff -C2 -d -r2.79 -r2.80 *** _sre.c 31 Mar 2002 15:46:00 -0000 2.79 --- _sre.c 13 Jun 2002 21:11:11 -0000 2.80 *************** *** 1377,1387 **** state_reset(SRE_STATE* state) { - int i; - state->lastmark = 0; /* FIXME: dynamic! */ ! for (i = 0; i < SRE_MARK_SIZE; i++) ! state->mark[i] = NULL; state->lastindex = -1; --- 1377,1384 ---- state_reset(SRE_STATE* state) { state->lastmark = 0; /* FIXME: dynamic! */ ! memset(state->mark, 0, sizeof(*state->mark) * SRE_MARK_SIZE); state->lastindex = -1; From nnorwitz@users.sourceforge.net Thu Jun 13 22:19:28 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu, 13 Jun 2002 14:19:28 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libos.tex,1.87,1.88 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv3047/Doc/lib Modified Files: libos.tex Log Message: Add "version added" for getpgid Index: libos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.87 retrieving revision 1.88 diff -C2 -d -r1.87 -r1.88 *** libos.tex 13 Jun 2002 21:09:03 -0000 1.87 --- libos.tex 13 Jun 2002 21:19:25 -0000 1.88 *************** *** 149,152 **** --- 149,153 ---- If \var{pid} is 0, the process group id of the current process is returned. Availability: \UNIX. + \versionadded{2.3} \end{funcdesc} From nnorwitz@users.sourceforge.net Thu Jun 13 22:22:14 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu, 13 Jun 2002 14:22:14 -0700 Subject: [Python-checkins] python/dist/src/Modules posixmodule.c,2.236,2.237 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv4266/Modules Modified Files: posixmodule.c Log Message: Use new PyDoc_STRVAR macro Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.236 retrieving revision 2.237 diff -C2 -d -r2.236 -r2.237 *** posixmodule.c 13 Jun 2002 21:09:08 -0000 2.236 --- posixmodule.c 13 Jun 2002 21:22:11 -0000 2.237 *************** *** 2119,2125 **** #ifdef HAVE_GETPGID ! static char posix_getpgid__doc__[] = "getpgid(pid) -> pgid\n\ ! Call the system call getpgid()."; static PyObject * --- 2119,2125 ---- #ifdef HAVE_GETPGID ! PyDoc_STRVAR(posix_getpgid__doc__, "getpgid(pid) -> pgid\n\ ! Call the system call getpgid()."); static PyObject * From nnorwitz@users.sourceforge.net Thu Jun 13 22:25:19 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu, 13 Jun 2002 14:25:19 -0700 Subject: [Python-checkins] python/dist/src/Objects unicodeobject.c,2.153,2.154 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv5288/Objects Modified Files: unicodeobject.c Log Message: Fix typo in exception message Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.153 retrieving revision 2.154 diff -C2 -d -r2.153 -r2.154 *** unicodeobject.c 13 Jun 2002 20:33:01 -0000 2.153 --- unicodeobject.c 13 Jun 2002 21:25:17 -0000 2.154 *************** *** 5133,5137 **** { PyErr_SetString(PyExc_TypeError, ! "cannot use unicode as modifyable buffer"); return -1; } --- 5133,5137 ---- { PyErr_SetString(PyExc_TypeError, ! "cannot use unicode as modifiable buffer"); return -1; } From gvanrossum@users.sourceforge.net Thu Jun 13 22:31:53 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 13 Jun 2002 14:31:53 -0700 Subject: [Python-checkins] python/dist/src/Objects classobject.c,2.154,2.155 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv7570 Modified Files: classobject.c Log Message: Fix for SF bug 532646. This is a little simpler than what Neal suggested there, based upon a better analysis (__getattr__ is a red herring). Will backport to 2.2. Index: classobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v retrieving revision 2.154 retrieving revision 2.155 diff -C2 -d -r2.154 -r2.155 *** classobject.c 26 Oct 2001 17:56:51 -0000 2.154 --- classobject.c 13 Jun 2002 21:31:27 -0000 2.155 *************** *** 1880,1883 **** --- 1880,1884 ---- instance_call(PyObject *func, PyObject *arg, PyObject *kw) { + PyThreadState *tstate = PyThreadState_GET(); PyObject *res, *call = PyObject_GetAttrString(func, "__call__"); if (call == NULL) { *************** *** 1889,1893 **** return NULL; } ! res = PyObject_Call(call, arg, kw); Py_DECREF(call); return res; --- 1890,1909 ---- return NULL; } ! /* We must check and increment the recursion depth here. Scenario: ! class A: ! pass ! A.__call__ = A() # that's right ! a = A() # ok ! a() # infinite recursion ! This bounces between instance_call() and PyObject_Call() without ! ever hitting eval_frame() (which has the main recursion check). */ ! if (tstate->recursion_depth++ > Py_GetRecursionLimit()) { ! PyErr_SetString(PyExc_RuntimeError, ! "maximum __call__ recursion depth exceeded"); ! res = NULL; ! } ! else ! res = PyObject_Call(call, arg, kw); ! tstate->recursion_depth--; Py_DECREF(call); return res; From nnorwitz@users.sourceforge.net Thu Jun 13 22:32:46 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu, 13 Jun 2002 14:32:46 -0700 Subject: [Python-checkins] python/dist/src/Objects object.c,2.177,2.178 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv7685/Objects Modified Files: object.c Log Message: SF # 561244 Micro optimizations Cleanup code a bit and return as early as possible. Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.177 retrieving revision 2.178 diff -C2 -d -r2.177 -r2.178 *** object.c 31 May 2002 20:23:33 -0000 2.177 --- object.c 13 Jun 2002 21:32:44 -0000 2.178 *************** *** 1436,1440 **** int res; if (v == Py_None) ! res = 0; else if (v->ob_type->tp_as_number != NULL && v->ob_type->tp_as_number->nb_nonzero != NULL) --- 1436,1440 ---- int res; if (v == Py_None) ! return 0; else if (v->ob_type->tp_as_number != NULL && v->ob_type->tp_as_number->nb_nonzero != NULL) *************** *** 1447,1454 **** res = (*v->ob_type->tp_as_sequence->sq_length)(v); else ! res = 1; ! if (res > 0) ! res = 1; ! return res; } --- 1447,1452 ---- res = (*v->ob_type->tp_as_sequence->sq_length)(v); else ! return 1; ! return (res > 0) ? 1 : res; } From gvanrossum@users.sourceforge.net Thu Jun 13 22:32:53 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 13 Jun 2002 14:32:53 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_class.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv8144 Modified Files: test_class.py Log Message: Fix for SF bug 532646. This is a little simpler than what Neal suggested there, based upon a better analysis (__getattr__ is a red herring). Will backport to 2.2. Index: test_class.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_class.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** test_class.py 11 Dec 2001 19:28:47 -0000 1.7 --- test_class.py 13 Jun 2002 21:32:51 -0000 1.8 *************** *** 275,276 **** --- 275,290 ---- except TypeError: pass else: raise TestFailed, "hash(C2()) should raise an exception" + + + # Test for SF bug 532646 + + class A: + pass + A.__call__ = A() + a = A() + try: + a() # This should not segfault + except RuntimeError: + pass + else: + raise TestFailed, "how could this not have overflowed the stack?" From gvanrossum@users.sourceforge.net Thu Jun 13 22:36:37 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 13 Jun 2002 14:36:37 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_class.py,1.7,1.7.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv9305/Lib/test Modified Files: Tag: release22-maint test_class.py Log Message: Backport: Fix for SF bug 532646. This is a little simpler than what Neal suggested there, based upon a better analysis (__getattr__ is a red herring). [This might be a 2.1 bugfix candidate we well, if people care] Index: test_class.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_class.py,v retrieving revision 1.7 retrieving revision 1.7.6.1 diff -C2 -d -r1.7 -r1.7.6.1 *** test_class.py 11 Dec 2001 19:28:47 -0000 1.7 --- test_class.py 13 Jun 2002 21:36:35 -0000 1.7.6.1 *************** *** 275,276 **** --- 275,290 ---- except TypeError: pass else: raise TestFailed, "hash(C2()) should raise an exception" + + + # Test for SF bug 532646 + + class A: + pass + A.__call__ = A() + a = A() + try: + a() # This should not segfault + except RuntimeError: + pass + else: + raise TestFailed, "how could this not have overflowed the stack?" From gvanrossum@users.sourceforge.net Thu Jun 13 22:36:38 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 13 Jun 2002 14:36:38 -0700 Subject: [Python-checkins] python/dist/src/Objects classobject.c,2.154,2.154.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv9305/Objects Modified Files: Tag: release22-maint classobject.c Log Message: Backport: Fix for SF bug 532646. This is a little simpler than what Neal suggested there, based upon a better analysis (__getattr__ is a red herring). [This might be a 2.1 bugfix candidate we well, if people care] Index: classobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v retrieving revision 2.154 retrieving revision 2.154.8.1 diff -C2 -d -r2.154 -r2.154.8.1 *** classobject.c 26 Oct 2001 17:56:51 -0000 2.154 --- classobject.c 13 Jun 2002 21:36:35 -0000 2.154.8.1 *************** *** 1880,1883 **** --- 1880,1884 ---- instance_call(PyObject *func, PyObject *arg, PyObject *kw) { + PyThreadState *tstate = PyThreadState_GET(); PyObject *res, *call = PyObject_GetAttrString(func, "__call__"); if (call == NULL) { *************** *** 1889,1893 **** return NULL; } ! res = PyObject_Call(call, arg, kw); Py_DECREF(call); return res; --- 1890,1909 ---- return NULL; } ! /* We must check and increment the recursion depth here. Scenario: ! class A: ! pass ! A.__call__ = A() # that's right ! a = A() # ok ! a() # infinite recursion ! This bounces between instance_call() and PyObject_Call() without ! ever hitting eval_frame() (which has the main recursion check). */ ! if (tstate->recursion_depth++ > Py_GetRecursionLimit()) { ! PyErr_SetString(PyExc_RuntimeError, ! "maximum __call__ recursion depth exceeded"); ! res = NULL; ! } ! else ! res = PyObject_Call(call, arg, kw); ! tstate->recursion_depth--; Py_DECREF(call); return res; From nnorwitz@users.sourceforge.net Thu Jun 13 22:39:49 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu, 13 Jun 2002 14:39:49 -0700 Subject: [Python-checkins] python/dist/src/Objects object.c,2.162.6.3,2.162.6.4 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv10541/Objects Modified Files: Tag: release22-maint object.c Log Message: SF # 533070 Silence AIX C Compiler Warnings Warning caused by using &func. & is not necessary. Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.162.6.3 retrieving revision 2.162.6.4 diff -C2 -d -r2.162.6.3 -r2.162.6.4 *** object.c 13 May 2002 18:30:40 -0000 2.162.6.3 --- object.c 13 Jun 2002 21:39:47 -0000 2.162.6.4 *************** *** 1885,1889 **** /* Hack to force loading of abstract.o */ ! int (*_Py_abstract_hack)(PyObject *) = &PyObject_Size; --- 1885,1889 ---- /* Hack to force loading of abstract.o */ ! int (*_Py_abstract_hack)(PyObject *) = PyObject_Size; From nnorwitz@users.sourceforge.net Thu Jun 13 22:39:49 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu, 13 Jun 2002 14:39:49 -0700 Subject: [Python-checkins] python/dist/src/Modules signalmodule.c,2.60.10.1,2.60.10.2 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv10541/Modules Modified Files: Tag: release22-maint signalmodule.c Log Message: SF # 533070 Silence AIX C Compiler Warnings Warning caused by using &func. & is not necessary. Index: signalmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/signalmodule.c,v retrieving revision 2.60.10.1 retrieving revision 2.60.10.2 diff -C2 -d -r2.60.10.1 -r2.60.10.2 *** signalmodule.c 12 Jan 2002 11:13:23 -0000 2.60.10.1 --- signalmodule.c 13 Jun 2002 21:39:47 -0000 2.60.10.2 *************** *** 367,371 **** Py_DECREF(Handlers[SIGINT].func); Handlers[SIGINT].func = IntHandler; ! old_siginthandler = PyOS_setsig(SIGINT, &signal_handler); } --- 367,371 ---- Py_DECREF(Handlers[SIGINT].func); Handlers[SIGINT].func = IntHandler; ! old_siginthandler = PyOS_setsig(SIGINT, signal_handler); } From gvanrossum@users.sourceforge.net Thu Jun 13 22:42:07 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 13 Jun 2002 14:42:07 -0700 Subject: [Python-checkins] python/dist/src/Objects classobject.c,2.155,2.156 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv11611 Modified Files: classobject.c Log Message: Major cleanup operation: whenever there's a call that looks for an optional attribute, only clear the exception when the internal getattr operation raised AttributeError. Many places in this file already had that policy; but just as many didn't, and there didn't seem to be any rhyme or reason to it. Be consistently cautious. Question: should I backport this? On the one hand it's a bugfix. On the other hand it's a change in behavior. Certain forms of buggy or just weird code would work in the past but raise an exception under the new rules; e.g. if you define a __getattr__ method that raises a non-AttributeError exception. Index: classobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v retrieving revision 2.155 retrieving revision 2.156 diff -C2 -d -r2.155 -r2.156 *** classobject.c 13 Jun 2002 21:31:27 -0000 2.155 --- classobject.c 13 Jun 2002 21:42:04 -0000 2.156 *************** *** 716,719 **** --- 716,721 ---- if (res == NULL && (func = inst->in_class->cl_getattr) != NULL) { PyObject *args; + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) + return NULL; PyErr_Clear(); args = Py_BuildValue("(OO)", inst, name); *************** *** 817,829 **** func = instance_getattr(inst, reprstr); if (func == NULL) { ! PyObject *classname = inst->in_class->cl_name; ! PyObject *mod = PyDict_GetItemString( ! inst->in_class->cl_dict, "__module__"); char *cname; if (classname != NULL && PyString_Check(classname)) cname = PyString_AsString(classname); else cname = "?"; - PyErr_Clear(); if (mod == NULL || !PyString_Check(mod)) return PyString_FromFormat("", --- 819,834 ---- func = instance_getattr(inst, reprstr); if (func == NULL) { ! PyObject *classname, *mod; char *cname; + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) + return NULL; + PyErr_Clear(); + classname = inst->in_class->cl_name; + mod = PyDict_GetItemString(inst->in_class->cl_dict, + "__module__"); if (classname != NULL && PyString_Check(classname)) cname = PyString_AsString(classname); else cname = "?"; if (mod == NULL || !PyString_Check(mod)) return PyString_FromFormat("", *************** *** 850,853 **** --- 855,860 ---- func = instance_getattr(inst, strstr); if (func == NULL) { + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) + return NULL; PyErr_Clear(); return instance_repr(inst); *************** *** 870,881 **** func = instance_getattr(inst, hashstr); if (func == NULL) { /* If there is no __eq__ and no __cmp__ method, we hash on the address. If an __eq__ or __cmp__ method exists, there must be a __hash__. */ - PyErr_Clear(); if (eqstr == NULL) eqstr = PyString_InternFromString("__eq__"); func = instance_getattr(inst, eqstr); if (func == NULL) { PyErr_Clear(); if (cmpstr == NULL) --- 877,892 ---- func = instance_getattr(inst, hashstr); if (func == NULL) { + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) + return -1; + PyErr_Clear(); /* If there is no __eq__ and no __cmp__ method, we hash on the address. If an __eq__ or __cmp__ method exists, there must be a __hash__. */ if (eqstr == NULL) eqstr = PyString_InternFromString("__eq__"); func = instance_getattr(inst, eqstr); if (func == NULL) { + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) + return -1; PyErr_Clear(); if (cmpstr == NULL) *************** *** 883,886 **** --- 894,900 ---- func = instance_getattr(inst, cmpstr); if (func == NULL) { + if (!PyErr_ExceptionMatches( + PyExc_AttributeError)) + return -1; PyErr_Clear(); return _Py_HashPointer(inst); *************** *** 1077,1080 **** --- 1091,1096 ---- if (func == NULL) { + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) + return NULL; PyErr_Clear(); *************** *** 1144,1147 **** --- 1160,1165 ---- func = instance_getattr(inst, delslicestr); if (func == NULL) { + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) + return -1; PyErr_Clear(); if (delitemstr == NULL) *************** *** 1163,1166 **** --- 1181,1186 ---- func = instance_getattr(inst, setslicestr); if (func == NULL) { + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) + return -1; PyErr_Clear(); if (setitemstr == NULL) *************** *** 1310,1313 **** --- 1330,1335 ---- coercefunc = PyObject_GetAttr(v, coerce_obj); if (coercefunc == NULL) { + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) + return NULL; PyErr_Clear(); return generic_binary_op(v, w, opname); *************** *** 1392,1395 **** --- 1414,1419 ---- if (coercefunc == NULL) { /* No __coerce__ method */ + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) + return -1; PyErr_Clear(); return 1; *************** *** 1503,1506 **** --- 1527,1532 ---- cmp_func = PyObject_GetAttr(v, cmp_obj); if (cmp_func == NULL) { + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) + return -2; PyErr_Clear(); return 2; *************** *** 1602,1609 **** --- 1628,1639 ---- nonzerostr = PyString_InternFromString("__nonzero__"); if ((func = instance_getattr(self, nonzerostr)) == NULL) { + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) + return -1; PyErr_Clear(); if (lenstr == NULL) lenstr = PyString_InternFromString("__len__"); if ((func = instance_getattr(self, lenstr)) == NULL) { + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) + return -1; PyErr_Clear(); /* Fall back to the default behavior: *************** *** 1824,1831 **** PyObject *func; ! if (iterstr == NULL) iterstr = PyString_InternFromString("__iter__"); ! if (getitemstr == NULL) getitemstr = PyString_InternFromString("__getitem__"); if ((func = instance_getattr(self, iterstr)) != NULL) { --- 1854,1867 ---- PyObject *func; ! if (iterstr == NULL) { iterstr = PyString_InternFromString("__iter__"); ! if (iterstr == NULL) ! return NULL; ! } ! if (getitemstr == NULL) { getitemstr = PyString_InternFromString("__getitem__"); + if (getitemstr == NULL) + return NULL; + } if ((func = instance_getattr(self, iterstr)) != NULL) { *************** *** 1842,1848 **** return res; } PyErr_Clear(); if ((func = instance_getattr(self, getitemstr)) == NULL) { ! PyErr_SetString(PyExc_TypeError, "iteration over non-sequence"); return NULL; } --- 1878,1887 ---- return res; } + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) + return NULL; PyErr_Clear(); if ((func = instance_getattr(self, getitemstr)) == NULL) { ! PyErr_SetString(PyExc_TypeError, ! "iteration over non-sequence"); return NULL; } *************** *** 1884,1887 **** --- 1923,1928 ---- if (call == NULL) { PyInstanceObject *inst = (PyInstanceObject*) func; + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) + return NULL; PyErr_Clear(); PyErr_Format(PyExc_AttributeError, *************** *** 2116,2121 **** funcname = PyObject_GetAttrString(func, "__name__"); ! if (funcname == NULL) PyErr_Clear(); else if (!PyString_Check(funcname)) { Py_DECREF(funcname); --- 2157,2165 ---- funcname = PyObject_GetAttrString(func, "__name__"); ! if (funcname == NULL) { ! if (!PyErr_ExceptionMatches(PyExc_AttributeError)) ! return NULL; PyErr_Clear(); + } else if (!PyString_Check(funcname)) { Py_DECREF(funcname); *************** *** 2128,2133 **** else { klassname = PyObject_GetAttrString(klass, "__name__"); ! if (klassname == NULL) PyErr_Clear(); else if (!PyString_Check(klassname)) { Py_DECREF(klassname); --- 2172,2180 ---- else { klassname = PyObject_GetAttrString(klass, "__name__"); ! if (klassname == NULL) { ! if (!PyErr_ExceptionMatches(PyExc_AttributeError)) ! return NULL; PyErr_Clear(); + } else if (!PyString_Check(klassname)) { Py_DECREF(klassname); *************** *** 2208,2211 **** --- 2255,2259 ---- name = PyObject_GetAttrString(class, "__name__"); if (name == NULL) { + /* This function cannot return an exception */ PyErr_Clear(); return "?"; *************** *** 2231,2234 **** --- 2279,2283 ---- class = PyObject_GetAttrString(inst, "__class__"); if (class == NULL) { + /* This function cannot return an exception */ PyErr_Clear(); class = (PyObject *)(inst->ob_type); From nnorwitz@users.sourceforge.net Thu Jun 13 22:42:53 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu, 13 Jun 2002 14:42:53 -0700 Subject: [Python-checkins] python/dist/src/Objects object.c,2.178,2.179 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv12063/Objects Modified Files: object.c Log Message: SF # 533070 Silence AIX C Compiler Warnings Warning caused by using &func. & is not necessary. Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.178 retrieving revision 2.179 diff -C2 -d -r2.178 -r2.179 *** object.c 13 Jun 2002 21:32:44 -0000 2.178 --- object.c 13 Jun 2002 21:42:51 -0000 2.179 *************** *** 1954,1958 **** /* Hack to force loading of abstract.o */ ! int (*_Py_abstract_hack)(PyObject *) = &PyObject_Size; --- 1954,1958 ---- /* Hack to force loading of abstract.o */ ! int (*_Py_abstract_hack)(PyObject *) = PyObject_Size; From nnorwitz@users.sourceforge.net Thu Jun 13 22:42:54 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu, 13 Jun 2002 14:42:54 -0700 Subject: [Python-checkins] python/dist/src/Modules signalmodule.c,2.68,2.69 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv12063/Modules Modified Files: signalmodule.c Log Message: SF # 533070 Silence AIX C Compiler Warnings Warning caused by using &func. & is not necessary. Index: signalmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/signalmodule.c,v retrieving revision 2.68 retrieving revision 2.69 diff -C2 -d -r2.68 -r2.69 *** signalmodule.c 13 Jun 2002 20:32:52 -0000 2.68 --- signalmodule.c 13 Jun 2002 21:42:51 -0000 2.69 *************** *** 523,527 **** Py_DECREF(Handlers[SIGINT].func); Handlers[SIGINT].func = IntHandler; ! old_siginthandler = PyOS_setsig(SIGINT, &signal_handler); } --- 523,527 ---- Py_DECREF(Handlers[SIGINT].func); Handlers[SIGINT].func = IntHandler; ! old_siginthandler = PyOS_setsig(SIGINT, signal_handler); } From nnorwitz@users.sourceforge.net Thu Jun 13 23:18:41 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu, 13 Jun 2002 15:18:41 -0700 Subject: [Python-checkins] python/dist/src/Lib socket.py,1.20,1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv25865/Lib Modified Files: socket.py Log Message: Cleanup a little Index: socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/socket.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** socket.py 6 Jun 2002 21:08:16 -0000 1.20 --- socket.py 13 Jun 2002 22:18:39 -0000 1.21 *************** *** 198,202 **** self._wbuf = [ ] ! def fileno (self): return self._sock.fileno() --- 198,202 ---- self._wbuf = [ ] ! def fileno(self): return self._sock.fileno() *************** *** 236,246 **** buf_len += len(data) self._rbuf.append(data) - data = ''.join(self._rbuf) # Clear the rbuf at the end so we're not affected by # an exception during a recv self._rbuf = [ ] if buf_len > size and size >= 0: ! self._rbuf.append(data[size:]) ! data = data[:size] return data --- 236,246 ---- buf_len += len(data) self._rbuf.append(data) # Clear the rbuf at the end so we're not affected by # an exception during a recv + data = ''.join(self._rbuf) self._rbuf = [ ] if buf_len > size and size >= 0: ! self._rbuf.append(data[size:]) ! data = data[:size] return data *************** *** 248,252 **** index = -1 buf_len = self.__get_rbuf_len() ! if len (self._rbuf): index = min([x.find('\n') for x in self._rbuf]) while index < 0 and (size < 0 or buf_len < size): --- 248,252 ---- index = -1 buf_len = self.__get_rbuf_len() ! if self._rbuf: index = min([x.find('\n') for x in self._rbuf]) while index < 0 and (size < 0 or buf_len < size): *************** *** 276,280 **** while 1: line = self.readline() ! if not line: break list.append(line) total += len(line) --- 276,281 ---- while 1: line = self.readline() ! if not line: ! break list.append(line) total += len(line) From nnorwitz@users.sourceforge.net Thu Jun 13 23:23:08 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu, 13 Jun 2002 15:23:08 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_types.py,1.31,1.32 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv27442/Lib/test Modified Files: test_types.py Log Message: Test exceptional conditions in list.sort() Index: test_types.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_types.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** test_types.py 11 Jun 2002 13:38:42 -0000 1.31 --- test_types.py 13 Jun 2002 22:23:06 -0000 1.32 *************** *** 354,357 **** --- 354,372 ---- z.sort(myComparison) + try: z.sort(2) + except TypeError: pass + else: raise TestFailed, 'list sort compare function is not callable' + + def selfmodifyingComparison(x,y): + z[0] = 1 + return cmp(x, y) + try: z.sort(selfmodifyingComparison) + except TypeError: pass + else: raise TestFailed, 'modifying list during sort' + + try: z.sort(lambda x, y: 's') + except TypeError: pass + else: raise TestFailed, 'list sort compare function does not return int' + # Test extreme cases with long ints a = [0,1,2,3,4] From nnorwitz@users.sourceforge.net Thu Jun 13 23:23:49 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu, 13 Jun 2002 15:23:49 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_select.py,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv27706/Lib/test Modified Files: test_select.py Log Message: Test exceptional condition in select() Index: test_select.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_select.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** test_select.py 17 Jan 2001 21:51:36 -0000 1.13 --- test_select.py 13 Jun 2002 22:23:47 -0000 1.14 *************** *** 33,36 **** --- 33,43 ---- print 'expected TypeError exception not raised' + try: + rfd, wfd, xfd = select.select([], [], [], 'not a number') + except TypeError: + pass + else: + print 'expected TypeError exception not raised' + def test(): From nnorwitz@users.sourceforge.net Fri Jun 14 01:27:16 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu, 13 Jun 2002 17:27:16 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libstdtypes.tex,1.96,1.97 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv4021/Doc/lib Modified Files: libstdtypes.tex Log Message: Use \code{True} (or False) instead of true/false. Not sure if code is correct, but that is what's in this file. I've seen \constant{True} in other places. Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.96 retrieving revision 1.97 diff -C2 -d -r1.96 -r1.97 *** libstdtypes.tex 11 Jun 2002 10:55:08 -0000 1.96 --- libstdtypes.tex 14 Jun 2002 00:27:13 -0000 1.97 *************** *** 548,553 **** \begin{methoddesc}[string]{endswith}{suffix\optional{, start\optional{, end}}} ! Return true if the string ends with the specified \var{suffix}, ! otherwise return false. With optional \var{start}, test beginning at that position. With optional \var{end}, stop comparing at that position. \end{methoddesc} --- 548,553 ---- \begin{methoddesc}[string]{endswith}{suffix\optional{, start\optional{, end}}} ! Return \code{True} if the string ends with the specified \var{suffix}, ! otherwise return \code{False}. With optional \var{start}, test beginning at that position. With optional \var{end}, stop comparing at that position. \end{methoddesc} *************** *** 679,684 **** \begin{methoddesc}[string]{startswith}{prefix\optional{, start\optional{, end}}} ! Return true if string starts with the \var{prefix}, otherwise ! return false. With optional \var{start}, test string beginning at that position. With optional \var{end}, stop comparing string at that position. --- 679,684 ---- \begin{methoddesc}[string]{startswith}{prefix\optional{, start\optional{, end}}} ! Return \code{True} if string starts with the \var{prefix}, otherwise ! return \code{False}. With optional \var{start}, test string beginning at that position. With optional \var{end}, stop comparing string at that position. From fdrake@users.sourceforge.net Fri Jun 14 01:33:04 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu, 13 Jun 2002 17:33:04 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libxmlrpclib.tex,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv6085/lib Modified Files: libxmlrpclib.tex Log Message: Document the Binary.data attribute. This closes SF bug #562878. Index: libxmlrpclib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libxmlrpclib.tex,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** libxmlrpclib.tex 17 Mar 2002 23:15:02 -0000 1.8 --- libxmlrpclib.tex 14 Jun 2002 00:33:02 -0000 1.9 *************** *** 178,189 **** This class may initialized from string data (which may include NULs). ! It has the following methods, supported mainly for internal use by the ! marshalling/unmarshalling code: ! \begin{methoddesc}{decode}{string} Accept a base64 string and decode it as the instance's new data. \end{methoddesc} ! \begin{methoddesc}{encode}{out} Write the XML-RPC base 64 encoding of this binary item to the out stream object. --- 178,197 ---- This class may initialized from string data (which may include NULs). ! The primary acess to the content of a \class{Binary} object is ! provided by an attribute: ! \begin{memberdesc}[Binary]{data} ! The binary data encapsulated by the \class{Binary} instance. The data ! is provided as an 8-bit string. ! \end{memberdesc} ! ! \class{Binary} objects have the following methods, supported mainly ! for internal use by the marshalling/unmarshalling code: ! ! \begin{methoddesc}[Binary]{decode}{string} Accept a base64 string and decode it as the instance's new data. \end{methoddesc} ! \begin{methoddesc}[Binary]{encode}{out} Write the XML-RPC base 64 encoding of this binary item to the out stream object. *************** *** 191,195 **** It also supports certain of Python's built-in operators through a ! \method{_cmp__} method. --- 199,203 ---- It also supports certain of Python's built-in operators through a ! \method{_cmp__()} method. From fdrake@users.sourceforge.net Fri Jun 14 01:33:19 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu, 13 Jun 2002 17:33:19 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libxmlrpclib.tex,1.5.10.2,1.5.10.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv6223/lib Modified Files: Tag: release22-maint libxmlrpclib.tex Log Message: Document the Binary.data attribute. This closes SF bug #562878. Index: libxmlrpclib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libxmlrpclib.tex,v retrieving revision 1.5.10.2 retrieving revision 1.5.10.3 diff -C2 -d -r1.5.10.2 -r1.5.10.3 *** libxmlrpclib.tex 17 Mar 2002 19:05:18 -0000 1.5.10.2 --- libxmlrpclib.tex 14 Jun 2002 00:33:17 -0000 1.5.10.3 *************** *** 176,187 **** This class may initialized from string data (which may include NULs). ! It has the following methods, supported mainly for internal use by the ! marshalling/unmarshalling code: ! \begin{methoddesc}{decode}{string} Accept a base64 string and decode it as the instance's new data. \end{methoddesc} ! \begin{methoddesc}{encode}{out} Write the XML-RPC base 64 encoding of this binary item to the out stream object. --- 176,195 ---- This class may initialized from string data (which may include NULs). ! The primary acess to the content of a \class{Binary} object is ! provided by an attribute: ! \begin{memberdesc}[Binary]{data} ! The binary data encapsulated by the \class{Binary} instance. The data ! is provided as an 8-bit string. ! \end{memberdesc} ! ! \class{Binary} objects have the following methods, supported mainly ! for internal use by the marshalling/unmarshalling code: ! ! \begin{methoddesc}[Binary]{decode}{string} Accept a base64 string and decode it as the instance's new data. \end{methoddesc} ! \begin{methoddesc}[Binary]{encode}{out} Write the XML-RPC base 64 encoding of this binary item to the out stream object. *************** *** 189,193 **** It also supports certain of Python's built-in operators through a ! \method{_cmp__} method. --- 197,201 ---- It also supports certain of Python's built-in operators through a ! \method{_cmp__()} method. From nnorwitz@users.sourceforge.net Fri Jun 14 01:50:44 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu, 13 Jun 2002 17:50:44 -0700 Subject: [Python-checkins] python/dist/src/Objects stringobject.c,2.167,2.168 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv11051/Objects Modified Files: stringobject.c Log Message: SF bug # 493951 string.{starts,ends}with vs slices Handle negative indices similar to slices. Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.167 retrieving revision 2.168 diff -C2 -d -r2.167 -r2.168 *** stringobject.c 13 Jun 2002 20:33:01 -0000 2.167 --- stringobject.c 14 Jun 2002 00:50:41 -0000 2.168 *************** *** 1311,1314 **** --- 1311,1329 ---- } + static void + string_adjust_indices(int *start, int *end, int len) + { + if (*end > len) + *end = len; + else if (*end < 0) + *end += len; + if (*end < 0) + *end = 0; + if (*start < 0) + *start += len; + if (*start < 0) + *start = 0; + } + static long string_find_internal(PyStringObject *self, PyObject *args, int dir) *************** *** 1333,1346 **** return -2; ! if (last > len) ! last = len; ! if (last < 0) ! last += len; ! if (last < 0) ! last = 0; ! if (i < 0) ! i += len; ! if (i < 0) ! i = 0; if (dir > 0) { --- 1348,1352 ---- return -2; ! string_adjust_indices(&i, &last, len); if (dir > 0) { *************** *** 1764,1777 **** return NULL; ! if (last > len) ! last = len; ! if (last < 0) ! last += len; ! if (last < 0) ! last = 0; ! if (i < 0) ! i += len; ! if (i < 0) ! i = 0; m = last + 1 - n; if (n == 0) --- 1770,1775 ---- return NULL; ! string_adjust_indices(&i, &last, len); ! m = last + 1 - n; if (n == 0) *************** *** 2170,2174 **** int plen; int start = 0; ! int end = -1; PyObject *subobj; --- 2168,2172 ---- int plen; int start = 0; ! int end = INT_MAX; PyObject *subobj; *************** *** 2194,2214 **** return NULL; ! /* adopt Java semantics for index out of range. it is legal for ! * offset to be == plen, but this only returns true if prefix is ! * the empty string. ! */ ! if (start < 0 || start+plen > len) return PyBool_FromLong(0); ! if (!memcmp(str+start, prefix, plen)) { ! /* did the match end after the specified end? */ ! if (end < 0) ! return PyBool_FromLong(1); ! else if (end - start < plen) ! return PyBool_FromLong(0); ! else ! return PyBool_FromLong(1); ! } ! else return PyBool_FromLong(0); } --- 2192,2204 ---- return NULL; ! string_adjust_indices(&start, &end, len); ! ! if (start+plen > len) return PyBool_FromLong(0); ! if (end-start >= plen) ! return PyBool_FromLong(!memcmp(str+start, prefix, plen)); ! else ! return PyBool_FromLong(0); } *************** *** 2229,2234 **** int slen; int start = 0; ! int end = -1; ! int lower, upper; PyObject *subobj; --- 2219,2223 ---- int slen; int start = 0; ! int end = INT_MAX; PyObject *subobj; *************** *** 2254,2266 **** return NULL; ! if (start < 0 || start > len || slen > len) ! return PyBool_FromLong(0); ! upper = (end >= 0 && end <= len) ? end : len; ! lower = (upper - slen) > start ? (upper - slen) : start; ! if (upper-lower >= slen && !memcmp(str+lower, suffix, slen)) ! return PyBool_FromLong(1); ! else return PyBool_FromLong(0); } --- 2243,2257 ---- return NULL; ! string_adjust_indices(&start, &end, len); ! if (end-start < slen || start > len) ! return PyBool_FromLong(0); ! if (end-slen > start) ! start = end - slen; ! if (end-start >= slen) ! return PyBool_FromLong(!memcmp(str+start, suffix, slen)); ! else ! return PyBool_FromLong(0); } From nnorwitz@users.sourceforge.net Fri Jun 14 01:50:44 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu, 13 Jun 2002 17:50:44 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.426,1.427 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv11051/Misc Modified Files: NEWS Log Message: SF bug # 493951 string.{starts,ends}with vs slices Handle negative indices similar to slices. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.426 retrieving revision 1.427 diff -C2 -d -r1.426 -r1.427 *** NEWS 13 Jun 2002 21:09:06 -0000 1.426 --- NEWS 14 Jun 2002 00:50:42 -0000 1.427 *************** *** 7,10 **** --- 7,13 ---- Core and builtins + - Fixed string.startswith and string.endswith builtin methods + so they accept negative indices. [SF bug 493951] + - Fixed a bug with a continue inside a try block and a yield in the finally clause. [SF bug 567538] From nnorwitz@users.sourceforge.net Fri Jun 14 01:50:44 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu, 13 Jun 2002 17:50:44 -0700 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew23.tex,1.24,1.25 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory usw-pr-cvs1:/tmp/cvs-serv11051/Doc/whatsnew Modified Files: whatsnew23.tex Log Message: SF bug # 493951 string.{starts,ends}with vs slices Handle negative indices similar to slices. Index: whatsnew23.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew23.tex,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** whatsnew23.tex 11 Jun 2002 10:55:09 -0000 1.24 --- whatsnew23.tex 14 Jun 2002 00:50:42 -0000 1.25 *************** *** 498,501 **** --- 498,505 ---- \end{verbatim} + \item The \method{startswith()} and \method{endswith()} + string methods now have accept negative numbers for + start and end parameters. + \item Another new string method is \method{zfill()}, originally a function in the \module{string} module. \method{zfill()} pads a From nnorwitz@users.sourceforge.net Fri Jun 14 01:50:44 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu, 13 Jun 2002 17:50:44 -0700 Subject: [Python-checkins] python/dist/src/Lib/test string_tests.py,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv11051/Lib/test Modified Files: string_tests.py Log Message: SF bug # 493951 string.{starts,ends}with vs slices Handle negative indices similar to slices. Index: string_tests.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/string_tests.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** string_tests.py 23 May 2002 15:15:30 -0000 1.17 --- string_tests.py 14 Jun 2002 00:50:42 -0000 1.18 *************** *** 224,227 **** --- 224,239 ---- test('startswith', 'helloworld', 0, 'lowo', 3, 6) + # test negative indices in startswith + test('startswith', 'hello', 1, 'he', 0, -1) + test('startswith', 'hello', 1, 'he', -53, -1) + test('startswith', 'hello', 0, 'hello', 0, -1) + test('startswith', 'hello', 0, 'hello world', -1, -10) + test('startswith', 'hello', 0, 'ello', -5) + test('startswith', 'hello', 1, 'ello', -4) + test('startswith', 'hello', 0, 'o', -2) + test('startswith', 'hello', 1, 'o', -1) + test('startswith', 'hello', 1, '', -3, -3) + test('startswith', 'hello', 0, 'lo', -9) + test('endswith', 'hello', 1, 'lo') test('endswith', 'hello', 0, 'he') *************** *** 238,241 **** --- 250,268 ---- test('endswith', 'ab', 0, 'ab', 0, 1) test('endswith', 'ab', 0, 'ab', 0, 0) + + # test negative indices in endswith + test('endswith', 'hello', 1, 'lo', -2) + test('endswith', 'hello', 0, 'he', -2) + test('endswith', 'hello', 1, '', -3, -3) + test('endswith', 'hello', 0, 'hello world', -10, -2) + test('endswith', 'helloworld', 0, 'worl', -6) + test('endswith', 'helloworld', 1, 'worl', -5, -1) + test('endswith', 'helloworld', 1, 'worl', -5, 9) + test('endswith', 'helloworld', 1, 'world', -7, 12) + test('endswith', 'helloworld', 1, 'lowo', -99, -3) + test('endswith', 'helloworld', 1, 'lowo', -8, -3) + test('endswith', 'helloworld', 1, 'lowo', -7, -3) + test('endswith', 'helloworld', 0, 'lowo', 3, -4) + test('endswith', 'helloworld', 0, 'lowo', -8, -2) test('zfill', '123', '123', 2) From nnorwitz@users.sourceforge.net Fri Jun 14 02:07:42 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu, 13 Jun 2002 18:07:42 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_import.py,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv15627/Lib/test Modified Files: test_import.py Log Message: Fix SF bug # 561858 Assertion with very long lists Write 4 bytes for co_stacksize, etc. to prevent writing out bad .pyc files which can cause a crash when read back in. Index: test_import.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_import.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** test_import.py 30 May 2002 17:10:20 -0000 1.11 --- test_import.py 14 Jun 2002 01:07:39 -0000 1.12 *************** *** 4,7 **** --- 4,8 ---- import random import sys + import py_compile # Brief digression to test that import is case-sensitive: if we got this *************** *** 75,76 **** --- 76,107 ---- x = imp.find_module("os") os = imp.load_module("os", *x) + + def test_module_with_large_stack(module): + # create module w/list of 65000 elements to test bug #561858 + filename = module + '.py' + + # create a file with a list of 65000 elements + f = open(filename, 'w+') + f.write('d = [\n') + for i in range(65000): + f.write('"",\n') + f.write(']') + f.close() + + # compile & remove .py file, we only need .pyc + f = open(filename, 'r') + py_compile.compile(filename) + os.unlink(filename) + + # need to be able to load from current dir + sys.path.append('') + + # this used to crash + exec 'import ' + module + + # cleanup + del sys.path[-1] + os.unlink(module + '.pyc') + + test_module_with_large_stack('longlist') + From nnorwitz@users.sourceforge.net Fri Jun 14 02:07:42 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu, 13 Jun 2002 18:07:42 -0700 Subject: [Python-checkins] python/dist/src/Python import.c,2.205,2.206 marshal.c,1.71,1.72 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv15627/Python Modified Files: import.c marshal.c Log Message: Fix SF bug # 561858 Assertion with very long lists Write 4 bytes for co_stacksize, etc. to prevent writing out bad .pyc files which can cause a crash when read back in. Index: import.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/import.c,v retrieving revision 2.205 retrieving revision 2.206 diff -C2 -d -r2.205 -r2.206 *** import.c 13 Jun 2002 20:33:02 -0000 2.205 --- import.c 14 Jun 2002 01:07:39 -0000 2.206 *************** *** 60,66 **** Python 2.1.2: 60202 Python 2.2: 60717 ! Python 2.3a0: 62001 */ ! #define MAGIC (62001 | ((long)'\r'<<16) | ((long)'\n'<<24)) /* Magic word as global; note that _PyImport_Init() can change the --- 60,66 ---- Python 2.1.2: 60202 Python 2.2: 60717 ! Python 2.3a0: 62011 */ ! #define MAGIC (62011 | ((long)'\r'<<16) | ((long)'\n'<<24)) /* Magic word as global; note that _PyImport_Init() can change the Index: marshal.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/marshal.c,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** marshal.c 3 Apr 2002 22:41:51 -0000 1.71 --- marshal.c 14 Jun 2002 01:07:39 -0000 1.72 *************** *** 242,249 **** PyCodeObject *co = (PyCodeObject *)v; w_byte(TYPE_CODE, p); ! w_short(co->co_argcount, p); ! w_short(co->co_nlocals, p); ! w_short(co->co_stacksize, p); ! w_short(co->co_flags, p); w_object(co->co_code, p); w_object(co->co_consts, p); --- 242,249 ---- PyCodeObject *co = (PyCodeObject *)v; w_byte(TYPE_CODE, p); ! w_long(co->co_argcount, p); ! w_long(co->co_nlocals, p); ! w_long(co->co_stacksize, p); ! w_long(co->co_flags, p); w_object(co->co_code, p); w_object(co->co_consts, p); *************** *** 254,258 **** w_object(co->co_filename, p); w_object(co->co_name, p); ! w_short(co->co_firstlineno, p); w_object(co->co_lnotab, p); } --- 254,258 ---- w_object(co->co_filename, p); w_object(co->co_name, p); ! w_long(co->co_firstlineno, p); w_object(co->co_lnotab, p); } *************** *** 589,596 **** } else { ! int argcount = r_short(p); ! int nlocals = r_short(p); ! int stacksize = r_short(p); ! int flags = r_short(p); PyObject *code = NULL; PyObject *consts = NULL; --- 589,596 ---- } else { ! int argcount = r_long(p); ! int nlocals = r_long(p); ! int stacksize = r_long(p); ! int flags = r_long(p); PyObject *code = NULL; PyObject *consts = NULL; *************** *** 613,617 **** if (filename) name = r_object(p); if (name) { ! firstlineno = r_short(p); lnotab = r_object(p); } --- 613,617 ---- if (filename) name = r_object(p); if (name) { ! firstlineno = r_long(p); lnotab = r_object(p); } From nnorwitz@users.sourceforge.net Fri Jun 14 02:11:59 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu, 13 Jun 2002 18:11:59 -0700 Subject: [Python-checkins] python/dist/src/Python frozen.c,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv17122/Python Modified Files: frozen.c Log Message: Fix SF bug # 561858 Assertion with very long lists Write 4 bytes for co_stacksize, etc. to prevent writing out bad .pyc files which can cause a crash when read back in. (I forgot that frozen needs to be updated too for the test.) Index: frozen.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/frozen.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** frozen.c 18 Oct 2001 18:57:31 -0000 1.11 --- frozen.c 14 Jun 2002 01:11:57 -0000 1.12 *************** *** 13,23 **** static unsigned char M___hello__[] = { ! 99,0,0,0,0,1,0,0,0,115,15,0,0,0,127,0, ! 0,127,1,0,100,0,0,71,72,100,1,0,83,40,2,0, ! 0,0,115,14,0,0,0,72,101,108,108,111,32,119,111,114, ! 108,100,46,46,46,78,40,0,0,0,0,40,0,0,0,0, ! 40,0,0,0,0,40,0,0,0,0,115,8,0,0,0,104, ! 101,108,108,111,46,112,121,115,1,0,0,0,63,1,0,115, ! 0,0,0,0, }; --- 13,23 ---- static unsigned char M___hello__[] = { ! 99,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0, ! 0,115,15,0,0,0,127,0,0,127,1,0,100,0,0,71, ! 72,100,1,0,83,40,2,0,0,0,115,14,0,0,0,72, ! 101,108,108,111,32,119,111,114,108,100,46,46,46,78,40,0, ! 0,0,0,40,0,0,0,0,40,0,0,0,0,40,0,0, ! 0,0,115,8,0,0,0,104,101,108,108,111,46,112,121,115, ! 1,0,0,0,63,1,0,0,0,115,0,0,0,0, }; From fdrake@users.sourceforge.net Fri Jun 14 02:58:21 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu, 13 Jun 2002 18:58:21 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libfcntl.tex,1.28,1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv27641/lib Modified Files: libfcntl.tex Log Message: Refer the reader to the correct module for constant definitions. This closes SF bug #550777. Index: libfcntl.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfcntl.tex,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** libfcntl.tex 28 Nov 2001 07:48:32 -0000 1.28 --- libfcntl.tex 14 Jun 2002 01:58:19 -0000 1.29 *************** *** 51,55 **** This function is identical to the \function{fcntl()} function, except that the operations are typically defined in the library module ! \module{IOCTL}. \end{funcdesc} --- 51,55 ---- This function is identical to the \function{fcntl()} function, except that the operations are typically defined in the library module ! \refmodule{termios}. \end{funcdesc} From fdrake@users.sourceforge.net Fri Jun 14 02:58:42 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu, 13 Jun 2002 18:58:42 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libfcntl.tex,1.28,1.28.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv27702/lib Modified Files: Tag: release22-maint libfcntl.tex Log Message: Refer the reader to the correct module for constant definitions. This closes SF bug #550777. Index: libfcntl.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfcntl.tex,v retrieving revision 1.28 retrieving revision 1.28.6.1 diff -C2 -d -r1.28 -r1.28.6.1 *** libfcntl.tex 28 Nov 2001 07:48:32 -0000 1.28 --- libfcntl.tex 14 Jun 2002 01:58:40 -0000 1.28.6.1 *************** *** 51,55 **** This function is identical to the \function{fcntl()} function, except that the operations are typically defined in the library module ! \module{IOCTL}. \end{funcdesc} --- 51,55 ---- This function is identical to the \function{fcntl()} function, except that the operations are typically defined in the library module ! \refmodule{termios}. \end{funcdesc} From nnorwitz@users.sourceforge.net Fri Jun 14 03:04:20 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Thu, 13 Jun 2002 19:04:20 -0700 Subject: [Python-checkins] python/dist/src/Objects listobject.c,2.112,2.113 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv28814/Objects Modified Files: listobject.c Log Message: Missed one use of new PyDoc_STRVAR macro Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.112 retrieving revision 2.113 diff -C2 -d -r2.112 -r2.113 *** listobject.c 13 Jun 2002 21:11:08 -0000 2.112 --- listobject.c 14 Jun 2002 02:04:18 -0000 2.113 *************** *** 1676,1682 **** }; ! static char list_doc[] = "list() -> new list\n" ! "list(sequence) -> new list initialized from sequence's items"; staticforward PyObject * list_iter(PyObject *seq); --- 1676,1682 ---- }; ! PyDoc_STRVAR(list_doc, "list() -> new list\n" ! "list(sequence) -> new list initialized from sequence's items"); staticforward PyObject * list_iter(PyObject *seq); From gvanrossum@users.sourceforge.net Fri Jun 14 03:27:09 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 13 Jun 2002 19:27:09 -0700 Subject: [Python-checkins] python/dist/src/Objects typeobject.c,2.153,2.154 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv567 Modified Files: typeobject.c Log Message: Inexplicably, recurse_down_subclasses() was comparing the object gotten from a weak reference to NULL instead of to None. This caused the following assert() to fail (but only in 2.2 in the debug build -- I have to find a better test case). Will backport. Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.153 retrieving revision 2.154 diff -C2 -d -r2.153 -r2.154 *** typeobject.c 13 Jun 2002 20:33:01 -0000 2.153 --- typeobject.c 14 Jun 2002 02:27:07 -0000 2.154 *************** *** 4030,4034 **** assert(PyWeakref_CheckRef(ref)); subclass = (PyTypeObject *)PyWeakref_GET_OBJECT(ref); ! if (subclass == NULL) continue; assert(PyType_Check(subclass)); --- 4030,4035 ---- assert(PyWeakref_CheckRef(ref)); subclass = (PyTypeObject *)PyWeakref_GET_OBJECT(ref); ! assert(subclass != NULL); ! if ((PyObject *)subclass == Py_None) continue; assert(PyType_Check(subclass)); From gvanrossum@users.sourceforge.net Fri Jun 14 03:28:29 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 13 Jun 2002 19:28:29 -0700 Subject: [Python-checkins] python/dist/src/Objects typeobject.c,2.126.4.15,2.126.4.16 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv770a Modified Files: Tag: release22-maint typeobject.c Log Message: Backport: Inexplicably, recurse_down_subclasses() was comparing the object gotten from a weak reference to NULL instead of to None. This caused the following assert() to fail (but only in 2.2 in the debug build -- I have to find a better test case). Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.126.4.15 retrieving revision 2.126.4.16 diff -C2 -d -r2.126.4.15 -r2.126.4.16 *** typeobject.c 10 Jun 2002 16:02:44 -0000 2.126.4.15 --- typeobject.c 14 Jun 2002 02:28:23 -0000 2.126.4.16 *************** *** 3863,3867 **** assert(PyWeakref_CheckRef(ref)); subclass = (PyTypeObject *)PyWeakref_GET_OBJECT(ref); ! if (subclass == NULL) continue; assert(PyType_Check(subclass)); --- 3863,3868 ---- assert(PyWeakref_CheckRef(ref)); subclass = (PyTypeObject *)PyWeakref_GET_OBJECT(ref); ! assert(subclass != NULL); ! if ((PyObject *)subclass == Py_None) continue; assert(PyType_Check(subclass)); From gvanrossum@users.sourceforge.net Fri Jun 14 03:35:47 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 13 Jun 2002 19:35:47 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_descr.py,1.140,1.141 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv2033a Modified Files: test_descr.py Log Message: Test for the bug in recurse_down_subclasses() that I just fixed. Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.140 retrieving revision 1.141 diff -C2 -d -r1.140 -r1.141 *** test_descr.py 13 Jun 2002 19:17:46 -0000 1.140 --- test_descr.py 14 Jun 2002 02:35:45 -0000 1.141 *************** *** 2774,2777 **** --- 2774,2787 ---- raise TestFailed, "d.foo should be undefined now" + # Test a nasty bug in recurse_down_subclasses() + import gc + class A(object): + pass + class B(A): + pass + del B + gc.collect() + A.__setitem__ = lambda *a: None # crash + def buffer_inherit(): import binascii From gvanrossum@users.sourceforge.net Fri Jun 14 03:37:02 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 13 Jun 2002 19:37:02 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_descr.py,1.113.4.17,1.113.4.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv2316 Modified Files: Tag: release22-maint test_descr.py Log Message: Test for the bug in recurse_down_subclasses() that I just fixed. Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.113.4.17 retrieving revision 1.113.4.18 diff -C2 -d -r1.113.4.17 -r1.113.4.18 *** test_descr.py 6 Jun 2002 17:55:35 -0000 1.113.4.17 --- test_descr.py 14 Jun 2002 02:37:00 -0000 1.113.4.18 *************** *** 2706,2709 **** --- 2706,2719 ---- raise TestFailed, "d.foo should be undefined now" + # Test a nasty bug in recurse_down_subclasses() + import gc + class A(object): + pass + class B(A): + pass + del B + gc.collect() + A.__setitem__ = lambda *a: None # crash + def buffer_inherit(): import binascii From holdenweb@users.sourceforge.net Fri Jun 14 10:16:42 2002 From: holdenweb@users.sourceforge.net (holdenweb@users.sourceforge.net) Date: Fri, 14 Jun 2002 02:16:42 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libstdtypes.tex,1.97,1.98 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv29235 Modified Files: libstdtypes.tex Log Message: Make a start at describing the results of class/type unification in the type documentation. Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.97 retrieving revision 1.98 diff -C2 -d -r1.97 -r1.98 *** libstdtypes.tex 14 Jun 2002 00:27:13 -0000 1.97 --- libstdtypes.tex 14 Jun 2002 09:16:40 -0000 1.98 *************** *** 2,7 **** The following sections describe the standard types that are built into ! the interpreter. These are the numeric types, sequence types, and ! several others, including types themselves. \indexii{built-in}{types} --- 2,14 ---- The following sections describe the standard types that are built into ! the interpreter. Historically, Python's built-in types have differed ! from user-defined types because it was not possible to use the built-in ! types as the basis for object-oriented inheritance. With the 2.2 ! release this situation has started to change, although the intended ! unification of user-defined and built-in types is as yet far from ! complete. ! ! The principal built-in types are numerics, sequences, mappings, files ! classes, instances and exceptions. \indexii{built-in}{types} *************** *** 13,17 **** ! \subsection{Truth Value Testing \label{truth}} Any object can be tested for truth value, for use in an \keyword{if} or --- 20,24 ---- ! \subsection{Truth Value Testing} \label{truth} Any object can be tested for truth value, for use in an \keyword{if} or *************** *** 129,136 **** \item[(1)] \code{<>} and \code{!=} are alternate spellings for the same operator. - (I couldn't choose between \ABC{} and C! :-) - \index{ABC language@\ABC{} language} - \index{language!ABC@\ABC} - \indexii{C}{language} \code{!=} is the preferred spelling; \code{<>} is obsolescent. --- 136,139 ---- *************** *** 143,147 **** degenerate notion of comparison where any two objects of that type are unequal. Again, such objects are ordered arbitrarily but ! consistently. \indexii{object}{numeric} \indexii{objects}{comparing} --- 146,152 ---- degenerate notion of comparison where any two objects of that type are unequal. Again, such objects are ordered arbitrarily but ! consistently. The \code{<}, \code{<=}, \code{>} and \code{>=} ! operators will raise a \exception{TypeError} exception when any operand ! is a complex number. \indexii{object}{numeric} \indexii{objects}{comparing} *************** *** 182,186 **** \indexii{C}{language} ! Complex numbers have a real and imaginary part, which are both implemented using \ctype{double} in C. To extract these parts from a complex number \var{z}, use \code{\var{z}.real} and \code{\var{z}.imag}. --- 187,191 ---- \indexii{C}{language} ! Complex numbers have a real and imaginary part, which are each implemented using \ctype{double} in C. To extract these parts from a complex number \var{z}, use \code{\var{z}.real} and \code{\var{z}.imag}. *************** *** 188,197 **** Numbers are created by numeric literals or as the result of built-in functions and operators. Unadorned integer literals (including hex ! and octal numbers) yield plain integers. Integer literals with an \character{L} or \character{l} suffix yield long integers (\character{L} is preferred because \samp{1l} looks too much like eleven!). Numeric literals containing a decimal point or an exponent sign yield floating point numbers. Appending \character{j} or ! \character{J} to a numeric literal yields a complex number. \indexii{numeric}{literals} \indexii{integer}{literals} --- 193,206 ---- Numbers are created by numeric literals or as the result of built-in functions and operators. Unadorned integer literals (including hex ! and octal numbers) yield plain integers unless the value they denote ! is too large to be represented as a plain integer, in which case ! they yield a long integer. Integer literals with an \character{L} or \character{l} suffix yield long integers (\character{L} is preferred because \samp{1l} looks too much like eleven!). Numeric literals containing a decimal point or an exponent sign yield floating point numbers. Appending \character{j} or ! \character{J} to a numeric literal yields a complex number with a ! zero real part. A complex numeric literal is the sum of a real and ! an imaginary part. \indexii{numeric}{literals} \indexii{integer}{literals} *************** *** 204,216 **** Python fully supports mixed arithmetic: when a binary arithmetic operator has operands of different numeric types, the operand with the ! ``smaller'' type is converted to that of the other, where plain ! integer is smaller than long integer is smaller than floating point is ! smaller than complex. Comparisons between numbers of mixed type use the same rule.\footnote{ As a consequence, the list \code{[1, 2]} is considered equal ! to \code{[1.0, 2.0]}, and similar for tuples. ! } The functions \function{int()}, \function{long()}, \function{float()}, and \function{complex()} can be used ! to coerce numbers to a specific type. \index{arithmetic} \bifuncindex{int} --- 213,225 ---- Python fully supports mixed arithmetic: when a binary arithmetic operator has operands of different numeric types, the operand with the ! ``narrower'' type is widened to that of the other, where plain ! integer is narrower than long integer is narrower than floating point is ! narrower than complex. Comparisons between numbers of mixed type use the same rule.\footnote{ As a consequence, the list \code{[1, 2]} is considered equal ! to \code{[1.0, 2.0]}, and similarly for tuples. ! } The constructors \function{int()}, \function{long()}, \function{float()}, and \function{complex()} can be used ! to produce numbers of a specific type. \index{arithmetic} \bifuncindex{int} *************** *** 219,224 **** \bifuncindex{complex} ! All numeric types (except complex) support the following operations, ! sorted by ascending priority (operations in the same box have the same priority; all numeric operations have a higher priority than comparison operations): --- 228,233 ---- \bifuncindex{complex} ! All numeric types support the following operations, sorted by ! ascending priority (operations in the same box have the same priority; all numeric operations have a higher priority than comparison operations): *************** *** 230,234 **** \lineiii{\var{x} * \var{y}}{product of \var{x} and \var{y}}{} \lineiii{\var{x} / \var{y}}{quotient of \var{x} and \var{y}}{(1)} ! \lineiii{\var{x} \%{} \var{y}}{remainder of \code{\var{x} / \var{y}}}{(4)} \hline \lineiii{-\var{x}}{\var{x} negated}{} --- 239,243 ---- \lineiii{\var{x} * \var{y}}{product of \var{x} and \var{y}}{} \lineiii{\var{x} / \var{y}}{quotient of \var{x} and \var{y}}{(1)} ! \lineiii{\var{x} \%{} \var{y}}{remainder of \code{\var{x} / \var{y}}}{} \hline \lineiii{-\var{x}}{\var{x} negated}{} *************** *** 241,245 **** \lineiii{complex(\var{re},\var{im})}{a complex number with real part \var{re}, imaginary part \var{im}. \var{im} defaults to zero.}{} \lineiii{\var{c}.conjugate()}{conjugate of the complex number \var{c}}{} ! \lineiii{divmod(\var{x}, \var{y})}{the pair \code{(\var{x} / \var{y}, \var{x} \%{} \var{y})}}{(3)(4)} \lineiii{pow(\var{x}, \var{y})}{\var{x} to the power \var{y}}{} \lineiii{\var{x} ** \var{y}}{\var{x} to the power \var{y}}{} --- 250,254 ---- \lineiii{complex(\var{re},\var{im})}{a complex number with real part \var{re}, imaginary part \var{im}. \var{im} defaults to zero.}{} \lineiii{\var{c}.conjugate()}{conjugate of the complex number \var{c}}{} ! \lineiii{divmod(\var{x}, \var{y})}{the pair \code{(\var{x} / \var{y}, \var{x} \%{} \var{y})}}{(3)} \lineiii{pow(\var{x}, \var{y})}{\var{x} to the power \var{y}}{} \lineiii{\var{x} ** \var{y}}{\var{x} to the power \var{y}}{} *************** *** 274,283 **** description. - \item[(4)] - Complex floor division operator, modulo operator, and \function{divmod()}. - - \deprecated{2.3}{Instead convert to float using \function{abs()} - if appropriate.} - \end{description} % XXXJH exceptions: overflow (when? what operations?) zerodivision --- 283,286 ---- *************** *** 381,385 **** tuples, buffers, and xrange objects. ! Strings literals are written in single or double quotes: \code{'xyzzy'}, \code{"frobozz"}. See chapter 2 of the \citetitle[../ref/strings.html]{Python Reference Manual} for more about --- 384,388 ---- tuples, buffers, and xrange objects. ! String literals are written in single or double quotes: \code{'xyzzy'}, \code{"frobozz"}. See chapter 2 of the \citetitle[../ref/strings.html]{Python Reference Manual} for more about *************** *** 400,414 **** Buffer objects are not directly supported by Python syntax, but can be created by calling the builtin function ! \function{buffer()}.\bifuncindex{buffer} They support concatenation ! and repetition, but the result is a new string object rather than a ! new buffer object. \obindex{buffer} Xrange objects are similar to buffers in that there is no specific ! syntax to create them, but they are created using the ! \function{xrange()} function.\bifuncindex{xrange} They don't support ! slicing, concatenation, or repetition, and using \keyword{in}, ! \keyword{not} \keyword{in}, \function{min()} or \function{max()} on ! them is inefficient. \obindex{xrange} --- 403,415 ---- Buffer objects are not directly supported by Python syntax, but can be created by calling the builtin function ! \function{buffer()}.\bifuncindex{buffer}. They don't support ! concatenation or repetition. \obindex{buffer} Xrange objects are similar to buffers in that there is no specific ! syntax to create them, but they are created using the \function{xrange()} ! function.\bifuncindex{xrange} They don't support slicing, ! concatenation or repetition, and using \code{in}, \code{not in}, ! \function{min()} or \function{max()} on them is inefficient. \obindex{xrange} *************** *** 434,438 **** \lineiii{\var{s}[\var{i}]}{\var{i}'th item of \var{s}, origin 0}{(2)} \lineiii{\var{s}[\var{i}:\var{j}]}{slice of \var{s} from \var{i} to \var{j}}{(2), (3)} - \lineiii{\var{s}[\var{i}:\var{j}:\var{k}]}{slice of \var{s} from \var{i} to \var{j} with step \var{k}}{(2), (4)} \hline \lineiii{len(\var{s})}{length of \var{s}}{} --- 435,438 ---- *************** *** 448,452 **** \indexii{subscript}{operation} \indexii{slice}{operation} - \indexii{extended slice}{operation} \opindex{in} \opindex{not in} --- 448,451 ---- *************** *** 495,507 **** use \code{0}. If \var{j} is omitted, use \code{len(\var{s})}. If \var{i} is greater than or equal to \var{j}, the slice is empty. - - \item[(4)] The slice of \var{s} from \var{i} to \var{j} with step \var{k} - is defined as the sequence of items with index \code{\var{x} = - \var{i} + \var{n}*\var{k}} such that \var{n} \code{>=} \code{0} and - \code{\var{i} <= \var{x} < \var{j}}. If \var{i} or \var{j} is - greater than \code{len(\var{s})}, use \code{len(\var{s})}. If - \var{i} or \var{j} are ommitted then they become ``end'' values - (which end depends on the sign of \var{k}). - \end{description} --- 494,497 ---- *************** *** 548,553 **** \begin{methoddesc}[string]{endswith}{suffix\optional{, start\optional{, end}}} ! Return \code{True} if the string ends with the specified \var{suffix}, ! otherwise return \code{False}. With optional \var{start}, test beginning at that position. With optional \var{end}, stop comparing at that position. \end{methoddesc} --- 538,543 ---- \begin{methoddesc}[string]{endswith}{suffix\optional{, start\optional{, end}}} ! Return true if the string ends with the specified \var{suffix}, ! otherwise return false. With optional \var{start}, test beginning at that position. With optional \var{end}, stop comparing at that position. \end{methoddesc} *************** *** 679,684 **** \begin{methoddesc}[string]{startswith}{prefix\optional{, start\optional{, end}}} ! Return \code{True} if string starts with the \var{prefix}, otherwise ! return \code{False}. With optional \var{start}, test string beginning at that position. With optional \var{end}, stop comparing string at that position. --- 669,674 ---- \begin{methoddesc}[string]{startswith}{prefix\optional{, start\optional{, end}}} ! Return true if string starts with the \var{prefix}, otherwise ! return false. With optional \var{start}, test string beginning at that position. With optional \var{end}, stop comparing string at that position. *************** *** 741,749 **** \var{format} is a Unicode object, or if any of the objects being converted using the \code{\%s} conversion are Unicode objects, the ! result will be a Unicode object as well. If \var{format} requires a single argument, \var{values} may be a ! single non-tuple object. \footnote{A tuple object in this case should ! be a singleton.} Otherwise, \var{values} must be a tuple with exactly the number of items specified by the format string, or a single mapping object (for example, a dictionary). --- 731,740 ---- \var{format} is a Unicode object, or if any of the objects being converted using the \code{\%s} conversion are Unicode objects, the ! result will also be a Unicode object. If \var{format} requires a single argument, \var{values} may be a ! single non-tuple object. \footnote{To format only a tuple you ! should therefore provide a singleton tuple whose only element ! is the tuple to be formatted.} Otherwise, \var{values} must be a tuple with exactly the number of items specified by the format string, or a single mapping object (for example, a dictionary). *************** *** 755,760 **** \item The \character{\%} character, which marks the start of the specifier. ! \item Mapping key value (optional), consisting of an identifier in ! parentheses (for example, \code{(somename)}). \item Conversion flags (optional), which affect the result of some conversion types. --- 746,751 ---- \item The \character{\%} character, which marks the start of the specifier. ! \item Mapping key (optional), consisting of a parenthesised sequence ! of characters (for example, \code{(somename)}). \item Conversion flags (optional), which affect the result of some conversion types. *************** *** 773,786 **** \end{enumerate} ! If the right argument is a dictionary (or any kind of mapping), then ! the formats in the string \emph{must} have a parenthesized key into that dictionary inserted immediately after the \character{\%} ! character, and each format formats the corresponding entry from the mapping. For example: \begin{verbatim} ! >>> count = 2 ! >>> language = 'Python' ! >>> print '%(language)s has %(count)03d quote types.' % vars() Python has 002 quote types. \end{verbatim} --- 764,776 ---- \end{enumerate} ! When the right argument is a dictionary (or other mapping type), then ! the formats in the string \emph{must} include a parenthesised mapping key into that dictionary inserted immediately after the \character{\%} ! character. The mapping key selects the value to be formatted from the mapping. For example: \begin{verbatim} ! >>> print '%(language)s has %(#)03d quote types.' % \ ! {'language': "Python", "#": 2} Python has 002 quote types. \end{verbatim} *************** *** 871,877 **** List objects support additional operations that allow in-place modification of the object. ! These operations would be supported by other mutable sequence types ! (when added to the language) as well. ! Strings and tuples are immutable sequence types and such objects cannot be modified once created. The following operations are defined on mutable sequence types (where --- 861,867 ---- List objects support additional operations that allow in-place modification of the object. ! Other mutable sequence types (when added to the language) should ! also support these operations. ! Strings and tuples are immutable sequence types: such objects cannot be modified once created. The following operations are defined on mutable sequence types (where *************** *** 887,913 **** \lineiii{del \var{s}[\var{i}:\var{j}]} {same as \code{\var{s}[\var{i}:\var{j}] = []}}{} - \lineiii{\var{s}[\var{i}:\var{j}:\var{k}] = \var{t}} - {the elements of \code{\var{s}[\var{i}:\var{j}:\var{k}]} are replaced by those of \var{t}}{(1)} - \lineiii{del \var{s}[\var{i}:\var{j}:\var{k}]} - {removes the elements of \code{\var{s}[\var{i}:\var{j}:\var{k}]} from the list}{} \lineiii{\var{s}.append(\var{x})} ! {same as \code{\var{s}[len(\var{s}):len(\var{s})] = [\var{x}]}}{(2)} \lineiii{\var{s}.extend(\var{x})} ! {same as \code{\var{s}[len(\var{s}):len(\var{s})] = \var{x}}}{(3)} \lineiii{\var{s}.count(\var{x})} {return number of \var{i}'s for which \code{\var{s}[\var{i}] == \var{x}}}{} \lineiii{\var{s}.index(\var{x})} ! {return smallest \var{i} such that \code{\var{s}[\var{i}] == \var{x}}}{(4)} \lineiii{\var{s}.insert(\var{i}, \var{x})} {same as \code{\var{s}[\var{i}:\var{i}] = [\var{x}]} ! if \code{\var{i} >= 0}}{(5)} \lineiii{\var{s}.pop(\optional{\var{i}})} ! {same as \code{\var{x} = \var{s}[\var{i}]; del \var{s}[\var{i}]; return \var{x}}}{(6)} \lineiii{\var{s}.remove(\var{x})} ! {same as \code{del \var{s}[\var{s}.index(\var{x})]}}{(4)} \lineiii{\var{s}.reverse()} ! {reverses the items of \var{s} in place}{(7)} \lineiii{\var{s}.sort(\optional{\var{cmpfunc}})} ! {sort the items of \var{s} in place}{(7), (8)} \end{tableiii} \indexiv{operations on}{mutable}{sequence}{types} --- 877,899 ---- \lineiii{del \var{s}[\var{i}:\var{j}]} {same as \code{\var{s}[\var{i}:\var{j}] = []}}{} \lineiii{\var{s}.append(\var{x})} ! {same as \code{\var{s}[len(\var{s}):len(\var{s})] = [\var{x}]}}{(1)} \lineiii{\var{s}.extend(\var{x})} ! {same as \code{\var{s}[len(\var{s}):len(\var{s})] = \var{x}}}{(2)} \lineiii{\var{s}.count(\var{x})} {return number of \var{i}'s for which \code{\var{s}[\var{i}] == \var{x}}}{} \lineiii{\var{s}.index(\var{x})} ! {return smallest \var{i} such that \code{\var{s}[\var{i}] == \var{x}}}{(3)} \lineiii{\var{s}.insert(\var{i}, \var{x})} {same as \code{\var{s}[\var{i}:\var{i}] = [\var{x}]} ! if \code{\var{i} >= 0}}{(4)} \lineiii{\var{s}.pop(\optional{\var{i}})} ! {same as \code{\var{x} = \var{s}[\var{i}]; del \var{s}[\var{i}]; return \var{x}}}{(5)} \lineiii{\var{s}.remove(\var{x})} ! {same as \code{del \var{s}[\var{s}.index(\var{x})]}}{(3)} \lineiii{\var{s}.reverse()} ! {reverses the items of \var{s} in place}{(6)} \lineiii{\var{s}.sort(\optional{\var{cmpfunc}})} ! {sort the items of \var{s} in place}{(6), (7)} \end{tableiii} \indexiv{operations on}{mutable}{sequence}{types} *************** *** 916,920 **** \indexii{subscript}{assignment} \indexii{slice}{assignment} - \indexii{extended slice}{assignment} \stindex{del} \withsubitem{(list method)}{ --- 902,905 ---- *************** *** 925,957 **** Notes: \begin{description} ! \item[(1)] \var{t} must have the same length as the slice it is ! replacing. ! ! \item[(2)] 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. ! \item[(3)] Raises an exception when \var{x} is not a list object. The \method{extend()} method is experimental and not supported by mutable sequence types other than lists. ! \item[(4)] Raises \exception{ValueError} when \var{x} is not found in \var{s}. ! \item[(5)] When a negative index is passed as the first parameter to the \method{insert()} method, the new element is prepended to the sequence. ! \item[(6)] The \method{pop()} method is only supported by the list and array types. The optional argument \var{i} defaults to \code{-1}, so that by default the last item is removed and returned. ! \item[(7)] The \method{sort()} and \method{reverse()} methods modify the list in place for economy of space when sorting or reversing a large list. To remind you that they operate by side effect, they don't return the sorted or reversed list. ! \item[(8)] The \method{sort()} method takes an optional argument specifying a comparison function of two arguments (list items) which should return a negative, zero or positive number depending on whether --- 910,939 ---- Notes: \begin{description} ! \item[(1)] The C implementation of Python historically accepted ! multiple parameters and implicitly joined them into a tuple; ! Use of this misfeature has been deprecated since Python 1.4, ! and became an error with the introduction of Python 2.0. ! \item[(2)] Raises an exception when \var{x} is not a list object. The \method{extend()} method is experimental and not supported by mutable sequence types other than lists. ! \item[(3)] Raises \exception{ValueError} when \var{x} is not found in \var{s}. ! \item[(4)] When a negative index is passed as the first parameter to the \method{insert()} method, the new element is prepended to the sequence. ! \item[(5)] The \method{pop()} method is only supported by the list and array types. The optional argument \var{i} defaults to \code{-1}, so that by default the last item is removed and returned. ! \item[(6)] The \method{sort()} and \method{reverse()} methods modify the list in place for economy of space when sorting or reversing a large list. To remind you that they operate by side effect, they don't return the sorted or reversed list. ! \item[(7)] The \method{sort()} method takes an optional argument specifying a comparison function of two arguments (list items) which should return a negative, zero or positive number depending on whether *************** *** 970,979 **** \obindex{dictionary} ! A \dfn{mapping} object maps values of one type (the key type) to arbitrary objects. Mappings are mutable objects. There is currently only one standard mapping type, the \dfn{dictionary}. A dictionary's keys are ! almost arbitrary values. The only types of values not acceptable as ! keys are values containing lists or dictionaries or other mutable ! types that are compared by value rather than by object identity. Numeric types used for keys obey the normal rules for numeric comparison: if two numbers compare equal (e.g. \code{1} and --- 952,961 ---- \obindex{dictionary} ! A \dfn{mapping} object maps immutable values to arbitrary objects. Mappings are mutable objects. There is currently only one standard mapping type, the \dfn{dictionary}. A dictionary's keys are ! almost arbitrary values. Only values containing lists, dictionaries ! or other mutable types (that are compared by value rather than by ! object identity) may not be used as keys. Numeric types used for keys obey the normal rules for numeric comparison: if two numbers compare equal (e.g. \code{1} and *************** *** 1001,1011 **** \ttindex{update()} \ttindex{values()} ! \ttindex{get()} ! \ttindex{setdefault()} ! \ttindex{pop()} ! \ttindex{popitem()} ! \ttindex{iteritems()} ! \ttindex{iterkeys)} ! \ttindex{itervalues()}} \begin{tableiii}{c|l|c}{code}{Operation}{Result}{Notes} --- 983,987 ---- \ttindex{update()} \ttindex{values()} ! \ttindex{get()}} \begin{tableiii}{c|l|c}{code}{Operation}{Result}{Notes} *************** *** 1099,1103 **** is new in Python 2.2. The older built-in \function{open()} is an alias for \function{file()}.} ! They are also returned by some other built-in functions and methods, such as \function{os.popen()} and \function{os.fdopen()} and the --- 1075,1079 ---- is new in Python 2.2. The older built-in \function{open()} is an alias for \function{file()}.} ! File objects are also returned by some other built-in functions and methods, such as \function{os.popen()} and \function{os.fdopen()} and the *************** *** 1115,1119 **** \begin{methoddesc}[file]{close}{} ! Close the file. A closed file cannot be read or written anymore. Any operation which requires that the file be open will raise a \exception{ValueError} after the file has been closed. Calling --- 1091,1095 ---- \begin{methoddesc}[file]{close}{} ! Close the file. A closed file cannot be read or written any more. Any operation which requires that the file be open will raise a \exception{ValueError} after the file has been closed. Calling *************** *** 1161,1169 **** Read one entire line from the file. A trailing newline character is kept in the string\footnote{ ! The advantage of leaving the newline on is that an empty string ! can be returned to mean \EOF{} without being ambiguous. Another ! advantage is that (in cases where it might matter, for example. if you want to make an exact copy of a file while scanning its lines) ! you can tell whether the last line of a file ended in a newline or not (yes this happens!). } (but may be absent when a file ends with an --- 1137,1146 ---- Read one entire line from the file. A trailing newline character is kept in the string\footnote{ ! The advantage of leaving the newline on is that ! returning an empty string is then an unambiguous \EOF{} ! indication. It is also possible (in cases where it might ! matter, for example, if you want to make an exact copy of a file while scanning its lines) ! to tell whether the last line of a file ended in a newline or not (yes this happens!). } (but may be absent when a file ends with an *************** *** 1171,1175 **** non-negative, it is a maximum byte count (including the trailing newline) and an incomplete line may be returned. ! An empty string is returned when \EOF{} is hit immediately. \note{Unlike \code{stdio}'s \cfunction{fgets()}, the returned string contains null characters (\code{'\e 0'}) if they --- 1148,1152 ---- non-negative, it is a maximum byte count (including the trailing newline) and an incomplete line may be returned. ! An empty string is returned \emph{only} when \EOF{} is encountered immediately. \note{Unlike \code{stdio}'s \cfunction{fgets()}, the returned string contains null characters (\code{'\e 0'}) if they *************** *** 1266,1281 **** file object, of the form \samp{<\mbox{\ldots}>}. This is a read-only attribute and may not be present on all file-like objects. - \end{memberdesc} - - \begin{memberdesc}[file]{newlines} - If Python was built with the \code{--with-universal-newlines} option - (the default) this read-only attribute exists, and for files opened in - universal newline read mode it keeps track of the types of newlines - encountered while reading the file. The values it can take are - \code{'\e r'}, \code{'\e n'}, \code{'\e r\e n'}, \code{None} (unknown, - no newlines read yet) or a tuple containing all the newline - types seen, to indicate that multiple - newline conventions were encountered. For files not opened in universal - newline read mode the value of this attribute will be \code{None}. \end{memberdesc} --- 1243,1246 ---- From fdrake@users.sourceforge.net Fri Jun 14 14:48:00 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri, 14 Jun 2002 06:48:00 -0700 Subject: [Python-checkins] python/dist/src/Doc/html style.css,1.22,1.23 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/html In directory usw-pr-cvs1:/tmp/cvs-serv26100 Modified Files: style.css Log Message: Anchors ("a" elements) used only for the name attribute should not change color on hover, only those that are link sources (href attributes). Index: style.css =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/html/style.css,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** style.css 1 May 2002 22:03:40 -0000 1.22 --- style.css 14 Jun 2002 13:47:58 -0000 1.23 *************** *** 40,44 **** a:active { color: #ff0000; } ! a:hover { background-color: #bbeeff; } a:visited { color: #551a8b; } a:link { color: #0000bb; } --- 40,44 ---- a:active { color: #ff0000; } ! a[href]:hover { background-color: #bbeeff; } a:visited { color: #551a8b; } a:link { color: #0000bb; } From gvanrossum@users.sourceforge.net Fri Jun 14 14:48:27 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Fri, 14 Jun 2002 06:48:27 -0700 Subject: [Python-checkins] python/dist/src/Lib rexec.py,1.38,1.39 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv26199 Modified Files: rexec.py Log Message: Don't poorly emulate the interactive interpreter, use code.InteractiveConsole to do a much better job. Index: rexec.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/rexec.py,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** rexec.py 1 Jun 2002 14:18:46 -0000 1.38 --- rexec.py 14 Jun 2002 13:48:25 -0000 1.39 *************** *** 553,575 **** return 1 if fp.isatty(): ! print "*** RESTRICTED *** Python", sys.version ! print 'Type "help", "copyright", "credits" or "license" ' \ ! 'for more information.' ! ! while 1: ! try: ! try: ! s = raw_input('>>> ') ! except EOFError: ! print ! break ! if s and s[0] != '#': ! s = s + '\n' ! c = compile(s, '', 'single') ! r.s_exec(c) ! except SystemExit, n: ! return n ! except: ! traceback.print_exc() else: text = fp.read() --- 553,565 ---- return 1 if fp.isatty(): ! import code ! interp = code.InteractiveConsole(r.modules['__main__'].__dict__) ! try: ! interp.interact( ! "*** RESTRICTED *** Python %s on %s\n" ! 'Type "help", "copyright", "credits" or "license" ' ! "for more information." % (sys.version, sys.platform)) ! except SystemExit, n: ! return n else: text = fp.read() From mwh@users.sourceforge.net Fri Jun 14 14:53:32 2002 From: mwh@users.sourceforge.net (mwh@users.sourceforge.net) Date: Fri, 14 Jun 2002 06:53:32 -0700 Subject: [Python-checkins] python/dist/src/Python ceval.c,2.313,2.314 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv27598 Modified Files: ceval.c Log Message: Now FOR_LOOP is gone, loop_subscript can go too. make -s rules :-) Index: ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.313 retrieving revision 2.314 diff -C2 -d -r2.313 -r2.314 *** ceval.c 13 Jun 2002 17:59:51 -0000 2.313 --- ceval.c 14 Jun 2002 13:53:29 -0000 2.314 *************** *** 52,56 **** PyFrameObject *, int); static void call_exc_trace(Py_tracefunc, PyObject *, PyFrameObject *); - static PyObject *loop_subscript(PyObject *, PyObject *); static PyObject *apply_slice(PyObject *, PyObject *, PyObject *); static int assign_slice(PyObject *, PyObject *, --- 52,55 ---- *************** *** 3303,3324 **** #define SLICE_ERROR_MSG \ "standard sequence type does not support step size other than one" - - static PyObject * - loop_subscript(PyObject *v, PyObject *w) - { - PySequenceMethods *sq = v->ob_type->tp_as_sequence; - int i; - if (sq == NULL || sq->sq_item == NULL) { - PyErr_SetString(PyExc_TypeError, "loop over non-sequence"); - return NULL; - } - i = PyInt_AsLong(w); - v = (*sq->sq_item)(v, i); - if (v) - return v; - if (PyErr_ExceptionMatches(PyExc_IndexError)) - PyErr_Clear(); - return NULL; - } /* Extract a slice index from a PyInt or PyLong, and store in *pi. --- 3302,3305 ---- From gvanrossum@users.sourceforge.net Fri Jun 14 14:54:28 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Fri, 14 Jun 2002 06:54:28 -0700 Subject: [Python-checkins] python/dist/src/Lib rexec.py,1.39,1.40 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv28089 Modified Files: rexec.py Log Message: Use code.interact(), which is even simpler, *and* imports readline when it can. Index: rexec.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/rexec.py,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** rexec.py 14 Jun 2002 13:48:25 -0000 1.39 --- rexec.py 14 Jun 2002 13:54:26 -0000 1.40 *************** *** 554,563 **** if fp.isatty(): import code - interp = code.InteractiveConsole(r.modules['__main__'].__dict__) try: ! interp.interact( "*** RESTRICTED *** Python %s on %s\n" 'Type "help", "copyright", "credits" or "license" ' ! "for more information." % (sys.version, sys.platform)) except SystemExit, n: return n --- 554,563 ---- if fp.isatty(): import code try: ! code.interact( "*** RESTRICTED *** Python %s on %s\n" 'Type "help", "copyright", "credits" or "license" ' ! "for more information." % (sys.version, sys.platform), ! local=r.modules['__main__'].__dict__) except SystemExit, n: return n From fdrake@users.sourceforge.net Fri Jun 14 15:35:58 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri, 14 Jun 2002 07:35:58 -0700 Subject: [Python-checkins] python/dist/src/Doc/api abstract.tex,1.16,1.17 refcounts.dat,1.40,1.41 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory usw-pr-cvs1:/tmp/cvs-serv10819/api Modified Files: abstract.tex refcounts.dat Log Message: Clean up descriptions of PyObject_RichCompare() and PyObject_RichCompareBool() based on comments from David Abrahams. Added refcount information for these functions. Index: abstract.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/abstract.tex,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** abstract.tex 13 Jun 2002 11:51:48 -0000 1.16 --- abstract.tex 14 Jun 2002 14:35:56 -0000 1.17 *************** *** 83,89 **** \begin{cfuncdesc}{PyObject*}{PyObject_RichCompare}{PyObject *o1, ! PyObject *o2, int op} Compare the values of \var{o1} and \var{o2} using the operation ! specified by \var{op}, which must be one of \constant{Py_LT}, \constant{Py_LE}, --- 83,89 ---- \begin{cfuncdesc}{PyObject*}{PyObject_RichCompare}{PyObject *o1, ! PyObject *o2, int opid} Compare the values of \var{o1} and \var{o2} using the operation ! specified by \var{opid}, which must be one of \constant{Py_LT}, \constant{Py_LE}, *************** *** 98,110 **** \code{>}, or \code{>=} respectively. This is the equivalent of the Python expression ! \samp{\var{o1} \emph{op} \var{o2}}, where \emph{op} is the operator ! corresponding to \var{op}. Returns the value of the comparison on success, or \NULL{} on failure. \end{cfuncdesc} \begin{cfuncdesc}{int}{PyObject_RichCompareBool}{PyObject *o1, ! PyObject *o2, int op} Compare the values of \var{o1} and \var{o2} using the operation ! specified by \var{op}, which must be one of \constant{Py_LT}, \constant{Py_LE}, --- 98,110 ---- \code{>}, or \code{>=} respectively. This is the equivalent of the Python expression ! \samp{\var{o1} op \var{o2}}, where \code{op} is the operator ! corresponding to \var{opid}. Returns the value of the comparison on success, or \NULL{} on failure. \end{cfuncdesc} \begin{cfuncdesc}{int}{PyObject_RichCompareBool}{PyObject *o1, ! PyObject *o2, int opid} Compare the values of \var{o1} and \var{o2} using the operation ! specified by \var{opid}, which must be one of \constant{Py_LT}, \constant{Py_LE}, *************** *** 120,125 **** \code{>=} respectively. Returns \code{-1} on error, \code{0} if the result is false, \code{1} otherwise. This is the equivalent of the ! Python expression \samp{\var{o1} \emph{op} \var{o2}}, where ! \emph{op} is the operator corresponding to \var{op}. \end{cfuncdesc} --- 120,125 ---- \code{>=} respectively. Returns \code{-1} on error, \code{0} if the result is false, \code{1} otherwise. This is the equivalent of the ! Python expression \samp{\var{o1} op \var{o2}}, where ! \code{op} is the operator corresponding to \var{opid}. \end{cfuncdesc} Index: refcounts.dat =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/refcounts.dat,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** refcounts.dat 23 May 2002 16:03:16 -0000 1.40 --- refcounts.dat 14 Jun 2002 14:35:56 -0000 1.41 *************** *** 844,847 **** --- 844,857 ---- PyObject_Repr:PyObject*:o:0: + PyObject_RichCompare:PyObject*::+1: + PyObject_RichCompare:PyObject*:o1:0: + PyObject_RichCompare:PyObject*:o2:0: + PyObject_RichCompare:int:opid:: + + PyObject_RichCompareBool:int::: + PyObject_RichCompareBool:PyObject*:o1:0: + PyObject_RichCompareBool:PyObject*:o2:0: + PyObject_RichCompareBool:int:opid:: + PyObject_SetAttr:int::: PyObject_SetAttr:PyObject*:o:0: From fdrake@users.sourceforge.net Fri Jun 14 15:36:25 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri, 14 Jun 2002 07:36:25 -0700 Subject: [Python-checkins] python/dist/src/Doc/api abstract.tex,1.8.6.4,1.8.6.5 refcounts.dat,1.38.6.1,1.38.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory usw-pr-cvs1:/tmp/cvs-serv11049/api Modified Files: Tag: release22-maint abstract.tex refcounts.dat Log Message: Clean up descriptions of PyObject_RichCompare() and PyObject_RichCompareBool() based on comments from David Abrahams. Added refcount information for these functions. Index: abstract.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/abstract.tex,v retrieving revision 1.8.6.4 retrieving revision 1.8.6.5 diff -C2 -d -r1.8.6.4 -r1.8.6.5 *** abstract.tex 13 Jun 2002 11:52:21 -0000 1.8.6.4 --- abstract.tex 14 Jun 2002 14:36:23 -0000 1.8.6.5 *************** *** 83,89 **** \begin{cfuncdesc}{PyObject*}{PyObject_RichCompare}{PyObject *o1, ! PyObject *o2, int op} Compare the values of \var{o1} and \var{o2} using the operation ! specified by \var{op}, which must be one of \constant{Py_LT}, \constant{Py_LE}, --- 83,89 ---- \begin{cfuncdesc}{PyObject*}{PyObject_RichCompare}{PyObject *o1, ! PyObject *o2, int opid} Compare the values of \var{o1} and \var{o2} using the operation ! specified by \var{opid}, which must be one of \constant{Py_LT}, \constant{Py_LE}, *************** *** 98,110 **** \code{>}, or \code{>=} respectively. This is the equivalent of the Python expression ! \samp{\var{o1} \emph{op} \var{o2}}, where \emph{op} is the operator ! corresponding to \var{op}. Returns the value of the comparison on success, or \NULL{} on failure. \end{cfuncdesc} \begin{cfuncdesc}{int}{PyObject_RichCompareBool}{PyObject *o1, ! PyObject *o2, int op} Compare the values of \var{o1} and \var{o2} using the operation ! specified by \var{op}, which must be one of \constant{Py_LT}, \constant{Py_LE}, --- 98,110 ---- \code{>}, or \code{>=} respectively. This is the equivalent of the Python expression ! \samp{\var{o1} op \var{o2}}, where \code{op} is the operator ! corresponding to \var{opid}. Returns the value of the comparison on success, or \NULL{} on failure. \end{cfuncdesc} \begin{cfuncdesc}{int}{PyObject_RichCompareBool}{PyObject *o1, ! PyObject *o2, int opid} Compare the values of \var{o1} and \var{o2} using the operation ! specified by \var{opid}, which must be one of \constant{Py_LT}, \constant{Py_LE}, *************** *** 120,125 **** \code{>=} respectively. Returns \code{-1} on error, \code{0} if the result is false, \code{1} otherwise. This is the equivalent of the ! Python expression \samp{\var{o1} \emph{op} \var{o2}}, where ! \emph{op} is the operator corresponding to \var{op}. \end{cfuncdesc} --- 120,125 ---- \code{>=} respectively. Returns \code{-1} on error, \code{0} if the result is false, \code{1} otherwise. This is the equivalent of the ! Python expression \samp{\var{o1} op \var{o2}}, where ! \code{op} is the operator corresponding to \var{opid}. \end{cfuncdesc} Index: refcounts.dat =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/refcounts.dat,v retrieving revision 1.38.6.1 retrieving revision 1.38.6.2 diff -C2 -d -r1.38.6.1 -r1.38.6.2 *** refcounts.dat 20 Feb 2002 05:08:02 -0000 1.38.6.1 --- refcounts.dat 14 Jun 2002 14:36:23 -0000 1.38.6.2 *************** *** 844,847 **** --- 844,857 ---- PyObject_Repr:PyObject*:o:0: + PyObject_RichCompare:PyObject*::+1: + PyObject_RichCompare:PyObject*:o1:0: + PyObject_RichCompare:PyObject*:o2:0: + PyObject_RichCompare:int:opid:: + + PyObject_RichCompareBool:int::: + PyObject_RichCompareBool:PyObject*:o1:0: + PyObject_RichCompareBool:PyObject*:o2:0: + PyObject_RichCompareBool:int:opid:: + PyObject_SetAttr:int::: PyObject_SetAttr:PyObject*:o:0: From andymac@bullseye.apana.org.au Fri Jun 14 12:19:09 2002 From: andymac@bullseye.apana.org.au (Andrew MacIntyre) Date: Fri, 14 Jun 2002 22:19:09 +1100 (edt) Subject: [Python-checkins] python/dist/src/Modules unicodedata.c,2.16,2.17 In-Reply-To: <3D088F22.50703@lemburg.com> Message-ID: On Thu, 13 Jun 2002, M.-A. Lemburg wrote: > Guido van Rossum wrote: > >>>Modified Files: > >>> unicodedata.c > >>>Log Message: > >>>_Py prefix is verboten for static entry points > >> > >>That's fine, but please mangle the names in a different way then, > >>since the _Py was added to avoid compiler problems on some > >>platform (don't remember which) where e.g. getname() is a system > >>API. > > > > > > Look carefully -- he called it _getucname. (Generally I don't think > > static function names should with an underscore though.) > > Even worse... that's not even allowed by ISO/ANSI C ;-) > > Seriously, I don't care what you name them, as long as they don't > stir up compiler noises. How about using "unicode_" as prefix ? The routine at the centre of this was originally called _getname() before the _Py prefix was added. There are also _gethash(), _cmpname() and _getcode() as well, all in a block prefaced with the comment /* database code (cut and pasted from the unidb package) */ There are other statics with a leading underscore in this file too. I note your name at the top of the file :-) I don't have any particular favourite convention for this sort of thing, although I was trying to maintain the pre-existing convention. However, going through the file I note that the prefix "unicodedata_" has been used for some of the other statics - this IMHO is probably slightly more fitting than "unicode_", no? This file also seems to be indented with a mixture of spaces and tabs, too. -- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: andymac@bullseye.apana.org.au | Snail: PO Box 370 andymac@pcug.org.au | Belconnen ACT 2616 Web: http://www.andymac.org/ | Australia From montanaro@users.sourceforge.net Fri Jun 14 21:30:33 2002 From: montanaro@users.sourceforge.net (montanaro@users.sourceforge.net) Date: Fri, 14 Jun 2002 13:30:33 -0700 Subject: [Python-checkins] python/dist/src/Modules dbmmodule.c,2.29,2.30 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv6862/Modules Modified Files: dbmmodule.c Log Message: This introduces stricter library/header file checking for the Berkeley DB library. Since multiple versions can be installed simultaneously, it's crucial that you only select libraries and header files which are compatible with each other. Version checking is done from highest version to lowest. Building using version 1 of Berkeley DB is disabled by default because of the hash file bugs people keep rediscovering. It can be enabled by uncommenting a few lines in setup.py. Closes patch 553108. Index: dbmmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/dbmmodule.c,v retrieving revision 2.29 retrieving revision 2.30 diff -C2 -d -r2.29 -r2.30 *** dbmmodule.c 3 Mar 2002 02:59:15 -0000 2.29 --- dbmmodule.c 14 Jun 2002 20:30:31 -0000 2.30 *************** *** 19,25 **** static char *which_dbm = "GNU gdbm"; /* EMX port of GDBM */ #endif - #elif defined(HAVE_DB1_NDBM_H) - #include - static char *which_dbm = "BSD db"; #elif defined(HAVE_GDBM_NDBM_H) #include --- 19,22 ---- From montanaro@users.sourceforge.net Fri Jun 14 21:30:33 2002 From: montanaro@users.sourceforge.net (montanaro@users.sourceforge.net) Date: Fri, 14 Jun 2002 13:30:33 -0700 Subject: [Python-checkins] python/dist/src README,1.146,1.147 configure,1.314,1.315 configure.in,1.324,1.325 pyconfig.h.in,1.41,1.42 setup.py,1.92,1.93 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv6862 Modified Files: README configure configure.in pyconfig.h.in setup.py Log Message: This introduces stricter library/header file checking for the Berkeley DB library. Since multiple versions can be installed simultaneously, it's crucial that you only select libraries and header files which are compatible with each other. Version checking is done from highest version to lowest. Building using version 1 of Berkeley DB is disabled by default because of the hash file bugs people keep rediscovering. It can be enabled by uncommenting a few lines in setup.py. Closes patch 553108. Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/README,v retrieving revision 1.146 retrieving revision 1.147 diff -C2 -d -r1.146 -r1.147 *** README 11 May 2002 03:36:26 -0000 1.146 --- README 14 Jun 2002 20:30:29 -0000 1.147 *************** *** 504,507 **** --- 504,547 ---- versions would be appreciated! + Configuring the bsddb and dbm modules + ------------------------------------- + + Configuring the bsddb module can sometimes be a bit tricky. This module + provides a Python interface to the Berkeley DB library. As of this writing + several versions of the underlying library are in common use (versions 1.85, + 2.x, 3.x, and 4.x). The file formats across the various versions tend to be + incompatible. Some Linux distributions install multiple versions by + default. It is important that compatible versions of header files and + libraries are used when building bsddb. To make matters worse, version 1.85 + of Berkeley DB has known bugs in its hash file implementation, but is still + the most widely available version of the library. Many people build bsddb + with version 1.85 but aren't aware of the bugs. This affects people using + the anydbm and dbhash modules because they are both use Berkeley DB's hash + file format as a side effect of calling bsddb.hashopen. + + To try and remedy this problem, beginning with Python version 2.3 a number + of changes to the bsddb build process were made. First, and most important, + the bsddb module will not be built with version 1.85 unless the relevant + lines in setup.py are uncommented first and no other higher-numbered + versions are found. Second, matching versions of the library and include + files must be found. Third, searching is performed in order, starting from + version 4 and proceeding to version 2 (or version 1 if it is enabled). + Version-independent libraries and header files (e.g. /usr/lib/libdb.a and + /usr/include/db.h) are never considered. They must be in version-specific + directories or have version-specific filenames (e.g. /usr/lib/libdb-3.2.so + and /usr/include/db3/db_185.h). + + Since the bsddb module is programmed using the Berkeley DB version 1 API, + the underlying library must be configured with the --enable-compat185 flag. + Most vendor-provided distributions are so-configured. This is generally + only an issue if you build Berkeley DB from source. + + All this affects the dbm module as well. There are several dbm-compliant + APIs provided by different libraries, including ndbm, gdbm and Berkeley DB. + The build process for dbm would previously use the version 1.85 library, + thus extending the potential hash file corruption to the dbm module as well. + The dbm module will use the library and include files found for the bsddb + module if neither ndbm nor gdbm libraries are found. + Configuring threads ------------------- Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.314 retrieving revision 1.315 diff -C2 -d -r1.314 -r1.315 *** configure 13 Jun 2002 21:08:49 -0000 1.314 --- configure 14 Jun 2002 20:30:29 -0000 1.315 *************** *** 1,4 **** #! /bin/sh ! # From configure.in Revision: 1.322 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.53. --- 1,4 ---- #! /bin/sh ! # From configure.in Revision: 1.323 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.53. *************** *** 3866,3879 **** - - - for ac_header in dlfcn.h fcntl.h grp.h limits.h langinfo.h \ libintl.h locale.h ncurses.h poll.h pthread.h \ signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h termios.h \ ! sys/audioio.h sys/file.h sys/lock.h sys/mkdev.h sys/modem.h db_185.h db.h \ sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \ sys/un.h sys/utsname.h sys/wait.h pty.h term.h libutil.h \ ! ndbm.h db1/ndbm.h gdbm/ndbm.h sys/resource.h netpacket/packet.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` --- 3866,3876 ---- for ac_header in dlfcn.h fcntl.h grp.h limits.h langinfo.h \ libintl.h locale.h ncurses.h poll.h pthread.h \ signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h termios.h \ ! sys/audioio.h sys/file.h sys/lock.h sys/mkdev.h sys/modem.h \ sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \ sys/un.h sys/utsname.h sys/wait.h pty.h term.h libutil.h \ ! ndbm.h gdbm/ndbm.h sys/resource.h netpacket/packet.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.324 retrieving revision 1.325 diff -C2 -d -r1.324 -r1.325 *** configure.in 13 Jun 2002 21:08:57 -0000 1.324 --- configure.in 14 Jun 2002 20:30:30 -0000 1.325 *************** *** 597,604 **** libintl.h locale.h ncurses.h poll.h pthread.h \ signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h termios.h \ ! sys/audioio.h sys/file.h sys/lock.h sys/mkdev.h sys/modem.h db_185.h db.h \ sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \ sys/un.h sys/utsname.h sys/wait.h pty.h term.h libutil.h \ ! ndbm.h db1/ndbm.h gdbm/ndbm.h sys/resource.h netpacket/packet.h) AC_HEADER_DIRENT --- 597,604 ---- libintl.h locale.h ncurses.h poll.h pthread.h \ signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h termios.h \ ! sys/audioio.h sys/file.h sys/lock.h sys/mkdev.h sys/modem.h \ sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \ sys/un.h sys/utsname.h sys/wait.h pty.h term.h libutil.h \ ! ndbm.h gdbm/ndbm.h sys/resource.h netpacket/packet.h) AC_HEADER_DIRENT Index: pyconfig.h.in =================================================================== RCS file: /cvsroot/python/python/dist/src/pyconfig.h.in,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** pyconfig.h.in 13 Jun 2002 21:09:00 -0000 1.41 --- pyconfig.h.in 14 Jun 2002 20:30:30 -0000 1.42 *************** *** 62,74 **** #undef HAVE_CTERMID_R - /* Define to 1 if you have the header file. */ - #undef HAVE_DB1_NDBM_H - - /* Define to 1 if you have the header file. */ - #undef HAVE_DB_185_H - - /* Define to 1 if you have the header file. */ - #undef HAVE_DB_H - /* Define to 1 if you have the header file, and it defines `DIR'. */ --- 62,65 ---- Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.92 retrieving revision 1.93 diff -C2 -d -r1.92 -r1.93 *** setup.py 13 Jun 2002 17:38:11 -0000 1.92 --- setup.py 14 Jun 2002 20:30:30 -0000 1.93 *************** *** 419,422 **** --- 419,527 ---- # similar functionality (but slower of course) implemented in Python. + # Berkeley DB interface. + # + # This requires the Berkeley DB code, see + # ftp://ftp.cs.berkeley.edu/pub/4bsd/db.1.85.tar.gz + # + # (See http://pybsddb.sourceforge.net/ for an interface to + # Berkeley DB 3.x.) + + # when sorted in reverse order, keys for this dict must appear in the + # order you wish to search - e.g., search for db3 before db2, db2 + # before db1 + db_try_this = { + 'db4': {'libs': ('db-4.3', 'db-4.2', 'db-4.1', 'db-4.0'), + 'libdirs': ('/usr/local/BerkeleyDB.4.3/lib', + '/usr/local/BerkeleyDB.4.2/lib', + '/usr/local/BerkeleyDB.4.1/lib', + '/usr/local/BerkeleyDB.4.0/lib', + '/usr/lib', + '/opt/sfw', + '/sw/lib', + '/lib', + ), + 'incdirs': ('/usr/local/BerkeleyDB.4.3/include', + '/usr/local/BerkeleyDB.4.2/include', + '/usr/local/BerkeleyDB.4.1/include', + '/usr/local/BerkeleyDB.4.0/include', + '/usr/include/db3', + '/opt/sfw/include/db3', + '/sw/include/db3', + '/usr/local/include/db3', + ), + 'incs': ('db_185.h',)}, + 'db3': {'libs': ('db-3.3', 'db-3.2', 'db-3.1', 'db-3.0'), + 'libdirs': ('/usr/local/BerkeleyDB.3.3/lib', + '/usr/local/BerkeleyDB.3.2/lib', + '/usr/local/BerkeleyDB.3.1/lib', + '/usr/local/BerkeleyDB.3.0/lib', + '/usr/lib', + '/opt/sfw', + '/sw/lib', + '/lib', + ), + 'incdirs': ('/usr/local/BerkeleyDB.3.3/include', + '/usr/local/BerkeleyDB.3.2/include', + '/usr/local/BerkeleyDB.3.1/include', + '/usr/local/BerkeleyDB.3.0/include', + '/usr/include/db3', + '/opt/sfw/include/db3', + '/sw/include/db3', + '/usr/local/include/db3', + ), + 'incs': ('db_185.h',)}, + 'db2': {'libs': ('db2',), + 'libdirs': ('/usr/lib', '/sw/lib', '/lib'), + 'incdirs': ('/usr/include/db2', + '/usr/local/include/db2', '/sw/include/db2'), + 'incs': ('db_185.h',)}, + # if you are willing to risk hash db file corruption you can + # uncomment the lines below for db1. Note that this will affect + # not only the bsddb module, but the dbhash and anydbm modules + # as well. you have been warned!!! + ##'db1': {'libs': ('db1', 'db'), + ## 'libdirs': ('/usr/lib', '/sw/lib', '/lib'), + ## 'incdirs': ('/usr/include/db1', '/usr/local/include/db1', + ## '/usr/include', '/usr/local/include'), + ## 'incs': ('db.h',)}, + } + + # override this list to affect the library version search order + # for example, if you want to force version 2 to be used: + # db_search_order = ["db2"] + db_search_order = db_try_this.keys() + db_search_order.sort() + db_search_order.reverse() + + find_lib_file = self.compiler.find_library_file + class found(Exception): pass + try: + for dbkey in db_search_order: + dbd = db_try_this[dbkey] + for dblib in dbd['libs']: + for dbinc in dbd['incs']: + db_incs = find_file(dbinc, [], dbd['incdirs']) + dblib_dir = find_lib_file(dbd['libdirs'], dblib) + if db_incs and dblib_dir: + dblib_dir = os.path.dirname(dblib_dir) + dblibs = [dblib] + raise found + except found: + if dbinc == 'db_185.h': + exts.append(Extension('bsddb', ['bsddbmodule.c'], + library_dirs=[dblib_dir], + include_dirs=db_incs, + define_macros=[('HAVE_DB_185_H',1)], + libraries=[dblib])) + else: + exts.append(Extension('bsddb', ['bsddbmodule.c'], + library_dirs=[dblib_dir], + include_dirs=db_incs, + libraries=[dblib])) + else: + db_incs = None + dblibs = [] + dblib_dir = None + # The standard Unix dbm module: if platform not in ['cygwin']: *************** *** 424,430 **** exts.append( Extension('dbm', ['dbmmodule.c'], libraries = ['ndbm'] ) ) ! elif self.compiler.find_library_file(lib_dirs, 'db1'): exts.append( Extension('dbm', ['dbmmodule.c'], ! libraries = ['db1'] ) ) else: exts.append( Extension('dbm', ['dbmmodule.c']) ) --- 529,540 ---- exts.append( Extension('dbm', ['dbmmodule.c'], libraries = ['ndbm'] ) ) ! elif self.compiler.find_library_file(lib_dirs, 'gdbm'): exts.append( Extension('dbm', ['dbmmodule.c'], ! libraries = ['gdbm'] ) ) ! elif db_incs is not None: ! exts.append( Extension('dbm', ['dbmmodule.c'], ! library_dirs=dblib_dir, ! include_dirs=db_incs, ! libraries=dblibs)) else: exts.append( Extension('dbm', ['dbmmodule.c']) ) *************** *** 434,475 **** exts.append( Extension('gdbm', ['gdbmmodule.c'], libraries = ['gdbm'] ) ) - - # Berkeley DB interface. - # - # This requires the Berkeley DB code, see - # ftp://ftp.cs.berkeley.edu/pub/4bsd/db.1.85.tar.gz - # - # Edit the variables DB and DBPORT to point to the db top directory - # and the subdirectory of PORT where you built it. - # - # (See http://pybsddb.sourceforge.net/ for an interface to - # Berkeley DB 3.x.) - - dblib = [] - if self.compiler.find_library_file(lib_dirs, 'db-3.2'): - dblib = ['db-3.2'] - elif self.compiler.find_library_file(lib_dirs, 'db-3.1'): - dblib = ['db-3.1'] - elif self.compiler.find_library_file(lib_dirs, 'db3'): - dblib = ['db3'] - elif self.compiler.find_library_file(lib_dirs, 'db2'): - dblib = ['db2'] - elif self.compiler.find_library_file(lib_dirs, 'db1'): - dblib = ['db1'] - elif self.compiler.find_library_file(lib_dirs, 'db'): - dblib = ['db'] - - db185_incs = find_file('db_185.h', inc_dirs, - ['/usr/include/db3', '/usr/include/db2']) - db_inc = find_file('db.h', inc_dirs, ['/usr/include/db1']) - if db185_incs is not None: - exts.append( Extension('bsddb', ['bsddbmodule.c'], - include_dirs = db185_incs, - define_macros=[('HAVE_DB_185_H',1)], - libraries = dblib ) ) - elif db_inc is not None: - exts.append( Extension('bsddb', ['bsddbmodule.c'], - include_dirs = db_inc, - libraries = dblib) ) # The mpz module interfaces to the GNU Multiple Precision library. --- 544,547 ---- From montanaro@users.sourceforge.net Fri Jun 14 21:30:33 2002 From: montanaro@users.sourceforge.net (montanaro@users.sourceforge.net) Date: Fri, 14 Jun 2002 13:30:33 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.427,1.428 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv6862/Misc Modified Files: NEWS Log Message: This introduces stricter library/header file checking for the Berkeley DB library. Since multiple versions can be installed simultaneously, it's crucial that you only select libraries and header files which are compatible with each other. Version checking is done from highest version to lowest. Building using version 1 of Berkeley DB is disabled by default because of the hash file bugs people keep rediscovering. It can be enabled by uncommenting a few lines in setup.py. Closes patch 553108. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.427 retrieving revision 1.428 diff -C2 -d -r1.427 -r1.428 *** NEWS 14 Jun 2002 00:50:42 -0000 1.427 --- NEWS 14 Jun 2002 20:30:31 -0000 1.428 *************** *** 277,280 **** --- 277,285 ---- well as Unix. + - The bsddb and dbm module builds have been changed to try and avoid version + skew problems and disable linkage with Berkeley DB 1.85 unless the + installer knows what s/he's doing. See the section on building these + modules in the README file for details. + C API From fredrik@pythonware.com Fri Jun 14 21:37:16 2002 From: fredrik@pythonware.com (Fredrik Lundh) Date: Fri, 14 Jun 2002 22:37:16 +0200 Subject: [Python-checkins] python/dist/src/Modules unicodedata.c,2.16,2.17 References: Message-ID: <02e101c213e3$4785cc10$ced241d5@hagrid> andrew wrote: > The routine at the centre of this was originally called _getname() before > the _Py prefix was added. There are also _gethash(), _cmpname() and > _getcode() as well, all in a block prefaced with the comment > > /* database code (cut and pasted from the unidb package) */ > > There are other statics with a leading underscore in this file too. > > I note your name at the top of the file :-) fwiw, I wrote that code (and the unidb package it's taken from) in my experience, simple names without underscores always conflicts with something on platforms that I don't have access to, while simple names with leading underscores never causes any problems... > I don't have any particular favourite convention for this sort of thing, > although I was trying to maintain the pre-existing convention. However, > going through the file I note that the prefix "unicodedata_" has been used > for some of the other statics - this IMHO is probably slightly more > fitting than "unicode_", no? I vote for "unicodedata_". From gvanrossum@users.sourceforge.net Fri Jun 14 21:41:18 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Fri, 14 Jun 2002 13:41:18 -0700 Subject: [Python-checkins] python/dist/src/PCbuild pythoncore.dsp,1.34,1.35 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory usw-pr-cvs1:/tmp/cvs-serv18223/PCbuild Modified Files: pythoncore.dsp Log Message: SF patch 568629 by Oren Tirosh: types made callable. These built-in functions are replaced by their (now callable) type: slice() buffer() and these types can also be called (but have no built-in named function named after them) classobj (type name used to be "class") code function instance instancemethod (type name used to be "instance method") The module "new" has been replaced with a small backward compatibility placeholder in Python. A large portion of the patch simply removes the new module from various platform-specific build recipes. The following binary Mac project files still have references to it: Mac/Build/PythonCore.mcp Mac/Build/PythonStandSmall.mcp Mac/Build/PythonStandalone.mcp [I've tweaked the code layout and the doc strings here and there, and added a comment to types.py about StringTypes vs. basestring. --Guido] Index: pythoncore.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pythoncore.dsp,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** pythoncore.dsp 26 Apr 2002 21:20:02 -0000 1.34 --- pythoncore.dsp 14 Jun 2002 20:41:16 -0000 1.35 *************** *** 1254,1272 **** # Begin Source File - SOURCE=..\Modules\newmodule.c - - !IF "$(CFG)" == "pythoncore - Win32 Release" - - !ELSEIF "$(CFG)" == "pythoncore - Win32 Debug" - - !ELSEIF "$(CFG)" == "pythoncore - Win32 Alpha Debug" - - !ELSEIF "$(CFG)" == "pythoncore - Win32 Alpha Release" - - !ENDIF - - # End Source File - # Begin Source File - SOURCE=..\Parser\node.c --- 1254,1257 ---- From gvanrossum@users.sourceforge.net Fri Jun 14 21:41:19 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Fri, 14 Jun 2002 13:41:19 -0700 Subject: [Python-checkins] python/dist/src/RISCOS Makefile,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/RISCOS In directory usw-pr-cvs1:/tmp/cvs-serv18223/RISCOS Modified Files: Makefile Log Message: SF patch 568629 by Oren Tirosh: types made callable. These built-in functions are replaced by their (now callable) type: slice() buffer() and these types can also be called (but have no built-in named function named after them) classobj (type name used to be "class") code function instance instancemethod (type name used to be "instance method") The module "new" has been replaced with a small backward compatibility placeholder in Python. A large portion of the patch simply removes the new module from various platform-specific build recipes. The following binary Mac project files still have references to it: Mac/Build/PythonCore.mcp Mac/Build/PythonStandSmall.mcp Mac/Build/PythonStandalone.mcp [I've tweaked the code layout and the doc strings here and there, and added a comment to types.py about StringTypes vs. basestring. --Guido] Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/RISCOS/Makefile,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Makefile 27 Oct 2001 21:16:16 -0000 1.4 --- Makefile 14 Jun 2002 20:41:17 -0000 1.5 *************** *** 265,271 **** $(MAKEDLK) -d @.^.Lib.md5/pyd -s s.linktab -o @.^.Modules.o.md5link -e initmd5 - @.^.Lib.new/pyd: @.^.Modules.o.newmodule s.linktab - $(MAKEDLK) -d @.^.Lib.new/pyd -s s.linktab -o @.^.Modules.o.newmodule -e initnew - @.^.Lib.operator/pyd: @.^.Modules.o.operator s.linktab $(MAKEDLK) -d @.^.Lib.operator/pyd -s s.linktab -o @.^.Modules.o.operator -e initoperator --- 265,268 ---- From gvanrossum@users.sourceforge.net Fri Jun 14 21:41:18 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Fri, 14 Jun 2002 13:41:18 -0700 Subject: [Python-checkins] python/dist/src/PC/os2vacpp makefile,1.6,1.7 makefile.omk,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/PC/os2vacpp In directory usw-pr-cvs1:/tmp/cvs-serv18223/PC/os2vacpp Modified Files: makefile makefile.omk Log Message: SF patch 568629 by Oren Tirosh: types made callable. These built-in functions are replaced by their (now callable) type: slice() buffer() and these types can also be called (but have no built-in named function named after them) classobj (type name used to be "class") code function instance instancemethod (type name used to be "instance method") The module "new" has been replaced with a small backward compatibility placeholder in Python. A large portion of the patch simply removes the new module from various platform-specific build recipes. The following binary Mac project files still have references to it: Mac/Build/PythonCore.mcp Mac/Build/PythonStandSmall.mcp Mac/Build/PythonStandalone.mcp [I've tweaked the code layout and the doc strings here and there, and added a comment to types.py about StringTypes vs. basestring. --Guido] Index: makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/os2vacpp/makefile,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** makefile 4 Dec 2001 03:18:47 -0000 1.6 --- makefile 14 Jun 2002 20:41:15 -0000 1.7 *************** *** 183,187 **** $(PATHOBJ)\MD5c.obj \ $(PATHOBJ)\MD5Module.obj \ - $(PATHOBJ)\NewModule.obj \ $(PATHOBJ)\Operator.obj \ $(PATHOBJ)\PCREModule.obj \ --- 183,186 ---- *************** *** 806,823 **** $(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \ $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h - - newmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \ - $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\compile.h $(PY_INCLUDE)\complexobject.h \ - pyconfig.h $(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h \ - $(PY_INCLUDE)\floatobject.h $(PY_INCLUDE)\funcobject.h $(PY_INCLUDE)\import.h \ - $(PY_INCLUDE)\intobject.h $(PY_INCLUDE)\intrcheck.h $(PY_INCLUDE)\listobject.h \ - $(PY_INCLUDE)\longobject.h $(PY_INCLUDE)\methodobject.h \ - $(PY_INCLUDE)\modsupport.h $(PY_INCLUDE)\moduleobject.h $(PY_INCLUDE)\mymalloc.h \ - $(PY_INCLUDE)\myproto.h $(PY_INCLUDE)\object.h $(PY_INCLUDE)\objimpl.h \ - $(PY_INCLUDE)\pydebug.h $(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h \ - $(PY_INCLUDE)\pystate.h $(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h \ - $(PY_INCLUDE)\rangeobject.h $(PY_INCLUDE)\sliceobject.h \ - $(PY_INCLUDE)\stringobject.h $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h \ - $(PY_INCLUDE)\tupleobject.h nismodule.obj: $(PY_INCLUDE)\abstract.h $(OS2TCPIP)\Include\sys\time.h $(PY_INCLUDE)\ceval.h \ --- 805,808 ---- Index: makefile.omk =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/os2vacpp/makefile.omk,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** makefile.omk 4 Dec 2001 03:18:48 -0000 1.3 --- makefile.omk 14 Jun 2002 20:41:16 -0000 1.4 *************** *** 153,157 **** MD5c.obj \ MD5Module.obj \ - NewModule.obj \ Operator.obj \ PosixModule.obj \ --- 153,156 ---- *************** *** 619,630 **** pyerrors.h pyfpe.h pystate.h python.h pythonrun.h rangeobject.h \ sliceobject.h stringobject.h sysmodule.h traceback.h tupleobject.h - - newmodule.obj: abstract.h ceval.h classobject.h cobject.h compile.h \ - complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \ - funcobject.h import.h intobject.h intrcheck.h listobject.h \ - longobject.h methodobject.h modsupport.h moduleobject.h mymalloc.h \ - myproto.h object.h objimpl.h pydebug.h pyerrors.h pyfpe.h \ - pystate.h python.h pythonrun.h rangeobject.h sliceobject.h \ - stringobject.h sysmodule.h traceback.h tupleobject.h nismodule.obj: abstract.h c:\mptn\include\sys\time.h ceval.h classobject.h \ --- 618,621 ---- From gvanrossum@users.sourceforge.net Fri Jun 14 21:41:19 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Fri, 14 Jun 2002 13:41:19 -0700 Subject: [Python-checkins] python/dist/src/Python bltinmodule.c,2.259,2.260 compile.c,2.245,2.246 dynload_aix.c,2.11,2.12 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv18223/Python Modified Files: bltinmodule.c compile.c dynload_aix.c Log Message: SF patch 568629 by Oren Tirosh: types made callable. These built-in functions are replaced by their (now callable) type: slice() buffer() and these types can also be called (but have no built-in named function named after them) classobj (type name used to be "class") code function instance instancemethod (type name used to be "instance method") The module "new" has been replaced with a small backward compatibility placeholder in Python. A large portion of the patch simply removes the new module from various platform-specific build recipes. The following binary Mac project files still have references to it: Mac/Build/PythonCore.mcp Mac/Build/PythonStandSmall.mcp Mac/Build/PythonStandalone.mcp [I've tweaked the code layout and the doc strings here and there, and added a comment to types.py about StringTypes vs. basestring. --Guido] Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.259 retrieving revision 2.260 diff -C2 -d -r2.259 -r2.260 *** bltinmodule.c 13 Jun 2002 20:33:02 -0000 2.259 --- bltinmodule.c 14 Jun 2002 20:41:16 -0000 2.260 *************** *** 108,132 **** static PyObject * - builtin_buffer(PyObject *self, PyObject *args) - { - PyObject *ob; - int offset = 0; - int size = Py_END_OF_BUFFER; - - if ( !PyArg_ParseTuple(args, "O|ii:buffer", &ob, &offset, &size) ) - return NULL; - return PyBuffer_FromObject(ob, offset, size); - } - - PyDoc_STRVAR(buffer_doc, - "buffer(object [, offset[, size]]) -> object\n\ - \n\ - Create a new buffer object which references the given object.\n\ - The buffer will reference a slice of the target object from the\n\ - start of the object (or at the specified offset). The slice will\n\ - extend to the end of the target object (or with the specified size)."); - - - static PyObject * builtin_callable(PyObject *self, PyObject *v) { --- 108,111 ---- *************** *** 1080,1108 **** static PyObject * - builtin_slice(PyObject *self, PyObject *args) - { - PyObject *start, *stop, *step; - - start = stop = step = NULL; - - if (!PyArg_ParseTuple(args, "O|OO:slice", &start, &stop, &step)) - return NULL; - - /* This swapping of stop and start is to maintain similarity with - range(). */ - if (stop == NULL) { - stop = start; - start = NULL; - } - return PySlice_New(start, stop, step); - } - - PyDoc_STRVAR(slice_doc, - "slice([start,] stop[, step]) -> slice object\n\ - \n\ - Create a slice object. This is used for slicing by the Numeric extensions."); - - - static PyObject * builtin_locals(PyObject *self) { --- 1059,1062 ---- *************** *** 1776,1780 **** {"abs", builtin_abs, METH_O, abs_doc}, {"apply", builtin_apply, METH_VARARGS, apply_doc}, - {"buffer", builtin_buffer, METH_VARARGS, buffer_doc}, {"callable", builtin_callable, METH_O, callable_doc}, {"chr", builtin_chr, METH_VARARGS, chr_doc}, --- 1730,1733 ---- *************** *** 1814,1818 **** {"round", builtin_round, METH_VARARGS, round_doc}, {"setattr", builtin_setattr, METH_VARARGS, setattr_doc}, - {"slice", builtin_slice, METH_VARARGS, slice_doc}, #ifdef Py_USING_UNICODE {"unichr", builtin_unichr, METH_VARARGS, unichr_doc}, --- 1767,1770 ---- *************** *** 1850,1853 **** --- 1802,1806 ---- SETBUILTIN("basestring", &PyBaseString_Type); SETBUILTIN("bool", &PyBool_Type); + SETBUILTIN("buffer", &PyBuffer_Type); SETBUILTIN("classmethod", &PyClassMethod_Type); #ifndef WITHOUT_COMPLEX *************** *** 1862,1865 **** --- 1815,1819 ---- SETBUILTIN("long", &PyLong_Type); SETBUILTIN("object", &PyBaseObject_Type); + SETBUILTIN("slice", &PySlice_Type); SETBUILTIN("staticmethod", &PyStaticMethod_Type); SETBUILTIN("str", &PyString_Type); Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.245 retrieving revision 2.246 diff -C2 -d -r2.245 -r2.246 *** compile.c 31 May 2002 14:08:29 -0000 2.245 --- compile.c 14 Jun 2002 20:41:16 -0000 2.246 *************** *** 92,95 **** --- 92,158 ---- }; + PyDoc_STRVAR(code_doc, + "code(argcount, nlocals, stacksize, flags, codestring, constants, names,\n\ + varnames, filename, name, firstlineno, lnotab[, freevars[, cellvars]])\n\ + \n\ + Create a code object. Not for the faint of heart."); + + static PyObject * + code_new(PyTypeObject *type, PyObject *args, PyObject *kw) + { + int argcount; + int nlocals; + int stacksize; + int flags; + PyObject *code; + PyObject *consts; + PyObject *names; + PyObject *varnames; + PyObject *freevars = NULL; + PyObject *cellvars = NULL; + PyObject *filename; + PyObject *name; + int firstlineno; + PyObject *lnotab; + + if (!PyArg_ParseTuple(args, "iiiiSO!O!O!SSiS|O!O!:code", + &argcount, &nlocals, &stacksize, &flags, + &code, + &PyTuple_Type, &consts, + &PyTuple_Type, &names, + &PyTuple_Type, &varnames, + &filename, &name, + &firstlineno, &lnotab, + &PyTuple_Type, &freevars, + &PyTuple_Type, &cellvars)) + return NULL; + + if (freevars == NULL || cellvars == NULL) { + PyObject *empty = PyTuple_New(0); + if (empty == NULL) + return NULL; + if (freevars == NULL) { + freevars = empty; + Py_INCREF(freevars); + } + if (cellvars == NULL) { + cellvars = empty; + Py_INCREF(cellvars); + } + Py_DECREF(empty); + } + + if (!PyObject_CheckReadBuffer(code)) { + PyErr_SetString(PyExc_TypeError, + "bytecode object must be a single-segment read-only buffer"); + return NULL; + } + + return (PyObject *)PyCode_New(argcount, nlocals, stacksize, flags, + code, consts, names, varnames, + freevars, cellvars, filename, name, + firstlineno, lnotab); + } + static void code_dealloc(PyCodeObject *co) *************** *** 201,205 **** 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ ! 0, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ --- 264,268 ---- 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ ! code_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ *************** *** 218,222 **** 0, /* tp_init */ 0, /* tp_alloc */ ! 0, /* tp_new */ }; --- 281,285 ---- 0, /* tp_init */ 0, /* tp_alloc */ ! code_new, /* tp_new */ }; Index: dynload_aix.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/dynload_aix.c,v retrieving revision 2.11 retrieving revision 2.12 diff -C2 -d -r2.11 -r2.12 *** dynload_aix.c 28 Nov 2001 21:35:49 -0000 2.11 --- dynload_aix.c 14 Jun 2002 20:41:16 -0000 2.12 *************** *** 105,121 **** } - static int - aix_bindnewmodule(void *newmoduleptr, void *modlistptr) - { - register ModulePtr modptr; - - /* - -- Bind the new module with the list of loaded modules. - */ - for (modptr = (ModulePtr)modlistptr; modptr; modptr = modptr->next) - if (loadbind(0, modptr->entry, newmoduleptr) != 0) - return -1; - return 0; - } static void --- 105,108 ---- *************** *** 190,197 **** p = (dl_funcptr) aix_load((char *)pathname, L_NOAUTODEFER, 0); if (p == NULL) { - aix_loaderror(pathname); - return NULL; - } - if (aix_bindnewmodule((void *)p, staticmodlistptr) == -1) { aix_loaderror(pathname); return NULL; --- 177,180 ---- From gvanrossum@users.sourceforge.net Fri Jun 14 21:41:18 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Fri, 14 Jun 2002 13:41:18 -0700 Subject: [Python-checkins] python/dist/src/Objects bufferobject.c,2.17,2.18 classobject.c,2.156,2.157 descrobject.c,2.26,2.27 funcobject.c,2.54,2.55 sliceobject.c,2.14,2.15 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv18223/Objects Modified Files: bufferobject.c classobject.c descrobject.c funcobject.c sliceobject.c Log Message: SF patch 568629 by Oren Tirosh: types made callable. These built-in functions are replaced by their (now callable) type: slice() buffer() and these types can also be called (but have no built-in named function named after them) classobj (type name used to be "class") code function instance instancemethod (type name used to be "instance method") The module "new" has been replaced with a small backward compatibility placeholder in Python. A large portion of the patch simply removes the new module from various platform-specific build recipes. The following binary Mac project files still have references to it: Mac/Build/PythonCore.mcp Mac/Build/PythonStandSmall.mcp Mac/Build/PythonStandalone.mcp [I've tweaked the code layout and the doc strings here and there, and added a comment to types.py about StringTypes vs. basestring. --Guido] Index: bufferobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/bufferobject.c,v retrieving revision 2.17 retrieving revision 2.18 diff -C2 -d -r2.17 -r2.18 *** bufferobject.c 29 Mar 2002 03:29:07 -0000 2.17 --- bufferobject.c 14 Jun 2002 20:41:14 -0000 2.18 *************** *** 156,159 **** --- 156,180 ---- /* Methods */ + static PyObject * + buffer_new(PyTypeObject *type, PyObject *args, PyObject *kw) + { + PyObject *ob; + int offset = 0; + int size = Py_END_OF_BUFFER; + + if ( !PyArg_ParseTuple(args, "O|ii:buffer", &ob, &offset, &size) ) + return NULL; + return PyBuffer_FromObject(ob, offset, size); + } + + PyDoc_STRVAR(buffer_doc, + "buffer(object [, offset[, size]])\n\ + \n\ + Create a new buffer object which references the given object.\n\ + The buffer will reference a slice of the target object from the\n\ + start of the object (or at the specified offset). The slice will\n\ + extend to the end of the target object (or with the specified size)."); + + static void buffer_dealloc(PyBufferObject *self) *************** *** 540,543 **** &buffer_as_buffer, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ ! 0, /* tp_doc */ }; --- 561,581 ---- &buffer_as_buffer, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ ! buffer_doc, /* tp_doc */ ! 0, /* tp_traverse */ ! 0, /* tp_clear */ ! 0, /* tp_richcompare */ ! 0, /* tp_weaklistoffset */ ! 0, /* tp_iter */ ! 0, /* tp_iternext */ ! 0, /* tp_methods */ ! 0, /* tp_members */ ! 0, /* tp_getset */ ! 0, /* tp_base */ ! 0, /* tp_dict */ ! 0, /* tp_descr_get */ ! 0, /* tp_descr_set */ ! 0, /* tp_dictoffset */ ! 0, /* tp_init */ ! 0, /* tp_alloc */ ! buffer_new, /* tp_new */ }; Index: classobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v retrieving revision 2.156 retrieving revision 2.157 diff -C2 -d -r2.156 -r2.157 *** classobject.c 13 Jun 2002 21:42:04 -0000 2.156 --- classobject.c 14 Jun 2002 20:41:14 -0000 2.157 *************** *** 150,153 **** --- 150,174 ---- } + PyDoc_STRVAR(class_doc, + "classobj(name, bases, dict)\n\ + \n\ + Create a class object. The name must be a string; the second argument\n\ + a tuple of classes, and the third a dictionary."); + + static PyObject * + new_class(PyObject* unused, PyObject* args) + { + PyObject *name; + PyObject *classes; + PyObject *dict; + + if (!PyArg_ParseTuple(args, "SO!O!:class", + &name, + &PyTuple_Type, &classes, + &PyDict_Type, &dict)) + return NULL; + return PyClass_New(classes, dict, name); + } + static PyObject * class_new(PyTypeObject *type, PyObject *args, PyObject *kwds) *************** *** 436,440 **** PyObject_HEAD_INIT(&PyType_Type) 0, ! "class", sizeof(PyClassObject), 0, --- 457,461 ---- PyObject_HEAD_INIT(&PyType_Type) 0, ! "classobj", sizeof(PyClassObject), 0, *************** *** 455,459 **** 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ ! 0, /* tp_doc */ (traverseproc)class_traverse, /* tp_traverse */ 0, /* tp_clear */ --- 476,480 ---- 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ ! class_doc, /* tp_doc */ (traverseproc)class_traverse, /* tp_traverse */ 0, /* tp_clear */ *************** *** 576,579 **** --- 597,628 ---- /* Instance methods */ + PyDoc_STRVAR(instance_doc, + "instance(class[, dict])\n\ + \n\ + Create an instance without calling its __init__() method.\n\ + The class must be a classic class.\n\ + If present, dict must be a dictionary or None."); + + static PyObject * + instance_new(PyTypeObject* type, PyObject* args, PyObject *kw) + { + PyObject *klass; + PyObject *dict = Py_None; + + if (!PyArg_ParseTuple(args, "O!|O:instance", + &PyClass_Type, &klass, &dict)) + return NULL; + + if (dict == Py_None) + dict = NULL; + else if (!PyDict_Check(dict)) { + PyErr_SetString(PyExc_TypeError, + "instance() second arg must be dictionary or None"); + return NULL; + } + return PyInstance_NewRaw(klass, dict); + } + + static void instance_dealloc(register PyInstanceObject *inst) *************** *** 2015,2019 **** 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES,/*tp_flags*/ ! 0, /* tp_doc */ (traverseproc)instance_traverse, /* tp_traverse */ 0, /* tp_clear */ --- 2064,2068 ---- 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES,/*tp_flags*/ ! instance_doc, /* tp_doc */ (traverseproc)instance_traverse, /* tp_traverse */ 0, /* tp_clear */ *************** *** 2022,2025 **** --- 2071,2085 ---- (getiterfunc)instance_getiter, /* tp_iter */ (iternextfunc)instance_iternext, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + instance_new, /* tp_new */ }; *************** *** 2126,2129 **** --- 2186,2214 ---- } + PyDoc_STRVAR(instancemethod_doc, + "instancemethod(function, instance, class)\n\ + \n\ + Create an instance method object."); + + static PyObject * + instancemethod_new(PyTypeObject* type, PyObject* args, PyObject *kw) + { + PyObject *func; + PyObject *self; + PyObject *classObj; + + if (!PyArg_ParseTuple(args, "OOO:instancemethod", + &func, &self, &classObj)) + return NULL; + if (!PyCallable_Check(func)) { + PyErr_SetString(PyExc_TypeError, + "first argument must be callable"); + return NULL; + } + if (self == Py_None) + self = NULL; + return PyMethod_New(func, self, classObj); + } + static void instancemethod_dealloc(register PyMethodObject *im) *************** *** 2363,2367 **** PyObject_HEAD_INIT(&PyType_Type) 0, ! "instance method", sizeof(PyMethodObject), 0, --- 2448,2452 ---- PyObject_HEAD_INIT(&PyType_Type) 0, ! "instancemethod", sizeof(PyMethodObject), 0, *************** *** 2382,2386 **** 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ ! 0, /* tp_doc */ (traverseproc)instancemethod_traverse, /* tp_traverse */ 0, /* tp_clear */ --- 2467,2471 ---- 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ ! instancemethod_doc, /* tp_doc */ (traverseproc)instancemethod_traverse, /* tp_traverse */ 0, /* tp_clear */ *************** *** 2397,2400 **** --- 2482,2488 ---- 0, /* tp_descr_set */ 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + instancemethod_new, /* tp_new */ }; Index: descrobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/descrobject.c,v retrieving revision 2.26 retrieving revision 2.27 diff -C2 -d -r2.26 -r2.27 *** descrobject.c 13 Jun 2002 20:32:56 -0000 2.26 --- descrobject.c 14 Jun 2002 20:41:15 -0000 2.27 *************** *** 726,730 **** PyObject_HEAD_INIT(&PyType_Type) 0, /* ob_size */ ! "dict-proxy", /* tp_name */ sizeof(proxyobject), /* tp_basicsize */ 0, /* tp_itemsize */ --- 726,730 ---- PyObject_HEAD_INIT(&PyType_Type) 0, /* ob_size */ ! "dictproxy", /* tp_name */ sizeof(proxyobject), /* tp_basicsize */ 0, /* tp_itemsize */ Index: funcobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/funcobject.c,v retrieving revision 2.54 retrieving revision 2.55 diff -C2 -d -r2.54 -r2.55 *** funcobject.c 13 Jun 2002 20:33:00 -0000 2.54 --- funcobject.c 14 Jun 2002 20:41:15 -0000 2.55 *************** *** 267,270 **** --- 267,316 ---- }; + PyDoc_STRVAR(func_doc, + "function(code, globals[, name[, argdefs]])\n\ + \n\ + Create a function object from a code object and a dictionary.\n\ + The optional name string overrides the name from the code object.\n\ + The optional argdefs tuple specifies the default argument values."); + + static PyObject * + func_new(PyTypeObject* type, PyObject* args, PyObject* kw) + { + PyObject *code; + PyObject *globals; + PyObject *name = Py_None; + PyObject *defaults = Py_None; + PyFunctionObject *newfunc; + + if (!PyArg_ParseTuple(args, "O!O!|OO!:function", + &PyCode_Type, &code, + &PyDict_Type, &globals, + &name, + &PyTuple_Type, &defaults)) + return NULL; + if (name != Py_None && !PyString_Check(name)) { + PyErr_SetString(PyExc_TypeError, + "arg 3 (name) must be None or string"); + return NULL; + } + + newfunc = (PyFunctionObject *)PyFunction_New(code, globals); + if (newfunc == NULL) + return NULL; + + if (name != Py_None) { + Py_XINCREF(name); + Py_XDECREF(newfunc->func_name); + newfunc->func_name = name; + } + if (defaults != Py_None) { + Py_XINCREF(defaults); + Py_XDECREF(newfunc->func_defaults); + newfunc->func_defaults = defaults; + } + + return (PyObject *)newfunc; + } + static void func_dealloc(PyFunctionObject *op) *************** *** 416,420 **** 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ ! 0, /* tp_doc */ (traverseproc)func_traverse, /* tp_traverse */ 0, /* tp_clear */ --- 462,466 ---- 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ ! func_doc, /* tp_doc */ (traverseproc)func_traverse, /* tp_traverse */ 0, /* tp_clear */ *************** *** 431,434 **** --- 477,483 ---- 0, /* tp_descr_set */ offsetof(PyFunctionObject, func_dict), /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + func_new, /* tp_new */ }; Index: sliceobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/sliceobject.c,v retrieving revision 2.14 retrieving revision 2.15 diff -C2 -d -r2.14 -r2.15 *** sliceobject.c 11 Jun 2002 13:38:42 -0000 2.14 --- sliceobject.c 14 Jun 2002 20:41:15 -0000 2.15 *************** *** 165,168 **** --- 165,192 ---- } + static PyObject * + slice_new(PyTypeObject *type, PyObject *args, PyObject *kw) + { + PyObject *start, *stop, *step; + + start = stop = step = NULL; + + if (!PyArg_ParseTuple(args, "O|OO:slice", &start, &stop, &step)) + return NULL; + + /* This swapping of stop and start is to maintain similarity with + range(). */ + if (stop == NULL) { + stop = start; + start = NULL; + } + return PySlice_New(start, stop, step); + } + + PyDoc_STRVAR(slice_doc, + "slice([start,] stop[, step])\n\ + \n\ + Create a slice object. This is used for extended slicing (e.g. a[0:10:2])."); + static void slice_dealloc(PySliceObject *r) *************** *** 241,245 **** 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ ! 0, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ --- 265,269 ---- 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ ! slice_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ *************** *** 253,255 **** --- 277,285 ---- 0, /* tp_base */ 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + slice_new, /* tp_new */ }; From gvanrossum@users.sourceforge.net Fri Jun 14 21:41:45 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Fri, 14 Jun 2002 13:41:45 -0700 Subject: [Python-checkins] python/dist/src/Lib types.py,1.28,1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv18223/Lib Modified Files: types.py Log Message: SF patch 568629 by Oren Tirosh: types made callable. These built-in functions are replaced by their (now callable) type: slice() buffer() and these types can also be called (but have no built-in named function named after them) classobj (type name used to be "class") code function instance instancemethod (type name used to be "instance method") The module "new" has been replaced with a small backward compatibility placeholder in Python. A large portion of the patch simply removes the new module from various platform-specific build recipes. The following binary Mac project files still have references to it: Mac/Build/PythonCore.mcp Mac/Build/PythonStandSmall.mcp Mac/Build/PythonStandalone.mcp [I've tweaked the code layout and the doc strings here and there, and added a comment to types.py about StringTypes vs. basestring. --Guido] Index: types.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/types.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** types.py 5 Jun 2002 23:12:44 -0000 1.28 --- types.py 14 Jun 2002 20:41:13 -0000 1.29 *************** *** 24,27 **** --- 24,31 ---- StringType = str + + # StringTypes is already outdated. Instead of writing "type(x) in + # types.StringTypes", you should use "isinstance(x, basestring)". But + # we keep around for compatibility with Python 2.2. try: UnicodeType = unicode *************** *** 30,34 **** StringTypes = (StringType,) ! BufferType = type(buffer('')) TupleType = tuple --- 34,38 ---- StringTypes = (StringType,) ! BufferType = buffer TupleType = tuple *************** *** 78,82 **** tb = None; del tb ! SliceType = type(slice(0)) EllipsisType = type(Ellipsis) --- 82,86 ---- tb = None; del tb ! SliceType = slice EllipsisType = type(Ellipsis) From gvanrossum@users.sourceforge.net Fri Jun 14 21:41:46 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Fri, 14 Jun 2002 13:41:46 -0700 Subject: [Python-checkins] python/dist/src/Mac/MPW Makefile,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/MPW In directory usw-pr-cvs1:/tmp/cvs-serv18223/Mac/MPW Modified Files: Makefile Log Message: SF patch 568629 by Oren Tirosh: types made callable. These built-in functions are replaced by their (now callable) type: slice() buffer() and these types can also be called (but have no built-in named function named after them) classobj (type name used to be "class") code function instance instancemethod (type name used to be "instance method") The module "new" has been replaced with a small backward compatibility placeholder in Python. A large portion of the patch simply removes the new module from various platform-specific build recipes. The following binary Mac project files still have references to it: Mac/Build/PythonCore.mcp Mac/Build/PythonStandSmall.mcp Mac/Build/PythonStandalone.mcp [I've tweaked the code layout and the doc strings here and there, and added a comment to types.py about StringTypes vs. basestring. --Guido] Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/MPW/Makefile,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Makefile 10 Mar 1995 15:12:23 -0000 1.7 --- Makefile 14 Jun 2002 20:41:13 -0000 1.8 *************** *** 78,82 **** "{Objs}"myreadline.c.o ¶ "{Objs}"mystrtoul.c.o ¶ - "{Objs}"newmodule.c.o ¶ "{Objs}"nfullpath.c.o ¶ "{Objs}"node.c.o ¶ --- 78,81 ---- *************** *** 473,479 **** "{Objs}"mathmodule.c.o Ä "{Top}"Modules:mathmodule.c {CC} "{Top}"Modules:mathmodule.c -o "{Objs}"mathmodule.c.o -s mathmodule.c {CFlags} - - "{Objs}"newmodule.c.o Ä "{Top}"Modules:newmodule.c - {CC} "{Top}"Modules:newmodule.c -o "{Objs}"newmodule.c.o -s newmodule.c {CFlags} "{Objs}"parsermodule.c.o Ä "{Top}"Modules:parsermodule.c --- 472,475 ---- From gvanrossum@users.sourceforge.net Fri Jun 14 21:41:45 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Fri, 14 Jun 2002 13:41:45 -0700 Subject: [Python-checkins] python/dist/src/Mac/Distributions dev.include,1.25,1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Distributions In directory usw-pr-cvs1:/tmp/cvs-serv18223/Mac/Distributions Modified Files: dev.include Log Message: SF patch 568629 by Oren Tirosh: types made callable. These built-in functions are replaced by their (now callable) type: slice() buffer() and these types can also be called (but have no built-in named function named after them) classobj (type name used to be "class") code function instance instancemethod (type name used to be "instance method") The module "new" has been replaced with a small backward compatibility placeholder in Python. A large portion of the patch simply removes the new module from various platform-specific build recipes. The following binary Mac project files still have references to it: Mac/Build/PythonCore.mcp Mac/Build/PythonStandSmall.mcp Mac/Build/PythonStandalone.mcp [I've tweaked the code layout and the doc strings here and there, and added a comment to types.py about StringTypes vs. basestring. --Guido] Index: dev.include =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Distributions/dev.include,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** dev.include 27 Dec 2001 23:01:17 -0000 1.25 --- dev.include 14 Jun 2002 20:41:13 -0000 1.26 *************** *** 502,506 **** (':Modules:mmapmodule.c', None) (':Modules:mpzmodule.c', None) - (':Modules:newmodule.c', None) (':Modules:nismodule.c', None) (':Modules:operator.c', None) --- 502,505 ---- From gvanrossum@users.sourceforge.net Fri Jun 14 21:41:46 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Fri, 14 Jun 2002 13:41:46 -0700 Subject: [Python-checkins] python/dist/src/Misc BeOS-setup.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv18223/Misc Modified Files: BeOS-setup.py Log Message: SF patch 568629 by Oren Tirosh: types made callable. These built-in functions are replaced by their (now callable) type: slice() buffer() and these types can also be called (but have no built-in named function named after them) classobj (type name used to be "class") code function instance instancemethod (type name used to be "instance method") The module "new" has been replaced with a small backward compatibility placeholder in Python. A large portion of the patch simply removes the new module from various platform-specific build recipes. The following binary Mac project files still have references to it: Mac/Build/PythonCore.mcp Mac/Build/PythonStandSmall.mcp Mac/Build/PythonStandalone.mcp [I've tweaked the code layout and the doc strings here and there, and added a comment to types.py about StringTypes vs. basestring. --Guido] Index: BeOS-setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/BeOS-setup.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BeOS-setup.py 4 Apr 2002 17:52:50 -0000 1.2 --- BeOS-setup.py 14 Jun 2002 20:41:14 -0000 1.3 *************** *** 233,240 **** exts.append( Extension('sha', ['shamodule.c']) ) - # Tommy Burnette's 'new' module (creates new empty objects of certain - # kinds): - exts.append( Extension('new', ['newmodule.c']) ) - # Helper module for various ascii-encoders exts.append( Extension('binascii', ['binascii.c']) ) --- 233,236 ---- From gvanrossum@users.sourceforge.net Fri Jun 14 21:41:46 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Fri, 14 Jun 2002 13:41:46 -0700 Subject: [Python-checkins] python/dist/src/Modules Setup.dist,1.27,1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv18223/Modules Modified Files: Setup.dist Log Message: SF patch 568629 by Oren Tirosh: types made callable. These built-in functions are replaced by their (now callable) type: slice() buffer() and these types can also be called (but have no built-in named function named after them) classobj (type name used to be "class") code function instance instancemethod (type name used to be "instance method") The module "new" has been replaced with a small backward compatibility placeholder in Python. A large portion of the patch simply removes the new module from various platform-specific build recipes. The following binary Mac project files still have references to it: Mac/Build/PythonCore.mcp Mac/Build/PythonStandSmall.mcp Mac/Build/PythonStandalone.mcp [I've tweaked the code layout and the doc strings here and there, and added a comment to types.py about StringTypes vs. basestring. --Guido] Index: Setup.dist =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Setup.dist,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** Setup.dist 19 Apr 2002 09:47:23 -0000 1.27 --- Setup.dist 14 Jun 2002 20:41:14 -0000 1.28 *************** *** 111,115 **** posix posixmodule.c # posix (UNIX) system calls _sre _sre.c # Fredrik Lundh's new regular expressions - new newmodule.c # Tommy Burnette's 'new' module # The rest of the modules listed in this file are all commented out by --- 111,114 ---- From guido@python.org Fri Jun 14 21:48:58 2002 From: guido@python.org (Guido van Rossum) Date: Fri, 14 Jun 2002 16:48:58 -0400 Subject: [Python-checkins] python/dist/src/Modules unicodedata.c,2.16,2.17 In-Reply-To: Your message of "Fri, 14 Jun 2002 22:37:16 +0200." <02e101c213e3$4785cc10$ced241d5@hagrid> References: <02e101c213e3$4785cc10$ced241d5@hagrid> Message-ID: <200206142048.g5EKmwC14089@pcp02138704pcs.reston01.va.comcast.net> > in my experience, simple names without underscores always conflicts > with something on platforms that I don't have access to, while simple > names with leading underscores never causes any problems... Unfortunately, that's exactly the opposite of what the C standardization committee wants you to do. > > I don't have any particular favourite convention for this sort of > > thing, although I was trying to maintain the pre-existing > > convention. However, going through the file I note that the > > prefix "unicodedata_" has been used for some of the other statics > > - this IMHO is probably slightly more fitting than "unicode_", no? > > I vote for "unicodedata_". Since this is only within one file, why not simly "uc_"? --Guido van Rossum (home page: http://www.python.org/~guido/) From gvanrossum@users.sourceforge.net Fri Jun 14 22:31:20 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Fri, 14 Jun 2002 14:31:20 -0700 Subject: [Python-checkins] python/dist/src/Misc ACKS,1.181,1.182 NEWS,1.428,1.429 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv1603 Modified Files: ACKS NEWS Log Message: Add Oren Tirosh and news about his patch. Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.181 retrieving revision 1.182 diff -C2 -d -r1.181 -r1.182 *** ACKS 11 Jun 2002 06:22:31 -0000 1.181 --- ACKS 14 Jun 2002 21:31:18 -0000 1.182 *************** *** 461,464 **** --- 461,465 ---- Eric Tiedemann Tracy Tims + Oren Tirosh Jason Tishler Christian Tismer Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.428 retrieving revision 1.429 diff -C2 -d -r1.428 -r1.429 *** NEWS 14 Jun 2002 20:30:31 -0000 1.428 --- NEWS 14 Jun 2002 21:31:18 -0000 1.429 *************** *** 7,10 **** --- 7,16 ---- Core and builtins + - The built-ins slice() and buffer() are now callable types. The + types classobj (formerly class), code, function, instance, and + instancemethod (formerly instance-method), which have no built-in + names but are accessible through the types module, are now also + callable. The type dict-proxy is renamed to dictproxy. + - Fixed string.startswith and string.endswith builtin methods so they accept negative indices. [SF bug 493951] *************** *** 113,116 **** --- 119,126 ---- Extension modules + + - The 'new' module is no longer an extension, but a Python module that + only exists for backwards compatibility. Its contents are no longer + functions but callable type objects. - The bsddb.*open functions can now take 'None' as a filename. From fredrik@pythonware.com Fri Jun 14 22:25:27 2002 From: fredrik@pythonware.com (Fredrik Lundh) Date: Fri, 14 Jun 2002 23:25:27 +0200 Subject: [Python-checkins] python/dist/src/Modules unicodedata.c,2.16,2.17 References: <02e101c213e3$4785cc10$ced241d5@hagrid> <200206142048.g5EKmwC14089@pcp02138704pcs.reston01.va.comcast.net> Message-ID: <009b01c213eb$7ea41500$ced241d5@hagrid> > > in my experience, simple names without underscores always conflicts > > with something on platforms that I don't have access to, while simple > > names with leading underscores never causes any problems... > > Unfortunately, that's exactly the opposite of what the C > standardization committee wants you to do. yup, but I'm more interested in things that work... > > > I don't have any particular favourite convention for this sort of > > > thing, although I was trying to maintain the pre-existing > > > convention. However, going through the file I note that the > > > prefix "unicodedata_" has been used for some of the other statics > > > - this IMHO is probably slightly more fitting than "unicode_", no? > > > > I vote for "unicodedata_". > > Since this is only within one file, why not simly "uc_"? uc_ is reserved by SUSv2, for use by signal.h and ucontext.h. Can we be sure that Python.h or any include file it uses won't ever include any of them? ;-) From tim_one@users.sourceforge.net Sat Jun 15 05:58:19 2002 From: tim_one@users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri, 14 Jun 2002 21:58:19 -0700 Subject: [Python-checkins] python/dist/src/PCbuild pythoncore.dsp,1.35,1.36 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory usw-pr-cvs1:/tmp/cvs-serv26511/python/PCbuild Modified Files: pythoncore.dsp Log Message: Unsure exactly why I'm doing this, but I couldn't build a debug-mode Python on Windows without it. Index: pythoncore.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pythoncore.dsp,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** pythoncore.dsp 14 Jun 2002 20:41:16 -0000 1.35 --- pythoncore.dsp 15 Jun 2002 04:58:17 -0000 1.36 *************** *** 1254,1257 **** --- 1254,1272 ---- # Begin Source File + SOURCE=..\Modules\newmodule.c + + !IF "$(CFG)" == "pythoncore - Win32 Release" + + !ELSEIF "$(CFG)" == "pythoncore - Win32 Debug" + + !ELSEIF "$(CFG)" == "pythoncore - Win32 Alpha Debug" + + !ELSEIF "$(CFG)" == "pythoncore - Win32 Alpha Release" + + !ENDIF + + # End Source File + # Begin Source File + SOURCE=..\Parser\node.c From tim_one@users.sourceforge.net Sat Jun 15 06:00:44 2002 From: tim_one@users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri, 14 Jun 2002 22:00:44 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_import.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv26922/python/Lib/test Modified Files: test_import.py Log Message: test_module_with_large_stack(): This failed on Windows, for the wrong reason : can't unlink an open file on Windows. Index: test_import.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_import.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** test_import.py 14 Jun 2002 01:07:39 -0000 1.12 --- test_import.py 15 Jun 2002 05:00:42 -0000 1.13 *************** *** 92,95 **** --- 92,96 ---- f = open(filename, 'r') py_compile.compile(filename) + f.close() os.unlink(filename) *************** *** 105,107 **** test_module_with_large_stack('longlist') - --- 106,107 ---- From tim_one@users.sourceforge.net Sat Jun 15 06:14:07 2002 From: tim_one@users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri, 14 Jun 2002 22:14:07 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_import.py,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv28734/python/Lib/test Modified Files: test_import.py Log Message: test_module_with_large_stack(): This failed when Python was run with -O, trying to delete a .pyc file that didn't exist (it needed to delete .pyo then). Index: test_import.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_import.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** test_import.py 15 Jun 2002 05:00:42 -0000 1.13 --- test_import.py 15 Jun 2002 05:14:05 -0000 1.14 *************** *** 89,93 **** f.close() ! # compile & remove .py file, we only need .pyc f = open(filename, 'r') py_compile.compile(filename) --- 89,93 ---- f.close() ! # compile & remove .py file, we only need .pyc (or .pyo) f = open(filename, 'r') py_compile.compile(filename) *************** *** 103,107 **** # cleanup del sys.path[-1] ! os.unlink(module + '.pyc') test_module_with_large_stack('longlist') --- 103,110 ---- # cleanup del sys.path[-1] ! for ext in '.pyc', '.pyo': ! fname = module + ext ! if os.path.exists(fname): ! os.unlink(fname) test_module_with_large_stack('longlist') From gvanrossum@users.sourceforge.net Sun Jun 16 02:22:15 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Sat, 15 Jun 2002 18:22:15 -0700 Subject: [Python-checkins] python/dist/src/Lib new.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv22869 Added Files: new.py Log Message: Forgot to add this. It's part of patch 568629. --- NEW FILE: new.py --- """Create new objects of various types. Deprecated. This module is no longer required except for backward compatibility. Objects of most types can now be created by calling the type object. """ from types import ClassType as classobj from types import FunctionType as function from types import InstanceType as instance from types import MethodType as instancemethod from types import ModuleType as module # CodeType is not accessible in restricted execution mode try: from types import CodeType as code except ImportError: pass From tim_one@users.sourceforge.net Sun Jun 16 02:34:51 2002 From: tim_one@users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sat, 15 Jun 2002 18:34:51 -0700 Subject: [Python-checkins] python/dist/src/Modules newmodule.c,2.39,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv24748/python/Modules Removed Files: newmodule.c Log Message: Removed newmodule.c from the project, and removed references to it from the Windowish builds. --- newmodule.c DELETED --- From tim_one@users.sourceforge.net Sun Jun 16 02:34:51 2002 From: tim_one@users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sat, 15 Jun 2002 18:34:51 -0700 Subject: [Python-checkins] python/dist/src/PC config.c,1.33,1.34 Message-ID: Update of /cvsroot/python/python/dist/src/PC In directory usw-pr-cvs1:/tmp/cvs-serv24748/python/PC Modified Files: config.c Log Message: Removed newmodule.c from the project, and removed references to it from the Windowish builds. Index: config.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/config.c,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** config.c 12 Oct 2001 22:08:39 -0000 1.33 --- config.c 16 Jun 2002 01:34:49 -0000 1.34 *************** *** 21,25 **** extern void initmath(void); extern void initmd5(void); - extern void initnew(void); extern void initnt(void); extern void initoperator(void); --- 21,24 ---- *************** *** 73,77 **** {"math", initmath}, {"md5", initmd5}, - {"new", initnew}, {"nt", initnt}, /* Use the NT os functions, not posix */ {"operator", initoperator}, --- 72,75 ---- From tim_one@users.sourceforge.net Sun Jun 16 02:34:51 2002 From: tim_one@users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sat, 15 Jun 2002 18:34:51 -0700 Subject: [Python-checkins] python/dist/src/PC/os2vacpp config.c,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/PC/os2vacpp In directory usw-pr-cvs1:/tmp/cvs-serv24748/python/PC/os2vacpp Modified Files: config.c Log Message: Removed newmodule.c from the project, and removed references to it from the Windowish builds. Index: config.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/os2vacpp/config.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** config.c 5 Nov 2001 02:45:58 -0000 1.7 --- config.c 16 Jun 2002 01:34:49 -0000 1.8 *************** *** 24,28 **** extern void initmath(void); extern void initmd5(void); - extern void initnew(void); extern void initnt(void); extern void initos2(void); --- 24,27 ---- From tim_one@users.sourceforge.net Sun Jun 16 02:34:51 2002 From: tim_one@users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sat, 15 Jun 2002 18:34:51 -0700 Subject: [Python-checkins] python/dist/src/PCbuild pythoncore.dsp,1.36,1.37 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory usw-pr-cvs1:/tmp/cvs-serv24748/python/PCbuild Modified Files: pythoncore.dsp Log Message: Removed newmodule.c from the project, and removed references to it from the Windowish builds. Index: pythoncore.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pythoncore.dsp,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** pythoncore.dsp 15 Jun 2002 04:58:17 -0000 1.36 --- pythoncore.dsp 16 Jun 2002 01:34:49 -0000 1.37 *************** *** 1254,1272 **** # Begin Source File - SOURCE=..\Modules\newmodule.c - - !IF "$(CFG)" == "pythoncore - Win32 Release" - - !ELSEIF "$(CFG)" == "pythoncore - Win32 Debug" - - !ELSEIF "$(CFG)" == "pythoncore - Win32 Alpha Debug" - - !ELSEIF "$(CFG)" == "pythoncore - Win32 Alpha Release" - - !ENDIF - - # End Source File - # Begin Source File - SOURCE=..\Parser\node.c --- 1254,1257 ---- From tim_one@users.sourceforge.net Sun Jun 16 02:37:39 2002 From: tim_one@users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sat, 15 Jun 2002 18:37:39 -0700 Subject: [Python-checkins] python/dist/src/PC/os2vacpp config.c,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/PC/os2vacpp In directory usw-pr-cvs1:/tmp/cvs-serv25408/python/PC/os2vacpp Modified Files: config.c Log Message: Nuked another reference to newmodule.c. Index: config.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/os2vacpp/config.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** config.c 16 Jun 2002 01:34:49 -0000 1.8 --- config.c 16 Jun 2002 01:37:36 -0000 1.9 *************** *** 62,66 **** {"math", initmath}, {"md5", initmd5}, - {"new", initnew}, #if defined(MS_WINDOWS) || defined(__BORLANDC__) || defined(__WATCOMC__) {"nt", initnt}, /* Use the NT os functions, not posix */ --- 62,65 ---- From pierslauder@users.sourceforge.net Mon Jun 17 08:06:27 2002 From: pierslauder@users.sourceforge.net (pierslauder@users.sourceforge.net) Date: Mon, 17 Jun 2002 00:06:27 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_imaplib.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv13277/dist/src/Lib/test Modified Files: test_imaplib.py Log Message: Alter text test arg to obey new rule, also include inverse test to make time-zone independant Index: test_imaplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_imaplib.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_imaplib.py 5 Jan 2002 17:12:57 -0000 1.2 --- test_imaplib.py 17 Jun 2002 07:06:24 -0000 1.3 *************** *** 2,12 **** import time - # We can check only that it successfully produces a result, - # not the correctness of the result itself, since the result - # depends on the timezone the machine is in. - timevalues = [2000000000, 2000000000.0, time.localtime(2000000000), ! "18-May-2033 05:33:20 +0200"] for t in timevalues: ! imaplib.Time2Internaldate(t) --- 2,11 ---- import time timevalues = [2000000000, 2000000000.0, time.localtime(2000000000), ! '"18-May-2033 05:33:20 +0200"', '"18-May-2033 13:33:20 +1000"'] ! ! check = timevalues[2] for t in timevalues: ! if check <> imaplib.Internaldate2tuple('INTERNALDATE ' + imaplib.Time2Internaldate(t)): ! print 'incorrect result when converting', `t` From pierslauder@users.sourceforge.net Mon Jun 17 08:07:22 2002 From: pierslauder@users.sourceforge.net (pierslauder@users.sourceforge.net) Date: Mon, 17 Jun 2002 00:07:22 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libimaplib.tex,1.19,1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv13513/dist/src/Doc/lib Modified Files: libimaplib.tex Log Message: Add IMAP4 QUOTA extension methods Index: libimaplib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libimaplib.tex,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** libimaplib.tex 8 Mar 2002 01:53:24 -0000 1.19 --- libimaplib.tex 17 Jun 2002 07:07:20 -0000 1.20 *************** *** 175,178 **** --- 175,188 ---- \end{methoddesc} + \begin{methoddesc}{getquota}{root} + Get the \samp{quota} \var{root}'s resource usage and limits. + This method is part of the IMAP4 QUOTA extension defined in rfc2087. + \end{methoddesc} + + \begin{methoddesc}{getquotaroot}{mailbox} + Get the list of \samp{quota} \samp{roots} for the named \var{mailbox}. + This method is part of the IMAP4 QUOTA extension defined in rfc2087. + \end{methoddesc} + \begin{methoddesc}{list}{\optional{directory\optional{, pattern}}} List mailbox names in \var{directory} matching *************** *** 205,209 **** Opens socket to \var{port} at \var{host}. The connection objects established by this method ! will be used in the \code{read}, \code{readline}, and \code{shutdown} methods. You may override this method. \end{methoddesc} --- 215,219 ---- Opens socket to \var{port} at \var{host}. The connection objects established by this method ! will be used in the \code{read}, \code{readline}, \code{send}, and \code{shutdown} methods. You may override this method. \end{methoddesc} *************** *** 264,270 **** --- 274,290 ---- \end{methoddesc} + \begin{methoddesc}{send}{data} + Sends \code{data} to the remote server. + You may override this method. + \end{methoddesc} + \begin{methoddesc}{setacl}{mailbox, who, what} Set an \samp{ACL} for \var{mailbox}. The method is non-standard, but is supported by the \samp{Cyrus} server. + \end{methoddesc} + + \begin{methoddesc}{setquota}{root, limits} + Set the \samp{quota} \var{root}'s resource \var{limits}. + This method is part of the IMAP4 QUOTA extension defined in rfc2087. \end{methoddesc} From pierslauder@users.sourceforge.net Mon Jun 17 08:07:23 2002 From: pierslauder@users.sourceforge.net (pierslauder@users.sourceforge.net) Date: Mon, 17 Jun 2002 00:07:23 -0700 Subject: [Python-checkins] python/dist/src/Lib imaplib.py,1.49,1.50 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv13513/dist/src/Lib Modified Files: imaplib.py Log Message: Add IMAP4 QUOTA extension methods Index: imaplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/imaplib.py,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** imaplib.py 5 Jun 2002 22:31:57 -0000 1.49 --- imaplib.py 17 Jun 2002 07:07:20 -0000 1.50 *************** *** 17,22 **** # GET/SETACL contributed by Anthony Baxter April 2001. # IMAP4_SSL contributed by Tino Lange March 2002. ! __version__ = "2.51" import binascii, re, socket, time, random, sys --- 17,23 ---- # GET/SETACL contributed by Anthony Baxter April 2001. # IMAP4_SSL contributed by Tino Lange March 2002. + # GET/SETQUOTA contributed by Andreas Zeidler June 2002. ! __version__ = "2.52" import binascii, re, socket, time, random, sys *************** *** 49,52 **** --- 50,55 ---- 'FETCH': ('SELECTED',), 'GETACL': ('AUTH', 'SELECTED'), + 'GETQUOTA': ('AUTH', 'SELECTED'), + 'GETQUOTAROOT': ('AUTH', 'SELECTED'), 'LIST': ('AUTH', 'SELECTED'), 'LOGIN': ('NONAUTH',), *************** *** 60,63 **** --- 63,67 ---- 'SELECT': ('AUTH', 'SELECTED'), 'SETACL': ('AUTH', 'SELECTED'), + 'SETQUOTA': ('AUTH', 'SELECTED'), 'SORT': ('SELECTED',), 'STATUS': ('AUTH', 'SELECTED'), *************** *** 417,420 **** --- 421,446 ---- + def getquota(self, root): + """Get the quota root's resource usage and limits. + + Part of the IMAP4 QUOTA extension defined in rfc2087. + + (typ, [data]) = .getquota(root) + """ + typ, dat = self._simple_command('GETQUOTA', root) + return self._untagged_response(typ, dat, 'QUOTA') + + + def getquotaroot(self, mailbox): + """Get the list of quota roots for the named mailbox. + + (typ, [[QUOTAROOT responses...], [QUOTA responses]]) = .getquotaroot(mailbox) + """ + typ, dat = self._simple_command('GETQUOTA', root) + typ, quota = self._untagged_response(typ, dat, 'QUOTA') + typ, quotaroot = self._untagged_response(typ, dat, 'QUOTAROOT') + return typ, [quotaroot, quota] + + def list(self, directory='""', pattern='*'): """List mailbox names in directory matching pattern. *************** *** 567,570 **** --- 593,605 ---- + def setquota(self, root, limits): + """Set the quota root's resource limits. + + (typ, [data]) = .setquota(root, limits) + """ + typ, dat = self._simple_command('SETQUOTA', root, limits) + return self._untagged_response(typ, dat, 'QUOTA') + + def sort(self, sort_criteria, charset, *search_criteria): """IMAP4rev1 extension SORT command. *************** *** 1187,1191 **** elif isinstance(date_time, (tuple, time.struct_time)): tt = date_time ! elif isinstance(date_time, str): return date_time # Assume in correct format else: --- 1222,1226 ---- elif isinstance(date_time, (tuple, time.struct_time)): tt = date_time ! elif isinstance(date_time, str) and (date_time[0],date_time[-1]) == ('"','"'): return date_time # Assume in correct format else: From doerwalter@users.sourceforge.net Mon Jun 17 11:44:07 2002 From: doerwalter@users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Mon, 17 Jun 2002 03:44:07 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.429,1.430 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv5793/Misc Modified Files: NEWS Log Message: Apply diff2.txt from SF patch http://www.python.org/sf/566999 This patch enhances Python/import.c/find_module() so that unicode objects found in sys.path will be treated as legal directory names (The current code ignores anything that is not a str). The unicode name is converted to str using Py_FileSystemDefaultEncoding. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.429 retrieving revision 1.430 diff -C2 -d -r1.429 -r1.430 *** NEWS 14 Jun 2002 21:31:18 -0000 1.429 --- NEWS 17 Jun 2002 10:43:57 -0000 1.430 *************** *** 7,10 **** --- 7,13 ---- Core and builtins + - Unicode objects in sys.path are no longer ignored but treated + as directory names. + - The built-ins slice() and buffer() are now callable types. The types classobj (formerly class), code, function, instance, and From doerwalter@users.sourceforge.net Mon Jun 17 11:44:07 2002 From: doerwalter@users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Mon, 17 Jun 2002 03:44:07 -0700 Subject: [Python-checkins] python/dist/src/Python import.c,2.206,2.207 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv5793/Python Modified Files: import.c Log Message: Apply diff2.txt from SF patch http://www.python.org/sf/566999 This patch enhances Python/import.c/find_module() so that unicode objects found in sys.path will be treated as legal directory names (The current code ignores anything that is not a str). The unicode name is converted to str using Py_FileSystemDefaultEncoding. Index: import.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/import.c,v retrieving revision 2.206 retrieving revision 2.207 diff -C2 -d -r2.206 -r2.207 *** import.c 14 Jun 2002 01:07:39 -0000 2.206 --- import.c 17 Jun 2002 10:43:59 -0000 2.207 *************** *** 970,982 **** namelen = strlen(name); for (i = 0; i < npath; i++) { PyObject *v = PyList_GetItem(path, i); if (!PyString_Check(v)) continue; len = PyString_Size(v); ! if (len + 2 + namelen + MAXSUFFIXSIZE >= buflen) continue; /* Too long */ strcpy(buf, PyString_AsString(v)); ! if (strlen(buf) != len) continue; /* v contains '\0' */ #ifdef macintosh /* --- 970,997 ---- namelen = strlen(name); for (i = 0; i < npath; i++) { + PyObject *copy = NULL; PyObject *v = PyList_GetItem(path, i); + #ifdef Py_USING_UNICODE + if (PyUnicode_Check(v)) { + copy = PyUnicode_Encode(PyUnicode_AS_UNICODE(v), + PyUnicode_GET_SIZE(v), Py_FileSystemDefaultEncoding, NULL); + if (copy == NULL) + return NULL; + v = copy; + } + else + #endif if (!PyString_Check(v)) continue; len = PyString_Size(v); ! if (len + 2 + namelen + MAXSUFFIXSIZE >= buflen) { ! Py_XDECREF(copy); continue; /* Too long */ + } strcpy(buf, PyString_AsString(v)); ! if (strlen(buf) != len) { ! Py_XDECREF(copy); continue; /* v contains '\0' */ + } #ifdef macintosh /* *************** *** 992,995 **** --- 1007,1011 ---- {"", "", PY_RESOURCE}; + Py_XDECREF(copy); return &resfiledescr; } *************** *** 998,1001 **** --- 1014,1018 ---- {"", "", PY_CODERESOURCE}; + Py_XDECREF(copy); return &resfiledescr; } *************** *** 1013,1021 **** and there's an __init__ module in that directory */ #ifdef HAVE_STAT ! if (stat(buf, &statbuf) == 0 && /* it exists */ ! S_ISDIR(statbuf.st_mode) && /* it's a directory */ ! find_init_module(buf) && /* it has __init__.py */ ! case_ok(buf, len, namelen, name)) /* and case matches */ return &fd_package; #else /* XXX How are you going to test for directories? */ --- 1030,1040 ---- and there's an __init__ module in that directory */ #ifdef HAVE_STAT ! if (stat(buf, &statbuf) == 0 && /* it exists */ ! S_ISDIR(statbuf.st_mode) && /* it's a directory */ ! find_init_module(buf) && /* it has __init__.py */ ! case_ok(buf, len, namelen, name)) { /* and case matches */ ! Py_XDECREF(copy); return &fd_package; + } #else /* XXX How are you going to test for directories? */ *************** *** 1023,1028 **** if (isdir(buf) && find_init_module(buf) && ! case_ok(buf, len, namelen, name)) return &fd_package; #endif #endif --- 1042,1049 ---- if (isdir(buf) && find_init_module(buf) && ! case_ok(buf, len, namelen, name)) { ! Py_XDECREF(copy); return &fd_package; + } #endif #endif *************** *** 1096,1099 **** --- 1117,1121 ---- } #endif + Py_XDECREF(copy); if (fp != NULL) break; From rhettinger@users.sourceforge.net Mon Jun 17 13:00:25 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon, 17 Jun 2002 05:00:25 -0700 Subject: [Python-checkins] python/nondist/peps pep-0290.txt,NONE,1.1 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv26376 Added Files: pep-0290.txt Log Message: Initial draft from discussions on py-dev. --- NEW FILE: pep-0290.txt --- PEP: 290 Title: Code Migration and Modernization Version: $Revision: 1.1 $ Last-Modified: $Date: 2002/06/17 12:00:22 $ Author: python@rcn.com (Raymond D. Hettinger) Status: Active Type: Informational Created: 6-Jun-2002 Post-History: Abstract This PEP is a collection of procedures and ideas for updating Python applications when newer versions of Python are installed. The migration tips highlight possible areas of incompatibility and make suggestions on how to find and resolve those differences. The modernization procedures show how older code can be updated to take advantage of new language features. Rationale This repository of procedures serves as a catalog or checklist of known migration issues and procedures for addressing those issues. Migration issues can arise for several reasons. Some obsolete features are slowly deprecated according to the guidelines in PEP 4. Also, some code relies on undocumented behaviors which are subject to change between versions. Some code may rely on behavior which was subsequently shown to be a bug and that behavior changes when the bug is fixed. Modernization options arise when new versions of Python add features that allow improved clarity or higher performance than previously available. Guidelines for New Entries Developers with commit access may update the PEP directly. Others can send their ideas to a developer for possible inclusion. While a consistent format makes the repository easier to use, feel free to add or subtract sections to improve clarity. Grep patterns may be supplied as tool to help maintainers locate code for possible updates. However, fully automated search/replace style regular expressions are not recommended. Instead, each code fragment should be evaluated individually. The contra-indications section is the most important part of a new entry. It lists known situations where the update SHOULD NOT be applied. Modernization Procedures Pattern: if d.has_key(k): --> if k in d: Idea: For testing dictionary membership, use the 'in' keyword instead of the 'has_key()' method. Version: 2.2 or greater Benefits: The result is shorter and more readable. The style becomes consistent with tests for membership in lists. The result is slightly faster because has_key requires an attribute search and uses a relatively expensive CALL FUNCTION op code. Locating: grep has_key Contra-indications: 1. if dictlike.has_key(k) ## objects like shelve do not define __contains__() Pattern: for k in d.keys() --> for k in d for k in d.items() --> for k in d.iteritems() for k in d.values() --> for k in d.itervalues() Idea: Use the new iter methods for looping over dictionaries Version: 2.2 or greater Benefits: The iter methods are faster because the do not have to create a new list object with a complete copy of all of the keys, values, or items. Selecting only keys, items, or values as needed saves the time for creating throwaway object references and, in the case of items, saves a second hash look-up of the key. Contra-indications: 1. def getids(): return d.keys() ## do not change the return type 2. for k in dictlike.keys() ## objects like shelve do not define itermethods 3. k = d.keys(); j = k[:] ## iterators do not support slicing, sorting or other operations 4. for k in d.keys(): del[k] ## dict iterators prohibit modifying the dictionary Pattern: if v == None --> if v is None: if v != None --> if v is not None: Idea: Since there is only one None object, equality can be tested with identity. Version: All Benefits: Identity tests are slightly faster than equality tests. Also, some object types may overload comparison to be much slower. Locating: grep '== None' or grep '!= None' Pattern: os.stat("foo")[stat.ST_MTIME] --> os.stat("foo").st_mtime os.stat("foo")[stat.ST_MTIME] --> os.path.getmtime("foo") Idea: Replace stat contants or indices with new stat methods Version: 2.2 or greater Benefits: The methods are not order dependent and do not require an import of the stat module Locating: grep os.stat Pattern: import whrandom --> import random Idea: Replace deprecated module Version: 2.1 or greater Benefits: All random methods collected in one place Locating: grep whrandom Pattern: import types ; type(v, types.IntType) --> isinstance(v, int) type(s, types.StringTypes --> isinstance(s, basestring) Idea: The types module will likely to be deprecated in the future. Version: 2.2 or greater Benefits: May be slightly faster, avoid a deprecated feature. Locating: grep types *.py | grep import Pattern: import string ; string.method(s, ...) --> s.method(...) c in string.whitespace --> c.isspace() Idea: The string module will likely to be deprecated in the future. Version: 2.0 or greater Benefits: Slightly faster, avoid a deprecated feature. Locating: grep string *.py | grep import Pattern: NewError = 'NewError' --> class NewError(Exception): pass Idea: String exceptions are deprecated, derive from the Exception base class. Version: Any Benefits: Unlike the obsolete string exceptions, class exceptions all derive from another exception or the Exception base class. This allows meaningful groupings of exceptions. It also allows an "except Exception" clause to catch all exceptions. Locating: Use PyChecker Pattern: "foobar"[:3] == "foo" -> "foobar".startswith("foo") "foobar"[-3:] == "bar" -> "foobar".endswith("bar") Version: 2.0 or greater Benefits: Faster because no slice has to be created. Less risk of miscounting. References [1] PEP 4, Deprecation of Standard Modules http://www.python.org/peps/pep-0004.html Copyright This document has been placed in the public domain. Local Variables: mode: indented-text indent-tabs-mode: nil sentence-end-double-space: t fill-column: 70 End: From rhettinger@users.sourceforge.net Mon Jun 17 13:01:51 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon, 17 Jun 2002 05:01:51 -0700 Subject: [Python-checkins] python/nondist/peps pep-0290.html,NONE,1.1 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv26800 Added Files: pep-0290.html Log Message: Initial draft from discussions on py-dev. --- NEW FILE: pep-0290.html --- PEP 290 -- Code Migration and Modernization
PEP: 290
Title: Code Migration and Modernization
Version: $Revision: 1.1 $
Last-Modified: $Date: 2002/06/17 12:01:48 $
Author: python at rcn.com (Raymond D. Hettinger)
Status: Active
Type: Informational
Created: 6-Jun-2002
Post-History: 

Abstract

    This PEP is a collection of procedures and ideas for updating
    Python applications when newer versions of Python are installed.

    The migration tips highlight possible areas of incompatibility and
    make suggestions on how to find and resolve those differences. The
    modernization procedures show how older code can be updated to
    take advantage of new language features.


Rationale

    This repository of procedures serves as a catalog or checklist of
    known migration issues and procedures for addressing those issues.

    Migration issues can arise for several reasons.  Some obsolete
    features are slowly deprecated according to the guidelines in PEP 4.
    Also, some code relies on undocumented behaviors which are subject to
    change between versions.  Some code may rely on behavior which was
    subsequently shown to be a bug and that behavior changes when the bug
    is fixed.

    Modernization options arise when new versions of Python add features
    that allow improved clarity or higher performance than previously
    available.



Guidelines for New Entries

    Developers with commit access may update the PEP directly.  Others
    can send their ideas to a developer for possible inclusion.

    While a consistent format makes the repository easier to use, feel
    free to add or subtract sections to improve clarity.

    Grep patterns may be supplied as tool to help maintainers locate
    code for possible updates.  However, fully automated search/replace
    style regular expressions are not recommended.  Instead, each code
    fragment should be evaluated individually.

    The contra-indications section is the most important part of a new
    entry.  It lists known situations where the update SHOULD NOT be
    applied.


Modernization Procedures

    Pattern:    if d.has_key(k):  --> if k in d:
    Idea:       For testing dictionary membership, use the 'in' keyword
                instead of the 'has_key()' method.
    Version:    2.2 or greater
    Benefits:   The result is shorter and more readable. The style becomes
                consistent with tests for membership in lists.  The result is
                slightly faster because has_key requires an attribute search
                and uses a relatively expensive CALL FUNCTION op code.
    Locating:   grep has_key
    Contra-indications:
        1.  if dictlike.has_key(k) ## objects like shelve do not define
            __contains__()


    Pattern:    for k in d.keys()  -->  for k in d
                for k in d.items() --> for k in d.iteritems()
                for k in d.values() -->  for k in d.itervalues()
    Idea:       Use the new iter methods for looping over dictionaries
    Version:    2.2 or greater
    Benefits:   The iter methods are faster because the do not have to create
                a new list object with a complete copy of all of the keys,
                values, or items. Selecting only keys, items, or values as
                needed saves the time for creating throwaway object references
                and, in the case of items, saves a second hash look-up of
                the key.
    Contra-indications:
        1.  def getids():  return d.keys()  ## do not change the return type
        2.  for k in dictlike.keys() ## objects like shelve do not define
            itermethods
        3.  k = d.keys(); j = k[:]   ## iterators do not support slicing,
            sorting or other operations
        4.  for k in d.keys(): del[k] ## dict iterators prohibit modifying the
            dictionary


    Pattern:    if v == None  -->  if v is None:
                if v != None  -->  if v is not None:
    Idea:       Since there is only one None object, equality can be tested
                with identity.
    Version:    All
    Benefits:   Identity tests are slightly faster than equality tests. Also,
                some object types may overload comparison to be much slower.
    Locating:   grep '== None' or grep '!= None'


    Pattern:    os.stat("foo")[stat.ST_MTIME] --> os.stat("foo").st_mtime
                    os.stat("foo")[stat.ST_MTIME] --> os.path.getmtime("foo")
    Idea:       Replace stat contants or indices with new stat methods
    Version:    2.2 or greater
    Benefits:   The methods are not order dependent and do not require an
                import of the stat module
    Locating:   grep os.stat


    Pattern:    import whrandom --> import random
    Idea:       Replace deprecated module
    Version:    2.1 or greater
    Benefits:   All random methods collected in one place
    Locating:   grep whrandom


    Pattern:    import types ; type(v, types.IntType)  -->  isinstance(v, int)
                type(s, types.StringTypes --> isinstance(s, basestring)
    Idea:       The types module will likely to be deprecated in the future.
    Version:    2.2 or greater
    Benefits:   May be slightly faster, avoid a deprecated feature.
    Locating:   grep types *.py | grep import


    Pattern:    import string ; string.method(s, ...)  -->  s.method(...)
                c in string.whitespace --> c.isspace()
    Idea:       The string module will likely to be deprecated in the future.
    Version:    2.0 or greater
    Benefits:   Slightly faster, avoid a deprecated feature.
    Locating:   grep string *.py | grep import


    Pattern:    NewError = 'NewError' --> class NewError(Exception): pass
    Idea:       String exceptions are deprecated, derive from the Exception
                base class.
    Version:    Any
    Benefits:   Unlike the obsolete string exceptions, class exceptions all
                derive from another exception or the Exception base class.
                This allows meaningful groupings of exceptions.  It also
                allows an "except Exception" clause to catch all exceptions.
    Locating:   Use PyChecker

    Pattern:    "foobar"[:3] == "foo" -> "foobar".startswith("foo")
                "foobar"[-3:] == "bar" -> "foobar".endswith("bar")
    Version:    2.0 or greater
    Benefits:   Faster because no slice has to be created.  Less risk of
                miscounting.


References

    [1] PEP 4, Deprecation of Standard Modules
        http://www.python.org/peps/pep-0004.html



Copyright

    This document has been placed in the public domain.



From rhettinger@users.sourceforge.net Mon Jun 17 13:03:25 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon, 17 Jun 2002 05:03:25 -0700 Subject: [Python-checkins] python/nondist/peps pep-0000.txt,1.185,1.186 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv27237 Modified Files: pep-0000.txt Log Message: Added Pep 290 Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.185 retrieving revision 1.186 diff -C2 -d -r1.185 -r1.186 *** pep-0000.txt 6 Jun 2002 19:25:31 -0000 1.185 --- pep-0000.txt 17 Jun 2002 12:03:22 -0000 1.186 *************** *** 49,52 **** --- 49,53 ---- IF 249 Python Database API Specification v2.0 Lemburg IF 272 API for Block Encryption Algorithms v1.0 Kuchling + I 290 Code Migration and Modernization Hettinger Accepted PEPs (accepted; may not be implemented yet) *************** *** 269,272 **** --- 270,274 ---- SD 288 Generators Attributes and Exceptions Hettinger SR 289 Generator Comprehensions Hettinger + I 290 Code Migration and Modernization Hettinger I 291 Backward Compatibility for Standard Library Norwitz SR 666 Reject Foolish Indentation Creighton From nnorwitz@users.sourceforge.net Mon Jun 17 13:43:23 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Mon, 17 Jun 2002 05:43:23 -0700 Subject: [Python-checkins] python/dist/src/Lib imaplib.py,1.50,1.51 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv5546/Lib Modified Files: imaplib.py Log Message: Whitespace normalization (tabs -> spaces) Index: imaplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/imaplib.py,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** imaplib.py 17 Jun 2002 07:07:20 -0000 1.50 --- imaplib.py 17 Jun 2002 12:43:20 -0000 1.51 *************** *** 424,431 **** """Get the quota root's resource usage and limits. ! Part of the IMAP4 QUOTA extension defined in rfc2087. (typ, [data]) = .getquota(root) ! """ typ, dat = self._simple_command('GETQUOTA', root) return self._untagged_response(typ, dat, 'QUOTA') --- 424,431 ---- """Get the quota root's resource usage and limits. ! Part of the IMAP4 QUOTA extension defined in rfc2087. (typ, [data]) = .getquota(root) ! """ typ, dat = self._simple_command('GETQUOTA', root) return self._untagged_response(typ, dat, 'QUOTA') *************** *** 436,444 **** (typ, [[QUOTAROOT responses...], [QUOTA responses]]) = .getquotaroot(mailbox) ! """ typ, dat = self._simple_command('GETQUOTA', root) typ, quota = self._untagged_response(typ, dat, 'QUOTA') typ, quotaroot = self._untagged_response(typ, dat, 'QUOTAROOT') ! return typ, [quotaroot, quota] --- 436,444 ---- (typ, [[QUOTAROOT responses...], [QUOTA responses]]) = .getquotaroot(mailbox) ! """ typ, dat = self._simple_command('GETQUOTA', root) typ, quota = self._untagged_response(typ, dat, 'QUOTA') typ, quotaroot = self._untagged_response(typ, dat, 'QUOTAROOT') ! return typ, [quotaroot, quota] *************** *** 597,601 **** (typ, [data]) = .setquota(root, limits) ! """ typ, dat = self._simple_command('SETQUOTA', root, limits) return self._untagged_response(typ, dat, 'QUOTA') --- 597,601 ---- (typ, [data]) = .setquota(root, limits) ! """ typ, dat = self._simple_command('SETQUOTA', root, limits) return self._untagged_response(typ, dat, 'QUOTA') From mwh@users.sourceforge.net Mon Jun 17 13:51:59 2002 From: mwh@users.sourceforge.net (mwh@users.sourceforge.net) Date: Mon, 17 Jun 2002 05:51:59 -0700 Subject: [Python-checkins] python/dist/src/Doc/ref ref6.tex,1.52,1.53 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv8241 Modified Files: ref6.tex Log Message: Typo. Index: ref6.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref6.tex,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** ref6.tex 1 Apr 2002 21:25:32 -0000 1.52 --- ref6.tex 17 Jun 2002 12:51:57 -0000 1.53 *************** *** 347,351 **** It is illegal to delete a name from the local namespace if it occurs ! as a free variable\indexii{free}{varaible} in a nested block. Deletion of attribute references, subscriptions and slicings --- 347,351 ---- It is illegal to delete a name from the local namespace if it occurs ! as a free variable\indexii{free}{variable} in a nested block. Deletion of attribute references, subscriptions and slicings From gvanrossum@users.sourceforge.net Mon Jun 17 13:59:30 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Mon, 17 Jun 2002 05:59:30 -0700 Subject: [Python-checkins] python/nondist/peps pep-0290.html,1.1,NONE Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv10214 Removed Files: pep-0290.html Log Message: We don't check in the HTML, only the text version. --- pep-0290.html DELETED --- From akuchling@users.sourceforge.net Mon Jun 17 14:40:07 2002 From: akuchling@users.sourceforge.net (akuchling@users.sourceforge.net) Date: Mon, 17 Jun 2002 06:40:07 -0700 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew23.tex,1.25,1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory usw-pr-cvs1:/tmp/cvs-serv26831 Modified Files: whatsnew23.tex Log Message: Add reminder, and a new POSIX function Tweak traceback display for consistency Index: whatsnew23.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew23.tex,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** whatsnew23.tex 14 Jun 2002 00:50:42 -0000 1.25 --- whatsnew23.tex 17 Jun 2002 13:40:04 -0000 1.26 *************** *** 25,28 **** --- 25,30 ---- % Docstrings now optional (with --without-doc-strings) % + % New dependency argument to distutils.Extension + % %\section{Introduction \label{intro}} *************** *** 110,115 **** >>> gen.next() Traceback (most recent call last): ! File "", line 1, in ? ! File "", line 2, in generate_ints StopIteration \end{verbatim} --- 112,117 ---- >>> gen.next() Traceback (most recent call last): ! File "stdin", line 1, in ? ! File "stdin", line 2, in generate_ints StopIteration \end{verbatim} *************** *** 535,539 **** >>> d.pop(1) Traceback (most recent call last): ! File ``'', line 1, in ? KeyError: pop(): dictionary is empty >>> d --- 537,541 ---- >>> d.pop(1) Traceback (most recent call last): ! File ``stdin'', line 1, in ? KeyError: pop(): dictionary is empty >>> d *************** *** 551,557 **** input values measured in radians. (Contributed by Raymond Hettinger.) ! \item Two new functions, \function{killpg()} and \function{mknod()}, ! were added to the \module{posix} module that underlies the \module{os} ! module. \item Two new binary packagers were added to the Distutils. --- 553,559 ---- input values measured in radians. (Contributed by Raymond Hettinger.) ! \item Three new functions, \function{getpgid()}, \function{killpg()}, ! and \function{mknod()}, were added to the \module{posix} module that ! underlies the \module{os} module. \item Two new binary packagers were added to the Distutils. From fdrake@users.sourceforge.net Mon Jun 17 16:01:12 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Mon, 17 Jun 2002 08:01:12 -0700 Subject: [Python-checkins] python/dist/src/Doc/perl python.perl,1.125,1.126 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/perl In directory usw-pr-cvs1:/tmp/cvs-serv17548/perl Modified Files: python.perl Log Message: Ensure \verbatiminput always uses a unique filename for each input file in the "Download as text" link. Previously, it could map multiple source files to a single name since all files end up with the same extension. This closes SF bug #558279. Index: python.perl =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/perl/python.perl,v retrieving revision 1.125 retrieving revision 1.126 diff -C2 -d -r1.125 -r1.126 *** python.perl 23 May 2002 17:59:16 -0000 1.125 --- python.perl 17 Jun 2002 15:01:05 -0000 1.126 *************** *** 1978,1981 **** --- 1978,2034 ---- } + # List of all filenames produced ny do_cmd_verbatiminput() + %VerbatimFiles = (); + @VerbatimOutputs = (); + + sub get_verbatim_output_name($){ + my $file = @_[0]; + # + # Re-write the source filename to always use a .txt extension + # so that Web servers will present it as text/plain. This is + # needed since there is no other even moderately reliable way + # to get the right Content-Type header on text files for + # servers which we can't configure (like python.org mirrors). + # + if (defined $VerbatimFiles{$file}) { + # We've seen this one before; re-use the same output file. + return $VerbatimFiles{$file}; + } + use File::Basename; + my $srcname, $srcdir, $srcext; + ($srcname, $srcdir, $srcext) = fileparse($file, '\..*'); + $filename = "$srcname.txt"; + # + # We need to determine if our default filename is already + # being used, and find a new one it it is. If the name is in + # used, this algorithm will first attempt to include the + # source extension as part of the name, and if that is also in + # use (if the same file is included multiple times, or if + # another source file has that as the base name), a counter is + # used instead. + # + my $found = 1; + FIND: + while ($found) { + foreach $fn (@VerbatimOutputs) { + if ($fn eq $filename) { + if ($found == 1) { + $srcext =~ s/^[.]//; # Remove '.' from extension + $filename = "$srcname-$srcext.txt"; + } + else { + $filename = "$srcname-$found.txt"; + } + ++$found; + next FIND; + } + } + $found = 0; + } + push @VerbatimOutputs, $filename; + $VerbatimFiles{$file} = $filename; + return $filename; + } + sub do_cmd_verbatiminput{ local($_) = @_; *************** *** 1989,1993 **** last if ($found = (-f $file)); } ! my $srcname; my $text; if ($found) { --- 2042,2046 ---- last if ($found = (-f $file)); } ! my $filename = ''; my $text; if ($found) { *************** *** 1995,2002 **** read(MYFILE, $text, 1024*1024); close(MYFILE); ! use File::Basename; ! my $srcdir, $srcext; ! ($srcname, $srcdir, $srcext) = fileparse($file, '\..*'); ! open(MYFILE, ">$srcname.txt"); print MYFILE $text; close(MYFILE); --- 2048,2054 ---- read(MYFILE, $text, 1024*1024); close(MYFILE); ! $filename = get_verbatim_output_name($file); ! # Now that we have a filename, write it out. ! open(MYFILE, ">$filename"); print MYFILE $text; close(MYFILE); *************** *** 2024,2034 **** } else { ! $text = 'Could not locate requested file $fname!\n'; } return ("
\n
"
              . $text
              . "
\n
\n" ! . "Download as text." . "\n
" . $_); --- 2076,2092 ---- } else { ! return 'Could not locate requested file $fname!\n'; ! } ! my $note = 'Download as text.'; ! if ($file ne $filename) { ! $note = ('Download as text (original file name: ' ! . $fname ! . ').'); } return ("
\n
"
              . $text
              . "
\n
\n" ! . "$note" . "\n
" . $_); From fdrake@users.sourceforge.net Mon Jun 17 16:44:21 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Mon, 17 Jun 2002 08:44:21 -0700 Subject: [Python-checkins] python/dist/src/Doc/api utilities.tex,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory usw-pr-cvs1:/tmp/cvs-serv31196/api Modified Files: utilities.tex Log Message: Fix documentation for PyMarshal_WriteObjectToFile() and PyMarshal_WriteObjectToFile(). This closes SF bug #533735. Index: utilities.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/utilities.tex,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** utilities.tex 5 Apr 2002 23:01:14 -0000 1.4 --- utilities.tex 17 Jun 2002 15:44:18 -0000 1.5 *************** *** 287,298 **** \begin{cfuncdesc}{void}{PyMarshal_WriteShortToFile}{short value, FILE *file} ! Marshal a \ctype{short} integer, \var{value}, to \var{file}. \end{cfuncdesc} \begin{cfuncdesc}{void}{PyMarshal_WriteObjectToFile}{PyObject *value, FILE *file} ! Marshal a Python object, \var{value}, to \var{file}. This ! will only write the least-significant 16 bits of \var{value}; ! regardless of the size of the native \ctype{short} type. \end{cfuncdesc} --- 287,298 ---- \begin{cfuncdesc}{void}{PyMarshal_WriteShortToFile}{short value, FILE *file} ! Marshal a \ctype{short} integer, \var{value}, to \var{file}. This ! will only write the least-significant 16 bits of \var{value}; ! regardless of the size of the native \ctype{short} type. \end{cfuncdesc} \begin{cfuncdesc}{void}{PyMarshal_WriteObjectToFile}{PyObject *value, FILE *file} ! Marshal a Python object, \var{value}, to \var{file}. \end{cfuncdesc} *************** *** 319,323 **** Return a C \ctype{short} from the data stream in a \ctype{FILE*} opened for reading. Only a 16-bit value can be read in using ! this function, regardless of the native size of \ctype{long}. \end{cfuncdesc} --- 319,323 ---- Return a C \ctype{short} from the data stream in a \ctype{FILE*} opened for reading. Only a 16-bit value can be read in using ! this function, regardless of the native size of \ctype{short}. \end{cfuncdesc} From fdrake@users.sourceforge.net Mon Jun 17 16:45:23 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Mon, 17 Jun 2002 08:45:23 -0700 Subject: [Python-checkins] python/dist/src/Doc/api utilities.tex,1.3,1.3.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory usw-pr-cvs1:/tmp/cvs-serv31469/api Modified Files: Tag: release22-maint utilities.tex Log Message: Fix documentation for PyMarshal_WriteObjectToFile() and PyMarshal_WriteObjectToFile(). This closes SF bug #533735. Index: utilities.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/utilities.tex,v retrieving revision 1.3 retrieving revision 1.3.8.1 diff -C2 -d -r1.3 -r1.3.8.1 *** utilities.tex 23 Oct 2001 21:10:18 -0000 1.3 --- utilities.tex 17 Jun 2002 15:45:21 -0000 1.3.8.1 *************** *** 287,298 **** \begin{cfuncdesc}{void}{PyMarshal_WriteShortToFile}{short value, FILE *file} ! Marshal a \ctype{short} integer, \var{value}, to \var{file}. \end{cfuncdesc} \begin{cfuncdesc}{void}{PyMarshal_WriteObjectToFile}{PyObject *value, FILE *file} ! Marshal a Python object, \var{value}, to \var{file}. This ! will only write the least-significant 16 bits of \var{value}; ! regardless of the size of the native \ctype{short} type. \end{cfuncdesc} --- 287,298 ---- \begin{cfuncdesc}{void}{PyMarshal_WriteShortToFile}{short value, FILE *file} ! Marshal a \ctype{short} integer, \var{value}, to \var{file}. This ! will only write the least-significant 16 bits of \var{value}; ! regardless of the size of the native \ctype{short} type. \end{cfuncdesc} \begin{cfuncdesc}{void}{PyMarshal_WriteObjectToFile}{PyObject *value, FILE *file} ! Marshal a Python object, \var{value}, to \var{file}. \end{cfuncdesc} *************** *** 319,323 **** Return a C \ctype{short} from the data stream in a \ctype{FILE*} opened for reading. Only a 16-bit value can be read in using ! this function, regardless of the native size of \ctype{long}. \end{cfuncdesc} --- 319,323 ---- Return a C \ctype{short} from the data stream in a \ctype{FILE*} opened for reading. Only a 16-bit value can be read in using ! this function, regardless of the native size of \ctype{short}. \end{cfuncdesc} From fdrake@users.sourceforge.net Mon Jun 17 18:16:14 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Mon, 17 Jun 2002 10:16:14 -0700 Subject: [Python-checkins] python/dist/src/Python modsupport.c,2.55,2.55.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv26263/Python Modified Files: Tag: release21-maint modsupport.c Log Message: PyModule_AddObject(): Added missing exceptions. Closes SF bug #523473. Index: modsupport.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/modsupport.c,v retrieving revision 2.55 retrieving revision 2.55.2.1 diff -C2 -d -r2.55 -r2.55.2.1 *** modsupport.c 12 Mar 2001 21:03:26 -0000 2.55 --- modsupport.c 17 Jun 2002 17:16:11 -0000 2.55.2.1 *************** *** 468,480 **** { PyObject *dict; ! if (!PyModule_Check(m) || o == NULL) ! return -1; dict = PyModule_GetDict(m); ! if (dict == NULL) return -1; ! if (PyDict_SetItemString(dict, name, o)) ! return -1; ! Py_DECREF(o); ! return 0; } --- 468,487 ---- { PyObject *dict; ! if (!PyModule_Check(m) || o == NULL) { ! PyErr_SetString(PyExc_TypeError, ! "PyModule_AddObject() needs module as first arg"); ! return -1; ! } dict = PyModule_GetDict(m); ! if (dict == NULL) { ! /* Internal error -- modules must have a dict! */ ! PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", ! PyModule_GetName(m)); return -1; ! } ! if (PyDict_SetItemString(dict, name, o)) ! return -1; ! Py_DECREF(o); ! return 0; } From fdrake@users.sourceforge.net Mon Jun 17 18:16:36 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Mon, 17 Jun 2002 10:16:36 -0700 Subject: [Python-checkins] python/dist/src/Python modsupport.c,2.58,2.58.16.1 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv26370/Python Modified Files: Tag: release22-maint modsupport.c Log Message: PyModule_AddObject(): Added missing exceptions. Closes SF bug #523473. Index: modsupport.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/modsupport.c,v retrieving revision 2.58 retrieving revision 2.58.16.1 diff -C2 -d -r2.58 -r2.58.16.1 *** modsupport.c 17 Aug 2001 18:39:25 -0000 2.58 --- modsupport.c 17 Jun 2002 17:16:34 -0000 2.58.16.1 *************** *** 482,494 **** { PyObject *dict; ! if (!PyModule_Check(m) || o == NULL) ! return -1; dict = PyModule_GetDict(m); ! if (dict == NULL) return -1; ! if (PyDict_SetItemString(dict, name, o)) ! return -1; ! Py_DECREF(o); ! return 0; } --- 482,501 ---- { PyObject *dict; ! if (!PyModule_Check(m) || o == NULL) { ! PyErr_SetString(PyExc_TypeError, ! "PyModule_AddObject() needs module as first arg"); ! return -1; ! } dict = PyModule_GetDict(m); ! if (dict == NULL) { ! /* Internal error -- modules must have a dict! */ ! PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", ! PyModule_GetName(m)); return -1; ! } ! if (PyDict_SetItemString(dict, name, o)) ! return -1; ! Py_DECREF(o); ! return 0; } From fdrake@users.sourceforge.net Mon Jun 17 18:17:00 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Mon, 17 Jun 2002 10:17:00 -0700 Subject: [Python-checkins] python/dist/src/Python modsupport.c,2.59,2.60 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv26470/Python Modified Files: modsupport.c Log Message: PyModule_AddObject(): Added missing exceptions. Closes SF bug #523473. Index: modsupport.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/modsupport.c,v retrieving revision 2.59 retrieving revision 2.60 diff -C2 -d -r2.59 -r2.60 *** modsupport.c 28 Mar 2002 05:33:33 -0000 2.59 --- modsupport.c 17 Jun 2002 17:16:57 -0000 2.60 *************** *** 489,501 **** { PyObject *dict; ! if (!PyModule_Check(m) || o == NULL) ! return -1; dict = PyModule_GetDict(m); ! if (dict == NULL) return -1; ! if (PyDict_SetItemString(dict, name, o)) ! return -1; ! Py_DECREF(o); ! return 0; } --- 489,508 ---- { PyObject *dict; ! if (!PyModule_Check(m) || o == NULL) { ! PyErr_SetString(PyExc_TypeError, ! "PyModule_AddObject() needs module as first arg"); ! return -1; ! } dict = PyModule_GetDict(m); ! if (dict == NULL) { ! /* Internal error -- modules must have a dict! */ ! PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", ! PyModule_GetName(m)); return -1; ! } ! if (PyDict_SetItemString(dict, name, o)) ! return -1; ! Py_DECREF(o); ! return 0; } From fdrake@users.sourceforge.net Mon Jun 17 18:55:34 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Mon, 17 Jun 2002 10:55:34 -0700 Subject: [Python-checkins] python/dist/src setup.py,1.93,1.94 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv6537 Modified Files: setup.py Log Message: Update description of the Expat library. Closes SF bug #556370. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.93 retrieving revision 1.94 diff -C2 -d -r1.93 -r1.94 *** setup.py 14 Jun 2002 20:30:30 -0000 1.93 --- setup.py 17 Jun 2002 17:55:30 -0000 1.94 *************** *** 654,663 **** # Interface to the Expat XML parser # ! # Expat is written by James Clark and must be downloaded separately ! # (see below). The pyexpat module was written by Paul Prescod after a ! # prototype by Jack Jansen. Source of Expat 1.95.2 is included ! # in Modules/expat. Usage of a system shared libexpat.so/expat.dll ! # is only advised if that has the same or newer version and was ! # build using the same defines. if sys.byteorder == "little": xmlbo = "12" --- 654,666 ---- # Interface to the Expat XML parser # ! # Expat was written by James Clark and is now maintained by a ! # group of developers on SourceForge; see www.libexpat.org for ! # more information. The pyexpat module was written by Paul ! # Prescod after a prototype by Jack Jansen. Source of Expat ! # 1.95.2 is included in Modules/expat/. Usage of a system ! # shared libexpat.so/expat.dll is not advised. ! # ! # More information on Expat can be found at www.libexpat.org. ! # if sys.byteorder == "little": xmlbo = "12" From fdrake@users.sourceforge.net Mon Jun 17 18:56:12 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Mon, 17 Jun 2002 10:56:12 -0700 Subject: [Python-checkins] python/dist/src setup.py,1.73.4.5,1.73.4.6 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv6802 Modified Files: Tag: release22-maint setup.py Log Message: Update description of the Expat library. Closes SF bug #556370. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.73.4.5 retrieving revision 1.73.4.6 diff -C2 -d -r1.73.4.5 -r1.73.4.6 *** setup.py 15 May 2002 20:46:56 -0000 1.73.4.5 --- setup.py 17 Jun 2002 17:56:10 -0000 1.73.4.6 *************** *** 541,560 **** # Interface to the Expat XML parser # ! # Expat is written by James Clark and must be downloaded separately ! # (see below). The pyexpat module was written by Paul Prescod after a ! # prototype by Jack Jansen. ! # ! # The Expat dist includes Windows .lib and .dll files. Home page is ! # at http://sourceforge.net/projects/expat/. ! # ! # 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 libexpat.a xmltok/*.o xmlparse/*.o # expat_defs = [] --- 541,552 ---- # Interface to the Expat XML parser # ! # Expat was written by James Clark and is now maintained by a ! # group of developers on SourceForge. The parser must be ! # downloaded separately (see below). The pyexpat module was ! # written by Paul Prescod after a prototype by Jack Jansen. # ! # The Expat dist includes Windows .lib and .dll files. The ! # home page for Expat is at http://www.libexpat.org/. Using ! # Expat version 1.95.2 or newer is recommended. # expat_defs = [] From mwh@users.sourceforge.net Tue Jun 18 13:38:10 2002 From: mwh@users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue, 18 Jun 2002 05:38:10 -0700 Subject: [Python-checkins] python/dist/src/Objects classobject.c,2.157,2.158 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv10274 Modified Files: classobject.c Log Message: About the new but unreferenced new_class, Guido sez: > Looks like an experiment by Oren Tirosh that didn't get nuked. I > think you can safely lose it. It's gone. Index: classobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v retrieving revision 2.157 retrieving revision 2.158 diff -C2 -d -r2.157 -r2.158 *** classobject.c 14 Jun 2002 20:41:14 -0000 2.157 --- classobject.c 18 Jun 2002 12:38:06 -0000 2.158 *************** *** 157,175 **** static PyObject * - new_class(PyObject* unused, PyObject* args) - { - PyObject *name; - PyObject *classes; - PyObject *dict; - - if (!PyArg_ParseTuple(args, "SO!O!:class", - &name, - &PyTuple_Type, &classes, - &PyDict_Type, &dict)) - return NULL; - return PyClass_New(classes, dict, name); - } - - static PyObject * class_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { --- 157,160 ---- From fdrake@users.sourceforge.net Tue Jun 18 15:31:07 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 18 Jun 2002 07:31:07 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libshutil.tex,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv10687/lib Modified Files: libshutil.tex Log Message: Clarified description of error handling for shutil.rmtree(). This closes SF patch #569832. Index: libshutil.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libshutil.tex,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** libshutil.tex 4 Sep 2001 18:26:27 -0000 1.8 --- libshutil.tex 18 Jun 2002 14:31:04 -0000 1.9 *************** *** 79,84 **** \index{directory!deleting} Delete an entire directory tree. If \var{ignore_errors} is true, ! errors will be ignored; if false or omitted, errors are handled by ! calling a handler specified by \var{onerror} or raise an exception. If \var{onerror} is provided, it must be a callable that accepts --- 79,85 ---- \index{directory!deleting} Delete an entire directory tree. If \var{ignore_errors} is true, ! errors resulting from failed removals will be ignored; if false or ! omitted, such errors are handled by calling a handler specified by ! \var{onerror} or, if that is omitted, they raise an exception. If \var{onerror} is provided, it must be a callable that accepts From fdrake@users.sourceforge.net Tue Jun 18 15:31:21 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 18 Jun 2002 07:31:21 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libshutil.tex,1.8,1.8.14.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv10730/lib Modified Files: Tag: release22-maint libshutil.tex Log Message: Clarified description of error handling for shutil.rmtree(). This closes SF patch #569832. Index: libshutil.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libshutil.tex,v retrieving revision 1.8 retrieving revision 1.8.14.1 diff -C2 -d -r1.8 -r1.8.14.1 *** libshutil.tex 4 Sep 2001 18:26:27 -0000 1.8 --- libshutil.tex 18 Jun 2002 14:31:19 -0000 1.8.14.1 *************** *** 79,84 **** \index{directory!deleting} Delete an entire directory tree. If \var{ignore_errors} is true, ! errors will be ignored; if false or omitted, errors are handled by ! calling a handler specified by \var{onerror} or raise an exception. If \var{onerror} is provided, it must be a callable that accepts --- 79,85 ---- \index{directory!deleting} Delete an entire directory tree. If \var{ignore_errors} is true, ! errors resulting from failed removals will be ignored; if false or ! omitted, such errors are handled by calling a handler specified by ! \var{onerror} or, if that is omitted, they raise an exception. If \var{onerror} is provided, it must be a callable that accepts From fdrake@users.sourceforge.net Tue Jun 18 15:32:18 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 18 Jun 2002 07:32:18 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libshutil.tex,1.7,1.7.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv11034/lib Modified Files: Tag: release21-maint libshutil.tex Log Message: Clarified description of error handling for shutil.rmtree(). This closes SF patch #569832. Index: libshutil.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libshutil.tex,v retrieving revision 1.7 retrieving revision 1.7.4.1 diff -C2 -d -r1.7 -r1.7.4.1 *** libshutil.tex 2 Mar 2001 16:46:42 -0000 1.7 --- libshutil.tex 18 Jun 2002 14:32:16 -0000 1.7.4.1 *************** *** 74,79 **** \index{directory!deleting} Delete an entire directory tree. If \var{ignore_errors} is true, ! errors will be ignored; if false or omitted, errors are handled by ! calling a handler specified by \var{onerror} or raise an exception. If \var{onerror} is provided, it must be a callable that accepts --- 74,80 ---- \index{directory!deleting} Delete an entire directory tree. If \var{ignore_errors} is true, ! errors resulting from failed removals will be ignored; if false or ! omitted, such errors are handled by calling a handler specified by ! \var{onerror} or, if that is omitted, they raise an exception. If \var{onerror} is provided, it must be a callable that accepts From fdrake@users.sourceforge.net Tue Jun 18 16:21:24 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 18 Jun 2002 08:21:24 -0700 Subject: [Python-checkins] python/dist/src/Tools/scripts texi2html.py,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/scripts In directory usw-pr-cvs1:/tmp/cvs-serv25661 Modified Files: texi2html.py Log Message: SF patch #552837, submitted by Robert Pyron: 1. BUGFIX: In function makefile(), strip blanks from the nodename. This is necesary to match the behavior of parser.makeref() and parser.do_node(). 2. BUGFIX fixed KeyError in end_ifset (well, I may have just made it go away, rather than fix it) 3. BUGFIX allow @menu and menu items inside @ifset or @ifclear 4. Support added for: @uref URL reference @image image file reference (see note below) @multitable output an HTML table @vtable 5. Partial support for accents, to match MAKEINFO output 6. I added a new command-line option, '-H basename', to specify HTML Help output. This will cause three files to be created in the current directory: `basename`.hhp HTML Help Workshop project file `basename`.hhc Contents file for the project `basename`.hhk Index file for the project When fed into HTML Help Workshop, the resulting file will be named `basename`.chm. 7. A new class, HTMLHelp, to accomplish item 6. 8. Various calls to HTMLHelp functions. A NOTE ON IMAGES: Just as 'outputdirectory' must exist before running this program, all referenced images must already exist in outputdirectory. FLD: wrapped some long lines. Index: texi2html.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/texi2html.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** texi2html.py 20 Jul 2001 18:59:21 -0000 1.13 --- texi2html.py 18 Jun 2002 15:21:21 -0000 1.14 *************** *** 33,40 **** # ... # Support the most recent texinfo version and take a good look at HTML 3.0 ! # More debugging output (customizable) and more fexible error handling # How about icons ? import os import string import re --- 33,69 ---- # ... # Support the most recent texinfo version and take a good look at HTML 3.0 ! # More debugging output (customizable) and more flexible error handling # How about icons ? + # rpyron 2002-05-07 + # Robert Pyron + # 1. BUGFIX: In function makefile(), strip blanks from the nodename. + # This is necesary to match the behavior of parser.makeref() and + # parser.do_node(). + # 2. BUGFIX fixed KeyError in end_ifset (well, I may have just made + # it go away, rather than fix it) + # 3. BUGFIX allow @menu and menu items inside @ifset or @ifclear + # 4. Support added for: + # @uref URL reference + # @image image file reference (see note below) + # @multitable output an HTML table + # @vtable + # 5. Partial support for accents, to match MAKEINFO output + # 6. I added a new command-line option, '-H basename', to specify + # HTML Help output. This will cause three files to be created + # in the current directory: + # `basename`.hhp HTML Help Workshop project file + # `basename`.hhc Contents file for the project + # `basename`.hhk Index file for the project + # When fed into HTML Help Workshop, the resulting file will be + # named `basename`.chm. + # 7. A new class, HTMLHelp, to accomplish item 6. + # 8. Various calls to HTMLHelp functions. + # A NOTE ON IMAGES: Just as 'outputdirectory' must exist before + # running this program, all referenced images must already exist + # in outputdirectory. + import os + import sys import string import re *************** *** 51,54 **** --- 80,88 ---- # menu item (Yuck!) miprog = re.compile('^\* ([^:]*):(:|[ \t]*([^\t,\n.]+)([^ \t\n]*))[ \t\n]*') + # 0 1 1 2 3 34 42 0 + # ----- ---------- --------- + # -|----------------------------- + # ----------------------------------------------------- + *************** *** 183,186 **** --- 217,221 ---- self.savetext = None # If not None, save text head instead self.savestack = [] # If not None, save text head instead + self.htmlhelp = None # html help data self.dirname = 'tmp' # directory where files are created self.includedir = '.' # directory to search @include files *************** *** 203,206 **** --- 238,246 ---- self.cont = 0 self.includedepth = 0 + + # Set htmlhelp helper class + def sethtmlhelp(self, htmlhelp): + self.htmlhelp = htmlhelp + # Set (output) directory name def setdirname(self, dirname): *************** *** 308,311 **** --- 348,352 ---- elif self.node: self.node.write(text) + # Complete the current node -- write footnotes and close file def endnode(self): *************** *** 343,351 **** def process(self, accu): if self.debugging > 1: ! print self.skip, self.stack, if accu: print accu[0][:30], if accu[0][30:] or accu[1:]: print '...', print ! if self.stack and self.stack[-1] == 'menu': # XXX should be done differently for line in accu: --- 384,392 ---- def process(self, accu): if self.debugging > 1: ! print '!'*self.debugging, 'process:', self.skip, self.stack, if accu: print accu[0][:30], if accu[0][30:] or accu[1:]: print '...', print ! if self.inmenu(): # XXX should be done differently for line in accu: *************** *** 369,372 **** --- 410,414 ---- '">', nodename, '', punct, '\n') + self.htmlhelp.menuitem(nodename) self.expand(line[end:]) else: *************** *** 374,377 **** --- 416,433 ---- self.expand(text) + # find 'menu' (we might be inside 'ifset' or 'ifclear') + def inmenu(self): + #if 'menu' in self.stack: + # print 'inmenu :', self.skip, self.stack, self.stackinfo + stack = self.stack + while stack and stack[-1] in ('ifset','ifclear'): + try: + if self.stackinfo[len(stack)]: + return 0 + except KeyError: + pass + stack = stack[:-1] + return (stack and stack[-1] == 'menu') + # Write a string, expanding embedded @-commands def expand(self, text): *************** *** 503,508 **** print '*** Can\'t open include file', `file` return ! if self.debugging: ! print '--> file', `file` save_done = self.done save_skip = self.skip --- 559,563 ---- print '*** Can\'t open include file', `file` return ! print '!'*self.debugging, '--> file', `file` save_done = self.done save_skip = self.skip *************** *** 515,520 **** self.skip = save_skip self.stack = save_stack ! if self.debugging: ! print '<-- file', `file` # --- Special Insertions --- --- 570,574 ---- self.skip = save_skip self.stack = save_stack ! print '!'*self.debugging, '<-- file', `file` # --- Special Insertions --- *************** *** 539,542 **** --- 593,659 ---- def close_minus(self): pass + # --- Accents --- + + # rpyron 2002-05-07 + # I would like to do at least as well as makeinfo when + # it is producing HTML output: + # + # input output + # @"o @"o umlaut accent + # @'o 'o acute accent + # @,{c} @,{c} cedilla accent + # @=o @=o macron/overbar accent + # @^o @^o circumflex accent + # @`o `o grave accent + # @~o @~o tilde accent + # @dotaccent{o} @dotaccent{o} overdot accent + # @H{o} @H{o} long Hungarian umlaut + # @ringaccent{o} @ringaccent{o} ring accent + # @tieaccent{oo} @tieaccent{oo} tie-after accent + # @u{o} @u{o} breve accent + # @ubaraccent{o} @ubaraccent{o} underbar accent + # @udotaccent{o} @udotaccent{o} underdot accent + # @v{o} @v{o} hacek or check accent + # @exclamdown{} ¡ upside-down ! + # @questiondown{} ¿ upside-down ? + # @aa{},@AA{} å,Å a,A with circle + # @ae{},@AE{} æ,Æ ae,AE ligatures + # @dotless{i} @dotless{i} dotless i + # @dotless{j} @dotless{j} dotless j + # @l{},@L{} l/,L/ suppressed-L,l + # @o{},@O{} ø,Ø O,o with slash + # @oe{},@OE{} oe,OE oe,OE ligatures + # @ss{} ß es-zet or sharp S + # + # The following character codes and approximations have been + # copied from makeinfo's HTML output. + + def open_exclamdown(self): self.write('¡') # upside-down ! + def close_exclamdown(self): pass + def open_questiondown(self): self.write('¿') # upside-down ? + def close_questiondown(self): pass + def open_aa(self): self.write('å') # a with circle + def close_aa(self): pass + def open_AA(self): self.write('Å') # A with circle + def close_AA(self): pass + def open_ae(self): self.write('æ') # ae ligatures + def close_ae(self): pass + def open_AE(self): self.write('Æ') # AE ligatures + def close_AE(self): pass + def open_o(self): self.write('ø') # o with slash + def close_o(self): pass + def open_O(self): self.write('Ø') # O with slash + def close_O(self): pass + def open_ss(self): self.write('ß') # es-zet or sharp S + def close_ss(self): pass + def open_oe(self): self.write('oe') # oe ligatures + def close_oe(self): pass + def open_OE(self): self.write('OE') # OE ligatures + def close_OE(self): pass + def open_l(self): self.write('l/') # suppressed-l + def close_l(self): pass + def open_L(self): self.write('L/') # suppressed-L + def close_L(self): pass + # --- Special Glyphs for Examples --- *************** *** 608,611 **** --- 725,791 ---- self.write('', label, '') + # rpyron 2002-05-07 uref support + def open_uref(self): + self.startsaving() + def close_uref(self): + text = self.collectsavings() + args = string.splitfields(text, ',') + n = len(args) + for i in range(n): + args[i] = string.strip(args[i]) + while len(args) < 2: args.append('') + href = args[0] + label = args[1] + if not label: label = href + self.write('', label, '') + + # rpyron 2002-05-07 image support + # GNU makeinfo producing HTML output tries `filename.png'; if + # that does not exist, it tries `filename.jpg'. If that does + # not exist either, it complains. GNU makeinfo does not handle + # GIF files; however, I include GIF support here because + # MySQL documentation uses GIF files. + + def open_image(self): + self.startsaving() + def close_image(self): + self.makeimage() + def makeimage(self): + text = self.collectsavings() + args = string.splitfields(text, ',') + n = len(args) + for i in range(n): + args[i] = string.strip(args[i]) + while len(args) < 5: args.append('') + filename = args[0] + width = args[1] + height = args[2] + alt = args[3] + ext = args[4] + + # The HTML output will have a reference to the image + # that is relative to the HTML output directory, + # which is what 'filename' gives us. However, we need + # to find it relative to our own current directory, + # so we construct 'imagename'. + imagelocation = self.dirname + '/' + filename + + if os.path.exists(imagelocation+'.png'): + filename += '.png' + elif os.path.exists(imagelocation+'.jpg'): + filename += '.jpg' + elif os.path.exists(imagelocation+'.gif'): # MySQL uses GIF files + filename += '.gif' + else: + print "*** Cannot find image " + imagelocation + #TODO: what is 'ext'? + self.write('' ) + self.htmlhelp.addimage(imagelocation) + + # --- Marking Words and Phrases --- *************** *** 705,709 **** args = string.strip(line[b:]) if self.debugging > 1: ! print self.skip, self.stack, '@' + cmd, args try: func = getattr(self, 'do_' + cmd) --- 885,890 ---- args = string.strip(line[b:]) if self.debugging > 1: ! print '!'*self.debugging, 'command:', self.skip, self.stack, \ ! '@' + cmd, args try: func = getattr(self, 'do_' + cmd) *************** *** 781,785 **** value = string.joinfields(fields[1:], ' ') self.values[key] = value - print self.values def do_clear(self, args): --- 962,965 ---- *************** *** 794,802 **** self.stackinfo[len(self.stack)] = 0 def end_ifset(self): ! print self.stack ! print self.stackinfo ! if self.stackinfo[len(self.stack) + 1]: ! self.skip = self.skip - 1 ! del self.stackinfo[len(self.stack) + 1] def bgn_ifclear(self, args): --- 974,983 ---- self.stackinfo[len(self.stack)] = 0 def end_ifset(self): ! try: ! if self.stackinfo[len(self.stack) + 1]: ! self.skip = self.skip - 1 ! del self.stackinfo[len(self.stack) + 1] ! except KeyError: ! print '*** end_ifset: KeyError :', len(self.stack) + 1 def bgn_ifclear(self, args): *************** *** 807,812 **** else: self.stackinfo[len(self.stack)] = 0 ! ! end_ifclear = end_ifset def open_value(self): --- 988,998 ---- else: self.stackinfo[len(self.stack)] = 0 ! def end_ifclear(self): ! try: ! if self.stackinfo[len(self.stack) + 1]: ! self.skip = self.skip - 1 ! del self.stackinfo[len(self.stack) + 1] ! except KeyError: ! print '*** end_ifclear: KeyError :', len(self.stack) + 1 def open_value(self): *************** *** 827,835 **** def do_settitle(self, args): - print args self.startsaving() self.expand(args) self.title = self.collectsavings() - print self.title def do_parskip(self, args): pass --- 1013,1019 ---- *************** *** 885,889 **** print '*** Filename already in use: ', file else: ! if self.debugging: print '--- writing', file self.filenames[file] = 1 # self.nodefp = open(file, 'w') --- 1069,1073 ---- print '*** Filename already in use: ', file else: ! if self.debugging: print '!'*self.debugging, '--- writing', file self.filenames[file] = 1 # self.nodefp = open(file, 'w') *************** *** 896,899 **** --- 1080,1084 ---- self.node = self.Node(self.dirname, self.nodename, self.topname, title, next, prev, up) + self.htmlhelp.addnode(self.nodename,next,prev,up,file) def link(self, label, nodename): *************** *** 1257,1264 **** self.end_table() def do_item(self, args): if self.itemindex: self.index(self.itemindex, args) if self.itemarg: ! if self.itemarg[0] == '@' and self.itemarg[1:2] and \ self.itemarg[1] in string.ascii_letters: args = self.itemarg + '{' + args + '}' --- 1442,1456 ---- self.end_table() + def bgn_vtable(self, args): + self.itemindex = 'vr' + self.bgn_table(args) + def end_vtable(self): + self.itemindex = None + self.end_table() + def do_item(self, args): if self.itemindex: self.index(self.itemindex, args) if self.itemarg: ! if self.itemarg[0] == '@' and self.itemarg[1] and \ self.itemarg[1] in string.ascii_letters: args = self.itemarg + '{' + args + '}' *************** *** 1273,1276 **** --- 1465,1472 ---- self.expand(args) self.write('\n
') + elif self.stack and self.stack[-1] == 'multitable': + self.write('') + self.expand(args) + self.write('\n\n') else: self.write('
  • ') *************** *** 1279,1282 **** --- 1475,1491 ---- do_itemx = do_item # XXX Should suppress leading blank line + # rpyron 2002-05-07 multitable support + def bgn_multitable(self, args): + self.itemarg = None # should be handled by columnfractions + self.write('\n') + def end_multitable(self): + self.itemarg = None + self.write('
    \n
    \n') + def handle_columnfractions(self): + # It would be better to handle this, but for now it's in the way... + self.itemarg = None + def handle_tab(self): + self.write('\n ') + # --- Enumerations, displays, quotations --- # XXX Most of these should increase the indentation somehow *************** *** 1327,1332 **** --- 1536,1543 ---- self.write('\n') self.write(' Menu

    \n') + self.htmlhelp.beginmenu() def end_menu(self): self.write('

    \n') + self.htmlhelp.endmenu() def bgn_cartouche(self, args): pass *************** *** 1364,1367 **** --- 1575,1579 ---- def index(self, name, args): self.whichindex[name].append((args, self.nodename)) + self.htmlhelp.index(args, self.nodename) def do_synindex(self, args): *************** *** 1395,1399 **** if not index: return if self.debugging: ! print '--- Generating', self.indextitle[name], 'index' # The node already provides a title index1 = [] --- 1607,1612 ---- if not index: return if self.debugging: ! print '!'*self.debugging, '--- Generating', \ ! self.indextitle[name], 'index' # The node already provides a title index1 = [] *************** *** 1418,1422 **** if (key, node) == (prevkey, prevnode): continue ! if self.debugging > 1: print key, ':', node self.write('
    ') if iscodeindex: key = '@code{' + key + '}' --- 1631,1635 ---- if (key, node) == (prevkey, prevnode): continue ! if self.debugging > 1: print '!'*self.debugging, key, ':', node self.write('
    ') if iscodeindex: key = '@code{' + key + '}' *************** *** 1482,1485 **** --- 1695,1953 ---- + # rpyron 2002-05-07 + class HTMLHelp: + """ + This class encapsulates support for HTML Help. Node names, + file names, menu items, index items, and image file names are + accumulated until a call to finalize(). At that time, three + output files are created in the current directory: + + `helpbase`.hhp is a HTML Help Workshop project file. + It contains various information, some of + which I do not understand; I just copied + the default project info from a fresh + installation. + `helpbase`.hhc is the Contents file for the project. + `helpbase`.hhk is the Index file for the project. + + When these files are used as input to HTML Help Workshop, + the resulting file will be named: + + `helpbase`.chm + + If none of the defaults in `helpbase`.hhp are changed, + the .CHM file will have Contents, Index, Search, and + Favorites tabs. + """ + + codeprog = re.compile('@code{(.*?)}') + + def __init__(self,helpbase,dirname): + self.helpbase = helpbase + self.dirname = dirname + self.projectfile = None + self.contentfile = None + self.indexfile = None + self.nodelist = [] + self.nodenames = {} # nodename : index + self.nodeindex = {} + self.filenames = {} # filename : filename + self.indexlist = [] # (args,nodename) == (key,location) + self.current = '' + self.menudict = {} + self.dumped = {} + + + def addnode(self,name,next,prev,up,filename): + node = (name,next,prev,up,filename) + # add this file to dict + # retrieve list with self.filenames.values() + self.filenames[filename] = filename + # add this node to nodelist + self.nodeindex[name] = len(self.nodelist) + self.nodelist.append(node) + # set 'current' for menu items + self.current = name + self.menudict[self.current] = [] + + def menuitem(self,nodename): + menu = self.menudict[self.current] + menu.append(nodename) + + + def addimage(self,imagename): + self.filenames[imagename] = imagename + + def index(self, args, nodename): + self.indexlist.append((args,nodename)) + + def beginmenu(self): + pass + + def endmenu(self): + pass + + def finalize(self): + if not self.helpbase: + return + + # generate interesting filenames + resultfile = self.helpbase + '.chm' + projectfile = self.helpbase + '.hhp' + contentfile = self.helpbase + '.hhc' + indexfile = self.helpbase + '.hhk' + + # generate a reasonable title + title = self.helpbase + + # get the default topic file + (topname,topnext,topprev,topup,topfile) = self.nodelist[0] + defaulttopic = topfile + + # PROJECT FILE + try: + fp = open(projectfile,'w') + print>>fp, '[OPTIONS]' + print>>fp, 'Auto Index=Yes' + print>>fp, 'Binary TOC=No' + print>>fp, 'Binary Index=Yes' + print>>fp, 'Compatibility=1.1' + print>>fp, 'Compiled file=' + resultfile + '' + print>>fp, 'Contents file=' + contentfile + '' + print>>fp, 'Default topic=' + defaulttopic + '' + print>>fp, 'Error log file=ErrorLog.log' + print>>fp, 'Index file=' + indexfile + '' + print>>fp, 'Title=' + title + '' + print>>fp, 'Display compile progress=Yes' + print>>fp, 'Full-text search=Yes' + print>>fp, 'Default window=main' + print>>fp, '' + print>>fp, '[WINDOWS]' + print>>fp, ('main=,"' + contentfile + '","' + indexfile + + '","","",,,,,0x23520,222,0x1046,[10,10,780,560],' + '0xB0000,,,,,,0') + print>>fp, '' + print>>fp, '[FILES]' + print>>fp, '' + self.dumpfiles(fp) + fp.close() + except IOError, msg: + print projectfile, ':', msg + sys.exit(1) + + # CONTENT FILE + try: + fp = open(contentfile,'w') + print>>fp, '' + print>>fp, '' + print>>fp, '' + print>>fp, '' + print>>fp, ('') + print>>fp, '' + print>>fp, '' + print>>fp, '' + print>>fp, ' ' + print>>fp, ' ' + print>>fp, ' ' + print>>fp, ' ' + print>>fp, ' ' + self.dumpnodes(fp) + print>>fp, '' + print>>fp, '' + fp.close() + except IOError, msg: + print contentfile, ':', msg + sys.exit(1) + + # INDEX FILE + try: + fp = open(indexfile ,'w') + print>>fp, '' + print>>fp, '' + print>>fp, '' + print>>fp, '' + print>>fp, ('') + print>>fp, '' + print>>fp, '' + print>>fp, '' + print>>fp, '' + print>>fp, '' + self.dumpindex(fp) + print>>fp, '' + print>>fp, '' + fp.close() + except IOError, msg: + print indexfile , ':', msg + sys.exit(1) + + def dumpfiles(self, outfile=sys.stdout): + filelist = self.filenames.values() + filelist.sort() + for filename in filelist: + print>>outfile, filename + + def dumpnodes(self, outfile=sys.stdout): + self.dumped = {} + if self.nodelist: + (nodename,None,None,None,None) = self.nodelist[0] + self.topnode = nodename + + print>>outfile, '
      ' + for node in self.nodelist: + self.dumpnode(node,0,outfile) + print>>outfile, '
    ' + + def dumpnode(self, node, indent=0, outfile=sys.stdout): + if node: + # Retrieve info for this node + (nodename,next,prev,up,filename) = node + self.current = nodename + + # Have we been dumped already? + if self.dumped.has_key(nodename): + return + self.dumped[nodename] = 1 + + # Print info for this node + print>>outfile, ' '*indent, + print>>outfile, '
  • ', + print>>outfile, '', + print>>outfile, '', + print>>outfile, '' + + # Does this node have menu items? + try: + menu = self.menudict[nodename] + self.dumpmenu(menu,indent+2,outfile) + except KeyError: + pass + + def dumpmenu(self, menu, indent=0, outfile=sys.stdout): + if menu: + currentnode = self.current + if currentnode != self.topnode: # XXX this is a hack + print>>outfile, ' '*indent + '
      ' + indent += 2 + for item in menu: + menunode = self.getnode(item) + self.dumpnode(menunode,indent,outfile) + if currentnode != self.topnode: # XXX this is a hack + print>>outfile, ' '*indent + '
    ' + indent -= 2 + + def getnode(self, nodename): + try: + index = self.nodeindex[nodename] + return self.nodelist[index] + except KeyError: + return None + except IndexError: + return None + + # (args,nodename) == (key,location) + def dumpindex(self, outfile=sys.stdout): + print>>outfile, '
      ' + for (key,location) in self.indexlist: + key = self.codeexpand(key) + location = makefile(location) + location = self.dirname + '/' + location + print>>outfile, '
    • ', + print>>outfile, '', + print>>outfile, '', + print>>outfile, '' + print>>outfile, '
    ' + + def codeexpand(self, line): + co = self.codeprog.match(line) + if not co: + return line + bgn, end = co.span(0) + a, b = co.span(1) + line = line[:bgn] + line[a:b] + line[end:] + return line + + # Put @var{} around alphabetic substrings def makevar(str): *************** *** 1521,1524 **** --- 1989,1993 ---- # Convert a node name into a file name def makefile(nodename): + nodename = string.strip(nodename) return fixfunnychars(nodename) + '.html' *************** *** 1569,1576 **** cont = 0 html3 = 0 ! while sys.argv[1:2] == ['-d']: debugging = debugging + 1 ! del sys.argv[1:2] if sys.argv[1] == '-p': print_headers = 1 --- 2038,2046 ---- cont = 0 html3 = 0 + htmlhelp = '' ! while sys.argv[1] == ['-d']: debugging = debugging + 1 ! del sys.argv[1] if sys.argv[1] == '-p': print_headers = 1 *************** *** 1582,1587 **** html3 = 1 del sys.argv[1] if len(sys.argv) <> 3: ! print 'usage: texi2html [-d [-d]] [-p] [-c] inputfile outputdirectory' sys.exit(2) --- 2052,2061 ---- html3 = 1 del sys.argv[1] + if sys.argv[1] == '-H': + helpbase = sys.argv[2] + del sys.argv[1:3] if len(sys.argv) <> 3: ! print 'usage: texi2hh [-d [-d]] [-p] [-c] [-3] [-H htmlhelp]', \ ! 'inputfile outputdirectory' sys.exit(2) *************** *** 1595,1603 **** file = sys.argv[1] ! parser.setdirname(sys.argv[2]) ! if file == '-': ! fp = sys.stdin ! else: parser.setincludedir(os.path.dirname(file)) try: fp = open(file, 'r') --- 2069,2079 ---- file = sys.argv[1] ! dirname = sys.argv[2] ! parser.setdirname(dirname) parser.setincludedir(os.path.dirname(file)) + + htmlhelp = HTMLHelp(helpbase, dirname) + parser.sethtmlhelp(htmlhelp) + try: fp = open(file, 'r') *************** *** 1605,1611 **** --- 2081,2090 ---- print file, ':', msg sys.exit(1) + parser.parse(fp) fp.close() parser.report() + + htmlhelp.finalize() From fdrake@users.sourceforge.net Tue Jun 18 16:37:08 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 18 Jun 2002 08:37:08 -0700 Subject: [Python-checkins] python/dist/src/Tools/scripts texi2html.py,1.14,1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/scripts In directory usw-pr-cvs1:/tmp/cvs-serv29988 Modified Files: texi2html.py Log Message: Mechanically translated string method calls to string methods. Instead of splitting a string and looping over it to call s.split(), use list comprehensions for readability. Index: texi2html.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/scripts/texi2html.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** texi2html.py 18 Jun 2002 15:21:21 -0000 1.14 --- texi2html.py 18 Jun 2002 15:37:05 -0000 1.15 *************** *** 126,130 **** def link(self, label, nodename, rel=None, rev=None): if nodename: ! if string.lower(nodename) == '(dir)': addr = '../dir.html' title = '' --- 126,130 ---- def link(self, label, nodename, rel=None, rev=None): if nodename: ! if nodename.lower() == '(dir)': addr = '../dir.html' title = '' *************** *** 139,150 **** def finalize(self): length = len(self.lines) ! self.text = string.joinfields(self.lines, '') self.lines = [] self.open_links() self.output_links() self.close_links() ! links = string.joinfields(self.lines, '') self.lines = [] - self.prologue = ( self.DOCTYPE + --- 139,149 ---- def finalize(self): length = len(self.lines) ! self.text = ''.join(self.lines) self.lines = [] self.open_links() self.output_links() self.close_links() ! links = ''.join(self.lines) self.lines = [] self.prologue = ( self.DOCTYPE + *************** *** 338,342 **** def write(self, *args): try: ! text = string.joinfields(args, '') except: print args --- 337,341 ---- def write(self, *args): try: ! text = ''.join(args) except: print args *************** *** 393,397 **** mo = miprog.match(line) if not mo: ! line = string.strip(line) + '\n' self.expand(line) continue --- 392,396 ---- mo = miprog.match(line) if not mo: ! line = line.strip() + '\n' self.expand(line) continue *************** *** 413,417 **** self.expand(line[end:]) else: ! text = string.joinfields(accu, '') self.expand(text) --- 412,416 ---- self.expand(line[end:]) else: ! text = ''.join(accu) self.expand(text) *************** *** 700,707 **** def close_inforef(self): text = self.collectsavings() ! args = string.splitfields(text, ',') ! n = len(args) ! for i in range(n): ! args[i] = string.strip(args[i]) while len(args) < 3: args.append('') node = args[0] --- 699,703 ---- def close_inforef(self): text = self.collectsavings() ! args = [s.strip() for s in text.split(',')] while len(args) < 3: args.append('') node = args[0] *************** *** 711,718 **** def makeref(self): text = self.collectsavings() ! args = string.splitfields(text, ',') ! n = len(args) ! for i in range(n): ! args[i] = string.strip(args[i]) while len(args) < 5: args.append('') nodename = label = args[0] --- 707,711 ---- def makeref(self): text = self.collectsavings() ! args = [s.strip() for s in text.split(',')] while len(args) < 5: args.append('') nodename = label = args[0] *************** *** 730,737 **** def close_uref(self): text = self.collectsavings() ! args = string.splitfields(text, ',') ! n = len(args) ! for i in range(n): ! args[i] = string.strip(args[i]) while len(args) < 2: args.append('') href = args[0] --- 723,727 ---- def close_uref(self): text = self.collectsavings() ! args = [s.strip() for s in text.split(',')] while len(args) < 2: args.append('') href = args[0] *************** *** 753,760 **** def makeimage(self): text = self.collectsavings() ! args = string.splitfields(text, ',') ! n = len(args) ! for i in range(n): ! args[i] = string.strip(args[i]) while len(args) < 5: args.append('') filename = args[0] --- 743,747 ---- def makeimage(self): text = self.collectsavings() ! args = [s.strip() for s in text.split(',')] while len(args) < 5: args.append('') filename = args[0] *************** *** 883,887 **** a, b = mo.span(1) cmd = line[a:b] ! args = string.strip(line[b:]) if self.debugging > 1: print '!'*self.debugging, 'command:', self.skip, self.stack, \ --- 870,874 ---- a, b = mo.span(1) cmd = line[a:b] ! args = line[b:].strip() if self.debugging > 1: print '!'*self.debugging, 'command:', self.skip, self.stack, \ *************** *** 911,915 **** def do_end(self, args): ! words = string.split(args) if not words: print '*** @end w/o args' --- 898,902 ---- def do_end(self, args): ! words = args.split() if not words: print '*** @end w/o args' *************** *** 955,964 **** def do_set(self, args): ! fields = string.splitfields(args, ' ') key = fields[0] if len(fields) == 1: value = 1 else: ! value = string.joinfields(fields[1:], ' ') self.values[key] = value --- 942,951 ---- def do_set(self, args): ! fields = args.split(' ') key = fields[0] if len(fields) == 1: value = 1 else: ! value = ' '.join(fields[1:]) self.values[key] = value *************** *** 1060,1066 **** self.endnode() self.nodelineno = 0 ! parts = string.splitfields(args, ',') while len(parts) < 4: parts.append('') - for i in range(4): parts[i] = string.strip(parts[i]) self.nodelinks = parts [name, next, prev, up] = parts[:4] --- 1047,1052 ---- self.endnode() self.nodelineno = 0 ! parts = [s.strip() for s in args.split(',')] while len(parts) < 4: parts.append('') self.nodelinks = parts [name, next, prev, up] = parts[:4] *************** *** 1084,1088 **** def link(self, label, nodename): if nodename: ! if string.lower(nodename) == '(dir)': addr = '../dir.html' else: --- 1070,1074 ---- def link(self, label, nodename): if nodename: ! if nodename.lower() == '(dir)': addr = '../dir.html' else: *************** *** 1578,1582 **** def do_synindex(self, args): ! words = string.split(args) if len(words) <> 2: print '*** bad @synindex', args --- 1564,1568 ---- def do_synindex(self, args): ! words = args.split() if len(words) <> 2: print '*** bad @synindex', args *************** *** 1595,1599 **** def do_printindex(self, args): ! words = string.split(args) for name in words: if self.whichindex.has_key(name): --- 1581,1585 ---- def do_printindex(self, args): ! words = args.split() for name in words: if self.whichindex.has_key(name): *************** *** 1613,1617 **** junkprog = re.compile('^(@[a-z]+)?{') for key, node in index: ! sortkey = string.lower(key) # Remove leading `@cmd{' from sort key # -- don't bother about the matching `}' --- 1599,1603 ---- junkprog = re.compile('^(@[a-z]+)?{') for key, node in index: ! sortkey = key.lower() # Remove leading `@cmd{' from sort key # -- don't bother about the matching `}' *************** *** 1648,1652 **** cmds.sort() for cmd in cmds: ! print string.ljust(cmd, 20), self.unknown[cmd] --- 1634,1638 ---- cmds.sort() for cmd in cmds: ! print cmd.ljust(20), self.unknown[cmd] *************** *** 1989,1993 **** # Convert a node name into a file name def makefile(nodename): ! nodename = string.strip(nodename) return fixfunnychars(nodename) + '.html' --- 1975,1979 ---- # Convert a node name into a file name def makefile(nodename): ! nodename = nodename.strip() return fixfunnychars(nodename) + '.html' *************** *** 2018,2022 **** lastc = s[-1] if lastc in sequence: ! i = string.index(sequence, lastc) + 1 if i >= len(sequence): if len(s) == 1: --- 2004,2008 ---- lastc = s[-1] if lastc in sequence: ! i = sequence.index(lastc) + 1 if i >= len(sequence): if len(s) == 1: From fdrake@users.sourceforge.net Tue Jun 18 17:15:53 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 18 Jun 2002 09:15:53 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libos.tex,1.88,1.89 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv10294/Doc/lib Modified Files: libos.tex Log Message: Clarified documentation for os.access(). Patch contributed by Sean Reifschneider. Closes SF patch #570618. Index: libos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.88 retrieving revision 1.89 diff -C2 -d -r1.88 -r1.89 *** libos.tex 13 Jun 2002 21:19:25 -0000 1.88 --- libos.tex 18 Jun 2002 16:15:50 -0000 1.89 *************** *** 569,577 **** \begin{funcdesc}{access}{path, mode} ! Check read/write/execute permissions for this process or existence of ! file \var{path}. \var{mode} should be \constant{F_OK} to test the ! existence of \var{path}, or it can be the inclusive OR of one or more ! of \constant{R_OK}, \constant{W_OK}, and \constant{X_OK} to test ! permissions. Return \code{1} if access is allowed, \code{0} if not. See the \UNIX{} man page \manpage{access}{2} for more information. Availability: \UNIX, Windows. --- 569,579 ---- \begin{funcdesc}{access}{path, mode} ! Use the real uid/gid to test for access to \var{path}. Note that most ! operations will use the effective uid/gid, therefore this routine can ! be used in a suid/sgid environment to test if the invoking user has the ! specified access to \var{path}. \var{mode} should be \constant{F_OK} ! to test the existence of \var{path}, or it can be the inclusive OR of ! one or more of \constant{R_OK}, \constant{W_OK}, and \constant{X_OK} to ! test permissions. Return \code{1} if access is allowed, \code{0} if not. See the \UNIX{} man page \manpage{access}{2} for more information. Availability: \UNIX, Windows. From fdrake@users.sourceforge.net Tue Jun 18 17:15:53 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 18 Jun 2002 09:15:53 -0700 Subject: [Python-checkins] python/dist/src/Modules posixmodule.c,2.237,2.238 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv10294/Modules Modified Files: posixmodule.c Log Message: Clarified documentation for os.access(). Patch contributed by Sean Reifschneider. Closes SF patch #570618. Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.237 retrieving revision 2.238 diff -C2 -d -r2.237 -r2.238 *** posixmodule.c 13 Jun 2002 21:22:11 -0000 2.237 --- posixmodule.c 18 Jun 2002 16:15:51 -0000 2.238 *************** *** 737,741 **** PyDoc_STRVAR(posix_access__doc__, "access(path, mode) -> 1 if granted, 0 otherwise\n\ ! Test for access to a file."); static PyObject * --- 737,745 ---- PyDoc_STRVAR(posix_access__doc__, "access(path, mode) -> 1 if granted, 0 otherwise\n\ ! Use the real uid/gid to test for access to a path. Note that most ! operations will use the effective uid/gid, therefore this routine can ! be used in a suid/sgid environment to test if the invoking user has the ! specified access to the path. The mode argument can be F_OK to test ! existance, or the inclusive-OR of R_OK, W_OK, and X_OK."); static PyObject * From fdrake@users.sourceforge.net Tue Jun 18 17:16:48 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 18 Jun 2002 09:16:48 -0700 Subject: [Python-checkins] python/dist/src/Modules posixmodule.c,2.216.4.3,2.216.4.4 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv10591/Modules Modified Files: Tag: release22-maint posixmodule.c Log Message: Clarified documentation for os.access(). Based on patch contributed by Sean Reifschneider. Closes SF patch #570618. Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.216.4.3 retrieving revision 2.216.4.4 diff -C2 -d -r2.216.4.3 -r2.216.4.4 *** posixmodule.c 12 Mar 2002 21:38:31 -0000 2.216.4.3 --- posixmodule.c 18 Jun 2002 16:16:46 -0000 2.216.4.4 *************** *** 727,731 **** static char posix_access__doc__[] = "access(path, mode) -> 1 if granted, 0 otherwise\n\ ! Test for access to a file."; static PyObject * --- 727,735 ---- static char posix_access__doc__[] = "access(path, mode) -> 1 if granted, 0 otherwise\n\ ! Use the real uid/gid to test for access to a path. Note that most ! operations will use the effective uid/gid, therefore this routine can ! be used in a suid/sgid environment to test if the invoking user has the ! specified access to the path. The mode argument can be F_OK to test ! existance, or the inclusive-OR of R_OK, W_OK, and X_OK."; static PyObject * From fdrake@users.sourceforge.net Tue Jun 18 17:16:48 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 18 Jun 2002 09:16:48 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libos.tex,1.74.2.1.2.3,1.74.2.1.2.4 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv10591/Doc/lib Modified Files: Tag: release22-maint libos.tex Log Message: Clarified documentation for os.access(). Based on patch contributed by Sean Reifschneider. Closes SF patch #570618. Index: libos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.74.2.1.2.3 retrieving revision 1.74.2.1.2.4 diff -C2 -d -r1.74.2.1.2.3 -r1.74.2.1.2.4 *** libos.tex 1 May 2002 03:32:25 -0000 1.74.2.1.2.3 --- libos.tex 18 Jun 2002 16:16:46 -0000 1.74.2.1.2.4 *************** *** 550,558 **** \begin{funcdesc}{access}{path, mode} ! Check read/write/execute permissions for this process or existence of ! file \var{path}. \var{mode} should be \constant{F_OK} to test the ! existence of \var{path}, or it can be the inclusive OR of one or more ! of \constant{R_OK}, \constant{W_OK}, and \constant{X_OK} to test ! permissions. Return \code{1} if access is allowed, \code{0} if not. See the \UNIX{} man page \manpage{access}{2} for more information. Availability: \UNIX, Windows. --- 550,560 ---- \begin{funcdesc}{access}{path, mode} ! Use the real uid/gid to test for access to \var{path}. Note that most ! operations will use the effective uid/gid, therefore this routine can ! be used in a suid/sgid environment to test if the invoking user has the ! specified access to \var{path}. \var{mode} should be \constant{F_OK} ! to test the existence of \var{path}, or it can be the inclusive OR of ! one or more of \constant{R_OK}, \constant{W_OK}, and \constant{X_OK} to ! test permissions. Return \code{1} if access is allowed, \code{0} if not. See the \UNIX{} man page \manpage{access}{2} for more information. Availability: \UNIX, Windows. From fdrake@users.sourceforge.net Tue Jun 18 17:17:34 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 18 Jun 2002 09:17:34 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libos.tex,1.53.4.7,1.53.4.8 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv10837/Doc/lib Modified Files: Tag: release21-maint libos.tex Log Message: Clarified documentation for os.access(). Based on patch contributed by Sean Reifschneider. Closes SF patch #570618. Index: libos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.53.4.7 retrieving revision 1.53.4.8 diff -C2 -d -r1.53.4.7 -r1.53.4.8 *** libos.tex 1 May 2002 03:33:02 -0000 1.53.4.7 --- libos.tex 18 Jun 2002 16:17:31 -0000 1.53.4.8 *************** *** 533,541 **** \begin{funcdesc}{access}{path, mode} ! Check read/write/execute permissions for this process or existence of ! file \var{path}. \var{mode} should be \constant{F_OK} to test the ! existence of \var{path}, or it can be the inclusive OR of one or more ! of \constant{R_OK}, \constant{W_OK}, and \constant{X_OK} to test ! permissions. Return \code{1} if access is allowed, \code{0} if not. See the \UNIX{} man page \manpage{access}{2} for more information. Availability: \UNIX{}, Windows. --- 533,543 ---- \begin{funcdesc}{access}{path, mode} ! Use the real uid/gid to test for access to \var{path}. Note that most ! operations will use the effective uid/gid, therefore this routine can ! be used in a suid/sgid environment to test if the invoking user has the ! specified access to \var{path}. \var{mode} should be \constant{F_OK} ! to test the existence of \var{path}, or it can be the inclusive OR of ! one or more of \constant{R_OK}, \constant{W_OK}, and \constant{X_OK} to ! test permissions. Return \code{1} if access is allowed, \code{0} if not. See the \UNIX{} man page \manpage{access}{2} for more information. Availability: \UNIX{}, Windows. From fdrake@users.sourceforge.net Tue Jun 18 17:17:34 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 18 Jun 2002 09:17:34 -0700 Subject: [Python-checkins] python/dist/src/Modules posixmodule.c,2.187.2.4,2.187.2.5 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv10837/Modules Modified Files: Tag: release21-maint posixmodule.c Log Message: Clarified documentation for os.access(). Based on patch contributed by Sean Reifschneider. Closes SF patch #570618. Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.187.2.4 retrieving revision 2.187.2.5 diff -C2 -d -r2.187.2.4 -r2.187.2.5 *** posixmodule.c 8 Apr 2002 04:42:09 -0000 2.187.2.4 --- posixmodule.c 18 Jun 2002 16:17:32 -0000 2.187.2.5 *************** *** 597,601 **** static char posix_access__doc__[] = "access(path, mode) -> 1 if granted, 0 otherwise\n\ ! Test for access to a file."; static PyObject * --- 597,605 ---- static char posix_access__doc__[] = "access(path, mode) -> 1 if granted, 0 otherwise\n\ ! Use the real uid/gid to test for access to a path. Note that most ! operations will use the effective uid/gid, therefore this routine can ! be used in a suid/sgid environment to test if the invoking user has the ! specified access to the path. The mode argument can be F_OK to test ! existance, or the inclusive-OR of R_OK, W_OK, and X_OK."; static PyObject * From gvanrossum@users.sourceforge.net Tue Jun 18 17:22:45 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue, 18 Jun 2002 09:22:45 -0700 Subject: [Python-checkins] python/dist/src/Modules posixmodule.c,2.238,2.239 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv12581 Modified Files: posixmodule.c Log Message: Corect speling and add \n\ to line ends in new docstring for access(). Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.238 retrieving revision 2.239 diff -C2 -d -r2.238 -r2.239 *** posixmodule.c 18 Jun 2002 16:15:51 -0000 2.238 --- posixmodule.c 18 Jun 2002 16:22:43 -0000 2.239 *************** *** 737,745 **** PyDoc_STRVAR(posix_access__doc__, "access(path, mode) -> 1 if granted, 0 otherwise\n\ ! Use the real uid/gid to test for access to a path. Note that most ! operations will use the effective uid/gid, therefore this routine can ! be used in a suid/sgid environment to test if the invoking user has the ! specified access to the path. The mode argument can be F_OK to test ! existance, or the inclusive-OR of R_OK, W_OK, and X_OK."); static PyObject * --- 737,745 ---- PyDoc_STRVAR(posix_access__doc__, "access(path, mode) -> 1 if granted, 0 otherwise\n\ ! Use the real uid/gid to test for access to a path. Note that most\n\ ! operations will use the effective uid/gid, therefore this routine can\n\ ! be used in a suid/sgid environment to test if the invoking user has the\n\ ! specified access to the path. The mode argument can be F_OK to test\n\ ! existence, or the inclusive-OR of R_OK, W_OK, and X_OK."); static PyObject * From gvanrossum@users.sourceforge.net Tue Jun 18 17:24:17 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue, 18 Jun 2002 09:24:17 -0700 Subject: [Python-checkins] python/dist/src/Modules posixmodule.c,2.216.4.4,2.216.4.5 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv13059 Modified Files: Tag: release22-maint posixmodule.c Log Message: Corect speling and add \n\ to line ends in new docstring for access(). Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.216.4.4 retrieving revision 2.216.4.5 diff -C2 -d -r2.216.4.4 -r2.216.4.5 *** posixmodule.c 18 Jun 2002 16:16:46 -0000 2.216.4.4 --- posixmodule.c 18 Jun 2002 16:24:15 -0000 2.216.4.5 *************** *** 727,735 **** static char posix_access__doc__[] = "access(path, mode) -> 1 if granted, 0 otherwise\n\ ! Use the real uid/gid to test for access to a path. Note that most ! operations will use the effective uid/gid, therefore this routine can ! be used in a suid/sgid environment to test if the invoking user has the ! specified access to the path. The mode argument can be F_OK to test ! existance, or the inclusive-OR of R_OK, W_OK, and X_OK."; static PyObject * --- 727,735 ---- static char posix_access__doc__[] = "access(path, mode) -> 1 if granted, 0 otherwise\n\ ! Use the real uid/gid to test for access to a path. Note that most\n\ ! operations will use the effective uid/gid, therefore this routine can\n\ ! be used in a suid/sgid environment to test if the invoking user has the\n\ ! specified access to the path. The mode argument can be F_OK to test\n\ ! existence, or the inclusive-OR of R_OK, W_OK, and X_OK."; static PyObject * From gvanrossum@users.sourceforge.net Tue Jun 18 17:26:45 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue, 18 Jun 2002 09:26:45 -0700 Subject: [Python-checkins] python/dist/src/Modules posixmodule.c,2.187.2.5,2.187.2.6 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv13839 Modified Files: Tag: release21-maint posixmodule.c Log Message: Corect speling and add \n\ to line ends in new docstring for access(). Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.187.2.5 retrieving revision 2.187.2.6 diff -C2 -d -r2.187.2.5 -r2.187.2.6 *** posixmodule.c 18 Jun 2002 16:17:32 -0000 2.187.2.5 --- posixmodule.c 18 Jun 2002 16:26:43 -0000 2.187.2.6 *************** *** 597,605 **** static char posix_access__doc__[] = "access(path, mode) -> 1 if granted, 0 otherwise\n\ ! Use the real uid/gid to test for access to a path. Note that most ! operations will use the effective uid/gid, therefore this routine can ! be used in a suid/sgid environment to test if the invoking user has the ! specified access to the path. The mode argument can be F_OK to test ! existance, or the inclusive-OR of R_OK, W_OK, and X_OK."; static PyObject * --- 597,605 ---- static char posix_access__doc__[] = "access(path, mode) -> 1 if granted, 0 otherwise\n\ ! Use the real uid/gid to test for access to a path. Note that most\n\ ! operations will use the effective uid/gid, therefore this routine can\n\ ! be used in a suid/sgid environment to test if the invoking user has the\n\ ! specified access to the path. The mode argument can be F_OK to test\n\ ! existence, or the inclusive-OR of R_OK, W_OK, and X_OK."; static PyObject * From gvanrossum@users.sourceforge.net Tue Jun 18 17:44:16 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue, 18 Jun 2002 09:44:16 -0700 Subject: [Python-checkins] python/dist/src/Objects typeobject.c,2.154,2.155 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv20837 Modified Files: typeobject.c Log Message: Patch from SF bug 570483 (Tim Northover). In a fresh interpreter, type.mro(tuple) would segfault, because PyType_Ready() isn't called for tuple yet. To fix, call PyType_Ready(type) if type->tp_dict is NULL. Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.154 retrieving revision 2.155 diff -C2 -d -r2.154 -r2.155 *** typeobject.c 14 Jun 2002 02:27:07 -0000 2.154 --- typeobject.c 18 Jun 2002 16:44:14 -0000 2.155 *************** *** 743,746 **** --- 743,751 ---- PyObject *bases, *result; + if(type->tp_dict == NULL) { + if(PyType_Ready(type) < 0) + return NULL; + } + bases = type->tp_bases; n = PyTuple_GET_SIZE(bases); From gvanrossum@users.sourceforge.net Tue Jun 18 17:45:09 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue, 18 Jun 2002 09:45:09 -0700 Subject: [Python-checkins] python/dist/src/Misc ACKS,1.182,1.183 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv21098 Modified Files: ACKS Log Message: Patch from SF bug 570483 (Tim Northover). In a fresh interpreter, type.mro(tuple) would segfault, because PyType_Ready() isn't called for tuple yet. To fix, call PyType_Ready(type) if type->tp_dict is NULL. Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.182 retrieving revision 1.183 diff -C2 -d -r1.182 -r1.183 *** ACKS 14 Jun 2002 21:31:18 -0000 1.182 --- ACKS 18 Jun 2002 16:44:57 -0000 1.183 *************** *** 337,340 **** --- 337,341 ---- Bill Noon Stefan Norberg + Tim Northover Joe Norton Neal Norwitz From gvanrossum@users.sourceforge.net Tue Jun 18 17:47:03 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue, 18 Jun 2002 09:47:03 -0700 Subject: [Python-checkins] python/dist/src/Objects typeobject.c,2.126.4.16,2.126.4.17 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv22197 Modified Files: Tag: release22-maint typeobject.c Log Message: Backport: Patch from SF bug 570483 (Tim Northover). In a fresh interpreter, type.mro(tuple) would segfault, because PyType_Ready() isn't called for tuple yet. To fix, call PyType_Ready(type) if type->tp_dict is NULL. Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.126.4.16 retrieving revision 2.126.4.17 diff -C2 -d -r2.126.4.16 -r2.126.4.17 *** typeobject.c 14 Jun 2002 02:28:23 -0000 2.126.4.16 --- typeobject.c 18 Jun 2002 16:46:57 -0000 2.126.4.17 *************** *** 734,737 **** --- 734,742 ---- PyObject *bases, *result; + if(type->tp_dict == NULL) { + if(PyType_Ready(type) < 0) + return NULL; + } + bases = type->tp_bases; n = PyTuple_GET_SIZE(bases); From gvanrossum@users.sourceforge.net Tue Jun 18 17:49:47 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue, 18 Jun 2002 09:49:47 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_descr.py,1.141,1.142 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv23262 Modified Files: test_descr.py Log Message: Patch from SF bug 570483 (Tim Northover). In a fresh interpreter, type.mro(tuple) would segfault, because PyType_Ready() isn't called for tuple yet. To fix, call PyType_Ready(type) if type->tp_dict is NULL. Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.141 retrieving revision 1.142 diff -C2 -d -r1.141 -r1.142 *** test_descr.py 14 Jun 2002 02:35:45 -0000 1.141 --- test_descr.py 18 Jun 2002 16:49:45 -0000 1.142 *************** *** 3170,3173 **** --- 3170,3179 ---- pass + if verbose: + print "Testing SF bug 570483..." + # Another segfault only when run early + # (before PyType_Ready(tuple) is called) + type.mro(tuple) + def test_main(): do_this_first() From jhylton@users.sourceforge.net Tue Jun 18 17:53:44 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 18 Jun 2002 09:53:44 -0700 Subject: [Python-checkins] python/dist/src/Lib posixpath.py,1.43,1.43.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv25579 Modified Files: Tag: release21-maint posixpath.py Log Message: Add a special case code to deal with unexpected large files. # On a Linux with large file support (LFS) using a Python without LFS, # stat() will raise EOVERFLOW. This unambiguously indicates that the # file exists because it only occurs when the size of the file can't # find into the stat struct. This change is only needed for Python 2.1, because LFS is automatically configured starting with Python 2.2. Index: posixpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/posixpath.py,v retrieving revision 1.43 retrieving revision 1.43.2.1 diff -C2 -d -r1.43 -r1.43.2.1 *** posixpath.py 16 Apr 2001 18:12:04 -0000 1.43 --- posixpath.py 18 Jun 2002 16:53:42 -0000 1.43.2.1 *************** *** 166,174 **** # This is false for dangling symbolic links. def exists(path): """Test whether a path exists. Returns false for broken symbolic links""" try: st = os.stat(path) ! except os.error: return 0 return 1 --- 166,194 ---- # This is false for dangling symbolic links. + # In some cases, an error from stat() means the file does exist. + + # On a Linux with large file support (LFS) using a Python without LFS, + # stat() will raise EOVERFLOW. This unambiguously indicates that the + # file exists because it only occurs when the size of the file can't + # find into the stat struct. + + _errno_for_exists = [] + + try: + import errno + except ImportError: + pass + else: + EOVERFLOW = getattr(errno, "EOVERFLOW", None) + if EOVERFLOW is not None: + _errno_for_exists.append(EOVERFLOW) + def exists(path): """Test whether a path exists. Returns false for broken symbolic links""" try: st = os.stat(path) ! except os.error, err: ! if err.errno in _errno_for_exists: ! return 1 return 0 return 1 From fdrake@users.sourceforge.net Tue Jun 18 19:24:21 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 18 Jun 2002 11:24:21 -0700 Subject: [Python-checkins] python/dist/src/Doc/perl python.perl,1.126,1.127 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/perl In directory usw-pr-cvs1:/tmp/cvs-serv1167 Modified Files: python.perl Log Message: Refactor the generation of signature lines for funcdesc, methoddesc, and friends. This was part of the changes to the presentation of signature lines, but does not include any of the aspects that people questioned. Index: python.perl =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/perl/python.perl,v retrieving revision 1.126 retrieving revision 1.127 diff -C2 -d -r1.126 -r1.127 *** python.perl 17 Jun 2002 15:01:05 -0000 1.126 --- python.perl 18 Jun 2002 18:24:16 -0000 1.127 *************** *** 173,178 **** # from local repositories. - # \file and \samp are at the end of this file since they screw up fontlock. - sub do_cmd_pytype{ return @_[0]; } sub do_cmd_makevar{ --- 173,176 ---- *************** *** 906,910 **** $TLSTART = ''; ! $TLEND = ''; sub cfuncline_helper($$$){ --- 904,908 ---- $TLSTART = ''; ! $TLEND = ' '; sub cfuncline_helper($$$){ *************** *** 1018,1021 **** --- 1016,1025 ---- } + sub funcline_helper($$$){ + my($first, $idxitem, $arglist) = @_; + return (($first ? '
    ' : '') + . "
    $idxitem($arglist)\n
    "); + } + sub do_env_funcdesc{ local($_) = @_; *************** *** 1027,1031 **** $idx =~ s/ \(.*\)//; $idx =~ s/\(\)<\/tt>/<\/tt>/; ! return "
    $idx($arg_list)\n
    " . $_ . '
    '; } --- 1031,1035 ---- $idx =~ s/ \(.*\)//; $idx =~ s/\(\)<\/tt>/<\/tt>/; ! return funcline_helper(1, $idx, $arg_list) . $_ . '
    '; } *************** *** 1034,1042 **** my $function_name = next_argument(); my $arg_list = convert_args(next_argument()); ! return "
    $function_name" ! . "($arg_list)\n" ! . '
    ' ! . $_ ! . '
    '; } --- 1038,1043 ---- my $function_name = next_argument(); my $arg_list = convert_args(next_argument()); ! my $prefix = "$function_name"; ! return funcline_helper(1, $prefix, $arg_list) . $_ . ''; } *************** *** 1049,1053 **** $prefix =~ s/\(\)//; ! return "
    $prefix($arg_list)\n
    " . $_; } --- 1050,1054 ---- $prefix =~ s/\(\)//; ! return funcline_helper(0, $prefix, $arg_list) . $_; } *************** *** 1058,1062 **** my $prefix = "$function_name"; ! return "
    $prefix($arg_list)\n
    " . $_; } --- 1059,1063 ---- my $prefix = "$function_name"; ! return funcline_helper(0, $prefix, $arg_list) . $_; } *************** *** 1124,1128 **** my $excname = next_argument(); my $idx = make_str_index_entry("$excname"); ! return ("
    ${TLSTART}exception$TLEND $idx" . "\n
    " . $_ --- 1125,1129 ---- my $excname = next_argument(); my $idx = make_str_index_entry("$excname"); ! return ("
    ${TLSTART}exception$TLEND$idx" . "\n
    " . $_ *************** *** 1140,1147 **** "$THIS_CLASS ($what in $THIS_MODULE)" ); $idx =~ s/ \(.*\)//; ! return ("
    $TLSTART$what$TLEND $idx" ! . "($arg_list)\n
    " ! . $_ ! . '
    '); } --- 1141,1146 ---- "$THIS_CLASS ($what in $THIS_MODULE)" ); $idx =~ s/ \(.*\)//; ! my $prefix = "$TLSTART$what$TLEND$idx"; ! return funcline_helper(1, $prefix, $arg_list) . $_ . '
    '; } *************** *** 1156,1162 **** "$THIS_CLASS (class in $THIS_MODULE)"); $idx =~ s/ \(.*\)//; ! return ("
    ${TLSTART}class$TLEND $idx\n
    " ! . $_ ! . '
    '); } --- 1155,1161 ---- "$THIS_CLASS (class in $THIS_MODULE)"); $idx =~ s/ \(.*\)//; ! my $prefix = "${TLSTART}class$TLEND$idx"; ! # Can't use funcline_helper() since there is no args list. ! return "
    $prefix\n
    " . $_ . '
    '; } *************** *** 1181,1185 **** $idx =~ s/ \(.*\)//; $idx =~ s/\(\)//; ! return "
    $idx($arg_list)\n
    " . $_ . '
    '; } --- 1180,1184 ---- $idx =~ s/ \(.*\)//; $idx =~ s/\(\)//; ! return funcline_helper(1, $idx, $arg_list) . $_ . '
    '; } *************** *** 1200,1205 **** $idx =~ s/ \(.*\)//; $idx =~ s/\(\)//; ! return "
    $idx($arg_list)\n
    " ! . $_; } --- 1199,1203 ---- $idx =~ s/ \(.*\)//; $idx =~ s/\(\)//; ! return funcline_helper(0, $idx, $arg_list) . $_; } *************** *** 1210,1215 **** my $method = next_argument(); my $arg_list = convert_args(next_argument()); ! return "
    $method($arg_list)\n
    " ! . $_; } --- 1208,1212 ---- my $method = next_argument(); my $arg_list = convert_args(next_argument()); ! return funcline_helper(0, $method, $arg_list) . $_; } *************** *** 1219,1225 **** my $method = next_argument(); my $arg_list = convert_args(next_argument()); ! return "
    $method($arg_list)\n
    " ! . $_ ! . '
    '; } --- 1216,1220 ---- my $method = next_argument(); my $arg_list = convert_args(next_argument()); ! return funcline_helper(1, $method, $arg_list) . $_ . ''; } From fdrake@users.sourceforge.net Tue Jun 18 19:30:30 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 18 Jun 2002 11:30:30 -0700 Subject: [Python-checkins] python/dist/src/Doc/perl python.perl,1.127,1.128 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/perl In directory usw-pr-cvs1:/tmp/cvs-serv3933 Modified Files: python.perl Log Message: \productioncont: Replace leading spaces with   so that it's possible to control the indentation of continuation lines. cfuncline_helper(): Only mark the argument names are , not the whole argument list. This leaves the argument types in the same font as the return type. Based on a casual suggestion from Guido. Index: python.perl =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/perl/python.perl,v retrieving revision 1.127 retrieving revision 1.128 diff -C2 -d -r1.127 -r1.128 *** python.perl 18 Jun 2002 18:24:16 -0000 1.127 --- python.perl 18 Jun 2002 18:30:28 -0000 1.128 *************** *** 809,812 **** --- 809,813 ---- local($_) = @_; my $defn = next_argument(); + $defn =~ s/^( +)/' ' x length $1/e; return ("\n" . "  \n" *************** *** 912,915 **** --- 913,918 ---- $idx =~ s/ \(.*\)//; $idx =~ s/\(\)//; # ???? - why both of these? + $args =~ s/(\s|\*)([a-z_][a-z_0-9]*),/\1\2<\/var>,/g; + $args =~ s/(\s|\*)([a-z_][a-z_0-9]*)$/\1\2<\/var>/s; return "$type $idx($args)"; } From gvanrossum@users.sourceforge.net Tue Jun 18 19:35:17 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue, 18 Jun 2002 11:35:17 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_socket.py,1.37,1.38 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv5996 Modified Files: test_socket.py Log Message: Michael fixed the race conditions and removed the sleeps. This is his SF patch 569697. I renamed main() to test_main() again so that this is run as part of the standard test suite. Index: test_socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** test_socket.py 13 Jun 2002 20:24:17 -0000 1.37 --- test_socket.py 18 Jun 2002 18:35:13 -0000 1.38 *************** *** 38,41 **** --- 38,77 ---- class ThreadableTest: + """Threadable Test class + + The ThreadableTest class makes it easy to create a threaded + client/server pair from an existing unit test. To create a + new threaded class from an existing unit test, use multiple + inheritance: + + class NewClass (OldClass, ThreadableTest): + pass + + This class defines two new fixture functions with obvious + purposes for overriding: + + clientSetUp () + clientTearDown () + + Any new test functions within the class must then define + tests in pairs, where the test name is preceeded with a + '_' to indicate the client portion of the test. Ex: + + def testFoo(self): + # Server portion + + def _testFoo(self): + # Client portion + + Any exceptions raised by the clients during their tests + are caught and transferred to the main thread to alert + the testing framework. + + Note, the server setup function cannot call any blocking + functions that rely on the client thread during setup, + unless serverExplicityReady() is called just before + the blocking call (such as in setting up a client/server + connection and performing the accept() in setUp(). + """ def __init__(self): *************** *** 46,51 **** self.tearDown = self._tearDown def _setUp(self): ! self.ready = threading.Event() self.done = threading.Event() self.queue = Queue.Queue(1) --- 82,95 ---- self.tearDown = self._tearDown + def serverExplicitReady(self): + """This method allows the server to explicitly indicate that + it wants the client thread to proceed. This is useful if the + server is about to execute a blocking routine that is + dependent upon the client thread during its setup routine.""" + self.server_ready.set() + def _setUp(self): ! self.server_ready = threading.Event() ! self.client_ready = threading.Event() self.done = threading.Event() self.queue = Queue.Queue(1) *************** *** 60,64 **** self.__setUp() ! self.ready.wait() def _tearDown(self): --- 104,110 ---- self.__setUp() ! if not self.server_ready.isSet(): ! self.server_ready.set() ! self.client_ready.wait() def _tearDown(self): *************** *** 71,75 **** def clientRun(self, test_func): ! self.ready.set() self.clientSetUp() if not callable(test_func): --- 117,122 ---- def clientRun(self, test_func): ! self.server_ready.wait() ! self.client_ready.set() self.clientSetUp() if not callable(test_func): *************** *** 118,121 **** --- 165,171 ---- def setUp(self): ThreadedTCPSocketTest.setUp(self) + # Indicate explicitly we're ready for the client thread to + # proceed and then perform the blocking call to accept + self.serverExplicitReady() conn, addr = self.serv.accept() self.cli_conn = conn *************** *** 370,374 **** def _testRecvFrom(self): - time.sleep(1) # Give server a chance to set up self.cli.sendto(MSG, 0, (HOST, PORT)) --- 420,423 ---- *************** *** 408,417 **** def _testAccept(self): - time.sleep(1) self.cli.connect((HOST, PORT)) def testConnect(self): """Testing non-blocking connect.""" - time.sleep(1) conn, addr = self.serv.accept() --- 457,464 ---- *************** *** 439,443 **** def _testRecv(self): self.cli.connect((HOST, PORT)) - time.sleep(1) self.cli.send(MSG) --- 486,489 ---- *************** *** 499,503 **** self.cli_file.flush() ! def main(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(GeneralModuleTests)) --- 545,549 ---- self.cli_file.flush() ! def test_main(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(GeneralModuleTests)) *************** *** 509,511 **** if __name__ == "__main__": ! main() --- 555,557 ---- if __name__ == "__main__": ! test_main() From jhylton@users.sourceforge.net Tue Jun 18 19:40:57 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 18 Jun 2002 11:40:57 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils/command build_ext.py,1.84,1.85 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory usw-pr-cvs1:/tmp/cvs-serv8560 Modified Files: build_ext.py Log Message: Only import msvccompiler on win32 platforms. Index: build_ext.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/build_ext.py,v retrieving revision 1.84 retrieving revision 1.85 diff -C2 -d -r1.84 -r1.85 *** build_ext.py 13 Jun 2002 17:32:20 -0000 1.84 --- build_ext.py 18 Jun 2002 18:40:54 -0000 1.85 *************** *** 625,639 **** # to need it mentioned explicitly, though, so that's what we do. # Append '_d' to the python import library on debug builds. ! from distutils.msvccompiler import MSVCCompiler ! if sys.platform == "win32" and \ ! not isinstance(self.compiler, MSVCCompiler): ! template = "python%d%d" ! if self.debug: ! template = template + '_d' ! pythonlib = (template % ! (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff)) ! # don't extend ext.libraries, it may be shared with other ! # extensions, it is a reference to the original list ! return ext.libraries + [pythonlib] elif sys.platform == "os2emx": # EMX/GCC requires the python library explicitly, and I --- 625,639 ---- # to need it mentioned explicitly, though, so that's what we do. # Append '_d' to the python import library on debug builds. ! if sys.platform == "win32": ! from distutils.msvccompiler import MSVCCompiler ! if not isinstance(self.compiler, MSVCCompiler): ! template = "python%d%d" ! if self.debug: ! template = template + '_d' ! pythonlib = (template % ! (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff)) ! # don't extend ext.libraries, it may be shared with other ! # extensions, it is a reference to the original list ! return ext.libraries + [pythonlib] elif sys.platform == "os2emx": # EMX/GCC requires the python library explicitly, and I From fdrake@users.sourceforge.net Tue Jun 18 19:42:03 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 18 Jun 2002 11:42:03 -0700 Subject: [Python-checkins] python/dist/src/Doc/ref ref5.tex,1.61,1.62 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv9151 Modified Files: ref5.tex Log Message: Played contortionist games with the argument_list production so it might be easier to understand. This relates to SF bug #493243, which will be closed. Index: ref5.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref5.tex,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** ref5.tex 21 May 2002 18:19:49 -0000 1.61 --- ref5.tex 18 Jun 2002 18:42:01 -0000 1.62 *************** *** 423,430 **** {\token{primary} "(" [\token{argument_list} [","]] ")"} \production{argument_list} ! {\token{positional_arguments} ["," \token{keyword_arguments}} ! \productioncont{ ["," "*" \token{expression} ["," "**" \token{expression}]]]} ! \productioncont{| \token{keyword_arguments} ["," "*" \token{expression}} ! \productioncont{ ["," "**" \token{expression}]]} \productioncont{| "*" \token{expression} ["," "**" \token{expression}]} \productioncont{| "**" \token{expression}} --- 423,430 ---- {\token{primary} "(" [\token{argument_list} [","]] ")"} \production{argument_list} ! {\token{positional_arguments} ["," \token{keyword_arguments} ! ["," "*" \token{expression} ["," "**" \token{expression}]]]} ! \productioncont{| \token{keyword_arguments} ["," "*" \token{expression} ! ["," "**" \token{expression}]]} \productioncont{| "*" \token{expression} ["," "**" \token{expression}]} \productioncont{| "**" \token{expression}} From jhylton@users.sourceforge.net Tue Jun 18 19:42:43 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 18 Jun 2002 11:42:43 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils ccompiler.py,1.45,1.46 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv9464 Modified Files: ccompiler.py Log Message: Add a default implementation of compile() to the base class. The default implementation calls _compile() to compile individual files. This method must be implemented by the subclass. This change factors out most of the remaining common code in all the compilers except mwerks. Index: ccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/ccompiler.py,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** ccompiler.py 13 Jun 2002 17:26:30 -0000 1.45 --- ccompiler.py 18 Jun 2002 18:42:41 -0000 1.46 *************** *** 645,650 **** Raises CompileError on failure. """ - pass def create_static_lib (self, --- 645,669 ---- Raises CompileError on failure. """ + # A concrete compiler class can either override this method + # entirely or implement _compile(). + + macros, objects, extra_postargs, pp_opts, build = \ + self._setup_compile(output_dir, macros, include_dirs, sources, + depends, extra_postargs) + cc_args = self._get_cc_args(pp_opts, debug, extra_preargs) + + for obj, (src, ext) in build.items(): + self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts) + + # Return *all* object filenames, not just the ones we just built. + return objects + + def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts): + """Compile 'src' to product 'obj'.""" + + # A concrete compiler class that does not override compile() + # should implement _compile(). + pass def create_static_lib (self, From jhylton@users.sourceforge.net Tue Jun 18 19:45:41 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 18 Jun 2002 11:45:41 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils unixccompiler.py,1.45,1.46 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv10802 Modified Files: unixccompiler.py Log Message: Add implementation of _compile() and use default compile() method. Index: unixccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/unixccompiler.py,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** unixccompiler.py 13 Jun 2002 17:28:18 -0000 1.45 --- unixccompiler.py 18 Jun 2002 18:45:39 -0000 1.46 *************** *** 106,127 **** raise CompileError, msg ! def compile(self, sources, ! output_dir=None, macros=None, include_dirs=None, debug=0, ! extra_preargs=None, extra_postargs=None, depends=None): ! ! macros, objects, extra_postargs, pp_opts, build = \ ! self._setup_compile(output_dir, macros, include_dirs, sources, ! depends, extra_postargs) ! cc_args = self._get_cc_args(pp_opts, debug, extra_preargs) ! ! for obj, (src, ext) in build.items(): ! try: ! self.spawn(self.compiler_so + cc_args + ! [src, '-o', obj] + extra_postargs) ! except DistutilsExecError, msg: ! raise CompileError, msg ! ! # Return *all* object filenames, not just the ones we just built. ! return objects def create_static_lib(self, objects, output_libname, --- 106,115 ---- raise CompileError, msg ! def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts): ! try: ! self.spawn(self.compiler_so + cc_args + [src, '-o', obj] + ! extra_postargs) ! except DistutilsExecError, msg: ! raise CompileError, msg def create_static_lib(self, objects, output_libname, From jhylton@users.sourceforge.net Tue Jun 18 19:46:46 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 18 Jun 2002 11:46:46 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils emxccompiler.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv11186 Modified Files: emxccompiler.py Log Message: Add implementation of _compile() and use default compile() method. Index: emxccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/emxccompiler.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** emxccompiler.py 13 Jun 2002 17:28:18 -0000 1.4 --- emxccompiler.py 18 Jun 2002 18:46:44 -0000 1.5 *************** *** 77,115 **** # __init__ () ! # not much different of the compile method in UnixCCompiler, ! # but we have to insert some lines in the middle of it, so ! # we put here a adapted version of it. ! # (If we would call compile() in the base class, it would do some ! # initializations a second time, this is why all is done here.) ! ! def compile(self, sources, ! output_dir=None, macros=None, include_dirs=None, debug=0, ! extra_preargs=None, extra_postargs=None, depends=None): ! ! macros, objects, extra_postargs, pp_opts, build = \ ! self._setup_compile(output_dir, macros, include_dirs, sources, ! depends, extra_postargs) ! cc_args = self._get_cc_args(pp_opts, debug, extra_preargs) ! ! for obj, (src, ext) in build.items(): ! if ext == '.rc': ! # gcc requires '.rc' compiled to binary ('.res') files !!! ! try: ! self.spawn (["rc","-r",src]) ! except DistutilsExecError, msg: ! raise CompileError, msg ! else: # for other files use the C-compiler ! try: ! self.spawn (self.compiler_so + cc_args + ! [src, '-o', obj] + ! extra_postargs) ! except DistutilsExecError, msg: ! raise CompileError, msg ! ! # Return *all* object filenames, not just the ones we just built. ! return objects ! ! # compile () ! def link (self, --- 77,93 ---- # __init__ () ! def _compile(self, obj, src, ext, cc_args, extra_postargs): ! if ext == '.rc': ! # gcc requires '.rc' compiled to binary ('.res') files !!! ! try: ! self.spawn(["rc", "-r", src]) ! except DistutilsExecError, msg: ! raise CompileError, msg ! else: # for other files use the C-compiler ! try: ! self.spawn(self.compiler_so + cc_args + [src, '-o', obj] + ! extra_postargs) ! except DistutilsExecError, msg: ! raise CompileError, msg def link (self, From jhylton@users.sourceforge.net Tue Jun 18 19:48:58 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 18 Jun 2002 11:48:58 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils cygwinccompiler.py,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv11987 Modified Files: cygwinccompiler.py Log Message: Add implementation of _compile() and use default compile() method. Index: cygwinccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/cygwinccompiler.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** cygwinccompiler.py 13 Jun 2002 17:28:18 -0000 1.17 --- cygwinccompiler.py 18 Jun 2002 18:48:55 -0000 1.18 *************** *** 114,148 **** # __init__ () - # not much different of the compile method in UnixCCompiler, - # but we have to insert some lines in the middle of it, so - # we put here a adapted version of it. - # (If we would call compile() in the base class, it would do some - # initializations a second time, this is why all is done here.) - def compile(self, sources, - output_dir=None, macros=None, include_dirs=None, debug=0, - extra_preargs=None, extra_postargs=None, depends=None): - - macros, objects, extra_postargs, pp_opts, build = \ - self._setup_compile(output_dir, macros, include_dirs, sources, - depends, extra_postargs) - cc_args = self._get_cc_args(pp_opts, debug, extra_preargs) ! for obj, (src, ext) in build.items(): ! if ext == '.rc' or ext == '.res': ! # gcc needs '.res' and '.rc' compiled to object files !!! ! try: ! self.spawn (["windres","-i",src,"-o",obj]) ! except DistutilsExecError, msg: ! raise CompileError, msg ! else: # for other files use the C-compiler ! try: ! self.spawn (self.compiler_so + cc_args + ! [src, '-o', obj] + ! extra_postargs) ! except DistutilsExecError, msg: ! raise CompileError, msg ! ! # Return *all* object filenames, not just the ones we just built. ! return objects def link (self, --- 114,131 ---- # __init__ () ! def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts): ! if ext == '.rc' or ext == '.res': ! # gcc needs '.res' and '.rc' compiled to object files !!! ! try: ! self.spawn(["windres", "-i", src, "-o", obj]) ! except DistutilsExecError, msg: ! raise CompileError, msg ! else: # for other files use the C-compiler ! try: ! self.spawn(self.compiler_so + cc_args + [src, '-o', obj] + ! extra_postargs) ! except DistutilsExecError, msg: ! raise CompileError, msg def link (self, From fdrake@users.sourceforge.net Tue Jun 18 19:51:32 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 18 Jun 2002 11:51:32 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libmimify.tex,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv13069/lib Modified Files: libmimify.tex Log Message: Note the limitation that mime_decode_header() only works for Latin-1. Closes SF bug #551912. Index: libmimify.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libmimify.tex,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** libmimify.tex 6 Jul 2001 19:28:48 -0000 1.11 --- libmimify.tex 18 Jun 2002 18:51:30 -0000 1.12 *************** *** 49,52 **** --- 49,53 ---- \begin{funcdesc}{mime_decode_header}{line} Return a decoded version of the encoded header line in \var{line}. + This only supports the ISO 8859-1 charset (Latin-1). \end{funcdesc} From fdrake@users.sourceforge.net Tue Jun 18 19:51:51 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 18 Jun 2002 11:51:51 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libmimify.tex,1.11,1.11.18.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv13234/lib Modified Files: Tag: release22-maint libmimify.tex Log Message: Note the limitation that mime_decode_header() only works for Latin-1. Closes SF bug #551912. Index: libmimify.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libmimify.tex,v retrieving revision 1.11 retrieving revision 1.11.18.1 diff -C2 -d -r1.11 -r1.11.18.1 *** libmimify.tex 6 Jul 2001 19:28:48 -0000 1.11 --- libmimify.tex 18 Jun 2002 18:51:49 -0000 1.11.18.1 *************** *** 49,52 **** --- 49,53 ---- \begin{funcdesc}{mime_decode_header}{line} Return a decoded version of the encoded header line in \var{line}. + This only supports the ISO 8859-1 charset (Latin-1). \end{funcdesc} From fdrake@users.sourceforge.net Tue Jun 18 19:52:18 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 18 Jun 2002 11:52:18 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libmimify.tex,1.10,1.10.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv13687/lib Modified Files: Tag: release21-maint libmimify.tex Log Message: Note the limitation that mime_decode_header() only works for Latin-1. Closes SF bug #551912. Index: libmimify.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libmimify.tex,v retrieving revision 1.10 retrieving revision 1.10.8.1 diff -C2 -d -r1.10 -r1.10.8.1 *** libmimify.tex 4 Apr 2000 20:42:38 -0000 1.10 --- libmimify.tex 18 Jun 2002 18:52:16 -0000 1.10.8.1 *************** *** 49,52 **** --- 49,53 ---- \begin{funcdesc}{mime_decode_header}{line} Return a decoded version of the encoded header line in \var{line}. + This only supports the ISO 8859-1 charset (Latin-1). \end{funcdesc} From jhylton@users.sourceforge.net Tue Jun 18 20:08:48 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 18 Jun 2002 12:08:48 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils msvccompiler.py,1.48,1.49 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv20650 Modified Files: msvccompiler.py Log Message: Define NDEBUG for releae builds, just like Python. XXX Why doesn't distutils on Windows use the same set of flags as Python? Index: msvccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/msvccompiler.py,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** msvccompiler.py 13 Jun 2002 17:28:18 -0000 1.48 --- msvccompiler.py 18 Jun 2002 19:08:40 -0000 1.49 *************** *** 234,238 **** self.preprocess_options = None ! self.compile_options = [ '/nologo', '/Ox', '/MD', '/W3', '/GX' ] self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3', '/GX', '/Z7', '/D_DEBUG'] --- 234,239 ---- self.preprocess_options = None ! self.compile_options = [ '/nologo', '/Ox', '/MD', '/W3', '/GX' , ! '/DNDEBUG'] self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3', '/GX', '/Z7', '/D_DEBUG'] From fdrake@users.sourceforge.net Tue Jun 18 20:17:17 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 18 Jun 2002 12:17:17 -0700 Subject: [Python-checkins] python/dist/src/Doc/ref ref2.tex,1.36,1.37 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv24337/ref Modified Files: ref2.tex Log Message: Add a note about "as" not being a keyword, though it has special meaning when used as part of the import statement. Note that both "as" and "None" becoming keywords in the future. Closes SF bug #553262. Index: ref2.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref2.tex,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** ref2.tex 23 Apr 2002 20:04:46 -0000 1.36 --- ref2.tex 18 Jun 2002 19:17:14 -0000 1.37 *************** *** 273,276 **** --- 273,283 ---- % When adding keywords, use reswords.py for reformatting + Note that although the identifier \code{as} can be used as part of the + syntax of \keyword{import} statements, it is not currently a reserved + word. + + In some future version of Python, the identifiers \code{as} and + \code{None} will both become keywords. + \subsection{Reserved classes of identifiers\label{id-classes}} From fdrake@users.sourceforge.net Tue Jun 18 20:18:24 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 18 Jun 2002 12:18:24 -0700 Subject: [Python-checkins] python/dist/src/Doc/ref ref2.tex,1.23,1.23.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv24640/ref Modified Files: Tag: release21-maint ref2.tex Log Message: Add a note about "as" not being a keyword, though it has special meaning when used as part of the import statement. Note that both "as" and "None" becoming keywords in the future. Closes SF bug #553262. Index: ref2.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref2.tex,v retrieving revision 1.23 retrieving revision 1.23.4.1 diff -C2 -d -r1.23 -r1.23.4.1 *** ref2.tex 14 Feb 2001 04:03:51 -0000 1.23 --- ref2.tex 18 Jun 2002 19:18:21 -0000 1.23.4.1 *************** *** 281,284 **** --- 281,291 ---- \end{description} + Note that although the identifier \code{as} can be used as part of the + syntax of \keyword{import} statements, it is not currently a reserved + word. + + In some future version of Python, the identifiers \code{as} and + \code{None} will both become keywords. + \section{Literals\label{literals}} From fdrake@users.sourceforge.net Tue Jun 18 20:18:05 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 18 Jun 2002 12:18:05 -0700 Subject: [Python-checkins] python/dist/src/Doc/ref ref2.tex,1.34.6.1,1.34.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv24543/ref Modified Files: Tag: release22-maint ref2.tex Log Message: Add a note about "as" not being a keyword, though it has special meaning when used as part of the import statement. Note that both "as" and "None" becoming keywords in the future. Closes SF bug #553262. Index: ref2.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref2.tex,v retrieving revision 1.34.6.1 retrieving revision 1.34.6.2 diff -C2 -d -r1.34.6.1 -r1.34.6.2 *** ref2.tex 15 Mar 2002 23:18:05 -0000 1.34.6.1 --- ref2.tex 18 Jun 2002 19:18:02 -0000 1.34.6.2 *************** *** 273,276 **** --- 273,283 ---- % When adding keywords, use reswords.py for reformatting + Note that although the identifier \code{as} can be used as part of the + syntax of \keyword{import} statements, it is not currently a reserved + word. + + In some future version of Python, the identifiers \code{as} and + \code{None} will both become keywords. + \subsection{Reserved classes of identifiers\label{id-classes}} From fdrake@users.sourceforge.net Tue Jun 18 21:30:39 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 18 Jun 2002 13:30:39 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libos.tex,1.89,1.90 libpopen2.tex,1.15,1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv15195/lib Modified Files: libos.tex libpopen2.tex Log Message: Add description of the deadlock problem with child processes and pipes, and hints about how to work around it. Closes SF bug #530637. Index: libos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.89 retrieving revision 1.90 diff -C2 -d -r1.89 -r1.90 *** libos.tex 18 Jun 2002 16:15:50 -0000 1.89 --- libos.tex 18 Jun 2002 20:30:37 -0000 1.90 *************** *** 340,343 **** --- 340,348 ---- module; these are only available on \UNIX. + For a discussion of possible dead lock conditions related to the use + of these functions, see ``\ulink{Flow Control + Issues}{popen2-flow-control.html}'' + (section~\ref{popen2-flow-control}). + \begin{funcdesc}{popen2}{cmd\optional{, mode\optional{, bufsize}}} Executes \var{cmd} as a sub-process. Returns the file objects Index: libpopen2.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpopen2.tex,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** libpopen2.tex 11 Sep 2001 19:56:51 -0000 1.15 --- libpopen2.tex 18 Jun 2002 20:30:37 -0000 1.16 *************** *** 115,116 **** --- 115,178 ---- The process ID of the child process. \end{memberdesc} + + + \subsection{Flow Control Issues \label{popen2-flow-control}} + + Any time you are working with any form of inter-process communication, + control flow needs to be carefully thought out. This remains the case + with the file objects provided by this module (or the \refmodule{os} + module equivalents). + + % Example explanation and suggested work-arounds substantially stolen + % from Martin von Löwis: + % http://mail.python.org/pipermail/python-dev/2000-September/009460.html + + When reading output from a child process that writes a lot of data to + standard error while the parent is reading from the child's standard + out, a dead lock can occur. A similar situation can occur with other + combinations of reads and writes. The essential factors are that more + than \constant{_PC_PIPE_BUF} bites are being written by one process in + a blocking fashion, while the other process is reading from the other + process, also in a blocking fashion. + + There are several ways to deal with this situation. + + The simplest application change, in many cases, will be to follow this + model in the parent process: + + \begin{verbatim} + import popen2 + + r, w, e = popen2.popen3('python slave.py') + e.readlines() + r.readlines() + r.close() + e.close() + w.close() + \end{verbatim} + + with code like this in the child: + + \begin{verbatim} + import os + import sys + + # note that each of these print statements + # writes a single long string + + print >>sys.stderr, 400 * 'this is a test\n' + os.close(sys.stderr.fileno()) + print >>sys.stdout, 400 * 'this is another test\n' + \end{verbatim} + + In particular, note that \code{sys.stderr} must be closed after + writing all data, or \method{readlines()} won't return. Also note + that \function{os.close()} must be used, as \code{sys.stderr.close()} + won't close \code{stderr} (otherwise assigning to \code{sys.stderr} + will silently close it, so no further errors can be printed). + + Applications which need to support a more general approach should + integrate I/O over pipes with their \function{select()} loops, or use + separate threads to read each of the individual files provided by + whichever \function{popen*()} function or \class{Popen*} class was + used. From fdrake@users.sourceforge.net Tue Jun 18 21:31:26 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 18 Jun 2002 13:31:26 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libos.tex,1.74.2.1.2.4,1.74.2.1.2.5 libpopen2.tex,1.15,1.15.12.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv15416/lib Modified Files: Tag: release22-maint libos.tex libpopen2.tex Log Message: Add description of the deadlock problem with child processes and pipes, and hints about how to work around it. Closes SF bug #530637. Index: libos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.74.2.1.2.4 retrieving revision 1.74.2.1.2.5 diff -C2 -d -r1.74.2.1.2.4 -r1.74.2.1.2.5 *** libos.tex 18 Jun 2002 16:16:46 -0000 1.74.2.1.2.4 --- libos.tex 18 Jun 2002 20:31:23 -0000 1.74.2.1.2.5 *************** *** 332,335 **** --- 332,340 ---- module; these are only available on \UNIX. + For a discussion of possible dead lock conditions related to the use + of these functions, see ``\ulink{Flow Control + Issues}{popen2-flow-control.html}'' + (section~\ref{popen2-flow-control}). + \begin{funcdesc}{popen2}{cmd\optional{, mode\optional{, bufsize}}} Executes \var{cmd} as a sub-process. Returns the file objects Index: libpopen2.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpopen2.tex,v retrieving revision 1.15 retrieving revision 1.15.12.1 diff -C2 -d -r1.15 -r1.15.12.1 *** libpopen2.tex 11 Sep 2001 19:56:51 -0000 1.15 --- libpopen2.tex 18 Jun 2002 20:31:24 -0000 1.15.12.1 *************** *** 115,116 **** --- 115,178 ---- The process ID of the child process. \end{memberdesc} + + + \subsection{Flow Control Issues \label{popen2-flow-control}} + + Any time you are working with any form of inter-process communication, + control flow needs to be carefully thought out. This remains the case + with the file objects provided by this module (or the \refmodule{os} + module equivalents). + + % Example explanation and suggested work-arounds substantially stolen + % from Martin von Löwis: + % http://mail.python.org/pipermail/python-dev/2000-September/009460.html + + When reading output from a child process that writes a lot of data to + standard error while the parent is reading from the child's standard + out, a dead lock can occur. A similar situation can occur with other + combinations of reads and writes. The essential factors are that more + than \constant{_PC_PIPE_BUF} bites are being written by one process in + a blocking fashion, while the other process is reading from the other + process, also in a blocking fashion. + + There are several ways to deal with this situation. + + The simplest application change, in many cases, will be to follow this + model in the parent process: + + \begin{verbatim} + import popen2 + + r, w, e = popen2.popen3('python slave.py') + e.readlines() + r.readlines() + r.close() + e.close() + w.close() + \end{verbatim} + + with code like this in the child: + + \begin{verbatim} + import os + import sys + + # note that each of these print statements + # writes a single long string + + print >>sys.stderr, 400 * 'this is a test\n' + os.close(sys.stderr.fileno()) + print >>sys.stdout, 400 * 'this is another test\n' + \end{verbatim} + + In particular, note that \code{sys.stderr} must be closed after + writing all data, or \method{readlines()} won't return. Also note + that \function{os.close()} must be used, as \code{sys.stderr.close()} + won't close \code{stderr} (otherwise assigning to \code{sys.stderr} + will silently close it, so no further errors can be printed). + + Applications which need to support a more general approach should + integrate I/O over pipes with their \function{select()} loops, or use + separate threads to read each of the individual files provided by + whichever \function{popen*()} function or \class{Popen*} class was + used. From fdrake@users.sourceforge.net Tue Jun 18 21:32:11 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 18 Jun 2002 13:32:11 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libos.tex,1.53.4.8,1.53.4.9 libpopen2.tex,1.13.6.1,1.13.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv15627/lib Modified Files: Tag: release21-maint libos.tex libpopen2.tex Log Message: Add description of the deadlock problem with child processes and pipes, and hints about how to work around it. Closes SF bug #530637. Index: libos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.53.4.8 retrieving revision 1.53.4.9 diff -C2 -d -r1.53.4.8 -r1.53.4.9 *** libos.tex 18 Jun 2002 16:17:31 -0000 1.53.4.8 --- libos.tex 18 Jun 2002 20:32:09 -0000 1.53.4.9 *************** *** 315,318 **** --- 315,323 ---- for \var{mode} is \code{'t'}. + For a discussion of possible dead lock conditions related to the use + of these functions, see ``\ulink{Flow Control + Issues}{popen2-flow-control.html}'' + (section~\ref{popen2-flow-control}). + \begin{funcdesc}{popen2}{cmd\optional{, mode\optional{, bufsize}}} Executes \var{cmd} as a sub-process. Returns the file objects Index: libpopen2.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpopen2.tex,v retrieving revision 1.13.6.1 retrieving revision 1.13.6.2 diff -C2 -d -r1.13.6.1 -r1.13.6.2 *** libpopen2.tex 6 Jul 2001 17:18:05 -0000 1.13.6.1 --- libpopen2.tex 18 Jun 2002 20:32:09 -0000 1.13.6.2 *************** *** 108,109 **** --- 108,171 ---- The process ID of the child process. \end{memberdesc} + + + \subsection{Flow Control Issues \label{popen2-flow-control}} + + Any time you are working with any form of inter-process communication, + control flow needs to be carefully thought out. This remains the case + with the file objects provided by this module (or the \refmodule{os} + module equivalents). + + % Example explanation and suggested work-arounds substantially stolen + % from Martin von Löwis: + % http://mail.python.org/pipermail/python-dev/2000-September/009460.html + + When reading output from a child process that writes a lot of data to + standard error while the parent is reading from the child's standard + out, a dead lock can occur. A similar situation can occur with other + combinations of reads and writes. The essential factors are that more + than \constant{_PC_PIPE_BUF} bites are being written by one process in + a blocking fashion, while the other process is reading from the other + process, also in a blocking fashion. + + There are several ways to deal with this situation. + + The simplest application change, in many cases, will be to follow this + model in the parent process: + + \begin{verbatim} + import popen2 + + r, w, e = popen2.popen3('python slave.py') + e.readlines() + r.readlines() + r.close() + e.close() + w.close() + \end{verbatim} + + with code like this in the child: + + \begin{verbatim} + import os + import sys + + # note that each of these print statements + # writes a single long string + + print >>sys.stderr, 400 * 'this is a test\n' + os.close(sys.stderr.fileno()) + print >>sys.stdout, 400 * 'this is another test\n' + \end{verbatim} + + In particular, note that \code{sys.stderr} must be closed after + writing all data, or \method{readlines()} won't return. Also note + that \function{os.close()} must be used, as \code{sys.stderr.close()} + won't close \code{stderr} (otherwise assigning to \code{sys.stderr} + will silently close it, so no further errors can be printed). + + Applications which need to support a more general approach should + integrate I/O over pipes with their \function{select()} loops, or use + separate threads to read each of the individual files provided by + whichever \function{popen*()} function or \class{Popen*} class was + used. From fredrik@pythonware.com Tue Jun 18 21:35:44 2002 From: fredrik@pythonware.com (Fredrik Lundh) Date: Tue, 18 Jun 2002 22:35:44 +0200 Subject: [Python-checkins] python/dist/src/Doc/lib libos.tex,1.89,1.90 libpopen2.tex,1.15,1.16 References: Message-ID: <002a01c21707$b973d020$0900a8c0@spiff> > + combinations of reads and writes. The essential factors are that = more > + than \constant{_PC_PIPE_BUF} bites are being written by one process = in bites? From fdrake@users.sourceforge.net Tue Jun 18 21:38:08 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 18 Jun 2002 13:38:08 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libpopen2.tex,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv17539 Modified Files: libpopen2.tex Log Message: Typo: bites --> bytes (Hanging around small kids too much...;) Index: libpopen2.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpopen2.tex,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** libpopen2.tex 18 Jun 2002 20:30:37 -0000 1.16 --- libpopen2.tex 18 Jun 2002 20:38:05 -0000 1.17 *************** *** 132,136 **** out, a dead lock can occur. A similar situation can occur with other combinations of reads and writes. The essential factors are that more ! than \constant{_PC_PIPE_BUF} bites are being written by one process in a blocking fashion, while the other process is reading from the other process, also in a blocking fashion. --- 132,136 ---- out, a dead lock can occur. A similar situation can occur with other combinations of reads and writes. The essential factors are that more ! than \constant{_PC_PIPE_BUF} bytes are being written by one process in a blocking fashion, while the other process is reading from the other process, also in a blocking fashion. From fdrake@users.sourceforge.net Tue Jun 18 21:38:46 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 18 Jun 2002 13:38:46 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libpopen2.tex,1.15.12.1,1.15.12.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv17693 Modified Files: Tag: release22-maint libpopen2.tex Log Message: Typo: bites --> bytes (Hanging around small kids too much...;) Index: libpopen2.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpopen2.tex,v retrieving revision 1.15.12.1 retrieving revision 1.15.12.2 diff -C2 -d -r1.15.12.1 -r1.15.12.2 *** libpopen2.tex 18 Jun 2002 20:31:24 -0000 1.15.12.1 --- libpopen2.tex 18 Jun 2002 20:38:43 -0000 1.15.12.2 *************** *** 132,136 **** out, a dead lock can occur. A similar situation can occur with other combinations of reads and writes. The essential factors are that more ! than \constant{_PC_PIPE_BUF} bites are being written by one process in a blocking fashion, while the other process is reading from the other process, also in a blocking fashion. --- 132,136 ---- out, a dead lock can occur. A similar situation can occur with other combinations of reads and writes. The essential factors are that more ! than \constant{_PC_PIPE_BUF} bytes are being written by one process in a blocking fashion, while the other process is reading from the other process, also in a blocking fashion. From fdrake@users.sourceforge.net Tue Jun 18 21:39:18 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 18 Jun 2002 13:39:18 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libpopen2.tex,1.13.6.2,1.13.6.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv17872 Modified Files: Tag: release21-maint libpopen2.tex Log Message: Typo: bites --> bytes Index: libpopen2.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpopen2.tex,v retrieving revision 1.13.6.2 retrieving revision 1.13.6.3 diff -C2 -d -r1.13.6.2 -r1.13.6.3 *** libpopen2.tex 18 Jun 2002 20:32:09 -0000 1.13.6.2 --- libpopen2.tex 18 Jun 2002 20:39:14 -0000 1.13.6.3 *************** *** 125,129 **** out, a dead lock can occur. A similar situation can occur with other combinations of reads and writes. The essential factors are that more ! than \constant{_PC_PIPE_BUF} bites are being written by one process in a blocking fashion, while the other process is reading from the other process, also in a blocking fashion. --- 125,129 ---- out, a dead lock can occur. A similar situation can occur with other combinations of reads and writes. The essential factors are that more ! than \constant{_PC_PIPE_BUF} bytes are being written by one process in a blocking fashion, while the other process is reading from the other process, also in a blocking fashion. From gvanrossum@users.sourceforge.net Tue Jun 18 21:43:23 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue, 18 Jun 2002 13:43:23 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.430,1.431 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv18981 Modified Files: NEWS Log Message: Minor tweaks to existing items (radian/degree, and UTF-16 readers.. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.430 retrieving revision 1.431 diff -C2 -d -r1.430 -r1.431 *** NEWS 17 Jun 2002 10:43:57 -0000 1.430 --- NEWS 18 Jun 2002 20:43:18 -0000 1.431 *************** *** 183,187 **** BOM32_* and BOM64_* were off by a factor of 2. ! - added degree/radian conversion functions to the math module. - ftplib.retrlines() now tests for callback is None rather than testing --- 183,187 ---- BOM32_* and BOM64_* were off by a factor of 2. ! - Added conversion functions math.degrees() and math.radians(). - ftplib.retrlines() now tests for callback is None rather than testing *************** *** 222,229 **** and other systems. ! - The UTF-16, -LE and -BE now raise a NotImplementedError ! for all calls to .readline(). Previously, they used to just ! produce garbage or fail with an encoding error -- UTF-16 is ! a 2-byte encoding and the C lib's line reading APIs don't work well with these. --- 222,229 ---- and other systems. ! - The UTF-16, -LE and -BE stream readers now raise a ! NotImplementedError for all calls to .readline(). Previously, they ! used to just produce garbage or fail with an encoding error -- ! UTF-16 is a 2-byte encoding and the C lib's line reading APIs don't work well with these. From gvanrossum@users.sourceforge.net Tue Jun 18 22:09:51 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue, 18 Jun 2002 14:09:51 -0700 Subject: [Python-checkins] python/nondist/peps pep-0283.txt,1.8,1.9 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv26600 Modified Files: pep-0283.txt Log Message: Various status updates. Index: pep-0283.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0283.txt,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** pep-0283.txt 30 May 2002 03:18:42 -0000 1.8 --- pep-0283.txt 18 Jun 2002 21:09:48 -0000 1.9 *************** *** 85,90 **** http://mail.python.org/pipermail/python-dev/2002-May/024346.html ! - Extended slice notation for all built-in sequences. Raymond ! Hettinger is working on this. - An iterator tools module featuring goodies from SML and Haskell? --- 85,92 ---- http://mail.python.org/pipermail/python-dev/2002-May/024346.html ! - Extended slice notation for all built-in sequences. A patch by ! Michael Hudson has solved this, mostly; there's an open issue ! about slice assignments where the source has a different length ! than the destination, as in L[:5:] = range(10). - An iterator tools module featuring goodies from SML and Haskell? *************** *** 92,96 **** - Speed up list iterations by filling tp_iter and other tweaks? ! http://www.python.org/sf/560736 - Fix the buffer object??? --- 94,98 ---- - Speed up list iterations by filling tp_iter and other tweaks? ! http://www.python.org/sf/560736 (This is done; also for xrange.) - Fix the buffer object??? *************** *** 103,111 **** - Timeoutsocket. Work in progress. http://mail.python.org/pipermail/python-dev/2002-May/024077.html ! http://www.python.org/sf/555085 - Making None a keyword. Can't be done right away, but a warning would be a first step. http://mail.python.org/pipermail/python-dev/2002-April/023600.html - Stage 2 of the int/long integration (PEP 237). This mostly --- 105,115 ---- - Timeoutsocket. Work in progress. http://mail.python.org/pipermail/python-dev/2002-May/024077.html ! http://www.python.org/sf/555085 (Most of this is done, but we ! still need to add a global timeout option.) - Making None a keyword. Can't be done right away, but a warning would be a first step. http://mail.python.org/pipermail/python-dev/2002-April/023600.html + Ditto for 'as', which has been a pseudo-keyword long enough. - Stage 2 of the int/long integration (PEP 237). This mostly *************** *** 124,128 **** - Write a pymemcompat.h that people can bundle with their extensions and then use the 2.3 memory interface with all ! Pythons in the range 1.5.2 to 2.3. (Michael Hudson.) - PEP 262 Database of Installed Python Packages Kuchling --- 128,133 ---- - Write a pymemcompat.h that people can bundle with their extensions and then use the 2.3 memory interface with all ! Pythons in the range 1.5.2 to 2.3. (Michael Hudson has done ! this; it's in Misc/pymemcompat.h.) - PEP 262 Database of Installed Python Packages Kuchling *************** *** 141,145 **** - Warn when an extension type's tp_compare returns anything except ! -1, 0 or 1. http://www.python.org/sf/472523 - A standard datetime type. An implementation effort is under way: --- 146,150 ---- - Warn when an extension type's tp_compare returns anything except ! -1, 0 or 1. http://www.python.org/sf/472523 (This is done.) - A standard datetime type. An implementation effort is under way: *************** *** 153,161 **** http://mail.python.org/pipermail/python-dev/2002-April/023165.html ! - Add a new concept, "silent deprecation", with associated warning ! SilentDeprecationWarning. This warning is normally suppressed, ! but can be enabled by a suitable -W option. ! - Use silent deprecation for the types and string modules. This requires providing alternatives for the parts that aren't covered yet (e.g. string.whitespace and types.TracebackType). --- 158,166 ---- http://mail.python.org/pipermail/python-dev/2002-April/023165.html ! - Add a new concept, "pending deprecation", with associated ! warning PendingDeprecationWarning. This warning is normally ! suppressed, but can be enabled by a suitable -W option. ! - Use pending deprecation for the types and string modules. This requires providing alternatives for the parts that aren't covered yet (e.g. string.whitespace and types.TracebackType). From gvanrossum@users.sourceforge.net Tue Jun 18 22:10:22 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue, 18 Jun 2002 14:10:22 -0700 Subject: [Python-checkins] python/nondist/peps pep-0283.txt,1.9,1.10 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv26830 Modified Files: pep-0283.txt Log Message: Another status update. Index: pep-0283.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0283.txt,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** pep-0283.txt 18 Jun 2002 21:09:48 -0000 1.9 --- pep-0283.txt 18 Jun 2002 21:10:20 -0000 1.10 *************** *** 160,164 **** - Add a new concept, "pending deprecation", with associated warning PendingDeprecationWarning. This warning is normally ! suppressed, but can be enabled by a suitable -W option. - Use pending deprecation for the types and string modules. This --- 160,165 ---- - Add a new concept, "pending deprecation", with associated warning PendingDeprecationWarning. This warning is normally ! suppressed, but can be enabled by a suitable -W option. (This ! has been added now, but nothing uses it yet.) - Use pending deprecation for the types and string modules. This From gvanrossum@users.sourceforge.net Tue Jun 18 22:20:16 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue, 18 Jun 2002 14:20:16 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.431,1.432 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv29680 Modified Files: NEWS Log Message: Mention pymemcompat.h. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.431 retrieving revision 1.432 diff -C2 -d -r1.431 -r1.432 *** NEWS 18 Jun 2002 20:43:18 -0000 1.431 --- NEWS 18 Jun 2002 21:20:13 -0000 1.432 *************** *** 100,104 **** could access a pointer to freed memory. ! - The optional object allocator has been enabled by default. - If you try to pickle an instance of a class that has __slots__ but --- 100,109 ---- could access a pointer to freed memory. ! - The optional object allocator ("pymalloc") has been enabled by ! default. The recommended practice for memory allocation and ! deallocation has been streamlined. A header file is included, ! Misc/pymemcompat.h, which can be bundled with 3rd party extensions ! and lets them use the same API with Python versions from 1.5.2 ! onwards. - If you try to pickle an instance of a class that has __slots__ but From bwarsaw@users.sourceforge.net Wed Jun 19 03:53:43 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Tue, 18 Jun 2002 19:53:43 -0700 Subject: [Python-checkins] python/nondist/peps pep-0292.txt,NONE,1.1 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv8917 Added Files: pep-0292.txt Log Message: PEP 292, Simpler String Substitutions, Warsaw --- NEW FILE: pep-0292.txt --- PEP: 292 Title: Simpler String Substitutions Version: $Revision: 1.1 $ Last-Modified: $Date: 2002/06/19 02:53:41 $ Author: barry@zope.com (Barry A. Warsaw) Status: Draft Type: Standards Track Created: 18-Jun-2002 Python-Version: 2.3 Post-History: Abstract This PEP describes a simpler string substitution feature, also known as string interpolation. This PEP is "simpler" in two respects: 1. Python's current string substitution feature (commonly known as %-substitutions) is complicated and error prone. This PEP is simpler at the cost of less expressiveness. 2. PEP 215 proposed an alternative string interpolation feature, introducing a new `$' string prefix. PEP 292 is simpler than this because it involves no syntax changes and has much simpler rules for what substitutions can occur in the string. Rationale Python currently supports a string substitution (a.k.a. string interpolation) syntax based on C's printf() % formatting character[1]. While quite rich, %-formatting codes are also quite error prone, even for experienced Python programmers. A common mistake is to leave off the trailing format character, e.g. the `s' in "%(name)s". In addition, the rules for what can follow a % sign are fairly complex, while the usual application rarely needs such complexity. A Simpler Proposal Here we propose the addition of a new string method, called .sub() which performs substitution of mapping values into a string with special substitution placeholders. These placeholders are introduced with the $ character. The following rules for $-placeholders apply: 1. $$ is an escape; it is replaced with a single $ 2. $identifier names a substitution placeholder matching a mapping key of "identifier". "identifier" must be a Python identifier as defined in [2]. The first non-identifier character after the $ character terminates this placeholder specification. 3. ${identifier} is equivalent to $identifier and for clarity, this is the preferred form. It is required for when valid identifier characters follow the placeholder but are not part of the placeholder, e.g. "${noun}ification". No other characters have special meaning. The .sub() method takes an optional mapping (e.g. dictionary) where the keys match placeholders in the string, and the values are substituted for the placeholders. For example: '${name} was born in ${country}'.sub({'name': 'Guido', 'country': 'the Netherlands'}) returns 'Guido was born in the Netherlands' The mapping argument is optional; if it is omitted then the mapping is taken from the locals and globals of the context in which the .sub() method is executed. For example: def birth(self, name): country = self.countryOfOrigin['name'] return '${name} was born in ${country}' birth('Guido') returns 'Guido was born in the Netherlands' Reference Implementation Here's a Python 2.2-based reference implementation. Of course the real implementation would be in C, would not require a string subclass, and would not be modeled on the existing %-interpolation feature. import sys import re dre = re.compile(r'(\$\$)|\$([_a-z]\w*)|\$\{([_a-z]\w*)\}', re.I) EMPTYSTRING = '' class dstr(str): def sub(self, mapping=None): # Default mapping is locals/globals of caller if mapping is None: frame = sys._getframe(1) mapping = frame.f_globals.copy() mapping.update(frame.f_locals) # Escape %'s s = self.replace('%', '%%') # Convert $name and ${name} to $(name)s parts = dre.split(s) for i in range(1, len(parts), 4): if parts[i] is not None: parts[i] = '$' elif parts[i+1] is not None: parts[i+1] = '%(' + parts[i+1] + ')s' else: parts[i+2] = '%(' + parts[i+2] + ')s' # Interpolate return EMPTYSTRING.join(filter(None, parts)) % mapping And here are some examples: s = dstr('${name} was born in ${country}') print s.sub({'name': 'Guido', 'country': 'the Netherlands'}) name = 'Barry' country = 'the USA' print s.sub() This will print "Guido was born in the Netherlands" followed by "Barry was born in the USA". Handling Missing Keys What should happen when one of the substitution keys is missing from the mapping (or the locals/globals namespace if no argument is given)? There are two possibilities: - We can simply allow the exception (likely a NameError or KeyError) to propagate. - We can return the original substitution placeholder unchanged. An example of the first is: print dstr('${name} was born in ${country}').sub({'name': 'Bob'}) would raise: Traceback (most recent call last): File "sub.py", line 66, in ? print s.sub({'name': 'Bob'}) File "sub.py", line 26, in sub return EMPTYSTRING.join(filter(None, parts)) % mapping KeyError: country An example of the second is: print dstr('${name} was born in ${country}').sub({'name': 'Bob'}) would print: Bob was born in ${country} The PEP author would prefer the latter interpretation, although a case can be made for raising the exception instead. We could almost ignore the issue, since the latter example could be accomplished by passing in a "safe-dictionary" in instead of a normal dictionary, like so: class safedict(dict): def __getitem__(self, key): try: return dict.__getitem__(self, key) except KeyError: return '${%s}' % key so that d = safedict({'name': 'Bob'}) print dstr('${name} was born in ${country}').sub(d) would print: Bob was born in ${country} The one place where this won't work is when no arguments are given to the .sub() method. .sub() wouldn't know whether to wrap locals/globals in a safedict or not. This ambiguity can be solved in several ways: - we could have a parallel method called .safesub() which always wrapped its argument in a safedict() - .sub() could take an optional keyword argument flag which indicates whether to wrap the argument in a safedict or not. - .sub() could take an optional keyword argument which is a callable that would get called with the original mapping and return the mapping to be used for the substitution. By default, this callable would be the identity function, but you could easily pass in the safedict constructor instead. BDFL proto-pronouncement: It should always raise a NameError when the key is missing. There may not be sufficient use case for soft failures in the no-argument version. Comparison to PEP 215 PEP 215 describes an alternate proposal for string interpolation. Unlike that PEP, this one does not propose any new syntax for Python. All the proposed new features are embodied in a new string method. PEP 215 proposes a new string prefix representation such as $"" which signal to Python that a new type of string is present. $-strings would have to interact with the existing r-prefixes and u-prefixes, essentially doubling the number of string prefix combinations. PEP 215 also allows for arbitrary Python expressions inside the $-strings, so that you could do things like: import sys print $"sys = $sys, sys = $sys.modules['sys']" which would return sys = , sys = It's generally accepted that the rules in PEP 215 are safe in the sense that they introduce no new security issues (see PEP 215, "Security Issues" for details). However, the rules are still quite complex, and make it more difficult to see what exactly is the substitution placeholder in the original $-string. By design, this PEP does not provide as much interpolation power as PEP 215, however it is expected that the no-argument version of .sub() allows at least as much power with no loss of readability. References [1] String Formatting Operations http://www.python.org/doc/current/lib/typesseq-strings.html [2] Identifiers and Keywords http://www.python.org/doc/current/ref/identifiers.html Copyright This document has been placed in the public domain. Local Variables: mode: indented-text indent-tabs-mode: nil sentence-end-double-space: t fill-column: 70 End: From bwarsaw@users.sourceforge.net Wed Jun 19 03:54:00 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Tue, 18 Jun 2002 19:54:00 -0700 Subject: [Python-checkins] python/nondist/peps pep-0000.txt,1.186,1.187 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv8981 Modified Files: pep-0000.txt Log Message: Added PEP 292, Simpler String Substitutions, Warsaw Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.186 retrieving revision 1.187 diff -C2 -d -r1.186 -r1.187 *** pep-0000.txt 17 Jun 2002 12:03:22 -0000 1.186 --- pep-0000.txt 19 Jun 2002 02:53:58 -0000 1.187 *************** *** 96,99 **** --- 96,100 ---- S 287 reStructuredText Standard Docstring Format Goodger I 291 Backward Compatibility for Standard Library Norwitz + S 292 Simpler String Substitutions Warsaw Finished PEPs (done, implemented in CVS) *************** *** 272,275 **** --- 273,277 ---- I 290 Code Migration and Modernization Hettinger I 291 Backward Compatibility for Standard Library Norwitz + S 292 Simpler String Substitutions Warsaw SR 666 Reject Foolish Indentation Creighton From bwarsaw@users.sourceforge.net Wed Jun 19 03:54:24 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Tue, 18 Jun 2002 19:54:24 -0700 Subject: [Python-checkins] python/nondist/peps pep-0292.txt,1.1,1.2 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv9078 Modified Files: pep-0292.txt Log Message: Updated Post-History Index: pep-0292.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0292.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pep-0292.txt 19 Jun 2002 02:53:41 -0000 1.1 --- pep-0292.txt 19 Jun 2002 02:54:22 -0000 1.2 *************** *** 8,12 **** Created: 18-Jun-2002 Python-Version: 2.3 ! Post-History: --- 8,12 ---- Created: 18-Jun-2002 Python-Version: 2.3 ! Post-History: 18-Jun-2002 From bwarsaw@users.sourceforge.net Wed Jun 19 04:22:14 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Tue, 18 Jun 2002 20:22:14 -0700 Subject: [Python-checkins] python/nondist/peps pep-0293.txt,NONE,1.1 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv13997 Added Files: pep-0293.txt Log Message: PEP 293, Codec Error Handling Callbacks, Walter Dörwald --- NEW FILE: pep-0293.txt --- (This appears to be a binary file; contents omitted.) From bwarsaw@users.sourceforge.net Wed Jun 19 04:22:27 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Tue, 18 Jun 2002 20:22:27 -0700 Subject: [Python-checkins] python/nondist/peps pep-0000.txt,1.187,1.188 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv14042 Modified Files: pep-0000.txt Log Message: Added PEP 293, Codec Error Handling Callbacks, Walter Dörwald Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.187 retrieving revision 1.188 diff -C2 -d -r1.187 -r1.188 *** pep-0000.txt 19 Jun 2002 02:53:58 -0000 1.187 --- pep-0000.txt 19 Jun 2002 03:22:24 -0000 1.188 *************** *** 97,100 **** --- 97,101 ---- I 291 Backward Compatibility for Standard Library Norwitz S 292 Simpler String Substitutions Warsaw + S 293 Codec Error Handling Callbacks Dörwald Finished PEPs (done, implemented in CVS) *************** *** 274,277 **** --- 275,279 ---- I 291 Backward Compatibility for Standard Library Norwitz S 292 Simpler String Substitutions Warsaw + S 293 Codec Error Handling Callbacks Dörwald SR 666 Reject Foolish Indentation Creighton *************** *** 298,301 **** --- 300,304 ---- Baxter, Anthony anthony@interlink.com.au Creighton, Laura lac@strakt.com + Dörwald, Walter Drake, Fred fdrake@acm.org Dubois, Paul F. paul@pfdubois.com From doerwalter@users.sourceforge.net Wed Jun 19 12:12:53 2002 From: doerwalter@users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Wed, 19 Jun 2002 04:12:53 -0700 Subject: [Python-checkins] python/nondist/peps pep-0293.txt,1.1,1.2 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv30945 Modified Files: pep-0293.txt Log Message: Update Post-History Index: pep-0293.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0293.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pep-0293.txt 19 Jun 2002 03:22:11 -0000 1.1 --- pep-0293.txt 19 Jun 2002 11:12:50 -0000 1.2 *************** *** 8,12 **** Created: 18-Jun-2002 Python-Version: 2.3 ! Post-History: --- 8,12 ---- Created: 18-Jun-2002 Python-Version: 2.3 ! Post-History: 19-Jun-2002 From mwh@users.sourceforge.net Wed Jun 19 16:44:17 2002 From: mwh@users.sourceforge.net (mwh@users.sourceforge.net) Date: Wed, 19 Jun 2002 08:44:17 -0700 Subject: [Python-checkins] python/dist/src/Objects listobject.c,2.113,2.114 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv17321/Objects Modified Files: listobject.c Log Message: Fix the bug described in http://mail.python.org/pipermail/python-dev/2002-June/025461.html with test cases. Also includes extended slice support for arrays, which I thought I'd already checked in but obviously not. Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.113 retrieving revision 2.114 diff -C2 -d -r2.113 -r2.114 *** listobject.c 14 Jun 2002 02:04:18 -0000 2.113 --- listobject.c 19 Jun 2002 15:44:15 -0000 2.114 *************** *** 1758,1764 **** } if (value == NULL) { /* delete slice */ ! PyObject **garbage, **item; int cur, i, j; --- 1758,1768 ---- } + /* treat L[slice(a,b)] = v _exactly_ like L[a:b] = v */ + if (step == 1 && ((PySliceObject*)item)->step == Py_None) + return list_ass_slice(self, start, stop, value); + if (value == NULL) { /* delete slice */ ! PyObject **garbage, **it; int cur, i, j; *************** *** 1789,1793 **** } } ! for (cur = start + slicelength*step + 1; cur < self->ob_size; cur++) { PyList_SET_ITEM(self, cur - slicelength, --- 1793,1797 ---- } } ! for (cur = start + slicelength*step + 1; cur < self->ob_size; cur++) { PyList_SET_ITEM(self, cur - slicelength, *************** *** 1795,1801 **** } self->ob_size -= slicelength; ! item = self->ob_item; ! NRESIZE(item, PyObject*, self->ob_size); ! self->ob_item = item; for (i = 0; i < slicelength; i++) { --- 1799,1805 ---- } self->ob_size -= slicelength; ! it = self->ob_item; ! NRESIZE(it, PyObject*, self->ob_size); ! self->ob_item = it; for (i = 0; i < slicelength; i++) { From mwh@users.sourceforge.net Wed Jun 19 16:44:17 2002 From: mwh@users.sourceforge.net (mwh@users.sourceforge.net) Date: Wed, 19 Jun 2002 08:44:17 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_array.py,1.15,1.16 test_types.py,1.32,1.33 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv17321/Lib/test Modified Files: test_array.py test_types.py Log Message: Fix the bug described in http://mail.python.org/pipermail/python-dev/2002-June/025461.html with test cases. Also includes extended slice support for arrays, which I thought I'd already checked in but obviously not. Index: test_array.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_array.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** test_array.py 15 May 2002 13:04:53 -0000 1.15 --- test_array.py 19 Jun 2002 15:44:15 -0000 1.16 *************** *** 4,8 **** """ import array ! from test_support import verbose, TESTFN, unlink, TestFailed, have_unicode def main(): --- 4,9 ---- """ import array ! from test_support import verbose, TESTFN, unlink, TestFailed,\ ! have_unicode, vereq def main(): *************** *** 313,316 **** --- 314,357 ---- if a != array.array(type, [4, 3, 1]): raise TestFailed, "array(%s) reverse-test" % `type` + # extended slicing + # subscription + a = array.array(type, [0,1,2,3,4]) + vereq(a[::], a) + vereq(a[::2], array.array(type, [0,2,4])) + vereq(a[1::2], array.array(type, [1,3])) + vereq(a[::-1], array.array(type, [4,3,2,1,0])) + vereq(a[::-2], array.array(type, [4,2,0])) + vereq(a[3::-2], array.array(type, [3,1])) + vereq(a[-100:100:], a) + vereq(a[100:-100:-1], a[::-1]) + vereq(a[-100L:100L:2L], array.array(type, [0,2,4])) + vereq(a[1000:2000:2], array.array(type, [])) + vereq(a[-1000:-2000:-2], array.array(type, [])) + # deletion + del a[::2] + vereq(a, array.array(type, [1,3])) + a = array.array(type, range(5)) + del a[1::2] + vereq(a, array.array(type, [0,2,4])) + a = array.array(type, range(5)) + del a[1::-2] + vereq(a, array.array(type, [0,2,3,4])) + # assignment + a = array.array(type, range(10)) + a[::2] = array.array(type, [-1]*5) + vereq(a, array.array(type, [-1, 1, -1, 3, -1, 5, -1, 7, -1, 9])) + a = array.array(type, range(10)) + a[::-4] = array.array(type, [10]*3) + vereq(a, array.array(type, [0, 10, 2, 3, 4, 10, 6, 7, 8 ,10])) + a = array.array(type, range(4)) + a[::-1] = a + vereq(a, array.array(type, [3, 2, 1, 0])) + a = array.array(type, range(10)) + b = a[:] + c = a[:] + ins = array.array(type, range(2)) + a[2:3] = ins + b[slice(2,3)] = ins + c[2:3:] = ins # test that overflow exceptions are raised as expected for assignment Index: test_types.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_types.py,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** test_types.py 13 Jun 2002 22:23:06 -0000 1.32 --- test_types.py 19 Jun 2002 15:44:15 -0000 1.33 *************** *** 411,414 **** --- 411,422 ---- a[::-1] = a vereq(a, [3, 2, 1, 0]) + a = range(10) + b = a[:] + c = a[:] + a[2:3] = ["two", "elements"] + b[slice(2,3)] = ["two", "elements"] + c[2:3:] = ["two", "elements"] + vereq(a, b) + vereq(a, c) print '6.6 Mappings == Dictionaries' From mwh@users.sourceforge.net Wed Jun 19 16:44:18 2002 From: mwh@users.sourceforge.net (mwh@users.sourceforge.net) Date: Wed, 19 Jun 2002 08:44:18 -0700 Subject: [Python-checkins] python/dist/src/Modules arraymodule.c,2.74,2.75 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv17321/Modules Modified Files: arraymodule.c Log Message: Fix the bug described in http://mail.python.org/pipermail/python-dev/2002-June/025461.html with test cases. Also includes extended slice support for arrays, which I thought I'd already checked in but obviously not. Index: arraymodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/arraymodule.c,v retrieving revision 2.74 retrieving revision 2.75 diff -C2 -d -r2.74 -r2.75 *** arraymodule.c 13 Jun 2002 20:32:48 -0000 2.74 --- arraymodule.c 19 Jun 2002 15:44:15 -0000 2.75 *************** *** 1479,1482 **** --- 1479,1655 ---- } + static PyObject* + array_subscr(arrayobject* self, PyObject* item) + { + if (PyInt_Check(item)) { + long i = PyInt_AS_LONG(item); + if (i < 0) + i += self->ob_size; + return array_item(self, i); + } + else if (PyLong_Check(item)) { + long i = PyLong_AsLong(item); + if (i == -1 && PyErr_Occurred()) + return NULL; + if (i < 0) + i += self->ob_size; + return array_item(self, i); + } + else if (PySlice_Check(item)) { + int start, stop, step, slicelength, cur, i; + PyObject* result; + arrayobject* ar; + int itemsize = self->ob_descr->itemsize; + + if (PySlice_GetIndicesEx((PySliceObject*)item, self->ob_size, + &start, &stop, &step, &slicelength) < 0) { + return NULL; + } + + if (slicelength <= 0) { + return newarrayobject(&Arraytype, 0, self->ob_descr); + } + else { + result = newarrayobject(&Arraytype, slicelength, self->ob_descr); + if (!result) return NULL; + + ar = (arrayobject*)result; + + for (cur = start, i = 0; i < slicelength; + cur += step, i++) { + memcpy(ar->ob_item + i*itemsize, + self->ob_item + cur*itemsize, + itemsize); + } + + return result; + } + } + else { + PyErr_SetString(PyExc_TypeError, + "list indices must be integers"); + return NULL; + } + } + + static int + array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value) + { + if (PyInt_Check(item)) { + long i = PyInt_AS_LONG(item); + if (i < 0) + i += self->ob_size; + return array_ass_item(self, i, value); + } + else if (PyLong_Check(item)) { + long i = PyLong_AsLong(item); + if (i == -1 && PyErr_Occurred()) + return -1; + if (i < 0) + i += self->ob_size; + return array_ass_item(self, i, value); + } + else if (PySlice_Check(item)) { + int start, stop, step, slicelength; + int itemsize = self->ob_descr->itemsize; + + if (PySlice_GetIndicesEx((PySliceObject*)item, self->ob_size, + &start, &stop, &step, &slicelength) < 0) { + return -1; + } + + /* treat A[slice(a,b)] = v _exactly_ like A[a:b] = v */ + if (step == 1 && ((PySliceObject*)item)->step == Py_None) + return array_ass_slice(self, start, stop, value); + + if (value == NULL) { + /* delete slice */ + int cur, i; + + if (slicelength <= 0) + return 0; + + if (step < 0) { + stop = start + 1; + start = stop + step*(slicelength - 1) - 1; + step = -step; + } + + for (cur = start, i = 0; cur < stop; + cur += step, i++) { + memmove(self->ob_item + (cur - i)*itemsize, + self->ob_item + (cur + 1)*itemsize, + (step - 1) * itemsize); + } + if (self->ob_size > (start + slicelength*step)) { + memmove(self->ob_item + (start + slicelength*(step - 1))*itemsize, + self->ob_item + (start + slicelength*step)*itemsize, + (self->ob_size - (start + slicelength*step))*itemsize); + } + + self->ob_size -= slicelength; + self->ob_item = PyMem_REALLOC(self->ob_item, itemsize*self->ob_size); + + + return 0; + } + else { + /* assign slice */ + int cur, i; + arrayobject* av; + + if (!array_Check(value)) { + PyErr_Format(PyExc_TypeError, + "must assign array (not \"%.200s\") to slice", + value->ob_type->tp_name); + return -1; + } + + av = (arrayobject*)value; + + if (av->ob_size != slicelength) { + PyErr_Format(PyExc_ValueError, + "attempt to assign array of size %d to extended slice of size %d", + av->ob_size, slicelength); + return -1; + } + + if (!slicelength) + return 0; + + /* protect against a[::-1] = a */ + if (self == av) { + value = array_slice(av, 0, av->ob_size); + av = (arrayobject*)value; + } + else { + Py_INCREF(value); + } + + for (cur = start, i = 0; i < slicelength; + cur += step, i++) { + memcpy(self->ob_item + cur*itemsize, + av->ob_item + i*itemsize, + itemsize); + } + + Py_DECREF(value); + + return 0; + } + } + else { + PyErr_SetString(PyExc_TypeError, + "list indices must be integers"); + return -1; + } + } + + static PyMappingMethods array_as_mapping = { + (inquiry)array_length, + (binaryfunc)array_subscr, + (objobjargproc)array_ass_subscr + }; + static int array_buffer_getreadbuf(arrayobject *self, int index, const void **ptr) *************** *** 1700,1704 **** 0, /* tp_as _number*/ &array_as_sequence, /* tp_as _sequence*/ ! 0, /* tp_as _mapping*/ 0, /* tp_hash */ 0, /* tp_call */ --- 1873,1877 ---- 0, /* tp_as _number*/ &array_as_sequence, /* tp_as _sequence*/ ! &array_as_mapping, /* tp_as _mapping*/ 0, /* tp_hash */ 0, /* tp_call */ From rhettinger@users.sourceforge.net Thu Jun 20 04:38:14 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed, 19 Jun 2002 20:38:14 -0700 Subject: [Python-checkins] python/dist/src/Lib calendar.py,1.27,1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv8954 Modified Files: calendar.py Log Message: SF 570727 indexer() class no longer needed since lists now support slicing Index: calendar.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/calendar.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** calendar.py 23 Mar 2002 03:26:53 -0000 1.27 --- calendar.py 20 Jun 2002 03:38:12 -0000 1.28 *************** *** 10,14 **** # Import functions and variables from time module from time import localtime, mktime, strftime - from types import SliceType __all__ = ["error","setfirstweekday","firstweekday","isleap", --- 10,13 ---- *************** *** 32,44 **** # fresh on each call, in case the user changes locale between calls. ! class _indexer: ! def __getitem__(self, i): ! if isinstance(i, SliceType): ! return self.data[i.start : i.stop] ! else: ! # May raise an appropriate exception. ! return self.data[i] ! ! class _localized_month(_indexer): def __init__(self, format): self.format = format --- 31,35 ---- # fresh on each call, in case the user changes locale between calls. ! class _localized_month: def __init__(self, format): self.format = format *************** *** 48,57 **** for j in range(1, 13)] self.data.insert(0, "") ! return _indexer.__getitem__(self, i) def __len__(self): return 13 ! class _localized_day(_indexer): def __init__(self, format): self.format = format --- 39,48 ---- for j in range(1, 13)] self.data.insert(0, "") ! return self.data[i] def __len__(self): return 13 ! class _localized_day: def __init__(self, format): self.format = format *************** *** 61,65 **** self.data = [strftime(self.format, (2001, 1, j+1, 12, 0, 0, j, j+1, 0)) for j in range(7)] ! return _indexer.__getitem__(self, i) def __len__(self_): --- 52,56 ---- self.data = [strftime(self.format, (2001, 1, j+1, 12, 0, 0, j, j+1, 0)) for j in range(7)] ! return self.data[i] def __len__(self_): From gvanrossum@users.sourceforge.net Thu Jun 20 04:40:18 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Wed, 19 Jun 2002 20:40:18 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_socket.py,1.38,1.39 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv9332 Modified Files: test_socket.py Log Message: I get failures half of the time that I run this, so I'll disable running this as part of the regular test suite again, until I have time to figure out why. Index: test_socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** test_socket.py 18 Jun 2002 18:35:13 -0000 1.38 --- test_socket.py 20 Jun 2002 03:40:16 -0000 1.39 *************** *** 545,549 **** self.cli_file.flush() ! def test_main(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(GeneralModuleTests)) --- 545,549 ---- self.cli_file.flush() ! def main(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(GeneralModuleTests)) *************** *** 555,557 **** if __name__ == "__main__": ! test_main() --- 555,557 ---- if __name__ == "__main__": ! main() From bwarsaw@users.sourceforge.net Thu Jun 20 04:58:05 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Wed, 19 Jun 2002 20:58:05 -0700 Subject: [Python-checkins] python/nondist/peps pep-0292.txt,1.2,1.3 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv12834 Modified Files: pep-0292.txt Log Message: Many updates based on great comments by python-dev'ers. Index: pep-0292.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0292.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pep-0292.txt 19 Jun 2002 02:54:22 -0000 1.2 --- pep-0292.txt 20 Jun 2002 03:58:03 -0000 1.3 *************** *** 55,62 **** the $ character terminates this placeholder specification. ! 3. ${identifier} is equivalent to $identifier and for clarity, ! this is the preferred form. It is required for when valid ! identifier characters follow the placeholder but are not part of ! the placeholder, e.g. "${noun}ification". No other characters have special meaning. --- 55,61 ---- the $ character terminates this placeholder specification. ! 3. ${identifier} is equivalent to $identifier. It is required for ! when valid identifier characters follow the placeholder but are ! not part of the placeholder, e.g. "${noun}ification". No other characters have special meaning. *************** *** 78,83 **** def birth(self, name): ! country = self.countryOfOrigin['name'] ! return '${name} was born in ${country}' birth('Guido') --- 77,82 ---- def birth(self, name): ! country = self.countryOfOrigin[name] ! return '${name} was born in ${country}'.sub() birth('Guido') *************** *** 88,91 **** --- 87,104 ---- + Why `$' and Braces? + + The BDFL said it best: The $ means "substitution" in so many + languages besides Perl that I wonder where you've been. [...] + We're copying this from the shell. + + + Security Issues + + Never use no-arg .sub() on strings that come from untrusted + sources. It could be used to gain unauthorized information about + variables in your local or global scope. + + Reference Implementation *************** *** 98,124 **** import re - dre = re.compile(r'(\$\$)|\$([_a-z]\w*)|\$\{([_a-z]\w*)\}', re.I) - EMPTYSTRING = '' - class dstr(str): ! def sub(self, mapping=None): ! # Default mapping is locals/globals of caller ! if mapping is None: ! frame = sys._getframe(1) ! mapping = frame.f_globals.copy() ! mapping.update(frame.f_locals) ! # Escape %'s ! s = self.replace('%', '%%') ! # Convert $name and ${name} to $(name)s ! parts = dre.split(s) ! for i in range(1, len(parts), 4): ! if parts[i] is not None: ! parts[i] = '$' ! elif parts[i+1] is not None: ! parts[i+1] = '%(' + parts[i+1] + ')s' ! else: ! parts[i+2] = '%(' + parts[i+2] + ')s' ! # Interpolate ! return EMPTYSTRING.join(filter(None, parts)) % mapping And here are some examples: --- 111,124 ---- import re class dstr(str): ! def sub(self, mapping=None): ! # Default mapping is locals/globals of caller ! if mapping is None: ! frame = sys._getframe(1) ! mapping = frame.f_globals.copy() ! mapping.update(frame.f_locals) ! def repl(m): ! return mapping[m.group(m.lastindex)] ! return re.sub(r'\$(?:([_a-z]\w*)|\{([_a-z]\w*)\})', repl, self) And here are some examples: *************** *** 142,147 **** is given)? There are two possibilities: ! - We can simply allow the exception (likely a NameError or ! KeyError) to propagate. - We can return the original substitution placeholder unchanged. --- 142,146 ---- is given)? There are two possibilities: ! - We can simply allow the exception. - We can return the original substitution placeholder unchanged. *************** *** 168,175 **** Bob was born in ${country} ! The PEP author would prefer the latter interpretation, although a ! case can be made for raising the exception instead. We could ! almost ignore the issue, since the latter example could be ! accomplished by passing in a "safe-dictionary" in instead of a normal dictionary, like so: --- 167,172 ---- Bob was born in ${country} ! We could almost ignore the issue, since the latter example could ! be accomplished by passing in a "safe-dictionary" in instead of a normal dictionary, like so: *************** *** 208,214 **** easily pass in the safedict constructor instead. ! BDFL proto-pronouncement: It should always raise a NameError when ! the key is missing. There may not be sufficient use case for soft ! failures in the no-argument version. --- 205,249 ---- easily pass in the safedict constructor instead. ! BDFL proto-pronouncement: Strongly in favor of raising the ! exception, with KeyError when a dict is used and NameError when ! locals/globals are used. There may not be sufficient use case for ! soft failures in the no-argument version. ! ! ! Open Issues, Comments, and Suggestions ! ! - Ka-Ping Yee makes the suggestion that .sub() should take keyword ! arguments instead of a dictionary, and that if a dictionary was ! to be passed in it should be done with **dict. For example: ! ! s = '${name} was born in ${country}' ! print s.sub(name='Guido', country='the Netherlands') ! ! or ! ! print s.sub(**{'name': 'Guido', 'country': 'the Netherlands'}) ! ! - Paul Prescod wonders whether having a method use sys._getframe() ! doesn't set a bad precedent. ! ! - Oren Tirosh suggests that .sub() take an optional argument which ! would be used as a default for missing keys. If the optional ! argument were not given, an exception would be raised. This may ! not play well with Ka-Ping's suggestion. ! ! - Other suggestions have been made as an alternative to a string ! method including: a builtin function, a function in a module, an ! operator (similar to "string % dict", e.g. "string / dict"). ! One strong argument for making it a built-in is given by Paul ! Prescod: ! ! "I really hate putting things in modules that will be needed in ! a Python programmer's second program (the one after "Hello ! world"). If this is to be the *simpler* way of doing ! introspection then getting at it should be simpler than getting ! at "%". $ is taught in hour 2, import is taught on day 2. ! Some people may never make it to the metaphorical day 2 if they ! are doing simple text processing in some kind of ! embedded-Python environment." From rhettinger@users.sourceforge.net Thu Jun 20 07:12:39 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed, 19 Jun 2002 23:12:39 -0700 Subject: [Python-checkins] python/dist/src/Doc/ref ref3.tex,1.91,1.92 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv3661 Modified Files: ref3.tex Log Message: SF 563530 added missing methods for emulating numeric types Index: ref3.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref3.tex,v retrieving revision 1.91 retrieving revision 1.92 diff -C2 -d -r1.91 -r1.92 *** ref3.tex 11 Jun 2002 10:55:08 -0000 1.91 --- ref3.tex 20 Jun 2002 06:12:37 -0000 1.92 *************** *** 1434,1437 **** --- 1434,1439 ---- \methodline[numeric object]{__rmul__}{self, other} \methodline[numeric object]{__rdiv__}{self, other} + \methodline[numeric object]{__rtruediv__}{self, other} + \methodline[numeric object]{__rfloordiv__}{self, other} \methodline[numeric object]{__rmod__}{self, other} \methodline[numeric object]{__rdivmod__}{self, other} *************** *** 1462,1466 **** \methodline[numeric object]{__imul__}{self, other} \methodline[numeric object]{__idiv__}{self, other} ! \methodline[numeric object]{__imod__}{self, other} \methodline[numeric object]{__ipow__}{self, other\optional{, modulo}} \methodline[numeric object]{__ilshift__}{self, other} --- 1464,1470 ---- \methodline[numeric object]{__imul__}{self, other} \methodline[numeric object]{__idiv__}{self, other} ! \methodline[numeric object]{__itruediv__}{self, other} ! \methodline[numeric object]{__ifloordiv__}{self, other} ! \methodline[numeric object]{__imod__}{self, other} \methodline[numeric object]{__ipow__}{self, other\optional{, modulo}} \methodline[numeric object]{__ilshift__}{self, other} From rhettinger@users.sourceforge.net Thu Jun 20 07:18:28 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed, 19 Jun 2002 23:18:28 -0700 Subject: [Python-checkins] python/dist/src/Doc/ref ref3.tex,1.82.4.3,1.82.4.4 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv4630 Modified Files: Tag: release22-maint ref3.tex Log Message: SF 563530 added missing methods for emulating numeric types Index: ref3.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref3.tex,v retrieving revision 1.82.4.3 retrieving revision 1.82.4.4 diff -C2 -d -r1.82.4.3 -r1.82.4.4 *** ref3.tex 4 Jun 2002 16:29:24 -0000 1.82.4.3 --- ref3.tex 20 Jun 2002 06:18:26 -0000 1.82.4.4 *************** *** 1403,1406 **** --- 1403,1408 ---- \methodline[numeric object]{__rmul__}{self, other} \methodline[numeric object]{__rdiv__}{self, other} + \methodline[numeric object]{__rtruediv__}{self, other} + \methodline[numeric object]{__rfloordiv__}{self, other} \methodline[numeric object]{__rmod__}{self, other} \methodline[numeric object]{__rdivmod__}{self, other} *************** *** 1431,1434 **** --- 1433,1438 ---- \methodline[numeric object]{__imul__}{self, other} \methodline[numeric object]{__idiv__}{self, other} + \methodline[numeric object]{__itruediv__}{self, other} + \methodline[numeric object]{__ifloordiv__}{self, other} \methodline[numeric object]{__imod__}{self, other} \methodline[numeric object]{__ipow__}{self, other\optional{, modulo}} From fdrake@users.sourceforge.net Thu Jun 20 15:23:18 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu, 20 Jun 2002 07:23:18 -0700 Subject: [Python-checkins] python/dist/src/Doc/ref ref5.tex,1.62,1.63 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv24043 Modified Files: ref5.tex Log Message: Simplify the production for argument list, making sure that it actually allows all the legal syntax, and nothing else. Previously, it did not allow a call like func(arg, **dictionary). This closes (again!) SF bug #493243. Index: ref5.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref5.tex,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** ref5.tex 18 Jun 2002 18:42:01 -0000 1.62 --- ref5.tex 20 Jun 2002 14:23:15 -0000 1.63 *************** *** 423,430 **** {\token{primary} "(" [\token{argument_list} [","]] ")"} \production{argument_list} ! {\token{positional_arguments} ["," \token{keyword_arguments} ! ["," "*" \token{expression} ["," "**" \token{expression}]]]} ! \productioncont{| \token{keyword_arguments} ["," "*" \token{expression} ! ["," "**" \token{expression}]]} \productioncont{| "*" \token{expression} ["," "**" \token{expression}]} \productioncont{| "**" \token{expression}} --- 423,430 ---- {\token{primary} "(" [\token{argument_list} [","]] ")"} \production{argument_list} ! {\token{positional_arguments} ["," \token{keyword_arguments}] ! ["," "*" \token{expression}] ["," "**" \token{expression}]} ! \productioncont{| \token{keyword_arguments} ["," "*" \token{expression}] ! ["," "**" \token{expression}]} \productioncont{| "*" \token{expression} ["," "**" \token{expression}]} \productioncont{| "**" \token{expression}} From tim_one@users.sourceforge.net Thu Jun 20 15:52:40 2002 From: tim_one@users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu, 20 Jun 2002 07:52:40 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_enumerate.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv32277/python/Lib/test Modified Files: test_enumerate.py Log Message: Removed the generator future-stmt -- not needed for 2.3. Index: test_enumerate.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_enumerate.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_enumerate.py 26 Apr 2002 19:40:54 -0000 1.1 --- test_enumerate.py 20 Jun 2002 14:52:37 -0000 1.2 *************** *** 1,3 **** - from __future__ import generators import unittest --- 1,2 ---- From fdrake@users.sourceforge.net Thu Jun 20 19:31:23 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu, 20 Jun 2002 11:31:23 -0700 Subject: [Python-checkins] python/dist/src/Modules posixmodule.c,2.239,2.240 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv29463 Modified Files: posixmodule.c Log Message: Clean up docstrings: - Include a blank line between the signature line and the description (Guido sez). - Don't include "-> None" for API functions that always return None because they don't have a meaningful return value. Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.239 retrieving revision 2.240 diff -C2 -d -r2.239 -r2.240 *** posixmodule.c 18 Jun 2002 16:22:43 -0000 2.239 --- posixmodule.c 20 Jun 2002 18:31:21 -0000 2.240 *************** *** 523,527 **** "stat_result: Result from stat or lstat.\n\n\ This object may be accessed either as a tuple of\n\ ! (mode,ino,dev,nlink,uid,gid,size,atime,mtime,ctime)\n\ or via the attributes st_mode, st_ino, st_dev, st_nlink, st_uid, and so on.\n\ \n\ --- 523,527 ---- "stat_result: Result from stat or lstat.\n\n\ This object may be accessed either as a tuple of\n\ ! (mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime)\n\ or via the attributes st_mode, st_ino, st_dev, st_nlink, st_uid, and so on.\n\ [...1313 lines suppressed...] --- 6137,6141 ---- PyDoc_STRVAR(posix_sysconf__doc__, ! "sysconf(name) -> integer\n\n\ Return an integer-valued system configuration variable."); *************** *** 6241,6245 **** PyDoc_STRVAR(posix_abort__doc__, ! "abort() -> does not return!\n\ Abort the interpreter immediately. This 'dumps core' or otherwise fails\n\ in the hardest way possible on the hosting operating system."); --- 6236,6240 ---- PyDoc_STRVAR(posix_abort__doc__, ! "abort() -> does not return!\n\n\ Abort the interpreter immediately. This 'dumps core' or otherwise fails\n\ in the hardest way possible on the hosting operating system."); From fdrake@users.sourceforge.net Thu Jun 20 19:56:13 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu, 20 Jun 2002 11:56:13 -0700 Subject: [Python-checkins] python/nondist/peps pep-0007.txt,1.2,1.3 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv2775 Modified Files: pep-0007.txt Log Message: Add information about writing docstrings in C code. Index: pep-0007.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0007.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pep-0007.txt 5 Jul 2001 18:53:01 -0000 1.2 --- pep-0007.txt 20 Jun 2002 18:56:11 -0000 1.3 *************** *** 141,144 **** --- 141,192 ---- + Documentation Strings + + - Use the PyDoc_STR() or PyDoc_STRVAR() macro for docstrings to + support building Python without docstrings (./configure + --without-doc-strings). + + For C code that needs to support versions of Python older than + 2.3, you can include this after including Python.h: + + #ifndef PyDoc_STR + #define PyDoc_VAR(name) static char name[] + #define PyDoc_STR(str) (str) + #define PyDoc_STRVAR(name, str) PyDoc_VAR(name) = PyDoc_STR(str) + #endif + + - The first line of each fuction docstring should be a "signature + line" that gives a brief synopsis of the arguments and return + value. For example: + + PyDoc_STRVAR(myfunction__doc__, + "myfunction(name, value) -> bool\n\n\ + Determine whether name and value make a valid pair."); + + Always include a blank line between the signature line and the + text of the description. + + If the return value for the function is always None (because + there is no meaningful return value), do not include the + indication of the return type. + + - When writing multi-line docstrings, be sure to always use + backslash continuations, as in the example above, or string + literal concatenation: + + PyDoc_STRVAR(myfunction__doc__, + "myfunction(name, value) -> bool\n\n" + "Determine whether name and value make a valid pair."); + + Though some C compilers accept string literals without either: + + /* BAD -- don't do this! */ + PyDoc_STRVAR(myfunction__doc__, + "myfunction(name, value) -> bool\n\n + Determine whether name and value make a valid pair."); + + not all do; the MSVC compiler is known to complain about this. + + References From jackjansen@users.sourceforge.net Thu Jun 20 21:42:11 2002 From: jackjansen@users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu, 20 Jun 2002 13:42:11 -0700 Subject: [Python-checkins] python/dist/src/Mac/Lib buildtools.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Lib In directory usw-pr-cvs1:/tmp/cvs-serv4422/Mac/Lib Modified Files: buildtools.py Log Message: Open the source file in universal newline mode. Index: buildtools.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Lib/buildtools.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** buildtools.py 9 Jun 2002 22:08:52 -0000 1.12 --- buildtools.py 20 Jun 2002 20:42:07 -0000 1.13 *************** *** 79,83 **** # (there's no point overwriting the destination if it has a syntax error) ! fp = open(filename) text = fp.read() fp.close() --- 79,83 ---- # (there's no point overwriting the destination if it has a syntax error) ! fp = open(filename, 'rU') text = fp.read() fp.close() From fdrake@users.sourceforge.net Thu Jun 20 21:55:31 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu, 20 Jun 2002 13:55:31 -0700 Subject: [Python-checkins] python/dist/src/Doc/ref ref4.tex,1.31,1.32 ref6.tex,1.53,1.54 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv9419/ref Modified Files: ref4.tex ref6.tex Log Message: Try to improve the explanation of the "raise" statement and how its arguments are interpreted. This closes SF bug #532467. Index: ref4.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref4.tex,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** ref4.tex 17 Apr 2002 03:41:50 -0000 1.31 --- ref4.tex 20 Jun 2002 20:55:29 -0000 1.32 *************** *** 193,201 **** When an exception is raised, an object (maybe \code{None}) is passed ! as the exception's ``parameter'' or ``value''; this object does not ! affect the selection of an exception handler, but is passed to the ! selected exception handler as additional information. For class ! exceptions, this object must be an instance of the exception class ! being raised. See also the description of the \keyword{try} statement in section --- 193,200 ---- When an exception is raised, an object (maybe \code{None}) is passed ! as the exception's \emph{value}; this object does not affect the ! selection of an exception handler, but is passed to the selected ! exception handler as additional information. For class exceptions, ! this object must be an instance of the exception class being raised. See also the description of the \keyword{try} statement in section Index: ref6.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref6.tex,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** ref6.tex 17 Jun 2002 12:51:57 -0000 1.53 --- ref6.tex 20 Jun 2002 20:55:29 -0000 1.54 *************** *** 508,542 **** If no expressions are present, \keyword{raise} re-raises the last ! expression that was raised in the current scope. ! ! Otherwise, \keyword{raise} evaluates its first expression, which must yield ! a string, class, or instance object. If there is a second expression, ! this is evaluated, else \code{None} is substituted. If the first ! expression is a class object, then the second expression may be an ! instance of that class or one of its derivatives, and then that ! instance is raised. If the second expression is not such an instance, ! the given class is instantiated. The argument list for the ! instantiation is determined as follows: if the second expression is a ! tuple, it is used as the argument list; if it is \code{None}, the ! argument list is empty; otherwise, the argument list consists of a ! single argument which is the second expression. If the first ! expression is an instance object, the second expression must be ! \code{None}. \index{exception} \indexii{raising}{exception} ! If the first object is a string, it then raises the exception ! identified by the first object, with the second one (or \code{None}) ! as its parameter. If the first object is a class or instance, ! it raises the exception identified by the class of the instance ! determined in the previous step, with the instance as ! its parameter. - If a third object is present, and it is not \code{None}, it should be - a traceback object (see section~\ref{traceback}), and it is - substituted instead of the current location as the place where the - exception occurred. This is useful to re-raise an exception - transparently in an except clause. - \obindex{traceback} --- 508,549 ---- If no expressions are present, \keyword{raise} re-raises the last ! expression that was active in the current scope. If no exception has ! been active in the current scope, an exception is raised that ! indicates indicates that this is the error. \index{exception} \indexii{raising}{exception} ! Otherwise, \keyword{raise} evaluates the expressions to get three ! objects, using \code{None} as the value of omitted expressions. The ! first two objects are used to determine the \emph{type} and ! \emph{value} of the exception. ! ! If the first object is an instance, the type of the exception is the ! class of the instance, the instance itself if the value, and the ! second object must be \code{None}. ! ! If the first object is a class, it becomes the type of the exception. ! The second object is used to determine the exception value: If it is ! an instance of the class, the instance becomes the exception value. ! If the second object is a tuple, it is used as the argument list for ! the class constructor; if it is \code{None}, an empty argument list is ! used, and any other object is treated as a single argument to the ! constructor. The instance so created by calling the constructor is ! used as the exception value. ! ! If the first object is a string, the string object is the exception ! type, and the second object becomes the exception value. ! ! If a third object is present and not \code{None}, it must be a ! traceback\obindex{traceback} object (see section~\ref{traceback}), and ! it is substituted instead of the current location as the place where ! the exception occurred. If the third object is present and not a ! traceback object or \code{None}, a \exception{TypeError} exception is ! raised. The three-expression form of \keyword{raise} is useful to ! re-raise an exception transparently in an except clause, but ! \keyword{raise} with no expressions should be preferred if the ! exception to be re-raised was the most recently active exception in ! the current scope. From fdrake@users.sourceforge.net Thu Jun 20 22:06:06 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu, 20 Jun 2002 14:06:06 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libpyexpat.tex,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv12761/lib Modified Files: libpyexpat.tex Log Message: Added reference to the Expat home page. Index: libpyexpat.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpyexpat.tex,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** libpyexpat.tex 5 Nov 2001 21:31:15 -0000 1.17 --- libpyexpat.tex 20 Jun 2002 21:06:03 -0000 1.18 *************** *** 100,103 **** --- 100,109 ---- + \begin{seealso} + \seetitle[http://www.libexpat.org/]{The Expat XML Parser} + {Home page of the Expat project.} + \end{seealso} + + \subsection{XMLParser Objects \label{xmlparser-objects}} From fdrake@users.sourceforge.net Thu Jun 20 22:10:27 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu, 20 Jun 2002 14:10:27 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libfuncs.tex,1.107,1.108 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv14237 Modified Files: libfuncs.tex Log Message: Add a note that divmod() with complex numbers is deprecated. Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.107 retrieving revision 1.108 diff -C2 -d -r1.107 -r1.108 *** libfuncs.tex 22 May 2002 20:39:43 -0000 1.107 --- libfuncs.tex 20 Jun 2002 21:10:25 -0000 1.108 *************** *** 260,263 **** --- 260,266 ---- \code{\var{a} \%{} \var{b}} is non-zero it has the same sign as \var{b}, and \code{0 <= abs(\var{a} \%{} \var{b}) < abs(\var{b})}. + + \versionchanged[Using \function{divmod()} with complex numbers is + deprecated]{2.3} \end{funcdesc} From fdrake@users.sourceforge.net Thu Jun 20 22:18:48 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu, 20 Jun 2002 14:18:48 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libstring.tex,1.46,1.47 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv17559/lib Modified Files: libstring.tex Log Message: Make the docs for string.capitalize() match those of str.capitalize() (which makes it more clear). Closes SF bug #571767. Index: libstring.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstring.tex,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** libstring.tex 22 Apr 2002 17:42:36 -0000 1.46 --- libstring.tex 20 Jun 2002 21:18:46 -0000 1.47 *************** *** 136,140 **** \begin{funcdesc}{capitalize}{word} ! Capitalize the first character of the argument. \end{funcdesc} --- 136,140 ---- \begin{funcdesc}{capitalize}{word} ! Return a copy of \var{word} with only its first character capitalized. \end{funcdesc} From fdrake@users.sourceforge.net Thu Jun 20 22:19:29 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu, 20 Jun 2002 14:19:29 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libstring.tex,1.45.8.1,1.45.8.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv17831/lib Modified Files: Tag: release22-maint libstring.tex Log Message: Make the docs for string.capitalize() match those of str.capitalize() (which makes it more clear). Closes SF bug #571767. Index: libstring.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstring.tex,v retrieving revision 1.45.8.1 retrieving revision 1.45.8.2 diff -C2 -d -r1.45.8.1 -r1.45.8.2 *** libstring.tex 22 Apr 2002 18:42:44 -0000 1.45.8.1 --- libstring.tex 20 Jun 2002 21:19:27 -0000 1.45.8.2 *************** *** 136,140 **** \begin{funcdesc}{capitalize}{word} ! Capitalize the first character of the argument. \end{funcdesc} --- 136,140 ---- \begin{funcdesc}{capitalize}{word} ! Return a copy of \var{word} with only its first character capitalized. \end{funcdesc} From fdrake@users.sourceforge.net Thu Jun 20 22:19:50 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu, 20 Jun 2002 14:19:50 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libstring.tex,1.42.4.1,1.42.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv17960/lib Modified Files: Tag: release21-maint libstring.tex Log Message: Make the docs for string.capitalize() match those of str.capitalize() (which makes it more clear). Closes SF bug #571767. Index: libstring.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstring.tex,v retrieving revision 1.42.4.1 retrieving revision 1.42.4.2 diff -C2 -d -r1.42.4.1 -r1.42.4.2 *** libstring.tex 10 May 2001 15:13:39 -0000 1.42.4.1 --- libstring.tex 20 Jun 2002 21:19:48 -0000 1.42.4.2 *************** *** 114,118 **** \begin{funcdesc}{capitalize}{word} ! Capitalize the first character of the argument. \end{funcdesc} --- 114,118 ---- \begin{funcdesc}{capitalize}{word} ! Return a copy of \var{word} with only its first character capitalized. \end{funcdesc} From jackjansen@users.sourceforge.net Thu Jun 20 22:34:37 2002 From: jackjansen@users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu, 20 Jun 2002 14:34:37 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_import.py,1.14,1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv23037/Lib/test Modified Files: test_import.py Log Message: Disable the test for importing very long lists for MacPython: it triggers an out-of-memory condition (and a hang on OSX). Filed a bug report (#571845) to make sure this is eventually fixed. Index: test_import.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_import.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** test_import.py 15 Jun 2002 05:14:05 -0000 1.14 --- test_import.py 20 Jun 2002 21:34:35 -0000 1.15 *************** *** 108,110 **** os.unlink(fname) ! test_module_with_large_stack('longlist') --- 108,111 ---- os.unlink(fname) ! if sys.platform != 'mac': ! test_module_with_large_stack('longlist') From fdrake@users.sourceforge.net Thu Jun 20 22:35:04 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu, 20 Jun 2002 14:35:04 -0700 Subject: [Python-checkins] python/dist/src/Python sysmodule.c,2.98.6.4,2.98.6.5 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv23678/Python Modified Files: Tag: release22-maint sysmodule.c Log Message: Fix the docstring for sys.getrefcount(). Closes SF bug #571759. Index: sysmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v retrieving revision 2.98.6.4 retrieving revision 2.98.6.5 diff -C2 -d -r2.98.6.4 -r2.98.6.5 *** sysmodule.c 25 Mar 2002 12:33:56 -0000 2.98.6.4 --- sysmodule.c 20 Jun 2002 21:35:02 -0000 2.98.6.5 *************** *** 467,472 **** "getrefcount(object) -> integer\n\ \n\ ! Return the current reference count for the object. This includes the\n\ ! temporary reference in the argument list, so it is at least 2."; #ifdef COUNT_ALLOCS --- 467,473 ---- "getrefcount(object) -> integer\n\ \n\ ! Return the reference count of object. The count returned is generally\n\ ! one higher than you might expect, because it includes the (temporary)\n\ ! reference as an argument to getrefcount()."; #ifdef COUNT_ALLOCS From fdrake@users.sourceforge.net Thu Jun 20 22:36:21 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu, 20 Jun 2002 14:36:21 -0700 Subject: [Python-checkins] python/dist/src/Python sysmodule.c,2.104,2.105 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv24099/Python Modified Files: sysmodule.c Log Message: Fix the docstring for sys.getrefcount(). Closes SF bug #571759. Index: sysmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v retrieving revision 2.104 retrieving revision 2.105 diff -C2 -d -r2.104 -r2.105 *** sysmodule.c 9 Jun 2002 13:33:54 -0000 2.104 --- sysmodule.c 20 Jun 2002 21:36:19 -0000 2.105 *************** *** 483,488 **** "getrefcount(object) -> integer\n\ \n\ ! Return the current reference count for the object. This includes the\n\ ! temporary reference in the argument list, so it is at least 2." ); --- 483,489 ---- "getrefcount(object) -> integer\n\ \n\ ! Return the reference count of object. The count returned is generally\n\ ! one higher than you might expect, because it includes the (temporary)\n\ ! reference as an argument to getrefcount()." ); From fdrake@users.sourceforge.net Thu Jun 20 23:07:06 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu, 20 Jun 2002 15:07:06 -0700 Subject: [Python-checkins] python/dist/src/Doc/api concrete.tex,1.16,1.17 refcounts.dat,1.41,1.42 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory usw-pr-cvs1:/tmp/cvs-serv819/api Modified Files: concrete.tex refcounts.dat Log Message: Corrected return type and value information for PyUnicode_Count() and PyUnicode_Find(). This closes SF bug #566631. Index: concrete.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/concrete.tex,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** concrete.tex 11 Jun 2002 10:55:08 -0000 1.16 --- concrete.tex 20 Jun 2002 22:07:04 -0000 1.17 *************** *** 1326,1346 **** \end{cfuncdesc} ! \begin{cfuncdesc}{PyObject*}{PyUnicode_Find}{PyObject *str, ! PyObject *substr, ! int start, ! int end, ! int direction} Return the first position of \var{substr} in \var{str}[\var{start}:\var{end}] using the given \var{direction} (\var{direction} == 1 means to do a forward search, ! \var{direction} == -1 a backward search), 0 otherwise. \end{cfuncdesc} ! \begin{cfuncdesc}{PyObject*}{PyUnicode_Count}{PyObject *str, ! PyObject *substr, ! int start, ! int end} ! Count the number of occurrences of \var{substr} in ! \var{str}[\var{start}:\var{end}] \end{cfuncdesc} --- 1326,1350 ---- \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyUnicode_Find}{PyObject *str, ! PyObject *substr, ! int start, ! int end, ! int direction} Return the first position of \var{substr} in \var{str}[\var{start}:\var{end}] using the given \var{direction} (\var{direction} == 1 means to do a forward search, ! \var{direction} == -1 a backward search). The return value is the ! index of the first match; a value of \code{-1} indicates that no ! match was found, and \code{-2} indicates that an error occurred and ! an exception has been set. \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyUnicode_Count}{PyObject *str, ! PyObject *substr, ! int start, ! int end} ! Return the number of non-overlapping occurrences of \var{substr} in ! \code{\var{str}[\var{start}:\var{end}]}. Returns \code{-1} if an ! error occurred. \end{cfuncdesc} Index: refcounts.dat =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/refcounts.dat,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** refcounts.dat 14 Jun 2002 14:35:56 -0000 1.41 --- refcounts.dat 20 Jun 2002 22:07:04 -0000 1.42 *************** *** 1394,1398 **** PyUnicode_Tailmatch:int:direction:: ! PyUnicode_Find:PyObject*::+1: PyUnicode_Find:PyObject*:str:0: PyUnicode_Find:PyObject*:substr:0: --- 1394,1398 ---- PyUnicode_Tailmatch:int:direction:: ! PyUnicode_Find:int::: PyUnicode_Find:PyObject*:str:0: PyUnicode_Find:PyObject*:substr:0: *************** *** 1401,1405 **** PyUnicode_Find:int:direction:: ! PyUnicode_Count:PyObject*::+1: PyUnicode_Count:PyObject*:str:0: PyUnicode_Count:PyObject*:substr:0: --- 1401,1405 ---- PyUnicode_Find:int:direction:: ! PyUnicode_Count:int::: PyUnicode_Count:PyObject*:str:0: PyUnicode_Count:PyObject*:substr:0: From fdrake@users.sourceforge.net Thu Jun 20 23:09:14 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu, 20 Jun 2002 15:09:14 -0700 Subject: [Python-checkins] python/dist/src/Doc/api concrete.tex,1.6.6.4,1.6.6.5 refcounts.dat,1.38.6.2,1.38.6.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory usw-pr-cvs1:/tmp/cvs-serv1434/api Modified Files: Tag: release22-maint concrete.tex refcounts.dat Log Message: Corrected return type and value information for PyUnicode_Count() and PyUnicode_Find(). This closes SF bug #566631. Index: concrete.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/concrete.tex,v retrieving revision 1.6.6.4 retrieving revision 1.6.6.5 diff -C2 -d -r1.6.6.4 -r1.6.6.5 *** concrete.tex 30 Apr 2002 04:07:57 -0000 1.6.6.4 --- concrete.tex 20 Jun 2002 22:09:12 -0000 1.6.6.5 *************** *** 1322,1342 **** \end{cfuncdesc} ! \begin{cfuncdesc}{PyObject*}{PyUnicode_Find}{PyObject *str, ! PyObject *substr, ! int start, ! int end, ! int direction} Return the first position of \var{substr} in \var{str}[\var{start}:\var{end}] using the given \var{direction} (\var{direction} == 1 means to do a forward search, ! \var{direction} == -1 a backward search), 0 otherwise. \end{cfuncdesc} ! \begin{cfuncdesc}{PyObject*}{PyUnicode_Count}{PyObject *str, ! PyObject *substr, ! int start, ! int end} ! Count the number of occurrences of \var{substr} in ! \var{str}[\var{start}:\var{end}] \end{cfuncdesc} --- 1322,1346 ---- \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyUnicode_Find}{PyObject *str, ! PyObject *substr, ! int start, ! int end, ! int direction} Return the first position of \var{substr} in \var{str}[\var{start}:\var{end}] using the given \var{direction} (\var{direction} == 1 means to do a forward search, ! \var{direction} == -1 a backward search). The return value is the ! index of the first match; a value of \code{-1} indicates that no ! match was found, and \code{-2} indicates that an error occurred and ! an exception has been set. \end{cfuncdesc} ! \begin{cfuncdesc}{int}{PyUnicode_Count}{PyObject *str, ! PyObject *substr, ! int start, ! int end} ! Return the number of non-overlapping occurrences of \var{substr} in ! \code{\var{str}[\var{start}:\var{end}]}. Returns \code{-1} if an ! error occurred. \end{cfuncdesc} Index: refcounts.dat =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/refcounts.dat,v retrieving revision 1.38.6.2 retrieving revision 1.38.6.3 diff -C2 -d -r1.38.6.2 -r1.38.6.3 *** refcounts.dat 14 Jun 2002 14:36:23 -0000 1.38.6.2 --- refcounts.dat 20 Jun 2002 22:09:12 -0000 1.38.6.3 *************** *** 1390,1394 **** PyUnicode_Tailmatch:int:direction:: ! PyUnicode_Find:PyObject*::+1: PyUnicode_Find:PyObject*:str:0: PyUnicode_Find:PyObject*:substr:0: --- 1390,1394 ---- PyUnicode_Tailmatch:int:direction:: ! PyUnicode_Find:int::: PyUnicode_Find:PyObject*:str:0: PyUnicode_Find:PyObject*:substr:0: *************** *** 1397,1401 **** PyUnicode_Find:int:direction:: ! PyUnicode_Count:PyObject*::+1: PyUnicode_Count:PyObject*:str:0: PyUnicode_Count:PyObject*:substr:0: --- 1397,1401 ---- PyUnicode_Find:int:direction:: ! PyUnicode_Count:int::: PyUnicode_Count:PyObject*:str:0: PyUnicode_Count:PyObject*:substr:0: From rhettinger@users.sourceforge.net Thu Jun 20 23:23:17 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu, 20 Jun 2002 15:23:17 -0700 Subject: [Python-checkins] python/dist/src/Python compile.c,2.246,2.247 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv4718/Python Modified Files: compile.c Log Message: SF 569257 -- Name mangle double underscored variable names in __slots__. Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.246 retrieving revision 2.247 diff -C2 -d -r2.246 -r2.247 *** compile.c 14 Jun 2002 20:41:16 -0000 2.246 --- compile.c 20 Jun 2002 22:23:14 -0000 2.247 *************** *** 929,934 **** } ! static int ! mangle(char *p, char *name, char *buffer, size_t maxlen) { /* Name mangling: __private becomes _classname__private. --- 929,934 ---- } ! int ! _Py_Mangle(char *p, char *name, char *buffer, size_t maxlen) { /* Name mangling: __private becomes _classname__private. *************** *** 964,968 **** char buffer[MANGLE_LEN]; ! if (mangle(c->c_private, name, buffer, sizeof(buffer))) name = buffer; if (name == NULL || (v = PyString_InternFromString(name)) == NULL) { --- 964,968 ---- char buffer[MANGLE_LEN]; ! if (_Py_Mangle(c->c_private, name, buffer, sizeof(buffer))) name = buffer; if (name == NULL || (v = PyString_InternFromString(name)) == NULL) { *************** *** 1001,1005 **** char buffer[MANGLE_LEN]; ! if (mangle(c->c_private, name, buffer, sizeof(buffer))) name = buffer; if (name == NULL || (v = PyString_InternFromString(name)) == NULL) { --- 1001,1005 ---- char buffer[MANGLE_LEN]; ! if (_Py_Mangle(c->c_private, name, buffer, sizeof(buffer))) name = buffer; if (name == NULL || (v = PyString_InternFromString(name)) == NULL) { *************** *** 4957,4961 **** int flags; ! if (mangle(st->st_private, name, buffer, sizeof(buffer))) name = buffer; v = PyDict_GetItemString(st->st_cur->ste_symbols, name); --- 4957,4961 ---- int flags; ! if (_Py_Mangle(st->st_private, name, buffer, sizeof(buffer))) name = buffer; v = PyDict_GetItemString(st->st_cur->ste_symbols, name); *************** *** 4978,4982 **** int ret; ! if (mangle(st->st_private, name, buffer, sizeof(buffer))) name = buffer; if ((s = PyString_InternFromString(name)) == NULL) --- 4978,4982 ---- int ret; ! if (_Py_Mangle(st->st_private, name, buffer, sizeof(buffer))) name = buffer; if ((s = PyString_InternFromString(name)) == NULL) From rhettinger@users.sourceforge.net Thu Jun 20 23:23:17 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu, 20 Jun 2002 15:23:17 -0700 Subject: [Python-checkins] python/dist/src/Objects typeobject.c,2.155,2.156 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv4718/Objects Modified Files: typeobject.c Log Message: SF 569257 -- Name mangle double underscored variable names in __slots__. Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.155 retrieving revision 2.156 diff -C2 -d -r2.155 -r2.156 *** typeobject.c 18 Jun 2002 16:44:14 -0000 2.155 --- typeobject.c 20 Jun 2002 22:23:14 -0000 2.156 *************** *** 1002,1006 **** PyObject *name, *bases, *dict; static char *kwlist[] = {"name", "bases", "dict", 0}; ! PyObject *slots, *tmp; PyTypeObject *type, *base, *tmptype, *winner; etype *et; --- 1002,1007 ---- PyObject *name, *bases, *dict; static char *kwlist[] = {"name", "bases", "dict", 0}; ! static char buffer[256]; ! PyObject *slots, *tmp, *newslots; PyTypeObject *type, *base, *tmptype, *winner; etype *et; *************** *** 1116,1119 **** --- 1117,1139 ---- } } + + newslots = PyTuple_New(nslots); + if (newslots == NULL) + return NULL; + for (i = 0; i < nslots; i++) { + tmp = PyTuple_GET_ITEM(slots, i); + if (_Py_Mangle(PyString_AS_STRING(name), + PyString_AS_STRING(tmp), + buffer, sizeof(buffer))) + { + tmp = PyString_FromString(buffer); + } else { + Py_INCREF(tmp); + } + PyTuple_SET_ITEM(newslots, i, tmp); + } + Py_DECREF(slots); + slots = newslots; + } if (slots != NULL) { From rhettinger@users.sourceforge.net Thu Jun 20 23:23:17 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu, 20 Jun 2002 15:23:17 -0700 Subject: [Python-checkins] python/dist/src/Include Python.h,2.51,2.52 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory usw-pr-cvs1:/tmp/cvs-serv4718/Include Modified Files: Python.h Log Message: SF 569257 -- Name mangle double underscored variable names in __slots__. Index: Python.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/Python.h,v retrieving revision 2.51 retrieving revision 2.52 diff -C2 -d -r2.51 -r2.52 *** Python.h 9 Jun 2002 13:33:54 -0000 2.51 --- Python.h 20 Jun 2002 22:23:15 -0000 2.52 *************** *** 120,123 **** --- 120,127 ---- #include "abstract.h" + /* _Py_Mangle is defined in compile.c */ + extern DL_IMPORT(int) _Py_Mangle(char *p, char *name, \ + char *buffer, size_t maxlen); + /* PyArg_GetInt is deprecated and should not be used, use PyArg_Parse(). */ #define PyArg_GetInt(v, a) PyArg_Parse((v), "i", (a)) From rhettinger@users.sourceforge.net Thu Jun 20 23:23:17 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu, 20 Jun 2002 15:23:17 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_descr.py,1.142,1.143 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv4718/Lib/test Modified Files: test_descr.py Log Message: SF 569257 -- Name mangle double underscored variable names in __slots__. Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.142 retrieving revision 1.143 diff -C2 -d -r1.142 -r1.143 *** test_descr.py 18 Jun 2002 16:49:45 -0000 1.142 --- test_descr.py 20 Jun 2002 22:23:15 -0000 1.143 *************** *** 1061,1064 **** --- 1061,1082 ---- vereq(x.c, 3) + class C4(object): + """Validate name mangling""" + __slots__ = ['__a'] + def __init__(self, value): + self.__a = value + def get(self): + return self.__a + x = C4(5) + verify(not hasattr(x, '__dict__')) + verify(not hasattr(x, '__a')) + vereq(x.get(), 5) + try: + x.__a = 6 + except AttributeError: + pass + else: + raise TestFailed, "Double underscored names not mangled" + # Make sure slot names are proper identifiers try: From jackjansen@users.sourceforge.net Thu Jun 20 23:55:37 2002 From: jackjansen@users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu, 20 Jun 2002 15:55:37 -0700 Subject: [Python-checkins] python/dist/src/Mac/Build PythonCore.mcp,1.35,1.36 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Build In directory usw-pr-cvs1:/tmp/cvs-serv14008/Python/Mac/Build Modified Files: PythonCore.mcp Log Message: - Got rid of newmodule.c - These are the final projects that support classic. Index: PythonCore.mcp =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Build/PythonCore.mcp,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 Binary files /tmp/cvsDvSuMQ and /tmp/cvsaPmfPy differ From jackjansen@users.sourceforge.net Thu Jun 20 23:56:14 2002 From: jackjansen@users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu, 20 Jun 2002 15:56:14 -0700 Subject: [Python-checkins] python/dist/src/Mac/Build PythonStandSmall.mcp,1.37,1.38 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Build In directory usw-pr-cvs1:/tmp/cvs-serv14099/Python/Mac/Build Modified Files: PythonStandSmall.mcp Log Message: - Got rid of newmodule.c - These are the final projects that support classic. Index: PythonStandSmall.mcp =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Build/PythonStandSmall.mcp,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 Binary files /tmp/cvs0kNHbI and /tmp/cvsmaHrSi differ From jackjansen@users.sourceforge.net Thu Jun 20 23:56:19 2002 From: jackjansen@users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu, 20 Jun 2002 15:56:19 -0700 Subject: [Python-checkins] python/dist/src/Mac/Modules macconfig.c,1.30,1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Modules In directory usw-pr-cvs1:/tmp/cvs-serv14232/Python/Mac/Modules Modified Files: macconfig.c Log Message: - Got rid of newmodule.c - These are the final projects that support classic. Index: macconfig.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Modules/macconfig.c,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** macconfig.c 30 Nov 2001 14:16:31 -0000 1.30 --- macconfig.c 20 Jun 2002 22:56:17 -0000 1.31 *************** *** 70,74 **** extern void inittiming(); extern void initsignal(); - extern void initnew(); extern void initdl(); extern void initsyslog(); --- 70,73 ---- *************** *** 200,204 **** {"md5", initmd5}, {"rotor", initrotor}, - {"new", initnew}, {"gestalt", initgestalt}, {"macfs", initmacfs}, --- 199,202 ---- From jackjansen@users.sourceforge.net Thu Jun 20 23:56:25 2002 From: jackjansen@users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu, 20 Jun 2002 15:56:25 -0700 Subject: [Python-checkins] python/dist/src/Mac/Include macbuildno.h,1.24,1.25 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Include In directory usw-pr-cvs1:/tmp/cvs-serv14259/Python/Mac/Include Modified Files: macbuildno.h Log Message: - Got rid of newmodule.c - These are the final projects that support classic. Index: macbuildno.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Include/macbuildno.h,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** macbuildno.h 27 Dec 2001 23:01:18 -0000 1.24 --- macbuildno.h 20 Jun 2002 22:56:22 -0000 1.25 *************** *** 1 **** ! #define BUILD 124 --- 1 ---- ! #define BUILD 144 From jhylton@users.sourceforge.net Fri Jun 21 00:13:19 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Thu, 20 Jun 2002 16:13:19 -0700 Subject: [Python-checkins] python/dist/src/Objects tupleobject.c,2.67,2.68 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv18791 Modified Files: tupleobject.c Log Message: Fix for SF bug 571885 When resizing a tuple, zero out the memory starting at the end of the old tuple not at the beginning of the old tuple. Index: tupleobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/tupleobject.c,v retrieving revision 2.67 retrieving revision 2.68 diff -C2 -d -r2.67 -r2.68 *** tupleobject.c 13 Jun 2002 21:11:09 -0000 2.67 --- tupleobject.c 20 Jun 2002 23:13:17 -0000 2.68 *************** *** 697,702 **** /* Zero out items added by growing */ if (newsize > oldsize) ! memset(sv->ob_item, 0, ! sizeof(*sv->ob_item) * (newsize - oldsize)); *pv = (PyObject *) sv; _PyObject_GC_TRACK(sv); --- 697,702 ---- /* Zero out items added by growing */ if (newsize > oldsize) ! memset(&sv->ob_item[oldsize], 0, ! sizeof(*sv->ob_item) * (newsize - oldsize)); *pv = (PyObject *) sv; _PyObject_GC_TRACK(sv); From gvanrossum@users.sourceforge.net Fri Jun 21 02:29:27 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 20 Jun 2002 18:29:27 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.432,1.433 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv13932 Modified Files: NEWS Log Message: Mention private vars in __slots__. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.432 retrieving revision 1.433 diff -C2 -d -r1.432 -r1.433 *** NEWS 18 Jun 2002 21:20:13 -0000 1.432 --- NEWS 21 Jun 2002 01:29:25 -0000 1.433 *************** *** 7,10 **** --- 7,13 ---- Core and builtins + - The __slots__ variable can now mention "private" names, and the + right thing will happen (e.g. __slots__ = ["__foo"]). + - Unicode objects in sys.path are no longer ignored but treated as directory names. From gvanrossum@users.sourceforge.net Fri Jun 21 03:14:12 2002 From: gvanrossum@users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu, 20 Jun 2002 19:14:12 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_types.py,1.33,1.34 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv23960 Modified Files: test_types.py Log Message: Add a check that the bug Jeremy just fixed in _PyTuple_Resize() is fixed. (Jeremy, how did you discover that?) Index: test_types.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_types.py,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** test_types.py 19 Jun 2002 15:44:15 -0000 1.33 --- test_types.py 21 Jun 2002 02:14:10 -0000 1.34 *************** *** 245,248 **** --- 245,253 ---- vereq(a[-100L:100L:2L], (0,2,4)) + # Check that a specific bug in _PyTuple_Resize() is squashed. + def f(): + for i in range(1000): + yield i + vereq(list(tuple(f())), range(1000)) print '6.5.3 Lists' From gward@users.sourceforge.net Fri Jun 21 13:33:11 2002 From: gward@users.sourceforge.net (gward@users.sourceforge.net) Date: Fri, 21 Jun 2002 05:33:11 -0700 Subject: [Python-checkins] python/dist/src/Doc/ext embedding.tex,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ext In directory usw-pr-cvs1:/tmp/cvs-serv21177 Modified Files: embedding.tex Log Message: Typo fix. Index: embedding.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/embedding.tex,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** embedding.tex 12 Apr 2002 19:04:17 -0000 1.5 --- embedding.tex 21 Jun 2002 12:33:08 -0000 1.6 *************** *** 190,194 **** Once the script is loaded, the name we're looking for is retrieved using \cfunction{PyObject_GetAttrString()}. If the name exists, and ! the object retunred is callable, you can safely assume that it is a function. The program then proceeds by constructing a tuple of arguments as normal. The call to the Python function is then made --- 190,194 ---- Once the script is loaded, the name we're looking for is retrieved using \cfunction{PyObject_GetAttrString()}. If the name exists, and ! the object returned is callable, you can safely assume that it is a function. The program then proceeds by constructing a tuple of arguments as normal. The call to the Python function is then made From fdrake@users.sourceforge.net Fri Jun 21 14:11:16 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri, 21 Jun 2002 06:11:16 -0700 Subject: [Python-checkins] python/dist/src/Doc/ext embedding.tex,1.4,1.4.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ext In directory usw-pr-cvs1:/tmp/cvs-serv797/ext Modified Files: Tag: release22-maint embedding.tex Log Message: Backport of Greg Ward's rev. 1.6 from the trunk: Typo fix. Index: embedding.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/embedding.tex,v retrieving revision 1.4 retrieving revision 1.4.6.1 diff -C2 -d -r1.4 -r1.4.6.1 *** embedding.tex 28 Nov 2001 07:26:14 -0000 1.4 --- embedding.tex 21 Jun 2002 13:11:12 -0000 1.4.6.1 *************** *** 193,197 **** \cfunction{PyModule_GetDict()}. The dictionary is then searched using the normal dictionary access routines for the function name. If the ! name exists, and the object retunred is callable, you can safely assume that it is a function. The program then proceeds by constructing a tuple of arguments as normal. The call to the python --- 193,197 ---- \cfunction{PyModule_GetDict()}. The dictionary is then searched using the normal dictionary access routines for the function name. If the ! name exists, and the object returned is callable, you can safely assume that it is a function. The program then proceeds by constructing a tuple of arguments as normal. The call to the python From jackjansen@users.sourceforge.net Fri Jun 21 15:48:40 2002 From: jackjansen@users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Fri, 21 Jun 2002 07:48:40 -0700 Subject: [Python-checkins] python/dist/src/Mac/OSX Mac.pth,NONE,1.1 Makefile,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX In directory usw-pr-cvs1:/tmp/cvs-serv2971/Mac/OSX Modified Files: Makefile Added Files: Mac.pth Log Message: Patch #557719 by Tony Lownds, slightly massaged by me: streamline the OSX framework build process. Things fixed/modified: - the filesystem case-sensitivity test now works for builds outside the source directory - various other fixes for building outside the source directory - python.app now has a target in the main Makefile - WASTE and AquaTk are found more automatically --- NEW FILE: Mac.pth --- ../../../Mac/Lib ../../../Mac/Lib/lib-scriptpackages Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/Makefile,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Makefile 23 May 2002 22:18:13 -0000 1.11 --- Makefile 21 Jun 2002 14:48:38 -0000 1.12 *************** *** 1,3 **** ! PYTHONBUILDDIR=../.. INSTALLDIR=/Library/Frameworks/Python.framework/Versions/Current APPINSTALLDIR=/Applications/Python.app --- 1,10 ---- ! # This file can be invoked from the "python.app" target in the ! # main Makefile. The next two variables are overridden on the ! # commandline in that case. ! ! # assume user was invoking from Mac/OSX directory and building in source tree ! PYTHONBUILDDIR = ../.. ! PYTHONSRCDIR = ../.. ! INSTALLDIR=/Library/Frameworks/Python.framework/Versions/Current APPINSTALLDIR=/Applications/Python.app *************** *** 18,23 **** OPT=-g -O3 -Wall -Wstrict-prototypes -Wno-long-double -no-cpp-precomp \ -fno-common -dynamic ! INCLUDES=-I$(PYTHONBUILDDIR) -I$(PYTHONBUILDDIR)/Include \ ! -I$(PYTHONBUILDDIR)/Mac/Include DEFINES=-DHAVE_CONFIG_H --- 25,30 ---- OPT=-g -O3 -Wall -Wstrict-prototypes -Wno-long-double -no-cpp-precomp \ -fno-common -dynamic ! INCLUDES=-I$(PYTHONBUILDDIR) -I$(PYTHONSRCDIR)/Include \ ! -I$(PYTHONSRCDIR)/Mac/Include DEFINES=-DHAVE_CONFIG_H *************** *** 37,45 **** PYTHON=$(PYTHONBUILDDIR)/python.exe ! APPTEMPLATE=$(PYTHONBUILDDIR)/Mac/OSXResources/app APPSUBDIRS=MacOS Resources Resources/English.lproj ! RESOURCEDIR=$(PYTHONBUILDDIR)/Mac/Resources RESOURCEFILE=python.rsrc ! RFCONVERTER=$(PYTHONBUILDDIR)/Mac/Lib/applesingle.py install: pythonforbundle @for i in $(APPINSTALLDIR) $(APPINSTALLDIR)/Contents; do \ --- 44,52 ---- PYTHON=$(PYTHONBUILDDIR)/python.exe ! APPTEMPLATE=$(PYTHONSRCDIR)/Mac/OSXResources/app APPSUBDIRS=MacOS Resources Resources/English.lproj ! RESOURCEDIR=$(PYTHONSRCDIR)/Mac/Resources RESOURCEFILE=python.rsrc ! RFCONVERTER=$(PYTHONSRCDIR)/Mac/Lib/applesingle.py install: pythonforbundle @for i in $(APPINSTALLDIR) $(APPINSTALLDIR)/Contents; do \ *************** *** 90,94 **** LIBDEST=$(INSTALLDIR)/Mac/Lib ! LIBSRC=$(PYTHONBUILDDIR)/Mac/Lib LIBSUBDIRS= \ Carbon \ --- 97,101 ---- LIBDEST=$(INSTALLDIR)/Mac/Lib ! LIBSRC=$(PYTHONSRCDIR)/Mac/Lib LIBSUBDIRS= \ Carbon \ *************** *** 106,110 **** mkcwproject/template-ppc TOOLSDEST=$(INSTALLDIR)/Mac/Tools ! TOOLSSRC=$(PYTHONBUILDDIR)/Mac/Tools TOOLSSUBDIRS=IDE installmacsubtree: --- 113,117 ---- mkcwproject/template-ppc TOOLSDEST=$(INSTALLDIR)/Mac/Tools ! TOOLSSRC=$(PYTHONSRCDIR)/Mac/Tools TOOLSSUBDIRS=IDE installmacsubtree: *************** *** 198,203 **** done ! @echo '** Copy the contents of sample_sitecustomize.py (or similar code) into' ! @echo '**' $(INSTALLDIR)/lib/python2.3/sitecustomize.py # Put symlinks "python" and "pythonw" in the standard place --- 205,209 ---- done ! $(INSTALL_DATA) $(PYTHONSRCDIR)/Mac/OSX/Mac.pth $(INSTALLDIR)/lib/python2.3/site-packages/ # Put symlinks "python" and "pythonw" in the standard place *************** *** 214,215 **** --- 220,230 ---- @echo '** Copy the contents of sample_sitecustomize.py (or similar code) into' @echo '**' $(INSTALLDIR)/lib/python2.3/sitecustomize.py + + + # Rules to build each file in OBJECTS - is there a better way? + $(PYTHONBUILDDIR)/Mac/Python/macmain.o: $(PYTHONSRCDIR)/Mac/Python/macmain.c + $(CC) $(CFLAGS) -c $(PYTHONSRCDIR)/Mac/Python/macmain.c -o $@ + + $(PYTHONBUILDDIR)/Mac/Python/macgetargv.o: $(PYTHONSRCDIR)/Mac/Python/macgetargv.c + $(CC) $(CFLAGS) -c $(PYTHONSRCDIR)/Mac/Python/macgetargv.c -o $@ + From jackjansen@users.sourceforge.net Fri Jun 21 15:48:40 2002 From: jackjansen@users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Fri, 21 Jun 2002 07:48:40 -0700 Subject: [Python-checkins] python/dist/src Makefile.pre.in,1.85,1.86 configure.in,1.325,1.326 configure,1.315,1.316 setup.py,1.94,1.95 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv2971 Modified Files: Makefile.pre.in configure.in configure setup.py Log Message: Patch #557719 by Tony Lownds, slightly massaged by me: streamline the OSX framework build process. Things fixed/modified: - the filesystem case-sensitivity test now works for builds outside the source directory - various other fixes for building outside the source directory - python.app now has a target in the main Makefile - WASTE and AquaTk are found more automatically Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.pre.in,v retrieving revision 1.85 retrieving revision 1.86 diff -C2 -d -r1.85 -r1.86 *** Makefile.pre.in 11 Jun 2002 06:22:30 -0000 1.85 --- Makefile.pre.in 21 Jun 2002 14:48:36 -0000 1.86 *************** *** 799,802 **** --- 799,808 ---- $(INSTALL_DATA) $(LDLIBRARY) $(PYTHONFRAMEWORKPREFIX)/$(LDLIBRARY) + # Build Python executable that can run GUI code. Another MacOSX pseudo + # target. + python.app: + $(MAKE) -f $(srcdir)/Mac/OSX/Makefile install installmacsubtree \ + PYTHONSRCDIR=$(srcdir) PYTHONBUILDDIR=. + # Build the toplevel Makefile Makefile.pre: Makefile.pre.in config.status Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.325 retrieving revision 1.326 diff -C2 -d -r1.325 -r1.326 *** configure.in 14 Jun 2002 20:30:30 -0000 1.325 --- configure.in 21 Jun 2002 14:48:36 -0000 1.326 *************** *** 222,226 **** AC_SUBST(BUILDEXEEXT) AC_MSG_CHECKING(for case-insensitive build directory) ! if test -d "python" then AC_MSG_RESULT(yes) --- 222,226 ---- AC_SUBST(BUILDEXEEXT) AC_MSG_CHECKING(for case-insensitive build directory) ! if test -d "${srcdir}/python" then AC_MSG_RESULT(yes) *************** *** 2317,2321 **** AC_SUBST(SRCDIRS) ! SRCDIRS="Parser Grammar Objects Python Modules" AC_MSG_CHECKING(for build directories) for dir in $SRCDIRS; do --- 2317,2321 ---- AC_SUBST(SRCDIRS) ! SRCDIRS="Parser Grammar Objects Python Modules Mac Mac/Python" AC_MSG_CHECKING(for build directories) for dir in $SRCDIRS; do Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.315 retrieving revision 1.316 diff -C2 -d -r1.315 -r1.316 *** configure 14 Jun 2002 20:30:29 -0000 1.315 --- configure 21 Jun 2002 14:48:36 -0000 1.316 *************** *** 1,4 **** #! /bin/sh ! # From configure.in Revision: 1.323 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.53. --- 1,4 ---- #! /bin/sh ! # From configure.in Revision: 1.325 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.53. *************** *** 2952,2956 **** echo "$as_me:$LINENO: checking for case-insensitive build directory" >&5 echo $ECHO_N "checking for case-insensitive build directory... $ECHO_C" >&6 ! if test -d "python" then echo "$as_me:$LINENO: result: yes" >&5 --- 2952,2956 ---- echo "$as_me:$LINENO: checking for case-insensitive build directory" >&5 echo $ECHO_N "checking for case-insensitive build directory... $ECHO_C" >&6 ! if test -d "${srcdir}/python" then echo "$as_me:$LINENO: result: yes" >&5 *************** *** 11445,11448 **** --- 11445,11449 ---- + for ac_func in alarm chown chroot clock confstr ctermid ctermid_r execv \ fchdir flock fork fsync fdatasync fpathconf ftime ftruncate \ *************** *** 15925,15929 **** ! SRCDIRS="Parser Grammar Objects Python Modules" echo "$as_me:$LINENO: checking for build directories" >&5 echo $ECHO_N "checking for build directories... $ECHO_C" >&6 --- 15926,15930 ---- ! SRCDIRS="Parser Grammar Objects Python Modules Mac Mac/Python" echo "$as_me:$LINENO: checking for build directories" >&5 echo $ECHO_N "checking for build directories... $ECHO_C" >&6 Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.94 retrieving revision 1.95 diff -C2 -d -r1.94 -r1.95 *** setup.py 17 Jun 2002 17:55:30 -0000 1.94 --- setup.py 21 Jun 2002 14:48:38 -0000 1.95 *************** *** 719,723 **** '../Python/getapplbycreator.c'], extra_link_args=['-framework', 'Carbon']) ) ! exts.append( Extension('_CF', ['cf/_CFmodule.c'], extra_link_args=['-framework', 'CoreFoundation']) ) exts.append( Extension('_Res', ['res/_Resmodule.c'], --- 719,723 ---- '../Python/getapplbycreator.c'], extra_link_args=['-framework', 'Carbon']) ) ! exts.append( Extension('_CF', ['cf/_CFmodule.c', 'cf/pycfbridge.c'], extra_link_args=['-framework', 'CoreFoundation']) ) exts.append( Extension('_Res', ['res/_Resmodule.c'], *************** *** 768,786 **** exts.append( Extension('_TE', ['te/_TEmodule.c'], extra_link_args=['-framework', 'Carbon']) ) ! # As there is no standardized place (yet) to put user-installed ! # Mac libraries on OSX you should put a symlink to your Waste ! # installation in the same folder as your python source tree. ! # Or modify the next two lines:-) ! waste_incs = find_file("WASTE.h", [], ["../waste/C_C++ Headers"]) waste_libs = find_library_file(self.compiler, "WASTE", [], ! ["../waste/Static Libraries"]) if waste_incs != None and waste_libs != None: exts.append( Extension('waste', ! ['waste/wastemodule.c', 'Mac/Wastemods/WEObjectHandlers.c', 'Mac/Wastemods/WETabHooks.c', 'Mac/Wastemods/WETabs.c' ], ! include_dirs = waste_incs + ['Mac/Wastemods'], library_dirs = waste_libs, libraries = ['WASTE'], --- 768,791 ---- exts.append( Extension('_TE', ['te/_TEmodule.c'], extra_link_args=['-framework', 'Carbon']) ) ! # As there is no standardized place (yet) to put ! # user-installed Mac libraries on OSX, we search for "waste" ! # in parent directories of the Python source tree. You ! # should put a symlink to your Waste installation in the ! # same folder as your python source tree. Or modify the ! # next few lines:-) ! waste_incs = find_file("WASTE.h", [], ! ['../'*n + 'waste/C_C++ Headers' for n in (0,1,2,3,4)]) waste_libs = find_library_file(self.compiler, "WASTE", [], ! ["../"*n + "waste/Static Libraries" for n in (0,1,2,3,4)]) if waste_incs != None and waste_libs != None: + (srcdir,) = sysconfig.get_config_vars('srcdir') exts.append( Extension('waste', ! ['waste/wastemodule.c'] + [ ! os.path.join(srcdir, d) for d in 'Mac/Wastemods/WEObjectHandlers.c', 'Mac/Wastemods/WETabHooks.c', 'Mac/Wastemods/WETabs.c' ], ! include_dirs = waste_incs + [os.path.join(srcdir, 'Mac/Wastemods')], library_dirs = waste_libs, libraries = ['WASTE'], *************** *** 795,802 **** --- 800,868 ---- self.detect_tkinter(inc_dirs, lib_dirs) + def detect_tkinter_darwin(self, inc_dirs, lib_dirs): + # The _tkinter module, using frameworks. Since frameworks are quite + # different the UNIX search logic is not sharable. + from os.path import join, exists + framework_dirs = [ + '/System/Library/Frameworks/', + '/Library/Frameworks', + join(os.getenv('HOME'), '/Library/Frameworks') + ] + # Find the directory that contains the Tcl.framwork and Tk.framework + # bundles. + # XXX distutils should support -F! + for F in framework_dirs: + # both Tcl.framework and Tk.framework should be present + for fw in 'Tcl', 'Tk': + if not exists(join(F, fw + '.framework')): + break + else: + # ok, F is now directory with both frameworks. Continure + # building + break + else: + # Tk and Tcl frameworks not found. Normal "unix" tkinter search + # will now resume. + return 0 + + # For 8.4a2, we must add -I options that point inside the Tcl and Tk + # frameworks. In later release we should hopefully be able to pass + # the -F option to gcc, which specifies a framework lookup path. + # + include_dirs = [ + join(F, fw + '.framework', H) + for fw in 'Tcl', 'Tk' + for H in 'Headers', 'Versions/Current/PrivateHeaders' + ] + + # For 8.4a2, the X11 headers are not included. Rather than include a + # complicated search, this is a hard-coded path. It could bail out + # if X11 libs are not found... + include_dirs.append('/usr/X11R6/include') + frameworks = ['-framework', 'Tcl', '-framework', 'Tk'] + + ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], + define_macros=[('WITH_APPINIT', 1)], + include_dirs = include_dirs, + libraries = [], + extra_compile_args = frameworks, + extra_link_args = frameworks, + ) + self.extensions.append(ext) + return 1 + + def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module. + # Rather than complicate the code below, detecting and building + # AquaTk is a separate method. Only one Tkinter will be built on + # Darwin - either AquaTk, if it is found, or X11 based Tk. + platform = self.get_platform() + if platform == 'darwin' and \ + self.detect_tkinter_darwin(inc_dirs, lib_dirs): + return + # Assume we haven't found any of the libraries or include files # The versions with dots are used on Unix, and the versions without *************** *** 836,840 **** # Check for various platform-specific directories - platform = self.get_platform() if platform == 'sunos5': include_dirs.append('/usr/openwin/include') --- 902,905 ---- From fdrake@users.sourceforge.net Sat Jun 22 02:07:39 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri, 21 Jun 2002 18:07:39 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libre.tex,1.83,1.84 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv32008/Doc/lib Modified Files: libre.tex Log Message: Correct the RE equivalent of scanf()'s %x and %X patterns. Closes SF bug #572169. Index: libre.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libre.tex,v retrieving revision 1.83 retrieving revision 1.84 diff -C2 -d -r1.83 -r1.84 *** libre.tex 11 Apr 2002 12:24:12 -0000 1.83 --- libre.tex 22 Jun 2002 01:07:37 -0000 1.84 *************** *** 863,867 **** {\regexp{\e d+}} \lineii{\code{\%x}, \code{\%X}} ! {\regexp{0[xX][\e dA-Fa-f]}} \end{tableii} --- 863,867 ---- {\regexp{\e d+}} \lineii{\code{\%x}, \code{\%X}} ! {\regexp{0[xX][\e dA-Fa-f]+}} \end{tableii} From fdrake@users.sourceforge.net Sat Jun 22 02:07:52 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri, 21 Jun 2002 18:07:52 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libre.tex,1.73.6.6,1.73.6.7 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv32061/Doc/lib Modified Files: Tag: release22-maint libre.tex Log Message: Correct the RE equivalent of scanf()'s %x and %X patterns. Closes SF bug #572169. Index: libre.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libre.tex,v retrieving revision 1.73.6.6 retrieving revision 1.73.6.7 diff -C2 -d -r1.73.6.6 -r1.73.6.7 *** libre.tex 25 Mar 2002 20:22:28 -0000 1.73.6.6 --- libre.tex 22 Jun 2002 01:07:50 -0000 1.73.6.7 *************** *** 878,882 **** {\regexp{\e d+}} \lineii{\code{\%x}, \code{\%X}} ! {\regexp{0[xX][\e dA-Fa-f]}} \end{tableii} --- 878,882 ---- {\regexp{\e d+}} \lineii{\code{\%x}, \code{\%X}} ! {\regexp{0[xX][\e dA-Fa-f]+}} \end{tableii} From fdrake@users.sourceforge.net Sat Jun 22 02:42:02 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri, 21 Jun 2002 18:42:02 -0700 Subject: [Python-checkins] python/dist/src/Doc/ext extending.tex,1.20,1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ext In directory usw-pr-cvs1:/tmp/cvs-serv7160/Doc/ext Modified Files: extending.tex Log Message: Convert the example C code to ANSI rather than K&R. This matches the Python C style guide (PEP 7). Closes SF patch #571489. Index: extending.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/extending.tex,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** extending.tex 16 May 2002 13:48:14 -0000 1.20 --- extending.tex 22 Jun 2002 01:42:00 -0000 1.21 *************** *** 66,72 **** \begin{verbatim} static PyObject * ! spam_system(self, args) ! PyObject *self; ! PyObject *args; { char *command; --- 66,70 ---- \begin{verbatim} static PyObject * ! spam_system(PyObject *self, PyObject *args) { char *command; *************** *** 372,376 **** \begin{verbatim} ! int main(int argc, char **argv) { /* Pass argv[0] to the Python interpreter */ --- 370,375 ---- \begin{verbatim} ! int ! main(int argc, char *argv[]) { /* Pass argv[0] to the Python interpreter */ *************** *** 477,482 **** static PyObject * ! my_set_callback(dummy, args) ! PyObject *dummy, *args; { PyObject *result = NULL; --- 476,480 ---- static PyObject * ! my_set_callback(PyObject *dummy, PyObject *args) { PyObject *result = NULL; *************** *** 697,701 **** \begin{verbatim} int PyArg_ParseTupleAndKeywords(PyObject *arg, PyObject *kwdict, ! char *format, char **kwlist, ...); \end{verbatim} --- 695,699 ---- \begin{verbatim} int PyArg_ParseTupleAndKeywords(PyObject *arg, PyObject *kwdict, ! char *format, char *kwlist[], ...); \end{verbatim} *************** *** 721,728 **** static PyObject * ! keywdarg_parrot(self, args, keywds) ! PyObject *self; ! PyObject *args; ! PyObject *keywds; { int voltage; --- 719,723 ---- static PyObject * ! keywdarg_parrot(PyObject *self, PyObject *args, PyObject *keywds) { int voltage; *************** *** 1019,1023 **** \begin{verbatim} ! bug(PyObject *list) { PyObject *item = PyList_GetItem(list, 0); --- 1014,1020 ---- \begin{verbatim} ! void ! bug(PyObject *list) ! { PyObject *item = PyList_GetItem(list, 0); *************** *** 1053,1057 **** \begin{verbatim} ! no_bug(PyObject *list) { PyObject *item = PyList_GetItem(list, 0); --- 1050,1056 ---- \begin{verbatim} ! void ! no_bug(PyObject *list) ! { PyObject *item = PyList_GetItem(list, 0); *************** *** 1079,1083 **** \begin{verbatim} ! bug(PyObject *list) { PyObject *item = PyList_GetItem(list, 0); Py_BEGIN_ALLOW_THREADS --- 1078,1084 ---- \begin{verbatim} ! void ! bug(PyObject *list) ! { PyObject *item = PyList_GetItem(list, 0); Py_BEGIN_ALLOW_THREADS *************** *** 1222,1227 **** \begin{verbatim} static int ! PySpam_System(command) ! char *command; { return system(command); --- 1223,1227 ---- \begin{verbatim} static int ! PySpam_System(char *command) { return system(command); *************** *** 1233,1239 **** \begin{verbatim} static PyObject * ! spam_system(self, args) ! PyObject *self; ! PyObject *args; { char *command; --- 1233,1237 ---- \begin{verbatim} static PyObject * ! spam_system(PyObject *self, PyObject *args) { char *command; From fdrake@users.sourceforge.net Sat Jun 22 03:14:51 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri, 21 Jun 2002 19:14:51 -0700 Subject: [Python-checkins] python/nondist/peps pep-0008.txt,1.15,1.16 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv14608 Modified Files: pep-0008.txt Log Message: Fix a couple of import statements. Index: pep-0008.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0008.txt,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** pep-0008.txt 4 Jun 2002 17:02:07 -0000 1.15 --- pep-0008.txt 22 Jun 2002 02:14:49 -0000 1.16 *************** *** 549,558 **** for that purpose, e.g.: ! from string import StringTypes if isinstance(obj, StringTypes): In Python 2.0 and 2.1, you should do: ! from string import StringType, UnicodeType if isinstance(obj, StringType) or \ isinstance(obj, UnicodeType) : --- 549,558 ---- for that purpose, e.g.: ! from types import StringTypes if isinstance(obj, StringTypes): In Python 2.0 and 2.1, you should do: ! from types import StringType, UnicodeType if isinstance(obj, StringType) or \ isinstance(obj, UnicodeType) : From bwarsaw@users.sourceforge.net Sun Jun 23 03:20:52 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Sat, 22 Jun 2002 19:20:52 -0700 Subject: [Python-checkins] python/nondist/peps pep-0292.txt,1.3,1.4 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv32280 Modified Files: pep-0292.txt Log Message: Bunch of updates (not sure I got them all, the thread was looonggg. ;) Index: pep-0292.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0292.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pep-0292.txt 20 Jun 2002 03:58:03 -0000 1.3 --- pep-0292.txt 23 Jun 2002 02:20:50 -0000 1.4 *************** *** 37,41 **** In addition, the rules for what can follow a % sign are fairly ! complex, while the usual application rarely needs such complexity. --- 37,47 ---- In addition, the rules for what can follow a % sign are fairly ! complex, while the usual application rarely needs such ! complexity. Also error prone is the right-hand side of the % ! operator: e.g. singleton tuples. ! ! Most scripts need to do some string interpolation, but most of ! those use simple `stringification' formats, i.e. %s or %(name)s ! This form should be made simpler and less error prone. *************** *** 246,249 **** --- 252,271 ---- are doing simple text processing in some kind of embedded-Python environment." + + - Should we take a cue from the `make' program and allow $(name) + as an alternative (or instead of) ${name}? + + - Should we require a dictionary to the .sub() method? Some + people feel that it could be a security risk allowing implicit + access to globals/locals, even with the proper admonitions in + the documentation. In that case, a new built-in would be + necessary (because none of globals(), locals(), or vars() does + the right the w.r.t. nested scopes, etc.). Chirstian Tismer + has suggested allvars(). Perhaps allvars() should be a method + on a frame object (too?)? + + - It has been suggested that using $ at all violates TOOWTDI. + Some other suggestions include using the % sign in the + following way: %{name} From pierslauder@users.sourceforge.net Sun Jun 23 11:47:15 2002 From: pierslauder@users.sourceforge.net (pierslauder@users.sourceforge.net) Date: Sun, 23 Jun 2002 03:47:15 -0700 Subject: [Python-checkins] python/dist/src/Lib imaplib.py,1.51,1.52 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv1482/dist/src/Lib Modified Files: imaplib.py Log Message: Fix IMAP4_SSL read and send methods to take account of short data Index: imaplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/imaplib.py,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** imaplib.py 17 Jun 2002 12:43:20 -0000 1.51 --- imaplib.py 23 Jun 2002 10:47:13 -0000 1.52 *************** *** 19,23 **** # GET/SETQUOTA contributed by Andreas Zeidler June 2002. ! __version__ = "2.52" import binascii, re, socket, time, random, sys --- 19,23 ---- # GET/SETQUOTA contributed by Andreas Zeidler June 2002. ! __version__ = "2.53" import binascii, re, socket, time, random, sys *************** *** 1057,1065 **** def read(self, size): """Read 'size' bytes from remote.""" ! return self.sslobj.read(size) def readline(self): """Read line from remote.""" line = "" while 1: --- 1057,1071 ---- def read(self, size): """Read 'size' bytes from remote.""" ! # sslobj.read() sometimes returns < size bytes ! data = self.sslobj.read(size) ! while len(data) < size: ! data += self.sslobj.read(len(data)-size) ! ! return data def readline(self): """Read line from remote.""" + # NB: socket.ssl needs a "readline" method, or perhaps a "makefile" method. line = "" while 1: *************** *** 1071,1075 **** def send(self, data): """Send data to remote.""" ! self.sslobj.write(data) --- 1077,1088 ---- def send(self, data): """Send data to remote.""" ! # NB: socket.ssl needs a "sendall" method to match socket objects. ! bytes = len(data) ! while bytes > 0: ! sent = self.sslobj.write(data) ! if sent == bytes: ! break # avoid copy ! data = data[sent:] ! bytes = bytes - sent From mwh@users.sourceforge.net Sun Jun 23 17:29:39 2002 From: mwh@users.sourceforge.net (mwh@users.sourceforge.net) Date: Sun, 23 Jun 2002 09:29:39 -0700 Subject: [Python-checkins] python/dist/src README,1.147,1.148 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv6643 Modified Files: README Log Message: Random tweaks & updates. Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/README,v retrieving revision 1.147 retrieving revision 1.148 diff -C2 -d -r1.147 -r1.148 *** README 14 Jun 2002 20:30:29 -0000 1.147 --- README 23 Jun 2002 16:29:36 -0000 1.148 *************** *** 89,94 **** authors, translators, and people with special formatting requirements. ! The best documentation for the new (in Python 2.2) type/class unification ! features is Guido's tutorial introduction, at http://www.python.org/2.2/descrintro.html --- 89,94 ---- authors, translators, and people with special formatting requirements. ! The best documentation for the new (in Python 2.2) type/class ! unification features is Guido's tutorial introduction, at http://www.python.org/2.2/descrintro.html *************** *** 101,105 **** http://www.python.org/. Come visit us! ! There's also a Python community web site at http://starship.python.net/. --- 101,106 ---- http://www.python.org/. Come visit us! ! There's also a Python community web site at ! http://starship.python.net/. *************** *** 113,118 **** overview of the many Python-related mailing lists. ! Archives are accessible via Deja.com Usenet News: see ! http://www.deja.com/usenet. The mailing lists are also archived, see http://www.python.org/psa/MailingLists.html for details. --- 114,119 ---- overview of the many Python-related mailing lists. ! Archives are accessible via the Google Groups usenet archive; see ! http://groups.google.com/. The mailing lists are also archived, see http://www.python.org/psa/MailingLists.html for details. *************** *** 926,934 **** effect of running the configure script manually (for Mac and PC, this has already been done for you). A good start is to copy the file ! config.h.in to config.h and edit the latter to reflect the actual configuration of your system. Most symbols must simply be defined as 1 only if the corresponding feature is present and can be left alone ! otherwise; however the *_t type symbols must be defined as some variant ! of int if they need to be defined at all. For all platforms, it's important that the build arrange to define the --- 927,935 ---- effect of running the configure script manually (for Mac and PC, this has already been done for you). A good start is to copy the file ! pyconfig.h.in to pyconfig.h and edit the latter to reflect the actual configuration of your system. Most symbols must simply be defined as 1 only if the corresponding feature is present and can be left alone ! otherwise; however the *_t type symbols must be defined as some ! variant of int if they need to be defined at all. For all platforms, it's important that the build arrange to define the *************** *** 997,1000 **** --- 998,1002 ---- LICENSE Licensing information Lib/ Python library modules + Mac/ Macintosh specific resources Makefile.pre.in Source from which config.status creates the Makefile.pre Misc/ Miscellaneous useful files *************** *** 1007,1012 **** README The file you're reading now Tools/ Some useful programs written in Python ! acconfig.h Additional input for the GNU autoheader program ! config.h.in Source from which config.h is created (GNU autoheader output) configure Configuration shell script (GNU autoconf output) configure.in Configuration specification (input for GNU autoconf) --- 1009,1013 ---- README The file you're reading now Tools/ Some useful programs written in Python ! pyconfig.h.in Source from which pyconfig.h is created (GNU autoheader output) configure Configuration shell script (GNU autoconf output) configure.in Configuration specification (input for GNU autoconf) *************** *** 1018,1024 **** Makefile Build rules Makefile.pre Build rules before running Modules/makesetup ! buildno Keeps track of the build number config.cache Cache of configuration variables ! config.h Configuration header config.log Log from last configure run config.status Status from last run of the configure script --- 1019,1025 ---- Makefile Build rules Makefile.pre Build rules before running Modules/makesetup ! buildno Keeps track of the build number config.cache Cache of configuration variables ! pyconfig.h Configuration header config.log Log from last configure run config.status Status from last run of the configure script From jackjansen@users.sourceforge.net Sun Jun 23 23:09:47 2002 From: jackjansen@users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Sun, 23 Jun 2002 15:09:47 -0700 Subject: [Python-checkins] python/dist/src/Mac/mwerks mwerks_nscarbon.pch,NONE,1.1 mwerks_shcarbon.pch,NONE,1.1 mwerks_smcarbon.pch,NONE,1.1 mwerks_smcarbon_config.h,NONE,1.1 mwerks_nscarbon_config.h,1.8,1.9 mwerks_shcarbon_config.h,1.7,1.8 mwerks_carbon_config.h,1.11,NONE mwerks_carbonplugin_config.h,1.6,NONE mwerks_nonshared_config.h,1.27,NONE mwerks_plugin_config.h,1.12,NONE mwerks_shared_config.h,1.22,NONE mwerks_shlib_config.h,1.1,NONE mwerks_small_config.h,1.17,NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/mwerks In directory usw-pr-cvs1:/tmp/cvs-serv13756 Modified Files: mwerks_nscarbon_config.h mwerks_shcarbon_config.h Added Files: mwerks_nscarbon.pch mwerks_shcarbon.pch mwerks_smcarbon.pch mwerks_smcarbon_config.h Removed Files: mwerks_carbon_config.h mwerks_carbonplugin_config.h mwerks_nonshared_config.h mwerks_plugin_config.h mwerks_shared_config.h mwerks_shlib_config.h mwerks_small_config.h Log Message: - Got rid of non-carbon stuff - Use precompiled headers - Rationalized naming scheme --- NEW FILE: mwerks_nscarbon.pch --- #pragma once on #pragma precompile_target "mwerks_nscarbon_pch" #include "mwerks_nscarbon_config.h" #include #include "Python.h" --- NEW FILE: mwerks_shcarbon.pch --- #pragma once on #pragma precompile_target "mwerks_shcarbon_pch" #include "mwerks_shcarbon_config.h" #include #include "Python.h" --- NEW FILE: mwerks_smcarbon.pch --- #pragma once on #pragma precompile_target "mwerks_smcarbon_pch" #include "mwerks_smcarbon_config.h" #include #include "Python.h" --- NEW FILE: mwerks_smcarbon_config.h --- /* ** Configuration file for small standalone Carbon Python. ** ** Note: enabling the switches below is not enough to enable the ** specific features, you may also need different sets of sources. */ #define ACCESSOR_CALLS_ARE_FUNCTIONS 1 #define OPAQUE_TOOLBOX_STRUCTS 1 #define TARGET_API_MAC_CARBON 1 #define USE_GUSI2 /* Stdio implemented with GUSI 2 */ #define USE_MSL /* Use Mw Standard Library (as opposed to Plaugher C libraries) */ #define USE_TOOLBOX /* Include toolbox modules in core Python */ /* #define USE_CORE_TOOLBOX /* Include minimal set of toolbox modules in core Python */ #define USE_QT /* Include quicktime modules in core Python */ /* #define USE_WASTE /* Include waste module in core Python */ /* #define USE_MACSPEECH /* Include macspeech module in core Python */ /* #define USE_IMG /* Include img modules in core Python */ /* #define USE_MACCTB /* Include ctb module in core Python */ /* #define USE_STDWIN /* Include stdwin module in core Python */ /* #define USE_MACTCP /* Include mactcp (*not* socket) modules in core */ /* #define USE_TK /* Include _tkinter module in core Python */ /* #define MAC_TCL /* This *must* be on if USE_TK is on */ /* #define USE_MAC_SHARED_LIBRARY /* Enable code to add shared-library resources */ /* #define USE_MAC_APPLET_SUPPORT /* Enable code to run a PYC resource */ /* #define HAVE_DYNAMIC_LOADING /* Enable dynamically loaded modules */ /* #define USE_GDBM /* Include the gdbm module */ /* #define USE_ZLIB /* Include the zlib module */ #define WITH_HOTSHOT /* Enable hotshot profiler */ #define USE_MSL_MALLOC /* Disable private malloc. Also disables next two defines */ #ifndef USE_MSL_MALLOC /* #define USE_MALLOC_DEBUG /* Enable range checking and other malloc debugging */ #endif #define WITHOUT_FRAMEWORKS /* Use old-style Universal Header includes, not Carbon/Carbon.h */ #ifdef USE_MSL #define MSL_USE_PRECOMPILED_HEADERS 0 /* Don't use precomp headers: we include our own */ #include #endif #ifndef Py_DEBUG #define NDEBUG #endif Index: mwerks_nscarbon_config.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/mwerks/mwerks_nscarbon_config.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** mwerks_nscarbon_config.h 11 Apr 2002 20:55:45 -0000 1.8 --- mwerks_nscarbon_config.h 23 Jun 2002 22:09:45 -0000 1.9 *************** *** 1,4 **** /* ! ** Configuration file for standalone 68k/ppc Python. ** ** Note: enabling the switches below is not enough to enable the --- 1,4 ---- /* ! ** Configuration file for standalone Carbon Python. ** ** Note: enabling the switches below is not enough to enable the Index: mwerks_shcarbon_config.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/mwerks/mwerks_shcarbon_config.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** mwerks_shcarbon_config.h 11 Apr 2002 20:55:54 -0000 1.7 --- mwerks_shcarbon_config.h 23 Jun 2002 22:09:45 -0000 1.8 *************** *** 1,5 **** /* ! ** Configuration file for dynamically loaded cfm68k/ppc PythonCore, ! ** interpreter and Applet. ** ** Note: enabling the switches below is not enough to enable the --- 1,5 ---- /* ! ** Configuration file for dynamically loaded Carbon PythonCore, ! ** interpreter and extension modules. ** ** Note: enabling the switches below is not enough to enable the --- mwerks_carbon_config.h DELETED --- --- mwerks_carbonplugin_config.h DELETED --- --- mwerks_nonshared_config.h DELETED --- --- mwerks_plugin_config.h DELETED --- --- mwerks_shared_config.h DELETED --- --- mwerks_shlib_config.h DELETED --- --- mwerks_small_config.h DELETED --- From bwarsaw@users.sourceforge.net Mon Jun 24 00:52:21 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Sun, 23 Jun 2002 16:52:21 -0700 Subject: [Python-checkins] python/nondist/peps pep-0294.txt,NONE,1.1 pep-0000.txt,1.188,1.189 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv29951 Modified Files: pep-0000.txt Added Files: pep-0294.txt Log Message: Added PEP 294, Type Names in the types Module, Oren Tirosh --- NEW FILE: pep-0294.txt --- PEP: 294 Title: Type Names in the types Module Version: $Revision: 1.1 $ Last-Modified: $Date: 2002/06/23 23:52:19 $ Author: oren at hishome.net (Oren Tirosh) Status: Draft Type: Standards track Created: 19-Jun-2002 Python-Version: 2.3 Post-History: Abstract This PEP proposes that symbols matching the type name should be added to the types module for all basic Python types in the types module: types.IntegerType -> types.int types.FunctionType -> types.function types.TracebackType -> types.traceback ... The long capitalized names currently in the types module will be deprecated. With this change the types module can serve as a replacement for the new module. The new module shall be deprecated and listed in PEP 4. Rationale Using two sets of names for the same objects is redundant and confusing. In Python versions prior to 2.2 the symbols matching many type names were taken by the factory functions for those types. Now all basic types have been unified with their factory functions and therefore the type names are available to be consistently used to refer to the type object. Most types are accessible as either builtins or in the new module but some types such as traceback and generator are only accssible through the types module under names which do not match the type name. This PEP provides a uniform way to access all basic types under a single set of names. Specification The types module shall pass the following test: import types for t in vars(types).values(): if type(t) is type: assert getattr(types, t.__name__) is t The types 'class', 'instance method' and 'dict-proxy' have already been renamed to the valid Python identifiers 'classobj', 'instancemethod' and 'dictproxy', making this possible. Backward compatibility Because of their widespread use it is not planned to actually remove the long names from the types module in some future version. However, the long names should be changed in documentation and library sources to discourage their use in new code. Reference Implementation A reference implementation is available in SourceForge patch #569328: http://www.python.org/sf/569328 Copyright This document has been placed in the public domain. Local Variables: mode: indented-text indent-tabs-mode: nil sentence-end-double-space: t fill-column: 70 End: Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.188 retrieving revision 1.189 diff -C2 -d -r1.188 -r1.189 *** pep-0000.txt 19 Jun 2002 03:22:24 -0000 1.188 --- pep-0000.txt 23 Jun 2002 23:52:19 -0000 1.189 *************** *** 98,101 **** --- 98,102 ---- S 292 Simpler String Substitutions Warsaw S 293 Codec Error Handling Callbacks Dörwald + S 294 Type Names in the types Module Tirosh Finished PEPs (done, implemented in CVS) *************** *** 276,279 **** --- 277,281 ---- S 292 Simpler String Substitutions Warsaw S 293 Codec Error Handling Callbacks Dörwald + S 294 Type Names in the types Module Tirosh SR 666 Reject Foolish Indentation Creighton *************** *** 336,339 **** --- 338,342 ---- Schneider-Kamp, Peter nowonder@nowonder.de Stein, Greg gstein@lyra.org + Tirosh, Oren oren at hishome.net Warsaw, Barry barry@zope.com Wilson, Greg gvwilson@ddj.com From bwarsaw@users.sourceforge.net Mon Jun 24 00:58:22 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Sun, 23 Jun 2002 16:58:22 -0700 Subject: [Python-checkins] python/nondist/peps pep-0000.txt,1.189,1.190 pep-0282.txt,1.1,1.2 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory usw-pr-cvs1:/tmp/cvs-serv31143 Modified Files: pep-0000.txt pep-0282.txt Log Message: Transferring ownership of PEP 282 to Vinaj Sajip with permission of previous PEP author. Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.189 retrieving revision 1.190 diff -C2 -d -r1.189 -r1.190 *** pep-0000.txt 23 Jun 2002 23:52:19 -0000 1.189 --- pep-0000.txt 23 Jun 2002 23:58:18 -0000 1.190 *************** *** 90,94 **** S 280 Optimizing access to globals van Rossum S 281 Loop Counter Iteration with range and xrange Hetland ! S 282 A Logging System Mick I 283 Python 2.3 Release Schedule van Rossum S 284 Integer for-loops Eppstein, Ewing --- 90,94 ---- S 280 Optimizing access to globals van Rossum S 281 Loop Counter Iteration with range and xrange Hetland ! S 282 A Logging System Sajip I 283 Python 2.3 Release Schedule van Rossum S 284 Integer for-loops Eppstein, Ewing *************** *** 265,269 **** S 280 Optimizing access to globals van Rossum S 281 Loop Counter Iteration with range and xrange Hetland ! S 282 A Logging System Mick I 283 Python 2.3 Release Schedule van Rossum S 284 Integer for-loops Eppstein, Ewing --- 265,269 ---- S 280 Optimizing access to globals van Rossum S 281 Loop Counter Iteration with range and xrange Hetland ! S 282 A Logging System Sajip I 283 Python 2.3 Release Schedule van Rossum S 284 Integer for-loops Eppstein, Ewing *************** *** 335,338 **** --- 335,339 ---- Riehl, Jonathan jriehl@spaceship.com van Rossum, Guido guido@python.org + Sajip, Vinay vinay_sajip@red-dove.com Schemenauer, Neil nas@arctrix.com Schneider-Kamp, Peter nowonder@nowonder.de Index: pep-0282.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0282.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pep-0282.txt 15 Feb 2002 04:09:17 -0000 1.1 --- pep-0282.txt 23 Jun 2002 23:58:18 -0000 1.2 *************** *** 3,7 **** Version: $Revision$ Last-Modified: $Date$ ! Author: trentm@activestate.com (Trent Mick) Status: Draft Type: Standards Track --- 3,7 ---- Version: $Revision$ Last-Modified: $Date$ ! Author: vinay_sajip@red-dove.com (Vinay Sajip) Status: Draft Type: Standards Track From nnorwitz@users.sourceforge.net Mon Jun 24 03:22:42 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Sun, 23 Jun 2002 19:22:42 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libgettext.tex,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv25777/Doc/lib Modified Files: libgettext.tex Log Message: SF # 572928 One word change for lib/libgettext.tex Fix typo. Index: libgettext.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libgettext.tex,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** libgettext.tex 11 Jan 2002 06:58:49 -0000 1.11 --- libgettext.tex 24 Jun 2002 02:22:39 -0000 1.12 *************** *** 449,453 **** \subsubsection{Deferred translations} ! In most coding situations, strings are translated were they are coded. Occasionally however, you need to mark strings for translation, but defer actual translation until later. A classic example is: --- 449,453 ---- \subsubsection{Deferred translations} ! In most coding situations, strings are translated where they are coded. Occasionally however, you need to mark strings for translation, but defer actual translation until later. A classic example is: From nnorwitz@users.sourceforge.net Mon Jun 24 03:29:59 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Sun, 23 Jun 2002 19:29:59 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libgettext.tex,1.9,1.9.10.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv27530/Doc/lib Modified Files: Tag: release22-maint libgettext.tex Log Message: SF # 572928 One word change for lib/libgettext.tex Fix typo. Index: libgettext.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libgettext.tex,v retrieving revision 1.9 retrieving revision 1.9.10.1 diff -C2 -d -r1.9 -r1.9.10.1 *** libgettext.tex 18 Oct 2001 19:41:48 -0000 1.9 --- libgettext.tex 24 Jun 2002 02:29:57 -0000 1.9.10.1 *************** *** 427,431 **** \subsubsection{Deferred translations} ! In most coding situations, strings are translated were they are coded. Occasionally however, you need to mark strings for translation, but defer actual translation until later. A classic example is: --- 427,431 ---- \subsubsection{Deferred translations} ! In most coding situations, strings are translated where they are coded. Occasionally however, you need to mark strings for translation, but defer actual translation until later. A classic example is: From nnorwitz@users.sourceforge.net Mon Jun 24 03:30:31 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Sun, 23 Jun 2002 19:30:31 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libgettext.tex,1.7,1.7.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv27762/Doc/lib Modified Files: Tag: release21-maint libgettext.tex Log Message: SF # 572928 One word change for lib/libgettext.tex Fix typo. Index: libgettext.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libgettext.tex,v retrieving revision 1.7 retrieving revision 1.7.4.1 diff -C2 -d -r1.7 -r1.7.4.1 *** libgettext.tex 31 Jan 2001 21:21:45 -0000 1.7 --- libgettext.tex 24 Jun 2002 02:30:29 -0000 1.7.4.1 *************** *** 426,430 **** \subsubsection{Deferred translations} ! In most coding situations, strings are translated were they are coded. Occasionally however, you need to mark strings for translation, but defer actual translation until later. A classic example is: --- 426,430 ---- \subsubsection{Deferred translations} ! In most coding situations, strings are translated where they are coded. Occasionally however, you need to mark strings for translation, but defer actual translation until later. A classic example is: From rhettinger@users.sourceforge.net Mon Jun 24 14:08:18 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon, 24 Jun 2002 06:08:18 -0700 Subject: [Python-checkins] python/dist/src/Misc ACKS,1.183,1.184 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv21353/Misc Modified Files: ACKS Log Message: Fix SF bug 572567: Memory leak in object comparison. Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.183 retrieving revision 1.184 diff -C2 -d -r1.183 -r1.184 *** ACKS 18 Jun 2002 16:44:57 -0000 1.183 --- ACKS 24 Jun 2002 13:08:16 -0000 1.184 *************** *** 234,237 **** --- 234,238 ---- Paul Jackson David Jacobs + Kevin Jacobs Geert Jansen Jack Jansen From rhettinger@users.sourceforge.net Mon Jun 24 14:08:18 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon, 24 Jun 2002 06:08:18 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_descr.py,1.143,1.144 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv21353/Lib/test Modified Files: test_descr.py Log Message: Fix SF bug 572567: Memory leak in object comparison. Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.143 retrieving revision 1.144 diff -C2 -d -r1.143 -r1.144 *** test_descr.py 20 Jun 2002 22:23:15 -0000 1.143 --- test_descr.py 24 Jun 2002 13:08:16 -0000 1.144 *************** *** 1164,1167 **** --- 1164,1179 ---- vereq(Counted.counter, 0) + # Test lookup leaks [SF bug 572567] + import sys,gc + class G(object): + def __cmp__(self, other): + return 0 + g = G() + orig_objects = len(gc.get_objects()) + for i in xrange(10): + g==g + new_objects = len(gc.get_objects()) + vereq(orig_objects, new_objects) + def dynamics(): if verbose: print "Testing class attribute propagation..." From rhettinger@users.sourceforge.net Mon Jun 24 14:08:18 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon, 24 Jun 2002 06:08:18 -0700 Subject: [Python-checkins] python/dist/src/Objects typeobject.c,2.156,2.157 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv21353/Objects Modified Files: typeobject.c Log Message: Fix SF bug 572567: Memory leak in object comparison. Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.156 retrieving revision 2.157 diff -C2 -d -r2.156 -r2.157 *** typeobject.c 20 Jun 2002 22:23:14 -0000 2.156 --- typeobject.c 24 Jun 2002 13:08:14 -0000 2.157 *************** *** 3287,3290 **** --- 3287,3291 ---- Py_DECREF(args); } + Py_DECREF(func); if (res != Py_NotImplemented) { if (res == NULL) From rhettinger@users.sourceforge.net Mon Jun 24 14:25:43 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon, 24 Jun 2002 06:25:43 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_descr.py,1.113.4.18,1.113.4.19 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv26904/Lib/test Modified Files: Tag: release22-maint test_descr.py Log Message: Fix SF Bug 572567: Memory leak in object comparison Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.113.4.18 retrieving revision 1.113.4.19 diff -C2 -d -r1.113.4.18 -r1.113.4.19 *** test_descr.py 14 Jun 2002 02:37:00 -0000 1.113.4.18 --- test_descr.py 24 Jun 2002 13:25:41 -0000 1.113.4.19 *************** *** 1106,1109 **** --- 1106,1121 ---- vereq(Counted.counter, 0) + # Test lookup leaks [SF bug 572567] + import sys,gc + class G(object): + def __cmp__(self, other): + return 0 + g = G() + orig_objects = len(gc.get_objects()) + for i in xrange(10): + g==g + new_objects = len(gc.get_objects()) + vereq(orig_objects, new_objects) + def dynamics(): if verbose: print "Testing class attribute propagation..." From rhettinger@users.sourceforge.net Mon Jun 24 14:25:43 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon, 24 Jun 2002 06:25:43 -0700 Subject: [Python-checkins] python/dist/src/Objects typeobject.c,2.126.4.17,2.126.4.18 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv26904/Objects Modified Files: Tag: release22-maint typeobject.c Log Message: Fix SF Bug 572567: Memory leak in object comparison Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.126.4.17 retrieving revision 2.126.4.18 diff -C2 -d -r2.126.4.17 -r2.126.4.18 *** typeobject.c 18 Jun 2002 16:46:57 -0000 2.126.4.17 --- typeobject.c 24 Jun 2002 13:25:41 -0000 2.126.4.18 *************** *** 3178,3181 **** --- 3178,3182 ---- Py_DECREF(args); } + Py_DECREF(func); if (res != Py_NotImplemented) { if (res == NULL) From rhettinger@users.sourceforge.net Mon Jun 24 14:25:43 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon, 24 Jun 2002 06:25:43 -0700 Subject: [Python-checkins] python/dist/src/Misc ACKS,1.149.4.6,1.149.4.7 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv26904/Misc Modified Files: Tag: release22-maint ACKS Log Message: Fix SF Bug 572567: Memory leak in object comparison Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.149.4.6 retrieving revision 1.149.4.7 diff -C2 -d -r1.149.4.6 -r1.149.4.7 *** ACKS 26 Mar 2002 12:21:23 -0000 1.149.4.6 --- ACKS 24 Jun 2002 13:25:41 -0000 1.149.4.7 *************** *** 220,223 **** --- 220,224 ---- Paul Jackson David Jacobs + Kevin Jacobs Jack Jansen Bill Janssen From bwarsaw@users.sourceforge.net Mon Jun 24 21:27:35 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Mon, 24 Jun 2002 13:27:35 -0700 Subject: [Python-checkins] python/dist/src setup.py,1.95,1.96 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv2107 Modified Files: setup.py Log Message: In the Extension() call, add runtime_library_dirs so that a useful -R/--rpath flag gets passed to the linker. Source builds of BerkeleyDB do their default installs in locations not normally on ld.so's search path. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.95 retrieving revision 1.96 diff -C2 -d -r1.95 -r1.96 *** setup.py 21 Jun 2002 14:48:38 -0000 1.95 --- setup.py 24 Jun 2002 20:27:33 -0000 1.96 *************** *** 508,514 **** --- 508,523 ---- raise found except found: + # A default source build puts Berkeley DB in something like + # /usr/local/Berkeley.3.3 and the lib dir under that isn't + # normally on ld.so's search path, unless the sysadmin has hacked + # /etc/ld.so.conf. We add the directory to runtime_library_dirs + # so the proper -R/--rpath flags get passed to the linker. This + # is usually correct and most trouble free, but may cause problems + # in some unusual system configurations (e.g. the directory is on + # an NFS server that goes away). if dbinc == 'db_185.h': exts.append(Extension('bsddb', ['bsddbmodule.c'], library_dirs=[dblib_dir], + runtime_library_dirs=[dblib_dir], include_dirs=db_incs, define_macros=[('HAVE_DB_185_H',1)], *************** *** 517,520 **** --- 526,530 ---- exts.append(Extension('bsddb', ['bsddbmodule.c'], library_dirs=[dblib_dir], + runtime_library_dirs=[dblib_dir], include_dirs=db_incs, libraries=[dblib])) From pierslauder@users.sourceforge.net Tue Jun 25 00:35:40 2002 From: pierslauder@users.sourceforge.net (pierslauder@users.sourceforge.net) Date: Mon, 24 Jun 2002 16:35:40 -0700 Subject: [Python-checkins] python/dist/src/Lib imaplib.py,1.52,1.53 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv25333/dist/src/Lib Modified Files: imaplib.py Log Message: fix incorrect size calc. in IMAP4_SSL.read Index: imaplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/imaplib.py,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** imaplib.py 23 Jun 2002 10:47:13 -0000 1.52 --- imaplib.py 24 Jun 2002 23:35:37 -0000 1.53 *************** *** 1060,1064 **** data = self.sslobj.read(size) while len(data) < size: ! data += self.sslobj.read(len(data)-size) return data --- 1060,1064 ---- data = self.sslobj.read(size) while len(data) < size: ! data += self.sslobj.read(size-len(data)) return data From rhettinger@users.sourceforge.net Tue Jun 25 01:25:32 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon, 24 Jun 2002 17:25:32 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.433,1.434 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv8578/Misc Modified Files: NEWS Log Message: Fix SF bug 546434 -- buffer slice type inconsistent. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.433 retrieving revision 1.434 diff -C2 -d -r1.433 -r1.434 *** NEWS 21 Jun 2002 01:29:25 -0000 1.433 --- NEWS 25 Jun 2002 00:25:30 -0000 1.434 *************** *** 7,10 **** --- 7,15 ---- Core and builtins + - Slices and repetitions of buffer objects now consistently return + a string. Formerly, strings would be returned most of the time, + but a buffer object would be returned when the repetition count + was one or when the slice range was all inclusive. + - The __slots__ variable can now mention "private" names, and the right thing will happen (e.g. __slots__ = ["__foo"]). From rhettinger@users.sourceforge.net Tue Jun 25 01:25:32 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon, 24 Jun 2002 17:25:32 -0700 Subject: [Python-checkins] python/dist/src/Objects bufferobject.c,2.18,2.19 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv8578/Objects Modified Files: bufferobject.c Log Message: Fix SF bug 546434 -- buffer slice type inconsistent. Index: bufferobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/bufferobject.c,v retrieving revision 2.18 retrieving revision 2.19 diff -C2 -d -r2.18 -r2.19 *** bufferobject.c 14 Jun 2002 20:41:14 -0000 2.18 --- bufferobject.c 25 Jun 2002 00:25:30 -0000 2.19 *************** *** 297,307 **** return NULL; - /* optimize special case */ - if ( count == 0 ) - { - Py_INCREF(self); - return (PyObject *)self; - } - ob = PyString_FromStringAndSize(NULL, self->b_size + count); p1 = PyString_AS_STRING(ob); --- 297,300 ---- *************** *** 362,371 **** if ( right > self->b_size ) right = self->b_size; - if ( left == 0 && right == self->b_size ) - { - /* same as self */ - Py_INCREF(self); - return (PyObject *)self; - } if ( right < left ) right = left; --- 355,358 ---- From rhettinger@users.sourceforge.net Tue Jun 25 04:17:06 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon, 24 Jun 2002 20:17:06 -0700 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.163,1.164 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory usw-pr-cvs1:/tmp/cvs-serv5584 Modified Files: tut.tex Log Message: Fix spacing in loop example Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.163 retrieving revision 1.164 diff -C2 -d -r1.163 -r1.164 *** tut.tex 11 Jun 2002 02:56:17 -0000 1.163 --- tut.tex 25 Jun 2002 03:17:03 -0000 1.164 *************** *** 2061,2067 **** ... print 'What is your %s? It is %s.' % (q, a) ... ! What is your name ? It is lancelot . ! What is your quest ? It is the holy grail . ! What is your favorite color ? It is blue . \end{verbatim} --- 2061,2067 ---- ... print 'What is your %s? It is %s.' % (q, a) ... ! What is your name? It is lancelot. ! What is your quest? It is the holy grail. ! What is your favorite color? It is blue. \end{verbatim} From rhettinger@users.sourceforge.net Tue Jun 25 05:00:26 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon, 24 Jun 2002 21:00:26 -0700 Subject: [Python-checkins] python/dist/src/Doc/ref ref5.tex,1.53.4.5,1.53.4.6 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv13367 Modified Files: Tag: release22-maint ref5.tex Log Message: Backport change to 1.58 giving Lambda a separate section. Index: ref5.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref5.tex,v retrieving revision 1.53.4.5 retrieving revision 1.53.4.6 diff -C2 -d -r1.53.4.5 -r1.53.4.6 *** ref5.tex 30 Apr 2002 02:21:32 -0000 1.53.4.5 --- ref5.tex 25 Jun 2002 04:00:24 -0000 1.53.4.6 *************** *** 974,982 **** not \code{''}.) Lambda forms (lambda expressions) have the same syntactic position as expressions. They are a shorthand to create anonymous functions; the expression \code{lambda \var{arguments}: \var{expression}} ! yields a function object that behaves virtually identical to one ! defined with \begin{verbatim} --- 974,987 ---- not \code{''}.) + \section{Lambdas\label{lambdas}} + \indexii{lambda}{expression} + \indexii{lambda}{form} + \indexii{anonmymous}{function} + Lambda forms (lambda expressions) have the same syntactic position as expressions. They are a shorthand to create anonymous functions; the expression \code{lambda \var{arguments}: \var{expression}} ! yields a function object. The unnamed object behaves like a function ! object defined with \begin{verbatim} *************** *** 988,1019 **** that functions created with lambda forms cannot contain statements. \label{lambda} - \indexii{lambda}{expression} - \indexii{lambda}{form} - \indexii{anonmymous}{function} - - \strong{Programmer's note:} Prior to Python 2.1, a lambda form defined - inside a function has no access to names defined in the function's - namespace. This is because Python had only two scopes: local and - global. A common work-around was to use default argument values to - pass selected variables into the lambda's namespace, e.g.: - - \begin{verbatim} - def make_incrementor(increment): - return lambda x, n=increment: x+n - \end{verbatim} - - As of Python 2.1, nested scopes were introduced, and this work-around - has not been necessary. Python 2.1 supports nested scopes in modules - which include the statement \samp{from __future__ import - nested_scopes}, and more recent versions of Python enable nested - scopes by default. This version works starting with Python 2.1: - - \begin{verbatim} - from __future__ import nested_scopes - - def make_incrementor(increment): - return lambda x: x+increment - \end{verbatim} - \section{Expression lists\label{exprlists}} --- 993,996 ---- From rhettinger@users.sourceforge.net Tue Jun 25 05:04:16 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon, 24 Jun 2002 21:04:16 -0700 Subject: [Python-checkins] python/dist/src/Doc/ref ref5.tex,1.63,1.64 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv14116 Modified Files: ref5.tex Log Message: Minor English grammar correction Index: ref5.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref5.tex,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** ref5.tex 20 Jun 2002 14:23:15 -0000 1.63 --- ref5.tex 25 Jun 2002 04:04:14 -0000 1.64 *************** *** 972,976 **** expression \code{lambda \var{arguments}: \var{expression}} yields a function object. The unnamed object behaves like a function ! object define with \begin{verbatim} --- 972,976 ---- expression \code{lambda \var{arguments}: \var{expression}} yields a function object. The unnamed object behaves like a function ! object defined with \begin{verbatim} From rhettinger@users.sourceforge.net Tue Jun 25 05:55:38 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon, 24 Jun 2002 21:55:38 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libwinreg.tex,1.7,1.7.18.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv22891 Modified Files: Tag: release22-maint libwinreg.tex Log Message: Fix SF bug 568269 by enclosing 'computername' in a raw string Index: libwinreg.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libwinreg.tex,v retrieving revision 1.7 retrieving revision 1.7.18.1 diff -C2 -d -r1.7 -r1.7.18.1 *** libwinreg.tex 6 Jul 2001 20:30:11 -0000 1.7 --- libwinreg.tex 25 Jun 2002 04:55:36 -0000 1.7.18.1 *************** *** 37,41 **** \var{computer_name} is the name of the remote computer, of the ! form \samp{\e\e computername}. If \code{None}, the local computer is used. --- 37,41 ---- \var{computer_name} is the name of the remote computer, of the ! form \code{"r\e\e computername"}. If \code{None}, the local computer is used. From rhettinger@users.sourceforge.net Tue Jun 25 05:53:07 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon, 24 Jun 2002 21:53:07 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libwinreg.tex,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv22577 Modified Files: libwinreg.tex Log Message: Fix SF bug 568269 by enclosing 'computername' in a raw string Index: libwinreg.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libwinreg.tex,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** libwinreg.tex 6 Jul 2001 20:30:11 -0000 1.7 --- libwinreg.tex 25 Jun 2002 04:53:05 -0000 1.8 *************** *** 37,41 **** \var{computer_name} is the name of the remote computer, of the ! form \samp{\e\e computername}. If \code{None}, the local computer is used. --- 37,41 ---- \var{computer_name} is the name of the remote computer, of the ! form \code{"r\e\e computername"}. If \code{None}, the local computer is used. From montanaro@users.sourceforge.net Tue Jun 25 06:53:50 2002 From: montanaro@users.sourceforge.net (montanaro@users.sourceforge.net) Date: Mon, 24 Jun 2002 22:53:50 -0700 Subject: [Python-checkins] python/dist/src configure,1.316,1.317 configure.in,1.326,1.327 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv832 Modified Files: configure configure.in Log Message: Not sure how I forgot to check these in - thought I did all the files in one fell swoop. Anyway, this just deletes a couple checks for dbm-type header files that are now performed in setup.py. See patch 553108 for details. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.316 retrieving revision 1.317 diff -C2 -d -r1.316 -r1.317 *** configure 21 Jun 2002 14:48:36 -0000 1.316 --- configure 25 Jun 2002 05:53:47 -0000 1.317 *************** *** 3864,3869 **** - - for ac_header in dlfcn.h fcntl.h grp.h limits.h langinfo.h \ libintl.h locale.h ncurses.h poll.h pthread.h \ --- 3864,3867 ---- *************** *** 3872,3876 **** sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \ sys/un.h sys/utsname.h sys/wait.h pty.h term.h libutil.h \ ! ndbm.h gdbm/ndbm.h sys/resource.h netpacket/packet.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` --- 3870,3874 ---- sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \ sys/un.h sys/utsname.h sys/wait.h pty.h term.h libutil.h \ ! sys/resource.h netpacket/packet.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` *************** *** 11370,11373 **** --- 11368,11372 ---- # checks for library functions + Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.326 retrieving revision 1.327 diff -C2 -d -r1.326 -r1.327 *** configure.in 21 Jun 2002 14:48:36 -0000 1.326 --- configure.in 25 Jun 2002 05:53:48 -0000 1.327 *************** *** 600,604 **** sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \ sys/un.h sys/utsname.h sys/wait.h pty.h term.h libutil.h \ ! ndbm.h gdbm/ndbm.h sys/resource.h netpacket/packet.h) AC_HEADER_DIRENT --- 600,604 ---- sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \ sys/un.h sys/utsname.h sys/wait.h pty.h term.h libutil.h \ ! sys/resource.h netpacket/packet.h) AC_HEADER_DIRENT From rhettinger@users.sourceforge.net Tue Jun 25 14:36:44 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue, 25 Jun 2002 06:36:44 -0700 Subject: [Python-checkins] python/dist/src/Doc/ref ref6.tex,1.54,1.55 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv28774 Modified Files: ref6.tex Log Message: Close bug 417930 by clarifying augmented assignment docs Index: ref6.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref6.tex,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** ref6.tex 20 Jun 2002 20:55:29 -0000 1.54 --- ref6.tex 25 Jun 2002 13:36:41 -0000 1.55 *************** *** 301,304 **** --- 301,318 ---- augmented assignment is the same as the normal binary operations. + For targets which are attribute references, the initial value is + retrieved with a \method{getattr()} and the result is assigned with a + \method{setattr()}. Notice that the two methods do not necessarily + refer to the same variable. When \method{getattr()} refers to a class + variable, \method{setattr()} still writes to an instance variable. + For example: + + \begin{verbatim} + class A: + x = 3 # class variable + a = A() + a.x += 1 # writes a.x as 4 leaving A.x as 3 + \end{verbatim} + \section{The \keyword{pass} statement \label{pass}} From rhettinger@users.sourceforge.net Tue Jun 25 14:39:51 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue, 25 Jun 2002 06:39:51 -0700 Subject: [Python-checkins] python/dist/src/Doc/ref ref6.tex,1.47.4.1,1.47.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv29777 Modified Files: Tag: release22-maint ref6.tex Log Message: Close bug 417930 by clarifying augmented assignment docs Index: ref6.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref6.tex,v retrieving revision 1.47.4.1 retrieving revision 1.47.4.2 diff -C2 -d -r1.47.4.1 -r1.47.4.2 *** ref6.tex 15 Mar 2002 23:18:05 -0000 1.47.4.1 --- ref6.tex 25 Jun 2002 13:39:49 -0000 1.47.4.2 *************** *** 301,304 **** --- 301,318 ---- augmented assignment is the same as the normal binary operations. + For targets which are attribute references, the initial value is + retrieved with a \method{getattr()} and the result is assigned with a + \method{setattr()}. Notice that the two methods do not necessarily + refer to the same variable. When \method{getattr()} refers to a class + variable, \method{setattr()} still writes to an instance variable. + For example: + + \begin{verbatim} + class A: + x = 3 # class variable + a = A() + a.x += 1 # writes a.x as 4 leaving A.x as 3 + \end{verbatim} + \section{The \keyword{pass} statement \label{pass}} From rhettinger@users.sourceforge.net Tue Jun 25 16:02:36 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue, 25 Jun 2002 08:02:36 -0700 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.156.4.1.2.3,1.156.4.1.2.4 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory usw-pr-cvs1:/tmp/cvs-serv28601 Modified Files: Tag: release22-maint tut.tex Log Message: Close bug 480337: Dict used before dicts explained. Added explanation and examples of the dict() constructor. Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.156.4.1.2.3 retrieving revision 1.156.4.1.2.4 diff -C2 -d -r1.156.4.1.2.3 -r1.156.4.1.2.4 *** tut.tex 11 Jun 2002 02:57:32 -0000 1.156.4.1.2.3 --- tut.tex 25 Jun 2002 15:02:31 -0000 1.156.4.1.2.4 *************** *** 2024,2027 **** --- 2024,2039 ---- \end{verbatim} + The \function{dict()} contructor builds dictionaries directly from + lists of key-value pairs stored as tuples. When the pairs form a + pattern, list comprehensions can compactly specify the key-value list. + + \begin{verbatim} + >>> dict([('sape', 4139), ('guido', 4127), ('jack', 4098)]) + {'sape': 4139, 'jack': 4098, 'guido': 4127} + >>> dict([(x, x**2) for x in vec]) # use a list comprehension + {2: 4, 4: 16, 6: 36} + \end{verbatim} + + \section{More on Conditions \label{conditions}} From rhettinger@users.sourceforge.net Tue Jun 25 16:13:20 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue, 25 Jun 2002 08:13:20 -0700 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.164,1.165 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory usw-pr-cvs1:/tmp/cvs-serv32056 Modified Files: tut.tex Log Message: Close bug 480337: Dict used before dicts explained. Added explanation and examples of the dict() constructor. Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.164 retrieving revision 1.165 diff -C2 -d -r1.164 -r1.165 *** tut.tex 25 Jun 2002 03:17:03 -0000 1.164 --- tut.tex 25 Jun 2002 15:13:18 -0000 1.165 *************** *** 1844,1849 **** >>> [3*x for x in vec if x < 2] [] - >>> [{x: x**2} for x in vec] - [{2: 4}, {4: 16}, {6: 36}] >>> [[x,x**2] for x in vec] [[2, 4], [4, 16], [6, 36]] --- 1844,1847 ---- *************** *** 2022,2025 **** --- 2020,2034 ---- >>> tel.has_key('guido') 1 + \end{verbatim} + + The \function{dict()} contructor builds dictionaries directly from + lists of key-value pairs stored as tuples. When the pairs form a + pattern, list comprehensions can compactly specify the key-value list. + + \begin{verbatim} + >>> dict([('sape', 4139), ('guido', 4127), ('jack', 4098)]) + {'sape': 4139, 'jack': 4098, 'guido': 4127} + >>> dict([(x, x**2) for x in vec]) # use a list comprehension + {2: 4, 4: 16, 6: 36} \end{verbatim} From rhettinger@users.sourceforge.net Tue Jun 25 16:21:04 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue, 25 Jun 2002 08:21:04 -0700 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.156.4.1.2.4,1.156.4.1.2.5 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory usw-pr-cvs1:/tmp/cvs-serv3656 Modified Files: Tag: release22-maint tut.tex Log Message: Completed previous edit Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.156.4.1.2.4 retrieving revision 1.156.4.1.2.5 diff -C2 -d -r1.156.4.1.2.4 -r1.156.4.1.2.5 *** tut.tex 25 Jun 2002 15:02:31 -0000 1.156.4.1.2.4 --- tut.tex 25 Jun 2002 15:21:02 -0000 1.156.4.1.2.5 *************** *** 1844,1849 **** >>> [3*x for x in vec if x < 2] [] - >>> [{x: x**2} for x in vec] - [{2: 4}, {4: 16}, {6: 36}] >>> [[x,x**2] for x in vec] [[2, 4], [4, 16], [6, 36]] --- 1844,1847 ---- From rhettinger@users.sourceforge.net Tue Jun 25 16:25:56 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue, 25 Jun 2002 08:25:56 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libwinreg.tex,1.7.18.1,1.7.18.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv6303 Modified Files: Tag: release22-maint libwinreg.tex Log Message: Fix typo Index: libwinreg.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libwinreg.tex,v retrieving revision 1.7.18.1 retrieving revision 1.7.18.2 diff -C2 -d -r1.7.18.1 -r1.7.18.2 *** libwinreg.tex 25 Jun 2002 04:55:36 -0000 1.7.18.1 --- libwinreg.tex 25 Jun 2002 15:25:53 -0000 1.7.18.2 *************** *** 37,41 **** \var{computer_name} is the name of the remote computer, of the ! form \code{"r\e\e computername"}. If \code{None}, the local computer is used. --- 37,41 ---- \var{computer_name} is the name of the remote computer, of the ! form \code{r"\e\e computername"}. If \code{None}, the local computer is used. From rhettinger@users.sourceforge.net Tue Jun 25 16:27:01 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue, 25 Jun 2002 08:27:01 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libwinreg.tex,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv6850 Modified Files: libwinreg.tex Log Message: Fix typo Index: libwinreg.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libwinreg.tex,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** libwinreg.tex 25 Jun 2002 04:53:05 -0000 1.8 --- libwinreg.tex 25 Jun 2002 15:26:59 -0000 1.9 *************** *** 37,41 **** \var{computer_name} is the name of the remote computer, of the ! form \code{"r\e\e computername"}. If \code{None}, the local computer is used. --- 37,41 ---- \var{computer_name} is the name of the remote computer, of the ! form \code{r"\e\e computername"}. If \code{None}, the local computer is used. From fdrake@users.sourceforge.net Tue Jun 25 17:25:04 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 25 Jun 2002 09:25:04 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib xmlsax.tex,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv25764 Modified Files: xmlsax.tex Log Message: When talking about interfaces, use the interface names, not the names of the implementation classes. (Remove the "Impl" from two names.) Index: xmlsax.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/xmlsax.tex,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** xmlsax.tex 10 Dec 2001 18:10:37 -0000 1.4 --- xmlsax.tex 25 Jun 2002 16:25:01 -0000 1.5 *************** *** 60,64 **** classes, but applications may use implementations which do not inherit from the provided classes. The \class{InputSource}, \class{Locator}, ! \class{AttributesImpl}, \class{AttributesNSImpl}, and \class{XMLReader} interfaces are defined in the module \refmodule{xml.sax.xmlreader}. The handler interfaces are defined in --- 60,64 ---- classes, but applications may use implementations which do not inherit from the provided classes. The \class{InputSource}, \class{Locator}, ! \class{Attributes}, \class{AttributesNS}, and \class{XMLReader} interfaces are defined in the module \refmodule{xml.sax.xmlreader}. The handler interfaces are defined in From fdrake@users.sourceforge.net Tue Jun 25 17:59:01 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 25 Jun 2002 09:59:01 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib xmlsax.tex,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv5670 Modified Files: xmlsax.tex Log Message: Added some more links to the "See also" section. Index: xmlsax.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/xmlsax.tex,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** xmlsax.tex 25 Jun 2002 16:25:01 -0000 1.5 --- xmlsax.tex 25 Jun 2002 16:58:58 -0000 1.6 *************** *** 118,121 **** --- 118,130 ---- documentation. Links to implementations and historical information are also available.} + + \seemodule{xml.sax.handler}{Definitions of the interfaces for + application-provided objects.} + + \seemodule{xml.sax.saxutils}{Convenience functions for use in SAX + applications.} + + \seemodule{xml.sax.xmlreader}{Definitions of the interfaces for + parser-provided objects.} \end{seealso} From fdrake@users.sourceforge.net Tue Jun 25 18:10:53 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 25 Jun 2002 10:10:53 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib xmlsaxhandler.tex,1.8,1.9 xmlsaxreader.tex,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv9299/lib Modified Files: xmlsaxhandler.tex xmlsaxreader.tex Log Message: Talk about interfaces rather than implementation classes where appropriate. Add hyperlinks to make the documentation on the Attributes and AttributesNS interfaces more discoverable. Closes SF bug #484603. Index: xmlsaxhandler.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/xmlsaxhandler.tex,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** xmlsaxhandler.tex 19 Nov 2001 04:34:50 -0000 1.8 --- xmlsaxhandler.tex 25 Jun 2002 17:10:49 -0000 1.9 *************** *** 194,216 **** There are cases, however, when applications need to use prefixes in character data or in attribute values, where they cannot safely be ! expanded automatically; the start/endPrefixMapping event supplies ! the information to the application to expand prefixes in those ! contexts itself, if necessary. ! Note that start/endPrefixMapping events are not guaranteed to be ! properly nested relative to each-other: all ! \method{startPrefixMapping()} events will occur before the ! corresponding \method{startElement()} event, and all ! \method{endPrefixMapping()} events will occur after the ! corresponding \method{endElement()} event, but their order is not ! guaranteed. \end{methoddesc} \begin{methoddesc}[ContentHandler]{endPrefixMapping}{prefix} End the scope of a prefix-URI mapping. ! ! See \method{startPrefixMapping()} for details. This event will always ! occur after the corresponding endElement event, but the order of ! endPrefixMapping events is not otherwise guaranteed. \end{methoddesc} --- 194,218 ---- There are cases, however, when applications need to use prefixes in character data or in attribute values, where they cannot safely be ! expanded automatically; the \method{startPrefixMapping()} and ! \method{endPrefixMapping()} events supply the information to the ! application to expand prefixes in those contexts itself, if ! necessary. ! Note that \method{startPrefixMapping()} and ! \method{endPrefixMapping()} events are not guaranteed to be properly ! nested relative to each-other: all \method{startPrefixMapping()} ! events will occur before the corresponding \method{startElement()} ! event, and all \method{endPrefixMapping()} events will occur after ! the corresponding \method{endElement()} event, but their order is ! not guaranteed. \end{methoddesc} \begin{methoddesc}[ContentHandler]{endPrefixMapping}{prefix} End the scope of a prefix-URI mapping. ! ! See \method{startPrefixMapping()} for details. This event will ! always occur after the corresponding \method{endElement()} event, ! but the order of \method{endPrefixMapping()} events is not otherwise ! guaranteed. \end{methoddesc} *************** *** 220,226 **** The \var{name} parameter contains the raw XML 1.0 name of the element type as a string and the \var{attrs} parameter holds an ! instance of the \class{Attributes} class containing the attributes ! of the element. The object passed as \var{attrs} may be re-used by ! the parser; holding on to a reference to it is not a reliable way to keep a copy of the attributes. To keep a copy of the attributes, use the \method{copy()} method of the \var{attrs} object. --- 222,229 ---- The \var{name} parameter contains the raw XML 1.0 name of the element type as a string and the \var{attrs} parameter holds an ! object of the \ulink{\class{Attributes} ! interface}{attributes-objects.html} containing the attributes of the ! element. The object passed as \var{attrs} may be re-used by the ! parser; holding on to a reference to it is not a reliable way to keep a copy of the attributes. To keep a copy of the attributes, use the \method{copy()} method of the \var{attrs} object. *************** *** 231,235 **** The \var{name} parameter contains the name of the element type, just ! as with the startElement event. \end{methoddesc} --- 234,238 ---- The \var{name} parameter contains the name of the element type, just ! as with the \method{startElement()} event. \end{methoddesc} *************** *** 240,245 **** \code{(\var{uri}, \var{localname})} tuple, the \var{qname} parameter contains the raw XML 1.0 name used in the source document, and the ! \var{attrs} parameter holds an instance of the \class{AttributesNS} ! class containing the attributes of the element. If no namespace is associated with the element, the \var{uri} component of \var{name} will be \code{None}. The object passed as \var{attrs} may be --- 243,249 ---- \code{(\var{uri}, \var{localname})} tuple, the \var{qname} parameter contains the raw XML 1.0 name used in the source document, and the ! \var{attrs} parameter holds an instance of the ! \ulink{\class{AttributesNS} interface}{attributes-ns-objects.html} ! containing the attributes of the element. If no namespace is associated with the element, the \var{uri} component of \var{name} will be \code{None}. The object passed as \var{attrs} may be Index: xmlsaxreader.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/xmlsaxreader.tex,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** xmlsaxreader.tex 6 Nov 2001 22:11:34 -0000 1.3 --- xmlsaxreader.tex 25 Jun 2002 17:10:50 -0000 1.4 *************** *** 70,87 **** \begin{classdesc}{AttributesImpl}{attrs} ! This is a dictionary-like object which represents the element ! attributes in a \method{startElement()} call. In addition to the ! most useful dictionary operations, it supports a number of other ! methods as described below. Objects of this class should be instantiated by readers; \var{attrs} must be a dictionary-like ! object. \end{classdesc} \begin{classdesc}{AttributesNSImpl}{attrs, qnames} ! Namespace-aware variant of attributes, which will be passed to ! \method{startElementNS()}. It is derived from \class{AttributesImpl}, ! but understands attribute names as two-tuples of \var{namespaceURI} ! and \var{localname}. In addition, it provides a number of methods ! expecting qualified names as they appear in the original document. \end{classdesc} --- 70,94 ---- \begin{classdesc}{AttributesImpl}{attrs} ! This is an implementation of the \ulink{\class{Attributes} ! interface}{attributes-objects.html} (see ! section~\ref{attributes-objects}). This is a dictionary-like ! object which represents the element attributes in a ! \method{startElement()} call. In addition to the most useful ! dictionary operations, it supports a number of other methods as ! described by the interface. Objects of this class should be instantiated by readers; \var{attrs} must be a dictionary-like ! object containing a mapping from attribute names to attribute ! values. \end{classdesc} \begin{classdesc}{AttributesNSImpl}{attrs, qnames} ! Namespace-aware variant of \class{AttributesImpl}, which will be ! passed to \method{startElementNS()}. It is derived from ! \class{AttributesImpl}, but understands attribute names as ! two-tuples of \var{namespaceURI} and \var{localname}. In addition, ! it provides a number of methods expecting qualified names as they ! appear in the original document. This class implements the ! \ulink{\class{AttributesNS} interface}{attributes-ns-objects.html} ! (see section~\ref{attributes-ns-objects}). \end{classdesc} *************** *** 289,313 **** ! \subsection{AttributesImpl Objects \label{attributes-impl-objects}} ! \class{AttributesImpl} objects implement a portion of the mapping ! protocol, and the methods \method{copy()}, \method{get()}, \method{has_key()}, \method{items()}, \method{keys()}, and \method{values()}. The following methods are also provided: ! \begin{methoddesc}[AttributesImpl]{getLength}{} Return the number of attributes. \end{methoddesc} ! \begin{methoddesc}[AttributesImpl]{getNames}{} Return the names of the attributes. \end{methoddesc} ! \begin{methoddesc}[AttributesImpl]{getType}{name} Returns the type of the attribute \var{name}, which is normally \code{'CDATA'}. \end{methoddesc} ! \begin{methoddesc}[AttributesImpl]{getValue}{name} Return the value of attribute \var{name}. \end{methoddesc} --- 296,320 ---- ! \subsection{The \class{Attributes} Interface \label{attributes-objects}} ! \class{Attributes} objects implement a portion of the mapping ! protocol, including the methods \method{copy()}, \method{get()}, \method{has_key()}, \method{items()}, \method{keys()}, and \method{values()}. The following methods are also provided: ! \begin{methoddesc}[Attributes]{getLength}{} Return the number of attributes. \end{methoddesc} ! \begin{methoddesc}[Attributes]{getNames}{} Return the names of the attributes. \end{methoddesc} ! \begin{methoddesc}[Attributes]{getType}{name} Returns the type of the attribute \var{name}, which is normally \code{'CDATA'}. \end{methoddesc} ! \begin{methoddesc}[Attributes]{getValue}{name} Return the value of attribute \var{name}. \end{methoddesc} *************** *** 317,337 **** ! \subsection{AttributesNSImpl Objects \label{attributes-ns-impl-objects}} ! \begin{methoddesc}[AttributesNSImpl]{getValueByQName}{name} Return the value for a qualified name. \end{methoddesc} ! \begin{methoddesc}[AttributesNSImpl]{getNameByQName}{name} Return the \code{(\var{namespace}, \var{localname})} pair for a qualified \var{name}. \end{methoddesc} ! \begin{methoddesc}[AttributesNSImpl]{getQNameByName}{name} Return the qualified name for a \code{(\var{namespace}, \var{localname})} pair. \end{methoddesc} ! \begin{methoddesc}[AttributesNSImpl]{getQNames}{} Return the qualified names of all attributes. \end{methoddesc} --- 324,351 ---- ! \subsection{The \class{AttributesNS} Interface \label{attributes-ns-objects}} ! This interface is a subtype of the \ulink{\class{Attributes} ! interface}{attributes-objects.html} (see ! section~\ref{attributes-objects}). All methods supported by that ! interface are also available on \class{AttributesNS} objects. ! ! The following methods are also available: ! ! \begin{methoddesc}[AttributesNS]{getValueByQName}{name} Return the value for a qualified name. \end{methoddesc} ! \begin{methoddesc}[AttributesNS]{getNameByQName}{name} Return the \code{(\var{namespace}, \var{localname})} pair for a qualified \var{name}. \end{methoddesc} ! \begin{methoddesc}[AttributesNS]{getQNameByName}{name} Return the qualified name for a \code{(\var{namespace}, \var{localname})} pair. \end{methoddesc} ! \begin{methoddesc}[AttributesNS]{getQNames}{} Return the qualified names of all attributes. \end{methoddesc} From fdrake@users.sourceforge.net Tue Jun 25 18:18:50 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 25 Jun 2002 10:18:50 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib xmlsax.tex,1.4,1.4.6.1 xmlsaxhandler.tex,1.8,1.8.6.1 xmlsaxreader.tex,1.3,1.3.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv12658/lib Modified Files: Tag: release22-maint xmlsax.tex xmlsaxhandler.tex xmlsaxreader.tex Log Message: [Backport of recent changes to the SAX documentation.] Add more links to the "See also" section for the xml.sax package. Talk about interfaces rather than implementation classes where appropriate. Add hyperlinks to make the documentation on the Attributes and AttributesNS interfaces more discoverable. Closes SF bug #484603. Index: xmlsax.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/xmlsax.tex,v retrieving revision 1.4 retrieving revision 1.4.6.1 diff -C2 -d -r1.4 -r1.4.6.1 *** xmlsax.tex 10 Dec 2001 18:10:37 -0000 1.4 --- xmlsax.tex 25 Jun 2002 17:18:47 -0000 1.4.6.1 *************** *** 60,64 **** classes, but applications may use implementations which do not inherit from the provided classes. The \class{InputSource}, \class{Locator}, ! \class{AttributesImpl}, \class{AttributesNSImpl}, and \class{XMLReader} interfaces are defined in the module \refmodule{xml.sax.xmlreader}. The handler interfaces are defined in --- 60,64 ---- classes, but applications may use implementations which do not inherit from the provided classes. The \class{InputSource}, \class{Locator}, ! \class{Attributes}, \class{AttributesNS}, and \class{XMLReader} interfaces are defined in the module \refmodule{xml.sax.xmlreader}. The handler interfaces are defined in *************** *** 118,121 **** --- 118,130 ---- documentation. Links to implementations and historical information are also available.} + + \seemodule{xml.sax.handler}{Definitions of the interfaces for + application-provided objects.} + + \seemodule{xml.sax.saxutils}{Convenience functions for use in SAX + applications.} + + \seemodule{xml.sax.xmlreader}{Definitions of the interfaces for + parser-provided objects.} \end{seealso} Index: xmlsaxhandler.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/xmlsaxhandler.tex,v retrieving revision 1.8 retrieving revision 1.8.6.1 diff -C2 -d -r1.8 -r1.8.6.1 *** xmlsaxhandler.tex 19 Nov 2001 04:34:50 -0000 1.8 --- xmlsaxhandler.tex 25 Jun 2002 17:18:48 -0000 1.8.6.1 *************** *** 194,216 **** There are cases, however, when applications need to use prefixes in character data or in attribute values, where they cannot safely be ! expanded automatically; the start/endPrefixMapping event supplies ! the information to the application to expand prefixes in those ! contexts itself, if necessary. ! Note that start/endPrefixMapping events are not guaranteed to be ! properly nested relative to each-other: all ! \method{startPrefixMapping()} events will occur before the ! corresponding \method{startElement()} event, and all ! \method{endPrefixMapping()} events will occur after the ! corresponding \method{endElement()} event, but their order is not ! guaranteed. \end{methoddesc} \begin{methoddesc}[ContentHandler]{endPrefixMapping}{prefix} End the scope of a prefix-URI mapping. ! ! See \method{startPrefixMapping()} for details. This event will always ! occur after the corresponding endElement event, but the order of ! endPrefixMapping events is not otherwise guaranteed. \end{methoddesc} --- 194,218 ---- There are cases, however, when applications need to use prefixes in character data or in attribute values, where they cannot safely be ! expanded automatically; the \method{startPrefixMapping()} and ! \method{endPrefixMapping()} events supply the information to the ! application to expand prefixes in those contexts itself, if ! necessary. ! Note that \method{startPrefixMapping()} and ! \method{endPrefixMapping()} events are not guaranteed to be properly ! nested relative to each-other: all \method{startPrefixMapping()} ! events will occur before the corresponding \method{startElement()} ! event, and all \method{endPrefixMapping()} events will occur after ! the corresponding \method{endElement()} event, but their order is ! not guaranteed. \end{methoddesc} \begin{methoddesc}[ContentHandler]{endPrefixMapping}{prefix} End the scope of a prefix-URI mapping. ! ! See \method{startPrefixMapping()} for details. This event will ! always occur after the corresponding \method{endElement()} event, ! but the order of \method{endPrefixMapping()} events is not otherwise ! guaranteed. \end{methoddesc} *************** *** 220,226 **** The \var{name} parameter contains the raw XML 1.0 name of the element type as a string and the \var{attrs} parameter holds an ! instance of the \class{Attributes} class containing the attributes ! of the element. The object passed as \var{attrs} may be re-used by ! the parser; holding on to a reference to it is not a reliable way to keep a copy of the attributes. To keep a copy of the attributes, use the \method{copy()} method of the \var{attrs} object. --- 222,229 ---- The \var{name} parameter contains the raw XML 1.0 name of the element type as a string and the \var{attrs} parameter holds an ! object of the \ulink{\class{Attributes} ! interface}{attributes-objects.html} containing the attributes of the ! element. The object passed as \var{attrs} may be re-used by the ! parser; holding on to a reference to it is not a reliable way to keep a copy of the attributes. To keep a copy of the attributes, use the \method{copy()} method of the \var{attrs} object. *************** *** 231,235 **** The \var{name} parameter contains the name of the element type, just ! as with the startElement event. \end{methoddesc} --- 234,238 ---- The \var{name} parameter contains the name of the element type, just ! as with the \method{startElement()} event. \end{methoddesc} *************** *** 240,245 **** \code{(\var{uri}, \var{localname})} tuple, the \var{qname} parameter contains the raw XML 1.0 name used in the source document, and the ! \var{attrs} parameter holds an instance of the \class{AttributesNS} ! class containing the attributes of the element. If no namespace is associated with the element, the \var{uri} component of \var{name} will be \code{None}. The object passed as \var{attrs} may be --- 243,249 ---- \code{(\var{uri}, \var{localname})} tuple, the \var{qname} parameter contains the raw XML 1.0 name used in the source document, and the ! \var{attrs} parameter holds an instance of the ! \ulink{\class{AttributesNS} interface}{attributes-ns-objects.html} ! containing the attributes of the element. If no namespace is associated with the element, the \var{uri} component of \var{name} will be \code{None}. The object passed as \var{attrs} may be Index: xmlsaxreader.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/xmlsaxreader.tex,v retrieving revision 1.3 retrieving revision 1.3.8.1 diff -C2 -d -r1.3 -r1.3.8.1 *** xmlsaxreader.tex 6 Nov 2001 22:11:34 -0000 1.3 --- xmlsaxreader.tex 25 Jun 2002 17:18:48 -0000 1.3.8.1 *************** *** 70,87 **** \begin{classdesc}{AttributesImpl}{attrs} ! This is a dictionary-like object which represents the element ! attributes in a \method{startElement()} call. In addition to the ! most useful dictionary operations, it supports a number of other ! methods as described below. Objects of this class should be instantiated by readers; \var{attrs} must be a dictionary-like ! object. \end{classdesc} \begin{classdesc}{AttributesNSImpl}{attrs, qnames} ! Namespace-aware variant of attributes, which will be passed to ! \method{startElementNS()}. It is derived from \class{AttributesImpl}, ! but understands attribute names as two-tuples of \var{namespaceURI} ! and \var{localname}. In addition, it provides a number of methods ! expecting qualified names as they appear in the original document. \end{classdesc} --- 70,94 ---- \begin{classdesc}{AttributesImpl}{attrs} ! This is an implementation of the \ulink{\class{Attributes} ! interface}{attributes-objects.html} (see ! section~\ref{attributes-objects}). This is a dictionary-like ! object which represents the element attributes in a ! \method{startElement()} call. In addition to the most useful ! dictionary operations, it supports a number of other methods as ! described by the interface. Objects of this class should be instantiated by readers; \var{attrs} must be a dictionary-like ! object containing a mapping from attribute names to attribute ! values. \end{classdesc} \begin{classdesc}{AttributesNSImpl}{attrs, qnames} ! Namespace-aware variant of \class{AttributesImpl}, which will be ! passed to \method{startElementNS()}. It is derived from ! \class{AttributesImpl}, but understands attribute names as ! two-tuples of \var{namespaceURI} and \var{localname}. In addition, ! it provides a number of methods expecting qualified names as they ! appear in the original document. This class implements the ! \ulink{\class{AttributesNS} interface}{attributes-ns-objects.html} ! (see section~\ref{attributes-ns-objects}). \end{classdesc} *************** *** 289,313 **** ! \subsection{AttributesImpl Objects \label{attributes-impl-objects}} ! \class{AttributesImpl} objects implement a portion of the mapping ! protocol, and the methods \method{copy()}, \method{get()}, \method{has_key()}, \method{items()}, \method{keys()}, and \method{values()}. The following methods are also provided: ! \begin{methoddesc}[AttributesImpl]{getLength}{} Return the number of attributes. \end{methoddesc} ! \begin{methoddesc}[AttributesImpl]{getNames}{} Return the names of the attributes. \end{methoddesc} ! \begin{methoddesc}[AttributesImpl]{getType}{name} Returns the type of the attribute \var{name}, which is normally \code{'CDATA'}. \end{methoddesc} ! \begin{methoddesc}[AttributesImpl]{getValue}{name} Return the value of attribute \var{name}. \end{methoddesc} --- 296,320 ---- ! \subsection{The \class{Attributes} Interface \label{attributes-objects}} ! \class{Attributes} objects implement a portion of the mapping ! protocol, including the methods \method{copy()}, \method{get()}, \method{has_key()}, \method{items()}, \method{keys()}, and \method{values()}. The following methods are also provided: ! \begin{methoddesc}[Attributes]{getLength}{} Return the number of attributes. \end{methoddesc} ! \begin{methoddesc}[Attributes]{getNames}{} Return the names of the attributes. \end{methoddesc} ! \begin{methoddesc}[Attributes]{getType}{name} Returns the type of the attribute \var{name}, which is normally \code{'CDATA'}. \end{methoddesc} ! \begin{methoddesc}[Attributes]{getValue}{name} Return the value of attribute \var{name}. \end{methoddesc} *************** *** 317,337 **** ! \subsection{AttributesNSImpl Objects \label{attributes-ns-impl-objects}} ! \begin{methoddesc}[AttributesNSImpl]{getValueByQName}{name} Return the value for a qualified name. \end{methoddesc} ! \begin{methoddesc}[AttributesNSImpl]{getNameByQName}{name} Return the \code{(\var{namespace}, \var{localname})} pair for a qualified \var{name}. \end{methoddesc} ! \begin{methoddesc}[AttributesNSImpl]{getQNameByName}{name} Return the qualified name for a \code{(\var{namespace}, \var{localname})} pair. \end{methoddesc} ! \begin{methoddesc}[AttributesNSImpl]{getQNames}{} Return the qualified names of all attributes. \end{methoddesc} --- 324,351 ---- ! \subsection{The \class{AttributesNS} Interface \label{attributes-ns-objects}} ! This interface is a subtype of the \ulink{\class{Attributes} ! interface}{attributes-objects.html} (see ! section~\ref{attributes-objects}). All methods supported by that ! interface are also available on \class{AttributesNS} objects. ! ! The following methods are also available: ! ! \begin{methoddesc}[AttributesNS]{getValueByQName}{name} Return the value for a qualified name. \end{methoddesc} ! \begin{methoddesc}[AttributesNS]{getNameByQName}{name} Return the \code{(\var{namespace}, \var{localname})} pair for a qualified \var{name}. \end{methoddesc} ! \begin{methoddesc}[AttributesNS]{getQNameByName}{name} Return the qualified name for a \code{(\var{namespace}, \var{localname})} pair. \end{methoddesc} ! \begin{methoddesc}[AttributesNS]{getQNames}{} Return the qualified names of all attributes. \end{methoddesc} From fdrake@users.sourceforge.net Tue Jun 25 20:20:12 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 25 Jun 2002 12:20:12 -0700 Subject: [Python-checkins] python/dist/src/Lib/test xmltests.py,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv2353 Added Files: xmltests.py Log Message: Add convenience module to run all the XML tests. --- NEW FILE: xmltests.py --- # Convenience test module to run all of the XML-related tests in the # standard library. import sys def runtest(name): __import__(name) module = sys.modules[name] if hasattr(module, "test_main"): module.test_main() runtest("test.test_minidom") runtest("test.test_pyexpat") runtest("test.test_sax") runtest("test.test_xmllib") runtest("test.test_xmlrpc") From fdrake@users.sourceforge.net Tue Jun 25 20:20:12 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue, 25 Jun 2002 12:20:12 -0700 Subject: [Python-checkins] python/dist/src/Lib/test/output xmltests,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory usw-pr-cvs1:/tmp/cvs-serv2353/output Added Files: xmltests Log Message: Add convenience module to run all the XML tests. --- NEW FILE: xmltests --- xmltests Passed testAAA Passed setAttribute() sets ownerDocument Passed setAttribute() sets ownerElement Test Succeeded testAAA Passed assertion: len(Node.allnodes) == 0 Passed testAAB Test Succeeded testAAB Passed assertion: len(Node.allnodes) == 0 Passed Test Passed Test Passed Test Passed Test Passed Test Passed Test Passed Test Passed Test Test Succeeded testAddAttr Passed assertion: len(Node.allnodes) == 0 Passed Test Passed Test Test Succeeded testAppendChild Passed assertion: len(Node.allnodes) == 0 Passed appendChild() Test Succeeded testAppendChildFragment Passed assertion: len(Node.allnodes) == 0 Test Succeeded testAttrListItem Passed assertion: len(Node.allnodes) == 0 Test Succeeded testAttrListItemNS Passed assertion: len(Node.allnodes) == 0 Test Succeeded testAttrListItems Passed assertion: len(Node.allnodes) == 0 Test Succeeded testAttrListKeys Passed assertion: len(Node.allnodes) == 0 Test Succeeded testAttrListKeysNS Passed assertion: len(Node.allnodes) == 0 Test Succeeded testAttrListLength Passed assertion: len(Node.allnodes) == 0 Test Succeeded testAttrListValues Passed assertion: len(Node.allnodes) == 0 Test Succeeded testAttrList__getitem__ Passed assertion: len(Node.allnodes) == 0 Test Succeeded testAttrList__setitem__ Passed assertion: len(Node.allnodes) == 0 Passed Test Passed Test Test Succeeded testAttributeRepr Passed assertion: len(Node.allnodes) == 0 Passed Test Passed Test Passed Test Passed Test Passed Test Test Succeeded testChangeAttr Passed assertion: len(Node.allnodes) == 0 Test Succeeded testChildNodes Passed assertion: len(Node.allnodes) == 0 Test Succeeded testCloneAttributeDeep Passed assertion: len(Node.allnodes) == 0 Test Succeeded testCloneAttributeShallow Passed assertion: len(Node.allnodes) == 0 Test Succeeded testCloneDocumentDeep Passed assertion: len(Node.allnodes) == 0 Test Succeeded testCloneDocumentShallow Passed assertion: len(Node.allnodes) == 0 Passed clone of element has same attribute keys Passed clone of attribute node has proper attribute values Passed clone of attribute node correctly owned Passed testCloneElementDeep Test Succeeded testCloneElementDeep Passed assertion: len(Node.allnodes) == 0 Passed clone of element has same attribute keys Passed clone of attribute node has proper attribute values Passed clone of attribute node correctly owned Passed testCloneElementShallow Test Succeeded testCloneElementShallow Passed assertion: len(Node.allnodes) == 0 Test Succeeded testClonePIDeep Passed assertion: len(Node.allnodes) == 0 Test Succeeded testClonePIShallow Passed assertion: len(Node.allnodes) == 0 Test Succeeded testComment Passed assertion: len(Node.allnodes) == 0 Test Succeeded testCreateAttributeNS Passed assertion: len(Node.allnodes) == 0 Test Succeeded testCreateElementNS Passed assertion: len(Node.allnodes) == 0 Passed Test Passed Test Passed Test Test Succeeded testDeleteAttr Passed assertion: len(Node.allnodes) == 0 Test Succeeded testDocumentElement Passed assertion: len(Node.allnodes) == 0 Passed Test Test Succeeded testElement Passed assertion: len(Node.allnodes) == 0 Passed Test Test Succeeded testElementReprAndStr Passed assertion: len(Node.allnodes) == 0 Test Succeeded testFirstChild Passed assertion: len(Node.allnodes) == 0 Test Succeeded testGetAttrLength Passed assertion: len(Node.allnodes) == 0 Test Succeeded testGetAttrList Passed assertion: len(Node.allnodes) == 0 Test Succeeded testGetAttrValues Passed assertion: len(Node.allnodes) == 0 Test Succeeded testGetAttribute Passed assertion: len(Node.allnodes) == 0 Test Succeeded testGetAttributeNS Passed assertion: len(Node.allnodes) == 0 Test Succeeded testGetAttributeNode Passed assertion: len(Node.allnodes) == 0 Passed Test Test Succeeded testGetElementsByTagName Passed assertion: len(Node.allnodes) == 0 Passed Test Test Succeeded testGetElementsByTagNameNS Passed assertion: len(Node.allnodes) == 0 Test Succeeded testGetEmptyNodeListFromElementsByTagNameNS Passed assertion: len(Node.allnodes) == 0 Test Succeeded testHasChildNodes Passed assertion: len(Node.allnodes) == 0 Passed testInsertBefore -- node properly placed in tree Passed testInsertBefore -- node properly placed in tree Passed testInsertBefore -- node properly placed in tree Test Succeeded testInsertBefore Passed assertion: len(Node.allnodes) == 0 Passed insertBefore(, None) Passed insertBefore(, orig) Test Succeeded testInsertBeforeFragment Passed assertion: len(Node.allnodes) == 0 Test Succeeded testLegalChildren Passed assertion: len(Node.allnodes) == 0 Passed NamedNodeMap.__setitem__() sets ownerDocument Passed NamedNodeMap.__setitem__() sets ownerElement Passed NamedNodeMap.__setitem__() sets value Passed NamedNodeMap.__setitem__() sets nodeValue Test Succeeded testNamedNodeMapSetItem Passed assertion: len(Node.allnodes) == 0 Passed test NodeList.item() Test Succeeded testNodeListItem Passed assertion: len(Node.allnodes) == 0 Passed Test Passed Test Test Succeeded testNonZero Passed assertion: len(Node.allnodes) == 0 Passed testNormalize -- preparation Passed testNormalize -- result Passed testNormalize -- single empty node removed Test Succeeded testNormalize Passed assertion: len(Node.allnodes) == 0 Passed testParents Test Succeeded testParents Passed assertion: len(Node.allnodes) == 0 Test Succeeded testParse Passed assertion: len(Node.allnodes) == 0 Test Succeeded testParseAttributeNamespaces Passed assertion: len(Node.allnodes) == 0 Test Succeeded testParseAttributes Passed assertion: len(Node.allnodes) == 0 Test Succeeded testParseElement Passed assertion: len(Node.allnodes) == 0 Test Succeeded testParseElementNamespaces Passed assertion: len(Node.allnodes) == 0 Passed Test Test Succeeded testParseFromFile Passed assertion: len(Node.allnodes) == 0 Test Succeeded testParseProcessingInstructions Passed assertion: len(Node.allnodes) == 0 Test Succeeded testParseString Passed assertion: len(Node.allnodes) == 0 Test Succeeded testProcessingInstruction Passed assertion: len(Node.allnodes) == 0 Test Succeeded testProcessingInstructionRepr Passed assertion: len(Node.allnodes) == 0 Passed Test Passed Test Test Succeeded testRemoveAttr Passed assertion: len(Node.allnodes) == 0 Passed Test Passed Test Test Succeeded testRemoveAttrNS Passed assertion: len(Node.allnodes) == 0 Passed Test Passed Test Test Succeeded testRemoveAttributeNode Passed assertion: len(Node.allnodes) == 0 Passed replaceChild() Test Succeeded testReplaceChildFragment Passed assertion: len(Node.allnodes) == 0 Passed testSAX2DOM - siblings Passed testSAX2DOM - parents Test Succeeded testSAX2DOM Passed assertion: len(Node.allnodes) == 0 Test Succeeded testSetAttrValueandNodeValue Passed assertion: len(Node.allnodes) == 0 Passed testSiblings Test Succeeded testSiblings Passed assertion: len(Node.allnodes) == 0 Test Succeeded testTextNodeRepr Passed assertion: len(Node.allnodes) == 0 Test Succeeded testTextRepr Passed assertion: len(Node.allnodes) == 0 Caught expected exception when adding extra document element. Test Succeeded testTooManyDocumentElements Passed assertion: len(Node.allnodes) == 0 Test Succeeded testUnlink Passed assertion: len(Node.allnodes) == 0 Test Succeeded testWriteText Passed assertion: len(Node.allnodes) == 0 Passed Test Passed Test Test Succeeded testWriteXML Passed assertion: len(Node.allnodes) == 0 All tests succeeded OK. OK. OK. OK. OK. OK. OK. OK. OK. OK. OK. OK. PI: 'xml-stylesheet' 'href="stylesheet.css"' Comment: ' comment data ' Notation declared: ('notation', None, 'notation.jpeg', None) Unparsed entity decl: ('unparsed_entity', None, 'entity.file', None, 'notation') Start element: 'root' {'attr1': 'value1', 'attr2': 'value2\xe1\xbd\x80'} 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: 'contents of CDATA section' End of CDATA section End element: 'sub2' External entity ref: (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: (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: (None, u'entity.file', None) End element: u'root' Testing constructor for proper handling of namespace_separator values: Legal values tested o.k. Caught expected TypeError: ParserCreate() argument 2 must be string or None, not int Caught expected ValueError: namespace_separator must be at most one character, omitted, or None Passed test_attrs_empty Passed test_attrs_wattr Passed test_double_quoteattr Passed test_escape_all Passed test_escape_basic Passed test_escape_extra Passed test_expat_attrs_empty Passed test_expat_attrs_wattr Passed test_expat_dtdhandler Passed test_expat_entityresolver Passed test_expat_file Passed test_expat_incomplete Passed test_expat_incremental Passed test_expat_incremental_reset Passed test_expat_inpsource_filename Passed test_expat_inpsource_location Passed test_expat_inpsource_stream Passed test_expat_inpsource_sysid Passed test_expat_locator_noinfo Passed test_expat_locator_withinfo Passed test_expat_nsattrs_empty Passed test_expat_nsattrs_wattr Passed test_filter_basic Passed test_make_parser Passed test_make_parser2 Passed test_nsattrs_empty Passed test_nsattrs_wattr Passed test_quoteattr_basic Passed test_single_double_quoteattr Passed test_single_quoteattr Passed test_xmlgen_attr_escape Passed test_xmlgen_basic Passed test_xmlgen_content Passed test_xmlgen_content_escape Passed test_xmlgen_ignorable Passed test_xmlgen_ns Passed test_xmlgen_pi 37 tests, 0 failures test_simple (test.test_xmllib.XMLParserTestCase) ... ok ---------------------------------------------------------------------- Ran 1 test in 0.019s OK test_dump_bad_dict (test.test_xmlrpc.XMLRPCTestCase) ... ok test_dump_big_int (test.test_xmlrpc.XMLRPCTestCase) ... ok test_dump_big_long (test.test_xmlrpc.XMLRPCTestCase) ... ok test_dump_load (test.test_xmlrpc.XMLRPCTestCase) ... ok ---------------------------------------------------------------------- Ran 4 tests in 0.005s OK From jhylton@users.sourceforge.net Tue Jun 25 20:26:36 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Tue, 25 Jun 2002 12:26:36 -0700 Subject: [Python-checkins] python/dist/src/Python thread.c,2.43,2.44 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv4935 Modified Files: thread.c Log Message: Silence compiler warning Index: thread.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread.c,v retrieving revision 2.43 retrieving revision 2.44 diff -C2 -d -r2.43 -r2.44 *** thread.c 11 Jun 2002 06:22:31 -0000 2.43 --- thread.c 25 Jun 2002 19:26:34 -0000 2.44 *************** *** 60,64 **** #ifdef Py_DEBUG static int thread_debug = 0; ! #define dprintf(args) ((thread_debug & 1) && printf args) #define d2printf(args) ((thread_debug & 8) && printf args) #else --- 60,64 ---- #ifdef Py_DEBUG static int thread_debug = 0; ! #define dprintf(args) (void)((thread_debug & 1) && printf args) #define d2printf(args) ((thread_debug & 8) && printf args) #else From akuchling@users.sourceforge.net Wed Jun 26 00:57:20 2002 From: akuchling@users.sourceforge.net (akuchling@users.sourceforge.net) Date: Tue, 25 Jun 2002 16:57:20 -0700 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew23.tex,1.26,1.27 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory usw-pr-cvs1:/tmp/cvs-serv25702 Modified Files: whatsnew23.tex Log Message: Add a reminder Index: whatsnew23.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew23.tex,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** whatsnew23.tex 17 Jun 2002 13:40:04 -0000 1.26 --- whatsnew23.tex 25 Jun 2002 23:57:17 -0000 1.27 *************** *** 14,17 **** --- 14,19 ---- \tableofcontents + % Types now callable; `new' module replaced + % % Timeout sockets: % Executive summary: after sock.settimeout(T), all methods of sock will *************** *** 671,675 **** suggestions, corrections and assistance with various drafts of this article: Michael Chermside, Scott David Daniels, Fred~L. Drake, Jr., ! Detlef Lannert, Andrew MacIntyre. \end{document} --- 673,677 ---- suggestions, corrections and assistance with various drafts of this article: Michael Chermside, Scott David Daniels, Fred~L. Drake, Jr., ! Detlef Lannert, Andrew MacIntyre, Gustavo Niemeyer. \end{document} From akuchling@users.sourceforge.net Wed Jun 26 01:03:07 2002 From: akuchling@users.sourceforge.net (akuchling@users.sourceforge.net) Date: Tue, 25 Jun 2002 17:03:07 -0700 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew23.tex,1.27,1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory usw-pr-cvs1:/tmp/cvs-serv27220 Modified Files: whatsnew23.tex Log Message: Add a reminder Index: whatsnew23.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew23.tex,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** whatsnew23.tex 25 Jun 2002 23:57:17 -0000 1.27 --- whatsnew23.tex 26 Jun 2002 00:03:05 -0000 1.28 *************** *** 25,28 **** --- 25,30 ---- % getopt.gnu_getopt % + % textwrap.py + % % Docstrings now optional (with --without-doc-strings) % From montanaro@users.sourceforge.net Wed Jun 26 06:07:31 2002 From: montanaro@users.sourceforge.net (montanaro@users.sourceforge.net) Date: Tue, 25 Jun 2002 22:07:31 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libbisect.tex,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv26247 Modified Files: libbisect.tex Log Message: add /F's PriorityQueue example Index: libbisect.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libbisect.tex,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** libbisect.tex 6 Jul 2001 19:28:48 -0000 1.10 --- libbisect.tex 26 Jun 2002 05:07:28 -0000 1.11 *************** *** 62,66 **** ! \subsection{Example} \nodename{bisect-example} --- 62,66 ---- ! \subsection{Examples} \nodename{bisect-example} *************** *** 81,83 **** --- 81,101 ---- >>> map(grade, [33, 99, 77, 44, 12, 88]) ['E', 'A', 'B', 'D', 'F', 'A'] + \end{verbatim} + + The bisect module can be used with the Queue module to implement a priority + queue (example courtesy of Fredrik Lundh): \index{Priority Queue} + + \begin{verbatim} + import Queue, bisect + + class PriorityQueue(Queue.Queue): + def _put(self, item): + bisect.insort(self.queue, item) + + # usage + queue = PriorityQueue(0) + queue.put((2, "second")) + queue.put((1, "first")) + queue.put((3, "third")) + priority, value = queue.get() \end{verbatim} From montanaro@users.sourceforge.net Wed Jun 26 06:22:10 2002 From: montanaro@users.sourceforge.net (montanaro@users.sourceforge.net) Date: Tue, 25 Jun 2002 22:22:10 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libqueue.tex,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv28718 Modified Files: libqueue.tex Log Message: add seealso link to the bisect module Index: libqueue.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libqueue.tex,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** libqueue.tex 10 Oct 2000 17:03:45 -0000 1.11 --- libqueue.tex 26 Jun 2002 05:22:08 -0000 1.12 *************** *** 13,16 **** --- 13,20 ---- Python. + \begin{seealso} + \seemodule{bisect}{PriorityQueue example using the Queue class} + \end{seealso} + The \module{Queue} module defines the following class and exception: From ping@users.sourceforge.net Wed Jun 26 08:10:59 2002 From: ping@users.sourceforge.net (ping@users.sourceforge.net) Date: Wed, 26 Jun 2002 00:10:59 -0700 Subject: [Python-checkins] python/dist/src/Lib cgitb.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv17524 Modified Files: cgitb.py Log Message: Also look up variable names in __builtins__ if not found in globals. Don't show hidden fields of exception values (names starting with '_'). Index: cgitb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cgitb.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** cgitb.py 19 Dec 2001 14:27:41 -0000 1.4 --- cgitb.py 26 Jun 2002 07:10:56 -0000 1.5 *************** *** 43,46 **** --- 43,54 ---- if name in frame.f_globals: return 'global', frame.f_globals[name] + if '__builtins__' in frame.f_globals: + builtins = frame.f_globals['__builtins__'] + if type(builtins) is type({}): + if name in builtins: + return 'builtin', builtins[name] + else: + if hasattr(builtins, name): + return 'builtin', getattr(builtins, name) return None, __UNDEF__ *************** *** 119,125 **** done[name] = 1 if value is not __UNDEF__: ! if where == 'global': name = 'global ' + strong(name) ! elif where == 'local': name = strong(name) ! else: name = where + strong(name.split('.')[-1]) dump.append('%s = %s' % (name, pydoc.html.repr(value))) else: --- 127,136 ---- done[name] = 1 if value is not __UNDEF__: ! if where in ['global', 'builtin']: ! name = ('%s ' % where) + strong(name) ! elif where == 'local': ! name = strong(name) ! else: ! name = where + strong(name.split('.')[-1]) dump.append('%s = %s' % (name, pydoc.html.repr(value))) else: *************** *** 134,137 **** --- 145,149 ---- if type(evalue) is types.InstanceType: for name in dir(evalue): + if name[:1] == '_': continue value = pydoc.html.repr(getattr(evalue, name)) exception.append('\n
    %s%s =\n%s' % (indent, name, value)) From rhettinger@users.sourceforge.net Wed Jun 26 08:51:36 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed, 26 Jun 2002 00:51:36 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib email.tex,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv26282 Modified Files: email.tex Log Message: Fix bug #573916. Sender and recipients reversed in email example. Index: email.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/email.tex,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** email.tex 15 Feb 2002 04:12:59 -0000 1.10 --- email.tex 26 Jun 2002 07:51:32 -0000 1.11 *************** *** 482,487 **** outer = MIMEBase('multipart', 'mixed') outer['Subject'] = 'Contents of directory %s' % os.path.abspath(dir) ! outer['To'] = sender ! outer['From'] = COMMASPACE.join(recips) outer.preamble = 'You will not see this in a MIME-aware mail reader.\n' # To guarantee the message ends with a newline --- 482,487 ---- outer = MIMEBase('multipart', 'mixed') outer['Subject'] = 'Contents of directory %s' % os.path.abspath(dir) ! outer['To'] = COMMASPACE.join(recips) ! outer['From'] = sender outer.preamble = 'You will not see this in a MIME-aware mail reader.\n' # To guarantee the message ends with a newline From rhettinger@users.sourceforge.net Wed Jun 26 08:52:43 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed, 26 Jun 2002 00:52:43 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib email.tex,1.9.6.1,1.9.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv26940 Modified Files: Tag: release22-maint email.tex Log Message: Fix bug #573916. Sender and recipients reversed in email example. Index: email.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/email.tex,v retrieving revision 1.9.6.1 retrieving revision 1.9.6.2 diff -C2 -d -r1.9.6.1 -r1.9.6.2 *** email.tex 15 Feb 2002 04:21:45 -0000 1.9.6.1 --- email.tex 26 Jun 2002 07:52:41 -0000 1.9.6.2 *************** *** 482,487 **** outer = MIMEBase('multipart', 'mixed') outer['Subject'] = 'Contents of directory %s' % os.path.abspath(dir) ! outer['To'] = sender ! outer['From'] = COMMASPACE.join(recips) outer.preamble = 'You will not see this in a MIME-aware mail reader.\n' # To guarantee the message ends with a newline --- 482,487 ---- outer = MIMEBase('multipart', 'mixed') outer['Subject'] = 'Contents of directory %s' % os.path.abspath(dir) ! outer['To'] = COMMASPACE.join(recips) ! outer['From'] = sender outer.preamble = 'You will not see this in a MIME-aware mail reader.\n' # To guarantee the message ends with a newline From akuchling@users.sourceforge.net Wed Jun 26 14:23:57 2002 From: akuchling@users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed, 26 Jun 2002 06:23:57 -0700 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew23.tex,1.28,1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory usw-pr-cvs1:/tmp/cvs-serv2552 Modified Files: whatsnew23.tex Log Message: Describe textwrap module Index: whatsnew23.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew23.tex,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** whatsnew23.tex 26 Jun 2002 00:03:05 -0000 1.28 --- whatsnew23.tex 26 Jun 2002 13:23:55 -0000 1.29 *************** *** 25,30 **** % getopt.gnu_getopt % - % textwrap.py - % % Docstrings now optional (with --without-doc-strings) % --- 25,28 ---- *************** *** 468,471 **** --- 466,504 ---- \begin{itemize} + + \item The \module{textwrap} module contains functions for wrapping + strings containing paragraphs of text. The \function{wrap(\var{text}, + \var{width})} function takes a string and returns a list containing + the text split into lines of no more than the chosen width. The + \function{fill(\var{text}, \var{width})} function returns a single + string, reformatted to fit into lines no longer than the chosen width. + (As you can guess, \function{fill()} is built on top of + \function{wrap()}. For example: + + \begin{verbatim} + >>> import textwrap + >>> paragraph = "Not a whit, we defy augury: ... more text ..." + >>> textwrap.wrap(paragraph, 60) + ["Not a whit, we defy augury: there's a special providence in", + "the fall of a sparrow. If it be now, 'tis not to come; if it", + ...] + >>> print textwrap.fill(paragraph, 35) + Not a whit, we defy augury: there's + a special providence in the fall of + a sparrow. If it be now, 'tis not + to come; if it be not to come, it + will be now; if it be not now, yet + it will come: the readiness is all. + >>> + \end{verbatim} + + The module also contains a \class{TextWrapper} class that actually + implements the text wrapping strategy. Both the + \class{TextWrapper} class and the \function{wrap()} and + \function{fill()} functions support a number of additional keyword + arguments for fine-tuning the formatting; consult the module's + documentation for details. + % XXX add a link to the module docs? + (Contributed by Greg Ward.) \item One minor but far-reaching change is that the names of extension From akuchling@users.sourceforge.net Wed Jun 26 14:28:21 2002 From: akuchling@users.sourceforge.net (akuchling@users.sourceforge.net) Date: Wed, 26 Jun 2002 06:28:21 -0700 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew23.tex,1.29,1.30 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory usw-pr-cvs1:/tmp/cvs-serv4333 Modified Files: whatsnew23.tex Log Message: Add some acks Index: whatsnew23.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew23.tex,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** whatsnew23.tex 26 Jun 2002 13:23:55 -0000 1.29 --- whatsnew23.tex 26 Jun 2002 13:28:19 -0000 1.30 *************** *** 708,712 **** suggestions, corrections and assistance with various drafts of this article: Michael Chermside, Scott David Daniels, Fred~L. Drake, Jr., ! Detlef Lannert, Andrew MacIntyre, Gustavo Niemeyer. \end{document} --- 708,713 ---- suggestions, corrections and assistance with various drafts of this article: Michael Chermside, Scott David Daniels, Fred~L. Drake, Jr., ! Michael Hudson, Detlef Lannert, Andrew MacIntyre, Gustavo Niemeyer, ! Neal Norwitz. \end{document} From jackjansen@users.sourceforge.net Wed Jun 26 16:00:31 2002 From: jackjansen@users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed, 26 Jun 2002 08:00:31 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils/command bdist_pkgtool.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory usw-pr-cvs1:/tmp/cvs-serv1292 Modified Files: bdist_pkgtool.py Log Message: This module broke on the Mac (where it can't work, but distutils seems to import it anyway) because it imported pwd and grp. Moved the import to inside the routine where they're used. Index: bdist_pkgtool.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_pkgtool.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** bdist_pkgtool.py 4 Jun 2002 21:00:33 -0000 1.7 --- bdist_pkgtool.py 26 Jun 2002 15:00:29 -0000 1.8 *************** *** 7,11 **** distributions).""" ! import os, string, sys, pwd, grp from types import * from distutils.util import get_platform --- 7,11 ---- distributions).""" ! import os, string, sys from types import * from distutils.util import get_platform *************** *** 282,285 **** --- 282,286 ---- def _make_prototype(self): + import pwd, grp proto_file = ["i pkginfo"] if self.request: From jackjansen@users.sourceforge.net Wed Jun 26 16:14:51 2002 From: jackjansen@users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed, 26 Jun 2002 08:14:51 -0700 Subject: [Python-checkins] python/dist/src/Mac/Lib EasyDialogs.py,1.36,1.37 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Lib In directory usw-pr-cvs1:/tmp/cvs-serv5295 Modified Files: EasyDialogs.py Log Message: Turns out GetArgv() options can be 4-tuples too, with the last value being the default (or something like that). Cater for this. Also put in a safeguard against very long help strings. Index: EasyDialogs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Lib/EasyDialogs.py,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** EasyDialogs.py 9 Sep 2001 00:36:01 -0000 1.36 --- EasyDialogs.py 26 Jun 2002 15:14:48 -0000 1.37 *************** *** 362,371 **** return option = optionlist[idx] ! if type(option) == type(()) and \ ! len(option) > 1: ! help = option[-1] else: help = '' h = d.GetDialogItemAsControl(ARGV_OPTION_EXPLAIN) Dlg.SetDialogItemText(h, help) hasvalue = 0 --- 362,377 ---- return option = optionlist[idx] ! if type(option) == type(()): ! if len(option) == 4: ! help = option[2] ! elif len(option) > 1: ! help = option[-1] ! else: ! help = '' else: help = '' h = d.GetDialogItemAsControl(ARGV_OPTION_EXPLAIN) + if help and len(help) > 250: + help = help[:250] + '...' Dlg.SetDialogItemText(h, help) hasvalue = 0 From fdrake@users.sourceforge.net Wed Jun 26 16:16:19 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed, 26 Jun 2002 08:16:19 -0700 Subject: [Python-checkins] python/dist/src/Lib/test/output xmltests,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory usw-pr-cvs1:/tmp/cvs-serv5697/output Modified Files: xmltests Log Message: Suppress the variable verbose output from test.xmltests; the inclusion of timing information in the output makes the determination of success bogus. Index: xmltests =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/xmltests,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** xmltests 25 Jun 2002 19:20:10 -0000 1.1 --- xmltests 26 Jun 2002 15:16:16 -0000 1.2 *************** *** 363,379 **** Passed test_xmlgen_pi 37 tests, 0 failures - test_simple (test.test_xmllib.XMLParserTestCase) ... ok - - ---------------------------------------------------------------------- - Ran 1 test in 0.019s - - OK - test_dump_bad_dict (test.test_xmlrpc.XMLRPCTestCase) ... ok - test_dump_big_int (test.test_xmlrpc.XMLRPCTestCase) ... ok - test_dump_big_long (test.test_xmlrpc.XMLRPCTestCase) ... ok - test_dump_load (test.test_xmlrpc.XMLRPCTestCase) ... ok - - ---------------------------------------------------------------------- - Ran 4 tests in 0.005s - - OK --- 363,364 ---- From fdrake@users.sourceforge.net Wed Jun 26 16:16:18 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed, 26 Jun 2002 08:16:18 -0700 Subject: [Python-checkins] python/dist/src/Lib/test xmltests.py,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv5697 Modified Files: xmltests.py Log Message: Suppress the variable verbose output from test.xmltests; the inclusion of timing information in the output makes the determination of success bogus. Index: xmltests.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/xmltests.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** xmltests.py 25 Jun 2002 19:20:10 -0000 1.1 --- xmltests.py 26 Jun 2002 15:16:16 -0000 1.2 *************** *** 3,6 **** --- 3,9 ---- import sys + import test.test_support + + test.test_support.verbose = 0 def runtest(name): From rhettinger@users.sourceforge.net Wed Jun 26 16:19:03 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed, 26 Jun 2002 08:19:03 -0700 Subject: [Python-checkins] python/dist/src/Lib Cookie.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv6524 Modified Files: Cookie.py Log Message: Apply SF 562987 modernizing Cookie to subclass from dict instead of UserDict Index: Cookie.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/Cookie.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Cookie.py 26 Apr 2002 02:29:55 -0000 1.12 --- Cookie.py 26 Jun 2002 15:19:01 -0000 1.13 *************** *** 217,221 **** # import string - from UserDict import UserDict try: --- 217,220 ---- *************** *** 407,411 **** # ! class Morsel(UserDict): # RFC 2109 lists these attributes as reserved: # path comment domain --- 406,410 ---- # ! class Morsel(dict): # RFC 2109 lists these attributes as reserved: # path comment domain *************** *** 426,450 **** "version" : "Version", } - _reserved_keys = _reserved.keys() def __init__(self): # Set defaults self.key = self.value = self.coded_value = None - UserDict.__init__(self) # Set default attributes ! for K in self._reserved_keys: ! UserDict.__setitem__(self, K, "") # end __init__ def __setitem__(self, K, V): K = K.lower() ! if not K in self._reserved_keys: raise CookieError("Invalid Attribute %s" % K) ! UserDict.__setitem__(self, K, V) # end __setitem__ def isReservedKey(self, K): ! return K.lower() in self._reserved_keys # end isReservedKey --- 425,447 ---- "version" : "Version", } def __init__(self): # Set defaults self.key = self.value = self.coded_value = None # Set default attributes ! for K in self._reserved: ! dict.__setitem__(self, K, "") # end __init__ def __setitem__(self, K, V): K = K.lower() ! if not K in self._reserved: raise CookieError("Invalid Attribute %s" % K) ! dict.__setitem__(self, K, V) # end __setitem__ def isReservedKey(self, K): ! return K.lower() in self._reserved # end isReservedKey *************** *** 454,458 **** # First we verify that the key isn't a reserved word # Second we make sure it only contains legal characters ! if key.lower() in self._reserved_keys: raise CookieError("Attempt to set a reserved key: %s" % key) if "" != translate(key, idmap, LegalChars): --- 451,455 ---- # First we verify that the key isn't a reserved word # Second we make sure it only contains legal characters ! if key.lower() in self._reserved: raise CookieError("Attempt to set a reserved key: %s" % key) if "" != translate(key, idmap, LegalChars): *************** *** 496,500 **** # Now add any defined attributes if attrs is None: ! attrs = self._reserved_keys items = self.items() items.sort() --- 493,497 ---- # Now add any defined attributes if attrs is None: ! attrs = self._reserved items = self.items() items.sort() *************** *** 547,551 **** # See this module's docstring for example usage. # ! class BaseCookie(UserDict): # A container class for a set of Morsels # --- 544,548 ---- # See this module's docstring for example usage. # ! class BaseCookie(dict): # A container class for a set of Morsels # *************** *** 572,576 **** def __init__(self, input=None): - UserDict.__init__(self) if input: self.load(input) # end __init__ --- 569,572 ---- *************** *** 580,584 **** M = self.get(key, Morsel()) M.set(key, real_value, coded_value) ! UserDict.__setitem__(self, key, M) # end __set --- 576,580 ---- M = self.get(key, Morsel()) M.set(key, real_value, coded_value) ! dict.__setitem__(self, key, M) # end __set *************** *** 652,656 **** if M: M[ K[1:] ] = V ! elif K.lower() in Morsel._reserved_keys: if M: M[ K ] = _unquote(V) --- 648,652 ---- if M: M[ K[1:] ] = V ! elif K.lower() in Morsel._reserved: if M: M[ K ] = _unquote(V) From jackjansen@users.sourceforge.net Wed Jun 26 16:42:51 2002 From: jackjansen@users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed, 26 Jun 2002 08:42:51 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils mwerkscompiler.py,1.8,1.9 sysconfig.py,1.47,1.48 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv15339 Modified Files: mwerkscompiler.py sysconfig.py Log Message: Fixed various MacPython-specific issues found by attempting to use the standard core setup.py for MacPython. Index: mwerkscompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/mwerkscompiler.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** mwerkscompiler.py 13 Jun 2002 17:27:13 -0000 1.8 --- mwerkscompiler.py 26 Jun 2002 15:42:49 -0000 1.9 *************** *** 162,166 **** # Build the export file exportfilename = os.path.join(build_temp, exportname) ! log.debug("\tCreate export file", exportfilename) fp = open(exportfilename, 'w') fp.write('%s\n'%export_symbols[0]) --- 162,166 ---- # Build the export file exportfilename = os.path.join(build_temp, exportname) ! log.debug("\tCreate export file %s", exportfilename) fp = open(exportfilename, 'w') fp.write('%s\n'%export_symbols[0]) *************** *** 183,187 **** # doesn't have a clue about our working directory. xmlfilename = os.path.join(os.getcwd(), os.path.join(build_temp, xmlname)) ! log.debug("\tCreate XML file", xmlfilename) xmlbuilder = mkcwproject.cwxmlgen.ProjectBuilder(settings) xmlbuilder.generate() --- 183,187 ---- # doesn't have a clue about our working directory. xmlfilename = os.path.join(os.getcwd(), os.path.join(build_temp, xmlname)) ! log.debug("\tCreate XML file %s", xmlfilename) xmlbuilder = mkcwproject.cwxmlgen.ProjectBuilder(settings) xmlbuilder.generate() *************** *** 192,196 **** # Generate the project. Again a full pathname. projectfilename = os.path.join(os.getcwd(), os.path.join(build_temp, projectname)) ! log.debug('\tCreate project file', projectfilename) mkcwproject.makeproject(xmlfilename, projectfilename) # And build it --- 192,196 ---- # Generate the project. Again a full pathname. projectfilename = os.path.join(os.getcwd(), os.path.join(build_temp, projectname)) ! log.debug('\tCreate project file %s', projectfilename) mkcwproject.makeproject(xmlfilename, projectfilename) # And build it *************** *** 214,215 **** --- 214,243 ---- components[i] = '' return string.join(components, ':') + + def library_dir_option (self, dir): + """Return the compiler option to add 'dir' to the list of + directories searched for libraries. + """ + return # XXXX Not correct... + + def runtime_library_dir_option (self, dir): + """Return the compiler option to add 'dir' to the list of + directories searched for runtime libraries. + """ + # Nothing needed or Mwerks/Mac. + return + + def library_option (self, lib): + """Return the compiler option to add 'dir' to the list of libraries + linked into the shared library or executable. + """ + return + + def find_library_file (self, dirs, lib, debug=0): + """Search the specified list of directories for a static or shared + library file 'lib' and return the full path to that file. If + 'debug' true, look for a debugging version (if that makes sense on + the current platform). Return None if 'lib' wasn't found in any of + the specified directories. + """ + return 0 Index: sysconfig.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/sysconfig.py,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** sysconfig.py 4 Jun 2002 20:26:44 -0000 1.47 --- sysconfig.py 26 Jun 2002 15:42:49 -0000 1.48 *************** *** 67,71 **** return os.path.join(prefix, "include") elif os.name == "mac": ! return os.path.join(prefix, "Include") elif os.name == "os2": return os.path.join(prefix, "Include") --- 67,74 ---- return os.path.join(prefix, "include") elif os.name == "mac": ! if plat_specific: ! return os.path.join(prefix, "Mac", "Include") ! else: ! return os.path.join(prefix, "Include") elif os.name == "os2": return os.path.join(prefix, "Include") *************** *** 404,407 **** --- 407,412 ---- g['install_platlib'] = os.path.join(EXEC_PREFIX, "Mac", "Lib") + # These are used by the extension module build + g['srcdir'] = ':' global _config_vars _config_vars = g From jackjansen@users.sourceforge.net Wed Jun 26 16:44:32 2002 From: jackjansen@users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed, 26 Jun 2002 08:44:32 -0700 Subject: [Python-checkins] python/dist/src setup.py,1.96,1.97 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv16013 Modified Files: setup.py Log Message: Fixed a few showstoppers in the process of making MacPython use setup.py to build it's exension modules (in stead of relying on a private mechanism). It definitely doesn't work yet, but it looks promising. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.96 retrieving revision 1.97 diff -C2 -d -r1.96 -r1.97 *** setup.py 24 Jun 2002 20:27:33 -0000 1.96 --- setup.py 26 Jun 2002 15:44:30 -0000 1.97 *************** *** 19,23 **** 1) 'dir' is not already in 'dirlist' 2) 'dir' actually exists, and is a directory.""" ! if os.path.isdir(dir) and dir not in dirlist: dirlist.insert(0, dir) --- 19,23 ---- 1) 'dir' is not already in 'dirlist' 2) 'dir' actually exists, and is a directory.""" ! if dir is not None and os.path.isdir(dir) and dir not in dirlist: dirlist.insert(0, dir) *************** *** 100,104 **** # Platform-dependent module source and include directories platform = self.get_platform() ! if platform == 'darwin': # Mac OS X also includes some mac-specific modules macmoddir = os.path.join(os.getcwd(), srcdir, 'Mac/Modules') --- 100,104 ---- # Platform-dependent module source and include directories platform = self.get_platform() ! if platform in ('darwin', 'mac'): # Mac OS X also includes some mac-specific modules macmoddir = os.path.join(os.getcwd(), srcdir, 'Mac/Modules') *************** *** 127,144 **** self.extensions.remove(ext) ! # Parse Modules/Setup to figure out which modules are turned ! # on in the file. ! input = text_file.TextFile('Modules/Setup', join_lines=1) ! remove_modules = [] ! while 1: ! line = input.readline() ! if not line: break ! line = line.split() ! remove_modules.append( line[0] ) ! input.close() ! ! for ext in self.extensions[:]: ! if ext.name in remove_modules: ! self.extensions.remove(ext) # When you run "make CC=altcc" or something similar, you really want --- 127,145 ---- self.extensions.remove(ext) ! if platform != 'mac': ! # Parse Modules/Setup to figure out which modules are turned ! # on in the file. ! input = text_file.TextFile('Modules/Setup', join_lines=1) ! remove_modules = [] ! while 1: ! line = input.readline() ! if not line: break ! line = line.split() ! remove_modules.append( line[0] ) ! input.close() ! ! for ext in self.extensions[:]: ! if ext.name in remove_modules: ! self.extensions.remove(ext) # When you run "make CC=altcc" or something similar, you really want *************** *** 259,263 **** # Check for MacOS X, which doesn't need libm.a at all math_libs = ['m'] ! if platform in ['darwin', 'beos']: math_libs = [] --- 260,264 ---- # Check for MacOS X, which doesn't need libm.a at all math_libs = ['m'] ! if platform in ['darwin', 'beos', 'mac']: math_libs = [] From jackjansen@users.sourceforge.net Wed Jun 26 21:17:05 2002 From: jackjansen@users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed, 26 Jun 2002 13:17:05 -0700 Subject: [Python-checkins] python/dist/src/Mac/Build PythonCore.mcp,1.36,1.37 PythonInterpreter.mcp,1.18,1.19 PythonStandSmall.mcp,1.38,1.39 PythonStandalone.mcp,1.22,1.23 _CG.carbon.mcp,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Build In directory usw-pr-cvs1:/tmp/cvs-serv12088 Modified Files: PythonCore.mcp PythonInterpreter.mcp PythonStandSmall.mcp PythonStandalone.mcp _CG.carbon.mcp Log Message: - Got rid of non-carbon builds - Use precompiled headers - Rationalize config file names. Index: PythonCore.mcp =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Build/PythonCore.mcp,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 Binary files /tmp/cvs5kBuAh and /tmp/cvsinxTeq differ Index: PythonInterpreter.mcp =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Build/PythonInterpreter.mcp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 Binary files /tmp/cvsOugj4j and /tmp/cvs0EWvhv differ Index: PythonStandSmall.mcp =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Build/PythonStandSmall.mcp,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 Binary files /tmp/cvs9joSNm and /tmp/cvsKTBYUB differ Index: PythonStandalone.mcp =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Build/PythonStandalone.mcp,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 Binary files /tmp/cvs0d5wbq and /tmp/cvsI5LOeH differ Index: _CG.carbon.mcp =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Build/_CG.carbon.mcp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 Binary files /tmp/cvsf2v5ns and /tmp/cvsetztiK differ From jackjansen@users.sourceforge.net Wed Jun 26 21:35:20 2002 From: jackjansen@users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed, 26 Jun 2002 13:35:20 -0700 Subject: [Python-checkins] python/dist/src/Mac/Lib/mkcwproject __init__.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Lib/mkcwproject In directory usw-pr-cvs1:/tmp/cvs-serv17857 Modified Files: __init__.py Log Message: Close the project after generating it, so we don't keep a gazillion project files open when we're rebuilding them all. Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Lib/mkcwproject/__init__.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** __init__.py 14 Dec 2001 14:31:09 -0000 1.12 --- __init__.py 26 Jun 2002 20:35:18 -0000 1.13 *************** *** 62,65 **** --- 62,66 ---- prjfss = macfs.FSSpec(projectfile) cw.my_mkproject(prjfss, xmlfss) + cw.Close_Project() def buildproject(projectfile): From jackjansen@users.sourceforge.net Wed Jun 26 21:36:15 2002 From: jackjansen@users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed, 26 Jun 2002 13:36:15 -0700 Subject: [Python-checkins] python/dist/src/Mac/Lib/mkcwproject cwxmlgen.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Lib/mkcwproject In directory usw-pr-cvs1:/tmp/cvs-serv18157 Modified Files: cwxmlgen.py Log Message: In plugin projects use (by default) the new mwerks_shcarbon_pch header file in stead of mwerks_carbonplugin_config.h. Index: cwxmlgen.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Lib/mkcwproject/cwxmlgen.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** cwxmlgen.py 23 May 2002 22:34:02 -0000 1.8 --- cwxmlgen.py 26 Jun 2002 20:36:12 -0000 1.9 *************** *** 40,44 **** if not dict.has_key('prefixname'): if hasattr(MacOS, 'runtimemodel') and MacOS.runtimemodel == "carbon": ! dict['prefixname'] = 'mwerks_carbonplugin_config.h' else: dict['prefixname'] = 'mwerks_plugin_config.h' --- 40,44 ---- if not dict.has_key('prefixname'): if hasattr(MacOS, 'runtimemodel') and MacOS.runtimemodel == "carbon": ! dict['prefixname'] = 'mwerks_shcarbon_pch' else: dict['prefixname'] = 'mwerks_plugin_config.h' From jackjansen@users.sourceforge.net Wed Jun 26 21:37:43 2002 From: jackjansen@users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed, 26 Jun 2002 13:37:43 -0700 Subject: [Python-checkins] python/dist/src/Mac/Python macshlglue.c,1.16,1.17 macglue.c,1.111,1.112 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Python In directory usw-pr-cvs1:/tmp/cvs-serv18553 Modified Files: macshlglue.c macglue.c Log Message: Changed some prototypes to match the exact definition in some faraway Apple header files. If we're building with precompiled headers these are in scope. Index: macshlglue.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Python/macshlglue.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** macshlglue.c 24 Jul 2000 19:50:31 -0000 1.16 --- macshlglue.c 26 Jun 2002 20:37:40 -0000 1.17 *************** *** 55,59 **** /* Defined either in macglue.c or in a MPW library: */ ! extern pascal int PLstrcmp(unsigned char *, unsigned char *); /* --- 55,59 ---- /* Defined either in macglue.c or in a MPW library: */ ! extern pascal short PLstrcmp(const unsigned char *, const unsigned char *); /* Index: macglue.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Python/macglue.c,v retrieving revision 1.111 retrieving revision 1.112 diff -C2 -d -r1.111 -r1.112 *** macglue.c 11 Apr 2002 20:48:19 -0000 1.111 --- macglue.c 26 Jun 2002 20:37:40 -0000 1.112 *************** *** 66,72 **** extern void SpinCursor(short x); extern void RotateCursor(short x); ! extern pascal void PLstrcpy(unsigned char *, unsigned char *); ! extern pascal int PLstrcmp(unsigned char *, unsigned char *); ! extern pascal unsigned char *PLstrrchr(unsigned char *, unsigned char); #endif --- 66,72 ---- extern void SpinCursor(short x); extern void RotateCursor(short x); ! extern pascal unsigned char * PLstrcpy(unsigned char *, const unsigned char *); ! extern pascal short PLstrcmp(const unsigned char *, const unsigned char *); ! extern pascal char *PLstrrchr(const unsigned char *, short); #endif From jackjansen@users.sourceforge.net Wed Jun 26 21:39:22 2002 From: jackjansen@users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed, 26 Jun 2002 13:39:22 -0700 Subject: [Python-checkins] python/dist/src/Python sysmodule.c,2.105,2.106 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv19261/Python Modified Files: sysmodule.c Log Message: Got rid of an extraneous semicolon. Index: sysmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v retrieving revision 2.105 retrieving revision 2.106 diff -C2 -d -r2.105 -r2.106 *** sysmodule.c 20 Jun 2002 21:36:19 -0000 2.105 --- sysmodule.c 26 Jun 2002 20:39:20 -0000 2.106 *************** *** 403,407 **** Return the current value of the recursion limit, the maximum depth\n\ of the Python interpreter stack. This limit prevents infinite\n\ ! recursion from causing an overflow of the C stack and crashing Python."; ); --- 403,407 ---- Return the current value of the recursion limit, the maximum depth\n\ of the Python interpreter stack. This limit prevents infinite\n\ ! recursion from causing an overflow of the C stack and crashing Python." ); From jackjansen@users.sourceforge.net Wed Jun 26 21:40:47 2002 From: jackjansen@users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed, 26 Jun 2002 13:40:47 -0700 Subject: [Python-checkins] python/dist/src/Modules cPickle.c,2.85,2.86 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv19642/Modules Modified Files: cPickle.c Log Message: Undefine TRUE and FALSE before redefining them. Index: cPickle.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cPickle.c,v retrieving revision 2.85 retrieving revision 2.86 diff -C2 -d -r2.85 -r2.86 *** cPickle.c 13 Jun 2002 20:32:48 -0000 2.85 --- cPickle.c 26 Jun 2002 20:40:42 -0000 2.86 *************** *** 77,81 **** --- 77,83 ---- #define EMPTY_TUPLE ')' #define SETITEMS 'u' + #undef TRUE #define TRUE "I01\n" + #undef FALSE #define FALSE "I00\n" From jackjansen@users.sourceforge.net Wed Jun 26 21:41:35 2002 From: jackjansen@users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed, 26 Jun 2002 13:41:35 -0700 Subject: [Python-checkins] python/dist/src/Modules pypcre.c,2.24,2.25 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv19881/Modules Modified Files: pypcre.c Log Message: Undefine DPRINTF before defining it, there was a conflict with some other definition. Index: pypcre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/pypcre.c,v retrieving revision 2.24 retrieving revision 2.25 diff -C2 -d -r2.24 -r2.25 *** pypcre.c 12 Apr 2002 07:22:56 -0000 2.24 --- pypcre.c 26 Jun 2002 20:41:30 -0000 2.25 *************** *** 578,581 **** --- 578,582 ---- indented pre-processor statements. I suppose it's only been 10 years... */ + #undef DPRINTF #ifdef DEBUG #define DPRINTF(p) printf p From jackjansen@users.sourceforge.net Wed Jun 26 21:43:26 2002 From: jackjansen@users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed, 26 Jun 2002 13:43:26 -0700 Subject: [Python-checkins] python/dist/src/Mac/Compat sync.c,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Compat In directory usw-pr-cvs1:/tmp/cvs-serv20741/Mac/Compat Modified Files: sync.c Log Message: Make the prototype match the declaration in the GUSI header files. Index: sync.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Compat/sync.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** sync.c 11 Jul 2000 21:15:38 -0000 1.2 --- sync.c 26 Jun 2002 20:43:24 -0000 1.3 *************** *** 6,17 **** #include "macdefs.h" ! int sync(void) { if (FlushVol((StringPtr)0, 0) == noErr) ! return 0; else { errno= ENODEV; ! return -1; } } --- 6,17 ---- #include "macdefs.h" ! void sync(void) { if (FlushVol((StringPtr)0, 0) == noErr) ! return; else { errno= ENODEV; ! return; } } From fdrake@users.sourceforge.net Wed Jun 26 22:25:18 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed, 26 Jun 2002 14:25:18 -0700 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.165,1.166 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory usw-pr-cvs1:/tmp/cvs-serv6881/tut Modified Files: tut.tex Log Message: Fix typo reported to python-docs. Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.165 retrieving revision 1.166 diff -C2 -d -r1.165 -r1.166 *** tut.tex 25 Jun 2002 15:13:18 -0000 1.165 --- tut.tex 26 Jun 2002 21:25:15 -0000 1.166 *************** *** 1827,1831 **** The resulting list definition tends often to be clearer than lists built using those constructs. Each list comprehension consists of an expression ! following by a \keyword{for} clause, then zero or more \keyword{for} or \keyword{if} clauses. The result will be a list resulting from evaluating the expression in the context of the \keyword{for} and \keyword{if} clauses --- 1827,1831 ---- The resulting list definition tends often to be clearer than lists built using those constructs. Each list comprehension consists of an expression ! followed by a \keyword{for} clause, then zero or more \keyword{for} or \keyword{if} clauses. The result will be a list resulting from evaluating the expression in the context of the \keyword{for} and \keyword{if} clauses From fdrake@users.sourceforge.net Wed Jun 26 22:43:45 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed, 26 Jun 2002 14:43:45 -0700 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.156.4.1.2.5,1.156.4.1.2.6 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory usw-pr-cvs1:/tmp/cvs-serv11698/tut Modified Files: Tag: release22-maint tut.tex Log Message: Fix typo reported to python-docs. Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.156.4.1.2.5 retrieving revision 1.156.4.1.2.6 diff -C2 -d -r1.156.4.1.2.5 -r1.156.4.1.2.6 *** tut.tex 25 Jun 2002 15:21:02 -0000 1.156.4.1.2.5 --- tut.tex 26 Jun 2002 21:43:42 -0000 1.156.4.1.2.6 *************** *** 1827,1831 **** The resulting list definition tends often to be clearer than lists built using those constructs. Each list comprehension consists of an expression ! following by a \keyword{for} clause, then zero or more \keyword{for} or \keyword{if} clauses. The result will be a list resulting from evaluating the expression in the context of the \keyword{for} and \keyword{if} clauses --- 1827,1831 ---- The resulting list definition tends often to be clearer than lists built using those constructs. Each list comprehension consists of an expression ! followed by a \keyword{for} clause, then zero or more \keyword{for} or \keyword{if} clauses. The result will be a list resulting from evaluating the expression in the context of the \keyword{for} and \keyword{if} clauses From neal@metaslash.com Wed Jun 26 22:46:19 2002 From: neal@metaslash.com (Neal Norwitz) Date: Wed, 26 Jun 2002 17:46:19 -0400 Subject: [Python-checkins] python/dist/src/Lib cgitb.py,1.4,1.5 References: Message-ID: <3D1A362B.F3D2D585@metaslash.com> ping@users.sourceforge.net wrote: > > Update of /cvsroot/python/python/dist/src/Lib > > Modified Files: > cgitb.py > + if name[:1] == '_': continue Any reason not to use: if name.startswith('_'): continue ? Neal From fdrake@users.sourceforge.net Wed Jun 26 22:49:38 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed, 26 Jun 2002 14:49:38 -0700 Subject: [Python-checkins] python/dist/src/Doc/ref refa1.tex,1.9.8.2,1.9.8.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv13391/ref Modified Files: Tag: release22-maint refa1.tex Log Message: Fix various typos reported to python-docs. Index: refa1.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/refa1.tex,v retrieving revision 1.9.8.2 retrieving revision 1.9.8.3 diff -C2 -d -r1.9.8.2 -r1.9.8.3 *** refa1.tex 15 Mar 2002 23:18:05 -0000 1.9.8.2 --- refa1.tex 26 Jun 2002 21:49:36 -0000 1.9.8.3 *************** *** 161,168 **** \indexii{nested}{scopes} ! This section defines the new scoping semantics that will be introduced ! in Python 2.2. They are available in Python 2.1 by using the future statement \samp{nested_scopes}. This section begins with a bit of ! terminology. \subsection{Definitions and rules \label{definitions}} --- 161,168 ---- \indexii{nested}{scopes} ! This section defines the new scoping semantics that were introduced ! in Python 2.2. They were available in Python 2.1 by using the future statement \samp{nested_scopes}. This section begins with a bit of ! terminology. \subsection{Definitions and rules \label{definitions}} *************** *** 178,182 **** A \dfn{scope} defines the visibility of a name within a block. If a ! local variable is defined in a block, it's scope includes that block. If the definition occurs in a function block, the scope extends to any blocks contained within the defining one, unless a contained block --- 178,182 ---- A \dfn{scope} defines the visibility of a name within a block. If a ! local variable is defined in a block, its scope includes that block. If the definition occurs in a function block, the scope extends to any blocks contained within the defining one, unless a contained block From fdrake@users.sourceforge.net Wed Jun 26 22:52:29 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed, 26 Jun 2002 14:52:29 -0700 Subject: [Python-checkins] python/dist/src/Doc/ref ref4.tex,1.32,1.33 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory usw-pr-cvs1:/tmp/cvs-serv14227/ref Modified Files: ref4.tex Log Message: Fix various typos reported to python-docs. Index: ref4.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref4.tex,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** ref4.tex 20 Jun 2002 20:55:29 -0000 1.32 --- ref4.tex 26 Jun 2002 21:52:26 -0000 1.33 *************** *** 33,37 **** A \dfn{scope}\index{scope} defines the visibility of a name within a ! block. If a local variable is defined in a block, it's scope includes that block. If the definition occurs in a function block, the scope extends to any blocks contained within the defining one, unless a --- 33,37 ---- A \dfn{scope}\index{scope} defines the visibility of a name within a ! block. If a local variable is defined in a block, its scope includes that block. If the definition occurs in a function block, the scope extends to any blocks contained within the defining one, unless a From nnorwitz@users.sourceforge.net Wed Jun 26 23:05:35 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Wed, 26 Jun 2002 15:05:35 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils sysconfig.py,1.48,1.49 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv17567/Lib/distutils Modified Files: sysconfig.py Log Message: Whitespace normalization (remove tabs) Index: sysconfig.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/sysconfig.py,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** sysconfig.py 26 Jun 2002 15:42:49 -0000 1.48 --- sysconfig.py 26 Jun 2002 22:05:33 -0000 1.49 *************** *** 67,74 **** return os.path.join(prefix, "include") elif os.name == "mac": ! if plat_specific: ! return os.path.join(prefix, "Mac", "Include") ! else: ! return os.path.join(prefix, "Include") elif os.name == "os2": return os.path.join(prefix, "Include") --- 67,74 ---- return os.path.join(prefix, "include") elif os.name == "mac": ! if plat_specific: ! return os.path.join(prefix, "Mac", "Include") ! else: ! return os.path.join(prefix, "Include") elif os.name == "os2": return os.path.join(prefix, "Include") From jackjansen@users.sourceforge.net Wed Jun 26 23:06:10 2002 From: jackjansen@users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Wed, 26 Jun 2002 15:06:10 -0700 Subject: [Python-checkins] python/dist/src/Mac/scripts fullbuild.py,1.80,1.81 genpluginprojects.py,1.31,1.32 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/scripts In directory usw-pr-cvs1:/tmp/cvs-serv17483 Modified Files: fullbuild.py genpluginprojects.py Log Message: Disabled non-carbon builds (for the moment still optional) and made these scripts work with the new precompiled headers. Index: fullbuild.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/scripts/fullbuild.py,v retrieving revision 1.80 retrieving revision 1.81 diff -C2 -d -r1.80 -r1.81 *** fullbuild.py 22 Jan 2002 23:24:41 -0000 1.80 --- fullbuild.py 26 Jun 2002 22:06:08 -0000 1.81 *************** *** 10,13 **** --- 10,15 ---- # script, rebuilding running programs does not work... + CARBON_ONLY = 1 + MACBUILDNO=":Mac:Include:macbuildno.h" *************** *** 25,37 **** from Carbon import AppleEvents ! OLDAESUPPORT = 0 ! ! if OLDAESUPPORT: ! from Metrowerks_Shell_Suite import Metrowerks_Shell_Suite ! from CodeWarrior_suite import CodeWarrior_suite ! from Metrowerks_Standard_Suite import Metrowerks_Standard_Suite ! from Required_Suite import Required_Suite ! else: ! import CodeWarrior from Carbon import Res --- 27,31 ---- from Carbon import AppleEvents ! import CodeWarrior from Carbon import Res *************** *** 75,90 **** N_BUTTONS=27 ! if OLDAESUPPORT: ! class MwShell(Metrowerks_Shell_Suite, CodeWarrior_suite, Metrowerks_Standard_Suite, ! Required_Suite, aetools.TalkTo): ! pass else: ! MwShell = CodeWarrior.CodeWarrior ! RUNNING=[] def buildmwproject(top, creator, projects): """Build projects with an MW compiler""" ! mgr = MwShell(creator, start=1) mgr.send_timeout = AppleEvents.kNoTimeOut --- 69,90 ---- N_BUTTONS=27 ! if CARBON_ONLY: ! BUTTONS_DISABLE = [ ! I_PPC_EXTLIBS, ! I_PPC_CORE, ! I_PPC_PLUGINS, ! I_PPC_EXTENSIONS, ! I_INTERPRETER, ! I_PPC_FULL, ! I_PPC_SMALL, ! ] else: ! BUTTONS_DISABLE = [] ! RUNNING=[] def buildmwproject(top, creator, projects): """Build projects with an MW compiler""" ! mgr = CodeWarrior.CodeWarrior(creator, start=1) mgr.send_timeout = AppleEvents.kNoTimeOut *************** *** 178,181 **** --- 178,184 ---- d.SetDialogCancelItem(I_CANCEL) results = [0]*N_BUTTONS + for n in BUTTONS_DISABLE: + ctl = d.GetDialogItemAsControl(n) + ctl.HideControl() while 1: n = Dlg.ModalDialog(None) Index: genpluginprojects.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/scripts/genpluginprojects.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** genpluginprojects.py 23 May 2002 22:33:56 -0000 1.31 --- genpluginprojects.py 26 Jun 2002 22:06:08 -0000 1.32 *************** *** 4,7 **** --- 4,9 ---- import string + CARBON_ONLY=1 + PYTHONDIR = sys.prefix PROJECTDIR = os.path.join(PYTHONDIR, ":Mac:Build") *************** *** 39,42 **** --- 41,46 ---- libraryflags=None, stdlibraryflags=None, prefixname=None, initialize=None): + if CARBON_ONLY and architecture == "ppc": + return if architecture == "all": # For the time being we generate two project files. Not as nice as *************** *** 83,87 **** pass elif architecture == "carbon": ! prefixname = "mwerks_carbonplugin_config.h" else: prefixname = "mwerks_plugin_config.h" --- 87,91 ---- pass elif architecture == "carbon": ! prefixname = "mwerks_shcarbon_pch" else: prefixname = "mwerks_plugin_config.h" *************** *** 113,122 **** sources=["pyexpat.c", "xmlparse.c", "xmlrole.c", "xmltok.c"], extradirs=[":::Modules:expat"], ! prefixname="mwerks_pyexpat_config.h" ) genpluginproject("carbon", "pyexpat", sources=["pyexpat.c", "xmlparse.c", "xmlrole.c", "xmltok.c"], extradirs=[":::Modules:expat"], ! prefixname="mwerks_carbonpyexpat_config.h" ) genpluginproject("all", "zlib", --- 117,126 ---- sources=["pyexpat.c", "xmlparse.c", "xmlrole.c", "xmltok.c"], extradirs=[":::Modules:expat"], ! prefixname="mwerks_shared_config.h" ) genpluginproject("carbon", "pyexpat", sources=["pyexpat.c", "xmlparse.c", "xmlrole.c", "xmltok.c"], extradirs=[":::Modules:expat"], ! prefixname="mwerks_shcarbon_config.h" ) genpluginproject("all", "zlib", *************** *** 195,199 **** libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") # Carbon Only? ! genpluginproject("carbon", "_CF", outputdir="::Lib:Carbon") genpluginproject("carbon", "_CarbonEvt", outputdir="::Lib:Carbon") genpluginproject("carbon", "hfsplus") --- 199,203 ---- libraryflags="Debug, WeakImport", outputdir="::Lib:Carbon") # Carbon Only? ! genpluginproject("carbon", "_CF", sources=[":cf:_CFmodule.c", ":cf:pycfbridge.c"], outputdir="::Lib:Carbon") genpluginproject("carbon", "_CarbonEvt", outputdir="::Lib:Carbon") genpluginproject("carbon", "hfsplus") From fredrik@pythonware.com Wed Jun 26 23:17:10 2002 From: fredrik@pythonware.com (Fredrik Lundh) Date: Thu, 27 Jun 2002 00:17:10 +0200 Subject: [Python-checkins] python/dist/src/Lib cgitb.py,1.4,1.5 References: <3D1A362B.F3D2D585@metaslash.com> Message-ID: <003901c21d5f$3970af20$ced241d5@hagrid> > ping@users.sourceforge.net wrote: > > > > Update of /cvsroot/python/python/dist/src/Lib > > > > Modified Files: > > cgitb.py > > > + if name[:1] == '_': continue > > Any reason not to use: > > if name.startswith('_'): continue > > ? tried benchmarking? in CPython, startswith() is an improvement only if you don't know the prefix length, or if you are too lazy to figure it out and won't use the program much anyway... and figuring out that "_" is exactly one character long isn't that hard, really. (can we please cut this python newspeak enforcement crap now, btw. even if slicing hadn't been much faster, there's nothing wrong with using an idiom that has worked perfectly fine for the last decade...) From nnorwitz@users.sourceforge.net Wed Jun 26 23:32:49 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Wed, 26 Jun 2002 15:32:49 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libdis.tex,1.36,1.37 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv24512/Doc/lib Modified Files: libdis.tex Log Message: dis.dis() also supports modules Index: libdis.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdis.tex,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** libdis.tex 13 Jun 2002 17:59:51 -0000 1.36 --- libdis.tex 26 Jun 2002 22:32:47 -0000 1.37 *************** *** 39,43 **** \begin{funcdesc}{dis}{\optional{bytesource}} Disassemble the \var{bytesource} object. \var{bytesource} can denote ! either a class, a method, a function, or a code object. For a class, it disassembles all methods. For a single code sequence, it prints one line per byte code instruction. If no object is provided, it --- 39,44 ---- \begin{funcdesc}{dis}{\optional{bytesource}} Disassemble the \var{bytesource} object. \var{bytesource} can denote ! either a module, a class, a method, a function, or a code object. ! For a module, it disassembles all functions. For a class, it disassembles all methods. For a single code sequence, it prints one line per byte code instruction. If no object is provided, it From nnorwitz@users.sourceforge.net Wed Jun 26 23:37:31 2002 From: nnorwitz@users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Wed, 26 Jun 2002 15:37:31 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libdis.tex,1.33.10.1,1.33.10.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv26018/Doc/lib Modified Files: Tag: release22-maint libdis.tex Log Message: Backport 1.37: dis.dis() also supports modules, (also backport other changes back to 1.33 since these all apply to 2.2) Index: libdis.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdis.tex,v retrieving revision 1.33.10.1 retrieving revision 1.33.10.2 diff -C2 -d -r1.33.10.1 -r1.33.10.2 *** libdis.tex 28 Mar 2002 19:35:33 -0000 1.33.10.1 --- libdis.tex 26 Jun 2002 22:37:28 -0000 1.33.10.2 *************** *** 39,43 **** \begin{funcdesc}{dis}{\optional{bytesource}} Disassemble the \var{bytesource} object. \var{bytesource} can denote ! either a class, a method, a function, or a code object. For a class, it disassembles all methods. For a single code sequence, it prints one line per byte code instruction. If no object is provided, it --- 39,44 ---- \begin{funcdesc}{dis}{\optional{bytesource}} Disassemble the \var{bytesource} object. \var{bytesource} can denote ! either a module, a class, a method, a function, or a code object. ! For a module, it disassembles all functions. For a class, it disassembles all methods. For a single code sequence, it prints one line per byte code instruction. If no object is provided, it *************** *** 167,170 **** --- 168,175 ---- \end{opcodedesc} + \begin{opcodedesc}{GET_ITER}{} + Implements \code{TOS = iter(TOS)}. + \end{opcodedesc} + Binary operations remove the top of the stack (TOS) and the second top-most stack item (TOS1) from the stack. They perform the operation, and put the *************** *** 180,184 **** \begin{opcodedesc}{BINARY_DIVIDE}{} ! Implements \code{TOS = TOS1 / TOS}. \end{opcodedesc} --- 185,199 ---- \begin{opcodedesc}{BINARY_DIVIDE}{} ! Implements \code{TOS = TOS1 / TOS} when ! \code{from __future__ import division} is not in effect. ! \end{opcodedesc} ! ! \begin{opcodedesc}{BINARY_FLOOR_DIVIDE}{} ! Implements \code{TOS = TOS1 // TOS}. ! \end{opcodedesc} ! ! \begin{opcodedesc}{BINARY_TRUE_DIVIDE}{} ! Implements \code{TOS = TOS1 / TOS} when ! \code{from __future__ import division} is in effect. \end{opcodedesc} *************** *** 233,237 **** \begin{opcodedesc}{INPLACE_DIVIDE}{} ! Implements in-place \code{TOS = TOS1 / TOS}. \end{opcodedesc} --- 248,262 ---- \begin{opcodedesc}{INPLACE_DIVIDE}{} ! Implements in-place \code{TOS = TOS1 / TOS} when ! \code{from __future__ import division} is not in effect. ! \end{opcodedesc} ! ! \begin{opcodedesc}{INPLACE_FLOOR_DIVIDE}{} ! Implements in-place \code{TOS = TOS1 // TOS}. ! \end{opcodedesc} ! ! \begin{opcodedesc}{INPLACE_TRUE_DIVIDE}{} ! Implements in-place \code{TOS = TOS1 / TOS} when ! \code{from __future__ import division} is in effect. \end{opcodedesc} *************** *** 329,332 **** --- 354,359 ---- \end{opcodedesc} + Miscellaneous opcodes. + \begin{opcodedesc}{PRINT_EXPR}{} Implements the expression statement for the interactive mode. TOS is *************** *** 360,363 **** --- 387,396 ---- \end{opcodedesc} + \begin{opcodedesc}{CONTINUE_LOOP}{target} + Continues a loop due to a \keyword{continue} statement. \var{target} + is the address to jump to (which should be a \code{FOR_ITER} + instruction). + \end{opcodedesc} + \begin{opcodedesc}{LOAD_LOCALS}{} Pushes a reference to the locals of the current scope on the stack. *************** *** 370,373 **** --- 403,410 ---- \end{opcodedesc} + \begin{opcodedesc}{YIELD_VALUE}{} + Pops \code{TOS} and yields it from a generator. + \end{opcodedesc} + \begin{opcodedesc}{IMPORT_STAR}{} Loads all symbols not starting with \character{_} directly from the module TOS *************** *** 514,523 **** \end{opcodedesc} ! \begin{opcodedesc}{FOR_LOOP}{delta} ! Iterate over a sequence. TOS is the current index, TOS1 the sequence. ! First, the next element is computed. If the sequence is exhausted, ! increment byte code counter by \var{delta}. Otherwise, push the ! sequence, the incremented counter, and the current item onto the stack. \end{opcodedesc} %\begin{opcodedesc}{LOAD_LOCAL}{namei} --- 551,564 ---- \end{opcodedesc} ! \begin{opcodedesc}{FOR_ITER}{delta} ! \code{TOS} is an iterator. Call its \method{next()} method. If this ! yields a new value, push it on the stack (leaving the iterator below ! it). If the iterator indicates it is exhausted \code{TOS} is ! popped, and the byte code counter is incremented by \var{delta}. \end{opcodedesc} + + %\begin{opcodedesc}{FOR_LOOP}{delta} + %This opcode is obsolete. + %\end{opcodedesc} %\begin{opcodedesc}{LOAD_LOCAL}{namei} From neal@metaslash.com Thu Jun 27 00:05:03 2002 From: neal@metaslash.com (Neal Norwitz) Date: Wed, 26 Jun 2002 19:05:03 -0400 Subject: [Python-checkins] Using string methods in stdlib References: <3D1A362B.F3D2D585@metaslash.com> <003901c21d5f$3970af20$ced241d5@hagrid> Message-ID: <3D1A489F.93B8942B@metaslash.com> (moved to python-dev and changed title) Fredrik Lundh wrote: > > > ping@users.sourceforge.net wrote: > > > > > > Update of /cvsroot/python/python/dist/src/Lib > > > > > > Modified Files: > > > cgitb.py > > > > > + if name[:1] == '_': continue > > > > Any reason not to use: > > > > if name.startswith('_'): continue > > > > ? > > tried benchmarking? I wasn't asking because of speed. I don't know which version is faster and I couldn't care less. I think using the method is clearer. > and figuring out that "_" is exactly one character long isn't > that hard, really. I agree that for a single character either way is clear. > (can we please cut this python newspeak enforcement crap > now, btw. even if slicing hadn't been much faster, there's > nothing wrong with using an idiom that has worked perfectly > fine for the last decade...) I thought the stdlib used startswith/endswith. But I did a simple grep just to find where startswith could be used and was surprised to find about 150 cases. Many are 1 char, but there are many others of 5+ chars which make it harder to determine immediately if the code is correct. I also see several cases of code like this in mimify: line[:len(prefix)] == prefix and other places where the length is calculated elsewhere, (rlcompleter) making it even harder to verify correctness. Part of the reason to prefer the methods is for defensive programming. There is duplicate information by using slicing (str & length) and it's possible to change half the information and not the other, leading to bugs. That's not possible with the methods. I don't think the stdlib should use every new feature. But I do think it should reflect the best programming practices and should be programmed defensively in order to try to avoid future bugs. Neal From fdrake@users.sourceforge.net Thu Jun 27 19:30:37 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu, 27 Jun 2002 11:30:37 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libcurses.tex,1.38,1.39 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv32249 Modified Files: libcurses.tex Log Message: Clean up some markup. Index: libcurses.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcurses.tex,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** libcurses.tex 26 Dec 2001 22:08:44 -0000 1.38 --- libcurses.tex 27 Jun 2002 18:30:34 -0000 1.39 *************** *** 389,400 **** \begin{funcdesc}{pair_content}{pair_number} ! Returns a tuple \var{(fg,bg)} containing the colors for the requested ! color pair. The value of \var{pair_number} must be between 0 and ! COLOR_PAIRS-1. \end{funcdesc} \begin{funcdesc}{pair_number}{attr} ! Returns the number of the color-pair set by the attribute value \var{attr}. ! \function{color_pair()} is the counterpart to this function. \end{funcdesc} --- 389,401 ---- \begin{funcdesc}{pair_content}{pair_number} ! Returns a tuple \code{(\var{fg}, \var{bg})} containing the colors for ! the requested color pair. The value of \var{pair_number} must be ! between \code{0} and \code{\constant{COLOR_PAIRS} - 1}. \end{funcdesc} \begin{funcdesc}{pair_number}{attr} ! Returns the number of the color-pair set by the attribute value ! \var{attr}. \function{color_pair()} is the counterpart to this ! function. \end{funcdesc} From fdrake@users.sourceforge.net Thu Jun 27 19:38:10 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu, 27 Jun 2002 11:38:10 -0700 Subject: [Python-checkins] python/dist/src/Doc/tools py2texi.el,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tools In directory usw-pr-cvs1:/tmp/cvs-serv2183 Modified Files: py2texi.el Log Message: Added support for some of the more recently defined macros and environments. Index: py2texi.el =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tools/py2texi.el,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** py2texi.el 3 May 2002 04:50:51 -0000 1.1 --- py2texi.el 27 Jun 2002 18:38:06 -0000 1.2 *************** *** 75,78 **** --- 75,82 ---- "\n@table @code\n@item \\1\n@obindex \\1\n") "@end table") + ("cmemberdesc" 3 + (progn (setq findex t) + "\n@table @code\n@item \\1 \\2 \\3\n@findex \\3\n") + "@end table") ("csimplemacrodesc" 1 (progn (setq cindex t) *************** *** 197,200 **** --- 201,207 ---- ("cdata" 1 "@code{\\1}") ("centerline" 1 "@center \\1") + ("cfuncline" 3 + (progn (setq findex t) + "\n@item \\1 \\2(\\3)\n@findex \\2\n")) ("cfunction" 1 "@code{\\1}") ("chapter" 1 (format "@node \\1\n@%s \\1\n" *************** *** 204,207 **** --- 211,217 ---- ("citetitle" 1 "@ref{Top,,,\\1}") ("class" 1 "@code{\\1}") + ("cmemberline" 3 + (progn (setq findex t) + "\n@item \\1 \\2 \\3\n@findex \\3\n")) ("code" 1 "@code{\\1}") ("command" 1 "@command{\\1}") *************** *** 209,212 **** --- 219,223 ---- ("copyright" 1 "@copyright{}") ("Cpp" 0 "C++") + ("csimplemacro" 1 "@code{\\1}") ("ctype" 1 "@code{\\1}") ("dataline" 1 (progn (setq findex t) "@item \\1\n@findex \\1\n")) *************** *** 298,301 **** --- 309,313 ---- ("POSIX" 0 "POSIX") ("production" 2 "@item \\1 \\2") + ("productioncont" 1 "@item \\1") ("program" 1 "@command{\\1}") ("programopt" 1 "@option{\\1}") *************** *** 349,352 **** --- 361,366 ---- ("textasciicircum" 0 "^") ("textbackslash" 0 "@backslash{}") + ("textgreater" 0 ">") + ("textless" 0 "<") ("textrm" 1 "\\1") ("texttt" 1 "@code{\\1}") From fdrake@users.sourceforge.net Thu Jun 27 20:40:51 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu, 27 Jun 2002 12:40:51 -0700 Subject: [Python-checkins] python/dist/src/Modules pyexpat.c,2.60,2.61 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv20596/Modules Modified Files: pyexpat.c Log Message: Integrate the changes from PyXML's version of pyexpat.c revisions 1.47, 1.48, 1.49 (name interning support). Index: pyexpat.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/pyexpat.c,v retrieving revision 2.60 retrieving revision 2.61 diff -C2 -d -r2.60 -r2.61 *** pyexpat.c 13 Jun 2002 20:32:52 -0000 2.60 --- pyexpat.c 27 Jun 2002 19:40:48 -0000 2.61 *************** *** 61,64 **** --- 61,65 ---- int specified_attributes; /* Report only specified attributes. */ int in_callback; /* Is a callback active? */ + PyObject *intern; /* Dictionary to intern strings */ PyObject **handlers; } xmlparseobject; *************** *** 124,128 **** static PyObject * ! conv_string_to_unicode(XML_Char *str) { /* XXX currently this code assumes that XML_Char is 8-bit, --- 125,129 ---- static PyObject * ! conv_string_to_unicode(const XML_Char *str) { /* XXX currently this code assumes that XML_Char is 8-bit, *************** *** 133,138 **** return Py_None; } ! return PyUnicode_DecodeUTF8((const char *)str, ! strlen((const char *)str), "strict"); } --- 134,138 ---- return Py_None; } ! return PyUnicode_DecodeUTF8(str, strlen(str), "strict"); } *************** *** 156,160 **** static PyObject * ! conv_string_to_utf8(XML_Char *str) { /* XXX currently this code assumes that XML_Char is 8-bit, --- 156,160 ---- static PyObject * ! conv_string_to_utf8(const XML_Char *str) { /* XXX currently this code assumes that XML_Char is 8-bit, *************** *** 165,169 **** return Py_None; } ! return PyString_FromString((const char *)str); } --- 165,169 ---- return Py_None; } ! return PyString_FromString(str); } *************** *** 276,279 **** --- 276,298 ---- #endif + static PyObject* + string_intern(xmlparseobject *self, const char* str) + { + PyObject *result = STRING_CONV_FUNC(str); + PyObject *value; + if (!self->intern) + return result; + value = PyDict_GetItem(self->intern, result); + if (!value) { + if (PyDict_SetItem(self->intern, result, result) == 0) + return result; + else + return NULL; + } + Py_INCREF(value); + Py_DECREF(result); + return value; + } + static void my_StartElementHandler(void *userData, *************** *** 308,312 **** } for (i = 0; i < max; i += 2) { ! PyObject *n = STRING_CONV_FUNC((XML_Char *) atts[i]); PyObject *v; if (n == NULL) { --- 327,331 ---- } for (i = 0; i < max; i += 2) { ! PyObject *n = string_intern(self, (XML_Char *) atts[i]); PyObject *v; if (n == NULL) { *************** *** 337,341 **** } } ! args = Py_BuildValue("(O&N)", STRING_CONV_FUNC,name, container); if (args == NULL) { Py_DECREF(container); --- 356,360 ---- } } ! args = Py_BuildValue("(NN)", string_intern(self, name), container); if (args == NULL) { Py_DECREF(container); *************** *** 395,399 **** VOID_HANDLER(EndElement, (void *userData, const XML_Char *name), ! ("(O&)", STRING_CONV_FUNC, name)) VOID_HANDLER(ProcessingInstruction, --- 414,418 ---- VOID_HANDLER(EndElement, (void *userData, const XML_Char *name), ! ("(N)", string_intern(self, name))) VOID_HANDLER(ProcessingInstruction, *************** *** 401,405 **** const XML_Char *target, const XML_Char *data), ! ("(O&O&)",STRING_CONV_FUNC,target, STRING_CONV_FUNC,data)) #ifndef Py_USING_UNICODE --- 420,424 ---- const XML_Char *target, const XML_Char *data), ! ("(NO&)", string_intern(self, target), STRING_CONV_FUNC,data)) #ifndef Py_USING_UNICODE *************** *** 422,429 **** const XML_Char *publicId, const XML_Char *notationName), ! ("(O&O&O&O&O&)", ! STRING_CONV_FUNC,entityName, STRING_CONV_FUNC,base, ! STRING_CONV_FUNC,systemId, STRING_CONV_FUNC,publicId, ! STRING_CONV_FUNC,notationName)) #ifndef Py_USING_UNICODE --- 441,448 ---- const XML_Char *publicId, const XML_Char *notationName), ! ("(NNNNN)", ! string_intern(self, entityName), string_intern(self, base), ! string_intern(self, systemId), string_intern(self, publicId), ! string_intern(self, notationName))) #ifndef Py_USING_UNICODE *************** *** 438,446 **** const XML_Char *publicId, const XML_Char *notationName), ! ("O&iNO&O&O&O&", ! STRING_CONV_FUNC,entityName, is_parameter_entity, conv_string_len_to_utf8(value, value_length), ! STRING_CONV_FUNC,base, STRING_CONV_FUNC,systemId, ! STRING_CONV_FUNC,publicId, STRING_CONV_FUNC,notationName)) #else VOID_HANDLER(EntityDecl, --- 457,466 ---- const XML_Char *publicId, const XML_Char *notationName), ! ("NiNNNNN", ! string_intern(self, entityName), is_parameter_entity, conv_string_len_to_utf8(value, value_length), ! string_intern(self, base), string_intern(self, systemId), ! string_intern(self, publicId), ! string_intern(self, notationName))) #else VOID_HANDLER(EntityDecl, *************** *** 454,464 **** const XML_Char *publicId, const XML_Char *notationName), ! ("O&iNO&O&O&O&", ! STRING_CONV_FUNC,entityName, is_parameter_entity, (self->returns_unicode ? conv_string_len_to_unicode(value, value_length) : conv_string_len_to_utf8(value, value_length)), ! STRING_CONV_FUNC,base, STRING_CONV_FUNC,systemId, ! STRING_CONV_FUNC,publicId, STRING_CONV_FUNC,notationName)) #endif --- 474,485 ---- const XML_Char *publicId, const XML_Char *notationName), ! ("NiNNNNN", ! string_intern(self, entityName), is_parameter_entity, (self->returns_unicode ? conv_string_len_to_unicode(value, value_length) : conv_string_len_to_utf8(value, value_length)), ! string_intern(self, base), string_intern(self, systemId), ! string_intern(self, publicId), ! string_intern(self, notationName))) #endif *************** *** 474,478 **** static PyObject * conv_content_model(XML_Content * const model, ! PyObject *(*conv_string)(XML_Char *)) { PyObject *result = NULL; --- 495,499 ---- static PyObject * conv_content_model(XML_Content * const model, ! PyObject *(*conv_string)(const XML_Char *)) { PyObject *result = NULL; *************** *** 515,520 **** const XML_Char *name, XML_Content *model), ! ("O&O&", ! STRING_CONV_FUNC,name, (self->returns_unicode ? conv_content_model_unicode : conv_content_model_utf8),model)) --- 536,541 ---- const XML_Char *name, XML_Content *model), ! ("NO&", ! string_intern(self, name), (self->returns_unicode ? conv_content_model_unicode : conv_content_model_utf8),model)) *************** *** 524,529 **** const XML_Char *name, XML_Content *model), ! ("O&O&", ! STRING_CONV_FUNC,name, conv_content_model_utf8,model)) #endif --- 545,550 ---- const XML_Char *name, XML_Content *model), ! ("NO&", ! string_intern(self, name), conv_content_model_utf8,model)) #endif *************** *** 535,540 **** const XML_Char *dflt, int isrequired), ! ("(O&O&O&O&i)", ! STRING_CONV_FUNC,elname, STRING_CONV_FUNC,attname, STRING_CONV_FUNC,att_type, STRING_CONV_FUNC,dflt, isrequired)) --- 556,561 ---- const XML_Char *dflt, int isrequired), ! ("(NNO&O&i)", ! string_intern(self, elname), string_intern(self, attname), STRING_CONV_FUNC,att_type, STRING_CONV_FUNC,dflt, isrequired)) *************** *** 546,552 **** const XML_Char *systemId, const XML_Char *publicId), ! ("(O&O&O&O&)", ! STRING_CONV_FUNC,notationName, STRING_CONV_FUNC,base, ! STRING_CONV_FUNC,systemId, STRING_CONV_FUNC,publicId)) VOID_HANDLER(StartNamespaceDecl, --- 567,573 ---- const XML_Char *systemId, const XML_Char *publicId), ! ("(NNNN)", ! string_intern(self, notationName), string_intern(self, base), ! string_intern(self, systemId), string_intern(self, publicId))) VOID_HANDLER(StartNamespaceDecl, *************** *** 554,567 **** const XML_Char *prefix, const XML_Char *uri), ! ("(O&O&)", STRING_CONV_FUNC,prefix, STRING_CONV_FUNC,uri)) VOID_HANDLER(EndNamespaceDecl, (void *userData, const XML_Char *prefix), ! ("(O&)", STRING_CONV_FUNC,prefix)) VOID_HANDLER(Comment, ! (void *userData, const XML_Char *prefix), ! ("(O&)", STRING_CONV_FUNC,prefix)) VOID_HANDLER(StartCdataSection, --- 575,589 ---- const XML_Char *prefix, const XML_Char *uri), ! ("(NN)", ! string_intern(self, prefix), string_intern(self, uri))) VOID_HANDLER(EndNamespaceDecl, (void *userData, const XML_Char *prefix), ! ("(N)", string_intern(self, prefix))) VOID_HANDLER(Comment, ! (void *userData, const XML_Char *data), ! ("(O&)", STRING_CONV_FUNC,data)) VOID_HANDLER(StartCdataSection, *************** *** 606,612 **** const XML_Char *publicId), int rc=0;, ! ("(O&O&O&O&)", ! STRING_CONV_FUNC,context, STRING_CONV_FUNC,base, ! STRING_CONV_FUNC,systemId, STRING_CONV_FUNC,publicId), rc = PyInt_AsLong(rv);, rc, XML_GetUserData(parser)) --- 628,634 ---- const XML_Char *publicId), int rc=0;, ! ("(O&NNN)", ! STRING_CONV_FUNC,context, string_intern(self, base), ! string_intern(self, systemId), string_intern(self, publicId)), rc = PyInt_AsLong(rv);, rc, XML_GetUserData(parser)) *************** *** 618,623 **** const XML_Char *sysid, const XML_Char *pubid, int has_internal_subset), ! ("(O&O&O&i)", STRING_CONV_FUNC,doctypeName, ! STRING_CONV_FUNC,sysid, STRING_CONV_FUNC,pubid, has_internal_subset)) --- 640,645 ---- const XML_Char *sysid, const XML_Char *pubid, int has_internal_subset), ! ("(NNNi)", string_intern(self, doctypeName), ! string_intern(self, sysid), string_intern(self, pubid), has_internal_subset)) *************** *** 857,860 **** --- 879,884 ---- encoding); new_parser->handlers = 0; + new_parser->intern = self->intern; + Py_XINCREF(new_parser->intern); #ifdef Py_TPFLAGS_HAVE_GC PyObject_GC_Track(new_parser); *************** *** 989,993 **** static PyObject * ! newxmlparseobject(char *encoding, char *namespace_separator) { int i; --- 1013,1017 ---- static PyObject * ! newxmlparseobject(char *encoding, char *namespace_separator, PyObject *intern) { int i; *************** *** 1023,1026 **** --- 1047,1052 ---- self->itself = XML_ParserCreate(encoding); } + self->intern = intern; + Py_XINCREF(self->intern); #ifdef Py_TPFLAGS_HAVE_GC PyObject_GC_Track(self); *************** *** 1075,1078 **** --- 1101,1105 ---- free(self->handlers); } + Py_XDECREF(self->intern); #if PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6 /* Code for versions before 1.6 */ *************** *** 1119,1122 **** --- 1146,1159 ---- if (strcmp(name, "specified_attributes") == 0) return PyInt_FromLong((long) self->specified_attributes); + if (strcmp(name, "intern") == 0) { + if (self->intern == NULL) { + Py_INCREF(Py_None); + return Py_None; + } + else { + Py_INCREF(self->intern); + return self->intern; + } + } handlernum = handlername2int(name); *************** *** 1139,1142 **** --- 1176,1180 ---- PyList_Append(rc, PyString_FromString("returns_unicode")); PyList_Append(rc, PyString_FromString("specified_attributes")); + PyList_Append(rc, PyString_FromString("intern")); return rc; *************** *** 1222,1225 **** --- 1260,1265 ---- { clear_handlers(op, 0); + Py_XDECREF(op->intern); + op->intern = 0; return 0; } *************** *** 1276,1283 **** char *encoding = NULL; char *namespace_separator = NULL; ! static char *kwlist[] = {"encoding", "namespace_separator", NULL}; ! if (!PyArg_ParseTupleAndKeywords(args, kw, "|zz:ParserCreate", kwlist, ! &encoding, &namespace_separator)) return NULL; if (namespace_separator != NULL --- 1316,1327 ---- char *encoding = NULL; char *namespace_separator = NULL; ! PyObject *intern = NULL; ! PyObject *result; ! int intern_decref = 0; ! static char *kwlist[] = {"encoding", "namespace_separator", ! "intern", NULL}; ! if (!PyArg_ParseTupleAndKeywords(args, kw, "|zzO:ParserCreate", kwlist, ! &encoding, &namespace_separator, &intern)) return NULL; if (namespace_separator != NULL *************** *** 1288,1292 **** return NULL; } ! return newxmlparseobject(encoding, namespace_separator); } --- 1332,1355 ---- return NULL; } ! /* Explicitly passing None means no interning is desired. ! Not passing anything means that a new dictionary is used. */ ! if (intern == Py_None) ! intern = NULL; ! else if (intern == NULL) { ! intern = PyDict_New(); ! if (!intern) ! return NULL; ! intern_decref = 1; ! } ! else if (!PyDict_Check(intern)) { ! PyErr_SetString(PyExc_TypeError, "intern must be a dictionary"); ! return NULL; ! } ! ! result = newxmlparseobject(encoding, namespace_separator, intern); ! if (intern_decref) { ! Py_DECREF(intern); ! } ! return result; } From fdrake@users.sourceforge.net Thu Jun 27 20:41:53 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu, 27 Jun 2002 12:41:53 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_pyexpat.py,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv20963/Lib/test Modified Files: test_pyexpat.py Log Message: Integrate the tests for name interning from PyXML (test_pyexpat.py revision 1.12 in PyXML). Index: test_pyexpat.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pyexpat.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** test_pyexpat.py 30 Jul 2001 21:47:25 -0000 1.10 --- test_pyexpat.py 27 Jun 2002 19:41:51 -0000 1.11 *************** *** 201,202 **** --- 201,220 ---- # expat.ParserCreate(namespace_separator='') # too short + + # Test the interning machinery. + p = expat.ParserCreate() + L = [] + def collector(name, *args): + L.append(name) + p.StartElementHandler = collector + p.EndElementHandler = collector + p.Parse(" ", 1) + tag = L[0] + if len(L) != 6: + print "L should only contain 6 entries; found", len(L) + for entry in L: + if tag is not entry: + print "expected L to contain many references to the same string", + print "(it didn't)" + print "L =", `L` + break From effbot@users.sourceforge.net Thu Jun 27 20:59:30 2002 From: effbot@users.sourceforge.net (effbot@users.sourceforge.net) Date: Thu, 27 Jun 2002 12:59:30 -0700 Subject: [Python-checkins] python/dist/src/Lib pre.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv24773/Lib Modified Files: pre.py Log Message: Fix bug #570057: Broken pre.subn() (and pre.sub()) This should be backported to the 2.2.X series (how do I do that?) Index: pre.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pre.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** pre.py 16 Apr 2002 01:38:39 -0000 1.12 --- pre.py 27 Jun 2002 19:59:27 -0000 1.13 *************** *** 368,375 **** if type(repl) is type(''): ! # See if repl contains group references try: repl = pcre_expand(_Dummy, repl) ! except error: m = MatchObject(self, source, 0, end, []) repl = lambda m, repl=repl, expand=pcre_expand: expand(m, repl) --- 368,377 ---- if type(repl) is type(''): ! # See if repl contains group references (if it does, ! # pcre_expand will attempt to call _Dummy.group, which ! # results in a TypeError) try: repl = pcre_expand(_Dummy, repl) ! except (error, TypeError): m = MatchObject(self, source, 0, end, []) repl = lambda m, repl=repl, expand=pcre_expand: expand(m, repl) From effbot@users.sourceforge.net Thu Jun 27 21:08:27 2002 From: effbot@users.sourceforge.net (effbot@users.sourceforge.net) Date: Thu, 27 Jun 2002 13:08:27 -0700 Subject: [Python-checkins] python/dist/src/Lib sre_compile.py,1.42,1.43 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv29436/Lib Modified Files: sre_compile.py Log Message: made the code match the comments (1.5.2 compatibility) Index: sre_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** sre_compile.py 2 Jun 2002 00:40:05 -0000 1.42 --- sre_compile.py 27 Jun 2002 20:08:25 -0000 1.43 *************** *** 11,15 **** """Internal support module for sre""" ! import _sre,sys from sre_constants import * --- 11,15 ---- """Internal support module for sre""" ! import _sre, sys from sre_constants import * *************** *** 279,284 **** mapping[i] = new if new == block: ! block += 1 ! data += _mk_bitmap(chunk) header = [block] assert MAXCODE == 65535 --- 279,284 ---- mapping[i] = new if new == block: ! block = block + 1 ! data = data + _mk_bitmap(chunk) header = [block] assert MAXCODE == 65535 From effbot@users.sourceforge.net Thu Jun 27 22:36:23 2002 From: effbot@users.sourceforge.net (effbot@users.sourceforge.net) Date: Thu, 27 Jun 2002 14:36:23 -0700 Subject: [Python-checkins] python/dist/src/Lib xmlrpclib.py,1.18,1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv28316/Lib Modified Files: xmlrpclib.py Log Message: merged with SLAB codebase (version 1.0.1) Index: xmlrpclib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xmlrpclib.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** xmlrpclib.py 2 Jun 2002 03:04:52 -0000 1.18 --- xmlrpclib.py 27 Jun 2002 21:36:21 -0000 1.19 *************** *** 34,43 **** # 2001-10-01 fl Remove containers from memo cache when done with them # 2001-10-01 fl Use faster escape method (80% dumps speedup) # 2001-10-10 sm Allow long ints to be passed as ints if they don't overflow ! # 2001-10-17 sm test for int and long overflow (allows use on 64-bit systems) # 2001-11-12 fl Use repr() to marshal doubles (from Paul Felix) # ! # Copyright (c) 1999-2001 by Secret Labs AB. ! # Copyright (c) 1999-2001 by Fredrik Lundh. # # info@pythonware.com --- 34,50 ---- # 2001-10-01 fl Remove containers from memo cache when done with them # 2001-10-01 fl Use faster escape method (80% dumps speedup) + # 2001-10-02 fl More dumps microtuning + # 2001-10-04 fl Make sure import expat gets a parser (from Guido van Rossum) # 2001-10-10 sm Allow long ints to be passed as ints if they don't overflow ! # 2001-10-17 sm Test for int and long overflow (allows use on 64-bit systems) # 2001-11-12 fl Use repr() to marshal doubles (from Paul Felix) + # 2002-03-17 fl Avoid buffered read when possible (from James Rucker) + # 2002-04-07 fl Added pythondoc comments + # 2002-04-16 fl Added __str__ methods to datetime/binary wrappers + # 2002-05-15 fl Added error constants (from Andrew Kuchling) + # 2002-06-27 fl Merged with Python CVS version # ! # Copyright (c) 1999-2002 by Secret Labs AB. ! # Copyright (c) 1999-2002 by Fredrik Lundh. # # info@pythonware.com *************** *** 47,52 **** # The XML-RPC client interface is # ! # Copyright (c) 1999-2001 by Secret Labs AB ! # Copyright (c) 1999-2001 by Fredrik Lundh # # By obtaining, using, and/or copying this software and/or its --- 54,59 ---- # The XML-RPC client interface is # ! # Copyright (c) 1999-2002 by Secret Labs AB ! # Copyright (c) 1999-2002 by Fredrik Lundh # # By obtaining, using, and/or copying this software and/or its *************** *** 74,84 **** # ! # things to look into: ! # TODO: support basic authentication (see robin's patch) ! # TODO: fix host tuple handling in the server constructor ! # TODO: let transport verify schemes ! # TODO: update documentation ! # TODO: authentication plugins """ --- 81,87 ---- # ! # things to look into some day: ! # TODO: sort out True/False/boolean issues for Python 2.3 """ *************** *** 131,134 **** --- 134,140 ---- from types import * + # -------------------------------------------------------------------- + # Internal stuff + try: unicode *************** *** 147,153 **** return replace(s, ">", ">",) - MAXINT = 2L**31-1 - MININT = -2L**31 - if unicode: def _stringify(string): --- 153,156 ---- *************** *** 161,169 **** return string ! __version__ = "1.0.0" # -------------------------------------------------------------------- # Exceptions class Error(Exception): """Base class for client errors.""" --- 164,199 ---- return string ! __version__ = "1.0.1" ! ! # xmlrpc integer limits ! MAXINT = 2L**31-1 ! MININT = -2L**31 ! ! # -------------------------------------------------------------------- ! # Error constants (from Dan Libby's specification at ! # http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php) ! ! # Ranges of errors ! PARSE_ERROR = -32700 ! SERVER_ERROR = -32600 ! APPLICATION_ERROR = -32500 ! SYSTEM_ERROR = -32400 ! TRANSPORT_ERROR = -32300 ! ! # Specific errors ! NOT_WELLFORMED_ERROR = -32700 ! UNSUPPORTED_ENCODING = -32701 ! INVALID_ENCODING_CHAR = -32702 ! INVALID_XMLRPC = -32600 ! METHOD_NOT_FOUND = -32601 ! INVALID_METHOD_PARAMS = -32602 ! INTERNAL_ERROR = -32603 # -------------------------------------------------------------------- # Exceptions + ## + # Base class for all kinds of client-side errors. + class Error(Exception): """Base class for client errors.""" *************** *** 171,174 **** --- 201,214 ---- return repr(self) + ## + # Indicates an HTTP-level protocol error. This is raised by the HTTP + # transport layer, if the server returns an error code other than 200 + # (OK). + # + # @param url The target URL. + # @param errcode The HTTP error code. + # @param errmsg The HTTP error message. + # @param headers The HTTP header dictionary. + class ProtocolError(Error): """Indicates an HTTP protocol error.""" *************** *** 185,192 **** --- 225,246 ---- ) + ## + # Indicates a broken XML-RPC response package. This exception is + # raised by the unmarshalling layer, if the XML-RPC response is + # malformed. + class ResponseError(Error): """Indicates a broken response package.""" pass + ## + # Indicates an XML-RPC fault response package. This exception is + # raised by the unmarshalling layer, if the XML-RPC response contains + # a fault string. This exception can also used as a class, to + # generate a fault XML-RPC message. + # + # @param faultCode The XML-RPC fault code. + # @param faultString The XML-RPC fault string. + class Fault(Error): """Indicates an XML-RPC fault package.""" *************** *** 204,207 **** --- 258,269 ---- # Special values + ## + # Wrapper for XML-RPC boolean values. Use the xmlrpclib.True and + # xmlrpclib.False constants, or the xmlrpclib.boolean() function, to + # generate boolean XML-RPC values. + # + # @param value A boolean value. Any true value is interpreted as True, + # all other values are interpreted as False. + class Boolean: """Boolean-value wrapper. *************** *** 235,241 **** True, False = Boolean(1), Boolean(0) ! def boolean(value, truefalse=(False, True)): """Convert any Python value to XML-RPC 'boolean'.""" ! return truefalse[operator.truth(value)] class DateTime: --- 297,327 ---- True, False = Boolean(1), Boolean(0) ! ## ! # Map true or false value to XML-RPC boolean values. ! # ! # @def boolean(value) ! # @param value A boolean value. Any true value is mapped to True, ! # all other values are mapped to False. ! # @return xmlrpclib.True or xmlrpclib.False. ! # @see Boolean ! # @see True ! # @see False ! ! def boolean(value, _truefalse=(False, True)): """Convert any Python value to XML-RPC 'boolean'.""" ! return _truefalse[operator.truth(value)] ! ! ## ! # Wrapper for XML-RPC DateTime values. This converts a time value to ! # the format used by XML-RPC. ! #

    ! # The value can be given as a string in the format ! # "yyyymmddThh:mm:ss", as a 9-item time tuple (as returned by ! # time.localtime()), or an integer value (as returned by time.time()). ! # The wrapper uses time.localtime() to convert an integer to a time ! # tuple. ! # ! # @param value The time, given as an ISO 8601 string, a time ! # tuple, or a integer time value. class DateTime: *************** *** 259,264 **** return cmp(self.value, other) def __repr__(self): ! return "" % (self.value, id(self)) def decode(self, data): --- 345,358 ---- return cmp(self.value, other) + ## + # Get date/time value. + # + # @return Date/time value, as an ISO 8601 string. + + def __str__(self): + return self.value + def __repr__(self): ! return "" % (repr(self.value), id(self)) def decode(self, data): *************** *** 270,278 **** out.write("\n") ! def datetime(data): value = DateTime() value.decode(data) return value class Binary: """Wrapper for binary data.""" --- 364,379 ---- out.write("\n") ! def _datetime(data): ! # decode xml element contents into a DateTime structure. value = DateTime() value.decode(data) return value + ## + # Wrapper for binary data. This can be used to transport any kind + # of binary data over XML-RPC, using BASE64 encoding. + # + # @param data An 8-bit string containing arbitrary data. + class Binary: """Wrapper for binary data.""" *************** *** 281,284 **** --- 382,393 ---- self.data = data + ## + # Get buffer contents. + # + # @return Buffer contents, as an 8-bit string. + + def __str__(self): + return self.data or "" + def __cmp__(self, other): if isinstance(other, Binary): *************** *** 296,300 **** out.write("\n") ! def binary(data): value = Binary() value.decode(data) --- 405,410 ---- out.write("\n") ! def _binary(data): ! # decode xml element contents into a Binary structure value = Binary() value.decode(data) *************** *** 315,318 **** --- 425,434 ---- FastParser = FastUnmarshaller = None + try: + import _xmlrpclib + FastMarshaller = _xmlrpclib.Marshaller + except (AttributeError, ImportError): + FastMarshaller = None + # # the SGMLOP parser is about 15x faster than Python's builtin *************** *** 368,378 **** from xml.parsers import expat if not hasattr(expat, "ParserCreate"): ! raise ImportError, "ParserCreate" except ImportError: ! ExpatParser = None else: class ExpatParser: ! # fast expat parser for Python 2.0. this is about 50% ! # slower than sgmlop, on roundtrip testing def __init__(self, target): self._parser = parser = expat.ParserCreate(None, None) --- 484,494 ---- from xml.parsers import expat if not hasattr(expat, "ParserCreate"): ! raise ImportError except ImportError: ! ExpatParser = None # expat not available else: class ExpatParser: ! # fast expat parser for Python 2.0 and later. this is about ! # 50% slower than sgmlop, on roundtrip testing def __init__(self, target): self._parser = parser = expat.ParserCreate(None, None) *************** *** 404,407 **** --- 520,524 ---- self.unknown_starttag = target.start self.handle_data = target.data + self.handle_cdata = target.data self.unknown_endtag = target.end try: *************** *** 413,416 **** --- 530,540 ---- # XML-RPC marshalling and unmarshalling code + ## + # XML-RPC marshaller. + # + # @param encoding Default encoding for 8-bit strings. The default + # value is None (interpreted as UTF-8). + # @see dumps + class Marshaller: """Generate an XML-RPC params chunk from a Python data structure. *************** *** 434,443 **** def dumps(self, values): ! self.__out = [] ! self.write = write = self.__out.append if isinstance(values, Fault): # fault instance write("\n") ! self.__dump(vars(values)) write("\n") else: --- 558,568 ---- def dumps(self, values): ! out = [] ! write = out.append ! dump = self.__dump if isinstance(values, Fault): # fault instance write("\n") ! dump(vars(values), write) write("\n") else: *************** *** 451,462 **** for v in values: write("\n") ! self.__dump(v) write("\n") write("\n") ! result = string.join(self.__out, "") ! del self.__out, self.write # don't need this any more return result ! def __dump(self, value): try: f = self.dispatch[type(value)] --- 576,586 ---- for v in values: write("\n") ! dump(v, write) write("\n") write("\n") ! result = string.join(out, "") return result ! def __dump(self, value, write): try: f = self.dispatch[type(value)] *************** *** 464,545 **** raise TypeError, "cannot marshal %s objects" % type(value) else: ! f(self, value) ! def dump_int(self, value): # in case ints are > 32 bits if value > MAXINT or value < MININT: raise OverflowError, "int exceeds XML-RPC limits" ! self.write("%s\n" % value) dispatch[IntType] = dump_int ! def dump_long(self, value): ! # in case ints are > 32 bits if value > MAXINT or value < MININT: raise OverflowError, "long int exceeds XML-RPC limits" ! self.write("%s\n" % int(value)) dispatch[LongType] = dump_long ! def dump_double(self, value): ! self.write("%s\n" % repr(value)) dispatch[FloatType] = dump_double ! def dump_string(self, value, escape=escape): ! self.write("%s\n" % escape(value)) dispatch[StringType] = dump_string if unicode: ! def dump_unicode(self, value, escape=escape): value = value.encode(self.encoding) ! self.write("%s\n" % escape(value)) dispatch[UnicodeType] = dump_unicode ! def opencontainer(self, value): ! if value: ! i = id(value) ! if i in self.memo: ! raise TypeError, "cannot marshal recursive data structures" ! self.memo[i] = None ! ! def closecontainer(self, value): ! if value: ! del self.memo[id(value)] ! ! def dump_array(self, value): ! self.opencontainer(value) ! write = self.write dump = self.__dump write("\n") for v in value: ! dump(v) write("\n") ! self.closecontainer(value) dispatch[TupleType] = dump_array dispatch[ListType] = dump_array ! def dump_struct(self, value, escape=escape): ! self.opencontainer(value) ! write = self.write dump = self.__dump write("\n") ! for k, v in value.items(): write("\n") if type(k) is not StringType: raise TypeError, "dictionary key must be string" write("%s\n" % escape(k)) ! dump(v) write("\n") write("\n") ! self.closecontainer(value) dispatch[DictType] = dump_struct ! def dump_instance(self, value): # check for special wrappers if value.__class__ in WRAPPERS: value.encode(self) else: # store instance attributes as a struct (really?) ! self.dump_struct(value.__dict__) dispatch[InstanceType] = dump_instance class Unmarshaller: """Unmarshal an XML-RPC response, based on incoming XML event --- 588,678 ---- raise TypeError, "cannot marshal %s objects" % type(value) else: ! f(self, value, write) ! def dump_int(self, value, write): # in case ints are > 32 bits if value > MAXINT or value < MININT: raise OverflowError, "int exceeds XML-RPC limits" ! write("") ! write(str(value)) ! write("\n") dispatch[IntType] = dump_int ! def dump_long(self, value, write): if value > MAXINT or value < MININT: raise OverflowError, "long int exceeds XML-RPC limits" ! write("") ! write(str(int(value))) ! write("\n") dispatch[LongType] = dump_long ! def dump_double(self, value, write): ! write("") ! write(repr(value)) ! write("\n") dispatch[FloatType] = dump_double ! def dump_string(self, value, write, escape=escape): ! write("") ! write(escape(value)) ! write("\n") dispatch[StringType] = dump_string if unicode: ! def dump_unicode(self, value, write, escape=escape): value = value.encode(self.encoding) ! write("") ! write(escape(value)) ! write("\n") dispatch[UnicodeType] = dump_unicode ! def dump_array(self, value, write): ! i = id(value) ! if self.memo.has_key(i): ! raise TypeError, "cannot marshal recursive sequences" ! self.memo[i] = None dump = self.__dump write("\n") for v in value: ! dump(v, write) write("\n") ! del self.memo[i] dispatch[TupleType] = dump_array dispatch[ListType] = dump_array ! def dump_struct(self, value, write, escape=escape): ! i = id(value) ! if self.memo.has_key(i): ! raise TypeError, "cannot marshal recursive dictionaries" ! self.memo[i] = None dump = self.__dump write("\n") ! for k in value.keys(): write("\n") if type(k) is not StringType: raise TypeError, "dictionary key must be string" write("%s\n" % escape(k)) ! dump(value[k], write) write("\n") write("\n") ! del self.memo[i] dispatch[DictType] = dump_struct ! def dump_instance(self, value, write): # check for special wrappers if value.__class__ in WRAPPERS: + self.write = write value.encode(self) + del self.write else: # store instance attributes as a struct (really?) ! self.dump_struct(value.__dict__, write) dispatch[InstanceType] = dump_instance + ## + # XML-RPC unmarshaller. + # + # @see loads + class Unmarshaller: """Unmarshal an XML-RPC response, based on incoming XML event *************** *** 680,684 **** def end_value(self, data): ! # if we stumble upon an value element with no internal # elements, treat it as a string element if self._value: --- 813,817 ---- def end_value(self, data): ! # if we stumble upon a value element with no internal # elements, treat it as a string element if self._value: *************** *** 705,708 **** --- 838,847 ---- # convenience functions + ## + # Create a parser object, and connect it to an unmarshalling instance. + # This function picks the fastest available XML parser. + # + # return A (parser, unmarshaller) tuple. + def getparser(): """getparser() -> parser, unmarshaller *************** *** 712,716 **** """ if FastParser and FastUnmarshaller: ! target = FastUnmarshaller(True, False, binary, datetime) parser = FastParser(target) else: --- 851,855 ---- """ if FastParser and FastUnmarshaller: ! target = FastUnmarshaller(True, False, _binary, _datetime, Fault) parser = FastParser(target) else: *************** *** 726,729 **** --- 865,881 ---- return parser, target + ## + # Convert a Python tuple or a Fault instance to an XML-RPC packet. + # + # @def dumps(params, **options) + # @param params A tuple or Fault instance. + # @keyparam methodname If given, create a methodCall request for + # this method name. + # @keyparam methodresponse If given, create a methodResponse packet. + # If used with a tuple, the tuple must be a singleton (that is, + # it must contain exactly one element). + # @keyparam encoding The packet encoding. + # @return A string containing marshalled data. + def dumps(params, methodname=None, methodresponse=None, encoding=None): """data [,options] -> marshalled data *************** *** 756,772 **** assert len(params) == 1, "response tuple must be a singleton" ! if encoding is None: encoding = "utf-8" ! m = Marshaller(encoding) data = m.dumps(params) if encoding != "utf-8": ! xmlheader = "\n" % repr(encoding) else: xmlheader = "\n" # utf-8 is default # standard XML-RPC wrappings ! if methodname is not None: # a method call if not isinstance(methodname, StringType): --- 908,928 ---- assert len(params) == 1, "response tuple must be a singleton" ! if not encoding: encoding = "utf-8" ! if FastMarshaller: ! m = FastMarshaller(encoding) ! else: ! m = Marshaller(encoding) ! data = m.dumps(params) if encoding != "utf-8": ! xmlheader = "\n" % str(encoding) else: xmlheader = "\n" # utf-8 is default # standard XML-RPC wrappings ! if methodname: # a method call if not isinstance(methodname, StringType): *************** *** 791,794 **** --- 947,959 ---- return string.join(data, "") + ## + # Convert an XML-RPC packet to a Python object. If the XML-RPC packet + # represents a fault condition, this function raises a Fault exception. + # + # @param data An XML-RPC packet, given as an 8-bit string. + # @return A tuple containing the the unpacked data, and the method name + # (None if not present). + # @see Fault + def loads(data): """data -> unmarshalled data, method name *************** *** 800,803 **** --- 965,969 ---- raises a Fault exception. """ + import sys p, u = getparser() p.feed(data) *************** *** 820,823 **** --- 986,994 ---- return self.__send(self.__name, args) + ## + # Standard transport class for XML-RPC over HTTP. + #

    + # You can create custom transports by subclassing this method, and + # overriding selected methods. class Transport: *************** *** 827,830 **** --- 998,1010 ---- user_agent = "xmlrpclib.py/%s (by www.pythonware.com)" % __version__ + ## + # Send a complete request, and parse the response. + # + # @param host Target host. + # @param handler Target PRC handler. + # @param request_body XML-RPC request body. + # @param verbose Debugging flag. + # @return Parsed response. + def request(self, host, handler, request_body, verbose=0): # issue XML-RPC request *************** *** 850,854 **** self.verbose = verbose ! return self.parse_response(h.getfile()) def getparser(self): --- 1030,1044 ---- self.verbose = verbose ! try: ! sock = h._conn.sock ! except AttributeError: ! sock = None ! ! return self._parse_response(h.getfile(), sock) ! ! ## ! # Create parser. ! # ! # @return A 2-tuple containing a parser and a unmarshaller. def getparser(self): *************** *** 856,859 **** --- 1046,1055 ---- return getparser() + ## + # Connect to server. + # + # @param host Target host. + # @return A connection handle. + def make_connection(self, host): # create a HTTP connection object from a host descriptor *************** *** 861,873 **** --- 1057,1093 ---- return httplib.HTTP(host) + ## + # Send request header. + # + # @param connection Connection handle. + # @param handler Target RPC handler. + # @param request_body XML-RPC body. + def send_request(self, connection, handler, request_body): connection.putrequest("POST", handler) + ## + # Send host name. + # + # @param connection Connection handle. + # @param host Host name. + def send_host(self, connection, host): connection.putheader("Host", host) + ## + # Send user-agent identifier. + # + # @param connection Connection handle. + def send_user_agent(self, connection): connection.putheader("User-Agent", self.user_agent) + ## + # Send request body. + # + # @param connection Connection handle. + # @param request_body XML-RPC request body. + def send_content(self, connection, request_body): connection.putheader("Content-Type", "text/xml") *************** *** 877,887 **** connection.send(request_body) ! def parse_response(self, f): ! # read response from input file, and parse it p, u = self.getparser() while 1: ! response = f.read(1024) if not response: break --- 1097,1130 ---- connection.send(request_body) ! ## ! # Parse response. ! # ! # @param file Stream. ! # @return Response tuple and target method. ! ! def parse_response(self, file): ! # compatibility interface ! return self._parse_response(file, None) ! ! ## ! # Parse response (alternate interface). This is similar to the ! # parse_response method, but also provides direct access to the ! # underlying socket object (where available). ! # ! # @param file Stream. ! # @param sock Socket handle (or None, if the socket object ! # could not be accessed). ! # @return Response tuple and target method. ! ! def _parse_response(self, file, sock): ! # read response from input file/socket, and parse it p, u = self.getparser() while 1: ! if sock: ! response = sock.recv(1024) ! else: ! response = file.read(1024) if not response: break *************** *** 890,901 **** p.feed(response) ! f.close() p.close() return u.close() class SafeTransport(Transport): """Handles an HTTPS transaction to an XML-RPC server.""" def make_connection(self, host): # create a HTTPS connection object from a host descriptor --- 1133,1149 ---- p.feed(response) ! file.close() p.close() return u.close() + ## + # Standard transport class for XML-RPC over HTTPS. + class SafeTransport(Transport): """Handles an HTTPS transaction to an XML-RPC server.""" + # FIXME: mostly untested + def make_connection(self, host): # create a HTTPS connection object from a host descriptor *************** *** 919,922 **** --- 1167,1187 ---- connection.putheader("Host", host) + ## + # Standard server proxy. This class establishes a virtual connection + # to an XML-RPC server. + #

    + # This class is available as ServerProxy and Server. New code should + # use ServerProxy, to avoid confusion. + # + # @def ServerProxy(uri, **options) + # @param uri The connection point on the server. + # @keyparam transport A transport factory, compatible with the + # standard transport class. + # @keyparam encoding The default encoding used for 8-bit strings + # (default is UTF-8). + # @keyparam verbose Use a true value to enable debugging output. + # (printed to standard output). + # @see Transport + class ServerProxy: """uri [,options] -> a logical connection to an XML-RPC server *************** *** 996,999 **** --- 1261,1265 ---- # compatibility + Server = ServerProxy From jackjansen@users.sourceforge.net Thu Jun 27 23:06:52 2002 From: jackjansen@users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu, 27 Jun 2002 15:06:52 -0700 Subject: [Python-checkins] python/dist/src setup.py,1.97,1.98 Message-ID: Update of /cvsroot/python/python/dist/src In directory usw-pr-cvs1:/tmp/cvs-serv8049 Modified Files: setup.py Log Message: More fixes for building MacPython extension modules. It now actually succeeds in building various modules. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.97 retrieving revision 1.98 diff -C2 -d -r1.97 -r1.98 *** setup.py 26 Jun 2002 15:44:30 -0000 1.97 --- setup.py 27 Jun 2002 22:06:49 -0000 1.98 *************** *** 310,317 **** # fcntl(2) and ioctl(2) exts.append( Extension('fcntl', ['fcntlmodule.c']) ) ! # pwd(3) ! exts.append( Extension('pwd', ['pwdmodule.c']) ) ! # grp(3) ! exts.append( Extension('grp', ['grpmodule.c']) ) # posix (UNIX) errno values exts.append( Extension('errno', ['errnomodule.c']) ) --- 310,318 ---- # fcntl(2) and ioctl(2) exts.append( Extension('fcntl', ['fcntlmodule.c']) ) ! if platform not in ['mac']: ! # pwd(3) ! exts.append( Extension('pwd', ['pwdmodule.c']) ) ! # grp(3) ! exts.append( Extension('grp', ['grpmodule.c']) ) # posix (UNIX) errno values exts.append( Extension('errno', ['errnomodule.c']) ) *************** *** 339,343 **** # Memory-mapped files (also works on Win32). ! if platform not in ['atheos']: exts.append( Extension('mmap', ['mmapmodule.c']) ) --- 340,344 ---- # Memory-mapped files (also works on Win32). ! if platform not in ['atheos', 'mac']: exts.append( Extension('mmap', ['mmapmodule.c']) ) *************** *** 345,350 **** # enigma-inspired encryption exts.append( Extension('rotor', ['rotormodule.c']) ) ! # syslog daemon interface ! exts.append( Extension('syslog', ['syslogmodule.c']) ) # George Neville-Neil's timing module: --- 346,352 ---- # enigma-inspired encryption exts.append( Extension('rotor', ['rotormodule.c']) ) ! if platform not in ['mac']: ! # syslog daemon interface ! exts.append( Extension('syslog', ['syslogmodule.c']) ) # George Neville-Neil's timing module: *************** *** 382,393 **** library_dirs=['/usr/lib/termcap'], libraries=readline_libs) ) ! ! # crypt module. ! ! if self.compiler.find_library_file(lib_dirs, 'crypt'): ! libs = ['crypt'] ! else: ! libs = [] ! exts.append( Extension('crypt', ['cryptmodule.c'], libraries=libs) ) # socket(2) --- 384,395 ---- library_dirs=['/usr/lib/termcap'], libraries=readline_libs) ) ! if platform not in ['mac']: ! # crypt module. ! ! if self.compiler.find_library_file(lib_dirs, 'crypt'): ! libs = ['crypt'] ! else: ! libs = [] ! exts.append( Extension('crypt', ['cryptmodule.c'], libraries=libs) ) # socket(2) *************** *** 536,540 **** # The standard Unix dbm module: ! if platform not in ['cygwin']: if (self.compiler.find_library_file(lib_dirs, 'ndbm')): exts.append( Extension('dbm', ['dbmmodule.c'], --- 538,542 ---- # The standard Unix dbm module: ! if platform not in ['cygwin', 'mac']: if (self.compiler.find_library_file(lib_dirs, 'ndbm')): exts.append( Extension('dbm', ['dbmmodule.c'], From jackjansen@users.sourceforge.net Thu Jun 27 23:09:21 2002 From: jackjansen@users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu, 27 Jun 2002 15:09:21 -0700 Subject: [Python-checkins] python/dist/src/Mac/scripts fullbuild.py,1.81,1.82 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/scripts In directory usw-pr-cvs1:/tmp/cvs-serv9084 Modified Files: fullbuild.py Log Message: Started on support for using standard setup.py to build at least the "standard" modules. Unfinished, but shouldn't harm anything. Index: fullbuild.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/scripts/fullbuild.py,v retrieving revision 1.81 retrieving revision 1.82 diff -C2 -d -r1.81 -r1.82 *** fullbuild.py 26 Jun 2002 22:06:08 -0000 1.81 --- fullbuild.py 27 Jun 2002 22:09:19 -0000 1.82 *************** *** 172,175 **** --- 172,240 ---- macostools.copy(src, dst, forcetype="APPL") + def buildsetup(top, dummy, list): + print 'Building extensions with setup.py ', ' '.join(list) + argv = ['setup.py'] + list[:] + save_argv = sys.argv + sys.argv = argv + sys.path.insert(0, top) + m = __import__('setup') + r = getattr(m, 'main') + r() + del sys.path[0] + sys.argv = save_argv + + def buildcarbonplugins(top, dummy1, dummy2): + ## XXXX Need to convert pathnames, I guess, and adapt distutils Mac-specific + ## code to not call GetArgv if not needed. + ## buildsetup(top, None, [ + ## '--dry_run', + ## 'install', + ## '--prefix=%s' % sys.prefix, + ## '--install-scripts=%s' % os.path.join(sys.prefix, 'Scripts'), + ## '--install-platlib=%s' % os.path.join(sys.prefix, 'Lib', 'lib-dynload') + ## ]) + buildmwproject(top, "CWIE", [ + (":Mac:Build:_weakref.carbon.mcp", "_weakref.carbon"), + (":Mac:Build:_symtable.carbon.mcp", "_symtable.carbon"), + (":Mac:Build:_testcapi.carbon.mcp", "_testcapi.carbon"), + (":Mac:Build:_hotshot.carbon.mcp", "_hotshot.carbon"), + (":Mac:Build:xx.carbon.mcp", "xx.carbon"), + (":Mac:Build:xxsubtype.carbon.mcp", "xxsubtype.carbon"), + (":Mac:Build:pyexpat.carbon.mcp", "pyexpat.carbon"), + (":Mac:Build:calldll.carbon.mcp", "calldll.carbon"), + (":Mac:Build:gdbm.carbon.mcp", "gdbm.carbon"), + (":Mac:Build:icglue.carbon.mcp", "icglue.carbon"), + (":Mac:Build:waste.carbon.mcp", "waste.carbon"), + (":Mac:Build:zlib.carbon.mcp", "zlib.carbon"), + (":Mac:Build:hfsplus.carbon.mcp", "hfsplus.carbon"), + ## (":Mac:Build:_dummy_tkinter.mcp", "_tkinter.carbon"), + (":Extensions:Imaging:_tkinter.mcp", "_tkinter.carbon"), + (":Mac:Build:ColorPicker.carbon.mcp", "ColorPicker.carbon"), + (":Mac:Build:_AE.carbon.mcp", "_AE.carbon"), + (":Mac:Build:_App.carbon.mcp", "_App.carbon"), + (":Mac:Build:_CF.carbon.mcp", "_CF.carbon"), + (":Mac:Build:_CG.carbon.mcp", "_CG.carbon"), + (":Mac:Build:_CarbonEvt.carbon.mcp", "_CarbonEvt.carbon"), + (":Mac:Build:_Cm.carbon.mcp", "_Cm.carbon"), + (":Mac:Build:_Ctl.carbon.mcp", "_Ctl.carbon"), + (":Mac:Build:_Dlg.carbon.mcp", "_Dlg.carbon"), + (":Mac:Build:_Drag.carbon.mcp", "_Drag.carbon"), + (":Mac:Build:_Evt.carbon.mcp", "_Evt.carbon"), + (":Mac:Build:_Fm.carbon.mcp", "_Fm.carbon"), + (":Mac:Build:_Icn.carbon.mcp", "_Icn.carbon"), + (":Mac:Build:_List.carbon.mcp", "_List.carbon"), + (":Mac:Build:_Menu.carbon.mcp", "_Menu.carbon"), + (":Mac:Build:_Mlte.carbon.mcp", "_Mlte.carbon"), + (":Mac:Build:_Qd.carbon.mcp", "_Qd.carbon"), + (":Mac:Build:_Qdoffs.carbon.mcp", "_Qdoffs.carbon"), + (":Mac:Build:_Qt.carbon.mcp", "_Qt.carbon"), + (":Mac:Build:_Res.carbon.mcp", "_Res.carbon"), + (":Mac:Build:_Scrap.carbon.mcp", "_Scrap.carbon"), + (":Mac:Build:_Snd.carbon.mcp", "_Snd.carbon"), + (":Mac:Build:_Sndihooks.carbon.mcp", "_Sndihooks.carbon"), + (":Mac:Build:_TE.carbon.mcp", "_TE.carbon"), + (":Mac:Build:_Win.carbon.mcp", "_Win.carbon"), + ]) + def handle_dialog(filename): """Handle selection dialog, return list of selected items""" *************** *** 282,328 **** ]), ! I_CARBON_PLUGINS : (buildmwproject, "CWIE", [ ! (":Mac:Build:_weakref.carbon.mcp", "_weakref.carbon"), ! (":Mac:Build:_symtable.carbon.mcp", "_symtable.carbon"), ! (":Mac:Build:_testcapi.carbon.mcp", "_testcapi.carbon"), ! (":Mac:Build:_hotshot.carbon.mcp", "_hotshot.carbon"), ! (":Mac:Build:xx.carbon.mcp", "xx.carbon"), ! (":Mac:Build:xxsubtype.carbon.mcp", "xxsubtype.carbon"), ! (":Mac:Build:pyexpat.carbon.mcp", "pyexpat.carbon"), ! (":Mac:Build:calldll.carbon.mcp", "calldll.carbon"), ! (":Mac:Build:gdbm.carbon.mcp", "gdbm.carbon"), ! (":Mac:Build:icglue.carbon.mcp", "icglue.carbon"), ! (":Mac:Build:waste.carbon.mcp", "waste.carbon"), ! (":Mac:Build:zlib.carbon.mcp", "zlib.carbon"), ! (":Mac:Build:hfsplus.carbon.mcp", "hfsplus.carbon"), ! ## (":Mac:Build:_dummy_tkinter.mcp", "_tkinter.carbon"), ! (":Extensions:Imaging:_tkinter.mcp", "_tkinter.carbon"), ! (":Mac:Build:ColorPicker.carbon.mcp", "ColorPicker.carbon"), ! (":Mac:Build:_AE.carbon.mcp", "_AE.carbon"), ! (":Mac:Build:_App.carbon.mcp", "_App.carbon"), ! (":Mac:Build:_CF.carbon.mcp", "_CF.carbon"), ! (":Mac:Build:_CG.carbon.mcp", "_CG.carbon"), ! (":Mac:Build:_CarbonEvt.carbon.mcp", "_CarbonEvt.carbon"), ! (":Mac:Build:_Cm.carbon.mcp", "_Cm.carbon"), ! (":Mac:Build:_Ctl.carbon.mcp", "_Ctl.carbon"), ! (":Mac:Build:_Dlg.carbon.mcp", "_Dlg.carbon"), ! (":Mac:Build:_Drag.carbon.mcp", "_Drag.carbon"), ! (":Mac:Build:_Evt.carbon.mcp", "_Evt.carbon"), ! (":Mac:Build:_Fm.carbon.mcp", "_Fm.carbon"), ! (":Mac:Build:_Icn.carbon.mcp", "_Icn.carbon"), ! (":Mac:Build:_List.carbon.mcp", "_List.carbon"), ! (":Mac:Build:_Menu.carbon.mcp", "_Menu.carbon"), ! (":Mac:Build:_Mlte.carbon.mcp", "_Mlte.carbon"), ! (":Mac:Build:_Qd.carbon.mcp", "_Qd.carbon"), ! (":Mac:Build:_Qdoffs.carbon.mcp", "_Qdoffs.carbon"), ! (":Mac:Build:_Qt.carbon.mcp", "_Qt.carbon"), ! (":Mac:Build:_Res.carbon.mcp", "_Res.carbon"), ! (":Mac:Build:_Scrap.carbon.mcp", "_Scrap.carbon"), ! (":Mac:Build:_Snd.carbon.mcp", "_Snd.carbon"), ! (":Mac:Build:_Sndihooks.carbon.mcp", "_Sndihooks.carbon"), ! (":Mac:Build:_TE.carbon.mcp", "_TE.carbon"), ! (":Mac:Build:_Win.carbon.mcp", "_Win.carbon"), ! ! ]), I_PPC_FULL : (buildmwproject, "CWIE", [ --- 347,351 ---- ]), ! I_CARBON_PLUGINS : (buildcarbonplugins, None, []), I_PPC_FULL : (buildmwproject, "CWIE", [ From jackjansen@users.sourceforge.net Thu Jun 27 23:10:21 2002 From: jackjansen@users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu, 27 Jun 2002 15:10:21 -0700 Subject: [Python-checkins] python/dist/src/Lib/distutils mwerkscompiler.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory usw-pr-cvs1:/tmp/cvs-serv9481 Modified Files: mwerkscompiler.py Log Message: The standard definition file is now called mwerks_shcarbon_plugin.h. Index: mwerkscompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/mwerkscompiler.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** mwerkscompiler.py 26 Jun 2002 15:42:49 -0000 1.9 --- mwerkscompiler.py 27 Jun 2002 22:10:19 -0000 1.10 *************** *** 170,174 **** prefixfilename = os.path.join(os.getcwd(), os.path.join(build_temp, prefixname)) fp = open(prefixfilename, 'w') ! fp.write('#include "mwerks_plugin_config.h"\n') for name, value in self.__macros: if value is None: --- 170,174 ---- prefixfilename = os.path.join(os.getcwd(), os.path.join(build_temp, prefixname)) fp = open(prefixfilename, 'w') ! fp.write('#include "mwerks_shcarbon_config.h"\n') for name, value in self.__macros: if value is None: From mhammond@users.sourceforge.net Fri Jun 28 02:13:04 2002 From: mhammond@users.sourceforge.net (mhammond@users.sourceforge.net) Date: Thu, 27 Jun 2002 18:13:04 -0700 Subject: [Python-checkins] python/dist/src/Tools/freeze extensions_win32.ini,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/freeze In directory usw-pr-cvs1:/tmp/cvs-serv26120 Modified Files: extensions_win32.ini Log Message: Patch 574531/Bug 574570 - allow freeze on windows to use the _winreg extension. Index: extensions_win32.ini =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/freeze/extensions_win32.ini,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** extensions_win32.ini 23 Feb 2001 03:45:13 -0000 1.5 --- extensions_win32.ini 28 Jun 2002 01:13:02 -0000 1.6 *************** *** 53,56 **** --- 53,61 ---- libs=%PYTHONPREFIX%\..\zlib-1.1.3\zlib.lib /nodefaultlib:libc + [_winreg] + dsp=%PYTHONPREFIX%\PCBuild\winreg.dsp + libs=advapi32.lib + + ;-------------------------------------------------------------- ; *************** *** 165,167 **** cl=/D _AFXDLL /D FREEZE_WIN32UI /GX /I %PYTHONEX%\win32\src libs=mfc42.lib - --- 170,171 ---- From nascheme@users.sourceforge.net Fri Jun 28 20:16:07 2002 From: nascheme@users.sourceforge.net (nascheme@users.sourceforge.net) Date: Fri, 28 Jun 2002 12:16:07 -0700 Subject: [Python-checkins] python/dist/src/Modules gcmodule.c,2.44,2.45 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv29051/Modules Modified Files: gcmodule.c Log Message: Fix small bug. The count of objects in all generations younger then the collected one should be zeroed. Index: gcmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/gcmodule.c,v retrieving revision 2.44 retrieving revision 2.45 diff -C2 -d -r2.44 -r2.45 *** gcmodule.c 13 Jun 2002 20:32:49 -0000 2.44 --- gcmodule.c 28 Jun 2002 19:16:04 -0000 2.45 *************** *** 397,401 **** generations[generation+1].count += 1; for (i = 0; i <= generation; i++) ! generations[generation].count = 0; /* merge younger generations with one we are currently collecting */ --- 397,401 ---- generations[generation+1].count += 1; for (i = 0; i <= generation; i++) ! generations[i].count = 0; /* merge younger generations with one we are currently collecting */ From fdrake@users.sourceforge.net Fri Jun 28 23:29:04 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri, 28 Jun 2002 15:29:04 -0700 Subject: [Python-checkins] python/dist/src/Modules pyexpat.c,2.61,2.62 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv26078/Modules Modified Files: pyexpat.c Log Message: pyexpat code cleanup and minor refactorings: The handlers array on each parser now has the invariant that None will never be set as a handler; it will always be NULL or a Python-level value passed in for the specific handler. have_handler(): Return true if there is a Python handler for a particular event. get_handler_name(): Return a string object giving the name of a particular handler. This caches the string object so it doesn't need to be created more than once. get_parse_result(): Helper to allow the Parse() and ParseFile() methods to share the same logic for determining the return value or exception state. PyUnknownEncodingHandler(), PyModule_AddIntConstant(): Made these helpers static. (The later is only defined for older versions of Python.) pyxml_UpdatePairedHandlers(), pyxml_SetStartElementHandler(), pyxml_SetEndElementHandler(), pyxml_SetStartNamespaceDeclHandler(), pyxml_SetEndNamespaceDeclHandler(), pyxml_SetStartCdataSection(), pyxml_SetEndCdataSection(), pyxml_SetStartDoctypeDeclHandler(), pyxml_SetEndDoctypeDeclHandler(): Removed. These are no longer needed with Expat 1.95.x. handler_info: Use the setter functions provided by Expat 1.95.x instead of the pyxml_Set*Handler() functions which have been removed. Minor code formatting changes for consistency. Trailing whitespace removed. Index: pyexpat.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/pyexpat.c,v retrieving revision 2.61 retrieving revision 2.62 diff -C2 -d -r2.61 -r2.62 *** pyexpat.c 27 Jun 2002 19:40:48 -0000 2.61 --- pyexpat.c 28 Jun 2002 22:29:01 -0000 2.62 *************** *** 75,78 **** --- 75,79 ---- xmlhandler handler; PyCodeObject *tb_code; + PyObject *nameobj; }; *************** *** 119,122 **** --- 120,142 ---- } [...1025 lines suppressed...] {"DefaultHandler", *************** *** 1736,1743 **** (xmlhandler)my_ExternalEntityRefHandler }, {"StartDoctypeDeclHandler", ! pyxml_SetStartDoctypeDeclHandler, (xmlhandler)my_StartDoctypeDeclHandler}, {"EndDoctypeDeclHandler", ! pyxml_SetEndDoctypeDeclHandler, (xmlhandler)my_EndDoctypeDeclHandler}, {"EntityDeclHandler", --- 1691,1698 ---- (xmlhandler)my_ExternalEntityRefHandler }, {"StartDoctypeDeclHandler", ! (xmlhandlersetter)XML_SetStartDoctypeDeclHandler, (xmlhandler)my_StartDoctypeDeclHandler}, {"EndDoctypeDeclHandler", ! (xmlhandlersetter)XML_SetEndDoctypeDeclHandler, (xmlhandler)my_EndDoctypeDeclHandler}, {"EntityDeclHandler", From jhylton@users.sourceforge.net Fri Jun 28 23:38:04 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Fri, 28 Jun 2002 15:38:04 -0700 Subject: [Python-checkins] python/dist/src/Lib httplib.py,1.51,1.52 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv28446 Modified Files: httplib.py Log Message: Fixes for two separate HTTP/1.1 bugs: 100 responses and HTTPS connections. The HTTPResponse class now handles 100 continue responses, instead of choking on them. It detects them internally in the _begin() method and ignores them. Based on a patch by Bob Kline. This closes SF bugs 498149 and 551273. The FakeSocket class (for SSL) is now usable with HTTP/1.1 connections. The old version of the code could not work with persistent connections, because the makefile() implementation read until EOF before returning. If the connection is persistent, the server sends a response and leaves the connection open. A client that reads until EOF will block until the server gives up on the connection -- more than a minute in my test case. The problem was fixed by implementing a reasonable makefile(). It reads data only when it is needed by the layers above it. It's implementation uses an internal buffer with a default size of 8192. Also, rename begin() method of HTTPResponse to _begin() because it should only be called by the HTTPConnection. Index: httplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/httplib.py,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** httplib.py 1 Jun 2002 14:18:45 -0000 1.51 --- httplib.py 28 Jun 2002 22:38:01 -0000 1.52 *************** *** 112,120 **** self.will_close = _UNKNOWN # conn will close at end of response ! def begin(self): ! if self.msg is not None: ! # we've already started reading the response ! return ! line = self.fp.readline() if self.debuglevel > 0: --- 112,116 ---- self.will_close = _UNKNOWN # conn will close at end of response ! def _read_status(self): line = self.fp.readline() if self.debuglevel > 0: *************** *** 136,146 **** # The status code is a three-digit number try: ! self.status = status = int(status) if status < 100 or status > 999: raise BadStatusLine(line) except ValueError: raise BadStatusLine(line) ! self.reason = reason.strip() if version == 'HTTP/1.0': self.version = 10 --- 132,162 ---- # The status code is a three-digit number try: ! status = int(status) if status < 100 or status > 999: raise BadStatusLine(line) except ValueError: raise BadStatusLine(line) ! return version, status, reason ! ! def _begin(self): ! if self.msg is not None: ! # we've already started reading the response ! return + # read until we get a non-100 response + while 1: + version, status, reason = self._read_status() + if status != 100: + break + # skip the header from the 100 response + while 1: + skip = self.fp.readline().strip() + if not skip: + break + if self.debuglevel > 0: + print "header:", skip + + self.status = status + self.reason = reason.strip() if version == 'HTTP/1.0': self.version = 10 *************** *** 153,156 **** --- 169,173 ---- if self.version == 9: + self.chunked = 0 self.msg = mimetools.Message(StringIO()) return *************** *** 234,237 **** --- 251,255 ---- if self.chunked: + assert self.chunked != _UNKNOWN chunk_left = self.chunk_left value = '' *************** *** 364,368 **** """Connect to the host and port specified in __init__.""" msg = "getaddrinfo returns an empty list" ! for res in socket.getaddrinfo(self.host, self.port, 0, socket.SOCK_STREAM): af, socktype, proto, canonname, sa = res try: --- 382,387 ---- """Connect to the host and port specified in __init__.""" msg = "getaddrinfo returns an empty list" ! for res in socket.getaddrinfo(self.host, self.port, 0, ! socket.SOCK_STREAM): af, socktype, proto, canonname, sa = res try: *************** *** 596,600 **** response = self.response_class(self.sock) ! response.begin() self.__state = _CS_IDLE --- 615,620 ---- response = self.response_class(self.sock) ! response._begin() ! assert response.will_close != _UNKNOWN self.__state = _CS_IDLE *************** *** 608,633 **** return response ! class FakeSocket: ! def __init__(self, sock, ssl): ! self.__sock = sock ! self.__ssl = ssl ! ! def makefile(self, mode, bufsize=None): ! """Return a readable file-like object with data from socket. ! ! This method offers only partial support for the makefile ! interface of a real socket. It only supports modes 'r' and ! 'rb' and the bufsize argument is ignored. ! ! The returned object contains *all* of the file data ! """ ! if mode != 'r' and mode != 'rb': ! raise UnimplementedFileMode() ! msgbuf = [] while 1: try: ! buf = self.__ssl.read() except socket.sslerror, err: if (err[0] == socket.SSL_ERROR_WANT_READ --- 628,648 ---- return response + class SSLFile: + """File-like object wrapping an SSL socket.""" ! BUFSIZE = 8192 ! ! def __init__(self, sock, ssl, bufsize=None): ! self._sock = sock ! self._ssl = ssl ! self._buf = '' ! self._bufsize = bufsize or self.__class__.BUFSIZE ! def _read(self): ! buf = '' ! # put in a loop so that we retry on transient errors while 1: try: ! buf = self._ssl.read(self._bufsize) except socket.sslerror, err: if (err[0] == socket.SSL_ERROR_WANT_READ *************** *** 641,649 **** if err[0] == errno.EINTR: continue raise ! if buf == '': break ! msgbuf.append(buf) ! return StringIO("".join(msgbuf)) def send(self, stuff, flags = 0): --- 656,718 ---- if err[0] == errno.EINTR: continue + if err[0] == errno.EBADF: + # XXX socket was closed? + break raise ! else: break ! return buf ! ! def read(self, size=None): ! L = [self._buf] ! avail = len(self._buf) ! while size is None or avail < size: ! s = self._read() ! if s == '': ! break ! L.append(s) ! avail += len(s) ! all = "".join(L) ! if size is None: ! self._buf = '' ! return all ! else: ! self._buf = all[size:] ! return all[:size] ! ! def readline(self): ! L = [self._buf] ! self._buf = '' ! while 1: ! i = L[-1].find("\n") ! if i >= 0: ! break ! s = self._read() ! if s == '': ! break ! L.append(s) ! if i == -1: ! # loop exited because there is no more data ! return "".join(L) ! else: ! all = "".join(L) ! # XXX could do enough bookkeeping not to do a 2nd search ! i = all.find("\n") + 1 ! line = all[:i] ! self._buf = all[i:] ! return line ! ! def close(self): ! self._sock.close() ! ! class FakeSocket: ! def __init__(self, sock, ssl): ! self.__sock = sock ! self.__ssl = ssl ! ! def makefile(self, mode, bufsize=None): ! if mode != 'r' and mode != 'rb': ! raise UnimplementedFileMode() ! return SSLFile(self.__sock, self.__ssl, bufsize) def send(self, stuff, flags = 0): *************** *** 886,890 **** for header in headers.headers: print header.strip() print ! print h.getfile().read() # minimal test that code to extract host from url works --- 955,959 ---- for header in headers.headers: print header.strip() print ! print "read", len(h.getfile().read()) # minimal test that code to extract host from url works *************** *** 907,910 **** --- 976,980 ---- hs.endheaders() status, reason, headers = hs.getreply() + # XXX why does this give a 302 response? print 'status =', status print 'reason =', reason *************** *** 913,917 **** for header in headers.headers: print header.strip() print ! print hs.getfile().read() --- 983,987 ---- for header in headers.headers: print header.strip() print ! print "read", len(hs.getfile().read()) From jhylton@users.sourceforge.net Fri Jun 28 23:39:59 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Fri, 28 Jun 2002 15:39:59 -0700 Subject: [Python-checkins] python/dist/src/Misc ACKS,1.184,1.185 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv28928 Modified Files: ACKS Log Message: Add Bob Kline of HTTP 100 fame. Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.184 retrieving revision 1.185 diff -C2 -d -r1.184 -r1.185 *** ACKS 24 Jun 2002 13:08:16 -0000 1.184 --- ACKS 28 Jun 2002 22:39:56 -0000 1.185 *************** *** 258,261 **** --- 258,262 ---- Ron Klatchko Bastian Kleineidam + Bob Kline Matthias Klose Kim Knapp From jeremy@zope.com Fri Jun 28 18:56:33 2002 From: jeremy@zope.com (Jeremy Hylton) Date: Fri, 28 Jun 2002 13:56:33 -0400 Subject: [Python-checkins] python/dist/src/Lib httplib.py,1.51,1.52 In-Reply-To: References: Message-ID: <15644.41809.390447.315374@slothrop.zope.com> I forgot to say that this is a bugfix candidate. If no one beats me to it, I'll backport these fixes to 2.2 and 2.1. Jeremy From fdrake@users.sourceforge.net Fri Jun 28 23:56:50 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri, 28 Jun 2002 15:56:50 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_pyexpat.py,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv32623/Lib/test Modified Files: test_pyexpat.py Log Message: Added character data buffering to pyexpat parser objects. Setting the buffer_text attribute to true causes the parser to collect character data, waiting as long as possible to report it to the Python callback. This can save an enormous number of callbacks from C to Python, which can be a substantial performance improvement. buffer_text defaults to false. Index: test_pyexpat.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_pyexpat.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** test_pyexpat.py 27 Jun 2002 19:41:51 -0000 1.11 --- test_pyexpat.py 28 Jun 2002 22:56:48 -0000 1.12 *************** *** 7,11 **** from xml.parsers import expat ! from test_support import sortdict class Outputter: --- 7,11 ---- from xml.parsers import expat ! from test_support import sortdict, TestFailed class Outputter: *************** *** 219,220 **** --- 219,313 ---- print "L =", `L` break + + # Tests of the buffer_text attribute. + import sys + + class TextCollector: + def __init__(self, parser): + self.stuff = [] + + def check(self, expected, label): + require(self.stuff == expected, + "%s\nstuff = %s\nexpected = %s" + % (label, `self.stuff`, `map(unicode, expected)`)) + + def CharacterDataHandler(self, text): + self.stuff.append(text) + + def StartElementHandler(self, name, attrs): + self.stuff.append("<%s>" % name) + bt = attrs.get("buffer-text") + if bt == "yes": + parser.buffer_text = 1 + elif bt == "no": + parser.buffer_text = 0 + + def EndElementHandler(self, name): + self.stuff.append("" % name) + + def CommentHandler(self, data): + self.stuff.append("" % data) + + def require(cond, label): + # similar to confirm(), but no extraneous output + if not cond: + raise TestFailed(label) + + def setup(handlers=[]): + parser = expat.ParserCreate() + require(not parser.buffer_text, + "buffer_text not disabled by default") + parser.buffer_text = 1 + handler = TextCollector(parser) + parser.CharacterDataHandler = handler.CharacterDataHandler + for name in handlers: + setattr(parser, name, getattr(handler, name)) + return parser, handler + + parser, handler = setup() + require(parser.buffer_text, + "text buffering either not acknowledged or not enabled") + parser.Parse("123", 1) + handler.check(["123"], + "buffered text not properly collapsed") + + # XXX This test exposes more detail of Expat's text chunking than we + # XXX like, but it tests what we need to concisely. + parser, handler = setup(["StartElementHandler"]) + parser.Parse("12\n34\n5", 1) + handler.check(["", "1", "", "2", "\n", "3", "", "4\n5"], + "buffering control not reacting as expected") + + parser, handler = setup() + parser.Parse("1<2> \n 3", 1) + handler.check(["1<2> \n 3"], + "buffered text not properly collapsed") + + parser, handler = setup(["StartElementHandler"]) + parser.Parse("123", 1) + handler.check(["", "1", "", "2", "", "3"], + "buffered text not properly split") + + parser, handler = setup(["StartElementHandler", "EndElementHandler"]) + parser.CharacterDataHandler = None + parser.Parse("123", 1) + handler.check(["", "", "", "", "", ""], + "huh?") + + parser, handler = setup(["StartElementHandler", "EndElementHandler"]) + parser.Parse("123", 1) + handler.check(["", "1", "", "", "2", "", "", "3", ""], + "huh?") + + parser, handler = setup(["CommentHandler", "EndElementHandler", + "StartElementHandler"]) + parser.Parse("12345 ", 1) + handler.check(["", "1", "", "", "2", "", "", "345", ""], + "buffered text not properly split") + + parser, handler = setup(["CommentHandler", "EndElementHandler", + "StartElementHandler"]) + parser.Parse("12345 ", 1) + handler.check(["", "1", "", "", "2", "", "", "3", + "", "4", "", "5", ""], + "buffered text not properly split") From fdrake@users.sourceforge.net Fri Jun 28 23:56:51 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri, 28 Jun 2002 15:56:51 -0700 Subject: [Python-checkins] python/dist/src/Modules pyexpat.c,2.62,2.63 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv32623/Modules Modified Files: pyexpat.c Log Message: Added character data buffering to pyexpat parser objects. Setting the buffer_text attribute to true causes the parser to collect character data, waiting as long as possible to report it to the Python callback. This can save an enormous number of callbacks from C to Python, which can be a substantial performance improvement. buffer_text defaults to false. Index: pyexpat.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/pyexpat.c,v retrieving revision 2.62 retrieving revision 2.63 diff -C2 -d -r2.62 -r2.63 *** pyexpat.c 28 Jun 2002 22:29:01 -0000 2.62 --- pyexpat.c 28 Jun 2002 22:56:48 -0000 2.63 *************** *** 61,68 **** --- 61,74 ---- int specified_attributes; /* Report only specified attributes. */ int in_callback; /* Is a callback active? */ + XML_Char *buffer; /* Buffer used when accumulating characters */ + /* NULL if not enabled */ + int buffer_size; /* Size of buffer, in XML_Char units */ + int buffer_used; /* Buffer units in use */ PyObject *intern; /* Dictionary to intern strings */ PyObject **handlers; } xmlparseobject; + #define CHARACTER_DATA_BUFFER_SIZE 8192 + staticforward PyTypeObject Xmlparsetype; *************** *** 314,317 **** --- 320,402 ---- } + /* Return 0 on success, -1 on exception. + * flag_error() will be called before return if needed. + */ + static int + call_character_handler(xmlparseobject *self, const XML_Char *buffer, int len) + { + PyObject *args; + PyObject *temp; + + args = PyTuple_New(1); + if (args == NULL) + return -1; + #ifdef Py_USING_UNICODE + temp = (self->returns_unicode + ? conv_string_len_to_unicode(buffer, len) + : conv_string_len_to_utf8(buffer, len)); + #else + temp = conv_string_len_to_utf8(buffer, len); + #endif + if (temp == NULL) { + Py_DECREF(args); + flag_error(self); + return -1; + } + PyTuple_SET_ITEM(args, 0, temp); + /* temp is now a borrowed reference; consider it unused. */ + self->in_callback = 1; + temp = call_with_frame(getcode(CharacterData, "CharacterData", __LINE__), + self->handlers[CharacterData], args); + /* temp is an owned reference again, or NULL */ + self->in_callback = 0; + Py_DECREF(args); + if (temp == NULL) { + flag_error(self); + return -1; + } + Py_DECREF(temp); + return 0; + } + + static int + flush_character_buffer(xmlparseobject *self) + { + int rc; + if (self->buffer == NULL || self->buffer_used == 0) + return 0; + rc = call_character_handler(self, self->buffer, self->buffer_used); + self->buffer_used = 0; + return rc; + } + + static void + my_CharacterDataHandler(void *userData, const XML_Char *data, int len) + { + xmlparseobject *self = (xmlparseobject *) userData; + if (self->buffer == NULL) + call_character_handler(self, data, len); + else { + if ((self->buffer_used + len) > self->buffer_size) { + if (flush_character_buffer(self) < 0) + return; + /* handler might have changed; drop the rest on the floor + * if there isn't a handler anymore + */ + if (!have_handler(self, CharacterData)) + return; + } + if (len > self->buffer_size) { + call_character_handler(self, data, len); + self->buffer_used = 0; + } + else { + memcpy(self->buffer + self->buffer_used, + data, len * sizeof(XML_Char)); + self->buffer_used += len; + } + } + } + static void my_StartElementHandler(void *userData, *************** *** 324,327 **** --- 409,414 ---- int i, max; + if (flush_character_buffer(self) < 0) + return; /* Set max to the number of slots filled in atts[]; max/2 is * the number of attributes we need to process. *************** *** 403,406 **** --- 490,495 ---- \ if (have_handler(self, NAME)) { \ + if (flush_character_buffer(self) < 0) \ + return RETURN; \ args = Py_BuildValue PARAM_FORMAT ;\ if (!args) { flag_error(self); return RETURN;} \ *************** *** 439,454 **** ("(NO&)", string_intern(self, target), STRING_CONV_FUNC,data)) - #ifndef Py_USING_UNICODE - VOID_HANDLER(CharacterData, - (void *userData, const XML_Char *data, int len), - ("(N)", conv_string_len_to_utf8(data,len))) - #else - VOID_HANDLER(CharacterData, - (void *userData, const XML_Char *data, int len), - ("(N)", (self->returns_unicode - ? conv_string_len_to_unicode(data,len) - : conv_string_len_to_utf8(data,len)))) - #endif - VOID_HANDLER(UnparsedEntityDecl, (void *userData, --- 528,531 ---- *************** *** 674,677 **** --- 751,757 ---- return set_error(self); } + if (flush_character_buffer(self) < 0) { + return NULL; + } return PyInt_FromLong(rv); } *************** *** 891,894 **** --- 971,985 ---- if (new_parser == NULL) return NULL; + new_parser->buffer_size = self->buffer_size; + new_parser->buffer_used = 0; + if (self->buffer != NULL) { + new_parser->buffer = malloc(new_parser->buffer_size); + if (new_parser->buffer == NULL) { + PyObject_GC_Del(new_parser); + return PyErr_NoMemory(); + } + } + else + new_parser->buffer = NULL; new_parser->returns_unicode = self->returns_unicode; new_parser->ordered_attributes = self->ordered_attributes; *************** *** 914,921 **** /* allocate and clear handlers first */ ! for(i = 0; handler_info[i].name != NULL; i++) /* do nothing */; ! new_parser->handlers = malloc(sizeof(PyObject *)*i); if (!new_parser->handlers) { Py_DECREF(new_parser); --- 1005,1012 ---- /* allocate and clear handlers first */ ! for (i = 0; handler_info[i].name != NULL; i++) /* do nothing */; ! new_parser->handlers = malloc(sizeof(PyObject *) * i); if (!new_parser->handlers) { Py_DECREF(new_parser); *************** *** 1054,1057 **** --- 1145,1151 ---- self->returns_unicode = 1; #endif + self->buffer = NULL; + self->buffer_size = CHARACTER_DATA_BUFFER_SIZE; + self->buffer_used = 0; self->ordered_attributes = 0; self->specified_attributes = 0; *************** *** 1082,1086 **** #endif ! for(i = 0; handler_info[i].name != NULL; i++) /* do nothing */; --- 1176,1180 ---- #endif ! for (i = 0; handler_info[i].name != NULL; i++) /* do nothing */; *************** *** 1119,1122 **** --- 1213,1220 ---- self->handlers = NULL; } + if (self->buffer != NULL) { + free(self->buffer); + self->buffer = NULL; + } Py_XDECREF(self->intern); #if PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6 *************** *** 1180,1183 **** --- 1278,1289 ---- XML_GetErrorByteIndex(self->itself)); } + if (name[0] == 'b') { + if (strcmp(name, "buffer_size") == 0) + return PyInt_FromLong((long) self->buffer_size); + if (strcmp(name, "buffer_text") == 0) + return get_pybool(self->buffer != NULL); + if (strcmp(name, "buffer_used") == 0) + return PyInt_FromLong((long) self->buffer_used); + } if (strcmp(name, "ordered_attributes") == 0) return get_pybool(self->ordered_attributes); *************** *** 1207,1210 **** --- 1313,1319 ---- PyList_Append(rc, PyString_FromString("ErrorColumnNumber")); PyList_Append(rc, PyString_FromString("ErrorByteIndex")); + PyList_Append(rc, PyString_FromString("buffer_size")); + PyList_Append(rc, PyString_FromString("buffer_text")); + PyList_Append(rc, PyString_FromString("buffer_used")); PyList_Append(rc, PyString_FromString("ordered_attributes")); PyList_Append(rc, PyString_FromString("returns_unicode")); *************** *** 1247,1250 **** --- 1356,1378 ---- return -1; } + if (strcmp(name, "buffer_text") == 0) { + if (PyObject_IsTrue(v)) { + if (self->buffer == NULL) { + self->buffer = malloc(self->buffer_size); + if (self->buffer == NULL) { + PyErr_NoMemory(); + return -1; + } + self->buffer_used = 0; + } + } + else if (self->buffer != NULL) { + if (flush_character_buffer(self) < 0) + return -1; + free(self->buffer); + self->buffer = NULL; + } + return 0; + } if (strcmp(name, "ordered_attributes") == 0) { if (PyObject_IsTrue(v)) *************** *** 1275,1278 **** --- 1403,1415 ---- return 0; } + if (strcmp(name, "CharacterDataHandler") == 0) { + /* If we're changing the character data handler, flush all + * cached data with the old handler. Not sure there's a + * "right" thing to do, though, but this probably won't + * happen. + */ + if (flush_character_buffer(self) < 0) + return -1; + } if (sethandler(self, name, v)) { return 0; *************** *** 1659,1672 **** {"UnparsedEntityDeclHandler", (xmlhandlersetter)XML_SetUnparsedEntityDeclHandler, ! (xmlhandler)my_UnparsedEntityDeclHandler }, {"NotationDeclHandler", (xmlhandlersetter)XML_SetNotationDeclHandler, ! (xmlhandler)my_NotationDeclHandler }, {"StartNamespaceDeclHandler", (xmlhandlersetter)XML_SetStartNamespaceDeclHandler, ! (xmlhandler)my_StartNamespaceDeclHandler }, {"EndNamespaceDeclHandler", (xmlhandlersetter)XML_SetEndNamespaceDeclHandler, ! (xmlhandler)my_EndNamespaceDeclHandler }, {"CommentHandler", (xmlhandlersetter)XML_SetCommentHandler, --- 1796,1809 ---- {"UnparsedEntityDeclHandler", (xmlhandlersetter)XML_SetUnparsedEntityDeclHandler, ! (xmlhandler)my_UnparsedEntityDeclHandler}, {"NotationDeclHandler", (xmlhandlersetter)XML_SetNotationDeclHandler, ! (xmlhandler)my_NotationDeclHandler}, {"StartNamespaceDeclHandler", (xmlhandlersetter)XML_SetStartNamespaceDeclHandler, ! (xmlhandler)my_StartNamespaceDeclHandler}, {"EndNamespaceDeclHandler", (xmlhandlersetter)XML_SetEndNamespaceDeclHandler, ! (xmlhandler)my_EndNamespaceDeclHandler}, {"CommentHandler", (xmlhandlersetter)XML_SetCommentHandler, *************** *** 1689,1693 **** {"ExternalEntityRefHandler", (xmlhandlersetter)XML_SetExternalEntityRefHandler, ! (xmlhandler)my_ExternalEntityRefHandler }, {"StartDoctypeDeclHandler", (xmlhandlersetter)XML_SetStartDoctypeDeclHandler, --- 1826,1830 ---- {"ExternalEntityRefHandler", (xmlhandlersetter)XML_SetExternalEntityRefHandler, ! (xmlhandler)my_ExternalEntityRefHandler}, {"StartDoctypeDeclHandler", (xmlhandlersetter)XML_SetStartDoctypeDeclHandler, From jhylton@users.sourceforge.net Sat Jun 29 00:32:53 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Fri, 28 Jun 2002 16:32:53 -0700 Subject: [Python-checkins] python/dist/src/Lib imputil.py,1.25,1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv11632 Modified Files: imputil.py Log Message: Close SF patch 523944: importing modules with foreign newlines. Didn't use the patch, because universal newlines support made it easy. It might be worth fixing the actual problem in the 2.2 maintenance branch, in which case the patch is still needed. Index: imputil.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/imputil.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** imputil.py 1 Jun 2002 19:51:15 -0000 1.25 --- imputil.py 28 Jun 2002 23:32:51 -0000 1.26 *************** *** 411,415 **** modification timestamp must be provided as a Long value. """ ! codestring = open(pathname, 'r').read() if codestring and codestring[-1] != '\n': codestring = codestring + '\n' --- 411,415 ---- modification timestamp must be provided as a Long value. """ ! codestring = open(pathname, 'rU').read() if codestring and codestring[-1] != '\n': codestring = codestring + '\n' From jhylton@users.sourceforge.net Sat Jun 29 00:38:16 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Fri, 28 Jun 2002 16:38:16 -0700 Subject: [Python-checkins] python/dist/src/Lib httplib.py,1.52,1.53 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv14075 Modified Files: httplib.py Log Message: Simplify HTTPSConnection constructor. See discussion in SF bug 458463. Index: httplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/httplib.py,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** httplib.py 28 Jun 2002 22:38:01 -0000 1.52 --- httplib.py 28 Jun 2002 23:38:14 -0000 1.53 *************** *** 79,86 **** __all__ = ["HTTP", "HTTPResponse", "HTTPConnection", "HTTPSConnection", "HTTPException", "NotConnected", "UnknownProtocol", ! "UnknownTransferEncoding", "IllegalKeywordArgument", ! "UnimplementedFileMode", "IncompleteRead", "InvalidURL", ! "ImproperConnectionState", "CannotSendRequest", "CannotSendHeader", ! "ResponseNotReady", "BadStatusLine", "error"] HTTP_PORT = 80 --- 79,86 ---- __all__ = ["HTTP", "HTTPResponse", "HTTPConnection", "HTTPSConnection", "HTTPException", "NotConnected", "UnknownProtocol", ! "UnknownTransferEncoding", "UnimplementedFileMode", ! "IncompleteRead", "InvalidURL", "ImproperConnectionState", ! "CannotSendRequest", "CannotSendHeader", "ResponseNotReady", ! "BadStatusLine", "error"] HTTP_PORT = 80 *************** *** 734,752 **** default_port = HTTPS_PORT ! def __init__(self, host, port=None, **x509): ! keys = x509.keys() ! try: ! keys.remove('key_file') ! except ValueError: ! pass ! try: ! keys.remove('cert_file') ! except ValueError: ! pass ! if keys: ! raise IllegalKeywordArgument() HTTPConnection.__init__(self, host, port) ! self.key_file = x509.get('key_file') ! self.cert_file = x509.get('cert_file') def connect(self): --- 734,741 ---- default_port = HTTPS_PORT ! def __init__(self, host, port=None, key_file=None, cert_file=None): HTTPConnection.__init__(self, host, port) ! self.key_file = key_file ! self.cert_file = cert_file def connect(self): *************** *** 890,896 **** class UnknownTransferEncoding(HTTPException): - pass - - class IllegalKeywordArgument(HTTPException): pass --- 879,882 ---- From bwarsaw@users.sourceforge.net Sat Jun 29 00:41:44 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Fri, 28 Jun 2002 16:41:44 -0700 Subject: [Python-checkins] python/dist/src/Lib/email Generator.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email In directory usw-pr-cvs1:/tmp/cvs-serv15842/email Modified Files: Generator.py Log Message: _split_header(): The code here was terminally broken because it didn't know anything about RFC 2047 encoded headers. Fortunately we have a perfectly good header splitter in Header.encode(). So we just call that to give us a properly formatted and split header. Header.encode() didn't know about "highest-level syntactic breaks" but that's been fixed now too. Index: Generator.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/Generator.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Generator.py 2 Jun 2002 19:02:37 -0000 1.9 --- Generator.py 28 Jun 2002 23:41:42 -0000 1.10 *************** *** 12,15 **** --- 12,17 ---- from cStringIO import StringIO + from email.Header import Header + EMPTYSTRING = '' SEMISPACE = '; ' *************** *** 150,164 **** text = '%s: %s' % (h, v) if self.__maxheaderlen > 0 and len(text) > self.__maxheaderlen: ! text = self._split_header(text) print >> self._fp, text # A blank line always separates headers from body print >> self._fp ! def _split_header(self, text): maxheaderlen = self.__maxheaderlen # Find out whether any lines in the header are really longer than # maxheaderlen characters wide. There could be continuation lines # that actually shorten it. Also, replace hard tabs with 8 spaces. ! lines = [s.replace('\t', SPACE8) for s in text.split('\n')] for line in lines: if len(line) > maxheaderlen: --- 152,166 ---- text = '%s: %s' % (h, v) if self.__maxheaderlen > 0 and len(text) > self.__maxheaderlen: ! text = self._split_header(h, text) print >> self._fp, text # A blank line always separates headers from body print >> self._fp ! def _split_header(self, name, text): maxheaderlen = self.__maxheaderlen # Find out whether any lines in the header are really longer than # maxheaderlen characters wide. There could be continuation lines # that actually shorten it. Also, replace hard tabs with 8 spaces. ! lines = [s.replace('\t', SPACE8) for s in text.splitlines()] for line in lines: if len(line) > maxheaderlen: *************** *** 168,221 **** # just return the original unchanged. return text ! rtn = [] ! for line in text.split('\n'): ! splitline = [] ! # Short lines can remain unchanged ! if len(line.replace('\t', SPACE8)) <= maxheaderlen: ! splitline.append(line) ! rtn.append(SEMINLTAB.join(splitline)) ! else: ! oldlen = len(line) ! # Try to break the line on semicolons, but if that doesn't ! # work, try to split on folding whitespace. ! while len(line) > maxheaderlen: ! i = line.rfind(';', 0, maxheaderlen) ! if i < 0: ! break ! splitline.append(line[:i]) ! line = line[i+1:].lstrip() ! if len(line) <> oldlen: ! # Splitting on semis worked ! splitline.append(line) ! rtn.append(SEMINLTAB.join(splitline)) ! continue ! # Splitting on semis didn't help, so try to split on ! # whitespace. ! parts = re.split(r'(\s+)', line) ! # Watch out though for "Header: longnonsplittableline" ! if parts[0].endswith(':') and len(parts) == 3: ! rtn.append(line) ! continue ! first = parts.pop(0) ! sublines = [first] ! acc = len(first) ! while parts: ! len0 = len(parts[0]) ! len1 = len(parts[1]) ! if acc + len0 + len1 < maxheaderlen: ! sublines.append(parts.pop(0)) ! sublines.append(parts.pop(0)) ! acc += len0 + len1 ! else: ! # Split it here, but don't forget to ignore the ! # next whitespace-only part ! splitline.append(EMPTYSTRING.join(sublines)) ! del parts[0] ! first = parts.pop(0) ! sublines = [first] ! acc = len(first) ! splitline.append(EMPTYSTRING.join(sublines)) ! rtn.append(NLTAB.join(splitline)) ! return NL.join(rtn) # --- 170,179 ---- # just return the original unchanged. return text ! # The `text' argument already has the field name prepended, so don't ! # provide it here or the first line will get folded too short. ! h = Header(text, maxlinelen=maxheaderlen, ! # For backwards compatibility, we use a hard tab here ! continuation_ws='\t') ! return h.encode() # From bwarsaw@users.sourceforge.net Sat Jun 29 00:46:56 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Fri, 28 Jun 2002 16:46:56 -0700 Subject: [Python-checkins] python/dist/src/Lib/email Header.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email In directory usw-pr-cvs1:/tmp/cvs-serv18840/email Modified Files: Header.py Log Message: Teach this class about "highest-level syntactic breaks" but only for headers with no charset or 'us-ascii' charsets. Actually this is only partially true: we know about semicolons (but not true parameters) and we know about whitespace (but not technically folding whitespace). Still it should be good enough for all practical purposes. Other changes include: __init__(): Add a continuation_ws argument, which defaults to a single space. Set this to change the whitespace used for continuation lines when a header must be split. Also, changed the way header line lengths are calculated, so that they take into account continuation_ws (when tabs-expanded) and any provided header_name parameter. This should do much better on returning split headers for which the first and subsequent lines must fit into a specified width. guess_maxlinelen(): Removed. I don't think we need this method as part of the public API. encode_chunks() -> _encode_chunks(): I don't think we need this one as part of the public API either. Index: Header.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/Header.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Header.py 1 Jun 2002 05:49:17 -0000 1.4 --- Header.py 28 Jun 2002 23:46:53 -0000 1.5 *************** *** 17,21 **** CRLFSPACE = '\r\n ' CRLF = '\r\n' ! NLSPACE = '\n ' MAXLINELEN = 76 --- 17,23 ---- CRLFSPACE = '\r\n ' CRLF = '\r\n' ! NL = '\n' ! SPACE8 = ' ' * 8 ! EMPTYSTRING = '' MAXLINELEN = 76 *************** *** 93,101 **** class Header: ! def __init__(self, s, charset=None, maxlinelen=None, header_name=None): """Create a MIME-compliant header that can contain many languages. Specify the initial header value in s. Specify its character set as a ! Charset object in the charset argument. If none, a default Charset instance will be used. --- 95,104 ---- class Header: ! def __init__(self, s, charset=None, maxlinelen=None, header_name=None, ! continuation_ws=' '): """Create a MIME-compliant header that can contain many languages. Specify the initial header value in s. Specify its character set as a ! Charset object in the charset argument. If None, a default Charset instance will be used. *************** *** 105,126 **** charset specified in the constructor. ! The maximum line length can be specified explicitly via maxlinelen. ! You can also pass None for maxlinelen and the name of a header field ! (e.g. "Subject") to let the constructor guess the best line length to ! use. The default maxlinelen is 76. """ if charset is None: charset = Charset() self._charset = charset # BAW: I believe `chunks' and `maxlinelen' should be non-public. self._chunks = [] self.append(s, charset) if maxlinelen is None: ! if header_name is None: ! self._maxlinelen = MAXLINELEN ! else: ! self.guess_maxlinelen(header_name) else: ! self._maxlinelen = maxlinelen def __str__(self): --- 108,141 ---- charset specified in the constructor. ! The maximum line length can be specified explicit via maxlinelen. For ! splitting the first line to a shorter value (to account for the field ! header which isn't included in s, e.g. `Subject') pass in the name of ! the field in header_name. The default maxlinelen is 76. ! ! continuation_ws must be RFC 2822 compliant folding whitespace (usually ! either a space or a hard tab) which will be prepended to continuation ! lines. """ if charset is None: charset = Charset() self._charset = charset + self._continuation_ws = continuation_ws + cws_expanded_len = len(continuation_ws.replace('\t', SPACE8)) # BAW: I believe `chunks' and `maxlinelen' should be non-public. self._chunks = [] self.append(s, charset) if maxlinelen is None: ! maxlinelen = MAXLINELEN ! if header_name is None: ! # We don't know anything about the field header so the first line ! # is the same length as subsequent lines. ! self._firstlinelen = maxlinelen else: ! # The first line should be shorter to take into account the field ! # header. Also subtract off 2 extra for the colon and space. ! self._firstlinelen = maxlinelen - len(header_name) - 2 ! # Second and subsequent lines should subtract off the length in ! # columns of the continuation whitespace prefix. ! self._maxlinelen = maxlinelen - cws_expanded_len def __str__(self): *************** *** 128,145 **** return self.encode() - def guess_maxlinelen(self, s=None): - """Guess the maximum length to make each header line. - - Given a header name (e.g. "Subject"), set this header's maximum line - length to an appropriate length to avoid line wrapping. If s is not - given, return the previous maximum line length and don't set it. - - Returns the new maximum line length. - """ - # BAW: is this semantic necessary? - if s is not None: - self._maxlinelen = MAXLINELEN - len(s) - 2 - return self._maxlinelen - def append(self, s, charset=None): """Append string s with Charset charset to the MIME header. --- 143,146 ---- *************** *** 151,155 **** self._chunks.append((s, charset)) ! def _split(self, s, charset): # Split up a header safely for use with encode_chunks. BAW: this # appears to be a private convenience method. --- 152,156 ---- self._chunks.append((s, charset)) ! def _split(self, s, charset, firstline=0): # Split up a header safely for use with encode_chunks. BAW: this # appears to be a private convenience method. *************** *** 160,163 **** --- 161,178 ---- if elen <= self._maxlinelen: return [(encoded, charset)] + # BAW: I'm not sure what the right test here is. What we're trying to + # do is be faithful to RFC 2822's recommendation that ($2.2.3): + # + # "Note: Though structured field bodies are defined in such a way that + # folding can take place between many of the lexical tokens (and even + # within some of the lexical tokens), folding SHOULD be limited to + # placing the CRLF at higher-level syntactic breaks." + # + # For now, I can only imagine doing this when the charset is us-ascii, + # although it's possible that other charsets may also benefit from the + # higher-level syntactic breaks. + # + elif charset == 'us-ascii': + return self._ascii_split(s, charset, firstline) # BAW: should we use encoded? elif elen == len(s): *************** *** 167,171 **** first = charset.from_splittable(splittable[:splitpnt], 0) last = charset.from_splittable(splittable[splitpnt:], 0) - return self._split(first, charset) + self._split(last, charset) else: # Divide and conquer. --- 182,185 ---- *************** *** 173,203 **** first = charset.from_splittable(splittable[:halfway], 0) last = charset.from_splittable(splittable[halfway:], 0) ! return self._split(first, charset) + self._split(last, charset) ! ! def encode(self): ! """Encode a message header, possibly converting charset and encoding. ! ! There are many issues involved in converting a given string for use in ! an email header. Only certain character sets are readable in most ! email clients, and as header strings can only contain a subset of ! 7-bit ASCII, care must be taken to properly convert and encode (with ! Base64 or quoted-printable) header strings. In addition, there is a ! 75-character length limit on any given encoded header field, so ! line-wrapping must be performed, even with double-byte character sets. ! ! This method will do its best to convert the string to the correct ! character set used in email, and encode and line wrap it safely with ! the appropriate scheme for that character set. ! If the given charset is not known or an error occurs during ! conversion, this function will return the header untouched. ! """ ! newchunks = [] ! for s, charset in self._chunks: ! newchunks += self._split(s, charset) ! self._chunks = newchunks ! return self.encode_chunks() ! def encode_chunks(self): """MIME-encode a header with many different charsets and/or encodings. --- 187,270 ---- first = charset.from_splittable(splittable[:halfway], 0) last = charset.from_splittable(splittable[halfway:], 0) ! # Do the split ! return self._split(first, charset, firstline) + \ ! self._split(last, charset) ! def _ascii_split(self, s, charset, firstline): ! # Attempt to split the line at the highest-level syntactic break ! # possible. Note that we don't have a lot of smarts about field ! # syntax; we just try to break on semi-colons, then whitespace. ! rtn = [] ! lines = s.splitlines() ! while lines: ! line = lines.pop(0) ! if firstline: ! maxlinelen = self._firstlinelen ! firstline = 0 ! else: ! line = line.lstrip() ! maxlinelen = self._maxlinelen ! # Short lines can remain unchanged ! if len(line.replace('\t', SPACE8)) <= maxlinelen: ! rtn.append(line) ! else: ! oldlen = len(line) ! # Try to break the line on semicolons, but if that doesn't ! # work, try to split on folding whitespace. ! while len(line) > maxlinelen: ! i = line.rfind(';', 0, maxlinelen) ! if i < 0: ! break ! rtn.append(line[:i] + ';') ! line = line[i+1:] ! # Is the remaining stuff still longer than maxlinelen? ! if len(line) <= maxlinelen: ! # Splitting on semis worked ! rtn.append(line) ! continue ! # Splitting on semis didn't finish the job. If it did any ! # work at all, stick the remaining junk on the front of the ! # `lines' sequence and let the next pass do its thing. ! if len(line) <> oldlen: ! lines.insert(0, line) ! continue ! # Otherwise, splitting on semis didn't help at all. ! parts = re.split(r'(\s+)', line) ! if len(parts) == 1 or (len(parts) == 3 and ! parts[0].endswith(':')): ! # This line can't be split on whitespace. There's now ! # little we can do to get this into maxlinelen. BAW: ! # We're still potentially breaking the RFC by possibly ! # allowing lines longer than the absolute maximum of 998 ! # characters. For now, let it slide. ! # ! # len(parts) will be 1 if this line has no `Field: ' ! # prefix, otherwise it will be len(3). ! rtn.append(line) ! continue ! # There is whitespace we can split on. ! first = parts.pop(0) ! sublines = [first] ! acc = len(first) ! while parts: ! len0 = len(parts[0]) ! len1 = len(parts[1]) ! if acc + len0 + len1 <= maxlinelen: ! sublines.append(parts.pop(0)) ! sublines.append(parts.pop(0)) ! acc += len0 + len1 ! else: ! # Split it here, but don't forget to ignore the ! # next whitespace-only part ! if first <> '': ! rtn.append(EMPTYSTRING.join(sublines)) ! del parts[0] ! first = parts.pop(0) ! sublines = [first] ! acc = len(first) ! rtn.append(EMPTYSTRING.join(sublines)) ! return [(chunk, charset) for chunk in rtn] ! def _encode_chunks(self): """MIME-encode a header with many different charsets and/or encodings. *************** *** 220,227 **** chunks = [] for header, charset in self._chunks: ! if charset is None: ! _max_append(chunks, header, self._maxlinelen, ' ') else: _max_append(chunks, charset.header_encode(header, 0), self._maxlinelen, ' ') ! return NLSPACE.join(chunks) --- 287,320 ---- chunks = [] for header, charset in self._chunks: ! if charset is None or charset.header_encoding is None: ! # There's no encoding for this chunk's charsets ! _max_append(chunks, header, self._maxlinelen) else: _max_append(chunks, charset.header_encode(header, 0), self._maxlinelen, ' ') ! joiner = NL + self._continuation_ws ! return joiner.join(chunks) ! ! def encode(self): ! """Encode a message header, possibly converting charset and encoding. ! ! There are many issues involved in converting a given string for use in ! an email header. Only certain character sets are readable in most ! email clients, and as header strings can only contain a subset of ! 7-bit ASCII, care must be taken to properly convert and encode (with ! Base64 or quoted-printable) header strings. In addition, there is a ! 75-character length limit on any given encoded header field, so ! line-wrapping must be performed, even with double-byte character sets. ! ! This method will do its best to convert the string to the correct ! character set used in email, and encode and line wrap it safely with ! the appropriate scheme for that character set. ! ! If the given charset is not known or an error occurs during ! conversion, this function will return the header untouched. ! """ ! newchunks = [] ! for s, charset in self._chunks: ! newchunks += self._split(s, charset, 1) ! self._chunks = newchunks ! return self._encode_chunks() From bwarsaw@users.sourceforge.net Sat Jun 29 00:48:26 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Fri, 28 Jun 2002 16:48:26 -0700 Subject: [Python-checkins] python/dist/src/Lib/email quopriMIME.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email In directory usw-pr-cvs1:/tmp/cvs-serv19646/email Modified Files: quopriMIME.py Log Message: _max_append(): When adding the string `s' to its own line, it should be lstrip'd so that old continuation whitespace is replaced by that specified in Header's continuation_ws parameter. Index: quopriMIME.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/quopriMIME.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** quopriMIME.py 23 May 2002 15:15:30 -0000 1.2 --- quopriMIME.py 28 Jun 2002 23:48:23 -0000 1.3 *************** *** 76,84 **** def _max_append(L, s, maxlen, extra=''): if not L: ! L.append(s) elif len(L[-1]) + len(s) < maxlen: L[-1] += extra + s else: ! L.append(s) --- 76,84 ---- def _max_append(L, s, maxlen, extra=''): if not L: ! L.append(s.lstrip()) elif len(L[-1]) + len(s) < maxlen: L[-1] += extra + s else: ! L.append(s.lstrip()) From bwarsaw@users.sourceforge.net Sat Jun 29 00:49:35 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Fri, 28 Jun 2002 16:49:35 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_email.py,1.34,1.35 test_email_codecs.py,1.2,1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv20251/test Modified Files: test_email.py test_email_codecs.py Log Message: Lots of new and updated tests to check for proper ascii header folding. Note that some of the Japanese tests have changed, but I don't really know if they are correct or not. :( Someone with Japanese and RFC 2047 expertise, please take a look! Index: test_email.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_email.py,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** test_email.py 2 Jun 2002 19:09:27 -0000 1.34 --- test_email.py 28 Jun 2002 23:49:32 -0000 1.35 *************** *** 7,10 **** --- 7,11 ---- import unittest import base64 + import difflib from cStringIO import StringIO from types import StringType, ListType *************** *** 51,54 **** --- 52,63 ---- # Base test class class TestEmailBase(unittest.TestCase): + def ndiffAssertEqual(self, first, second): + """Like failUnlessEqual except use ndiff to produce readable output.""" + if first <> second: + diff = difflib.ndiff(first.splitlines(), second.splitlines()) + fp = StringIO() + print >> fp, NL, NL.join(diff) + raise self.failureException, fp.getvalue() + def _msgobj(self, filename): fp = openfile(findfile(filename)) *************** *** 394,399 **** # Test long header wrapping ! class TestLongHeaders(unittest.TestCase): def test_header_splitter(self): msg = MIMEText('') # It'd be great if we could use add_header() here, but that doesn't --- 403,516 ---- # Test long header wrapping ! class TestLongHeaders(TestEmailBase): ! def test_split_long_continuation(self): ! eq = self.ndiffAssertEqual ! msg = email.message_from_string("""\ ! Subject: bug demonstration ! \t12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789 ! \tmore text ! ! test ! """) ! sfp = StringIO() ! g = Generator(sfp) ! g.flatten(msg) ! eq(sfp.getvalue(), """\ ! Subject: bug demonstration ! \t12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789 ! \tmore text ! ! test ! """) ! ! def test_another_long_almost_unsplittable_header(self): ! eq = self.ndiffAssertEqual ! hstr = """\ ! bug demonstration ! \t12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789 ! \tmore text""" ! h = Header(hstr, continuation_ws='\t') ! eq(h.encode(), """\ ! bug demonstration ! \t12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789 ! \tmore text""") ! h = Header(hstr) ! eq(h.encode(), """\ ! bug demonstration ! 12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789 ! more text""") ! ! def test_long_nonstring(self): ! eq = self.ndiffAssertEqual ! g = Charset("iso-8859-1") ! cz = Charset("iso-8859-2") ! utf8 = Charset("utf-8") ! g_head = "Die Mieter treten hier ein werden mit einem Foerderband komfortabel den Korridor entlang, an s\xfcdl\xfcndischen Wandgem\xe4lden vorbei, gegen die rotierenden Klingen bef\xf6rdert. " ! cz_head = "Finan\xe8ni metropole se hroutily pod tlakem jejich d\xf9vtipu.. " ! utf8_head = u"\u6b63\u78ba\u306b\u8a00\u3046\u3068\u7ffb\u8a33\u306f\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002\u4e00\u90e8\u306f\u30c9\u30a4\u30c4\u8a9e\u3067\u3059\u304c\u3001\u3042\u3068\u306f\u3067\u305f\u3089\u3081\u3067\u3059\u3002\u5b9f\u969b\u306b\u306f\u300cWenn ist das Nunstuck git und Slotermeyer? Ja! Beiherhund das Oder die Flipperwaldt gersput.\u300d\u3068\u8a00\u3063\u3066\u3044\u307e\u3059\u3002".encode("utf-8") ! h = Header(g_head, g) ! h.append(cz_head, cz) ! h.append(utf8_head, utf8) ! msg = Message() ! msg['Subject'] = h ! sfp = StringIO() ! g = Generator(sfp) ! g.flatten(msg) ! eq(sfp.getvalue(), '''\ ! Subject: =?iso-8859-1?q?Die_Mieter_treten_hier_ein_werden_mit_eine?= ! =?iso-8859-1?q?m_Foerderband_komfortabel_den_Korridor_ent?= ! =?iso-8859-1?q?lang=2C_an_s=FCdl=FCndischen_Wandgem=E4lden_vorbei?= ! =?iso-8859-1?q?=2C_gegen_die_rotierenden_Klingen_bef=F6rdert=2E_?= ! =?iso-8859-2?q?Finan=E8ni_metropole_se_hroutil?= ! =?iso-8859-2?q?y_pod_tlakem_jejich_d=F9vtipu=2E=2E_?= ! =?utf-8?b?5q2j56K644Gr6KiA44GG44Go57+76Kiz44Gv?= ! =?utf-8?b?44GV44KM44Gm44GE44G+44Gb44KT44CC5LiA?= ! =?utf-8?b?6YOo44Gv44OJ44Kk44OE6Kqe44Gn44GZ44GM?= ! =?utf-8?b?44CB44GC44Go44Gv44Gn44Gf44KJ44KB44Gn?= ! =?utf-8?b?44GZ44CC5a6f6Zqb44Gr44Gv44CMV2VubiBpc3QgZGE=?= ! =?utf-8?b?cyBOdW5zdHVjayBnaXQgdW5k?= ! =?utf-8?b?IFNsb3Rlcm1leWVyPyBKYSEgQmVpaGVyaHVuZCBkYXMgT2Rl?= ! =?utf-8?b?ciBkaWUgRmxpcHBlcndhbGR0?= ! =?utf-8?b?IGdlcnNwdXQu44CN44Go6KiA44Gj44Gm44GE44G+44GZ44CC?= ! ! ''') ! eq(h.encode(), '''\ ! =?iso-8859-1?q?Die_Mieter_treten_hier_ein_werden_mit_eine?= ! =?iso-8859-1?q?m_Foerderband_komfortabel_den_Korridor_ent?= ! =?iso-8859-1?q?lang=2C_an_s=FCdl=FCndischen_Wandgem=E4lden_vorbei?= ! =?iso-8859-1?q?=2C_gegen_die_rotierenden_Klingen_bef=F6rdert=2E_?= ! =?iso-8859-2?q?Finan=E8ni_metropole_se_hroutil?= ! =?iso-8859-2?q?y_pod_tlakem_jejich_d=F9vtipu=2E=2E_?= ! =?utf-8?b?5q2j56K644Gr6KiA44GG44Go57+76Kiz44Gv?= ! =?utf-8?b?44GV44KM44Gm44GE44G+44Gb44KT44CC5LiA?= ! =?utf-8?b?6YOo44Gv44OJ44Kk44OE6Kqe44Gn44GZ44GM?= ! =?utf-8?b?44CB44GC44Go44Gv44Gn44Gf44KJ44KB44Gn?= ! =?utf-8?b?44GZ44CC5a6f6Zqb44Gr44Gv44CMV2VubiBpc3QgZGE=?= ! =?utf-8?b?cyBOdW5zdHVjayBnaXQgdW5k?= ! =?utf-8?b?IFNsb3Rlcm1leWVyPyBKYSEgQmVpaGVyaHVuZCBkYXMgT2Rl?= ! =?utf-8?b?ciBkaWUgRmxpcHBlcndhbGR0?= ! =?utf-8?b?IGdlcnNwdXQu44CN44Go6KiA44Gj44Gm44GE44G+44GZ44CC?=''') ! ! def test_long_header_encode(self): ! eq = self.ndiffAssertEqual ! h = Header('wasnipoop; giraffes="very-long-necked-animals"; ' ! 'spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"', ! header_name='X-Foobar-Spoink-Defrobnit') ! eq(h.encode(), '''\ ! wasnipoop; giraffes="very-long-necked-animals"; ! spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"''') ! ! def test_long_header_encode_with_tab_continuation(self): ! eq = self.ndiffAssertEqual ! h = Header('wasnipoop; giraffes="very-long-necked-animals"; ' ! 'spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"', ! header_name='X-Foobar-Spoink-Defrobnit', ! continuation_ws='\t') ! eq(h.encode(), '''\ ! wasnipoop; giraffes="very-long-necked-animals"; ! \tspooge="yummy"; hippos="gargantuan"; marshmallows="gooey"''') ! def test_header_splitter(self): + eq = self.ndiffAssertEqual msg = MIMEText('') # It'd be great if we could use add_header() here, but that doesn't *************** *** 405,409 **** g = Generator(sfp) g.flatten(msg) ! self.assertEqual(sfp.getvalue(), '''\ Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 --- 522,526 ---- g = Generator(sfp) g.flatten(msg) ! eq(sfp.getvalue(), '''\ Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 *************** *** 415,429 **** def test_no_semis_header_splitter(self): msg = Message() msg['From'] = 'test@dom.ain' ! refparts = [] ! for i in range(10): ! refparts.append('<%d@dom.ain>' % i) ! msg['References'] = SPACE.join(refparts) msg.set_payload('Test') sfp = StringIO() g = Generator(sfp) g.flatten(msg) ! self.assertEqual(sfp.getvalue(), """\ From: test@dom.ain References: <0@dom.ain> <1@dom.ain> <2@dom.ain> <3@dom.ain> <4@dom.ain> --- 532,544 ---- def test_no_semis_header_splitter(self): + eq = self.ndiffAssertEqual msg = Message() msg['From'] = 'test@dom.ain' ! msg['References'] = SPACE.join(['<%d@dom.ain>' % i for i in range(10)]) msg.set_payload('Test') sfp = StringIO() g = Generator(sfp) g.flatten(msg) ! eq(sfp.getvalue(), """\ From: test@dom.ain References: <0@dom.ain> <1@dom.ain> <2@dom.ain> <3@dom.ain> <4@dom.ain> *************** *** 433,459 **** def test_no_split_long_header(self): ! msg = Message() ! msg['From'] = 'test@dom.ain' ! refparts = [] ! msg['References'] = 'x' * 80 ! msg.set_payload('Test') ! sfp = StringIO() ! g = Generator(sfp) ! g.flatten(msg) ! self.assertEqual(sfp.getvalue(), """\ ! From: test@dom.ain ! References: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ! ! Test""") def test_splitting_multiple_long_lines(self): ! msg = Message() ! msg['Received'] = """\ from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for ; Sat, 2 Feb 2002 17:00:06 -0800 (PST) \tfrom babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for ; Sat, 2 Feb 2002 17:00:06 -0800 (PST) \tfrom babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for ; Sat, 2 Feb 2002 17:00:06 -0800 (PST) """ ! self.assertEqual(msg.as_string(), """\ ! Received: from babylon.socal-raves.org (localhost [127.0.0.1]); \tby babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; \tfor ; --- 548,567 ---- def test_no_split_long_header(self): ! eq = self.ndiffAssertEqual ! hstr = 'References: ' + 'x' * 80 ! h = Header(hstr, continuation_ws='\t') ! eq(h.encode(), """\ ! References: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx""") def test_splitting_multiple_long_lines(self): ! eq = self.ndiffAssertEqual ! hstr = """\ from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for ; Sat, 2 Feb 2002 17:00:06 -0800 (PST) \tfrom babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for ; Sat, 2 Feb 2002 17:00:06 -0800 (PST) \tfrom babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for ; Sat, 2 Feb 2002 17:00:06 -0800 (PST) """ ! h = Header(hstr, continuation_ws='\t') ! eq(h.encode(), """\ ! from babylon.socal-raves.org (localhost [127.0.0.1]); \tby babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; \tfor ; *************** *** 466,473 **** \tby babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; \tfor ; ! \tSat, 2 Feb 2002 17:00:06 -0800 (PST) ! ! ! """) --- 574,578 ---- \tby babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; \tfor ; ! \tSat, 2 Feb 2002 17:00:06 -0800 (PST)""") *************** *** 994,998 **** # should be identical. Note: that we ignore the Unix-From since that may # contain a changed date. ! class TestIdempotent(unittest.TestCase): def _msgobj(self, filename): fp = openfile(filename) --- 1099,1103 ---- # should be identical. Note: that we ignore the Unix-From since that may # contain a changed date. ! class TestIdempotent(TestEmailBase): def _msgobj(self, filename): fp = openfile(filename) *************** *** 1005,1009 **** def _idempotent(self, msg, text): ! eq = self.assertEquals s = StringIO() g = Generator(s, maxheaderlen=0) --- 1110,1114 ---- def _idempotent(self, msg, text): ! eq = self.ndiffAssertEqual s = StringIO() g = Generator(s, maxheaderlen=0) *************** *** 1039,1042 **** --- 1144,1151 ---- self._idempotent(msg, text) + ## def test_MIME_digest_with_part_headers(self): + ## msg, text = self._msgobj('msg_28.txt') + ## self._idempotent(msg, text) + def test_mixed_with_image(self): msg, text = self._msgobj('msg_06.txt') *************** *** 1371,1374 **** --- 1480,1497 ---- eq(part2.get_type(), 'application/riscos') + ## def test_multipart_digest_with_extra_mime_headers(self): + ## eq = self.assertEqual + ## fp = openfile('msg_28.txt') + ## p = Parser() + ## msg = p.parse(fp) + ## self.failUnless(msg.is_multipart()) + ## eq(len(msg.get_payload()), 2) + ## part1 = msg.get_payload(0) + ## eq(part1.get_type(), 'text/plain') + ## eq(part1.get_payload(), 'message 1') + ## part2 = msg.get_payload(1) + ## eq(part2.get_type(), 'text/plain') + ## eq(part2.get_payload(), 'message 2') + *************** *** 1572,1583 **** # Test multilingual MIME headers. ! class TestHeader(unittest.TestCase): def test_simple(self): ! eq = self.assertEqual h = Header('Hello World!') eq(h.encode(), 'Hello World!') ! h.append('Goodbye World!') eq(h.encode(), 'Hello World! Goodbye World!') def test_header_needs_no_decoding(self): h = 'no decoding needed' --- 1695,1713 ---- # Test multilingual MIME headers. ! class TestHeader(TestEmailBase): def test_simple(self): ! eq = self.ndiffAssertEqual h = Header('Hello World!') eq(h.encode(), 'Hello World!') ! h.append(' Goodbye World!') eq(h.encode(), 'Hello World! Goodbye World!') + def test_simple_surprise(self): + eq = self.ndiffAssertEqual + h = Header('Hello World!') + eq(h.encode(), 'Hello World!') + h.append('Goodbye World!') + eq(h.encode(), 'Hello World!Goodbye World!') + def test_header_needs_no_decoding(self): h = 'no decoding needed' *************** *** 1622,1635 **** def test_explicit_maxlinelen(self): ! eq = self.assertEqual hstr = 'A very long line that must get split to something other than at the 76th character boundary to test the non-default behavior' h = Header(hstr) eq(h.encode(), '''\ ! A very long line that must get split to something other than at the 76th cha ! racter boundary to test the non-default behavior''') h = Header(hstr, header_name='Subject') eq(h.encode(), '''\ A very long line that must get split to something other than at the ! 76th character boundary to test the non-default behavior''') h = Header(hstr, maxlinelen=1024, header_name='Subject') eq(h.encode(), hstr) --- 1752,1765 ---- def test_explicit_maxlinelen(self): ! eq = self.ndiffAssertEqual hstr = 'A very long line that must get split to something other than at the 76th character boundary to test the non-default behavior' h = Header(hstr) eq(h.encode(), '''\ ! A very long line that must get split to something other than at the 76th ! character boundary to test the non-default behavior''') h = Header(hstr, header_name='Subject') eq(h.encode(), '''\ A very long line that must get split to something other than at the ! 76th character boundary to test the non-default behavior''') h = Header(hstr, maxlinelen=1024, header_name='Subject') eq(h.encode(), hstr) Index: test_email_codecs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_email_codecs.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_email_codecs.py 15 Apr 2002 22:14:06 -0000 1.2 --- test_email_codecs.py 28 Jun 2002 23:49:33 -0000 1.3 *************** *** 4,12 **** import unittest import test_support from email.Charset import Charset from email.Header import Header, decode_header - # See if we have the Japanese codecs package installed try: --- 4,12 ---- import unittest import test_support + from test_email import TestEmailBase from email.Charset import Charset from email.Header import Header, decode_header # See if we have the Japanese codecs package installed try: *************** *** 17,23 **** ! class TestEmailAsianCodecs(unittest.TestCase): def test_japanese_codecs(self): ! eq = self.assertEqual j = Charset("euc-jp") g = Charset("iso-8859-1") --- 17,23 ---- ! class TestEmailAsianCodecs(TestEmailBase): def test_japanese_codecs(self): ! eq = self.ndiffAssertEqual j = Charset("euc-jp") g = Charset("iso-8859-1") *************** *** 36,41 **** # test a very long header enc = h.encode() ! eq(enc, '=?iso-2022-jp?b?dGVzdC1qYSAbJEIkWEVqOUYkNSRsJD8lYRsoQg==?=\n =?iso-2022-jp?b?GyRCITwlayRPO0oycTxUJE4+NRsoQg==?=\n =?iso-2022-jp?b?GyRCRyckckJUJEMkRiQkJF4kORsoQg==?=') ! eq(decode_header(enc), [("test-ja \x1b$B$XEj9F$5$l$?%a\x1b(B\x1b$B!<%k$O;J2q5\x1b(B\x1b$BG'$rBT$C$F$$$^$9\x1b(B", 'iso-2022-jp')]) --- 36,56 ---- # test a very long header enc = h.encode() ! # BAW: The following used to pass. Sadly, the test afterwards is what ! # happens now. I've no idea which is right. Please, any Japanese and ! # RFC 2047 experts, please verify! ! ## eq(enc, '''\ ! ##=?iso-2022-jp?b?dGVzdC1qYSAbJEIkWEVqOUYkNSRsJD8lYRsoQg==?= ! ## =?iso-2022-jp?b?GyRCITwlayRPO0oycTxUJE4+NRsoQg==?= ! ## =?iso-2022-jp?b?GyRCRyckckJUJEMkRiQkJF4kORsoQg==?=''') ! eq(enc, """\ ! =?iso-2022-jp?b?dGVzdC1qYSAbJEIkWEVqOUYkNSRsJD8lYRsoQg==?= ! =?iso-2022-jp?b?GyRCITwlayRPO0oycTxUJE4+NUcnJHJCVCRDJEYkJCReJDkbKEI=?=""") ! # BAW: same deal here. :( ! ## self.assertEqual( ! ## decode_header(enc), ! ## [("test-ja \x1b$B$XEj9F$5$l$?%a\x1b(B\x1b$B!<%k$O;J2q5\x1b(B\x1b$BG'$rBT$C$F$$$^$9\x1b(B", 'iso-2022-jp')]) ! self.assertEqual( ! decode_header(enc), ! [("test-ja \x1b$B$XEj9F$5$l$?%a\x1b(B\x1b$B!<%k$O;J2q5G'$rBT$C$F$$$^$9\x1b(B", 'iso-2022-jp')]) From jhylton@users.sourceforge.net Sat Jun 29 00:54:32 2002 From: jhylton@users.sourceforge.net (jhylton@users.sourceforge.net) Date: Fri, 28 Jun 2002 16:54:32 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_httplib.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv22827 Modified Files: test_httplib.py Log Message: Track change of begin() to _begin(). Index: test_httplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_httplib.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_httplib.py 1 Apr 2002 19:00:50 -0000 1.4 --- test_httplib.py 28 Jun 2002 23:54:30 -0000 1.5 *************** *** 17,21 **** sock = FakeSocket(body) resp = httplib.HTTPResponse(sock,1) ! resp.begin() print resp.read() resp.close() --- 17,21 ---- sock = FakeSocket(body) resp = httplib.HTTPResponse(sock,1) ! resp._begin() print resp.read() resp.close() *************** *** 25,29 **** resp = httplib.HTTPResponse(sock,1) try: ! resp.begin() except httplib.BadStatusLine: print "BadStatusLine raised as expected" --- 25,29 ---- resp = httplib.HTTPResponse(sock,1) try: ! resp._begin() except httplib.BadStatusLine: print "BadStatusLine raised as expected" From gward@users.sourceforge.net Sat Jun 29 02:23:47 2002 From: gward@users.sourceforge.net (gward@users.sourceforge.net) Date: Fri, 28 Jun 2002 18:23:47 -0700 Subject: [Python-checkins] python/dist/src/Doc/doc doc.tex,1.66,1.67 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/doc In directory usw-pr-cvs1:/tmp/cvs-serv24320a Modified Files: doc.tex Log Message: Typo fix. Index: doc.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/doc/doc.tex,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** doc.tex 21 May 2002 16:27:20 -0000 1.66 --- doc.tex 29 Jun 2002 01:23:45 -0000 1.67 *************** *** 934,938 **** \begin{macrodesc}{programopt}{\p{option}} A command-line option to an executable program. Use this only ! for ``shot'' options, and include the leading hyphen. \end{macrodesc} --- 934,938 ---- \begin{macrodesc}{programopt}{\p{option}} A command-line option to an executable program. Use this only ! for ``short'' options, and include the leading hyphen. \end{macrodesc} From gward@users.sourceforge.net Sat Jun 29 03:38:52 2002 From: gward@users.sourceforge.net (gward@users.sourceforge.net) Date: Fri, 28 Jun 2002 19:38:52 -0700 Subject: [Python-checkins] python/dist/src/Doc Makefile.deps,1.85,1.86 Message-ID: Update of /cvsroot/python/python/dist/src/Doc In directory usw-pr-cvs1:/tmp/cvs-serv10122 Modified Files: Makefile.deps Log Message: Add documentation for new textwrap module. Index: Makefile.deps =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile.deps,v retrieving revision 1.85 retrieving revision 1.86 diff -C2 -d -r1.85 -r1.86 *** Makefile.deps 16 Apr 2002 18:48:25 -0000 1.85 --- Makefile.deps 29 Jun 2002 02:38:50 -0000 1.86 *************** *** 125,128 **** --- 125,129 ---- lib/libstrings.tex \ lib/libstring.tex \ + lib/libtextwrap.tex \ lib/libcodecs.tex \ lib/libunicodedata.tex \ From gward@users.sourceforge.net Sat Jun 29 03:38:52 2002 From: gward@users.sourceforge.net (gward@users.sourceforge.net) Date: Fri, 28 Jun 2002 19:38:52 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libtextwrap.tex,NONE,1.1 lib.tex,1.200,1.201 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv10122/lib Modified Files: lib.tex Added Files: libtextwrap.tex Log Message: Add documentation for new textwrap module. --- NEW FILE: libtextwrap.tex --- \section{\module{textwrap} --- Text wrapping and filling} \declaremodule{standard}{textwrap} \modulesynopsis{Text wrapping and filling} \moduleauthor{Greg Ward}{gward@python.net} \sectionauthor{Greg Ward}{gward@python.net} \versionadded{2.3} The \module{textwrap} module provides two convenience functions, \function{wrap()} and \function{fill()}, as well as \class{TextWrapper}, the class that does all the work. If you're just wrapping or filling one or two text strings, the convenience functions should be good enough; otherwise, you should use an instance of \class{TextWrapper} for efficiency. \begin{funcdesc}{wrap}{text, width=70, **kwargs} Wraps the single paragraph in \var{text} (a string) so every line is at most \var{width} characters long. Returns a list of output lines, without final newlines. Optional keyword arguments correspond to the instance attributes of \class{TextWrapper}, documented below. \end{funcdesc} \begin{funcdesc}{fill}{text, width=70, **kwargs} Wraps the single paragraph in \var{text}, and returns a single string containing the wrapped paragraph. \function{fill()} is shorthand for \begin{verbatim} "\n".join(wrap(text, ...)) \end{verbatim} In particular, \function{fill()} accepts exactly the same keyword arguments as \function{wrap()}. \end{funcdesc} Both \function{wrap()} and \function{fill()} work by creating a \class{TextWrapper} instance and calling a single method on it. That instance is not reused, so for applications that wrap/fill many text strings, it will be more efficient for you to create your own \class{TextWrapper} object. % XXX how to typeset long argument lists? this just spills off % the edge of the page, with or without \\ delimiters \begin{classdesc}{TextWrapper}{width=70, \\ initial_indent="", \\ subsequent_indent="", \\ expand_tabs=True, \\ replace_whitespace=True, \\ fix_sentence_endings=False, \\ break_long_words=True} Each keyword argument to the constructor corresponds to an instance attribute, so for example \begin{verbatim} wrapper = TextWrapper(initial_indent="* ") \end{verbatim} is the same as \begin{verbatim} wrapper = TextWrapper() wrapper.initial_indent = "* " \end{verbatim} You can re-use the same \class{TextWrapper} object many times, and you can change any of its options through direct assignment to instance attributes between uses. The effects of the instance attributes are as follows: \begin{memberdesc}[bool]{expand_tabs} If true (the default), then all tab characters in \var{text} will be expanded to spaces using the \method{expand_tabs()} method of \var{text}. \end{memberdesc} \begin{memberdesc}[bool]{replace_whitespace} If true (the default), each whitespace character (as defined by \var{string.whitespace}) remaining after tab expansion will be replaced by a single space. \note{If \var{expand_tabs} is false and \var{replace_whitespace} is true, each tab character will be replaced by a single space, which is \emph{not} the same as tab expansion.} \end{memberdesc} % XXX how to typeset the empty string? this looks awful, and "" is worse. \begin{memberdesc}[string]{initial_indent} (default: '') String that will be prepended to the first line of wrapped output. Counts towards the length of the first line. \end{memberdesc} \begin{memberdesc}[string]{subsequent_indent} (default: '') String that will be prepended to all lines of wrapped output except the first. Counts towards the length of each line except the first. \end{memberdesc} \begin{memberdesc}[bool]{fix_sentence_endings} (default: false) If true, \class{TextWrapper} attempts to detect sentence endings and ensure that sentences are always separated by exactly two spaces. This is generally desired for text in a monospaced font. However, the sentence detection algorithm is imperfect: it assumes that a sentence ending consists of a lowercase letter followed by one of \character{.}, \character{!}, or \character{?}, possibly followed by one of \character{"} or \character{'}. One problem with this is algoritm is that it is unable to detect the difference between ``Dr.'' in \begin{verbatim} [...] Dr. Frankenstein's monster [...] \end{verbatim} and ``Spot.'' in \begin{verbatim} [...] See Spot. See Spot run [...] \end{verbatim} Furthermore, since it relies on \var{string.lowercase} for the definition of ``lowercase letter'', it is specific to English-language texts. Thus, \var{fix_sentence_endings} is false by default. \end{memberdesc} \begin{memberdesc}[bool]{break_long_words} If true (the default), then words longer than \var{width} will be broken in order to ensure that no lines are longer than \var{width}. If it is false, long words will not be broken, and some lines may be longer than \var{width}. (Long words will be put on a line by themselves, in order to minimize the amount by which \var{width} is exceeded.) \end{memberdesc} \class{TextWrapper} also provides two public methods, analogous to the module-level convenience functions: \begin{methoddesc}{wrap}{text} Wraps the single paragraph in \var{text} (a string) so every line is at most \var{width} characters long. All wrapping options are taken from instance attributes of the \class{TextWrapper} instance. Returns a list of output lines, without final newlines. \end{methoddesc} \begin{methoddesc}{fill}{text} Wraps the single paragraph in \var{text}, and returns a single string containing the wrapped paragraph. \end{methoddesc} \end{classdesc} Index: lib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/lib.tex,v retrieving revision 1.200 retrieving revision 1.201 diff -C2 -d -r1.200 -r1.201 *** lib.tex 18 Dec 2001 16:32:30 -0000 1.200 --- lib.tex 29 Jun 2002 02:38:50 -0000 1.201 *************** *** 108,111 **** --- 108,112 ---- \input{libfpformat} \input{libstringio} + \input{libtextwrap} \input{libcodecs} \input{libunicodedata} From bwarsaw@users.sourceforge.net Sat Jun 29 04:27:01 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Fri, 28 Jun 2002 20:27:01 -0700 Subject: [Python-checkins] python/dist/src/Lib/email Header.py,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email In directory usw-pr-cvs1:/tmp/cvs-serv20231 Modified Files: Header.py Log Message: __unicode__(): Patch # 541263 by Mikhail Zabaluev, implementation modified by Barry. Index: Header.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/Header.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Header.py 28 Jun 2002 23:46:53 -0000 1.5 --- Header.py 29 Jun 2002 03:26:58 -0000 1.6 *************** *** 143,146 **** --- 143,152 ---- return self.encode() + def __unicode__(self): + """Helper for the built-in unicode function.""" + # charset item is a Charset instance so we need to stringify it. + uchunks = [unicode(s, str(charset)) for s, charset in self._chunks] + return u''.join(uchunks) + def append(self, s, charset=None): """Append string s with Charset charset to the MIME header. From bwarsaw@users.sourceforge.net Sat Jun 29 04:27:31 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Fri, 28 Jun 2002 20:27:31 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_email.py,1.35,1.36 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv20363 Modified Files: test_email.py Log Message: test_multilingual(): Test for Header.__unicode__(). Index: test_email.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_email.py,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** test_email.py 28 Jun 2002 23:49:32 -0000 1.35 --- test_email.py 29 Jun 2002 03:27:27 -0000 1.36 *************** *** 1750,1753 **** --- 1750,1775 ---- [(g_head, "iso-8859-1"), (cz_head, "iso-8859-2"), (utf8_head, "utf-8")]) + # Test for conversion to unicode. BAW: Python 2.1 doesn't support the + # __unicode__() protocol, so do things this way for compatibility. + ustr = h.__unicode__() + # For Python 2.2 and beyond + #ustr = unicode(h) + eq(ustr.encode('utf-8'), + 'Die Mieter treten hier ein werden mit einem Foerderband ' + 'komfortabel den Korridor entlang, an s\xc3\xbcdl\xc3\xbcndischen ' + 'Wandgem\xc3\xa4lden vorbei, gegen die rotierenden Klingen ' + 'bef\xc3\xb6rdert. Finan\xc4\x8dni metropole se hroutily pod ' + 'tlakem jejich d\xc5\xafvtipu.. \xe6\xad\xa3\xe7\xa2\xba\xe3\x81' + '\xab\xe8\xa8\x80\xe3\x81\x86\xe3\x81\xa8\xe7\xbf\xbb\xe8\xa8\xb3' + '\xe3\x81\xaf\xe3\x81\x95\xe3\x82\x8c\xe3\x81\xa6\xe3\x81\x84\xe3' + '\x81\xbe\xe3\x81\x9b\xe3\x82\x93\xe3\x80\x82\xe4\xb8\x80\xe9\x83' + '\xa8\xe3\x81\xaf\xe3\x83\x89\xe3\x82\xa4\xe3\x83\x84\xe8\xaa\x9e' + '\xe3\x81\xa7\xe3\x81\x99\xe3\x81\x8c\xe3\x80\x81\xe3\x81\x82\xe3' + '\x81\xa8\xe3\x81\xaf\xe3\x81\xa7\xe3\x81\x9f\xe3\x82\x89\xe3\x82' + '\x81\xe3\x81\xa7\xe3\x81\x99\xe3\x80\x82\xe5\xae\x9f\xe9\x9a\x9b' + '\xe3\x81\xab\xe3\x81\xaf\xe3\x80\x8cWenn ist das Nunstuck git ' + 'und Slotermeyer? Ja! Beiherhund das Oder die Flipperwaldt ' + 'gersput.\xe3\x80\x8d\xe3\x81\xa8\xe8\xa8\x80\xe3\x81\xa3\xe3\x81' + '\xa6\xe3\x81\x84\xe3\x81\xbe\xe3\x81\x99\xe3\x80\x82') def test_explicit_maxlinelen(self): From bwarsaw@users.sourceforge.net Sat Jun 29 06:56:17 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Fri, 28 Jun 2002 22:56:17 -0700 Subject: [Python-checkins] python/dist/src/Lib/email Message.py,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email In directory usw-pr-cvs1:/tmp/cvs-serv3560/email Modified Files: Message.py Log Message: Oleg Broytmann's support for RFC 2231 encoded parameters, SF patch #549133 Specifically, _formatparam(): Teach this about encoded `param' arguments, which are a 3-tuple of items (charset, language, value). language is ignored. _unquotevalue(): Handle both 3-tuple RFC 2231 values and unencoded values. _get_params_preserve(): Decode the parameters before returning them. get_params(), get_param(): Use _unquotevalue(). get_filename(), get_boundary(): Teach these about encoded (3-tuple) parameters. Index: Message.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/Message.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Message.py 2 Jun 2002 19:05:51 -0000 1.13 --- Message.py 29 Jun 2002 05:56:15 -0000 1.14 *************** *** 8,12 **** import warnings from cStringIO import StringIO ! from types import ListType, StringType # Intrapackage imports --- 8,12 ---- import warnings from cStringIO import StringIO ! from types import ListType, TupleType, StringType # Intrapackage imports *************** *** 28,38 **** ! # Helper function def _formatparam(param, value=None, quote=1): """Convenience function to format and return a key=value pair. ! Will quote the value if needed or if quote is true. """ if value is not None and len(value) > 0: # BAW: Please check this. I think that if quote is set it should # force quoting even if not necessary. --- 28,44 ---- ! # Helper functions def _formatparam(param, value=None, quote=1): """Convenience function to format and return a key=value pair. ! This will quote the value if needed or if quote is true. """ if value is not None and len(value) > 0: + # TupleType is used for RFC 2231 encoded parameter values where items + # are (charset, language, value). charset is a string, not a Charset + # instance. + if isinstance(value, TupleType): + # Convert to ascii, ignore language + value = unicode(value[2], value[0]).encode("ascii") # BAW: Please check this. I think that if quote is set it should # force quoting even if not necessary. *************** *** 45,48 **** --- 51,61 ---- + def _unquotevalue(value): + if isinstance(value, TupleType): + return (value[0], value[1], Utils.unquote(value[2])) + else: + return Utils.unquote(value) + + class Message: *************** *** 401,404 **** --- 414,418 ---- val = '' params.append((name, val)) + params = Utils.decode_params(params) return params *************** *** 421,425 **** return failobj if unquote: ! return [(k, Utils.unquote(v)) for k, v in params] else: return params --- 435,439 ---- return failobj if unquote: ! return [(k, _unquotevalue(v)) for k, v in params] else: return params *************** *** 440,444 **** if k.lower() == param.lower(): if unquote: ! return Utils.unquote(v) else: return v --- 454,458 ---- if k.lower() == param.lower(): if unquote: ! return _unquotevalue(v) else: return v *************** *** 549,553 **** if filename is missing: return failobj ! return Utils.unquote(filename.strip()) def get_boundary(self, failobj=None): --- 563,573 ---- if filename is missing: return failobj ! if isinstance(filename, TupleType): ! # It's an RFC 2231 encoded parameter ! newvalue = _unquotevalue(filename) ! return unicode(newvalue[2], newvalue[0]) ! else: ! newvalue = _unquotevalue(filename.strip()) ! return newvalue def get_boundary(self, failobj=None): *************** *** 561,565 **** if boundary is missing: return failobj ! return Utils.unquote(boundary.strip()) def set_boundary(self, boundary): --- 581,585 ---- if boundary is missing: return failobj ! return _unquotevalue(boundary.strip()) def set_boundary(self, boundary): From bwarsaw@users.sourceforge.net Sat Jun 29 06:58:06 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Fri, 28 Jun 2002 22:58:06 -0700 Subject: [Python-checkins] python/dist/src/Lib/email Utils.py,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/email In directory usw-pr-cvs1:/tmp/cvs-serv4405/email Modified Files: Utils.py Log Message: Oleg Broytmann's support for RFC 2231 encoded parameters, SF patch #549133 Specifically, decode_rfc2231(), encode_rfc2231(): Functions to encode and decode RFC 2231 style parameters. decode_params(): Function to decode a list of parameters. Index: Utils.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/Utils.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Utils.py 2 Jun 2002 19:07:16 -0000 1.16 --- Utils.py 29 Jun 2002 05:58:04 -0000 1.17 *************** *** 46,49 **** --- 46,50 ---- COMMASPACE = ', ' + EMPTYSTRING = '' UEMPTYSTRING = u'' CRLF = '\r\n' *************** *** 258,259 **** --- 259,316 ---- return '', '' return addrs[0] + + + + # RFC2231-related functions - parameter encoding and decoding + def decode_rfc2231(s): + """Decode string according to RFC 2231""" + import urllib + charset, language, s = s.split("'", 2) + s = urllib.unquote(s) + return charset, language, s + + + def encode_rfc2231(s, charset=None, language=None): + """Encode string according to RFC 2231""" + import urllib + s = urllib.quote(s, safe='') + if charset is None and language is None: + return s + else: + return "%s'%s'%s" % (charset, language, s) + + + rfc2231_continuation = re.compile(r'^(?P\w+)\*((?P[0-9]+)\*?)?$') + + def decode_params(params): + """Decode parameters list according to RFC 2231""" + new_params = [] + # maps parameter's name to a list of continuations + rfc2231_params = {} + # params is a sequence of 2-tuples containing (content_type, string value) + name, value = params[0] + new_params.append((name, value)) + # Cycle through each of the rest of the parameters. + for name, value in params[1:]: + value = unquote(value) + mo = rfc2231_continuation.match(name) + if mo: + name, num = mo.group('name', 'num') + if num is not None: + num = int(num) + rfc2231_param1 = rfc2231_params.setdefault(name, []) + rfc2231_param1.append((num, value)) + else: + new_params.append((name, '"%s"' % quote(value))) + if rfc2231_params: + for name, continuations in rfc2231_params.items(): + value = [] + # Sort by number + continuations.sort() + # And now append all values in num order + for num, continuation in continuations: + value.append(continuation) + charset, language, value = decode_rfc2231(EMPTYSTRING.join(value)) + new_params.append((name, + (charset, language, '"%s"' % quote(value)))) + return new_params From bwarsaw@users.sourceforge.net Sat Jun 29 06:58:48 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Fri, 28 Jun 2002 22:58:48 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_email.py,1.36,1.37 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv4702/test Modified Files: test_email.py Log Message: Oleg Broytmann's support for RFC 2231 encoded parameters, SF patch #549133 New test cases. Index: test_email.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_email.py,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** test_email.py 29 Jun 2002 03:27:27 -0000 1.36 --- test_email.py 29 Jun 2002 05:58:45 -0000 1.37 *************** *** 159,163 **** header, value = msg.items()[4] eq(header.lower(), 'content-type') ! eq(value, 'text/plain; charset=us-ascii; boundary="BOUNDARY"') # This one has a Content-Type: header, with a boundary, stuck in the # middle of its headers. Make sure the order is preserved; it should --- 159,163 ---- header, value = msg.items()[4] eq(header.lower(), 'content-type') ! eq(value, 'text/plain; charset="us-ascii"; boundary="BOUNDARY"') # This one has a Content-Type: header, with a boundary, stuck in the # middle of its headers. Make sure the order is preserved; it should *************** *** 1786,1789 **** --- 1786,1800 ---- h = Header(hstr, maxlinelen=1024, header_name='Subject') eq(h.encode(), hstr) + + + # Test RFC 2231 header parameters decoding + class TestRFC2231(TestEmailBase): + def test_get_param(self): + eq = self.assertEqual + msg = self._msgobj('msg_29.txt') + eq(msg.get_param('title'), + ('us-ascii', 'en', 'This is even more ***fun*** isn\'t it!')) + eq(msg.get_param('title', unquote=0), + ('us-ascii', 'en', '"This is even more ***fun*** isn\'t it!"')) From bwarsaw@users.sourceforge.net Sat Jun 29 06:58:48 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Fri, 28 Jun 2002 22:58:48 -0700 Subject: [Python-checkins] python/dist/src/Lib/test/data msg_29.txt,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/data In directory usw-pr-cvs1:/tmp/cvs-serv4702/test/data Added Files: msg_29.txt Log Message: Oleg Broytmann's support for RFC 2231 encoded parameters, SF patch #549133 New test cases. --- NEW FILE: msg_29.txt --- Return-Path: Delivered-To: bbb@zzz.org Received: by mail.zzz.org (Postfix, from userid 889) id 27CEAD38CC; Fri, 4 May 2001 14:05:44 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; title*0*="us-ascii'en'This%20is%20even%20more%20"; title*1*="%2A%2A%2Afun%2A%2A%2A%20"; title*2="isn't it!" Content-Transfer-Encoding: 7bit Message-ID: <15090.61304.110929.45684@aaa.zzz.org> From: bbb@ddd.com (John X. Doe) To: bbb@zzz.org Subject: This is a test message Date: Fri, 4 May 2001 14:05:44 -0400 Hi, Do you like this message? -Me From bwarsaw@users.sourceforge.net Sat Jun 29 16:23:41 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Sat, 29 Jun 2002 08:23:41 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_email.py,1.37,1.38 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv9761/test Modified Files: test_email.py Log Message: Another test of long headers. Index: test_email.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_email.py,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** test_email.py 29 Jun 2002 05:58:45 -0000 1.37 --- test_email.py 29 Jun 2002 15:23:39 -0000 1.38 *************** *** 1144,1147 **** --- 1144,1151 ---- self._idempotent(msg, text) + def test_long_header(self): + msg, text = self._msgobj('msg_27.txt') + self._idempotent(msg, text) + ## def test_MIME_digest_with_part_headers(self): ## msg, text = self._msgobj('msg_28.txt') From bwarsaw@users.sourceforge.net Sat Jun 29 16:23:42 2002 From: bwarsaw@users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Sat, 29 Jun 2002 08:23:42 -0700 Subject: [Python-checkins] python/dist/src/Lib/test/data msg_27.txt,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/data In directory usw-pr-cvs1:/tmp/cvs-serv9761/test/data Added Files: msg_27.txt Log Message: Another test of long headers. --- NEW FILE: msg_27.txt --- Return-Path: Received: by mail.dom.ain (Postfix, from userid 889) id B9D0AD35DB; Tue, 4 Jun 2002 21:46:59 -0400 (EDT) Message-ID: <15613.28051.707126.569693@dom.ain> Date: Tue, 4 Jun 2002 21:46:59 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: bug demonstration 12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789 more text From: aperson@dom.ain (Anne P. Erson) To: bperson@dom.ain (Barney P. Erson) test From fdrake@users.sourceforge.net Sat Jun 29 17:06:49 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Sat, 29 Jun 2002 09:06:49 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libfuncs.tex,1.108,1.109 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv19687/lib Modified Files: libfuncs.tex Log Message: Clarify the version information for the unicode() built-in. Closes SF bug #575272. Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.108 retrieving revision 1.109 diff -C2 -d -r1.108 -r1.109 *** libfuncs.tex 20 Jun 2002 21:10:25 -0000 1.108 --- libfuncs.tex 29 Jun 2002 16:06:47 -0000 1.109 *************** *** 874,884 **** instead of 8-bit strings. More precisely, if \var{object} is an Unicode string or subclass it will return a Unicode string without ! any additional decoding applied. For objects which provide a ! \code{__unicode__} method, it will call this method without ! arguments to create a Unicode string. For all other objects, the ! 8-bit string version or representation is requested and then ! converted to a Unicode string using the codec for the default ! encoding in \code{'strict'} mode. \versionadded{2.0} \end{funcdesc} --- 874,887 ---- instead of 8-bit strings. More precisely, if \var{object} is an Unicode string or subclass it will return a Unicode string without ! any additional decoding applied. ! ! For objects which provide a \method{__unicode__()} method, it will ! call this method without arguments to create a Unicode string. For ! all other objects, the 8-bit string version or representation is ! requested and then converted to a Unicode string using the codec for ! the default encoding in \code{'strict'} mode. ! \versionadded{2.0} + \versionchanged[Support for \method{__unicode__()} added]{2.2} \end{funcdesc} From fdrake@users.sourceforge.net Sat Jun 29 17:11:11 2002 From: fdrake@users.sourceforge.net (fdrake@users.sourceforge.net) Date: Sat, 29 Jun 2002 09:11:11 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libfuncs.tex,1.100.4.3,1.100.4.4 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv23751/lib Modified Files: Tag: release22-maint libfuncs.tex Log Message: Clarify the version information for the unicode() built-in. Closes SF bug #575272. Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.100.4.3 retrieving revision 1.100.4.4 diff -C2 -d -r1.100.4.3 -r1.100.4.4 *** libfuncs.tex 17 Apr 2002 12:54:56 -0000 1.100.4.3 --- libfuncs.tex 29 Jun 2002 16:11:08 -0000 1.100.4.4 *************** *** 834,844 **** instead of 8-bit strings. More precisely, if \var{object} is an Unicode string or subclass it will return a Unicode string without ! any additional decoding applied. For objects which provide a ! \code{__unicode__} method, it will call this method without ! arguments to create a Unicode string. For all other objects, the ! 8-bit string version or representation is requested and then ! converted to a Unicode string using the codec for the default ! encoding in \code{'strict'} mode. \versionadded{2.0} \end{funcdesc} --- 834,847 ---- instead of 8-bit strings. More precisely, if \var{object} is an Unicode string or subclass it will return a Unicode string without ! any additional decoding applied. ! ! For objects which provide a \method{__unicode__()} method, it will ! call this method without arguments to create a Unicode string. For ! all other objects, the 8-bit string version or representation is ! requested and then converted to a Unicode string using the codec for ! the default encoding in \code{'strict'} mode. ! \versionadded{2.0} + \versionchanged[Support for \method{__unicode__()} added]{2.2} \end{funcdesc} From rhettinger@users.sourceforge.net Sun Jun 30 04:39:16 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat, 29 Jun 2002 20:39:16 -0700 Subject: [Python-checkins] python/dist/src/Lib asynchat.py,1.18,1.19 cgi.py,1.73,1.74 cmd.py,1.30,1.31 mailbox.py,1.37,1.38 imaplib.py,1.53,1.54 multifile.py,1.20,1.21 mutex.py,1.10,1.11 Queue.py,1.15,1.16 threading.py,1.23,1.24 pickle.py,1.66,1.67 xmlrpclib.py,1.19,1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv13333 Modified Files: asynchat.py cgi.py cmd.py mailbox.py imaplib.py multifile.py mutex.py Queue.py threading.py pickle.py xmlrpclib.py Log Message: Code modernization. Replace v=s[i]; del s[i] with single lookup v=s.pop(i) Index: asynchat.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/asynchat.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** asynchat.py 16 Apr 2002 01:38:39 -0000 1.18 --- asynchat.py 30 Jun 2002 03:39:14 -0000 1.19 *************** *** 270,276 **** def pop (self): if self.list: ! result = self.list[0] ! del self.list[0] ! return (1, result) else: return (0, None) --- 270,274 ---- def pop (self): if self.list: ! return (1, self.list.pop(0)) else: return (0, None) Index: cgi.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cgi.py,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** cgi.py 1 Jun 2002 14:18:45 -0000 1.73 --- cgi.py 30 Jun 2002 03:39:14 -0000 1.74 *************** *** 324,329 **** """ plist = map(lambda x: x.strip(), line.split(';')) ! key = plist[0].lower() ! del plist[0] pdict = {} for p in plist: --- 324,328 ---- """ plist = map(lambda x: x.strip(), line.split(';')) ! key = plist.pop(0).lower() pdict = {} for p in plist: Index: cmd.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cmd.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** cmd.py 1 Jun 2002 14:18:45 -0000 1.30 --- cmd.py 30 Jun 2002 03:39:14 -0000 1.31 *************** *** 110,115 **** while not stop: if self.cmdqueue: ! line = self.cmdqueue[0] ! del self.cmdqueue[0] else: if self.use_rawinput: --- 110,114 ---- while not stop: if self.cmdqueue: ! line = self.cmdqueue.pop(0) else: if self.use_rawinput: *************** *** 262,270 **** classes = [self.__class__] while classes: ! aclass = classes[0] if aclass.__bases__: classes = classes + list(aclass.__bases__) names = names + dir(aclass) - del classes[0] return names --- 261,268 ---- classes = [self.__class__] while classes: ! aclass = classes.pop(0) if aclass.__bases__: classes = classes + list(aclass.__bases__) names = names + dir(aclass) return names Index: mailbox.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mailbox.py,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** mailbox.py 1 Jun 2002 14:18:45 -0000 1.37 --- mailbox.py 30 Jun 2002 03:39:14 -0000 1.38 *************** *** 203,208 **** if not self.boxes: return None ! fn = self.boxes[0] ! del self.boxes[0] fp = open(os.path.join(self.dirname, fn)) return self.factory(fp) --- 203,207 ---- if not self.boxes: return None ! fn = self.boxes.pop(0) fp = open(os.path.join(self.dirname, fn)) return self.factory(fp) *************** *** 234,239 **** if not self.boxes: return None ! fn = self.boxes[0] ! del self.boxes[0] fp = open(fn) return self.factory(fp) --- 233,237 ---- if not self.boxes: return None ! fn = self.boxes.pop(0) fp = open(fn) return self.factory(fp) Index: imaplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/imaplib.py,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** imaplib.py 24 Jun 2002 23:35:37 -0000 1.53 --- imaplib.py 30 Jun 2002 03:39:14 -0000 1.54 *************** *** 974,982 **** if not name in self.untagged_responses: return typ, [None] ! data = self.untagged_responses[name] if __debug__: if self.debug >= 5: self._mesg('untagged_responses[%s] => %s' % (name, data)) - del self.untagged_responses[name] return typ, data --- 974,981 ---- if not name in self.untagged_responses: return typ, [None] ! data = self.untagged_responses.pop(name) if __debug__: if self.debug >= 5: self._mesg('untagged_responses[%s] => %s' % (name, data)) return typ, data Index: multifile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/multifile.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** multifile.py 5 Oct 2001 21:22:21 -0000 1.20 --- multifile.py 30 Jun 2002 03:39:14 -0000 1.21 *************** *** 161,166 **** del self.stack[0] if self.seekable: ! self.start = self.posstack[0] ! del self.posstack[0] if self.level > 0: self.lastpos = abslastpos - self.start --- 161,165 ---- del self.stack[0] if self.seekable: ! self.start = self.posstack.pop(0) if self.level > 0: self.lastpos = abslastpos - self.start Index: mutex.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mutex.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** mutex.py 4 Apr 2002 22:55:58 -0000 1.10 --- mutex.py 30 Jun 2002 03:39:14 -0000 1.11 *************** *** 45,50 **** function with its argument.""" if self.queue: ! function, argument = self.queue[0] ! del self.queue[0] function(argument) else: --- 45,49 ---- function with its argument.""" if self.queue: ! function, argument = self.queue.pop(0) function(argument) else: Index: Queue.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/Queue.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Queue.py 19 Apr 2002 00:11:31 -0000 1.15 --- Queue.py 30 Jun 2002 03:39:14 -0000 1.16 *************** *** 147,151 **** # Get an item from the queue def _get(self): ! item = self.queue[0] ! del self.queue[0] ! return item --- 147,149 ---- # Get an item from the queue def _get(self): ! return self.queue.pop(0) Index: threading.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/threading.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** threading.py 7 Apr 2002 06:36:23 -0000 1.23 --- threading.py 30 Jun 2002 03:39:14 -0000 1.24 *************** *** 634,639 **** self._note("get(): queue empty") self.rc.wait() ! item = self.queue[0] ! del self.queue[0] self._note("get(): got %s, %d left", item, len(self.queue)) self.wc.notify() --- 634,638 ---- self._note("get(): queue empty") self.rc.wait() ! item = self.queue.pop(0) self._note("get(): got %s, %d left", item, len(self.queue)) self.wc.notify() Index: pickle.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pickle.py,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** pickle.py 1 Jun 2002 14:18:46 -0000 1.66 --- pickle.py 30 Jun 2002 03:39:14 -0000 1.67 *************** *** 693,701 **** def load_binpersid(self): ! stack = self.stack ! ! pid = stack[-1] ! del stack[-1] ! self.append(self.persistent_load(pid)) dispatch[BINPERSID] = load_binpersid --- 693,697 ---- def load_binpersid(self): ! pid = self.stack.pop() self.append(self.persistent_load(pid)) dispatch[BINPERSID] = load_binpersid *************** *** 978,983 **** def load_append(self): stack = self.stack ! value = stack[-1] ! del stack[-1] list = stack[-1] list.append(value) --- 974,978 ---- def load_append(self): stack = self.stack ! value = stack.pop() list = stack[-1] list.append(value) *************** *** 996,1002 **** def load_setitem(self): stack = self.stack ! value = stack[-1] ! key = stack[-2] ! del stack[-2:] dict = stack[-1] dict[key] = value --- 991,996 ---- def load_setitem(self): stack = self.stack ! value = stack.pop() ! key = stack.pop() dict = stack[-1] dict[key] = value *************** *** 1015,1020 **** def load_build(self): stack = self.stack ! value = stack[-1] ! del stack[-1] inst = stack[-1] try: --- 1009,1013 ---- def load_build(self): stack = self.stack ! value = stack.pop() inst = stack[-1] try: *************** *** 1039,1044 **** def load_stop(self): ! value = self.stack[-1] ! del self.stack[-1] raise _Stop(value) dispatch[STOP] = load_stop --- 1032,1036 ---- def load_stop(self): ! value = self.stack.pop() raise _Stop(value) dispatch[STOP] = load_stop Index: xmlrpclib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xmlrpclib.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** xmlrpclib.py 27 Jun 2002 21:36:21 -0000 1.19 --- xmlrpclib.py 30 Jun 2002 03:39:14 -0000 1.20 *************** *** 780,785 **** def end_array(self, data): ! mark = self._marks[-1] ! del self._marks[-1] # map arrays to Python lists self._stack[mark:] = [self._stack[mark:]] --- 780,784 ---- def end_array(self, data): ! mark = self._marks.pop() # map arrays to Python lists self._stack[mark:] = [self._stack[mark:]] *************** *** 788,793 **** def end_struct(self, data): ! mark = self._marks[-1] ! del self._marks[-1] # map structs to Python dictionaries dict = {} --- 787,791 ---- def end_struct(self, data): ! mark = self._marks.pop() # map structs to Python dictionaries dict = {} From rhettinger@users.sourceforge.net Sun Jun 30 05:32:41 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat, 29 Jun 2002 21:32:41 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libuserdict.tex,1.20,1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv27684 Modified Files: libuserdict.tex Log Message: Fix bug 575221 referred to dictionary type instead of dict. Index: libuserdict.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libuserdict.tex,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** libuserdict.tex 26 Oct 2001 18:37:27 -0000 1.20 --- libuserdict.tex 30 Jun 2002 04:32:38 -0000 1.21 *************** *** 8,12 **** you are writing code that does not need to work with versions of Python earlier than Python 2.2, please consider subclassing directly ! from the built-in \class{dictionary} type.} This module defines a class that acts as a wrapper around --- 8,12 ---- you are writing code that does not need to work with versions of Python earlier than Python 2.2, please consider subclassing directly ! from the built-in \class{dict} type.} This module defines a class that acts as a wrapper around From rhettinger@users.sourceforge.net Sun Jun 30 05:33:40 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat, 29 Jun 2002 21:33:40 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libuserdict.tex,1.20,1.20.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv27865 Modified Files: Tag: release22-maint libuserdict.tex Log Message: Fix bug 575221 referred to dictionary type instead of dict. Index: libuserdict.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libuserdict.tex,v retrieving revision 1.20 retrieving revision 1.20.8.1 diff -C2 -d -r1.20 -r1.20.8.1 *** libuserdict.tex 26 Oct 2001 18:37:27 -0000 1.20 --- libuserdict.tex 30 Jun 2002 04:33:37 -0000 1.20.8.1 *************** *** 8,12 **** you are writing code that does not need to work with versions of Python earlier than Python 2.2, please consider subclassing directly ! from the built-in \class{dictionary} type.} This module defines a class that acts as a wrapper around --- 8,12 ---- you are writing code that does not need to work with versions of Python earlier than Python 2.2, please consider subclassing directly ! from the built-in \class{dict} type.} This module defines a class that acts as a wrapper around From rhettinger@users.sourceforge.net Sun Jun 30 05:43:22 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat, 29 Jun 2002 21:43:22 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libshutil.tex,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv30395 Modified Files: libshutil.tex Log Message: Fixed bug 574978 shutil example out of sync with source code Index: libshutil.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libshutil.tex,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** libshutil.tex 18 Jun 2002 14:31:04 -0000 1.9 --- libshutil.tex 30 Jun 2002 04:43:20 -0000 1.10 *************** *** 113,120 **** os.symlink(linkto, dstname) elif os.path.isdir(srcname): ! copytree(srcname, dstname) else: copy2(srcname, dstname) - # XXX What about devices, sockets etc.? except (IOError, os.error), why: print "Can't copy %s to %s: %s" % (`srcname`, `dstname`, str(why)) --- 113,119 ---- os.symlink(linkto, dstname) elif os.path.isdir(srcname): ! copytree(srcname, dstname, symlinks) else: copy2(srcname, dstname) except (IOError, os.error), why: print "Can't copy %s to %s: %s" % (`srcname`, `dstname`, str(why)) From rhettinger@users.sourceforge.net Sun Jun 30 05:44:31 2002 From: rhettinger@users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat, 29 Jun 2002 21:44:31 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib libshutil.tex,1.8.14.1,1.8.14.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv30757 Modified Files: Tag: release22-maint libshutil.tex Log Message: Fixed bug 574978 shutil example out of sync with source code Index: libshutil.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libshutil.tex,v retrieving revision 1.8.14.1 retrieving revision 1.8.14.2 diff -C2 -d -r1.8.14.1 -r1.8.14.2 *** libshutil.tex 18 Jun 2002 14:31:19 -0000 1.8.14.1 --- libshutil.tex 30 Jun 2002 04:44:29 -0000 1.8.14.2 *************** *** 113,120 **** os.symlink(linkto, dstname) elif os.path.isdir(srcname): ! copytree(srcname, dstname) else: copy2(srcname, dstname) - # XXX What about devices, sockets etc.? except (IOError, os.error), why: print "Can't copy %s to %s: %s" % (`srcname`, `dstname`, str(why)) --- 113,119 ---- os.symlink(linkto, dstname) elif os.path.isdir(srcname): ! copytree(srcname, dstname, symlinks) else: copy2(srcname, dstname) except (IOError, os.error), why: print "Can't copy %s to %s: %s" % (`srcname`, `dstname`, str(why)) From loewis@users.sourceforge.net Sun Jun 30 07:03:37 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Sat, 29 Jun 2002 23:03:37 -0700 Subject: [Python-checkins] python/dist/src/Modules pyexpat.c,2.63,2.64 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv16090 Modified Files: pyexpat.c Log Message: Undo usage of PyOS_snprintf (rev. 1.51 of PyXML). Index: pyexpat.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/pyexpat.c,v retrieving revision 2.63 retrieving revision 2.64 diff -C2 -d -r2.63 -r2.64 *** pyexpat.c 28 Jun 2002 22:56:48 -0000 2.63 --- pyexpat.c 30 Jun 2002 06:03:35 -0000 2.64 *************** *** 114,118 **** enum XML_Error code = XML_GetErrorCode(parser); ! PyOS_snprintf(buffer, sizeof(buffer), "%.200s: line %i, column %i", XML_ErrorString(code), lineno, column); err = PyObject_CallFunction(ErrorObject, "s", buffer); --- 114,120 ---- enum XML_Error code = XML_GetErrorCode(parser); ! /* There is no risk of overflowing this buffer, since ! even for 64-bit integers, there is sufficient space. */ ! sprintf(buffer, "%.200s: line %i, column %i", XML_ErrorString(code), lineno, column); err = PyObject_CallFunction(ErrorObject, "s", buffer); From loewis@users.sourceforge.net Sun Jun 30 07:41:00 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Sat, 29 Jun 2002 23:41:00 -0700 Subject: [Python-checkins] python/dist/src/Modules pyexpat.c,2.64,2.65 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv24438 Modified Files: pyexpat.c Log Message: Define PyDoc_STRVAR if it is not available (PyXML 1.54). Remove support for Python 1.5 (PyXML 1.55). Index: pyexpat.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/pyexpat.c,v retrieving revision 2.64 retrieving revision 2.65 diff -C2 -d -r2.64 -r2.65 *** pyexpat.c 30 Jun 2002 06:03:35 -0000 2.64 --- pyexpat.c 30 Jun 2002 06:40:55 -0000 2.65 *************** *** 1,6 **** #include "Python.h" - #if PY_VERSION_HEX < 0x020000B1 - #include - #endif #include --- 1,3 ---- *************** *** 9,21 **** #include "expat.h" ! #ifndef PyGC_HEAD_SIZE ! #define PyGC_HEAD_SIZE 0 ! #define PyObject_GC_Init(x) ! #define PyObject_GC_Fini(m) ! #define Py_TPFLAGS_GC 0 #endif ! #if (PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION > 5) || (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 2) ! /* In Python 1.6, 2.0 and 2.1, disabling Unicode was not possible. */ #define Py_USING_UNICODE #endif --- 6,15 ---- #include "expat.h" ! #ifndef PyDoc_STRVAR ! #define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str) #endif ! #if (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 2) ! /* In Python 2.0 and 2.1, disabling Unicode was not possible. */ #define Py_USING_UNICODE #endif *************** *** 298,302 **** #define STRING_CONV_FUNC conv_string_to_utf8 #else ! /* Python 1.6 and later versions */ #define STRING_CONV_FUNC (self->returns_unicode \ ? conv_string_to_unicode : conv_string_to_utf8) --- 292,296 ---- #define STRING_CONV_FUNC conv_string_to_utf8 #else ! /* Python 2.0 and later versions */ #define STRING_CONV_FUNC (self->returns_unicode \ ? conv_string_to_unicode : conv_string_to_utf8) *************** *** 959,967 **** } - #if PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6 - new_parser = PyObject_NEW(xmlparseobject, &Xmlparsetype); - #else #ifndef Py_TPFLAGS_HAVE_GC ! /* Python versions 1.6 to 2.1 */ new_parser = PyObject_New(xmlparseobject, &Xmlparsetype); #else --- 953,958 ---- } #ifndef Py_TPFLAGS_HAVE_GC ! /* Python versions 2.0 and 2.1 */ new_parser = PyObject_New(xmlparseobject, &Xmlparsetype); #else *************** *** 969,973 **** new_parser = PyObject_GC_New(xmlparseobject, &Xmlparsetype); #endif - #endif if (new_parser == NULL) --- 960,963 ---- *************** *** 1128,1139 **** xmlparseobject *self; - #if PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6 - self = PyObject_NEW(xmlparseobject, &Xmlparsetype); - if (self == NULL) - return NULL; - - self->returns_unicode = 0; - #else - /* Code for versions 1.6 and later */ #ifdef Py_TPFLAGS_HAVE_GC /* Code for versions 2.2 and later */ --- 1118,1121 ---- *************** *** 1145,1150 **** --- 1127,1136 ---- return NULL; + #ifdef Py_USING_UNICODE self->returns_unicode = 1; + #else + self->returns_unicode = 0; #endif + self->buffer = NULL; self->buffer_size = CHARACTER_DATA_BUFFER_SIZE; *************** *** 1220,1229 **** } Py_XDECREF(self->intern); - #if PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6 - /* Code for versions before 1.6 */ - free(self); - #else #ifndef Py_TPFLAGS_HAVE_GC ! /* Code for versions 1.6 to 2.1 */ PyObject_Del(self); #else --- 1206,1211 ---- } Py_XDECREF(self->intern); #ifndef Py_TPFLAGS_HAVE_GC ! /* Code for versions 2.0 and 2.1 */ PyObject_Del(self); #else *************** *** 1231,1235 **** PyObject_GC_Del(self); #endif - #endif } --- 1213,1216 ---- *************** *** 1563,1599 **** PyDoc_STRVAR(pyexpat_module_documentation, "Python wrapper for Expat parser."); - - #if PY_VERSION_HEX < 0x20000F0 - - /* 1.5 compatibility: PyModule_AddObject */ - static int - PyModule_AddObject(PyObject *m, char *name, PyObject *o) - { - PyObject *dict; - if (!PyModule_Check(m) || o == NULL) - return -1; - dict = PyModule_GetDict(m); - if (dict == NULL) - return -1; - if (PyDict_SetItemString(dict, name, o)) - return -1; - Py_DECREF(o); - return 0; - } - - static int - PyModule_AddIntConstant(PyObject *m, char *name, long value) - { - return PyModule_AddObject(m, name, PyInt_FromLong(value)); - } - - static int - PyModule_AddStringConstant(PyObject *m, char *name, char *value) - { - return PyModule_AddObject(m, name, PyString_FromString(value)); - } - - #endif - /* Return a Python string that represents the version number without the --- 1544,1547 ---- From loewis@users.sourceforge.net Sun Jun 30 08:21:26 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun, 30 Jun 2002 00:21:26 -0700 Subject: [Python-checkins] python/dist/src/Lib/xml/sax expatreader.py,1.28,1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/xml/sax In directory usw-pr-cvs1:/tmp/cvs-serv1234 Modified Files: expatreader.py Log Message: Merge changes from PyXML: [1.15] Added understanding of the feature_validation, feature_external_pes, and feature_string_interning features. Added support for the feature_external_ges feature. Added support for the property_xml_string property. [1.16] Made it recognize the namespace prefixes feature. [1.17] removed erroneous first line [1.19] Support optional string interning in pyexpat. [1.21] Restore compatibility with versions of Python that did not support weak references. These do not get the cyclic reference fix, but they will continue to work as they did before. [1.22] Activate entity processing unless standalone. Index: expatreader.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/sax/expatreader.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** expatreader.py 31 May 2002 20:46:39 -0000 1.28 --- expatreader.py 30 Jun 2002 07:21:24 -0000 1.29 *************** *** 7,10 **** --- 7,15 ---- from xml.sax._exceptions import * + from xml.sax.handler import feature_validation, feature_namespaces + from xml.sax.handler import feature_namespace_prefixes + from xml.sax.handler import feature_external_ges, feature_external_pes + from xml.sax.handler import feature_string_interning + from xml.sax.handler import property_xml_string, property_interning_dict # xml.parsers.expat does not raise ImportError in Jython *************** *** 26,30 **** AttributesNSImpl = xmlreader.AttributesNSImpl ! import weakref # --- ExpatLocator --- 31,46 ---- AttributesNSImpl = xmlreader.AttributesNSImpl ! # If we're using a sufficiently recent version of Python, we can use ! # weak references to avoid cycles between the parser and content ! # handler, otherwise we'll just have to pretend. ! try: ! import _weakref ! except ImportError: ! def _mkproxy(o): ! return o ! else: ! import weakref ! _mkproxy = weakref.proxy ! del weakref, _weakref # --- ExpatLocator *************** *** 37,56 **** """ def __init__(self, parser): ! self._ref = weakref.ref(parser) def getColumnNumber(self): ! parser = self._ref() ! if parser is None or parser._parser is None: return None return parser._parser.ErrorColumnNumber def getLineNumber(self): ! parser = self._ref() ! if parser is None or parser._parser is None: return 1 return parser._parser.ErrorLineNumber def getPublicId(self): ! parser = self._ref() if parser is None: return None --- 53,72 ---- """ def __init__(self, parser): ! self._ref = _mkproxy(parser) def getColumnNumber(self): ! parser = self._ref ! if parser._parser is None: return None return parser._parser.ErrorColumnNumber def getLineNumber(self): ! parser = self._ref ! if parser._parser is None: return 1 return parser._parser.ErrorLineNumber def getPublicId(self): ! parser = self._ref if parser is None: return None *************** *** 58,62 **** def getSystemId(self): ! parser = self._ref() if parser is None: return None --- 74,78 ---- def getSystemId(self): ! parser = self._ref if parser is None: return None *************** *** 77,80 **** --- 93,98 ---- self._parsing = 0 self._entity_stack = [] + self._external_ges = 1 + self._interning = None # XMLReader methods *************** *** 101,106 **** def getFeature(self, name): ! if name == handler.feature_namespaces: return self._namespaces raise SAXNotRecognizedException("Feature '%s' not recognized" % name) --- 119,131 ---- def getFeature(self, name): ! if name == feature_namespaces: return self._namespaces + elif name == feature_string_interning: + return self._interning is not None + elif name in (feature_validation, feature_external_pes, + feature_namespace_prefixes): + return 0 + elif name == feature_external_ges: + return self._external_ges raise SAXNotRecognizedException("Feature '%s' not recognized" % name) *************** *** 108,113 **** if self._parsing: raise SAXNotSupportedException("Cannot set features while parsing") ! if name == handler.feature_namespaces: self._namespaces = state else: raise SAXNotRecognizedException("Feature '%s' not recognized" % --- 133,156 ---- if self._parsing: raise SAXNotSupportedException("Cannot set features while parsing") ! ! if name == feature_namespaces: self._namespaces = state + elif name == feature_external_ges: + self._external_ges = state + elif name == feature_string_interning: + if state: + if self._interning is None: + self._interning = {} + else: + self._interning = None + elif name == feature_validation: + if state: + raise SAXNotSupportedException("expat does not support validation") + elif name == feature_external_pes: + if state: + raise SAXNotSupportedException("expat does not read external parameter entities") + elif name == feature_namespace_prefixes: + if state: + raise SAXNotSupportedException("expat does not report namespace prefixes") else: raise SAXNotRecognizedException("Feature '%s' not recognized" % *************** *** 117,120 **** --- 160,173 ---- if name == handler.property_lexical_handler: return self._lex_handler_prop + elif name == property_interning_dict: + return self._interning + elif name == property_xml_string: + if self._parser: + if hasattr(self._parser, "GetInputContext"): + return self._parser.GetInputContext() + else: + raise SAXNotRecognizedException("This version of expat does not support getting the XML string") + else: + raise SAXNotSupportedException("XML string cannot be returned when not parsing") raise SAXNotRecognizedException("Property '%s' not recognized" % name) *************** *** 124,129 **** if self._parsing: self._reset_lex_handler_prop() else: ! raise SAXNotRecognizedException("Property '%s' not recognized" % name) # IncrementalParser methods --- 177,188 ---- if self._parsing: self._reset_lex_handler_prop() + elif name == property_interning_dict: + self._interning = value + elif name == property_xml_string: + raise SAXNotSupportedException("Property '%s' cannot be set" % + name) else: ! raise SAXNotRecognizedException("Property '%s' not recognized" % ! name) # IncrementalParser methods *************** *** 169,177 **** def reset(self): if self._namespaces: ! self._parser = expat.ParserCreate(None, " ") self._parser.StartElementHandler = self.start_element_ns self._parser.EndElementHandler = self.end_element_ns else: ! self._parser = expat.ParserCreate() self._parser.StartElementHandler = self.start_element self._parser.EndElementHandler = self.end_element --- 228,236 ---- def reset(self): if self._namespaces: ! self._parser = expat.ParserCreate(None, " ", intern = self._interning) self._parser.StartElementHandler = self.start_element_ns self._parser.EndElementHandler = self.end_element_ns else: ! self._parser = expat.ParserCreate(intern = self._interning) self._parser.StartElementHandler = self.start_element self._parser.EndElementHandler = self.end_element *************** *** 190,193 **** --- 249,253 ---- # self._parser.NotStandaloneHandler = self._parser.ExternalEntityRefHandler = self.external_entity_ref + self._parser.SetParamEntityParsing(expat.XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE) self._parsing = 0 *************** *** 269,272 **** --- 329,335 ---- def external_entity_ref(self, context, base, sysid, pubid): + if not self._external_ges: + return 1 + source = self._ent_handler.resolveEntity(pubid, sysid) source = saxutils.prepare_input_source(source, From loewis@users.sourceforge.net Sun Jun 30 08:27:32 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun, 30 Jun 2002 00:27:32 -0700 Subject: [Python-checkins] python/dist/src/Lib/xml/sax expatreader.py,1.29,1.30 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/xml/sax In directory usw-pr-cvs1:/tmp/cvs-serv2697 Modified Files: expatreader.py Log Message: Fix spacing. Index: expatreader.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/sax/expatreader.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** expatreader.py 30 Jun 2002 07:21:24 -0000 1.29 --- expatreader.py 30 Jun 2002 07:27:30 -0000 1.30 *************** *** 331,335 **** if not self._external_ges: return 1 ! source = self._ent_handler.resolveEntity(pubid, sysid) source = saxutils.prepare_input_source(source, --- 331,335 ---- if not self._external_ges: return 1 ! source = self._ent_handler.resolveEntity(pubid, sysid) source = saxutils.prepare_input_source(source, From loewis@users.sourceforge.net Sun Jun 30 08:32:58 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun, 30 Jun 2002 00:32:58 -0700 Subject: [Python-checkins] python/dist/src/Lib/xml/dom pulldom.py,1.24,1.25 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/xml/dom In directory usw-pr-cvs1:/tmp/cvs-serv3853 Modified Files: pulldom.py Log Message: Add xml namespace initially (PyXML 1.19). Index: pulldom.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/dom/pulldom.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** pulldom.py 20 Mar 2002 23:56:34 -0000 1.24 --- pulldom.py 30 Jun 2002 07:32:56 -0000 1.25 *************** *** 22,25 **** --- 22,26 ---- def __init__(self, documentFactory=None): + from xml.dom import XML_NAMESPACE self.documentFactory = documentFactory self.firstEvent = [None, None] *************** *** 32,36 **** # use class' pop instead pass ! self._ns_contexts = [{}] # contains uri -> prefix dicts self._current_context = self._ns_contexts[-1] self.pending_events = [] --- 33,37 ---- # use class' pop instead pass ! self._ns_contexts = [{XML_NAMESPACE:'xml'}] # contains uri -> prefix dicts self._current_context = self._ns_contexts[-1] self.pending_events = [] From loewis@users.sourceforge.net Sun Jun 30 08:38:52 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun, 30 Jun 2002 00:38:52 -0700 Subject: [Python-checkins] python/dist/src/Lib/xml/sax handler.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/xml/sax In directory usw-pr-cvs1:/tmp/cvs-serv5079 Modified Files: handler.py Log Message: Merge from PyXML: [1.3] Added documentation of the namespace URI for elements with no namespace. [1.4] New property http://www.python.org/sax/properties/encoding. [1.5] Support optional string interning in pyexpat. Index: handler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/sax/handler.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** handler.py 23 Oct 2000 18:09:50 -0000 1.8 --- handler.py 30 Jun 2002 07:38:50 -0000 1.9 *************** *** 145,149 **** name used in the source document, and the attrs parameter holds an instance of the Attributes class containing the ! attributes of the element.""" def endElementNS(self, name, qname): --- 145,152 ---- name used in the source document, and the attrs parameter holds an instance of the Attributes class containing the ! attributes of the element. ! ! The uri part of the name tuple is None for elements which have ! no namespace.""" def endElementNS(self, name, qname): *************** *** 316,321 **** # access: read-only all_properties = [property_lexical_handler, property_dom_node, property_declaration_handler, ! property_xml_string] --- 319,345 ---- # access: read-only + property_encoding = "http://www.python.org/sax/properties/encoding" + # data type: String + # description: The name of the encoding to assume for input data. + # access: write: set the encoding, e.g. established by a higher-level + # protocol. May change during parsing (e.g. after + # processing a META tag) + # read: return the current encoding (possibly established through + # auto-detection. + # initial value: UTF-8 + # + + property_interning_dict = "http://www.python.org/sax/properties/interning-dict" + # data type: Dictionary + # description: The dictionary used to intern common strings in the document + # access: write: Request that the parser uses a specific dictionary, to + # allow interning across different documents + # read: return the current interning dictionary, or None + # + all_properties = [property_lexical_handler, property_dom_node, property_declaration_handler, ! property_xml_string, ! property_encoding, ! property_interning_dict] From loewis@users.sourceforge.net Sun Jun 30 16:05:02 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun, 30 Jun 2002 08:05:02 -0700 Subject: [Python-checkins] python/dist/src/Lib/xml/dom minidom.py,1.46,1.47 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/xml/dom In directory usw-pr-cvs1:/tmp/cvs-serv931/Lib/xml/dom Modified Files: minidom.py Log Message: Implement the encoding argument for toxml and toprettyxml. Document toprettyxml. Index: minidom.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/dom/minidom.py,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** minidom.py 31 May 2002 20:46:38 -0000 1.46 --- minidom.py 30 Jun 2002 15:05:00 -0000 1.47 *************** *** 66,79 **** return 1 ! def toxml(self): ! writer = _get_StringIO() ! self.writexml(writer) ! return writer.getvalue() ! def toprettyxml(self, indent="\t", newl="\n"): # indent = the indentation string to prepend, per level # newl = the newline string to append writer = _get_StringIO() ! self.writexml(writer, "", indent, newl) return writer.getvalue() --- 66,85 ---- return 1 ! def toxml(self, encoding = None): ! return self.toprettyxml("", "", encoding) ! def toprettyxml(self, indent="\t", newl="\n", encoding = None): # indent = the indentation string to prepend, per level # newl = the newline string to append writer = _get_StringIO() ! if encoding is not None: ! import codecs ! # Can't use codecs.getwriter to preserve 2.0 compatibility ! writer = codecs.lookup(encoding)[3](writer) ! if self.nodeType == Node.DOCUMENT_NODE: ! # Can pass encoding only to document, to put it into XML header ! self.writexml(writer, "", indent, newl, encoding) ! else: ! self.writexml(writer, "", indent, newl) return writer.getvalue() *************** *** 935,940 **** NodeList()) ! def writexml(self, writer, indent="", addindent="", newl=""): ! writer.write('\n') for node in self.childNodes: node.writexml(writer, indent, addindent, newl) --- 941,950 ---- NodeList()) ! def writexml(self, writer, indent="", addindent="", newl="", ! encoding = None): ! if encoding is None: ! writer.write('\n') ! else: ! writer.write('\n' % encoding) for node in self.childNodes: node.writexml(writer, indent, addindent, newl) From loewis@users.sourceforge.net Sun Jun 30 16:05:02 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun, 30 Jun 2002 08:05:02 -0700 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.434,1.435 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory usw-pr-cvs1:/tmp/cvs-serv931/Misc Modified Files: NEWS Log Message: Implement the encoding argument for toxml and toprettyxml. Document toprettyxml. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.434 retrieving revision 1.435 diff -C2 -d -r1.434 -r1.435 *** NEWS 25 Jun 2002 00:25:30 -0000 1.434 --- NEWS 30 Jun 2002 15:05:00 -0000 1.435 *************** *** 171,174 **** --- 171,177 ---- Library + - xml.dom.minidom.toxml and toprettyxml now take an optional encoding + argument. + - Some fixes in the copy module: when an object is copied through its __reduce__ method, there was no check for a __setstate__ method on From loewis@users.sourceforge.net Sun Jun 30 16:05:02 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun, 30 Jun 2002 08:05:02 -0700 Subject: [Python-checkins] python/dist/src/Lib/test/output test_minidom,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory usw-pr-cvs1:/tmp/cvs-serv931/Lib/test/output Modified Files: test_minidom Log Message: Implement the encoding argument for toxml and toprettyxml. Document toprettyxml. Index: test_minidom =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_minidom,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** test_minidom 6 Dec 2001 18:27:48 -0000 1.16 --- test_minidom 30 Jun 2002 15:05:00 -0000 1.17 *************** *** 99,102 **** --- 99,105 ---- Test Succeeded testElementReprAndStr Passed assertion: len(Node.allnodes) == 0 + Passed testEncodings - encoding EURO SIGN + Test Succeeded testEncodings + Passed assertion: len(Node.allnodes) == 0 Test Succeeded testFirstChild Passed assertion: len(Node.allnodes) == 0 From loewis@users.sourceforge.net Sun Jun 30 16:05:02 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun, 30 Jun 2002 08:05:02 -0700 Subject: [Python-checkins] python/dist/src/Lib/test test_minidom.py,1.31,1.32 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory usw-pr-cvs1:/tmp/cvs-serv931/Lib/test Modified Files: test_minidom.py Log Message: Implement the encoding argument for toxml and toprettyxml. Document toprettyxml. Index: test_minidom.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_minidom.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** test_minidom.py 6 Dec 2001 18:27:48 -0000 1.31 --- test_minidom.py 30 Jun 2002 15:05:00 -0000 1.32 *************** *** 607,610 **** --- 607,618 ---- doc.unlink() + def testEncodings(): + doc = parseString('') + confirm(doc.toxml() == u'\n\u20ac' + and doc.toxml('utf-8') == '\n\xe2\x82\xac' + and doc.toxml('iso-8859-15') == '\n\xa4', + "testEncodings - encoding EURO SIGN") + doc.unlink() + # --- MAIN PROGRAM From loewis@users.sourceforge.net Sun Jun 30 16:05:02 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun, 30 Jun 2002 08:05:02 -0700 Subject: [Python-checkins] python/dist/src/Doc/lib xmldomminidom.tex,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory usw-pr-cvs1:/tmp/cvs-serv931/Doc/lib Modified Files: xmldomminidom.tex Log Message: Implement the encoding argument for toxml and toprettyxml. Document toprettyxml. Index: xmldomminidom.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/xmldomminidom.tex,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** xmldomminidom.tex 26 Oct 2001 20:09:49 -0000 1.5 --- xmldomminidom.tex 30 Jun 2002 15:04:59 -0000 1.6 *************** *** 122,129 **** \method{write()} method which matches that of the file object interface. \end{methoddesc} ! \begin{methoddesc}{toxml}{} Return the XML that the DOM represents as a string. \end{methoddesc} --- 122,164 ---- \method{write()} method which matches that of the file object interface. + + \versionadded[To support pretty output, new keyword parameters indent, + addindent, and newl have been added]{2.1} + + \versionadded[For the \class{Document} node, an additional keyword + argument encoding can be used to specify the encoding field of the XML + header]{2.3} + \end{methoddesc} ! \begin{methoddesc}{toxml}{\optional{encoding}} Return the XML that the DOM represents as a string. + + \versionadded[the \var{encoding} argument]{2.3} + + With no argument, the XML header does not specify an encoding, and the + result is Unicode string if the default encoding cannot represent all + characters in the document. Encoding this string in an encoding other + than UTF-8 is likely incorrect, since UTF-8 is the default encoding of + XML. + + With an explicit \var{encoding} argument, the result is a byte string + in the specified encoding. It is recommended that this argument is + always specified. To avoid UnicodeError exceptions in case of + unrepresentable text data, the encoding argument should be specified + as "utf-8". + + \end{methoddesc} + + \begin{methoddesc}{toprettyxml}{\optional{indent\optional{, newl}}} + + Return a pretty-printed version of the document. \var{indent} specifies + the indentation string and defaults to a tabulator; \var{newl} specifies + the string emitted at the end of each line and defaults to \\n. + + \versionadded{2.1} + + \versionadded[the encoding argument; see \method{toxml}]{2.3} + \end{methoddesc} From loewis@users.sourceforge.net Sun Jun 30 16:08:24 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun, 30 Jun 2002 08:08:24 -0700 Subject: [Python-checkins] python/dist/src/Lib/xml __init__.py,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/xml In directory usw-pr-cvs1:/tmp/cvs-serv2222/Lib/xml Modified Files: __init__.py Log Message: Bump required PyXML version to 0.6.5. Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/__init__.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** __init__.py 27 Mar 2001 21:38:15 -0000 1.11 --- __init__.py 30 Jun 2002 15:08:22 -0000 1.12 *************** *** 22,26 **** ! _MINIMUM_XMLPLUS_VERSION = (0, 6, 1) --- 22,26 ---- ! _MINIMUM_XMLPLUS_VERSION = (0, 6, 5) From loewis@users.sourceforge.net Sun Jun 30 16:26:12 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun, 30 Jun 2002 08:26:12 -0700 Subject: [Python-checkins] python/dist/src/PC getpathp.c,1.26,1.27 pyconfig.h,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/PC In directory usw-pr-cvs1:/tmp/cvs-serv9631/PC Modified Files: getpathp.c pyconfig.h Log Message: Patch #569753: Remove support for WIN16. Rename all occurrences of MS_WIN32 to MS_WINDOWS. Index: getpathp.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/getpathp.c,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** getpathp.c 12 Jan 2002 11:05:09 -0000 1.26 --- getpathp.c 30 Jun 2002 15:26:10 -0000 1.27 *************** *** 58,62 **** #include "osdefs.h" ! #ifdef MS_WIN32 #include #include --- 58,62 ---- #include "osdefs.h" ! #ifdef MS_WINDOWS #include #include *************** *** 183,187 **** } ! #ifdef MS_WIN32 /* a string loaded from the DLL at startup.*/ --- 183,187 ---- } ! #ifdef MS_WINDOWS /* a string loaded from the DLL at startup.*/ *************** *** 341,345 **** return retval; } ! #endif /* MS_WIN32 */ static void --- 341,345 ---- return retval; } ! #endif /* MS_WINDOWS */ static void *************** *** 350,354 **** char *prog = Py_GetProgramName(); ! #ifdef MS_WIN32 #ifdef UNICODE WCHAR wprogpath[MAXPATHLEN+1]; --- 350,354 ---- char *prog = Py_GetProgramName(); ! #ifdef MS_WINDOWS #ifdef UNICODE WCHAR wprogpath[MAXPATHLEN+1]; *************** *** 424,428 **** char *envpath = Py_GETENV("PYTHONPATH"); ! #ifdef MS_WIN32 int skiphome, skipdefault; char *machinepath = NULL; --- 424,428 ---- char *envpath = Py_GETENV("PYTHONPATH"); ! #ifdef MS_WINDOWS int skiphome, skipdefault; char *machinepath = NULL; *************** *** 447,451 **** ! #ifdef MS_WIN32 skiphome = pythonhome==NULL ? 0 : 1; machinepath = getpythonregpath(HKEY_LOCAL_MACHINE, skiphome); --- 447,451 ---- ! #ifdef MS_WINDOWS skiphome = pythonhome==NULL ? 0 : 1; machinepath = getpythonregpath(HKEY_LOCAL_MACHINE, skiphome); *************** *** 483,487 **** bufsz += strlen(PYTHONPATH) + 1; bufsz += strlen(argv0_path) + 1; ! #ifdef MS_WIN32 if (userpath) bufsz += strlen(userpath) + 1; --- 483,487 ---- bufsz += strlen(PYTHONPATH) + 1; bufsz += strlen(argv0_path) + 1; ! #ifdef MS_WINDOWS if (userpath) bufsz += strlen(userpath) + 1; *************** *** 504,513 **** module_search_path = PYTHONPATH; } ! #ifdef MS_WIN32 if (machinepath) free(machinepath); if (userpath) free(userpath); ! #endif /* MS_WIN32 */ return; } --- 504,513 ---- module_search_path = PYTHONPATH; } ! #ifdef MS_WINDOWS if (machinepath) free(machinepath); if (userpath) free(userpath); ! #endif /* MS_WINDOWS */ return; } *************** *** 518,522 **** *buf++ = DELIM; } ! #ifdef MS_WIN32 if (userpath) { strcpy(buf, userpath); --- 518,522 ---- *buf++ = DELIM; } ! #ifdef MS_WINDOWS if (userpath) { strcpy(buf, userpath); *************** *** 542,546 **** buf = strchr(buf, '\0'); } ! #endif /* MS_WIN32 */ else { char *p = PYTHONPATH; --- 542,546 ---- buf = strchr(buf, '\0'); } ! #endif /* MS_WINDOWS */ else { char *p = PYTHONPATH; Index: pyconfig.h =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/pyconfig.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** pyconfig.h 9 Jun 2002 13:41:36 -0000 1.10 --- pyconfig.h 30 Jun 2002 15:26:10 -0000 1.11 *************** *** 13,18 **** MS_WIN64 - Code specific to the MS Win64 API ! MS_WIN32 - Code specific to the MS Win32 (and Win64) API ! MS_WIN16 - Code specific to the old 16 bit Windows API. MS_WINDOWS - Code specific to Windows, but all versions. MS_COREDLL - Code if the Python core is built as a DLL. --- 13,17 ---- MS_WIN64 - Code specific to the MS Win64 API ! MS_WIN32 - Code specific to the MS Win32 (and Win64) API (obsolete, this covers all supported APIs) MS_WINDOWS - Code specific to Windows, but all versions. MS_COREDLL - Code if the Python core is built as a DLL. *************** *** 66,72 **** #define MS_WIN32 #endif - #ifdef _WIN16 - #define MS_WIN16 - #endif #define MS_WINDOWS --- 65,68 ---- *************** *** 452,459 **** /* Define if you have the putenv function. */ - #ifdef MS_WIN32 - /* Does this exist on Win16? */ #define HAVE_PUTENV - #endif /* Define if your compiler supports function prototypes */ --- 448,452 ---- From loewis@users.sourceforge.net Sun Jun 30 16:26:12 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun, 30 Jun 2002 08:26:12 -0700 Subject: [Python-checkins] python/dist/src/Objects fileobject.c,2.163,2.164 unicodeobject.c,2.154,2.155 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory usw-pr-cvs1:/tmp/cvs-serv9631/Objects Modified Files: fileobject.c unicodeobject.c Log Message: Patch #569753: Remove support for WIN16. Rename all occurrences of MS_WIN32 to MS_WINDOWS. Index: fileobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/fileobject.c,v retrieving revision 2.163 retrieving revision 2.164 diff -C2 -d -r2.163 -r2.164 *** fileobject.c 13 Jun 2002 20:32:59 -0000 2.163 --- fileobject.c 30 Jun 2002 15:26:09 -0000 2.164 *************** *** 9,13 **** #endif /* DONT_HAVE_SYS_TYPES_H */ ! #ifdef MS_WIN32 #define fileno _fileno /* can simulate truncate with Win32 API functions; see file_truncate */ --- 9,13 ---- #endif /* DONT_HAVE_SYS_TYPES_H */ ! #ifdef MS_WINDOWS #define fileno _fileno /* can simulate truncate with Win32 API functions; see file_truncate */ *************** *** 481,485 **** goto onioerror; ! #ifdef MS_WIN32 /* MS _chsize doesn't work if newsize doesn't fit in 32 bits, so don't even try using it. */ --- 481,485 ---- goto onioerror; ! #ifdef MS_WINDOWS /* MS _chsize doesn't work if newsize doesn't fit in 32 bits, so don't even try using it. */ *************** *** 543,547 **** Py_END_ALLOW_THREADS if (ret != 0) goto onioerror; ! #endif /* !MS_WIN32 */ Py_INCREF(Py_None); --- 543,547 ---- Py_END_ALLOW_THREADS if (ret != 0) goto onioerror; ! #endif /* !MS_WINDOWS */ Py_INCREF(Py_None); Index: unicodeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v retrieving revision 2.154 retrieving revision 2.155 diff -C2 -d -r2.154 -r2.155 *** unicodeobject.c 13 Jun 2002 21:25:17 -0000 2.154 --- unicodeobject.c 30 Jun 2002 15:26:10 -0000 2.155 *************** *** 42,46 **** #include "ucnhash.h" ! #ifdef MS_WIN32 #include #endif --- 42,46 ---- #include "ucnhash.h" ! #ifdef MS_WINDOWS #include #endif *************** *** 2244,2248 **** } ! #if defined(MS_WIN32) && defined(HAVE_USABLE_WCHAR_T) /* --- MBCS codecs for Windows -------------------------------------------- */ --- 2244,2248 ---- } ! #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T) /* --- MBCS codecs for Windows -------------------------------------------- */ *************** *** 2306,2310 **** } ! #endif /* MS_WIN32 */ /* --- Character Mapping Codec -------------------------------------------- */ --- 2306,2310 ---- } ! #endif /* MS_WINDOWS */ /* --- Character Mapping Codec -------------------------------------------- */ From loewis@users.sourceforge.net Sun Jun 30 16:26:12 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun, 30 Jun 2002 08:26:12 -0700 Subject: [Python-checkins] python/dist/src/Python bltinmodule.c,2.260,2.261 dynload_win.c,2.10,2.11 errors.c,2.69,2.70 frozenmain.c,2.27,2.28 import.c,2.207,2.208 pythonrun.c,2.160,2.161 sysmodule.c,2.106,2.107 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory usw-pr-cvs1:/tmp/cvs-serv9631/Python Modified Files: bltinmodule.c dynload_win.c errors.c frozenmain.c import.c pythonrun.c sysmodule.c Log Message: Patch #569753: Remove support for WIN16. Rename all occurrences of MS_WIN32 to MS_WINDOWS. Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.260 retrieving revision 2.261 diff -C2 -d -r2.260 -r2.261 *** bltinmodule.c 14 Jun 2002 20:41:16 -0000 2.260 --- bltinmodule.c 30 Jun 2002 15:26:10 -0000 2.261 *************** *** 17,21 **** Can remain NULL for all platforms that don't have such a concept */ ! #if defined(MS_WIN32) && defined(HAVE_USABLE_WCHAR_T) const char *Py_FileSystemDefaultEncoding = "mbcs"; #else --- 17,21 ---- Can remain NULL for all platforms that don't have such a concept */ ! #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T) const char *Py_FileSystemDefaultEncoding = "mbcs"; #else Index: dynload_win.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/dynload_win.c,v retrieving revision 2.10 retrieving revision 2.11 diff -C2 -d -r2.10 -r2.11 *** dynload_win.c 28 Nov 2001 20:40:47 -0000 2.10 --- dynload_win.c 30 Jun 2002 15:26:10 -0000 2.11 *************** *** 21,26 **** - #ifdef MS_WIN32 - /* Case insensitive string compare, to avoid any dependencies on particular C RTL implementations */ --- 21,24 ---- *************** *** 151,155 **** return NULL; } - #endif /* MS_WIN32 */ --- 149,152 ---- *************** *** 162,166 **** PyOS_snprintf(funcname, sizeof(funcname), "init%.200s", shortname); - #ifdef MS_WIN32 { HINSTANCE hDLL = NULL; --- 159,162 ---- *************** *** 243,271 **** p = GetProcAddress(hDLL, funcname); } - #endif /* MS_WIN32 */ - #ifdef MS_WIN16 - { - HINSTANCE hDLL; - char pathbuf[16]; - if (strchr(pathname, '\\') == NULL && - strchr(pathname, '/') == NULL) - { - /* Prefix bare filename with ".\" */ - PyOS_snprintf(pathbuf, sizeof(pathbuf), - ".\\%-.13s", pathname); - pathname = pathbuf; - } - hDLL = LoadLibrary(pathname); - if (hDLL < HINSTANCE_ERROR){ - char errBuf[256]; - PyOS_snprintf(errBuf, sizeof(errBuf), - "DLL load failed with error code %d", - hDLL); - PyErr_SetString(PyExc_ImportError, errBuf); - return NULL; - } - p = GetProcAddress(hDLL, funcname); - } - #endif /* MS_WIN16 */ return p; --- 239,242 ---- Index: errors.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/errors.c,v retrieving revision 2.69 retrieving revision 2.70 diff -C2 -d -r2.69 -r2.70 *** errors.c 14 Apr 2002 20:12:41 -0000 2.69 --- errors.c 30 Jun 2002 15:26:10 -0000 2.70 *************** *** 16,20 **** #endif ! #ifdef MS_WIN32 #include "windows.h" #include "winbase.h" --- 16,20 ---- #endif ! #ifdef MS_WINDOWS #include "windows.h" #include "winbase.h" *************** *** 268,272 **** char errbuf[ERRMAX]; #endif ! #ifdef MS_WIN32 char *s_buf = NULL; #endif --- 268,272 ---- char errbuf[ERRMAX]; #endif ! #ifdef MS_WINDOWS char *s_buf = NULL; #endif *************** *** 282,286 **** s = "Error"; /* Sometimes errno didn't get set */ else ! #ifndef MS_WIN32 s = strerror(i); #else --- 282,286 ---- s = "Error"; /* Sometimes errno didn't get set */ else ! #ifndef MS_WINDOWS s = strerror(i); #else *************** *** 323,327 **** Py_DECREF(v); } ! #ifdef MS_WIN32 LocalFree(s_buf); #endif --- 323,327 ---- Py_DECREF(v); } ! #ifdef MS_WINDOWS LocalFree(s_buf); #endif Index: frozenmain.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/frozenmain.c,v retrieving revision 2.27 retrieving revision 2.28 diff -C2 -d -r2.27 -r2.28 *** frozenmain.c 12 Jan 2002 11:05:10 -0000 2.27 --- frozenmain.c 30 Jun 2002 15:26:10 -0000 2.28 *************** *** 4,8 **** #include "Python.h" ! #ifdef MS_WIN32 extern void PyWinFreeze_ExeInit(void); extern void PyWinFreeze_ExeTerm(void); --- 4,8 ---- #include "Python.h" ! #ifdef MS_WINDOWS extern void PyWinFreeze_ExeInit(void); extern void PyWinFreeze_ExeTerm(void); *************** *** 33,42 **** } ! #ifdef MS_WIN32 PyInitFrozenExtensions(); ! #endif /* MS_WIN32 */ Py_SetProgramName(argv[0]); Py_Initialize(); ! #ifdef MS_WIN32 PyWinFreeze_ExeInit(); #endif --- 33,42 ---- } ! #ifdef MS_WINDOWS PyInitFrozenExtensions(); ! #endif /* MS_WINDOWS */ Py_SetProgramName(argv[0]); Py_Initialize(); ! #ifdef MS_WINDOWS PyWinFreeze_ExeInit(); #endif *************** *** 61,65 **** sts = PyRun_AnyFile(stdin, "") != 0; ! #ifdef MS_WIN32 PyWinFreeze_ExeTerm(); #endif --- 61,65 ---- sts = PyRun_AnyFile(stdin, "") != 0; ! #ifdef MS_WINDOWS PyWinFreeze_ExeTerm(); #endif Index: import.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/import.c,v retrieving revision 2.207 retrieving revision 2.208 diff -C2 -d -r2.207 -r2.208 *** import.c 17 Jun 2002 10:43:59 -0000 2.207 --- import.c 30 Jun 2002 15:26:10 -0000 2.208 *************** *** 89,93 **** static const struct filedescr _PyImport_StandardFiletab[] = { {".py", "U", PY_SOURCE}, ! #ifdef MS_WIN32 {".pyw", "U", PY_SOURCE}, #endif --- 89,93 ---- static const struct filedescr _PyImport_StandardFiletab[] = { {".py", "U", PY_SOURCE}, ! #ifdef MS_WINDOWS {".pyw", "U", PY_SOURCE}, #endif *************** *** 549,553 **** return NULL; ! #ifdef MS_WIN32 /* Treat .pyw as if it were .py. The case of ".pyw" must match that used in _PyImport_StandardFiletab. */ --- 549,553 ---- return NULL; ! #ifdef MS_WINDOWS /* Treat .pyw as if it were .py. The case of ".pyw" must match that used in _PyImport_StandardFiletab. */ *************** *** 1157,1161 **** * of #if's here should match the sequence in the body of case_ok(). */ ! #if defined(MS_WIN32) || defined(__CYGWIN__) #include #ifdef __CYGWIN__ --- 1157,1161 ---- * of #if's here should match the sequence in the body of case_ok(). */ ! #if defined(MS_WINDOWS) || defined(__CYGWIN__) #include #ifdef __CYGWIN__ *************** *** 1190,1195 **** */ ! /* MS_WIN32 || __CYGWIN__ */ ! #if defined(MS_WIN32) || defined(__CYGWIN__) WIN32_FIND_DATA data; HANDLE h; --- 1190,1195 ---- */ ! /* MS_WINDOWS || __CYGWIN__ */ ! #if defined(MS_WINDOWS) || defined(__CYGWIN__) WIN32_FIND_DATA data; HANDLE h; Index: pythonrun.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v retrieving revision 2.160 retrieving revision 2.161 diff -C2 -d -r2.160 -r2.161 *** pythonrun.c 23 Apr 2002 20:31:01 -0000 2.160 --- pythonrun.c 30 Jun 2002 15:26:10 -0000 2.161 *************** *** 18,22 **** #endif ! #ifdef MS_WIN32 #undef BYTE #include "windows.h" --- 18,22 ---- #endif ! #ifdef MS_WINDOWS #undef BYTE #include "windows.h" *************** *** 1273,1277 **** for (;;); #endif ! #ifdef MS_WIN32 OutputDebugString("Fatal Python error: "); OutputDebugString(msg); --- 1273,1277 ---- for (;;); #endif ! #ifdef MS_WINDOWS OutputDebugString("Fatal Python error: "); OutputDebugString(msg); *************** *** 1280,1284 **** DebugBreak(); #endif ! #endif /* MS_WIN32 */ abort(); } --- 1280,1284 ---- DebugBreak(); #endif ! #endif /* MS_WINDOWS */ abort(); } Index: sysmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v retrieving revision 2.106 retrieving revision 2.107 diff -C2 -d -r2.106 -r2.107 *** sysmodule.c 26 Jun 2002 20:39:20 -0000 2.106 --- sysmodule.c 30 Jun 2002 15:26:10 -0000 2.107 *************** *** 688,692 **** " ) - #ifndef MS_WIN16 /* concatenating string here */ PyDoc_STR( --- 688,691 ---- *************** *** 738,742 **** " ) - #endif /* MS_WIN16 */ /* end of sys_doc */ ; --- 737,740 ---- From loewis@users.sourceforge.net Sun Jun 30 16:26:12 2002 From: loewis@users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun, 30 Jun 2002 08:26:12 -0700 Subject: [Python-checkins] python/dist/src/Modules _codecsmodule.c,2.11,2.12 _hotshot.c,1.18,1.19 _localemodule.c,2.32,2.33 mmapmodule.c,2.38,2.39 posixmodule.c,2.240,2.241 signalmodule.c,2.69,2.70 timemodule.c,2.127,2.128 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv9631/Modules Modified Files: _codecsmodule.c _hotshot.c _localemodule.c mmapmodule.c posixmodule.c signalmodule.c timemodule.c Log Message: Patch #569753: Remove support for WIN16. Rename all occurrences of MS_WIN32 to MS_WINDOWS. Index: _codecsmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_codecsmodule.c,v retrieving revision 2.11 retrieving revision 2.12 diff -C2 -d -r2.11 -r2.12 *** _codecsmodule.c 17 Jan 2002 23:15:58 -0000 2.11 --- _codecsmodule.c 30 Jun 2002 15:26:09 -0000 2.12 *************** *** 317,321 **** } ! #if defined(MS_WIN32) && defined(HAVE_USABLE_WCHAR_T) static PyObject * --- 317,321 ---- } ! #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T) static PyObject * *************** *** 335,339 **** } ! #endif /* MS_WIN32 */ /* --- Encoder ------------------------------------------------------------ */ --- 335,339 ---- } ! #endif /* MS_WINDOWS */ /* --- Encoder ------------------------------------------------------------ */ *************** *** 637,641 **** } ! #if defined(MS_WIN32) && defined(HAVE_USABLE_WCHAR_T) static PyObject * --- 637,641 ---- } ! #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T) static PyObject * *************** *** 662,666 **** } ! #endif /* MS_WIN32 */ #endif /* Py_USING_UNICODE */ --- 662,666 ---- } ! #endif /* MS_WINDOWS */ #endif /* Py_USING_UNICODE */ *************** *** 696,700 **** {"readbuffer_encode", readbuffer_encode, METH_VARARGS}, {"charbuffer_encode", charbuffer_encode, METH_VARARGS}, ! #if defined(MS_WIN32) && defined(HAVE_USABLE_WCHAR_T) {"mbcs_encode", mbcs_encode, METH_VARARGS}, {"mbcs_decode", mbcs_decode, METH_VARARGS}, --- 696,700 ---- {"readbuffer_encode", readbuffer_encode, METH_VARARGS}, {"charbuffer_encode", charbuffer_encode, METH_VARARGS}, ! #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T) {"mbcs_encode", mbcs_encode, METH_VARARGS}, {"mbcs_decode", mbcs_decode, METH_VARARGS}, Index: _hotshot.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_hotshot.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** _hotshot.c 13 Jun 2002 20:32:45 -0000 1.18 --- _hotshot.c 30 Jun 2002 15:26:09 -0000 1.19 *************** *** 13,17 **** * be difficult. This will do for now. */ ! #ifdef MS_WIN32 #include #include /* for getcwd() */ --- 13,17 ---- * be difficult. This will do for now. */ ! #ifdef MS_WINDOWS #include #include /* for getcwd() */ *************** *** 91,95 **** ! #ifndef MS_WIN32 #ifdef GETTIMEOFDAY_NO_TZ #define GETTIMEOFDAY(ptv) gettimeofday((ptv)) --- 91,95 ---- ! #ifndef MS_WINDOWS #ifdef GETTIMEOFDAY_NO_TZ #define GETTIMEOFDAY(ptv) gettimeofday((ptv)) *************** *** 819,823 **** { int tdelta; ! #ifdef MS_WIN32 hs_time tv; hs_time diff; --- 819,823 ---- { int tdelta; ! #ifdef MS_WINDOWS hs_time tv; hs_time diff; *************** *** 910,914 **** /* A couple of useful helper functions. */ ! #ifdef MS_WIN32 static LARGE_INTEGER frequency = {0, 0}; #endif --- 910,914 ---- /* A couple of useful helper functions. */ ! #ifdef MS_WINDOWS static LARGE_INTEGER frequency = {0, 0}; #endif *************** *** 922,926 **** hs_time tv1, tv2; ! #ifdef MS_WIN32 hs_time diff; QueryPerformanceFrequency(&frequency); --- 922,926 ---- hs_time tv1, tv2; ! #ifdef MS_WINDOWS hs_time diff; QueryPerformanceFrequency(&frequency); *************** *** 930,934 **** while (1) { GETTIMEOFDAY(&tv2); ! #ifdef MS_WIN32 diff = tv2 - tv1; if (diff != 0) { --- 930,934 ---- while (1) { GETTIMEOFDAY(&tv2); ! #ifdef MS_WINDOWS diff = tv2 - tv1; if (diff != 0) { *************** *** 946,950 **** #endif } ! #if defined(MS_WIN32) || defined(macintosh) || defined(PYOS_OS2) rusage_diff = -1; #else --- 946,950 ---- #endif } ! #if defined(MS_WINDOWS) || defined(macintosh) || defined(PYOS_OS2) rusage_diff = -1; #else *************** *** 1449,1453 **** pack_add_info(self, "executable-version", buffer); ! #ifdef MS_WIN32 PyOS_snprintf(cwdbuffer, sizeof(cwdbuffer), "%I64d", frequency.QuadPart); pack_add_info(self, "reported-performance-frequency", cwdbuffer); --- 1449,1453 ---- pack_add_info(self, "executable-version", buffer); ! #ifdef MS_WINDOWS PyOS_snprintf(cwdbuffer, sizeof(cwdbuffer), "%I64d", frequency.QuadPart); pack_add_info(self, "reported-performance-frequency", cwdbuffer); *************** *** 1554,1558 **** PyDoc_VAR(resolution__doc__) = ! #ifdef MS_WIN32 PyDoc_STR( "resolution() -> (performance-counter-ticks, update-frequency)\n" --- 1554,1558 ---- PyDoc_VAR(resolution__doc__) = ! #ifdef MS_WINDOWS PyDoc_STR( "resolution() -> (performance-counter-ticks, update-frequency)\n" *************** *** 1581,1585 **** calibrate(); } ! #ifdef MS_WIN32 result = Py_BuildValue("ii", timeofday_diff, frequency.LowPart); #else --- 1581,1585 ---- calibrate(); } ! #ifdef MS_WINDOWS result = Py_BuildValue("ii", timeofday_diff, frequency.LowPart); #else Index: _localemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_localemodule.c,v retrieving revision 2.32 retrieving revision 2.33 diff -C2 -d -r2.32 -r2.33 *** _localemodule.c 13 Jun 2002 20:32:45 -0000 2.32 --- _localemodule.c 30 Jun 2002 15:26:09 -0000 2.33 *************** *** 26,30 **** #endif ! #if defined(MS_WIN32) #define WINDOWS_LEAN_AND_MEAN #include --- 26,30 ---- #endif ! #if defined(MS_WINDOWS) #define WINDOWS_LEAN_AND_MEAN #include *************** *** 364,368 **** } ! #if defined(MS_WIN32) static PyObject* PyLocale_getdefaultlocale(PyObject* self) --- 364,368 ---- } ! #if defined(MS_WINDOWS) static PyObject* PyLocale_getdefaultlocale(PyObject* self) *************** *** 628,632 **** {"strxfrm", (PyCFunction) PyLocale_strxfrm, METH_VARARGS, strxfrm__doc__}, ! #if defined(MS_WIN32) || defined(macintosh) {"_getdefaultlocale", (PyCFunction) PyLocale_getdefaultlocale, METH_NOARGS}, #endif --- 628,632 ---- {"strxfrm", (PyCFunction) PyLocale_strxfrm, METH_VARARGS, strxfrm__doc__}, ! #if defined(MS_WINDOWS) || defined(macintosh) {"_getdefaultlocale", (PyCFunction) PyLocale_getdefaultlocale, METH_NOARGS}, #endif Index: mmapmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/mmapmodule.c,v retrieving revision 2.38 retrieving revision 2.39 diff -C2 -d -r2.38 -r2.39 *** mmapmodule.c 8 Mar 2002 05:43:32 -0000 2.38 --- mmapmodule.c 30 Jun 2002 15:26:09 -0000 2.39 *************** *** 21,29 **** #include ! #ifndef MS_WIN32 #define UNIX #endif ! #ifdef MS_WIN32 #include static int --- 21,29 ---- #include ! #ifndef MS_WINDOWS #define UNIX #endif ! #ifdef MS_WINDOWS #include static int *************** *** 76,80 **** size_t pos; ! #ifdef MS_WIN32 HANDLE map_handle; HANDLE file_handle; --- 76,80 ---- size_t pos; ! #ifdef MS_WINDOWS HANDLE map_handle; HANDLE file_handle; *************** *** 93,97 **** mmap_object_dealloc(mmap_object *m_obj) { ! #ifdef MS_WIN32 if (m_obj->data != NULL) UnmapViewOfFile (m_obj->data); --- 93,97 ---- mmap_object_dealloc(mmap_object *m_obj) { ! #ifdef MS_WINDOWS if (m_obj->data != NULL) UnmapViewOfFile (m_obj->data); *************** *** 102,106 **** if (m_obj->tagname) PyMem_Free(m_obj->tagname); ! #endif /* MS_WIN32 */ #ifdef UNIX --- 102,106 ---- if (m_obj->tagname) PyMem_Free(m_obj->tagname); ! #endif /* MS_WINDOWS */ #ifdef UNIX *************** *** 119,123 **** if (!PyArg_ParseTuple(args, ":close")) return NULL; ! #ifdef MS_WIN32 /* For each resource we maintain, we need to check the value is valid, and if so, free the resource --- 119,123 ---- if (!PyArg_ParseTuple(args, ":close")) return NULL; ! #ifdef MS_WINDOWS /* For each resource we maintain, we need to check the value is valid, and if so, free the resource *************** *** 139,143 **** self->file_handle = INVALID_HANDLE_VALUE; } ! #endif /* MS_WIN32 */ #ifdef UNIX --- 139,143 ---- self->file_handle = INVALID_HANDLE_VALUE; } ! #endif /* MS_WINDOWS */ #ifdef UNIX *************** *** 150,154 **** } ! #ifdef MS_WIN32 #define CHECK_VALID(err) \ do { \ --- 150,154 ---- } ! #ifdef MS_WINDOWS #define CHECK_VALID(err) \ do { \ *************** *** 158,162 **** } \ } while (0) ! #endif /* MS_WIN32 */ #ifdef UNIX --- 158,162 ---- } \ } while (0) ! #endif /* MS_WINDOWS */ #ifdef UNIX *************** *** 337,341 **** return NULL; ! #ifdef MS_WIN32 if (self->file_handle != INVALID_HANDLE_VALUE) { return (Py_BuildValue ( --- 337,341 ---- return NULL; ! #ifdef MS_WINDOWS if (self->file_handle != INVALID_HANDLE_VALUE) { return (Py_BuildValue ( *************** *** 345,349 **** return (Py_BuildValue ("l", (long) self->size) ); } ! #endif /* MS_WIN32 */ #ifdef UNIX --- 345,349 ---- return (Py_BuildValue ("l", (long) self->size) ); } ! #endif /* MS_WINDOWS */ #ifdef UNIX *************** *** 377,381 **** !is_resizeable(self)) { return NULL; ! #ifdef MS_WIN32 } else { DWORD dwErrCode = 0; --- 377,381 ---- !is_resizeable(self)) { return NULL; ! #ifdef MS_WINDOWS } else { DWORD dwErrCode = 0; *************** *** 415,419 **** PyErr_SetFromWindowsErr(dwErrCode); return (NULL); ! #endif /* MS_WIN32 */ #ifdef UNIX --- 415,419 ---- PyErr_SetFromWindowsErr(dwErrCode); return (NULL); ! #endif /* MS_WINDOWS */ #ifdef UNIX *************** *** 468,475 **** return NULL; } else { ! #ifdef MS_WIN32 return (Py_BuildValue("l", (long) FlushViewOfFile(self->data+offset, size))); ! #endif /* MS_WIN32 */ #ifdef UNIX /* XXX semantics of return value? */ --- 468,475 ---- return NULL; } else { ! #ifdef MS_WINDOWS return (Py_BuildValue("l", (long) FlushViewOfFile(self->data+offset, size))); ! #endif /* MS_WINDOWS */ #ifdef UNIX /* XXX semantics of return value? */ *************** *** 910,914 **** #endif /* UNIX */ ! #ifdef MS_WIN32 static PyObject * new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict) --- 910,914 ---- #endif /* UNIX */ ! #ifdef MS_WINDOWS static PyObject * new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict) *************** *** 1043,1047 **** return (NULL); } ! #endif /* MS_WIN32 */ /* List of functions exported by this module */ --- 1043,1047 ---- return (NULL); } ! #endif /* MS_WINDOWS */ /* List of functions exported by this module */ Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.240 retrieving revision 2.241 diff -C2 -d -r2.240 -r2.241 *** posixmodule.c 20 Jun 2002 18:31:21 -0000 2.240 --- posixmodule.c 30 Jun 2002 15:26:09 -0000 2.241 *************** *** 5,9 **** module actually calls itself 'nt' or 'os2', not 'posix', and a few functions are either unimplemented or implemented differently. The source ! assumes that for Windows NT, the macro 'MS_WIN32' is defined independent of the compiler used. Different compilers define their own feature test macro, e.g. '__BORLANDC__' or '_MSC_VER'. For OS/2, the compiler --- 5,9 ---- module actually calls itself 'nt' or 'os2', not 'posix', and a few functions are either unimplemented or implemented differently. The source ! assumes that for Windows NT, the macro 'MS_WINDOWS' is defined independent of the compiler used. Different compilers define their own feature test macro, e.g. '__BORLANDC__' or '_MSC_VER'. For OS/2, the compiler *************** *** 83,87 **** #ifdef _MSC_VER /* Microsoft compiler */ #define HAVE_GETCWD 1 - #ifdef MS_WIN32 #define HAVE_SPAWNV 1 #define HAVE_EXECV 1 --- 83,86 ---- *************** *** 90,95 **** #define HAVE_SYSTEM 1 #define HAVE_CWAIT 1 - #else /* 16-bit Windows */ - #endif /* !MS_WIN32 */ #else #if defined(PYOS_OS2) && defined(PYCC_GCC) --- 89,92 ---- *************** *** 223,233 **** #define WINDOWS_LEAN_AND_MEAN #include - #ifdef MS_WIN32 #define popen _popen #define pclose _pclose - #else /* 16-bit Windows */ - #include - #include - #endif /* MS_WIN32 */ #endif /* _MSC_VER */ --- 220,225 ---- *************** *** 269,273 **** /* choose the appropriate stat and fstat functions and return structs */ #undef STAT ! #if defined(MS_WIN64) || defined(MS_WIN32) # define STAT _stati64 # define FSTAT _fstati64 --- 261,265 ---- /* choose the appropriate stat and fstat functions and return structs */ #undef STAT ! #if defined(MS_WIN64) || defined(MS_WINDOWS) # define STAT _stati64 # define FSTAT _fstati64 *************** *** 368,372 **** } ! #ifdef MS_WIN32 static PyObject * win32_error(char* function, char* filename) --- 360,364 ---- } ! #ifdef MS_WINDOWS static PyObject * win32_error(char* function, char* filename) *************** *** 685,692 **** int res; ! #ifdef MS_WIN32 int pathlen; char pathcopy[MAX_PATH]; ! #endif /* MS_WIN32 */ if (!PyArg_ParseTuple(args, format, --- 677,684 ---- int res; ! #ifdef MS_WINDOWS int pathlen; char pathcopy[MAX_PATH]; ! #endif /* MS_WINDOWS */ if (!PyArg_ParseTuple(args, format, *************** *** 695,699 **** pathfree = path; ! #ifdef MS_WIN32 pathlen = strlen(path); /* the library call can blow up if the file name is too long! */ --- 687,691 ---- pathfree = path; ! #ifdef MS_WINDOWS pathlen = strlen(path); /* the library call can blow up if the file name is too long! */ *************** *** 720,724 **** } } ! #endif /* MS_WIN32 */ Py_BEGIN_ALLOW_THREADS --- 712,716 ---- } } ! #endif /* MS_WINDOWS */ Py_BEGIN_ALLOW_THREADS *************** *** 992,996 **** /* XXX Should redo this putting the (now four) versions of opendir in separate files instead of having them all here... */ ! #if defined(MS_WIN32) && !defined(HAVE_OPENDIR) PyObject *d, *v; --- 984,988 ---- /* XXX Should redo this putting the (now four) versions of opendir in separate files instead of having them all here... */ ! #if defined(MS_WINDOWS) && !defined(HAVE_OPENDIR) PyObject *d, *v; *************** *** 1048,1112 **** return d; - #elif defined(_MSC_VER) /* 16-bit Windows */ - - #ifndef MAX_PATH - #define MAX_PATH 250 - #endif - char *name, *pt; - int len; - PyObject *d, *v; - char namebuf[MAX_PATH+5]; - struct _find_t ep; - - if (!PyArg_ParseTuple(args, "t#:listdir", &name, &len)) - return NULL; - if (len >= MAX_PATH) { - PyErr_SetString(PyExc_ValueError, "path too long"); - return NULL; - } - strcpy(namebuf, name); - for (pt = namebuf; *pt; pt++) - if (*pt == ALTSEP) - *pt = SEP; - if (namebuf[len-1] != SEP) - namebuf[len++] = SEP; - strcpy(namebuf + len, "*.*"); - - if ((d = PyList_New(0)) == NULL) - return NULL; - - if (_dos_findfirst(namebuf, _A_RDONLY | - _A_HIDDEN | _A_SYSTEM | _A_SUBDIR, &ep) != 0) - { - errno = ENOENT; - return posix_error_with_filename(name); - } - do { - if (ep.name[0] == '.' && - (ep.name[1] == '\0' || - ep.name[1] == '.' && - ep.name[2] == '\0')) - continue; - strcpy(namebuf, ep.name); - for (pt = namebuf; *pt; pt++) - if (isupper(*pt)) - *pt = tolower(*pt); - v = PyString_FromString(namebuf); - if (v == NULL) { - Py_DECREF(d); - d = NULL; - break; - } - if (PyList_Append(d, v) != 0) { - Py_DECREF(v); - Py_DECREF(d); - d = NULL; - break; - } - Py_DECREF(v); - } while (_dos_findnext(&ep) == 0); - - return d; - #elif defined(PYOS_OS2) --- 1040,1043 ---- *************** *** 1221,1225 **** } /* end of posix_listdir */ ! #ifdef MS_WIN32 /* A helper function for abspath on win32 */ static PyObject * --- 1152,1156 ---- } /* end of posix_listdir */ ! #ifdef MS_WINDOWS /* A helper function for abspath on win32 */ static PyObject * *************** *** 1241,1245 **** return PyString_FromString(outbuf); } /* end of posix__getfullpathname */ ! #endif /* MS_WIN32 */ PyDoc_STRVAR(posix_mkdir__doc__, --- 1172,1176 ---- return PyString_FromString(outbuf); } /* end of posix__getfullpathname */ ! #endif /* MS_WINDOWS */ PyDoc_STRVAR(posix_mkdir__doc__, *************** *** 3051,3055 **** #endif /* PYCC_??? */ ! #elif defined(MS_WIN32) /* --- 2982,2986 ---- #endif /* PYCC_??? */ ! #elif defined(MS_WINDOWS) /* *************** *** 4212,4216 **** ! #ifdef MS_WIN32 #define HAVE_TIMES /* so the method table will pick it up */ static PyObject * --- 4143,4147 ---- ! #ifdef MS_WINDOWS #define HAVE_TIMES /* so the method table will pick it up */ static PyObject * *************** *** 4238,4242 **** (double)0); } ! #endif /* MS_WIN32 */ #ifdef HAVE_TIMES --- 4169,4173 ---- (double)0); } ! #endif /* MS_WINDOWS */ #ifdef HAVE_TIMES *************** *** 4415,4419 **** { int fd, how; ! #if defined(MS_WIN64) || defined(MS_WIN32) LONG_LONG pos, res; #else --- 4346,4350 ---- { int fd, how; ! #if defined(MS_WIN64) || defined(MS_WINDOWS) LONG_LONG pos, res; #else *************** *** 4442,4446 **** Py_BEGIN_ALLOW_THREADS ! #if defined(MS_WIN64) || defined(MS_WIN32) res = _lseeki64(fd, pos, how); #else --- 4373,4377 ---- Py_BEGIN_ALLOW_THREADS ! #if defined(MS_WIN64) || defined(MS_WINDOWS) res = _lseeki64(fd, pos, how); #else *************** *** 4591,4595 **** return Py_BuildValue("(ii)", read, write); #else ! #if !defined(MS_WIN32) int fds[2]; int res; --- 4522,4526 ---- return Py_BuildValue("(ii)", read, write); #else ! #if !defined(MS_WINDOWS) int fds[2]; int res; *************** *** 4602,4606 **** return posix_error(); return Py_BuildValue("(ii)", fds[0], fds[1]); ! #else /* MS_WIN32 */ HANDLE read, write; int read_fd, write_fd; --- 4533,4537 ---- return posix_error(); return Py_BuildValue("(ii)", fds[0], fds[1]); ! #else /* MS_WINDOWS */ HANDLE read, write; int read_fd, write_fd; *************** *** 4616,4620 **** write_fd = _open_osfhandle((Py_intptr_t)write, 1); return Py_BuildValue("(ii)", read_fd, write_fd); ! #endif /* MS_WIN32 */ #endif } --- 4547,4551 ---- write_fd = _open_osfhandle((Py_intptr_t)write, 1); return Py_BuildValue("(ii)", read_fd, write_fd); ! #endif /* MS_WINDOWS */ #endif } *************** *** 5190,5194 **** return NULL; ! #ifdef MS_WIN32 name = _tempnam(dir, pfx); #else --- 5121,5125 ---- return NULL; ! #ifdef MS_WINDOWS name = _tempnam(dir, pfx); #else *************** *** 6251,6255 **** } ! #ifdef MS_WIN32 PyDoc_STRVAR(win32_startfile__doc__, "startfile(filepath) - Start a file with its associated application.\n\ --- 6182,6186 ---- } ! #ifdef MS_WINDOWS PyDoc_STRVAR(win32_startfile__doc__, "startfile(filepath) - Start a file with its associated application.\n\ *************** *** 6391,6395 **** #ifdef HAVE_POPEN {"popen", posix_popen, METH_VARARGS, posix_popen__doc__}, ! #ifdef MS_WIN32 {"popen2", win32_popen2, METH_VARARGS}, {"popen3", win32_popen3, METH_VARARGS}, --- 6322,6326 ---- #ifdef HAVE_POPEN {"popen", posix_popen, METH_VARARGS, posix_popen__doc__}, ! #ifdef MS_WINDOWS {"popen2", win32_popen2, METH_VARARGS}, {"popen3", win32_popen3, METH_VARARGS}, *************** *** 6543,6547 **** #endif {"abort", posix_abort, METH_VARARGS, posix_abort__doc__}, ! #ifdef MS_WIN32 {"_getfullpathname", posix__getfullpathname, METH_VARARGS, NULL}, #endif --- 6474,6478 ---- #endif {"abort", posix_abort, METH_VARARGS, posix_abort__doc__}, ! #ifdef MS_WINDOWS {"_getfullpathname", posix__getfullpathname, METH_VARARGS, NULL}, #endif Index: signalmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/signalmodule.c,v retrieving revision 2.69 retrieving revision 2.70 diff -C2 -d -r2.69 -r2.70 *** signalmodule.c 13 Jun 2002 21:42:51 -0000 2.69 --- signalmodule.c 30 Jun 2002 15:26:09 -0000 2.70 *************** *** 7,11 **** #include "intrcheck.h" ! #ifdef MS_WIN32 #include #endif --- 7,11 ---- #include "intrcheck.h" ! #ifdef MS_WINDOWS #include #endif Index: timemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/timemodule.c,v retrieving revision 2.127 retrieving revision 2.128 diff -C2 -d -r2.127 -r2.128 *** timemodule.c 13 Jun 2002 20:32:53 -0000 2.127 --- timemodule.c 30 Jun 2002 15:26:09 -0000 2.128 *************** *** 30,50 **** #ifdef MS_WINDOWS #include ! #if defined(MS_WIN16) || defined(__BORLANDC__) /* These overrides not needed for Win32 */ #define timezone _timezone #define tzname _tzname #define daylight _daylight ! #endif /* MS_WIN16 || __BORLANDC__ */ ! #ifdef MS_WIN16 ! #define altzone _altzone ! #endif /* MS_WIN16 */ #endif /* MS_WINDOWS */ #endif /* !__WATCOMC__ || __QNX__ */ ! #if defined(MS_WIN32) && !defined(MS_WIN64) && !defined(__BORLANDC__) /* Win32 has better clock replacement XXX Win64 does not yet, but might when the platform matures. */ #undef HAVE_CLOCK /* We have our own version down below */ ! #endif /* MS_WIN32 && !MS_WIN64 */ #if defined(PYOS_OS2) --- 30,47 ---- #ifdef MS_WINDOWS #include ! #if defined(__BORLANDC__) /* These overrides not needed for Win32 */ #define timezone _timezone #define tzname _tzname #define daylight _daylight ! #endif /* __BORLANDC__ */ #endif /* MS_WINDOWS */ #endif /* !__WATCOMC__ || __QNX__ */ ! #if defined(MS_WINDOWS) && !defined(MS_WIN64) && !defined(__BORLANDC__) /* Win32 has better clock replacement XXX Win64 does not yet, but might when the platform matures. */ #undef HAVE_CLOCK /* We have our own version down below */ ! #endif /* MS_WINDOWS && !MS_WIN64 */ #if defined(PYOS_OS2) *************** *** 142,146 **** #endif /* HAVE_CLOCK */ ! #if defined(MS_WIN32) && !defined(MS_WIN64) && !defined(__BORLANDC__) /* Due to Mark Hammond and Tim Peters */ static PyObject * --- 139,143 ---- #endif /* HAVE_CLOCK */ ! #if defined(MS_WINDOWS) && !defined(MS_WIN64) && !defined(__BORLANDC__) /* Due to Mark Hammond and Tim Peters */ static PyObject * *************** *** 171,175 **** #define HAVE_CLOCK /* So it gets included in the methods */ ! #endif /* MS_WIN32 && !MS_WIN64 */ #ifdef HAVE_CLOCK --- 168,172 ---- #define HAVE_CLOCK /* So it gets included in the methods */ ! #endif /* MS_WINDOWS && !MS_WIN64 */ #ifdef HAVE_CLOCK *************** *** 737,741 **** floatsleep(double secs) { ! /* XXX Should test for MS_WIN32 first! */ #if defined(HAVE_SELECT) && !defined(__BEOS__) && !defined(__EMX__) struct timeval t; --- 734,738 ---- floatsleep(double secs) { ! /* XXX Should test for MS_WINDOWS first! */ #if defined(HAVE_SELECT) && !defined(__BEOS__) && !defined(__EMX__) struct timeval t; *************** *** 772,805 **** delay((int)(secs * 1000 + 0.5)); /* delay() uses milliseconds */ Py_END_ALLOW_THREADS ! #elif defined(MSDOS) ! struct timeb t1, t2; ! double frac; ! extern double fmod(double, double); ! extern double floor(double); ! if (secs <= 0.0) ! return; ! frac = fmod(secs, 1.0); ! secs = floor(secs); ! ftime(&t1); ! t2.time = t1.time + (int)secs; ! t2.millitm = t1.millitm + (int)(frac*1000.0); ! while (t2.millitm >= 1000) { ! t2.time++; ! t2.millitm -= 1000; ! } ! for (;;) { ! #ifdef QUICKWIN ! Py_BEGIN_ALLOW_THREADS ! _wyield(); ! Py_END_ALLOW_THREADS ! #endif ! if (PyErr_CheckSignals()) ! return -1; ! ftime(&t1); ! if (t1.time > t2.time || ! t1.time == t2.time && t1.millitm >= t2.millitm) ! break; ! } ! #elif defined(MS_WIN32) { double millisecs = secs * 1000.0; --- 769,773 ---- delay((int)(secs * 1000 + 0.5)); /* delay() uses milliseconds */ Py_END_ALLOW_THREADS ! #elif defined(MS_WINDOWS) { double millisecs = secs * 1000.0; From tim_one@users.sourceforge.net Sun Jun 30 18:56:42 2002 From: tim_one@users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun, 30 Jun 2002 10:56:42 -0700 Subject: [Python-checkins] python/dist/src/Modules gcmodule.c,2.45,2.46 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv24796/python/Modules Modified Files: gcmodule.c Log Message: SF bug #574132: Major GC related performance regression "The regression" is actually due to that 2.2.1 had a bug that prevented the regression (which isn't a regression at all) from showing up. "The regression" is actually a glitch in cyclic gc that's been there forever. As the generation being collected is analyzed, objects that can't be collected (because, e.g., we find they're externally referenced, or are in an unreachable cycle but have a __del__ method) are moved out of the list of candidates. A tricksy scheme uses negative values of gc_refs to mark such objects as being moved. However, the exact negative value set at the start may become "more negative" over time for objects not in the generation being collected, and the scheme was checking for an exact match on the negative value originally assigned. As a result, objects in generations older than the one being collected could get scanned too, and yanked back into a younger generation. Doing so doesn't lead to an error, but doesn't do any good, and can burn an unbounded amount of time doing useless work. A test case is simple (thanks to Kevin Jacobs for finding it!): x = [] for i in xrange(200000): x.append((1,)) Without the patch, this ends up scanning all of x on every gen0 collection, scans all of x twice on every gen1 collection, and x gets yanked back into gen1 on every gen0 collection. With the patch, once x gets to gen2, it's never scanned again until another gen2 collection, and stays in gen2. Bugfix candidate, although the code has changed enough that I think I'll need to port it by hand. 2.2.1 also has a different bug that causes bound method objects not to get tracked at all (so the test case doesn't burn absurd amounts of time in 2.2.1, but *should* ). Index: gcmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/gcmodule.c,v retrieving revision 2.45 retrieving revision 2.46 diff -C2 -d -r2.45 -r2.46 *** gcmodule.c 28 Jun 2002 19:16:04 -0000 2.45 --- gcmodule.c 30 Jun 2002 17:56:40 -0000 2.46 *************** *** 1,4 **** /* ! Reference Cycle Garbage Collection ================================== --- 1,4 ---- /* ! Reference Cycle Garbage Collection ================================== *************** *** 73,81 **** static int debug; ! /* Special gc_refs value */ #define GC_MOVED -123 ! /* True if an object has been moved to the older generation */ ! #define IS_MOVED(o) ((AS_GC(o))->gc.gc_refs == GC_MOVED) /* list of uncollectable objects */ --- 73,89 ---- static int debug; ! /* When a collection begins, gc_refs is set to ob_refcnt for, and only for, ! * the objects in the generation being collected, called the "young" ! * generation at that point. As collection proceeds, when it's determined ! * that one of these can't be collected (e.g., because it's reachable from ! * outside, or has a __del__ method), the object is moved out of young, and ! * gc_refs is set to a negative value. The latter is so we can distinguish ! * collection candidates from non-candidates just by looking at the object. ! */ ! /* Special gc_refs value, although any negative value means "moved". */ #define GC_MOVED -123 ! /* True iff an object is still a candidate for collection. */ ! #define STILL_A_CANDIDATE(o) ((AS_GC(o))->gc.gc_refs >= 0) /* list of uncollectable objects */ *************** *** 117,121 **** } ! static void gc_list_move(PyGC_Head *from, PyGC_Head *to) { --- 125,129 ---- } ! static void gc_list_move(PyGC_Head *from, PyGC_Head *to) { *************** *** 162,166 **** ! /* Set all gc_refs = ob_refcnt */ static void update_refs(PyGC_Head *containers) --- 170,177 ---- ! /* Set all gc_refs = ob_refcnt. After this, STILL_A_CANDIDATE(o) is true ! * for all objects in containers, and false for all tracked gc objects not ! * in containers (although see the comment in visit_decref). ! */ static void update_refs(PyGC_Head *containers) *************** *** 175,181 **** visit_decref(PyObject *op, void *data) { if (op && PyObject_IS_GC(op)) { ! if (IS_TRACKED(op)) AS_GC(op)->gc.gc_refs--; } return 0; --- 186,204 ---- visit_decref(PyObject *op, void *data) { + /* There's no point to decrementing gc_refs unless + * STILL_A_CANDIDATE(op) is true. It would take extra cycles to + * check that, though. If STILL_A_CANDIDATE(op) is false, + * decrementing gc_refs almost always makes it "even more negative", + * so doesn't change that STILL_A_CANDIDATE is false, and no harm is + * done. However, it's possible that, after many collections, this + * could underflow gc_refs in a long-lived old object. In that case, + * visit_move() may move the old object back to the generation + * getting collected. That would be a waste of time, but wouldn't + * cause an error. + */ if (op && PyObject_IS_GC(op)) { ! if (IS_TRACKED(op)) { AS_GC(op)->gc.gc_refs--; + } } return 0; *************** *** 196,200 **** } ! /* Append objects with gc_refs > 0 to roots list */ static void move_roots(PyGC_Head *containers, PyGC_Head *roots) --- 219,223 ---- } ! /* Move objects with gc_refs > 0 to roots list. They can't be collected. */ static void move_roots(PyGC_Head *containers, PyGC_Head *roots) *************** *** 217,221 **** { if (PyObject_IS_GC(op)) { ! if (IS_TRACKED(op) && !IS_MOVED(op)) { PyGC_Head *gc = AS_GC(op); gc_list_remove(gc); --- 240,244 ---- { if (PyObject_IS_GC(op)) { ! if (IS_TRACKED(op) && STILL_A_CANDIDATE(op)) { PyGC_Head *gc = AS_GC(op); gc_list_remove(gc); *************** *** 227,231 **** } ! /* Move objects referenced from reachable to reachable set. */ static void move_root_reachable(PyGC_Head *reachable) --- 250,256 ---- } ! /* Move candidates referenced from reachable to reachable set (they're no ! * longer candidates). ! */ static void move_root_reachable(PyGC_Head *reachable) *************** *** 243,247 **** } ! /* return true of object has a finalization method */ static int has_finalizer(PyObject *op) --- 268,272 ---- } ! /* return true if object has a finalization method */ static int has_finalizer(PyObject *op) *************** *** 270,273 **** --- 295,299 ---- gc_list_remove(gc); gc_list_append(gc, finalizers); + gc->gc.gc_refs = GC_MOVED; } } *************** *** 283,287 **** /* careful, finalizers list is growing here */ traverse = FROM_GC(gc)->ob_type->tp_traverse; ! (void) traverse(FROM_GC(gc), (visitproc)visit_move, (void *)finalizers); --- 309,313 ---- /* careful, finalizers list is growing here */ traverse = FROM_GC(gc)->ob_type->tp_traverse; ! (void) traverse(FROM_GC(gc), (visitproc)visit_move, (void *)finalizers); *************** *** 333,337 **** PyList_Append(garbage, op); } ! /* object is now reachable again */ gc_list_remove(gc); gc_list_append(gc, old); --- 359,364 ---- PyList_Append(garbage, op); } ! /* object is now reachable again */ ! assert(!STILL_A_CANDIDATE(op)); gc_list_remove(gc); gc_list_append(gc, old); *************** *** 350,353 **** --- 377,382 ---- PyGC_Head *gc = unreachable->gc.gc_next; PyObject *op = FROM_GC(gc); + + assert(STILL_A_CANDIDATE(op)); if (debug & DEBUG_SAVEALL) { PyList_Append(garbage, op); *************** *** 364,367 **** --- 393,397 ---- gc_list_remove(gc); gc_list_append(gc, old); + gc->gc.gc_refs = GC_MOVED; } } From tim_one@users.sourceforge.net Sun Jun 30 19:48:55 2002 From: tim_one@users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun, 30 Jun 2002 11:48:55 -0700 Subject: [Python-checkins] python/dist/src/Modules gcmodule.c,2.33.6.4,2.33.6.5 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv12908/Modules Modified Files: Tag: release22-maint gcmodule.c Log Message: Backport for SF bug #574132: Major GC related performance regression. 2.2.1 has another bug that prevents the regression (which isn't a regression at all) from showing up. "The regression" is actually a glitch in cyclic gc that's been there forever. As the generation being collected is analyzed, objects that can't be collected (because, e.g., we find they're externally referenced, or are in an unreachable cycle but have a __del__ method) are moved out of the list of candidates. A tricksy scheme uses negative values of gc_refs to mark such objects as being moved. However, the exact negative value set at the start may become "more negative" over time for objects not in the generation being collected, and the scheme was checking for an exact match on the negative value originally assigned. As a result, objects in generations older than the one being collected could get scanned too, and yanked back into a younger generation. Doing so doesn't lead to an error, but doesn't do any good, and can burn an unbounded amount of time doing useless work. A test case is simple (thanks to Kevin Jacobs for finding it!): x = [] for i in xrange(200000): x.append((1,)) Without the patch, this ends up scanning all of x on every gen0 collection, scans all of x twice on every gen1 collection, and x gets yanked back into gen1 on every gen0 collection. With the patch, once x gets to gen2, it's never scanned again until another gen2 collection, and stays in gen2. Opened another bug about that 2.2.1 isn't actually tracking (at least) iterators, generators, and bound method objects, due to using the 2.1 gc API internally in those places (which #defines itself out of existence in 2.2.x). Index: gcmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/gcmodule.c,v retrieving revision 2.33.6.4 retrieving revision 2.33.6.5 diff -C2 -d -r2.33.6.4 -r2.33.6.5 *** gcmodule.c 30 Apr 2002 03:33:15 -0000 2.33.6.4 --- gcmodule.c 30 Jun 2002 18:48:53 -0000 2.33.6.5 *************** *** 1,4 **** /* ! Reference Cycle Garbage Collection ================================== --- 1,4 ---- /* ! Reference Cycle Garbage Collection ================================== *************** *** 64,70 **** static int debug; ! /* Special gc_refs value */ #define GC_MOVED -123 /* list of uncollectable objects */ static PyObject *garbage; --- 64,81 ---- static int debug; ! /* When a collection begins, gc_refs is set to ob_refcnt for, and only for, ! * the objects in the generation being collected, called the "young" ! * generation at that point. As collection proceeds, when it's determined ! * that one of these can't be collected (e.g., because it's reachable from ! * outside, or has a __del__ method), the object is moved out of young, and ! * gc_refs is set to a negative value. The latter is so we can distinguish ! * collection candidates from non-candidates just by looking at the object. ! */ ! /* Special gc_refs value, although any negative value means "moved". */ #define GC_MOVED -123 + /* True iff an object is still a candidate for collection. */ + #define STILL_A_CANDIDATE(o) ((AS_GC(o))->gc.gc_refs >= 0) + /* list of uncollectable objects */ static PyObject *garbage; *************** *** 99,103 **** } ! static void gc_list_move(PyGC_Head *from, PyGC_Head *to) { --- 110,114 ---- } ! static void gc_list_move(PyGC_Head *from, PyGC_Head *to) { *************** *** 145,149 **** ! /* Set all gc_refs = ob_refcnt */ static void update_refs(PyGC_Head *containers) --- 156,163 ---- ! /* Set all gc_refs = ob_refcnt. After this, STILL_A_CANDIDATE(o) is true ! * for all objects in containers, and false for all tracked gc objects not ! * in containers (although see the comment in visit_decref). ! */ static void update_refs(PyGC_Head *containers) *************** *** 158,161 **** --- 172,186 ---- visit_decref(PyObject *op, void *data) { + /* There's no point to decrementing gc_refs unless + * STILL_A_CANDIDATE(op) is true. It would take extra cycles to + * check that, though. If STILL_A_CANDIDATE(op) is false, + * decrementing gc_refs almost always makes it "even more negative", + * so doesn't change that STILL_A_CANDIDATE is false, and no harm is + * done. However, it's possible that, after many collections, this + * could underflow gc_refs in a long-lived old object. In that case, + * visit_move() may move the old object back to the generation + * getting collected. That would be a waste of time, but wouldn't + * cause an error. + */ if (op && PyObject_IS_GC(op)) { PyGC_Head *gc = AS_GC(op); *************** *** 180,184 **** } ! /* Append objects with gc_refs > 0 to roots list */ static void move_roots(PyGC_Head *containers, PyGC_Head *roots) --- 205,209 ---- } ! /* Move objects with gc_refs > 0 to roots list. They can't be collected. */ static void move_roots(PyGC_Head *containers, PyGC_Head *roots) *************** *** 202,206 **** if (PyObject_IS_GC(op)) { PyGC_Head *gc = AS_GC(op); ! if (gc->gc.gc_next != NULL && gc->gc.gc_refs != GC_MOVED) { gc_list_remove(gc); gc_list_append(gc, tolist); --- 227,231 ---- if (PyObject_IS_GC(op)) { PyGC_Head *gc = AS_GC(op); ! if (gc->gc.gc_next != NULL && STILL_A_CANDIDATE(op)) { gc_list_remove(gc); gc_list_append(gc, tolist); *************** *** 211,215 **** } ! /* Move objects referenced from reachable to reachable set. */ static void move_root_reachable(PyGC_Head *reachable) --- 236,242 ---- } ! /* Move candidates referenced from reachable to reachable set (they're no ! * longer candidates). ! */ static void move_root_reachable(PyGC_Head *reachable) *************** *** 227,231 **** } ! /* return true of object has a finalization method */ static int has_finalizer(PyObject *op) --- 254,258 ---- } ! /* return true if object has a finalization method */ static int has_finalizer(PyObject *op) *************** *** 254,257 **** --- 281,285 ---- gc_list_remove(gc); gc_list_append(gc, finalizers); + gc->gc.gc_refs = GC_MOVED; } } *************** *** 267,271 **** /* careful, finalizers list is growing here */ traverse = FROM_GC(gc)->ob_type->tp_traverse; ! (void) traverse(FROM_GC(gc), (visitproc)visit_move, (void *)finalizers); --- 295,299 ---- /* careful, finalizers list is growing here */ traverse = FROM_GC(gc)->ob_type->tp_traverse; ! (void) traverse(FROM_GC(gc), (visitproc)visit_move, (void *)finalizers); *************** *** 317,321 **** PyList_Append(garbage, op); } ! /* object is now reachable again */ gc_list_remove(gc); gc_list_append(gc, old); --- 345,350 ---- PyList_Append(garbage, op); } ! /* object is now reachable again */ ! assert(!STILL_A_CANDIDATE(op)); gc_list_remove(gc); gc_list_append(gc, old); *************** *** 334,337 **** --- 363,368 ---- PyGC_Head *gc = unreachable->gc.gc_next; PyObject *op = FROM_GC(gc); + + assert(STILL_A_CANDIDATE(op)); if (debug & DEBUG_SAVEALL) { PyList_Append(garbage, op); *************** *** 348,351 **** --- 379,383 ---- gc_list_remove(gc); gc_list_append(gc, old); + gc->gc.gc_refs = GC_MOVED; } } *************** *** 573,577 **** } ! static char gc_set_debug__doc__[] = "set_debug(flags) -> None\n" "\n" --- 605,609 ---- } ! static char gc_set_debug__doc__[] = "set_debug(flags) -> None\n" "\n" *************** *** 600,604 **** } ! static char gc_get_debug__doc__[] = "get_debug() -> flags\n" "\n" --- 632,636 ---- } ! static char gc_get_debug__doc__[] = "get_debug() -> flags\n" "\n" *************** *** 625,629 **** gc_set_thresh(PyObject *self, PyObject *args) { ! if (!PyArg_ParseTuple(args, "i|ii:set_threshold", &threshold0, &threshold1, &threshold2)) return NULL; --- 657,661 ---- gc_set_thresh(PyObject *self, PyObject *args) { ! if (!PyArg_ParseTuple(args, "i|ii:set_threshold", &threshold0, &threshold1, &threshold2)) return NULL; From tim_one@users.sourceforge.net Sun Jun 30 22:31:06 2002 From: tim_one@users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sun, 30 Jun 2002 14:31:06 -0700 Subject: [Python-checkins] python/dist/src/Modules gcmodule.c,2.46,2.47 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv864/python/Modules Modified Files: gcmodule.c Log Message: visit_decref(): Two optimizations. 1. You're not supposed to call this with a NULL argument, although the docs could be clearer about that. The other visit_XYZ() functions don't bother to check. This doesn't either now, although it does assert non-NULL-ness now. 2. It doesn't matter whether the object is currently tracked, so don't bother checking that either (if it isn't currently tracked, it may have some nonsense value in gc_refs, but it doesn't hurt to decrement gibberish, and it's cheaper to do so than to make everyone test for trackedness). It would be nice to get rid of the other tests on IS_TRACKED. Perhaps trackedness should not be a matter of not being in any gc list, but should be a matter of being in a new "untracked" gc list. This list simply wouldn't be involved in the collection mechanism. A newly created object would be put in the untracked list. Tracking would simply unlink it and move it into the gen0 list. Untracking would do the reverse. No test+branch needed then. visit_move() may be vulnerable then, though, and I don't know how this would work with the trashcan. Index: gcmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/gcmodule.c,v retrieving revision 2.46 retrieving revision 2.47 diff -C2 -d -r2.46 -r2.47 *** gcmodule.c 30 Jun 2002 17:56:40 -0000 2.46 --- gcmodule.c 30 Jun 2002 21:31:03 -0000 2.47 *************** *** 197,205 **** * cause an error. */ ! if (op && PyObject_IS_GC(op)) { ! if (IS_TRACKED(op)) { ! AS_GC(op)->gc.gc_refs--; ! } ! } return 0; } --- 197,203 ---- * cause an error. */ ! assert(op != NULL); ! if (PyObject_IS_GC(op)) ! AS_GC(op)->gc.gc_refs--; return 0; }