From holdenweb at users.sourceforge.net Wed Feb 2 19:47:22 2005 From: holdenweb at users.sourceforge.net (holdenweb@users.sourceforge.net) Date: Wed Feb 2 19:47:25 2005 Subject: [Python-checkins] python/dist/src/Lib/bsddb db.py,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/bsddb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3242 Modified Files: db.py Log Message: Simplify string comparison using startswith() Index: db.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/bsddb/db.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- db.py 21 Sep 2003 00:08:14 -0000 1.3 +++ db.py 2 Feb 2005 18:47:18 -0000 1.4 @@ -37,7 +37,7 @@ # case we ever want to augment the stuff in _db in any way. For now # it just simply imports everything from _db. -if __name__[:len('bsddb3.')] == 'bsddb3.': +if __name__.startswith('bsddb3.'): # import _pybsddb binary as it should be the more recent version from # a standalone pybsddb addon package than the version included with # python as bsddb._bsddb. From kbk at users.sourceforge.net Thu Feb 3 02:37:17 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Thu Feb 3 02:37:21 2005 Subject: [Python-checkins] python/dist/src/Lib/idlelib IdleHistory.py, 1.4, 1.5 NEWS.txt, 1.55, 1.56 config-main.def, 1.21, 1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32060 Modified Files: IdleHistory.py NEWS.txt config-main.def Log Message: Add config-main.def option to make the 'history' feature non-cyclic. Default remains cyclic. Python Patch 914546 Noam Raphael. M IdleHistory.py M NEWS.txt M config-main.def Index: IdleHistory.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/IdleHistory.py,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- IdleHistory.py 16 Sep 2002 22:09:19 -0000 1.4 +++ IdleHistory.py 3 Feb 2005 01:37:13 -0000 1.5 @@ -1,3 +1,5 @@ +from configHandler import idleConf + class History: def __init__(self, text, output_sep = "\n"): @@ -6,6 +8,7 @@ self.history_prefix = None self.history_pointer = None self.output_sep = output_sep + self.cyclic = idleConf.GetOption("main", "History", "cyclic", 1, "bool") text.bind("<>", self.history_prev) text.bind("<>", self.history_next) @@ -40,7 +43,11 @@ if reverse: pointer = nhist else: - pointer = -1 + if self.cyclic: + pointer = -1 + else: + self.text.bell() + return nprefix = len(prefix) while 1: if reverse: @@ -49,10 +56,13 @@ pointer = pointer + 1 if pointer < 0 or pointer >= nhist: self.text.bell() - if self._get_source("iomark", "end-1c") != prefix: - self.text.delete("iomark", "end-1c") - self._put_source("iomark", prefix) - pointer = prefix = None + if not self.cyclic and pointer < 0: + return + else: + if self._get_source("iomark", "end-1c") != prefix: + self.text.delete("iomark", "end-1c") + self._put_source("iomark", prefix) + pointer = prefix = None break item = self.history[pointer] if item[:nprefix] == prefix and len(item) > nprefix: Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.55 retrieving revision 1.56 diff -u -d -r1.55 -r1.56 --- NEWS.txt 31 Jan 2005 03:34:26 -0000 1.55 +++ NEWS.txt 3 Feb 2005 01:37:13 -0000 1.56 @@ -3,6 +3,9 @@ *Release date: XX-XXX-2005* +- Add config-main option to make the 'history' feature non-cyclic. + Default remains cyclic. Python Patch 914546 Noam Raphael. + - Removed ability to configure tabs indent from Options dialog. This 'feature' has never worked and no one has complained. It is still possible to set a default tabs (v. spaces) indent 'manually' via config-main.def (or to turn on Index: config-main.def =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/config-main.def,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- config-main.def 4 Jun 2004 06:31:08 -0000 1.21 +++ config-main.def 3 Feb 2005 01:37:14 -0000 1.22 @@ -18,8 +18,8 @@ # ~/.idlerc/config-highlight.cfg the user highlighting config file # ~/.idlerc/config-keys.cfg the user keybinding config file # -# On Windows2000 and Windows XP the .idlerc directory is at -# Documents and Settings\\.idlerc +# On Windows2000 and Windows XP the .idlerc directory is at +# Documents and Settings\\.idlerc # # On Windows98 it is at c:\.idlerc # @@ -73,4 +73,7 @@ default= 1 name= IDLE Classic Windows +[History] +cyclic=1 + [HelpFiles] From akuchling at users.sourceforge.net Thu Feb 3 03:27:05 2005 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Thu Feb 3 03:27:08 2005 Subject: [Python-checkins] python/nondist/peps pep-0314.txt,1.15,1.16 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10708 Modified Files: pep-0314.txt Log Message: Add Richard Jones's edits Index: pep-0314.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0314.txt,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- pep-0314.txt 14 May 2003 17:12:55 -0000 1.15 +++ pep-0314.txt 3 Feb 2005 02:27:01 -0000 1.16 @@ -81,15 +81,13 @@ Platform (multiple use) A comma-separated list of platform specifications, summarizing - the operating systems supported by the package. The major - supported platforms are listed below, but this list is - necessarily incomplete. - - POSIX, MacOS, Windows, BeOS, PalmOS. + the operating systems supported by the package which are not + listed in the "Operating System" Trove classifiers. See + "Classifier" below. Example: - Platform: POSIX, Windows + Platform: ObscureUnix, RareDOS Supported-Platform (multiple use) @@ -183,53 +181,15 @@ License - A string selected from a short list of choices, specifying the - license covering the package. Some licenses result in the - software being freely redistributable, so packagers and - resellers can automatically know that they're free to - redistribute the software. Other licenses will require - a careful reading by a human to determine how the software can be - repackaged and resold. - - The choices are: - - Artistic, BSD, DFSG, GNU GPL, GNU LGPL, "MIT", - Mozilla PL, "public domain", Python, Qt PL, Zope PL, unknown, - nocommercial, nosell, nosource, shareware, other - - Definitions of some of the licenses are: - - DFSG The license conforms to the Debian Free Software - Guidelines, but does not use one of the other - DFSG conforming licenses listed here. - More information is available at: - http://www.debian.org/social_contract#guidelines - - Python Python 1.6 or higher license. Version 1.5.2 and - earlier are under the MIT license. - - public domain Software is public domain, not copyrighted. - unknown Status is not known - nocommercial Free private use but commercial use not permitted - nosell Free use but distribution for profit by arrangement - nosource Freely distributable but no source code - shareware Payment is requested if software is used - other General category for other non-DFSG licenses - - Some of these licenses can be interpreted to mean the software is - freely redistributable. The list of redistributable licenses is: - - Artistic, BSD, DFSG, GNU GPL, GNU LGPL, "MIT", - Mozilla PL, "public domain", Python, Qt PL, Zope PL, - nosource, shareware - - Note that being redistributable does not mean a package - qualifies as free software, 'nosource' and 'shareware' being - examples. + Text indicating the license covering the package where the license + is not a selection from the "License" Trove classifiers. See + "Classifier" below. Example: - License: MIT + License: This software may only be obtained by sending the + author a postcard, and then the user promises not + to redistribute it. Classifier (multiple use) @@ -244,14 +204,13 @@ Requires (multiple use) - Each entry contains a string describing some other component or - module required by this package. + Each entry contains a string describing some other module or + package required by this package. - The format of a requirement string is simple: an arbitrary - sequence of characters, optionally followed by a version - declaration within parentheses. Leading and trailing whitespace - are ignored, and whitespace within the string is normalized to a - single space. + The format of a requirement string is simple: an module or + package name, optionally followed by a version declaration within + parentheses. Leading and trailing whitespace are ignored, and + whitespace within the string is normalized to a single space. A version declaration is a series of conditional operators and version numbers, separated by commas. Conditional operators @@ -266,7 +225,7 @@ the string ">1.0, !=1.3.4, <2.0" is a legal version declaration. All of the following are possible requirement strings: "rfc822", - "zlib (>=1.1.4)", "XML parser". + "zlib (>=1.1.4)", "zope". There's no canonical list of what strings should be used; the Python community is left to choose its own standards. @@ -277,11 +236,11 @@ Requires: sys Requires: zlib Requires: pyexpat (>1.0) - Requires: DB-API 2.0 module + Requires: psycopg Provides (multiple use) - Each entry contains a string describing a component or + Each entry contains a string describing a package or module that will be provided by this package once it is installed. These strings should match the ones used in Requirements fields. Version declarations cannot be supplied; @@ -296,7 +255,7 @@ Obsoletes (multiple use) - Each entry contains a string describing a component or module + Each entry contains a string describing a package or module that this package renders obsolete, meaning that the two packages should not be installed at the same time. Version declarations can be supplied. @@ -310,20 +269,6 @@ Obsoletes: Gorgon - Conflicts (multiple use) - - Each entry contains a string describing a component or module - that conflicts with this package, meaning that the two packages - should not be installed at the same time. Version declarations - can be supplied. - - Conflict resolution probably isn't very important for Python - programs, because few extensions will cause problems for other - extensions, unless they happen to be using the same package - name. This field name is being defined here for future use. - - Conflicts: Gorgon - Summary of Differences From PEP 241 @@ -336,8 +281,7 @@ Open issues - With the addition of the 'Classifiers' field, should the Platform - and License fields be removed? + None. Acknowledgements From akuchling at users.sourceforge.net Thu Feb 3 03:30:56 2005 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Thu Feb 3 03:30:58 2005 Subject: [Python-checkins] python/nondist/peps pep-0314.txt,1.16,1.17 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11619 Modified Files: pep-0314.txt Log Message: Add Richard as author; minor corrections Index: pep-0314.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0314.txt,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- pep-0314.txt 3 Feb 2005 02:27:01 -0000 1.16 +++ pep-0314.txt 3 Feb 2005 02:30:53 -0000 1.17 @@ -2,7 +2,7 @@ Title: Metadata for Python Software Packages v1.1 Version: $Revision$ Last-Modified: $Date$ -Author: A.M. Kuchling +Author: A.M. Kuchling , Richard Jones Status: Draft Type: Standards Track Content-type: text/plain @@ -207,7 +207,7 @@ Each entry contains a string describing some other module or package required by this package. - The format of a requirement string is simple: an module or + The format of a requirement string is simple: a module or package name, optionally followed by a version declaration within parentheses. Leading and trailing whitespace are ignored, and whitespace within the string is normalized to a single space. @@ -276,7 +276,11 @@ * Added the Classifiers field from PEP 301. - * Added fields: Download-URL, Requires, Provides, Obsoletes, Conflicts. + * The License and Platform files should now only be used if the + platform or license can't be handled by an appropriate Classifier + value. + + * Added fields: Download-URL, Requires, Provides, Obsoletes. Open issues @@ -286,7 +290,7 @@ Acknowledgements - Richard Jones suggested using reST for the Description field. + None. References From akuchling at users.sourceforge.net Thu Feb 3 13:31:03 2005 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Thu Feb 3 13:31:07 2005 Subject: [Python-checkins] python/nondist/peps pep-0314.txt,1.17,1.18 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16960 Modified Files: pep-0314.txt Log Message: Restrict package names to importable ones Index: pep-0314.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0314.txt,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- pep-0314.txt 3 Feb 2005 02:30:53 -0000 1.17 +++ pep-0314.txt 3 Feb 2005 12:30:44 -0000 1.18 @@ -207,10 +207,9 @@ Each entry contains a string describing some other module or package required by this package. - The format of a requirement string is simple: a module or - package name, optionally followed by a version declaration within - parentheses. Leading and trailing whitespace are ignored, and - whitespace within the string is normalized to a single space. + The format of a requirement string is identical to that of a + module or package name usable with the 'import' statement, + optionally followed by a version declaration within parentheses. A version declaration is a series of conditional operators and version numbers, separated by commas. Conditional operators From gvanrossum at users.sourceforge.net Thu Feb 3 15:58:47 2005 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu Feb 3 15:58:51 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.337.2.4.2.94, 1.337.2.4.2.95 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14681/Misc Modified Files: Tag: release22-maint NEWS Log Message: Security fix PSF-2005-001 for SimpleXMLRPCServer.py. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.337.2.4.2.94 retrieving revision 1.337.2.4.2.95 diff -u -d -r1.337.2.4.2.94 -r1.337.2.4.2.95 --- NEWS 17 Sep 2003 03:32:41 -0000 1.337.2.4.2.94 +++ NEWS 3 Feb 2005 14:58:41 -0000 1.337.2.4.2.95 @@ -2,6 +2,10 @@ Release date: XX-XXX-XXXX =========================== +- Applied a security fix to SimpleXMLRPCserver (PSF-2005-001). This + disables recursive traversal through instance attributes, which can + be exploited in various ways. + - Fixed a bug in the cache of length-one Unicode strings that could lead to a seg fault. The specific problem occurred when an earlier, non-fatal error left an uninitialized Unicode object in the From gvanrossum at users.sourceforge.net Thu Feb 3 15:59:14 2005 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu Feb 3 15:59:17 2005 Subject: [Python-checkins] python/dist/src/Lib SimpleXMLRPCServer.py, 1.2, 1.2.10.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14681/Lib Modified Files: Tag: release22-maint SimpleXMLRPCServer.py Log Message: Security fix PSF-2005-001 for SimpleXMLRPCServer.py. Index: SimpleXMLRPCServer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/SimpleXMLRPCServer.py,v retrieving revision 1.2 retrieving revision 1.2.10.1 diff -u -d -r1.2 -r1.2.10.1 --- SimpleXMLRPCServer.py 29 Sep 2001 04:54:33 -0000 1.2 +++ SimpleXMLRPCServer.py 3 Feb 2005 14:58:26 -0000 1.2.10.1 @@ -161,7 +161,8 @@ try: func = _resolve_dotted_attribute( self.server.instance, - method + method, + self.allow_dotted_names ) except AttributeError: pass @@ -178,11 +179,20 @@ BaseHTTPServer.BaseHTTPRequestHandler.log_request(self, code, size) -def _resolve_dotted_attribute(obj, attr): +def _resolve_dotted_attribute(obj, attr, allow_dotted_names=True): """Resolves a dotted attribute name to an object. Raises an AttributeError if any attribute in the chain starts with a '_'. + + If the optional allow_dotted_names argument is false, dots are not + supported and this function operates similar to getattr(obj, attr). """ - for i in attr.split('.'): + + if allow_dotted_names: + attrs = attr.split('.') + else: + attrs = [attr] + + for i in attrs: if i.startswith('_'): raise AttributeError( 'attempt to access private attribute "%s"' % i @@ -206,7 +216,7 @@ self.instance = None SocketServer.TCPServer.__init__(self, addr, requestHandler) - def register_instance(self, instance): + def register_instance(self, instance, allow_dotted_names=False): """Registers an instance to respond to XML-RPC requests. Only one instance can be installed at a time. @@ -225,9 +235,23 @@ If a registered function matches a XML-RPC request, then it will be called instead of the registered instance. + + If the optional allow_dotted_names argument is true and the + instance does not have a _dispatch method, method names + containing dots are supported and resolved, as long as none of + the name segments start with an '_'. + + *** SECURITY WARNING: *** + + Enabling the allow_dotted_names options allows intruders + to access your module's global variables and may allow + intruders to execute arbitrary code on your machine. Only + use this option on a secure, closed network. + """ self.instance = instance + self.allow_dotted_names = allow_dotted_names def register_function(self, function, name = None): """Registers a function to respond to XML-RPC requests. From gvanrossum at users.sourceforge.net Thu Feb 3 15:59:46 2005 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu Feb 3 15:59:50 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libsimplexmlrpc.tex, 1.5.14.1, 1.5.14.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14953/Doc/lib Modified Files: Tag: release23-maint libsimplexmlrpc.tex Log Message: Security fix PSF-2005-001 for SimpleXMLRPCServer.py. Index: libsimplexmlrpc.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsimplexmlrpc.tex,v retrieving revision 1.5.14.1 retrieving revision 1.5.14.2 diff -u -d -r1.5.14.1 -r1.5.14.2 --- libsimplexmlrpc.tex 8 Oct 2004 18:35:46 -0000 1.5.14.1 +++ libsimplexmlrpc.tex 3 Feb 2005 14:59:43 -0000 1.5.14.2 @@ -55,19 +55,34 @@ period character. \end{methoddesc} -\begin{methoddesc}[SimpleXMLRPCServer]{register_instance}{instance} +\begin{methoddesc}[SimpleXMLRPCServer]{register_instance}{instance\optional{, + allow_dotted_names}} Register an object which is used to expose method names which have not been registered using \method{register_function()}. If \var{instance} contains a \method{_dispatch()} method, it is called with the requested method name and the parameters from the request; the return value is returned to the client as the result. If \var{instance} does not have a \method{_dispatch()} method, it is - searched for an attribute matching the name of the requested method; + searched for an attribute matching the name of the requested method. + + If the optional \var{allow_dotted_names} argument is true and the + instance does not have a \method{_dispatch()} method, then if the requested method name contains periods, each component of the method name is searched for individually, with the effect that a simple hierarchical search is performed. The value found from this search is then called with the parameters from the request, and the return value is passed back to the client. + + \begin{notice}[warning] + Enabling the \var{allow_dotted_names} option allows intruders to access + your module's global variables and may allow intruders to execute + arbitrary code on your machine. Only use this option on a secure, + closed network. + \end{notice} + + \versionchanged[\var{allow_dotted_names} was added to plug a security hole; + prior versions are insecure]{2.3.5, 2.4.1} + \end{methoddesc} \begin{methoddesc}{register_introspection_functions}{} From gvanrossum at users.sourceforge.net Thu Feb 3 15:59:47 2005 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu Feb 3 15:59:51 2005 Subject: [Python-checkins] python/dist/src/Lib SimpleXMLRPCServer.py, 1.7.8.1, 1.7.8.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14953/Lib Modified Files: Tag: release23-maint SimpleXMLRPCServer.py Log Message: Security fix PSF-2005-001 for SimpleXMLRPCServer.py. Index: SimpleXMLRPCServer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/SimpleXMLRPCServer.py,v retrieving revision 1.7.8.1 retrieving revision 1.7.8.2 diff -u -d -r1.7.8.1 -r1.7.8.2 --- SimpleXMLRPCServer.py 3 Oct 2004 23:23:00 -0000 1.7.8.1 +++ SimpleXMLRPCServer.py 3 Feb 2005 14:59:43 -0000 1.7.8.2 @@ -107,14 +107,22 @@ import types import os -def resolve_dotted_attribute(obj, attr): +def resolve_dotted_attribute(obj, attr, allow_dotted_names=True): """resolve_dotted_attribute(a, 'b.c.d') => a.b.c.d Resolves a dotted attribute name to an object. Raises an AttributeError if any attribute in the chain starts with a '_'. + + If the optional allow_dotted_names argument is false, dots are not + supported and this function operates similar to getattr(obj, attr). """ - for i in attr.split('.'): + if allow_dotted_names: + attrs = attr.split('.') + else: + attrs = [attr] + + for i in attrs: if i.startswith('_'): raise AttributeError( 'attempt to access private attribute "%s"' % i @@ -156,7 +164,7 @@ self.funcs = {} self.instance = None - def register_instance(self, instance): + def register_instance(self, instance, allow_dotted_names=False): """Registers an instance to respond to XML-RPC requests. Only one instance can be installed at a time. @@ -174,9 +182,23 @@ If a registered function matches a XML-RPC request, then it will be called instead of the registered instance. + + If the optional allow_dotted_names argument is true and the + instance does not have a _dispatch method, method names + containing dots are supported and resolved, as long as none of + the name segments start with an '_'. + + *** SECURITY WARNING: *** + + Enabling the allow_dotted_names options allows intruders + to access your module's global variables and may allow + intruders to execute arbitrary code on your machine. Only + use this option on a secure, closed network. + """ self.instance = instance + self.allow_dotted_names = allow_dotted_names def register_function(self, function, name = None): """Registers a function to respond to XML-RPC requests. @@ -295,7 +317,8 @@ try: method = resolve_dotted_attribute( self.instance, - method_name + method_name, + self.allow_dotted_names ) except AttributeError: pass @@ -374,7 +397,8 @@ try: func = resolve_dotted_attribute( self.instance, - method + method, + self.allow_dotted_names ) except AttributeError: pass From gvanrossum at users.sourceforge.net Thu Feb 3 15:59:49 2005 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu Feb 3 15:59:52 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.166, 1.831.4.167 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14953/Misc Modified Files: Tag: release23-maint NEWS Log Message: Security fix PSF-2005-001 for SimpleXMLRPCServer.py. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.166 retrieving revision 1.831.4.167 diff -u -d -r1.831.4.166 -r1.831.4.167 --- NEWS 27 Jan 2005 18:55:01 -0000 1.831.4.166 +++ NEWS 3 Feb 2005 14:59:43 -0000 1.831.4.167 @@ -11,8 +11,17 @@ Core and builtins ----------------- + - Partially revert the fix for #1074011; don't try to fflush stdin anymore. +Library +------- + +- Applied a security fix to SimpleXMLRPCserver (PSF-2005-001). This + disables recursive traversal through instance attributes, which can + be exploited in various ways. + + What's New in Python 2.3.5rc1? ============================== From gvanrossum at users.sourceforge.net Thu Feb 3 16:00:25 2005 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu Feb 3 16:00:28 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.17, 1.1193.2.18 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15199/Misc Modified Files: Tag: release24-maint NEWS Log Message: Security fix PSF-2005-001 for SimpleXMLRPCServer.py. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.17 retrieving revision 1.1193.2.18 diff -u -d -r1.1193.2.17 -r1.1193.2.18 --- NEWS 29 Jan 2005 13:33:27 -0000 1.1193.2.17 +++ NEWS 3 Feb 2005 15:00:18 -0000 1.1193.2.18 @@ -25,6 +25,10 @@ Library ------- +- Applied a security fix to SimpleXMLRPCserver (PSF-2005-001). This + disables recursive traversal through instance attributes, which can + be exploited in various ways. + - Bug #1110478: Revert os.environ.update to do putenv again. - Bug #1103844: fix distutils.install.dump_dirs() with negated options. From gvanrossum at users.sourceforge.net Thu Feb 3 16:00:51 2005 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu Feb 3 16:00:53 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libsimplexmlrpc.tex, 1.7, 1.7.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15199/Doc/lib Modified Files: Tag: release24-maint libsimplexmlrpc.tex Log Message: Security fix PSF-2005-001 for SimpleXMLRPCServer.py. Index: libsimplexmlrpc.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsimplexmlrpc.tex,v retrieving revision 1.7 retrieving revision 1.7.2.1 diff -u -d -r1.7 -r1.7.2.1 --- libsimplexmlrpc.tex 8 Oct 2004 18:34:47 -0000 1.7 +++ libsimplexmlrpc.tex 3 Feb 2005 15:00:17 -0000 1.7.2.1 @@ -55,7 +55,8 @@ period character. \end{methoddesc} -\begin{methoddesc}[SimpleXMLRPCServer]{register_instance}{instance} +\begin{methoddesc}[SimpleXMLRPCServer]{register_instance}{instance\optional{, + allow_dotted_names}} Register an object which is used to expose method names which have not been registered using \method{register_function()}. If \var{instance} contains a \method{_dispatch()} method, it is called @@ -67,12 +68,26 @@ The return value from \method{_dispatch()} is returned to the client as the result. If \var{instance} does not have a \method{_dispatch()} method, it is - searched for an attribute matching the name of the requested method; + searched for an attribute matching the name of the requested method. + + If the optional \var{allow_dotted_names} argument is true and the + instance does not have a \method{_dispatch()} method, then if the requested method name contains periods, each component of the method name is searched for individually, with the effect that a simple hierarchical search is performed. The value found from this search is then called with the parameters from the request, and the return value is passed back to the client. + + \begin{notice}[warning] + Enabling the \var{allow_dotted_names} option allows intruders to access + your module's global variables and may allow intruders to execute + arbitrary code on your machine. Only use this option on a secure, + closed network. + \end{notice} + + \versionchanged[\var{allow_dotted_names} was added to plug a security hole; + prior versions are insecure]{2.3.5, 2.4.1} + \end{methoddesc} \begin{methoddesc}{register_introspection_functions}{} From gvanrossum at users.sourceforge.net Thu Feb 3 16:00:51 2005 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu Feb 3 16:00:55 2005 Subject: [Python-checkins] python/dist/src/Lib SimpleXMLRPCServer.py, 1.9, 1.9.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15199/Lib Modified Files: Tag: release24-maint SimpleXMLRPCServer.py Log Message: Security fix PSF-2005-001 for SimpleXMLRPCServer.py. Index: SimpleXMLRPCServer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/SimpleXMLRPCServer.py,v retrieving revision 1.9 retrieving revision 1.9.2.1 diff -u -d -r1.9 -r1.9.2.1 --- SimpleXMLRPCServer.py 3 Oct 2004 23:21:44 -0000 1.9 +++ SimpleXMLRPCServer.py 3 Feb 2005 15:00:18 -0000 1.9.2.1 @@ -106,14 +106,22 @@ import sys import os -def resolve_dotted_attribute(obj, attr): +def resolve_dotted_attribute(obj, attr, allow_dotted_names=True): """resolve_dotted_attribute(a, 'b.c.d') => a.b.c.d Resolves a dotted attribute name to an object. Raises an AttributeError if any attribute in the chain starts with a '_'. + + If the optional allow_dotted_names argument is false, dots are not + supported and this function operates similar to getattr(obj, attr). """ - for i in attr.split('.'): + if allow_dotted_names: + attrs = attr.split('.') + else: + attrs = [attr] + + for i in attrs: if i.startswith('_'): raise AttributeError( 'attempt to access private attribute "%s"' % i @@ -155,7 +163,7 @@ self.funcs = {} self.instance = None - def register_instance(self, instance): + def register_instance(self, instance, allow_dotted_names=False): """Registers an instance to respond to XML-RPC requests. Only one instance can be installed at a time. @@ -173,9 +181,23 @@ If a registered function matches a XML-RPC request, then it will be called instead of the registered instance. + + If the optional allow_dotted_names argument is true and the + instance does not have a _dispatch method, method names + containing dots are supported and resolved, as long as none of + the name segments start with an '_'. + + *** SECURITY WARNING: *** + + Enabling the allow_dotted_names options allows intruders + to access your module's global variables and may allow + intruders to execute arbitrary code on your machine. Only + use this option on a secure, closed network. + """ self.instance = instance + self.allow_dotted_names = allow_dotted_names def register_function(self, function, name = None): """Registers a function to respond to XML-RPC requests. @@ -294,7 +316,8 @@ try: method = resolve_dotted_attribute( self.instance, - method_name + method_name, + self.allow_dotted_names ) except AttributeError: pass @@ -373,7 +396,8 @@ try: func = resolve_dotted_attribute( self.instance, - method + method, + self.allow_dotted_names ) except AttributeError: pass From gvanrossum at users.sourceforge.net Thu Feb 3 16:01:27 2005 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu Feb 3 16:01:29 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libsimplexmlrpc.tex, 1.8, 1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15460/Doc/lib Modified Files: libsimplexmlrpc.tex Log Message: Security fix PSF-2005-001 for SimpleXMLRPCServer.py. Index: libsimplexmlrpc.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsimplexmlrpc.tex,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- libsimplexmlrpc.tex 1 Dec 2004 18:34:11 -0000 1.8 +++ libsimplexmlrpc.tex 3 Feb 2005 15:01:23 -0000 1.9 @@ -55,7 +55,8 @@ period character. \end{methoddesc} -\begin{methoddesc}[SimpleXMLRPCServer]{register_instance}{instance} +\begin{methoddesc}[SimpleXMLRPCServer]{register_instance}{instance\optional{, + allow_dotted_names}} Register an object which is used to expose method names which have not been registered using \method{register_function()}. If \var{instance} contains a \method{_dispatch()} method, it is called @@ -67,12 +68,26 @@ The return value from \method{_dispatch()} is returned to the client as the result. If \var{instance} does not have a \method{_dispatch()} method, it is - searched for an attribute matching the name of the requested method; + searched for an attribute matching the name of the requested method. + + If the optional \var{allow_dotted_names} argument is true and the + instance does not have a \method{_dispatch()} method, then if the requested method name contains periods, each component of the method name is searched for individually, with the effect that a simple hierarchical search is performed. The value found from this search is then called with the parameters from the request, and the return value is passed back to the client. + + \begin{notice}[warning] + Enabling the \var{allow_dotted_names} option allows intruders to access + your module's global variables and may allow intruders to execute + arbitrary code on your machine. Only use this option on a secure, + closed network. + \end{notice} + + \versionchanged[\var{allow_dotted_names} was added to plug a security hole; + prior versions are insecure]{2.3.5, 2.4.1} + \end{methoddesc} \begin{methoddesc}{register_introspection_functions}{} From gvanrossum at users.sourceforge.net Thu Feb 3 16:01:27 2005 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu Feb 3 16:01:30 2005 Subject: [Python-checkins] python/dist/src/Lib SimpleXMLRPCServer.py, 1.9, 1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15460/Lib Modified Files: SimpleXMLRPCServer.py Log Message: Security fix PSF-2005-001 for SimpleXMLRPCServer.py. Index: SimpleXMLRPCServer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/SimpleXMLRPCServer.py,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- SimpleXMLRPCServer.py 3 Oct 2004 23:21:44 -0000 1.9 +++ SimpleXMLRPCServer.py 3 Feb 2005 15:01:24 -0000 1.10 @@ -106,14 +106,22 @@ import sys import os -def resolve_dotted_attribute(obj, attr): +def resolve_dotted_attribute(obj, attr, allow_dotted_names=True): """resolve_dotted_attribute(a, 'b.c.d') => a.b.c.d Resolves a dotted attribute name to an object. Raises an AttributeError if any attribute in the chain starts with a '_'. + + If the optional allow_dotted_names argument is false, dots are not + supported and this function operates similar to getattr(obj, attr). """ - for i in attr.split('.'): + if allow_dotted_names: + attrs = attr.split('.') + else: + attrs = [attr] + + for i in attrs: if i.startswith('_'): raise AttributeError( 'attempt to access private attribute "%s"' % i @@ -155,7 +163,7 @@ self.funcs = {} self.instance = None - def register_instance(self, instance): + def register_instance(self, instance, allow_dotted_names=False): """Registers an instance to respond to XML-RPC requests. Only one instance can be installed at a time. @@ -173,9 +181,23 @@ If a registered function matches a XML-RPC request, then it will be called instead of the registered instance. + + If the optional allow_dotted_names argument is true and the + instance does not have a _dispatch method, method names + containing dots are supported and resolved, as long as none of + the name segments start with an '_'. + + *** SECURITY WARNING: *** + + Enabling the allow_dotted_names options allows intruders + to access your module's global variables and may allow + intruders to execute arbitrary code on your machine. Only + use this option on a secure, closed network. + """ self.instance = instance + self.allow_dotted_names = allow_dotted_names def register_function(self, function, name = None): """Registers a function to respond to XML-RPC requests. @@ -294,7 +316,8 @@ try: method = resolve_dotted_attribute( self.instance, - method_name + method_name, + self.allow_dotted_names ) except AttributeError: pass @@ -373,7 +396,8 @@ try: func = resolve_dotted_attribute( self.instance, - method + method, + self.allow_dotted_names ) except AttributeError: pass From gvanrossum at users.sourceforge.net Thu Feb 3 16:01:28 2005 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Thu Feb 3 16:01:32 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1236,1.1237 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15460/Misc Modified Files: NEWS Log Message: Security fix PSF-2005-001 for SimpleXMLRPCServer.py. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1236 retrieving revision 1.1237 diff -u -d -r1.1236 -r1.1237 --- NEWS 31 Jan 2005 17:09:20 -0000 1.1236 +++ NEWS 3 Feb 2005 15:01:24 -0000 1.1237 @@ -47,6 +47,10 @@ Library ------- +- Applied a security fix to SimpleXMLRPCserver (PSF-2005-001). This + disables recursive traversal through instance attributes, which can + be exploited in various ways. + - Bug #1110478: Revert os.environ.update to do putenv again. - Bug #1103844: fix distutils.install.dump_dirs() with negated options. From fdrake at users.sourceforge.net Thu Feb 3 18:29:36 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu Feb 3 18:29:40 2005 Subject: [Python-checkins] python/dist/src/Lib/xml/sax saxutils.py, 1.21.10.2, 1.21.10.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/xml/sax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16302 Modified Files: Tag: release23-maint saxutils.py Log Message: fix XMLFilterBase.resolveEntity() so the caller gets the result (PyXML bug #1112052) Index: saxutils.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/sax/saxutils.py,v retrieving revision 1.21.10.2 retrieving revision 1.21.10.3 diff -u -d -r1.21.10.2 -r1.21.10.3 --- saxutils.py 6 May 2004 02:22:23 -0000 1.21.10.2 +++ saxutils.py 3 Feb 2005 17:29:32 -0000 1.21.10.3 @@ -232,7 +232,7 @@ # EntityResolver methods def resolveEntity(self, publicId, systemId): - self._ent_handler.resolveEntity(publicId, systemId) + return self._ent_handler.resolveEntity(publicId, systemId) # XMLReader methods From fdrake at users.sourceforge.net Thu Feb 3 18:30:50 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu Feb 3 18:30:53 2005 Subject: [Python-checkins] python/dist/src/Lib/xml/sax saxutils.py, 1.25, 1.25.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/xml/sax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16596 Modified Files: Tag: release24-maint saxutils.py Log Message: fix XMLFilterBase.resolveEntity() so the caller gets the result (PyXML bug #1112052) Index: saxutils.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/sax/saxutils.py,v retrieving revision 1.25 retrieving revision 1.25.2.1 diff -u -d -r1.25 -r1.25.2.1 --- saxutils.py 20 Oct 2004 11:08:35 -0000 1.25 +++ saxutils.py 3 Feb 2005 17:30:46 -0000 1.25.2.1 @@ -232,7 +232,7 @@ # EntityResolver methods def resolveEntity(self, publicId, systemId): - self._ent_handler.resolveEntity(publicId, systemId) + return self._ent_handler.resolveEntity(publicId, systemId) # XMLReader methods From fdrake at users.sourceforge.net Thu Feb 3 18:31:59 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu Feb 3 18:32:02 2005 Subject: [Python-checkins] python/dist/src/Lib/xml/sax saxutils.py, 1.25, 1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/xml/sax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16764 Modified Files: saxutils.py Log Message: fix XMLFilterBase.resolveEntity() so the caller gets the result (PyXML bug #1112052) Index: saxutils.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xml/sax/saxutils.py,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- saxutils.py 20 Oct 2004 11:08:35 -0000 1.25 +++ saxutils.py 3 Feb 2005 17:31:39 -0000 1.26 @@ -232,7 +232,7 @@ # EntityResolver methods def resolveEntity(self, publicId, systemId): - self._ent_handler.resolveEntity(publicId, systemId) + return self._ent_handler.resolveEntity(publicId, systemId) # XMLReader methods From theller at users.sourceforge.net Thu Feb 3 21:09:32 2005 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Thu Feb 3 21:09:35 2005 Subject: [Python-checkins] python/dist/src/PC/bdist_wininst install.c, 1.10.4.3, 1.10.4.4 Message-ID: Update of /cvsroot/python/python/dist/src/PC/bdist_wininst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17857 Modified Files: Tag: release24-maint install.c Log Message: Set PYTHONHOME before loading Python, so that sys.path will be set correctly. Already backported. Index: install.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/bdist_wininst/install.c,v retrieving revision 1.10.4.3 retrieving revision 1.10.4.4 diff -u -d -r1.10.4.3 -r1.10.4.4 --- install.c 22 Dec 2004 16:49:05 -0000 1.10.4.3 +++ install.c 3 Feb 2005 20:09:24 -0000 1.10.4.4 @@ -613,7 +613,13 @@ char fullpath[_MAX_PATH]; LONG size = sizeof(fullpath); char subkey_name[80]; - HINSTANCE h = LoadLibrary(fname); + char buffer[260 + 12]; + HINSTANCE h; + + /* make sure PYTHONHOME is set, to that sys.path is initialized correctly */ + wsprintf(buffer, "PYTHONHOME=%s", python_dir); + _putenv(buffer); + h = LoadLibrary(fname); if (h) return h; wsprintf(subkey_name, From theller at users.sourceforge.net Thu Feb 3 21:11:31 2005 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Thu Feb 3 21:11:34 2005 Subject: [Python-checkins] python/dist/src/PC/bdist_wininst install.c, 1.13, 1.14 Message-ID: Update of /cvsroot/python/python/dist/src/PC/bdist_wininst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18261 Modified Files: install.c Log Message: Set PYTHONHOME before loading Python, so that sys.path will be set correctly. Already backported. Index: install.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/bdist_wininst/install.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- install.c 22 Dec 2004 17:24:14 -0000 1.13 +++ install.c 3 Feb 2005 20:11:28 -0000 1.14 @@ -613,7 +613,13 @@ char fullpath[_MAX_PATH]; LONG size = sizeof(fullpath); char subkey_name[80]; - HINSTANCE h = LoadLibrary(fname); + char buffer[260 + 12]; + HINSTANCE h; + + /* make sure PYTHONHOME is set, to that sys.path is initialized correctly */ + wsprintf(buffer, "PYTHONHOME=%s", python_dir); + _putenv(buffer); + h = LoadLibrary(fname); if (h) return h; wsprintf(subkey_name, From theller at users.sourceforge.net Thu Feb 3 21:35:12 2005 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Thu Feb 3 21:35:16 2005 Subject: [Python-checkins] python/dist/src/PC/bdist_wininst install.c, 1.14, 1.15 Message-ID: Update of /cvsroot/python/python/dist/src/PC/bdist_wininst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23581 Modified Files: install.c Log Message: Running a bdist_wininst installer, built with Python 2.3, installing for Python 2.4 caused a segfault when post_install_script was used. The reason was that the file handle passed to PyRun_SimpleFile() was created with MSVCRT.DLL, but Python 2.4 uses MSVCR71.DLL. So, I replaced PyRun_SimpleFile() with PyRun_SimpleString(). The segfault is gone, but the output of the postinstall script doesn't show up, because still freopen() from MSVCRT is used. Already backported. Index: install.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/bdist_wininst/install.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- install.c 3 Feb 2005 20:11:28 -0000 1.14 +++ install.c 3 Feb 2005 20:35:10 -0000 1.15 @@ -88,6 +88,11 @@ #include #include #include +#include +#include +#include +#include +#include #include "archive.h" @@ -671,7 +676,7 @@ * 1 if the Python-dll does not export the functions we need * 2 if no install-script is specified in pathname * 3 if the install-script file could not be opened - * the return value of PyRun_SimpleFile() otherwise, + * the return value of PyRun_SimpleString() otherwise, * which is 0 if everything is ok, -1 if an exception had occurred * in the install-script. */ @@ -681,7 +686,7 @@ { DECLPROC(hPython, void, Py_Initialize, (void)); DECLPROC(hPython, int, PySys_SetArgv, (int, char **)); - DECLPROC(hPython, int, PyRun_SimpleFile, (FILE *, char *)); + DECLPROC(hPython, int, PyRun_SimpleString, (char *)); DECLPROC(hPython, void, Py_Finalize, (void)); DECLPROC(hPython, PyObject *, Py_BuildValue, (char *, ...)); DECLPROC(hPython, PyObject *, PyCFunction_New, @@ -690,10 +695,10 @@ DECLPROC(hPython, PyObject *, PyErr_Format, (PyObject *, char *)); int result = 0; - FILE *fp; + int fh; if (!Py_Initialize || !PySys_SetArgv - || !PyRun_SimpleFile || !Py_Finalize) + || !PyRun_SimpleString || !Py_Finalize) return 1; if (!Py_BuildValue || !PyArg_ParseTuple || !PyErr_Format) @@ -705,8 +710,8 @@ if (pathname == NULL || pathname[0] == '\0') return 2; - fp = fopen(pathname, "r"); - if (!fp) { + fh = open(pathname, _O_RDONLY); + if (-1 == fh) { fprintf(stderr, "Could not open postinstall-script %s\n", pathname); return 3; @@ -718,10 +723,22 @@ prepare_script_environment(hPython); PySys_SetArgv(argc, argv); - result = PyRun_SimpleFile(fp, pathname); + result = 3; + { + struct _stat statbuf; + if(0 == _fstat(fh, &statbuf)) { + char *script = alloca(statbuf.st_size + 5); + int n = read(fh, script, statbuf.st_size); + if (n > 0) { + script[n] = '\n'; + script[n+1] = 0; + result = PyRun_SimpleString(script); + } + } + } Py_Finalize(); - fclose(fp); + close(fh); return result; } From theller at users.sourceforge.net Thu Feb 3 21:37:07 2005 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Thu Feb 3 21:37:10 2005 Subject: [Python-checkins] python/dist/src/PC/bdist_wininst install.c, 1.10.4.4, 1.10.4.5 Message-ID: Update of /cvsroot/python/python/dist/src/PC/bdist_wininst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24067 Modified Files: Tag: release24-maint install.c Log Message: Running a bdist_wininst installer, built with Python 2.3, installing for Python 2.4 caused a segfault when post_install_script was used. The reason was that the file handle passed to PyRun_SimpleFile() was created with MSVCRT.DLL, but Python 2.4 uses MSVCR71.DLL. So, I replaced PyRun_SimpleFile() with PyRun_SimpleString(). The segfault is gone, but the output of the postinstall script doesn't show up, because still freopen() from MSVCRT is used. Index: install.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/bdist_wininst/install.c,v retrieving revision 1.10.4.4 retrieving revision 1.10.4.5 diff -u -d -r1.10.4.4 -r1.10.4.5 --- install.c 3 Feb 2005 20:09:24 -0000 1.10.4.4 +++ install.c 3 Feb 2005 20:37:04 -0000 1.10.4.5 @@ -88,6 +88,11 @@ #include #include #include +#include +#include +#include +#include +#include #include "archive.h" @@ -671,7 +676,7 @@ * 1 if the Python-dll does not export the functions we need * 2 if no install-script is specified in pathname * 3 if the install-script file could not be opened - * the return value of PyRun_SimpleFile() otherwise, + * the return value of PyRun_SimpleString() otherwise, * which is 0 if everything is ok, -1 if an exception had occurred * in the install-script. */ @@ -681,7 +686,7 @@ { DECLPROC(hPython, void, Py_Initialize, (void)); DECLPROC(hPython, int, PySys_SetArgv, (int, char **)); - DECLPROC(hPython, int, PyRun_SimpleFile, (FILE *, char *)); + DECLPROC(hPython, int, PyRun_SimpleString, (char *)); DECLPROC(hPython, void, Py_Finalize, (void)); DECLPROC(hPython, PyObject *, Py_BuildValue, (char *, ...)); DECLPROC(hPython, PyObject *, PyCFunction_New, @@ -690,10 +695,10 @@ DECLPROC(hPython, PyObject *, PyErr_Format, (PyObject *, char *)); int result = 0; - FILE *fp; + int fh; if (!Py_Initialize || !PySys_SetArgv - || !PyRun_SimpleFile || !Py_Finalize) + || !PyRun_SimpleString || !Py_Finalize) return 1; if (!Py_BuildValue || !PyArg_ParseTuple || !PyErr_Format) @@ -705,8 +710,8 @@ if (pathname == NULL || pathname[0] == '\0') return 2; - fp = fopen(pathname, "r"); - if (!fp) { + fh = open(pathname, _O_RDONLY); + if (-1 == fh) { fprintf(stderr, "Could not open postinstall-script %s\n", pathname); return 3; @@ -718,10 +723,22 @@ prepare_script_environment(hPython); PySys_SetArgv(argc, argv); - result = PyRun_SimpleFile(fp, pathname); + result = 3; + { + struct _stat statbuf; + if(0 == _fstat(fh, &statbuf)) { + char *script = alloca(statbuf.st_size + 5); + int n = read(fh, script, statbuf.st_size); + if (n > 0) { + script[n] = '\n'; + script[n+1] = 0; + result = PyRun_SimpleString(script); + } + } + } Py_Finalize(); - fclose(fp); + close(fh); return result; } @@ -1804,7 +1821,7 @@ /* Strip the trailing backslash again */ python_dir[strlen(python_dir)-1] = '\0'; - CheckRootKey(hwnd); + CheckRootKey(hwnd); if (!OpenLogfile(python_dir)) break; From theller at users.sourceforge.net Thu Feb 3 21:44:32 2005 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Thu Feb 3 21:44:34 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils/command wininst-7.1.exe, 1.5.4.1, 1.5.4.2 wininst-6.exe, 1.5.4.1, 1.5.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25975 Modified Files: Tag: release24-maint wininst-7.1.exe wininst-6.exe Log Message: Recompiled after source changes. Index: wininst-7.1.exe =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/wininst-7.1.exe,v retrieving revision 1.5.4.1 retrieving revision 1.5.4.2 diff -u -d -r1.5.4.1 -r1.5.4.2 Binary files /tmp/cvs568EZm and /tmp/cvstCaTNN differ Index: wininst-6.exe =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/wininst-6.exe,v retrieving revision 1.5.4.1 retrieving revision 1.5.4.2 diff -u -d -r1.5.4.1 -r1.5.4.2 Binary files /tmp/cvszpWFST and /tmp/cvsmCUO6k differ From theller at users.sourceforge.net Thu Feb 3 21:48:29 2005 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Thu Feb 3 21:48:32 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils/command wininst-7.1.exe, 1.7, 1.8 wininst-6.exe, 1.7, 1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26710 Modified Files: wininst-7.1.exe wininst-6.exe Log Message: Recompiled after source changes. Index: wininst-7.1.exe =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/wininst-7.1.exe,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 Binary files /tmp/cvsfKRHc4 and /tmp/cvsz6wQ4p differ Index: wininst-6.exe =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/wininst-6.exe,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 Binary files /tmp/cvsbUGPs9 and /tmp/cvsjfArov differ From vincent at instonline.com Thu Feb 3 09:24:23 2005 From: vincent at instonline.com (vincent) Date: Fri Feb 4 11:59:57 2005 Subject: [Python-checkins] instonilne.com Message-ID: <200502041605562.SM03408@vincent> An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-checkins/attachments/20050203/b4cda821/attachment.html From doerwalter at users.sourceforge.net Fri Feb 4 15:15:37 2005 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Fri Feb 4 15:15:40 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_codecs.py, 1.18, 1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27454/Lib/test Modified Files: test_codecs.py Log Message: Add a test for UTF-16 reading where the byte sequence doesn't start with a BOM. Index: test_codecs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_codecs.py,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- test_codecs.py 10 Jan 2005 12:01:39 -0000 1.18 +++ test_codecs.py 4 Feb 2005 14:15:34 -0000 1.19 @@ -159,6 +159,15 @@ f = reader(s) self.assertEquals(f.read(), u"spamspam") + def test_badbom(self): + s = StringIO.StringIO("\xff\xff") + f = codecs.getwriter(self.encoding)(s) + self.assertRaises(UnicodeError, f.read) + + s = StringIO.StringIO("\xff\xff\xff\xff") + f = codecs.getwriter(self.encoding)(s) + self.assertRaises(UnicodeError, f.read) + def test_partial(self): self.check_partial( u"\x00\xff\u0100\uffff", From jhylton at users.sourceforge.net Fri Feb 4 19:38:47 2005 From: jhylton at users.sourceforge.net (jhylton@users.sourceforge.net) Date: Fri Feb 4 19:38:51 2005 Subject: [Python-checkins] python/dist/src/Python future.c,2.14,2.15 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22549/Python Modified Files: future.c Log Message: Fix bug that allowed future statements virtually anywhere in a module. If we exit via the break here, we need to set ff_last_lineno or FUTURE_POSSIBLE() will remain true. The bug affected statements containing a variety of expressions, but not all expressions. It has been present since Python 2.2. Index: future.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/future.c,v retrieving revision 2.14 retrieving revision 2.15 diff -u -d -r2.14 -r2.15 --- future.c 31 Aug 2004 10:07:13 -0000 2.14 +++ future.c 4 Feb 2005 18:38:43 -0000 2.15 @@ -93,7 +93,6 @@ { int i, r; loop: - switch (TYPE(n)) { case single_input: @@ -222,6 +221,7 @@ n = CHILD(n, 0); goto loop; } + ff->ff_last_lineno = n->n_lineno; break; case atom: @@ -258,4 +258,3 @@ } return ff; } - From jhylton at users.sourceforge.net Fri Feb 4 19:44:12 2005 From: jhylton at users.sourceforge.net (jhylton@users.sourceforge.net) Date: Fri Feb 4 19:44:15 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1237,1.1238 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23479 Modified Files: NEWS Log Message: Add NEWS item about future parser bug. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1237 retrieving revision 1.1238 diff -u -d -r1.1237 -r1.1238 --- NEWS 3 Feb 2005 15:01:24 -0000 1.1237 +++ NEWS 4 Feb 2005 18:44:06 -0000 1.1238 @@ -24,6 +24,10 @@ - Bug #1077106: Poor argument checking could cause memory corruption in calls to os.read(). +- The parser did not complain about future statements in illegal + positions. It once again reports a syntax error if a future + statement occurs after anything other than a doc string. + Extension Modules ----------------- From rhettinger at users.sourceforge.net Sat Feb 5 02:31:40 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Feb 5 02:31:45 2005 Subject: [Python-checkins] python/dist/src/Misc ACKS, 1.292, 1.293 NEWS, 1.1238, 1.1239 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15146/Misc Modified Files: ACKS NEWS Log Message: SF patch #1116583: NameError in cookielib domain check Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.292 retrieving revision 1.293 diff -u -d -r1.292 -r1.293 --- ACKS 13 Jan 2005 04:12:27 -0000 1.292 +++ ACKS 5 Feb 2005 01:31:18 -0000 1.293 @@ -399,6 +399,7 @@ Mike Meyer Steven Miale Trent Mick +Chad Miller Roman Milner Dom Mitchell Doug Moen Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1238 retrieving revision 1.1239 diff -u -d -r1.1238 -r1.1239 --- NEWS 4 Feb 2005 18:44:06 -0000 1.1238 +++ NEWS 5 Feb 2005 01:31:19 -0000 1.1239 @@ -51,6 +51,8 @@ Library ------- +- Fixed bug in a NameError bug in cookielib. Patch #1116583. + - Applied a security fix to SimpleXMLRPCserver (PSF-2005-001). This disables recursive traversal through instance attributes, which can be exploited in various ways. From rhettinger at users.sourceforge.net Sat Feb 5 02:31:50 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Feb 5 02:31:57 2005 Subject: [Python-checkins] python/dist/src/Lib cookielib.py,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15146/Lib Modified Files: cookielib.py Log Message: SF patch #1116583: NameError in cookielib domain check Index: cookielib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cookielib.py,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- cookielib.py 17 Oct 2004 16:23:52 -0000 1.4 +++ cookielib.py 5 Feb 2005 01:31:17 -0000 1.5 @@ -1134,11 +1134,10 @@ # having to load lots of MSIE cookie files unless necessary. req_host, erhn = eff_request_host(request) if not req_host.startswith("."): - dotted_req_host = "."+req_host + req_host = "."+req_host if not erhn.startswith("."): - dotted_erhn = "."+erhn - if not (dotted_req_host.endswith(domain) or - dotted_erhn.endswith(domain)): + erhn = "."+erhn + if not (req_host.endswith(domain) or erhn.endswith(domain)): #debug(" request domain %s does not match cookie domain %s", # req_host, domain) return False From rhettinger at users.sourceforge.net Sat Feb 5 02:33:19 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Feb 5 02:33:22 2005 Subject: [Python-checkins] python/dist/src/Lib cookielib.py,1.4,1.4.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15465 Modified Files: Tag: release24-maint cookielib.py Log Message: SF patch #1116583: NameError in cookielib domain check Index: cookielib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cookielib.py,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -d -r1.4 -r1.4.2.1 --- cookielib.py 17 Oct 2004 16:23:52 -0000 1.4 +++ cookielib.py 5 Feb 2005 01:33:16 -0000 1.4.2.1 @@ -1134,11 +1134,10 @@ # having to load lots of MSIE cookie files unless necessary. req_host, erhn = eff_request_host(request) if not req_host.startswith("."): - dotted_req_host = "."+req_host + req_host = "."+req_host if not erhn.startswith("."): - dotted_erhn = "."+erhn - if not (dotted_req_host.endswith(domain) or - dotted_erhn.endswith(domain)): + erhn = "."+erhn + if not (req_host.endswith(domain) or erhn.endswith(domain)): #debug(" request domain %s does not match cookie domain %s", # req_host, domain) return False From rhettinger at users.sourceforge.net Sat Feb 5 15:37:11 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Feb 5 15:37:15 2005 Subject: [Python-checkins] python/dist/src/Lib urllib2.py,1.79,1.80 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13622 Modified Files: urllib2.py Log Message: SF patch #1028908 (John J Lee) Minor code clarification and simplification. Index: urllib2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib2.py,v retrieving revision 1.79 retrieving revision 1.80 diff -u -d -r1.79 -r1.80 --- urllib2.py 9 Jan 2005 05:51:49 -0000 1.79 +++ urllib2.py 5 Feb 2005 14:37:06 -0000 1.80 @@ -304,10 +304,13 @@ self.handle_error[protocol] = lookup elif condition == "open": kind = protocol - lookup = getattr(self, "handle_"+condition) - elif condition in ["response", "request"]: + lookup = self.handle_open + elif condition == "response": kind = protocol - lookup = getattr(self, "process_"+condition) + lookup = self.process_response + elif condition == "request": + kind = protocol + lookup = self.process_request else: continue From rhettinger at users.sourceforge.net Sun Feb 6 00:43:09 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Feb 6 00:43:12 2005 Subject: [Python-checkins] python/dist/src/Objects dictobject.c,2.162,2.163 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31379 Modified Files: dictobject.c Log Message: Code simplification -- eliminate lookup when value is known in advance. Index: dictobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/dictobject.c,v retrieving revision 2.162 retrieving revision 2.163 diff -u -d -r2.162 -r2.163 --- dictobject.c 15 Jul 2004 15:54:04 -0000 2.162 +++ dictobject.c 5 Feb 2005 23:42:57 -0000 2.163 @@ -400,8 +400,10 @@ else { if (ep->me_key == NULL) mp->ma_fill++; - else - Py_DECREF(ep->me_key); + else { + assert(ep->me_key == dummy); + Py_DECREF(dummy); + } ep->me_key = key; ep->me_hash = hash; ep->me_value = value; From rhettinger at users.sourceforge.net Sun Feb 6 07:57:27 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Feb 6 07:57:32 2005 Subject: [Python-checkins] python/dist/src/Lib cgitb.py, 1.15, 1.16 cookielib.py, 1.5, 1.6 decimal.py, 1.32, 1.33 inspect.py, 1.59, 1.60 mhlib.py, 1.38, 1.39 posixfile.py, 1.27, 1.28 pydoc.py, 1.102, 1.103 smtplib.py, 1.68, 1.69 urllib2.py, 1.80, 1.81 warnings.py, 1.25, 1.26 whichdb.py, 1.19, 1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12661 Modified Files: cgitb.py cookielib.py decimal.py inspect.py mhlib.py posixfile.py pydoc.py smtplib.py urllib2.py warnings.py whichdb.py Log Message: Replace list of constants with tuples of constants. Index: cgitb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cgitb.py,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- cgitb.py 18 Jul 2004 06:14:41 -0000 1.15 +++ cgitb.py 6 Feb 2005 06:57:07 -0000 1.16 @@ -146,7 +146,7 @@ if name in done: continue done[name] = 1 if value is not __UNDEF__: - if where in ['global', 'builtin']: + if where in ('global', 'builtin'): name = ('%s ' % where) + strong(name) elif where == 'local': name = strong(name) Index: cookielib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cookielib.py,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- cookielib.py 5 Feb 2005 01:31:17 -0000 1.5 +++ cookielib.py 6 Feb 2005 06:57:07 -0000 1.6 @@ -783,12 +783,12 @@ def __repr__(self): args = [] - for name in ["version", "name", "value", + for name in ("version", "name", "value", "port", "port_specified", "domain", "domain_specified", "domain_initial_dot", "path", "path_specified", "secure", "expires", "discard", "comment", "comment_url", - ]: + ): attr = getattr(self, name) args.append("%s=%s" % (name, repr(attr))) args.append("rest=%s" % repr(self._rest)) @@ -981,9 +981,9 @@ if j == 0: # domain like .foo.bar tld = domain[i+1:] sld = domain[j+1:i] - if (sld.lower() in [ + if (sld.lower() in ( "co", "ac", - "com", "edu", "org", "net", "gov", "mil", "int"] and + "com", "edu", "org", "net", "gov", "mil", "int") and len(tld) == 2): # domain like .co.uk debug(" country-code second level domain %s", domain) @@ -1415,7 +1415,7 @@ v = self._now + v if (k in value_attrs) or (k in boolean_attrs): if (v is None and - k not in ["port", "comment", "commenturl"]): + k not in ("port", "comment", "commenturl")): debug(" missing value for %s attribute" % k) bad_cookie = True break Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- decimal.py 18 Dec 2004 19:07:15 -0000 1.32 +++ decimal.py 6 Feb 2005 06:57:07 -0000 1.33 @@ -515,7 +515,7 @@ if isinstance(value, (list,tuple)): if len(value) != 3: raise ValueError, 'Invalid arguments' - if value[0] not in [0,1]: + if value[0] not in (0,1): raise ValueError, 'Invalid sign' for digit in value[1]: if not isinstance(digit, (int,long)) or digit < 0: Index: inspect.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/inspect.py,v retrieving revision 1.59 retrieving revision 1.60 diff -u -d -r1.59 -r1.60 --- inspect.py 12 Dec 2004 16:46:28 -0000 1.59 +++ inspect.py 6 Feb 2005 06:57:07 -0000 1.60 @@ -346,7 +346,7 @@ def getsourcefile(object): """Return the Python source file an object was defined in, if it exists.""" filename = getfile(object) - if string.lower(filename[-4:]) in ['.pyc', '.pyo']: + if string.lower(filename[-4:]) in ('.pyc', '.pyo'): filename = filename[:-4] + '.py' for suffix, mode, kind in imp.get_suffixes(): if 'b' in mode and string.lower(filename[-len(suffix):]) == suffix: @@ -453,7 +453,7 @@ # Look for a comment block at the top of the file. start = 0 if lines and lines[0][:2] == '#!': start = 1 - while start < len(lines) and string.strip(lines[start]) in ['', '#']: + while start < len(lines) and string.strip(lines[start]) in ('', '#'): start = start + 1 if start < len(lines) and lines[start][:1] == '#': comments = [] @@ -621,7 +621,7 @@ # The following acrobatics are for anonymous (tuple) arguments. for i in range(nargs): - if args[i][:1] in ['', '.']: + if args[i][:1] in ('', '.'): stack, remain, count = [], [], [] while step < len(code): op = ord(code[step]) @@ -630,7 +630,7 @@ opname = dis.opname[op] value = ord(code[step]) + ord(code[step+1])*256 step = step + 2 - if opname in ['UNPACK_TUPLE', 'UNPACK_SEQUENCE']: + if opname in ('UNPACK_TUPLE', 'UNPACK_SEQUENCE'): remain.append(value) count.append(value) elif opname == 'STORE_FAST': @@ -696,7 +696,7 @@ def strseq(object, convert, join=joinseq): """Recursively walk a sequence, stringifying each element.""" - if type(object) in [types.ListType, types.TupleType]: + if type(object) in (list, tuple): return join(map(lambda o, c=convert, j=join: strseq(o, c, j), object)) else: return convert(object) Index: mhlib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mhlib.py,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- mhlib.py 31 Dec 2004 19:15:26 -0000 1.38 +++ mhlib.py 6 Feb 2005 06:57:07 -0000 1.39 @@ -982,11 +982,11 @@ context = mh.getcontext() f = mh.openfolder(context) do('f.getcurrent()') - for seq in ['first', 'last', 'cur', '.', 'prev', 'next', + for seq in ('first', 'last', 'cur', '.', 'prev', 'next', 'first:3', 'last:3', 'cur:3', 'cur:-3', 'prev:3', 'next:3', '1:3', '1:-3', '100:3', '100:-3', '10000:3', '10000:-3', - 'all']: + 'all'): try: do('f.parsesequence(%r)' % (seq,)) except Error, msg: Index: posixfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/posixfile.py,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- posixfile.py 5 Dec 2004 04:55:09 -0000 1.27 +++ posixfile.py 6 Feb 2005 06:57:07 -0000 1.28 @@ -182,7 +182,7 @@ 'freebsd6', 'bsdos2', 'bsdos3', 'bsdos4'): flock = struct.pack('lxxxxlxxxxlhh', \ l_start, l_len, os.getpid(), l_type, l_whence) - elif sys.platform in ['aix3', 'aix4']: + elif sys.platform in ('aix3', 'aix4'): flock = struct.pack('hhlllii', \ l_type, l_whence, l_start, l_len, 0, 0, 0) else: @@ -198,7 +198,7 @@ 'bsdos2', 'bsdos3', 'bsdos4'): l_start, l_len, l_pid, l_type, l_whence = \ struct.unpack('lxxxxlxxxxlhh', flock) - elif sys.platform in ['aix3', 'aix4']: + elif sys.platform in ('aix3', 'aix4'): l_type, l_whence, l_start, l_len, l_sysid, l_pid, l_vfs = \ struct.unpack('hhlllii', flock) elif sys.platform == "linux2": Index: pydoc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pydoc.py,v retrieving revision 1.102 retrieving revision 1.103 diff -u -d -r1.102 -r1.103 --- pydoc.py 8 Jan 2005 20:16:43 -0000 1.102 +++ pydoc.py 6 Feb 2005 06:57:07 -0000 1.103 @@ -153,8 +153,8 @@ def visiblename(name, all=None): """Decide whether to show documentation on a variable.""" # Certain special names are redundant. - if name in ['__builtins__', '__doc__', '__file__', '__path__', - '__module__', '__name__', '__slots__']: return 0 + if name in ('__builtins__', '__doc__', '__file__', '__path__', + '__module__', '__name__', '__slots__'): return 0 # Private names are hidden, but special names are displayed. if name.startswith('__') and name.endswith('__'): return 1 if all is not None: @@ -176,7 +176,7 @@ def ispackage(path): """Guess whether a path refers to a package directory.""" if os.path.isdir(path): - for ext in ['.py', '.pyc', '.pyo']: + for ext in ('.py', '.pyc', '.pyo'): if os.path.isfile(os.path.join(path, '__init__' + ext)): return True return False @@ -1298,12 +1298,12 @@ return plainpager if not sys.stdin.isatty() or not sys.stdout.isatty(): return plainpager - if os.environ.get('TERM') in ['dumb', 'emacs']: + 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']) - elif os.environ.get('TERM') in ['dumb', 'emacs']: + elif os.environ.get('TERM') in ('dumb', 'emacs'): return lambda text: pipepager(plain(text), os.environ['PAGER']) else: return lambda text: pipepager(text, os.environ['PAGER']) @@ -1369,14 +1369,14 @@ sys.stdout.flush() c = getchar() - if c in ['q', 'Q']: + if c in ('q', 'Q'): sys.stdout.write('\r \r') break - elif c in ['\r', '\n']: + elif c in ('\r', '\n'): sys.stdout.write('\r \r' + lines[r] + '\n') r = r + 1 continue - if c in ['b', 'B', '\x1b']: + if c in ('b', 'B', '\x1b'): r = r - inc - inc if r < 0: r = 0 sys.stdout.write('\n' + join(lines[r:r+inc], '\n') + '\n') @@ -1646,7 +1646,7 @@ except (KeyboardInterrupt, EOFError): break request = strip(replace(request, '"', '', "'", '')) - if lower(request) in ['q', 'quit']: break + if lower(request) in ('q', 'quit'): break self.help(request) def getline(self, prompt): Index: smtplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/smtplib.py,v retrieving revision 1.68 retrieving revision 1.69 diff -u -d -r1.68 -r1.69 --- smtplib.py 16 Jan 2005 13:04:30 -0000 1.68 +++ smtplib.py 6 Feb 2005 06:57:08 -0000 1.69 @@ -578,7 +578,7 @@ (code, resp) = self.docmd(encode_base64(password, eol="")) elif authmethod is None: raise SMTPException("No suitable authentication method found.") - if code not in [235, 503]: + if code not in (235, 503): # 235 == 'Authentication successful' # 503 == 'Error: already authenticated' raise SMTPAuthenticationError(code, resp) Index: urllib2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib2.py,v retrieving revision 1.80 retrieving revision 1.81 diff -u -d -r1.80 -r1.81 --- urllib2.py 5 Feb 2005 14:37:06 -0000 1.80 +++ urllib2.py 6 Feb 2005 06:57:08 -0000 1.81 @@ -384,7 +384,7 @@ 'unknown_open', req) def error(self, proto, *args): - if proto in ['http', 'https']: + if proto in ('http', 'https'): # XXX http[s] protocols are special-cased dict = self.handle_error['http'] # https is not different than http proto = args[2] # YUCK! Index: warnings.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/warnings.py,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- warnings.py 29 Dec 2004 15:28:09 -0000 1.25 +++ warnings.py 6 Feb 2005 06:57:08 -0000 1.26 @@ -216,7 +216,7 @@ if not action: return "default" if action == "all": return "always" # Alias - for a in ['default', 'always', 'ignore', 'module', 'once', 'error']: + for a in ('default', 'always', 'ignore', 'module', 'once', 'error'): if a.startswith(action): return a raise _OptionError("invalid action: %r" % (action,)) Index: whichdb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/whichdb.py,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- whichdb.py 20 Oct 2004 07:17:16 -0000 1.19 +++ whichdb.py 6 Feb 2005 06:57:08 -0000 1.20 @@ -62,7 +62,7 @@ return "dumbdbm" f = open(filename + os.extsep + "dir", "rb") try: - if f.read(1) in ["'", '"']: + if f.read(1) in ("'", '"'): return "dumbdbm" finally: f.close() From aleax at users.sourceforge.net Sun Feb 6 08:56:21 2005 From: aleax at users.sourceforge.net (aleax@users.sourceforge.net) Date: Sun Feb 6 08:56:24 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_copy.py, 1.11.8.1, 1.11.8.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20725/test Modified Files: Tag: release23-maint test_copy.py Log Message: fix bug 1114776 Index: test_copy.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_copy.py,v retrieving revision 1.11.8.1 retrieving revision 1.11.8.2 diff -u -d -r1.11.8.1 -r1.11.8.2 --- test_copy.py 25 Jan 2005 12:52:18 -0000 1.11.8.1 +++ test_copy.py 6 Feb 2005 07:56:18 -0000 1.11.8.2 @@ -222,6 +222,23 @@ x = C(23) self.assertEqual(copy.deepcopy(x), x) + def _nomro(self): + class C(type): + def __getattribute__(self, attr): + if attr == '__mro__': + raise AttributeError, "What, *me*, a __mro__? Nevah!" + return super(C, self).__getattribute__(attr) + class D(object): + __metaclass__ = C + return D() + + def test_copy_mro(self): + x = self._nomro() + y = copy.copy(x) + + def test_deepcopy_mro(self): + x = self._nomro() + y = copy.deepcopy(x) # The deepcopy() method def test_deepcopy_basic(self): From aleax at users.sourceforge.net Sun Feb 6 08:56:21 2005 From: aleax at users.sourceforge.net (aleax@users.sourceforge.net) Date: Sun Feb 6 08:56:24 2005 Subject: [Python-checkins] python/dist/src/Lib copy.py,1.42.8.1,1.42.8.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20725 Modified Files: Tag: release23-maint copy.py Log Message: fix bug 1114776 Index: copy.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/copy.py,v retrieving revision 1.42.8.1 retrieving revision 1.42.8.2 diff -u -d -r1.42.8.1 -r1.42.8.2 --- copy.py 25 Jan 2005 12:52:18 -0000 1.42.8.1 +++ copy.py 6 Feb 2005 07:56:18 -0000 1.42.8.2 @@ -62,8 +62,9 @@ __all__ = ["Error", "copy", "deepcopy"] +import inspect def _getspecial(cls, name): - for basecls in cls.__mro__: + for basecls in inspect.getmro(cls): try: return basecls.__dict__[name] except: From python at rcn.com Sun Feb 6 19:42:24 2005 From: python at rcn.com (Raymond Hettinger) Date: Sun Feb 6 19:46:11 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_copy.py, 1.11.8.1, 1.11.8.2 In-Reply-To: Message-ID: <001701c50c7b$9a25b3c0$8abb9d8d@oemcomputer> > Modified Files: > Tag: release23-maint > test_copy.py > Log Message: > fix bug 1114776 Don't forget release24-maint. Raymond From rhettinger at users.sourceforge.net Sun Feb 6 23:05:45 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Feb 6 23:05:47 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_peepholer.py, 1.8, 1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26507/Lib/test Modified Files: test_peepholer.py Log Message: Transform "x in (1,2,3)" to "x in frozenset([1,2,3])". Inspired by Skip's idea to recognize the throw-away nature of sequences in this context and to transform their type to one with better performance. Index: test_peepholer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_peepholer.py,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- test_peepholer.py 26 Jan 2005 12:50:05 -0000 1.8 +++ test_peepholer.py 6 Feb 2005 22:05:42 -0000 1.9 @@ -133,6 +133,16 @@ asm = dis_single('a="x"*1000') self.assert_('(1000)' in asm) + def test_set_conversion(self): + for line in ( + 'x in (1,2,3)', + 'x not in (1,2,3)', + 'not x in (1,2,3)', + 'not x not in (1,2,3)', + ): + asm = dis_single(line) + self.assert_('frozenset' in asm) + def test_elim_extra_return(self): # RETURN LOAD_CONST None RETURN --> RETURN def f(x): From rhettinger at users.sourceforge.net Sun Feb 6 23:05:44 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Feb 6 23:05:47 2005 Subject: [Python-checkins] python/dist/src/Python compile.c,2.340,2.341 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26507/Python Modified Files: compile.c Log Message: Transform "x in (1,2,3)" to "x in frozenset([1,2,3])". Inspired by Skip's idea to recognize the throw-away nature of sequences in this context and to transform their type to one with better performance. Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.340 retrieving revision 2.341 diff -u -d -r2.340 -r2.341 --- compile.c 26 Jan 2005 12:50:04 -0000 2.340 +++ compile.c 6 Feb 2005 22:05:38 -0000 2.341 @@ -540,6 +540,47 @@ return 1; } +/* Replace LOAD_CONST tuple with LOAD_CONST frozenset in the context + of a single-use constant for "in" and "not in" tests. +*/ +int +try_set_conversion(unsigned char *codestr, PyObject *consts) +{ + PyObject *newconst, *constant; + int arg, len_consts; + + /* Pre-conditions */ + assert(PyList_CheckExact(consts)); + assert(codestr[0] == LOAD_CONST); + assert(codestr[3] == COMPARE_OP); + assert(GETARG(codestr, 3) == 6 || GETARG(codestr, 3) == 7); + + /* Attempt to convert constant to a frozenset. Bail-out with no + changes if the tuple contains unhashable values. */ + arg = GETARG(codestr, 0); + constant = PyList_GET_ITEM(consts, arg); + if (constant->ob_type != &PyTuple_Type) + return 0; + newconst = PyObject_CallFunctionObjArgs( + (PyObject *)&PyFrozenSet_Type, constant, NULL); + if (newconst == NULL) { + PyErr_Clear(); + return 0; + } + + /* Append new constant onto consts list.*/ + len_consts = PyList_GET_SIZE(consts); + if (PyList_Append(consts, newconst)) { + Py_DECREF(newconst); + return 0; + } + Py_DECREF(newconst); + + /* Write new LOAD_CONST newconst on top of LOAD_CONST oldconst */ + SETARG(codestr, 0, len_consts); + return 1; +} + static unsigned int * markblocks(unsigned char *code, int len) { @@ -665,9 +706,15 @@ /* not a is b --> a is not b not a in b --> a not in b not a is not b --> a is b - not a not in b --> a in b */ + not a not in b --> a in b + + a in c --> a in frozenset(c) + where c is a constant tuple of hashable values + */ case COMPARE_OP: j = GETARG(codestr, i); + if (lastlc >= 1 && (j == 6 || j == 7) && ISBASICBLOCK(blocks,i-3,6)) + try_set_conversion(&codestr[i-3], consts); if (j < 6 || j > 9 || codestr[i+3] != UNARY_NOT || !ISBASICBLOCK(blocks,i,4)) From aleax at users.sourceforge.net Mon Feb 7 13:04:27 2005 From: aleax at users.sourceforge.net (aleax@users.sourceforge.net) Date: Mon Feb 7 13:04:30 2005 Subject: [Python-checkins] python/dist/src/Modules _testcapimodule.c, 1.24.10.1, 1.24.10.2 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29103/Modules Modified Files: Tag: release23-maint _testcapimodule.c Log Message: tiny backport from 2.4, fix a leak in _testcapi Index: _testcapimodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_testcapimodule.c,v retrieving revision 1.24.10.1 retrieving revision 1.24.10.2 diff -u -d -r1.24.10.1 -r1.24.10.2 --- _testcapimodule.c 25 Jan 2005 12:52:18 -0000 1.24.10.1 +++ _testcapimodule.c 7 Feb 2005 12:04:22 -0000 1.24.10.2 @@ -544,6 +544,7 @@ PyTuple_SET_ITEM(exc_args, i, v); } PyErr_SetObject(exc, exc_args); + Py_DECREF(exc_args); return NULL; } From aleax at users.sourceforge.net Mon Feb 7 13:18:29 2005 From: aleax at users.sourceforge.net (aleax@users.sourceforge.net) Date: Mon Feb 7 13:18:31 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_copy.py, 1.11.8.2, 1.11.8.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31915 Modified Files: Tag: release23-maint test_copy.py Log Message: sligtly strengthen unit tests for copy.py Index: test_copy.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_copy.py,v retrieving revision 1.11.8.2 retrieving revision 1.11.8.3 diff -u -d -r1.11.8.2 -r1.11.8.3 --- test_copy.py 6 Feb 2005 07:56:18 -0000 1.11.8.2 +++ test_copy.py 7 Feb 2005 12:18:26 -0000 1.11.8.3 @@ -185,7 +185,33 @@ self.assert_(x is not y) self.assert_(x.tag is not y.tag) - # regression tests for metaclass-confusion + # regression tests for class-vs-instance and metaclass-confusion + def test_copy_classoverinstance(self): + class C(object): + def __init__(self, v): + self.v = v + def __cmp__(self, other): + return -cmp(other, self.v) + def __copy__(self): + return self.__class__(self.v) + x = C(23) + self.assertEqual(copy.copy(x), x) + x.__copy__ = lambda: 42 + self.assertEqual(copy.copy(x), x) + + def test_deepcopy_classoverinstance(self): + class C(object): + def __init__(self, v): + self.v = v + def __cmp__(self, other): + return -cmp(other, self.v) + def __deepcopy__(self, memo): + return self.__class__(copy.deepcopy(self.v, memo)) + x = C(23) + self.assertEqual(copy.deepcopy(x), x) + x.__deepcopy__ = lambda memo: 42 + self.assertEqual(copy.deepcopy(x), x) + def test_copy_metaclassconfusion(self): class MyOwnError(copy.Error): pass From aleax at users.sourceforge.net Mon Feb 7 13:39:58 2005 From: aleax at users.sourceforge.net (aleax@users.sourceforge.net) Date: Mon Feb 7 13:40:02 2005 Subject: [Python-checkins] python/dist/src/Lib copy.py,1.43,1.43.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3361/Lib Modified Files: Tag: release24-maint copy.py Log Message: forwardport of 2.3.5 fixes to copy.py Index: copy.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/copy.py,v retrieving revision 1.43 retrieving revision 1.43.4.1 diff -u -d -r1.43 -r1.43.4.1 --- copy.py 8 Mar 2004 05:59:33 -0000 1.43 +++ copy.py 7 Feb 2005 12:39:54 -0000 1.43.4.1 @@ -62,6 +62,16 @@ __all__ = ["Error", "copy", "deepcopy"] +import inspect +def _getspecial(cls, name): + for basecls in inspect.getmro(cls): + try: + return basecls.__dict__[name] + except: + pass + else: + return None + def copy(x): """Shallow copy operation on arbitrary Python objects. @@ -74,7 +84,7 @@ if copier: return copier(x) - copier = getattr(cls, "__copy__", None) + copier = _getspecial(cls, "__copy__") if copier: return copier(x) @@ -90,6 +100,9 @@ if reductor: rv = reductor() else: + copier = getattr(x, "__copy__", None) + if copier: + return copier() raise Error("un(shallow)copyable object of type %s" % cls) return _reconstruct(x, rv, 0) @@ -167,9 +180,9 @@ if issc: y = _deepcopy_atomic(x, memo) else: - copier = getattr(x, "__deepcopy__", None) + copier = _getspecial(cls, "__deepcopy__") if copier: - y = copier(memo) + y = copier(x, memo) else: reductor = dispatch_table.get(cls) if reductor: @@ -183,6 +196,9 @@ if reductor: rv = reductor() else: + copier = getattr(x, "__deepcopy__", None) + if copier: + return copier(memo) raise Error( "un(deep)copyable object of type %s" % cls) y = _reconstruct(x, rv, 1, memo) From aleax at users.sourceforge.net Mon Feb 7 13:39:58 2005 From: aleax at users.sourceforge.net (aleax@users.sourceforge.net) Date: Mon Feb 7 13:40:03 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_copy.py, 1.13, 1.13.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3361/Lib/test Modified Files: Tag: release24-maint test_copy.py Log Message: forwardport of 2.3.5 fixes to copy.py Index: test_copy.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_copy.py,v retrieving revision 1.13 retrieving revision 1.13.4.1 diff -u -d -r1.13 -r1.13.4.1 --- test_copy.py 12 Feb 2004 17:35:11 -0000 1.13 +++ test_copy.py 7 Feb 2005 12:39:55 -0000 1.13.4.1 @@ -166,6 +166,107 @@ x = C(42) self.assertEqual(copy.copy(x), x) + # tests for copying extension types, iff module trycopy is installed + def test_copy_classictype(self): + from _testcapi import make_copyable + x = make_copyable([23]) + y = copy.copy(x) + self.assertEqual(x, y) + self.assertEqual(x.tag, y.tag) + self.assert_(x is not y) + self.assert_(x.tag is y.tag) + + def test_deepcopy_classictype(self): + from _testcapi import make_copyable + x = make_copyable([23]) + y = copy.deepcopy(x) + self.assertEqual(x, y) + self.assertEqual(x.tag, y.tag) + self.assert_(x is not y) + self.assert_(x.tag is not y.tag) + + # regression tests for class-vs-instance and metaclass-confusion + def test_copy_classoverinstance(self): + class C(object): + def __init__(self, v): + self.v = v + def __cmp__(self, other): + return -cmp(other, self.v) + def __copy__(self): + return self.__class__(self.v) + x = C(23) + self.assertEqual(copy.copy(x), x) + x.__copy__ = lambda: 42 + self.assertEqual(copy.copy(x), x) + + def test_deepcopy_classoverinstance(self): + class C(object): + def __init__(self, v): + self.v = v + def __cmp__(self, other): + return -cmp(other, self.v) + def __deepcopy__(self, memo): + return self.__class__(copy.deepcopy(self.v, memo)) + x = C(23) + self.assertEqual(copy.deepcopy(x), x) + x.__deepcopy__ = lambda memo: 42 + self.assertEqual(copy.deepcopy(x), x) + + + def test_copy_metaclassconfusion(self): + class MyOwnError(copy.Error): + pass + class Meta(type): + def __copy__(cls): + raise MyOwnError("can't copy classes w/this metaclass") + class C: + __metaclass__ = Meta + def __init__(self, tag): + self.tag = tag + def __cmp__(self, other): + return -cmp(other, self.tag) + # the metaclass can forbid shallow copying of its classes + self.assertRaises(MyOwnError, copy.copy, C) + # check that there is no interference with instances + x = C(23) + self.assertEqual(copy.copy(x), x) + + def test_deepcopy_metaclassconfusion(self): + class MyOwnError(copy.Error): + pass + class Meta(type): + def __deepcopy__(cls, memo): + raise MyOwnError("can't deepcopy classes w/this metaclass") + class C: + __metaclass__ = Meta + def __init__(self, tag): + self.tag = tag + def __cmp__(self, other): + return -cmp(other, self.tag) + # types are ALWAYS deepcopied atomically, no matter what + self.assertEqual(copy.deepcopy(C), C) + # check that there is no interference with instances + x = C(23) + self.assertEqual(copy.deepcopy(x), x) + + def _nomro(self): + class C(type): + def __getattribute__(self, attr): + if attr == '__mro__': + raise AttributeError, "What, *me*, a __mro__? Nevah!" + return super(C, self).__getattribute__(attr) + class D(object): + __metaclass__ = C + return D() + + def test_copy_mro(self): + x = self._nomro() + y = copy.copy(x) + + def test_deepcopy_mro(self): + x = self._nomro() + y = copy.deepcopy(x) + # The deepcopy() method def test_deepcopy_basic(self): From aleax at users.sourceforge.net Mon Feb 7 13:39:58 2005 From: aleax at users.sourceforge.net (aleax@users.sourceforge.net) Date: Mon Feb 7 13:40:03 2005 Subject: [Python-checkins] python/dist/src/Modules _testcapimodule.c, 1.25, 1.25.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3361/Modules Modified Files: Tag: release24-maint _testcapimodule.c Log Message: forwardport of 2.3.5 fixes to copy.py Index: _testcapimodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_testcapimodule.c,v retrieving revision 1.25 retrieving revision 1.25.4.1 diff -u -d -r1.25 -r1.25.4.1 --- _testcapimodule.c 15 Aug 2003 13:03:30 -0000 1.25 +++ _testcapimodule.c 7 Feb 2005 12:39:55 -0000 1.25.4.1 @@ -588,6 +588,169 @@ } #endif +/* a classic-type with copyable instances */ + +typedef struct { + PyObject_HEAD + /* instance tag (a string). */ + PyObject* tag; +} CopyableObject; + +staticforward PyTypeObject Copyable_Type; + +#define Copyable_CheckExact(op) ((op)->ob_type == &Copyable_Type) + +/* -------------------------------------------------------------------- */ + +/* copyable constructor and destructor */ +static PyObject* +copyable_new(PyObject* tag) +{ + CopyableObject* self; + + self = PyObject_New(CopyableObject, &Copyable_Type); + if (self == NULL) + return NULL; + Py_INCREF(tag); + self->tag = tag; + return (PyObject*) self; +} + +static PyObject* +copyable(PyObject* self, PyObject* args, PyObject* kw) +{ + PyObject* elem; + PyObject* tag; + if (!PyArg_ParseTuple(args, "O:Copyable", &tag)) + return NULL; + elem = copyable_new(tag); + return elem; +} + +static void +copyable_dealloc(CopyableObject* self) +{ + /* discard attributes */ + Py_DECREF(self->tag); + PyObject_Del(self); +} + +/* copyable methods */ + +static PyObject* +copyable_copy(CopyableObject* self, PyObject* args) +{ + CopyableObject* copyable; + if (!PyArg_ParseTuple(args, ":__copy__")) + return NULL; + copyable = (CopyableObject*)copyable_new(self->tag); + if (!copyable) + return NULL; + return (PyObject*) copyable; +} + +PyObject* _copy_deepcopy; + +static PyObject* +copyable_deepcopy(CopyableObject* self, PyObject* args) +{ + CopyableObject* copyable = 0; + PyObject* memo; + PyObject* tag_copy; + if (!PyArg_ParseTuple(args, "O:__deepcopy__", &memo)) + return NULL; + + tag_copy = PyObject_CallFunctionObjArgs(_copy_deepcopy, self->tag, memo, NULL); + + if(tag_copy) { + copyable = (CopyableObject*)copyable_new(tag_copy); + Py_DECREF(tag_copy); + } + return (PyObject*) copyable; +} + +static PyObject* +copyable_repr(CopyableObject* self) +{ + PyObject* repr; + char buffer[100]; + + repr = PyString_FromString("tag)); + + sprintf(buffer, "} at %p>", self); + PyString_ConcatAndDel(&repr, PyString_FromString(buffer)); + + return repr; +} + +static int +copyable_compare(CopyableObject* obj1, CopyableObject* obj2) +{ + return PyObject_Compare(obj1->tag, obj2->tag); +} + +static PyMethodDef copyable_methods[] = { + {"__copy__", (PyCFunction) copyable_copy, METH_VARARGS}, + {"__deepcopy__", (PyCFunction) copyable_deepcopy, METH_VARARGS}, + {NULL, NULL} +}; + +static PyObject* +copyable_getattr(CopyableObject* self, char* name) +{ + PyObject* res; + res = Py_FindMethod(copyable_methods, (PyObject*) self, name); + if (res) + return res; + PyErr_Clear(); + if (strcmp(name, "tag") == 0) { + res = self->tag; + } else { + PyErr_SetString(PyExc_AttributeError, name); + return NULL; + } + if (!res) + return NULL; + Py_INCREF(res); + return res; +} + +static int +copyable_setattr(CopyableObject* self, const char* name, PyObject* value) +{ + if (value == NULL) { + PyErr_SetString( + PyExc_AttributeError, + "can't delete copyable attributes" + ); + return -1; + } + if (strcmp(name, "tag") == 0) { + Py_DECREF(self->tag); + self->tag = value; + Py_INCREF(self->tag); + } else { + PyErr_SetString(PyExc_AttributeError, name); + return -1; + } + return 0; +} + +statichere PyTypeObject Copyable_Type = { + PyObject_HEAD_INIT(NULL) + 0, "Copyable", sizeof(CopyableObject), 0, + /* methods */ + (destructor)copyable_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + (getattrfunc)copyable_getattr, /* tp_getattr */ + (setattrfunc)copyable_setattr, /* tp_setattr */ + (cmpfunc)copyable_compare, /* tp_compare */ + (reprfunc)copyable_repr, /* tp_repr */ + 0, /* tp_as_number */ +}; + static PyMethodDef TestMethods[] = { {"raise_exception", raise_exception, METH_VARARGS}, {"test_config", (PyCFunction)test_config, METH_NOARGS}, @@ -614,9 +777,11 @@ {"test_u_code", (PyCFunction)test_u_code, METH_NOARGS}, #endif #ifdef WITH_THREAD - {"_test_thread_state", (PyCFunction)test_thread_state, METH_VARARGS}, + {"_test_thread_state", (PyCFunction)test_thread_state, METH_VARARGS}, #endif + {"make_copyable", (PyCFunction) copyable, METH_VARARGS}, {NULL, NULL} /* sentinel */ + }; #define AddSym(d, n, f, v) {PyObject *o = f(v); PyDict_SetItemString(d, n, o); Py_DECREF(o);} @@ -625,6 +790,15 @@ init_testcapi(void) { PyObject *m; + PyObject *copy_module; + + + copy_module = PyImport_ImportModule("copy"); + if(!copy_module) + return; + _copy_deepcopy = PyObject_GetAttrString(copy_module, "deepcopy"); + Py_DECREF(copy_module); + Copyable_Type.ob_type = &PyType_Type; m = Py_InitModule("_testcapi", TestMethods); From aleax at aleax.it Mon Feb 7 14:49:56 2005 From: aleax at aleax.it (Alex Martelli) Date: Mon Feb 7 14:50:00 2005 Subject: [Python-Dev] RE: [Python-checkins] python/dist/src/Lib/test test_copy.py, 1.11.8.1, 1.11.8.2 In-Reply-To: <001701c50c7b$9a25b3c0$8abb9d8d@oemcomputer> References: <001701c50c7b$9a25b3c0$8abb9d8d@oemcomputer> Message-ID: On 2005 Feb 06, at 19:42, Raymond Hettinger wrote: >> Modified Files: >> Tag: release23-maint >> test_copy.py >> Log Message: >> fix bug 1114776 > > Don't forget release24-maint. Done -- but the maintenance branch of 2.4 has a problem right now: it doesn't pass unit tests, specifically test_os (I checked right after a cvs up and before doing any changes, of course). This appears to be connected to: mapping_tests.py being very strict (or something) and demanding that some mapping be able to update itself from a ``simple dictionary'' that's not iterable and does not have an .items method either; while the _Environ class in os.py appears to make some reasonable demands from the argument to its .update method. I'm not _sure_ which side of the dispute is in the right, so I haven't changed anything there (even though committing anything with unit tests broken makes my teeth grit). I do admit that this kind of issue makes a good case for more formalized interfaces...;-) Alex From rhettinger at users.sourceforge.net Mon Feb 7 15:16:28 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Feb 7 15:16:33 2005 Subject: [Python-checkins] python/dist/src/Lib DocXMLRPCServer.py, 1.4, 1.5 cookielib.py, 1.6, 1.7 copy.py, 1.43, 1.44 optparse.py, 1.12, 1.13 pickle.py, 1.160, 1.161 subprocess.py, 1.13, 1.14 unittest.py, 1.37, 1.38 xmlrpclib.py, 1.36, 1.37 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24200 Modified Files: DocXMLRPCServer.py cookielib.py copy.py optparse.py pickle.py subprocess.py unittest.py xmlrpclib.py Log Message: Reduce the usage of the types module. Index: DocXMLRPCServer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/DocXMLRPCServer.py,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- DocXMLRPCServer.py 31 Aug 2004 11:38:11 -0000 1.4 +++ DocXMLRPCServer.py 7 Feb 2005 14:16:09 -0000 1.5 @@ -12,7 +12,6 @@ import pydoc import inspect -import types import re import sys @@ -92,7 +91,7 @@ else: argspec = '(...)' - if isinstance(object, types.TupleType): + if isinstance(object, tuple): argspec = object[0] or argspec docstring = object[1] or "" else: Index: cookielib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cookielib.py,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- cookielib.py 6 Feb 2005 06:57:07 -0000 1.6 +++ cookielib.py 7 Feb 2005 14:16:09 -0000 1.7 @@ -26,7 +26,6 @@ """ import sys, re, urlparse, copy, time, urllib, logging -from types import StringTypes try: import threading as _threading except ImportError: @@ -359,7 +358,7 @@ [[('Basic', None), ('realm', '"foobar"')]] """ - assert type(header_values) not in StringTypes + assert not isinstance(header_values, basestring) result = [] for text in header_values: orig_text = text Index: copy.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/copy.py,v retrieving revision 1.43 retrieving revision 1.44 diff -u -d -r1.43 -r1.44 --- copy.py 8 Mar 2004 05:59:33 -0000 1.43 +++ copy.py 7 Feb 2005 14:16:09 -0000 1.44 @@ -99,7 +99,7 @@ def _copy_immutable(x): return x -for t in (types.NoneType, int, long, float, bool, str, tuple, +for t in (type(None), int, long, float, bool, str, tuple, frozenset, type, xrange, types.ClassType, types.BuiltinFunctionType): d[t] = _copy_immutable @@ -195,26 +195,26 @@ def _deepcopy_atomic(x, memo): return x -d[types.NoneType] = _deepcopy_atomic -d[types.IntType] = _deepcopy_atomic -d[types.LongType] = _deepcopy_atomic -d[types.FloatType] = _deepcopy_atomic -d[types.BooleanType] = _deepcopy_atomic +d[type(None)] = _deepcopy_atomic +d[int] = _deepcopy_atomic +d[long] = _deepcopy_atomic +d[float] = _deepcopy_atomic +d[bool] = _deepcopy_atomic try: - d[types.ComplexType] = _deepcopy_atomic + d[complex] = _deepcopy_atomic except AttributeError: pass -d[types.StringType] = _deepcopy_atomic +d[str] = _deepcopy_atomic try: - d[types.UnicodeType] = _deepcopy_atomic + d[unicode] = _deepcopy_atomic except AttributeError: pass try: d[types.CodeType] = _deepcopy_atomic except AttributeError: pass -d[types.TypeType] = _deepcopy_atomic -d[types.XRangeType] = _deepcopy_atomic +d[type] = _deepcopy_atomic +d[xrange] = _deepcopy_atomic d[types.ClassType] = _deepcopy_atomic d[types.BuiltinFunctionType] = _deepcopy_atomic @@ -224,7 +224,7 @@ for a in x: y.append(deepcopy(a, memo)) return y -d[types.ListType] = _deepcopy_list +d[list] = _deepcopy_list def _deepcopy_tuple(x, memo): y = [] @@ -243,7 +243,7 @@ y = x memo[d] = y return y -d[types.TupleType] = _deepcopy_tuple +d[tuple] = _deepcopy_tuple def _deepcopy_dict(x, memo): y = {} @@ -251,7 +251,7 @@ for key, value in x.iteritems(): y[deepcopy(key, memo)] = deepcopy(value, memo) return y -d[types.DictionaryType] = _deepcopy_dict +d[dict] = _deepcopy_dict if PyStringMap is not None: d[PyStringMap] = _deepcopy_dict Index: optparse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/optparse.py,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- optparse.py 7 Dec 2004 03:25:18 -0000 1.12 +++ optparse.py 7 Feb 2005 14:16:20 -0000 1.13 @@ -67,7 +67,6 @@ """ import sys, os -import types import textwrap try: from gettext import gettext as _ @@ -590,7 +589,7 @@ if self.choices is None: raise OptionError( "must supply a list of choices for type 'choice'", self) - elif type(self.choices) not in (types.TupleType, types.ListType): + elif type(self.choices) not in (tuple, list): raise OptionError( "choices must be a list of strings ('%s' supplied)" % str(type(self.choices)).split("'")[1], self) @@ -634,12 +633,12 @@ raise OptionError( "callback not callable: %r" % self.callback, self) if (self.callback_args is not None and - type(self.callback_args) is not types.TupleType): + type(self.callback_args) is not tuple): raise OptionError( "callback_args, if supplied, must be a tuple: not %r" % self.callback_args, self) if (self.callback_kwargs is not None and - type(self.callback_kwargs) is not types.DictType): + type(self.callback_kwargs) is not dict): raise OptionError( "callback_kwargs, if supplied, must be a dict: not %r" % self.callback_kwargs, self) @@ -927,7 +926,7 @@ """add_option(Option) add_option(opt_str, ..., kwarg=val, ...) """ - if type(args[0]) is types.StringType: + if type(args[0]) is str: option = self.option_class(*args, **kwargs) elif len(args) == 1 and not kwargs: option = args[0] @@ -1213,7 +1212,7 @@ def add_option_group(self, *args, **kwargs): # XXX lots of overlap with OptionContainer.add_option() - if type(args[0]) is types.StringType: + if type(args[0]) is str: group = OptionGroup(self, *args, **kwargs) elif len(args) == 1 and not kwargs: group = args[0] Index: pickle.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pickle.py,v retrieving revision 1.160 retrieving revision 1.161 diff -u -d -r1.160 -r1.161 --- pickle.py 7 Dec 2004 07:05:52 -0000 1.160 +++ pickle.py 7 Feb 2005 14:16:20 -0000 1.161 @@ -288,7 +288,7 @@ # Check for a class with a custom metaclass; treat as regular class try: - issc = issubclass(t, TypeType) + issc = issubclass(t, type) except TypeError: # t is not a class (old Boost; see SF #502085) issc = 0 if issc: @@ -313,12 +313,12 @@ (t.__name__, obj)) # Check for string returned by reduce(), meaning "save as global" - if type(rv) is StringType: + if type(rv) is str: self.save_global(obj, rv) return # Assert that reduce() returned a tuple - if type(rv) is not TupleType: + if type(rv) is not tuple: raise PicklingError("%s must return string or tuple" % reduce) # Assert that it returned an appropriately sized tuple @@ -347,7 +347,7 @@ # This API is called by some subclasses # Assert that args is a tuple or None - if not isinstance(args, TupleType): + if not isinstance(args, tuple): raise PicklingError("args from reduce() should be a tuple") # Assert that func is callable @@ -425,7 +425,7 @@ def save_none(self, obj): self.write(NONE) - dispatch[NoneType] = save_none + dispatch[type(None)] = save_none def save_bool(self, obj): if self.proto >= 2: @@ -456,7 +456,7 @@ return # Text pickle, or int too big to fit in signed 4-byte format. self.write(INT + repr(obj) + '\n') - dispatch[IntType] = save_int + dispatch[int] = save_int def save_long(self, obj, pack=struct.pack): if self.proto >= 2: @@ -468,14 +468,14 @@ self.write(LONG4 + pack("d', obj)) else: self.write(FLOAT + repr(obj) + '\n') - dispatch[FloatType] = save_float + dispatch[float] = save_float def save_string(self, obj, pack=struct.pack): if self.bin: @@ -487,7 +487,7 @@ else: self.write(STRING + repr(obj) + '\n') self.memoize(obj) - dispatch[StringType] = save_string + dispatch[str] = save_string def save_unicode(self, obj, pack=struct.pack): if self.bin: @@ -501,7 +501,7 @@ self.memoize(obj) dispatch[UnicodeType] = save_unicode - if StringType == UnicodeType: + if str == UnicodeType: # This is true for Jython def save_string(self, obj, pack=struct.pack): unicode = obj.isunicode() @@ -527,7 +527,7 @@ else: self.write(STRING + repr(obj) + '\n') self.memoize(obj) - dispatch[StringType] = save_string + dispatch[str] = save_string def save_tuple(self, obj): write = self.write @@ -580,7 +580,7 @@ self.write(TUPLE) self.memoize(obj) - dispatch[TupleType] = save_tuple + dispatch[tuple] = save_tuple # save_empty_tuple() isn't used by anything in Python 2.3. However, I # found a Pickler subclass in Zope3 that calls it, so it's not harmless @@ -599,7 +599,7 @@ self.memoize(obj) self._batch_appends(iter(obj)) - dispatch[ListType] = save_list + dispatch[list] = save_list # Keep in synch with cPickle's BATCHSIZE. Nothing will break if it gets # out of synch, though. @@ -648,7 +648,7 @@ self.memoize(obj) self._batch_setitems(obj.iteritems()) - dispatch[DictionaryType] = save_dict + dispatch[dict] = save_dict if not PyStringMap is None: dispatch[PyStringMap] = save_dict @@ -770,7 +770,7 @@ dispatch[ClassType] = save_global dispatch[FunctionType] = save_global dispatch[BuiltinFunctionType] = save_global - dispatch[TypeType] = save_global + dispatch[type] = save_global # Pickling helpers Index: subprocess.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/subprocess.py,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- subprocess.py 1 Jan 2005 09:38:57 -0000 1.13 +++ subprocess.py 7 Feb 2005 14:16:21 -0000 1.14 @@ -372,7 +372,6 @@ mswindows = (sys.platform == "win32") import os -import types import traceback # Exception classes used by this module. @@ -638,7 +637,7 @@ # Detach and turn into fd p2cwrite = p2cwrite.Detach() p2cwrite = msvcrt.open_osfhandle(p2cwrite, 0) - elif type(stdin) == types.IntType: + elif type(stdin) == int: p2cread = msvcrt.get_osfhandle(stdin) else: # Assuming file-like object @@ -652,7 +651,7 @@ # Detach and turn into fd c2pread = c2pread.Detach() c2pread = msvcrt.open_osfhandle(c2pread, 0) - elif type(stdout) == types.IntType: + elif type(stdout) == int: c2pwrite = msvcrt.get_osfhandle(stdout) else: # Assuming file-like object @@ -668,7 +667,7 @@ errread = msvcrt.open_osfhandle(errread, 0) elif stderr == STDOUT: errwrite = c2pwrite - elif type(stderr) == types.IntType: + elif type(stderr) == int: errwrite = msvcrt.get_osfhandle(stderr) else: # Assuming file-like object @@ -711,7 +710,7 @@ errread, errwrite): """Execute program (MS Windows version)""" - if not isinstance(args, types.StringTypes): + if not isinstance(args, basestring): args = list2cmdline(args) # Process startup details @@ -876,7 +875,7 @@ pass elif stdin == PIPE: p2cread, p2cwrite = os.pipe() - elif type(stdin) == types.IntType: + elif type(stdin) == int: p2cread = stdin else: # Assuming file-like object @@ -886,7 +885,7 @@ pass elif stdout == PIPE: c2pread, c2pwrite = os.pipe() - elif type(stdout) == types.IntType: + elif type(stdout) == int: c2pwrite = stdout else: # Assuming file-like object @@ -898,7 +897,7 @@ errread, errwrite = os.pipe() elif stderr == STDOUT: errwrite = c2pwrite - elif type(stderr) == types.IntType: + elif type(stderr) == int: errwrite = stderr else: # Assuming file-like object @@ -937,7 +936,7 @@ errread, errwrite): """Execute program (POSIX version)""" - if isinstance(args, types.StringTypes): + if isinstance(args, basestring): args = [args] if shell: Index: unittest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/unittest.py,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- unittest.py 4 Dec 2004 21:21:53 -0000 1.37 +++ unittest.py 7 Feb 2005 14:16:21 -0000 1.38 @@ -71,7 +71,7 @@ False, True = 0, 1 def isinstance(obj, clsinfo): import __builtin__ - if type(clsinfo) in (types.TupleType, types.ListType): + if type(clsinfo) in (tuple, list): for cls in clsinfo: if cls is type: cls = types.ClassType if __builtin__.isinstance(obj, cls): Index: xmlrpclib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xmlrpclib.py,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- xmlrpclib.py 13 Oct 2004 06:48:37 -0000 1.36 +++ xmlrpclib.py 7 Feb 2005 14:16:21 -0000 1.37 @@ -138,7 +138,7 @@ import re, string, time, operator -from types import * +from types import InstanceType # -------------------------------------------------------------------- # Internal stuff @@ -348,8 +348,8 @@ """ def __init__(self, value=0): - if not isinstance(value, StringType): - if not isinstance(value, (TupleType, time.struct_time)): + if not isinstance(value, str): + if not isinstance(value, (tuple, time.struct_time)): if value == 0: value = time.time() value = time.localtime(value) @@ -618,7 +618,7 @@ if not self.allow_none: raise TypeError, "cannot marshal None unless allow_none is enabled" write("") - dispatch[NoneType] = dump_nil + dispatch[type(None)] = dump_nil def dump_int(self, value, write): # in case ints are > 32 bits @@ -627,7 +627,7 @@ write("") write(str(value)) write("\n") - dispatch[IntType] = dump_int + dispatch[int] = dump_int if _bool_is_builtin: def dump_bool(self, value, write): @@ -642,19 +642,19 @@ write("") write(str(int(value))) write("\n") - dispatch[LongType] = dump_long + dispatch[long] = dump_long def dump_double(self, value, write): write("") write(repr(value)) write("\n") - dispatch[FloatType] = dump_double + dispatch[float] = dump_double def dump_string(self, value, write, escape=escape): write("") write(escape(value)) write("\n") - dispatch[StringType] = dump_string + dispatch[str] = dump_string if unicode: def dump_unicode(self, value, write, escape=escape): @@ -662,7 +662,7 @@ write("") write(escape(value)) write("\n") - dispatch[UnicodeType] = dump_unicode + dispatch[unicode] = dump_unicode def dump_array(self, value, write): i = id(value) @@ -675,8 +675,8 @@ dump(v, write) write("\n") del self.memo[i] - dispatch[TupleType] = dump_array - dispatch[ListType] = dump_array + dispatch[tuple] = dump_array + dispatch[list] = dump_array def dump_struct(self, value, write, escape=escape): i = id(value) @@ -687,8 +687,8 @@ write("\n") for k, v in value.items(): write("\n") - if type(k) is not StringType: - if unicode and type(k) is UnicodeType: + if type(k) is not str: + if unicode and type(k) is unicode: k = k.encode(self.encoding) else: raise TypeError, "dictionary key must be string" @@ -697,7 +697,7 @@ write("\n") write("\n") del self.memo[i] - dispatch[DictType] = dump_struct + dispatch[dict] = dump_struct def dump_instance(self, value, write): # check for special wrappers @@ -1010,12 +1010,12 @@ where necessary. """ - assert isinstance(params, TupleType) or isinstance(params, Fault),\ + assert isinstance(params, tuple) or isinstance(params, Fault),\ "argument must be tuple or Fault instance" if isinstance(params, Fault): methodresponse = 1 - elif methodresponse and isinstance(params, TupleType): + elif methodresponse and isinstance(params, tuple): assert len(params) == 1, "response tuple must be a singleton" if not encoding: @@ -1036,7 +1036,7 @@ # standard XML-RPC wrappings if methodname: # a method call - if not isinstance(methodname, StringType): + if not isinstance(methodname, str): methodname = methodname.encode(encoding) data = ( xmlheader, @@ -1168,7 +1168,7 @@ def get_host_info(self, host): x509 = {} - if isinstance(host, TupleType): + if isinstance(host, tuple): host, x509 = host import urllib @@ -1218,7 +1218,7 @@ host, extra_headers, x509 = self.get_host_info(host) connection.putheader("Host", host) if extra_headers: - if isinstance(extra_headers, DictType): + if isinstance(extra_headers, dict): extra_headers = extra_headers.items() for key, value in extra_headers: connection.putheader(key, value) From rhettinger at users.sourceforge.net Mon Feb 7 16:28:49 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Feb 7 16:28:54 2005 Subject: [Python-checkins] python/dist/src/Lib pickle.py, 1.161, 1.162 xmlrpclib.py, 1.37, 1.38 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8169 Modified Files: pickle.py xmlrpclib.py Log Message: Revert previous checkin. Index: pickle.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pickle.py,v retrieving revision 1.161 retrieving revision 1.162 diff -u -d -r1.161 -r1.162 --- pickle.py 7 Feb 2005 14:16:20 -0000 1.161 +++ pickle.py 7 Feb 2005 15:28:45 -0000 1.162 @@ -288,7 +288,7 @@ # Check for a class with a custom metaclass; treat as regular class try: - issc = issubclass(t, type) + issc = issubclass(t, TypeType) except TypeError: # t is not a class (old Boost; see SF #502085) issc = 0 if issc: @@ -313,12 +313,12 @@ (t.__name__, obj)) # Check for string returned by reduce(), meaning "save as global" - if type(rv) is str: + if type(rv) is StringType: self.save_global(obj, rv) return # Assert that reduce() returned a tuple - if type(rv) is not tuple: + if type(rv) is not TupleType: raise PicklingError("%s must return string or tuple" % reduce) # Assert that it returned an appropriately sized tuple @@ -347,7 +347,7 @@ # This API is called by some subclasses # Assert that args is a tuple or None - if not isinstance(args, tuple): + if not isinstance(args, TupleType): raise PicklingError("args from reduce() should be a tuple") # Assert that func is callable @@ -425,7 +425,7 @@ def save_none(self, obj): self.write(NONE) - dispatch[type(None)] = save_none + dispatch[NoneType] = save_none def save_bool(self, obj): if self.proto >= 2: @@ -456,7 +456,7 @@ return # Text pickle, or int too big to fit in signed 4-byte format. self.write(INT + repr(obj) + '\n') - dispatch[int] = save_int + dispatch[IntType] = save_int def save_long(self, obj, pack=struct.pack): if self.proto >= 2: @@ -468,14 +468,14 @@ self.write(LONG4 + pack("d', obj)) else: self.write(FLOAT + repr(obj) + '\n') - dispatch[float] = save_float + dispatch[FloatType] = save_float def save_string(self, obj, pack=struct.pack): if self.bin: @@ -487,7 +487,7 @@ else: self.write(STRING + repr(obj) + '\n') self.memoize(obj) - dispatch[str] = save_string + dispatch[StringType] = save_string def save_unicode(self, obj, pack=struct.pack): if self.bin: @@ -501,7 +501,7 @@ self.memoize(obj) dispatch[UnicodeType] = save_unicode - if str == UnicodeType: + if StringType == UnicodeType: # This is true for Jython def save_string(self, obj, pack=struct.pack): unicode = obj.isunicode() @@ -527,7 +527,7 @@ else: self.write(STRING + repr(obj) + '\n') self.memoize(obj) - dispatch[str] = save_string + dispatch[StringType] = save_string def save_tuple(self, obj): write = self.write @@ -580,7 +580,7 @@ self.write(TUPLE) self.memoize(obj) - dispatch[tuple] = save_tuple + dispatch[TupleType] = save_tuple # save_empty_tuple() isn't used by anything in Python 2.3. However, I # found a Pickler subclass in Zope3 that calls it, so it's not harmless @@ -599,7 +599,7 @@ self.memoize(obj) self._batch_appends(iter(obj)) - dispatch[list] = save_list + dispatch[ListType] = save_list # Keep in synch with cPickle's BATCHSIZE. Nothing will break if it gets # out of synch, though. @@ -648,7 +648,7 @@ self.memoize(obj) self._batch_setitems(obj.iteritems()) - dispatch[dict] = save_dict + dispatch[DictionaryType] = save_dict if not PyStringMap is None: dispatch[PyStringMap] = save_dict @@ -770,7 +770,7 @@ dispatch[ClassType] = save_global dispatch[FunctionType] = save_global dispatch[BuiltinFunctionType] = save_global - dispatch[type] = save_global + dispatch[TypeType] = save_global # Pickling helpers Index: xmlrpclib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xmlrpclib.py,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- xmlrpclib.py 7 Feb 2005 14:16:21 -0000 1.37 +++ xmlrpclib.py 7 Feb 2005 15:28:45 -0000 1.38 @@ -138,7 +138,7 @@ import re, string, time, operator -from types import InstanceType +from types import * # -------------------------------------------------------------------- # Internal stuff @@ -348,8 +348,8 @@ """ def __init__(self, value=0): - if not isinstance(value, str): - if not isinstance(value, (tuple, time.struct_time)): + if not isinstance(value, StringType): + if not isinstance(value, (TupleType, time.struct_time)): if value == 0: value = time.time() value = time.localtime(value) @@ -618,7 +618,7 @@ if not self.allow_none: raise TypeError, "cannot marshal None unless allow_none is enabled" write("") - dispatch[type(None)] = dump_nil + dispatch[NoneType] = dump_nil def dump_int(self, value, write): # in case ints are > 32 bits @@ -627,7 +627,7 @@ write("") write(str(value)) write("\n") - dispatch[int] = dump_int + dispatch[IntType] = dump_int if _bool_is_builtin: def dump_bool(self, value, write): @@ -642,19 +642,19 @@ write("") write(str(int(value))) write("\n") - dispatch[long] = dump_long + dispatch[LongType] = dump_long def dump_double(self, value, write): write("") write(repr(value)) write("\n") - dispatch[float] = dump_double + dispatch[FloatType] = dump_double def dump_string(self, value, write, escape=escape): write("") write(escape(value)) write("\n") - dispatch[str] = dump_string + dispatch[StringType] = dump_string if unicode: def dump_unicode(self, value, write, escape=escape): @@ -662,7 +662,7 @@ write("") write(escape(value)) write("\n") - dispatch[unicode] = dump_unicode + dispatch[UnicodeType] = dump_unicode def dump_array(self, value, write): i = id(value) @@ -675,8 +675,8 @@ dump(v, write) write("\n") del self.memo[i] - dispatch[tuple] = dump_array - dispatch[list] = dump_array + dispatch[TupleType] = dump_array + dispatch[ListType] = dump_array def dump_struct(self, value, write, escape=escape): i = id(value) @@ -687,8 +687,8 @@ write("\n") for k, v in value.items(): write("\n") - if type(k) is not str: - if unicode and type(k) is unicode: + if type(k) is not StringType: + if unicode and type(k) is UnicodeType: k = k.encode(self.encoding) else: raise TypeError, "dictionary key must be string" @@ -697,7 +697,7 @@ write("\n") write("\n") del self.memo[i] - dispatch[dict] = dump_struct + dispatch[DictType] = dump_struct def dump_instance(self, value, write): # check for special wrappers @@ -1010,12 +1010,12 @@ where necessary. """ - assert isinstance(params, tuple) or isinstance(params, Fault),\ + assert isinstance(params, TupleType) or isinstance(params, Fault),\ "argument must be tuple or Fault instance" if isinstance(params, Fault): methodresponse = 1 - elif methodresponse and isinstance(params, tuple): + elif methodresponse and isinstance(params, TupleType): assert len(params) == 1, "response tuple must be a singleton" if not encoding: @@ -1036,7 +1036,7 @@ # standard XML-RPC wrappings if methodname: # a method call - if not isinstance(methodname, str): + if not isinstance(methodname, StringType): methodname = methodname.encode(encoding) data = ( xmlheader, @@ -1168,7 +1168,7 @@ def get_host_info(self, host): x509 = {} - if isinstance(host, tuple): + if isinstance(host, TupleType): host, x509 = host import urllib @@ -1218,7 +1218,7 @@ host, extra_headers, x509 = self.get_host_info(host) connection.putheader("Host", host) if extra_headers: - if isinstance(extra_headers, dict): + if isinstance(extra_headers, DictType): extra_headers = extra_headers.items() for key, value in extra_headers: connection.putheader(key, value) From rhettinger at users.sourceforge.net Mon Feb 7 20:32:52 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Feb 7 20:32:57 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_peepholer.py, 1.9, 1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29047/Lib/test Modified Files: test_peepholer.py Log Message: Adopt Skip's idea to optimize lists of constants in the context of a "in" or "not in" test. Index: test_peepholer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_peepholer.py,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- test_peepholer.py 6 Feb 2005 22:05:42 -0000 1.9 +++ test_peepholer.py 7 Feb 2005 19:32:38 -0000 1.10 @@ -135,7 +135,8 @@ def test_set_conversion(self): for line in ( - 'x in (1,2,3)', + 'x in [1,2,3]', + 'x in (1,2,3)', 'x not in (1,2,3)', 'not x in (1,2,3)', 'not x not in (1,2,3)', From rhettinger at users.sourceforge.net Mon Feb 7 20:33:13 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Feb 7 20:33:16 2005 Subject: [Python-checkins] python/dist/src/Python compile.c,2.341,2.342 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29047/Python Modified Files: compile.c Log Message: Adopt Skip's idea to optimize lists of constants in the context of a "in" or "not in" test. Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.341 retrieving revision 2.342 diff -u -d -r2.341 -r2.342 --- compile.c 6 Feb 2005 22:05:38 -0000 2.341 +++ compile.c 7 Feb 2005 19:32:29 -0000 2.342 @@ -397,7 +397,9 @@ The consts table must still be in list form so that the new constant (c1, c2, ... cn) can be appended. Called with codestr pointing to the first LOAD_CONST. - Bails out with no change if one or more of the LOAD_CONSTs is missing. */ + Bails out with no change if one or more of the LOAD_CONSTs is missing. + Also works for BUILD_LIST when followed by an "in" or "not in" test. +*/ static int tuple_of_constants(unsigned char *codestr, int n, PyObject *consts) { @@ -406,7 +408,7 @@ /* Pre-conditions */ assert(PyList_CheckExact(consts)); - assert(codestr[n*3] == BUILD_TUPLE); + assert(codestr[n*3] == BUILD_TUPLE || codestr[n*3] == BUILD_LIST); assert(GETARG(codestr, (n*3)) == n); for (i=0 ; i= 0 && j <= lastlc && - ISBASICBLOCK(blocks, h, 3*(j+1)) && + (opcode == BUILD_TUPLE && + ISBASICBLOCK(blocks, h, 3*(j+1)) || + opcode == BUILD_LIST && + codestr[i+3]==COMPARE_OP && + ISBASICBLOCK(blocks, h, 3*(j+2)) && + (GETARG(codestr,i+3)==6 || GETARG(codestr,i+3)==7)) && tuple_of_constants(&codestr[h], j, consts)) { assert(codestr[i] == LOAD_CONST); cumlc = 1; break; } - /* Intentional fallthrough */ - case BUILD_LIST: - j = GETARG(codestr, i); if (codestr[i+3] != UNPACK_SEQUENCE || !ISBASICBLOCK(blocks,i,6) || j != GETARG(codestr, i+3)) From gvanrossum at users.sourceforge.net Tue Feb 8 03:08:00 2005 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue Feb 8 03:08:04 2005 Subject: [Python-checkins] python/dist/src/Python pystate.c,2.38,2.39 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1875 Modified Files: pystate.c Log Message: Close the discussion in SF bug 1069160. Index: pystate.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/pystate.c,v retrieving revision 2.38 retrieving revision 2.39 diff -u -d -r2.38 -r2.39 --- pystate.c 8 Nov 2004 04:30:21 -0000 2.38 +++ pystate.c 8 Feb 2005 02:07:57 -0000 2.39 @@ -320,7 +320,7 @@ /* Asynchronously raise an exception in a thread. Requested by Just van Rossum and Alex Martelli. - To prevent naive misuse, you must write your own exception + To prevent naive misuse, you must write your own extension to call this. Must be called with the GIL held. Returns the number of tstates modified; if it returns a number greater than one, you're in trouble, and you should call it again @@ -332,6 +332,7 @@ PyInterpreterState *interp = tstate->interp; PyThreadState *p; int count = 0; + HEAD_LOCK(); for (p = interp->tstate_head; p != NULL; p = p->next) { if (p->thread_id != id) continue; @@ -340,6 +341,7 @@ p->async_exc = exc; count += 1; } + HEAD_UNLOCK(); return count; } From anthonybaxter at users.sourceforge.net Tue Feb 8 06:57:24 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Feb 8 06:57:27 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.167, 1.831.4.168 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15389/Misc Modified Files: Tag: release23-maint NEWS Log Message: news update for 2.3.5 final Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.167 retrieving revision 1.831.4.168 diff -u -d -r1.831.4.167 -r1.831.4.168 --- NEWS 3 Feb 2005 14:59:43 -0000 1.831.4.167 +++ NEWS 8 Feb 2005 05:57:20 -0000 1.831.4.168 @@ -7,7 +7,7 @@ What's New in Python 2.3.5? ============================== -*Release date: XX-XXX-2005* +*Release date: 08-FEB-2005* Core and builtins ----------------- @@ -21,6 +21,9 @@ disables recursive traversal through instance attributes, which can be exploited in various ways. +- Bug #1114776. Applied a fix to the copy.py fix in 2.3.5rc1 to deal + with types that don't have an __mro__. + What's New in Python 2.3.5rc1? ============================== From fdrake at users.sourceforge.net Tue Feb 8 06:58:07 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Feb 8 06:58:10 2005 Subject: [Python-checkins] python/dist/src/Include patchlevel.h, 2.74.4.13, 2.74.4.14 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15602 Modified Files: Tag: release23-maint patchlevel.h Log Message: bump version number Index: patchlevel.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/patchlevel.h,v retrieving revision 2.74.4.13 retrieving revision 2.74.4.14 diff -u -d -r2.74.4.13 -r2.74.4.14 --- patchlevel.h 25 Jan 2005 07:53:30 -0000 2.74.4.13 +++ patchlevel.h 8 Feb 2005 05:58:05 -0000 2.74.4.14 @@ -22,8 +22,8 @@ #define PY_MAJOR_VERSION 2 #define PY_MINOR_VERSION 3 #define PY_MICRO_VERSION 5 -#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_GAMMA -#define PY_RELEASE_SERIAL 1 +#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL +#define PY_RELEASE_SERIAL 0 /* Version as a string */ #define PY_VERSION "2.3.5c1" From fdrake at users.sourceforge.net Tue Feb 8 07:01:56 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Feb 8 07:01:58 2005 Subject: [Python-checkins] python/dist/src/Doc/commontex license.tex, 1.1.2.2, 1.1.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/commontex In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16432 Modified Files: Tag: release23-maint license.tex Log Message: add 2.3.5 to the history and licensing info Index: license.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/commontex/license.tex,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -d -r1.1.2.2 -r1.1.2.3 --- license.tex 31 Mar 2004 08:02:55 -0000 1.1.2.2 +++ license.tex 8 Feb 2005 06:01:50 -0000 1.1.2.3 @@ -45,6 +45,7 @@ \linev{2.3.2}{2.3.1}{2003}{PSF}{yes} \linev{2.3.3}{2.3.2}{2003}{PSF}{yes} \linev{2.3.4}{2.3.3}{2004}{PSF}{yes} + \linev{2.3.5}{2.3.4}{2005}{PSF}{yes} \end{tablev} \note{GPL-compatible doesn't mean that we're distributing From fdrake at users.sourceforge.net Tue Feb 8 07:13:22 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Feb 8 07:13:24 2005 Subject: [Python-checkins] python/dist/src/Doc/commontex boilerplate.tex, 1.1.2.10, 1.1.2.11 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/commontex In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18166 Modified Files: Tag: release23-maint boilerplate.tex Log Message: set release date in the docs Index: boilerplate.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/commontex/boilerplate.tex,v retrieving revision 1.1.2.10 retrieving revision 1.1.2.11 diff -u -d -r1.1.2.10 -r1.1.2.11 --- boilerplate.tex 25 Jan 2005 15:16:49 -0000 1.1.2.10 +++ boilerplate.tex 8 Feb 2005 06:13:18 -0000 1.1.2.11 @@ -6,5 +6,5 @@ } %\date{\today} -\date{January 26, 2005} % XXX update before final release! +\date{February 8, 2005} % XXX update before final release! \input{patchlevel} % include Python version information From fdrake at users.sourceforge.net Tue Feb 8 07:41:38 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Feb 8 07:41:50 2005 Subject: [Python-checkins] python/dist/src/Doc/commontex license.tex, 1.6, 1.6.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/commontex In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22166 Modified Files: Tag: release24-maint license.tex Log Message: add 2.3.5, 2.4 to the history and licensing info Index: license.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/commontex/license.tex,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -u -d -r1.6 -r1.6.2.1 --- license.tex 31 Aug 2004 13:24:08 -0000 1.6 +++ license.tex 8 Feb 2005 06:41:20 -0000 1.6.2.1 @@ -45,6 +45,8 @@ \linev{2.3.2}{2.3.1}{2003}{PSF}{yes} \linev{2.3.3}{2.3.2}{2003}{PSF}{yes} \linev{2.3.4}{2.3.3}{2004}{PSF}{yes} + \linev{2.3.5}{2.3.4}{2005}{PSF}{yes} + \linev{2.4}{2.3}{2004}{PSF}{yes} \end{tablev} \note{GPL-compatible doesn't mean that we're distributing From fdrake at users.sourceforge.net Tue Feb 8 07:42:41 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Feb 8 07:42:45 2005 Subject: [Python-checkins] python/dist/src/Doc/commontex license.tex, 1.6, 1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/commontex In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22387 Modified Files: license.tex Log Message: add 2.3.5, 2.4 to the history and licensing info Index: license.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/commontex/license.tex,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- license.tex 31 Aug 2004 13:24:08 -0000 1.6 +++ license.tex 8 Feb 2005 06:42:39 -0000 1.7 @@ -45,6 +45,8 @@ \linev{2.3.2}{2.3.1}{2003}{PSF}{yes} \linev{2.3.3}{2.3.2}{2003}{PSF}{yes} \linev{2.3.4}{2.3.3}{2004}{PSF}{yes} + \linev{2.3.5}{2.3.4}{2005}{PSF}{yes} + \linev{2.4}{2.3}{2004}{PSF}{yes} \end{tablev} \note{GPL-compatible doesn't mean that we're distributing From rhettinger at users.sourceforge.net Tue Feb 8 09:05:16 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Feb 8 09:05:19 2005 Subject: [Python-checkins] python/dist/src/Lib rfc822.py,1.78,1.79 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4108 Modified Files: rfc822.py Log Message: Wholistic code cleanup / modernization: * Use += * Replace loop logic with str.splitlines equivalent * Don't use variable names that shadow tuple, list, and str * Use dict.get instead of equivalent try/except * Minor loop logic simplications Index: rfc822.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/rfc822.py,v retrieving revision 1.78 retrieving revision 1.79 diff -u -d -r1.78 -r1.79 --- rfc822.py 22 Sep 2004 17:17:31 -0000 1.78 +++ rfc822.py 8 Feb 2005 08:05:13 -0000 1.79 @@ -90,8 +90,6 @@ fp.tell() except (AttributeError, IOError): seekable = 0 - else: - seekable = 1 self.fp = fp self.seekable = seekable self.startofheaders = None @@ -134,7 +132,7 @@ """ self.dict = {} self.unixfrom = '' - self.headers = list = [] + self.headers = lst = [] self.status = '' headerseen = "" firstline = 1 @@ -161,7 +159,7 @@ firstline = 0 if headerseen and line[0] in ' \t': # It's a continuation line. - list.append(line) + lst.append(line) x = (self.dict[headerseen] + "\n " + line.strip()) self.dict[headerseen] = x.strip() continue @@ -174,7 +172,7 @@ headerseen = self.isheader(line) if headerseen: # It's a legal header line, save it. - list.append(line) + lst.append(line) self.dict[headerseen] = line[len(headerseen)+1:].strip() continue else: @@ -202,8 +200,7 @@ i = line.find(':') if i > 0: return line[:i].lower() - else: - return None + return None def islast(self, line): """Determine whether a line is a legal end of RFC 2822 headers. @@ -235,7 +232,7 @@ """ name = name.lower() + ':' n = len(name) - list = [] + lst = [] hit = 0 for line in self.headers: if line[:n].lower() == name: @@ -243,8 +240,8 @@ elif not line[:1].isspace(): hit = 0 if hit: - list.append(line) - return list + lst.append(line) + return lst def getfirstmatchingheader(self, name): """Get the first header line matching name. @@ -254,7 +251,7 @@ """ name = name.lower() + ':' n = len(name) - list = [] + lst = [] hit = 0 for line in self.headers: if hit: @@ -263,8 +260,8 @@ elif line[:n].lower() == name: hit = 1 if hit: - list.append(line) - return list + lst.append(line) + return lst def getrawheader(self, name): """A higher-level interface to getfirstmatchingheader(). @@ -275,11 +272,11 @@ occur. """ - list = self.getfirstmatchingheader(name) - if not list: + lst = self.getfirstmatchingheader(name) + if not lst: return None - list[0] = list[0][len(name) + 1:] - return ''.join(list) + lst[0] = lst[0][len(name) + 1:] + return ''.join(lst) def getheader(self, name, default=None): """Get the header value for a name. @@ -288,10 +285,7 @@ header value for a given header name, or None if it doesn't exist. This uses the dictionary version which finds the *last* such header. """ - try: - return self.dict[name.lower()] - except KeyError: - return default + return self.dict.get(name.lower(), default) get = getheader def getheaders(self, name): @@ -399,9 +393,8 @@ del self[name] # Won't fail if it doesn't exist self.dict[name.lower()] = value text = name + ": " + value - lines = text.split("\n") - for line in lines: - self.headers.append(line + "\n") + self.headers.extend(text.splitlines(True)) + self.headers.append('\n') def __delitem__(self, name): """Delete all occurrences of a specific header, if it is present.""" @@ -411,7 +404,7 @@ del self.dict[name] name = name + ':' n = len(name) - list = [] + lst = [] hit = 0 for i in range(len(self.headers)): line = self.headers[i] @@ -420,8 +413,8 @@ elif not line[:1].isspace(): hit = 0 if hit: - list.append(i) - for i in reversed(list): + lst.append(i) + for i in reversed(lst): del self.headers[i] def setdefault(self, name, default=""): @@ -430,9 +423,8 @@ return self.dict[lowername] else: text = name + ": " + default - lines = text.split("\n") - for line in lines: - self.headers.append(line + "\n") + self.headers.extend(text.splitlines(True)) + self.headers.append('\n') self.dict[lowername] = default return default @@ -473,29 +465,28 @@ # XXX The inverses of the parse functions may also be useful. -def unquote(str): +def unquote(s): """Remove quotes from a string.""" - if len(str) > 1: - if str.startswith('"') and str.endswith('"'): - return str[1:-1].replace('\\\\', '\\').replace('\\"', '"') - if str.startswith('<') and str.endswith('>'): - return str[1:-1] - return str + if len(s) > 1: + if s.startswith('"') and s.endswith('"'): + return s[1:-1].replace('\\\\', '\\').replace('\\"', '"') + if s.startswith('<') and s.endswith('>'): + return s[1:-1] + return s -def quote(str): +def quote(s): """Add quotes around a string.""" - return str.replace('\\', '\\\\').replace('"', '\\"') + return s.replace('\\', '\\\\').replace('"', '\\"') def parseaddr(address): """Parse an address into a (realname, mailaddr) tuple.""" a = AddressList(address) - list = a.addresslist - if not list: + lst = a.addresslist + if not lst: return (None, None) - else: - return list[0] + return lst[0] class AddrlistClass: @@ -543,12 +534,10 @@ Returns a list containing all of the addresses. """ result = [] - while 1: + ad = self.getaddress() + while ad: + result += ad ad = self.getaddress() - if ad: - result += ad - else: - break return result def getaddress(self): @@ -581,11 +570,11 @@ returnlist = [] fieldlen = len(self.field) - self.pos = self.pos + 1 + self.pos += 1 while self.pos < len(self.field): self.gotonext() if self.pos < fieldlen and self.field[self.pos] == ';': - self.pos = self.pos + 1 + self.pos += 1 break returnlist = returnlist + self.getaddress() @@ -602,11 +591,11 @@ if plist: returnlist = [(' '.join(self.commentlist), plist[0])] elif self.field[self.pos] in self.specials: - self.pos = self.pos + 1 + self.pos += 1 self.gotonext() if self.pos < len(self.field) and self.field[self.pos] == ',': - self.pos = self.pos + 1 + self.pos += 1 return returnlist def getrouteaddr(self): @@ -618,7 +607,7 @@ return expectroute = 0 - self.pos = self.pos + 1 + self.pos += 1 self.gotonext() adlist = "" while self.pos < len(self.field): @@ -626,16 +615,16 @@ self.getdomain() expectroute = 0 elif self.field[self.pos] == '>': - self.pos = self.pos + 1 + self.pos += 1 break elif self.field[self.pos] == '@': - self.pos = self.pos + 1 + self.pos += 1 expectroute = 1 elif self.field[self.pos] == ':': - self.pos = self.pos + 1 + self.pos += 1 else: adlist = self.getaddrspec() - self.pos = self.pos + 1 + self.pos += 1 break self.gotonext() @@ -649,7 +638,7 @@ while self.pos < len(self.field): if self.field[self.pos] == '.': aslist.append('.') - self.pos = self.pos + 1 + self.pos += 1 elif self.field[self.pos] == '"': aslist.append('"%s"' % self.getquote()) elif self.field[self.pos] in self.atomends: @@ -661,7 +650,7 @@ return ''.join(aslist) aslist.append('@') - self.pos = self.pos + 1 + self.pos += 1 self.gotonext() return ''.join(aslist) + self.getdomain() @@ -670,13 +659,13 @@ sdlist = [] while self.pos < len(self.field): if self.field[self.pos] in self.LWS: - self.pos = self.pos + 1 + self.pos += 1 elif self.field[self.pos] == '(': self.commentlist.append(self.getcomment()) elif self.field[self.pos] == '[': sdlist.append(self.getdomainliteral()) elif self.field[self.pos] == '.': - self.pos = self.pos + 1 + self.pos += 1 sdlist.append('.') elif self.field[self.pos] in self.atomends: break @@ -701,13 +690,13 @@ slist = [''] quote = 0 - self.pos = self.pos + 1 + self.pos += 1 while self.pos < len(self.field): if quote == 1: slist.append(self.field[self.pos]) quote = 0 elif self.field[self.pos] in endchars: - self.pos = self.pos + 1 + self.pos += 1 break elif allowcomments and self.field[self.pos] == '(': slist.append(self.getcomment()) @@ -715,7 +704,7 @@ quote = 1 else: slist.append(self.field[self.pos]) - self.pos = self.pos + 1 + self.pos += 1 return ''.join(slist) @@ -746,7 +735,7 @@ if self.field[self.pos] in atomends: break else: atomlist.append(self.field[self.pos]) - self.pos = self.pos + 1 + self.pos += 1 return ''.join(atomlist) @@ -761,7 +750,7 @@ while self.pos < len(self.field): if self.field[self.pos] in self.LWS: - self.pos = self.pos + 1 + self.pos += 1 elif self.field[self.pos] == '"': plist.append(self.getquote()) elif self.field[self.pos] == '(': @@ -930,16 +919,15 @@ else: tzsign = 1 tzoffset = tzsign * ( (tzoffset//100)*3600 + (tzoffset % 100)*60) - tuple = (yy, mm, dd, thh, tmm, tss, 0, 1, 0, tzoffset) - return tuple + return (yy, mm, dd, thh, tmm, tss, 0, 1, 0, tzoffset) def parsedate(data): """Convert a time string to a time tuple.""" t = parsedate_tz(data) - if type(t) == type( () ): - return t[:9] - else: return t + if t is None: + return t + return t[:9] def mktime_tz(data): @@ -965,10 +953,10 @@ timeval = time.time() timeval = time.gmtime(timeval) return "%s, %02d %s %04d %02d:%02d:%02d GMT" % ( - ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"][timeval[6]], + ("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")[timeval[6]], timeval[2], - ["Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][timeval[1]-1], + ("Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")[timeval[1]-1], timeval[0], timeval[3], timeval[4], timeval[5]) @@ -1002,7 +990,7 @@ m.rewindbody() n = 0 while f.readline(): - n = n + 1 + n += 1 print 'Lines:', n print '-'*70 print 'len =', len(m) From doerwalter at users.sourceforge.net Tue Feb 8 11:10:04 2005 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Tue Feb 8 11:10:09 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_codecs.py, 1.19, 1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25913/Lib/test Modified Files: test_codecs.py Log Message: Fix stupid typo: Don't read from a writer. Index: test_codecs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_codecs.py,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- test_codecs.py 4 Feb 2005 14:15:34 -0000 1.19 +++ test_codecs.py 8 Feb 2005 10:10:01 -0000 1.20 @@ -161,11 +161,11 @@ def test_badbom(self): s = StringIO.StringIO("\xff\xff") - f = codecs.getwriter(self.encoding)(s) + f = codecs.getreader(self.encoding)(s) self.assertRaises(UnicodeError, f.read) s = StringIO.StringIO("\xff\xff\xff\xff") - f = codecs.getwriter(self.encoding)(s) + f = codecs.getreader(self.encoding)(s) self.assertRaises(UnicodeError, f.read) def test_partial(self): From anthonybaxter at users.sourceforge.net Tue Feb 8 12:37:03 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Feb 8 12:37:06 2005 Subject: [Python-checkins] python/dist/src/Include patchlevel.h, 2.74.4.14, 2.74.4.15 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26982/Include Modified Files: Tag: release23-maint patchlevel.h Log Message: 2.3.5 final Index: patchlevel.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/patchlevel.h,v retrieving revision 2.74.4.14 retrieving revision 2.74.4.15 diff -u -d -r2.74.4.14 -r2.74.4.15 --- patchlevel.h 8 Feb 2005 05:58:05 -0000 2.74.4.14 +++ patchlevel.h 8 Feb 2005 11:37:01 -0000 2.74.4.15 @@ -26,7 +26,7 @@ #define PY_RELEASE_SERIAL 0 /* Version as a string */ -#define PY_VERSION "2.3.5c1" +#define PY_VERSION "2.3.5" /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. Use this for numeric comparisons, e.g. #if PY_VERSION_HEX >= ... */ From anthonybaxter at users.sourceforge.net Tue Feb 8 13:57:57 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Feb 8 13:58:00 2005 Subject: [Python-checkins] python/dist/src/Lib/idlelib NEWS.txt, 1.23.4.17, 1.23.4.18 idlever.py, 1.15.4.7, 1.15.4.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29154/Lib/idlelib Modified Files: Tag: release23-maint NEWS.txt idlever.py Log Message: 2.3.5 final Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.23.4.17 retrieving revision 1.23.4.18 diff -u -d -r1.23.4.17 -r1.23.4.18 --- NEWS.txt 25 Jan 2005 13:08:15 -0000 1.23.4.17 +++ NEWS.txt 8 Feb 2005 12:57:54 -0000 1.23.4.18 @@ -1,6 +1,11 @@ What's New in IDLE 1.0.5rc1? ============================ +*Release date: 08-Feb-2005* + +What's New in IDLE 1.0.5rc1? +============================ + *Release date: 26-Jan-2005* - On OpenBSD, terminating IDLE with ctrl-c from the command line caused a Index: idlever.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/idlever.py,v retrieving revision 1.15.4.7 retrieving revision 1.15.4.8 diff -u -d -r1.15.4.7 -r1.15.4.8 --- idlever.py 25 Jan 2005 12:51:43 -0000 1.15.4.7 +++ idlever.py 8 Feb 2005 12:57:54 -0000 1.15.4.8 @@ -1 +1 @@ -IDLE_VERSION = "1.0.5c1" +IDLE_VERSION = "1.0.5" From anthonybaxter at users.sourceforge.net Tue Feb 8 13:57:57 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Feb 8 13:58:00 2005 Subject: [Python-checkins] python/dist/src/PCbuild BUILDno.txt, 1.51.4.8, 1.51.4.9 pythoncore.dsp, 1.48.4.8, 1.48.4.9 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29154/PCbuild Modified Files: Tag: release23-maint BUILDno.txt pythoncore.dsp Log Message: 2.3.5 final Index: BUILDno.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/BUILDno.txt,v retrieving revision 1.51.4.8 retrieving revision 1.51.4.9 diff -u -d -r1.51.4.8 -r1.51.4.9 --- BUILDno.txt 25 Jan 2005 12:51:43 -0000 1.51.4.8 +++ BUILDno.txt 8 Feb 2005 12:57:55 -0000 1.51.4.9 @@ -33,6 +33,8 @@ Windows Python BUILD numbers ---------------------------- + 62 2.3.5 + 08-Feb-2005 61 2.3.5c1 26-Jan-2005 60 2.4 Index: pythoncore.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/Attic/pythoncore.dsp,v retrieving revision 1.48.4.8 retrieving revision 1.48.4.9 diff -u -d -r1.48.4.8 -r1.48.4.9 --- pythoncore.dsp 25 Jan 2005 22:05:22 -0000 1.48.4.8 +++ pythoncore.dsp 8 Feb 2005 12:57:55 -0000 1.48.4.9 @@ -258,7 +258,7 @@ # Begin Source File SOURCE=..\Modules\getbuildinfo.c -# ADD CPP /D BUILD=61 +# ADD CPP /D BUILD=62 # End Source File # Begin Source File From anthonybaxter at users.sourceforge.net Tue Feb 8 13:57:57 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Feb 8 13:58:01 2005 Subject: [Python-checkins] python/dist/src/Misc/RPM python-2.3.spec, 1.2.12.15, 1.2.12.16 Message-ID: Update of /cvsroot/python/python/dist/src/Misc/RPM In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29154/Misc/RPM Modified Files: Tag: release23-maint python-2.3.spec Log Message: 2.3.5 final Index: python-2.3.spec =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/RPM/Attic/python-2.3.spec,v retrieving revision 1.2.12.15 retrieving revision 1.2.12.16 diff -u -d -r1.2.12.15 -r1.2.12.16 --- python-2.3.spec 5 Jan 2005 04:59:29 -0000 1.2.12.15 +++ python-2.3.spec 8 Feb 2005 12:57:54 -0000 1.2.12.16 @@ -33,7 +33,7 @@ ################################# %define name python -%define version 2.3.4 +%define version 2.3.5 %define libvers 2.3 %define release 4pydotorg %define __prefix /usr From anthonybaxter at users.sourceforge.net Tue Feb 8 14:24:30 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Feb 8 14:24:34 2005 Subject: [Python-checkins] python/dist/src/Lib/idlelib NEWS.txt, 1.23.4.18, 1.23.4.19 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7142/Lib/idlelib Modified Files: Tag: release23-maint NEWS.txt Log Message: damn Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.23.4.18 retrieving revision 1.23.4.19 diff -u -d -r1.23.4.18 -r1.23.4.19 --- NEWS.txt 8 Feb 2005 12:57:54 -0000 1.23.4.18 +++ NEWS.txt 8 Feb 2005 13:24:28 -0000 1.23.4.19 @@ -1,5 +1,5 @@ -What's New in IDLE 1.0.5rc1? -============================ +What's New in IDLE 1.0.5? +========================= *Release date: 08-Feb-2005* From anthonybaxter at users.sourceforge.net Tue Feb 8 14:27:55 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Feb 8 14:27:57 2005 Subject: [Python-checkins] python/dist/src/PCbuild python20.wse, 1.133.4.10, 1.133.4.11 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8488/PCbuild Modified Files: Tag: release23-maint python20.wse Log Message: 2.3.5 final Index: python20.wse =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/python20.wse,v retrieving revision 1.133.4.10 retrieving revision 1.133.4.11 diff -u -d -r1.133.4.10 -r1.133.4.11 --- python20.wse 25 Jan 2005 22:07:51 -0000 1.133.4.10 +++ python20.wse 8 Feb 2005 13:27:52 -0000 1.133.4.11 @@ -1,7 +1,7 @@ Document Type: WSE item: Global Version=9.0 - Title=Python 2.3.5c1 + Title=Python 2.3.5 Flags=00010100 Languages=65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Japanese Font Name=MS Gothic @@ -20,9 +20,9 @@ Patch Memory=4000 MIF PDF Version=1.0 MIF SMS Version=2.0 - EXE Filename=Python-2.3.5c1.exe + EXE Filename=Python-2.3.5.exe Dialogs Version=8 - Version File=2.3.5c1 + Version File=2.3.5 Version Description=Python Programming Language Version Copyright=©2001-2005 Python Software Foundation Version Company=Python Software Foundation @@ -81,7 +81,7 @@ end item: Set Variable Variable=PYVER_STRING - Value=2.3.5c1 + Value=2.3.5 end item: Remark end From gvanrossum at users.sourceforge.net Tue Feb 8 16:01:39 2005 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Tue Feb 8 16:01:42 2005 Subject: [Python-checkins] python/dist/src/Python pystate.c,2.38,2.38.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15462 Modified Files: Tag: release24-maint pystate.c Log Message: Backport 2.39: Close the discussion in SF bug 1069160. Index: pystate.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/pystate.c,v retrieving revision 2.38 retrieving revision 2.38.2.1 diff -u -d -r2.38 -r2.38.2.1 --- pystate.c 8 Nov 2004 04:30:21 -0000 2.38 +++ pystate.c 8 Feb 2005 15:01:35 -0000 2.38.2.1 @@ -320,7 +320,7 @@ /* Asynchronously raise an exception in a thread. Requested by Just van Rossum and Alex Martelli. - To prevent naive misuse, you must write your own exception + To prevent naive misuse, you must write your own extension to call this. Must be called with the GIL held. Returns the number of tstates modified; if it returns a number greater than one, you're in trouble, and you should call it again @@ -332,6 +332,7 @@ PyInterpreterState *interp = tstate->interp; PyThreadState *p; int count = 0; + HEAD_LOCK(); for (p = interp->tstate_head; p != NULL; p = p->next) { if (p->thread_id != id) continue; @@ -340,6 +341,7 @@ p->async_exc = exc; count += 1; } + HEAD_UNLOCK(); return count; } From rhettinger at users.sourceforge.net Tue Feb 8 16:39:15 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Feb 8 16:39:18 2005 Subject: [Python-checkins] python/dist/src/Lib rfc822.py,1.79,1.80 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31557 Modified Files: rfc822.py Log Message: Convert splitlines to for-loop (handles case where input does not have a trailing newline). Index: rfc822.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/rfc822.py,v retrieving revision 1.79 retrieving revision 1.80 diff -u -d -r1.79 -r1.80 --- rfc822.py 8 Feb 2005 08:05:13 -0000 1.79 +++ rfc822.py 8 Feb 2005 15:39:11 -0000 1.80 @@ -393,8 +393,8 @@ del self[name] # Won't fail if it doesn't exist self.dict[name.lower()] = value text = name + ": " + value - self.headers.extend(text.splitlines(True)) - self.headers.append('\n') + for line in text.split("\n"): + self.headers.append(line + "\n") def __delitem__(self, name): """Delete all occurrences of a specific header, if it is present.""" @@ -423,8 +423,8 @@ return self.dict[lowername] else: text = name + ": " + default - self.headers.extend(text.splitlines(True)) - self.headers.append('\n') + for line in text.split("\n"): + self.headers.append(line + "\n") self.dict[lowername] = default return default From beta_nunessdkdj8374 at hotmail.com Wed Feb 9 13:05:43 2005 From: beta_nunessdkdj8374 at hotmail.com (Roberta Nunes) Date: Wed Feb 9 13:05:58 2005 Subject: [Python-checkins] =?iso-8859-1?q?MALA_DIRETA_DE_E-MAILS_SEGMENTA?= =?iso-8859-1?q?DOS_GEN=C9RICOS_MIRADOS_FOCADOS_http=3A//www=2Egueb?= =?iso-8859-1?q?=2Ede/segmails?= Message-ID: <20050209120555.E9A431E4003@bag.python.org> .. MALA DIRETA DE E-MAILS SEGMENTADOS GEN?RICOS MIRADOS FOCADOS http://www.gueb.de/segmails @ Listas de E-Mails Mala Direta E-mails Segmentados ou E-mails Gen?ricos Marketing Direto Divulga??o Visite agora: http://www.gueb.de/segmails . CADASTRAMENTO DE HOME PAGES EM MILHARES DE SITES DE BUSCAS NO BRASIL E NO MUNDO . MALA DIRETA DE EMAILS SEGMENTADA . MALA DIRETA DE EMAILS GEN?RICA . VALIDA??O DE LISTAS E-MAILS . SMS (MENSANGENS A CELULAR ) . ICQ 9(MENSANGENS A ICQ ) Visite agora: http://www.gueb.de/segmails bulk mail,mailing list,e-maling,listas,cadastros,email,emaiu,emeiu,emaiu,emaius e-mails para mala direta,e-mails,emails,email,emaio,listas de e-mails,mailing list,listagem,cadastros,listas de e-mail,marketing direto,mmv,publicidade,divulga??o,mp3,e-mails segmentados,home page,bulk mail,playboy,propaganda,maladireta,maling list,sexo E-mails para Mala Direta/Marketing Direto gen?ricos ou segmentados por ramo de atividade,sexo,idade,cidade,estado Visite agora: http://www.gueb.de/segmails Cadastramento de Home Page em sites de buscas,otimiza??o,dicas e downloads gr?tis From tmick at users.sourceforge.net Wed Feb 9 22:03:52 2005 From: tmick at users.sourceforge.net (tmick@users.sourceforge.net) Date: Wed Feb 9 22:03:57 2005 Subject: [Python-checkins] python/dist/src/PC python_nt.rc,1.30,1.31 Message-ID: Update of /cvsroot/python/python/dist/src/PC In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13204 Modified Files: python_nt.rc Log Message: Update PSF copyright year to 2005. Index: python_nt.rc =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/python_nt.rc,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- python_nt.rc 11 May 2004 18:14:05 -0000 1.30 +++ python_nt.rc 9 Feb 2005 21:03:47 -0000 1.31 @@ -61,7 +61,7 @@ VALUE "FileDescription", "Python Core\0" VALUE "FileVersion", PYTHON_VERSION VALUE "InternalName", "Python DLL\0" - VALUE "LegalCopyright", "Copyright © 2001-2004 Python Software Foundation. Copyright © 2000 BeOpen.com. Copyright © 1995-2001 CNRI. Copyright © 1991-1995 SMC.\0" + VALUE "LegalCopyright", "Copyright © 2001-2005 Python Software Foundation. Copyright © 2000 BeOpen.com. Copyright © 1995-2001 CNRI. Copyright © 1991-1995 SMC.\0" VALUE "OriginalFilename", PYTHON_DLL_NAME "\0" VALUE "ProductName", "Python\0" VALUE "ProductVersion", PYTHON_VERSION From rhettinger at users.sourceforge.net Thu Feb 10 00:19:30 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Feb 10 00:19:40 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libstdtypes.tex, 1.174, 1.175 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5578 Modified Files: libstdtypes.tex Log Message: SF bug #1119700: list extend() accepts args besides lists Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.174 retrieving revision 1.175 diff -u -d -r1.174 -r1.175 --- libstdtypes.tex 26 Jan 2005 22:40:08 -0000 1.174 +++ libstdtypes.tex 9 Feb 2005 23:19:25 -0000 1.175 @@ -1075,7 +1075,7 @@ 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. +\item[(3)] \var{x} can be any iterable object. \item[(4)] Raises \exception{ValueError} when \var{x} is not found in \var{s}. When a negative index is passed as the second or third parameter From rhettinger at users.sourceforge.net Thu Feb 10 00:23:12 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Feb 10 00:23:15 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libstdtypes.tex, 1.170.2.4, 1.170.2.5 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6755 Modified Files: Tag: release24-maint libstdtypes.tex Log Message: SF bug #1119700: list extend() accepts args besides lists Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.170.2.4 retrieving revision 1.170.2.5 diff -u -d -r1.170.2.4 -r1.170.2.5 --- libstdtypes.tex 26 Jan 2005 22:46:26 -0000 1.170.2.4 +++ libstdtypes.tex 9 Feb 2005 23:23:10 -0000 1.170.2.5 @@ -1075,7 +1075,7 @@ 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. +\item[(3)] \var{x} can be any iterable object. \item[(4)] Raises \exception{ValueError} when \var{x} is not found in \var{s}. When a negative index is passed as the second or third parameter From rhettinger at users.sourceforge.net Thu Feb 10 02:42:41 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Feb 10 02:42:45 2005 Subject: [Python-checkins] python/dist/src/Python compile.c,2.343,2.344 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31172 Modified Files: compile.c Log Message: Remove the set conversion which didn't work with: [] in (0,) Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.343 retrieving revision 2.344 diff -u -d -r2.343 -r2.344 --- compile.c 9 Feb 2005 21:24:51 -0000 2.343 +++ compile.c 10 Feb 2005 01:42:32 -0000 2.344 @@ -542,53 +542,6 @@ return 1; } -/* Replace LOAD_CONST tuple with LOAD_CONST frozenset in the context - of a single-use constant for "in" and "not in" tests. -*/ -int -try_set_conversion(unsigned char *codestr, PyObject *consts) -{ - PyObject *newconst, *constant; - int arg, len_consts; - - /* Pre-conditions */ - assert(PyList_CheckExact(consts)); - assert(codestr[0] == LOAD_CONST); - assert(codestr[3] == COMPARE_OP); - assert(GETARG(codestr, 3) == 6 || GETARG(codestr, 3) == 7); - - /* Attempt to convert constant to a frozenset. Bail-out with no - changes if the tuple contains unhashable values. */ - arg = GETARG(codestr, 0); - constant = PyList_GET_ITEM(consts, arg); - if (constant->ob_type != &PyTuple_Type) - return 0; - newconst = PyObject_CallFunctionObjArgs( - (PyObject *)&PyFrozenSet_Type, constant, NULL); - if (newconst == NULL) { - PyErr_Clear(); - return 0; - } - - /* Append new constant onto consts list or replace existing constant - if there are no other references to it.*/ - if (constant->ob_refcnt == 1) { - PyList_SET_ITEM(consts, arg, newconst); - Py_DECREF(constant); - return 1; - } - len_consts = PyList_GET_SIZE(consts); - if (PyList_Append(consts, newconst)) { - Py_DECREF(newconst); - return 0; - } - Py_DECREF(newconst); - - /* Write new LOAD_CONST newconst on top of LOAD_CONST oldconst */ - SETARG(codestr, 0, len_consts); - return 1; -} - static unsigned int * markblocks(unsigned char *code, int len) { @@ -714,15 +667,10 @@ /* not a is b --> a is not b not a in b --> a not in b not a is not b --> a is b - not a not in b --> a in b - - a in c --> a in frozenset(c) - where c is a constant tuple of hashable values + not a not in b --> a in b */ case COMPARE_OP: j = GETARG(codestr, i); - if (lastlc >= 1 && (j == 6 || j == 7) && ISBASICBLOCK(blocks,i-3,6)) - try_set_conversion(&codestr[i-3], consts); if (j < 6 || j > 9 || codestr[i+3] != UNARY_NOT || !ISBASICBLOCK(blocks,i,4)) From astrand at users.sourceforge.net Thu Feb 10 09:32:52 2005 From: astrand at users.sourceforge.net (astrand@users.sourceforge.net) Date: Thu Feb 10 09:32:56 2005 Subject: [Python-checkins] python/dist/src/Lib subprocess.py,1.14,1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30793 Modified Files: subprocess.py Log Message: Patch from Leandro Lucarella: replaced: var == None and var != None with var is None and var is not None and type(var) == int with instanceof(var, int) ...as recomended in PEP 8 [1]. Index: subprocess.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/subprocess.py,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- subprocess.py 7 Feb 2005 14:16:21 -0000 1.14 +++ subprocess.py 10 Feb 2005 08:32:50 -0000 1.15 @@ -623,42 +623,42 @@ """Construct and return tupel with IO objects: p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite """ - if stdin == None and stdout == None and stderr == None: + if stdin is None and stdout is None and stderr is None: return (None, None, None, None, None, None) p2cread, p2cwrite = None, None c2pread, c2pwrite = None, None errread, errwrite = None, None - if stdin == None: + if stdin is None: p2cread = GetStdHandle(STD_INPUT_HANDLE) elif stdin == PIPE: p2cread, p2cwrite = CreatePipe(None, 0) # Detach and turn into fd p2cwrite = p2cwrite.Detach() p2cwrite = msvcrt.open_osfhandle(p2cwrite, 0) - elif type(stdin) == int: + elif isinstance(stdin, int): p2cread = msvcrt.get_osfhandle(stdin) else: # Assuming file-like object p2cread = msvcrt.get_osfhandle(stdin.fileno()) p2cread = self._make_inheritable(p2cread) - if stdout == None: + if stdout is None: c2pwrite = GetStdHandle(STD_OUTPUT_HANDLE) elif stdout == PIPE: c2pread, c2pwrite = CreatePipe(None, 0) # Detach and turn into fd c2pread = c2pread.Detach() c2pread = msvcrt.open_osfhandle(c2pread, 0) - elif type(stdout) == int: + elif isinstance(stdout, int): c2pwrite = msvcrt.get_osfhandle(stdout) else: # Assuming file-like object c2pwrite = msvcrt.get_osfhandle(stdout.fileno()) c2pwrite = self._make_inheritable(c2pwrite) - if stderr == None: + if stderr is None: errwrite = GetStdHandle(STD_ERROR_HANDLE) elif stderr == PIPE: errread, errwrite = CreatePipe(None, 0) @@ -667,7 +667,7 @@ errread = msvcrt.open_osfhandle(errread, 0) elif stderr == STDOUT: errwrite = c2pwrite - elif type(stderr) == int: + elif isinstance(stderr, int): errwrite = msvcrt.get_osfhandle(stderr) else: # Assuming file-like object @@ -715,7 +715,7 @@ # Process startup details default_startupinfo = STARTUPINFO() - if startupinfo == None: + if startupinfo is None: startupinfo = default_startupinfo if not None in (p2cread, c2pwrite, errwrite): startupinfo.dwFlags |= STARTF_USESTDHANDLES @@ -774,18 +774,18 @@ # output pipe are maintained in this process or else the # pipe will not close when the child process exits and the # ReadFile will hang. - if p2cread != None: + if p2cread is not None: p2cread.Close() - if c2pwrite != None: + if c2pwrite is not None: c2pwrite.Close() - if errwrite != None: + if errwrite is not None: errwrite.Close() def poll(self): """Check if child process has terminated. Returns returncode attribute.""" - if self.returncode == None: + if self.returncode is None: if WaitForSingleObject(self._handle, 0) == WAIT_OBJECT_0: self.returncode = GetExitCodeProcess(self._handle) _active.remove(self) @@ -795,7 +795,7 @@ def wait(self): """Wait for child process to terminate. Returns returncode attribute.""" - if self.returncode == None: + if self.returncode is None: obj = WaitForSingleObject(self._handle, INFINITE) self.returncode = GetExitCodeProcess(self._handle) _active.remove(self) @@ -831,7 +831,7 @@ stderr_thread.start() if self.stdin: - if input != None: + if input is not None: self.stdin.write(input) self.stdin.close() @@ -841,9 +841,9 @@ stderr_thread.join() # All data exchanged. Translate lists into strings. - if stdout != None: + if stdout is not None: stdout = stdout[0] - if stderr != None: + if stderr is not None: stderr = stderr[0] # Translate newlines, if requested. We cannot let the file @@ -871,33 +871,33 @@ c2pread, c2pwrite = None, None errread, errwrite = None, None - if stdin == None: + if stdin is None: pass elif stdin == PIPE: p2cread, p2cwrite = os.pipe() - elif type(stdin) == int: + elif isinstance(stdin, int): p2cread = stdin else: # Assuming file-like object p2cread = stdin.fileno() - if stdout == None: + if stdout is None: pass elif stdout == PIPE: c2pread, c2pwrite = os.pipe() - elif type(stdout) == int: + elif isinstance(stdout, int): c2pwrite = stdout else: # Assuming file-like object c2pwrite = stdout.fileno() - if stderr == None: + if stderr is None: pass elif stderr == PIPE: errread, errwrite = os.pipe() elif stderr == STDOUT: errwrite = c2pwrite - elif type(stderr) == int: + elif isinstance(stderr, int): errwrite = stderr else: # Assuming file-like object @@ -942,7 +942,7 @@ if shell: args = ["/bin/sh", "-c"] + args - if executable == None: + if executable is None: executable = args[0] # For transferring possible exec failure from child to parent @@ -985,13 +985,13 @@ if close_fds: self._close_fds(but=errpipe_write) - if cwd != None: + if cwd is not None: os.chdir(cwd) if preexec_fn: apply(preexec_fn) - if env == None: + if env is None: os.execvp(executable, args) else: os.execvpe(executable, args, env) @@ -1042,7 +1042,7 @@ def poll(self): """Check if child process has terminated. Returns returncode attribute.""" - if self.returncode == None: + if self.returncode is None: try: pid, sts = os.waitpid(self.pid, os.WNOHANG) if pid == self.pid: @@ -1055,7 +1055,7 @@ def wait(self): """Wait for child process to terminate. Returns returncode attribute.""" - if self.returncode == None: + if self.returncode is None: pid, sts = os.waitpid(self.pid, 0) self._handle_exitstatus(sts) return self.returncode @@ -1117,9 +1117,9 @@ stderr.append(data) # All data exchanged. Translate lists into strings. - if stdout != None: + if stdout is not None: stdout = ''.join(stdout) - if stderr != None: + if stderr is not None: stderr = ''.join(stderr) # Translate newlines, if requested. We cannot let the file From akuchling at users.sourceforge.net Thu Feb 10 14:24:52 2005 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Thu Feb 10 14:24:54 2005 Subject: [Python-checkins] python/dist/src/Lib popen2.py,1.30,1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23112/Lib Modified Files: popen2.py Log Message: Fix typo Index: popen2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/popen2.py,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- popen2.py 11 Oct 2004 18:12:20 -0000 1.30 +++ popen2.py 10 Feb 2005 13:24:49 -0000 1.31 @@ -213,7 +213,7 @@ raise ValueError("wrote %r read %r" % (teststr, got)) got = e.read() if got: - raise ValueError("unexected %r on stderr" % (got,)) + raise ValueError("unexpected %r on stderr" % (got,)) for inst in _active[:]: inst.wait() if _active: From akuchling at users.sourceforge.net Thu Feb 10 14:24:52 2005 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Thu Feb 10 14:24:55 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_popen2.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23112/Lib/test Modified Files: test_popen2.py Log Message: Fix typo Index: test_popen2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_popen2.py,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- test_popen2.py 12 Feb 2004 17:35:11 -0000 1.8 +++ test_popen2.py 10 Feb 2005 13:24:50 -0000 1.9 @@ -62,7 +62,7 @@ raise ValueError("wrote %r read %r" % (teststr, got)) got = e.read() if got: - raise ValueError("unexected %r on stderr" % (got,)) + raise ValueError("unexpected %r on stderr" % (got,)) for inst in popen2._active[:]: inst.wait() if popen2._active: From akuchling at users.sourceforge.net Thu Feb 10 14:46:17 2005 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Thu Feb 10 14:46:19 2005 Subject: [Python-checkins] python/dist/src/Lib popen2.py,1.30,1.30.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv720/Lib Modified Files: Tag: release24-maint popen2.py Log Message: Fix typo Index: popen2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/popen2.py,v retrieving revision 1.30 retrieving revision 1.30.2.1 diff -u -d -r1.30 -r1.30.2.1 --- popen2.py 11 Oct 2004 18:12:20 -0000 1.30 +++ popen2.py 10 Feb 2005 13:46:14 -0000 1.30.2.1 @@ -213,7 +213,7 @@ raise ValueError("wrote %r read %r" % (teststr, got)) got = e.read() if got: - raise ValueError("unexected %r on stderr" % (got,)) + raise ValueError("unexpected %r on stderr" % (got,)) for inst in _active[:]: inst.wait() if _active: From akuchling at users.sourceforge.net Thu Feb 10 14:46:17 2005 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Thu Feb 10 14:46:21 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_popen2.py, 1.8, 1.8.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv720/Lib/test Modified Files: Tag: release24-maint test_popen2.py Log Message: Fix typo Index: test_popen2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_popen2.py,v retrieving revision 1.8 retrieving revision 1.8.4.1 diff -u -d -r1.8 -r1.8.4.1 --- test_popen2.py 12 Feb 2004 17:35:11 -0000 1.8 +++ test_popen2.py 10 Feb 2005 13:46:14 -0000 1.8.4.1 @@ -62,7 +62,7 @@ raise ValueError("wrote %r read %r" % (teststr, got)) got = e.read() if got: - raise ValueError("unexected %r on stderr" % (got,)) + raise ValueError("unexpected %r on stderr" % (got,)) for inst in popen2._active[:]: inst.wait() if popen2._active: From fdrake at users.sourceforge.net Thu Feb 10 19:33:32 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu Feb 10 19:33:41 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_xmlrpc.py,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18795/Lib/test Modified Files: test_xmlrpc.py Log Message: accept datetime.datetime instances when marshalling; dateTime.iso8601 elements still unmarshal into xmlrpclib.DateTime objects Index: test_xmlrpc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_xmlrpc.py,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- test_xmlrpc.py 5 Jun 2004 12:33:27 -0000 1.5 +++ test_xmlrpc.py 10 Feb 2005 18:33:30 -0000 1.6 @@ -1,3 +1,4 @@ +import datetime import sys import unittest import xmlrpclib @@ -12,6 +13,11 @@ 'boolean': xmlrpclib.False, 'unicode': u'\u4000\u6000\u8000', u'ukey\u4000': 'regular value', + 'datetime1': xmlrpclib.DateTime('20050210T11:41:23'), + 'datetime2': xmlrpclib.DateTime( + (2005, 02, 10, 11, 41, 23, 0, 1, -1)), + 'datetime3': xmlrpclib.DateTime( + datetime.datetime(2005, 02, 10, 11, 41, 23)), }] class XMLRPCTestCase(unittest.TestCase): @@ -20,6 +26,17 @@ self.assertEquals(alist, xmlrpclib.loads(xmlrpclib.dumps((alist,)))[0][0]) + def test_dump_bare_datetime(self): + # This checks that an unwrapped datetime object can be handled + # by the marshalling code. This can't be done via + # test_dump_load() since the unmarshaller doesn't produce base + # datetime instances. + dt = datetime.datetime(2005, 02, 10, 11, 41, 23) + s = xmlrpclib.dumps((dt,)) + r, m = xmlrpclib.loads(s) + self.assertEquals(r, (xmlrpclib.DateTime('20050210T11:41:23'),)) + self.assertEquals(m, None) + def test_dump_big_long(self): self.assertRaises(OverflowError, xmlrpclib.dumps, (2L**99,)) From fdrake at users.sourceforge.net Thu Feb 10 19:33:32 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu Feb 10 19:33:42 2005 Subject: [Python-checkins] python/dist/src/Lib xmlrpclib.py,1.38,1.39 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18795/Lib Modified Files: xmlrpclib.py Log Message: accept datetime.datetime instances when marshalling; dateTime.iso8601 elements still unmarshal into xmlrpclib.DateTime objects Index: xmlrpclib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xmlrpclib.py,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- xmlrpclib.py 7 Feb 2005 15:28:45 -0000 1.38 +++ xmlrpclib.py 10 Feb 2005 18:33:29 -0000 1.39 @@ -149,6 +149,11 @@ unicode = None # unicode support not available try: + import datetime +except ImportError: + datetime = None + +try: _bool_is_builtin = False.__class__.__name__ == "bool" except NameError: _bool_is_builtin = 0 @@ -349,7 +354,10 @@ def __init__(self, value=0): if not isinstance(value, StringType): - if not isinstance(value, (TupleType, time.struct_time)): + if datetime and isinstance(value, datetime.datetime): + self.value = value.strftime("%Y%m%dT%H:%M:%S") + return + elif not isinstance(value, (TupleType, time.struct_time)): if value == 0: value = time.time() value = time.localtime(value) @@ -699,6 +707,13 @@ del self.memo[i] dispatch[DictType] = dump_struct + if datetime: + def dump_datetime(self, value, write): + write("") + write(value.strftime("%Y%m%dT%H:%M:%S")) + write("\n") + dispatch[datetime.datetime] = dump_datetime + def dump_instance(self, value, write): # check for special wrappers if value.__class__ in WRAPPERS: From tim.peters at gmail.com Thu Feb 10 20:09:34 2005 From: tim.peters at gmail.com (Tim Peters) Date: Thu Feb 10 20:09:37 2005 Subject: [Python-checkins] python/dist/src/Lib xmlrpclib.py,1.38,1.39 In-Reply-To: References: Message-ID: <1f7befae0502101109161da0d1@mail.gmail.com> [fdrake@users.sourceforge.net] > Modified Files: > xmlrpclib.py > Log Message: > accept datetime.datetime instances when marshalling; > dateTime.iso8601 elements still unmarshal into xmlrpclib.DateTime objects > > Index: xmlrpclib.py ... > + if datetime and isinstance(value, datetime.datetime): > + self.value = value.strftime("%Y%m%dT%H:%M:%S") > + return ... [and similarly later] ... Fred, is there a reason to avoid datetime.datetime's .isoformat() method here? Like so: >>> import datetime >>> print datetime.datetime(2005, 2, 10, 14, 0, 8).isoformat() 2005-02-10T14:00:08 A possible downside is that you'll also get fractional seconds if the instance records a non-zero .microseconds value. From fdrake at acm.org Thu Feb 10 20:23:59 2005 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Thu Feb 10 20:24:11 2005 Subject: [Python-checkins] python/dist/src/Lib xmlrpclib.py,1.38,1.39 In-Reply-To: <1f7befae0502101109161da0d1@mail.gmail.com> References: <1f7befae0502101109161da0d1@mail.gmail.com> Message-ID: <200502101423.59995.fdrake@acm.org> On Thursday 10 February 2005 14:09, Tim Peters wrote: > Fred, is there a reason to avoid datetime.datetime's .isoformat() > method here? Like so: Yes. The XML-RPC spec is quite vague. It claims that the dates are in ISO 8601 format, but doesn't say anything more about it. The example shows a string without hyphens (but with colons), so I stuck with eactly that. > A possible downside is that you'll also get fractional seconds if the > instance records a non-zero .microseconds value. There's nothing in the XML-RPC spec about the resolution of time, so, again, I'd rather be conservative in what we generate. -Fred -- Fred L. Drake, Jr. From bcannon at users.sourceforge.net Thu Feb 10 21:40:36 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Thu Feb 10 21:40:40 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_peepholer.py, 1.10, 1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5299/Lib/test Modified Files: test_peepholer.py Log Message: Remove set conversion optimization test (backed out of Python/compile.c in rev. 2.344). Index: test_peepholer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_peepholer.py,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- test_peepholer.py 7 Feb 2005 19:32:38 -0000 1.10 +++ test_peepholer.py 10 Feb 2005 20:40:29 -0000 1.11 @@ -133,17 +133,6 @@ asm = dis_single('a="x"*1000') self.assert_('(1000)' in asm) - def test_set_conversion(self): - for line in ( - 'x in [1,2,3]', - 'x in (1,2,3)', - 'x not in (1,2,3)', - 'not x in (1,2,3)', - 'not x not in (1,2,3)', - ): - asm = dis_single(line) - self.assert_('frozenset' in asm) - def test_elim_extra_return(self): # RETURN LOAD_CONST None RETURN --> RETURN def f(x): From bcannon at users.sourceforge.net Thu Feb 10 21:48:09 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Thu Feb 10 21:48:13 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1239, 1.1240 ACKS, 1.293, 1.294 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7187/Misc Modified Files: NEWS ACKS Log Message: Modified test for tzset to not rely on tm->tm_zone's existence. Also added sanity checks on tzname if HAVE_TZNAME defined. Closes bug #1096244. Thanks Gregory Bond. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1239 retrieving revision 1.1240 diff -u -d -r1.1239 -r1.1240 --- NEWS 5 Feb 2005 01:31:19 -0000 1.1239 +++ NEWS 10 Feb 2005 20:47:44 -0000 1.1240 @@ -161,6 +161,11 @@ ``-L/opt/local/lib`` for DarwinPorts) and CPPFLAGS (``-I/sw/include`` for Fink, ``-I/opt/local/include`` for DarwinPorts). +- Test in configure.in that checks for tzset no longer dependent on tm->tm_zone + to exist in the struct (not required by either ISO C nor the UNIX 2 spec). + Tests for sanity in tzname when HAVE_TZNAME defined were also defined. + Closes bug #1096244. Thanks Gregory Bond. + C API ----- Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.293 retrieving revision 1.294 diff -u -d -r1.293 -r1.294 --- ACKS 5 Feb 2005 01:31:18 -0000 1.293 +++ ACKS 10 Feb 2005 20:48:03 -0000 1.294 @@ -66,6 +66,7 @@ Paul Boddie Matthew Boedicker David Bolen +Gregory Bond Jurjen Bos Peter Bosch Eric Bouck From bcannon at users.sourceforge.net Thu Feb 10 21:48:27 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Thu Feb 10 21:48:30 2005 Subject: [Python-checkins] python/dist/src configure.in, 1.481, 1.482 configure, 1.468, 1.469 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7187 Modified Files: configure.in configure Log Message: Modified test for tzset to not rely on tm->tm_zone's existence. Also added sanity checks on tzname if HAVE_TZNAME defined. Closes bug #1096244. Thanks Gregory Bond. Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.481 retrieving revision 1.482 diff -u -d -r1.481 -r1.482 --- configure.in 23 Jan 2005 09:27:22 -0000 1.481 +++ configure.in 10 Feb 2005 20:45:37 -0000 1.482 @@ -2917,45 +2917,74 @@ [Define if poll() sets errno on invalid file descriptors.]) fi +# Before we can test tzset, we need to check if struct tm has a tm_zone +# (which is not required by ISO C or UNIX spec) and/or if we support +# tzname[] +AC_STRUCT_TIMEZONE -# tzset(3) exists and works like we expect it to +# check tzset(3) exists and works like we expect it to AC_MSG_CHECKING(for working tzset()) AC_CACHE_VAL(ac_cv_working_tzset, [ AC_TRY_RUN([ #include #include #include + +#if HAVE_TZNAME +extern char *tzname[]; +#endif + int main() { /* Note that we need to ensure that not only does tzset(3) do 'something' with localtime, but it works as documented in the library reference and as expected by the test suite. + This includes making sure that tzname is set properly if + tm->tm_zone does not exist since it is the alternative way + of getting timezone info. Red Hat 6.2 doesn't understand the southern hemisphere - after New Year's Day; it thinks swaps on that day. + after New Year's Day. */ - time_t groundhogday = 1044144000; /* GMT-based; well, it's a colony */ + time_t groundhogday = 1044144000; /* GMT-based */ time_t midyear = groundhogday + (365 * 24 * 3600 / 2); putenv("TZ=UTC+0"); tzset(); if (localtime(&groundhogday)->tm_hour != 0) exit(1); +#if HAVE_TZNAME + /* For UTC, tzname[1] is sometimes "", sometimes " " */ + if (strcmp(tzname[0], "UTC") || + (tzname[1][0] != 0 && tzname[1][0] != ' ')) + exit(1); +#endif putenv("TZ=EST+5EDT,M4.1.0,M10.5.0"); tzset(); if (localtime(&groundhogday)->tm_hour != 19) exit(1); +#if HAVE_TZNAME + if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT")) + exit(1); +#endif putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0"); tzset(); if (localtime(&groundhogday)->tm_hour != 11) exit(1); +#if HAVE_TZNAME + if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT")) + exit(1); +#endif + +#if HAVE_STRUCT_TM_TM_ZONE if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT")) exit(1); if (strcmp(localtime(&midyear)->tm_zone, "AEST")) exit(1); +#endif exit(0); } Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.468 retrieving revision 1.469 diff -u -d -r1.468 -r1.469 --- configure 23 Jan 2005 09:27:17 -0000 1.468 +++ configure 10 Feb 2005 20:45:41 -0000 1.469 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 1.480 . +# From configure.in Revision: 1.481 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59 for python 2.5. # @@ -976,7 +976,7 @@ else echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi - cd "$ac_popdir" [...2278 lines suppressed...] + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ @@ -20854,12 +21282,6 @@ fi;; esac done` || { (exit 1); exit 1; } - - if test x"$ac_file" != x-; then - { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} - rm -f "$ac_file" - fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF sed "$ac_vpsub From bcannon at users.sourceforge.net Thu Feb 10 23:47:17 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Thu Feb 10 23:47:20 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.18, 1.1193.2.19 ACKS, 1.289, 1.289.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24745/Misc Modified Files: Tag: release24-maint NEWS ACKS Log Message: Fix tzset() check to not require the existence of tm->tm_zone. Also added more sanity checks for tzname when HAVE_TZNAME is defined. Closes bug #1096244. Thanks Gregory Bond. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.18 retrieving revision 1.1193.2.19 diff -u -d -r1.1193.2.18 -r1.1193.2.19 --- NEWS 3 Feb 2005 15:00:18 -0000 1.1193.2.18 +++ NEWS 10 Feb 2005 22:47:08 -0000 1.1193.2.19 @@ -62,6 +62,12 @@ - term.h is now properly detected again. +- Check for tzset no longer dependent on tm->tm_zone to exist in the struct + (not required by either ISO C nor the UNIX 2 spec). + Tests for sanity in tzname when HAVE_TZNAME defined were also defined. + Closes bug #1096244. Thanks Gregory Bond. + + Windows ------- Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.289 retrieving revision 1.289.2.1 diff -u -d -r1.289 -r1.289.2.1 --- ACKS 10 Nov 2004 13:13:05 -0000 1.289 +++ ACKS 10 Feb 2005 22:47:13 -0000 1.289.2.1 @@ -64,6 +64,7 @@ Paul Boddie Matthew Boedicker David Bolen +Gregory Bond Jurjen Bos Peter Bosch Eric Bouck From bcannon at users.sourceforge.net Thu Feb 10 23:47:48 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Thu Feb 10 23:47:52 2005 Subject: [Python-checkins] python/dist/src configure.in, 1.475.2.5, 1.475.2.6 configure, 1.462.2.5, 1.462.2.6 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24745 Modified Files: Tag: release24-maint configure.in configure Log Message: Fix tzset() check to not require the existence of tm->tm_zone. Also added more sanity checks for tzname when HAVE_TZNAME is defined. Closes bug #1096244. Thanks Gregory Bond. Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.475.2.5 retrieving revision 1.475.2.6 diff -u -d -r1.475.2.5 -r1.475.2.6 --- configure.in 7 Jan 2005 13:17:33 -0000 1.475.2.5 +++ configure.in 10 Feb 2005 22:46:33 -0000 1.475.2.6 @@ -2917,45 +2917,74 @@ [Define if poll() sets errno on invalid file descriptors.]) fi +# Before we can test tzset, we need to check if struct tm has a tm_zone +# (which is not required by ISO C or UNIX spec) and/or if we support +# tzname[] +AC_STRUCT_TIMEZONE -# tzset(3) exists and works like we expect it to +# check tzset(3) exists and works like we expect it to AC_MSG_CHECKING(for working tzset()) AC_CACHE_VAL(ac_cv_working_tzset, [ AC_TRY_RUN([ #include #include #include + +#if HAVE_TZNAME +extern char *tzname[]; +#endif + int main() { /* Note that we need to ensure that not only does tzset(3) do 'something' with localtime, but it works as documented in the library reference and as expected by the test suite. + This includes making sure that tzname is set properly if + tm->tm_zone does not exist since it is the alternative way + of getting timezone info. Red Hat 6.2 doesn't understand the southern hemisphere - after New Year's Day; it thinks swaps on that day. + after New Year's Day. */ - time_t groundhogday = 1044144000; /* GMT-based; well, it's a colony */ + time_t groundhogday = 1044144000; /* GMT-based */ time_t midyear = groundhogday + (365 * 24 * 3600 / 2); putenv("TZ=UTC+0"); tzset(); if (localtime(&groundhogday)->tm_hour != 0) exit(1); +#if HAVE_TZNAME + /* For UTC, tzname[1] is sometimes "", sometimes " " */ + if (strcmp(tzname[0], "UTC") || + (tzname[1][0] != 0 && tzname[1][0] != ' ')) + exit(1); +#endif putenv("TZ=EST+5EDT,M4.1.0,M10.5.0"); tzset(); if (localtime(&groundhogday)->tm_hour != 19) exit(1); +#if HAVE_TZNAME + if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT")) + exit(1); +#endif putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0"); tzset(); if (localtime(&groundhogday)->tm_hour != 11) exit(1); +#if HAVE_TZNAME + if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT")) + exit(1); +#endif + +#if HAVE_STRUCT_TM_TM_ZONE if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT")) exit(1); if (strcmp(localtime(&midyear)->tm_zone, "AEST")) exit(1); +#endif exit(0); } Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.462.2.5 retrieving revision 1.462.2.6 diff -u -d -r1.462.2.5 -r1.462.2.6 --- configure 7 Jan 2005 13:17:33 -0000 1.462.2.5 +++ configure 10 Feb 2005 22:46:35 -0000 1.462.2.6 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 1.475.2.4 . +# From configure.in Revision: 1.475.2.5 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59 for python 2.4. # @@ -19748,8 +19748,201 @@ fi +# Before we can test tzset, we need to check if struct tm has a tm_zone +# (which is not required by ISO C or UNIX spec) and/or if we support +# tzname[] +echo "$as_me:$LINENO: checking for struct tm.tm_zone" >&5 +echo $ECHO_N "checking for struct tm.tm_zone... $ECHO_C" >&6 +if test "${ac_cv_member_struct_tm_tm_zone+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include <$ac_cv_struct_tm> -# tzset(3) exists and works like we expect it to + +int +main () +{ +static struct tm ac_aggr; +if (ac_aggr.tm_zone) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (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); }; } && + { 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_cv_member_struct_tm_tm_zone=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include <$ac_cv_struct_tm> + + +int +main () +{ +static struct tm ac_aggr; +if (sizeof ac_aggr.tm_zone) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (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); }; } && + { 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_cv_member_struct_tm_tm_zone=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_member_struct_tm_tm_zone=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_member_struct_tm_tm_zone" >&5 +echo "${ECHO_T}$ac_cv_member_struct_tm_tm_zone" >&6 +if test $ac_cv_member_struct_tm_tm_zone = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_TM_TM_ZONE 1 +_ACEOF + + +fi + +if test "$ac_cv_member_struct_tm_tm_zone" = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_TM_ZONE 1 +_ACEOF + +else + echo "$as_me:$LINENO: checking for tzname" >&5 +echo $ECHO_N "checking for tzname... $ECHO_C" >&6 +if test "${ac_cv_var_tzname+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#ifndef tzname /* For SGI. */ +extern char *tzname[]; /* RS6000 and others reject char **tzname. */ +#endif + +int +main () +{ +atoi(*tzname); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (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); }; } && + { ac_try='test -s conftest$ac_exeext' + { (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_cv_var_tzname=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_var_tzname=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_var_tzname" >&5 +echo "${ECHO_T}$ac_cv_var_tzname" >&6 + if test $ac_cv_var_tzname = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_TZNAME 1 +_ACEOF + + fi +fi + + +# check tzset(3) exists and works like we expect it to echo "$as_me:$LINENO: checking for working tzset()" >&5 echo $ECHO_N "checking for working tzset()... $ECHO_C" >&6 if test "${ac_cv_working_tzset+set}" = set; then @@ -19769,37 +19962,62 @@ #include #include #include + +#if HAVE_TZNAME +extern char *tzname[]; +#endif + int main() { /* Note that we need to ensure that not only does tzset(3) do 'something' with localtime, but it works as documented in the library reference and as expected by the test suite. + This includes making sure that tzname is set properly if + tm->tm_zone does not exist since it is the alternative way + of getting timezone info. Red Hat 6.2 doesn't understand the southern hemisphere - after New Year's Day; it thinks swaps on that day. + after New Year's Day. */ - time_t groundhogday = 1044144000; /* GMT-based; well, it's a colony */ + time_t groundhogday = 1044144000; /* GMT-based */ time_t midyear = groundhogday + (365 * 24 * 3600 / 2); putenv("TZ=UTC+0"); tzset(); if (localtime(&groundhogday)->tm_hour != 0) exit(1); +#if HAVE_TZNAME + /* For UTC, tzname[1] is sometimes "", sometimes " " */ + if (strcmp(tzname[0], "UTC") || + (tzname[1][0] != 0 && tzname[1][0] != ' ')) + exit(1); +#endif putenv("TZ=EST+5EDT,M4.1.0,M10.5.0"); tzset(); if (localtime(&groundhogday)->tm_hour != 19) exit(1); +#if HAVE_TZNAME + if (strcmp(tzname[0], "EST") || strcmp(tzname[1], "EDT")) + exit(1); +#endif putenv("TZ=AEST-10AEDT-11,M10.5.0,M3.5.0"); tzset(); if (localtime(&groundhogday)->tm_hour != 11) exit(1); +#if HAVE_TZNAME + if (strcmp(tzname[0], "AEST") || strcmp(tzname[1], "AEDT")) + exit(1); +#endif + +#if HAVE_STRUCT_TM_TM_ZONE if (strcmp(localtime(&groundhogday)->tm_zone, "AEDT")) exit(1); if (strcmp(localtime(&midyear)->tm_zone, "AEST")) exit(1); +#endif exit(0); } From fdrake at users.sourceforge.net Fri Feb 11 18:59:24 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri Feb 11 18:59:27 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_xmlrpc.py,1.6,1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18158/Lib/test Modified Files: test_xmlrpc.py Log Message: fix decoding in _stringify to not depend on the default encoding (closes SF bug #1115989) Index: test_xmlrpc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_xmlrpc.py,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- test_xmlrpc.py 10 Feb 2005 18:33:30 -0000 1.6 +++ test_xmlrpc.py 11 Feb 2005 17:59:08 -0000 1.7 @@ -4,6 +4,13 @@ import xmlrpclib from test import test_support +try: + unicode +except NameError: + have_unicode = False +else: + have_unicode = True + alist = [{'astring': 'foo@bar.baz.spam', 'afloat': 7283.43, 'anint': 2**20, @@ -56,6 +63,41 @@ xmlrpclib.loads(strg)[0][0]) self.assertRaises(TypeError, xmlrpclib.dumps, (arg1,)) + def test_default_encoding_issues(self): + # SF bug #1115989: wrong decoding in '_stringify' + utf8 = """ + + + abc \x95 + + + + + def \x96 + ghi \x97 + + + + + """ + old_encoding = sys.getdefaultencoding() + reload(sys) # ugh! + sys.setdefaultencoding("iso-8859-1") + try: + (s, d), m = xmlrpclib.loads(utf8) + finally: + sys.setdefaultencoding(old_encoding) + items = d.items() + if have_unicode: + self.assertEquals(s, u"abc \x95") + self.assert_(isinstance(s, unicode)) + self.assertEquals(items, [(u"def \x96", u"ghi \x97")]) + self.assert_(isinstance(items[0][0], unicode)) + self.assert_(isinstance(items[0][1], unicode)) + else: + self.assertEquals(s, "abc \xc2\x95") + self.assertEquals(items, [("def \xc2\x96", "ghi \xc2\x97")]) + def test_main(): test_support.run_unittest(XMLRPCTestCase) From fdrake at users.sourceforge.net Fri Feb 11 18:59:22 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri Feb 11 18:59:29 2005 Subject: [Python-checkins] python/dist/src/Lib xmlrpclib.py,1.39,1.40 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18158/Lib Modified Files: xmlrpclib.py Log Message: fix decoding in _stringify to not depend on the default encoding (closes SF bug #1115989) Index: xmlrpclib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xmlrpclib.py,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- xmlrpclib.py 10 Feb 2005 18:33:29 -0000 1.39 +++ xmlrpclib.py 11 Feb 2005 17:59:03 -0000 1.40 @@ -173,7 +173,7 @@ def _stringify(string): # convert to 7-bit ascii if possible try: - return str(string) + return string.encode("ascii") except UnicodeError: return string else: From fdrake at users.sourceforge.net Fri Feb 11 19:00:26 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri Feb 11 19:00:30 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_xmlrpc.py, 1.5, 1.5.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18573/Lib/test Modified Files: Tag: release24-maint test_xmlrpc.py Log Message: fix decoding in _stringify to not depend on the default encoding (closes SF bug #1115989) Index: test_xmlrpc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_xmlrpc.py,v retrieving revision 1.5 retrieving revision 1.5.4.1 diff -u -d -r1.5 -r1.5.4.1 --- test_xmlrpc.py 5 Jun 2004 12:33:27 -0000 1.5 +++ test_xmlrpc.py 11 Feb 2005 18:00:16 -0000 1.5.4.1 @@ -3,6 +3,13 @@ import xmlrpclib from test import test_support +try: + unicode +except NameError: + have_unicode = False +else: + have_unicode = True + alist = [{'astring': 'foo@bar.baz.spam', 'afloat': 7283.43, 'anint': 2**20, @@ -39,6 +46,41 @@ xmlrpclib.loads(strg)[0][0]) self.assertRaises(TypeError, xmlrpclib.dumps, (arg1,)) + def test_default_encoding_issues(self): + # SF bug #1115989: wrong decoding in '_stringify' + utf8 = """ + + + abc \x95 + + + + + def \x96 + ghi \x97 + + + + + """ + old_encoding = sys.getdefaultencoding() + reload(sys) # ugh! + sys.setdefaultencoding("iso-8859-1") + try: + (s, d), m = xmlrpclib.loads(utf8) + finally: + sys.setdefaultencoding(old_encoding) + items = d.items() + if have_unicode: + self.assertEquals(s, u"abc \x95") + self.assert_(isinstance(s, unicode)) + self.assertEquals(items, [(u"def \x96", u"ghi \x97")]) + self.assert_(isinstance(items[0][0], unicode)) + self.assert_(isinstance(items[0][1], unicode)) + else: + self.assertEquals(s, "abc \xc2\x95") + self.assertEquals(items, [("def \xc2\x96", "ghi \xc2\x97")]) + def test_main(): test_support.run_unittest(XMLRPCTestCase) From fdrake at users.sourceforge.net Fri Feb 11 19:00:26 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Fri Feb 11 19:00:35 2005 Subject: [Python-checkins] python/dist/src/Lib xmlrpclib.py,1.36,1.36.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18573/Lib Modified Files: Tag: release24-maint xmlrpclib.py Log Message: fix decoding in _stringify to not depend on the default encoding (closes SF bug #1115989) Index: xmlrpclib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xmlrpclib.py,v retrieving revision 1.36 retrieving revision 1.36.2.1 diff -u -d -r1.36 -r1.36.2.1 --- xmlrpclib.py 13 Oct 2004 06:48:37 -0000 1.36 +++ xmlrpclib.py 11 Feb 2005 17:59:58 -0000 1.36.2.1 @@ -168,7 +168,7 @@ def _stringify(string): # convert to 7-bit ascii if possible try: - return str(string) + return string.encode("ascii") except UnicodeError: return string else: From bcannon at users.sourceforge.net Sat Feb 12 23:02:07 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Feb 12 23:02:11 2005 Subject: [Python-checkins] python/nondist/peps pep-0339.txt, NONE, 1.1 pep-0000.txt, 1.299, 1.300 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7649 Modified Files: pep-0000.txt Added Files: pep-0339.txt Log Message: Added PEP 339, "How to Change CPython's Bytecode", by Brett Cannon. --- NEW FILE: pep-0339.txt --- PEP: 339 Title: How to Change CPython's Bytecode Version: $Revision: 1.1 $ Last-Modified: $Date: 2005/02/12 22:02:04 $ Author: Brett Cannon Status: Active Type: Informational Content-Type: text/x-rst Created: 02-Feb-2005 Post-History: 02-Feb-2005 Abstract ======== Python source code is compiled down to something called bytecode. This bytecode must implement enough semantics to perform the actions required by the Language Reference [#lang_ref]_. As such, knowing how to add, remove, or change the bytecode is important to do properly when changing the abilities of the Python language. This PEP covers how to accomplish this in the CPython implementation of the language (referred to as simply "Python" for the rest of this PEP). .. warning:: The guidelines outlined in this PEP apply to Python 2.4 and earlier. Current plans for Python 2.5 will lead to a significant change in how Python's bytecode is handled. This PEP will be updated once these planned changes are committed into CVS. Rationale ========= While changing Python's bytecode is not a frequent occurence, it still happens. Having the required steps documented in a single location should make experimentation with the bytecode easier since it is not necessarily obvious what the steps are to change the bytecode. This PEP, paired with PEP 306 [#PEP-306]_, should provide enough basic guidelines for handling any changes performed to the Python language itself in terms of syntactic changes that introduce new semantics. Checklist ========= This is a rough checklist of what files need to change and how they are involved with the bytecode. All paths are given from the viewpoint of ``/cvsroot/python/dist/src`` from CVS). This list should not be considered exhaustive nor to cover all possible situations. - ``Include/opcode.h`` This include file lists all known opcodes and associates each opcode name with a unique number. When adding a new opcode it is important to take note of the ``HAVE_ARGUMENT`` value. This ``#define``'s value specifies the value at which all opcodes greater than ``HAVE_ARGUMENT`` are expected to take an argument to the opcode. - ``Lib/opcode.py`` Lists all of the opcodes and their associated value. Used by the dis module [#dis]_ to map bytecode values to their names. - ``Python/ceval.c`` Contains the main interpreter loop. Code to handle the evalution of an opcode goes here. - ``Python/compile.c`` To make sure an opcode is actually used, this file must be altered. The emitting of all bytecode occurs here. - ``Lib/compiler/pyassem.py``, ``Lib/compiler/pycodegen.py`` The 'compiler' package [#compiler]_ needs to be altered to also reflect any changes to the bytecode. - ``Doc/lib/libdis.tex`` The documentation [#opcode_list]_ for the dis module contains a complete list of all the opcodes. - ``Python/import.c`` Defines the magic word (named ``MAGIC``) used in .pyc files to detect if the bytecode used matches the one used by the version of Python running. This number needs to be changed to make sure that the running interpreter does not try to execute bytecode that it does not know about. Suggestions for bytecode development ==================================== A few things can be done to make sure that development goes smoothly when experimenting with Python's bytecode. One is to delete all .py(c|o) files after each semantic change to Python/compile.c . That way all files will use any bytecode changes. Make sure to run the entire testing suite [#test-suite]_. Since the ``regrtest.py`` driver recompiles all source code before a test is run it acts a good test to make sure that no existing semantics are broken. Running parrotbench [#parrotbench]_ is also a good way to make sure existing semantics are not broken; this benchmark is practically a compliance test. Previous experiments ==================== This section lists known bytecode experiments that have not gone into Python. Skip Montanaro presented a paper at a Python workshop on a peephole optimizer [#skip-peephole]_. Michael Hudson has a non-active SourceForge project named Bytecodehacks [#Bytecodehacks]_ that provides functionality for playing with bytecode directly. An opcode to combine the functionality of LOAD_ATTR/CALL_FUNCTION was created named CALL_ATTR [#CALL_ATTR]_. Currently only works for classic classes and for new-style classes rough benchmarking showed an actual slowdown thanks to having to support both classic and new-style classes. References ========== .. [#lang_ref] Python Language Reference, van Rossum & Drake (http://docs.python.org/ref/ref.html) .. [#PEP-306] PEP 306, How to Change Python's Grammar, Hudson (http://www.python.org/peps/pep-0306.html) .. [#dis] dis Module (http://docs.python.org/lib/module-dis.html) .. [#compiler] 'compiler' Package (http://docs.python.org/lib/module-compiler.html) .. [#test-suite] 'test' Package (http://docs.python.org/lib/module-test.html) .. [#opcode_list] Python Byte Code Instructions (http://docs.python.org/lib/bytecodes.html) .. [#parrotbench] Parrotbench (ftp://ftp.python.org/pub/python/parrotbench/parrotbench.tgz, http://mail.python.org/pipermail/python-dev/2003-December/041527.html) .. [#skip-peephole] Skip Montanaro's Peephole Optimizer Paper (http://www.foretec.com/python/workshops/1998-11/proceedings/papers/montanaro/montanaro.html) .. [#Bytecodehacks] Bytecodehacks Project (http://bytecodehacks.sourceforge.net/bch-docs/bch/index.html) .. [#CALL_ATTR] CALL_ATTR opcode (http://www.python.org/sf/709744) 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.299 retrieving revision 1.300 diff -u -d -r1.299 -r1.300 --- pep-0000.txt 30 Jan 2005 03:08:02 -0000 1.299 +++ pep-0000.txt 12 Feb 2005 22:02:05 -0000 1.300 @@ -58,6 +58,7 @@ I 291 Backward Compatibility for Standard Library Norwitz I 306 How to Change Python's Grammar Hudson I 333 Python Web Server Gateway Interface v1.0 Eby + I 339 How to Change CPython's Bytecode Cannon I 3000 Python 3.0 Plans Kuchling, Cannon Accepted PEPs (accepted; may not be implemented yet) @@ -372,6 +373,7 @@ S 336 Make None Callable McClelland S 337 Logging Usage in the Standard Library Dubner S 338 Executing modules inside packages with '-m' Coghlan + I 339 How to Change CPython's Bytecode Cannon SR 666 Reject Foolish Indentation Creighton S 754 IEEE 754 Floating Point Special Values Warnes I 3000 Python 3.0 Plans Kuchling, Cannon @@ -401,7 +403,7 @@ Batista, Facundo facundo@taniquetil.com.ar Baxter, Anthony anthony@interlink.com.au Bellman, Thomas bellman+pep-divmod@lysator.liu.se - Cannon, Brett drifty@alum.berkeley.edu + Cannon, Brett brett@python.org Carlson, Josiah jcarlson@uci.edu Carroll, W Isaac icarroll@pobox.com Coghlan, Nick ncoghlan@email.com From bcannon at users.sourceforge.net Sun Feb 13 23:50:05 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Feb 13 23:50:21 2005 Subject: [Python-checkins] python/dist/src/Doc/inst inst.tex,1.59,1.60 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/inst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3121/Doc/inst Modified Files: inst.tex Log Message: Update references specifying "Macintosh" to mean OS X semantics and not Mac OS 9. Applies patch #1095802. Thanks Jack Jansen. Index: inst.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/inst/inst.tex,v retrieving revision 1.59 retrieving revision 1.60 diff -u -d -r1.59 -r1.60 --- inst.tex 1 Jan 2005 00:28:32 -0000 1.59 +++ inst.tex 13 Feb 2005 22:50:03 -0000 1.60 @@ -142,7 +142,7 @@ On \UNIX, you'd run this command from a shell prompt; on Windows, you have to open a command prompt window (``DOS box'') and do it there; on -Mac OS, things are a tad more complicated (see below). +Mac OS X, you open a \command{Terminal} window to get a shell prompt. \subsection{Platform variations} @@ -262,7 +262,8 @@ \code{setup.py install}---then the \command{install} command installs to the standard location for third-party Python modules. This location varies by platform and by how you built/installed Python itself. On -\UNIX{} and Mac OS, it also depends on whether the module distribution +\UNIX{} (and Mac OS X, which is also Unix-based), +it also depends on whether the module distribution being installed is pure Python or contains extensions (``non-pure''): \begin{tableiv}{l|l|l|c}{textrm}% {Platform}{Standard installation location}{Default value}{Notes} @@ -278,14 +279,6 @@ {\filenq{\filevar{prefix}}} {\filenq{C:\textbackslash{}Python}} {(2)} - \lineiv{Mac OS (pure)} - {\filenq{\filevar{prefix}:Lib:site-packages}} - {\filenq{Python:Lib:site-packages}} - {} - \lineiv{Mac OS (non-pure)} - {\filenq{\filevar{prefix}:Lib:site-packages}} - {\filenq{Python:Lib:site-packages}} - {} \end{tableiv} \noindent Notes: @@ -302,8 +295,8 @@ \filevar{prefix} and \filevar{exec-prefix} stand for the directories that Python is installed to, and where it finds its libraries at -run-time. They are always the same under Windows and Mac OS, and very -often the same under \UNIX. You can find out what your Python +run-time. They are always the same under Windows, and very +often the same under \UNIX and Mac OS X. You can find out what your Python installation uses for \filevar{prefix} and \filevar{exec-prefix} by running Python in interactive mode and typing a few simple commands. Under \UNIX, just type \code{python} at the shell prompt. Under @@ -658,7 +651,7 @@ variables supplied by the Distutils are the only ones you can use.) See section~\ref{config-files} for details. -% XXX need some Windows and Mac OS examples---when would custom +% XXX need some Windows examples---when would custom % installation schemes be needed on those platforms? @@ -764,7 +757,7 @@ \label{config-filenames} The names and locations of the configuration files vary slightly across -platforms. On \UNIX, the three configuration files (in the order they +platforms. On \UNIX and Mac OS X, the three configuration files (in the order they are processed) are: \begin{tableiii}{l|l|c}{textrm} {Type of file}{Location and filename}{Notes} @@ -773,7 +766,7 @@ \lineiii{local}{\filenq{setup.cfg}}{(3)} \end{tableiii} -On Windows, the configuration files are: +And on Windows, the configuration files are: \begin{tableiii}{l|l|c}{textrm} {Type of file}{Location and filename}{Notes} \lineiii{system}{\filenq{\filevar{prefix}\textbackslash{}Lib\textbackslash{}distutils\textbackslash{}distutils.cfg}}{(4)} @@ -781,14 +774,6 @@ \lineiii{local}{\filenq{setup.cfg}}{(3)} \end{tableiii} -And on Mac OS, they are: -\begin{tableiii}{l|l|c}{textrm} - {Type of file}{Location and filename}{Notes} - \lineiii{system}{\filenq{\filevar{prefix}:Lib:distutils:distutils.cfg}}{(6)} - \lineiii{personal}{N/A}{} - \lineiii{local}{\filenq{setup.cfg}}{(3)} -\end{tableiii} - \noindent Notes: \begin{description} \item[(1)] Strictly speaking, the system-wide configuration file lives @@ -818,9 +803,6 @@ defined, no personal configuration file will be found or used. (In other words, the Distutils make no attempt to guess your home directory on Windows.) -\item[(6)] (See also notes (1) and (4).) The default installation - prefix is just \file{Python:}, so under Python 1.6 and later this is - normally\file{Python:Lib:distutils:distutils.cfg}. \end{description} From bcannon at users.sourceforge.net Sun Feb 13 23:50:06 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Feb 13 23:50:22 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libimp.tex, 1.36, 1.37 libsite.tex, 1.26, 1.27 libtempfile.tex, 1.22, 1.23 libos.tex, 1.152, 1.153 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3121/Doc/lib Modified Files: libimp.tex libsite.tex libtempfile.tex libos.tex Log Message: Update references specifying "Macintosh" to mean OS X semantics and not Mac OS 9. Applies patch #1095802. Thanks Jack Jansen. Index: libimp.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libimp.tex,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- libimp.tex 20 Aug 2004 14:38:56 -0000 1.36 +++ libimp.tex 13 Feb 2005 22:50:03 -0000 1.37 @@ -135,8 +135,8 @@ \end{datadesc} \begin{datadesc}{PY_RESOURCE} -The module was found as a Macintosh resource. This value can only be -returned on a Macintosh. +The module was found as a Mac OS 9 resource. This value can only be +returned on a Mac OS 9 or earlier Macintosh. \end{datadesc} \begin{datadesc}{PKG_DIRECTORY} Index: libsite.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsite.tex,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- libsite.tex 20 Mar 2004 21:41:28 -0000 1.26 +++ libsite.tex 13 Feb 2005 22:50:03 -0000 1.27 @@ -16,9 +16,9 @@ It starts by constructing up to four directories from a head and a tail part. For the head part, it uses \code{sys.prefix} and \code{sys.exec_prefix}; empty heads are skipped. For -the tail part, it uses the empty string (on Macintosh or Windows) or +the tail part, it uses the empty string (on Windows) or it uses first \file{lib/python\shortversion/site-packages} and then -\file{lib/site-python} (on \UNIX). For each of the distinct +\file{lib/site-python} (on \UNIX and Macintosh). For each of the distinct head-tail combinations, it sees if it refers to an existing directory, and if so, adds it to \code{sys.path} and also inspects the newly added path for configuration files. Index: libtempfile.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libtempfile.tex,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- libtempfile.tex 11 Sep 2003 18:18:54 -0000 1.22 +++ libtempfile.tex 13 Feb 2005 22:50:03 -0000 1.23 @@ -146,7 +146,6 @@ \item The directory named by the \envvar{TMP} environment variable. \item A platform-specific location: \begin{itemize} - \item On Macintosh, the \file{Temporary Items} folder. \item On RiscOS, the directory named by the \envvar{Wimp\$ScrapDir} environment variable. \item On Windows, the directories Index: libos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.152 retrieving revision 1.153 diff -u -d -r1.152 -r1.153 --- libos.tex 23 Jan 2005 09:19:22 -0000 1.152 +++ libos.tex 13 Feb 2005 22:50:03 -0000 1.153 @@ -337,7 +337,7 @@ available as the return value of the \method{close()} method of the file object, except that when the exit status is zero (termination without errors), \code{None} is returned. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \versionchanged[This function worked unreliably under Windows in earlier versions of Python. This was due to the use of the @@ -350,7 +350,7 @@ 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. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \end{funcdesc} @@ -380,21 +380,21 @@ \begin{funcdesc}{popen2}{cmd\optional{, mode\optional{, bufsize}}} Executes \var{cmd} as a sub-process. Returns the file objects \code{(\var{child_stdin}, \var{child_stdout})}. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \versionadded{2.0} \end{funcdesc} \begin{funcdesc}{popen3}{cmd\optional{, mode\optional{, bufsize}}} Executes \var{cmd} as a sub-process. Returns the file objects \code{(\var{child_stdin}, \var{child_stdout}, \var{child_stderr})}. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \versionadded{2.0} \end{funcdesc} \begin{funcdesc}{popen4}{cmd\optional{, mode\optional{, bufsize}}} Executes \var{cmd} as a sub-process. Returns the file objects \code{(\var{child_stdin}, \var{child_stdout_and_stderr})}. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \versionadded{2.0} \end{funcdesc} @@ -434,7 +434,7 @@ \begin{funcdesc}{dup2}{fd, fd2} Duplicate file descriptor \var{fd} to \var{fd2}, closing the latter first if necessary. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \end{funcdesc} \begin{funcdesc}{fdatasync}{fd} @@ -453,7 +453,7 @@ \code{pathconf_names} dictionary. For configuration variables not included in that mapping, passing an integer for \var{name} is also accepted. -Availability: \UNIX. +Availability: Macintosh, \UNIX. If \var{name} is a string and is not known, \exception{ValueError} is raised. If a specific value for \var{name} is not supported by the @@ -464,7 +464,7 @@ \begin{funcdesc}{fstat}{fd} Return status for file descriptor \var{fd}, like \function{stat()}. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \end{funcdesc} \begin{funcdesc}{fstatvfs}{fd} @@ -482,19 +482,19 @@ \code{\var{f}.flush()}, and then do \code{os.fsync(\var{f}.fileno())}, to ensure that all internal buffers associated with \var{f} are written to disk. -Availability: \UNIX, and Windows starting in 2.2.3. +Availability: Macintosh, \UNIX, and Windows starting in 2.2.3. \end{funcdesc} \begin{funcdesc}{ftruncate}{fd, length} Truncate the file corresponding to file descriptor \var{fd}, so that it is at most \var{length} bytes in size. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{isatty}{fd} Return \code{True} if the file descriptor \var{fd} is open and connected to a tty(-like) device, else \code{False}. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{lseek}{fd, pos, how} @@ -531,13 +531,13 @@ \code{(\var{master}, \var{slave})} for the pty and the tty, respectively. For a (slightly) more portable approach, use the \refmodule{pty}\refstmodindex{pty} module. -Availability: Some flavors of \UNIX. +Availability: Macintosh, Some flavors of \UNIX. \end{funcdesc} \begin{funcdesc}{pipe}{} Create a pipe. Return a pair of file descriptors \code{(\var{r}, \var{w})} usable for reading and writing, respectively. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \end{funcdesc} \begin{funcdesc}{read}{fd, n} @@ -560,21 +560,21 @@ \begin{funcdesc}{tcgetpgrp}{fd} Return the process group associated with the terminal given by \var{fd} (an open file descriptor as returned by \function{open()}). -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{tcsetpgrp}{fd, pg} Set the process group associated with the terminal given by \var{fd} (an open file descriptor as returned by \function{open()}) to \var{pg}. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{ttyname}{fd} Return a string which specifies the terminal device associated with file-descriptor \var{fd}. If \var{fd} is not associated with a terminal device, an exception is raised. -Availability: \UNIX. +Availability:Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{write}{fd, str} @@ -621,7 +621,7 @@ \begin{datadesc}{O_BINARY} Option for the \var{flag} argument to the \function{open()} function. This can be bit-wise OR'd together with those listed above. -Availability: Macintosh, Windows. +Availability: Windows. % XXX need to check on the availability of this one. \end{datadesc} @@ -657,7 +657,7 @@ test permissions. Return \constant{True} if access is allowed, \constant{False} if not. See the \UNIX{} man page \manpage{access}{2} for more information. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \end{funcdesc} \begin{datadesc}{F_OK} @@ -701,13 +701,13 @@ \begin{funcdesc}{getcwdu}{} Return a Unicode object representing the current working directory. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \versionadded{2.3} \end{funcdesc} \begin{funcdesc}{chroot}{path} Change the root directory of the current process to \var{path}. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.2} \end{funcdesc} @@ -736,25 +736,25 @@ \item \code{S_IWOTH} \item \code{S_IXOTH} \end{itemize} -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \end{funcdesc} \begin{funcdesc}{chown}{path, uid, gid} Change the owner and group id of \var{path} to the numeric \var{uid} and \var{gid}. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{lchown}{path, uid, gid} Change the owner and group id of \var{path} to the numeric \var{uid} and gid. This function will not follow symbolic links. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{funcdesc} \begin{funcdesc}{link}{src, dst} Create a hard link pointing to \var{src} named \var{dst}. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{listdir}{path} @@ -770,14 +770,14 @@ \begin{funcdesc}{lstat}{path} Like \function{stat()}, but do not follow symbolic links. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{mkfifo}{path\optional{, mode}} Create a FIFO (a named pipe) named \var{path} with numeric mode \var{mode}. The default \var{mode} is \code{0666} (octal). The current umask value is first masked out from the mode. -Availability: \UNIX. +Availability: Macintosh, \UNIX. FIFOs are pipes that can be accessed like regular files. FIFOs exist until they are deleted (for example with \function{os.unlink()}). @@ -844,7 +844,7 @@ \code{pathconf_names} dictionary. For configuration variables not included in that mapping, passing an integer for \var{name} is also accepted. -Availability: \UNIX. +Availability: Macintosh, \UNIX. If \var{name} is a string and is not known, \exception{ValueError} is raised. If a specific value for \var{name} is not supported by the @@ -858,7 +858,7 @@ \function{fpathconf()} to the integer values defined for those names by the host operating system. This can be used to determine the set of names known to the system. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{datadesc} \begin{funcdesc}{readlink}{path} @@ -866,7 +866,7 @@ points. The result may be either an absolute or relative pathname; if it is relative, it may be converted to an absolute pathname using \code{os.path.join(os.path.dirname(\var{path}), \var{result})}. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{remove}{path} @@ -1079,7 +1079,7 @@ some aspects are underspecified in system documentation. \warning{Use of \function{tempnam()} is vulnerable to symlink attacks; consider using \function{tmpfile()} instead.} -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \end{funcdesc} \begin{funcdesc}{tmpnam}{} @@ -1238,7 +1238,7 @@ process immediately returns an exit code of \code{3}. Be aware that programs which use \function{signal.signal()} to register a handler for \constant{SIGABRT} will behave differently. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \end{funcdesc} \begin{funcdesc}{execl}{path, arg0, arg1, \moreargs} @@ -1284,13 +1284,13 @@ \function{execlp()}, \function{execv()}, and \function{execvp()} all cause the new process to inherit the environment of the current process. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \end{funcdesc} \begin{funcdesc}{_exit}{n} Exit to the system with status \var{n}, without calling cleanup handlers, flushing stdio buffers, etc. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \begin{notice} The standard way to exit is \code{sys.exit(\var{n})}. @@ -1306,76 +1306,76 @@ \begin{datadesc}{EX_OK} Exit code that means no error occurred. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{datadesc}{EX_USAGE} Exit code that means the command was used incorrectly, such as when the wrong number of arguments are given. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{datadesc}{EX_DATAERR} Exit code that means the input data was incorrect. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{datadesc}{EX_NOINPUT} Exit code that means an input file did not exist or was not readable. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{datadesc}{EX_NOUSER} Exit code that means a specified user did not exist. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{datadesc}{EX_NOHOST} Exit code that means a specified host did not exist. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{datadesc}{EX_UNAVAILABLE} Exit code that means that a required service is unavailable. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{datadesc}{EX_SOFTWARE} Exit code that means an internal software error was detected. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{datadesc}{EX_OSERR} Exit code that means an operating system error was detected, such as the inability to fork or create a pipe. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{datadesc}{EX_OSFILE} Exit code that means some system file did not exist, could not be opened, or had some other kind of error. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{datadesc}{EX_CANTCREAT} Exit code that means a user specified output file could not be created. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{datadesc}{EX_IOERR} Exit code that means that an error occurred while doing I/O on some file. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} @@ -1383,40 +1383,40 @@ Exit code that means a temporary failure occurred. This indicates something that may not really be an error, such as a network connection that couldn't be made during a retryable operation. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{datadesc}{EX_PROTOCOL} Exit code that means that a protocol exchange was illegal, invalid, or not understood. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{datadesc}{EX_NOPERM} Exit code that means that there were insufficient permissions to perform the operation (but not intended for file system problems). -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{datadesc}{EX_CONFIG} Exit code that means that some kind of configuration error occurred. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{datadesc}{EX_NOTFOUND} Exit code that means something like ``an entry was not found''. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{funcdesc}{fork}{} Fork a child process. Return \code{0} in the child, the child's process id in the parent. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{forkpty}{} @@ -1426,7 +1426,7 @@ in the parent, and \var{fd} is the file descriptor of the master end of the pseudo-terminal. For a more portable approach, use the \refmodule{pty} module. -Availability: Some flavors of \UNIX. +Availability: Macintosh, Some flavors of \UNIX. \end{funcdesc} \begin{funcdesc}{kill}{pid, sig} @@ -1435,27 +1435,27 @@ Kill the process \var{pid} with signal \var{sig}. Constants for the specific signals available on the host platform are defined in the \refmodule{signal} module. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{killpg}{pgid, sig} \index{process!killing} \index{process!signalling} Kill the process group \var{pgid} with the signal \var{sig}. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{funcdesc} \begin{funcdesc}{nice}{increment} Add \var{increment} to the process's ``niceness''. Return the new niceness. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{plock}{op} Lock program segments into memory. The value of \var{op} (defined in \code{}) determines which segments are locked. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdescni}{popen}{\unspecified} @@ -1536,7 +1536,7 @@ family of functions. If either of these values is given, the \function{spawn*()} functions will return as soon as the new process has been created, with the process ID as the return value. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \versionadded{1.6} \end{datadesc} @@ -1547,7 +1547,7 @@ has run to completion and will return the exit code of the process the run is successful, or \code{-\var{signal}} if a signal kills the process. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \versionadded{1.6} \end{datadesc} @@ -1601,7 +1601,7 @@ and XP) this is the exit status of the command run; on systems using a non-native shell, consult your shell documentation. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \end{funcdesc} \begin{funcdesc}{times}{} @@ -1612,7 +1612,7 @@ point in the past, in that order. See the \UNIX{} manual page \manpage{times}{2} or the corresponding Windows Platform API documentation. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \end{funcdesc} \begin{funcdesc}{wait}{} @@ -1621,7 +1621,7 @@ the signal number that killed the process, and whose high byte is the exit status (if the signal number is zero); the high bit of the low byte is set if a core file was produced. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{waitpid}{pid, options} @@ -1659,7 +1659,7 @@ \begin{datadesc}{WNOHANG} The option for \function{waitpid()} to avoid hanging if no child process status is available immediately. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{datadesc} \begin{datadesc}{WCONTINUED} @@ -1674,7 +1674,7 @@ This option causes child processes to be reported if they have been stopped but their current state has not been reported since they were stopped. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} @@ -1686,7 +1686,7 @@ \begin{funcdesc}{WCOREDUMP}{status} Returns \code{True} if a core dump was generated for the process, otherwise it returns \code{False}. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{funcdesc} @@ -1706,30 +1706,30 @@ \begin{funcdesc}{WIFSIGNALED}{status} Returns \code{True} if the process exited due to a signal, otherwise it returns \code{False}. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{WIFEXITED}{status} Returns \code{True} if the process exited using the \manpage{exit}{2} system call, otherwise it returns \code{False}. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{WEXITSTATUS}{status} If \code{WIFEXITED(\var{status})} is true, return the integer parameter to the \manpage{exit}{2} system call. Otherwise, the return value is meaningless. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{WSTOPSIG}{status} Return the signal which caused the process to stop. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{WTERMSIG}{status} Return the signal which caused the process to exit. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} @@ -1746,7 +1746,7 @@ \code{confstr_names} dictionary. For configuration variables not included in that mapping, passing an integer for \var{name} is also accepted. -Availability: \UNIX. +Availability: Macintosh, \UNIX. If the configuration value specified by \var{name} isn't defined, the empty string is returned. @@ -1762,7 +1762,7 @@ Dictionary mapping names accepted by \function{confstr()} to the integer values defined for those names by the host operating system. This can be used to determine the set of names known to the system. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{datadesc} \begin{funcdesc}{getloadavg}{} @@ -1780,14 +1780,14 @@ parameter for \function{confstr()} apply here as well; the dictionary that provides information on the known names is given by \code{sysconf_names}. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{datadesc}{sysconf_names} Dictionary mapping names accepted by \function{sysconf()} to the integer values defined for those names by the host operating system. This can be used to determine the set of names known to the system. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{datadesc} @@ -1801,21 +1801,21 @@ \begin{datadesc}{curdir} The constant string used by the operating system to refer to the current directory. -For example: \code{'.'} for \POSIX{} or \code{':'} for the Macintosh. +For example: \code{'.'} for \POSIX{} or \code{':'} for Mac OS 9. Also available via \module{os.path}. \end{datadesc} \begin{datadesc}{pardir} The constant string used by the operating system to refer to the parent directory. -For example: \code{'..'} for \POSIX{} or \code{'::'} for the Macintosh. +For example: \code{'..'} for \POSIX{} or \code{'::'} for Mac OS 9. Also available via \module{os.path}. \end{datadesc} \begin{datadesc}{sep} The character used by the operating system to separate pathname components, -for example, \character{/} for \POSIX{} or \character{:} for the -Macintosh. Note that knowing this is not sufficient to be able to +for example, \character{/} for \POSIX{} or \character{:} for +Mac OS 9. Note that knowing this is not sufficient to be able to parse or concatenate pathnames --- use \function{os.path.split()} and \function{os.path.join()} --- but it is occasionally useful. Also available via \module{os.path}. @@ -1859,8 +1859,8 @@ \begin{datadesc}{devnull} The file path of the null device. -For example: \code{'/dev/null'} for \POSIX{} or \code{'Dev:Nul'} for the -Macintosh. +For example: \code{'/dev/null'} for \POSIX{} or \code{'Dev:Nul'} for +Mac OS 9. Also available via \module{os.path}. \versionadded{2.4} \end{datadesc} From bcannon at users.sourceforge.net Sun Feb 13 23:50:28 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Feb 13 23:50:30 2005 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.268,1.269 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3121/Doc/tut Modified Files: tut.tex Log Message: Update references specifying "Macintosh" to mean OS X semantics and not Mac OS 9. Applies patch #1095802. Thanks Jack Jansen. Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.268 retrieving revision 1.269 diff -u -d -r1.268 -r1.269 --- tut.tex 12 Jan 2005 19:11:45 -0000 1.268 +++ tut.tex 13 Feb 2005 22:50:04 -0000 1.269 @@ -3105,8 +3105,7 @@ written. This behind-the-scenes modification to file data is fine for \ASCII{} text files, but it'll corrupt binary data like that in JPEGs or \file{.EXE} files. Be very careful to use binary mode when reading and -writing such files. (Note that the precise semantics of text mode on -the Macintosh depends on the underlying C library being used.) +writing such files. \subsection{Methods of File Objects \label{fileMethods}} From bcannon at users.sourceforge.net Sun Feb 13 23:50:35 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Feb 13 23:50:39 2005 Subject: [Python-checkins] python/dist/src/Doc/ext extending.tex,1.31,1.32 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ext In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3121/Doc/ext Modified Files: extending.tex Log Message: Update references specifying "Macintosh" to mean OS X semantics and not Mac OS 9. Applies patch #1095802. Thanks Jack Jansen. Index: extending.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/extending.tex,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- extending.tex 1 Jan 2005 00:28:30 -0000 1.31 +++ extending.tex 13 Feb 2005 22:50:02 -0000 1.32 @@ -374,7 +374,7 @@ \cdata{_PyImport_Inittab} table. The easiest way to handle this is to statically initialize your statically-linked modules by directly calling \cfunction{initspam()} after the call to -\cfunction{Py_Initialize()} or \cfunction{PyMac_Initialize()}: +\cfunction{Py_Initialize()}: \begin{verbatim} int @@ -426,7 +426,6 @@ (chapter \ref{building}) and additional information that pertains only to building on Windows (chapter \ref{building-on-windows}) for more information about this. -% XXX Add information about Mac OS If you can't use dynamic loading, or if you want to make your module a permanent part of the Python interpreter, you will have to change the From bcannon at users.sourceforge.net Sun Feb 13 23:50:35 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Feb 13 23:50:39 2005 Subject: [Python-checkins] python/dist/src/Doc/api init.tex, 1.22, 1.23 utilities.tex, 1.20, 1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3121/Doc/api Modified Files: init.tex utilities.tex Log Message: Update references specifying "Macintosh" to mean OS X semantics and not Mac OS 9. Applies patch #1095802. Thanks Jack Jansen. Index: init.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/init.tex,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- init.tex 19 Jan 2005 04:18:39 -0000 1.22 +++ init.tex 13 Feb 2005 22:50:02 -0000 1.23 @@ -239,9 +239,8 @@ program name (set by \cfunction{Py_SetProgramName()} above) and some environment variables. The returned string consists of a series of directory names separated by a platform dependent delimiter - character. The delimiter character is \character{:} on \UNIX, - \character{;} on Windows, and \character{\e n} (the \ASCII{} - newline character) on Macintosh. The returned string points into + character. The delimiter character is \character{:} on \UNIX and Mac OS X, + \character{;} on Windows. The returned string points into static storage; the caller should not modify its value. The value is available to Python code as the list \code{sys.path}\withsubitem{(in module sys)}{\ttindex{path}}, which @@ -272,7 +271,7 @@ this is formed from the ``official'' name of the operating system, converted to lower case, followed by the major revision number; e.g., for Solaris 2.x, which is also known as SunOS 5.x, the value - is \code{'sunos5'}. On Macintosh, it is \code{'mac'}. On Windows, + is \code{'sunos5'}. On Mac OS X, it is \code{'darwin'}. On Windows, it is \code{'win'}. The returned string points into static storage; the caller should not modify its value. The value is available to Python code as \code{sys.platform}. Index: utilities.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/utilities.tex,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- utilities.tex 10 Aug 2004 19:01:50 -0000 1.20 +++ utilities.tex 13 Feb 2005 22:50:02 -0000 1.21 @@ -34,7 +34,7 @@ Return true when the interpreter runs out of stack space. This is a reliable check, but is only available when \constant{USE_STACKCHECK} is defined (currently on Windows using the Microsoft Visual \Cpp{} - compiler and on the Macintosh). \constant{USE_CHECKSTACK} will be + compiler). \constant{USE_CHECKSTACK} will be defined automatically; you should never change the definition in your own code. \end{cfuncdesc} From bcannon at users.sourceforge.net Sun Feb 13 23:50:35 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Feb 13 23:50:40 2005 Subject: [Python-checkins] python/dist/src/Doc/dist dist.tex,1.87,1.88 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/dist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3121/Doc/dist Modified Files: dist.tex Log Message: Update references specifying "Macintosh" to mean OS X semantics and not Mac OS 9. Applies patch #1095802. Thanks Jack Jansen. Index: dist.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/dist/dist.tex,v retrieving revision 1.87 retrieving revision 1.88 diff -u -d -r1.87 -r1.88 --- dist.tex 1 Jan 2005 00:28:29 -0000 1.87 +++ dist.tex 13 Feb 2005 22:50:02 -0000 1.88 @@ -298,7 +298,7 @@ current platform before actually using the pathname. This makes your setup script portable across operating systems, which of course is one of the major goals of the Distutils. In this spirit, all pathnames in -this document are slash-separated. (Mac OS programmers should keep in +this document are slash-separated. (Mac OS 9 programmers should keep in mind that the \emph{absence} of a leading slash indicates a relative path, the opposite of the Mac OS convention with colons.) @@ -1021,7 +1021,6 @@ script or config file), \command{sdist} creates the archive of the default format for the current platform. The default format is a gzip'ed tar file (\file{.tar.gz}) on \UNIX, and ZIP file on Windows. -\XXX{no Mac OS support here} You can specify as many formats as you like using the \longprogramopt{formats} option, for example: @@ -2059,9 +2058,9 @@ characters in \var{range} (e.g., \code{a-z}, \code{a-zA-Z}, \code{a-f0-9\_.}). The definition of ``regular filename character'' is platform-specific: on \UNIX{} it is anything except slash; on Windows -anything except backslash or colon; on Mac OS anything except colon. +anything except backslash or colon; on Mac OS 9 anything except colon. -\XXX{Windows and Mac OS support not there yet} +\XXX{Windows support not there yet} %\section{Creating a built distribution: the @@ -2759,7 +2758,8 @@ \modulesynopsis{Metrowerks CodeWarrior support} Contains \class{MWerksCompiler}, an implementation of the abstract -\class{CCompiler} class for MetroWerks CodeWarrior on the Macintosh. Needs work to support CW on Windows. +\class{CCompiler} class for MetroWerks CodeWarrior on the pre-Mac OS X Macintosh. +Needs work to support CW on Windows or Mac OS X. %\subsection{Utility modules} @@ -2999,7 +2999,7 @@ Return \var{pathname} with \var{new_root} prepended. If \var{pathname} is relative, this is equivalent to \samp{os.path.join(new_root,pathname)} Otherwise, it requires making \var{pathname} relative and then joining the -two, which is tricky on DOS/Windows and Mac OS. +two, which is tricky on DOS/Windows. \end{funcdesc} \begin{funcdesc}{check_environ}{} From bcannon at users.sourceforge.net Sun Feb 13 23:53:25 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Feb 13 23:53:28 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1240,1.1241 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4667/Misc Modified Files: NEWS Log Message: Add mention of patch #1095802 (fixing "Macintosh" references to represent OS X). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1240 retrieving revision 1.1241 diff -u -d -r1.1240 -r1.1241 --- NEWS 10 Feb 2005 20:47:44 -0000 1.1240 +++ NEWS 13 Feb 2005 22:53:22 -0000 1.1241 @@ -178,6 +178,14 @@ - In test_os, st_?time is now truncated before comparing it with ST_?TIME. + +Documentation +------------- + +- Remove all latent references for "Macintosh" that referred to semantics for + Mac OS 9 and change to reflect the state for OS X. + Closes patch #1095802. Thanks Jack Jansen. + Mac --- From bcannon at users.sourceforge.net Sun Feb 13 23:56:45 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Feb 13 23:56:48 2005 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex, 1.261.2.3, 1.261.2.4 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5837/Doc/tut Modified Files: Tag: release24-maint tut.tex Log Message: Update refences to "Macintosh" to reflect the state of affairs for OS X and not Mac OS 9. Backport of patch #1095802. Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.261.2.3 retrieving revision 1.261.2.4 diff -u -d -r1.261.2.3 -r1.261.2.4 --- tut.tex 12 Jan 2005 19:14:55 -0000 1.261.2.3 +++ tut.tex 13 Feb 2005 22:56:41 -0000 1.261.2.4 @@ -3105,8 +3105,7 @@ written. This behind-the-scenes modification to file data is fine for \ASCII{} text files, but it'll corrupt binary data like that in JPEGs or \file{.EXE} files. Be very careful to use binary mode when reading and -writing such files. (Note that the precise semantics of text mode on -the Macintosh depends on the underlying C library being used.) +writing such files. \subsection{Methods of File Objects \label{fileMethods}} From bcannon at users.sourceforge.net Sun Feb 13 23:56:46 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Feb 13 23:56:50 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.19, 1.1193.2.20 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5837/Misc Modified Files: Tag: release24-maint NEWS Log Message: Update refences to "Macintosh" to reflect the state of affairs for OS X and not Mac OS 9. Backport of patch #1095802. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.19 retrieving revision 1.1193.2.20 diff -u -d -r1.1193.2.19 -r1.1193.2.20 --- NEWS 10 Feb 2005 22:47:08 -0000 1.1193.2.19 +++ NEWS 13 Feb 2005 22:56:41 -0000 1.1193.2.20 @@ -97,7 +97,16 @@ - PackageManager and the underlying pimp.py module have been updated to version 0.5, which greatly simplifies maintainance of the package databases. - + + +Documentation +------------- + +- Remove all latent references for "Macintosh" that referred to semantics for + Mac OS 9 and change to reflect the state for OS X. + Closes patch #1095802. Thanks Jack Jansen. + + What's New in Python 2.4 final? =============================== From bcannon at users.sourceforge.net Sun Feb 13 23:57:08 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Feb 13 23:57:10 2005 Subject: [Python-checkins] python/dist/src/Doc/api init.tex, 1.21.2.1, 1.21.2.2 utilities.tex, 1.20, 1.20.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5837/Doc/api Modified Files: Tag: release24-maint init.tex utilities.tex Log Message: Update refences to "Macintosh" to reflect the state of affairs for OS X and not Mac OS 9. Backport of patch #1095802. Index: init.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/init.tex,v retrieving revision 1.21.2.1 retrieving revision 1.21.2.2 diff -u -d -r1.21.2.1 -r1.21.2.2 --- init.tex 19 Jan 2005 04:13:14 -0000 1.21.2.1 +++ init.tex 13 Feb 2005 22:56:35 -0000 1.21.2.2 @@ -239,9 +239,8 @@ program name (set by \cfunction{Py_SetProgramName()} above) and some environment variables. The returned string consists of a series of directory names separated by a platform dependent delimiter - character. The delimiter character is \character{:} on \UNIX, - \character{;} on Windows, and \character{\e n} (the \ASCII{} - newline character) on Macintosh. The returned string points into + character. The delimiter character is \character{:} on \UNIX and Mac OS X, + \character{;} on Windows. The returned string points into static storage; the caller should not modify its value. The value is available to Python code as the list \code{sys.path}\withsubitem{(in module sys)}{\ttindex{path}}, which @@ -272,7 +271,7 @@ this is formed from the ``official'' name of the operating system, converted to lower case, followed by the major revision number; e.g., for Solaris 2.x, which is also known as SunOS 5.x, the value - is \code{'sunos5'}. On Macintosh, it is \code{'mac'}. On Windows, + is \code{'sunos5'}. On Mac OS X, it is \code{'darwin'}. On Windows, it is \code{'win'}. The returned string points into static storage; the caller should not modify its value. The value is available to Python code as \code{sys.platform}. Index: utilities.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/utilities.tex,v retrieving revision 1.20 retrieving revision 1.20.2.1 diff -u -d -r1.20 -r1.20.2.1 --- utilities.tex 10 Aug 2004 19:01:50 -0000 1.20 +++ utilities.tex 13 Feb 2005 22:56:35 -0000 1.20.2.1 @@ -34,7 +34,7 @@ Return true when the interpreter runs out of stack space. This is a reliable check, but is only available when \constant{USE_STACKCHECK} is defined (currently on Windows using the Microsoft Visual \Cpp{} - compiler and on the Macintosh). \constant{USE_CHECKSTACK} will be + compiler). \constant{USE_CHECKSTACK} will be defined automatically; you should never change the definition in your own code. \end{cfuncdesc} From bcannon at users.sourceforge.net Sun Feb 13 23:57:08 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Feb 13 23:57:12 2005 Subject: [Python-checkins] python/dist/src/Doc/dist dist.tex, 1.86.2.1, 1.86.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/dist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5837/Doc/dist Modified Files: Tag: release24-maint dist.tex Log Message: Update refences to "Macintosh" to reflect the state of affairs for OS X and not Mac OS 9. Backport of patch #1095802. Index: dist.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/dist/dist.tex,v retrieving revision 1.86.2.1 retrieving revision 1.86.2.2 diff -u -d -r1.86.2.1 -r1.86.2.2 --- dist.tex 1 Jan 2005 00:34:52 -0000 1.86.2.1 +++ dist.tex 13 Feb 2005 22:56:35 -0000 1.86.2.2 @@ -298,7 +298,7 @@ current platform before actually using the pathname. This makes your setup script portable across operating systems, which of course is one of the major goals of the Distutils. In this spirit, all pathnames in -this document are slash-separated. (Mac OS programmers should keep in +this document are slash-separated. (Mac OS 9 programmers should keep in mind that the \emph{absence} of a leading slash indicates a relative path, the opposite of the Mac OS convention with colons.) @@ -1021,7 +1021,6 @@ script or config file), \command{sdist} creates the archive of the default format for the current platform. The default format is a gzip'ed tar file (\file{.tar.gz}) on \UNIX, and ZIP file on Windows. -\XXX{no Mac OS support here} You can specify as many formats as you like using the \longprogramopt{formats} option, for example: @@ -2059,9 +2058,9 @@ characters in \var{range} (e.g., \code{a-z}, \code{a-zA-Z}, \code{a-f0-9\_.}). The definition of ``regular filename character'' is platform-specific: on \UNIX{} it is anything except slash; on Windows -anything except backslash or colon; on Mac OS anything except colon. +anything except backslash or colon; on Mac OS 9 anything except colon. -\XXX{Windows and Mac OS support not there yet} +\XXX{Windows support not there yet} %\section{Creating a built distribution: the @@ -2759,7 +2758,8 @@ \modulesynopsis{Metrowerks CodeWarrior support} Contains \class{MWerksCompiler}, an implementation of the abstract -\class{CCompiler} class for MetroWerks CodeWarrior on the Macintosh. Needs work to support CW on Windows. +\class{CCompiler} class for MetroWerks CodeWarrior on the pre-Mac OS X Macintosh. +Needs work to support CW on Windows or Mac OS X. %\subsection{Utility modules} @@ -2999,7 +2999,7 @@ Return \var{pathname} with \var{new_root} prepended. If \var{pathname} is relative, this is equivalent to \samp{os.path.join(new_root,pathname)} Otherwise, it requires making \var{pathname} relative and then joining the -two, which is tricky on DOS/Windows and Mac OS. +two, which is tricky on DOS/Windows. \end{funcdesc} \begin{funcdesc}{check_environ}{} From bcannon at users.sourceforge.net Sun Feb 13 23:57:12 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Feb 13 23:57:15 2005 Subject: [Python-checkins] python/dist/src/Doc/ext extending.tex, 1.30.4.1, 1.30.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ext In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5837/Doc/ext Modified Files: Tag: release24-maint extending.tex Log Message: Update refences to "Macintosh" to reflect the state of affairs for OS X and not Mac OS 9. Backport of patch #1095802. Index: extending.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/extending.tex,v retrieving revision 1.30.4.1 retrieving revision 1.30.4.2 diff -u -d -r1.30.4.1 -r1.30.4.2 --- extending.tex 1 Jan 2005 00:34:52 -0000 1.30.4.1 +++ extending.tex 13 Feb 2005 22:56:35 -0000 1.30.4.2 @@ -374,7 +374,7 @@ \cdata{_PyImport_Inittab} table. The easiest way to handle this is to statically initialize your statically-linked modules by directly calling \cfunction{initspam()} after the call to -\cfunction{Py_Initialize()} or \cfunction{PyMac_Initialize()}: +\cfunction{Py_Initialize()}: \begin{verbatim} int @@ -426,7 +426,6 @@ (chapter \ref{building}) and additional information that pertains only to building on Windows (chapter \ref{building-on-windows}) for more information about this. -% XXX Add information about Mac OS If you can't use dynamic loading, or if you want to make your module a permanent part of the Python interpreter, you will have to change the From bcannon at users.sourceforge.net Sun Feb 13 23:57:12 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Feb 13 23:57:16 2005 Subject: [Python-checkins] python/dist/src/Doc/inst inst.tex, 1.58.2.1, 1.58.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/inst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5837/Doc/inst Modified Files: Tag: release24-maint inst.tex Log Message: Update refences to "Macintosh" to reflect the state of affairs for OS X and not Mac OS 9. Backport of patch #1095802. Index: inst.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/inst/inst.tex,v retrieving revision 1.58.2.1 retrieving revision 1.58.2.2 diff -u -d -r1.58.2.1 -r1.58.2.2 --- inst.tex 1 Jan 2005 00:34:53 -0000 1.58.2.1 +++ inst.tex 13 Feb 2005 22:56:39 -0000 1.58.2.2 @@ -142,7 +142,7 @@ On \UNIX, you'd run this command from a shell prompt; on Windows, you have to open a command prompt window (``DOS box'') and do it there; on -Mac OS, things are a tad more complicated (see below). +Mac OS X, you open a \command{Terminal} window to get a shell prompt. \subsection{Platform variations} @@ -262,7 +262,8 @@ \code{setup.py install}---then the \command{install} command installs to the standard location for third-party Python modules. This location varies by platform and by how you built/installed Python itself. On -\UNIX{} and Mac OS, it also depends on whether the module distribution +\UNIX{} (and Mac OS X, which is also Unix-based), +it also depends on whether the module distribution being installed is pure Python or contains extensions (``non-pure''): \begin{tableiv}{l|l|l|c}{textrm}% {Platform}{Standard installation location}{Default value}{Notes} @@ -278,14 +279,6 @@ {\filenq{\filevar{prefix}}} {\filenq{C:\textbackslash{}Python}} {(2)} - \lineiv{Mac OS (pure)} - {\filenq{\filevar{prefix}:Lib:site-packages}} - {\filenq{Python:Lib:site-packages}} - {} - \lineiv{Mac OS (non-pure)} - {\filenq{\filevar{prefix}:Lib:site-packages}} - {\filenq{Python:Lib:site-packages}} - {} \end{tableiv} \noindent Notes: @@ -302,8 +295,8 @@ \filevar{prefix} and \filevar{exec-prefix} stand for the directories that Python is installed to, and where it finds its libraries at -run-time. They are always the same under Windows and Mac OS, and very -often the same under \UNIX. You can find out what your Python +run-time. They are always the same under Windows, and very +often the same under \UNIX and Mac OS X. You can find out what your Python installation uses for \filevar{prefix} and \filevar{exec-prefix} by running Python in interactive mode and typing a few simple commands. Under \UNIX, just type \code{python} at the shell prompt. Under @@ -658,7 +651,7 @@ variables supplied by the Distutils are the only ones you can use.) See section~\ref{config-files} for details. -% XXX need some Windows and Mac OS examples---when would custom +% XXX need some Windows examples---when would custom % installation schemes be needed on those platforms? @@ -764,7 +757,7 @@ \label{config-filenames} The names and locations of the configuration files vary slightly across -platforms. On \UNIX, the three configuration files (in the order they +platforms. On \UNIX and Mac OS X, the three configuration files (in the order they are processed) are: \begin{tableiii}{l|l|c}{textrm} {Type of file}{Location and filename}{Notes} @@ -773,7 +766,7 @@ \lineiii{local}{\filenq{setup.cfg}}{(3)} \end{tableiii} -On Windows, the configuration files are: +And on Windows, the configuration files are: \begin{tableiii}{l|l|c}{textrm} {Type of file}{Location and filename}{Notes} \lineiii{system}{\filenq{\filevar{prefix}\textbackslash{}Lib\textbackslash{}distutils\textbackslash{}distutils.cfg}}{(4)} @@ -781,14 +774,6 @@ \lineiii{local}{\filenq{setup.cfg}}{(3)} \end{tableiii} -And on Mac OS, they are: -\begin{tableiii}{l|l|c}{textrm} - {Type of file}{Location and filename}{Notes} - \lineiii{system}{\filenq{\filevar{prefix}:Lib:distutils:distutils.cfg}}{(6)} - \lineiii{personal}{N/A}{} - \lineiii{local}{\filenq{setup.cfg}}{(3)} -\end{tableiii} - \noindent Notes: \begin{description} \item[(1)] Strictly speaking, the system-wide configuration file lives @@ -818,9 +803,6 @@ defined, no personal configuration file will be found or used. (In other words, the Distutils make no attempt to guess your home directory on Windows.) -\item[(6)] (See also notes (1) and (4).) The default installation - prefix is just \file{Python:}, so under Python 1.6 and later this is - normally\file{Python:Lib:distutils:distutils.cfg}. \end{description} From bcannon at users.sourceforge.net Sun Feb 13 23:57:13 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Feb 13 23:57:17 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libimp.tex, 1.36, 1.36.2.1 libsite.tex, 1.26, 1.26.4.1 libtempfile.tex, 1.22, 1.22.4.1 libos.tex, 1.146.2.1, 1.146.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5837/Doc/lib Modified Files: Tag: release24-maint libimp.tex libsite.tex libtempfile.tex libos.tex Log Message: Update refences to "Macintosh" to reflect the state of affairs for OS X and not Mac OS 9. Backport of patch #1095802. Index: libimp.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libimp.tex,v retrieving revision 1.36 retrieving revision 1.36.2.1 diff -u -d -r1.36 -r1.36.2.1 --- libimp.tex 20 Aug 2004 14:38:56 -0000 1.36 +++ libimp.tex 13 Feb 2005 22:56:40 -0000 1.36.2.1 @@ -135,8 +135,8 @@ \end{datadesc} \begin{datadesc}{PY_RESOURCE} -The module was found as a Macintosh resource. This value can only be -returned on a Macintosh. +The module was found as a Mac OS 9 resource. This value can only be +returned on a Mac OS 9 or earlier Macintosh. \end{datadesc} \begin{datadesc}{PKG_DIRECTORY} Index: libsite.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsite.tex,v retrieving revision 1.26 retrieving revision 1.26.4.1 diff -u -d -r1.26 -r1.26.4.1 --- libsite.tex 20 Mar 2004 21:41:28 -0000 1.26 +++ libsite.tex 13 Feb 2005 22:56:40 -0000 1.26.4.1 @@ -16,9 +16,9 @@ It starts by constructing up to four directories from a head and a tail part. For the head part, it uses \code{sys.prefix} and \code{sys.exec_prefix}; empty heads are skipped. For -the tail part, it uses the empty string (on Macintosh or Windows) or +the tail part, it uses the empty string (on Windows) or it uses first \file{lib/python\shortversion/site-packages} and then -\file{lib/site-python} (on \UNIX). For each of the distinct +\file{lib/site-python} (on \UNIX and Macintosh). For each of the distinct head-tail combinations, it sees if it refers to an existing directory, and if so, adds it to \code{sys.path} and also inspects the newly added path for configuration files. Index: libtempfile.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libtempfile.tex,v retrieving revision 1.22 retrieving revision 1.22.4.1 diff -u -d -r1.22 -r1.22.4.1 --- libtempfile.tex 11 Sep 2003 18:18:54 -0000 1.22 +++ libtempfile.tex 13 Feb 2005 22:56:40 -0000 1.22.4.1 @@ -146,7 +146,6 @@ \item The directory named by the \envvar{TMP} environment variable. \item A platform-specific location: \begin{itemize} - \item On Macintosh, the \file{Temporary Items} folder. \item On RiscOS, the directory named by the \envvar{Wimp\$ScrapDir} environment variable. \item On Windows, the directories Index: libos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.146.2.1 retrieving revision 1.146.2.2 diff -u -d -r1.146.2.1 -r1.146.2.2 --- libos.tex 15 Dec 2004 23:45:05 -0000 1.146.2.1 +++ libos.tex 13 Feb 2005 22:56:40 -0000 1.146.2.2 @@ -337,7 +337,7 @@ available as the return value of the \method{close()} method of the file object, except that when the exit status is zero (termination without errors), \code{None} is returned. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \versionchanged[This function worked unreliably under Windows in earlier versions of Python. This was due to the use of the @@ -350,7 +350,7 @@ 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. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \end{funcdesc} @@ -380,21 +380,21 @@ \begin{funcdesc}{popen2}{cmd\optional{, mode\optional{, bufsize}}} Executes \var{cmd} as a sub-process. Returns the file objects \code{(\var{child_stdin}, \var{child_stdout})}. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \versionadded{2.0} \end{funcdesc} \begin{funcdesc}{popen3}{cmd\optional{, mode\optional{, bufsize}}} Executes \var{cmd} as a sub-process. Returns the file objects \code{(\var{child_stdin}, \var{child_stdout}, \var{child_stderr})}. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \versionadded{2.0} \end{funcdesc} \begin{funcdesc}{popen4}{cmd\optional{, mode\optional{, bufsize}}} Executes \var{cmd} as a sub-process. Returns the file objects \code{(\var{child_stdin}, \var{child_stdout_and_stderr})}. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \versionadded{2.0} \end{funcdesc} @@ -434,7 +434,7 @@ \begin{funcdesc}{dup2}{fd, fd2} Duplicate file descriptor \var{fd} to \var{fd2}, closing the latter first if necessary. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \end{funcdesc} \begin{funcdesc}{fdatasync}{fd} @@ -453,7 +453,7 @@ \code{pathconf_names} dictionary. For configuration variables not included in that mapping, passing an integer for \var{name} is also accepted. -Availability: \UNIX. +Availability: Macintosh, \UNIX. If \var{name} is a string and is not known, \exception{ValueError} is raised. If a specific value for \var{name} is not supported by the @@ -464,7 +464,7 @@ \begin{funcdesc}{fstat}{fd} Return status for file descriptor \var{fd}, like \function{stat()}. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \end{funcdesc} \begin{funcdesc}{fstatvfs}{fd} @@ -482,19 +482,19 @@ \code{\var{f}.flush()}, and then do \code{os.fsync(\var{f}.fileno())}, to ensure that all internal buffers associated with \var{f} are written to disk. -Availability: \UNIX, and Windows starting in 2.2.3. +Availability: Macintosh, \UNIX, and Windows starting in 2.2.3. \end{funcdesc} \begin{funcdesc}{ftruncate}{fd, length} Truncate the file corresponding to file descriptor \var{fd}, so that it is at most \var{length} bytes in size. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{isatty}{fd} Return \code{True} if the file descriptor \var{fd} is open and connected to a tty(-like) device, else \code{False}. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{lseek}{fd, pos, how} @@ -531,13 +531,13 @@ \code{(\var{master}, \var{slave})} for the pty and the tty, respectively. For a (slightly) more portable approach, use the \refmodule{pty}\refstmodindex{pty} module. -Availability: Some flavors of \UNIX. +Availability: Macintosh, Some flavors of \UNIX. \end{funcdesc} \begin{funcdesc}{pipe}{} Create a pipe. Return a pair of file descriptors \code{(\var{r}, \var{w})} usable for reading and writing, respectively. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \end{funcdesc} \begin{funcdesc}{read}{fd, n} @@ -560,21 +560,21 @@ \begin{funcdesc}{tcgetpgrp}{fd} Return the process group associated with the terminal given by \var{fd} (an open file descriptor as returned by \function{open()}). -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{tcsetpgrp}{fd, pg} Set the process group associated with the terminal given by \var{fd} (an open file descriptor as returned by \function{open()}) to \var{pg}. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{ttyname}{fd} Return a string which specifies the terminal device associated with file-descriptor \var{fd}. If \var{fd} is not associated with a terminal device, an exception is raised. -Availability: \UNIX. +Availability:Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{write}{fd, str} @@ -621,7 +621,7 @@ \begin{datadesc}{O_BINARY} Option for the \var{flag} argument to the \function{open()} function. This can be bit-wise OR'd together with those listed above. -Availability: Macintosh, Windows. +Availability: Windows. % XXX need to check on the availability of this one. \end{datadesc} @@ -648,7 +648,7 @@ test permissions. Return \constant{True} if access is allowed, \constant{False} if not. See the \UNIX{} man page \manpage{access}{2} for more information. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \end{funcdesc} \begin{datadesc}{F_OK} @@ -692,13 +692,13 @@ \begin{funcdesc}{getcwdu}{} Return a Unicode object representing the current working directory. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \versionadded{2.3} \end{funcdesc} \begin{funcdesc}{chroot}{path} Change the root directory of the current process to \var{path}. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.2} \end{funcdesc} @@ -727,25 +727,25 @@ \item \code{S_IWOTH} \item \code{S_IXOTH} \end{itemize} -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \end{funcdesc} \begin{funcdesc}{chown}{path, uid, gid} Change the owner and group id of \var{path} to the numeric \var{uid} and \var{gid}. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{lchown}{path, uid, gid} Change the owner and group id of \var{path} to the numeric \var{uid} and gid. This function will not follow symbolic links. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{funcdesc} \begin{funcdesc}{link}{src, dst} Create a hard link pointing to \var{src} named \var{dst}. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{listdir}{path} @@ -761,14 +761,14 @@ \begin{funcdesc}{lstat}{path} Like \function{stat()}, but do not follow symbolic links. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{mkfifo}{path\optional{, mode}} Create a FIFO (a named pipe) named \var{path} with numeric mode \var{mode}. The default \var{mode} is \code{0666} (octal). The current umask value is first masked out from the mode. -Availability: \UNIX. +Availability: Macintosh, \UNIX. FIFOs are pipes that can be accessed like regular files. FIFOs exist until they are deleted (for example with \function{os.unlink()}). @@ -835,7 +835,7 @@ \code{pathconf_names} dictionary. For configuration variables not included in that mapping, passing an integer for \var{name} is also accepted. -Availability: \UNIX. +Availability: Macintosh, \UNIX. If \var{name} is a string and is not known, \exception{ValueError} is raised. If a specific value for \var{name} is not supported by the @@ -849,7 +849,7 @@ \function{fpathconf()} to the integer values defined for those names by the host operating system. This can be used to determine the set of names known to the system. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{datadesc} \begin{funcdesc}{readlink}{path} @@ -857,7 +857,7 @@ points. The result may be either an absolute or relative pathname; if it is relative, it may be converted to an absolute pathname using \code{os.path.join(os.path.dirname(\var{path}), \var{result})}. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{remove}{path} @@ -1061,7 +1061,7 @@ some aspects are underspecified in system documentation. \warning{Use of \function{tempnam()} is vulnerable to symlink attacks; consider using \function{tmpfile()} instead.} -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \end{funcdesc} \begin{funcdesc}{tmpnam}{} @@ -1220,7 +1220,7 @@ process immediately returns an exit code of \code{3}. Be aware that programs which use \function{signal.signal()} to register a handler for \constant{SIGABRT} will behave differently. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \end{funcdesc} \begin{funcdesc}{execl}{path, arg0, arg1, \moreargs} @@ -1266,13 +1266,13 @@ \function{execlp()}, \function{execv()}, and \function{execvp()} all cause the new process to inherit the environment of the current process. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \end{funcdesc} \begin{funcdesc}{_exit}{n} Exit to the system with status \var{n}, without calling cleanup handlers, flushing stdio buffers, etc. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \begin{notice} The standard way to exit is \code{sys.exit(\var{n})}. @@ -1288,76 +1288,76 @@ \begin{datadesc}{EX_OK} Exit code that means no error occurred. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{datadesc}{EX_USAGE} Exit code that means the command was used incorrectly, such as when the wrong number of arguments are given. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{datadesc}{EX_DATAERR} Exit code that means the input data was incorrect. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{datadesc}{EX_NOINPUT} Exit code that means an input file did not exist or was not readable. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{datadesc}{EX_NOUSER} Exit code that means a specified user did not exist. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{datadesc}{EX_NOHOST} Exit code that means a specified host did not exist. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{datadesc}{EX_UNAVAILABLE} Exit code that means that a required service is unavailable. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{datadesc}{EX_SOFTWARE} Exit code that means an internal software error was detected. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{datadesc}{EX_OSERR} Exit code that means an operating system error was detected, such as the inability to fork or create a pipe. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{datadesc}{EX_OSFILE} Exit code that means some system file did not exist, could not be opened, or had some other kind of error. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{datadesc}{EX_CANTCREAT} Exit code that means a user specified output file could not be created. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{datadesc}{EX_IOERR} Exit code that means that an error occurred while doing I/O on some file. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} @@ -1365,40 +1365,40 @@ Exit code that means a temporary failure occurred. This indicates something that may not really be an error, such as a network connection that couldn't be made during a retryable operation. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{datadesc}{EX_PROTOCOL} Exit code that means that a protocol exchange was illegal, invalid, or not understood. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{datadesc}{EX_NOPERM} Exit code that means that there were insufficient permissions to perform the operation (but not intended for file system problems). -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{datadesc}{EX_CONFIG} Exit code that means that some kind of configuration error occurred. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{datadesc}{EX_NOTFOUND} Exit code that means something like ``an entry was not found''. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} \begin{funcdesc}{fork}{} Fork a child process. Return \code{0} in the child, the child's process id in the parent. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{forkpty}{} @@ -1408,7 +1408,7 @@ in the parent, and \var{fd} is the file descriptor of the master end of the pseudo-terminal. For a more portable approach, use the \refmodule{pty} module. -Availability: Some flavors of \UNIX. +Availability: Macintosh, Some flavors of \UNIX. \end{funcdesc} \begin{funcdesc}{kill}{pid, sig} @@ -1417,27 +1417,27 @@ Kill the process \var{pid} with signal \var{sig}. Constants for the specific signals available on the host platform are defined in the \refmodule{signal} module. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{killpg}{pgid, sig} \index{process!killing} \index{process!signalling} Kill the process group \var{pgid} with the signal \var{sig}. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{funcdesc} \begin{funcdesc}{nice}{increment} Add \var{increment} to the process's ``niceness''. Return the new niceness. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{plock}{op} Lock program segments into memory. The value of \var{op} (defined in \code{}) determines which segments are locked. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdescni}{popen}{\unspecified} @@ -1518,7 +1518,7 @@ family of functions. If either of these values is given, the \function{spawn*()} functions will return as soon as the new process has been created, with the process ID as the return value. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \versionadded{1.6} \end{datadesc} @@ -1529,7 +1529,7 @@ has run to completion and will return the exit code of the process the run is successful, or \code{-\var{signal}} if a signal kills the process. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \versionadded{1.6} \end{datadesc} @@ -1583,7 +1583,7 @@ and XP) this is the exit status of the command run; on systems using a non-native shell, consult your shell documentation. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \end{funcdesc} \begin{funcdesc}{times}{} @@ -1594,7 +1594,7 @@ point in the past, in that order. See the \UNIX{} manual page \manpage{times}{2} or the corresponding Windows Platform API documentation. -Availability: \UNIX, Windows. +Availability: Macintosh, \UNIX, Windows. \end{funcdesc} \begin{funcdesc}{wait}{} @@ -1603,7 +1603,7 @@ the signal number that killed the process, and whose high byte is the exit status (if the signal number is zero); the high bit of the low byte is set if a core file was produced. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{waitpid}{pid, options} @@ -1641,7 +1641,7 @@ \begin{datadesc}{WNOHANG} The option for \function{waitpid()} to avoid hanging if no child process status is available immediately. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{datadesc} \begin{datadesc}{WCONTINUED} @@ -1656,7 +1656,7 @@ This option causes child processes to be reported if they have been stopped but their current state has not been reported since they were stopped. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{datadesc} @@ -1668,7 +1668,7 @@ \begin{funcdesc}{WCOREDUMP}{status} Returns \code{True} if a core dump was generated for the process, otherwise it returns \code{False}. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \versionadded{2.3} \end{funcdesc} @@ -1688,30 +1688,30 @@ \begin{funcdesc}{WIFSIGNALED}{status} Returns \code{True} if the process exited due to a signal, otherwise it returns \code{False}. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{WIFEXITED}{status} Returns \code{True} if the process exited using the \manpage{exit}{2} system call, otherwise it returns \code{False}. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{WEXITSTATUS}{status} If \code{WIFEXITED(\var{status})} is true, return the integer parameter to the \manpage{exit}{2} system call. Otherwise, the return value is meaningless. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{WSTOPSIG}{status} Return the signal which caused the process to stop. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{funcdesc}{WTERMSIG}{status} Return the signal which caused the process to exit. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} @@ -1728,7 +1728,7 @@ \code{confstr_names} dictionary. For configuration variables not included in that mapping, passing an integer for \var{name} is also accepted. -Availability: \UNIX. +Availability: Macintosh, \UNIX. If the configuration value specified by \var{name} isn't defined, the empty string is returned. @@ -1744,7 +1744,7 @@ Dictionary mapping names accepted by \function{confstr()} to the integer values defined for those names by the host operating system. This can be used to determine the set of names known to the system. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{datadesc} \begin{funcdesc}{getloadavg}{} @@ -1762,14 +1762,14 @@ parameter for \function{confstr()} apply here as well; the dictionary that provides information on the known names is given by \code{sysconf_names}. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{funcdesc} \begin{datadesc}{sysconf_names} Dictionary mapping names accepted by \function{sysconf()} to the integer values defined for those names by the host operating system. This can be used to determine the set of names known to the system. -Availability: \UNIX. +Availability: Macintosh, \UNIX. \end{datadesc} @@ -1783,21 +1783,21 @@ \begin{datadesc}{curdir} The constant string used by the operating system to refer to the current directory. -For example: \code{'.'} for \POSIX{} or \code{':'} for the Macintosh. +For example: \code{'.'} for \POSIX{} or \code{':'} for Mac OS 9. Also available via \module{os.path}. \end{datadesc} \begin{datadesc}{pardir} The constant string used by the operating system to refer to the parent directory. -For example: \code{'..'} for \POSIX{} or \code{'::'} for the Macintosh. +For example: \code{'..'} for \POSIX{} or \code{'::'} for Mac OS 9. Also available via \module{os.path}. \end{datadesc} \begin{datadesc}{sep} The character used by the operating system to separate pathname components, -for example, \character{/} for \POSIX{} or \character{:} for the -Macintosh. Note that knowing this is not sufficient to be able to +for example, \character{/} for \POSIX{} or \character{:} for +Mac OS 9. Note that knowing this is not sufficient to be able to parse or concatenate pathnames --- use \function{os.path.split()} and \function{os.path.join()} --- but it is occasionally useful. Also available via \module{os.path}. @@ -1841,8 +1841,8 @@ \begin{datadesc}{devnull} The file path of the null device. -For example: \code{'/dev/null'} for \POSIX{} or \code{'Dev:Nul'} for the -Macintosh. +For example: \code{'/dev/null'} for \POSIX{} or \code{'Dev:Nul'} for +Mac OS 9. Also available via \module{os.path}. \versionadded{2.4} \end{datadesc} From bcannon at users.sourceforge.net Sun Feb 13 23:56:46 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Mon Feb 14 01:00:57 2005 Subject: [Python-checkins] python/dist/src/Doc/mac libframework.tex, 1.11.4.1, 1.11.4.2 libmac.tex, 1.23, 1.23.18.1 libmacic.tex, 1.17, 1.17.2.1 libmacos.tex, 1.22, 1.22.4.1 scripting.tex, 1.3.4.1, 1.3.4.2 undoc.tex, 1.13.4.1, 1.13.4.2 using.tex, 1.12.2.2, 1.12.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/mac In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5837/Doc/mac Modified Files: Tag: release24-maint libframework.tex libmac.tex libmacic.tex libmacos.tex scripting.tex undoc.tex using.tex Log Message: Update refences to "Macintosh" to reflect the state of affairs for OS X and not Mac OS 9. Backport of patch #1095802. Index: libframework.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/mac/libframework.tex,v retrieving revision 1.11.4.1 retrieving revision 1.11.4.2 diff -u -d -r1.11.4.1 -r1.11.4.2 --- libframework.tex 1 Jan 2005 00:34:55 -0000 1.11.4.1 +++ libframework.tex 13 Feb 2005 22:56:40 -0000 1.11.4.2 @@ -15,7 +15,8 @@ non-standard way it is not necessary to override the complete event handling. -The \module{FrameWork} is still very much work-in-progress, and the +Work on the \module{FrameWork} has pretty much stopped, now that +\module{PyObjC} is available for full Cocoa access from Python, and the documentation describes only the most important functionality, and not in the most logical manner at that. Examine the source or the examples for more details. The following are some comments posted on the Index: libmac.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/mac/libmac.tex,v retrieving revision 1.23 retrieving revision 1.23.18.1 diff -u -d -r1.23 -r1.23.18.1 --- libmac.tex 12 Feb 2003 09:58:33 -0000 1.23 +++ libmac.tex 13 Feb 2005 22:56:40 -0000 1.23.18.1 @@ -1,36 +1,3 @@ -\section{\module{mac} --- - Implementations for the \module{os} module} - -\declaremodule{builtin}{mac} - \platform{Mac} -\modulesynopsis{Implementations for the \module{os} module.} - - -This module implements the Mac OS 9 operating system dependent functionality -provided by the standard module \module{os}\refstmodindex{os}. It is -best accessed through the \module{os} module. This module is only available in -MacPython-OS9, on MacPython-OSX \module{posix} is used. - -The following functions are available in this module: -\function{chdir()}, -\function{close()}, -\function{dup()}, -\function{fdopen()}, -\function{getcwd()}, -\function{lseek()}, -\function{listdir()}, -\function{mkdir()}, -\function{open()}, -\function{read()}, -\function{rename()}, -\function{rmdir()}, -\function{stat()}, -\function{sync()}, -\function{unlink()}, -\function{write()}, -as well as the exception \exception{error}. Note that the times -returned by \function{stat()} are floating-point values, like all time -values in MacPython-OS9. \section{\module{macpath} --- MacOS path manipulation functions} @@ -41,9 +8,10 @@ \modulesynopsis{MacOS path manipulation functions.} -This module is the Macintosh implementation of the \module{os.path} -module. It is most portably accessed as -\module{os.path}\refstmodindex{os.path}. Refer to the +This module is the Mac OS 9 (and earlier) implementation of the \module{os.path} +module. It can be used to manipulate old-style Macintosh pathnames on Mac OS +X (or any other platform). +Refer to the \citetitle[../lib/lib.html]{Python Library Reference} for documentation of \module{os.path}. Index: libmacic.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/mac/libmacic.tex,v retrieving revision 1.17 retrieving revision 1.17.2.1 diff -u -d -r1.17 -r1.17.2.1 --- libmacic.tex 2 Oct 2004 11:02:58 -0000 1.17 +++ libmacic.tex 13 Feb 2005 22:56:40 -0000 1.17.2.1 @@ -6,13 +6,8 @@ \modulesynopsis{Access to Internet Config.} -This module provides access to Macintosh Internet -Config\index{Internet Config} package, -which stores preferences for Internet programs such as mail address, -default homepage, etc. Also, Internet Config contains an elaborate set -of mappings from Macintosh creator/type codes to foreign filename -extensions plus information on how to transfer files (binary, ascii, -etc.). Since MacOS 9, this module is a control panel named Internet. +This module provides access to various internet-related preferences +set through \program{System Preferences} or the \program{Finder}. There is a low-level companion module \module{icglue}\refbimodindex{icglue} which provides the basic @@ -92,7 +87,7 @@ \begin{methoddesc}{mapfile}{file} Return the mapping entry for the given \var{file}, which can be passed -as either a filename or an \function{macfs.FSSpec()} result, and which +as either a filename or an \function{FSSpec()} result, and which need not exist. The mapping entry is returned as a tuple \code{(\var{version}, @@ -122,7 +117,7 @@ \begin{methoddesc}{settypecreator}{file} Given an existing \var{file}, specified either as a filename or as an -\function{macfs.FSSpec()} result, set its creator and type correctly based +\function{FSSpec()} result, set its creator and type correctly based on its extension. The finder is told about the change, so the finder icon will be updated quickly. \end{methoddesc} Index: libmacos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/mac/libmacos.tex,v retrieving revision 1.22 retrieving revision 1.22.4.1 diff -u -d -r1.22 -r1.22.4.1 --- libmacos.tex 14 Dec 2003 15:02:54 -0000 1.22 +++ libmacos.tex 13 Feb 2005 22:56:41 -0000 1.22.4.1 @@ -14,11 +14,10 @@ artifact. \begin{datadesc}{runtimemodel} -Either\code{'carbon'} or \code{'macho'}. This -signifies whether this Python uses the Mac OS X and Mac OS 9 compatible -CarbonLib style or the Mac OS -X-only Mach-O style. In earlier versions of Python the value could -also be \code{'ppc'} for the classic Mac OS 8 runtime model. +Always \code{'macho'}, from Python 2.4 on. +In earlier versions of Python the value could +also be \code{'ppc'} for the classic Mac OS 8 runtime model or +\code{'carbon'} for the Mac OS 9 runtime model. \end{datadesc} \begin{datadesc}{linkmodel} @@ -26,8 +25,9 @@ incompatible between linking models, packages could use this information to give more decent error messages. The value is one of \code{'static'} for a statically linked Python, \code{'framework'} for Python in a Mac OS X framework, -\code{'shared'} for Python in a standard unix shared library and -\code{'cfm'} for the Mac OS 9-compatible Python. +\code{'shared'} for Python in a standard unix shared library. +Older Pythons could also have the value +\code{'cfm'} for Mac OS 9-compatible Python. \end{datadesc} \begin{excdesc}{Error} @@ -39,84 +39,16 @@ module \refmodule{macerrors}.\refstmodindex{macerrors} \end{excdesc} -\begin{funcdesc}{SetEventHandler}{handler} -In the inner interpreter loop Python will occasionally check for events, -unless disabled with \function{ScheduleParams()}. With this function you -can pass a Python event-handler function that will be called if an event -is available. The event is passed as parameter and the function should return -non-zero if the event has been fully processed, otherwise event processing -continues (by passing the event to the console window package, for instance). - -Call \function{SetEventHandler()} without a parameter to clear the -event handler. Setting an event handler while one is already set is an -error. - -Availability: MacPython-OS9. -\end{funcdesc} - -\begin{funcdesc}{SchedParams}{\optional{doint\optional{, evtmask\optional{, - besocial\optional{, interval\optional{, - bgyield}}}}}} -Influence the interpreter inner loop event handling. \var{Interval} -specifies how often (in seconds, floating point) the interpreter -should enter the event processing code. When true, \var{doint} causes -interrupt (command-dot) checking to be done. \var{evtmask} tells the -interpreter to do event processing for events in the mask (redraws, -mouseclicks to switch to other applications, etc). The \var{besocial} -flag gives other processes a chance to run. They are granted minimal -runtime when Python is in the foreground and \var{bgyield} seconds per -\var{interval} when Python runs in the background. - -All parameters are optional, and default to the current value. The return -value of this function is a tuple with the old values of these options. -Initial defaults are that all processing is enabled, checking is done every -quarter second and the processor is given up for a quarter second when in the -background. - -The most common use case is to call \code{SchedParams(0, 0)} to completely disable -event handling in the interpreter mainloop. - -Availability: MacPython-OS9. -\end{funcdesc} - -\begin{funcdesc}{HandleEvent}{ev} -Pass the event record \var{ev} back to the Python event loop, or -possibly to the handler for the \code{sys.stdout} window (based on the -compiler used to build Python). This allows Python programs that do -their own event handling to still have some command-period and -window-switching capability. - -If you attempt to call this function from an event handler set through -\function{SetEventHandler()} you will get an exception. - -Availability: MacPython-OS9. -\end{funcdesc} \begin{funcdesc}{GetErrorString}{errno} Return the textual description of MacOS error code \var{errno}. \end{funcdesc} -\begin{funcdesc}{splash}{resid} -This function will put a splash window -on-screen, with the contents of the DLOG resource specified by -\var{resid}. Calling with a zero argument will remove the splash -screen. This function is useful if you want an applet to post a splash screen -early in initialization without first having to load numerous -extension modules. - -Availability: MacPython-OS9. -\end{funcdesc} - \begin{funcdesc}{DebugStr}{message \optional{, object}} -On Mac OS 9, drop to the low-level debugger with message \var{message}. The -optional \var{object} argument is not used, but can easily be -inspected from the debugger. On Mac OS X the string is simply printed -to stderr. - -Note that you should use this function with extreme care: if no -low-level debugger like MacsBug is installed this call will crash your -system. It is intended mainly for developers of Python extension -modules. +On Mac OS X the string is simply printed to stderr (on older +Mac OS systems more elaborate functionality was available), +but it provides a convenient location to attach a breakpoint +in a low-level debugger like \program{gdb}. \end{funcdesc} \begin{funcdesc}{SysBeep}{} @@ -155,6 +87,4 @@ bundle. A script runs from an application bundle either when it has been started with \program{pythonw} instead of \program{python} or when running as an applet. - -On Mac OS 9 the method always returns \code{True}. \end{funcdesc} Index: scripting.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/mac/scripting.tex,v retrieving revision 1.3.4.1 retrieving revision 1.3.4.2 diff -u -d -r1.3.4.1 -r1.3.4.2 --- scripting.tex 19 Jan 2005 03:42:10 -0000 1.3.4.1 +++ scripting.tex 13 Feb 2005 22:56:41 -0000 1.3.4.2 @@ -1,9 +1,10 @@ \chapter{MacPython OSA Modules \label{scripting}} -Python has a fairly complete implementation of the Open Scripting -Architecture (OSA, also commonly referred to as AppleScript), allowing +This chapter describes the current implementation of the Open Scripting +Architecure (OSA, also commonly referred to as AppleScript) for Python, allowing you to control scriptable applications from your Python program, -and with a fairly pythonic interface. +and with a fairly pythonic interface. Development on this set of modules +has stopped, and a replacement is expected for Python 2.5. For a description of the various components of AppleScript and OSA, and to get an understanding of the architecture and terminology, you should Index: undoc.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/mac/undoc.tex,v retrieving revision 1.13.4.1 retrieving revision 1.13.4.2 diff -u -d -r1.13.4.1 -r1.13.4.2 --- undoc.tex 1 Jan 2005 00:34:55 -0000 1.13.4.1 +++ undoc.tex 13 Feb 2005 22:56:41 -0000 1.13.4.2 @@ -21,17 +21,7 @@ \modulesynopsis{Helper module for BuildApplet, BuildApplication and macfreeze.} - -\section{\module{py_resource} --- Resources from Python code} -\declaremodule[pyresource]{standard}{py_resource} - \platform{Mac} -\modulesynopsis{Helper to create \texttt{'PYC~'} resources for compiled - applications.} - -This module is primarily used as a help module for -\program{BuildApplet} and \program{BuildApplication}. It is able to -store compiled Python code as \texttt{'PYC~'} resources in a file. - +\deprecated{2.4} \section{\module{cfmfile} --- Code Fragment Resource module} \declaremodule{standard}{cfmfile} @@ -43,6 +33,7 @@ used by BuildApplication to combine all plugin modules to a single executable. +\deprecated{2.4} \section{\module{icopen} --- Internet Config replacement for \method{open()}} \declaremodule{standard}{icopen} @@ -79,30 +70,6 @@ A low-level interface to Navigation Services. -\section{\module{mkcwproject} --- Create CodeWarrior projects} -\declaremodule{standard}{mkcwproject} - \platform{Mac} -\modulesynopsis{Create CodeWarrior projects.} - -\refmodindex{distutils} -\module{mkcwproject} creates project files for the Metrowerks CodeWarrior -development environment. It is a helper module for -\module{distutils} but can be used separately for more -control. - - -\section{\module{nsremote} --- Wrapper around Netscape OSA modules} -\declaremodule{standard}{nsremote} - \platform{Mac} -\modulesynopsis{Wrapper around Netscape OSA modules.} - -\module{nsremote} is a wrapper around the Netscape OSA modules that -allows you to easily send your browser to a given URL. A related -module that may be of interest is the \module{webbrowser} module, -documented in the \citetitle[../lib/lib.html]{Python Library -Reference}. - - \section{\module{PixMapWrapper} --- Wrapper for PixMap objects} \declaremodule{standard}{PixMapWrapper} \platform{Mac} @@ -112,43 +79,6 @@ allows access to the fields by name. It also has methods to convert to and from \module{PIL} images. - -\section{\module{preferences} --- Application preferences manager} -\declaremodule{standard}{preferences} - \platform{Mac} -\modulesynopsis{Nice application preferences manager with support for - defaults.} - -The \module{preferences} module allows storage of user preferences in -the system-wide preferences folder, with defaults coming from the -application itself and the possibility to override preferences for -specific situations. - - -\section{\module{pythonprefs} --- Preferences manager for Python} -\declaremodule{standard}{pythonprefs} - \platform{Mac} -\modulesynopsis{Specialized preferences manager for the Python - interpreter.} - -This module is a specialization of the \refmodule{preferences} module -that allows reading and writing of the preferences for the Python -interpreter. - - -\section{\module{quietconsole} --- Non-visible standard output} -\declaremodule{standard}{quietconsole} - \platform{Mac} -\modulesynopsis{Buffered, non-visible standard output.} - -\module{quietconsole} allows you to keep stdio output in a buffer -without displaying it (or without displaying the stdout window -altogether, if set with \program{EditPythonPrefs}) until you try to read from -stdin or disable the buffering, at which point all the saved output is -sent to the window. Good for programs with graphical user interfaces -that do want to display their output at a crash. - - \section{\module{videoreader} --- Read QuickTime movies} \declaremodule{standard}{videoreader} \platform{Mac} Index: using.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/mac/using.tex,v retrieving revision 1.12.2.2 retrieving revision 1.12.2.3 diff -u -d -r1.12.2.2 -r1.12.2.3 --- using.tex 1 Jan 2005 00:34:55 -0000 1.12.2.2 +++ using.tex 13 Feb 2005 22:56:41 -0000 1.12.2.3 @@ -1,27 +1,25 @@ -\chapter{Using Python on a Mac OS 9 Macintosh \label{using}} +\chapter{Using Python on a Macintosh \label{using}} \sectionauthor{Bob Savage}{bobsavage@mac.com} -Using Python on a Macintosh, especially on Mac OS 9 (MacPython-OSX -includes a complete \UNIX{} Python) can seem like something completely -different than using it on a \UNIX-like or Windows system. Most of the -Python documentation, both the ``official'' documentation and published -books, describe only how Python is used on these systems, causing -confusion for the new user of MacPython-OS9. This chapter gives a brief -introduction to the specifics of using Python on a Macintosh. - - -The section on the IDE (see Section \ref{IDE}) is relevant to MacPython-OSX -too. +Python on a Macintosh running Mac OS X is in principle very similar to +Python on any other \UNIX platform, but there are a number of additional +features such as the IDE and the Package Manager that are worth pointing out. -\section{Getting and Installing MacPython-OSX \label{getting-OSX}} +Python on Mac OS 9 or earlier can be quite different from Python on +Unix or Windows, but is beyond the scope of this manual, as that platform +is no longer supported, starting with Python 2.4. See +\url{http://www.cwi.nl/\textasciitilde jack/macpython} for installers +for the latest 2.3 release for Mac OS 9 and related documentation. -As of Python 2.3a2 the only sure way of getting MacPython-OSX on your machine -is getting a source distribution and building what is called a "framework Python". -The details are in the file \file{Mac/OSX/README}. +\section{Getting and Installing MacPython \label{getting-OSX}} -As binary installers become available the details will be posted to -\url{http://www.cwi.nl/\textasciitilde jack/macpython.html}. +Mac OS X 10.3 comes with Python 2.3 pre-installed by Apple. +This installation does not come with the IDE and other additions, however, +so to get these you need to install the \program{MacPython for Panther additions} +from the MacPython website, \url{http://www.cwi.nl/\textasciitilde jack/macpython}. +For MacPython 2.4, or for any MacPython on earlier releases of Mac OS X, +you need to install a full distribution from the same website. What you get after installing is a number of things: @@ -41,6 +39,14 @@ To uninstall MacPython you can simply remove these three things. +If you use the ``additions'' installer to install on top of an existing +Apple-Python you will not get the framework and the commandline interpreter, +as they have been installed by Apple already, in +\file{/System/Library/Frameworks/Python.framework} and +\file{/usr/bin/python}, respectively. You should in principle never modify +or delete these, as they are Apple-controlled and may be used by Apple- or +third-party software. + PythonIDE contains an Apple Help Viewer book called "MacPython Help" which you can access through its help menu. If you are completely new to Python you should start reading the IDE introduction in that document. @@ -57,18 +63,15 @@ If you want to run Python scripts from the Terminal window command line or from the Finder you first need an editor to create your script. Mac OS X comes with a number of standard \UNIX{} command line editors, -\program{vi} and \program{emacs} among them. If you want a more Mac-like +\program{vim} and \program{emacs} among them. If you want a more Mac-like editor \program{BBEdit} or \program{TextWrangler} from Bare Bones Software (see \url{http://www.barebones.com/products/bbedit/index.shtml}) are -good choices. Their freeware \program{BBEdit Lite} is officially -discontinued but still available. \program{AppleWorks} or any other +good choices. \program{AppleWorks} or any other word processor that can save files in ASCII is also a possibility, including \program{TextEdit} which is included with OS X. To run your script from the Terminal window you must make sure that -\file{/usr/local/bin} is in your shell search path before \file{/usr/bin}, -where the Apple-supplied Python lives (which is version 2.2, as of Mac OS X -10.2.4). +\file{/usr/local/bin} is in your shell search path. To run your script from the Finder you have two options: \begin{itemize} @@ -101,263 +104,6 @@ Installing additional Python packages is most easily done through the Package Manager, see the MacPython Help Book for details. -\section{Getting and Installing MacPython-OS9 \label{getting}} - -The most recent release version as well as possible newer experimental -versions are best found at the MacPython page maintained by Jack -Jansen: \url{http://homepages.cwi.nl/\textasciitilde jack/macpython.html}. - -Please refer to the \file{README} included with your distribution for -the most up-to-date instructions. - -Note that MacPython-OS9 runs fine on Mac OS X, and it runs in native -mode, not in the Classic environment. Unless you have specific -requirements for a CFM-based Python there is no reason not to -use MacPython-OSX, though. - - -\subsection{Entering the interactive Interpreter - \label{interpreter}} - -The interactive interpreter that you will see used in Python -documentation is started by double-clicking the -\program{PythonInterpreter} icon, which looks like a 16-ton weight -falling. You should see the version information and the -\samp{>\code{>}>~} prompt. Use it exactly as described in the -standard documentation. - - -\subsection{How to run a Python script} - -There are several ways to run an existing Python script; two common -ways to run a Python script are ``drag and drop'' and ``double -clicking''. Other ways include running it from within the IDE (see -Section \ref{IDE}), or launching via AppleScript. - - -\subsubsection{Drag and drop} - -One of the easiest ways to launch a Python script is via ``Drag and -Drop''. This is just like launching a text file in the Finder by -``dragging'' it over your word processor's icon and ``dropping'' it -there. Make sure that you use an icon referring to the -\program{PythonInterpreter}, not the \program{IDE} or \program{Idle} -icons which have different behaviour which is described below. - -Some things that might have gone wrong: - -\begin{itemize} -\item -A window flashes after dropping the script onto the -\program{PythonInterpreter}, but then disappears. Most likely this is a -configuration issue; your \program{PythonInterpreter} is setup to exit -immediately upon completion, but your script assumes that if it prints -something that text will stick around for a while. To fix this, see -section \ref{defaults}. - -\item -When you waved the script icon over the \program{PythonInterpreter}, -the \program{PythonInterpreter} icon did not highlight. Most likely -the Creator code and document type is unset (or set incorrectly) -- -this often happens when a file originates on a non-Mac computer. See -section \ref{creator-code} for more details. -\end{itemize} - - -\subsubsection{Set Creator and Double Click \label{creator-code}} - -If the script that you want to launch has the appropriate Creator Code -and File Type you can simply double-click on the script to launch it. -To be ``double-clickable'' a file needs to be of type \samp{TEXT}, -with a creator code of \samp{Pyth}. - -Setting the creator code and filetype can be done with the IDE (see -sections \ref{IDEwrite} and \ref{IDEapplet}), with an editor with a -Python mode (\program{BBEdit}) -- see section -\ref{scripting-with-BBedit}, or with assorted other Mac utilities, but -a script (\file{fixfiletypes.py}) has been included in the MacPython -distribution, making it possible to set the proper Type and Creator -Codes with Python. - -The \file{fixfiletypes.py} script will change the file type and -creator codes for the indicated directory. To use -\file{fixfiletypes.py}: - -\begin{enumerate} -\item -Locate it in the \file{scripts} folder of the \file{Mac} folder of the -MacPython distribution. - -\item -Put all of the scripts that you want to fix in a folder with nothing -else in it. - -\item -Double-click on the \file{fixfiletypes.py} icon. - -\item -Navigate into the folder of files you want to fix, and press the -``Select current folder'' button. -\end{enumerate} - - -\subsection{Simulating command line arguments - \label{argv}} - -There are two ways to simulate command-line arguments with MacPython-OS9. - -\begin{enumerate} -\item via Interpreter options -\begin{itemize} % nestable? I hope so! - \item Hold the option-key down when launching your script. This will - bring up a dialog box of Python Interpreter options. - \item Click ``Set \UNIX-style command line..'' button. - \item Type the arguments into the ``Argument'' field. - \item Click ``OK'' - \item Click ``Run''. -\end{itemize} % end - -\item via drag and drop -If you save the script as an applet (see Section \ref{IDEapplet}), you -can also simulate some command-line arguments via -``Drag-and-Drop''. In this case, the names of the files that were -dropped onto the applet will be appended to \code{sys.argv}, so that -it will appear to the script as though they had been typed on a -command line. As on \UNIX\ systems, the first item in \code{sys.srgv} is -the path to the applet, and the rest are the files dropped on the -applet. -\end{enumerate} - - -\subsection{Creating a Python script} - -Since Python scripts are simply text files, they can be created in any -way that text files can be created, but some special tools also exist -with extra features. - - -\subsubsection{In an editor} - -You can create a text file with any word processing program such as -\program{MSWord} or \program{AppleWorks} but you need to make sure -that the file is saved as ``\ASCII'' or ``plain text''. This also -works for \program{TextEdit}, but you need to use the command ``Make Plain Text`` -in the ``Format`` menu before trying to save. - - -\subsubsection{Editors with Python modes} - -Several text editors have additional features that add functionality -when you are creating a Python script. These can include coloring -Python keywords to make your code easier to read, module browsing, or -a built-in debugger. These include \program{Alpha}, \program{Pepper}, -and \program{BBedit}, and the MacPython IDE (Section \ref{IDE}). - -%\subsubsection{Alpha} -% **NEED INFO HERE** - -\subsubsection{BBedit \label{scripting-with-BBedit}} - -If you use \program{BBEdit} to create your scripts you will want to tell it about the Python creator code so that -you can simply double click on the saved file to launch it. -\begin{itemize} - \item Launch \program{BBEdit}. - \item Select ``Preferences'' from the ``Edit'' menu. - \item Select ``File Types'' from the scrolling list. - \item click on the ``Add...'' button and navigate to - \program{PythonInterpreter} in the main directory of the - MacPython distribution; click ``open''. - \item Click on the ``Save'' button in the Preferences panel. -\end{itemize} -% Are there additional BBedit Python-specific features? I'm not aware of any. - -%\subsubsection{IDE} -%You can use the \program{Python IDE} supplied in the MacPython Distribution to create longer Python scripts -%-- see Section \ref{IDEwrite} for details. - -%\subsubsection{IDLE} -%Idle is an IDE for Python that was written in Python, using TKInter. You should be able to use it on a Mac by following -%the standard documentation, but see Section \ref{TKInter} for guidance on using TKInter with MacPython. - -%\subsubsection{Pepper} -% **NEED INFO HERE** - -\subsection{Configuration \label{configuration}} - -The MacPython distribution comes with \program{EditPythonPrefs}, an -applet which will help you to customize the MacPython environment for -your working habits. - -\subsubsection{EditPythonPrefs\label{EditPythonPrefs}} - -\program{EditPythonPrefs} gives you the capability to configure Python -to behave the way you want it to. There are two ways to use -\program{EditPythonPrefs}, you can use it to set the preferences in -general, or you can drop a particular Python engine onto it to -customize only that version. The latter can be handy if, for example, -you want to have a second copy of the \program{PythonInterpreter} that -keeps the output window open on a normal exit even though you prefer -to normally not work that way. - -To change the default preferences, simply double-click on -\program{EditPythonPrefs}. To change the preferences only for one copy -of the Interpreter, drop the icon for that copy onto -\program{EditPythonPrefs}. You can also use \program{EditPythonPrefs} -in this fashion to set the preferences of the \program{Python IDE} and -any applets you create -- see section %s \ref{BuildApplet} and -\ref{IDEapplet}. - -\subsubsection{Adding modules to the Module Search Path - \label{search-path}} - -When executing an \keyword{import} statement, Python looks for modules -in places defined by the \member{sys.path} To edit the -\member{sys.path} on a Mac, launch \program{EditPythonPrefs}, and -enter them into the largish field at the top (one per line). - -Since MacPython defines a main Python directory, the easiest thing is -to add folders to search within the main Python directory. To add a -folder of scripts that you created called ``My Folder'' located in the -main Python Folder, enter \samp{\$(PYTHON):My Folder} onto a new line. - -To add the Desktop under OS 9 or below, add -\samp{StartupDriveName:Desktop Folder} on a new line. - -\subsubsection{Default startup options \label{defaults}} - -% I'm assuming that there exists some other documentation on the -% rest of the options so I only go over a couple here. - -The ``Default startup options...'' button in the -\program{EditPythonPrefs} dialog box gives you many options including -the ability to keep the ``Output'' window open after the script -terminates, and the ability to enter interactive mode after the -termination of the run script. The latter can be very helpful if you -want to examine the objects that were created during your script. - -%\section{Nifty Tools} -%There are many other tools included with the MacPython -%distribution. In addition to those discussed here, make -%sure to check the \file{Mac} directory. - -%\subsection{BuildApplet \label{BuildApplet}} -% **NEED INFO HERE** - -%\subsection{BuildApplication} -% **NEED INFO HERE** - -%\section{TKInter on the Mac \label{TKInter}} - -%TKinter is installed by default with the MacPython distribution, but -%you may need to add the \file{lib-tk} folder to the Python Path (see -%section \ref{search-path}). Also, it is important that you do not -%try to launch Tk from within the \program{Python IDE} because the two -%event loops will collide -- always run a script which uses Tkinter -%with the \program{PythonInterpreter} instead -- see section -%\ref{interpreter}. - -%\section{CGI on the Mac with Python \label{CGI}} -%**NEED INFO HERE** \section{The IDE\label{IDE}} @@ -365,15 +111,13 @@ separate application that acts as a text editor for your Python code, a class browser, a graphical debugger, and more. +The online Python Help contains a quick walkthrough of the IDE that +shows the major features and how to use them. \subsection{Using the ``Python Interactive'' window} -Use this window like you would the \program{PythonInterpreter}, except -that you cannot use the ``Drag and drop'' method above. Instead, -dropping a script onto the \program{Python IDE} icon will open the -file in a separate script window (which you can then execute manually --- see section \ref{IDEexecution}). - +Use this window like you would use a normal \UNIX{} command line +interpreter. \subsection{Writing a Python Script \label{IDEwrite}} @@ -386,11 +130,6 @@ ``File'' menu. Dropping a Python script onto the \program{Python IDE} will open it for editing. -If you try to open a script with the \program{Python IDE} but either -can't locate it from the ``Open'' dialog box, or you get an error -message like ``Can't open file of type ...'' see section -\ref{creator-code}. - When the \program{Python IDE} saves a script, it uses the creator code settings which are available by clicking on the small black triangle on the top right of the document window, and selecting ``save @@ -398,8 +137,8 @@ IDE} as the creator, this means that you can open the file for editing by simply double-clicking on its icon. You might want to change this behaviour so that it will be opened by the -\program{PythonInterpreter}, and run. To do this simply choose -``Python Interpreter'' from the ``save options''. Note that these +\program{PythonLauncher}, and run. To do this simply choose +``PythonLauncher'' from the ``save options''. Note that these options are associated with the \emph{file} not the application. @@ -449,4 +188,31 @@ %\subsection{The ``Scripts'' menu} % **NEED INFO HERE** - + +\section{The Package Manager} + +Historically MacPython came with a number of useful extension packages +included, because most Macintosh users do not have access to a development +environment and C compiler. For Mac OS X that bundling is no longer done, +but a new mechanism has been made available to allow easy access to +extension packages. + +The Python Package Manager helps you installing additional packages +that enhance Python. It determines the exact MacOS version and Python +version you have and uses that information to download a database that +has packages that are tested and tried on that combination. In other +words: if something is in your Package Manager window but does not work +you are free to blame the database maintainer. + +PackageManager then checks which of the packages you have installed and +which ones are not. This should also work when you have installed packages +outside of PackageManager. You can select packages and install them, +and PackageManager will work out the requirements and install these too. + +Often PackageManager will list a package in two flavors: binary and +source. Binary should always work, source will only work if you have +installed the Apple Developer Tools. PackageManager will warn you about +this, and also about other external dependencies. + +PackageManager is available as a separate application and also as a +function of the IDE, through the File->Package Manager menu entry. From bcannon at users.sourceforge.net Sun Feb 13 23:50:07 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Mon Feb 14 01:00:58 2005 Subject: [Python-checkins] python/dist/src/Doc/mac libframework.tex, 1.12, 1.13 libmac.tex, 1.23, 1.24 libmacic.tex, 1.17, 1.18 libmacos.tex, 1.22, 1.23 scripting.tex, 1.4, 1.5 undoc.tex, 1.14, 1.15 using.tex, 1.14, 1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/mac In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3121/Doc/mac Modified Files: libframework.tex libmac.tex libmacic.tex libmacos.tex scripting.tex undoc.tex using.tex Log Message: Update references specifying "Macintosh" to mean OS X semantics and not Mac OS 9. Applies patch #1095802. Thanks Jack Jansen. Index: libframework.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/mac/libframework.tex,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- libframework.tex 1 Jan 2005 00:28:43 -0000 1.12 +++ libframework.tex 13 Feb 2005 22:50:03 -0000 1.13 @@ -15,7 +15,8 @@ non-standard way it is not necessary to override the complete event handling. -The \module{FrameWork} is still very much work-in-progress, and the +Work on the \module{FrameWork} has pretty much stopped, now that +\module{PyObjC} is available for full Cocoa access from Python, and the documentation describes only the most important functionality, and not in the most logical manner at that. Examine the source or the examples for more details. The following are some comments posted on the Index: libmac.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/mac/libmac.tex,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- libmac.tex 12 Feb 2003 09:58:33 -0000 1.23 +++ libmac.tex 13 Feb 2005 22:50:03 -0000 1.24 @@ -1,36 +1,3 @@ -\section{\module{mac} --- - Implementations for the \module{os} module} - -\declaremodule{builtin}{mac} - \platform{Mac} -\modulesynopsis{Implementations for the \module{os} module.} - - -This module implements the Mac OS 9 operating system dependent functionality -provided by the standard module \module{os}\refstmodindex{os}. It is -best accessed through the \module{os} module. This module is only available in -MacPython-OS9, on MacPython-OSX \module{posix} is used. - -The following functions are available in this module: -\function{chdir()}, -\function{close()}, -\function{dup()}, -\function{fdopen()}, -\function{getcwd()}, -\function{lseek()}, -\function{listdir()}, -\function{mkdir()}, -\function{open()}, -\function{read()}, -\function{rename()}, -\function{rmdir()}, -\function{stat()}, -\function{sync()}, -\function{unlink()}, -\function{write()}, -as well as the exception \exception{error}. Note that the times -returned by \function{stat()} are floating-point values, like all time -values in MacPython-OS9. \section{\module{macpath} --- MacOS path manipulation functions} @@ -41,9 +8,10 @@ \modulesynopsis{MacOS path manipulation functions.} -This module is the Macintosh implementation of the \module{os.path} -module. It is most portably accessed as -\module{os.path}\refstmodindex{os.path}. Refer to the +This module is the Mac OS 9 (and earlier) implementation of the \module{os.path} +module. It can be used to manipulate old-style Macintosh pathnames on Mac OS +X (or any other platform). +Refer to the \citetitle[../lib/lib.html]{Python Library Reference} for documentation of \module{os.path}. Index: libmacic.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/mac/libmacic.tex,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- libmacic.tex 2 Oct 2004 11:02:58 -0000 1.17 +++ libmacic.tex 13 Feb 2005 22:50:03 -0000 1.18 @@ -6,13 +6,8 @@ \modulesynopsis{Access to Internet Config.} -This module provides access to Macintosh Internet -Config\index{Internet Config} package, -which stores preferences for Internet programs such as mail address, -default homepage, etc. Also, Internet Config contains an elaborate set -of mappings from Macintosh creator/type codes to foreign filename -extensions plus information on how to transfer files (binary, ascii, -etc.). Since MacOS 9, this module is a control panel named Internet. +This module provides access to various internet-related preferences +set through \program{System Preferences} or the \program{Finder}. There is a low-level companion module \module{icglue}\refbimodindex{icglue} which provides the basic @@ -92,7 +87,7 @@ \begin{methoddesc}{mapfile}{file} Return the mapping entry for the given \var{file}, which can be passed -as either a filename or an \function{macfs.FSSpec()} result, and which +as either a filename or an \function{FSSpec()} result, and which need not exist. The mapping entry is returned as a tuple \code{(\var{version}, @@ -122,7 +117,7 @@ \begin{methoddesc}{settypecreator}{file} Given an existing \var{file}, specified either as a filename or as an -\function{macfs.FSSpec()} result, set its creator and type correctly based +\function{FSSpec()} result, set its creator and type correctly based on its extension. The finder is told about the change, so the finder icon will be updated quickly. \end{methoddesc} Index: libmacos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/mac/libmacos.tex,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- libmacos.tex 14 Dec 2003 15:02:54 -0000 1.22 +++ libmacos.tex 13 Feb 2005 22:50:04 -0000 1.23 @@ -14,11 +14,10 @@ artifact. \begin{datadesc}{runtimemodel} -Either\code{'carbon'} or \code{'macho'}. This -signifies whether this Python uses the Mac OS X and Mac OS 9 compatible -CarbonLib style or the Mac OS -X-only Mach-O style. In earlier versions of Python the value could -also be \code{'ppc'} for the classic Mac OS 8 runtime model. +Always \code{'macho'}, from Python 2.4 on. +In earlier versions of Python the value could +also be \code{'ppc'} for the classic Mac OS 8 runtime model or +\code{'carbon'} for the Mac OS 9 runtime model. \end{datadesc} \begin{datadesc}{linkmodel} @@ -26,8 +25,9 @@ incompatible between linking models, packages could use this information to give more decent error messages. The value is one of \code{'static'} for a statically linked Python, \code{'framework'} for Python in a Mac OS X framework, -\code{'shared'} for Python in a standard unix shared library and -\code{'cfm'} for the Mac OS 9-compatible Python. +\code{'shared'} for Python in a standard unix shared library. +Older Pythons could also have the value +\code{'cfm'} for Mac OS 9-compatible Python. \end{datadesc} \begin{excdesc}{Error} @@ -39,84 +39,16 @@ module \refmodule{macerrors}.\refstmodindex{macerrors} \end{excdesc} -\begin{funcdesc}{SetEventHandler}{handler} -In the inner interpreter loop Python will occasionally check for events, -unless disabled with \function{ScheduleParams()}. With this function you -can pass a Python event-handler function that will be called if an event -is available. The event is passed as parameter and the function should return -non-zero if the event has been fully processed, otherwise event processing -continues (by passing the event to the console window package, for instance). - -Call \function{SetEventHandler()} without a parameter to clear the -event handler. Setting an event handler while one is already set is an -error. - -Availability: MacPython-OS9. -\end{funcdesc} - -\begin{funcdesc}{SchedParams}{\optional{doint\optional{, evtmask\optional{, - besocial\optional{, interval\optional{, - bgyield}}}}}} -Influence the interpreter inner loop event handling. \var{Interval} -specifies how often (in seconds, floating point) the interpreter -should enter the event processing code. When true, \var{doint} causes -interrupt (command-dot) checking to be done. \var{evtmask} tells the -interpreter to do event processing for events in the mask (redraws, -mouseclicks to switch to other applications, etc). The \var{besocial} -flag gives other processes a chance to run. They are granted minimal -runtime when Python is in the foreground and \var{bgyield} seconds per -\var{interval} when Python runs in the background. - -All parameters are optional, and default to the current value. The return -value of this function is a tuple with the old values of these options. -Initial defaults are that all processing is enabled, checking is done every -quarter second and the processor is given up for a quarter second when in the -background. - -The most common use case is to call \code{SchedParams(0, 0)} to completely disable -event handling in the interpreter mainloop. - -Availability: MacPython-OS9. -\end{funcdesc} - -\begin{funcdesc}{HandleEvent}{ev} -Pass the event record \var{ev} back to the Python event loop, or -possibly to the handler for the \code{sys.stdout} window (based on the -compiler used to build Python). This allows Python programs that do -their own event handling to still have some command-period and -window-switching capability. - -If you attempt to call this function from an event handler set through -\function{SetEventHandler()} you will get an exception. - -Availability: MacPython-OS9. -\end{funcdesc} \begin{funcdesc}{GetErrorString}{errno} Return the textual description of MacOS error code \var{errno}. \end{funcdesc} -\begin{funcdesc}{splash}{resid} -This function will put a splash window -on-screen, with the contents of the DLOG resource specified by -\var{resid}. Calling with a zero argument will remove the splash -screen. This function is useful if you want an applet to post a splash screen -early in initialization without first having to load numerous -extension modules. - -Availability: MacPython-OS9. -\end{funcdesc} - \begin{funcdesc}{DebugStr}{message \optional{, object}} -On Mac OS 9, drop to the low-level debugger with message \var{message}. The -optional \var{object} argument is not used, but can easily be -inspected from the debugger. On Mac OS X the string is simply printed -to stderr. - -Note that you should use this function with extreme care: if no -low-level debugger like MacsBug is installed this call will crash your -system. It is intended mainly for developers of Python extension -modules. +On Mac OS X the string is simply printed to stderr (on older +Mac OS systems more elaborate functionality was available), +but it provides a convenient location to attach a breakpoint +in a low-level debugger like \program{gdb}. \end{funcdesc} \begin{funcdesc}{SysBeep}{} @@ -155,6 +87,4 @@ bundle. A script runs from an application bundle either when it has been started with \program{pythonw} instead of \program{python} or when running as an applet. - -On Mac OS 9 the method always returns \code{True}. \end{funcdesc} Index: scripting.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/mac/scripting.tex,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- scripting.tex 19 Jan 2005 03:39:17 -0000 1.4 +++ scripting.tex 13 Feb 2005 22:50:04 -0000 1.5 @@ -1,9 +1,10 @@ \chapter{MacPython OSA Modules \label{scripting}} -Python has a fairly complete implementation of the Open Scripting -Architecture (OSA, also commonly referred to as AppleScript), allowing +This chapter describes the current implementation of the Open Scripting +Architecure (OSA, also commonly referred to as AppleScript) for Python, allowing you to control scriptable applications from your Python program, -and with a fairly pythonic interface. +and with a fairly pythonic interface. Development on this set of modules +has stopped, and a replacement is expected for Python 2.5. For a description of the various components of AppleScript and OSA, and to get an understanding of the architecture and terminology, you should Index: undoc.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/mac/undoc.tex,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- undoc.tex 1 Jan 2005 00:28:43 -0000 1.14 +++ undoc.tex 13 Feb 2005 22:50:04 -0000 1.15 @@ -21,17 +21,7 @@ \modulesynopsis{Helper module for BuildApplet, BuildApplication and macfreeze.} - -\section{\module{py_resource} --- Resources from Python code} -\declaremodule[pyresource]{standard}{py_resource} - \platform{Mac} -\modulesynopsis{Helper to create \texttt{'PYC~'} resources for compiled - applications.} - -This module is primarily used as a help module for -\program{BuildApplet} and \program{BuildApplication}. It is able to -store compiled Python code as \texttt{'PYC~'} resources in a file. - +\deprecated{2.4} \section{\module{cfmfile} --- Code Fragment Resource module} \declaremodule{standard}{cfmfile} @@ -43,6 +33,7 @@ used by BuildApplication to combine all plugin modules to a single executable. +\deprecated{2.4} \section{\module{icopen} --- Internet Config replacement for \method{open()}} \declaremodule{standard}{icopen} @@ -79,30 +70,6 @@ A low-level interface to Navigation Services. -\section{\module{mkcwproject} --- Create CodeWarrior projects} -\declaremodule{standard}{mkcwproject} - \platform{Mac} -\modulesynopsis{Create CodeWarrior projects.} - -\refmodindex{distutils} -\module{mkcwproject} creates project files for the Metrowerks CodeWarrior -development environment. It is a helper module for -\module{distutils} but can be used separately for more -control. - - -\section{\module{nsremote} --- Wrapper around Netscape OSA modules} -\declaremodule{standard}{nsremote} - \platform{Mac} -\modulesynopsis{Wrapper around Netscape OSA modules.} - -\module{nsremote} is a wrapper around the Netscape OSA modules that -allows you to easily send your browser to a given URL. A related -module that may be of interest is the \module{webbrowser} module, -documented in the \citetitle[../lib/lib.html]{Python Library -Reference}. - - \section{\module{PixMapWrapper} --- Wrapper for PixMap objects} \declaremodule{standard}{PixMapWrapper} \platform{Mac} @@ -112,43 +79,6 @@ allows access to the fields by name. It also has methods to convert to and from \module{PIL} images. - -\section{\module{preferences} --- Application preferences manager} -\declaremodule{standard}{preferences} - \platform{Mac} -\modulesynopsis{Nice application preferences manager with support for - defaults.} - -The \module{preferences} module allows storage of user preferences in -the system-wide preferences folder, with defaults coming from the -application itself and the possibility to override preferences for -specific situations. - - -\section{\module{pythonprefs} --- Preferences manager for Python} -\declaremodule{standard}{pythonprefs} - \platform{Mac} -\modulesynopsis{Specialized preferences manager for the Python - interpreter.} - -This module is a specialization of the \refmodule{preferences} module -that allows reading and writing of the preferences for the Python -interpreter. - - -\section{\module{quietconsole} --- Non-visible standard output} -\declaremodule{standard}{quietconsole} - \platform{Mac} -\modulesynopsis{Buffered, non-visible standard output.} - -\module{quietconsole} allows you to keep stdio output in a buffer -without displaying it (or without displaying the stdout window -altogether, if set with \program{EditPythonPrefs}) until you try to read from -stdin or disable the buffering, at which point all the saved output is -sent to the window. Good for programs with graphical user interfaces -that do want to display their output at a crash. - - \section{\module{videoreader} --- Read QuickTime movies} \declaremodule{standard}{videoreader} \platform{Mac} Index: using.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/mac/using.tex,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- using.tex 1 Jan 2005 00:28:43 -0000 1.14 +++ using.tex 13 Feb 2005 22:50:04 -0000 1.15 @@ -1,27 +1,25 @@ -\chapter{Using Python on a Mac OS 9 Macintosh \label{using}} +\chapter{Using Python on a Macintosh \label{using}} \sectionauthor{Bob Savage}{bobsavage@mac.com} -Using Python on a Macintosh, especially on Mac OS 9 (MacPython-OSX -includes a complete \UNIX{} Python) can seem like something completely -different than using it on a \UNIX-like or Windows system. Most of the -Python documentation, both the ``official'' documentation and published -books, describe only how Python is used on these systems, causing -confusion for the new user of MacPython-OS9. This chapter gives a brief -introduction to the specifics of using Python on a Macintosh. - - -The section on the IDE (see Section \ref{IDE}) is relevant to MacPython-OSX -too. +Python on a Macintosh running Mac OS X is in principle very similar to +Python on any other \UNIX platform, but there are a number of additional +features such as the IDE and the Package Manager that are worth pointing out. -\section{Getting and Installing MacPython-OSX \label{getting-OSX}} +Python on Mac OS 9 or earlier can be quite different from Python on +Unix or Windows, but is beyond the scope of this manual, as that platform +is no longer supported, starting with Python 2.4. See +\url{http://www.cwi.nl/\textasciitilde jack/macpython} for installers +for the latest 2.3 release for Mac OS 9 and related documentation. -As of Python 2.3a2 the only sure way of getting MacPython-OSX on your machine -is getting a source distribution and building what is called a "framework Python". -The details are in the file \file{Mac/OSX/README}. +\section{Getting and Installing MacPython \label{getting-OSX}} -As binary installers become available the details will be posted to -\url{http://www.cwi.nl/\textasciitilde jack/macpython.html}. +Mac OS X 10.3 comes with Python 2.3 pre-installed by Apple. +This installation does not come with the IDE and other additions, however, +so to get these you need to install the \program{MacPython for Panther additions} +from the MacPython website, \url{http://www.cwi.nl/\textasciitilde jack/macpython}. +For MacPython 2.4, or for any MacPython on earlier releases of Mac OS X, +you need to install a full distribution from the same website. What you get after installing is a number of things: @@ -41,6 +39,14 @@ To uninstall MacPython you can simply remove these three things. +If you use the ``additions'' installer to install on top of an existing +Apple-Python you will not get the framework and the commandline interpreter, +as they have been installed by Apple already, in +\file{/System/Library/Frameworks/Python.framework} and +\file{/usr/bin/python}, respectively. You should in principle never modify +or delete these, as they are Apple-controlled and may be used by Apple- or +third-party software. + PythonIDE contains an Apple Help Viewer book called "MacPython Help" which you can access through its help menu. If you are completely new to Python you should start reading the IDE introduction in that document. @@ -57,18 +63,15 @@ If you want to run Python scripts from the Terminal window command line or from the Finder you first need an editor to create your script. Mac OS X comes with a number of standard \UNIX{} command line editors, -\program{vi} and \program{emacs} among them. If you want a more Mac-like +\program{vim} and \program{emacs} among them. If you want a more Mac-like editor \program{BBEdit} or \program{TextWrangler} from Bare Bones Software (see \url{http://www.barebones.com/products/bbedit/index.shtml}) are -good choices. Their freeware \program{BBEdit Lite} is officially -discontinued but still available. \program{AppleWorks} or any other +good choices. \program{AppleWorks} or any other word processor that can save files in ASCII is also a possibility, including \program{TextEdit} which is included with OS X. To run your script from the Terminal window you must make sure that -\file{/usr/local/bin} is in your shell search path before \file{/usr/bin}, -where the Apple-supplied Python lives (which is version 2.2, as of Mac OS X -10.2.4). +\file{/usr/local/bin} is in your shell search path. To run your script from the Finder you have two options: \begin{itemize} @@ -101,263 +104,6 @@ Installing additional Python packages is most easily done through the Package Manager, see the MacPython Help Book for details. -\section{Getting and Installing MacPython-OS9 \label{getting}} - -The most recent release version as well as possible newer experimental -versions are best found at the MacPython page maintained by Jack -Jansen: \url{http://homepages.cwi.nl/\textasciitilde jack/macpython.html}. - -Please refer to the \file{README} included with your distribution for -the most up-to-date instructions. - -Note that MacPython-OS9 runs fine on Mac OS X, and it runs in native -mode, not in the Classic environment. Unless you have specific -requirements for a CFM-based Python there is no reason not to -use MacPython-OSX, though. - - -\subsection{Entering the interactive Interpreter - \label{interpreter}} - -The interactive interpreter that you will see used in Python -documentation is started by double-clicking the -\program{PythonInterpreter} icon, which looks like a 16-ton weight -falling. You should see the version information and the -\samp{>\code{>}>~} prompt. Use it exactly as described in the -standard documentation. - - -\subsection{How to run a Python script} - -There are several ways to run an existing Python script; two common -ways to run a Python script are ``drag and drop'' and ``double -clicking''. Other ways include running it from within the IDE (see -Section \ref{IDE}), or launching via AppleScript. - - -\subsubsection{Drag and drop} - -One of the easiest ways to launch a Python script is via ``Drag and -Drop''. This is just like launching a text file in the Finder by -``dragging'' it over your word processor's icon and ``dropping'' it -there. Make sure that you use an icon referring to the -\program{PythonInterpreter}, not the \program{IDE} or \program{Idle} -icons which have different behaviour which is described below. - -Some things that might have gone wrong: - -\begin{itemize} -\item -A window flashes after dropping the script onto the -\program{PythonInterpreter}, but then disappears. Most likely this is a -configuration issue; your \program{PythonInterpreter} is setup to exit -immediately upon completion, but your script assumes that if it prints -something that text will stick around for a while. To fix this, see -section \ref{defaults}. - -\item -When you waved the script icon over the \program{PythonInterpreter}, -the \program{PythonInterpreter} icon did not highlight. Most likely -the Creator code and document type is unset (or set incorrectly) -- -this often happens when a file originates on a non-Mac computer. See -section \ref{creator-code} for more details. -\end{itemize} - - -\subsubsection{Set Creator and Double Click \label{creator-code}} - -If the script that you want to launch has the appropriate Creator Code -and File Type you can simply double-click on the script to launch it. -To be ``double-clickable'' a file needs to be of type \samp{TEXT}, -with a creator code of \samp{Pyth}. - -Setting the creator code and filetype can be done with the IDE (see -sections \ref{IDEwrite} and \ref{IDEapplet}), with an editor with a -Python mode (\program{BBEdit}) -- see section -\ref{scripting-with-BBedit}, or with assorted other Mac utilities, but -a script (\file{fixfiletypes.py}) has been included in the MacPython -distribution, making it possible to set the proper Type and Creator -Codes with Python. - -The \file{fixfiletypes.py} script will change the file type and -creator codes for the indicated directory. To use -\file{fixfiletypes.py}: - -\begin{enumerate} -\item -Locate it in the \file{scripts} folder of the \file{Mac} folder of the -MacPython distribution. - -\item -Put all of the scripts that you want to fix in a folder with nothing -else in it. - -\item -Double-click on the \file{fixfiletypes.py} icon. - -\item -Navigate into the folder of files you want to fix, and press the -``Select current folder'' button. -\end{enumerate} - - -\subsection{Simulating command line arguments - \label{argv}} - -There are two ways to simulate command-line arguments with MacPython-OS9. - -\begin{enumerate} -\item via Interpreter options -\begin{itemize} % nestable? I hope so! - \item Hold the option-key down when launching your script. This will - bring up a dialog box of Python Interpreter options. - \item Click ``Set \UNIX-style command line..'' button. - \item Type the arguments into the ``Argument'' field. - \item Click ``OK'' - \item Click ``Run''. -\end{itemize} % end - -\item via drag and drop -If you save the script as an applet (see Section \ref{IDEapplet}), you -can also simulate some command-line arguments via -``Drag-and-Drop''. In this case, the names of the files that were -dropped onto the applet will be appended to \code{sys.argv}, so that -it will appear to the script as though they had been typed on a -command line. As on \UNIX\ systems, the first item in \code{sys.srgv} is -the path to the applet, and the rest are the files dropped on the -applet. -\end{enumerate} - - -\subsection{Creating a Python script} - -Since Python scripts are simply text files, they can be created in any -way that text files can be created, but some special tools also exist -with extra features. - - -\subsubsection{In an editor} - -You can create a text file with any word processing program such as -\program{MSWord} or \program{AppleWorks} but you need to make sure -that the file is saved as ``\ASCII'' or ``plain text''. This also -works for \program{TextEdit}, but you need to use the command ``Make Plain Text`` -in the ``Format`` menu before trying to save. - - -\subsubsection{Editors with Python modes} - -Several text editors have additional features that add functionality -when you are creating a Python script. These can include coloring -Python keywords to make your code easier to read, module browsing, or -a built-in debugger. These include \program{Alpha}, \program{Pepper}, -and \program{BBedit}, and the MacPython IDE (Section \ref{IDE}). - -%\subsubsection{Alpha} -% **NEED INFO HERE** - -\subsubsection{BBedit \label{scripting-with-BBedit}} - -If you use \program{BBEdit} to create your scripts you will want to tell it about the Python creator code so that -you can simply double click on the saved file to launch it. -\begin{itemize} - \item Launch \program{BBEdit}. - \item Select ``Preferences'' from the ``Edit'' menu. - \item Select ``File Types'' from the scrolling list. - \item click on the ``Add...'' button and navigate to - \program{PythonInterpreter} in the main directory of the - MacPython distribution; click ``open''. - \item Click on the ``Save'' button in the Preferences panel. -\end{itemize} -% Are there additional BBedit Python-specific features? I'm not aware of any. - -%\subsubsection{IDE} -%You can use the \program{Python IDE} supplied in the MacPython Distribution to create longer Python scripts -%-- see Section \ref{IDEwrite} for details. - -%\subsubsection{IDLE} -%Idle is an IDE for Python that was written in Python, using TKInter. You should be able to use it on a Mac by following -%the standard documentation, but see Section \ref{TKInter} for guidance on using TKInter with MacPython. - -%\subsubsection{Pepper} -% **NEED INFO HERE** - -\subsection{Configuration \label{configuration}} - -The MacPython distribution comes with \program{EditPythonPrefs}, an -applet which will help you to customize the MacPython environment for -your working habits. - -\subsubsection{EditPythonPrefs\label{EditPythonPrefs}} - -\program{EditPythonPrefs} gives you the capability to configure Python -to behave the way you want it to. There are two ways to use -\program{EditPythonPrefs}, you can use it to set the preferences in -general, or you can drop a particular Python engine onto it to -customize only that version. The latter can be handy if, for example, -you want to have a second copy of the \program{PythonInterpreter} that -keeps the output window open on a normal exit even though you prefer -to normally not work that way. - -To change the default preferences, simply double-click on -\program{EditPythonPrefs}. To change the preferences only for one copy -of the Interpreter, drop the icon for that copy onto -\program{EditPythonPrefs}. You can also use \program{EditPythonPrefs} -in this fashion to set the preferences of the \program{Python IDE} and -any applets you create -- see section %s \ref{BuildApplet} and -\ref{IDEapplet}. - -\subsubsection{Adding modules to the Module Search Path - \label{search-path}} - -When executing an \keyword{import} statement, Python looks for modules -in places defined by the \member{sys.path} To edit the -\member{sys.path} on a Mac, launch \program{EditPythonPrefs}, and -enter them into the largish field at the top (one per line). - -Since MacPython defines a main Python directory, the easiest thing is -to add folders to search within the main Python directory. To add a -folder of scripts that you created called ``My Folder'' located in the -main Python Folder, enter \samp{\$(PYTHON):My Folder} onto a new line. - -To add the Desktop under OS 9 or below, add -\samp{StartupDriveName:Desktop Folder} on a new line. - -\subsubsection{Default startup options \label{defaults}} - -% I'm assuming that there exists some other documentation on the -% rest of the options so I only go over a couple here. - -The ``Default startup options...'' button in the -\program{EditPythonPrefs} dialog box gives you many options including -the ability to keep the ``Output'' window open after the script -terminates, and the ability to enter interactive mode after the -termination of the run script. The latter can be very helpful if you -want to examine the objects that were created during your script. - -%\section{Nifty Tools} -%There are many other tools included with the MacPython -%distribution. In addition to those discussed here, make -%sure to check the \file{Mac} directory. - -%\subsection{BuildApplet \label{BuildApplet}} -% **NEED INFO HERE** - -%\subsection{BuildApplication} -% **NEED INFO HERE** - -%\section{TKInter on the Mac \label{TKInter}} - -%TKinter is installed by default with the MacPython distribution, but -%you may need to add the \file{lib-tk} folder to the Python Path (see -%section \ref{search-path}). Also, it is important that you do not -%try to launch Tk from within the \program{Python IDE} because the two -%event loops will collide -- always run a script which uses Tkinter -%with the \program{PythonInterpreter} instead -- see section -%\ref{interpreter}. - -%\section{CGI on the Mac with Python \label{CGI}} -%**NEED INFO HERE** \section{The IDE\label{IDE}} @@ -365,15 +111,13 @@ separate application that acts as a text editor for your Python code, a class browser, a graphical debugger, and more. +The online Python Help contains a quick walkthrough of the IDE that +shows the major features and how to use them. \subsection{Using the ``Python Interactive'' window} -Use this window like you would the \program{PythonInterpreter}, except -that you cannot use the ``Drag and drop'' method above. Instead, -dropping a script onto the \program{Python IDE} icon will open the -file in a separate script window (which you can then execute manually --- see section \ref{IDEexecution}). - +Use this window like you would use a normal \UNIX{} command line +interpreter. \subsection{Writing a Python Script \label{IDEwrite}} @@ -386,11 +130,6 @@ ``File'' menu. Dropping a Python script onto the \program{Python IDE} will open it for editing. -If you try to open a script with the \program{Python IDE} but either -can't locate it from the ``Open'' dialog box, or you get an error -message like ``Can't open file of type ...'' see section -\ref{creator-code}. - When the \program{Python IDE} saves a script, it uses the creator code settings which are available by clicking on the small black triangle on the top right of the document window, and selecting ``save @@ -398,8 +137,8 @@ IDE} as the creator, this means that you can open the file for editing by simply double-clicking on its icon. You might want to change this behaviour so that it will be opened by the -\program{PythonInterpreter}, and run. To do this simply choose -``Python Interpreter'' from the ``save options''. Note that these +\program{PythonLauncher}, and run. To do this simply choose +``PythonLauncher'' from the ``save options''. Note that these options are associated with the \emph{file} not the application. @@ -449,4 +188,31 @@ %\subsection{The ``Scripts'' menu} % **NEED INFO HERE** - + +\section{The Package Manager} + +Historically MacPython came with a number of useful extension packages +included, because most Macintosh users do not have access to a development +environment and C compiler. For Mac OS X that bundling is no longer done, +but a new mechanism has been made available to allow easy access to +extension packages. + +The Python Package Manager helps you installing additional packages +that enhance Python. It determines the exact MacOS version and Python +version you have and uses that information to download a database that +has packages that are tested and tried on that combination. In other +words: if something is in your Package Manager window but does not work +you are free to blame the database maintainer. + +PackageManager then checks which of the packages you have installed and +which ones are not. This should also work when you have installed packages +outside of PackageManager. You can select packages and install them, +and PackageManager will work out the requirements and install these too. + +Often PackageManager will list a package in two flavors: binary and +source. Binary should always work, source will only work if you have +installed the Apple Developer Tools. PackageManager will warn you about +this, and also about other external dependencies. + +PackageManager is available as a separate application and also as a +function of the IDE, through the File->Package Manager menu entry. From astrand at users.sourceforge.net Mon Feb 14 09:56:35 2005 From: astrand at users.sourceforge.net (astrand@users.sourceforge.net) Date: Mon Feb 14 09:56:38 2005 Subject: [Python-checkins] python/dist/src/Lib subprocess.py,1.15,1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4900 Modified Files: subprocess.py Log Message: Added copyright notice: Licensed to PSF under a Contributor Agreement. Index: subprocess.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/subprocess.py,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- subprocess.py 10 Feb 2005 08:32:50 -0000 1.15 +++ subprocess.py 14 Feb 2005 08:56:32 -0000 1.16 @@ -4,6 +4,8 @@ # # Copyright (c) 2003-2004 by Peter Astrand # +# Licensed to PSF under a Contributor Agreement. +# # By obtaining, using, and/or copying this software and/or its # associated documentation, you agree that you have read, understood, # and will comply with the following terms and conditions: From just at letterror.com Mon Feb 14 10:23:03 2005 From: just at letterror.com (Just van Rossum) Date: Mon Feb 14 10:23:06 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libimp.tex, 1.36, 1.36.2.1 libsite.tex, 1.26, 1.26.4.1 libtempfile.tex, 1.22, 1.22.4.1 libos.tex, 1.146.2.1, 1.146.2.2 In-Reply-To: Message-ID: bcannon@users.sourceforge.net wrote: > \begin{datadesc}{PY_RESOURCE} > -The module was found as a Macintosh resource. This value can only be > -returned on a Macintosh. > +The module was found as a Mac OS 9 resource. This value can only be > +returned on a Mac OS 9 or earlier Macintosh. > \end{datadesc} not entirely true: it's limited to the sa called "OS9" version of MacPython, which happily runs natively on OSX as a Carbon app... Just From mwh at users.sourceforge.net Tue Feb 15 16:22:45 2005 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue Feb 15 16:22:50 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_tempfile.py, 1.18, 1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31678 Modified Files: test_tempfile.py Log Message: Exceedingly minor tweak. Index: test_tempfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_tempfile.py,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- test_tempfile.py 15 Sep 2004 06:02:54 -0000 1.18 +++ test_tempfile.py 15 Feb 2005 15:22:37 -0000 1.19 @@ -307,7 +307,7 @@ retval = os.spawnl(os.P_WAIT, sys.executable, decorated, tester, v, fd) self.failIf(retval < 0, "child process caught fatal signal %d" % -retval) - self.failIf(retval > 0, "child process reports failure") + self.failIf(retval > 0, "child process reports failure %d"%retval) def test_textmode(self): # _mkstemp_inner can create files in text mode From mwh at users.sourceforge.net Tue Feb 15 16:26:14 2005 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue Feb 15 16:26:18 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_sys.py,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32682 Modified Files: test_sys.py Log Message: Test that SystemExits are handled properly by the exit machinery. I broke the "raise SystemExit(46)" case when doing new-style exceptions, but I'd much rather have found out here than in test_tempfile (growl). Index: test_sys.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_sys.py,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- test_sys.py 6 Jul 2003 18:36:54 -0000 1.8 +++ test_sys.py 15 Feb 2005 15:26:11 -0000 1.9 @@ -161,6 +161,18 @@ else: self.fail("no exception") + # test that the exit machinery handles SystemExits properly + import subprocess + # both unnormalized... + rc = subprocess.call([sys.executable, "-c", + "raise SystemExit, 46"]) + self.assertEqual(rc, 46) + # ... and normalized + rc = subprocess.call([sys.executable, "-c", + "raise SystemExit(47)"]) + self.assertEqual(rc, 47) + + def test_getdefaultencoding(self): if test.test_support.have_unicode: self.assertRaises(TypeError, sys.getdefaultencoding, 42) From tim_one at users.sourceforge.net Tue Feb 15 17:22:37 2005 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Tue Feb 15 17:22:40 2005 Subject: [Python-checkins] python/dist/src/Lib pickletools.py,1.29,1.30 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12464/Lib Modified Files: pickletools.py Log Message: An instance of class PicklingError was used here simply as an example of _some_ user-defined class instance. That it was also an exception isn't interesting, but does interfere with Michael Hudson's new-style exception patch. This just changes the doctest example, to use an instance of a non-exception class. Index: pickletools.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pickletools.py,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- pickletools.py 7 Dec 2004 08:26:10 -0000 1.29 +++ pickletools.py 15 Feb 2005 16:22:34 -0000 1.30 @@ -1996,6 +1996,11 @@ if stack: raise ValueError("stack not empty after STOP: %r" % stack) +# For use in the doctest, simply as an example of a class to pickle. +class _Example: + def __init__(self, value): + self.value = value + _dis_test = r""" >>> import pickle >>> x = [1, 2, (3, 4), {'abc': u"def"}] @@ -2060,27 +2065,27 @@ 18: . STOP highest protocol among opcodes = 0 ->>> x = [pickle.PicklingError()] * 2 +>>> from pickletools import _Example +>>> x = [_Example(42)] * 2 >>> dis(pickle.dumps(x, 0)) 0: ( MARK 1: l LIST (MARK at 0) 2: p PUT 0 5: ( MARK - 6: i INST 'pickle PicklingError' (MARK at 5) + 6: i INST 'pickletools _Example' (MARK at 5) 28: p PUT 1 31: ( MARK 32: d DICT (MARK at 31) 33: p PUT 2 - 36: S STRING 'args' - 44: p PUT 3 - 47: ( MARK - 48: t TUPLE (MARK at 47) - 49: s SETITEM - 50: b BUILD - 51: a APPEND - 52: g GET 1 - 55: a APPEND - 56: . STOP + 36: S STRING 'value' + 45: p PUT 3 + 48: I INT 42 + 52: s SETITEM + 53: b BUILD + 54: a APPEND + 55: g GET 1 + 58: a APPEND + 59: . STOP highest protocol among opcodes = 0 >>> dis(pickle.dumps(x, 1)) @@ -2088,20 +2093,20 @@ 1: q BINPUT 0 3: ( MARK 4: ( MARK - 5: c GLOBAL 'pickle PicklingError' + 5: c GLOBAL 'pickletools _Example' 27: q BINPUT 1 29: o OBJ (MARK at 4) 30: q BINPUT 2 32: } EMPTY_DICT 33: q BINPUT 3 - 35: U SHORT_BINSTRING 'args' - 41: q BINPUT 4 - 43: ) EMPTY_TUPLE - 44: s SETITEM - 45: b BUILD - 46: h BINGET 2 - 48: e APPENDS (MARK at 3) - 49: . STOP + 35: U SHORT_BINSTRING 'value' + 42: q BINPUT 4 + 44: K BININT1 42 + 46: s SETITEM + 47: b BUILD + 48: h BINGET 2 + 50: e APPENDS (MARK at 3) + 51: . STOP highest protocol among opcodes = 1 Try "the canonical" recursive-object test. From tim_one at users.sourceforge.net Tue Feb 15 22:50:16 2005 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Tue Feb 15 22:50:19 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_sys.py,1.9,1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30094 Modified Files: test_sys.py Log Message: Whitespace normalization. Index: test_sys.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_sys.py,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- test_sys.py 15 Feb 2005 15:26:11 -0000 1.9 +++ test_sys.py 15 Feb 2005 21:50:12 -0000 1.10 @@ -171,8 +171,8 @@ rc = subprocess.call([sys.executable, "-c", "raise SystemExit(47)"]) self.assertEqual(rc, 47) - - + + def test_getdefaultencoding(self): if test.test_support.have_unicode: self.assertRaises(TypeError, sys.getdefaultencoding, 42) From bcannon at users.sourceforge.net Wed Feb 16 01:07:43 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Wed Feb 16 01:07:47 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1241,1.1242 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31917/Misc Modified Files: NEWS Log Message: spwdmodule.c should only be built when either HAVE_GETSPNAM or HAVE_GETSPENT is defined. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1241 retrieving revision 1.1242 diff -u -d -r1.1241 -r1.1242 --- NEWS 13 Feb 2005 22:53:22 -0000 1.1241 +++ NEWS 16 Feb 2005 00:07:19 -0000 1.1242 @@ -152,6 +152,9 @@ Build ----- +- spwdmodule.c is built only if either HAVE_GETSPNAM or HAVE_HAVE_GETSPENT is + defined. Discovered as a result of not being able to build on OS X. + - setup.py now uses the directories specified in LDFLAGS using the -L option and in CPPFLAGS using the -I option for adding library and include directories, respectively, for compiling extension modules against. This has From bcannon at users.sourceforge.net Wed Feb 16 01:07:52 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Wed Feb 16 01:07:55 2005 Subject: [Python-checkins] python/dist/src setup.py,1.212,1.213 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31917 Modified Files: setup.py Log Message: spwdmodule.c should only be built when either HAVE_GETSPNAM or HAVE_GETSPENT is defined. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.212 retrieving revision 1.213 diff -u -d -r1.212 -r1.213 --- setup.py 23 Jan 2005 09:27:22 -0000 1.212 +++ setup.py 16 Feb 2005 00:07:16 -0000 1.213 @@ -384,12 +384,14 @@ # fcntl(2) and ioctl(2) exts.append( Extension('fcntl', ['fcntlmodule.c']) ) if platform not in ['mac']: - # pwd(3) + # pwd(3) exts.append( Extension('pwd', ['pwdmodule.c']) ) # grp(3) exts.append( Extension('grp', ['grpmodule.c']) ) # spwd, shadow passwords - exts.append( Extension('spwd', ['spwdmodule.c']) ) + if (sysconfig.get_config_var('HAVE_GETSPNAM') or + sysconfig.get_config_var('HAVE_GETSPENT')): + exts.append( Extension('spwd', ['spwdmodule.c']) ) # select(2); not on ancient System V exts.append( Extension('select', ['selectmodule.c']) ) From evandro_hdkwe8 at yahoo.com.br Wed Feb 16 00:50:02 2005 From: evandro_hdkwe8 at yahoo.com.br (evandro) Date: Wed Feb 16 04:50:14 2005 Subject: [Python-checkins] Listas de e-mails: http://www.gueb.de/segmails Message-ID: <15j8-1xh0n$6b6oawk0d-typk5@0gbvj> Listas de e-mails selecionadas: Visite agora: http://www.gueb.de/segmails Cadastros de e-mails para mala direta, divulgaÿFFFFE7ÿFFFFE3o de sites, listas de e-mails,mailing list,listagem,cadastros,listas de e-mail,marketing direto,mmv,publicidade,divulgaÿFFFFE7ÿFFFFE3o,mp3,e-mails segmentados,home page,bulk mail,playboy,propaganda,maladireta,maling list,sexo bulk mail,mailing list,e-maling,listas,cadastros,email,emaiu,emeiu,emaiu,emaius E-mails para Mala Direta/Marketing Direto genÿFFFFE9ricos ou segmentados por ramo de atividade,sexo,idade,cidade,estado Visite agora: http://www.gueb.de/segmails From rhettinger at users.sourceforge.net Wed Feb 16 10:27:52 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Feb 16 10:27:54 2005 Subject: [Python-checkins] python/dist/src/Lib zipfile.py,1.34,1.35 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31564 Modified Files: zipfile.py Log Message: Remove dependency on order of mode flags Index: zipfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/zipfile.py,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- zipfile.py 6 Nov 2004 00:31:51 -0000 1.34 +++ zipfile.py 16 Feb 2005 09:27:49 -0000 1.35 @@ -193,7 +193,7 @@ self.NameToInfo = {} # Find file info given name self.filelist = [] # List of ZipInfo instances for archive self.compression = compression # Method of compression - self.mode = key = mode[0].replace('b', '') + self.mode = key = mode.replace('b', '')[0] # Check if we were passed a file-like object if isinstance(file, basestring): From rhettinger at users.sourceforge.net Wed Feb 16 10:30:20 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Feb 16 10:30:24 2005 Subject: [Python-checkins] python/dist/src/Lib zipfile.py,1.34,1.34.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32157 Modified Files: Tag: release24-maint zipfile.py Log Message: Remove dependency on order of mode flags Index: zipfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/zipfile.py,v retrieving revision 1.34 retrieving revision 1.34.2.1 diff -u -d -r1.34 -r1.34.2.1 --- zipfile.py 6 Nov 2004 00:31:51 -0000 1.34 +++ zipfile.py 16 Feb 2005 09:30:17 -0000 1.34.2.1 @@ -193,7 +193,7 @@ self.NameToInfo = {} # Find file info given name self.filelist = [] # List of ZipInfo instances for archive self.compression = compression # Method of compression - self.mode = key = mode[0].replace('b', '') + self.mode = key = mode.replace('b', '')[0] # Check if we were passed a file-like object if isinstance(file, basestring): From bcannon at users.sourceforge.net Thu Feb 17 06:16:21 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Thu Feb 17 06:16:24 2005 Subject: [Python-checkins] python/dist/src/Doc/api concrete.tex, 1.58.2.1, 1.58.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1087/Doc/api Modified Files: Tag: release24-maint concrete.tex Log Message: Fix name from PyDate_FromDateAndTime to PyDateTime_FromDateAndTime. Closes bug #1124278. Index: concrete.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/concrete.tex,v retrieving revision 1.58.2.1 retrieving revision 1.58.2.2 diff -u -d -r1.58.2.1 -r1.58.2.2 --- concrete.tex 10 Dec 2004 17:13:51 -0000 1.58.2.1 +++ concrete.tex 17 Feb 2005 05:16:19 -0000 1.58.2.2 @@ -2793,7 +2793,7 @@ \versionadded{2.4} \end{cfuncdesc} -\begin{cfuncdesc}{PyObject*}{PyDate_FromDateAndTime}{int year, int month, +\begin{cfuncdesc}{PyObject*}{PyDateTime_FromDateAndTime}{int year, int month, int day, int hour, int minute, int second, int usecond} Return a \code{datetime.datetime} object with the specified year, month, day, hour, minute, second and microsecond. From bcannon at users.sourceforge.net Thu Feb 17 06:17:20 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Thu Feb 17 06:17:23 2005 Subject: [Python-checkins] python/dist/src/Doc/api concrete.tex,1.59,1.60 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1280/Doc/api Modified Files: concrete.tex Log Message: Fix name for PyDateTime_FromDateAndTime. Closes bug #1124278. Index: concrete.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/concrete.tex,v retrieving revision 1.59 retrieving revision 1.60 diff -u -d -r1.59 -r1.60 --- concrete.tex 10 Dec 2004 17:12:32 -0000 1.59 +++ concrete.tex 17 Feb 2005 05:17:17 -0000 1.60 @@ -2793,7 +2793,7 @@ \versionadded{2.4} \end{cfuncdesc} -\begin{cfuncdesc}{PyObject*}{PyDate_FromDateAndTime}{int year, int month, +\begin{cfuncdesc}{PyObject*}{PyDateTime_FromDateAndTime}{int year, int month, int day, int hour, int minute, int second, int usecond} Return a \code{datetime.datetime} object with the specified year, month, day, hour, minute, second and microsecond. From mwh at users.sourceforge.net Thu Feb 17 11:37:30 2005 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Thu Feb 17 11:37:32 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_funcattrs.py, 1.16, 1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3732/Lib/test Modified Files: test_funcattrs.py Log Message: Fix [ 1124295 ] Function's __name__ no longer accessible in restricted mode which I introduced with a bit of mindless copy-paste when making __name__ writable. You can't assign to __name__ in restricted mode, which I'm going to pretend was intentional :) Index: test_funcattrs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_funcattrs.py,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- test_funcattrs.py 28 Oct 2004 16:31:59 -0000 1.16 +++ test_funcattrs.py 17 Feb 2005 10:37:21 -0000 1.17 @@ -276,6 +276,9 @@ verify(f.func_name == "h") cantset(f, "func_globals", 1) cantset(f, "__name__", 1) + # test that you can access func.__name__ in restricted mode + s = """def f(): pass\nf.__name__""" + exec s in {'__builtins__':{}} def test_func_code(): From mwh at users.sourceforge.net Thu Feb 17 11:37:30 2005 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Thu Feb 17 11:37:33 2005 Subject: [Python-checkins] python/dist/src/Objects funcobject.c,2.67,2.68 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3732/Objects Modified Files: funcobject.c Log Message: Fix [ 1124295 ] Function's __name__ no longer accessible in restricted mode which I introduced with a bit of mindless copy-paste when making __name__ writable. You can't assign to __name__ in restricted mode, which I'm going to pretend was intentional :) Index: funcobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/funcobject.c,v retrieving revision 2.67 retrieving revision 2.68 diff -u -d -r2.67 -r2.68 --- funcobject.c 28 Oct 2004 16:32:00 -0000 2.67 +++ funcobject.c 17 Feb 2005 10:37:21 -0000 2.68 @@ -262,8 +262,6 @@ static PyObject * func_get_name(PyFunctionObject *op) { - if (restricted()) - return NULL; Py_INCREF(op->func_name); return op->func_name; } From mwh at users.sourceforge.net Thu Feb 17 11:43:15 2005 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Thu Feb 17 11:43:17 2005 Subject: [Python-checkins] python/dist/src/Objects funcobject.c, 2.67, 2.67.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5089/Objects Modified Files: Tag: release24-maint funcobject.c Log Message: Backport: Fix [ 1124295 ] Function's __name__ no longer accessible in restricted mode which I introduced with a bit of mindless copy-paste when making __name__ writable. You can't assign to __name__ in restricted mode, which I'm going to pretend was intentional :) Index: funcobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/funcobject.c,v retrieving revision 2.67 retrieving revision 2.67.2.1 diff -u -d -r2.67 -r2.67.2.1 --- funcobject.c 28 Oct 2004 16:32:00 -0000 2.67 +++ funcobject.c 17 Feb 2005 10:43:12 -0000 2.67.2.1 @@ -262,8 +262,6 @@ static PyObject * func_get_name(PyFunctionObject *op) { - if (restricted()) - return NULL; Py_INCREF(op->func_name); return op->func_name; } From mwh at users.sourceforge.net Thu Feb 17 11:43:15 2005 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Thu Feb 17 11:43:18 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_funcattrs.py, 1.16, 1.16.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5089/Lib/test Modified Files: Tag: release24-maint test_funcattrs.py Log Message: Backport: Fix [ 1124295 ] Function's __name__ no longer accessible in restricted mode which I introduced with a bit of mindless copy-paste when making __name__ writable. You can't assign to __name__ in restricted mode, which I'm going to pretend was intentional :) Index: test_funcattrs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_funcattrs.py,v retrieving revision 1.16 retrieving revision 1.16.2.1 diff -u -d -r1.16 -r1.16.2.1 --- test_funcattrs.py 28 Oct 2004 16:31:59 -0000 1.16 +++ test_funcattrs.py 17 Feb 2005 10:43:12 -0000 1.16.2.1 @@ -276,6 +276,9 @@ verify(f.func_name == "h") cantset(f, "func_globals", 1) cantset(f, "__name__", 1) + # test that you can access func.__name__ in restricted mode + s = """def f(): pass\nf.__name__""" + exec s in {'__builtins__':{}} def test_func_code(): From aimacintyre at users.sourceforge.net Thu Feb 17 13:44:55 2005 From: aimacintyre at users.sourceforge.net (aimacintyre@users.sourceforge.net) Date: Thu Feb 17 13:44:57 2005 Subject: [Python-checkins] python/dist/src/PC/os2emx Makefile,1.19,1.20 Message-ID: Update of /cvsroot/python/python/dist/src/PC/os2emx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32465 Modified Files: Makefile Log Message: add build machinery for the SSL socket module Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/os2emx/Makefile,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- Makefile 17 Jan 2005 12:18:12 -0000 1.19 +++ Makefile 17 Feb 2005 12:44:51 -0000 1.20 @@ -59,6 +59,8 @@ HAVE_GDBM= no # Do you have the BZ2 compression library installed? HAVE_BZ2= no +# Do you have the OpenSSL libraries installed +HAVE_OPENSSL= no # === install locations === # default value of PYTHONHOME @@ -476,6 +478,9 @@ ifeq ($(HAVE_BZ2),yes) HARDEXTMODULES+= bz2 endif +ifeq ($(HAVE_OPENSSL),yes) + HARDEXTMODULES+= _ssl +endif # Expat is now distributed with the Python source HARDEXTMODULES+= pyexpat @@ -671,6 +676,9 @@ bz2$(MODULE.EXT): $(OUT)bz2module$O $(OUT)bz2_m.def $(PYTHON.IMPLIB) $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lbz2 +_ssl$(MODULE.EXT): $(OUT)_ssl$O $(OUT)_ssl_m.def $(PYTHON.IMPLIB) + $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lssl -lcrypto + # the test target test: -find ../../Lib -name "*.py[co]" -exec rm {} ";" From aimacintyre at users.sourceforge.net Thu Feb 17 13:46:38 2005 From: aimacintyre at users.sourceforge.net (aimacintyre@users.sourceforge.net) Date: Thu Feb 17 13:46:41 2005 Subject: [Python-checkins] python/dist/src/PC/os2emx README.os2emx, 1.10, 1.11 Message-ID: Update of /cvsroot/python/python/dist/src/PC/os2emx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32757 Modified Files: README.os2emx Log Message: add notes about subprocess module & thread stacks, SSL support Index: README.os2emx =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/os2emx/README.os2emx,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- README.os2emx 3 Oct 2004 08:26:36 -0000 1.10 +++ README.os2emx 17 Feb 2005 12:46:34 -0000 1.11 @@ -330,6 +330,7 @@ ncurses HAVE_NCURSES GNU gdbm HAVE_GDBM libbz2 HAVE_BZ2 + OpenSSL HAVE_OPENSSL Please note that you need to check that what you have installed is compatible with Python's build options. In particular, the @@ -651,6 +652,22 @@ 27. As of Python 2.4, the mpz, rotor and xreadlines modules have been dropped from the Python source tree. +28. The subprocess module was added to the standard library relatively +late in the 2.4 development cycle. Unfortunately I haven't had the +round tuits to adapt the module to the EMX environment yet, and +test_subprocess has a number of failures as a result. + +29. The default stack size for threads has been 64k. This is proving +insufficient for some codebases, such as Zope. The thread stack size +still defaults to 64k, but this can now be increased by defining +THREAD_STACK_SIZE to an appropriate value in the Makefile (which contains +a commented out definition for 128kB thread stacks). I have seen +references to heavy Zope/Plone usage requiring 1MB thread stacks on +FreeBSD and Linux, but doubt that for most likely usage on OS/2 that +more than 256kB is necessary. The size of the required stacks (main +and thread) can vary significantly depending on which version of gcc +is used along with the compiler optimisations selected. + ... probably other issues that I've not encountered, or don't remember :-( If you encounter other difficulties with this port, which can be @@ -690,4 +707,4 @@ E-mail: andymac@bullseye.apana.org.au, or andymac@pcug.org.au Web: http://www.andymac.org/ -3 October, 2004. +17 February, 2005. From aimacintyre at users.sourceforge.net Thu Feb 17 13:47:06 2005 From: aimacintyre at users.sourceforge.net (aimacintyre@users.sourceforge.net) Date: Thu Feb 17 13:47:08 2005 Subject: [Python-checkins] python/dist/src/PC/os2emx Makefile, 1.18.2.1, 1.18.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/PC/os2emx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv397 Modified Files: Tag: release24-maint Makefile Log Message: add build machinery for the SSL socket module Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/os2emx/Makefile,v retrieving revision 1.18.2.1 retrieving revision 1.18.2.2 diff -u -d -r1.18.2.1 -r1.18.2.2 --- Makefile 17 Jan 2005 12:20:31 -0000 1.18.2.1 +++ Makefile 17 Feb 2005 12:47:03 -0000 1.18.2.2 @@ -59,6 +59,8 @@ HAVE_GDBM= no # Do you have the BZ2 compression library installed? HAVE_BZ2= no +# Do you have the OpenSSL libraries installed +HAVE_OPENSSL= no # === install locations === # default value of PYTHONHOME @@ -476,6 +478,9 @@ ifeq ($(HAVE_BZ2),yes) HARDEXTMODULES+= bz2 endif +ifeq ($(HAVE_OPENSSL),yes) + HARDEXTMODULES+= _ssl +endif # Expat is now distributed with the Python source HARDEXTMODULES+= pyexpat @@ -671,6 +676,9 @@ bz2$(MODULE.EXT): $(OUT)bz2module$O $(OUT)bz2_m.def $(PYTHON.IMPLIB) $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lbz2 +_ssl$(MODULE.EXT): $(OUT)_ssl$O $(OUT)_ssl_m.def $(PYTHON.IMPLIB) + $(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS) -lssl -lcrypto + # the test target test: -find ../../Lib -name "*.py[co]" -exec rm {} ";" From aimacintyre at users.sourceforge.net Thu Feb 17 13:47:45 2005 From: aimacintyre at users.sourceforge.net (aimacintyre@users.sourceforge.net) Date: Thu Feb 17 13:47:48 2005 Subject: [Python-checkins] python/dist/src/PC/os2emx README.os2emx, 1.10, 1.10.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/PC/os2emx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv546 Modified Files: Tag: release24-maint README.os2emx Log Message: add notes about subprocess module & thread stacks, SSL support Index: README.os2emx =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/os2emx/README.os2emx,v retrieving revision 1.10 retrieving revision 1.10.2.1 diff -u -d -r1.10 -r1.10.2.1 --- README.os2emx 3 Oct 2004 08:26:36 -0000 1.10 +++ README.os2emx 17 Feb 2005 12:47:42 -0000 1.10.2.1 @@ -330,6 +330,7 @@ ncurses HAVE_NCURSES GNU gdbm HAVE_GDBM libbz2 HAVE_BZ2 + OpenSSL HAVE_OPENSSL Please note that you need to check that what you have installed is compatible with Python's build options. In particular, the @@ -651,6 +652,22 @@ 27. As of Python 2.4, the mpz, rotor and xreadlines modules have been dropped from the Python source tree. +28. The subprocess module was added to the standard library relatively +late in the 2.4 development cycle. Unfortunately I haven't had the +round tuits to adapt the module to the EMX environment yet, and +test_subprocess has a number of failures as a result. + +29. The default stack size for threads has been 64k. This is proving +insufficient for some codebases, such as Zope. The thread stack size +still defaults to 64k, but this can now be increased by defining +THREAD_STACK_SIZE to an appropriate value in the Makefile (which contains +a commented out definition for 128kB thread stacks). I have seen +references to heavy Zope/Plone usage requiring 1MB thread stacks on +FreeBSD and Linux, but doubt that for most likely usage on OS/2 that +more than 256kB is necessary. The size of the required stacks (main +and thread) can vary significantly depending on which version of gcc +is used along with the compiler optimisations selected. + ... probably other issues that I've not encountered, or don't remember :-( If you encounter other difficulties with this port, which can be @@ -690,4 +707,4 @@ E-mail: andymac@bullseye.apana.org.au, or andymac@pcug.org.au Web: http://www.andymac.org/ -3 October, 2004. +17 February, 2005. From aimacintyre at users.sourceforge.net Thu Feb 17 13:50:30 2005 From: aimacintyre at users.sourceforge.net (aimacintyre@users.sourceforge.net) Date: Thu Feb 17 13:50:32 2005 Subject: [Python-checkins] python/dist/src/PC/os2emx README.os2emx, 1.11, 1.12 Message-ID: Update of /cvsroot/python/python/dist/src/PC/os2emx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1206 Modified Files: README.os2emx Log Message: update version numbers Index: README.os2emx =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/os2emx/README.os2emx,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- README.os2emx 17 Feb 2005 12:46:34 -0000 1.11 +++ README.os2emx 17 Feb 2005 12:50:27 -0000 1.12 @@ -1,4 +1,4 @@ -This is a port of Python 2.4 to OS/2 using the EMX development tools +This is a port of Python 2.5 to OS/2 using the EMX development tools ========================================================================= What's new since the previous release @@ -10,11 +10,11 @@ Licenses and info about Python and EMX -------------------------------------- -Please read the file README.Python-2.4 included in this package for -information about Python 2.4. This file is the README file from the -Python 2.4 source distribution available via http://www.python.org/ -and its mirrors. The file LICENCE.Python-2.4 is the text of the Licence -from the Python 2.4 source distribution. +Please read the file README.Python-2.5 included in this package for +information about Python 2.5. This file is the README file from the +Python 2.5 source distribution available via http://www.python.org/ +and its mirrors. The file LICENCE.Python-2.5 is the text of the Licence +from the Python 2.5 source distribution. Note that the EMX package that this package depends on is released under the GNU General Public Licence. Please refer to the documentation @@ -46,7 +46,7 @@ The best known would be that by Jeff Rush, most recently of version 1.5.2. Jeff used IBM's Visual Age C++ (v3) for his ports, and his -patches have been included in the Python 2.4 source distribution. +patches have been included in the Python 2.5 source distribution. Andy Zabolotny implemented a port of Python v1.5.2 using the EMX development tools. His patches against the Python v1.5.2 source @@ -92,7 +92,7 @@ to compile & link the executable. This is so that fork() works (see "YOU HAVE BEEN WARNED" item 1). -Python24.dll is created as a normal OMF DLL, with an OMF import +Python25.dll is created as a normal OMF DLL, with an OMF import library and module definition file. There is also an a.out (.a) import library to support linking the DLL to a.out executables. The DLL requires the EMX runtime DLLs. @@ -148,7 +148,7 @@ Upstream source patches: -No updates to the Python 2.4 release have become available. +No updates to the Python 2.5 release have become available. Eberhard Mattes' EMXFIX04 update to his EMX 0.9d tools suite includes bug fixes for the BSD DB library. The bsddb module included in this @@ -157,7 +157,7 @@ Library and other distributed Python code: The Python standard library lives in the Lib directory. All the standard -library code included with the Python 2.4 source distribution is included +library code included with the Python 2.5 source distribution is included in the binary archive, with the exception of the dos-8x3 and tkinter subdirectories which have been omitted to reduce the size of the binary archive - the dos-8x3 components are unnecessary duplicates and Tkinter @@ -172,7 +172,7 @@ also been omitted. All subdirectories omitted from the binary archive can be reconstituted -from the Python 2.4 source distribution, if desired. +from the Python 2.5 source distribution, if desired. Support for building Python extensions: @@ -190,15 +190,15 @@ --------- This port is packaged as follows: -- python-2.4-os2emx-bin-03????.zip (binaries, library modules) -- python-2.4-os2emx-src-03???? (patches+makefiles for non-Python code) +- python-2.5-os2emx-bin-03????.zip (binaries, library modules) +- python-2.5-os2emx-src-03???? (patches+makefiles for non-Python code) As all the Python specific patches for the port are now part of the Python release tarball, only the patches and makefiles involved in building external libraries for optional extensions are included in the source archive. -Documentation for the Python language, as well as the Python 2.4 +Documentation for the Python language, as well as the Python 2.5 source distibution, can be obtained from the Python website (http://www.python.org/) or the Python project pages at Sourceforge (http://sf.net/projects/python/). @@ -213,7 +213,7 @@ Unpack this archive, preserving the subdirectories, in the root directory of the drive where you want Python to live. -Add the Python directory (eg C:\Python24) to the PATH and LIBPATH +Add the Python directory (eg C:\Python25) to the PATH and LIBPATH variables in CONFIG.SYS. You should then set the PYTHONHOME and PYTHONPATH environment variables @@ -223,9 +223,9 @@ should be set to the semicolon separated list of principal Python library directories. I use: - SET PYTHONHOME=F:/Python24 - SET PYTHONPATH=F:/Python24/Lib;F:/Python24/Lib/plat-os2emx; - F:/Python24/Lib/lib-dynload;F:/Python24/Lib/site-packages + SET PYTHONHOME=F:/Python25 + SET PYTHONPATH=F:/Python25/Lib;F:/Python25/Lib/plat-os2emx; + F:/Python25/Lib/lib-dynload;F:/Python25/Lib/site-packages NOTE!: the PYTHONPATH setting above is linewrapped for this document - it should all be on one line in CONFIG.SYS! @@ -238,7 +238,7 @@ distribution. This can be used by setting the TERMINFO environment variable to the path of the Terminfo subdirectory below the Python home directory. On my system this looks like: - SET TERMINFO=F:/Python24/Terminfo + SET TERMINFO=F:/Python25/Terminfo For the TERM environment variable, I would try one of the following: SET TERM=ansi @@ -252,8 +252,8 @@ you can change into the Python home directory and run the COMPILEALL.CMD batch file. -You can execute the regression tests included with the Python 2.4 source -distribution by changing to the Python 2.4 home directory and executing the +You can execute the regression tests included with the Python 2.5 source +distribution by changing to the Python 2.5 home directory and executing the REGRTEST.CMD batch file. The following tests are known to fail at this time: - test_mhlib (I don't know of any port of MH to OS/2); @@ -299,7 +299,7 @@ 1. decide if you need to change the location of the Python installation. If you wish to do this, set the value of the Makefile variable LIB_DIR to the directory you wish to use for PYTHONHOME - (eg /usr/local/lib/python2.4). + (eg /usr/local/lib/python2.5). If you want Python to find its library without the PYTHONHOME environment variable set, set the value of the Makefile variable @@ -309,7 +309,7 @@ to be installed in a directory other than the PYTHONHOME directory, set the value of the Makefile variable EXE_DIR to the appropriate directory. -3. If you wish the Python core DLL (python24.dll) to be installed in a +3. If you wish the Python core DLL (python25.dll) to be installed in a directory other than the directory in which the Python executables are installed (by default, the PYTHONHOME directory), set the value of the Makefile variable DLL_DIR to the appropriate directory. This DLL must From mwh at users.sourceforge.net Thu Feb 17 15:55:26 2005 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Thu Feb 17 15:55:29 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1242,1.1243 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30396 Modified Files: NEWS Log Message: NEWS blurb for fix of: [ 1124295 ] Function's __name__ no longer accessible in restricted mode Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1242 retrieving revision 1.1243 diff -u -d -r1.1242 -r1.1243 --- NEWS 16 Feb 2005 00:07:19 -0000 1.1242 +++ NEWS 17 Feb 2005 14:55:21 -0000 1.1243 @@ -10,6 +10,9 @@ Core and builtins ----------------- +- Bug #1124295: the __name__ attribute of file objects was + inadvertently made inaccessible in restricted mode. + - Bug #1074011: closing sys.std{out,err} now causes a flush() and an ferror() call. From mwh at users.sourceforge.net Thu Feb 17 15:57:07 2005 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Thu Feb 17 15:57:10 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.20, 1.1193.2.21 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30839 Modified Files: Tag: release24-maint NEWS Log Message: Backport: NEWS blurb for fix of: [ 1124295 ] Function's __name__ no longer accessible in restricted mode Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.20 retrieving revision 1.1193.2.21 diff -u -d -r1.1193.2.20 -r1.1193.2.21 --- NEWS 13 Feb 2005 22:56:41 -0000 1.1193.2.20 +++ NEWS 17 Feb 2005 14:57:04 -0000 1.1193.2.21 @@ -12,6 +12,9 @@ Core and builtins ----------------- +- Bug #1124295: the __name__ attribute of file objects was + inadvertently made inaccessible in restricted mode. + - Bug #1074011: closing sys.std{out,err} now causes a flush() and an ferror() call. From doerwalter at users.sourceforge.net Thu Feb 17 19:51:50 2005 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Thu Feb 17 19:51:53 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_userstring.py, 1.13, 1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26604/Lib/test Modified Files: test_userstring.py Log Message: Add a basic test for UserString.MutableString. Index: test_userstring.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_userstring.py,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- test_userstring.py 4 Aug 2004 07:38:33 -0000 1.13 +++ test_userstring.py 17 Feb 2005 18:51:48 -0000 1.14 @@ -5,7 +5,7 @@ import unittest from test import test_support, string_tests -from UserString import UserString +from UserString import UserString, MutableString class UserStringTest( string_tests.CommonTest, @@ -43,8 +43,15 @@ # we don't fix the arguments, because UserString can't cope with it getattr(object, methodname)(*args) +class MutableStringTest(UserStringTest): + type2test = MutableString + + # MutableStrings can be hashed => deactivate test + def test_hash(self): + pass + def test_main(): - test_support.run_unittest(UserStringTest) + test_support.run_unittest(UserStringTest, MutableStringTest) if __name__ == "__main__": test_main() From Jack.Jansen at cwi.nl Thu Feb 17 21:46:03 2005 From: Jack.Jansen at cwi.nl (Jack Jansen) Date: Thu Feb 17 21:46:04 2005 Subject: [Python-Dev] Re: [Python-checkins] python/dist/src/Doc/lib libimp.tex, 1.36, 1.36.2.1 libsite.tex, 1.26, 1.26.4.1 libtempfile.tex, 1.22, 1.22.4.1 libos.tex, 1.146.2.1, 1.146.2.2 In-Reply-To: References: Message-ID: On 14-feb-05, at 10:23, Just van Rossum wrote: > bcannon@users.sourceforge.net wrote: > >> \begin{datadesc}{PY_RESOURCE} >> -The module was found as a Macintosh resource. This value can only be >> -returned on a Macintosh. >> +The module was found as a Mac OS 9 resource. This value can only be >> +returned on a Mac OS 9 or earlier Macintosh. >> \end{datadesc} > > not entirely true: it's limited to the sa called "OS9" version of > MacPython, which happily runs natively on OSX as a Carbon app... But as of 2.4 there's no such thing as MacPython-OS9 any more. But as the constant is still in there I thought it best to document it. -- Jack Jansen, , http://www.cwi.nl/~jack If I can't dance I don't want to be part of your revolution -- Emma Goldman From loewis at users.sourceforge.net Thu Feb 17 22:23:23 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Feb 17 22:23:26 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_os.py,1.29,1.30 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1766/Lib/test Modified Files: test_os.py Log Message: Avoid using items() in environ.update(). Fixes #1124513. Will backport to 2.4. Index: test_os.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_os.py,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- test_os.py 29 Jan 2005 13:29:23 -0000 1.29 +++ test_os.py 17 Feb 2005 21:23:20 -0000 1.30 @@ -227,7 +227,7 @@ os.environ.update(self.__save) # Bug 1110478 - def test_update(self): + def test_update2(self): if os.path.exists("/bin/sh"): os.environ.update(HELLO="World") value = os.popen("/bin/sh -c 'echo $HELLO'").read().strip() From loewis at users.sourceforge.net Thu Feb 17 22:23:32 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Feb 17 22:23:34 2005 Subject: [Python-checkins] python/dist/src/Lib os.py,1.85,1.86 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1766/Lib Modified Files: os.py Log Message: Avoid using items() in environ.update(). Fixes #1124513. Will backport to 2.4. Index: os.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/os.py,v retrieving revision 1.85 retrieving revision 1.86 diff -u -d -r1.85 -r1.86 --- os.py 29 Jan 2005 13:29:22 -0000 1.85 +++ os.py 17 Feb 2005 21:23:20 -0000 1.86 @@ -445,12 +445,17 @@ def update(self, dict=None, **kwargs): if dict: try: - items = dict.items() + keys = dict.keys() except AttributeError: # List of (key, value) - items = dict - for k, v in items: - self[k] = v + for k, v in dict: + self[k] = v + else: + # got keys + # cannot use items(), since mappings + # may not have them. + for k in keys: + self[k] = dict[k] if kwargs: self.update(kwargs) def copy(self): @@ -467,12 +472,17 @@ def update(self, dict=None, **kwargs): if dict: try: - items = dict.items() + keys = dict.keys() except AttributeError: # List of (key, value) - items = dict - for k, v in items: - self[k] = v + for k, v in dict: + self[k] = v + else: + # got keys + # cannot use items(), since mappings + # may not have them. + for k in keys: + self[k] = dict[k] if kwargs: self.update(kwargs) try: From loewis at users.sourceforge.net Thu Feb 17 22:23:45 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Feb 17 22:23:48 2005 Subject: [Python-checkins] python/dist/src/Lib os.py,1.83.2.1,1.83.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1983/Lib Modified Files: Tag: release24-maint os.py Log Message: Avoid using items() in environ.update(). Fixes #1124513. Index: os.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/os.py,v retrieving revision 1.83.2.1 retrieving revision 1.83.2.2 diff -u -d -r1.83.2.1 -r1.83.2.2 --- os.py 29 Jan 2005 13:33:23 -0000 1.83.2.1 +++ os.py 17 Feb 2005 21:23:42 -0000 1.83.2.2 @@ -438,12 +438,17 @@ def update(self, dict=None, **kwargs): if dict: try: - items = dict.items() + keys = dict.keys() except AttributeError: # List of (key, value) - items = dict - for k, v in items: - self[k] = v + for k, v in dict: + self[k] = v + else: + # got keys + # cannot use items(), since mappings + # may not have them. + for k in keys: + self[k] = dict[k] if kwargs: self.update(kwargs) def copy(self): @@ -460,12 +465,17 @@ def update(self, dict=None, **kwargs): if dict: try: - items = dict.items() + keys = dict.keys() except AttributeError: # List of (key, value) - items = dict - for k, v in items: - self[k] = v + for k, v in dict: + self[k] = v + else: + # got keys + # cannot use items(), since mappings + # may not have them. + for k in keys: + self[k] = dict[k] if kwargs: self.update(kwargs) try: From doerwalter at users.sourceforge.net Thu Feb 17 23:03:40 2005 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Thu Feb 17 23:03:43 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_userstring.py, 1.14, 1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11375/Lib/test Modified Files: test_userstring.py Log Message: Add tests for the methods added by UserString.MutableString. Index: test_userstring.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_userstring.py,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- test_userstring.py 17 Feb 2005 18:51:48 -0000 1.14 +++ test_userstring.py 17 Feb 2005 22:03:31 -0000 1.15 @@ -50,6 +50,68 @@ def test_hash(self): pass + def test_setitem(self): + s = self.type2test("foo") + self.assertRaises(IndexError, s.__setitem__, -1, "bar") + self.assertRaises(IndexError, s.__setitem__, 3, "bar") + s[0] = "bar" + self.assertEqual(s, "baroo") + s[4] = "foo" + self.assertEqual(s, "barofoo") + + def test_delitem(self): + s = self.type2test("foo") + self.assertRaises(IndexError, s.__setitem__, -1, "bar") + self.assertRaises(IndexError, s.__setitem__, 3, "bar") + del s[0] + self.assertEqual(s, "oo") + del s[1] + self.assertEqual(s, "o") + del s[0] + self.assertEqual(s, "") + + def test_setslice(self): + s = self.type2test("foo") + s[:] = "bar" + self.assertEqual(s, "bar") + s[1:2] = "foo" + self.assertEqual(s, "bfoor") + s[1:-1] = UserString("a") + self.assertEqual(s, "bar") + s[0:10] = 42 + self.assertEqual(s, "42") + + def test_delslice(self): + s = self.type2test("foobar") + del s[3:10] + self.assertEqual(s, "foo") + del s[-1:10] + self.assertEqual(s, "fo") + + def test_immutable(self): + s = self.type2test("foobar") + s2 = s.immutable() + self.assertEqual(s, s2) + self.assert_(isinstance(s2, UserString)) + + def test_iadd(self): + s = self.type2test("foo") + s += "bar" + self.assertEqual(s, "foobar") + s += UserString("baz") + self.assertEqual(s, "foobarbaz") + s += 42 + self.assertEqual(s, "foobarbaz42") + + def test_imul(self): + s = self.type2test("foo") + s *= 1 + self.assertEqual(s, "foo") + s *= 2 + self.assertEqual(s, "foofoo") + s *= -1 + self.assertEqual(s, "") + def test_main(): test_support.run_unittest(UserStringTest, MutableStringTest) From doerwalter at users.sourceforge.net Thu Feb 17 23:31:31 2005 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Thu Feb 17 23:31:33 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_userstring.py, 1.15, 1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20918/Lib/test Modified Files: test_userstring.py Log Message: Fix copy & paste error. Index: test_userstring.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_userstring.py,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- test_userstring.py 17 Feb 2005 22:03:31 -0000 1.15 +++ test_userstring.py 17 Feb 2005 22:31:28 -0000 1.16 @@ -61,8 +61,8 @@ def test_delitem(self): s = self.type2test("foo") - self.assertRaises(IndexError, s.__setitem__, -1, "bar") - self.assertRaises(IndexError, s.__setitem__, 3, "bar") + self.assertRaises(IndexError, s.__delitem__, -1) + self.assertRaises(IndexError, s.__delitem__, 3) del s[0] self.assertEqual(s, "oo") del s[1] From vsajip at users.sourceforge.net Fri Feb 18 12:50:13 2005 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Fri Feb 18 12:50:18 2005 Subject: [Python-checkins] python/dist/src/Doc/lib liblogging.tex,1.34,1.35 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27496/lib Modified Files: liblogging.tex Log Message: Fixed documentation for SMTPHandler Index: liblogging.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liblogging.tex,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- liblogging.tex 2 Dec 2004 21:27:42 -0000 1.34 +++ liblogging.tex 18 Feb 2005 11:50:11 -0000 1.35 @@ -1133,8 +1133,7 @@ \begin{classdesc}{SMTPHandler}{mailhost, fromaddr, toaddrs, subject} Returns a new instance of the \class{SMTPHandler} class. The instance is initialized with the from and to addresses and subject -line of the email. The \var{toaddrs} should be a list of strings without -domain names (That's what the \var{mailhost} is for). To specify a +line of the email. The \var{toaddrs} should be a list of strings. To specify a non-standard SMTP port, use the (host, port) tuple format for the \var{mailhost} argument. If you use a string, the standard SMTP port is used. From vsajip at users.sourceforge.net Fri Feb 18 12:53:34 2005 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Fri Feb 18 12:53:37 2005 Subject: [Python-checkins] python/dist/src/Lib/logging __init__.py, 1.24, 1.25 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/logging In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28274 Modified Files: __init__.py Log Message: Improved frame handling for 1.5.2, and now return func from findCaller (not actually used yet) Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/logging/__init__.py,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- __init__.py 21 Oct 2004 21:24:27 -0000 1.24 +++ __init__.py 18 Feb 2005 11:53:32 -0000 1.25 @@ -37,14 +37,14 @@ __author__ = "Vinay Sajip " __status__ = "beta" __version__ = "0.4.9.6" -__date__ = "20 October 2004" +__date__ = "03 February 2005" #--------------------------------------------------------------------------- # Miscellaneous module data #--------------------------------------------------------------------------- # -#_srcfile is used when walking the stack to check when we've got the first +# _srcfile is used when walking the stack to check when we've got the first # caller stack frame. # if string.lower(__file__[-4:]) in ['.pyc', '.pyo']: @@ -53,12 +53,23 @@ _srcfile = __file__ _srcfile = os.path.normcase(_srcfile) +# next bit filched from 1.5.2's inspect.py +def currentframe(): + """Return the frame object for the caller's stack frame.""" + try: + raise 'catch me' + except: + return sys.exc_traceback.tb_frame.f_back + +if hasattr(sys, '_getframe'): currentframe = sys._getframe +# done filching + # _srcfile is only used in conjunction with sys._getframe(). # To provide compatibility with older versions of Python, set _srcfile # to None if _getframe() is not available; this value will prevent # findCaller() from being called. -if not hasattr(sys, "_getframe"): - _srcfile = None +#if not hasattr(sys, "_getframe"): +# _srcfile = None # #_startTime is used as the base when calculating the relative time of events @@ -1005,16 +1016,16 @@ def findCaller(self): """ Find the stack frame of the caller so that we can note the source - file name and line number. + file name, line number and function name. """ - f = sys._getframe(1) + f = currentframe().f_back while 1: co = f.f_code filename = os.path.normcase(co.co_filename) if filename == _srcfile: f = f.f_back continue - return filename, f.f_lineno + return filename, f.f_lineno, co.co_name def makeRecord(self, name, level, fn, lno, msg, args, exc_info): """ @@ -1029,9 +1040,9 @@ all the handlers of this logger to handle the record. """ if _srcfile: - fn, lno = self.findCaller() + fn, lno, func = self.findCaller() else: - fn, lno = "", 0 + fn, lno, func = "(unknown file)", 0, "(unknown function)" if exc_info: if type(exc_info) != types.TupleType: exc_info = sys.exc_info() From vsajip at users.sourceforge.net Fri Feb 18 12:54:48 2005 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Fri Feb 18 12:55:02 2005 Subject: [Python-checkins] python/dist/src/Lib/logging config.py,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/logging In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28658 Modified Files: config.py Log Message: Handle errors in imports of thread, threading Index: config.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/logging/config.py,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- config.py 24 Sep 2004 11:45:13 -0000 1.10 +++ config.py 18 Feb 2005 11:54:46 -0000 1.11 @@ -27,7 +27,13 @@ To use, simply 'import logging' and log away! """ -import sys, logging, logging.handlers, string, thread, threading, socket, struct, os +import sys, logging, logging.handlers, string, socket, struct, os + +try: + import thread + import threading +except ImportError: + thread = None from SocketServer import ThreadingTCPServer, StreamRequestHandler From doerwalter at users.sourceforge.net Fri Feb 18 14:22:55 2005 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Fri Feb 18 14:22:58 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1243,1.1244 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23548/Misc Modified Files: NEWS Log Message: Add support for negative indices in UserString.MutableString.__setitem__ and UserString.MutableString.__delitem__. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1243 retrieving revision 1.1244 diff -u -d -r1.1243 -r1.1244 --- NEWS 17 Feb 2005 14:55:21 -0000 1.1243 +++ NEWS 18 Feb 2005 13:22:43 -0000 1.1244 @@ -152,6 +152,9 @@ - The reconvert.quote function can now emit triple-quoted strings. The reconvert module now has some simple documentation. +- ``UserString.MutableString`` now supports negative indices in + ``__setitem__`` and ``__delitem__`` + Build ----- From doerwalter at users.sourceforge.net Fri Feb 18 14:23:19 2005 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Fri Feb 18 14:23:21 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_userstring.py, 1.16, 1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23548/Lib/test Modified Files: test_userstring.py Log Message: Add support for negative indices in UserString.MutableString.__setitem__ and UserString.MutableString.__delitem__. Index: test_userstring.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_userstring.py,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- test_userstring.py 17 Feb 2005 22:31:28 -0000 1.16 +++ test_userstring.py 18 Feb 2005 13:22:43 -0000 1.17 @@ -52,20 +52,20 @@ def test_setitem(self): s = self.type2test("foo") - self.assertRaises(IndexError, s.__setitem__, -1, "bar") + self.assertRaises(IndexError, s.__setitem__, -4, "bar") self.assertRaises(IndexError, s.__setitem__, 3, "bar") + s[-1] = "bar" + self.assertEqual(s, "fobar") s[0] = "bar" - self.assertEqual(s, "baroo") - s[4] = "foo" - self.assertEqual(s, "barofoo") + self.assertEqual(s, "barobar") def test_delitem(self): s = self.type2test("foo") - self.assertRaises(IndexError, s.__delitem__, -1) + self.assertRaises(IndexError, s.__delitem__, -4) self.assertRaises(IndexError, s.__delitem__, 3) + del s[-1] + self.assertEqual(s, "fo") del s[0] - self.assertEqual(s, "oo") - del s[1] self.assertEqual(s, "o") del s[0] self.assertEqual(s, "") From doerwalter at users.sourceforge.net Fri Feb 18 14:23:19 2005 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Fri Feb 18 14:23:23 2005 Subject: [Python-checkins] python/dist/src/Lib UserString.py,1.23,1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23548/Lib Modified Files: UserString.py Log Message: Add support for negative indices in UserString.MutableString.__setitem__ and UserString.MutableString.__delitem__. Index: UserString.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/UserString.py,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- UserString.py 4 Aug 2004 08:01:06 -0000 1.23 +++ UserString.py 18 Feb 2005 13:22:43 -0000 1.24 @@ -146,9 +146,13 @@ def __hash__(self): raise TypeError, "unhashable type (it is mutable)" def __setitem__(self, index, sub): + if index < 0: + index += len(self.data) if index < 0 or index >= len(self.data): raise IndexError self.data = self.data[:index] + sub + self.data[index+1:] def __delitem__(self, index): + if index < 0: + index += len(self.data) if index < 0 or index >= len(self.data): raise IndexError self.data = self.data[:index] + self.data[index+1:] def __setslice__(self, start, end, sub): From loewis at users.sourceforge.net Fri Feb 18 17:13:09 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Feb 18 17:13:11 2005 Subject: [Python-checkins] python/dist/src/Tools/msi msisupport.c, 1.1.2.1, 1.1.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7824 Modified Files: Tag: release24-maint msisupport.c Log Message: Avoid using *W functions on Win95. Index: msisupport.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/msi/msisupport.c,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -d -r1.1.2.1 -r1.1.2.2 --- msisupport.c 22 Dec 2004 12:36:08 -0000 1.1.2.1 +++ msisupport.c 18 Feb 2005 16:13:06 -0000 1.1.2.2 @@ -1,14 +1,16 @@ #include "windows.h" #include "msiquery.h" +int isWinNT; + /* Print a debug message to the installer log file. * To see the debug messages, install with * msiexec /i pythonxy.msi /l*v python.log */ -static UINT debug(MSIHANDLE hInstall, LPCWSTR msg) +static UINT debug(MSIHANDLE hInstall, LPCSTR msg) { MSIHANDLE hRec = MsiCreateRecord(1); - if (!hRec || MsiRecordSetStringW(hRec, 1, msg) != ERROR_SUCCESS) { + if (!hRec || MsiRecordSetStringA(hRec, 1, msg) != ERROR_SUCCESS) { return ERROR_INSTALL_FAILURE; } MsiProcessMessage(hInstall, INSTALLMESSAGE_INFO, hRec); @@ -21,23 +23,34 @@ */ UINT __declspec(dllexport) __stdcall CheckDir(MSIHANDLE hInstall) { - WCHAR path[1024]; +#define PSIZE 1024 + WCHAR wpath[PSIZE]; + char path[PSIZE]; UINT result; - DWORD size = sizeof(path)/sizeof(WCHAR); + DWORD size = PSIZE; DWORD attributes; + + isWinNT = (GetVersion() < 0x80000000) ? 1 : 0; - result = MsiGetPropertyW(hInstall, L"TARGETDIR", path, &size); + if (isWinNT) + result = MsiGetPropertyW(hInstall, L"TARGETDIR", wpath, &size); + else + result = MsiGetPropertyA(hInstall, "TARGETDIR", path, &size); if (result != ERROR_SUCCESS) return result; + wpath[size] = L'\0'; path[size] = L'\0'; - attributes = GetFileAttributesW(path); + if (isWinNT) + attributes = GetFileAttributesW(wpath); + else + attributes = GetFileAttributesA(path); if (attributes == INVALID_FILE_ATTRIBUTES || !(attributes & FILE_ATTRIBUTE_DIRECTORY)) { - return MsiSetPropertyW(hInstall, L"TargetExists", L"0"); + return MsiSetPropertyA(hInstall, "TargetExists", "0"); } else { - return MsiSetPropertyW(hInstall, L"TargetExists", L"1"); + return MsiSetPropertyA(hInstall, "TargetExists", "1"); } } @@ -50,10 +63,10 @@ INSTALLSTATE ext_old, ext_new, tcl_old, tcl_new, reg_new; UINT result; - result = MsiGetFeatureStateW(hInstall, L"Extensions", &ext_old, &ext_new); + result = MsiGetFeatureStateA(hInstall, "Extensions", &ext_old, &ext_new); if (result != ERROR_SUCCESS) return result; - result = MsiGetFeatureStateW(hInstall, L"TclTk", &tcl_old, &tcl_new); + result = MsiGetFeatureStateA(hInstall, "TclTk", &tcl_old, &tcl_new); if (result != ERROR_SUCCESS) return result; @@ -76,7 +89,7 @@ } else { reg_new = INSTALLSTATE_ABSENT; } - result = MsiSetComponentStateW(hInstall, L"REGISTRY.tcl", reg_new); + result = MsiSetComponentStateA(hInstall, "REGISTRY.tcl", reg_new); return result; } From loewis at users.sourceforge.net Fri Feb 18 17:18:11 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Feb 18 17:18:15 2005 Subject: [Python-checkins] python/dist/src/Tools/msi msisupport.c,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9213 Modified Files: msisupport.c Log Message: Avoid using *W functions on Win95. Backported to 2.4. Index: msisupport.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/msi/msisupport.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- msisupport.c 12 Dec 2004 15:29:21 -0000 1.1 +++ msisupport.c 18 Feb 2005 16:18:09 -0000 1.2 @@ -1,14 +1,16 @@ #include "windows.h" #include "msiquery.h" +int isWinNT; + /* Print a debug message to the installer log file. * To see the debug messages, install with * msiexec /i pythonxy.msi /l*v python.log */ -static UINT debug(MSIHANDLE hInstall, LPCWSTR msg) +static UINT debug(MSIHANDLE hInstall, LPCSTR msg) { MSIHANDLE hRec = MsiCreateRecord(1); - if (!hRec || MsiRecordSetStringW(hRec, 1, msg) != ERROR_SUCCESS) { + if (!hRec || MsiRecordSetStringA(hRec, 1, msg) != ERROR_SUCCESS) { return ERROR_INSTALL_FAILURE; } MsiProcessMessage(hInstall, INSTALLMESSAGE_INFO, hRec); @@ -21,23 +23,34 @@ */ UINT __declspec(dllexport) __stdcall CheckDir(MSIHANDLE hInstall) { - WCHAR path[1024]; +#define PSIZE 1024 + WCHAR wpath[PSIZE]; + char path[PSIZE]; UINT result; - DWORD size = sizeof(path)/sizeof(WCHAR); + DWORD size = PSIZE; DWORD attributes; + + isWinNT = (GetVersion() < 0x80000000) ? 1 : 0; - result = MsiGetPropertyW(hInstall, L"TARGETDIR", path, &size); + if (isWinNT) + result = MsiGetPropertyW(hInstall, L"TARGETDIR", wpath, &size); + else + result = MsiGetPropertyA(hInstall, "TARGETDIR", path, &size); if (result != ERROR_SUCCESS) return result; + wpath[size] = L'\0'; path[size] = L'\0'; - attributes = GetFileAttributesW(path); + if (isWinNT) + attributes = GetFileAttributesW(wpath); + else + attributes = GetFileAttributesA(path); if (attributes == INVALID_FILE_ATTRIBUTES || !(attributes & FILE_ATTRIBUTE_DIRECTORY)) { - return MsiSetPropertyW(hInstall, L"TargetExists", L"0"); + return MsiSetPropertyA(hInstall, "TargetExists", "0"); } else { - return MsiSetPropertyW(hInstall, L"TargetExists", L"1"); + return MsiSetPropertyA(hInstall, "TargetExists", "1"); } } @@ -50,10 +63,10 @@ INSTALLSTATE ext_old, ext_new, tcl_old, tcl_new, reg_new; UINT result; - result = MsiGetFeatureStateW(hInstall, L"Extensions", &ext_old, &ext_new); + result = MsiGetFeatureStateA(hInstall, "Extensions", &ext_old, &ext_new); if (result != ERROR_SUCCESS) return result; - result = MsiGetFeatureStateW(hInstall, L"TclTk", &tcl_old, &tcl_new); + result = MsiGetFeatureStateA(hInstall, "TclTk", &tcl_old, &tcl_new); if (result != ERROR_SUCCESS) return result; @@ -76,7 +89,7 @@ } else { reg_new = INSTALLSTATE_ABSENT; } - result = MsiSetComponentStateW(hInstall, L"REGISTRY.tcl", reg_new); + result = MsiSetComponentStateA(hInstall, "REGISTRY.tcl", reg_new); return result; } From nascheme at users.sourceforge.net Sat Feb 19 03:43:47 2005 From: nascheme at users.sourceforge.net (nascheme@users.sourceforge.net) Date: Sat Feb 19 03:43:51 2005 Subject: [Python-checkins] python/dist/src/Python newcompile.c, 1.1.2.101, 1.1.2.102 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18511/Python Modified Files: Tag: ast-branch newcompile.c Log Message: Use pointers to basic blocks rather than indexes into the u_blocks array. Index: newcompile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/Attic/newcompile.c,v retrieving revision 1.1.2.101 retrieving revision 1.1.2.102 diff -u -d -r1.1.2.101 -r1.1.2.102 --- newcompile.c 16 Jan 2005 17:09:12 -0000 1.1.2.101 +++ newcompile.c 19 Feb 2005 02:43:45 -0000 1.1.2.102 @@ -42,10 +42,6 @@ ISSUES: - Tim mentioned that it's more common for a basic blocks representation - to use real pointers for jump targets rather than indexes into an - array of basic blocks. - opcode_stack_effect() function should be reviewed since stack depth bugs could be really hard to find later. @@ -53,20 +49,6 @@ */ -/* fblockinfo tracks the current frame block. - - A frame block is used to handle loops, try/except, and try/finally. - It's called a frame block to distinguish it from a basic block in the - compiler IR. -*/ - -enum fblocktype { LOOP, EXCEPT, FINALLY_TRY, FINALLY_END }; - -struct fblockinfo { - enum fblocktype fb_type; - int fb_block; -}; - #define DEFAULT_BLOCK_SIZE 16 #define DEFAULT_BLOCKS 8 #define DEFAULT_CODE_SIZE 128 @@ -78,24 +60,42 @@ int i_hasarg : 1; unsigned char i_opcode; int i_oparg; - int i_target; /* target block index (if jump instruction) */ + struct basicblock_ *i_target; /* target block (if jump instruction) */ int i_lineno; }; -struct basicblock { +typedef struct basicblock_ { + /* number of instructions used */ int b_iused; + /* length of instruction array (b_instr) */ int b_ialloc; - /* If b_next is non-zero, it is the block id of the next - block reached by normal control flow. - Since a valid b_next must always be > 0, - 0 can be reserved to mean no next block. */ - int b_next; + /* pointer to an array of instructions, initially NULL */ + struct instr *b_instr; + /* If b_next is non-NULL, it is a pointer to the next + block reached by normal control flow. */ + struct basicblock_ *b_next; /* b_seen is used to perform a DFS of basicblocks. */ int b_seen : 1; /* b_return is true if a RETURN_VALUE opcode is inserted. */ int b_return : 1; - int b_startdepth; /* depth of stack upon entry of block */ - struct instr b_instr[DEFAULT_BLOCK_SIZE]; + /* depth of stack upon entry of block, computed by stackdepth() */ + int b_startdepth; + /* instruction offset for block, computed by assemble_jump_offsets() */ + int b_offset; +} basicblock; + +/* fblockinfo tracks the current frame block. + + A frame block is used to handle loops, try/except, and try/finally. + It's called a frame block to distinguish it from a basic block in the + compiler IR. +*/ + +enum fblocktype { LOOP, EXCEPT, FINALLY_TRY, FINALLY_END }; + +struct fblockinfo { + enum fblocktype fb_type; + basicblock *fb_block; }; /* The following items change on entry and exit of code blocks. @@ -121,9 +121,9 @@ int u_nblocks; /* number of used blocks in u_blocks u_nblocks < u_nalloc */ int u_nalloc; /* current alloc count for u_blocks */ - int u_curblock; /* index of current block in u_blocks */ + basicblock *u_curblock; /* pointer to current block (from u_blocks) */ int u_tmpname; /* temporary variables for list comps */ - struct basicblock **u_blocks; + basicblock **u_blocks; int u_nfblocks; struct fblockinfo u_fblock[CO_MAXBLOCKS]; @@ -152,7 +152,7 @@ PyObject *a_bytecode; /* string containing bytecode */ int a_offset; /* offset into bytecode */ int a_nblocks; /* number of reachable blocks */ - int *a_postorder; /* list of block indices in dfs postorder */ + basicblock **a_postorder; /* list of blocks in dfs postorder */ PyObject *a_lnotab; /* string containing lnotab */ int a_lnotab_off; /* offset into lnotab */ int a_lineno; /* last lineno of emitted instruction */ @@ -161,14 +161,14 @@ static int compiler_enter_scope(struct compiler *, identifier, void *, int); static void compiler_free(struct compiler *); -static int compiler_new_block(struct compiler *); -static int compiler_next_instr(struct compiler *, int); +static basicblock *compiler_new_block(struct compiler *); +static int compiler_next_instr(struct compiler *, basicblock *); static int compiler_addop(struct compiler *, int); static int compiler_addop_o(struct compiler *, int, PyObject *, PyObject *); static int compiler_addop_i(struct compiler *, int, int); -static int compiler_addop_j(struct compiler *, int, int, int); -static void compiler_use_block(struct compiler *, int); -static int compiler_use_new_block(struct compiler *); +static int compiler_addop_j(struct compiler *, int, basicblock *, int); +static void compiler_use_block(struct compiler *, basicblock *); +static basicblock *compiler_use_new_block(struct compiler *); static int compiler_error(struct compiler *, const char *); static int compiler_nameop(struct compiler *, identifier, expr_context_ty); @@ -180,8 +180,10 @@ static int compiler_visit_slice(struct compiler *, slice_ty, expr_context_ty); -static int compiler_push_fblock(struct compiler *, enum fblocktype, int); -static void compiler_pop_fblock(struct compiler *, enum fblocktype, int); +static int compiler_push_fblock(struct compiler *, enum fblocktype, + basicblock *); +static void compiler_pop_fblock(struct compiler *, enum fblocktype, + basicblock *); static int inplace_binop(struct compiler *, operator_ty); static int expr_constant(expr_ty e); @@ -438,8 +440,8 @@ u->u_nblocks = 0; u->u_nalloc = DEFAULT_BLOCKS; - u->u_blocks = (struct basicblock **)PyObject_Malloc( - sizeof(struct basicblock *) * DEFAULT_BLOCKS); + u->u_blocks = (basicblock **)PyObject_Malloc( + sizeof(basicblock *) * DEFAULT_BLOCKS); if (!u->u_blocks) return 0; u->u_tmpname = 0; @@ -447,7 +449,7 @@ u->u_firstlineno = lineno; u->u_lineno = 0; u->u_lineno_set = false; - memset(u->u_blocks, 0, sizeof(struct basicblock *) * DEFAULT_BLOCKS); + memset(u->u_blocks, 0, sizeof(basicblock *) * DEFAULT_BLOCKS); u->u_consts = PyDict_New(); if (!u->u_consts) return 0; @@ -483,16 +485,22 @@ compiler_unit_check(struct compiler_unit *u) { int i; - assert(u->u_curblock < u->u_nblocks); assert(u->u_nblocks <= u->u_nalloc); for (i = 0; i < u->u_nblocks; i++) { - struct basicblock *block = u->u_blocks[i]; + basicblock *block = u->u_blocks[i]; assert(block); assert(block != (void *)0xcbcbcbcb); assert(block != (void *)0xfbfbfbfb); - assert(block->b_ialloc > 0); - assert(block->b_iused >= 0 - && block->b_ialloc >= block->b_iused); + assert(block != (void *)0xdbdbdbdb); + if (block->b_instr != NULL) { + assert(block->b_ialloc > 0); + assert(block->b_iused > 0); + assert(block->b_ialloc >= block->b_iused); + } + else { + assert (block->b_iused == 0); + assert (block->b_ialloc == 0); + } } } @@ -502,8 +510,12 @@ int i; compiler_unit_check(u); - for (i = 0; i < u->u_nblocks; i++) - PyObject_Free((void *)u->u_blocks[i]); + for (i = 0; i < u->u_nblocks; i++) { + basicblock *b = u->u_blocks[i]; + if (b->b_instr) + PyObject_Free((void *)b->b_instr); + PyObject_Free((void *)b); + } if (u->u_blocks) PyObject_Free((void *)u->u_blocks); Py_XDECREF(u->u_ste); @@ -540,75 +552,73 @@ return 1; /* XXX void? */ } -/* Allocate a new block and return its index in c_blocks. - Returns -1 on error. +/* Allocate a new block and return a pointer to it. + Returns NULL on error. */ -static int +static basicblock * compiler_new_block(struct compiler *c) { - struct basicblock *b; + basicblock *b; struct compiler_unit *u; - int block; + int i; u = c->u; if (u->u_nblocks == u->u_nalloc) { int newsize = ((u->u_nalloc + u->u_nalloc) - * sizeof(struct basicblock *)); - u->u_blocks = (struct basicblock **)PyObject_Realloc( + * sizeof(basicblock *)); + u->u_blocks = (basicblock **)PyObject_Realloc( u->u_blocks, newsize); if (u->u_blocks == NULL) - return -1; + return NULL; memset(u->u_blocks + u->u_nalloc, 0, - sizeof(struct basicblock *) * u->u_nalloc); + sizeof(basicblock *) * u->u_nalloc); u->u_nalloc += u->u_nalloc; } - b = (struct basicblock *)PyObject_Malloc(sizeof(struct basicblock)); + b = (basicblock *)PyObject_Malloc(sizeof(basicblock)); if (b == NULL) - return -1; - memset((void *)b, 0, sizeof(struct basicblock)); - b->b_ialloc = DEFAULT_BLOCK_SIZE; - block = u->u_nblocks++; - assert(u->u_blocks[block] == NULL); - u->u_blocks[block] = b; - return block; + return NULL; + memset((void *)b, 0, sizeof(basicblock)); + assert (b->b_next == NULL); + i = u->u_nblocks++; + assert(u->u_blocks[i] == NULL); + u->u_blocks[i] = b; + return b; } static void -compiler_use_block(struct compiler *c, int block) +compiler_use_block(struct compiler *c, basicblock *block) { - assert(block < c->u->u_nblocks); + assert (block != NULL); c->u->u_curblock = block; - assert(c->u->u_blocks[block]); } -static int +static basicblock * compiler_use_new_block(struct compiler *c) { - int block = compiler_new_block(c); - if (block < 0) - return 0; + basicblock *block = compiler_new_block(c); + if (block == NULL) + return NULL; c->u->u_curblock = block; return block; } -static int +static basicblock * compiler_next_block(struct compiler *c) { - int block = compiler_new_block(c); - if (block < 0) - return 0; - c->u->u_blocks[c->u->u_curblock]->b_next = block; + basicblock *block = compiler_new_block(c); + if (block == NULL) + return NULL; + c->u->u_curblock->b_next = block; c->u->u_curblock = block; return block; } -static int -compiler_use_next_block(struct compiler *c, int block) +static basicblock * +compiler_use_next_block(struct compiler *c, basicblock *block) { - assert(block < c->u->u_nblocks); - c->u->u_blocks[c->u->u_curblock]->b_next = block; - assert(c->u->u_blocks[block]); + assert(block != NULL); + c->u->u_curblock->b_next = block; c->u->u_curblock = block; return block; } @@ -619,34 +629,33 @@ */ static int -compiler_next_instr(struct compiler *c, int block) +compiler_next_instr(struct compiler *c, basicblock *b) { - struct basicblock *b; - assert(block < c->u->u_nblocks); - b = c->u->u_blocks[block]; - assert(b); - if (b->b_iused == b->b_ialloc) { - void *ptr; - int oldsize, newsize; - oldsize = sizeof(struct basicblock); - if (b->b_ialloc > DEFAULT_BLOCK_SIZE) - oldsize += ((b->b_ialloc - DEFAULT_BLOCK_SIZE) - * sizeof(struct instr)); - newsize = oldsize + b->b_ialloc * sizeof(struct instr); - if (newsize <= 0) { + assert(b != NULL); + if (b->b_instr == NULL) { + b->b_instr = PyObject_Malloc(sizeof(struct instr) * + DEFAULT_BLOCK_SIZE); + if (b->b_instr == NULL) { PyErr_NoMemory(); return -1; } - b->b_ialloc <<= 1; - ptr = PyObject_Realloc((void *)b, newsize); - if (ptr == NULL) + b->b_ialloc = DEFAULT_BLOCK_SIZE; + memset((char *)b->b_instr, 0, + sizeof(struct instr) * DEFAULT_BLOCK_SIZE); + } + else if (b->b_iused == b->b_ialloc) { + size_t oldsize, newsize; + oldsize = b->b_ialloc * sizeof(struct instr); + newsize = oldsize << 1; + if (newsize == 0) { + PyErr_NoMemory(); return -1; - memset((char *)ptr + oldsize, 0, newsize - oldsize); - if (ptr != (void *)b) { - fprintf(stderr, "resize block %d\n", block); - c->u->u_blocks[block] = (struct basicblock *)ptr; - b = ptr; } + b->b_ialloc <<= 1; + b->b_instr = PyObject_Realloc((void *)b->b_instr, newsize); + if (b->b_instr == NULL) + return -1; + memset((char *)b->b_instr + oldsize, 0, newsize - oldsize); } return b->b_iused++; } @@ -658,11 +667,11 @@ static void compiler_set_lineno(struct compiler *c, int off) { - struct basicblock *b; + basicblock *b; if (c->u->u_lineno_set) return; c->u->u_lineno_set = true; - b = c->u->u_blocks[c->u->u_curblock]; + b = c->u->u_curblock; b->b_instr[off].i_lineno = c->u->u_lineno; } @@ -886,13 +895,13 @@ static int compiler_addop(struct compiler *c, int opcode) { - struct basicblock *b; + basicblock *b; struct instr *i; int off; off = compiler_next_instr(c, c->u->u_curblock); if (off < 0) return 0; - b = c->u->u_blocks[c->u->u_curblock]; + b = c->u->u_curblock; i = &b->b_instr[off]; i->i_opcode = opcode; i->i_hasarg = 0; @@ -972,7 +981,7 @@ off = compiler_next_instr(c, c->u->u_curblock); if (off < 0) return 0; - i = &c->u->u_blocks[c->u->u_curblock]->b_instr[off]; + i = &c->u->u_curblock->b_instr[off]; i->i_opcode = opcode; i->i_oparg = oparg; i->i_hasarg = 1; @@ -981,19 +990,19 @@ } static int -compiler_addop_j(struct compiler *c, int opcode, int block, int absolute) +compiler_addop_j(struct compiler *c, int opcode, basicblock *b, int absolute) { struct instr *i; int off; - assert(block >= 0); + assert(b != NULL); off = compiler_next_instr(c, c->u->u_curblock); if (off < 0) return 0; compiler_set_lineno(c, off); - i = &c->u->u_blocks[c->u->u_curblock]->b_instr[off]; + i = &c->u->u_curblock->b_instr[off]; i->i_opcode = opcode; - i->i_target = block; + i->i_target = b; i->i_hasarg = 1; if (absolute) i->i_jabs = 1; @@ -1014,12 +1023,12 @@ #define NEW_BLOCK(C) { \ - if (compiler_use_new_block((C)) < 0) \ + if (compiler_use_new_block((C)) == NULL) \ return 0; \ } #define NEXT_BLOCK(C) { \ - if (compiler_next_block((C)) < 0) \ + if (compiler_next_block((C)) == NULL) \ return 0; \ } @@ -1410,14 +1419,14 @@ static int compiler_if(struct compiler *c, stmt_ty s) { - int end, next; + basicblock *end, *next; assert(s->kind == If_kind); end = compiler_new_block(c); - if (end < 0) + if (end == NULL) return 0; next = compiler_new_block(c); - if (next < 0) + if (next == NULL) return 0; VISIT(c, expr, s->v.If.test); ADDOP_JREL(c, JUMP_IF_FALSE, next); @@ -1435,12 +1444,12 @@ static int compiler_for(struct compiler *c, stmt_ty s) { - int start, cleanup, end; + basicblock *start, *cleanup, *end; start = compiler_new_block(c); cleanup = compiler_new_block(c); end = compiler_new_block(c); - if (start < 0 || end < 0 || cleanup < 0) + if (start == NULL || end == NULL || cleanup == NULL) return 0; ADDOP_JREL(c, SETUP_LOOP, end); if (!compiler_push_fblock(c, LOOP, start)) @@ -1463,7 +1472,7 @@ static int compiler_while(struct compiler *c, stmt_ty s) { - int loop, orelse, end, anchor; + basicblock *loop, *orelse, *end, *anchor; int constant = expr_constant(s->v.While.test); if (constant == 0) @@ -1472,18 +1481,18 @@ end = compiler_new_block(c); if (constant == -1) { anchor = compiler_new_block(c); - if (anchor < 0) + if (anchor == NULL) return 0; } - if (loop < 0 || end < 0) + if (loop == NULL || end == NULL) return 0; if (s->v.While.orelse) { orelse = compiler_new_block(c); - if (orelse < 0) + if (orelse == NULL) return 0; } else - orelse = -1; + orelse = NULL; ADDOP_JREL(c, SETUP_LOOP, end); compiler_use_next_block(c, loop); @@ -1507,7 +1516,7 @@ ADDOP(c, POP_BLOCK); } compiler_pop_fblock(c, LOOP, loop); - if (orelse != -1) + if (orelse != NULL) VISIT_SEQ(c, stmt, s->v.While.orelse); compiler_use_next_block(c, end); @@ -1579,10 +1588,10 @@ static int compiler_try_finally(struct compiler *c, stmt_ty s) { - int body, end; + basicblock *body, *end; body = compiler_new_block(c); end = compiler_new_block(c); - if (body < 0 || end < 0) + if (body == NULL || end == NULL) return 0; ADDOP_JREL(c, SETUP_FINALLY, end); @@ -1641,13 +1650,14 @@ static int compiler_try_except(struct compiler *c, stmt_ty s) { - int i, n, body, orelse, except, end; + basicblock *body, *orelse, *except, *end; + int i, n; body = compiler_new_block(c); except = compiler_new_block(c); orelse = compiler_new_block(c); end = compiler_new_block(c); - if (body < 0 || except < 0 || orelse < 0 || end < 0) + if (body == NULL || except == NULL || orelse == NULL || end == NULL) return 0; ADDOP_JREL(c, SETUP_EXCEPT, except); compiler_use_next_block(c, body); @@ -1665,7 +1675,7 @@ if (!handler->type && i < n-1) return compiler_error(c, "default 'except:' must be last"); except = compiler_new_block(c); - if (except < 0) + if (except == NULL) return 0; if (handler->type) { ADDOP(c, DUP_TOP); @@ -1792,7 +1802,7 @@ compiler_assert(struct compiler *c, stmt_ty s) { static PyObject *assertion_error = NULL; - int end; + basicblock *end; if (Py_OptimizeFlag) return 1; @@ -1803,7 +1813,7 @@ } VISIT(c, expr, s->v.Assert.test); end = compiler_new_block(c); - if (end < 0) + if (end == NULL) return 0; ADDOP_JREL(c, JUMP_IF_TRUE, end); ADDOP(c, POP_TOP); @@ -2167,7 +2177,8 @@ static int compiler_boolop(struct compiler *c, expr_ty e) { - int end, jumpi, i, n; + basicblock *end; + int jumpi, i, n; asdl_seq *s; assert(e->kind == BoolOp_kind); @@ -2221,7 +2232,8 @@ static int compiler_compare(struct compiler *c, expr_ty e) { - int i, n, cleanup = -1; + int i, n; + basicblock *cleanup = NULL; /* XXX the logic can be cleaned up for 1 or multiple comparisons */ VISIT(c, expr, e->v.Compare.left); @@ -2229,6 +2241,8 @@ assert(n > 0); if (n > 1) { cleanup = compiler_new_block(c); + if (cleanup == NULL) + return 0; VISIT(c, expr, asdl_seq_GET(e->v.Compare.comparators, 0)); } for (i = 1; i < n; i++) { @@ -2248,7 +2262,9 @@ /* XXX We're casting a void* to cmpop_ty in the next stmt. */ cmpop((cmpop_ty)asdl_seq_GET(e->v.Compare.ops, n - 1))); if (n > 1) { - int end = compiler_new_block(c); + basicblock *end = compiler_new_block(c); + if (end == NULL) + return 0; ADDOP_JREL(c, JUMP_FORWARD, end); compiler_use_next_block(c, cleanup); ADDOP(c, ROT_TWO); @@ -2304,14 +2320,16 @@ and then write to the element */ comprehension_ty l; - int start, anchor, skip, if_cleanup, i, n; + basicblock *start, *anchor, *skip, *if_cleanup; + int i, n; start = compiler_new_block(c); skip = compiler_new_block(c); if_cleanup = compiler_new_block(c); anchor = compiler_new_block(c); - if (start < 0 || skip < 0 || if_cleanup < 0 || anchor < 0) + if (start == NULL || skip == NULL || if_cleanup == NULL || + anchor == NULL) return 0; l = asdl_seq_GET(generators, gen_index); @@ -2585,7 +2603,7 @@ } static int -compiler_push_fblock(struct compiler *c, enum fblocktype t, int b) +compiler_push_fblock(struct compiler *c, enum fblocktype t, basicblock *b) { struct fblockinfo *f; if (c->u->u_nfblocks >= CO_MAXBLOCKS) @@ -2597,7 +2615,7 @@ } static void -compiler_pop_fblock(struct compiler *c, enum fblocktype t, int b) +compiler_pop_fblock(struct compiler *c, enum fblocktype t, basicblock *b) { struct compiler_unit *u = c->u; assert(u->u_nfblocks > 0); @@ -2809,40 +2827,34 @@ */ static void -dfs(struct compiler *c, int block, struct assembler *a) +dfs(struct compiler *c, basicblock *b, struct assembler *a) { int i; - struct basicblock *b; struct instr *instr = NULL; - if (block >= c->u->u_nblocks) - return; - b = c->u->u_blocks[block]; if (b->b_seen) return; b->b_seen = 1; - if (b->b_next) + if (b->b_next != NULL) dfs(c, b->b_next, a); for (i = 0; i < b->b_iused; i++) { instr = &b->b_instr[i]; if (instr->i_jrel || instr->i_jabs) dfs(c, instr->i_target, a); } - a->a_postorder[a->a_nblocks++] = block; + a->a_postorder[a->a_nblocks++] = b; } int -stackdepth_walk(struct compiler *c, int block, int depth, int maxdepth) +stackdepth_walk(struct compiler *c, basicblock *b, int depth, int maxdepth) { int i; struct instr *instr; - struct basicblock *b; - b = c->u->u_blocks[block]; if (b->b_seen || b->b_startdepth >= depth) return maxdepth; b->b_seen = 1; b->b_startdepth = depth; - fprintf(stderr, "block %d\n", block); + fprintf(stderr, "block %p\n", b); for (i = 0; i < b->b_iused; i++) { instr = &b->b_instr[i]; depth += opcode_stack_effect(instr->i_opcode, instr->i_oparg); @@ -2879,7 +2891,7 @@ c->u->u_blocks[i]->b_seen = 0; c->u->u_blocks[i]->b_startdepth = INT_MIN; } - return stackdepth_walk(c, 0, 0, 0); + return stackdepth_walk(c, c->u->u_blocks[0], 0, 0); } static int @@ -2893,7 +2905,8 @@ a->a_lnotab = PyString_FromStringAndSize(NULL, DEFAULT_LNOTAB_SIZE); if (!a->a_lnotab) return 0; - a->a_postorder = (int *)PyObject_Malloc(sizeof(int) * nblocks); + a->a_postorder = (basicblock **)PyObject_Malloc( + sizeof(basicblock *) * nblocks); if (!a->a_postorder) return 0; return 1; @@ -2923,7 +2936,7 @@ } static int -blocksize(struct basicblock *b) +blocksize(basicblock *b) { int i; int size = 0; @@ -3121,28 +3134,21 @@ static int assemble_jump_offsets(struct assembler *a, struct compiler *c) { - int *blockoff; int bsize, totsize = 0; int i, j; /* Compute the size of each block and fixup jump args. - Replace block index with position in bytecode. */ - blockoff = malloc(sizeof(int) * c->u->u_nblocks); - if (!blockoff) - return 0; - /* blockoff computed in dfs postorder, but stored using - c_blocks[] indices. - */ + Replace block pointer with position in bytecode. */ assert(a->a_nblocks <= c->u->u_nblocks); for (i = a->a_nblocks - 1; i >= 0; i--) { - int block = a->a_postorder[i]; - bsize = blocksize(c->u->u_blocks[block]); - blockoff[block] = totsize; + basicblock *b = a->a_postorder[i]; + bsize = blocksize(b); + b->b_offset = totsize; totsize += bsize; } for (i = 0; i < c->u->u_nblocks; i++) { - struct basicblock *b = c->u->u_blocks[i]; - bsize = blockoff[i]; + basicblock *b = c->u->u_blocks[i]; + bsize = b->b_offset; for (j = 0; j < b->b_iused; j++) { struct instr *instr = &b->b_instr[j]; /* Relative jumps are computed relative to @@ -3151,15 +3157,13 @@ */ bsize += instrsize(instr); if (instr->i_jabs) - instr->i_oparg = blockoff[instr->i_target]; + instr->i_oparg = instr->i_target->b_offset; else if (instr->i_jrel) { - int delta = blockoff[instr->i_target] - bsize; + int delta = instr->i_target->b_offset - bsize; instr->i_oparg = delta; } } } - free(blockoff); - return 1; } @@ -3289,7 +3293,7 @@ if (!assemble_init(&a, c->u->u_nblocks)) goto error; - dfs(c, 0, &a); + dfs(c, c->u->u_blocks[0], &a); /* Can't modify the bytecode after computing jump offsets. */ if (!assemble_jump_offsets(&a, c)) @@ -3297,10 +3301,10 @@ /* Emit code in reverse postorder from dfs. */ for (i = a.a_nblocks - 1; i >= 0; i--) { - struct basicblock *b = c->u->u_blocks[a.a_postorder[i]]; + basicblock *b = a.a_postorder[i]; fprintf(stderr, - "\nblock %d: order=%d used=%d alloc=%d next=%d\n", - i, a.a_postorder[i], b->b_iused, b->b_ialloc, + "\nblock %p: order=%d used=%d alloc=%d next=%p\n", + a.a_postorder[i], i, b->b_iused, b->b_ialloc, b->b_next); for (j = 0; j < b->b_iused; j++) if (!assemble_emit(&a, &b->b_instr[j])) From nascheme at users.sourceforge.net Sat Feb 19 04:42:39 2005 From: nascheme at users.sourceforge.net (nascheme@users.sourceforge.net) Date: Sat Feb 19 04:42:42 2005 Subject: [Python-checkins] python/dist/src/Python newcompile.c, 1.1.2.102, 1.1.2.103 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30888/Python Modified Files: Tag: ast-branch newcompile.c Log Message: Store basic blocks in a linked list rather than an array. The code is a little simpler that way. Index: newcompile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/Attic/newcompile.c,v retrieving revision 1.1.2.102 retrieving revision 1.1.2.103 diff -u -d -r1.1.2.102 -r1.1.2.103 --- newcompile.c 19 Feb 2005 02:43:45 -0000 1.1.2.102 +++ newcompile.c 19 Feb 2005 03:42:35 -0000 1.1.2.103 @@ -65,6 +65,9 @@ }; typedef struct basicblock_ { + /* next block in the list of blocks for a unit (don't confuse with + * b_next) */ + struct basicblock_ *b_list; /* number of instructions used */ int b_iused; /* length of instruction array (b_instr) */ @@ -118,12 +121,9 @@ PyObject *u_private; /* for private name mangling */ int u_argcount; /* number of arguments for block */ - int u_nblocks; /* number of used blocks in u_blocks - u_nblocks < u_nalloc */ - int u_nalloc; /* current alloc count for u_blocks */ - basicblock *u_curblock; /* pointer to current block (from u_blocks) */ + basicblock *u_blocks; /* pointer to list of blocks */ + basicblock *u_curblock; /* pointer to current block */ int u_tmpname; /* temporary variables for list comps */ - basicblock **u_blocks; int u_nfblocks; struct fblockinfo u_fblock[CO_MAXBLOCKS]; @@ -438,18 +438,12 @@ u->u_freevars = dictbytype(u->u_ste->ste_symbols, FREE, DEF_FREE_CLASS, PyDict_Size(u->u_cellvars)); - u->u_nblocks = 0; - u->u_nalloc = DEFAULT_BLOCKS; - u->u_blocks = (basicblock **)PyObject_Malloc( - sizeof(basicblock *) * DEFAULT_BLOCKS); - if (!u->u_blocks) - return 0; + u->u_blocks = NULL; u->u_tmpname = 0; u->u_nfblocks = 0; u->u_firstlineno = lineno; u->u_lineno = 0; u->u_lineno_set = false; - memset(u->u_blocks, 0, sizeof(basicblock *) * DEFAULT_BLOCKS); u->u_consts = PyDict_New(); if (!u->u_consts) return 0; @@ -484,11 +478,8 @@ static void compiler_unit_check(struct compiler_unit *u) { - int i; - assert(u->u_nblocks <= u->u_nalloc); - for (i = 0; i < u->u_nblocks; i++) { - basicblock *block = u->u_blocks[i]; - assert(block); + basicblock *block; + for (block = u->u_blocks; block != NULL; block = block->b_list) { assert(block != (void *)0xcbcbcbcb); assert(block != (void *)0xfbfbfbfb); assert(block != (void *)0xdbdbdbdb); @@ -507,17 +498,17 @@ static void compiler_unit_free(struct compiler_unit *u) { - int i; + basicblock *b, *next; compiler_unit_check(u); - for (i = 0; i < u->u_nblocks; i++) { - basicblock *b = u->u_blocks[i]; + b = u->u_blocks; + while (b != NULL) { if (b->b_instr) PyObject_Free((void *)b->b_instr); + next = b->b_list; PyObject_Free((void *)b); + b = next; } - if (u->u_blocks) - PyObject_Free((void *)u->u_blocks); Py_XDECREF(u->u_ste); Py_XDECREF(u->u_name); Py_XDECREF(u->u_consts); @@ -561,28 +552,15 @@ { basicblock *b; struct compiler_unit *u; - int i; u = c->u; - if (u->u_nblocks == u->u_nalloc) { - int newsize = ((u->u_nalloc + u->u_nalloc) - * sizeof(basicblock *)); - u->u_blocks = (basicblock **)PyObject_Realloc( - u->u_blocks, newsize); - if (u->u_blocks == NULL) - return NULL; - memset(u->u_blocks + u->u_nalloc, 0, - sizeof(basicblock *) * u->u_nalloc); - u->u_nalloc += u->u_nalloc; - } b = (basicblock *)PyObject_Malloc(sizeof(basicblock)); if (b == NULL) return NULL; memset((void *)b, 0, sizeof(basicblock)); assert (b->b_next == NULL); - i = u->u_nblocks++; - assert(u->u_blocks[i] == NULL); - u->u_blocks[i] = b; + b->b_list = u->u_blocks; + u->u_blocks = b; return b; } @@ -2886,12 +2864,14 @@ static int stackdepth(struct compiler *c) { - int i; - for (i = 0; i < c->u->u_nblocks; i++) { - c->u->u_blocks[i]->b_seen = 0; - c->u->u_blocks[i]->b_startdepth = INT_MIN; + basicblock *b, *entryblock; + entryblock = NULL; + for (b = c->u->u_blocks; b != NULL; b = b->b_list) { + b->b_seen = 0; + b->b_startdepth = INT_MIN; + entryblock = b; } - return stackdepth_walk(c, c->u->u_blocks[0], 0, 0); + return stackdepth_walk(c, entryblock, 0, 0); } static int @@ -3134,23 +3114,22 @@ static int assemble_jump_offsets(struct assembler *a, struct compiler *c) { + basicblock *b; int bsize, totsize = 0; - int i, j; + int i; /* Compute the size of each block and fixup jump args. Replace block pointer with position in bytecode. */ - assert(a->a_nblocks <= c->u->u_nblocks); for (i = a->a_nblocks - 1; i >= 0; i--) { basicblock *b = a->a_postorder[i]; bsize = blocksize(b); b->b_offset = totsize; totsize += bsize; } - for (i = 0; i < c->u->u_nblocks; i++) { - basicblock *b = c->u->u_blocks[i]; + for (b = c->u->u_blocks; b != NULL; b = b->b_list) { bsize = b->b_offset; - for (j = 0; j < b->b_iused; j++) { - struct instr *instr = &b->b_instr[j]; + for (i = 0; i < b->b_iused; i++) { + struct instr *instr = &b->b_instr[i]; /* Relative jumps are computed relative to the instruction pointer after fetching the jump instruction. @@ -3278,8 +3257,9 @@ static PyCodeObject * assemble(struct compiler *c, int addNone) { + basicblock *b, *entryblock; struct assembler a; - int i, j; + int i, j, nblocks; PyCodeObject *co = NULL; /* Make sure every block that falls off the end returns None. @@ -3291,9 +3271,16 @@ ADDOP_O(c, LOAD_CONST, Py_None, consts); ADDOP(c, RETURN_VALUE); - if (!assemble_init(&a, c->u->u_nblocks)) + nblocks = 0; + entryblock = NULL; + for (b = c->u->u_blocks; b != NULL; b = b->b_list) { + nblocks++; + entryblock = b; + } + + if (!assemble_init(&a, nblocks)) goto error; - dfs(c, c->u->u_blocks[0], &a); + dfs(c, entryblock, &a); /* Can't modify the bytecode after computing jump offsets. */ if (!assemble_jump_offsets(&a, c)) From ping at users.sourceforge.net Sat Feb 19 23:57:40 2005 From: ping at users.sourceforge.net (ping@users.sourceforge.net) Date: Sat Feb 19 23:57:43 2005 Subject: [Python-checkins] python/dist/src/Lib pydoc.py,1.100.2.1,1.100.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18476 Modified Files: Tag: release24-maint pydoc.py Log Message: Use getdoc(object) instead of object.__doc__ to fix indentation problems. Thanks to Robert Dick for reporting this bug and submitting a patch. Adjust doc(object) to display useful documentation for plain values (e.g. help([]) now shows the methods on the list instead of just printing "[]"). (This change has been tested interactively, by generating docs for the standard library, and by running the module documentation webserver.) Index: pydoc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pydoc.py,v retrieving revision 1.100.2.1 retrieving revision 1.100.2.2 diff -u -d -r1.100.2.1 -r1.100.2.2 --- pydoc.py 1 Jan 2005 07:52:40 -0000 1.100.2.1 +++ pydoc.py 19 Feb 2005 22:57:37 -0000 1.100.2.2 @@ -878,7 +878,7 @@ if name: push('
%s
\n' % name) if value.__doc__ is not None: - doc = self.markup(value.__doc__, self.preformat) + doc = self.markup(getdoc(value), self.preformat) push('
%s
\n' % doc) for attr, tag in [('fget', 'get'), ('fset', 'set'), @@ -1159,7 +1159,7 @@ push(msg) for name, kind, homecls, value in ok: if callable(value) or inspect.isdatadescriptor(value): - doc = getattr(value, "__doc__", None) + doc = getdoc(value) else: doc = None push(self.docother(getattr(object, name), @@ -1464,6 +1464,14 @@ desc += ' in ' + name[:name.rfind('.')] elif module and module is not object: desc += ' in module ' + module.__name__ + if not (inspect.ismodule(object) or + inspect.isclass(object) or + inspect.isroutine(object) or + isinstance(object, property)): + # If the passed object is a piece of data or an instance, + # document its available methods instead of its value. + object = type(object) + desc += ' object' pager(title % desc + '\n\n' + text.document(object, name)) except (ImportError, ErrorDuringImport), value: print value From ping at users.sourceforge.net Sat Feb 19 23:58:28 2005 From: ping at users.sourceforge.net (ping@users.sourceforge.net) Date: Sat Feb 19 23:58:31 2005 Subject: [Python-checkins] python/dist/src/Lib pydoc.py,1.103,1.104 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19132 Modified Files: pydoc.py Log Message: Use getdoc(object) instead of object.__doc__ to fix indentation problems. Thanks to Robert Dick for reporting this bug and submitting a patch. Adjust doc(object) to display useful documentation for plain values (e.g. help([]) now shows the methods on the list instead of just printing "[]"). (This change has been tested interactively, by generating docs for the standard library, and by running the module documentation webserver.) Index: pydoc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pydoc.py,v retrieving revision 1.103 retrieving revision 1.104 diff -u -d -r1.103 -r1.104 --- pydoc.py 6 Feb 2005 06:57:07 -0000 1.103 +++ pydoc.py 19 Feb 2005 22:58:26 -0000 1.104 @@ -886,7 +886,7 @@ if name: push('
%s
\n' % name) if value.__doc__ is not None: - doc = self.markup(value.__doc__, self.preformat) + doc = self.markup(getdoc(value), self.preformat) push('
%s
\n' % doc) push('
\n') @@ -1160,7 +1160,7 @@ push(msg) for name, kind, homecls, value in ok: if callable(value) or inspect.isdatadescriptor(value): - doc = getattr(value, "__doc__", None) + doc = getdoc(value) else: doc = None push(self.docother(getattr(object, name), @@ -1454,6 +1454,14 @@ desc += ' in ' + name[:name.rfind('.')] elif module and module is not object: desc += ' in module ' + module.__name__ + if not (inspect.ismodule(object) or + inspect.isclass(object) or + inspect.isroutine(object) or + isinstance(object, property)): + # If the passed object is a piece of data or an instance, + # document its available methods instead of its value. + object = type(object) + desc += ' object' pager(title % desc + '\n\n' + text.document(object, name)) except (ImportError, ErrorDuringImport), value: print value From gvanrossum at users.sourceforge.net Sun Feb 20 04:02:20 2005 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Sun Feb 20 04:02:22 2005 Subject: [Python-checkins] python/dist/src/Modules threadmodule.c,2.59,2.60 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9262 Modified Files: threadmodule.c Log Message: The error message "can't start new thread" should not end in a newline. Index: threadmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/threadmodule.c,v retrieving revision 2.59 retrieving revision 2.60 diff -u -d -r2.59 -r2.60 --- threadmodule.c 24 Aug 2004 22:24:08 -0000 2.59 +++ threadmodule.c 20 Feb 2005 03:02:16 -0000 2.60 @@ -494,7 +494,7 @@ PyEval_InitThreads(); /* Start the interpreter's thread-awareness */ ident = PyThread_start_new_thread(t_bootstrap, (void*) boot); if (ident == -1) { - PyErr_SetString(ThreadError, "can't start new thread\n"); + PyErr_SetString(ThreadError, "can't start new thread"); Py_DECREF(func); Py_DECREF(args); Py_XDECREF(keyw); From rhettinger at users.sourceforge.net Sun Feb 20 05:07:21 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Feb 20 05:07:24 2005 Subject: [Python-checkins] python/dist/src/Lib/test string_tests.py, 1.42, 1.43 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21408/Lib/test Modified Files: string_tests.py Log Message: * Beef-up testing of str.__contains__() and str.find(). * Speed-up "x in y" where x has more than one character. The existing code made excessive calls to the expensive memcmp() function. The new code uses memchr() to rapidly find a start point for memcmp(). In addition to knowing that the first character is a match, the new code also checks that the last character is a match. This significantly reduces the incidence of false starts (saving memcmp() calls and making quadratic behavior less likely). Improves the timings on: python -m timeit -r7 -s"x='a'*1000" "'ab' in x" python -m timeit -r7 -s"x='a'*1000" "'bc' in x" Once this code has proven itself, then string_find_internal() should refer to it rather than running its own version. Also, something similar may apply to unicode objects. Index: string_tests.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/string_tests.py,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- string_tests.py 26 Oct 2004 01:52:36 -0000 1.42 +++ string_tests.py 20 Feb 2005 04:07:08 -0000 1.43 @@ -122,6 +122,30 @@ self.checkraises(TypeError, 'hello', 'find') self.checkraises(TypeError, 'hello', 'find', 42) + # For a variety of combinations, + # verify that str.find() matches __contains__ + # and that the found substring is really at that location + charset = ['', 'a', 'b', 'c'] + digits = 5 + base = len(charset) + teststrings = set() + for i in xrange(base ** digits): + entry = [] + for j in xrange(digits): + i, m = divmod(i, base) + entry.append(charset[m]) + teststrings.add(''.join(entry)) + for i in teststrings: + i = self.fixtype(i) + for j in teststrings: + loc = i.find(j) + r1 = (loc != -1) + r2 = j in i + if r1 != r2: + self.assertEqual(r1, r2) + if loc != -1: + self.assertEqual(i[loc:loc+len(j)], j) + def test_rfind(self): self.checkequal(9, 'abcdefghiabc', 'rfind', 'abc') self.checkequal(12, 'abcdefghiabc', 'rfind', '') From rhettinger at users.sourceforge.net Sun Feb 20 05:07:41 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Feb 20 05:07:44 2005 Subject: [Python-checkins] python/dist/src/Objects stringobject.c, 2.227, 2.228 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21408/Objects Modified Files: stringobject.c Log Message: * Beef-up testing of str.__contains__() and str.find(). * Speed-up "x in y" where x has more than one character. The existing code made excessive calls to the expensive memcmp() function. The new code uses memchr() to rapidly find a start point for memcmp(). In addition to knowing that the first character is a match, the new code also checks that the last character is a match. This significantly reduces the incidence of false starts (saving memcmp() calls and making quadratic behavior less likely). Improves the timings on: python -m timeit -r7 -s"x='a'*1000" "'ab' in x" python -m timeit -r7 -s"x='a'*1000" "'bc' in x" Once this code has proven itself, then string_find_internal() should refer to it rather than running its own version. Also, something similar may apply to unicode objects. Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.227 retrieving revision 2.228 diff -u -d -r2.227 -r2.228 --- stringobject.c 31 Jan 2005 17:09:25 -0000 2.227 +++ stringobject.c 20 Feb 2005 04:07:04 -0000 2.228 @@ -1002,8 +1002,12 @@ static int string_contains(PyObject *a, PyObject *el) { - const char *lhs, *rhs, *end; - int size; + char *s = PyString_AS_STRING(a); + const char *sub = PyString_AS_STRING(el); + char *last; + int len_sub = PyString_GET_SIZE(el); + int shortsub; + char firstchar, lastchar; if (!PyString_CheckExact(el)) { #ifdef Py_USING_UNICODE @@ -1016,20 +1020,29 @@ return -1; } } - size = PyString_GET_SIZE(el); - rhs = PyString_AS_STRING(el); - lhs = PyString_AS_STRING(a); - - /* optimize for a single character */ - if (size == 1) - return memchr(lhs, *rhs, PyString_GET_SIZE(a)) != NULL; - end = lhs + (PyString_GET_SIZE(a) - size); - while (lhs <= end) { - if (memcmp(lhs++, rhs, size) == 0) + if (len_sub == 0) + return 1; + /* last points to one char beyond the start of the rightmost + substring. When s Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22296/Objects Modified Files: stringobject.c Log Message: * Beef-up tests for str.count(). * Speed-up str.count() by using memchr() to fly between first char matches. Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.228 retrieving revision 2.229 diff -u -d -r2.228 -r2.229 --- stringobject.c 20 Feb 2005 04:07:04 -0000 2.228 +++ stringobject.c 20 Feb 2005 09:54:52 -0000 2.229 @@ -2145,7 +2145,7 @@ static PyObject * string_count(PyStringObject *self, PyObject *args) { - const char *s = PyString_AS_STRING(self), *sub; + const char *s = PyString_AS_STRING(self), *sub, *t; int len = PyString_GET_SIZE(self), n; int i = 0, last = INT_MAX; int m, r; @@ -2186,11 +2186,16 @@ } else { i++; } + if (i >= m) + break; + t = memchr(s+i, sub[0], m-i); + if (t == NULL) + break; + i = t - s; } return PyInt_FromLong((long) r); } - PyDoc_STRVAR(swapcase__doc__, "S.swapcase() -> string\n\ \n\ From rhettinger at users.sourceforge.net Sun Feb 20 10:54:55 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Feb 20 10:55:00 2005 Subject: [Python-checkins] python/dist/src/Lib/test string_tests.py, 1.43, 1.44 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22296/Lib/test Modified Files: string_tests.py Log Message: * Beef-up tests for str.count(). * Speed-up str.count() by using memchr() to fly between first char matches. Index: string_tests.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/string_tests.py,v retrieving revision 1.43 retrieving revision 1.44 diff -u -d -r1.43 -r1.44 --- string_tests.py 20 Feb 2005 04:07:08 -0000 1.43 +++ string_tests.py 20 Feb 2005 09:54:53 -0000 1.44 @@ -114,6 +114,33 @@ self.checkraises(TypeError, 'hello', 'count') self.checkraises(TypeError, 'hello', 'count', 42) + # For a variety of combinations, + # verify that str.count() matches an equivalent function + # replacing all occurrences and then differencing the string lengths + charset = ['', 'a', 'b'] + digits = 7 + base = len(charset) + teststrings = set() + for i in xrange(base ** digits): + entry = [] + for j in xrange(digits): + i, m = divmod(i, base) + entry.append(charset[m]) + teststrings.add(''.join(entry)) + teststrings = list(teststrings) + for i in teststrings: + i = self.fixtype(i) + n = len(i) + for j in teststrings: + r1 = i.count(j) + if j: + r2, rem = divmod(n - len(i.replace(j, '')), len(j)) + else: + r2, rem = len(i)+1, 0 + if rem or r1 != r2: + self.assertEqual(rem, 0) + self.assertEqual(r1, r2) + def test_find(self): self.checkequal(0, 'abcdefghiabc', 'find', 'abc') self.checkequal(9, 'abcdefghiabc', 'find', 'abc', 1) @@ -135,6 +162,7 @@ i, m = divmod(i, base) entry.append(charset[m]) teststrings.add(''.join(entry)) + teststrings = list(teststrings) for i in teststrings: i = self.fixtype(i) for j in teststrings: From rhettinger at users.sourceforge.net Sun Feb 20 13:41:48 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Feb 20 13:41:51 2005 Subject: [Python-checkins] python/dist/src/Python compile.c,2.344,2.345 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2403 Modified Files: compile.c Log Message: Teach the peepholer to fold unary operations on constants. Afterwards, -0.5 loads in a single step and no longer requires a runtime UNARY_NEGATIVE operation. Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.344 retrieving revision 2.345 diff -u -d -r2.344 -r2.345 --- compile.c 10 Feb 2005 01:42:32 -0000 2.344 +++ compile.c 20 Feb 2005 12:41:32 -0000 2.345 @@ -542,6 +542,54 @@ return 1; } +static int +fold_unaryops_on_constants(unsigned char *codestr, PyObject *consts) +{ + PyObject *newconst, *v; + int len_consts, opcode; + + /* Pre-conditions */ + assert(PyList_CheckExact(consts)); + assert(codestr[0] == LOAD_CONST); + + /* Create new constant */ + v = PyList_GET_ITEM(consts, GETARG(codestr, 0)); + opcode = codestr[3]; + switch (opcode) { + case UNARY_NEGATIVE: + newconst = PyNumber_Negative(v); + break; + case UNARY_CONVERT: + newconst = PyObject_Repr(v); + break; + case UNARY_INVERT: + newconst = PyNumber_Invert(v); + break; + default: + /* Called with an unknown opcode */ + assert(0); + return 0; + } + if (newconst == NULL) { + PyErr_Clear(); + return 0; + } + + /* Append folded constant into consts table */ + len_consts = PyList_GET_SIZE(consts); + if (PyList_Append(consts, newconst)) { + Py_DECREF(newconst); + return 0; + } + Py_DECREF(newconst); + + /* Write NOP LOAD_CONST newconst */ + codestr[0] = NOP; + codestr[1] = LOAD_CONST; + SETARG(codestr, 1, len_consts); + return 1; +} + static unsigned int * markblocks(unsigned char *code, int len) { @@ -771,6 +819,20 @@ } break; + /* Fold unary ops on constants. + LOAD_CONST c1 UNARY_OP --> LOAD_CONST unary_op(c) */ + case UNARY_NEGATIVE: + case UNARY_CONVERT: + case UNARY_INVERT: + if (lastlc >= 1 && + ISBASICBLOCK(blocks, i-3, 4) && + fold_unaryops_on_constants(&codestr[i-3], consts)) { + i -= 2; + assert(codestr[i] == LOAD_CONST); + cumlc = 1; + } + break; + /* Simplify conditional jump to conditional jump where the result of the first test implies the success of a similar test or the failure of the opposite test. From rhettinger at users.sourceforge.net Sun Feb 20 13:46:56 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Feb 20 13:47:00 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_peepholer.py, 1.11, 1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3491 Modified Files: test_peepholer.py Log Message: Teach the peepholer to fold unary operations on constants. Afterwards, -0.5 loads in a single step and no longer requires a runtime UNARY_NEGATIVE operation. Index: test_peepholer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_peepholer.py,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- test_peepholer.py 10 Feb 2005 20:40:29 -0000 1.11 +++ test_peepholer.py 20 Feb 2005 12:46:54 -0000 1.12 @@ -133,6 +133,25 @@ asm = dis_single('a="x"*1000') self.assert_('(1000)' in asm) + def test_folding_of_unaryops_on_constants(self): + for line, elem in ( + ('`1`', "('1')"), # unary convert + ('-0.5', '(-0.5)'), # unary negative + ('~-2', '(1)'), # unary invert + ): + asm = dis_single(line) + self.assert_(elem in asm, asm) + self.assert_('UNARY_' not in asm) + + # Verify that unfoldables are skipped + for line, elem in ( + ('-"abc"', "('abc')"), # unary negative + ('~"abc"', "('abc')"), # unary invert + ): + asm = dis_single(line) + self.assert_(elem in asm, asm) + self.assert_('UNARY_' in asm) + def test_elim_extra_return(self): # RETURN LOAD_CONST None RETURN --> RETURN def f(x): From astrand at users.sourceforge.net Mon Feb 21 09:13:06 2005 From: astrand at users.sourceforge.net (astrand@users.sourceforge.net) Date: Mon Feb 21 09:13:08 2005 Subject: [Python-checkins] python/dist/src/Lib subprocess.py,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30011 Modified Files: subprocess.py Log Message: Made the module compatible with Python 2.2 again. Index: subprocess.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/subprocess.py,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- subprocess.py 14 Feb 2005 08:56:32 -0000 1.16 +++ subprocess.py 21 Feb 2005 08:13:02 -0000 1.17 @@ -2,6 +2,8 @@ # # For more information about this module, see PEP 324. # +# This module should remain compatible with Python 2.2, see PEP 291. +# # Copyright (c) 2003-2004 by Peter Astrand # # Licensed to PSF under a Contributor Agreement. @@ -374,6 +376,7 @@ mswindows = (sys.platform == "win32") import os +import types import traceback # Exception classes used by this module. @@ -712,7 +715,7 @@ errread, errwrite): """Execute program (MS Windows version)""" - if not isinstance(args, basestring): + if not isinstance(args, types.StringTypes): args = list2cmdline(args) # Process startup details @@ -938,7 +941,7 @@ errread, errwrite): """Execute program (POSIX version)""" - if isinstance(args, basestring): + if isinstance(args, types.StringTypes): args = [args] if shell: From rhettinger at users.sourceforge.net Mon Feb 21 16:46:59 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Feb 21 16:47:03 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libdecimal.tex,1.24,1.25 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11538 Modified Files: libdecimal.tex Log Message: Fix some wording and grammar nits. Index: libdecimal.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdecimal.tex,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- libdecimal.tex 25 Nov 2004 05:35:32 -0000 1.24 +++ libdecimal.tex 21 Feb 2005 15:46:52 -0000 1.25 @@ -84,7 +84,7 @@ \constant{Subnormal}, \constant{Overflow}, and \constant{Underflow}. For each signal there is a flag and a trap enabler. When a signal is -encountered, its flag incremented from zero and, then, if the trap enabler +encountered, its flag is incremented from zero and, then, if the trap enabler is set to one, an exception is raised. Flags are sticky, so the user needs to reset them before monitoring a calculation. @@ -119,7 +119,7 @@ \end{verbatim} -Decimal instances can be constructed from integers, strings or tuples. To +Decimal instances can be constructed from integers, strings, or tuples. To create a Decimal from a \class{float}, first convert it to a string. This serves as an explicit reminder of the details of the conversion (including representation error). Decimal numbers include special values such as @@ -160,7 +160,7 @@ \end{verbatim} -Decimals interact well with much of the rest of python. Here is a small +Decimals interact well with much of the rest of Python. Here is a small decimal floating point flying circus: \begin{verbatim} @@ -741,7 +741,7 @@ \end{classdesc*} \begin{classdesc*}{DecimalException} - Base class for other signals and is a subclass of + Base class for other signals and a subclass of \exception{ArithmeticError}. \end{classdesc*} @@ -847,7 +847,7 @@ \begin{verbatim} # Examples from Seminumerical Algorithms, Section 4.2.2. ->>> from decimal import * +>>> from decimal import Decimal, getcontext >>> getcontext().prec = 8 >>> u, v, w = Decimal(11111113), Decimal(-11111111), Decimal('7.51111111') From rhettinger at users.sourceforge.net Mon Feb 21 21:04:49 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Feb 21 21:04:52 2005 Subject: [Python-checkins] python/dist/src/Python compile.c,2.345,2.346 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12494 Modified Files: compile.c Log Message: Document how the pattern recognizer keeps all of its references in bounds. Add a test in case the underlying assumptions ever change (i.e. the compiler starts generating code blocks that are not punctuated by RETURN_VALUE). Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.345 retrieving revision 2.346 diff -u -d -r2.345 -r2.346 --- compile.c 20 Feb 2005 12:41:32 -0000 2.345 +++ compile.c 21 Feb 2005 20:03:14 -0000 2.346 @@ -677,6 +677,14 @@ goto exitUnchanged; codestr = memcpy(codestr, PyString_AS_STRING(code), codelen); + /* Verify that RETURN_VALUE terminates the codestring. This allows + the various transformation patterns to look ahead several + instructions without additional checks to make sure they are not + looking beyond the end of the code string. + */ + if (codestr[codelen-1] != RETURN_VALUE) + goto exitUnchanged; + /* Mapping to new jump targets after NOPs are removed */ addrmap = PyMem_Malloc(codelen * sizeof(int)); if (addrmap == NULL) From rhettinger at users.sourceforge.net Mon Feb 21 21:30:54 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Feb 21 21:30:58 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libdis.tex,1.42,1.43 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19073 Modified Files: libdis.tex Log Message: Document missing opcodes. Index: libdis.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdis.tex,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- libdis.tex 5 Jan 2005 07:19:11 -0000 1.42 +++ libdis.tex 21 Feb 2005 20:28:07 -0000 1.43 @@ -126,6 +126,10 @@ Indicates end-of-code to the compiler, not used by the interpreter. \end{opcodedesc} +\begin{opcodedesc}{NOP}{} +Do nothing code. Used as a placeholder by the bytecode optimizer. +\end{opcodedesc} + \begin{opcodedesc}{POP_TOP}{} Removes the top-of-stack (TOS) item. \end{opcodedesc} @@ -396,6 +400,10 @@ instruction). \end{opcodedesc} +\begin{opcodedesc}{LIST_APPEND}{} +Calls \code{list.append(TOS1, TOS)}. Used to implement list comprehensions. +\end{opcodedesc} + \begin{opcodedesc}{LOAD_LOCALS}{} Pushes a reference to the locals of the current scope on the stack. This is used in the code for a class definition: After the class body From rhettinger at users.sourceforge.net Mon Feb 21 21:34:27 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Feb 21 21:34:31 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libdis.tex, 1.41, 1.41.14.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20336 Modified Files: Tag: release24-maint libdis.tex Log Message: Document missing opcodes. Index: libdis.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdis.tex,v retrieving revision 1.41 retrieving revision 1.41.14.1 diff -u -d -r1.41 -r1.41.14.1 --- libdis.tex 10 May 2003 08:51:26 -0000 1.41 +++ libdis.tex 21 Feb 2005 20:33:50 -0000 1.41.14.1 @@ -122,6 +122,10 @@ Indicates end-of-code to the compiler, not used by the interpreter. \end{opcodedesc} +\begin{opcodedesc}{NOP}{} +Do nothing code. Used as a placeholder by the bytecode optimizer. +\end{opcodedesc} + \begin{opcodedesc}{POP_TOP}{} Removes the top-of-stack (TOS) item. \end{opcodedesc} @@ -392,6 +396,10 @@ instruction). \end{opcodedesc} +\begin{opcodedesc}{LIST_APPEND}{} +Calls \code{list.append(TOS1, TOS)}. Used to implement list comprehensions. +\end{opcodedesc} + \begin{opcodedesc}{LOAD_LOCALS}{} Pushes a reference to the locals of the current scope on the stack. This is used in the code for a class definition: After the class body From juliocastro98745 at mail.com Mon Feb 21 22:31:58 2005 From: juliocastro98745 at mail.com (Julio Castro) Date: Mon Feb 21 22:43:32 2005 Subject: [Python-checkins] listas de e-mails por atividade Message-ID: <20050221213143.A35F98893@scorpion5.uol.com.br> listas de envio de mala-direta, milh?es de e-mails para divulga??o, lista de email, emails para mala direta segmentada por segmento. Visite agora: http://www.gueb.de/dvgamail Listas para mala direta por e-mail, cadastros de e-mails divididos por atividade, listas de e-mails por atividade, milh?es de e-mails para divulga??o, lista de email: http://www.gueb.de/dvgamail -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-checkins/attachments/20050221/ed7d3ac8/attachment.htm From mwh at users.sourceforge.net Tue Feb 22 16:33:34 2005 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue Feb 22 16:33:38 2005 Subject: [Python-checkins] python/dist/src README,1.186,1.187 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27945 Modified Files: README Log Message: A few random updates to make things less horrifyingly out of date. Delete some advice that can never, ever have worked. There are a couple of XXX comments for bits I don't know how to update. It would be really good not to release Python 2.5 with these in place :) This file is way too big. There's basically no chance of it staying up to date. Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/README,v retrieving revision 1.186 retrieving revision 1.187 diff -u -d -r1.186 -r1.187 --- README 25 Jan 2005 12:40:00 -0000 1.186 +++ README 22 Feb 2005 15:33:26 -0000 1.187 @@ -35,6 +35,7 @@ See the file "Misc/NEWS". + If you don't read instructions ------------------------------ @@ -45,30 +46,29 @@ executable "./python"; to install in /usr/local, first do "su root" and then "make install". -The section `Build instructions' below is still recommended reading, -especially the part on customizing Modules/Setup. +The section `Build instructions' below is still recommended reading. What is Python anyway? ---------------------- -Python is an interpreted object-oriented programming language suitable -(amongst other uses) for distributed application development, -scripting, numeric computing and system testing. Python is often -compared to Tcl, Perl, Java, JavaScript, Visual Basic or Scheme. To -find out more about what Python can do for you, point your browser to -http://www.python.org/. +Python is an interpreted, interactive object-oriented programming +language suitable (amongst other uses) for distributed application +development, scripting, numeric computing and system testing. Python +is often compared to Tcl, Perl, Java, JavaScript, Visual Basic or +Scheme. To find out more about what Python can do for you, point your +browser to http://www.python.org/. How do I learn Python? ---------------------- The official tutorial is still a good place to start; see -http://www.python.org/doc/ for online and downloadable versions, as -well as a list of other introductions, and reference documentation. +http://docs.python.org/ for online and downloadable versions, as well +as a list of other introductions, and reference documentation. There's a quickly growing set of books on Python. See -http://www.python.org/cgi-bin/moinmoin/PythonBooks for a list. +www.python.org/moin/PythonBooks for a list. Documentation @@ -82,16 +82,17 @@ and functions! All documentation is also available online at the Python web site -(http://www.python.org/doc/, see below). It is available online for +(http://docs.python.org/, see below). It is available online for occasional reference, or can be downloaded in many formats for faster access. The documentation is available in HTML, PostScript, PDF, and LaTeX formats; the LaTeX version is primarily for documentation 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 +Unfortunately, new-style classes (new in Python 2.2) have not yet been +integrated into Python's standard documention. A collection of +pointers to what has been written is at: - http://www.python.org/2.2.1/descrintro.html + http://www.python.org/doc/newstyle.html Web sites @@ -110,12 +111,12 @@ Read comp.lang.python, a high-volume discussion newsgroup about Python, or comp.lang.python.announce, a low-volume moderated newsgroup for Python-related announcements. These are also accessible as -mailing lists: see http://www.python.org/psa/MailingLists.html for an -overview of the many Python-related mailing lists. +mailing lists: see http://www.python.org/community/lists.html for an +overview of these and many other 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. +http://www.python.org/community/lists.html for details. Bug reports @@ -135,7 +136,7 @@ If you have a proposal to change Python, it's best to submit a Python Enhancement Proposal (PEP) first. All current PEPs, as well as guidelines for submitting a new PEP, are listed at -http://python.sourceforge.net/peps/. +http://www.python.org/peps/. Questions @@ -189,10 +190,9 @@ See also the platform specific notes in the next section. -If you run into other trouble, see section 3 of the FAQ -(http://www.python.org/cgi-bin/faqw.py or -http://www.python.org/doc/FAQ.html) for hints on what can go wrong, -and how to fix it. +If you run into other trouble, see the FAQ +(http://www.python.org/doc/faq) for hints on what can go wrong, and +how to fix it. If you rerun the configure script with different options, remove all object files by running "make clean" before rebuilding. Believe it or @@ -200,8 +200,7 @@ problems as well. Try it before sending in a bug report! If the configure script fails or doesn't seem to find things that -should be there, inspect the config.log file. When you fix a -configure problem, be sure to remove config.cache! +should be there, inspect the config.log file. If you get a warning for every file about the -Olimit option being no longer supported, you can ignore it. There's no foolproof way to know @@ -227,8 +226,10 @@ Unsupported systems ------------------- +XXX This section is out of date! + A number of features are not supported in Python 2.3 anymore. Some -support code is still present, but will be removed in Python 2.4. +support code is still present, but will be removed in Python 2.4. If you still need to use current Python versions on these systems, please send a message to python-dev@python.org indicating that you volunteer to support this system. @@ -263,12 +264,9 @@ bsddb185 bsddbmodule.c should work. (You may need to add -I, -L or -l flags to direct the - compiler and linker to your include files and libraries.) You can - then force it to be the version people import by adding - - import bsddb185 as bsddb + compiler and linker to your include files and libraries.) - in sitecustomize.py. +XXX I think this next bit is out of date: 64-bit platforms: The modules audioop, imageop and rgbimg don't work. The setup.py script disables them on 64-bit installations. @@ -295,8 +293,8 @@ When the dynamic loader complains about errors finding shared libraries, such as - ld.so.1: ./python: fatal: libstdc++.so.5: open failed: - No such file or directory + ld.so.1: ./python: fatal: libstdc++.so.5: open failed: + No such file or directory you need to first make sure that the library is available on your system. Then, you need to instruct the dynamic loader how @@ -314,13 +312,9 @@ solves the problem. This causes the popen2 test to fail; problem and solution reported by Pablo Bleyer. - Under Linux systems using GNU libc 2 (aka libc6), the crypt - module now needs the -lcrypt option. The setup.py script - takes care of this automatically. - Red Hat Linux: Red Hat 9 built Python2.2 in UCS-4 mode and hacked Tcl to support it. To compile Python2.3 with Tkinter, you will - need to pass --enable-unicode=ucs4 flag to ./configure. + need to pass --enable-unicode=ucs4 flag to ./configure. There's an executable /usr/bin/python which is Python 1.5.2 on most older Red Hat installations; several key Red Hat tools @@ -367,13 +361,13 @@ OPT variable in the top-level Makefile; reported by Pat Knight, this seems to make a difference (at least for HP-UX 10.20) even though pyconfig.h defines it. This seems unnecessary when - using HP/UX 11 and later - threading seems to work "out of the + using HP/UX 11 and later - threading seems to work "out of the box". -HP-UX ia64: When building on the ia64 (Itanium) platform using HP's - compiler, some experience has shown that the compiler's - optimiser produces a completely broken version of python - (see http://www.python.org/sf/814976). To work around this, +HP-UX ia64: When building on the ia64 (Itanium) platform using HP's + compiler, some experience has shown that the compiler's + optimiser produces a completely broken version of python + (see http://www.python.org/sf/814976). To work around this, edit the Makefile and remove -O from the OPT line. HP PA-RISC 2.0: A recent bug report (http://www.python.org/sf/546117) @@ -541,7 +535,7 @@ do "sudo make install" which installs everything as superuser, as this may later cause problems when installing distutils-based additions. - + Some people have reported problems building Python after using "fink" to install additional unix software. Disabling fink (remove all references to /sw from your .profile or .login) should solve this. @@ -552,7 +546,7 @@ /Library/Frameworks). A framework install is probably needed if you want to use any Aqua-based GUI toolkit (whether Tkinter, wxPython, Carbon, Cocoa or anything else). - + See Mac/OSX/README for more information on framework builds. Cygwin: With recent (relative to the time of writing, 2001-12-19) @@ -767,9 +761,9 @@ --------------------------- Starting with Python 2.3, the majority of the interpreter can be built -into a shared library, which can then be used by the interpreter +into a shared library, which can then be used by the interpreter executable, and by applications embedding Python. To enable this feature, -configure with --enable-shared. +configure with --enable-shared. If you enable this feature, the same object files will be used to create a static library. In particular, the static library will contain object @@ -1018,7 +1012,7 @@ --with-pydebug: Enable additional debugging code to help track down memory management problems. This allows printing a list of all live objects when the interpreter terminates. - + --with(out)-universal-newlines: enable reading of text files with foreign newline convention (default: enabled). In other words, any of \r, \n or \r\n is acceptable as end-of-line character. @@ -1028,6 +1022,7 @@ --with-tsc: Profile using the Pentium timestamping counter (TSC). + Building for multiple architectures (using the VPATH feature) ------------------------------------------------------------- @@ -1130,9 +1125,7 @@ For more Tkinter information, see the Tkinter Resource page: http://www.python.org/topics/tkinter/ -There are demos in the Demo/tkinter directory, in the subdirectories -guido, matt and www (the matt and guido subdirectories have been -overhauled to use more recent Tkinter coding conventions). +There are demos in the Demo/tkinter directory. Note that there's a Python module called "Tkinter" (capital T) which lives in Lib/lib-tk/Tkinter.py, and a C module called "_tkinter" From rhettinger at users.sourceforge.net Wed Feb 23 14:37:58 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Feb 23 14:38:02 2005 Subject: [Python-checkins] python/dist/src/Python compile.c,2.346,2.347 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25613 Modified Files: compile.c Log Message: Preserve sign of -0.0 when result is run through marshal. Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.346 retrieving revision 2.347 diff -u -d -r2.346 -r2.347 --- compile.c 21 Feb 2005 20:03:14 -0000 2.346 +++ compile.c 23 Feb 2005 13:37:55 -0000 2.347 @@ -545,7 +545,7 @@ static int fold_unaryops_on_constants(unsigned char *codestr, PyObject *consts) { - PyObject *newconst, *v; + PyObject *newconst=NULL, *v; int len_consts, opcode; /* Pre-conditions */ @@ -557,7 +557,9 @@ opcode = codestr[3]; switch (opcode) { case UNARY_NEGATIVE: - newconst = PyNumber_Negative(v); + /* Preserve the sign of -0.0 */ + if (PyObject_IsTrue(v) == 1) + newconst = PyNumber_Negative(v); break; case UNARY_CONVERT: newconst = PyObject_Repr(v); From rhettinger at users.sourceforge.net Wed Feb 23 21:40:46 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Feb 23 21:40:48 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libdis.tex,1.43,1.44 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5815 Modified Files: libdis.tex Log Message: Update an example to match current output. Index: libdis.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdis.tex,v retrieving revision 1.43 retrieving revision 1.44 diff -u -d -r1.43 -r1.44 --- libdis.tex 21 Feb 2005 20:28:07 -0000 1.43 +++ libdis.tex 23 Feb 2005 20:40:42 -0000 1.44 @@ -26,9 +26,7 @@ 2 0 LOAD_GLOBAL 0 (len) 3 LOAD_FAST 0 (alist) 6 CALL_FUNCTION 1 - 9 RETURN_VALUE - 10 LOAD_CONST 0 (None) - 13 RETURN_VALUE + 9 RETURN_VALUE \end{verbatim} (The ``2'' is a line number). From loewis at users.sourceforge.net Thu Feb 24 21:22:14 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Feb 24 21:22:17 2005 Subject: [Python-checkins] python/dist/src/Lib/test/output test_xdrlib, NONE, 1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10039/Lib/test/output Added Files: test_xdrlib Log Message: Patch #1049151: adding bool support to xdrlib.py. Also add xdrlib._test into the test suite. --- NEW FILE: test_xdrlib --- test_xdrlib pack test 0 succeeded pack test 1 succeeded pack test 2 succeeded pack test 3 succeeded pack test 4 succeeded pack test 5 succeeded pack test 6 succeeded pack test 7 succeeded pack test 8 succeeded unpack test 0 succeeded : 9 unpack test 1 succeeded : True unpack test 2 succeeded : False unpack test 3 succeeded : 45 unpack test 4 succeeded : 1.89999997616 unpack test 5 succeeded : 1.9 unpack test 6 succeeded : hello world unpack test 7 succeeded : [0, 1, 2, 3, 4] unpack test 8 succeeded : ['what', 'is', 'hapnin', 'doctor'] From loewis at users.sourceforge.net Thu Feb 24 21:22:17 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Feb 24 21:22:19 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1244,1.1245 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10039/Misc Modified Files: NEWS Log Message: Patch #1049151: adding bool support to xdrlib.py. Also add xdrlib._test into the test suite. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1244 retrieving revision 1.1245 diff -u -d -r1.1244 -r1.1245 --- NEWS 18 Feb 2005 13:22:43 -0000 1.1244 +++ NEWS 24 Feb 2005 20:22:12 -0000 1.1245 @@ -54,6 +54,8 @@ Library ------- +- Patch #1049151: xdrlib now unpacks booleans as True or False. + - Fixed bug in a NameError bug in cookielib. Patch #1116583. - Applied a security fix to SimpleXMLRPCserver (PSF-2005-001). This From loewis at users.sourceforge.net Thu Feb 24 21:22:43 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Feb 24 21:22:46 2005 Subject: [Python-checkins] python/dist/src/Lib xdrlib.py,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10039/Lib Modified Files: xdrlib.py Log Message: Patch #1049151: adding bool support to xdrlib.py. Also add xdrlib._test into the test suite. Index: xdrlib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/xdrlib.py,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- xdrlib.py 12 Feb 2004 17:35:07 -0000 1.16 +++ xdrlib.py 24 Feb 2005 20:22:11 -0000 1.17 @@ -157,7 +157,9 @@ return struct.unpack('>l', data)[0] unpack_enum = unpack_int - unpack_bool = unpack_int + + def unpack_bool(self): + return bool(self.unpack_int()) def unpack_uhyper(self): hi = self.unpack_uint() @@ -232,8 +234,8 @@ p = Packer() packtest = [ (p.pack_uint, (9,)), - (p.pack_bool, (None,)), - (p.pack_bool, ('hello',)), + (p.pack_bool, (True,)), + (p.pack_bool, (False,)), (p.pack_uhyper, (45L,)), (p.pack_float, (1.9,)), (p.pack_double, (1.9,)), @@ -257,8 +259,8 @@ up = Unpacker(data) unpacktest = [ (up.unpack_uint, (), lambda x: x == 9), - (up.unpack_bool, (), lambda x: not x), - (up.unpack_bool, (), lambda x: x), + (up.unpack_bool, (), lambda x: x is True), + (up.unpack_bool, (), lambda x: x is False), (up.unpack_uhyper, (), lambda x: x == 45L), (up.unpack_float, (), lambda x: 1.89 < x < 1.91), (up.unpack_double, (), lambda x: 1.89 < x < 1.91), From loewis at users.sourceforge.net Thu Feb 24 21:22:44 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Feb 24 21:22:47 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_xdrlib.py, NONE, 1.1 test_sundry.py, 1.16, 1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10039/Lib/test Modified Files: test_sundry.py Added Files: test_xdrlib.py Log Message: Patch #1049151: adding bool support to xdrlib.py. Also add xdrlib._test into the test suite. --- NEW FILE: test_xdrlib.py --- import xdrlib xdrlib._test() Index: test_sundry.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_sundry.py,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- test_sundry.py 5 Dec 2004 11:38:18 -0000 1.16 +++ test_sundry.py 24 Feb 2005 20:22:11 -0000 1.17 @@ -93,5 +93,4 @@ #import user import webbrowser import whichdb -import xdrlib import xml From goodger at users.sourceforge.net Thu Feb 24 22:20:19 2005 From: goodger at users.sourceforge.net (goodger@users.sourceforge.net) Date: Thu Feb 24 22:20:26 2005 Subject: [Python-checkins] python/nondist/peps pep-0754.txt,1.5,1.6 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27661 Modified Files: pep-0754.txt Log Message: applied patch from Gregory Warnes Index: pep-0754.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0754.txt,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- pep-0754.txt 11 Dec 2004 18:34:25 -0000 1.5 +++ pep-0754.txt 24 Feb 2005 21:20:14 -0000 1.6 @@ -158,10 +158,12 @@ which is written in pure Python by taking advantage of the "struct" standard module to directly set or test for the bit patterns that define IEEE 754 special values. Care has been taken to generate -proper results on both big-endian and little-endian machines. +proper results on both big-endian and little-endian machines. The +current implementation is pure Python, but some efficiency could be +gained by translating the core routines into C. -The current implementation is pure Python, but some efficiency could -be gained by translating the core routines into C. +Patch 1151323 "New fpconst module" [2]_ on SourceForge adds the +fpconst module to the Python standard library. References @@ -171,7 +173,10 @@ reference material on the IEEE 754 floating point standard. .. [1] Further information on the reference package is available at - http://research.warnes.net/projects/rzope/fpconst/ + http://research.warnes.net/projects/rzope/fpconst/ + +.. [2] http://sourceforge.net/tracker/?func=detail&aid=1151323&group_id=5470&atid=305470 + Copyright From vincent at instonline.com Thu Feb 24 10:16:56 2005 From: vincent at instonline.com (vincent) Date: Fri Feb 25 16:04:35 2005 Subject: [Python-checkins] instonilne.com Message-ID: <200502251656703.SM03408@vincent> An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-checkins/attachments/20050224/722cfefc/attachment.html From loewis at users.sourceforge.net Sun Feb 27 21:33:28 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Feb 27 21:33:32 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1245,1.1246 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16792/Misc Modified Files: NEWS Log Message: Patch #1093585: raise a ValueError for negative history items in remove_history and replace_history. Will backport to 2.4. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1245 retrieving revision 1.1246 diff -u -d -r1.1245 -r1.1246 --- NEWS 24 Feb 2005 20:22:12 -0000 1.1245 +++ NEWS 27 Feb 2005 20:33:22 -0000 1.1246 @@ -34,6 +34,9 @@ Extension Modules ----------------- +- Patch #1093585: raise a ValueError for negative history items in readline. + {remove_history,replace_history} + - The spwd module has been added, allowing access to the shadow password database. From loewis at users.sourceforge.net Sun Feb 27 21:33:29 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Feb 27 21:33:32 2005 Subject: [Python-checkins] python/dist/src/Modules readline.c,2.79,2.80 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16792/Modules Modified Files: readline.c Log Message: Patch #1093585: raise a ValueError for negative history items in remove_history and replace_history. Will backport to 2.4. Index: readline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v retrieving revision 2.79 retrieving revision 2.80 diff -u -d -r2.79 -r2.80 --- readline.c 25 Nov 2004 04:04:20 -0000 2.79 +++ readline.c 27 Feb 2005 20:33:25 -0000 2.80 @@ -303,6 +303,11 @@ if (!PyArg_ParseTuple(args, "i:remove_history", &entry_number)) return NULL; + if (entry_number < 0) { + PyErr_SetString(PyExc_ValueError, + "History index cannot be negative"); + return NULL; + } entry = remove_history(entry_number); if (!entry) { PyErr_Format(PyExc_ValueError, @@ -335,6 +340,11 @@ if (!PyArg_ParseTuple(args, "is:replace_history", &entry_number, &line)) { return NULL; } + if (entry_number < 0) { + PyErr_SetString(PyExc_ValueError, + "History index cannot be negative"); + return NULL; + } old_entry = replace_history_entry(entry_number, line, (void *)NULL); if (!old_entry) { PyErr_Format(PyExc_ValueError, From loewis at users.sourceforge.net Sun Feb 27 21:34:04 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Feb 27 21:34:07 2005 Subject: [Python-checkins] python/dist/src/Modules readline.c,2.79,2.79.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16157/Modules Modified Files: Tag: release24-maint readline.c Log Message: Patch #1093585: raise a ValueError for negative history items in remove_history and replace_history. Index: readline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v retrieving revision 2.79 retrieving revision 2.79.2.1 diff -u -d -r2.79 -r2.79.2.1 --- readline.c 25 Nov 2004 04:04:20 -0000 2.79 +++ readline.c 27 Feb 2005 20:34:01 -0000 2.79.2.1 @@ -303,6 +303,11 @@ if (!PyArg_ParseTuple(args, "i:remove_history", &entry_number)) return NULL; + if (entry_number < 0) { + PyErr_SetString(PyExc_ValueError, + "History index cannot be negative"); + return NULL; + } entry = remove_history(entry_number); if (!entry) { PyErr_Format(PyExc_ValueError, @@ -335,6 +340,11 @@ if (!PyArg_ParseTuple(args, "is:replace_history", &entry_number, &line)) { return NULL; } + if (entry_number < 0) { + PyErr_SetString(PyExc_ValueError, + "History index cannot be negative"); + return NULL; + } old_entry = replace_history_entry(entry_number, line, (void *)NULL); if (!old_entry) { PyErr_Format(PyExc_ValueError, From loewis at users.sourceforge.net Sun Feb 27 21:34:04 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Feb 27 21:34:08 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.21, 1.1193.2.22 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16157/Misc Modified Files: Tag: release24-maint NEWS Log Message: Patch #1093585: raise a ValueError for negative history items in remove_history and replace_history. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.21 retrieving revision 1.1193.2.22 diff -u -d -r1.1193.2.21 -r1.1193.2.22 --- NEWS 17 Feb 2005 14:57:04 -0000 1.1193.2.21 +++ NEWS 27 Feb 2005 20:34:00 -0000 1.1193.2.22 @@ -25,6 +25,13 @@ is provided. +Extension Modules +----------------- + +- Patch #1093585: raise a ValueError for negative history items in readline. + {remove_history,replace_history} + + Library ------- @@ -59,7 +66,6 @@ - Bug #1083110: ``zlib.decompress.flush()`` would segfault if called immediately after creating the object, without any intervening ``.decompress()`` calls. - Build ----- From rhettinger at users.sourceforge.net Mon Feb 28 20:27:55 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Feb 28 20:27:59 2005 Subject: [Python-checkins] python/dist/src/Lib sre_parse.py, 1.63, 1.64 sre_compile.py, 1.56, 1.57 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12064 Modified Files: sre_parse.py sre_compile.py Log Message: Complete the previous effort to factor out constant expressions and improve the speed of the if/elif/else blocks. Index: sre_parse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_parse.py,v retrieving revision 1.63 retrieving revision 1.64 diff -u -d -r1.63 -r1.64 --- sre_parse.py 3 Sep 2004 20:15:56 -0000 1.63 +++ sre_parse.py 28 Feb 2005 19:27:52 -0000 1.64 @@ -16,15 +16,21 @@ from sre_constants import * +def set(seq): + s = {} + for elem in seq: + s[elem] = 1 + return s + SPECIAL_CHARS = ".\\[{()*+?^$|" REPEAT_CHARS = "*+?{" -DIGITS = tuple("0123456789") +DIGITS = set("0123456789") -OCTDIGITS = tuple("01234567") -HEXDIGITS = tuple("0123456789abcdefABCDEF") +OCTDIGITS = set("01234567") +HEXDIGITS = set("0123456789abcdefABCDEF") -WHITESPACE = tuple(" \t\n\r\v\f") +WHITESPACE = set(" \t\n\r\v\f") ESCAPES = { r"\a": (LITERAL, ord("\a")), @@ -371,6 +377,11 @@ subpattern.append((GROUPREF_EXISTS, (condgroup, item_yes, item_no))) return subpattern +_PATTERNENDERS = set("|)") +_ASSERTCHARS = set("=!<") +_LOOKBEHINDASSERTCHARS = set("=!") +_REPEATCODES = set([MIN_REPEAT, MAX_REPEAT]) + def _parse(source, state): # parse a simple pattern subpattern = SubPattern(state) @@ -380,10 +391,10 @@ sourceget = source.get sourcematch = source.match _len = len - PATTERNENDERS = ("|", ")") - ASSERTCHARS = ("=", "!", "<") - LOOKBEHINDASSERTCHARS = ("=", "!") - REPEATCODES = (MIN_REPEAT, MAX_REPEAT) + PATTERNENDERS = _PATTERNENDERS + ASSERTCHARS = _ASSERTCHARS + LOOKBEHINDASSERTCHARS = _LOOKBEHINDASSERTCHARS + REPEATCODES = _REPEATCODES while 1: Index: sre_compile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/sre_compile.py,v retrieving revision 1.56 retrieving revision 1.57 diff -u -d -r1.56 -r1.57 --- sre_compile.py 15 Oct 2004 06:15:08 -0000 1.56 +++ sre_compile.py 28 Feb 2005 19:27:52 -0000 1.57 @@ -24,14 +24,25 @@ def _identityfunction(x): return x +def set(seq): + s = {} + for elem in seq: + s[elem] = 1 + return s + +_LITERAL_CODES = set([LITERAL, NOT_LITERAL]) +_REPEATING_CODES = set([REPEAT, MIN_REPEAT, MAX_REPEAT]) +_SUCCESS_CODES = set([SUCCESS, FAILURE]) +_ASSERT_CODES = set([ASSERT, ASSERT_NOT]) + def _compile(code, pattern, flags): # internal: compile a (sub)pattern emit = code.append _len = len - LITERAL_CODES = {LITERAL:1, NOT_LITERAL:1} - REPEATING_CODES = {REPEAT:1, MIN_REPEAT:1, MAX_REPEAT:1} - SUCCESS_CODES = {SUCCESS:1, FAILURE:1} - ASSERT_CODES = {ASSERT:1, ASSERT_NOT:1} + LITERAL_CODES = _LITERAL_CODES + REPEATING_CODES = _REPEATING_CODES + SUCCESS_CODES = _SUCCESS_CODES + ASSERT_CODES = _ASSERT_CODES for op, av in pattern: if op in LITERAL_CODES: if flags & SRE_FLAG_IGNORECASE: From rhettinger at users.sourceforge.net Mon Feb 28 20:39:25 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Feb 28 20:39:30 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_functional.py, NONE, 1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14403/Lib/test Added Files: test_functional.py Log Message: SF patch #941881: PEP 309 Implementation (Partial Function Application). Combined efforts of many including Peter Harris, Hye-Shik Chang, Martin v. Löwis, Nick Coghlan, Paul Moore, and Raymond Hettinger. --- NEW FILE: test_functional.py --- import functional import unittest from test import test_support @staticmethod def PythonPartial(func, *args, **keywords): 'Pure Python approximation of partial()' def newfunc(*fargs, **fkeywords): newkeywords = keywords.copy() newkeywords.update(fkeywords) return func(*(args + fargs), **newkeywords) newfunc.func = func newfunc.args = args newfunc.keywords = keywords return newfunc def capture(*args, **kw): """capture all positional and keyword arguments""" return args, kw class TestPartial(unittest.TestCase): thetype = functional.partial def test_basic_examples(self): p = self.thetype(capture, 1, 2, a=10, b=20) self.assertEqual(p(3, 4, b=30, c=40), ((1, 2, 3, 4), dict(a=10, b=30, c=40))) p = self.thetype(map, lambda x: x*10) self.assertEqual(p([1,2,3,4]), [10, 20, 30, 40]) def test_attributes(self): p = self.thetype(capture, 1, 2, a=10, b=20) # attributes should be readable self.assertEqual(p.func, capture) self.assertEqual(p.args, (1, 2)) self.assertEqual(p.keywords, dict(a=10, b=20)) # attributes should not be writable if not isinstance(self.thetype, type): return self.assertRaises(TypeError, setattr, p, 'func', map) self.assertRaises(TypeError, setattr, p, 'args', (1, 2)) self.assertRaises(TypeError, setattr, p, 'keywords', dict(a=1, b=2)) def test_argument_checking(self): self.assertRaises(TypeError, self.thetype) # need at least a func arg try: self.thetype(2)() except TypeError: pass else: self.fail('First arg not checked for callability') def test_protection_of_callers_dict_argument(self): # a caller's dictionary should not be altered by partial def func(a=10, b=20): return a d = {'a':3} p = self.thetype(func, a=5) self.assertEqual(p(**d), 3) self.assertEqual(d, {'a':3}) p(b=7) self.assertEqual(d, {'a':3}) def test_arg_combinations(self): # exercise special code paths for zero args in either partial # object or the caller p = self.thetype(capture) self.assertEqual(p(), ((), {})) self.assertEqual(p(1,2), ((1,2), {})) p = self.thetype(capture, 1, 2) self.assertEqual(p(), ((1,2), {})) self.assertEqual(p(3,4), ((1,2,3,4), {})) def test_kw_combinations(self): # exercise special code paths for no keyword args in # either the partial object or the caller p = self.thetype(capture) self.assertEqual(p(), ((), {})) self.assertEqual(p(a=1), ((), {'a':1})) p = self.thetype(capture, a=1) self.assertEqual(p(), ((), {'a':1})) self.assertEqual(p(b=2), ((), {'a':1, 'b':2})) # keyword args in the call override those in the partial object self.assertEqual(p(a=3, b=2), ((), {'a':3, 'b':2})) def test_positional(self): # make sure positional arguments are captured correctly for args in [(), (0,), (0,1), (0,1,2), (0,1,2,3)]: p = self.thetype(capture, *args) expected = args + ('x',) got, empty = p('x') self.failUnless(expected == got and empty == {}) def test_keyword(self): # make sure keyword arguments are captured correctly for a in ['a', 0, None, 3.5]: p = self.thetype(capture, a=a) expected = {'a':a,'x':None} empty, got = p(x=None) self.failUnless(expected == got and empty == ()) def test_no_side_effects(self): # make sure there are no side effects that affect subsequent calls p = self.thetype(capture, 0, a=1) args1, kw1 = p(1, b=2) self.failUnless(args1 == (0,1) and kw1 == {'a':1,'b':2}) args2, kw2 = p() self.failUnless(args2 == (0,) and kw2 == {'a':1}) def test_error_propagation(self): def f(x, y): x / y self.assertRaises(ZeroDivisionError, self.thetype(f, 1, 0)) self.assertRaises(ZeroDivisionError, self.thetype(f, 1), 0) self.assertRaises(ZeroDivisionError, self.thetype(f), 1, 0) self.assertRaises(ZeroDivisionError, self.thetype(f, y=0), 1) class PartialSubclass(functional.partial): pass class TestPartialSubclass(TestPartial): thetype = PartialSubclass class TestPythonPartial(TestPartial): thetype = PythonPartial def test_main(verbose=None): import sys test_classes = ( TestPartial, TestPartialSubclass, TestPythonPartial, ) test_support.run_unittest(*test_classes) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in xrange(len(counts)): test_support.run_unittest(*test_classes) gc.collect() counts[i] = sys.gettotalrefcount() print counts if __name__ == '__main__': test_main(verbose=True) From rhettinger at users.sourceforge.net Mon Feb 28 20:39:46 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Feb 28 20:39:49 2005 Subject: [Python-checkins] python/dist/src/Modules functionalmodule.c, NONE, 1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14403/Modules Added Files: functionalmodule.c Log Message: SF patch #941881: PEP 309 Implementation (Partial Function Application). Combined efforts of many including Peter Harris, Hye-Shik Chang, Martin v. Löwis, Nick Coghlan, Paul Moore, and Raymond Hettinger. --- NEW FILE: functionalmodule.c --- #include "Python.h" #include "structmember.h" /* Functional module written and maintained by Hye-Shik Chang with adaptations by Raymond Hettinger Copyright (c) 2004, 2005 Python Software Foundation. All rights reserved. */ /* partial object **********************************************************/ typedef struct { PyObject_HEAD PyObject *fn; PyObject *args; PyObject *kw; } partialobject; static PyTypeObject partial_type; static PyObject * partial_new(PyTypeObject *type, PyObject *args, PyObject *kw) { PyObject *func; partialobject *pto; if (PyTuple_GET_SIZE(args) < 1) { PyErr_SetString(PyExc_TypeError, "type 'partial' takes at least one argument"); return NULL; } func = PyTuple_GET_ITEM(args, 0); if (!PyCallable_Check(func)) { PyErr_SetString(PyExc_TypeError, "the first argument must be callable"); return NULL; } /* create partialobject structure */ pto = (partialobject *)type->tp_alloc(type, 0); if (pto == NULL) return NULL; pto->fn = func; Py_INCREF(func); pto->args = PyTuple_GetSlice(args, 1, INT_MAX); if (pto->args == NULL) { pto->kw = NULL; Py_DECREF(pto); return NULL; } if (kw != NULL) { pto->kw = PyDict_Copy(kw); if (pto->kw == NULL) { Py_DECREF(pto); return NULL; } } else { pto->kw = Py_None; Py_INCREF(Py_None); } return (PyObject *)pto; } static void partial_dealloc(partialobject *pto) { PyObject_GC_UnTrack(pto); Py_XDECREF(pto->fn); Py_XDECREF(pto->args); Py_XDECREF(pto->kw); pto->ob_type->tp_free(pto); } static PyObject * partial_call(partialobject *pto, PyObject *args, PyObject *kw) { PyObject *ret; PyObject *argappl = NULL, *kwappl = NULL; assert (PyCallable_Check(pto->fn)); assert (PyTuple_Check(pto->args)); assert (pto->kw == Py_None || PyDict_Check(pto->kw)); if (PyTuple_GET_SIZE(pto->args) == 0) { argappl = args; Py_INCREF(args); } else if (PyTuple_GET_SIZE(args) == 0) { argappl = pto->args; Py_INCREF(pto->args); } else { argappl = PySequence_Concat(pto->args, args); if (argappl == NULL) return NULL; } if (pto->kw == Py_None) { kwappl = kw; Py_XINCREF(kw); } else { kwappl = PyDict_Copy(pto->kw); if (kwappl == NULL) { Py_DECREF(argappl); return NULL; } if (kw != NULL) { if (PyDict_Merge(kwappl, kw, 1) != 0) { Py_DECREF(argappl); Py_DECREF(kwappl); return NULL; } } } ret = PyObject_Call(pto->fn, argappl, kwappl); Py_DECREF(argappl); Py_XDECREF(kwappl); return ret; } static int partial_traverse(partialobject *pto, visitproc visit, void *arg) { Py_VISIT(pto->fn); Py_VISIT(pto->args); Py_VISIT(pto->kw); return 0; } PyDoc_STRVAR(partial_doc, "partial(func, *args, **keywords) - new function with partial application\n\ of the given arguments and keywords.\n"); #define OFF(x) offsetof(partialobject, x) static PyMemberDef partial_memberlist[] = { {"func", T_OBJECT, OFF(fn), READONLY, "function object to use in future partial calls"}, {"args", T_OBJECT, OFF(args), READONLY, "tuple of arguments to future partial calls"}, {"keywords", T_OBJECT, OFF(kw), READONLY, "dictionary of keyword arguments to future partial calls"}, {NULL} /* Sentinel */ }; static PyTypeObject partial_type = { PyObject_HEAD_INIT(NULL) 0, /* ob_size */ "functional.partial", /* tp_name */ sizeof(partialobject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ (destructor)partial_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_compare */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ (ternaryfunc)partial_call, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /* tp_flags */ partial_doc, /* tp_doc */ (traverseproc)partial_traverse, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ partial_memberlist, /* 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 */ partial_new, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; /* module level code ********************************************************/ PyDoc_STRVAR(module_doc, "Tools for functional programming."); static PyMethodDef module_methods[] = { {NULL, NULL} /* sentinel */ }; PyMODINIT_FUNC initfunctional(void) { int i; PyObject *m; char *name; PyTypeObject *typelist[] = { &partial_type, NULL }; m = Py_InitModule3("functional", module_methods, module_doc); for (i=0 ; typelist[i] != NULL ; i++) { if (PyType_Ready(typelist[i]) < 0) return; name = strchr(typelist[i]->tp_name, '.'); assert (name != NULL); Py_INCREF(typelist[i]); PyModule_AddObject(m, name+1, (PyObject *)typelist[i]); } } From rhettinger at users.sourceforge.net Mon Feb 28 20:39:47 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Feb 28 20:39:51 2005 Subject: [Python-checkins] python/dist/src/PC config.c,1.51,1.52 Message-ID: Update of /cvsroot/python/python/dist/src/PC In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14403/PC Modified Files: config.c Log Message: SF patch #941881: PEP 309 Implementation (Partial Function Application). Combined efforts of many including Peter Harris, Hye-Shik Chang, Martin v. Löwis, Nick Coghlan, Paul Moore, and Raymond Hettinger. Index: config.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/config.c,v retrieving revision 1.51 retrieving revision 1.52 diff -u -d -r1.51 -r1.52 --- config.c 12 Oct 2004 21:48:56 -0000 1.51 +++ config.c 28 Feb 2005 19:39:44 -0000 1.52 @@ -53,6 +53,7 @@ extern void initparser(void); extern void init_winreg(void); extern void initdatetime(void); +extern void initfunctional(void); extern void init_multibytecodec(void); extern void init_codecs_cn(void); @@ -124,6 +125,7 @@ {"parser", initparser}, {"_winreg", init_winreg}, {"datetime", initdatetime}, + {"functional", initfunctional}, {"xxsubtype", initxxsubtype}, {"zipimport", initzipimport}, From rhettinger at users.sourceforge.net Mon Feb 28 20:39:48 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Feb 28 20:39:52 2005 Subject: [Python-checkins] python/dist/src/PCbuild pythoncore.vcproj, 1.26, 1.27 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14403/PCbuild Modified Files: pythoncore.vcproj Log Message: SF patch #941881: PEP 309 Implementation (Partial Function Application). Combined efforts of many including Peter Harris, Hye-Shik Chang, Martin v. Löwis, Nick Coghlan, Paul Moore, and Raymond Hettinger. Index: pythoncore.vcproj =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pythoncore.vcproj,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- pythoncore.vcproj 1 Dec 2004 19:40:45 -0000 1.26 +++ pythoncore.vcproj 28 Feb 2005 19:39:44 -0000 1.27 @@ -1294,6 +1294,33 @@ + + + + + + + + + + + From rhettinger at users.sourceforge.net Mon Feb 28 20:39:48 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Feb 28 20:39:53 2005 Subject: [Python-checkins] python/dist/src/PC/VC6 pythoncore.dsp,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/PC/VC6 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14403/PC/VC6 Modified Files: pythoncore.dsp Log Message: SF patch #941881: PEP 309 Implementation (Partial Function Application). Combined efforts of many including Peter Harris, Hye-Shik Chang, Martin v. Löwis, Nick Coghlan, Paul Moore, and Raymond Hettinger. Index: pythoncore.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/VC6/pythoncore.dsp,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- pythoncore.dsp 2 Dec 2004 08:53:14 -0000 1.16 +++ pythoncore.dsp 28 Feb 2005 19:39:44 -0000 1.17 @@ -301,6 +301,10 @@ # End Source File # Begin Source File +SOURCE=..\..\Modules\functionalmodule.c +# End Source File +# Begin Source File + SOURCE=..\..\Python\future.c # End Source File # Begin Source File From rhettinger at users.sourceforge.net Mon Feb 28 20:39:55 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Feb 28 20:39:58 2005 Subject: [Python-checkins] python/dist/src setup.py,1.213,1.214 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14403 Modified Files: setup.py Log Message: SF patch #941881: PEP 309 Implementation (Partial Function Application). Combined efforts of many including Peter Harris, Hye-Shik Chang, Martin v. Löwis, Nick Coghlan, Paul Moore, and Raymond Hettinger. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.213 retrieving revision 1.214 diff -u -d -r1.213 -r1.214 --- setup.py 16 Feb 2005 00:07:16 -0000 1.213 +++ setup.py 28 Feb 2005 19:39:22 -0000 1.214 @@ -355,6 +355,8 @@ exts.append( Extension("_heapq", ["_heapqmodule.c"]) ) # operator.add() and similar goodies exts.append( Extension('operator', ['operator.c']) ) + # functional + exts.append( Extension("functional", ["functionalmodule.c"]) ) # Python C API test module exts.append( Extension('_testcapi', ['_testcapimodule.c']) ) # static Unicode character database From rhettinger at users.sourceforge.net Mon Feb 28 20:39:55 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Feb 28 20:40:00 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libfunctional.tex, NONE, 1.1 lib.tex, 1.237, 1.238 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14403/Doc/lib Modified Files: lib.tex Added Files: libfunctional.tex Log Message: SF patch #941881: PEP 309 Implementation (Partial Function Application). Combined efforts of many including Peter Harris, Hye-Shik Chang, Martin v. Löwis, Nick Coghlan, Paul Moore, and Raymond Hettinger. --- NEW FILE: libfunctional.tex --- \section{\module{functional} --- Higher order functions and operations on callable objects.} \declaremodule{standard}{functional} % standard library, in Python \moduleauthor{Peter Harris}{scav@blueyonder.co.uk} \moduleauthor{Raymond Hettinger}{python@rcn.com} \sectionauthor{Peter Harris}{scav@blueyonder.co.uk} \modulesynopsis{Higher-order functions and operations on callable objects.} The \module{functional} module is for higher-order functions: functions that act on or return other functions. In general, any callable object can be treated as a function for the purposes of this module. The \module{functional} module defines the following function: \begin{funcdesc}{partial}{func\optional{,*args}\optional{, **keywords}} Return a new \class{partial} object which when called will behave like \var{func} called with the positional arguments \var{args} and keyword arguments \var{keywords}. If more arguments are supplied to the call, they are appended to \var{args}. If additional keyword arguments are supplied, they extend and override \var{keywords}. Roughly equivalent to: \begin{verbatim} def partial(func, *args, **keywords): def newfunc(*fargs, **fkeywords): newkeywords = keywords.copy() newkeywords.update(fkeywords) return func(*(args + fargs), **newkeywords) newfunc.func = func newfunc.args = args newfunc.keywords = keywords return newfunc \end{verbatim} The \function{partial} is used for partial function application which ``freezes'' some portion of a function's arguments and/or keywords resulting in an new object with a simplified signature. For example, \function{partial} can be used to create a callable that behaves like the \function{int} function where the \var{base} argument defaults to two: \begin{verbatim} >>> basetwo = partial(int, base=2) >>> basetwo('10010') 18 \end{verbatim} \end{funcdesc} \subsection{\class{partial} Objects \label{partial-objects}} \class{partial} objects are callable objects created by \function{partial()}. They have three read-only attributes: \begin{memberdesc}[callable]{func}{} A callable object or function. Calls to the \class{partial} object will be forwarded to \member{func} with new arguments and keywords. \end{memberdesc} \begin{memberdesc}[tuple]{args}{} The leftmost positional arguments that will be prepended to the positional arguments provided to a \class{partial} object call. \end{memberdesc} \begin{memberdesc}[dict]{keywords}{} The keyword arguments that will be supplied when the \class{partial} object is called. \end{memberdesc} Index: lib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/lib.tex,v retrieving revision 1.237 retrieving revision 1.238 diff -u -d -r1.237 -r1.238 --- lib.tex 23 Jan 2005 09:27:23 -0000 1.237 +++ lib.tex 28 Feb 2005 19:39:23 -0000 1.238 @@ -132,6 +132,7 @@ \input{libarray} \input{libsets} \input{libitertools} +\input{libfunctional} \input{libcfgparser} \input{libfileinput} \input{libcalendar} From rhettinger at users.sourceforge.net Mon Feb 28 20:40:32 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Feb 28 20:40:35 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1246,1.1247 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14403/Misc Modified Files: NEWS Log Message: SF patch #941881: PEP 309 Implementation (Partial Function Application). Combined efforts of many including Peter Harris, Hye-Shik Chang, Martin v. Löwis, Nick Coghlan, Paul Moore, and Raymond Hettinger. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1246 retrieving revision 1.1247 diff -u -d -r1.1246 -r1.1247 --- NEWS 27 Feb 2005 20:33:22 -0000 1.1246 +++ NEWS 28 Feb 2005 19:39:23 -0000 1.1247 @@ -34,6 +34,8 @@ Extension Modules ----------------- +- Added functional.partial(). See PEP309. + - Patch #1093585: raise a ValueError for negative history items in readline. {remove_history,replace_history} From rhettinger at users.sourceforge.net Mon Feb 28 20:53:32 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Feb 28 20:53:35 2005 Subject: [Python-checkins] python/nondist/peps pep-0309.txt, 1.7, 1.8 pep-0000.txt, 1.300, 1.301 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19270 Modified Files: pep-0309.txt pep-0000.txt Log Message: Update PEP 309 and mark as final (checked-in to cvs). Index: pep-0309.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0309.txt,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- pep-0309.txt 27 Aug 2004 13:29:47 -0000 1.7 +++ pep-0309.txt 28 Feb 2005 19:53:29 -0000 1.8 @@ -3,11 +3,11 @@ Version: $Revision$ Last-Modified: $Date$ Author: Peter Harris -Status: Accepted +Status: Final Type: Standards Track Content-Type: text/x-rst Created: 08-Feb-2003 -Python-Version: 2.4 +Python-Version: 2.5 Post-History: 10-Feb-2003, 27-Feb-2003, 22-Feb-2004 @@ -25,6 +25,19 @@ An implementation has been submitted to SourceForge [2]_. +Acceptance +========== + +Patch #941881 was accepted and applied in 2005 for Py2.5. It is +essentially as outlined here, a partial() type constructor binding +leftmost positional arguments and any keywords. The partial object has +three read-only attributes func, args, and keywords. Calls to the partial +object can specify keywords that override those in the object itself. + +There is a separate and continuing discussion of whether to modify the +partial implementation with a __get__ method to more closely emulate +the behavior of an equivalent function. + Motivation ========== Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.300 retrieving revision 1.301 diff -u -d -r1.300 -r1.301 --- pep-0000.txt 12 Feb 2005 22:02:05 -0000 1.300 +++ pep-0000.txt 28 Feb 2005 19:53:29 -0000 1.301 @@ -63,7 +63,6 @@ Accepted PEPs (accepted; may not be implemented yet) - SA 309 Partial Function Application Harris SA 328 Imports: Multi-Line and Absolute/Relative Aahz Open PEPs (under consideration) @@ -168,6 +167,7 @@ SF 293 Codec Error Handling Callbacks Dörwald SF 305 CSV File API Montanaro, et al SF 307 Extensions to the pickle protocol GvR, Peters + SF 309 Partial Function Application Harris SF 311 Simplified GIL Acquisition for Extensions Hammond SF 318 Decorators for Functions and Methods Smith, et al IF 320 Python 2.4 Release Schedule Warsaw, et al @@ -343,7 +343,7 @@ I 306 How to Change Python's Grammar Hudson SF 307 Extensions to the pickle protocol GvR, Peters SR 308 If-then-else expression GvR, Hettinger - SA 309 Partial Function Application Harris + SF 309 Partial Function Application Harris S 310 Reliable Acquisition/Release Pairs Hudson, Moore SF 311 Simplified GIL Acquisition for Extensions Hammond S 312 Simple Implicit Lambda Suzi, Martelli