From rhettinger at users.sourceforge.net Sat Jan 1 01:28:47 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jan 1 01:28:50 2005 Subject: [Python-checkins] python/dist/src/Doc/templates module.tex, 1.22, 1.23 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/templates In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3901/Doc/templates Modified Files: module.tex Log Message: SF Patch #1093896: miscellaneous doc typos Index: module.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/templates/module.tex,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- module.tex 6 Jun 2001 16:02:47 -0000 1.22 +++ module.tex 1 Jan 2005 00:28:44 -0000 1.23 @@ -50,7 +50,7 @@ % Leave at least one blank line after this, to simplify ad-hoc tools % that are sometimes used to massage these files. -\modulesynopsis{This is a one-line descrition, for the chapter header.} +\modulesynopsis{This is a one-line description, for the chapter header.} % ==== 2. ==== @@ -110,7 +110,7 @@ % Exceptions are described using a ``excdesc'' block. This has only % one parameter: the exception name. Exceptions defined as classes in % the source code should be documented using this environment, but -% constructor parameters must be ommitted. +% constructor parameters must be omitted. \begin{excdesc}{error} Exception raised when an operation fails for a Spam specific reason. From rhettinger at users.sourceforge.net Sat Jan 1 01:28:47 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jan 1 01:28:50 2005 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.265,1.266 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3901/Doc/tut Modified Files: tut.tex Log Message: SF Patch #1093896: miscellaneous doc typos Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.265 retrieving revision 1.266 diff -u -d -r1.265 -r1.266 --- tut.tex 4 Dec 2004 10:50:50 -0000 1.265 +++ tut.tex 1 Jan 2005 00:28:44 -0000 1.266 @@ -3553,9 +3553,10 @@ __main__.MyError: 'oops!' \end{verbatim} -In this example, the default \method{__init__} of \class{Exception} has -been overriden. The new behavior simply creates the \var{value} attribute. -This replaces the default behavior of creating the \var{args} attribute. +In this example, the default \method{__init__} of \class{Exception} +has been overridden. The new behavior simply creates the \var{value} +attribute. This replaces the default behavior of creating the +\var{args} attribute. Exception classes can be defined which do anything any other class can do, but are usually kept simple, often only offering a number of @@ -4636,7 +4637,7 @@ >>> import smtplib >>> server = smtplib.SMTP('localhost') ->>> server.sendmail('soothsayer@example.org', 'jceasar@example.org', +>>> server.sendmail('soothsayer@example.org', 'jcaesar@example.org', """To: jcaesar@example.org From: soothsayer@example.org From rhettinger at users.sourceforge.net Sat Jan 1 01:28:49 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jan 1 01:28:52 2005 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew20.tex, 1.52, 1.53 whatsnew21.tex, 1.33, 1.34 whatsnew23.tex, 1.166, 1.167 whatsnew24.tex, 1.126, 1.127 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3901/Doc/whatsnew Modified Files: whatsnew20.tex whatsnew21.tex whatsnew23.tex whatsnew24.tex Log Message: SF Patch #1093896: miscellaneous doc typos Index: whatsnew20.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew20.tex,v retrieving revision 1.52 retrieving revision 1.53 diff -u -d -r1.52 -r1.53 --- whatsnew20.tex 11 Nov 2004 06:14:05 -0000 1.52 +++ whatsnew20.tex 1 Jan 2005 00:28:45 -0000 1.53 @@ -642,7 +642,7 @@ \url{http://starship.python.net/crew/mhammond/ce/} for more information. -Another new platform is Darwin/MacOS X; inital support for it is in +Another new platform is Darwin/MacOS X; initial support for it is in Python 2.0. Dynamic loading works, if you specify ``configure --with-dyld --with-suffix=.x''. Consult the README in the Python source distribution for more instructions. @@ -908,8 +908,8 @@ configuration files, which only really work on Unix and leave Windows and MacOS unsupported. Python users faced wildly differing installation instructions which varied between different extension -packages, which made adminstering a Python installation something of a -chore. +packages, which made administering a Python installation something of +a chore. The SIG for distribution utilities, shepherded by Greg Ward, has created the Distutils, a system to make package installation much Index: whatsnew21.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew21.tex,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- whatsnew21.tex 2 Jun 2004 15:33:59 -0000 1.33 +++ whatsnew21.tex 1 Jan 2005 00:28:46 -0000 1.34 @@ -203,7 +203,7 @@ (The magic methods are named after the corresponding Fortran operators \code{.LT.}. \code{.LE.}, \&c. Numeric programmers are almost -certainly quite familar with these names and will find them easy to +certainly quite familiar with these names and will find them easy to remember.) Each of these magic methods is of the form \code{\var{method}(self, Index: whatsnew23.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew23.tex,v retrieving revision 1.166 retrieving revision 1.167 diff -u -d -r1.166 -r1.167 --- whatsnew23.tex 11 Nov 2004 06:14:05 -0000 1.166 +++ whatsnew23.tex 1 Jan 2005 00:28:46 -0000 1.167 @@ -2223,7 +2223,7 @@ On MacOS, most toolbox modules have been weaklinked to improve backward compatibility. This means that modules will no longer fail -to load if a single routine is missing on the curent OS version. +to load if a single routine is missing on the current OS version. Instead calling the missing routine will raise an exception. (Contributed by Jack Jansen.) Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.126 retrieving revision 1.127 diff -u -d -r1.126 -r1.127 --- whatsnew24.tex 29 Dec 2004 12:34:21 -0000 1.126 +++ whatsnew24.tex 1 Jan 2005 00:28:46 -0000 1.127 @@ -1493,7 +1493,7 @@ In order to store cookies across sessions, two implementations of cookie jars are provided: one that stores cookies in the Netscape format so applications can use the Mozilla or Lynx cookie files, and -one that stores cookies in the same format as the Perl libwww libary. +one that stores cookies in the same format as the Perl libwww library. \module{urllib2} has been changed to interact with \module{cookielib}: \class{HTTPCookieProcessor} manages a cookie jar that is used when From rhettinger at users.sourceforge.net Sat Jan 1 01:29:01 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jan 1 01:29:04 2005 Subject: [Python-checkins] python/dist/src/Doc/api intro.tex, 1.6, 1.7 memory.tex, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3901/Doc/api Modified Files: intro.tex memory.tex Log Message: SF Patch #1093896: miscellaneous doc typos Index: intro.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/intro.tex,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- intro.tex 31 Mar 2004 07:45:46 -0000 1.6 +++ intro.tex 1 Jan 2005 00:28:28 -0000 1.7 @@ -277,7 +277,7 @@ The situation is slightly different for function return values. While passing a reference to most functions does not change your ownership responsibilities for that reference, many functions that -return a referece to an object give you ownership of the reference. +return a reference to an object give you ownership of the reference. The reason is simple: in many cases, the returned object is created on the fly, and the reference you get is the only reference to the object. Therefore, the generic functions that return object Index: memory.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/memory.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- memory.tex 6 Apr 2002 09:14:33 -0000 1.2 +++ memory.tex 1 Jan 2005 00:28:28 -0000 1.3 @@ -134,7 +134,7 @@ In addition, the following macro sets are provided for calling the Python memory allocator directly, without involving the C API functions listed above. However, note that their use does not preserve binary -compatibility accross Python versions and is therefore deprecated in +compatibility across Python versions and is therefore deprecated in extension modules. \cfunction{PyMem_MALLOC()}, \cfunction{PyMem_REALLOC()}, \cfunction{PyMem_FREE()}. From rhettinger at users.sourceforge.net Sat Jan 1 01:29:02 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jan 1 01:29:05 2005 Subject: [Python-checkins] python/dist/src/Doc/dist dist.tex,1.86,1.87 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/dist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3901/Doc/dist Modified Files: dist.tex Log Message: SF Patch #1093896: miscellaneous doc typos Index: dist.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/dist/dist.tex,v retrieving revision 1.86 retrieving revision 1.87 diff -u -d -r1.86 -r1.87 --- dist.tex 25 Aug 2004 14:01:32 -0000 1.86 +++ dist.tex 1 Jan 2005 00:28:29 -0000 1.87 @@ -34,7 +34,7 @@ build/release/install mechanics. \end{abstract} -% The ugly "%begin{latexonly}" pseudo-environment supresses the table +% The ugly "%begin{latexonly}" pseudo-environment suppresses the table % of contents for HTML generation. % %begin{latexonly} @@ -965,7 +965,7 @@ \end{verbatim} This will affect all builds of this module distribution, whether or not -you explcitly specify \command{build\_ext}. If you include +you explicitly specify \command{build\_ext}. If you include \file{setup.cfg} in your source distribution, it will also affect end-user builds---which is probably a bad idea for this option, since always building extensions in-place would break installation of the @@ -2521,7 +2521,7 @@ \var{extra_preargs} and \var{extra_postargs} are implementation- dependent. On platforms that have the notion of a command-line (e.g. \UNIX, DOS/Windows), they are most likely lists of strings: extra -command-line arguments to prepand/append to the compiler command +command-line arguments to prepend/append to the compiler command line. On other platforms, consult the implementation class documentation. In any event, they are intended as an escape hatch for those occasions when the abstract compiler framework doesn't From rhettinger at users.sourceforge.net Sat Jan 1 01:29:03 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jan 1 01:29:05 2005 Subject: [Python-checkins] python/dist/src/Doc/doc doc.tex,1.90,1.91 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3901/Doc/doc Modified Files: doc.tex Log Message: SF Patch #1093896: miscellaneous doc typos Index: doc.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/doc/doc.tex,v retrieving revision 1.90 retrieving revision 1.91 diff -u -d -r1.90 -r1.91 --- doc.tex 13 Nov 2004 04:41:01 -0000 1.90 +++ doc.tex 1 Jan 2005 00:28:30 -0000 1.91 @@ -204,7 +204,7 @@ For ``central processing unit.'' Many style guides say this should be spelled out on the first use (and if you must use it, do so!). For the Python documentation, this abbreviation should - be avoided since there's no reasonable way to predict which occurance + be avoided since there's no reasonable way to predict which occurrence will be the first seen by the reader. It is better to use the word ``processor'' instead. @@ -471,7 +471,7 @@ \LaTeX{} provides a variety of environments even without the additional markup provided by the Python-specific document classes - introducted in the next section. The following environments are + introduced in the next section. The following environments are provided as part of standard \LaTeX{} and are being used in the standard Python documentation; descriptions will be added here as time allows. @@ -651,7 +651,7 @@ \end{envdesc} \begin{envdesc}{excclassdesc}{\p{name}\p{constructor parameters}} - Descibe an exception defined by a class. \var{constructor + Describe an exception defined by a class. \var{constructor parameters} should not include the \var{self} parameter or the parentheses used in the call syntax. To describe an exception class without describing the parameters to its @@ -830,7 +830,7 @@ with release \var{version}. The text given as \var{what to do} should recommend something to use instead. It should be complete sentences. The entire deprecation notice will be - presented as a separate paragraph; it should either preceed or + presented as a separate paragraph; it should either precede or succeed the description of the deprecated feature. \end{macrodesc} @@ -1122,7 +1122,7 @@ \begin{envdesc}{notice}{\op{type}} Label some paragraphs as being worthy of additional attention from - the reader. What sort of attention is warrented can be indicated + the reader. What sort of attention is warranted can be indicated by specifying the \var{type} of the notice. The only values defined for \var{type} are \code{note} and \code{warning}; these are equivalent in intent to the inline markup of the same name. @@ -1660,7 +1660,7 @@ \begin{envdesc}{productionlist}{\op{language}} This environment is used to enclose a group of productions. The two macros are only defined within this environment. If a - document descibes more than one language, the optional parameter + document describes more than one language, the optional parameter \var{language} should be used to distinguish productions between languages. The value of the parameter should be a short name that can be used as part of a filename; colons or other @@ -1731,7 +1731,7 @@ a complete sequence of menu selections, including selecting submenus and choosing a specific operation, or any subsequence of such a sequence. The names of individual selections should be - separated by occurances of \macro{sub}. + separated by occurrences of \macro{sub}. For example, to mark the selection ``\menuselection{Start \sub Programs}'', use this markup: @@ -2080,7 +2080,7 @@ fairly rough. The timeframe for the conversion is not clear since there doesn't - seem to be much time available to work on this, but the appearant + seem to be much time available to work on this, but the apparent benefits are growing more substantial at a moderately rapid pace. From rhettinger at users.sourceforge.net Sat Jan 1 01:29:04 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jan 1 01:29:07 2005 Subject: [Python-checkins] python/dist/src/Doc/ext extending.tex,1.30,1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ext In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3901/Doc/ext Modified Files: extending.tex Log Message: SF Patch #1093896: miscellaneous doc typos Index: extending.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/extending.tex,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- extending.tex 29 Jun 2004 03:48:23 -0000 1.30 +++ extending.tex 1 Jan 2005 00:28:30 -0000 1.31 @@ -23,7 +23,7 @@ of Monty Python fans...) and let's say we want to create a Python interface to the C library function \cfunction{system()}.\footnote{An interface for this function already exists in the standard module -\module{os} --- it was chosen as a simple and straightfoward example.} +\module{os} --- it was chosen as a simple and straightforward example.} This function takes a null-terminated character string as argument and returns an integer. We want this function to be callable from Python as follows: @@ -1002,8 +1002,8 @@ \cfunction{Py_INCREF()}. The object reference returned from a C function that is called from -Python must be an owned reference --- ownership is tranferred from the -function to its caller. +Python must be an owned reference --- ownership is transferred from +the function to its caller. \subsection{Thin Ice @@ -1147,7 +1147,7 @@ linked by the C compiler, global or static objects with constructors cannot be used. This is not a problem if the main program is linked by the \Cpp{} compiler. Functions that will be called by the -Python interpreter (in particular, module initalization functions) +Python interpreter (in particular, module initialization functions) have to be declared using \code{extern "C"}. It is unnecessary to enclose the Python header files in \code{extern "C" \{...\}} --- they use this form already if the symbol From rhettinger at users.sourceforge.net Sat Jan 1 01:29:07 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jan 1 01:29:09 2005 Subject: [Python-checkins] python/dist/src/Doc/inst inst.tex,1.58,1.59 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/inst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3901/Doc/inst Modified Files: inst.tex Log Message: SF Patch #1093896: miscellaneous doc typos Index: inst.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/inst/inst.tex,v retrieving revision 1.58 retrieving revision 1.59 diff -u -d -r1.58 -r1.59 --- inst.tex 10 Aug 2004 21:20:10 -0000 1.58 +++ inst.tex 1 Jan 2005 00:28:32 -0000 1.59 @@ -44,7 +44,7 @@ %\end{abstract} -% The ugly "%begin{latexonly}" pseudo-environment supresses the table +% The ugly "%begin{latexonly}" pseudo-environment suppresses the table % of contents for HTML generation. % %begin{latexonly} From rhettinger at users.sourceforge.net Sat Jan 1 01:29:16 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jan 1 01:29:18 2005 Subject: [Python-checkins] python/dist/src/Doc/mac libframework.tex, 1.11, 1.12 undoc.tex, 1.13, 1.14 using.tex, 1.13, 1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/mac In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3901/Doc/mac Modified Files: libframework.tex undoc.tex using.tex Log Message: SF Patch #1093896: miscellaneous doc typos Index: libframework.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/mac/libframework.tex,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- libframework.tex 22 Sep 2003 15:27:11 -0000 1.11 +++ libframework.tex 1 Jan 2005 00:28:43 -0000 1.12 @@ -151,7 +151,7 @@ are available. This will cause FrameWork window updates and the user interface to remain working during long computations, but will slow the interpreter down and may cause surprising results in non-reentrant code -(such as FrameWork itself). By default \var{async_dispatch} will immedeately +(such as FrameWork itself). By default \var{async_dispatch} will immediately call \var{our_dispatch} but you may override this to handle only certain events asynchronously. Events you do not handle will be passed to Sioux and such. Index: undoc.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/mac/undoc.tex,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- undoc.tex 21 Jul 2004 21:34:45 -0000 1.13 +++ undoc.tex 1 Jan 2005 00:28:43 -0000 1.14 @@ -59,7 +59,7 @@ \platform{Mac} \modulesynopsis{Constant definitions for many Mac OS error codes.} -\module{macerrors} cotains constant definitions for many Mac OS error +\module{macerrors} contains constant definitions for many Mac OS error codes. Index: using.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/mac/using.tex,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- using.tex 24 Dec 2004 02:40:59 -0000 1.13 +++ using.tex 1 Jan 2005 00:28:43 -0000 1.14 @@ -157,9 +157,9 @@ \item When you waved the script icon over the \program{PythonInterpreter}, -the \program{PythonInterpreter} icon did not hilight. 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 +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} From rhettinger at users.sourceforge.net Sat Jan 1 01:29:17 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jan 1 01:29:20 2005 Subject: [Python-checkins] python/dist/src/Doc/ref ref3.tex, 1.121, 1.122 ref5.tex, 1.86, 1.87 ref6.tex, 1.74, 1.75 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3901/Doc/ref Modified Files: ref3.tex ref5.tex ref6.tex Log Message: SF Patch #1093896: miscellaneous doc typos Index: ref3.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref3.tex,v retrieving revision 1.121 retrieving revision 1.122 diff -u -d -r1.121 -r1.122 --- ref3.tex 12 Aug 2004 18:12:43 -0000 1.121 +++ ref3.tex 1 Jan 2005 00:28:43 -0000 1.122 @@ -1328,7 +1328,7 @@ \begin{methoddesc}[object]{__get__}{self, instance, owner} Called to get the attribute of the owner class (class attribute access) -or of an instance of that class (instance attribute acces). +or of an instance of that class (instance attribute access). \var{owner} is always the owner class, while \var{instance} is the instance that the attribute was accessed through, or \code{None} when the attribute is accessed through the \var{owner}. This method should Index: ref5.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref5.tex,v retrieving revision 1.86 retrieving revision 1.87 diff -u -d -r1.86 -r1.87 --- ref5.tex 11 Nov 2004 06:14:05 -0000 1.86 +++ ref5.tex 1 Jan 2005 00:28:43 -0000 1.87 @@ -262,7 +262,7 @@ dictionary to store the corresponding datum. Restrictions on the types of the key values are listed earlier in -section \ref{types}. (To summarize,the key type should be hashable, +section \ref{types}. (To summarize, the key type should be hashable, which excludes all mutable objects.) Clashes between duplicate keys are not detected; the last datum (textually rightmost in the display) stored for a given key value prevails. Index: ref6.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref6.tex,v retrieving revision 1.74 retrieving revision 1.75 diff -u -d -r1.74 -r1.75 --- ref6.tex 12 Dec 2004 16:52:40 -0000 1.74 +++ ref6.tex 1 Jan 2005 00:28:44 -0000 1.75 @@ -497,7 +497,7 @@ \begin{notice} In Python 2.2, the \keyword{yield} statement is only allowed when the \code{generators} feature has been enabled. It will always -be enabled in Python 2.3. This \code{__future__} import statment can +be enabled in Python 2.3. This \code{__future__} import statement can be used to enable the feature: \begin{verbatim} From rhettinger at users.sourceforge.net Sat Jan 1 01:29:19 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jan 1 01:29:23 2005 Subject: [Python-checkins] python/dist/src/Doc/lib compiler.tex, 1.5, 1.6 emailheaders.tex, 1.5, 1.6 libbsddb.tex, 1.19, 1.20 libcd.tex, 1.13, 1.14 libcmath.tex, 1.14, 1.15 libcodecs.tex, 1.34, 1.35 libcodeop.tex, 1.7, 1.8 libcookielib.tex, 1.2, 1.3 libcurses.tex, 1.48, 1.49 libdifflib.tex, 1.22, 1.23 libdoctest.tex, 1.66, 1.67 libexcs.tex, 1.54, 1.55 libfilecmp.tex, 1.9, 1.10 libfuncs.tex, 1.177, 1.178 libgdbm.tex, 1.20, 1.21 libhotshot.tex, 1.5, 1.6 libimaplib.tex, 1.30, 1.31 libimgfile.tex, 1.12, 1.13 libmimetools.tex, 1.24, 1.25 libmultifile.tex, 1.14, 1.15 liboperator.tex, 1.31, 1.32 libossaudiodev.tex, 1.12, 1.13 libplatform.tex, 1.2, 1.3 libpprint.tex, 1.17, 1.18 libpyexpat.tex, 1.24, 1.25 libre.tex, 1.112, 1.113 libresource.tex, 1.18, 1.19 librfc822.tex, 1.45, 1.46 libselect.tex, 1.22, 1.23 libshelve.tex, 1.21, 1.22 libstdtypes.tex, 1.171, 1.172 libtime.tex, 1.70, 1.71 libunittest.tex, 1.19, 1.20 libuserdict.tex, 1.24, 1.25 libuu.tex, 1.12, 1.13 libwarnings.tex, 1.12, 1.13 libxmlrpclib.tex, 1.19, 1.20 libzipfile.tex, 1.16, 1.17 mimelib.tex, 1.8, 1.9 tkinter.tex, 1.27, 1.28 xmldom.tex, 1.25, 1.26 xmldomminidom.tex, 1.10, 1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3901/Doc/lib Modified Files: compiler.tex emailheaders.tex libbsddb.tex libcd.tex libcmath.tex libcodecs.tex libcodeop.tex libcookielib.tex libcurses.tex libdifflib.tex libdoctest.tex libexcs.tex libfilecmp.tex libfuncs.tex libgdbm.tex libhotshot.tex libimaplib.tex libimgfile.tex libmimetools.tex libmultifile.tex liboperator.tex libossaudiodev.tex libplatform.tex libpprint.tex libpyexpat.tex libre.tex libresource.tex librfc822.tex libselect.tex libshelve.tex libstdtypes.tex libtime.tex libunittest.tex libuserdict.tex libuu.tex libwarnings.tex libxmlrpclib.tex libzipfile.tex mimelib.tex tkinter.tex xmldom.tex xmldomminidom.tex Log Message: SF Patch #1093896: miscellaneous doc typos Index: compiler.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/compiler.tex,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- compiler.tex 28 Sep 2004 02:53:50 -0000 1.5 +++ compiler.tex 1 Jan 2005 00:28:34 -0000 1.6 @@ -299,7 +299,7 @@ The visitor pattern is ... The \refmodule{compiler} package uses a variant on the visitor pattern that takes advantage of Python's -introspection features to elminiate the need for much of the visitor's +introspection features to eliminate the need for much of the visitor's infrastructure. The classes being visited do not need to be programmed to accept Index: emailheaders.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/emailheaders.tex,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- emailheaders.tex 28 Sep 2004 02:54:54 -0000 1.5 +++ emailheaders.tex 1 Jan 2005 00:28:34 -0000 1.6 @@ -10,7 +10,7 @@ Of course, as email has been deployed worldwide, it has become internationalized, such that language specific character sets can now be used in email messages. The base standard still requires email -messages to be transfered using only 7-bit \ASCII{} characters, so a +messages to be transferred using only 7-bit \ASCII{} characters, so a slew of RFCs have been written describing how to encode email containing non-\ASCII{} characters into \rfc{2822}-compliant format. These RFCs include \rfc{2045}, \rfc{2046}, \rfc{2047}, and \rfc{2231}. Index: libbsddb.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libbsddb.tex,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- libbsddb.tex 13 Dec 2004 09:57:32 -0000 1.19 +++ libbsddb.tex 1 Jan 2005 00:28:34 -0000 1.20 @@ -16,7 +16,7 @@ Starting with Python 2.3 the \module{bsddb} module requires the Berkeley DB library version 3.2 or later (it is known to work with 3.2 -thru 4.3 at the time of this writing). +through 4.3 at the time of this writing). \begin{seealso} \seeurl{http://pybsddb.sourceforge.net/}{Website with documentation Index: libcd.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcd.tex,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- libcd.tex 16 Jul 2000 19:01:09 -0000 1.13 +++ libcd.tex 1 Jan 2005 00:28:34 -0000 1.14 @@ -50,7 +50,7 @@ methods of the player object are described below. The device is the name of the SCSI device file, e.g. \code{'/dev/scsi/sc0d4l0'}, or \code{None}. If omitted or \code{None}, the hardware inventory is -consulted to locate a CD-ROM drive. The \var{mode}, if not omited, +consulted to locate a CD-ROM drive. The \var{mode}, if not omitted, should be the string \code{'r'}. \end{funcdesc} Index: libcmath.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcmath.tex,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- libcmath.tex 14 Jun 2004 07:40:10 -0000 1.14 +++ libcmath.tex 1 Jan 2005 00:28:34 -0000 1.15 @@ -136,7 +136,7 @@ \begin{seealso} \seetext{Kahan, W: Branch cuts for complex elementary functions; - or, Much ado about nothings's sign bit. In Iserles, A., + or, Much ado about nothing's sign bit. In Iserles, A., and Powell, M. (eds.), \citetitle{The state of the art in numerical analysis}. Clarendon Press (1987) pp165-211.} \end{seealso} Index: libcodecs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcodecs.tex,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- libcodecs.tex 10 Sep 2004 01:16:49 -0000 1.34 +++ libcodecs.tex 1 Jan 2005 00:28:34 -0000 1.35 @@ -977,7 +977,7 @@ \lineiv{unicode_internal} {} {Unicode string} - {Return the internal represenation of the operand} + {Return the internal representation of the operand} \lineiv{uu_codec} {uu} Index: libcodeop.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcodeop.tex,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- libcodeop.tex 17 Jun 2004 13:29:11 -0000 1.7 +++ libcodeop.tex 1 Jan 2005 00:28:34 -0000 1.8 @@ -58,7 +58,7 @@ \end{funcdesc} \begin{classdesc}{Compile}{} -Instances of this class have \method{__call__()} methods indentical in +Instances of this class have \method{__call__()} methods identical in signature to the built-in function \function{compile()}, but with the difference that if the instance compiles program text containing a \module{__future__} statement, the instance 'remembers' and compiles Index: libcookielib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcookielib.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- libcookielib.tex 10 Jul 2004 18:41:28 -0000 1.2 +++ libcookielib.tex 1 Jan 2005 00:28:35 -0000 1.3 @@ -414,7 +414,7 @@ switched off by default. The easiest way to provide your own policy is to override this class -and call its methods in your overriden implementations before adding +and call its methods in your overridden implementations before adding your own additional checks: \begin{verbatim} Index: libcurses.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcurses.tex,v retrieving revision 1.48 retrieving revision 1.49 diff -u -d -r1.48 -r1.49 --- libcurses.tex 19 Oct 2004 19:39:02 -0000 1.48 +++ libcurses.tex 1 Jan 2005 00:28:35 -0000 1.49 @@ -1173,7 +1173,7 @@ \constant{KEY_F2}, \constant{KEY_F3}, \constant{KEY_F4}) available, and the arrow keys mapped to \constant{KEY_UP}, \constant{KEY_DOWN}, \constant{KEY_LEFT} and \constant{KEY_RIGHT} in the obvious way. If -your machine has a PC keybboard, it is safe to expect arrow keys and +your machine has a PC keyboard, it is safe to expect arrow keys and twelve function keys (older PC keyboards may have only ten function keys); also, the following keypad mappings are standard: Index: libdifflib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdifflib.tex,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- libdifflib.tex 5 Nov 2004 16:38:08 -0000 1.22 +++ libdifflib.tex 1 Jan 2005 00:28:35 -0000 1.23 @@ -431,7 +431,7 @@ Each tuple is of the form \code{(\var{tag}, \var{i1}, \var{i2}, \var{j1}, \var{j2})}. The first tuple has \code{\var{i1} == \var{j1} == 0}, and remaining tuples have \var{i1} equal to the - \var{i2} from the preceeding tuple, and, likewise, \var{j1} equal to + \var{i2} from the preceding tuple, and, likewise, \var{j1} equal to the previous \var{j2}. The \var{tag} values are strings, with these meanings: Index: libdoctest.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdoctest.tex,v retrieving revision 1.66 retrieving revision 1.67 diff -u -d -r1.66 -r1.67 --- libdoctest.tex 21 Dec 2004 23:46:34 -0000 1.66 +++ libdoctest.tex 1 Jan 2005 00:28:36 -0000 1.67 @@ -1347,7 +1347,7 @@ \begin{memberdesc}{indent} The example's indentation in the containing string, i.e., the - number of space characters that preceed the example's first + number of space characters that precede the example's first prompt. \end{memberdesc} Index: libexcs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libexcs.tex,v retrieving revision 1.54 retrieving revision 1.55 diff -u -d -r1.54 -r1.55 --- libexcs.tex 25 Aug 2004 02:14:06 -0000 1.54 +++ libexcs.tex 1 Jan 2005 00:28:36 -0000 1.55 @@ -278,7 +278,7 @@ when reading the initial script or standard input (also interactively). - Instances of this class have atttributes \member{filename}, + Instances of this class have attributes \member{filename}, \member{lineno}, \member{offset} and \member{text} for easier access to the details. \function{str()} of the exception instance returns only the message. Index: libfilecmp.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfilecmp.tex,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- libfilecmp.tex 5 Dec 2004 01:58:08 -0000 1.9 +++ libfilecmp.tex 1 Jan 2005 00:28:37 -0000 1.10 @@ -70,12 +70,12 @@ \begin{methoddesc}[dircmp]{report_partial_closure}{} Print a comparison between \var{a} and \var{b} and common immediate -subdirctories. +subdirectories. \end{methoddesc} \begin{methoddesc}[dircmp]{report_full_closure}{} Print a comparison between \var{a} and \var{b} and common -subdirctories (recursively). +subdirectories (recursively). \end{methoddesc} @@ -84,7 +84,7 @@ being compared. Note that via \method{__getattr__()} hooks, all attributes are -computed lazilly, so there is no speed penalty if only those +computed lazily, so there is no speed penalty if only those attributes which are lightweight to compute are used. \begin{memberdesc}[dircmp]{left_list} Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.177 retrieving revision 1.178 diff -u -d -r1.177 -r1.178 --- libfuncs.tex 3 Dec 2004 14:59:09 -0000 1.177 +++ libfuncs.tex 1 Jan 2005 00:28:37 -0000 1.178 @@ -169,7 +169,7 @@ argument is it -- the future statements in effect around the call to compile are ignored. - Future statemants are specified by bits which can be bitwise or-ed + Future statements are specified by bits which can be bitwise or-ed together to specify multiple statements. The bitfield required to specify a given feature can be found as the \member{compiler_flag} attribute on the \class{_Feature} instance in the Index: libgdbm.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libgdbm.tex,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- libgdbm.tex 17 Dec 2000 07:14:13 -0000 1.20 +++ libgdbm.tex 1 Jan 2005 00:28:37 -0000 1.21 @@ -40,7 +40,7 @@ \begin{itemize} \item \code{'f'} --- Open the database in fast mode. Writes to the database - will not be syncronized. + will not be synchronized. \item \code{'s'} --- Synchronized mode. This will cause changes to the database will be immediately written to the file. \item \code{'u'} --- Do not lock database. Index: libhotshot.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libhotshot.tex,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- libhotshot.tex 16 Jan 2004 17:30:16 -0000 1.5 +++ libhotshot.tex 1 Jan 2005 00:28:37 -0000 1.6 @@ -59,7 +59,7 @@ Profile a single call of a callable. Additional positional and keyword arguments may be passed along; the result of the call is returned, and exceptions are -allowed to propogate cleanly, while ensuring that profiling is +allowed to propagate cleanly, while ensuring that profiling is disabled on the way out. \end{methoddesc} Index: libimaplib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libimaplib.tex,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- libimaplib.tex 30 Jul 2004 19:12:38 -0000 1.30 +++ libimaplib.tex 1 Jan 2005 00:28:37 -0000 1.31 @@ -413,7 +413,7 @@ \code{uid search} corresponds to \code{search}. The \code{thread} command first searches the mailbox for messages that match the given searching criteria using the charset argument for the interpretation - of strings in the searching criteria. It thren returns the matching + of strings in the searching criteria. It then returns the matching messages threaded according to the specified threading algorithm. This is an \samp{IMAP4rev1} extension command. \versionadded{2.4} Index: libimgfile.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libimgfile.tex,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- libimgfile.tex 22 Sep 2003 15:00:55 -0000 1.12 +++ libimgfile.tex 1 Jan 2005 00:28:37 -0000 1.13 @@ -40,7 +40,7 @@ simply dropping or duplicating pixels, so the result will be less than perfect, especially for computer-generated images. -Alternatively, you can specify a filter to use to smoothen the image +Alternatively, you can specify a filter to use to smooth the image after scaling. The filter forms supported are \code{'impulse'}, \code{'box'}, \code{'triangle'}, \code{'quadratic'} and \code{'gaussian'}. If a filter is specified \var{blur} is an optional Index: libmimetools.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libmimetools.tex,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- libmimetools.tex 12 May 2003 03:23:51 -0000 1.24 +++ libmimetools.tex 1 Jan 2005 00:28:37 -0000 1.25 @@ -57,7 +57,7 @@ \begin{seealso} - \seemodule{email}{Comprehensive email handling package; supercedes + \seemodule{email}{Comprehensive email handling package; supersedes the \module{mimetools} module.} \seemodule{rfc822}{Provides the base class for \class{mimetools.Message}.} Index: libmultifile.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libmultifile.tex,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- libmultifile.tex 22 Sep 2003 15:00:55 -0000 1.14 +++ libmultifile.tex 1 Jan 2005 00:28:37 -0000 1.15 @@ -35,7 +35,7 @@ own pattern for section-divider and end-marker lines. \begin{seealso} - \seemodule{email}{Comprehensive email handling package; supercedes + \seemodule{email}{Comprehensive email handling package; supersedes the \module{multifile} module.} \end{seealso} Index: liboperator.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liboperator.tex,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- liboperator.tex 17 Dec 2003 20:50:46 -0000 1.31 +++ liboperator.tex 1 Jan 2005 00:28:37 -0000 1.32 @@ -42,7 +42,7 @@ Note that unlike the built-in \function{cmp()}, these functions can return any value, which may or may not be interpretable as a Boolean value. See the \citetitle[../ref/ref.html]{Python Reference Manual} -for more informations about rich comparisons. +for more information about rich comparisons. \versionadded{2.2} \end{funcdesc} Index: libossaudiodev.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libossaudiodev.tex,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- libossaudiodev.tex 5 May 2004 01:36:16 -0000 1.12 +++ libossaudiodev.tex 1 Jan 2005 00:28:37 -0000 1.13 @@ -261,7 +261,7 @@ raises \exception{OSSAudioError} if not. Returns a tuple (\var{format}, \var{nchannels}, \var{samplerate}) indicating the parameter values that were actually set by the device driver (i.e., the same as the return -valus of \method{setfmt()}, \method{channels()}, and \method{speed()}). +values of \method{setfmt()}, \method{channels()}, and \method{speed()}). For example, \begin{verbatim} Index: libplatform.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libplatform.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- libplatform.tex 21 Oct 2003 17:58:55 -0000 1.2 +++ libplatform.tex 1 Jan 2005 00:28:37 -0000 1.3 @@ -17,7 +17,7 @@ \begin{funcdesc}{architecture}{executable=sys.executable, bits='', linkage=''} Queries the given executable (defaults to the Python interpreter - binary) for various architecture informations. + binary) for various architecture information. Returns a tuple \code{(bits, linkage)} which contain information about the bit architecture and the linkage format used for the Index: libpprint.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpprint.tex,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- libpprint.tex 3 Dec 2003 20:26:05 -0000 1.17 +++ libpprint.tex 1 Jan 2005 00:28:37 -0000 1.18 @@ -196,7 +196,7 @@ affecting the presentation) as the keys; if an object needs to be presented which is already represented in \var{context}, the third return value should be true. Recursive calls to the \method{format()} -method should add additionaly entries for containers to this +method should add additional entries for containers to this dictionary. The fourth argument, \var{maxlevels}, gives the requested limit to recursion; this will be \code{0} if there is no requested limit. This argument should be passed unmodified to recursive calls. Index: libpyexpat.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpyexpat.tex,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- libpyexpat.tex 26 Aug 2004 00:37:30 -0000 1.24 +++ libpyexpat.tex 1 Jan 2005 00:28:37 -0000 1.25 @@ -310,7 +310,7 @@ \end{methoddesc} \begin{methoddesc}[xmlparser]{EndDoctypeDeclHandler}{} -Called when Expat is done parsing the document type delaration. +Called when Expat is done parsing the document type declaration. This requires Expat version 1.2 or newer. \end{methoddesc} @@ -379,7 +379,7 @@ of the entity; this will be \code{None} for external entities. The \var{notationName} parameter will be \code{None} for parsed entities, and the name of the notation for unparsed entities. -\var{is_parameter_entity} will be true if the entity is a paremeter +\var{is_parameter_entity} will be true if the entity is a parameter entity or false for general entities (most applications only need to be concerned with general entities). This is only available starting with version 1.95.0 of the Expat Index: libre.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libre.tex,v retrieving revision 1.112 retrieving revision 1.113 diff -u -d -r1.112 -r1.113 --- libre.tex 11 Nov 2004 05:04:55 -0000 1.112 +++ libre.tex 1 Jan 2005 00:28:37 -0000 1.113 @@ -845,9 +845,9 @@ The integer index of the last matched capturing group, or \code{None} if no group was matched at all. For example, the expressions \regexp{(a)b}, \regexp{((a)(b))}, and \regexp{((ab))} will have -\code{lastindex == 1} if applyied to the string \code{'ab'}, +\code{lastindex == 1} if applied to the string \code{'ab'}, while the expression \regexp{(a)(b)} will have \code{lastindex == 2}, -if applyied to the same string. +if applied to the same string. \end{memberdesc} \begin{memberdesc}[MatchObject]{lastgroup} Index: libresource.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libresource.tex,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- libresource.tex 13 Jul 2003 00:46:40 -0000 1.18 +++ libresource.tex 1 Jan 2005 00:28:43 -0000 1.19 @@ -44,7 +44,7 @@ Returns a tuple \code{(\var{soft}, \var{hard})} with the current soft and hard limits of \var{resource}. Raises \exception{ValueError} if an invalid resource is specified, or \exception{error} if the - underyling system call fails unexpectedly. + underlying system call fails unexpectedly. \end{funcdesc} \begin{funcdesc}{setrlimit}{resource, limits} @@ -56,7 +56,7 @@ Raises \exception{ValueError} if an invalid resource is specified, if the new soft limit exceeds the hard limit, or if a process tries to raise its hard limit (unless the process has an effective UID of - super-user). Can also raise \exception{error} if the underyling + super-user). Can also raise \exception{error} if the underlying system call fails. \end{funcdesc} Index: librfc822.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/librfc822.tex,v retrieving revision 1.45 retrieving revision 1.46 diff -u -d -r1.45 -r1.46 --- librfc822.tex 25 Aug 2003 04:28:04 -0000 1.45 +++ librfc822.tex 1 Jan 2005 00:28:43 -0000 1.46 @@ -129,7 +129,7 @@ \begin{seealso} - \seemodule{email}{Comprehensive email handling package; supercedes + \seemodule{email}{Comprehensive email handling package; supersedes the \module{rfc822} module.} \seemodule{mailbox}{Classes to read various mailbox formats produced by end-user mail programs.} Index: libselect.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libselect.tex,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- libselect.tex 10 Sep 2003 19:37:42 -0000 1.22 +++ libselect.tex 1 Jan 2005 00:28:43 -0000 1.23 @@ -61,7 +61,7 @@ \note{File objects on Windows are not acceptable, but sockets are.\index{WinSock} On Windows, the underlying \cfunction{select()} function is provided by the WinSock library, and does not handle file -desciptors that don't originate from WinSock.} +descriptors that don't originate from WinSock.} \end{funcdesc} \subsection{Polling Objects Index: libshelve.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libshelve.tex,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- libshelve.tex 5 Dec 2004 03:58:17 -0000 1.21 +++ libshelve.tex 1 Jan 2005 00:28:43 -0000 1.22 @@ -18,7 +18,7 @@ for the underlying database. As a side-effect, an extension may be added to the filename and more than one file may be created. By default, the underlying database file is opened for reading and writing. The optional -{}\var{flag} pararameter has the same interpretation as the \var{flag} +{}\var{flag} parameter has the same interpretation as the \var{flag} parameter of \function{anydbm.open}. By default, version 0 pickles are used to serialize values. Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.171 retrieving revision 1.172 diff -u -d -r1.171 -r1.172 --- libstdtypes.tex 2 Dec 2004 08:31:41 -0000 1.171 +++ libstdtypes.tex 1 Jan 2005 00:28:43 -0000 1.172 @@ -414,7 +414,7 @@ \code{'xyzzy'}, \code{"frobozz"}. See chapter 2 of the \citetitle[../ref/strings.html]{Python Reference Manual} for more about string literals. Unicode strings are much like strings, but are -specified in the syntax using a preceeding \character{u} character: +specified in the syntax using a preceding \character{u} character: \code{u'abc'}, \code{u"def"}. Lists are constructed with square brackets, separating items with commas: \code{[a, b, c]}. Tuples are constructed by the comma operator (not within square brackets), with @@ -546,7 +546,7 @@ \code{\var{s}+=\var{t}}. When applicable, this optimization makes quadratic run-time much less likely. This optimization is both version and implementation dependent. For performance sensitive code, it is -preferrable to use the \method{str.join()} method which assures consistent +preferable to use the \method{str.join()} method which assures consistent linear concatenation performance across versions and implementations. \versionchanged[Formerly, string concatenation never occurred in-place]{2.4} @@ -932,8 +932,8 @@ \lineiii{i}{Signed integer decimal.}{} \lineiii{o}{Unsigned octal.}{(1)} \lineiii{u}{Unsigned decimal.}{} - \lineiii{x}{Unsigned hexidecimal (lowercase).}{(2)} - \lineiii{X}{Unsigned hexidecimal (uppercase).}{(2)} + \lineiii{x}{Unsigned hexadecimal (lowercase).}{(2)} + \lineiii{X}{Unsigned hexadecimal (uppercase).}{(2)} \lineiii{e}{Floating point exponential format (lowercase).}{} \lineiii{E}{Floating point exponential format (uppercase).}{} \lineiii{f}{Floating point decimal format.}{} @@ -1202,7 +1202,7 @@ A set is greater than another set if and only if the first set is a proper superset of the second set (is a superset, but is not equal). -Instanceas of \class{set} are compared to instances of \class{frozenset} based +Instances of \class{set} are compared to instances of \class{frozenset} based on their members. For example, \samp{set('abc') == frozenset('abc')} returns \code{True}. Index: libtime.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libtime.tex,v retrieving revision 1.70 retrieving revision 1.71 diff -u -d -r1.70 -r1.71 --- libtime.tex 31 Oct 2004 12:19:34 -0000 1.70 +++ libtime.tex 1 Jan 2005 00:28:43 -0000 1.71 @@ -375,14 +375,14 @@ \begin{itemize} \item[std and dst] Three or more alphanumerics giving the timezone abbreviations. - These will be propogated into time.tzname + These will be propagated into time.tzname \item[offset] The offset has the form: \plusminus{} hh[:mm[:ss]]. This indicates the value added the local time to arrive at UTC. If preceded by a '-', the timezone is east of the Prime Meridian; otherwise, it is west. If no offset follows - dst, summmer time is assumed to be one hour ahead of standard time. + dst, summer time is assumed to be one hour ahead of standard time. \item[start[/time],end[/time]] Indicates when to change to and back from DST. The format of the Index: libunittest.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libunittest.tex,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- libunittest.tex 7 Nov 2004 16:02:07 -0000 1.19 +++ libunittest.tex 1 Jan 2005 00:28:43 -0000 1.20 @@ -568,7 +568,7 @@ \begin{methoddesc}[TestCase]{debug}{} Run the test without collecting the result. This allows exceptions - raised by the test to be propogated to the caller, and can be used + raised by the test to be propagated to the caller, and can be used to support running tests under a debugger. \end{methoddesc} Index: libuserdict.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libuserdict.tex,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- libuserdict.tex 25 Aug 2003 04:28:04 -0000 1.24 +++ libuserdict.tex 1 Jan 2005 00:28:43 -0000 1.25 @@ -51,7 +51,7 @@ defining all but \method{__delitem__} will preclude only \method{pop} and \method{popitem} from the full interface. -In addition to the four base methods, progessively more efficiency +In addition to the four base methods, progressively more efficiency comes with defining \method{__contains__()}, \method{__iter__()}, and \method{iteritems()}. Index: libuu.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libuu.tex,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- libuu.tex 10 Oct 2002 18:24:54 -0000 1.12 +++ libuu.tex 1 Jan 2005 00:28:43 -0000 1.13 @@ -43,7 +43,7 @@ \begin{excclassdesc}{Error}{} Subclass of \exception{Exception}, this can be raised by \function{uu.decode()} under various situations, such as described - above, but also including a badly formated header, or truncated + above, but also including a badly formatted header, or truncated input file. \end{excclassdesc} Index: libwarnings.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libwarnings.tex,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- libwarnings.tex 1 Jul 2003 14:37:59 -0000 1.12 +++ libwarnings.tex 1 Jan 2005 00:28:43 -0000 1.13 @@ -39,7 +39,7 @@ \function{resetwarnings()}. The printing of warning messages is done by calling -\function{showwarning()}, which may be overidden; the default +\function{showwarning()}, which may be overridden; the default implementation of this function formats the message by calling \function{formatwarning()}, which is also available for use by custom implementations. Index: libxmlrpclib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libxmlrpclib.tex,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- libxmlrpclib.tex 12 Dec 2004 16:52:40 -0000 1.19 +++ libxmlrpclib.tex 1 Jan 2005 00:28:43 -0000 1.20 @@ -97,7 +97,7 @@ everything an XML-RPC client developer needs to know.} \seetitle[http://xmlrpc-c.sourceforge.net/hacks.php] {XML-RPC-Hacks page}{Extensions for various open-source - libraries to support instrospection and multicall.} + libraries to support introspection and multicall.} \end{seealso} Index: libzipfile.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libzipfile.tex,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- libzipfile.tex 25 Aug 2003 04:28:05 -0000 1.16 +++ libzipfile.tex 1 Jan 2005 00:28:43 -0000 1.17 @@ -36,7 +36,7 @@ \end{classdesc*} \begin{classdesc}{ZipInfo}{\optional{filename\optional{, date_time}}} - Class used the represent infomation about a member of an archive. + Class used to represent information about a member of an archive. Instances of this class are returned by the \method{getinfo()} and \method{infolist()} methods of \class{ZipFile} objects. Most users of the \module{zipfile} module will not need to create these, but Index: mimelib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/mimelib.tex,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- mimelib.tex 3 Oct 2004 03:58:01 -0000 1.8 +++ mimelib.tex 1 Jan 2005 00:28:43 -0000 1.9 @@ -26,7 +26,7 @@ relevant email and MIME related RFCs. \end{abstract} -% The ugly "%begin{latexonly}" pseudo-environment supresses the table +% The ugly "%begin{latexonly}" pseudo-environment suppresses the table % of contents for HTML generation. % %begin{latexonly} @@ -39,7 +39,7 @@ relevant email and MIME related RFCs. This document describes version 3.0 of the \module{email} package, which is -distributed with Python 2.4 and is availble as a standalone distutils-based +distributed with Python 2.4 and is available as a standalone distutils-based package for use with Python 2.3. \module{email} 3.0 is not compatible with Python versions earlier than 2.3. For more information about the \module{email} package, including download links and mailing lists, see Index: tkinter.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/tkinter.tex,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- tkinter.tex 7 Nov 2004 19:36:48 -0000 1.27 +++ tkinter.tex 1 Jan 2005 00:28:43 -0000 1.28 @@ -10,7 +10,7 @@ Python programmers using the \refmodule{Tkinter} module, and its extension, the \refmodule{Tix} module. -The \refmodule{Tkinter} module is a thin object--oriented layer on top of +The \refmodule{Tkinter} module is a thin object-oriented layer on top of Tcl/Tk. To use \refmodule{Tkinter}, you don't need to write Tcl code, but you will need to consult the Tk documentation, and occasionally the Tcl documentation. \refmodule{Tkinter} is a set of wrappers that @@ -97,7 +97,7 @@ \begin{classdesc}{Tk}{screenName=None, baseName=None, className='Tk', useTk=1} The \class{Tk} class is instantiated without arguments. This creates a toplevel widget of Tk which usually is the main window -of an appliation. Each instance has its own associated Tcl interpreter. +of an application. Each instance has its own associated Tcl interpreter. % FIXME: The following keyword arguments are currently recognized: \versionchanged[The \var{useTk} parameter was added]{2.4} \end{classdesc} @@ -461,7 +461,7 @@ fred["fg"] = "red" fred["bg"] = "blue" \end{verbatim} -\item[Use the config() method to update multiple attrs subesequent to +\item[Use the config() method to update multiple attrs subsequent to object creation]: \begin{verbatim} fred.config(fg = "red", bg = "blue") @@ -812,7 +812,7 @@ self.button.bind("", self.turnRed) \end{verbatim} -Notice how the widget field of the event is being accesed in the +Notice how the widget field of the event is being accessed in the \method{turnRed()} callback. This field contains the widget that caught the X event. The following table lists the other event fields you can access, and how they are denoted in Tk, which can be useful @@ -1218,7 +1218,7 @@ widget can be used to display any data that have a hierarchical structure, for example, file system directory trees. The list entries are indented and connected by branch lines according to their places -in the hierachy. +in the hierarchy. \end{classdesc} % Python Demo of: @@ -1243,7 +1243,7 @@ \begin{classdesc}{Tree}{} The \ulink{Tree} {http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixTree.htm} -widget can be used to display hierachical data in a tree form. The +widget can be used to display hierarchical data in a tree form. The user can adjust the view of the tree by opening or closing parts of the tree. \end{classdesc} @@ -1359,7 +1359,7 @@ horizontal lines; each line is composed of a series of items (texts, bitmaps, images or spaces) arranged from left to right. For example, a compound image can be used to display a bitmap and a text string -simutaneously in a Tk \class{Button} widget. +simultaneously in a Tk \class{Button} widget. % Python Demo of: % \ulink{Compound Image In Buttons}{http://tix.sourceforge.net/dist/current/demos/samples/CmpImg.tcl} @@ -1486,7 +1486,7 @@ \end{methoddesc} \begin{methoddesc}{tix_option_get}{name} -Gets the options manitained by the Tix scheme mechanism. +Gets the options maintained by the Tix scheme mechanism. \end{methoddesc} \begin{methoddesc}{tix_resetoptions}{newScheme, newFontSet\optional{, @@ -1547,13 +1547,13 @@ \section{Idle \label{idle}} %\declaremodule{standard}{idle} -%\modulesynopsis{A Python Integrated Developement Environment} +%\modulesynopsis{A Python Integrated Development Environment} \moduleauthor{Guido van Rossum}{guido@Python.org} Idle is the Python IDE built with the \refmodule{Tkinter} GUI toolkit. \index{Idle} \index{Python Editor} -\index{Integrated Developement Environment} +\index{Integrated Development Environment} IDLE has the following features: Index: xmldom.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/xmldom.tex,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- xmldom.tex 7 Nov 2004 19:55:18 -0000 1.25 +++ xmldom.tex 1 Jan 2005 00:28:43 -0000 1.26 @@ -584,7 +584,7 @@ \end{methoddesc} \begin{methoddesc}[Element]{setAttributeNode}{newAttr} -Add a new attibute node to the element, replacing an existing +Add a new attribute node to the element, replacing an existing attribute if necessary if the \member{name} attribute matches. If a replacement occurs, the old attribute node will be returned. If \var{newAttr} is already in use, \exception{InuseAttributeErr} will be @@ -592,7 +592,7 @@ \end{methoddesc} \begin{methoddesc}[Element]{setAttributeNodeNS}{newAttr} -Add a new attibute node to the element, replacing an existing +Add a new attribute node to the element, replacing an existing attribute if necessary if the \member{namespaceURI} and \member{localName} attributes match. If a replacement occurs, the old attribute node will be returned. If \var{newAttr} is already in use, @@ -639,7 +639,7 @@ Return an attribute with a particular index. The order you get the attributes in is arbitrary but will be consistent for the life of a DOM. Each item is an attribute node. Get its value with the -\member{value} attribbute. +\member{value} attribute. \end{methoddesc} There are also experimental methods that give this class more mapping Index: xmldomminidom.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/xmldomminidom.tex,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- xmldomminidom.tex 28 Sep 2004 18:40:42 -0000 1.10 +++ xmldomminidom.tex 1 Jan 2005 00:28:43 -0000 1.11 @@ -110,7 +110,7 @@ \method{unlink()} is a \module{xml.dom.minidom}-specific extension to the DOM API. After calling \method{unlink()} on a node, the node and -its descendents are essentially useless. +its descendants are essentially useless. \begin{seealso} \seetitle[http://www.w3.org/TR/REC-DOM-Level-1/]{Document Object From rhettinger at users.sourceforge.net Sat Jan 1 01:34:57 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jan 1 01:35:00 2005 Subject: [Python-checkins] python/dist/src/Doc/mac libframework.tex, 1.11, 1.11.4.1 undoc.tex, 1.13, 1.13.4.1 using.tex, 1.12.2.1, 1.12.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/mac In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5382/mac Modified Files: Tag: release24-maint libframework.tex undoc.tex using.tex Log Message: SF Patch #1093896: miscellaneous doc typos Index: libframework.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/mac/libframework.tex,v retrieving revision 1.11 retrieving revision 1.11.4.1 diff -u -d -r1.11 -r1.11.4.1 --- libframework.tex 22 Sep 2003 15:27:11 -0000 1.11 +++ libframework.tex 1 Jan 2005 00:34:55 -0000 1.11.4.1 @@ -151,7 +151,7 @@ are available. This will cause FrameWork window updates and the user interface to remain working during long computations, but will slow the interpreter down and may cause surprising results in non-reentrant code -(such as FrameWork itself). By default \var{async_dispatch} will immedeately +(such as FrameWork itself). By default \var{async_dispatch} will immediately call \var{our_dispatch} but you may override this to handle only certain events asynchronously. Events you do not handle will be passed to Sioux and such. Index: undoc.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/mac/undoc.tex,v retrieving revision 1.13 retrieving revision 1.13.4.1 diff -u -d -r1.13 -r1.13.4.1 --- undoc.tex 21 Jul 2004 21:34:45 -0000 1.13 +++ undoc.tex 1 Jan 2005 00:34:55 -0000 1.13.4.1 @@ -59,7 +59,7 @@ \platform{Mac} \modulesynopsis{Constant definitions for many Mac OS error codes.} -\module{macerrors} cotains constant definitions for many Mac OS error +\module{macerrors} contains constant definitions for many Mac OS error codes. Index: using.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/mac/using.tex,v retrieving revision 1.12.2.1 retrieving revision 1.12.2.2 diff -u -d -r1.12.2.1 -r1.12.2.2 --- using.tex 24 Dec 2004 02:41:48 -0000 1.12.2.1 +++ using.tex 1 Jan 2005 00:34:55 -0000 1.12.2.2 @@ -157,9 +157,9 @@ \item When you waved the script icon over the \program{PythonInterpreter}, -the \program{PythonInterpreter} icon did not hilight. 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 +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} From rhettinger at users.sourceforge.net Sat Jan 1 01:34:58 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jan 1 01:35:04 2005 Subject: [Python-checkins] python/dist/src/Doc/templates module.tex, 1.22, 1.22.40.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/templates In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5382/templates Modified Files: Tag: release24-maint module.tex Log Message: SF Patch #1093896: miscellaneous doc typos Index: module.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/templates/module.tex,v retrieving revision 1.22 retrieving revision 1.22.40.1 diff -u -d -r1.22 -r1.22.40.1 --- module.tex 6 Jun 2001 16:02:47 -0000 1.22 +++ module.tex 1 Jan 2005 00:34:56 -0000 1.22.40.1 @@ -50,7 +50,7 @@ % Leave at least one blank line after this, to simplify ad-hoc tools % that are sometimes used to massage these files. -\modulesynopsis{This is a one-line descrition, for the chapter header.} +\modulesynopsis{This is a one-line description, for the chapter header.} % ==== 2. ==== @@ -110,7 +110,7 @@ % Exceptions are described using a ``excdesc'' block. This has only % one parameter: the exception name. Exceptions defined as classes in % the source code should be documented using this environment, but -% constructor parameters must be ommitted. +% constructor parameters must be omitted. \begin{excdesc}{error} Exception raised when an operation fails for a Spam specific reason. From rhettinger at users.sourceforge.net Sat Jan 1 01:34:58 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jan 1 01:35:04 2005 Subject: [Python-checkins] python/dist/src/Doc/ref ref3.tex, 1.121, 1.121.2.1 ref5.tex, 1.86, 1.86.2.1 ref6.tex, 1.73.2.1, 1.73.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5382/ref Modified Files: Tag: release24-maint ref3.tex ref5.tex ref6.tex Log Message: SF Patch #1093896: miscellaneous doc typos Index: ref3.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref3.tex,v retrieving revision 1.121 retrieving revision 1.121.2.1 diff -u -d -r1.121 -r1.121.2.1 --- ref3.tex 12 Aug 2004 18:12:43 -0000 1.121 +++ ref3.tex 1 Jan 2005 00:34:55 -0000 1.121.2.1 @@ -1328,7 +1328,7 @@ \begin{methoddesc}[object]{__get__}{self, instance, owner} Called to get the attribute of the owner class (class attribute access) -or of an instance of that class (instance attribute acces). +or of an instance of that class (instance attribute access). \var{owner} is always the owner class, while \var{instance} is the instance that the attribute was accessed through, or \code{None} when the attribute is accessed through the \var{owner}. This method should Index: ref5.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref5.tex,v retrieving revision 1.86 retrieving revision 1.86.2.1 diff -u -d -r1.86 -r1.86.2.1 --- ref5.tex 11 Nov 2004 06:14:05 -0000 1.86 +++ ref5.tex 1 Jan 2005 00:34:55 -0000 1.86.2.1 @@ -262,7 +262,7 @@ dictionary to store the corresponding datum. Restrictions on the types of the key values are listed earlier in -section \ref{types}. (To summarize,the key type should be hashable, +section \ref{types}. (To summarize, the key type should be hashable, which excludes all mutable objects.) Clashes between duplicate keys are not detected; the last datum (textually rightmost in the display) stored for a given key value prevails. Index: ref6.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref6.tex,v retrieving revision 1.73.2.1 retrieving revision 1.73.2.2 diff -u -d -r1.73.2.1 -r1.73.2.2 --- ref6.tex 12 Dec 2004 16:51:48 -0000 1.73.2.1 +++ ref6.tex 1 Jan 2005 00:34:55 -0000 1.73.2.2 @@ -497,7 +497,7 @@ \begin{notice} In Python 2.2, the \keyword{yield} statement is only allowed when the \code{generators} feature has been enabled. It will always -be enabled in Python 2.3. This \code{__future__} import statment can +be enabled in Python 2.3. This \code{__future__} import statement can be used to enable the feature: \begin{verbatim} From rhettinger at users.sourceforge.net Sat Jan 1 01:34:59 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jan 1 01:35:05 2005 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex, 1.261.2.1, 1.261.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5382/tut Modified Files: Tag: release24-maint tut.tex Log Message: SF Patch #1093896: miscellaneous doc typos Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.261.2.1 retrieving revision 1.261.2.2 diff -u -d -r1.261.2.1 -r1.261.2.2 --- tut.tex 2 Dec 2004 08:57:19 -0000 1.261.2.1 +++ tut.tex 1 Jan 2005 00:34:56 -0000 1.261.2.2 @@ -3553,9 +3553,10 @@ __main__.MyError: 'oops!' \end{verbatim} -In this example, the default \method{__init__} of \class{Exception} has -been overriden. The new behavior simply creates the \var{value} attribute. -This replaces the default behavior of creating the \var{args} attribute. +In this example, the default \method{__init__} of \class{Exception} +has been overridden. The new behavior simply creates the \var{value} +attribute. This replaces the default behavior of creating the +\var{args} attribute. Exception classes can be defined which do anything any other class can do, but are usually kept simple, often only offering a number of @@ -4636,7 +4637,7 @@ >>> import smtplib >>> server = smtplib.SMTP('localhost') ->>> server.sendmail('soothsayer@example.org', 'jceasar@example.org', +>>> server.sendmail('soothsayer@example.org', 'jcaesar@example.org', """To: jcaesar@example.org From: soothsayer@example.org From rhettinger at users.sourceforge.net Sat Jan 1 01:35:00 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jan 1 01:35:05 2005 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew20.tex, 1.52, 1.52.2.1 whatsnew21.tex, 1.33, 1.33.4.1 whatsnew23.tex, 1.166, 1.166.2.1 whatsnew24.tex, 1.118, 1.118.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5382/whatsnew Modified Files: Tag: release24-maint whatsnew20.tex whatsnew21.tex whatsnew23.tex whatsnew24.tex Log Message: SF Patch #1093896: miscellaneous doc typos Index: whatsnew20.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew20.tex,v retrieving revision 1.52 retrieving revision 1.52.2.1 diff -u -d -r1.52 -r1.52.2.1 --- whatsnew20.tex 11 Nov 2004 06:14:05 -0000 1.52 +++ whatsnew20.tex 1 Jan 2005 00:34:56 -0000 1.52.2.1 @@ -642,7 +642,7 @@ \url{http://starship.python.net/crew/mhammond/ce/} for more information. -Another new platform is Darwin/MacOS X; inital support for it is in +Another new platform is Darwin/MacOS X; initial support for it is in Python 2.0. Dynamic loading works, if you specify ``configure --with-dyld --with-suffix=.x''. Consult the README in the Python source distribution for more instructions. @@ -908,8 +908,8 @@ configuration files, which only really work on Unix and leave Windows and MacOS unsupported. Python users faced wildly differing installation instructions which varied between different extension -packages, which made adminstering a Python installation something of a -chore. +packages, which made administering a Python installation something of +a chore. The SIG for distribution utilities, shepherded by Greg Ward, has created the Distutils, a system to make package installation much Index: whatsnew21.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew21.tex,v retrieving revision 1.33 retrieving revision 1.33.4.1 diff -u -d -r1.33 -r1.33.4.1 --- whatsnew21.tex 2 Jun 2004 15:33:59 -0000 1.33 +++ whatsnew21.tex 1 Jan 2005 00:34:56 -0000 1.33.4.1 @@ -203,7 +203,7 @@ (The magic methods are named after the corresponding Fortran operators \code{.LT.}. \code{.LE.}, \&c. Numeric programmers are almost -certainly quite familar with these names and will find them easy to +certainly quite familiar with these names and will find them easy to remember.) Each of these magic methods is of the form \code{\var{method}(self, Index: whatsnew23.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew23.tex,v retrieving revision 1.166 retrieving revision 1.166.2.1 diff -u -d -r1.166 -r1.166.2.1 --- whatsnew23.tex 11 Nov 2004 06:14:05 -0000 1.166 +++ whatsnew23.tex 1 Jan 2005 00:34:56 -0000 1.166.2.1 @@ -2223,7 +2223,7 @@ On MacOS, most toolbox modules have been weaklinked to improve backward compatibility. This means that modules will no longer fail -to load if a single routine is missing on the curent OS version. +to load if a single routine is missing on the current OS version. Instead calling the missing routine will raise an exception. (Contributed by Jack Jansen.) Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.118 retrieving revision 1.118.2.1 diff -u -d -r1.118 -r1.118.2.1 --- whatsnew24.tex 25 Nov 2004 01:15:25 -0000 1.118 +++ whatsnew24.tex 1 Jan 2005 00:34:56 -0000 1.118.2.1 @@ -1489,7 +1489,7 @@ In order to store cookies across sessions, two implementations of cookie jars are provided: one that stores cookies in the Netscape format so applications can use the Mozilla or Lynx cookie files, and -one that stores cookies in the same format as the Perl libwww libary. +one that stores cookies in the same format as the Perl libwww library. \module{urllib2} has been changed to interact with \module{cookielib}: \class{HTTPCookieProcessor} manages a cookie jar that is used when From rhettinger at users.sourceforge.net Sat Jan 1 01:35:00 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jan 1 01:35:06 2005 Subject: [Python-checkins] python/dist/src/Doc/lib compiler.tex, 1.5, 1.5.2.1 emailheaders.tex, 1.5, 1.5.2.1 libbsddb.tex, 1.18.2.1, 1.18.2.2 libcd.tex, 1.13, 1.13.46.1 libcmath.tex, 1.14, 1.14.4.1 libcodecs.tex, 1.34, 1.34.2.1 libcodeop.tex, 1.7, 1.7.4.1 libcookielib.tex, 1.2, 1.2.4.1 libcurses.tex, 1.48, 1.48.2.1 libdifflib.tex, 1.22, 1.22.2.1 libdoctest.tex, 1.65, 1.65.2.1 libexcs.tex, 1.54, 1.54.2.1 libfilecmp.tex, 1.8, 1.8.18.1 libfuncs.tex, 1.175, 1.175.2.1 libgdbm.tex, 1.20, 1.20.44.1 libhotshot.tex, 1.5, 1.5.4.1 libimaplib.tex, 1.30, 1.30.4.1 libimgfile.tex, 1.12, 1.12.4.1 libmimetools.tex, 1.24, 1.24.14.1 libmultifile.tex, 1.14, 1.14.4.1 liboperator.tex, 1.31, 1.31.4.1 libossaudiodev.tex, 1.12, 1.12.4.1 libplatform.tex, 1.2, 1.2.6.1 libpprint.tex, 1.17, 1.17.4.1 libpyexpat.tex, 1.24, 1.24.2.1 libre.tex, 1.112, 1.112.2.1 libresource.tex, 1.18, 1.18.12.1 librfc822.tex, 1.45, 1.45.4.1 libselect.tex, 1.22, 1.22.4.1 libshelve.tex, 1.20, 1.20.16.1 libstdtypes.tex, 1.170.2.1, 1.170.2.2 libtime.tex, 1.70, 1.70.2.1 libunittest.tex, 1.19, 1.19.2.1 libuserdict.tex, 1.24, 1.24.4.1 libuu.tex, 1.12, 1.12.20.1 libwarnings.tex, 1.12, 1.12.12.1 libxmlrpclib.tex, 1.18.2.1, 1.18.2.2 libzipfile.tex, 1.16, 1.16.4.1 mimelib.tex, 1.8, 1.8.2.1 tkinter.tex, 1.27, 1.27.2.1 xmldom.tex, 1.25, 1.25.2.1 xmldomminidom.tex, 1.10, 1.10.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5382/lib Modified Files: Tag: release24-maint compiler.tex emailheaders.tex libbsddb.tex libcd.tex libcmath.tex libcodecs.tex libcodeop.tex libcookielib.tex libcurses.tex libdifflib.tex libdoctest.tex libexcs.tex libfilecmp.tex libfuncs.tex libgdbm.tex libhotshot.tex libimaplib.tex libimgfile.tex libmimetools.tex libmultifile.tex liboperator.tex libossaudiodev.tex libplatform.tex libpprint.tex libpyexpat.tex libre.tex libresource.tex librfc822.tex libselect.tex libshelve.tex libstdtypes.tex libtime.tex libunittest.tex libuserdict.tex libuu.tex libwarnings.tex libxmlrpclib.tex libzipfile.tex mimelib.tex tkinter.tex xmldom.tex xmldomminidom.tex Log Message: SF Patch #1093896: miscellaneous doc typos Index: compiler.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/compiler.tex,v retrieving revision 1.5 retrieving revision 1.5.2.1 diff -u -d -r1.5 -r1.5.2.1 --- compiler.tex 28 Sep 2004 02:53:50 -0000 1.5 +++ compiler.tex 1 Jan 2005 00:34:53 -0000 1.5.2.1 @@ -299,7 +299,7 @@ The visitor pattern is ... The \refmodule{compiler} package uses a variant on the visitor pattern that takes advantage of Python's -introspection features to elminiate the need for much of the visitor's +introspection features to eliminate the need for much of the visitor's infrastructure. The classes being visited do not need to be programmed to accept Index: emailheaders.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/emailheaders.tex,v retrieving revision 1.5 retrieving revision 1.5.2.1 diff -u -d -r1.5 -r1.5.2.1 --- emailheaders.tex 28 Sep 2004 02:54:54 -0000 1.5 +++ emailheaders.tex 1 Jan 2005 00:34:53 -0000 1.5.2.1 @@ -10,7 +10,7 @@ Of course, as email has been deployed worldwide, it has become internationalized, such that language specific character sets can now be used in email messages. The base standard still requires email -messages to be transfered using only 7-bit \ASCII{} characters, so a +messages to be transferred using only 7-bit \ASCII{} characters, so a slew of RFCs have been written describing how to encode email containing non-\ASCII{} characters into \rfc{2822}-compliant format. These RFCs include \rfc{2045}, \rfc{2046}, \rfc{2047}, and \rfc{2231}. Index: libbsddb.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libbsddb.tex,v retrieving revision 1.18.2.1 retrieving revision 1.18.2.2 diff -u -d -r1.18.2.1 -r1.18.2.2 --- libbsddb.tex 19 Dec 2004 22:25:32 -0000 1.18.2.1 +++ libbsddb.tex 1 Jan 2005 00:34:53 -0000 1.18.2.2 @@ -16,7 +16,7 @@ Starting with Python 2.3 the \module{bsddb} module requires the Berkeley DB library version 3.2 or later (it is known to work with 3.2 -thru 4.3 at the time of this writing). +through 4.3 at the time of this writing). \begin{seealso} \seeurl{http://pybsddb.sourceforge.net/}{Website with documentation Index: libcd.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcd.tex,v retrieving revision 1.13 retrieving revision 1.13.46.1 diff -u -d -r1.13 -r1.13.46.1 --- libcd.tex 16 Jul 2000 19:01:09 -0000 1.13 +++ libcd.tex 1 Jan 2005 00:34:53 -0000 1.13.46.1 @@ -50,7 +50,7 @@ methods of the player object are described below. The device is the name of the SCSI device file, e.g. \code{'/dev/scsi/sc0d4l0'}, or \code{None}. If omitted or \code{None}, the hardware inventory is -consulted to locate a CD-ROM drive. The \var{mode}, if not omited, +consulted to locate a CD-ROM drive. The \var{mode}, if not omitted, should be the string \code{'r'}. \end{funcdesc} Index: libcmath.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcmath.tex,v retrieving revision 1.14 retrieving revision 1.14.4.1 diff -u -d -r1.14 -r1.14.4.1 --- libcmath.tex 14 Jun 2004 07:40:10 -0000 1.14 +++ libcmath.tex 1 Jan 2005 00:34:53 -0000 1.14.4.1 @@ -136,7 +136,7 @@ \begin{seealso} \seetext{Kahan, W: Branch cuts for complex elementary functions; - or, Much ado about nothings's sign bit. In Iserles, A., + or, Much ado about nothing's sign bit. In Iserles, A., and Powell, M. (eds.), \citetitle{The state of the art in numerical analysis}. Clarendon Press (1987) pp165-211.} \end{seealso} Index: libcodecs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcodecs.tex,v retrieving revision 1.34 retrieving revision 1.34.2.1 diff -u -d -r1.34 -r1.34.2.1 --- libcodecs.tex 10 Sep 2004 01:16:49 -0000 1.34 +++ libcodecs.tex 1 Jan 2005 00:34:53 -0000 1.34.2.1 @@ -977,7 +977,7 @@ \lineiv{unicode_internal} {} {Unicode string} - {Return the internal represenation of the operand} + {Return the internal representation of the operand} \lineiv{uu_codec} {uu} Index: libcodeop.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcodeop.tex,v retrieving revision 1.7 retrieving revision 1.7.4.1 diff -u -d -r1.7 -r1.7.4.1 --- libcodeop.tex 17 Jun 2004 13:29:11 -0000 1.7 +++ libcodeop.tex 1 Jan 2005 00:34:53 -0000 1.7.4.1 @@ -58,7 +58,7 @@ \end{funcdesc} \begin{classdesc}{Compile}{} -Instances of this class have \method{__call__()} methods indentical in +Instances of this class have \method{__call__()} methods identical in signature to the built-in function \function{compile()}, but with the difference that if the instance compiles program text containing a \module{__future__} statement, the instance 'remembers' and compiles Index: libcookielib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcookielib.tex,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -u -d -r1.2 -r1.2.4.1 --- libcookielib.tex 10 Jul 2004 18:41:28 -0000 1.2 +++ libcookielib.tex 1 Jan 2005 00:34:53 -0000 1.2.4.1 @@ -414,7 +414,7 @@ switched off by default. The easiest way to provide your own policy is to override this class -and call its methods in your overriden implementations before adding +and call its methods in your overridden implementations before adding your own additional checks: \begin{verbatim} Index: libcurses.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcurses.tex,v retrieving revision 1.48 retrieving revision 1.48.2.1 diff -u -d -r1.48 -r1.48.2.1 --- libcurses.tex 19 Oct 2004 19:39:02 -0000 1.48 +++ libcurses.tex 1 Jan 2005 00:34:53 -0000 1.48.2.1 @@ -1173,7 +1173,7 @@ \constant{KEY_F2}, \constant{KEY_F3}, \constant{KEY_F4}) available, and the arrow keys mapped to \constant{KEY_UP}, \constant{KEY_DOWN}, \constant{KEY_LEFT} and \constant{KEY_RIGHT} in the obvious way. If -your machine has a PC keybboard, it is safe to expect arrow keys and +your machine has a PC keyboard, it is safe to expect arrow keys and twelve function keys (older PC keyboards may have only ten function keys); also, the following keypad mappings are standard: Index: libdifflib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdifflib.tex,v retrieving revision 1.22 retrieving revision 1.22.2.1 diff -u -d -r1.22 -r1.22.2.1 --- libdifflib.tex 5 Nov 2004 16:38:08 -0000 1.22 +++ libdifflib.tex 1 Jan 2005 00:34:53 -0000 1.22.2.1 @@ -431,7 +431,7 @@ Each tuple is of the form \code{(\var{tag}, \var{i1}, \var{i2}, \var{j1}, \var{j2})}. The first tuple has \code{\var{i1} == \var{j1} == 0}, and remaining tuples have \var{i1} equal to the - \var{i2} from the preceeding tuple, and, likewise, \var{j1} equal to + \var{i2} from the preceding tuple, and, likewise, \var{j1} equal to the previous \var{j2}. The \var{tag} values are strings, with these meanings: Index: libdoctest.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdoctest.tex,v retrieving revision 1.65 retrieving revision 1.65.2.1 diff -u -d -r1.65 -r1.65.2.1 --- libdoctest.tex 4 Oct 2004 03:34:32 -0000 1.65 +++ libdoctest.tex 1 Jan 2005 00:34:53 -0000 1.65.2.1 @@ -1343,7 +1343,7 @@ \begin{memberdesc}{indent} The example's indentation in the containing string, i.e., the - number of space characters that preceed the example's first + number of space characters that precede the example's first prompt. \end{memberdesc} Index: libexcs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libexcs.tex,v retrieving revision 1.54 retrieving revision 1.54.2.1 diff -u -d -r1.54 -r1.54.2.1 --- libexcs.tex 25 Aug 2004 02:14:06 -0000 1.54 +++ libexcs.tex 1 Jan 2005 00:34:53 -0000 1.54.2.1 @@ -278,7 +278,7 @@ when reading the initial script or standard input (also interactively). - Instances of this class have atttributes \member{filename}, + Instances of this class have attributes \member{filename}, \member{lineno}, \member{offset} and \member{text} for easier access to the details. \function{str()} of the exception instance returns only the message. Index: libfilecmp.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfilecmp.tex,v retrieving revision 1.8 retrieving revision 1.8.18.1 diff -u -d -r1.8 -r1.8.18.1 --- libfilecmp.tex 6 Feb 2003 21:17:17 -0000 1.8 +++ libfilecmp.tex 1 Jan 2005 00:34:53 -0000 1.8.18.1 @@ -71,12 +71,12 @@ \begin{methoddesc}[dircmp]{report_partial_closure}{} Print a comparison between \var{a} and \var{b} and common immediate -subdirctories. +subdirectories. \end{methoddesc} \begin{methoddesc}[dircmp]{report_full_closure}{} Print a comparison between \var{a} and \var{b} and common -subdirctories (recursively). +subdirectories (recursively). \end{methoddesc} @@ -85,7 +85,7 @@ being compared. Note that via \method{__getattr__()} hooks, all attributes are -computed lazilly, so there is no speed penalty if only those +computed lazily, so there is no speed penalty if only those attributes which are lightweight to compute are used. \begin{memberdesc}[dircmp]{left_list} Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.175 retrieving revision 1.175.2.1 diff -u -d -r1.175 -r1.175.2.1 --- libfuncs.tex 30 Sep 2004 00:59:08 -0000 1.175 +++ libfuncs.tex 1 Jan 2005 00:34:53 -0000 1.175.2.1 @@ -169,7 +169,7 @@ argument is it -- the future statements in effect around the call to compile are ignored. - Future statemants are specified by bits which can be bitwise or-ed + Future statements are specified by bits which can be bitwise or-ed together to specify multiple statements. The bitfield required to specify a given feature can be found as the \member{compiler_flag} attribute on the \class{_Feature} instance in the Index: libgdbm.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libgdbm.tex,v retrieving revision 1.20 retrieving revision 1.20.44.1 diff -u -d -r1.20 -r1.20.44.1 --- libgdbm.tex 17 Dec 2000 07:14:13 -0000 1.20 +++ libgdbm.tex 1 Jan 2005 00:34:53 -0000 1.20.44.1 @@ -40,7 +40,7 @@ \begin{itemize} \item \code{'f'} --- Open the database in fast mode. Writes to the database - will not be syncronized. + will not be synchronized. \item \code{'s'} --- Synchronized mode. This will cause changes to the database will be immediately written to the file. \item \code{'u'} --- Do not lock database. Index: libhotshot.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libhotshot.tex,v retrieving revision 1.5 retrieving revision 1.5.4.1 diff -u -d -r1.5 -r1.5.4.1 --- libhotshot.tex 16 Jan 2004 17:30:16 -0000 1.5 +++ libhotshot.tex 1 Jan 2005 00:34:53 -0000 1.5.4.1 @@ -59,7 +59,7 @@ Profile a single call of a callable. Additional positional and keyword arguments may be passed along; the result of the call is returned, and exceptions are -allowed to propogate cleanly, while ensuring that profiling is +allowed to propagate cleanly, while ensuring that profiling is disabled on the way out. \end{methoddesc} Index: libimaplib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libimaplib.tex,v retrieving revision 1.30 retrieving revision 1.30.4.1 diff -u -d -r1.30 -r1.30.4.1 --- libimaplib.tex 30 Jul 2004 19:12:38 -0000 1.30 +++ libimaplib.tex 1 Jan 2005 00:34:53 -0000 1.30.4.1 @@ -413,7 +413,7 @@ \code{uid search} corresponds to \code{search}. The \code{thread} command first searches the mailbox for messages that match the given searching criteria using the charset argument for the interpretation - of strings in the searching criteria. It thren returns the matching + of strings in the searching criteria. It then returns the matching messages threaded according to the specified threading algorithm. This is an \samp{IMAP4rev1} extension command. \versionadded{2.4} Index: libimgfile.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libimgfile.tex,v retrieving revision 1.12 retrieving revision 1.12.4.1 diff -u -d -r1.12 -r1.12.4.1 --- libimgfile.tex 22 Sep 2003 15:00:55 -0000 1.12 +++ libimgfile.tex 1 Jan 2005 00:34:53 -0000 1.12.4.1 @@ -40,7 +40,7 @@ simply dropping or duplicating pixels, so the result will be less than perfect, especially for computer-generated images. -Alternatively, you can specify a filter to use to smoothen the image +Alternatively, you can specify a filter to use to smooth the image after scaling. The filter forms supported are \code{'impulse'}, \code{'box'}, \code{'triangle'}, \code{'quadratic'} and \code{'gaussian'}. If a filter is specified \var{blur} is an optional Index: libmimetools.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libmimetools.tex,v retrieving revision 1.24 retrieving revision 1.24.14.1 diff -u -d -r1.24 -r1.24.14.1 --- libmimetools.tex 12 May 2003 03:23:51 -0000 1.24 +++ libmimetools.tex 1 Jan 2005 00:34:53 -0000 1.24.14.1 @@ -57,7 +57,7 @@ \begin{seealso} - \seemodule{email}{Comprehensive email handling package; supercedes + \seemodule{email}{Comprehensive email handling package; supersedes the \module{mimetools} module.} \seemodule{rfc822}{Provides the base class for \class{mimetools.Message}.} Index: libmultifile.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libmultifile.tex,v retrieving revision 1.14 retrieving revision 1.14.4.1 diff -u -d -r1.14 -r1.14.4.1 --- libmultifile.tex 22 Sep 2003 15:00:55 -0000 1.14 +++ libmultifile.tex 1 Jan 2005 00:34:53 -0000 1.14.4.1 @@ -35,7 +35,7 @@ own pattern for section-divider and end-marker lines. \begin{seealso} - \seemodule{email}{Comprehensive email handling package; supercedes + \seemodule{email}{Comprehensive email handling package; supersedes the \module{multifile} module.} \end{seealso} Index: liboperator.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liboperator.tex,v retrieving revision 1.31 retrieving revision 1.31.4.1 diff -u -d -r1.31 -r1.31.4.1 --- liboperator.tex 17 Dec 2003 20:50:46 -0000 1.31 +++ liboperator.tex 1 Jan 2005 00:34:53 -0000 1.31.4.1 @@ -42,7 +42,7 @@ Note that unlike the built-in \function{cmp()}, these functions can return any value, which may or may not be interpretable as a Boolean value. See the \citetitle[../ref/ref.html]{Python Reference Manual} -for more informations about rich comparisons. +for more information about rich comparisons. \versionadded{2.2} \end{funcdesc} Index: libossaudiodev.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libossaudiodev.tex,v retrieving revision 1.12 retrieving revision 1.12.4.1 diff -u -d -r1.12 -r1.12.4.1 --- libossaudiodev.tex 5 May 2004 01:36:16 -0000 1.12 +++ libossaudiodev.tex 1 Jan 2005 00:34:53 -0000 1.12.4.1 @@ -261,7 +261,7 @@ raises \exception{OSSAudioError} if not. Returns a tuple (\var{format}, \var{nchannels}, \var{samplerate}) indicating the parameter values that were actually set by the device driver (i.e., the same as the return -valus of \method{setfmt()}, \method{channels()}, and \method{speed()}). +values of \method{setfmt()}, \method{channels()}, and \method{speed()}). For example, \begin{verbatim} Index: libplatform.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libplatform.tex,v retrieving revision 1.2 retrieving revision 1.2.6.1 diff -u -d -r1.2 -r1.2.6.1 --- libplatform.tex 21 Oct 2003 17:58:55 -0000 1.2 +++ libplatform.tex 1 Jan 2005 00:34:53 -0000 1.2.6.1 @@ -17,7 +17,7 @@ \begin{funcdesc}{architecture}{executable=sys.executable, bits='', linkage=''} Queries the given executable (defaults to the Python interpreter - binary) for various architecture informations. + binary) for various architecture information. Returns a tuple \code{(bits, linkage)} which contain information about the bit architecture and the linkage format used for the Index: libpprint.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpprint.tex,v retrieving revision 1.17 retrieving revision 1.17.4.1 diff -u -d -r1.17 -r1.17.4.1 --- libpprint.tex 3 Dec 2003 20:26:05 -0000 1.17 +++ libpprint.tex 1 Jan 2005 00:34:53 -0000 1.17.4.1 @@ -196,7 +196,7 @@ affecting the presentation) as the keys; if an object needs to be presented which is already represented in \var{context}, the third return value should be true. Recursive calls to the \method{format()} -method should add additionaly entries for containers to this +method should add additional entries for containers to this dictionary. The fourth argument, \var{maxlevels}, gives the requested limit to recursion; this will be \code{0} if there is no requested limit. This argument should be passed unmodified to recursive calls. Index: libpyexpat.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpyexpat.tex,v retrieving revision 1.24 retrieving revision 1.24.2.1 diff -u -d -r1.24 -r1.24.2.1 --- libpyexpat.tex 26 Aug 2004 00:37:30 -0000 1.24 +++ libpyexpat.tex 1 Jan 2005 00:34:53 -0000 1.24.2.1 @@ -310,7 +310,7 @@ \end{methoddesc} \begin{methoddesc}[xmlparser]{EndDoctypeDeclHandler}{} -Called when Expat is done parsing the document type delaration. +Called when Expat is done parsing the document type declaration. This requires Expat version 1.2 or newer. \end{methoddesc} @@ -379,7 +379,7 @@ of the entity; this will be \code{None} for external entities. The \var{notationName} parameter will be \code{None} for parsed entities, and the name of the notation for unparsed entities. -\var{is_parameter_entity} will be true if the entity is a paremeter +\var{is_parameter_entity} will be true if the entity is a parameter entity or false for general entities (most applications only need to be concerned with general entities). This is only available starting with version 1.95.0 of the Expat Index: libre.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libre.tex,v retrieving revision 1.112 retrieving revision 1.112.2.1 diff -u -d -r1.112 -r1.112.2.1 --- libre.tex 11 Nov 2004 05:04:55 -0000 1.112 +++ libre.tex 1 Jan 2005 00:34:53 -0000 1.112.2.1 @@ -845,9 +845,9 @@ The integer index of the last matched capturing group, or \code{None} if no group was matched at all. For example, the expressions \regexp{(a)b}, \regexp{((a)(b))}, and \regexp{((ab))} will have -\code{lastindex == 1} if applyied to the string \code{'ab'}, +\code{lastindex == 1} if applied to the string \code{'ab'}, while the expression \regexp{(a)(b)} will have \code{lastindex == 2}, -if applyied to the same string. +if applied to the same string. \end{memberdesc} \begin{memberdesc}[MatchObject]{lastgroup} Index: libresource.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libresource.tex,v retrieving revision 1.18 retrieving revision 1.18.12.1 diff -u -d -r1.18 -r1.18.12.1 --- libresource.tex 13 Jul 2003 00:46:40 -0000 1.18 +++ libresource.tex 1 Jan 2005 00:34:53 -0000 1.18.12.1 @@ -44,7 +44,7 @@ Returns a tuple \code{(\var{soft}, \var{hard})} with the current soft and hard limits of \var{resource}. Raises \exception{ValueError} if an invalid resource is specified, or \exception{error} if the - underyling system call fails unexpectedly. + underlying system call fails unexpectedly. \end{funcdesc} \begin{funcdesc}{setrlimit}{resource, limits} @@ -56,7 +56,7 @@ Raises \exception{ValueError} if an invalid resource is specified, if the new soft limit exceeds the hard limit, or if a process tries to raise its hard limit (unless the process has an effective UID of - super-user). Can also raise \exception{error} if the underyling + super-user). Can also raise \exception{error} if the underlying system call fails. \end{funcdesc} Index: librfc822.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/librfc822.tex,v retrieving revision 1.45 retrieving revision 1.45.4.1 diff -u -d -r1.45 -r1.45.4.1 --- librfc822.tex 25 Aug 2003 04:28:04 -0000 1.45 +++ librfc822.tex 1 Jan 2005 00:34:53 -0000 1.45.4.1 @@ -129,7 +129,7 @@ \begin{seealso} - \seemodule{email}{Comprehensive email handling package; supercedes + \seemodule{email}{Comprehensive email handling package; supersedes the \module{rfc822} module.} \seemodule{mailbox}{Classes to read various mailbox formats produced by end-user mail programs.} Index: libselect.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libselect.tex,v retrieving revision 1.22 retrieving revision 1.22.4.1 diff -u -d -r1.22 -r1.22.4.1 --- libselect.tex 10 Sep 2003 19:37:42 -0000 1.22 +++ libselect.tex 1 Jan 2005 00:34:53 -0000 1.22.4.1 @@ -61,7 +61,7 @@ \note{File objects on Windows are not acceptable, but sockets are.\index{WinSock} On Windows, the underlying \cfunction{select()} function is provided by the WinSock library, and does not handle file -desciptors that don't originate from WinSock.} +descriptors that don't originate from WinSock.} \end{funcdesc} \subsection{Polling Objects Index: libshelve.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libshelve.tex,v retrieving revision 1.20 retrieving revision 1.20.16.1 diff -u -d -r1.20 -r1.20.16.1 --- libshelve.tex 19 Apr 2003 20:59:02 -0000 1.20 +++ libshelve.tex 1 Jan 2005 00:34:53 -0000 1.20.16.1 @@ -18,7 +18,7 @@ for the underlying database. As a side-effect, an extension may be added to the filename and more than one file may be created. By default, the underlying database file is opened for reading and writing. The optional -{}\var{flag} pararameter has the same interpretation as the \var{flag} +{}\var{flag} parameter has the same interpretation as the \var{flag} parameter of \function{anydbm.open}. By default, version 0 pickles are used to serialize values. Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.170.2.1 retrieving revision 1.170.2.2 diff -u -d -r1.170.2.1 -r1.170.2.2 --- libstdtypes.tex 2 Dec 2004 08:57:19 -0000 1.170.2.1 +++ libstdtypes.tex 1 Jan 2005 00:34:53 -0000 1.170.2.2 @@ -414,7 +414,7 @@ \code{'xyzzy'}, \code{"frobozz"}. See chapter 2 of the \citetitle[../ref/strings.html]{Python Reference Manual} for more about string literals. Unicode strings are much like strings, but are -specified in the syntax using a preceeding \character{u} character: +specified in the syntax using a preceding \character{u} character: \code{u'abc'}, \code{u"def"}. Lists are constructed with square brackets, separating items with commas: \code{[a, b, c]}. Tuples are constructed by the comma operator (not within square brackets), with @@ -546,7 +546,7 @@ \code{\var{s}+=\var{t}}. When applicable, this optimization makes quadratic run-time much less likely. This optimization is both version and implementation dependent. For performance sensitive code, it is -preferrable to use the \method{str.join()} method which assures consistent +preferable to use the \method{str.join()} method which assures consistent linear concatenation performance across versions and implementations. \versionchanged[Formerly, string concatenation never occurred in-place]{2.4} @@ -932,8 +932,8 @@ \lineiii{i}{Signed integer decimal.}{} \lineiii{o}{Unsigned octal.}{(1)} \lineiii{u}{Unsigned decimal.}{} - \lineiii{x}{Unsigned hexidecimal (lowercase).}{(2)} - \lineiii{X}{Unsigned hexidecimal (uppercase).}{(2)} + \lineiii{x}{Unsigned hexadecimal (lowercase).}{(2)} + \lineiii{X}{Unsigned hexadecimal (uppercase).}{(2)} \lineiii{e}{Floating point exponential format (lowercase).}{} \lineiii{E}{Floating point exponential format (uppercase).}{} \lineiii{f}{Floating point decimal format.}{} @@ -1202,7 +1202,7 @@ A set is greater than another set if and only if the first set is a proper superset of the second set (is a superset, but is not equal). -Instanceas of \class{set} are compared to instances of \class{frozenset} based +Instances of \class{set} are compared to instances of \class{frozenset} based on their members. For example, \samp{set('abc') == frozenset('abc')} returns \code{True}. Index: libtime.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libtime.tex,v retrieving revision 1.70 retrieving revision 1.70.2.1 diff -u -d -r1.70 -r1.70.2.1 --- libtime.tex 31 Oct 2004 12:19:34 -0000 1.70 +++ libtime.tex 1 Jan 2005 00:34:53 -0000 1.70.2.1 @@ -375,14 +375,14 @@ \begin{itemize} \item[std and dst] Three or more alphanumerics giving the timezone abbreviations. - These will be propogated into time.tzname + These will be propagated into time.tzname \item[offset] The offset has the form: \plusminus{} hh[:mm[:ss]]. This indicates the value added the local time to arrive at UTC. If preceded by a '-', the timezone is east of the Prime Meridian; otherwise, it is west. If no offset follows - dst, summmer time is assumed to be one hour ahead of standard time. + dst, summer time is assumed to be one hour ahead of standard time. \item[start[/time],end[/time]] Indicates when to change to and back from DST. The format of the Index: libunittest.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libunittest.tex,v retrieving revision 1.19 retrieving revision 1.19.2.1 diff -u -d -r1.19 -r1.19.2.1 --- libunittest.tex 7 Nov 2004 16:02:07 -0000 1.19 +++ libunittest.tex 1 Jan 2005 00:34:53 -0000 1.19.2.1 @@ -568,7 +568,7 @@ \begin{methoddesc}[TestCase]{debug}{} Run the test without collecting the result. This allows exceptions - raised by the test to be propogated to the caller, and can be used + raised by the test to be propagated to the caller, and can be used to support running tests under a debugger. \end{methoddesc} Index: libuserdict.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libuserdict.tex,v retrieving revision 1.24 retrieving revision 1.24.4.1 diff -u -d -r1.24 -r1.24.4.1 --- libuserdict.tex 25 Aug 2003 04:28:04 -0000 1.24 +++ libuserdict.tex 1 Jan 2005 00:34:53 -0000 1.24.4.1 @@ -51,7 +51,7 @@ defining all but \method{__delitem__} will preclude only \method{pop} and \method{popitem} from the full interface. -In addition to the four base methods, progessively more efficiency +In addition to the four base methods, progressively more efficiency comes with defining \method{__contains__()}, \method{__iter__()}, and \method{iteritems()}. Index: libuu.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libuu.tex,v retrieving revision 1.12 retrieving revision 1.12.20.1 diff -u -d -r1.12 -r1.12.20.1 --- libuu.tex 10 Oct 2002 18:24:54 -0000 1.12 +++ libuu.tex 1 Jan 2005 00:34:53 -0000 1.12.20.1 @@ -43,7 +43,7 @@ \begin{excclassdesc}{Error}{} Subclass of \exception{Exception}, this can be raised by \function{uu.decode()} under various situations, such as described - above, but also including a badly formated header, or truncated + above, but also including a badly formatted header, or truncated input file. \end{excclassdesc} Index: libwarnings.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libwarnings.tex,v retrieving revision 1.12 retrieving revision 1.12.12.1 diff -u -d -r1.12 -r1.12.12.1 --- libwarnings.tex 1 Jul 2003 14:37:59 -0000 1.12 +++ libwarnings.tex 1 Jan 2005 00:34:53 -0000 1.12.12.1 @@ -39,7 +39,7 @@ \function{resetwarnings()}. The printing of warning messages is done by calling -\function{showwarning()}, which may be overidden; the default +\function{showwarning()}, which may be overridden; the default implementation of this function formats the message by calling \function{formatwarning()}, which is also available for use by custom implementations. Index: libxmlrpclib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libxmlrpclib.tex,v retrieving revision 1.18.2.1 retrieving revision 1.18.2.2 diff -u -d -r1.18.2.1 -r1.18.2.2 --- libxmlrpclib.tex 12 Dec 2004 16:51:48 -0000 1.18.2.1 +++ libxmlrpclib.tex 1 Jan 2005 00:34:53 -0000 1.18.2.2 @@ -97,7 +97,7 @@ everything an XML-RPC client developer needs to know.} \seetitle[http://xmlrpc-c.sourceforge.net/hacks.php] {XML-RPC-Hacks page}{Extensions for various open-source - libraries to support instrospection and multicall.} + libraries to support introspection and multicall.} \end{seealso} Index: libzipfile.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libzipfile.tex,v retrieving revision 1.16 retrieving revision 1.16.4.1 diff -u -d -r1.16 -r1.16.4.1 --- libzipfile.tex 25 Aug 2003 04:28:05 -0000 1.16 +++ libzipfile.tex 1 Jan 2005 00:34:53 -0000 1.16.4.1 @@ -36,7 +36,7 @@ \end{classdesc*} \begin{classdesc}{ZipInfo}{\optional{filename\optional{, date_time}}} - Class used the represent infomation about a member of an archive. + Class used to represent information about a member of an archive. Instances of this class are returned by the \method{getinfo()} and \method{infolist()} methods of \class{ZipFile} objects. Most users of the \module{zipfile} module will not need to create these, but Index: mimelib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/mimelib.tex,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -u -d -r1.8 -r1.8.2.1 --- mimelib.tex 3 Oct 2004 03:58:01 -0000 1.8 +++ mimelib.tex 1 Jan 2005 00:34:53 -0000 1.8.2.1 @@ -26,7 +26,7 @@ relevant email and MIME related RFCs. \end{abstract} -% The ugly "%begin{latexonly}" pseudo-environment supresses the table +% The ugly "%begin{latexonly}" pseudo-environment suppresses the table % of contents for HTML generation. % %begin{latexonly} @@ -39,7 +39,7 @@ relevant email and MIME related RFCs. This document describes version 3.0 of the \module{email} package, which is -distributed with Python 2.4 and is availble as a standalone distutils-based +distributed with Python 2.4 and is available as a standalone distutils-based package for use with Python 2.3. \module{email} 3.0 is not compatible with Python versions earlier than 2.3. For more information about the \module{email} package, including download links and mailing lists, see Index: tkinter.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/tkinter.tex,v retrieving revision 1.27 retrieving revision 1.27.2.1 diff -u -d -r1.27 -r1.27.2.1 --- tkinter.tex 7 Nov 2004 19:36:48 -0000 1.27 +++ tkinter.tex 1 Jan 2005 00:34:53 -0000 1.27.2.1 @@ -10,7 +10,7 @@ Python programmers using the \refmodule{Tkinter} module, and its extension, the \refmodule{Tix} module. -The \refmodule{Tkinter} module is a thin object--oriented layer on top of +The \refmodule{Tkinter} module is a thin object-oriented layer on top of Tcl/Tk. To use \refmodule{Tkinter}, you don't need to write Tcl code, but you will need to consult the Tk documentation, and occasionally the Tcl documentation. \refmodule{Tkinter} is a set of wrappers that @@ -97,7 +97,7 @@ \begin{classdesc}{Tk}{screenName=None, baseName=None, className='Tk', useTk=1} The \class{Tk} class is instantiated without arguments. This creates a toplevel widget of Tk which usually is the main window -of an appliation. Each instance has its own associated Tcl interpreter. +of an application. Each instance has its own associated Tcl interpreter. % FIXME: The following keyword arguments are currently recognized: \versionchanged[The \var{useTk} parameter was added]{2.4} \end{classdesc} @@ -461,7 +461,7 @@ fred["fg"] = "red" fred["bg"] = "blue" \end{verbatim} -\item[Use the config() method to update multiple attrs subesequent to +\item[Use the config() method to update multiple attrs subsequent to object creation]: \begin{verbatim} fred.config(fg = "red", bg = "blue") @@ -812,7 +812,7 @@ self.button.bind("", self.turnRed) \end{verbatim} -Notice how the widget field of the event is being accesed in the +Notice how the widget field of the event is being accessed in the \method{turnRed()} callback. This field contains the widget that caught the X event. The following table lists the other event fields you can access, and how they are denoted in Tk, which can be useful @@ -1218,7 +1218,7 @@ widget can be used to display any data that have a hierarchical structure, for example, file system directory trees. The list entries are indented and connected by branch lines according to their places -in the hierachy. +in the hierarchy. \end{classdesc} % Python Demo of: @@ -1243,7 +1243,7 @@ \begin{classdesc}{Tree}{} The \ulink{Tree} {http://tix.sourceforge.net/dist/current/man/html/TixCmd/tixTree.htm} -widget can be used to display hierachical data in a tree form. The +widget can be used to display hierarchical data in a tree form. The user can adjust the view of the tree by opening or closing parts of the tree. \end{classdesc} @@ -1359,7 +1359,7 @@ horizontal lines; each line is composed of a series of items (texts, bitmaps, images or spaces) arranged from left to right. For example, a compound image can be used to display a bitmap and a text string -simutaneously in a Tk \class{Button} widget. +simultaneously in a Tk \class{Button} widget. % Python Demo of: % \ulink{Compound Image In Buttons}{http://tix.sourceforge.net/dist/current/demos/samples/CmpImg.tcl} @@ -1486,7 +1486,7 @@ \end{methoddesc} \begin{methoddesc}{tix_option_get}{name} -Gets the options manitained by the Tix scheme mechanism. +Gets the options maintained by the Tix scheme mechanism. \end{methoddesc} \begin{methoddesc}{tix_resetoptions}{newScheme, newFontSet\optional{, @@ -1547,13 +1547,13 @@ \section{Idle \label{idle}} %\declaremodule{standard}{idle} -%\modulesynopsis{A Python Integrated Developement Environment} +%\modulesynopsis{A Python Integrated Development Environment} \moduleauthor{Guido van Rossum}{guido@Python.org} Idle is the Python IDE built with the \refmodule{Tkinter} GUI toolkit. \index{Idle} \index{Python Editor} -\index{Integrated Developement Environment} +\index{Integrated Development Environment} IDLE has the following features: Index: xmldom.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/xmldom.tex,v retrieving revision 1.25 retrieving revision 1.25.2.1 diff -u -d -r1.25 -r1.25.2.1 --- xmldom.tex 7 Nov 2004 19:55:18 -0000 1.25 +++ xmldom.tex 1 Jan 2005 00:34:53 -0000 1.25.2.1 @@ -584,7 +584,7 @@ \end{methoddesc} \begin{methoddesc}[Element]{setAttributeNode}{newAttr} -Add a new attibute node to the element, replacing an existing +Add a new attribute node to the element, replacing an existing attribute if necessary if the \member{name} attribute matches. If a replacement occurs, the old attribute node will be returned. If \var{newAttr} is already in use, \exception{InuseAttributeErr} will be @@ -592,7 +592,7 @@ \end{methoddesc} \begin{methoddesc}[Element]{setAttributeNodeNS}{newAttr} -Add a new attibute node to the element, replacing an existing +Add a new attribute node to the element, replacing an existing attribute if necessary if the \member{namespaceURI} and \member{localName} attributes match. If a replacement occurs, the old attribute node will be returned. If \var{newAttr} is already in use, @@ -639,7 +639,7 @@ Return an attribute with a particular index. The order you get the attributes in is arbitrary but will be consistent for the life of a DOM. Each item is an attribute node. Get its value with the -\member{value} attribbute. +\member{value} attribute. \end{methoddesc} There are also experimental methods that give this class more mapping Index: xmldomminidom.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/xmldomminidom.tex,v retrieving revision 1.10 retrieving revision 1.10.2.1 diff -u -d -r1.10 -r1.10.2.1 --- xmldomminidom.tex 28 Sep 2004 18:40:42 -0000 1.10 +++ xmldomminidom.tex 1 Jan 2005 00:34:53 -0000 1.10.2.1 @@ -110,7 +110,7 @@ \method{unlink()} is a \module{xml.dom.minidom}-specific extension to the DOM API. After calling \method{unlink()} on a node, the node and -its descendents are essentially useless. +its descendants are essentially useless. \begin{seealso} \seetitle[http://www.w3.org/TR/REC-DOM-Level-1/]{Document Object From rhettinger at users.sourceforge.net Sat Jan 1 01:35:24 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jan 1 01:35:27 2005 Subject: [Python-checkins] python/dist/src/Doc/api intro.tex, 1.6, 1.6.4.1 memory.tex, 1.2, 1.2.22.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5382/api Modified Files: Tag: release24-maint intro.tex memory.tex Log Message: SF Patch #1093896: miscellaneous doc typos Index: intro.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/intro.tex,v retrieving revision 1.6 retrieving revision 1.6.4.1 diff -u -d -r1.6 -r1.6.4.1 --- intro.tex 31 Mar 2004 07:45:46 -0000 1.6 +++ intro.tex 1 Jan 2005 00:34:52 -0000 1.6.4.1 @@ -277,7 +277,7 @@ The situation is slightly different for function return values. While passing a reference to most functions does not change your ownership responsibilities for that reference, many functions that -return a referece to an object give you ownership of the reference. +return a reference to an object give you ownership of the reference. The reason is simple: in many cases, the returned object is created on the fly, and the reference you get is the only reference to the object. Therefore, the generic functions that return object Index: memory.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/memory.tex,v retrieving revision 1.2 retrieving revision 1.2.22.1 diff -u -d -r1.2 -r1.2.22.1 --- memory.tex 6 Apr 2002 09:14:33 -0000 1.2 +++ memory.tex 1 Jan 2005 00:34:52 -0000 1.2.22.1 @@ -134,7 +134,7 @@ In addition, the following macro sets are provided for calling the Python memory allocator directly, without involving the C API functions listed above. However, note that their use does not preserve binary -compatibility accross Python versions and is therefore deprecated in +compatibility across Python versions and is therefore deprecated in extension modules. \cfunction{PyMem_MALLOC()}, \cfunction{PyMem_REALLOC()}, \cfunction{PyMem_FREE()}. From rhettinger at users.sourceforge.net Sat Jan 1 01:35:25 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jan 1 01:35:27 2005 Subject: [Python-checkins] python/dist/src/Doc/dist dist.tex,1.86,1.86.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/dist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5382/dist Modified Files: Tag: release24-maint dist.tex Log Message: SF Patch #1093896: miscellaneous doc typos Index: dist.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/dist/dist.tex,v retrieving revision 1.86 retrieving revision 1.86.2.1 diff -u -d -r1.86 -r1.86.2.1 --- dist.tex 25 Aug 2004 14:01:32 -0000 1.86 +++ dist.tex 1 Jan 2005 00:34:52 -0000 1.86.2.1 @@ -34,7 +34,7 @@ build/release/install mechanics. \end{abstract} -% The ugly "%begin{latexonly}" pseudo-environment supresses the table +% The ugly "%begin{latexonly}" pseudo-environment suppresses the table % of contents for HTML generation. % %begin{latexonly} @@ -965,7 +965,7 @@ \end{verbatim} This will affect all builds of this module distribution, whether or not -you explcitly specify \command{build\_ext}. If you include +you explicitly specify \command{build\_ext}. If you include \file{setup.cfg} in your source distribution, it will also affect end-user builds---which is probably a bad idea for this option, since always building extensions in-place would break installation of the @@ -2521,7 +2521,7 @@ \var{extra_preargs} and \var{extra_postargs} are implementation- dependent. On platforms that have the notion of a command-line (e.g. \UNIX, DOS/Windows), they are most likely lists of strings: extra -command-line arguments to prepand/append to the compiler command +command-line arguments to prepend/append to the compiler command line. On other platforms, consult the implementation class documentation. In any event, they are intended as an escape hatch for those occasions when the abstract compiler framework doesn't From rhettinger at users.sourceforge.net Sat Jan 1 01:35:25 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jan 1 01:35:30 2005 Subject: [Python-checkins] python/dist/src/Doc/doc doc.tex,1.90,1.90.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5382/doc Modified Files: Tag: release24-maint doc.tex Log Message: SF Patch #1093896: miscellaneous doc typos Index: doc.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/doc/doc.tex,v retrieving revision 1.90 retrieving revision 1.90.2.1 diff -u -d -r1.90 -r1.90.2.1 --- doc.tex 13 Nov 2004 04:41:01 -0000 1.90 +++ doc.tex 1 Jan 2005 00:34:52 -0000 1.90.2.1 @@ -204,7 +204,7 @@ For ``central processing unit.'' Many style guides say this should be spelled out on the first use (and if you must use it, do so!). For the Python documentation, this abbreviation should - be avoided since there's no reasonable way to predict which occurance + be avoided since there's no reasonable way to predict which occurrence will be the first seen by the reader. It is better to use the word ``processor'' instead. @@ -471,7 +471,7 @@ \LaTeX{} provides a variety of environments even without the additional markup provided by the Python-specific document classes - introducted in the next section. The following environments are + introduced in the next section. The following environments are provided as part of standard \LaTeX{} and are being used in the standard Python documentation; descriptions will be added here as time allows. @@ -651,7 +651,7 @@ \end{envdesc} \begin{envdesc}{excclassdesc}{\p{name}\p{constructor parameters}} - Descibe an exception defined by a class. \var{constructor + Describe an exception defined by a class. \var{constructor parameters} should not include the \var{self} parameter or the parentheses used in the call syntax. To describe an exception class without describing the parameters to its @@ -830,7 +830,7 @@ with release \var{version}. The text given as \var{what to do} should recommend something to use instead. It should be complete sentences. The entire deprecation notice will be - presented as a separate paragraph; it should either preceed or + presented as a separate paragraph; it should either precede or succeed the description of the deprecated feature. \end{macrodesc} @@ -1122,7 +1122,7 @@ \begin{envdesc}{notice}{\op{type}} Label some paragraphs as being worthy of additional attention from - the reader. What sort of attention is warrented can be indicated + the reader. What sort of attention is warranted can be indicated by specifying the \var{type} of the notice. The only values defined for \var{type} are \code{note} and \code{warning}; these are equivalent in intent to the inline markup of the same name. @@ -1660,7 +1660,7 @@ \begin{envdesc}{productionlist}{\op{language}} This environment is used to enclose a group of productions. The two macros are only defined within this environment. If a - document descibes more than one language, the optional parameter + document describes more than one language, the optional parameter \var{language} should be used to distinguish productions between languages. The value of the parameter should be a short name that can be used as part of a filename; colons or other @@ -1731,7 +1731,7 @@ a complete sequence of menu selections, including selecting submenus and choosing a specific operation, or any subsequence of such a sequence. The names of individual selections should be - separated by occurances of \macro{sub}. + separated by occurrences of \macro{sub}. For example, to mark the selection ``\menuselection{Start \sub Programs}'', use this markup: @@ -2080,7 +2080,7 @@ fairly rough. The timeframe for the conversion is not clear since there doesn't - seem to be much time available to work on this, but the appearant + seem to be much time available to work on this, but the apparent benefits are growing more substantial at a moderately rapid pace. From rhettinger at users.sourceforge.net Sat Jan 1 01:35:26 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jan 1 01:35:31 2005 Subject: [Python-checkins] python/dist/src/Doc/ext extending.tex, 1.30, 1.30.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ext In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5382/ext Modified Files: Tag: release24-maint extending.tex Log Message: SF Patch #1093896: miscellaneous doc typos Index: extending.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/extending.tex,v retrieving revision 1.30 retrieving revision 1.30.4.1 diff -u -d -r1.30 -r1.30.4.1 --- extending.tex 29 Jun 2004 03:48:23 -0000 1.30 +++ extending.tex 1 Jan 2005 00:34:52 -0000 1.30.4.1 @@ -23,7 +23,7 @@ of Monty Python fans...) and let's say we want to create a Python interface to the C library function \cfunction{system()}.\footnote{An interface for this function already exists in the standard module -\module{os} --- it was chosen as a simple and straightfoward example.} +\module{os} --- it was chosen as a simple and straightforward example.} This function takes a null-terminated character string as argument and returns an integer. We want this function to be callable from Python as follows: @@ -1002,8 +1002,8 @@ \cfunction{Py_INCREF()}. The object reference returned from a C function that is called from -Python must be an owned reference --- ownership is tranferred from the -function to its caller. +Python must be an owned reference --- ownership is transferred from +the function to its caller. \subsection{Thin Ice @@ -1147,7 +1147,7 @@ linked by the C compiler, global or static objects with constructors cannot be used. This is not a problem if the main program is linked by the \Cpp{} compiler. Functions that will be called by the -Python interpreter (in particular, module initalization functions) +Python interpreter (in particular, module initialization functions) have to be declared using \code{extern "C"}. It is unnecessary to enclose the Python header files in \code{extern "C" \{...\}} --- they use this form already if the symbol From rhettinger at users.sourceforge.net Sat Jan 1 01:35:26 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jan 1 01:35:31 2005 Subject: [Python-checkins] python/dist/src/Doc/inst inst.tex,1.58,1.58.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/inst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5382/inst Modified Files: Tag: release24-maint inst.tex Log Message: SF Patch #1093896: miscellaneous doc typos Index: inst.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/inst/inst.tex,v retrieving revision 1.58 retrieving revision 1.58.2.1 diff -u -d -r1.58 -r1.58.2.1 --- inst.tex 10 Aug 2004 21:20:10 -0000 1.58 +++ inst.tex 1 Jan 2005 00:34:53 -0000 1.58.2.1 @@ -44,7 +44,7 @@ %\end{abstract} -% The ugly "%begin{latexonly}" pseudo-environment supresses the table +% The ugly "%begin{latexonly}" pseudo-environment suppresses the table % of contents for HTML generation. % %begin{latexonly} From rhettinger at users.sourceforge.net Sat Jan 1 07:10:29 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jan 1 07:10:33 2005 Subject: [Python-checkins] python/dist/src/Lib locale.py,1.30,1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25399 Modified Files: locale.py Log Message: SF patch #1051395: locale.getdefaultlocale does not return tuple in some OS (Contributed by Jiwon Seo.) Index: locale.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/locale.py,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- locale.py 13 Dec 2004 19:56:01 -0000 1.30 +++ locale.py 1 Jan 2005 06:10:26 -0000 1.31 @@ -285,7 +285,7 @@ return code, 'iso-8859-15' if '.' in code: - return code.split('.')[:2] + return tuple(code.split('.')[:2]) elif code == 'C': return None, None raise ValueError, 'unknown locale: %s' % localename From rhettinger at users.sourceforge.net Sat Jan 1 07:12:29 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jan 1 07:12:32 2005 Subject: [Python-checkins] python/dist/src/Lib locale.py,1.28,1.28.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26130 Modified Files: Tag: release24-maint locale.py Log Message: SF patch #1051395: locale.getdefaultlocale does not return tuple in some OS (Contributed by Jiwon Seo.) Index: locale.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/locale.py,v retrieving revision 1.28 retrieving revision 1.28.4.1 diff -u -d -r1.28 -r1.28.4.1 --- locale.py 26 Jul 2004 12:45:18 -0000 1.28 +++ locale.py 1 Jan 2005 06:12:26 -0000 1.28.4.1 @@ -272,7 +272,7 @@ return code, 'iso-8859-15' if '.' in code: - return code.split('.')[:2] + return tuple(code.split('.')[:2]) elif code == 'C': return None, None raise ValueError, 'unknown locale: %s' % localename From rhettinger at users.sourceforge.net Sat Jan 1 08:51:08 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jan 1 08:51:11 2005 Subject: [Python-checkins] python/dist/src/Lib pydoc.py,1.100,1.101 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8359 Modified Files: pydoc.py Log Message: SF patch #1094007: Remove witty comment in pydoc.py (Removed at Ping's request.) Index: pydoc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pydoc.py,v retrieving revision 1.100 retrieving revision 1.101 diff -u -d -r1.100 -r1.101 --- pydoc.py 14 Nov 2004 10:21:04 -0000 1.100 +++ pydoc.py 1 Jan 2005 07:51:01 -0000 1.101 @@ -41,8 +41,7 @@ Tommy Burnette, the original creator of manpy. Paul Prescod, for all his work on onlinehelp. Richard Chamberlain, for the first implementation of textdoc. - -Mynd you, møøse bites Kan be pretty nasti...""" +""" # Known bugs that can't be fixed here: # - imp.load_module() cannot be prevented from clobbering existing From rhettinger at users.sourceforge.net Sat Jan 1 08:52:44 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Jan 1 08:52:47 2005 Subject: [Python-checkins] python/dist/src/Lib pydoc.py,1.100,1.100.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8670 Modified Files: Tag: release24-maint pydoc.py Log Message: SF patch #1094007: Remove witty comment in pydoc.py (Removed at Ping's request.) Index: pydoc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pydoc.py,v retrieving revision 1.100 retrieving revision 1.100.2.1 diff -u -d -r1.100 -r1.100.2.1 --- pydoc.py 14 Nov 2004 10:21:04 -0000 1.100 +++ pydoc.py 1 Jan 2005 07:52:40 -0000 1.100.2.1 @@ -41,8 +41,7 @@ Tommy Burnette, the original creator of manpy. Paul Prescod, for all his work on onlinehelp. Richard Chamberlain, for the first implementation of textdoc. - -Mynd you, møøse bites Kan be pretty nasti...""" +""" # Known bugs that can't be fixed here: # - imp.load_module() cannot be prevented from clobbering existing From astrand at users.sourceforge.net Sat Jan 1 10:32:19 2005 From: astrand at users.sourceforge.net (astrand@users.sourceforge.net) Date: Sat Jan 1 10:32:23 2005 Subject: [Python-checkins] python/dist/src/Lib subprocess.py, 1.8.2.2, 1.8.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23470 Modified Files: Tag: release24-maint subprocess.py Log Message: On UNIX, when the execution of the child fails, we must waitpid() to prevent leaving zombies. Index: subprocess.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/subprocess.py,v retrieving revision 1.8.2.2 retrieving revision 1.8.2.3 diff -u -d -r1.8.2.2 -r1.8.2.3 --- subprocess.py 5 Dec 2004 20:04:56 -0000 1.8.2.2 +++ subprocess.py 1 Jan 2005 09:32:16 -0000 1.8.2.3 @@ -985,6 +985,7 @@ data = os.read(errpipe_read, 1048576) # Exceptions limited to 1 MB os.close(errpipe_read) if data != "": + os.waitpid(self.pid, 0) child_exception = pickle.loads(data) raise child_exception From astrand at users.sourceforge.net Sat Jan 1 10:36:37 2005 From: astrand at users.sourceforge.net (astrand@users.sourceforge.net) Date: Sat Jan 1 10:36:40 2005 Subject: [Python-checkins] python/dist/src/Lib subprocess.py,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24099/d Modified Files: subprocess.py Log Message: New subprocess utility function: check_call. Closes #1071764. Index: subprocess.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/subprocess.py,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- subprocess.py 5 Dec 2004 20:15:36 -0000 1.11 +++ subprocess.py 1 Jan 2005 09:36:34 -0000 1.12 @@ -133,6 +133,15 @@ retcode = call(["ls", "-l"]) +check_call(*popenargs, **kwargs): + Run command with arguments. Wait for command to complete. If the + exit code was zero then return, otherwise raise + CalledProcessError. The CalledProcessError object will have the + return code in the errno attribute. + + The arguments are the same as for the Popen constructor. Example: + + check_call(["ls", "-l"]) Exceptions ---------- @@ -148,6 +157,9 @@ A ValueError will be raised if Popen is called with invalid arguments. +check_call() will raise CalledProcessError, which is a subclass of +OSError, if the called process returns a non-zero return code. + Security -------- @@ -363,6 +375,13 @@ import types import traceback +# Exception classes used by this module. +class CalledProcessError(OSError): + """This exception is raised when a process run by check_call() returns + a non-zero exit status. The exit status will be stored in the + errno attribute. This exception is a subclass of + OSError.""" + if mswindows: import threading import msvcrt @@ -393,7 +412,7 @@ import fcntl import pickle -__all__ = ["Popen", "PIPE", "STDOUT", "call"] +__all__ = ["Popen", "PIPE", "STDOUT", "call", "check_call", "CalledProcessError"] try: MAXFD = os.sysconf("SC_OPEN_MAX") @@ -428,6 +447,25 @@ return Popen(*popenargs, **kwargs).wait() +def check_call(*popenargs, **kwargs): + """Run command with arguments. Wait for command to complete. If + the exit code was zero then return, otherwise raise + CalledProcessError. The CalledProcessError object will have the + return code in the errno attribute. + + The arguments are the same as for the Popen constructor. Example: + + check_call(["ls", "-l"]) + """ + retcode = call(*popenargs, **kwargs) + cmd = kwargs.get("args") + if cmd is None: + cmd = popenargs[0] + if retcode: + raise CalledProcessError(retcode, "Command %s returned non-zero exit status" % cmd) + return retcode + + def list2cmdline(seq): """ Translate a sequence of arguments into a command line From astrand at users.sourceforge.net Sat Jan 1 10:36:38 2005 From: astrand at users.sourceforge.net (astrand@users.sourceforge.net) Date: Sat Jan 1 10:36:42 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libsubprocess.tex, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24099/Doc/lib Modified Files: libsubprocess.tex Log Message: New subprocess utility function: check_call. Closes #1071764. Index: libsubprocess.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsubprocess.tex,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- libsubprocess.tex 5 Dec 2004 20:15:36 -0000 1.4 +++ libsubprocess.tex 1 Jan 2005 09:36:35 -0000 1.5 @@ -120,7 +120,7 @@ \subsubsection{Convenience Functions} -This module also defines one shortcut function: +This module also defines two shortcut functions: \begin{funcdesc}{call}{*popenargs, **kwargs} Run command with arguments. Wait for command to complete, then @@ -133,6 +133,18 @@ \end{verbatim} \end{funcdesc} +\begin{funcdesc}{check_call}{*popenargs, **kwargs} +Run command with arguments. Wait for command to complete. If the exit +code was zero then return, otherwise raise CalledProcessError. The +CalledProcessError object will have the return code in the +\member{errno} attribute. + +The arguments are the same as for the Popen constructor. Example: + +\begin{verbatim} + check_call(["ls", "-l"]) +\end{verbatim} +\end{funcdesc} \subsubsection{Exceptions} @@ -149,6 +161,10 @@ A \exception{ValueError} will be raised if \class{Popen} is called with invalid arguments. +check_call() will raise \exception{CalledProcessError}, which is a +subclass of \exception{OSError}, if the called process returns a +non-zero return code. + \subsubsection{Security} From astrand at users.sourceforge.net Sat Jan 1 10:36:39 2005 From: astrand at users.sourceforge.net (astrand@users.sourceforge.net) Date: Sat Jan 1 10:36:43 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_subprocess.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-serv24099/d/test Modified Files: test_subprocess.py Log Message: New subprocess utility function: check_call. Closes #1071764. Index: test_subprocess.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_subprocess.py,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- test_subprocess.py 30 Nov 2004 21:04:45 -0000 1.16 +++ test_subprocess.py 1 Jan 2005 09:36:35 -0000 1.17 @@ -44,6 +44,22 @@ "import sys; sys.exit(47)"]) self.assertEqual(rc, 47) + def test_check_call_zero(self): + # check_call() function with zero return code + rc = subprocess.check_call([sys.executable, "-c", + "import sys; sys.exit(0)"]) + self.assertEqual(rc, 0) + + def test_check_call_nonzero(self): + # check_call() function with non-zero return code + try: + subprocess.check_call([sys.executable, "-c", + "import sys; sys.exit(47)"]) + except subprocess.CalledProcessError, e: + self.assertEqual(e.errno, 47) + else: + self.fail("Expected CalledProcessError") + def test_call_kwargs(self): # call() function with keyword args newenv = os.environ.copy() From astrand at users.sourceforge.net Sat Jan 1 10:38:59 2005 From: astrand at users.sourceforge.net (astrand@users.sourceforge.net) Date: Sat Jan 1 10:39:03 2005 Subject: [Python-checkins] python/dist/src/Lib subprocess.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24402 Modified Files: subprocess.py Log Message: On UNIX, when the execution of the child fails, we must waitpid() to prevent leaving zombies. Index: subprocess.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/subprocess.py,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- subprocess.py 1 Jan 2005 09:36:34 -0000 1.12 +++ subprocess.py 1 Jan 2005 09:38:57 -0000 1.13 @@ -1023,6 +1023,7 @@ data = os.read(errpipe_read, 1048576) # Exceptions limited to 1 MB os.close(errpipe_read) if data != "": + os.waitpid(self.pid, 0) child_exception = pickle.loads(data) raise child_exception From jackjansen at users.sourceforge.net Sat Jan 1 23:33:39 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Sat Jan 1 23:33:42 2005 Subject: [Python-checkins] python/dist/src/Mac/OSX fixapplepython23.py, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14408 Modified Files: fixapplepython23.py Log Message: Create the wrapper scripts for gcc/g++ too. Index: fixapplepython23.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/fixapplepython23.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- fixapplepython23.py 28 Dec 2004 21:30:35 -0000 1.2 +++ fixapplepython23.py 1 Jan 2005 22:33:36 -0000 1.3 @@ -16,10 +16,26 @@ import gestalt MAKEFILE='/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/Makefile' -OLD_LDSHARED='LDSHARED=\t$(CC) $(LDFLAGS) -bundle -framework $(PYTHONFRAMEWORK)\n' -OLD_BLDSHARED='B' + OLD_LDSHARED -NEW_LDSHARED='LDSHARED=\tenv MACOSX_DEPLOYMENT_TARGET=10.3 $(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup\n' -NEW_BLDSHARED='B' + NEW_LDSHARED +CHANGES=(( + 'LDSHARED=\t$(CC) $(LDFLAGS) -bundle -framework $(PYTHONFRAMEWORK)\n', + 'LDSHARED=\t$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup\n' + ),( + 'BLDSHARED=\t$(CC) $(LDFLAGS) -bundle -framework $(PYTHONFRAMEWORK)\n', + 'BLDSHARED=\t$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup\n' + ),( + 'CC=\t\tgcc\n', + 'CC=\t\t/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/PantherPythonFix/run-gcc\n' + ),( + 'CXX=\t\tc++\n', + 'CXX=\t\t/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/PantherPythonFix/run-g++\n' +)) + +GCC_SCRIPT='/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/PantherPythonFix/run-gcc' +GXX_SCRIPT='/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/PantherPythonFix/run-g++' +SCRIPT="""#!/bin/sh +export MACOSX_DEPLOYMENT_TARGET=10.3 +exec %s "${@}" +""" def findline(lines, start): """return line starting with given string or -1""" @@ -33,28 +49,19 @@ fixed = False lines = open(makefile).readlines() - i = findline(lines, 'LDSHARED=') - if i < 0: - print 'fixapplepython23: Python installation not fixed (appears broken, no LDSHARED)' - return 2 - if lines[i] == OLD_LDSHARED: - lines[i] = NEW_LDSHARED - fixed = True - elif lines[i] != NEW_LDSHARED: - print 'fixapplepython23: Python installation not fixed (appears modified, unexpected LDSHARED)' - return 2 - - i = findline(lines, 'BLDSHARED=') - if i < 0: - print 'fixapplepython23: Python installation not fixed (appears broken, no BLDSHARED)' - return 2 - if lines[i] == OLD_BLDSHARED: - lines[i] = NEW_BLDSHARED + for old, new in CHANGES: + i = findline(lines, new) + if i >= 0: + # Already fixed + continue + i = findline(lines, old) + if i < 0: + print 'fixapplepython23: Python installation not fixed (appears broken)' + print 'fixapplepython23: missing line:', old + return 2 + lines[i] = new fixed = True - elif lines[i] != NEW_BLDSHARED: - print 'fixapplepython23: Python installation not fixed (appears modified, unexpected BLDSHARED)' - return 2 - + if fixed: if do_apply: print 'fixapplepython23: Fix to Apple-installed Python 2.3 applied' @@ -68,6 +75,17 @@ print 'fixapplepython23: No fix needed, appears to have been applied before' return 0 +def makescript(filename, compiler): + """Create a wrapper script for a compiler""" + dirname = os.path.split(filename)[0] + if not os.access(dirname, os.X_OK): + os.mkdir(dirname, 0755) + fp = open(filename, 'w') + fp.write(SCRIPT % compiler) + fp.close() + os.chmod(filename, 0755) + print 'fixapplepython23: Created', filename + def main(): # Check for -n option if len(sys.argv) > 1 and sys.argv[1] == '-n': @@ -86,7 +104,13 @@ if do_apply and not os.access(MAKEFILE, os.W_OK): print 'fixapplepython23: No write permission, please run with "sudo"' sys.exit(2) - # And finally fix it + # Create the shell scripts + if do_apply: + if not os.access(GCC_SCRIPT, os.X_OK): + makescript(GCC_SCRIPT, "gcc") + if not os.access(GXX_SCRIPT, os.X_OK): + makescript(GXX_SCRIPT, "g++") + # Finally fix the makefile rv = fix(MAKEFILE, do_apply) sys.exit(rv) From rhettinger at users.sourceforge.net Sun Jan 2 07:17:35 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Jan 2 07:17:37 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_peepholer.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-serv7497/Lib/test Modified Files: test_peepholer.py Log Message: Teach the peephole optimizer to fold simple constant expressions. Index: test_peepholer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_peepholer.py,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- test_peepholer.py 2 Nov 2004 04:20:10 -0000 1.5 +++ test_peepholer.py 2 Jan 2005 06:17:32 -0000 1.6 @@ -102,6 +102,34 @@ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ],) + def test_folding_of_binops_on_constants(self): + for line, elem in ( + ('a = 2+3+4', '(9)'), # chained fold + ('"@"*4', "('@@@@')"), # check string ops + ('a="abc" + "def"', "('abcdef')"), # check string ops + ('a = 3**4', '(81)'), # binary power + ('a = 3*4', '(12)'), # binary multiply + ('a = 13/4.0', '(3.25)'), # binary divide + ('a = 13//4', '(3)'), # binary floor divide + ('a = 14%4', '(2)'), # binary modulo + ('a = 2+3', '(5)'), # binary add + ('a = 13-4', '(9)'), # binary subtract + ('a = (12,13)[1]', '(13)'), # binary subscr + ('a = 13 << 2', '(52)'), # binary lshift + ('a = 13 >> 2', '(3)'), # binary rshift + ('a = 13 & 7', '(5)'), # binary and + ('a = 13 ^ 7', '(10)'), # binary xor + ('a = 13 | 7', '(15)'), # binary or + ): + asm = dis_single(line) + self.assert_(elem in asm, asm) + self.assert_('BINARY_' not in asm) + + # Verify that unfoldables are skipped + asm = dis_single('a=2+"b"') + self.assert_('(2)' in asm) + self.assert_("('b')" in asm) + def test_elim_extra_return(self): # RETURN LOAD_CONST None RETURN --> RETURN def f(x): From rhettinger at users.sourceforge.net Sun Jan 2 07:17:36 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Jan 2 07:17:39 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1214,1.1215 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7497/Misc Modified Files: NEWS Log Message: Teach the peephole optimizer to fold simple constant expressions. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1214 retrieving revision 1.1215 diff -u -d -r1.1214 -r1.1215 --- NEWS 28 Dec 2004 20:10:40 -0000 1.1214 +++ NEWS 2 Jan 2005 06:17:32 -0000 1.1215 @@ -13,6 +13,9 @@ - min() and max() now support key= arguments with the same meaning as in list.sort(). +- The peephole optimizer now performs simple constant folding in expressions: + (2+3) --> (5). + Extension Modules ----------------- From rhettinger at users.sourceforge.net Sun Jan 2 07:17:37 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Jan 2 07:17:40 2005 Subject: [Python-checkins] python/dist/src/Python compile.c,2.337,2.338 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7497/Python Modified Files: compile.c Log Message: Teach the peephole optimizer to fold simple constant expressions. Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.337 retrieving revision 2.338 diff -u -d -r2.337 -r2.338 --- compile.c 7 Nov 2004 14:04:00 -0000 2.337 +++ compile.c 2 Jan 2005 06:17:33 -0000 2.338 @@ -439,6 +439,99 @@ return 1; } +/* Replace LOAD_CONST c1. LOAD_CONST c2 BINOP + with LOAD_CONST binop(c1,c2) + The consts table must still be in list form so that the + new constant can be appended. + Called with codestr pointing to the first LOAD_CONST. + Abandons the transformation if the folding fails (i.e. 1+'a'). */ +static int +fold_binops_on_constants(unsigned char *codestr, PyObject *consts) +{ + PyObject *newconst, *v, *w; + int len_consts, opcode; + + /* Pre-conditions */ + assert(PyList_CheckExact(consts)); + assert(codestr[0] == LOAD_CONST); + assert(codestr[3] == LOAD_CONST); + + /* Create new constant */ + v = PyList_GET_ITEM(consts, GETARG(codestr, 0)); + w = PyList_GET_ITEM(consts, GETARG(codestr, 3)); + opcode = codestr[6]; + switch (opcode) { + case BINARY_POWER: + newconst = PyNumber_Power(v, w, Py_None); + break; + case BINARY_MULTIPLY: + newconst = PyNumber_Multiply(v, w); + break; + case BINARY_DIVIDE: + if (!_Py_QnewFlag) { + newconst = PyNumber_Divide(v, w); + break; + } + /* -Qnew is in effect: fall through to + BINARY_TRUE_DIVIDE */ + case BINARY_TRUE_DIVIDE: + newconst = PyNumber_TrueDivide(v, w); + break; + case BINARY_FLOOR_DIVIDE: + newconst = PyNumber_FloorDivide(v, w); + break; + case BINARY_MODULO: + newconst = PyNumber_Remainder(v, w); + break; + case BINARY_ADD: + newconst = PyNumber_Add(v, w); + break; + case BINARY_SUBTRACT: + newconst = PyNumber_Subtract(v, w); + break; + case BINARY_SUBSCR: + newconst = PyObject_GetItem(v, w); + break; + case BINARY_LSHIFT: + newconst = PyNumber_Lshift(v, w); + break; + case BINARY_RSHIFT: + newconst = PyNumber_Rshift(v, w); + break; + case BINARY_AND: + newconst = PyNumber_And(v, w); + break; + case BINARY_XOR: + newconst = PyNumber_Xor(v, w); + break; + case BINARY_OR: + newconst = PyNumber_Or(v, w); + 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 NOP NOP NOP LOAD_CONST newconst */ + memset(codestr, NOP, 4); + codestr[4] = LOAD_CONST; + SETARG(codestr, 4, len_consts); + return 1; +} + static unsigned int * markblocks(unsigned char *code, int len) { @@ -614,7 +707,6 @@ h = i - 3 * j; if (h >= 0 && j <= lastlc && - codestr[h] == LOAD_CONST && ISBASICBLOCK(blocks, h, 3*(j+1)) && tuple_of_constants(&codestr[h], j, consts)) { assert(codestr[i] == LOAD_CONST); @@ -640,6 +732,31 @@ } break; + /* Fold binary ops on constants. + LOAD_CONST c1 LOAD_CONST c2 BINOP --> LOAD_CONST binop(c1,c2) */ + case BINARY_POWER: + case BINARY_MULTIPLY: + case BINARY_DIVIDE: + case BINARY_TRUE_DIVIDE: + case BINARY_FLOOR_DIVIDE: + case BINARY_MODULO: + case BINARY_ADD: + case BINARY_SUBTRACT: + case BINARY_SUBSCR: + case BINARY_LSHIFT: + case BINARY_RSHIFT: + case BINARY_AND: + case BINARY_XOR: + case BINARY_OR: + if (lastlc >= 2 && + ISBASICBLOCK(blocks, i-6, 7) && + fold_binops_on_constants(&codestr[i-6], 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 Jan 2 22:41:56 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Jan 2 22:42:01 2005 Subject: [Python-checkins] python/nondist/peps pep-0288.txt,1.3,1.4 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7108 Modified Files: pep-0288.txt Log Message: Update for Py2.5. Index: pep-0288.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0288.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- pep-0288.txt 18 Nov 2002 10:40:44 -0000 1.3 +++ pep-0288.txt 2 Jan 2005 21:41:54 -0000 1.4 @@ -6,186 +6,77 @@ Status: Draft Type: Standards Track Created: 21-Mar-2002 -Python-Version: 2.4 +Python-Version: 2.5 Post-History: Abstract - This PEP introduces ideas for enhancing the generators introduced - in Python version 2.2 [1]. The goal is to increase the - convenience, utility, and power of generators by providing a - mechanism for passing data into a generator and for triggering - exceptions inside a generator. + This PEP proposes to enhance generators by providing mechanisms for + raising exceptions and sharing data with running generators. - These mechanisms were first proposed along with two other - generator tools in PEP 279 [7]. They were split-off to this - separate PEP to allow the ideas more time to mature and for - alternatives to be considered. Subsequently, the argument - passing idea gave way to Detlef Lannert's idea of using attributes. Rationale - Python 2.2 introduced the concept of an iterable interface as - proposed in PEP 234 [2]. The iter() factory function was provided - as common calling convention and deep changes were made to use - iterators as a unifying theme throughout Python. The unification - came in the form of establishing a common iterable interface for - mappings, sequences, and file objects. - - Generators, as proposed in PEP 255 [1], were introduced as a means for - making it easier to create iterators, especially ones with complex - internal states. + Currently, only class based iterators can provide attributes and + exception handling. However, class based iterators are harder to + write, less compact, less readable, and slower. A better solution + is to enable these capabilities for generators. - The next step in the evolution of generators is to allow generators to - accept attribute assignments. This allows data to be passed in a - standard Python fashion. + Enabling attribute assignments allows data to be passed to and from + running generators. The approach of sharing data using attributes + pervades Python. Other approaches exist but are somewhat hackish + in comparison. - A related evolutionary step is to add a generator method to enable + Another evolutionary step is to add a generator method to allow exceptions to be passed to a generator. Currently, there is no clean method for triggering exceptions from outside the generator. Also, generator exception passing helps mitigate the try/finally - prohibition for generators. + prohibition for generators. The need is especially acute for + generators needing to flush buffers or close resources upon termination. + + The two proposals are backwards compatible and require no new + keywords. They are being recommended for Python version 2.5. - These suggestions are designed to take advantage of the existing - implementation and require little additional effort to - incorporate. They are backwards compatible and require no new - keywords. They are being recommended for Python version 2.4. Specification for Generator Attributes Essentially, the proposal is to emulate attribute writing for classes. The only wrinkle is that generators lack a way to refer to instances of - themselves. So, generators need an automatic instance variable, __self__. - - Here is a minimal example: - - def mygen(): - while True: - print __self__.data - yield None - - g = mygen() - g.data = 1 - g.next() # prints 1 - g.data = 2 - g.next() # prints 2 - - The control flow of 'yield' and 'next' is unchanged by this - proposal. The only change is that data can be sent into the - generator. By analogy, consider the quality improvement from - GOSUB (which had no argument passing mechanism) to modern - procedure calls (which can pass in arguments and return values). - Most of the underlying machinery is already in place, only the - __self__ variable needs to be added. - - Yield is more than just a simple iterator creator. It does - something else truly wonderful -- it suspends execution and saves - state. It is good for a lot more than writing iterators. This - proposal further taps its capabilities by making it easier to - share data with the generator. - - The attribute mechanism is especially useful for: - 1. Sending data to any generator - 2. Writing lazy consumers with complex execution states - 3. Writing co-routines (as demonstrated in Dr. Mertz's articles [3]) - - The proposal is a clear improvement over the existing alternative - of passing data via global variables. It is also much simpler, - more readable and easier to debug than an approach involving the - threading module with its attendant mutexes, semaphores, and data - queues. A class-based approach competes well when there are no - complex execution states or variable states. However, when the - complexity increases, generators with writable attributes are much - simpler because they automatically save state (unlike classes - which must explicitly save the variable and execution state in - instance variables). - - -Examples - - Example of a Complex Consumer - - The encoder for arithmetic compression sends a series of - fractional values to a complex, lazy consumer. That consumer - makes computations based on previous inputs and only writes out - when certain conditions have been met. After the last fraction is - received, it has a procedure for flushing any unwritten data. - - - Example of a Consumer Stream - - def filelike(packagename, appendOrOverwrite): - data = [] - if appendOrOverwrite == 'w+': - data.extend(packages[packagename]) - try: - while True: - data.append(__self__.dat) - yield None - except FlushStream: - packages[packagename] = data - - ostream = filelike('mydest','w') - ostream.dat = firstdat; ostream.next() - ostream.dat = firstdat; ostream.next() - ostream.throw(FlushStream) # Throw is proposed below - - - Example of a Complex Consumer - - Loop over the picture files in a directory, shrink them one at a - time to thumbnail size using PIL [4], and send them to a lazy - consumer. That consumer is responsible for creating a large blank - image, accepting thumbnails one at a time and placing them in a 5 - by 3 grid format onto the blank image. Whenever the grid is full, - it writes-out the large image as an index print. A FlushStream - exception indicates that no more thumbnails are available and that - the partial index print should be written out if there are one or - more thumbnails on it. - - - Example of a Producer and Consumer Used Together in a Pipe-like Fashion - - 'Analogy to Linux style pipes: source | upper | sink' - sink = sinkgen() - for word in source(): - sink.data = word.upper() - sink.next() - - -Initialization Mechanism - - If the attribute passing idea is accepted, Detlef Lannert further - proposed that generator instances have attributes initialized to - values in the generator's func_dict. This makes it easy to set - default values. For example: - - def mygen(): - while True: - print __self__.data - yield None - mygen.data = 0 + themselves. So, the proposal is to provide a function for discovering + the reference. For example: - g = mygen() # g initialized with .data set to 0 - g.next() # prints 0 - g.data = 1 - g.next() # prints 1 + def mygen(filename): + self = mygen.get_instance() + myfile = open(filename) + for line in myfile: + if len(line) < 10: + continue + self.pos = myfile.tell() + yield line.upper() + g = mygen('sample.txt') + line1 = g.next() + print 'Position', g.pos -Rejected Alternative + Uses for generator attributes include: - One idea for passing data into a generator was to pass an argument - through next() and make a assignment using the yield keyword: + 1. Providing generator clients with extra information (as shown + above). + 2. Externally setting control flags governing generator operation + (possibly telling a generator when to step in or step over + data groups). + 3. Writing lazy consumers with complex execution states + (an arithmetic encoder output stream for example). + 4. Writing co-routines (as demonstrated in Dr. Mertz's articles [1]). - datain = yield dataout - . . . - dataout = gen.next(datain) + The control flow of 'yield' and 'next' is unchanged by this + proposal. The only change is that data can passed to and from the + generator. Most of the underlying machinery is already in place, + only the access function needs to be added. - The intractable problem is that the argument to the first next() call - has to be thrown away, because it doesn't correspond to a yield keyword. Specification for Generator Exception Passing: @@ -197,7 +88,7 @@ log = [] try: while True: - log.append( time.time() - start ) + log.append(time.time() - start) yield log[-1] except WriteLog: writelog(log) @@ -214,9 +105,7 @@ Generator exception passing also helps address an intrinsic limitation on generators, the prohibition against their using - try/finally to trigger clean-up code [1]. Without .throw(), the - current work-around forces the resolution or clean-up code to be - moved outside the generator. + try/finally to trigger clean-up code [2]. Note A: The name of the throw method was selected for several reasons. Raise is a keyword and so cannot be used as a method @@ -227,10 +116,10 @@ already associated with exceptions in other languages. Alternative method names were considered: resolve(), signal(), - genraise(), raiseinto(), and flush(). None of these seem to fit - as well as throw(). + genraise(), raiseinto(), and flush(). None of these fit as well + as throw(). - Note B: The throw syntax should exactly match raise's syntax: + Note B: The full throw() syntax should exactly match raise's syntax: throw([expression, [expression, [expression]]]) @@ -243,59 +132,19 @@ raise g.throw() - Comments from GvR: I'm not convinced that the cleanup problem that - this is trying to solve exists in practice. I've never felt - the need to put yield inside a try/except. I think the PEP - doesn't make enough of a case that this is useful. - - This one gets a big fat -1 until there's a good motivational - section. - - Comments from Ka-Ping Yee: I agree that the exception issue needs to - be resolved and [that] you have suggested a fine solution. - - Comments from Neil Schemenauer: The exception passing idea is one I - hadn't thought of before and looks interesting. If we enable - the passing of values back, then we should add this feature - too. - - Comments for Magnus Lie Hetland: Even though I cannot speak for the - ease of implementation, I vote +1 for the exception passing - mechanism. - - Comments from the Community: The response has been mostly favorable. One - negative comment from GvR is shown above. The other was from - Martin von Loewis who was concerned that it could be difficult - to implement and is withholding his support until a working - patch is available. To probe Martin's comment, I checked with - the implementers of the original generator PEP for an opinion - on the ease of implementation. They felt that implementation - would be straight-forward and could be grafted onto the - existing implementation without disturbing its internals. - - Author response: When the sole use of generators is to simplify writing - iterators for lazy producers, then the odds of needing - generator exception passing are slim. If, on the other hand, - generators are used to write lazy consumers, create - coroutines, generate output streams, or simply for their - marvelous capability for restarting a previously frozen state, - THEN the need to raise exceptions will come up frequently. - References - [1] PEP 255 Simple Generators - http://www.python.org/peps/pep-0255.html - - [2] PEP 234 Iterators - http://www.python.org/peps/pep-0234.html - - [3] Dr. David Mertz's draft column for Charming Python. + [1] Dr. David Mertz's draft columns for Charming Python: http://gnosis.cx/publish/programming/charming_python_b5.txt http://gnosis.cx/publish/programming/charming_python_b7.txt - [4] PIL, the Python Imaging Library can be found at: - http://www.pythonware.com/products/pil/ + [2] PEP 255 Simple Generators: + http://www.python.org/peps/pep-0255.html + + [3] Proof-of-concept recipe: + http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/164044 + Copyright From bcannon at users.sourceforge.net Sun Jan 2 22:54:10 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sun Jan 2 22:54:13 2005 Subject: [Python-checkins] python/dist/src setup.py,1.210,1.211 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9596 Modified Files: setup.py Log Message: Since it is a possibility that LDFLAGS or CPPFLAGS were set with options that in no way affect library or include directories the code must take that into account and not assume some options were found. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.210 retrieving revision 1.211 diff -u -d -r1.210 -r1.211 --- setup.py 31 Dec 2004 08:11:21 -0000 1.210 +++ setup.py 2 Jan 2005 21:54:07 -0000 1.211 @@ -270,8 +270,9 @@ parser.error = lambda msg: None parser.add_option(arg_name, dest="dirs", action="append") options = parser.parse_args(env_val.split())[0] - for directory in options.dirs: - add_dir_to_list(dir_list, directory) + if options.dirs: + for directory in options.dirs: + add_dir_to_list(dir_list, directory) if os.path.normpath(sys.prefix) != '/usr': add_dir_to_list(self.compiler.library_dirs, From jackjansen at users.sourceforge.net Mon Jan 3 00:17:09 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Mon Jan 3 00:17:12 2005 Subject: [Python-checkins] python/dist/src/Mac/scripts BuildApplet.py, 1.20.8.1, 1.20.8.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28345 Modified Files: Tag: release23-maint BuildApplet.py Log Message: Added a band-aid to make this script work with the older 2.3.0 buildtools if no destroot option is given. That makes life for the additions installer a lot simpler. Index: BuildApplet.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/scripts/BuildApplet.py,v retrieving revision 1.20.8.1 retrieving revision 1.20.8.2 diff -u -d -r1.20.8.1 -r1.20.8.2 --- BuildApplet.py 31 Dec 2004 10:44:24 -0000 1.20.8.1 +++ BuildApplet.py 2 Jan 2005 23:17:06 -0000 1.20.8.2 @@ -99,9 +99,14 @@ if tp == 'APPL': buildtools.update(template, filename, dstfilename) else: - buildtools.process(template, filename, dstfilename, 1, - rsrcname=rsrcfilename, others=extras, raw=raw, - progress=verbose, destroot=destroot) + if destroot: + buildtools.process(template, filename, dstfilename, 1, + rsrcname=rsrcfilename, others=extras, raw=raw, + progress=verbose, destroot=destroot) + else: + buildtools.process(template, filename, dstfilename, 1, + rsrcname=rsrcfilename, others=extras, raw=raw, + progress=verbose) def usage(): print "BuildApplet creates an application from a Python source file" From jackjansen at users.sourceforge.net Mon Jan 3 00:18:09 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Mon Jan 3 00:18:11 2005 Subject: [Python-checkins] python/dist/src/Mac/OSX fixapplepython23.py, NONE, 1.3.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28679 Added Files: Tag: release23-maint fixapplepython23.py Log Message: Backported from the trunk. --- NEW FILE: fixapplepython23.py --- """fixapplepython23 - Fix Apple-installed Python 2.3 (on Mac OS X 10.3) Python 2.3 (and 2.3.X for X<5) have the problem that building an extension for a framework installation may accidentally pick up the framework of a newer Python, in stead of the one that was used to build the extension. This script modifies the Makefile (in .../lib/python2.3/config) to use the newer method of linking extensions with "-undefined dynamic_lookup" which fixes this problem. The script will first check all prerequisites, and return a zero exit status also when nothing needs to be fixed. """ import sys import os import gestalt MAKEFILE='/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/Makefile' CHANGES=(( 'LDSHARED=\t$(CC) $(LDFLAGS) -bundle -framework $(PYTHONFRAMEWORK)\n', 'LDSHARED=\t$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup\n' ),( 'BLDSHARED=\t$(CC) $(LDFLAGS) -bundle -framework $(PYTHONFRAMEWORK)\n', 'BLDSHARED=\t$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup\n' ),( 'CC=\t\tgcc\n', 'CC=\t\t/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/PantherPythonFix/run-gcc\n' ),( 'CXX=\t\tc++\n', 'CXX=\t\t/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/PantherPythonFix/run-g++\n' )) GCC_SCRIPT='/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/PantherPythonFix/run-gcc' GXX_SCRIPT='/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/PantherPythonFix/run-g++' SCRIPT="""#!/bin/sh export MACOSX_DEPLOYMENT_TARGET=10.3 exec %s "${@}" """ def findline(lines, start): """return line starting with given string or -1""" for i in range(len(lines)): if lines[i][:len(start)] == start: return i return -1 def fix(makefile, do_apply): """Fix the Makefile, if required.""" fixed = False lines = open(makefile).readlines() for old, new in CHANGES: i = findline(lines, new) if i >= 0: # Already fixed continue i = findline(lines, old) if i < 0: print 'fixapplepython23: Python installation not fixed (appears broken)' print 'fixapplepython23: missing line:', old return 2 lines[i] = new fixed = True if fixed: if do_apply: print 'fixapplepython23: Fix to Apple-installed Python 2.3 applied' os.rename(makefile, makefile + '~') open(makefile, 'w').writelines(lines) return 0 else: print 'fixapplepython23: Fix to Apple-installed Python 2.3 should be applied' return 1 else: print 'fixapplepython23: No fix needed, appears to have been applied before' return 0 def makescript(filename, compiler): """Create a wrapper script for a compiler""" dirname = os.path.split(filename)[0] if not os.access(dirname, os.X_OK): os.mkdir(dirname, 0755) fp = open(filename, 'w') fp.write(SCRIPT % compiler) fp.close() os.chmod(filename, 0755) print 'fixapplepython23: Created', filename def main(): # Check for -n option if len(sys.argv) > 1 and sys.argv[1] == '-n': do_apply = False else: do_apply = True # First check OS version if gestalt.gestalt('sysv') < 0x1030: print 'fixapplepython23: no fix needed on MacOSX < 10.3' sys.exit(0) # Test that a framework Python is indeed installed if not os.path.exists(MAKEFILE): print 'fixapplepython23: Python framework does not appear to be installed (?), nothing fixed' sys.exit(0) # Check that we can actually write the file if do_apply and not os.access(MAKEFILE, os.W_OK): print 'fixapplepython23: No write permission, please run with "sudo"' sys.exit(2) # Create the shell scripts if do_apply: if not os.access(GCC_SCRIPT, os.X_OK): makescript(GCC_SCRIPT, "gcc") if not os.access(GXX_SCRIPT, os.X_OK): makescript(GXX_SCRIPT, "g++") # Finally fix the makefile rv = fix(MAKEFILE, do_apply) sys.exit(rv) if __name__ == '__main__': main() From jackjansen at users.sourceforge.net Mon Jan 3 00:19:42 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Mon Jan 3 00:19:45 2005 Subject: [Python-checkins] python/dist/src/Mac/OSX Makefile.panther, 1.1.2.6, 1.1.2.7 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28932 Modified Files: Tag: release23-maint Makefile.panther Log Message: Getting things in place for the MacPython additions build 3. Index: Makefile.panther =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/Attic/Makefile.panther,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -u -d -r1.1.2.6 -r1.1.2.7 --- Makefile.panther 30 Dec 2004 22:43:29 -0000 1.1.2.6 +++ Makefile.panther 2 Jan 2005 23:19:39 -0000 1.1.2.7 @@ -2,27 +2,30 @@ # It installs the things that are available in MacPython but that are # ommitted from Apple's installation of Python 2.3. # -all: install_waste install_IDE install_PackageManager install_IDLE \ +all: install_waste install_IDE install_PackageManager \ install_BuildApplet installextras install_PythonLauncher install_pimpupdate +srcdir=../.. VERSION=2.3 DESTDIR= PYTHONAPPSDIR=/Applications/MacPython-$(VERSION) APPLE_prefix=/System/Library/Frameworks/Python.framework/Versions/$(VERSION) -APPLE_PYTHON=/usr/bin/python$(VERSION) +BUILDPYTHON=/usr/bin/python$(VERSION) APPLE_LIBDEST=$(APPLE_prefix)/lib/python$(VERSION) -APPLE_PYTHONW=$(APPLE_prefix)/Resources/Python.app/Contents/MacOS/Python +INSTALLED_PYTHONW=$(APPLE_prefix)/Resources/Python.app/Contents/MacOS/Python APPLE_PYTHONLAUNCHER=$(APPLE_prefix)/Resources/PythonLauncher.app +bundlebuilder=$(srcdir)/Lib/plat-mac/bundlebuilder.py install_waste: - $(APPLE_PYTHON) setup.panther.py install \ + $(BUILDPYTHON) setup.panther.py install \ --prefix=$(APPLE_prefix) --root=/$(DESTDIR) install_IDE: - $(MAKE) -f Makefile install_IDE \ - BUILDPYTHON=$(APPLE_PYTHON) INSTALLED_PYTHONW=$(APPLE_PYTHONW) \ - DESTDIR=$(DESTDIR) PYTHONAPPSDIR=$(PYTHONAPPSDIR) + $(BUILDPYTHON) $(srcdir)/Mac/scripts/BuildApplet.py \ + --python $(INSTALLED_PYTHONW) \ + --output $(DESTDIR)$(PYTHONAPPSDIR)/PythonIDE.app --noargv \ + $(srcdir)/Mac/Tools/IDE/PythonIDE.py # Add the extra files to the resources. This is to work around bugs in # them in the original 2.3. cp ../Tools/IDE/PythonIDEMain.py $(DESTDIR)$(PYTHONAPPSDIR)/PythonIDE.app/Contents/Resources @@ -31,23 +34,24 @@ cp ../Tools/IDE/PyEdit.py $(DESTDIR)$(PYTHONAPPSDIR)/PythonIDE.app/Contents/Resources install_PackageManager: - $(MAKE) -f Makefile install_PackageManager \ - BUILDPYTHON=$(APPLE_PYTHON) INSTALLED_PYTHONW=$(APPLE_PYTHONW) \ - DESTDIR=$(DESTDIR) PYTHONAPPSDIR=$(PYTHONAPPSDIR) - -install_IDLE: - $(MAKE) -f Makefile install_IDLE \ - BUILDPYTHON=$(APPLE_PYTHON) INSTALLED_PYTHONW=$(APPLE_PYTHONW) \ - DESTDIR=$(DESTDIR) PYTHONAPPSDIR=$(PYTHONAPPSDIR) + $(BUILDPYTHON) $(bundlebuilder) \ + --builddir $(DESTDIR)$(PYTHONAPPSDIR)/ \ + --python $(INSTALLED_PYTHONW) \ + --resource $(srcdir)/Mac/Tools/IDE/PythonIDE.rsrc \ + --mainprogram $(srcdir)/Mac/Tools/IDE/PackageManager.py \ + --iconfile $(srcdir)/Mac/Tools/IDE/PackageManager.icns \ + --plist $(srcdir)/Mac/Tools/IDE/PackageManager.plist \ + --creator Pimp build install_BuildApplet: - $(MAKE) -f Makefile install_BuildApplet \ - BUILDPYTHON=$(APPLE_PYTHON) INSTALLED_PYTHONW=$(APPLE_PYTHONW) \ - DESTDIR=$(DESTDIR) PYTHONAPPSDIR=$(PYTHONAPPSDIR) + $(BUILDPYTHON) $(srcdir)/Mac/scripts/BuildApplet.py \ + --python $(INSTALLED_PYTHONW) \ + --output $(DESTDIR)$(PYTHONAPPSDIR)/BuildApplet.app \ + $(srcdir)/Mac/scripts/BuildApplet.py installextras: $(MAKE) -f Makefile installextras \ - BUILDPYTHON=$(APPLE_PYTHON) INSTALLED_PYTHONW=$(APPLE_PYTHONW) \ + BUILDPYTHON=$(BUILDPYTHON) INSTALLED_PYTHONW=$(INSTALLED_PYTHONW) \ DESTDIR=$(DESTDIR) PYTHONAPPSDIR=$(PYTHONAPPSDIR) install_PythonLauncher: From jackjansen at users.sourceforge.net Mon Jan 3 00:19:43 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Mon Jan 3 00:19:46 2005 Subject: [Python-checkins] python/dist/src/Mac/OSX/Dist build.panther, 1.1.2.4, 1.1.2.5 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX/Dist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28932/Dist Modified Files: Tag: release23-maint build.panther Log Message: Getting things in place for the MacPython additions build 3. Index: build.panther =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/Dist/Attic/build.panther,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -d -r1.1.2.4 -r1.1.2.5 --- build.panther 27 Dec 2004 16:41:53 -0000 1.1.2.4 +++ build.panther 2 Jan 2005 23:19:39 -0000 1.1.2.5 @@ -24,6 +24,11 @@ echo "No /usr/bin/python; this script expects to be run on 10.3 only" exit 1 fi +vers=`/usr/bin/python -V 2>&1` +if [ "$vers" != "Python 2.3" ]; then + echo "/usr/bin/python is not version 2.3; this script expects to be run on 10.3 only" + exit 1 +fi TMPDIR=/tmp/_py #TMPDIR=/projects/_py @@ -62,11 +67,29 @@ pushd $PYTHONOSXDIR +# Check that the Apple Python 2.3 Makefile fixes have been applied on this +# machine +if python fixapplepython23.py -n; then + : +else + echo + echo The additions installer will also install a fix to Apple-installed 2.3 + echo to make building extensions work in the face of other Pythons. + echo But this system needs to have that fix to be able to put it in the installer. + echo + echo Please run $PYTHONOSXDIR/fixapplepython23.py to install the fix. + exit +fi + make -f Makefile.panther DIRMODE=775 EXEMODE=775 FILEMODE=664 DESTDIR=$INSTALLROOT # Remove the temporary symlink rm -r $INSTALLROOT/System +# Install the Makefile fixes +config=System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config +(cd / ; tar cf - $config/Makefile $config/PantherPythonFix) | (cd $INSTALLROOT; tar xf -) + # Unfortunately all the ...MODE arguments above still don't do the trick. # Cop out, and recursively set everything group-writeable. chmod -R ug+w $INSTALLROOT From jackjansen at users.sourceforge.net Mon Jan 3 00:19:43 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Mon Jan 3 00:19:47 2005 Subject: [Python-checkins] python/dist/src/Mac/OSX/Dist/resources.panther ReadMe.txt, 1.1.2.4, 1.1.2.5 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX/Dist/resources.panther In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28932/Dist/resources.panther Modified Files: Tag: release23-maint ReadMe.txt Log Message: Getting things in place for the MacPython additions build 3. Index: ReadMe.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/Dist/resources.panther/Attic/ReadMe.txt,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -d -r1.1.2.4 -r1.1.2.5 --- ReadMe.txt 27 Dec 2004 16:41:53 -0000 1.1.2.4 +++ ReadMe.txt 2 Jan 2005 23:19:40 -0000 1.1.2.5 @@ -1,4 +1,4 @@ -This package will install the third build of +This package will install beta 1 of the third build of the MacPython 2.3 additions for Mac OS X 10.3. Installation requires approximately 3.3 MB of disk @@ -34,6 +34,11 @@ - fixed "run with commandline python" to use pythonw. - fixed a crash with very big scripts folders. - fixed the double-scroll problem when you single-clicked. +- Python fixes: + - One fix is made to the Apple-installed Python itself. + As distributed the installation of a newer Python would + cause Apple python to have problems building extensions, + this is fixed. Changes since the first build: - The startup crash of the IDE some people experienced @@ -43,6 +48,6 @@ through the Package Manager. More information on MacPython can be found at -http://www.cwi.nl/~jack/macpython.html, more +http://www.cwi.nl/~jack/macpython, more information on Python in general at http://www.python.org. From rhettinger at users.sourceforge.net Mon Jan 3 05:59:24 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Jan 3 05:59:27 2005 Subject: [Python-checkins] python/nondist/peps pep-0288.txt,1.4,1.5 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28765 Modified Files: pep-0288.txt Log Message: Simplify the proposal for gen.throw(). Index: pep-0288.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0288.txt,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- pep-0288.txt 2 Jan 2005 21:41:54 -0000 1.4 +++ pep-0288.txt 3 Jan 2005 04:59:21 -0000 1.5 @@ -119,17 +119,12 @@ genraise(), raiseinto(), and flush(). None of these fit as well as throw(). - Note B: The full throw() syntax should exactly match raise's syntax: - - throw([expression, [expression, [expression]]]) - - Accordingly, it should be implemented to handle all of the following: + Note B: To keep the throw() syntax simple only the instance + version of the raise syntax would be supported (no variants for + "raise string" or "raise class, instance"). - raise string g.throw(string) - raise string, data g.throw(string,data) - raise class, instance g.throw(class,instance) - raise instance g.throw(instance) - raise g.throw() + Calling "g.throw(instance)" would correspond to writing + "raise instance" immediately after the most recent yield. From rhettinger at users.sourceforge.net Mon Jan 3 08:14:15 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Jan 3 08:14:17 2005 Subject: [Python-checkins] python/dist/src/Lib textwrap.py,1.35,1.36 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16879 Modified Files: textwrap.py Log Message: Removed unused line. Index: textwrap.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/textwrap.py,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- textwrap.py 3 Jun 2004 01:59:40 -0000 1.35 +++ textwrap.py 3 Jan 2005 07:14:12 -0000 1.36 @@ -267,7 +267,6 @@ converted to space. """ text = self._munge_whitespace(text) - indent = self.initial_indent chunks = self._split(text) if self.fix_sentence_endings: self._fix_sentence_endings(chunks) From rhettinger at users.sourceforge.net Mon Jan 3 08:33:19 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Mon Jan 3 08:33:22 2005 Subject: [Python-checkins] python/dist/src/Lib random.py,1.69,1.70 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19876 Modified Files: random.py Log Message: Removed unused line. Index: random.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/random.py,v retrieving revision 1.69 retrieving revision 1.70 diff -u -d -r1.69 -r1.70 --- random.py 27 Sep 2004 15:29:03 -0000 1.69 +++ random.py 3 Jan 2005 07:33:16 -0000 1.70 @@ -43,7 +43,6 @@ from types import MethodType as _MethodType, BuiltinMethodType as _BuiltinMethodType from math import log as _log, exp as _exp, pi as _pi, e as _e from math import sqrt as _sqrt, acos as _acos, cos as _cos, sin as _sin -from math import floor as _floor from os import urandom as _urandom from binascii import hexlify as _hexlify From jackjansen at users.sourceforge.net Mon Jan 3 16:44:20 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Mon Jan 3 16:44:24 2005 Subject: [Python-checkins] python/dist/src/Lib/plat-mac pimp.py,1.36,1.37 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-mac In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10817 Modified Files: pimp.py Log Message: - Added an "installer" flavor, which uses the "open" command to install something (overridable through Install-command entry) - Hidden status is now determined by flavor == hidden, not by missing Download-URL. Hidden packages behave like installer packages. - Made some error messages a bit more understandable. Because there's new functionality the version has been upped to 0.5. Index: pimp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/pimp.py,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- pimp.py 28 Dec 2004 21:33:27 -0000 1.36 +++ pimp.py 3 Jan 2005 15:44:18 -0000 1.37 @@ -36,12 +36,13 @@ NO_EXECUTE=0 -PIMP_VERSION="0.4" +PIMP_VERSION="0.5" # Flavors: # source: setup-based package # binary: tar (or other) archive created with setup.py bdist. -DEFAULT_FLAVORORDER=['source', 'binary'] +# installer: something that can be opened +DEFAULT_FLAVORORDER=['source', 'binary', 'installer'] DEFAULT_DOWNLOADDIR='/tmp' DEFAULT_BUILDDIR='/tmp' DEFAULT_INSTALLDIR=distutils.sysconfig.get_python_lib() @@ -418,6 +419,10 @@ pkg = PimpPackage_source(self, p) elif flavor == 'binary': pkg = PimpPackage_binary(self, p) + elif flavor == 'installer': + pkg = PimpPackage_installer(self, p) + elif flavor == 'hidden': + pkg = PimpPackage_installer(self, p) else: pkg = PimpPackage(self, dict(p)) self._packages.append(pkg) @@ -543,7 +548,7 @@ rv = rv + '-%s' % self._dict['Version'] if self._dict.has_key('Flavor'): rv = rv + '-%s' % self._dict['Flavor'] - if not self._dict.get('Download-URL'): + if self._dict.get('Flavor') == 'hidden': # Pseudo-package, show in parentheses rv = '(%s)' % rv return rv @@ -620,11 +625,11 @@ if status == "yes": return [] return [(None, - "%s: This package cannot be installed automatically (no Download-URL field)" % + "Package %s cannot be installed automatically, see the description" % self.fullname())] if self.systemwideOnly() and self._db.preferences.isUserInstall(): return [(None, - "%s: This package can only be installed system-wide" % + "Package %s can only be installed system-wide" % self.fullname())] if not self._dict.get('Prerequisites'): return [] @@ -791,7 +796,7 @@ return "%s: Binary package cannot have Install-command" % self.fullname() if self._dict.has_key('Pre-install-command'): - if _cmd(output, self._buildDirname, self._dict['Pre-install-command']): + if _cmd(output, '/tmp', self._dict['Pre-install-command']): return "pre-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Pre-install-command']) @@ -824,7 +829,7 @@ self.afterInstall() if self._dict.has_key('Post-install-command'): - if _cmd(output, self._buildDirname, self._dict['Post-install-command']): + if _cmd(output, '/tmp', self._dict['Post-install-command']): return "%s: post-install: running \"%s\" failed" % \ (self.fullname(), self._dict['Post-install-command']) @@ -891,6 +896,37 @@ (self.fullname(), self._dict['Post-install-command']) return None +class PimpPackage_installer(PimpPackage): + + def unpackPackageOnly(self, output=None): + """We don't unpack dmg packages until installing""" + pass + + def installPackageOnly(self, output=None): + """Install a single source package. + + If output is given it should be a file-like object and it + will receive a log of what happened.""" + + if self._dict.has_key('Post-install-command'): + return "%s: Installer package cannot have Post-install-command" % self.fullname() + + if self._dict.has_key('Pre-install-command'): + if _cmd(output, '/tmp', self._dict['Pre-install-command']): + return "pre-install %s: running \"%s\" failed" % \ + (self.fullname(), self._dict['Pre-install-command']) + + self.beforeInstall() + + installcmd = self._dict.get('Install-command') + if installcmd: + if '%' in installcmd: + installcmd = installcmd % self.archiveFilename + else: + installcmd = 'open \"%s\"' % self.archiveFilename + if _cmd(output, "/tmp", installcmd): + return '%s: install command failed (use verbose for details)' % self.fullname() + return '%s: downloaded and opened. Install manually and restart Package Manager' % self.archiveFilename class PimpInstaller: """Installer engine: computes dependencies and installs From jackjansen at users.sourceforge.net Mon Jan 3 16:46:33 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Mon Jan 3 16:46:36 2005 Subject: [Python-checkins] python/dist/src/Lib/plat-mac pimp.py, 1.27.4.3, 1.27.4.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-mac In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11725 Modified Files: Tag: release23-maint pimp.py Log Message: Backport of 1.37: - Added an "installer" flavor, which uses the "open" command to install something (overridable through Install-command entry) - Hidden status is now determined by flavor == hidden, not by missing Download-URL. Hidden packages behave like installer packages. - Made some error messages a bit more understandable. Because there's new functionality the version has been upped to 0.5. Index: pimp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/pimp.py,v retrieving revision 1.27.4.3 retrieving revision 1.27.4.4 diff -u -d -r1.27.4.3 -r1.27.4.4 --- pimp.py 28 Dec 2004 21:53:15 -0000 1.27.4.3 +++ pimp.py 3 Jan 2005 15:46:30 -0000 1.27.4.4 @@ -36,12 +36,13 @@ NO_EXECUTE=0 -PIMP_VERSION="0.4" +PIMP_VERSION="0.5" # Flavors: # source: setup-based package # binary: tar (or other) archive created with setup.py bdist. -DEFAULT_FLAVORORDER=['source', 'binary'] +# installer: something that can be opened +DEFAULT_FLAVORORDER=['source', 'binary', 'installer'] DEFAULT_DOWNLOADDIR='/tmp' DEFAULT_BUILDDIR='/tmp' DEFAULT_INSTALLDIR=distutils.sysconfig.get_python_lib() @@ -418,6 +419,10 @@ pkg = PimpPackage_source(self, p) elif flavor == 'binary': pkg = PimpPackage_binary(self, p) + elif flavor == 'installer': + pkg = PimpPackage_installer(self, p) + elif flavor == 'hidden': + pkg = PimpPackage_installer(self, p) else: pkg = PimpPackage(self, dict(p)) self._packages.append(pkg) @@ -543,7 +548,7 @@ rv = rv + '-%s' % self._dict['Version'] if self._dict.has_key('Flavor'): rv = rv + '-%s' % self._dict['Flavor'] - if not self._dict.get('Download-URL'): + if self._dict.get('Flavor') == 'hidden': # Pseudo-package, show in parentheses rv = '(%s)' % rv return rv @@ -620,11 +625,11 @@ if status == "yes": return [] return [(None, - "%s: This package cannot be installed automatically (no Download-URL field)" % + "Package %s cannot be installed automatically, see the description" % self.fullname())] if self.systemwideOnly() and self._db.preferences.isUserInstall(): return [(None, - "%s: This package can only be installed system-wide" % + "Package %s can only be installed system-wide" % self.fullname())] if not self._dict.get('Prerequisites'): return [] @@ -791,7 +796,7 @@ return "%s: Binary package cannot have Install-command" % self.fullname() if self._dict.has_key('Pre-install-command'): - if _cmd(output, self._buildDirname, self._dict['Pre-install-command']): + if _cmd(output, '/tmp', self._dict['Pre-install-command']): return "pre-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Pre-install-command']) @@ -824,7 +829,7 @@ self.afterInstall() if self._dict.has_key('Post-install-command'): - if _cmd(output, self._buildDirname, self._dict['Post-install-command']): + if _cmd(output, '/tmp', self._dict['Post-install-command']): return "%s: post-install: running \"%s\" failed" % \ (self.fullname(), self._dict['Post-install-command']) @@ -891,6 +896,37 @@ (self.fullname(), self._dict['Post-install-command']) return None +class PimpPackage_installer(PimpPackage): + + def unpackPackageOnly(self, output=None): + """We don't unpack dmg packages until installing""" + pass + + def installPackageOnly(self, output=None): + """Install a single source package. + + If output is given it should be a file-like object and it + will receive a log of what happened.""" + + if self._dict.has_key('Post-install-command'): + return "%s: Installer package cannot have Post-install-command" % self.fullname() + + if self._dict.has_key('Pre-install-command'): + if _cmd(output, '/tmp', self._dict['Pre-install-command']): + return "pre-install %s: running \"%s\" failed" % \ + (self.fullname(), self._dict['Pre-install-command']) + + self.beforeInstall() + + installcmd = self._dict.get('Install-command') + if installcmd: + if '%' in installcmd: + installcmd = installcmd % self.archiveFilename + else: + installcmd = 'open \"%s\"' % self.archiveFilename + if _cmd(output, "/tmp", installcmd): + return '%s: install command failed (use verbose for details)' % self.fullname() + return '%s: downloaded and opened. Install manually and restart Package Manager' % self.archiveFilename class PimpInstaller: """Installer engine: computes dependencies and installs From jackjansen at users.sourceforge.net Mon Jan 3 16:46:48 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Mon Jan 3 16:46:51 2005 Subject: [Python-checkins] python/dist/src/Lib/plat-mac pimp.py, 1.35.4.1, 1.35.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-mac In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12063 Modified Files: Tag: release24-maint pimp.py Log Message: Backport of 1.37: - Added an "installer" flavor, which uses the "open" command to install something (overridable through Install-command entry) - Hidden status is now determined by flavor == hidden, not by missing Download-URL. Hidden packages behave like installer packages. - Made some error messages a bit more understandable. Because there's new functionality the version has been upped to 0.5. Index: pimp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/pimp.py,v retrieving revision 1.35.4.1 retrieving revision 1.35.4.2 diff -u -d -r1.35.4.1 -r1.35.4.2 --- pimp.py 28 Dec 2004 21:53:49 -0000 1.35.4.1 +++ pimp.py 3 Jan 2005 15:46:45 -0000 1.35.4.2 @@ -36,12 +36,13 @@ NO_EXECUTE=0 -PIMP_VERSION="0.4" +PIMP_VERSION="0.5" # Flavors: # source: setup-based package # binary: tar (or other) archive created with setup.py bdist. -DEFAULT_FLAVORORDER=['source', 'binary'] +# installer: something that can be opened +DEFAULT_FLAVORORDER=['source', 'binary', 'installer'] DEFAULT_DOWNLOADDIR='/tmp' DEFAULT_BUILDDIR='/tmp' DEFAULT_INSTALLDIR=distutils.sysconfig.get_python_lib() @@ -418,6 +419,10 @@ pkg = PimpPackage_source(self, p) elif flavor == 'binary': pkg = PimpPackage_binary(self, p) + elif flavor == 'installer': + pkg = PimpPackage_installer(self, p) + elif flavor == 'hidden': + pkg = PimpPackage_installer(self, p) else: pkg = PimpPackage(self, dict(p)) self._packages.append(pkg) @@ -543,7 +548,7 @@ rv = rv + '-%s' % self._dict['Version'] if self._dict.has_key('Flavor'): rv = rv + '-%s' % self._dict['Flavor'] - if not self._dict.get('Download-URL'): + if self._dict.get('Flavor') == 'hidden': # Pseudo-package, show in parentheses rv = '(%s)' % rv return rv @@ -620,11 +625,11 @@ if status == "yes": return [] return [(None, - "%s: This package cannot be installed automatically (no Download-URL field)" % + "Package %s cannot be installed automatically, see the description" % self.fullname())] if self.systemwideOnly() and self._db.preferences.isUserInstall(): return [(None, - "%s: This package can only be installed system-wide" % + "Package %s can only be installed system-wide" % self.fullname())] if not self._dict.get('Prerequisites'): return [] @@ -791,7 +796,7 @@ return "%s: Binary package cannot have Install-command" % self.fullname() if self._dict.has_key('Pre-install-command'): - if _cmd(output, self._buildDirname, self._dict['Pre-install-command']): + if _cmd(output, '/tmp', self._dict['Pre-install-command']): return "pre-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Pre-install-command']) @@ -824,7 +829,7 @@ self.afterInstall() if self._dict.has_key('Post-install-command'): - if _cmd(output, self._buildDirname, self._dict['Post-install-command']): + if _cmd(output, '/tmp', self._dict['Post-install-command']): return "%s: post-install: running \"%s\" failed" % \ (self.fullname(), self._dict['Post-install-command']) @@ -891,6 +896,37 @@ (self.fullname(), self._dict['Post-install-command']) return None +class PimpPackage_installer(PimpPackage): + + def unpackPackageOnly(self, output=None): + """We don't unpack dmg packages until installing""" + pass + + def installPackageOnly(self, output=None): + """Install a single source package. + + If output is given it should be a file-like object and it + will receive a log of what happened.""" + + if self._dict.has_key('Post-install-command'): + return "%s: Installer package cannot have Post-install-command" % self.fullname() + + if self._dict.has_key('Pre-install-command'): + if _cmd(output, '/tmp', self._dict['Pre-install-command']): + return "pre-install %s: running \"%s\" failed" % \ + (self.fullname(), self._dict['Pre-install-command']) + + self.beforeInstall() + + installcmd = self._dict.get('Install-command') + if installcmd: + if '%' in installcmd: + installcmd = installcmd % self.archiveFilename + else: + installcmd = 'open \"%s\"' % self.archiveFilename + if _cmd(output, "/tmp", installcmd): + return '%s: install command failed (use verbose for details)' % self.fullname() + return '%s: downloaded and opened. Install manually and restart Package Manager' % self.archiveFilename class PimpInstaller: """Installer engine: computes dependencies and installs From jackjansen at users.sourceforge.net Mon Jan 3 17:00:32 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Mon Jan 3 17:00:34 2005 Subject: [Python-checkins] python/dist/src/Mac/OSX/Dist/resources.panther ReadMe.txt, 1.1.2.5, 1.1.2.6 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX/Dist/resources.panther In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15145/resources.panther Modified Files: Tag: release23-maint ReadMe.txt Log Message: Added one-liner about pimp 0.5 Index: ReadMe.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/Dist/resources.panther/Attic/ReadMe.txt,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -d -r1.1.2.5 -r1.1.2.6 --- ReadMe.txt 2 Jan 2005 23:19:40 -0000 1.1.2.5 +++ ReadMe.txt 3 Jan 2005 16:00:28 -0000 1.1.2.6 @@ -22,13 +22,14 @@ references to other documentation. Changes since the second build: -- Package Manager has been updated to version 0.4: +- Package Manager has been updated to version 0.5: - added commands to open database description page and standard experimental database. - the scrollbar had a mind of its own. Fixed. - show all packages in case of an error message. - easier maintainance (mainly important for me:-) in the light of micro-releases of OSX. + - some integration with external installers - IDE fixes: - better handling of various end-of-line schemes. - fixed "run with commandline python" to use pythonw. From loewis at users.sourceforge.net Tue Jan 4 00:42:04 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Jan 4 00:42:07 2005 Subject: [Python-checkins] python/dist/src/Doc/ext windows.tex,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ext In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26284 Modified Files: windows.tex Log Message: Fix typo. Index: windows.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/windows.tex,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- windows.tex 30 Dec 2004 10:44:32 -0000 1.10 +++ windows.tex 3 Jan 2005 23:42:01 -0000 1.11 @@ -163,8 +163,8 @@ click OK. (Inserting them one by one is fine too.) Now open the \menuselection{Project \sub spam properties} dialog. - You only need to change a few settings. Make sure \guilable{All - Configurations} is selected from the \guilable{Settings for:} + You only need to change a few settings. Make sure \guilabel{All + Configurations} is selected from the \guilabel{Settings for:} dropdown list. Select the C/\Cpp{} tab. Choose the General category in the popup menu at the top. Type the following text in the entry box labeled \guilabel{Additional Include Directories}: From loewis at users.sourceforge.net Tue Jan 4 00:42:37 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Jan 4 00:42:40 2005 Subject: [Python-checkins] python/dist/src/Doc/ext windows.tex, 1.9.4.1, 1.9.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ext In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26474 Modified Files: Tag: release24-maint windows.tex Log Message: Fix typo. Index: windows.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ext/windows.tex,v retrieving revision 1.9.4.1 retrieving revision 1.9.4.2 diff -u -d -r1.9.4.1 -r1.9.4.2 --- windows.tex 30 Dec 2004 10:44:50 -0000 1.9.4.1 +++ windows.tex 3 Jan 2005 23:42:34 -0000 1.9.4.2 @@ -163,8 +163,8 @@ click OK. (Inserting them one by one is fine too.) Now open the \menuselection{Project \sub spam properties} dialog. - You only need to change a few settings. Make sure \guilable{All - Configurations} is selected from the \guilable{Settings for:} + You only need to change a few settings. Make sure \guilabel{All + Configurations} is selected from the \guilabel{Settings for:} dropdown list. Select the C/\Cpp{} tab. Choose the General category in the popup menu at the top. Type the following text in the entry box labeled \guilabel{Additional Include Directories}: From jackjansen at users.sourceforge.net Tue Jan 4 16:25:50 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Tue Jan 4 16:25:55 2005 Subject: [Python-checkins] python/dist/src/Mac/scripts BuildApplication.py, 1.10, 1.10.12.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3954 Modified Files: Tag: release23-maint BuildApplication.py Log Message: Fix for #1076490 submitted by Neil Mayhew: a serious typo means BuildApplication has never worked in 2.3. I guess that shows how popular MacOS9 is:-) Index: BuildApplication.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/scripts/Attic/BuildApplication.py,v retrieving revision 1.10 retrieving revision 1.10.12.1 diff -u -d -r1.10 -r1.10.12.1 --- BuildApplication.py 22 Jan 2003 14:03:11 -0000 1.10 +++ BuildApplication.py 4 Jan 2005 15:25:48 -0000 1.10.12.1 @@ -72,7 +72,7 @@ else: tf = tf + '.app' - dstfilename = EasyDialogs.AskFileForSate(message='Save application as:', + dstfilename = EasyDialogs.AskFileForSave(message='Save application as:', savedFileName=tf) if not ok: return From jackjansen at users.sourceforge.net Tue Jan 4 17:05:36 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Tue Jan 4 17:05:39 2005 Subject: [Python-checkins] python/dist/src/Mac/OSX Makefile, 1.50.4.4, 1.50.4.5 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14059 Modified Files: Tag: release23-maint Makefile Log Message: Backport of 1.55 and 1.57: - Added quotes around the destroot arguments, so empty destroot works. - Run fixapplepython23 script to check whether Apple's Python 2.3 needs to be patched. Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/Makefile,v retrieving revision 1.50.4.4 retrieving revision 1.50.4.5 diff -u -d -r1.50.4.4 -r1.50.4.5 --- Makefile 31 Dec 2004 10:44:24 -0000 1.50.4.4 +++ Makefile 4 Jan 2005 16:05:33 -0000 1.50.4.5 @@ -61,7 +61,7 @@ bundlebuilder=$(srcdir)/Lib/plat-mac/bundlebuilder.py installapps: install_PythonLauncher install_Python install_BuildApplet install_IDE \ - install_IDLE install_PackageManager + install_IDLE install_PackageManager checkapplepython install_PythonLauncher: cd $(srcdir)/Mac/OSX/PythonLauncher/PythonLauncher.pbproj ; \ @@ -121,12 +121,12 @@ echo See Mac/OSX/README for details; \ else \ echo $(BUILDPYTHON) $(srcdir)/Mac/scripts/BuildApplet.py \ - --destroot $(DESTDIR) \ + --destroot "$(DESTDIR)" \ --python $(INSTALLED_PYTHONW) \ --output $(DESTDIR)$(PYTHONAPPSDIR)/PythonIDE.app --noargv \ $(srcdir)/Mac/Tools/IDE/PythonIDE.py ; \ $(BUILDPYTHON) $(srcdir)/Mac/scripts/BuildApplet.py \ - --destroot $(DESTDIR) \ + --destroot "$(DESTDIR)" \ --python $(INSTALLED_PYTHONW) \ --output $(DESTDIR)$(PYTHONAPPSDIR)/PythonIDE.app --noargv \ $(srcdir)/Mac/Tools/IDE/PythonIDE.py; \ @@ -139,7 +139,7 @@ else \ echo $(BUILDPYTHON) $(bundlebuilder) \ --builddir $(DESTDIR)$(PYTHONAPPSDIR)/ \ - --destroot $(DESTDIR) \ + --destroot "$(DESTDIR)" \ --python $(INSTALLED_PYTHONW) \ --resource $(srcdir)/Mac/Tools/IDE/PythonIDE.rsrc \ --mainprogram $(srcdir)/Mac/Tools/IDE/PackageManager.py \ @@ -148,7 +148,7 @@ --creator Pimp build; \ $(BUILDPYTHON) $(bundlebuilder) \ --builddir $(DESTDIR)$(PYTHONAPPSDIR)/ \ - --destroot $(DESTDIR) \ + --destroot "$(DESTDIR)" \ --python $(INSTALLED_PYTHONW) \ --resource $(srcdir)/Mac/Tools/IDE/PythonIDE.rsrc \ --mainprogram $(srcdir)/Mac/Tools/IDE/PackageManager.py \ @@ -164,13 +164,13 @@ else \ echo $(BUILDPYTHON) $(srcdir)/Mac/scripts/BuildApplet.py \ --python $(INSTALLED_PYTHONW) \ - --destroot $(DESTDIR) \ + --destroot "$(DESTDIR)" \ --output $(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app \ --extra $(srcdir)/Lib/idlelib \ $(srcdir)/Lib/idlelib/idle ; \ $(BUILDPYTHON) $(srcdir)/Mac/scripts/BuildApplet.py \ --python $(INSTALLED_PYTHONW) \ - --destroot $(DESTDIR) \ + --destroot "$(DESTDIR)" \ --output $(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app \ --extra $(srcdir)/Lib/idlelib:Contents/Resources/idlelib \ $(srcdir)/Lib/idlelib/idle ; \ @@ -179,7 +179,7 @@ install_BuildApplet: $(BUILDPYTHON) $(srcdir)/Mac/scripts/BuildApplet.py \ - --destroot $(DESTDIR) \ + --destroot "$(DESTDIR)" \ --python $(INSTALLED_PYTHONW) \ --output $(DESTDIR)$(PYTHONAPPSDIR)/BuildApplet.app \ $(srcdir)/Mac/scripts/BuildApplet.py @@ -267,3 +267,10 @@ $(DESTDIR)$(PYTHONAPPSDIR)/Extras/Demo $(BUILDPYTHON) $(srcdir)/Mac/OSX/Extras.install.py $(srcdir)/Tools \ $(DESTDIR)$(PYTHONAPPSDIR)/Extras/Tools + +checkapplepython: + @if ! $(BUILDPYTHON) $(srcdir)/Mac/OSX/fixapplepython23.py -n; then \ + echo "* WARNING: Apple-installed Python 2.3 will have trouble building extensions from now on."; \ + echo "* WARNING: Run $(srcdir)/Mac/OSX/fixapplepython23.py with \"sudo\" to fix this."; \ + fi + From jackjansen at users.sourceforge.net Tue Jan 4 17:07:11 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Tue Jan 4 17:07:14 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.160, 1.831.4.161 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14590/Misc Modified Files: Tag: release23-maint NEWS Log Message: Mac news items. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.160 retrieving revision 1.831.4.161 diff -u -d -r1.831.4.160 -r1.831.4.161 --- NEWS 28 Dec 2004 20:31:25 -0000 1.831.4.160 +++ NEWS 4 Jan 2005 16:07:04 -0000 1.831.4.161 @@ -151,6 +151,14 @@ - pygettext.py: Generate POT-Creation-Date header in ISO format. +Macintosh +--------- + +- Bug #1091468: make frameworkinstall now works with DESTROOT builds + +- Bug #1076490 (MacOS9 only): fixed a BuildApplication crash when it tried + to actually save the application + Build ----- From rhettinger at users.sourceforge.net Tue Jan 4 22:25:27 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Jan 4 22:25:29 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libuserdict.tex, 1.25, 1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21906 Modified Files: libuserdict.tex Log Message: Clarify that DictMixin is still useful. Only the UserDict class was supplanted. Index: libuserdict.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libuserdict.tex,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- libuserdict.tex 1 Jan 2005 00:28:43 -0000 1.25 +++ libuserdict.tex 4 Jan 2005 21:25:00 -0000 1.26 @@ -4,22 +4,20 @@ \declaremodule{standard}{UserDict} \modulesynopsis{Class wrapper for dictionary objects.} -\note{This module is available for backward compatibility only. If -you are writing code that does not need to work with versions of -Python earlier than Python 2.2, please consider subclassing directly -from the built-in \class{dict} type.} - -This module defines a class that acts as a wrapper around -dictionary objects. It is a useful base class for -your own dictionary-like classes, which can inherit from -them and override existing methods or add new ones. In this way one -can add new behaviors to dictionaries. -The module also defines a mixin defining all dictionary methods for -classes that already have a minimum mapping interface. This greatly -simplifies writing classes that need to be substitutable for +The module defines a mixin, \class{DictMixin}, defining all dictionary +methods for classes that already have a minimum mapping interface. This +greatly simplifies writing classes that need to be substitutable for dictionaries (such as the shelve module). +This also module defines a class, \class{UserDict}, that acts as a wrapper +around dictionary objects. The need for this class has been largely +supplanted by the ability to subclass directly from \class{dict} (a feature +that became available starting with Python version 2.2). Prior to the +introduction of \class{dict}, the \class{UserDict} class was used to +create dictionary-like sub-classes that obtained new behaviors by overriding +existing methods or adding new ones. + The \module{UserDict} module defines the \class{UserDict} class and \class{DictMixin}: From rhettinger at users.sourceforge.net Tue Jan 4 22:28:54 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Jan 4 22:28:57 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libuserdict.tex, 1.24.4.1, 1.24.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22754 Modified Files: Tag: release24-maint libuserdict.tex Log Message: Clarify that DictMixin is still useful. Only the UserDict class was supplanted. Index: libuserdict.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libuserdict.tex,v retrieving revision 1.24.4.1 retrieving revision 1.24.4.2 diff -u -d -r1.24.4.1 -r1.24.4.2 --- libuserdict.tex 1 Jan 2005 00:34:53 -0000 1.24.4.1 +++ libuserdict.tex 4 Jan 2005 21:28:48 -0000 1.24.4.2 @@ -4,22 +4,20 @@ \declaremodule{standard}{UserDict} \modulesynopsis{Class wrapper for dictionary objects.} -\note{This module is available for backward compatibility only. If -you are writing code that does not need to work with versions of -Python earlier than Python 2.2, please consider subclassing directly -from the built-in \class{dict} type.} - -This module defines a class that acts as a wrapper around -dictionary objects. It is a useful base class for -your own dictionary-like classes, which can inherit from -them and override existing methods or add new ones. In this way one -can add new behaviors to dictionaries. -The module also defines a mixin defining all dictionary methods for -classes that already have a minimum mapping interface. This greatly -simplifies writing classes that need to be substitutable for +The module defines a mixin, \class{DictMixin}, defining all dictionary +methods for classes that already have a minimum mapping interface. This +greatly simplifies writing classes that need to be substitutable for dictionaries (such as the shelve module). +This also module defines a class, \class{UserDict}, that acts as a wrapper +around dictionary objects. The need for this class has been largely +supplanted by the ability to subclass directly from \class{dict} (a feature +that became available starting with Python version 2.2). Prior to the +introduction of \class{dict}, the \class{UserDict} class was used to +create dictionary-like sub-classes that obtained new behaviors by overriding +existing methods or adding new ones. + The \module{UserDict} module defines the \class{UserDict} class and \class{DictMixin}: From jafo at users.sourceforge.net Wed Jan 5 05:59:32 2005 From: jafo at users.sourceforge.net (jafo@users.sourceforge.net) Date: Wed Jan 5 05:59:37 2005 Subject: [Python-checkins] python/dist/src/Misc/RPM python-2.3.spec, 1.2.12.14, 1.2.12.15 Message-ID: Update of /cvsroot/python/python/dist/src/Misc/RPM In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11543/Misc/RPM Modified Files: Tag: release23-maint python-2.3.spec Log Message: Merging the current development changes for the idle wrapper. 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.14 retrieving revision 1.2.12.15 diff -u -d -r1.2.12.14 -r1.2.12.15 --- python-2.3.spec 26 Jul 2004 14:32:11 -0000 1.2.12.14 +++ python-2.3.spec 5 Jan 2005 04:59:29 -0000 1.2.12.15 @@ -35,7 +35,7 @@ %define name python %define version 2.3.4 %define libvers 2.3 -%define release 3pydotorg +%define release 4pydotorg %define __prefix /usr # kludge to get around rpm define weirdness @@ -131,6 +131,9 @@ %endif %changelog +* Tue Jan 04 2005 Sean Reifschneider [2.3.4-4pydotorg] +- Changing the idle wrapper so that it passes arguments to idle. + * Thu Jul 22 2004 Sean Reifschneider [2.3.4-3pydotorg] - Paul Tiemann fixes for %{prefix}. - Adding permission changes for directory as suggested by reimeika.ca @@ -254,8 +257,11 @@ ######## # Tools -echo '#!/bin/bash' >${RPM_BUILD_ROOT}%{__prefix}/bin/idle%{binsuffix} -echo 'exec %{__prefix}/bin/python%{binsuffix} %{__prefix}/%{libdirname}/python%{libvers}/idlelib/idle.py' >>$RPM_BUILD_ROOT%{__prefix}/bin/idle%{binsuffix} +echo '#!%{__prefix}/bin/env python%{binsuffix}' >${RPM_BUILD_ROOT}%{__prefix}/bin/idle%{binsuffix} +echo 'import os, sys' >>${RPM_BUILD_ROOT}%{__prefix}/bin/idle%{binsuffix} +echo 'os.execvp("%{__prefix}/bin/python%{binsuffix}", ["%{__prefix}/bin/python%{binsuffix}", "%{__prefix}/lib/python%{libvers}/idlelib/idle.py"] + sys.argv[1:])' >>${RPM_BUILD_ROOT}%{__prefix}/bin/idle%{binsuffix} +echo 'print "Failed to exec Idle"' >>${RPM_BUILD_ROOT}%{__prefix}/bin/idle%{binsuffix} +echo 'sys.exit(1)' >>${RPM_BUILD_ROOT}%{__prefix}/bin/idle%{binsuffix} chmod 755 $RPM_BUILD_ROOT%{__prefix}/bin/idle%{binsuffix} cp -a Tools $RPM_BUILD_ROOT%{__prefix}/%{libdirname}/python%{libvers} From montanaro at users.sourceforge.net Wed Jan 5 07:55:00 2005 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Wed Jan 5 07:55:03 2005 Subject: [Python-checkins] python/dist/src/Lib csv.py,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31929 Modified Files: csv.py Log Message: add a couple missing docstrings Index: csv.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/csv.py,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- csv.py 3 Oct 2003 14:03:01 -0000 1.10 +++ csv.py 5 Jan 2005 06:54:58 -0000 1.11 @@ -20,6 +20,13 @@ "unregister_dialect", "__version__", "DictReader", "DictWriter" ] class Dialect: + """Describe an Excel dialect. + + This must be subclassed (see csv.excel). Valid attributes are: + delimiter, quotechar, escapechar, doublequote, skipinitialspace, + lineterminator, quoting. + + """ _name = "" _valid = False # placeholders @@ -78,6 +85,7 @@ return errors class excel(Dialect): + """Describe the usual properties of Excel-generated CSV files.""" delimiter = ',' quotechar = '"' doublequote = True @@ -87,6 +95,7 @@ register_dialect("excel", excel) class excel_tab(excel): + """Describe the usual properties of Excel-generated TAB-delimited files.""" delimiter = '\t' register_dialect("excel-tab", excel_tab) From montanaro at users.sourceforge.net Wed Jan 5 07:58:17 2005 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Wed Jan 5 07:58:20 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libcsv.tex,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32570 Modified Files: libcsv.tex Log Message: add a couple missing items Index: libcsv.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcsv.tex,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- libcsv.tex 7 Aug 2004 15:11:24 -0000 1.16 +++ libcsv.tex 5 Jan 2005 06:58:15 -0000 1.17 @@ -170,6 +170,16 @@ \class{reader} or \class{writer} instance. \end{classdesc*} +\begin{classdesc}{excel}{} +The \class{excel} class defines the usual properties of an Excel-generated +CSV file. +\end{classdesc} + +\begin{classdesc}{excel_tab}{} +The \class{excel_tab} class defines the usual properties of an +Excel-generated TAB-delimited file. +\end{classdesc} + \begin{classdesc}{Sniffer}{} The \class{Sniffer} class is used to deduce the format of a CSV file. \end{classdesc} From montanaro at users.sourceforge.net Wed Jan 5 08:03:56 2005 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Wed Jan 5 08:03:58 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libdircache.tex,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1192 Modified Files: libdircache.tex Log Message: describe reset() Index: libdircache.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdircache.tex,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- libdircache.tex 31 Dec 2003 07:41:52 -0000 1.5 +++ libdircache.tex 5 Jan 2005 07:03:53 -0000 1.6 @@ -12,6 +12,10 @@ The \module{dircache} module defines the following functions: +\begin{funcdesc}{reset}{} +Resets the directory cache. +\end{funcdesc} + \begin{funcdesc}{listdir}{path} Return a directory listing of \var{path}, as gotten from \function{os.listdir()}. Note that unless \var{path} changes, further call From montanaro at users.sourceforge.net Wed Jan 5 08:13:34 2005 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Wed Jan 5 08:13:37 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libcalendar.tex, 1.19, 1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2785 Modified Files: libcalendar.tex Log Message: add descriptions of exported data attributes Index: libcalendar.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcalendar.tex,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- libcalendar.tex 6 Dec 2004 07:58:14 -0000 1.19 +++ libcalendar.tex 5 Jan 2005 07:13:32 -0000 1.20 @@ -112,6 +112,31 @@ \versionadded{2.0} \end{funcdesc} +The \module{calendar} module exports the following data attributes: + +\begin{datadesc}{day_name} +An array that represents the days of the week in the +current locale. +\end{datadesc} + +\begin{datadesc}{day_abbr} +An array that represents the abbreviated days of the week +in the current locale. +\end{datadesc} + +\begin{datadesc}{month_name} +An array that represents the months of the year in the +current locale. This follows normal convention +of January being month number 1, so it has a length of 13 and +\code{month_name[0]} is the empty string. +\end{datadesc} + +\begin{datadesc}{month_abbr} +An array that represents the abbreviated months of the year +in the current locale. This follows normal convention +of January being month number 1, so it has a length of 13 and +\code{month_abbr[0]} is the empty string. +\end{datadesc} \begin{seealso} \seemodule{datetime}{Object-oriented interface to dates and times From montanaro at users.sourceforge.net Wed Jan 5 08:19:13 2005 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Wed Jan 5 08:19:16 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libdis.tex,1.41,1.42 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3602 Modified Files: libdis.tex Log Message: add two missing items Index: libdis.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdis.tex,v retrieving revision 1.41 retrieving revision 1.42 diff -u -d -r1.41 -r1.42 --- libdis.tex 10 May 2003 08:51:26 -0000 1.41 +++ libdis.tex 5 Jan 2005 07:19:11 -0000 1.42 @@ -78,6 +78,10 @@ Sequence of operation names, indexable using the byte code. \end{datadesc} +\begin{datadesc}{opmap} +Dictionary mapping byte codes to operation names. +\end{datadesc} + \begin{datadesc}{cmp_op} Sequence of all compare operation names. \end{datadesc} @@ -688,3 +692,9 @@ keyword arguments dictionary, followed by the variable-arguments tuple, followed by explicit keyword and positional arguments. \end{opcodedesc} + +\begin{opcodedesc}{HAVE_ARGUMENT}{} +This is not really an opcode. It identifies the dividing line between +opcodes which don't take arguments \code{< HAVE_ARGUMENT} and those which do +\code{>= HAVE_ARGUMENT}. +\end{opcodedesc} From jafo at users.sourceforge.net Wed Jan 5 16:53:57 2005 From: jafo at users.sourceforge.net (jafo@users.sourceforge.net) Date: Wed Jan 5 16:54:01 2005 Subject: [Python-checkins] python/dist/src/Misc/RPM python-2.4.spec, 1.8, 1.8.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Misc/RPM In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12059 Modified Files: Tag: release24-maint python-2.4.spec Log Message: Updating the Idle wrapper to match the current CVS copy. Index: python-2.4.spec =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/RPM/python-2.4.spec,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -u -d -r1.8 -r1.8.2.1 --- python-2.4.spec 29 Nov 2004 01:40:31 -0000 1.8 +++ python-2.4.spec 5 Jan 2005 15:53:54 -0000 1.8.2.1 @@ -35,7 +35,7 @@ %define name python %define version 2.4 %define libvers 2.4 -%define release 1pydotorg +%define release 3pydotorg %define __prefix /usr # kludge to get around rpm define weirdness @@ -131,6 +131,9 @@ %endif %changelog +* Wed Jan 05 2004 Sean Reifschneider [2.4-3pydotorg] +- Changing the idle wrapper so that it passes arguments to idle. + * Tue Oct 19 2004 Sean Reifschneider [2.4b1-1pydotorg] - Updating to 2.4. @@ -257,8 +260,11 @@ ######## # Tools -echo '#!/bin/bash' >${RPM_BUILD_ROOT}%{__prefix}/bin/idle%{binsuffix} -echo 'exec %{__prefix}/bin/python%{binsuffix} %{__prefix}/%{libdirname}/python%{libvers}/idlelib/idle.py' >>$RPM_BUILD_ROOT%{__prefix}/bin/idle%{binsuffix} +echo '#!%{__prefix}/bin/env python%{binsuffix}' >${RPM_BUILD_ROOT}%{__prefix}/bin/idle%{binsuffix} +echo 'import os, sys' >>${RPM_BUILD_ROOT}%{__prefix}/bin/idle%{binsuffix} +echo 'os.execvp("%{__prefix}/bin/python%{binsuffix}", ["%{__prefix}/bin/python%{binsuffix}", "%{__prefix}/lib/python%{libvers}/idlelib/idle.py"] + sys.argv[1:])' >>${RPM_BUILD_ROOT}%{__prefix}/bin/idle%{binsuffix} +echo 'print "Failed to exec Idle"' >>${RPM_BUILD_ROOT}%{__prefix}/bin/idle%{binsuffix} +echo 'sys.exit(1)' >>${RPM_BUILD_ROOT}%{__prefix}/bin/idle%{binsuffix} chmod 755 $RPM_BUILD_ROOT%{__prefix}/bin/idle%{binsuffix} cp -a Tools $RPM_BUILD_ROOT%{__prefix}/%{libdirname}/python%{libvers} From andrewmcnamara at users.sourceforge.net Thu Jan 6 03:25:43 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Thu Jan 6 03:25:46 2005 Subject: [Python-checkins] python/dist/src/Modules _csv.c,1.15,1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5675 Modified Files: _csv.c Log Message: Delete Reader_getiter and replace with PyObject_SelfIter. Index: _csv.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_csv.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- _csv.c 15 Aug 2004 12:23:10 -0000 1.15 +++ _csv.c 6 Jan 2005 02:25:41 -0000 1.16 @@ -642,13 +642,6 @@ }; static PyObject * -Reader_getiter(ReaderObj *self) -{ - Py_INCREF(self); - return (PyObject *)self; -} - -static PyObject * Reader_iternext(ReaderObj *self) { PyObject *lineobj; @@ -814,7 +807,7 @@ (inquiry)Reader_clear, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ - (getiterfunc)Reader_getiter, /*tp_iter*/ + PyObject_SelfIter, /*tp_iter*/ (getiterfunc)Reader_iternext, /*tp_iternext*/ Reader_methods, /*tp_methods*/ Reader_memberlist, /*tp_members*/ From admin at waaini.com Thu Jan 6 17:07:40 2005 From: admin at waaini.com (Anna) Date: Thu Jan 6 17:21:14 2005 Subject: [Python-checkins] Please read this message thanks Message-ID: <20050106162112.ED7291E4005@bag.python.org> View on the link you like Age group 18 ~ 29 For viewing age group above 29 and Boyfriends view more listings after enter Other Countries contains adult material United States contains adult material Russia contains adult material Thailand contains adult material China contains adult material Japan contains adult material NOTE: If you do not want to receive email from us, be understanding simply use the block email function in your email provider alternatively you could reply with the subject DELIST DATABASE to admin@waaini.com and your email address will be deleted from our database. Amazing Category FREE FREE FREE things TO MAN ONLY TO WOMAN ONLY HOW TO MAKE $MONEY$ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-checkins/attachments/20050107/002ca8e1/attachment.html From jackjansen at users.sourceforge.net Thu Jan 6 23:33:58 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Thu Jan 6 23:34:01 2005 Subject: [Python-checkins] python/dist/src/Mac/OSX fixapplepython23.py, NONE, 1.3.4.1 Makefile, 1.54.4.1, 1.54.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2094 Modified Files: Tag: release24-maint Makefile Added Files: Tag: release24-maint fixapplepython23.py Log Message: Backported from the trunk: - When doing a frameworkinstall test whether Apple's Python 2.3 may need fixing - Added quotes around destroot arguments. --- NEW FILE: fixapplepython23.py --- """fixapplepython23 - Fix Apple-installed Python 2.3 (on Mac OS X 10.3) Python 2.3 (and 2.3.X for X<5) have the problem that building an extension for a framework installation may accidentally pick up the framework of a newer Python, in stead of the one that was used to build the extension. This script modifies the Makefile (in .../lib/python2.3/config) to use the newer method of linking extensions with "-undefined dynamic_lookup" which fixes this problem. The script will first check all prerequisites, and return a zero exit status also when nothing needs to be fixed. """ import sys import os import gestalt MAKEFILE='/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/Makefile' CHANGES=(( 'LDSHARED=\t$(CC) $(LDFLAGS) -bundle -framework $(PYTHONFRAMEWORK)\n', 'LDSHARED=\t$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup\n' ),( 'BLDSHARED=\t$(CC) $(LDFLAGS) -bundle -framework $(PYTHONFRAMEWORK)\n', 'BLDSHARED=\t$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup\n' ),( 'CC=\t\tgcc\n', 'CC=\t\t/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/PantherPythonFix/run-gcc\n' ),( 'CXX=\t\tc++\n', 'CXX=\t\t/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/PantherPythonFix/run-g++\n' )) GCC_SCRIPT='/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/PantherPythonFix/run-gcc' GXX_SCRIPT='/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/PantherPythonFix/run-g++' SCRIPT="""#!/bin/sh export MACOSX_DEPLOYMENT_TARGET=10.3 exec %s "${@}" """ def findline(lines, start): """return line starting with given string or -1""" for i in range(len(lines)): if lines[i][:len(start)] == start: return i return -1 def fix(makefile, do_apply): """Fix the Makefile, if required.""" fixed = False lines = open(makefile).readlines() for old, new in CHANGES: i = findline(lines, new) if i >= 0: # Already fixed continue i = findline(lines, old) if i < 0: print 'fixapplepython23: Python installation not fixed (appears broken)' print 'fixapplepython23: missing line:', old return 2 lines[i] = new fixed = True if fixed: if do_apply: print 'fixapplepython23: Fix to Apple-installed Python 2.3 applied' os.rename(makefile, makefile + '~') open(makefile, 'w').writelines(lines) return 0 else: print 'fixapplepython23: Fix to Apple-installed Python 2.3 should be applied' return 1 else: print 'fixapplepython23: No fix needed, appears to have been applied before' return 0 def makescript(filename, compiler): """Create a wrapper script for a compiler""" dirname = os.path.split(filename)[0] if not os.access(dirname, os.X_OK): os.mkdir(dirname, 0755) fp = open(filename, 'w') fp.write(SCRIPT % compiler) fp.close() os.chmod(filename, 0755) print 'fixapplepython23: Created', filename def main(): # Check for -n option if len(sys.argv) > 1 and sys.argv[1] == '-n': do_apply = False else: do_apply = True # First check OS version if gestalt.gestalt('sysv') < 0x1030: print 'fixapplepython23: no fix needed on MacOSX < 10.3' sys.exit(0) # Test that a framework Python is indeed installed if not os.path.exists(MAKEFILE): print 'fixapplepython23: Python framework does not appear to be installed (?), nothing fixed' sys.exit(0) # Check that we can actually write the file if do_apply and not os.access(MAKEFILE, os.W_OK): print 'fixapplepython23: No write permission, please run with "sudo"' sys.exit(2) # Create the shell scripts if do_apply: if not os.access(GCC_SCRIPT, os.X_OK): makescript(GCC_SCRIPT, "gcc") if not os.access(GXX_SCRIPT, os.X_OK): makescript(GXX_SCRIPT, "g++") # Finally fix the makefile rv = fix(MAKEFILE, do_apply) sys.exit(rv) if __name__ == '__main__': main() Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/Makefile,v retrieving revision 1.54.4.1 retrieving revision 1.54.4.2 diff -u -d -r1.54.4.1 -r1.54.4.2 --- Makefile 31 Dec 2004 11:23:20 -0000 1.54.4.1 +++ Makefile 6 Jan 2005 22:33:55 -0000 1.54.4.2 @@ -2,7 +2,7 @@ # main Makefile. The next couple of variables are overridden on the # commandline in that case. -VERSION=2.5 +VERSION=2.4 builddir = ../.. srcdir = ../.. prefix=/Library/Frameworks/Python.framework/Versions/$(VERSION) @@ -60,7 +60,7 @@ bundlebuilder=$(srcdir)/Lib/plat-mac/bundlebuilder.py installapps: install_PythonLauncher install_Python install_BuildApplet install_IDE \ - install_IDLE install_PackageManager + install_IDLE install_PackageManager checkapplepython install_PythonLauncher: cd $(srcdir)/Mac/OSX/PythonLauncher/PythonLauncher.pbproj ; \ @@ -120,12 +120,12 @@ echo See Mac/OSX/README for details; \ else \ echo $(BUILDPYTHON) $(srcdir)/Mac/scripts/BuildApplet.py \ - --destroot $(DESTDIR) \ + --destroot "$(DESTDIR)" \ --python $(INSTALLED_PYTHONW) \ --output $(DESTDIR)$(PYTHONAPPSDIR)/PythonIDE.app --noargv \ $(srcdir)/Mac/Tools/IDE/PythonIDE.py ; \ $(BUILDPYTHON) $(srcdir)/Mac/scripts/BuildApplet.py \ - --destroot $(DESTDIR) \ + --destroot "$(DESTDIR)" \ --python $(INSTALLED_PYTHONW) \ --output $(DESTDIR)$(PYTHONAPPSDIR)/PythonIDE.app --noargv \ $(srcdir)/Mac/Tools/IDE/PythonIDE.py; \ @@ -138,7 +138,7 @@ else \ echo $(BUILDPYTHON) $(bundlebuilder) \ --builddir $(DESTDIR)$(PYTHONAPPSDIR)/ \ - --destroot $(DESTDIR) \ + --destroot "$(DESTDIR)" \ --python $(INSTALLED_PYTHONW) \ --resource $(srcdir)/Mac/Tools/IDE/PythonIDE.rsrc \ --mainprogram $(srcdir)/Mac/Tools/IDE/PackageManager.py \ @@ -146,7 +146,7 @@ --creator Pimp build; \ $(BUILDPYTHON) $(bundlebuilder) \ --builddir $(DESTDIR)$(PYTHONAPPSDIR)/ \ - --destroot $(DESTDIR) \ + --destroot "$(DESTDIR)" \ --python $(INSTALLED_PYTHONW) \ --resource $(srcdir)/Mac/Tools/IDE/PythonIDE.rsrc \ --mainprogram $(srcdir)/Mac/Tools/IDE/PackageManager.py \ @@ -161,13 +161,13 @@ else \ echo $(BUILDPYTHON) $(srcdir)/Mac/scripts/BuildApplet.py \ --python $(INSTALLED_PYTHONW) \ - --destroot $(DESTDIR) \ + --destroot "$(DESTDIR)" \ --output $(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app \ --extra $(srcdir)/Lib/idlelib \ $(srcdir)/Tools/scripts/idle ; \ $(BUILDPYTHON) $(srcdir)/Mac/scripts/BuildApplet.py \ --python $(INSTALLED_PYTHONW) \ - --destroot $(DESTDIR) \ + --destroot "$(DESTDIR)" \ --output $(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app \ --extra $(srcdir)/Lib/idlelib:Contents/Resources/idlelib \ $(srcdir)/Tools/scripts/idle ; \ @@ -176,7 +176,7 @@ install_BuildApplet: $(BUILDPYTHON) $(srcdir)/Mac/scripts/BuildApplet.py \ - --destroot $(DESTDIR) \ + --destroot "$(DESTDIR)" \ --python $(INSTALLED_PYTHONW) \ --output $(DESTDIR)$(PYTHONAPPSDIR)/BuildApplet.app \ $(srcdir)/Mac/scripts/BuildApplet.py @@ -264,3 +264,10 @@ $(DESTDIR)$(PYTHONAPPSDIR)/Extras/Demo $(BUILDPYTHON) $(srcdir)/Mac/OSX/Extras.install.py $(srcdir)/Tools \ $(DESTDIR)$(PYTHONAPPSDIR)/Extras/Tools + +checkapplepython: + @if ! $(BUILDPYTHON) $(srcdir)/Mac/OSX/fixapplepython23.py -n; then \ + echo "* WARNING: Apple-installed Python 2.3 will have trouble building extensions from now on."; \ + echo "* WARNING: Run $(srcdir)/Mac/OSX/fixapplepython23.py with \"sudo\" to fix this."; \ + fi + From jackjansen at users.sourceforge.net Fri Jan 7 00:16:17 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Fri Jan 7 00:16:21 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils sysconfig.py, 1.61, 1.61.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15114/Lib/distutils Modified Files: Tag: release24-maint sysconfig.py Log Message: Backported from the trunk: After discussion on the PythonMac-SIG it was decided that it is better to make using "-undefined dynamic_lookup" for linking extensions more automatic on 10.3 and later. So if we're on that platform and MACOSX_DEPLOYMENT_TARGET is not set we now set it to the current OSX version during configure. Additionally, distutils will pick up the configure-time value by default. Index: sysconfig.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/sysconfig.py,v retrieving revision 1.61 retrieving revision 1.61.2.1 diff -u -d -r1.61 -r1.61.2.1 --- sysconfig.py 13 Oct 2004 15:54:16 -0000 1.61 +++ sysconfig.py 6 Jan 2005 23:16:03 -0000 1.61.2.1 @@ -360,11 +360,13 @@ # On MacOSX we need to check the setting of the environment variable # MACOSX_DEPLOYMENT_TARGET: configure bases some choices on it so # it needs to be compatible. - # An alternative would be to force MACOSX_DEPLOYMENT_TARGET to be - # the same as during configure. + # If it isn't set we set it to the configure-time value if sys.platform == 'darwin' and g.has_key('CONFIGURE_MACOSX_DEPLOYMENT_TARGET'): cfg_target = g['CONFIGURE_MACOSX_DEPLOYMENT_TARGET'] cur_target = os.getenv('MACOSX_DEPLOYMENT_TARGET', '') + if cur_target == '': + cur_target = cfg_target + os.putenv('MACOSX_DEPLOYMENT_TARGET', cfg_target) if cfg_target != cur_target: my_msg = ('$MACOSX_DEPLOYMENT_TARGET mismatch: now "%s" but "%s" during configure' % (cur_target, cfg_target)) From jackjansen at users.sourceforge.net Fri Jan 7 00:16:18 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Fri Jan 7 00:16:21 2005 Subject: [Python-checkins] python/dist/src configure, 1.462.2.2, 1.462.2.3 configure.in, 1.475.2.2, 1.475.2.3 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15114 Modified Files: Tag: release24-maint configure configure.in Log Message: Backported from the trunk: After discussion on the PythonMac-SIG it was decided that it is better to make using "-undefined dynamic_lookup" for linking extensions more automatic on 10.3 and later. So if we're on that platform and MACOSX_DEPLOYMENT_TARGET is not set we now set it to the current OSX version during configure. Additionally, distutils will pick up the configure-time value by default. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.462.2.2 retrieving revision 1.462.2.3 diff -u -d -r1.462.2.2 -r1.462.2.3 --- configure 24 Dec 2004 08:24:21 -0000 1.462.2.2 +++ configure 6 Jan 2005 23:15:05 -0000 1.462.2.3 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 1.475 . +# From configure.in Revision: 1.475.2.2 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59 for python 2.4. # @@ -10322,11 +10322,12 @@ Darwin/*) # Use -undefined dynamic_lookup whenever possible (10.3 and later). # This allows an extension to be used in any Python - if test ${MACOSX_DEPLOYMENT_TARGET-10.1} '>' 10.2 + cur_target=`sw_vers -productVersion | sed 's/\(10\.[0-9]*\).*/\1/'` + if test ${MACOSX_DEPLOYMENT_TARGET-${cur_target}} '>' 10.2 then LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup' BLDSHARED="$LDSHARED" - CONFIGURE_MACOSX_DEPLOYMENT_TARGET=$MACOSX_DEPLOYMENT_TARGET + CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}} else LDSHARED='$(CC) $(LDFLAGS) -bundle' if test "$enable_framework" ; then Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.475.2.2 retrieving revision 1.475.2.3 diff -u -d -r1.475.2.2 -r1.475.2.3 --- configure.in 24 Dec 2004 08:24:05 -0000 1.475.2.2 +++ configure.in 6 Jan 2005 23:16:01 -0000 1.475.2.3 @@ -1324,11 +1324,12 @@ Darwin/*) # Use -undefined dynamic_lookup whenever possible (10.3 and later). # This allows an extension to be used in any Python - if test ${MACOSX_DEPLOYMENT_TARGET-10.1} '>' 10.2 + cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'` + if test ${MACOSX_DEPLOYMENT_TARGET-${cur_target}} '>' 10.2 then LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup' BLDSHARED="$LDSHARED" - CONFIGURE_MACOSX_DEPLOYMENT_TARGET=$MACOSX_DEPLOYMENT_TARGET + CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}} else LDSHARED='$(CC) $(LDFLAGS) -bundle' if test "$enable_framework" ; then From rhettinger at users.sourceforge.net Fri Jan 7 01:49:20 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jan 7 01:49:23 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libgc.tex,1.15,1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6014 Modified Files: libgc.tex Log Message: SF bug #1091740: garbage collector still documented as optional Index: libgc.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libgc.tex,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- libgc.tex 28 Oct 2003 12:10:38 -0000 1.15 +++ libgc.tex 7 Jan 2005 00:49:17 -0000 1.16 @@ -6,11 +6,6 @@ \moduleauthor{Neil Schemenauer}{nas@arctrix.com} \sectionauthor{Neil Schemenauer}{nas@arctrix.com} -The \module{gc} module is only available if the interpreter was built -with the optional cyclic garbage detector (enabled by default). If -this was not enabled, an \exception{ImportError} is raised by attempts -to import this module. - This module provides an interface to the optional garbage collector. It provides the ability to disable the collector, tune the collection frequency, and set debugging options. It also provides access to From rhettinger at users.sourceforge.net Fri Jan 7 01:51:09 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jan 7 01:51:10 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libgc.tex,1.15,1.15.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6664 Modified Files: Tag: release24-maint libgc.tex Log Message: SF bug #1091740: garbage collector still documented as optional Index: libgc.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libgc.tex,v retrieving revision 1.15 retrieving revision 1.15.4.1 diff -u -d -r1.15 -r1.15.4.1 --- libgc.tex 28 Oct 2003 12:10:38 -0000 1.15 +++ libgc.tex 7 Jan 2005 00:51:02 -0000 1.15.4.1 @@ -6,11 +6,6 @@ \moduleauthor{Neil Schemenauer}{nas@arctrix.com} \sectionauthor{Neil Schemenauer}{nas@arctrix.com} -The \module{gc} module is only available if the interpreter was built -with the optional cyclic garbage detector (enabled by default). If -this was not enabled, an \exception{ImportError} is raised by attempts -to import this module. - This module provides an interface to the optional garbage collector. It provides the ability to disable the collector, tune the collection frequency, and set debugging options. It also provides access to From facundobatista at users.sourceforge.net Fri Jan 7 03:50:25 2005 From: facundobatista at users.sourceforge.net (facundobatista@users.sourceforge.net) Date: Fri Jan 7 03:50:29 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libos.tex,1.147,1.148 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3037 Modified Files: libos.tex Log Message: Added example to os.stat() Index: libos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.147 retrieving revision 1.148 diff -u -d -r1.147 -r1.148 --- libos.tex 15 Dec 2004 23:44:18 -0000 1.147 +++ libos.tex 7 Jan 2005 02:50:22 -0000 1.148 @@ -931,7 +931,17 @@ \member{st_mtime} (time of most recent content modification), \member{st_ctime} (platform dependent; time of most recent metadata change on \UNIX, or -the time of creation on Windows). +the time of creation on Windows): + +\begin{verbatim} +>>> import os +>>> statinfo = os.stat('somefile.txt') +>>> statinfo +(33188, 422511L, 769L, 1, 1032, 100, 926L, 1105022698,1105022732, 1105022732) +>>> statinfo.st_size +926L +>>> +\end{verbatim} \versionchanged [If \function{stat_float_times} returns true, the time values are floats, measuring seconds. Fractions of a second may be From rhettinger at users.sourceforge.net Fri Jan 7 05:33:46 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jan 7 05:33:49 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libfuncs.tex,1.178,1.179 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23705 Modified Files: libfuncs.tex Log Message: SF patch 1094011: Docs for file() vs open(). Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.178 retrieving revision 1.179 diff -u -d -r1.178 -r1.179 --- libfuncs.tex 1 Jan 2005 00:28:37 -0000 1.178 +++ libfuncs.tex 7 Jan 2005 04:33:44 -0000 1.179 @@ -416,9 +416,12 @@ after any I/O has been performed, and there's no reliable way to determine whether this is the case.} - The \function{file()} constructor is new in Python 2.2. The previous - spelling, \function{open()}, is retained for compatibility, and is an - alias for \function{file()}. + The \function{file()} constructor is new in Python 2.2 and is an + alias for \function{open()}. Both spellings are equivalent. The + intent is for \function{open()} to continue to be preferred for use + as a factory function which returns a new \class{file} object. The + spelling, \class{file} is more suited to type testing (for example, + writing \samp{isinstance(f, file)}). \end{funcdesc} \begin{funcdesc}{filter}{function, list} From rhettinger at users.sourceforge.net Fri Jan 7 05:35:11 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jan 7 05:35:14 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libfuncs.tex, 1.175.2.1, 1.175.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24014 Modified Files: Tag: release24-maint libfuncs.tex Log Message: SF patch 1094011: Docs for file() vs open(). Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.175.2.1 retrieving revision 1.175.2.2 diff -u -d -r1.175.2.1 -r1.175.2.2 --- libfuncs.tex 1 Jan 2005 00:34:53 -0000 1.175.2.1 +++ libfuncs.tex 7 Jan 2005 04:35:08 -0000 1.175.2.2 @@ -416,9 +416,12 @@ after any I/O has been performed, and there's no reliable way to determine whether this is the case.} - The \function{file()} constructor is new in Python 2.2. The previous - spelling, \function{open()}, is retained for compatibility, and is an - alias for \function{file()}. + The \function{file()} constructor is new in Python 2.2 and is an + alias for \function{open()}. Both spellings are equivalent. The + intent is for \function{open()} to continue to be preferred for use + as a factory function which returns a new \class{file} object. The + spelling, \class{file} is more suited to type testing (for example, + writing \samp{isinstance(f, file)}). \end{funcdesc} \begin{funcdesc}{filter}{function, list} From andrewmcnamara at users.sourceforge.net Fri Jan 7 05:42:47 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Fri Jan 7 05:42:52 2005 Subject: [Python-checkins] python/dist/src/Modules _csv.c,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25171/Modules Modified Files: _csv.c Log Message: Improved the implementation of the internal "dialect" type. The new implementation features better error reporting, and better compliance with the PEP. Index: _csv.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_csv.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- _csv.c 6 Jan 2005 02:25:41 -0000 1.16 +++ _csv.c 7 Jan 2005 04:42:41 -0000 1.17 @@ -73,7 +73,7 @@ char escapechar; /* escape character */ int skipinitialspace; /* ignore spaces following delimiter? */ PyObject *lineterminator; /* string to write between records */ - QuoteStyle quoting; /* style of quoting to write */ + int quoting; /* style of quoting to write */ int strict; /* raise exception on bad CSV */ } DialectObj; @@ -130,17 +130,6 @@ return dialect_obj; } -static int -check_delattr(PyObject *v) -{ - if (v == NULL) { - PyErr_SetString(PyExc_TypeError, - "Cannot delete attribute"); - return -1; - } - return 0; -} - static PyObject * get_string(PyObject *str) { @@ -148,25 +137,6 @@ return str; } -static int -set_string(PyObject **str, PyObject *v) -{ - if (check_delattr(v) < 0) - return -1; - if (!PyString_Check(v) -#ifdef Py_USING_UNICODE -&& !PyUnicode_Check(v) -#endif -) { - PyErr_BadArgument(); - return -1; - } - Py_XDECREF(*str); - Py_INCREF(v); - *str = v; - return 0; -} - static PyObject * get_nullchar_as_None(char c) { @@ -178,48 +148,22 @@ return PyString_FromStringAndSize((char*)&c, 1); } -static int -set_None_as_nullchar(char * addr, PyObject *v) -{ - if (check_delattr(v) < 0) - return -1; - if (v == Py_None) - *addr = '\0'; - else if (!PyString_Check(v) || PyString_Size(v) != 1) { - PyErr_BadArgument(); - return -1; - } - else { - char *s = PyString_AsString(v); - if (s == NULL) - return -1; - *addr = s[0]; - } - return 0; -} - static PyObject * Dialect_get_lineterminator(DialectObj *self) { return get_string(self->lineterminator); } -static int -Dialect_set_lineterminator(DialectObj *self, PyObject *value) -{ - return set_string(&self->lineterminator, value); -} - static PyObject * Dialect_get_escapechar(DialectObj *self) { return get_nullchar_as_None(self->escapechar); } -static int -Dialect_set_escapechar(DialectObj *self, PyObject *value) +static PyObject * +Dialect_get_quotechar(DialectObj *self) { - return set_None_as_nullchar(&self->escapechar, value); + return get_nullchar_as_None(self->quotechar); } static PyObject * @@ -229,51 +173,109 @@ } static int -Dialect_set_quoting(DialectObj *self, PyObject *v) +_set_bool(const char *name, int *target, PyObject *src, int dflt) +{ + if (src == NULL) + *target = dflt; + else + *target = PyObject_IsTrue(src); + return 0; +} + +static int +_set_int(const char *name, int *target, PyObject *src, int dflt) +{ + if (src == NULL) + *target = dflt; + else { + if (!PyInt_Check(src)) { + PyErr_Format(PyExc_TypeError, + "\"%s\" must be an integer", name); + return -1; + } + *target = PyInt_AsLong(src); + } + return 0; +} + +static int +_set_char(const char *name, char *target, PyObject *src, char dflt) +{ + if (src == NULL) + *target = dflt; + else { + if (src == Py_None) + *target = '\0'; + else if (!PyString_Check(src) || PyString_Size(src) != 1) { + PyErr_Format(PyExc_TypeError, + "\"%s\" must be an 1-character string", + name); + return -1; + } + else { + char *s = PyString_AsString(src); + if (s == NULL) + return -1; + *target = s[0]; + } + } + return 0; +} + +static int +_set_str(const char *name, PyObject **target, PyObject *src, const char *dflt) +{ + if (src == NULL) + *target = PyString_FromString(dflt); + else { + if (src == Py_None) + *target = NULL; + else if (!PyString_Check(src) +#ifdef Py_USING_UNICODE + && !PyUnicode_Check(src) +#endif + ) { + PyErr_Format(PyExc_TypeError, + "\"%s\" must be an string", name); + return -1; + } else { + Py_XDECREF(*target); + Py_INCREF(src); + *target = src; + } + } + return 0; +} + +static int +dialect_check_quoting(int quoting) { - int quoting; StyleDesc *qs = quote_styles; - if (check_delattr(v) < 0) - return -1; - if (!PyInt_Check(v)) { - PyErr_BadArgument(); - return -1; - } - quoting = PyInt_AsLong(v); for (qs = quote_styles; qs->name; qs++) { - if (qs->style == quoting) { - self->quoting = quoting; + if (qs->style == quoting) return 0; - } } - PyErr_BadArgument(); + PyErr_Format(PyExc_TypeError, "bad \"quoting\" value"); return -1; } -static struct PyMethodDef Dialect_methods[] = { - { NULL, NULL } -}; - #define D_OFF(x) offsetof(DialectObj, x) static struct PyMemberDef Dialect_memberlist[] = { - { "quotechar", T_CHAR, D_OFF(quotechar) }, - { "delimiter", T_CHAR, D_OFF(delimiter) }, - { "skipinitialspace", T_INT, D_OFF(skipinitialspace) }, - { "doublequote", T_INT, D_OFF(doublequote) }, - { "strict", T_INT, D_OFF(strict) }, + { "delimiter", T_CHAR, D_OFF(delimiter), READONLY }, + { "skipinitialspace", T_INT, D_OFF(skipinitialspace), READONLY }, + { "doublequote", T_INT, D_OFF(doublequote), READONLY }, + { "strict", T_INT, D_OFF(strict), READONLY }, { NULL } }; static PyGetSetDef Dialect_getsetlist[] = { - { "escapechar", (getter)Dialect_get_escapechar, - (setter)Dialect_set_escapechar }, - { "lineterminator", (getter)Dialect_get_lineterminator, - (setter)Dialect_set_lineterminator }, - { "quoting", (getter)Dialect_get_quoting, - (setter)Dialect_set_quoting }, - {NULL}, + { "escapechar", (getter)Dialect_get_escapechar}, + { "lineterminator", (getter)Dialect_get_lineterminator}, + { "quotechar", (getter)Dialect_get_quotechar}, + { "quoting", (getter)Dialect_get_quoting}, + {NULL}, }; static void @@ -283,107 +285,155 @@ self->ob_type->tp_free((PyObject *)self); } +/* + * Return a new reference to a dialect instance + * + * If given a string, looks up the name in our dialect registry + * If given a class, instantiate (which runs python validity checks) + * If given an instance, return a new reference to the instance + */ +static PyObject * +dialect_instantiate(PyObject *dialect) +{ + Py_INCREF(dialect); + /* If dialect is a string, look it up in our registry */ + if (PyString_Check(dialect) +#ifdef Py_USING_UNICODE + || PyUnicode_Check(dialect) +#endif + ) { + PyObject * new_dia; + new_dia = get_dialect_from_registry(dialect); + Py_DECREF(dialect); + return new_dia; + } + /* A class rather than an instance? Instantiate */ + if (PyObject_TypeCheck(dialect, &PyClass_Type)) { + PyObject * new_dia; + new_dia = PyObject_CallFunction(dialect, ""); + Py_DECREF(dialect); + return new_dia; + } + /* Make sure we finally have an instance */ + if (!PyInstance_Check(dialect)) { + PyErr_SetString(PyExc_TypeError, "dialect must be an instance"); + Py_DECREF(dialect); + return NULL; + } + return dialect; +} + +static char *dialect_kws[] = { + "dialect", + "delimiter", + "doublequote", + "escapechar", + "lineterminator", + "quotechar", + "quoting", + "skipinitialspace", + "strict", + NULL +}; + static int dialect_init(DialectObj * self, PyObject * args, PyObject * kwargs) { - PyObject *dialect = NULL, *name_obj, *value_obj; + int ret = -1; + PyObject *dialect = NULL; + PyObject *delimiter = NULL; + PyObject *doublequote = NULL; + PyObject *escapechar = NULL; + PyObject *lineterminator = NULL; + PyObject *quotechar = NULL; + PyObject *quoting = NULL; + PyObject *skipinitialspace = NULL; + PyObject *strict = NULL; - self->quotechar = '"'; - self->delimiter = ','; - self->escapechar = '\0'; - self->skipinitialspace = 0; - Py_XDECREF(self->lineterminator); - self->lineterminator = PyString_FromString("\r\n"); - if (self->lineterminator == NULL) + if (!PyArg_ParseTupleAndKeywords(args, kwargs, + "|OOOOOOOOO", dialect_kws, + &dialect, + &delimiter, + &doublequote, + &escapechar, + &lineterminator, + "echar, + "ing, + &skipinitialspace, + &strict)) return -1; - self->quoting = QUOTE_MINIMAL; - self->doublequote = 1; - self->strict = 0; - if (!PyArg_UnpackTuple(args, "", 0, 1, &dialect)) - return -1; - Py_XINCREF(dialect); - if (kwargs != NULL) { - PyObject * key = PyString_FromString("dialect"); - PyObject * d; + Py_XINCREF(delimiter); + Py_XINCREF(doublequote); + Py_XINCREF(escapechar); + Py_XINCREF(lineterminator); + Py_XINCREF(quotechar); + Py_XINCREF(quoting); + Py_XINCREF(skipinitialspace); + Py_XINCREF(strict); + if (dialect != NULL) { + dialect = dialect_instantiate(dialect); + if (dialect == NULL) + goto err; +#define DIALECT_GETATTR(v, n) \ + if (v == NULL) \ + v = PyObject_GetAttrString(dialect, n) - d = PyDict_GetItem(kwargs, key); - if (d) { - Py_INCREF(d); - Py_XDECREF(dialect); - PyDict_DelItem(kwargs, key); - dialect = d; - } - Py_DECREF(key); - } - if (dialect != NULL) { - int i; - PyObject * dir_list; + DIALECT_GETATTR(delimiter, "delimiter"); + DIALECT_GETATTR(doublequote, "doublequote"); + DIALECT_GETATTR(escapechar, "escapechar"); + DIALECT_GETATTR(lineterminator, "lineterminator"); + DIALECT_GETATTR(quotechar, "quotechar"); + DIALECT_GETATTR(quoting, "quoting"); + DIALECT_GETATTR(skipinitialspace, "skipinitialspace"); + DIALECT_GETATTR(strict, "strict"); + PyErr_Clear(); + Py_DECREF(dialect); + } - /* If dialect is a string, look it up in our registry */ - if (PyString_Check(dialect) -#ifdef Py_USING_UNICODE - || PyUnicode_Check(dialect) -#endif - ) { - PyObject * new_dia; - new_dia = get_dialect_from_registry(dialect); - Py_DECREF(dialect); - if (new_dia == NULL) - return -1; - dialect = new_dia; - } - /* A class rather than an instance? Instantiate */ - if (PyObject_TypeCheck(dialect, &PyClass_Type)) { - PyObject * new_dia; - new_dia = PyObject_CallFunction(dialect, ""); - Py_DECREF(dialect); - if (new_dia == NULL) - return -1; - dialect = new_dia; - } - /* Make sure we finally have an instance */ - if (!PyInstance_Check(dialect) || - (dir_list = PyObject_Dir(dialect)) == NULL) { - PyErr_SetString(PyExc_TypeError, - "dialect must be an instance"); - Py_DECREF(dialect); - return -1; - } - /* And extract the attributes */ - for (i = 0; i < PyList_GET_SIZE(dir_list); ++i) { - char *s; - name_obj = PyList_GET_ITEM(dir_list, i); - s = PyString_AsString(name_obj); - if (s == NULL) - return -1; - if (s[0] == '_') - continue; - value_obj = PyObject_GetAttr(dialect, name_obj); - if (value_obj) { - if (PyObject_SetAttr((PyObject *)self, - name_obj, value_obj)) { - Py_DECREF(value_obj); - Py_DECREF(dir_list); - Py_DECREF(dialect); - return -1; - } - Py_DECREF(value_obj); - } - } - Py_DECREF(dir_list); - Py_DECREF(dialect); - } - if (kwargs != NULL) { - int pos = 0; + /* check types and convert to C values */ +#define DIASET(meth, name, target, src, dflt) \ + if (meth(name, target, src, dflt)) \ + goto err + DIASET(_set_char, "delimiter", &self->delimiter, delimiter, ','); + DIASET(_set_bool, "doublequote", &self->doublequote, doublequote, 1); + DIASET(_set_char, "escapechar", &self->escapechar, escapechar, 0); + DIASET(_set_str, "lineterminator", &self->lineterminator, lineterminator, "\r\n"); + DIASET(_set_char, "quotechar", &self->quotechar, quotechar, '"'); + DIASET(_set_int, "quoting", &self->quoting, quoting, QUOTE_MINIMAL); + DIASET(_set_bool, "skipinitialspace", &self->skipinitialspace, skipinitialspace, 0); + DIASET(_set_bool, "strict", &self->strict, strict, 0); - while (PyDict_Next(kwargs, &pos, &name_obj, &value_obj)) { - if (PyObject_SetAttr((PyObject *)self, - name_obj, value_obj)) - return -1; - } - } - return 0; + /* validate options */ + if (dialect_check_quoting(self->quoting)) + goto err; + if (self->delimiter == 0) { + PyErr_SetString(PyExc_TypeError, "delimiter must be set"); + goto err; + } + if (quotechar == Py_None && self->quoting != QUOTE_NONE) + self->quoting = QUOTE_NONE; + if (self->quoting != QUOTE_NONE && self->quotechar == 0) { + PyErr_SetString(PyExc_TypeError, + "quotechar must be set if quoting enabled"); + goto err; + } + if (self->lineterminator == 0) { + PyErr_SetString(PyExc_TypeError, "lineterminator must be set"); + goto err; + } + + ret = 0; +err: + Py_XDECREF(delimiter); + Py_XDECREF(doublequote); + Py_XDECREF(escapechar); + Py_XDECREF(lineterminator); + Py_XDECREF(quotechar); + Py_XDECREF(quoting); + Py_XDECREF(skipinitialspace); + Py_XDECREF(strict); + return ret; } static PyObject * @@ -433,7 +483,7 @@ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ - Dialect_methods, /* tp_methods */ + 0, /* tp_methods */ Dialect_memberlist, /* tp_members */ Dialect_getsetlist, /* tp_getset */ 0, /* tp_base */ @@ -509,7 +559,8 @@ parse_save_field(self); self->state = START_RECORD; } - else if (c == dialect->quotechar) { + else if (c == dialect->quotechar && + dialect->quoting != QUOTE_NONE) { /* start quoted field */ self->state = IN_QUOTED_FIELD; } @@ -572,7 +623,8 @@ /* Possible escape character */ self->state = ESCAPE_IN_QUOTED_FIELD; } - else if (c == dialect->quotechar) { + else if (c == dialect->quotechar && + dialect->quoting != QUOTE_NONE) { if (dialect->doublequote) { /* doublequote; " represented by "" */ self->state = QUOTE_IN_QUOTED_FIELD; @@ -1332,7 +1384,7 @@ return NULL; } Py_INCREF(dialect_obj); - /* A class rather than an instance? Instanciate */ + /* A class rather than an instance? Instantiate */ if (PyObject_TypeCheck(dialect_obj, &PyClass_Type)) { PyObject * new_dia; new_dia = PyObject_CallFunction(dialect_obj, ""); From andrewmcnamara at users.sourceforge.net Fri Jan 7 05:42:48 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Fri Jan 7 05:42:52 2005 Subject: [Python-checkins] python/dist/src/Lib csv.py,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25171/Lib Modified Files: csv.py Log Message: Improved the implementation of the internal "dialect" type. The new implementation features better error reporting, and better compliance with the PEP. Index: csv.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/csv.py,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- csv.py 5 Jan 2005 06:54:58 -0000 1.11 +++ csv.py 7 Jan 2005 04:42:45 -0000 1.12 @@ -68,7 +68,7 @@ elif not isinstance(self.lineterminator, str): errors.append("lineterminator must be a string") - if self.doublequote not in (True, False): + if self.doublequote not in (True, False) and self.quoting != QUOTE_NONE: errors.append("doublequote parameter must be True or False") if self.skipinitialspace not in (True, False): From andrewmcnamara at users.sourceforge.net Fri Jan 7 05:42:48 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Fri Jan 7 05:42:53 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_csv.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-serv25171/Lib/test Modified Files: test_csv.py Log Message: Improved the implementation of the internal "dialect" type. The new implementation features better error reporting, and better compliance with the PEP. Index: test_csv.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_csv.py,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- test_csv.py 8 Jul 2004 04:22:19 -0000 1.13 +++ test_csv.py 7 Jan 2005 04:42:45 -0000 1.14 @@ -17,44 +17,112 @@ from the high level interface. Further tests of this nature are done in TestDialectRegistry. """ - def test_reader_arg_valid(self): - self.assertRaises(TypeError, csv.reader) - self.assertRaises(TypeError, csv.reader, None) - self.assertRaises(AttributeError, csv.reader, [], bad_attr = 0) - self.assertRaises(csv.Error, csv.reader, [], 'foo') + def _test_arg_valid(self, ctor, arg): + self.assertRaises(TypeError, ctor) + self.assertRaises(TypeError, ctor, None) + self.assertRaises(TypeError, ctor, arg, bad_attr = 0) + self.assertRaises(TypeError, ctor, arg, delimiter = 0) + self.assertRaises(TypeError, ctor, arg, delimiter = 'XX') + self.assertRaises(csv.Error, ctor, arg, 'foo') + self.assertRaises(TypeError, ctor, arg, None) + self.assertRaises(TypeError, ctor, arg, delimiter=None) + self.assertRaises(TypeError, ctor, arg, delimiter=1) + self.assertRaises(TypeError, ctor, arg, quotechar=1) + self.assertRaises(TypeError, ctor, arg, lineterminator=None) + self.assertRaises(TypeError, ctor, arg, lineterminator=1) + self.assertRaises(TypeError, ctor, arg, quoting=None) +# We now allow this, only raising an exception if quoting is needed. +# self.assertRaises(TypeError, ctor, arg, quotechar=None) +# self.assertRaises(TypeError, ctor, arg, +# quoting=csv.QUOTE_NONE, escapechar=None) +# No longer complains about dialects with invalid attributes [AM] +# class BadDialect: +# bad_attr = 0 +# self.assertRaises(AttributeError, csv.reader, [], BadDialect) class BadClass: def __init__(self): raise IOError self.assertRaises(IOError, csv.reader, [], BadClass) - self.assertRaises(TypeError, csv.reader, [], None) - class BadDialect: - bad_attr = 0 - self.assertRaises(AttributeError, csv.reader, [], BadDialect) + + def test_reader_arg_valid(self): + self._test_arg_valid(csv.reader, []) def test_writer_arg_valid(self): - self.assertRaises(TypeError, csv.writer) - self.assertRaises(TypeError, csv.writer, None) - self.assertRaises(AttributeError, csv.writer, StringIO(), bad_attr = 0) + self._test_arg_valid(csv.writer, StringIO()) - def _test_attrs(self, obj): + def _test_default_attrs(self, ctor, *args): + obj = ctor(*args) + # Check defaults self.assertEqual(obj.dialect.delimiter, ',') - obj.dialect.delimiter = '\t' - self.assertEqual(obj.dialect.delimiter, '\t') - self.assertRaises(TypeError, delattr, obj.dialect, 'delimiter') - self.assertRaises(TypeError, setattr, obj.dialect, - 'lineterminator', None) - obj.dialect.escapechar = None + self.assertEqual(obj.dialect.doublequote, True) self.assertEqual(obj.dialect.escapechar, None) + self.assertEqual(obj.dialect.lineterminator, "\r\n") + self.assertEqual(obj.dialect.quotechar, '"') + self.assertEqual(obj.dialect.quoting, csv.QUOTE_MINIMAL) + self.assertEqual(obj.dialect.skipinitialspace, False) + self.assertEqual(obj.dialect.strict, False) + # Try deleting or changing attributes (they are read-only) + self.assertRaises(TypeError, delattr, obj.dialect, 'delimiter') + self.assertRaises(TypeError, setattr, obj.dialect, 'delimiter', ':') self.assertRaises(TypeError, delattr, obj.dialect, 'quoting') self.assertRaises(TypeError, setattr, obj.dialect, 'quoting', None) - obj.dialect.quoting = csv.QUOTE_MINIMAL - self.assertEqual(obj.dialect.quoting, csv.QUOTE_MINIMAL) def test_reader_attrs(self): - self._test_attrs(csv.reader([])) + self._test_default_attrs(csv.reader, []) def test_writer_attrs(self): - self._test_attrs(csv.writer(StringIO())) + self._test_default_attrs(csv.writer, StringIO()) + + def _test_kw_attrs(self, ctor, *args): + # Now try with alternate options + kwargs = dict(delimiter=':', doublequote=False, escapechar='\\', + lineterminator='\r', quotechar='*', + quoting=csv.QUOTE_NONE, skipinitialspace=True, + strict=True) + obj = ctor(*args, **kwargs) + self.assertEqual(obj.dialect.delimiter, ':') + self.assertEqual(obj.dialect.doublequote, False) + self.assertEqual(obj.dialect.escapechar, '\\') + self.assertEqual(obj.dialect.lineterminator, "\r") + self.assertEqual(obj.dialect.quotechar, '*') + self.assertEqual(obj.dialect.quoting, csv.QUOTE_NONE) + self.assertEqual(obj.dialect.skipinitialspace, True) + self.assertEqual(obj.dialect.strict, True) + + def test_reader_kw_attrs(self): + self._test_kw_attrs(csv.reader, []) + + def test_writer_kw_attrs(self): + self._test_kw_attrs(csv.writer, StringIO()) + + def _test_dialect_attrs(self, ctor, *args): + # Now try with dialect-derived options + class dialect: + delimiter='-' + doublequote=False + escapechar='^' + lineterminator='$' + quotechar='#' + quoting=csv.QUOTE_ALL + skipinitialspace=True + strict=False + args = args + (dialect,) + obj = ctor(*args) + self.assertEqual(obj.dialect.delimiter, '-') + self.assertEqual(obj.dialect.doublequote, False) + self.assertEqual(obj.dialect.escapechar, '^') + self.assertEqual(obj.dialect.lineterminator, "$") + self.assertEqual(obj.dialect.quotechar, '#') + self.assertEqual(obj.dialect.quoting, csv.QUOTE_ALL) + self.assertEqual(obj.dialect.skipinitialspace, True) + self.assertEqual(obj.dialect.strict, False) + + def test_reader_dialect_attrs(self): + self._test_dialect_attrs(csv.reader, []) + + def test_writer_dialect_attrs(self): + self._test_dialect_attrs(csv.writer, StringIO()) + def _write_test(self, fields, expect, **kwargs): fd, name = tempfile.mkstemp() @@ -166,6 +234,13 @@ self._read_test(['a,"b,c\\""'], [['a', 'b,c"']], escapechar='\\') self._read_test(['a,"b,c"\\'], [['a', 'b,c\\']], escapechar='\\') + def test_read_quoting(self): + self._read_test(['1,",3,",5'], [['1', ',3,', '5']]) + self._read_test(['1,",3,",5'], [['1', '"', '3', '"', '5']], + quotechar=None, escapechar='\\') + self._read_test(['1,",3,",5'], [['1', '"', '3', '"', '5']], + quoting=csv.QUOTE_NONE, escapechar='\\') + def test_read_bigfield(self): # This exercises the buffer realloc functionality bigstring = 'X' * 50000 @@ -297,7 +372,7 @@ def test_bad_dialect(self): # Unknown parameter - self.assertRaises(AttributeError, csv.reader, [], bad_attr = 0) + self.assertRaises(TypeError, csv.reader, [], bad_attr = 0) # Bad values self.assertRaises(TypeError, csv.reader, [], delimiter = None) self.assertRaises(TypeError, csv.reader, [], quoting = -1) From andrewmcnamara at users.sourceforge.net Fri Jan 7 07:46:52 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Fri Jan 7 07:46:56 2005 Subject: [Python-checkins] python/dist/src/Modules _csv.c,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14477/Modules Modified Files: _csv.c Log Message: Fix to use PEP7 brace style. Index: _csv.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_csv.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- _csv.c 7 Jan 2005 04:42:41 -0000 1.17 +++ _csv.c 7 Jan 2005 06:46:50 -0000 1.18 @@ -238,7 +238,8 @@ PyErr_Format(PyExc_TypeError, "\"%s\" must be an string", name); return -1; - } else { + } + else { Py_XDECREF(*target); Py_INCREF(src); *target = src; @@ -1025,7 +1026,8 @@ PyErr_Format(error_obj, "single empty field record must be quoted"); return -1; - } else + } + else *quoted = 1; } From kbk at users.sourceforge.net Fri Jan 7 08:02:09 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Fri Jan 7 08:02:11 2005 Subject: [Python-checkins] python/dist/src/Mac/OSX/Dist example-pimp-database.plist, NONE, 1.1.14.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX/Dist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12896/Mac/OSX/Dist Added Files: Tag: ast-branch example-pimp-database.plist Log Message: Merge MAIN into ast-branch cvs up -kk -j mrg_to_ast-branch_24APR03 -j mrg_to_ast-branch_05JAN05 (date of earlier merge estimated 24Apr03 17:30 UTC, repository tagged) Not merged: Lib/test/test_compile.py, Python/compile.c Refer to Tracker Patch # 1097671 for the merge output and list of conflicts resolved. --- NEW FILE: example-pimp-database.plist --- Description Enter database description Maintainer Enter your email address Packages Description Enter package description Download-URL Enter URL for archive download, delete for pseudo-pkgs Flavor Enter binary or source Home-page Enter URL of human-readable webpage Install-command Enter shell commands to run for installation Install-test Enter Python code to test for already installed MD5Sum Enter checksum of package archive Name Enter name of package Post-install-command Enter shell command to run after install Pre-install-command Enter shell command to run before install Prerequisites Enter human-readable recipy for pseudo-dependencies Flavor Enter optional flavor for real dependency Name Enter name for real dependency Version Version Enter version string for package Version 0.1 From kbk at users.sourceforge.net Fri Jan 7 08:02:09 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Fri Jan 7 08:02:11 2005 Subject: [Python-checkins] python/dist/src/Mac/OSX/Dist/resources ReadMe.txt, NONE, 1.3.2.1 Welcome.rtf, NONE, 1.3.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX/Dist/resources In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12896/Mac/OSX/Dist/resources Added Files: Tag: ast-branch ReadMe.txt Welcome.rtf Log Message: Merge MAIN into ast-branch cvs up -kk -j mrg_to_ast-branch_24APR03 -j mrg_to_ast-branch_05JAN05 (date of earlier merge estimated 24Apr03 17:30 UTC, repository tagged) Not merged: Lib/test/test_compile.py, Python/compile.c Refer to Tracker Patch # 1097671 for the merge output and list of conflicts resolved. --- NEW FILE: ReadMe.txt --- This package will install MacPython 2.5a0 for Mac OS X 10.3. Installation requires approximately 20 MB of disk space, ignore the message that it will take zero bytes. You must install onto your current boot disk, even though the installer does not enforce this, otherwise things will not work. MacPython consists of the Python programming language interpreter, plus a set of programs to allow easy access to it for Mac users (an integrated development environment, a Python extension package manager), plus a set of pre-built extension modules that open up specific Macintosh technologies to Python programs (Carbon, AppleScript, Quicktime, more). The installer puts the applications in MacPython-2.5 in your Applications folder, command-line tools in /usr/local/bin and the underlying machinery in /Library/Frameworks/Python.framework. The PythonIDE application has a Help command that gets you started quickly with MacPython and contains references to other documentation. More information on MacPython can be found at http://www.cwi.nl/~jack/macpython, more information on Python in general at http://www.python.org. --- NEW FILE: Welcome.rtf --- {\rtf1\mac\ansicpg10000\cocoartf102 {\fonttbl\f0\fswiss\fcharset77 Helvetica;\f1\fswiss\fcharset77 Helvetica-Bold;} {\colortbl;\red255\green255\blue255;} \paperw11900\paperh16840\margl1440\margr1440\vieww9920\viewh10660\viewkind0 \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural \f0\fs24 \cf0 This package will install \f1\b MacPython 2.5a0 \f0\b0 for \f1\b Mac OS X 10.3 \f0\b0 . Installation on 10.2 or earlier will not work.\ \ MacPython consists of the Python programming language interpreter, plus a set of programs to allow easy access to it for Mac users (an integrated development environment, a Python extension package manager), plus a set of pre-built extension modules that open up specific Macintosh technologies to Python programs (Carbon, AppleScript, Quicktime, more).\ \ See the ReadMe file for more information.} From kbk at users.sourceforge.net Fri Jan 7 08:02:10 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Fri Jan 7 08:02:13 2005 Subject: [Python-checkins] python/dist/src/Mac/OSX/Doc/HelpIndexingTool Help_Indexing_Tool_Suite.py, NONE, 1.1.14.1 Miscellaneous_Standards.py, NONE, 1.1.14.1 Required_Suite.py, NONE, 1.1.14.1 Standard_Suite.py, NONE, 1.2.6.1 __init__.py, NONE, 1.2.6.1 odds_and_ends.py, NONE, 1.1.14.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX/Doc/HelpIndexingTool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12896/Mac/OSX/Doc/HelpIndexingTool Added Files: Tag: ast-branch Help_Indexing_Tool_Suite.py Miscellaneous_Standards.py Required_Suite.py Standard_Suite.py __init__.py odds_and_ends.py Log Message: Merge MAIN into ast-branch cvs up -kk -j mrg_to_ast-branch_24APR03 -j mrg_to_ast-branch_05JAN05 (date of earlier merge estimated 24Apr03 17:30 UTC, repository tagged) Not merged: Lib/test/test_compile.py, Python/compile.c Refer to Tracker Patch # 1097671 for the merge output and list of conflicts resolved. --- NEW FILE: Help_Indexing_Tool_Suite.py --- """Suite Help Indexing Tool Suite: Special events that just the Help Indexing Tool supports. Level 0, version 0 Generated from /Developer/Applications/Apple Help Indexing Tool.app AETE/AEUT resource version 1/1, language 0, script 0 """ import aetools import MacOS _code = 'HIT ' class Help_Indexing_Tool_Suite_Events: def turn_anchor_indexing(self, _object, _attributes={}, **_arguments): """turn anchor indexing: Turns anchor indexing on or off. Required argument: \xd2on\xd3 or \xd2off\xd3, to turn anchor indexing on or off Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'HIT ' _subcode = 'tAnc' if _arguments: raise TypeError, 'No optional args expected' _arguments['----'] = _object _reply, _arguments, _attributes = self.send(_code, _subcode, _arguments, _attributes) if _arguments.get('errn', 0): raise aetools.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result if _arguments.has_key('----'): return _arguments['----'] _argmap_turn_remote_root = { 'with_root_url' : 'rURL', } def turn_remote_root(self, _object, _attributes={}, **_arguments): """turn remote root: Turn usage of remote root for content on the web on or off. If turning \xd2on\xd3, supply a string as second parameter. Required argument: \xd2on\xd3 or \xd2off\xd3, to turn remote root on or off Keyword argument with_root_url: The remote root to use, in the form of \xd2http://www.apple.com/help/\xd3. Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'HIT ' _subcode = 'tRem' aetools.keysubst(_arguments, self._argmap_turn_remote_root) _arguments['----'] = _object _reply, _arguments, _attributes = self.send(_code, _subcode, _arguments, _attributes) if _arguments.get('errn', 0): raise aetools.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result if _arguments.has_key('----'): return _arguments['----'] def use_tokenizer(self, _object, _attributes={}, **_arguments): """use tokenizer: Tells the indexing tool which tokenizer to use. Required argument: Specify \xd2English\xd3, \xd2European\xd3, \xd2Japanese\xd3, \xd2Korean\xd3, or \xd2Simple\xd3. Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'HIT ' _subcode = 'uTok' if _arguments: raise TypeError, 'No optional args expected' _arguments['----'] = _object _reply, _arguments, _attributes = self.send(_code, _subcode, _arguments, _attributes) if _arguments.get('errn', 0): raise aetools.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result if _arguments.has_key('----'): return _arguments['----'] class application(aetools.ComponentItem): """application - Application class """ want = 'capp' class _Prop_idleStatus(aetools.NProperty): """idleStatus - """ which = 'sIdl' want = 'bool' application._superclassnames = [] application._privpropdict = { 'idleStatus' : _Prop_idleStatus, } application._privelemdict = { } # # Indices of types declared in this module # _classdeclarations = { 'capp' : application, } _propdeclarations = { 'sIdl' : _Prop_idleStatus, } _compdeclarations = { } _enumdeclarations = { } --- NEW FILE: Miscellaneous_Standards.py --- """Suite Miscellaneous Standards: Useful events that aren\xd5t in any other suite Level 0, version 0 Generated from /Developer/Applications/Apple Help Indexing Tool.app AETE/AEUT resource version 1/1, language 0, script 0 """ import aetools import MacOS _code = 'misc' class Miscellaneous_Standards_Events: def revert(self, _object, _attributes={}, **_arguments): """revert: Revert an object to the most recently saved version Required argument: object to revert Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'misc' _subcode = 'rvrt' if _arguments: raise TypeError, 'No optional args expected' _arguments['----'] = _object _reply, _arguments, _attributes = self.send(_code, _subcode, _arguments, _attributes) if _arguments.get('errn', 0): raise aetools.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result if _arguments.has_key('----'): return _arguments['----'] # # Indices of types declared in this module # _classdeclarations = { } _propdeclarations = { } _compdeclarations = { } _enumdeclarations = { } --- NEW FILE: Required_Suite.py --- """Suite Required Suite: Terms that every application should support Level 1, version 1 Generated from /Developer/Applications/Apple Help Indexing Tool.app AETE/AEUT resource version 1/1, language 0, script 0 """ import aetools import MacOS _code = 'reqd' from StdSuites.Required_Suite import * class Required_Suite_Events(Required_Suite_Events): pass # # Indices of types declared in this module # _classdeclarations = { } _propdeclarations = { } _compdeclarations = { } _enumdeclarations = { } --- NEW FILE: Standard_Suite.py --- """Suite Standard Suite: Common terms for most applications Level 1, version 1 Generated from /Developer/Applications/Apple Help Indexing Tool.app AETE/AEUT resource version 1/1, language 0, script 0 """ import aetools import MacOS _code = 'CoRe' from StdSuites.Standard_Suite import * class Standard_Suite_Events(Standard_Suite_Events): _argmap_close = { 'saving' : 'savo', 'in_' : 'kfil', } def close(self, _object, _attributes={}, **_arguments): """close: Close an object Required argument: the objects to close Keyword argument saving: specifies whether or not changes should be saved before closing Keyword argument in_: the file in which to save the object Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'core' _subcode = 'clos' aetools.keysubst(_arguments, self._argmap_close) _arguments['----'] = _object aetools.enumsubst(_arguments, 'savo', _Enum_savo) _reply, _arguments, _attributes = self.send(_code, _subcode, _arguments, _attributes) if _arguments.get('errn', 0): raise aetools.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result if _arguments.has_key('----'): return _arguments['----'] def data_size(self, _object, _attributes={}, **_arguments): """data size: Return the size in bytes of an object Required argument: the object whose data size is to be returned Keyword argument _attributes: AppleEvent attribute dictionary Returns: the size of the object in bytes """ _code = 'core' _subcode = 'dsiz' if _arguments: raise TypeError, 'No optional args expected' _arguments['----'] = _object _reply, _arguments, _attributes = self.send(_code, _subcode, _arguments, _attributes) if _arguments.get('errn', 0): raise aetools.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result if _arguments.has_key('----'): return _arguments['----'] def get(self, _object, _attributes={}, **_arguments): """get: Get the data for an object Required argument: the object whose data is to be returned Keyword argument _attributes: AppleEvent attribute dictionary Returns: The data from the object """ _code = 'core' _subcode = 'getd' if _arguments: raise TypeError, 'No optional args expected' _arguments['----'] = _object _reply, _arguments, _attributes = self.send(_code, _subcode, _arguments, _attributes) if _arguments.get('errn', 0): raise aetools.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result if _arguments.has_key('----'): return _arguments['----'] _argmap_make = { 'new' : 'kocl', 'at' : 'insh', 'with_data' : 'data', 'with_properties' : 'prdt', } def make(self, _no_object=None, _attributes={}, **_arguments): """make: Make a new element Keyword argument new: the class of the new element Keyword argument at: the location at which to insert the element Keyword argument with_data: the initial data for the element Keyword argument with_properties: the initial values for the properties of the element Keyword argument _attributes: AppleEvent attribute dictionary Returns: Object specifier for the new element """ _code = 'core' _subcode = 'crel' aetools.keysubst(_arguments, self._argmap_make) if _no_object != None: raise TypeError, 'No direct arg expected' _reply, _arguments, _attributes = self.send(_code, _subcode, _arguments, _attributes) if _arguments.get('errn', 0): raise aetools.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result if _arguments.has_key('----'): return _arguments['----'] def open(self, _object, _attributes={}, **_arguments): """open: Open the specified object(s) Required argument: Objects to open. Can be a list of files or an object specifier. Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'aevt' _subcode = 'odoc' if _arguments: raise TypeError, 'No optional args expected' _arguments['----'] = _object _reply, _arguments, _attributes = self.send(_code, _subcode, _arguments, _attributes) if _arguments.get('errn', 0): raise aetools.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result if _arguments.has_key('----'): return _arguments['----'] def print_(self, _object, _attributes={}, **_arguments): """print: Print the specified object(s) Required argument: Objects to print. Can be a list of files or an object specifier. Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'aevt' _subcode = 'pdoc' if _arguments: raise TypeError, 'No optional args expected' _arguments['----'] = _object _reply, _arguments, _attributes = self.send(_code, _subcode, _arguments, _attributes) if _arguments.get('errn', 0): raise aetools.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result if _arguments.has_key('----'): return _arguments['----'] _argmap_save = { 'in_' : 'kfil', 'as' : 'fltp', } def save(self, _object, _attributes={}, **_arguments): """save: save a set of objects Required argument: Objects to save. Keyword argument in_: the file in which to save the object(s) Keyword argument as: the file type of the document in which to save the data Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'core' _subcode = 'save' aetools.keysubst(_arguments, self._argmap_save) _arguments['----'] = _object _reply, _arguments, _attributes = self.send(_code, _subcode, _arguments, _attributes) if _arguments.get('errn', 0): raise aetools.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result if _arguments.has_key('----'): return _arguments['----'] _argmap_set = { 'to' : 'data', } def set(self, _object, _attributes={}, **_arguments): """set: Set an object\xd5s data Required argument: the object to change Keyword argument to: the new value Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'core' _subcode = 'setd' aetools.keysubst(_arguments, self._argmap_set) _arguments['----'] = _object _reply, _arguments, _attributes = self.send(_code, _subcode, _arguments, _attributes) if _arguments.get('errn', 0): raise aetools.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result if _arguments.has_key('----'): return _arguments['----'] class application(aetools.ComponentItem): """application - An application program """ want = 'capp' # element 'cwin' as ['indx', 'name', 'rele'] # element 'docu' as ['name'] class window(aetools.ComponentItem): """window - A Window """ want = 'cwin' class _Prop_bounds(aetools.NProperty): """bounds - the boundary rectangle for the window """ which = 'pbnd' want = 'qdrt' class _Prop_closeable(aetools.NProperty): """closeable - Does the window have a close box? """ which = 'hclb' want = 'bool' class _Prop_floating(aetools.NProperty): """floating - Does the window float? """ which = 'isfl' want = 'bool' class _Prop_index(aetools.NProperty): """index - the number of the window """ which = 'pidx' want = 'long' class _Prop_modal(aetools.NProperty): """modal - Is the window modal? """ which = 'pmod' want = 'bool' class _Prop_name(aetools.NProperty): """name - the title of the window """ which = 'pnam' want = 'itxt' class _Prop_position(aetools.NProperty): """position - upper left coordinates of window """ which = 'ppos' want = 'QDpt' class _Prop_resizable(aetools.NProperty): """resizable - Is the window resizable? """ which = 'prsz' want = 'bool' class _Prop_titled(aetools.NProperty): """titled - Does the window have a title bar? """ which = 'ptit' want = 'bool' class _Prop_visible(aetools.NProperty): """visible - is the window visible? """ which = 'pvis' want = 'bool' class _Prop_zoomable(aetools.NProperty): """zoomable - Is the window zoomable? """ which = 'iszm' want = 'bool' class _Prop_zoomed(aetools.NProperty): """zoomed - Is the window zoomed? """ which = 'pzum' want = 'bool' class document(aetools.ComponentItem): """document - A Document """ want = 'docu' class _Prop_modified(aetools.NProperty): """modified - Has the document been modified since the last save? """ which = 'imod' want = 'bool' application._superclassnames = [] application._privpropdict = { } application._privelemdict = { 'document' : document, 'window' : window, } window._superclassnames = [] window._privpropdict = { 'bounds' : _Prop_bounds, 'closeable' : _Prop_closeable, 'floating' : _Prop_floating, 'index' : _Prop_index, 'modal' : _Prop_modal, 'name' : _Prop_name, 'position' : _Prop_position, 'resizable' : _Prop_resizable, 'titled' : _Prop_titled, 'visible' : _Prop_visible, 'zoomable' : _Prop_zoomable, 'zoomed' : _Prop_zoomed, } window._privelemdict = { } document._superclassnames = [] document._privpropdict = { 'modified' : _Prop_modified, 'name' : _Prop_name, } document._privelemdict = { } _Enum_savo = { 'yes' : 'yes ', # Save objects now 'no' : 'no ', # Do not save objects 'ask' : 'ask ', # Ask the user whether to save } # # Indices of types declared in this module # _classdeclarations = { 'capp' : application, 'cwin' : window, 'docu' : document, } _propdeclarations = { 'hclb' : _Prop_closeable, 'imod' : _Prop_modified, 'isfl' : _Prop_floating, 'iszm' : _Prop_zoomable, 'pbnd' : _Prop_bounds, 'pidx' : _Prop_index, 'pmod' : _Prop_modal, 'pnam' : _Prop_name, 'ppos' : _Prop_position, 'prsz' : _Prop_resizable, 'ptit' : _Prop_titled, 'pvis' : _Prop_visible, 'pzum' : _Prop_zoomed, } _compdeclarations = { } _enumdeclarations = { 'savo' : _Enum_savo, } --- NEW FILE: __init__.py --- """ Package generated from /Developer/Applications/Apple Help Indexing Tool.app """ import aetools Error = aetools.Error import Standard_Suite import Help_Indexing_Tool_Suite import odds_and_ends import Miscellaneous_Standards import Required_Suite _code_to_module = { 'CoRe' : Standard_Suite, 'HIT ' : Help_Indexing_Tool_Suite, 'Odds' : odds_and_ends, 'misc' : Miscellaneous_Standards, 'reqd' : Required_Suite, } _code_to_fullname = { 'CoRe' : ('HelpIndexingTool.Standard_Suite', 'Standard_Suite'), 'HIT ' : ('HelpIndexingTool.Help_Indexing_Tool_Suite', 'Help_Indexing_Tool_Suite'), 'Odds' : ('HelpIndexingTool.odds_and_ends', 'odds_and_ends'), 'misc' : ('HelpIndexingTool.Miscellaneous_Standards', 'Miscellaneous_Standards'), 'reqd' : ('HelpIndexingTool.Required_Suite', 'Required_Suite'), } from Standard_Suite import * from Help_Indexing_Tool_Suite import * from odds_and_ends import * from Miscellaneous_Standards import * from Required_Suite import * def getbaseclasses(v): if not getattr(v, '_propdict', None): v._propdict = {} v._elemdict = {} for superclassname in getattr(v, '_superclassnames', []): superclass = eval(superclassname) getbaseclasses(superclass) v._propdict.update(getattr(superclass, '_propdict', {})) v._elemdict.update(getattr(superclass, '_elemdict', {})) v._propdict.update(getattr(v, '_privpropdict', {})) v._elemdict.update(getattr(v, '_privelemdict', {})) import StdSuites # # Set property and element dictionaries now that all classes have been defined # getbaseclasses(window) getbaseclasses(application) getbaseclasses(document) getbaseclasses(application) # # Indices of types declared in this module # _classdeclarations = { 'cwin' : window, 'capp' : application, 'docu' : document, 'capp' : application, } class HelpIndexingTool(Standard_Suite_Events, Help_Indexing_Tool_Suite_Events, odds_and_ends_Events, Miscellaneous_Standards_Events, Required_Suite_Events, aetools.TalkTo): _signature = 'hiti' _moduleName = 'HelpIndexingTool' --- NEW FILE: odds_and_ends.py --- """Suite odds and ends: Things that should be in some standard suite, but aren\xd5t Level 1, version 1 Generated from /Developer/Applications/Apple Help Indexing Tool.app AETE/AEUT resource version 1/1, language 0, script 0 """ import aetools import MacOS _code = 'Odds' class odds_and_ends_Events: def select(self, _object=None, _attributes={}, **_arguments): """select: Select the specified object Required argument: the object to select Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'misc' _subcode = 'slct' if _arguments: raise TypeError, 'No optional args expected' _arguments['----'] = _object _reply, _arguments, _attributes = self.send(_code, _subcode, _arguments, _attributes) if _arguments.get('errn', 0): raise aetools.Error, aetools.decodeerror(_arguments) # XXXX Optionally decode result if _arguments.has_key('----'): return _arguments['----'] # # Indices of types declared in this module # _classdeclarations = { } _propdeclarations = { } _compdeclarations = { } _enumdeclarations = { } From kbk at users.sourceforge.net Fri Jan 7 08:02:11 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Fri Jan 7 08:02:15 2005 Subject: [Python-checkins] python/dist/src/Mac/OSXResources/app/Resources/English.lproj/Documentation community.html, NONE, 1.2.14.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSXResources/app/Resources/English.lproj/Documentation In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12896/Mac/OSXResources/app/Resources/English.lproj/Documentation Added Files: Tag: ast-branch community.html Log Message: Merge MAIN into ast-branch cvs up -kk -j mrg_to_ast-branch_24APR03 -j mrg_to_ast-branch_05JAN05 (date of earlier merge estimated 24Apr03 17:30 UTC, repository tagged) Not merged: Lib/test/test_compile.py, Python/compile.c Refer to Tracker Patch # 1097671 for the merge output and list of conflicts resolved. --- NEW FILE: community.html --- What is MacPython?

MacPython Community


Web Sites

The MacPython homepage, www.cwi.nl/~jack/macpython.html is where you can find installers, documents, links to useful packages and more. And, of course, www.python.org has a much larger collection of material on Python that is not Mac-specific.

News groups and Mailing lists

There are a lot of mailing lists on Python. Some of the more interesting ones are:

  • python-help@python.org where you can send questions for individual support. Please check the websites mentioned above first, though!
  • The comp.lang.python newsgroup for general discussion. Also available as a mailing list.
  • The comp.lang.python.announce newsgroup for announcements. Low-volume and moderated. Also available as a mailing list.
  • Last but not least, the pythonmac-sig mailing list is specifically for MacPython. Discussions on the implementation of new features, but beginners questions are welcome too.

In addition there are Python Special Interest Group mailing lists on a wide variety of topics such as image processing, numerical algorithms and more.

More

An index of conferences, Wiki's, bookshops and more can be found at the Community section of the Python website.

If you find a bug you are kindly requested to report it, preferrably through the automatic bug tracker at www.python.org

If you want to become an active developer you are very welcome! Join the pythonmac-sig mailing list mentioned above, and read the Developer section on the Python website.

From kbk at users.sourceforge.net Fri Jan 7 08:02:13 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Fri Jan 7 08:02:16 2005 Subject: [Python-checkins] python/dist/src/Mac/OSXResources/app/Resources/English.lproj/Documentation/ide IDE.gif, NONE, 1.1.12.1 entering_in_new_window.gif, NONE, 1.1.12.1 hello_world.gif, NONE, 1.1.12.1 index.html, NONE, 1.1.12.1 loading_ide.gif, NONE, 1.1.12.1 making_new_window.gif, NONE, 1.1.12.1 new_ide_window.gif, NONE, 1.1.12.1 new_window_made.gif, NONE, 1.1.12.1 output_window.gif, NONE, 1.1.12.1 saving_edited_file.gif, NONE, 1.1.12.1 simple_commands.gif, NONE, 1.1.12.1 syntax_error.gif, NONE, 1.1.12.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSXResources/app/Resources/English.lproj/Documentation/ide In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12896/Mac/OSXResources/app/Resources/English.lproj/Documentation/ide Added Files: Tag: ast-branch IDE.gif entering_in_new_window.gif hello_world.gif index.html loading_ide.gif making_new_window.gif new_ide_window.gif new_window_made.gif output_window.gif saving_edited_file.gif simple_commands.gif syntax_error.gif Log Message: Merge MAIN into ast-branch cvs up -kk -j mrg_to_ast-branch_24APR03 -j mrg_to_ast-branch_05JAN05 (date of earlier merge estimated 24Apr03 17:30 UTC, repository tagged) Not merged: Lib/test/test_compile.py, Python/compile.c Refer to Tracker Patch # 1097671 for the merge output and list of conflicts resolved. --- NEW FILE: IDE.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: entering_in_new_window.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: hello_world.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: index.html --- One Day of MacPython IDE Toying

One Day of MacPython IDE Toying

This document gives a very basic introduction to the MacPython Integrated Development Environment (IDE) on Mac OS. It was written specifically for MacPython 2.3 on Mac OS X, but most of it is applicable to MacPython-OS9 too. It is based on "One Day of IDLE Toying" by Danny Yoo, which you should read if you want to use the cross-platform IDLE Python development environment.



Ok, let's assume that we've already installed Python. (If not, we can visit: http://www.cwi.nl/~jack/macpython.html or http://python.org and download the most recent Python interpreter. Get the Mac OSX binary installer.) The first thing we'd like to do is actually start running it! We can do this by opening up the IDE, which should be in Applications under the newly-created MacPython program folder:

image of IDE icon



The IDE starts up and shows an interactive window:

image of new window

If the window does not show up (because you have run the IDE before and closed it: it remembers that between runs) open it with the Windows->Python Interactive menu entry.

This is the interactive window to the IDE, it allows us to enter commands directly into Python, and as soon as we enter a command, Python will execute it and spit its result back to us. We'll be using this interactive window a lot when we're exploring Python: it's very nice because we get back our results immediately. If it helps, we can think of it as a very powerful calculator.



Let's try something now! As per tradition, let's get Python to say the immortal words, "Hello World". image of hello world program

Those '>>>' signs act as a prompt for us: Python is ready to read in a new command by giving us that visual cue. Also, we notice that as we enter commands, Python will give us its output immediately.



Ok, this seems pretty simple enough. Let's try a few more commands. If we look below:

image of command window

we'll see the result of running a few more commands. Don't worry too much about knowing the exact rules for making programs yet: the idea is that we can experiment with Python by typing in commands. If things don't work, then we can correct the mistake, and try it again.

If you got to this point, you now know enough to start playing around with Python! Crack open one of the tutorials from the Python For Beginners web page, and start exploring with the interpreter. No time limit here. *grin*



Now that we've paddled long enough, we might be asking: ok, this is neat, but if we close down Python and start it up again, how do we get the computer to remember what we typed?

The solution is a little subtle: we can't directly save what's in the interpreter window, because it will include both our commands and the system's responses. What we'd like is to make a prepared file, with just our own commands, and to be able to save that file as a document. When we're in the mood, we can later open that file and "run" Python over it, saving us the time of retyping the whole thing over again.

Let's try this. First, let's start with a clean slate by opening up a new window.

image of making new window

Here's the result of that menu command:

image of new window

We notice that there's nothing in this new window. What this means is that this file is purely for our commands: Python won't interject with its own responses as we enter the program, that is, not until we tell it to. This is called an edit window, and it is very similar to edit windows in other editors such as TextEdit or BBEdit.



What we wanted to do before was save some of the stuff we had tried out on the interpreter window. Let's do that by typing (or copy/pasting) those commands into our edit window.

image of entering commands

Ok, we're done with copying and pasting. One big thing to notice is that we're careful to get rid of the ">>>" prompts because they're not really part of our program. The interpreter uses them just to tell us that we're in the interpreter, but now that we're editing in a separate file, we can remove the artifacts that the interpreter introduces. I have added an extra empty print statement so our output ends with a newline.



Let's save the file now. The Save command is located under the File menu:

image of saving file



Now that we've saved the program, how do we run the program? Use the Run All button at the top of the editing window, or the equivalent menu command Python->Run Window. The output will appear in a new window called Output Window.

By the way, one thing to notice is that I made a typo: I didn't quite copy exactly what I had entered in the interpreter window before. Does this affect things?

image of syntax error

Ooops. Here is an example of what Python calls a "syntax error". Python sees that we made a typo, and warns us to take a much closer look at our program. The designers of Python feel that having the system point out the error is better than trying to guess at what the programmer meant. Press the Edit button and you will be brought to the trouble spot.

Python is often perceptive enough to direct us toward the problem, and in this case, it's telling us that we forgot to put something at the end of this line. In this case, we need to add a quotation mark at the end. Let's add that in now.

Other errors, which usually occur later, when your program has already done something, result in a different dialog that allows you to look at variables and such in addition to showing you where the error occurred.



Ok, let's say that we fixed that silly typo. Let's try to run the program again. This gives us a new window, the Output window, showing the output of our program:

image of output window



As we play with Python, we'll find ourselves "switching modes" between the Interpreter window and the edit window. However, if we try anything more complicated than two or three lines it is often a good idea to work in an edit window. Align your edit and output window such that you can see them at the same time.

This is pretty much all we need to know about the MacPython IDE to actually do interesting things. There is a lot more to the IDE, here is a quick breakdown of things to see and explore:

  • All sorts of edit commands such as find and replace can be used in the editor windows. See the Edit menu.
  • The bottom of the edit window has the scrollbar, but at the left are two navigation devices: a line number box that you can type numbers into to quickly go to a specific place, and a popup menu that lists all classes, functions and methods in your file.
  • Above the vertical scrollbar you find another popup menu, this influences how the Run command works. You should try the debugger some time! If you do, and you wonder what the new small column on the left of your script is: you can click in it to make Python stop when it reaches this line so you can inspect things. The profiler is also nifty: it shows you where your program is spending its time.
  • The module browser (Python->Module Browser) shows you all Python modules currently loaded. You can look at the contents of the module with Browse... and (for modules written in Python) at the source with Source...
  • The Package Manager (under the File menu, also available as a separate application) allows you to easily install Python extension packages for all sorts of things: scientific computation, image processing, building user interfaces and more.
  • The Help menu gives you quick access to both the Python documentation, if you have installed it with the Package Manager, and the Apple Developer documentation.
  • The File->Save as Applet menu command saves your script as a MacOSX application. This allows you to create a script that you can drop files on, and much more. The IDE itself is such an applet, completely written in Python.
--- NEW FILE: loading_ide.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: making_new_window.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: new_ide_window.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: new_window_made.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: output_window.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: saving_edited_file.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: simple_commands.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: syntax_error.gif --- (This appears to be a binary file; contents omitted.) From kbk at users.sourceforge.net Fri Jan 7 08:02:16 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Fri Jan 7 08:02:19 2005 Subject: [Python-checkins] python/dist/src/Mac/Python getapplbycreator.c, 1.3, NONE gusiconfig.cpp, 1.8, NONE macapplication.c, 1.12, NONE macgetargv.c, 1.26.14.1, NONE macgetcompiler.c, 1.17.2.1, NONE macgetpath.c, 1.26.2.1, NONE macgetplatform.c, 1.4, NONE macglue.c, 1.112.2.1, NONE macimport.c, 1.15.2.1, NONE macmain.c, 1.78.2.1, NONE macsetfiletype.c, 1.7, NONE macshlglue.c, 1.17, NONE pyGUSISIOUX.cp, 1.4.2.1, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12896/Mac/Python Removed Files: Tag: ast-branch getapplbycreator.c gusiconfig.cpp macapplication.c macgetargv.c macgetcompiler.c macgetpath.c macgetplatform.c macglue.c macimport.c macmain.c macsetfiletype.c macshlglue.c pyGUSISIOUX.cp Log Message: Merge MAIN into ast-branch cvs up -kk -j mrg_to_ast-branch_24APR03 -j mrg_to_ast-branch_05JAN05 (date of earlier merge estimated 24Apr03 17:30 UTC, repository tagged) Not merged: Lib/test/test_compile.py, Python/compile.c Refer to Tracker Patch # 1097671 for the merge output and list of conflicts resolved. --- getapplbycreator.c DELETED --- --- gusiconfig.cpp DELETED --- --- macapplication.c DELETED --- --- macgetargv.c DELETED --- --- macgetcompiler.c DELETED --- --- macgetpath.c DELETED --- --- macgetplatform.c DELETED --- --- macglue.c DELETED --- --- macimport.c DELETED --- --- macmain.c DELETED --- --- macsetfiletype.c DELETED --- --- macshlglue.c DELETED --- --- pyGUSISIOUX.cp DELETED --- From kbk at users.sourceforge.net Fri Jan 7 08:02:22 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Fri Jan 7 08:02:25 2005 Subject: [Python-checkins] python/dist/src/Mac/Resources Carbon.r, 1.3, NONE balloons.bh, 1.4, NONE bundle.rsrc, 1.13, NONE dialogs.rsrc, 1.17.16.1, NONE gusiprefs.rsrc, 1.3, NONE pythonpath.r, 1.14.16.1, NONE tkpython.rsrc, 1.6, NONE version.r, 1.2, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Resources In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12896/Mac/Resources Removed Files: Tag: ast-branch Carbon.r balloons.bh bundle.rsrc dialogs.rsrc gusiprefs.rsrc pythonpath.r tkpython.rsrc version.r Log Message: Merge MAIN into ast-branch cvs up -kk -j mrg_to_ast-branch_24APR03 -j mrg_to_ast-branch_05JAN05 (date of earlier merge estimated 24Apr03 17:30 UTC, repository tagged) Not merged: Lib/test/test_compile.py, Python/compile.c Refer to Tracker Patch # 1097671 for the merge output and list of conflicts resolved. --- Carbon.r DELETED --- --- balloons.bh DELETED --- --- bundle.rsrc DELETED --- --- dialogs.rsrc DELETED --- --- gusiprefs.rsrc DELETED --- --- pythonpath.r DELETED --- --- tkpython.rsrc DELETED --- --- version.r DELETED --- From kbk at users.sourceforge.net Fri Jan 7 08:02:22 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Fri Jan 7 08:02:26 2005 Subject: [Python-checkins] python/dist/src/Mac/Tools/CGI BuildCGIApplet.py, 1.5, NONE BuildCGIApplet.rsrc, 1.5, NONE CGI_README.txt, 1.1, NONE PythonCGISlave.py, 1.2, NONE PythonCGISlave.rsrc, 1.5, NONE cgi.html, 1.1, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/CGI In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12896/Mac/Tools/CGI Removed Files: Tag: ast-branch BuildCGIApplet.py BuildCGIApplet.rsrc CGI_README.txt PythonCGISlave.py PythonCGISlave.rsrc cgi.html Log Message: Merge MAIN into ast-branch cvs up -kk -j mrg_to_ast-branch_24APR03 -j mrg_to_ast-branch_05JAN05 (date of earlier merge estimated 24Apr03 17:30 UTC, repository tagged) Not merged: Lib/test/test_compile.py, Python/compile.c Refer to Tracker Patch # 1097671 for the merge output and list of conflicts resolved. --- BuildCGIApplet.py DELETED --- --- BuildCGIApplet.rsrc DELETED --- --- CGI_README.txt DELETED --- --- PythonCGISlave.py DELETED --- --- PythonCGISlave.rsrc DELETED --- --- cgi.html DELETED --- From kbk at users.sourceforge.net Fri Jan 7 08:02:25 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Fri Jan 7 08:02:28 2005 Subject: [Python-checkins] python/dist/src/Mac/Unsupported unshar.py, 1.1.6.1, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Unsupported In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12896/Mac/Unsupported Removed Files: Tag: ast-branch unshar.py Log Message: Merge MAIN into ast-branch cvs up -kk -j mrg_to_ast-branch_24APR03 -j mrg_to_ast-branch_05JAN05 (date of earlier merge estimated 24Apr03 17:30 UTC, repository tagged) Not merged: Lib/test/test_compile.py, Python/compile.c Refer to Tracker Patch # 1097671 for the merge output and list of conflicts resolved. --- unshar.py DELETED --- From kbk at users.sourceforge.net Fri Jan 7 08:02:27 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Fri Jan 7 08:02:30 2005 Subject: [Python-checkins] python/dist/src/Mac/mwerks/malloc README, 1.2, NONE calloc.c, 1.1, NONE malloc.c, 1.12, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/mwerks/malloc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12896/Mac/mwerks/malloc Removed Files: Tag: ast-branch README calloc.c malloc.c Log Message: Merge MAIN into ast-branch cvs up -kk -j mrg_to_ast-branch_24APR03 -j mrg_to_ast-branch_05JAN05 (date of earlier merge estimated 24Apr03 17:30 UTC, repository tagged) Not merged: Lib/test/test_compile.py, Python/compile.c Refer to Tracker Patch # 1097671 for the merge output and list of conflicts resolved. --- README DELETED --- --- calloc.c DELETED --- --- malloc.c DELETED --- From kbk at users.sourceforge.net Fri Jan 7 08:02:27 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Fri Jan 7 08:02:31 2005 Subject: [Python-checkins] python/dist/src/Mac/mwerks errno_unix.h, 1.7, NONE macuseshlstart.c, 1.3, NONE mwerks_nscarbon.pch, 1.1, NONE mwerks_nscarbon_config.h, 1.9.2.1, NONE mwerks_pyexpat_config.h, 1.2.4.1, NONE mwerks_shcarbon.pch, 1.1, NONE mwerks_shcarbon_config.h, 1.8, NONE mwerks_smcarbon.pch, 1.1, NONE mwerks_smcarbon_config.h, 1.1, NONE mwerks_thrcarbonsm_config.h, 1.6, NONE mwerks_threadsmall_config.h, 1.6, NONE mwerks_tkplugin_config.h, 1.8, NONE mwfopenrf.c, 1.5, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Mac/mwerks In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12896/Mac/mwerks Removed Files: Tag: ast-branch errno_unix.h macuseshlstart.c mwerks_nscarbon.pch mwerks_nscarbon_config.h mwerks_pyexpat_config.h mwerks_shcarbon.pch mwerks_shcarbon_config.h mwerks_smcarbon.pch mwerks_smcarbon_config.h mwerks_thrcarbonsm_config.h mwerks_threadsmall_config.h mwerks_tkplugin_config.h mwfopenrf.c Log Message: Merge MAIN into ast-branch cvs up -kk -j mrg_to_ast-branch_24APR03 -j mrg_to_ast-branch_05JAN05 (date of earlier merge estimated 24Apr03 17:30 UTC, repository tagged) Not merged: Lib/test/test_compile.py, Python/compile.c Refer to Tracker Patch # 1097671 for the merge output and list of conflicts resolved. --- errno_unix.h DELETED --- --- macuseshlstart.c DELETED --- --- mwerks_nscarbon.pch DELETED --- --- mwerks_nscarbon_config.h DELETED --- --- mwerks_pyexpat_config.h DELETED --- --- mwerks_shcarbon.pch DELETED --- --- mwerks_shcarbon_config.h DELETED --- --- mwerks_smcarbon.pch DELETED --- --- mwerks_smcarbon_config.h DELETED --- --- mwerks_thrcarbonsm_config.h DELETED --- --- mwerks_threadsmall_config.h DELETED --- --- mwerks_tkplugin_config.h DELETED --- --- mwfopenrf.c DELETED --- From kbk at users.sourceforge.net Fri Jan 7 08:03:42 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Fri Jan 7 08:03:47 2005 Subject: [Python-checkins] python/dist/src/Modules/cjkcodecs README, NONE, 1.3.4.1 _codecs_cn.c, NONE, 1.1.6.1 _codecs_hk.c, NONE, 1.2.4.1 _codecs_iso2022.c, NONE, 1.3.4.1 _codecs_jp.c, NONE, 1.1.6.1 _codecs_kr.c, NONE, 1.1.6.1 _codecs_tw.c, NONE, 1.1.6.1 alg_jisx0201.h, NONE, 1.2.6.1 cjkcodecs.h, NONE, 1.5.4.1 emu_jisx0213_2000.h, NONE, 1.1.6.1 mappings_cn.h, NONE, 1.1.6.1 mappings_hk.h, NONE, 1.1.6.1 mappings_jisx0213_pair.h, NONE, 1.1.6.1 mappings_jp.h, NONE, 1.1.6.1 mappings_kr.h, NONE, 1.1.6.1 mappings_tw.h, NONE, 1.1.6.1 multibytecodec.c, NONE, 1.3.4.1 multibytecodec.h, NONE, 1.2.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Modules/cjkcodecs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12896/Modules/cjkcodecs Added Files: Tag: ast-branch README _codecs_cn.c _codecs_hk.c _codecs_iso2022.c _codecs_jp.c _codecs_kr.c _codecs_tw.c alg_jisx0201.h cjkcodecs.h emu_jisx0213_2000.h mappings_cn.h mappings_hk.h mappings_jisx0213_pair.h mappings_jp.h mappings_kr.h mappings_tw.h multibytecodec.c multibytecodec.h Log Message: Merge MAIN into ast-branch cvs up -kk -j mrg_to_ast-branch_24APR03 -j mrg_to_ast-branch_05JAN05 (date of earlier merge estimated 24Apr03 17:30 UTC, repository tagged) Not merged: Lib/test/test_compile.py, Python/compile.c Refer to Tracker Patch # 1097671 for the merge output and list of conflicts resolved. --- NEW FILE: README --- Notes on cjkcodecs ------------------- This directory contains source files for cjkcodecs extension modules. They are based on CJKCodecs (http://cjkpython.i18n.org/#CJKCodecs) as of Aug 20 2004 currently. To generate or modify mapping headers ------------------------------------- Mapping headers are imported from CJKCodecs as pre-generated form. If you need to tweak or add something on it, please look at tools/ subdirectory of CJKCodecs' distribution. Notes on implmentation characteristics of each codecs ----------------------------------------------------- 1) Big5 codec The big5 codec maps the following characters as cp950 does rather than conforming Unicode.org's that maps to 0xFFFD. BIG5 Unicode Description 0xA15A 0x2574 SPACING UNDERSCORE 0xA1C3 0xFFE3 SPACING HEAVY OVERSCORE 0xA1C5 0x02CD SPACING HEAVY UNDERSCORE 0xA1FE 0xFF0F LT DIAG UP RIGHT TO LOW LEFT 0xA240 0xFF3C LT DIAG UP LEFT TO LOW RIGHT 0xA2CC 0x5341 HANGZHOU NUMERAL TEN 0xA2CE 0x5345 HANGZHOU NUMERAL THIRTY Because unicode 0x5341, 0x5345, 0xFF0F, 0xFF3C is mapped to another big5 codes already, a roundtrip compatibility is not guaranteed for them. 2) cp932 codec To conform to Windows's real mapping, cp932 codec maps the following codepoints in addition of the official cp932 mapping. CP932 Unicode Description 0x80 0x80 UNDEFINED 0xA0 0xF8F0 UNDEFINED 0xFD 0xF8F1 UNDEFINED 0xFE 0xF8F2 UNDEFINED 0xFF 0xF8F3 UNDEFINED 3) euc-jisx0213 codec The euc-jisx0213 codec maps JIS X 0213 Plane 1 code 0x2140 into unicode U+FF3C instead of U+005C as on unicode.org's mapping. Because euc-jisx0213 has REVERSE SOLIDUS on 0x5c already and A140 is shown as a full width character, mapping to U+FF3C can make more sense. The euc-jisx0213 codec is enabled to decode JIS X 0212 codes on codeset 2. Because JIS X 0212 and JIS X 0213 Plane 2 don't have overlapped by each other, it doesn't bother standard conformations (and JIS X 0213 Plane 2 is intended to use so.) On encoding sessions, the codec will try to encode kanji characters in this order: JIS X 0213 Plane 1 -> JIS X 0213 Plane 2 -> JIS X 0212 4) euc-jp codec The euc-jp codec is a compatibility instance on these points: - U+FF3C FULLWIDTH REVERSE SOLIDUS is mapped to EUC-JP A1C0 (vice versa) - U+00A5 YEN SIGN is mapped to EUC-JP 0x5c. (one way) - U+203E OVERLINE is mapped to EUC-JP 0x7e. (one way) 5) shift-jis codec The shift-jis codec is mapping 0x20-0x7e area to U+20-U+7E directly instead of using JIS X 0201 for compatibility. The differences are: - U+005C REVERSE SOLIDUS is mapped to SHIFT-JIS 0x5c. - U+007E TILDE is mapped to SHIFT-JIS 0x7e. - U+FF3C FULL-WIDTH REVERSE SOLIDUS is mapped to SHIFT-JIS 815f. --- NEW FILE: _codecs_cn.c --- /* * _codecs_cn.c: Codecs collection for Mainland Chinese encodings * * Written by Hye-Shik Chang * $CJKCodecs: _codecs_cn.c,v 1.8 2004/07/07 14:59:26 perky Exp $ */ #include "cjkcodecs.h" #include "mappings_cn.h" #define GBK_PREDECODE(dc1, dc2, assi) \ if ((dc1) == 0xa1 && (dc2) == 0xaa) (assi) = 0x2014; \ else if ((dc1) == 0xa8 && (dc2) == 0x44) (assi) = 0x2015; \ else if ((dc1) == 0xa1 && (dc2) == 0xa4) (assi) = 0x00b7; #define GBK_PREENCODE(code, assi) \ if ((code) == 0x2014) (assi) = 0xa1aa; \ else if ((code) == 0x2015) (assi) = 0xa844; \ else if ((code) == 0x00b7) (assi) = 0xa1a4; /* * GB2312 codec */ ENCODER(gb2312) { while (inleft > 0) { Py_UNICODE c = IN1; DBCHAR code; if (c < 0x80) { WRITE1((unsigned char)c) NEXT(1, 1) continue; } UCS4INVALID(c) REQUIRE_OUTBUF(2) TRYMAP_ENC(gbcommon, code, c); else return 1; if (code & 0x8000) /* MSB set: GBK */ return 1; OUT1((code >> 8) | 0x80) OUT2((code & 0xFF) | 0x80) NEXT(1, 2) } return 0; } DECODER(gb2312) { while (inleft > 0) { unsigned char c = **inbuf; REQUIRE_OUTBUF(1) if (c < 0x80) { OUT1(c) NEXT(1, 1) continue; } REQUIRE_INBUF(2) TRYMAP_DEC(gb2312, **outbuf, c ^ 0x80, IN2 ^ 0x80) { NEXT(2, 1) } else return 2; } return 0; } /* * GBK codec */ ENCODER(gbk) { while (inleft > 0) { Py_UNICODE c = IN1; DBCHAR code; if (c < 0x80) { WRITE1((unsigned char)c) NEXT(1, 1) continue; } UCS4INVALID(c) REQUIRE_OUTBUF(2) GBK_PREENCODE(c, code) else TRYMAP_ENC(gbcommon, code, c); else return 1; OUT1((code >> 8) | 0x80) if (code & 0x8000) OUT2((code & 0xFF)) /* MSB set: GBK */ else OUT2((code & 0xFF) | 0x80) /* MSB unset: GB2312 */ NEXT(1, 2) } return 0; } DECODER(gbk) { while (inleft > 0) { unsigned char c = IN1; REQUIRE_OUTBUF(1) if (c < 0x80) { OUT1(c) NEXT(1, 1) continue; } REQUIRE_INBUF(2) GBK_PREDECODE(c, IN2, **outbuf) else TRYMAP_DEC(gb2312, **outbuf, c ^ 0x80, IN2 ^ 0x80); else TRYMAP_DEC(gbkext, **outbuf, c, IN2); else return 2; NEXT(2, 1) } return 0; } /* * GB18030 codec */ ENCODER(gb18030) { while (inleft > 0) { ucs4_t c = IN1; DBCHAR code; if (c < 0x80) { WRITE1(c) NEXT(1, 1) continue; } DECODE_SURROGATE(c) if (c > 0x10FFFF) #if Py_UNICODE_SIZE == 2 return 2; /* surrogates pair */ #else return 1; #endif else if (c >= 0x10000) { ucs4_t tc = c - 0x10000; REQUIRE_OUTBUF(4) OUT4((unsigned char)(tc % 10) + 0x30) tc /= 10; OUT3((unsigned char)(tc % 126) + 0x81) tc /= 126; OUT2((unsigned char)(tc % 10) + 0x30) tc /= 10; OUT1((unsigned char)(tc + 0x90)) #if Py_UNICODE_SIZE == 2 NEXT(2, 4) /* surrogates pair */ #else NEXT(1, 4) #endif continue; } REQUIRE_OUTBUF(2) GBK_PREENCODE(c, code) else TRYMAP_ENC(gbcommon, code, c); else TRYMAP_ENC(gb18030ext, code, c); else { const struct _gb18030_to_unibmp_ranges *utrrange; REQUIRE_OUTBUF(4) for (utrrange = gb18030_to_unibmp_ranges; utrrange->first != 0; utrrange++) if (utrrange->first <= c && c <= utrrange->last) { Py_UNICODE tc; tc = c - utrrange->first + utrrange->base; OUT4((unsigned char)(tc % 10) + 0x30) tc /= 10; OUT3((unsigned char)(tc % 126) + 0x81) tc /= 126; OUT2((unsigned char)(tc % 10) + 0x30) tc /= 10; OUT1((unsigned char)tc + 0x81) NEXT(1, 4) break; } if (utrrange->first == 0) { PyErr_SetString(PyExc_RuntimeError, "unicode mapping invalid"); return 1; } continue; } OUT1((code >> 8) | 0x80) if (code & 0x8000) OUT2((code & 0xFF)) /* MSB set: GBK or GB18030ext */ else OUT2((code & 0xFF) | 0x80) /* MSB unset: GB2312 */ NEXT(1, 2) } return 0; } DECODER(gb18030) { while (inleft > 0) { unsigned char c = IN1, c2; REQUIRE_OUTBUF(1) if (c < 0x80) { OUT1(c) NEXT(1, 1) continue; } REQUIRE_INBUF(2) c2 = IN2; if (c2 >= 0x30 && c2 <= 0x39) { /* 4 bytes seq */ const struct _gb18030_to_unibmp_ranges *utr; unsigned char c3, c4; ucs4_t lseq; REQUIRE_INBUF(4) c3 = IN3; c4 = IN4; if (c < 0x81 || c3 < 0x81 || c4 < 0x30 || c4 > 0x39) return 4; c -= 0x81; c2 -= 0x30; c3 -= 0x81; c4 -= 0x30; if (c < 4) { /* U+0080 - U+FFFF */ lseq = ((ucs4_t)c * 10 + c2) * 1260 + (ucs4_t)c3 * 10 + c4; if (lseq < 39420) { for (utr = gb18030_to_unibmp_ranges; lseq >= (utr + 1)->base; utr++) ; OUT1(utr->first - utr->base + lseq) NEXT(4, 1) continue; } } else if (c >= 15) { /* U+10000 - U+10FFFF */ lseq = 0x10000 + (((ucs4_t)c-15) * 10 + c2) * 1260 + (ucs4_t)c3 * 10 + c4; if (lseq <= 0x10FFFF) { WRITEUCS4(lseq); NEXT_IN(4) continue; } } return 4; } GBK_PREDECODE(c, c2, **outbuf) else TRYMAP_DEC(gb2312, **outbuf, c ^ 0x80, c2 ^ 0x80); else TRYMAP_DEC(gbkext, **outbuf, c, c2); else TRYMAP_DEC(gb18030ext, **outbuf, c, c2); else return 2; NEXT(2, 1) } return 0; } /* * HZ codec */ ENCODER_INIT(hz) { state->i = 0; return 0; } ENCODER_RESET(hz) { if (state->i != 0) { WRITE2('~', '}') state->i = 0; NEXT_OUT(2) } return 0; } ENCODER(hz) { while (inleft > 0) { Py_UNICODE c = IN1; DBCHAR code; if (c < 0x80) { if (state->i == 0) { WRITE1((unsigned char)c) NEXT(1, 1) } else { WRITE3('~', '}', (unsigned char)c) NEXT(1, 3) state->i = 0; } continue; } UCS4INVALID(c) TRYMAP_ENC(gbcommon, code, c); else return 1; if (code & 0x8000) /* MSB set: GBK */ return 1; if (state->i == 0) { WRITE4('~', '{', code >> 8, code & 0xff) NEXT(1, 4) state->i = 1; } else { WRITE2(code >> 8, code & 0xff) NEXT(1, 2) } } return 0; } DECODER_INIT(hz) { state->i = 0; return 0; } DECODER_RESET(hz) { state->i = 0; return 0; } DECODER(hz) { while (inleft > 0) { unsigned char c = IN1; if (c == '~') { unsigned char c2 = IN2; REQUIRE_INBUF(2) if (c2 == '~') { WRITE1('~') NEXT(2, 1) continue; } else if (c2 == '{' && state->i == 0) state->i = 1; /* set GB */ else if (c2 == '}' && state->i == 1) state->i = 0; /* set ASCII */ else if (c2 == '\n') ; /* line-continuation */ else return 2; NEXT(2, 0); continue; } if (c & 0x80) return 1; if (state->i == 0) { /* ASCII mode */ WRITE1(c) NEXT(1, 1) } else { /* GB mode */ REQUIRE_INBUF(2) REQUIRE_OUTBUF(1) TRYMAP_DEC(gb2312, **outbuf, c, IN2) { NEXT(2, 1) } else return 2; } } return 0; } BEGIN_MAPPINGS_LIST MAPPING_DECONLY(gb2312) MAPPING_DECONLY(gbkext) MAPPING_ENCONLY(gbcommon) MAPPING_ENCDEC(gb18030ext) END_MAPPINGS_LIST BEGIN_CODECS_LIST CODEC_STATELESS(gb2312) CODEC_STATELESS(gbk) CODEC_STATELESS(gb18030) CODEC_STATEFUL(hz) END_CODECS_LIST I_AM_A_MODULE_FOR(cn) --- NEW FILE: _codecs_hk.c --- /* * _codecs_hk.c: Codecs collection for encodings from Hong Kong * * Written by Hye-Shik Chang * $CJKCodecs: _codecs_hk.c,v 1.4 2004/07/18 04:44:27 perky Exp $ */ #define USING_IMPORTED_MAPS #include "cjkcodecs.h" #include "mappings_hk.h" /* * BIG5HKSCS codec */ static const encode_map *big5_encmap = NULL; static const decode_map *big5_decmap = NULL; CODEC_INIT(big5hkscs) { static int initialized = 0; if (!initialized && IMPORT_MAP(tw, big5, &big5_encmap, &big5_decmap)) return -1; initialized = 1; return 0; } ENCODER(big5hkscs) { while (inleft > 0) { ucs4_t c = **inbuf; DBCHAR code; int insize; if (c < 0x80) { REQUIRE_OUTBUF(1) **outbuf = (unsigned char)c; NEXT(1, 1) continue; } DECODE_SURROGATE(c) insize = GET_INSIZE(c); REQUIRE_OUTBUF(2) if (c < 0x10000) { TRYMAP_ENC(big5hkscs_bmp, code, c); else TRYMAP_ENC(big5, code, c); else return 1; } else if (c < 0x20000) return insize; else if (c < 0x30000) { TRYMAP_ENC(big5hkscs_nonbmp, code, c & 0xffff); else return insize; } else return insize; OUT1(code >> 8) OUT2(code & 0xFF) NEXT(insize, 2) } return 0; } #define BH2S(c1, c2) (((c1) - 0x88) * (0xfe - 0x40 + 1) + ((c2) - 0x40)) DECODER(big5hkscs) { while (inleft > 0) { unsigned char c = IN1; ucs4_t decoded; REQUIRE_OUTBUF(1) if (c < 0x80) { OUT1(c) NEXT(1, 1) continue; } REQUIRE_INBUF(2) if (0xc6 <= c && c <= 0xc8 && (c >= 0xc7 || IN2 >= 0xa1)) goto hkscsdec; TRYMAP_DEC(big5, **outbuf, c, IN2) { NEXT(2, 1) } else hkscsdec: TRYMAP_DEC(big5hkscs, decoded, c, IN2) { int s = BH2S(c, IN2); const unsigned char *hintbase; assert(0x88 <= c && c <= 0xfe); assert(0x40 <= IN2 && IN2 <= 0xfe); if (BH2S(0x88, 0x40) <= s && s <= BH2S(0xa0, 0xfe)) { hintbase = big5hkscs_phint_0; s -= BH2S(0x88, 0x40); } else if (BH2S(0xc6,0xa1) <= s && s <= BH2S(0xc8,0xfe)){ hintbase = big5hkscs_phint_11939; s -= BH2S(0xc6, 0xa1); } else if (BH2S(0xf9,0xd6) <= s && s <= BH2S(0xfe,0xfe)){ hintbase = big5hkscs_phint_21733; s -= BH2S(0xf9, 0xd6); } else return MBERR_INTERNAL; if (hintbase[s >> 3] & (1 << (s & 7))) { WRITEUCS4(decoded | 0x20000) NEXT_IN(2) } else { OUT1(decoded) NEXT(2, 1) } } else return 2; } return 0; } BEGIN_MAPPINGS_LIST MAPPING_DECONLY(big5hkscs) MAPPING_ENCONLY(big5hkscs_bmp) MAPPING_ENCONLY(big5hkscs_nonbmp) END_MAPPINGS_LIST BEGIN_CODECS_LIST CODEC_STATELESS_WINIT(big5hkscs) END_CODECS_LIST I_AM_A_MODULE_FOR(hk) --- NEW FILE: _codecs_iso2022.c --- /* * _codecs_iso2022.c: Codecs collection for ISO-2022 encodings. * * Written by Hye-Shik Chang * $CJKCodecs: _codecs_iso2022.c,v 1.22 2004/08/19 17:08:13 perky Exp $ */ #define USING_IMPORTED_MAPS #define USING_BINARY_PAIR_SEARCH #define EXTERN_JISX0213_PAIR #define EMULATE_JISX0213_2000_ENCODE_INVALID MAP_UNMAPPABLE #define EMULATE_JISX0213_2000_DECODE_INVALID MAP_UNMAPPABLE #include "cjkcodecs.h" #include "alg_jisx0201.h" #include "emu_jisx0213_2000.h" #include "mappings_jisx0213_pair.h" /* STATE [...1082 lines suppressed...] END_MAPPINGS_LIST #define ISO2022_CODEC(variation) { \ "iso2022_" #variation, \ &iso2022_##variation##_config, \ iso2022_codec_init, \ _STATEFUL_METHODS(iso2022) \ }, BEGIN_CODECS_LIST ISO2022_CODEC(kr) ISO2022_CODEC(jp) ISO2022_CODEC(jp_1) ISO2022_CODEC(jp_2) ISO2022_CODEC(jp_2004) ISO2022_CODEC(jp_3) ISO2022_CODEC(jp_ext) END_CODECS_LIST I_AM_A_MODULE_FOR(iso2022) --- NEW FILE: _codecs_jp.c --- /* * _codecs_jp.c: Codecs collection for Japanese encodings * * Written by Hye-Shik Chang * $CJKCodecs: _codecs_jp.c,v 1.14 2004/07/07 17:54:47 perky Exp $ */ #define USING_BINARY_PAIR_SEARCH #define EMPBASE 0x20000 #include "cjkcodecs.h" #include "mappings_jp.h" #include "mappings_jisx0213_pair.h" #include "alg_jisx0201.h" #include "emu_jisx0213_2000.h" /* * CP932 codec */ ENCODER(cp932) { while (inleft > 0) { Py_UNICODE c = IN1; DBCHAR code; unsigned char c1, c2; if (c <= 0x80) { WRITE1((unsigned char)c) NEXT(1, 1) continue; } else if (c >= 0xff61 && c <= 0xff9f) { WRITE1(c - 0xfec0) NEXT(1, 1) continue; } else if (c >= 0xf8f0 && c <= 0xf8f3) { /* Windows compatability */ REQUIRE_OUTBUF(1) if (c == 0xf8f0) OUT1(0xa0) else OUT1(c - 0xfef1 + 0xfd) NEXT(1, 1) continue; } UCS4INVALID(c) REQUIRE_OUTBUF(2) TRYMAP_ENC(cp932ext, code, c) { OUT1(code >> 8) OUT2(code & 0xff) } else TRYMAP_ENC(jisxcommon, code, c) { if (code & 0x8000) /* MSB set: JIS X 0212 */ return 1; /* JIS X 0208 */ c1 = code >> 8; c2 = code & 0xff; c2 = (((c1 - 0x21) & 1) ? 0x5e : 0) + (c2 - 0x21); c1 = (c1 - 0x21) >> 1; OUT1(c1 < 0x1f ? c1 + 0x81 : c1 + 0xc1) OUT2(c2 < 0x3f ? c2 + 0x40 : c2 + 0x41) } else if (c >= 0xe000 && c < 0xe758) { /* User-defined area */ c1 = (Py_UNICODE)(c - 0xe000) / 188; c2 = (Py_UNICODE)(c - 0xe000) % 188; OUT1(c1 + 0xf0) OUT2(c2 < 0x3f ? c2 + 0x40 : c2 + 0x41) } else return 1; NEXT(1, 2) } return 0; } DECODER(cp932) { while (inleft > 0) { unsigned char c = IN1, c2; REQUIRE_OUTBUF(1) if (c <= 0x80) { OUT1(c) NEXT(1, 1) continue; } else if (c >= 0xa0 && c <= 0xdf) { if (c == 0xa0) OUT1(0xf8f0) /* half-width katakana */ else OUT1(0xfec0 + c) NEXT(1, 1) continue; } else if (c >= 0xfd/* && c <= 0xff*/) { /* Windows compatibility */ OUT1(0xf8f1 - 0xfd + c) NEXT(1, 1) continue; } REQUIRE_INBUF(2) c2 = IN2; TRYMAP_DEC(cp932ext, **outbuf, c, c2); else if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea)){ if (c2 < 0x40 || (c2 > 0x7e && c2 < 0x80) || c2 > 0xfc) return 2; c = (c < 0xe0 ? c - 0x81 : c - 0xc1); c2 = (c2 < 0x80 ? c2 - 0x40 : c2 - 0x41); c = (2 * c + (c2 < 0x5e ? 0 : 1) + 0x21); c2 = (c2 < 0x5e ? c2 : c2 - 0x5e) + 0x21; TRYMAP_DEC(jisx0208, **outbuf, c, c2); else return 2; } else if (c >= 0xf0 && c <= 0xf9) { if ((c2 >= 0x40 && c2 <= 0x7e) || (c2 >= 0x80 && c2 <= 0xfc)) OUT1(0xe000 + 188 * (c - 0xf0) + (c2 < 0x80 ? c2 - 0x40 : c2 - 0x41)) else return 2; } else return 2; NEXT(2, 1) } return 0; } /* * EUC-JIS-2004 codec */ ENCODER(euc_jis_2004) { while (inleft > 0) { ucs4_t c = IN1; DBCHAR code; int insize; if (c < 0x80) { WRITE1(c) NEXT(1, 1) continue; } DECODE_SURROGATE(c) insize = GET_INSIZE(c); if (c <= 0xFFFF) { EMULATE_JISX0213_2000_ENCODE_BMP(code, c) else TRYMAP_ENC(jisx0213_bmp, code, c) { if (code == MULTIC) { if (inleft < 2) { if (flags & MBENC_FLUSH) { code = find_pairencmap( (ucs2_t)c, 0, jisx0213_pair_encmap, JISX0213_ENCPAIRS); if (code == DBCINV) return 1; } else return MBERR_TOOFEW; } else { code = find_pairencmap( (ucs2_t)c, (*inbuf)[1], jisx0213_pair_encmap, JISX0213_ENCPAIRS); if (code == DBCINV) { code = find_pairencmap( (ucs2_t)c, 0, jisx0213_pair_encmap, JISX0213_ENCPAIRS); if (code == DBCINV) return 1; } else insize = 2; } } } else TRYMAP_ENC(jisxcommon, code, c); else if (c >= 0xff61 && c <= 0xff9f) { /* JIS X 0201 half-width katakana */ WRITE2(0x8e, c - 0xfec0) NEXT(1, 2) continue; } else if (c == 0xff3c) /* F/W REVERSE SOLIDUS (see NOTES) */ code = 0x2140; else if (c == 0xff5e) /* F/W TILDE (see NOTES) */ code = 0x2232; else return 1; } else if (c >> 16 == EMPBASE >> 16) { EMULATE_JISX0213_2000_ENCODE_EMP(code, c) else TRYMAP_ENC(jisx0213_emp, code, c & 0xffff); else return insize; } else return insize; if (code & 0x8000) { /* Codeset 2 */ WRITE3(0x8f, code >> 8, (code & 0xFF) | 0x80) NEXT(insize, 3) } else { /* Codeset 1 */ WRITE2((code >> 8) | 0x80, (code & 0xFF) | 0x80) NEXT(insize, 2) } } return 0; } DECODER(euc_jis_2004) { while (inleft > 0) { unsigned char c = IN1; ucs4_t code; REQUIRE_OUTBUF(1) if (c < 0x80) { OUT1(c) NEXT(1, 1) continue; } if (c == 0x8e) { /* JIS X 0201 half-width katakana */ unsigned char c2; REQUIRE_INBUF(2) c2 = IN2; if (c2 >= 0xa1 && c2 <= 0xdf) { OUT1(0xfec0 + c2) NEXT(2, 1) } else return 2; } else if (c == 0x8f) { unsigned char c2, c3; REQUIRE_INBUF(3) c2 = IN2 ^ 0x80; c3 = IN3 ^ 0x80; /* JIS X 0213 Plane 2 or JIS X 0212 (see NOTES) */ EMULATE_JISX0213_2000_DECODE_PLANE2(**outbuf, c2, c3) else TRYMAP_DEC(jisx0213_2_bmp, **outbuf, c2, c3) ; else TRYMAP_DEC(jisx0213_2_emp, code, c2, c3) { WRITEUCS4(EMPBASE | code) NEXT_IN(3) continue; } else TRYMAP_DEC(jisx0212, **outbuf, c2, c3) ; else return 3; NEXT(3, 1) } else { unsigned char c2; REQUIRE_INBUF(2) c ^= 0x80; c2 = IN2 ^ 0x80; /* JIS X 0213 Plane 1 */ EMULATE_JISX0213_2000_DECODE_PLANE1(**outbuf, c, c2) else if (c == 0x21 && c2 == 0x40) **outbuf = 0xff3c; else if (c == 0x22 && c2 == 0x32) **outbuf = 0xff5e; else TRYMAP_DEC(jisx0208, **outbuf, c, c2); else TRYMAP_DEC(jisx0213_1_bmp, **outbuf, c, c2); else TRYMAP_DEC(jisx0213_1_emp, code, c, c2) { WRITEUCS4(EMPBASE | code) NEXT_IN(2) continue; } else TRYMAP_DEC(jisx0213_pair, code, c, c2) { WRITE2(code >> 16, code & 0xffff) NEXT(2, 2) continue; } else return 2; NEXT(2, 1) } } return 0; } /* * EUC-JP codec */ ENCODER(euc_jp) { while (inleft > 0) { Py_UNICODE c = IN1; DBCHAR code; if (c < 0x80) { WRITE1((unsigned char)c) NEXT(1, 1) continue; } UCS4INVALID(c) TRYMAP_ENC(jisxcommon, code, c); else if (c >= 0xff61 && c <= 0xff9f) { /* JIS X 0201 half-width katakana */ WRITE2(0x8e, c - 0xfec0) NEXT(1, 2) continue; } #ifndef STRICT_BUILD else if (c == 0xff3c) /* FULL-WIDTH REVERSE SOLIDUS */ code = 0x2140; else if (c == 0xa5) { /* YEN SIGN */ WRITE1(0x5c); NEXT(1, 1) continue; } else if (c == 0x203e) { /* OVERLINE */ WRITE1(0x7e); NEXT(1, 1) continue; } #endif else return 1; if (code & 0x8000) { /* JIS X 0212 */ WRITE3(0x8f, code >> 8, (code & 0xFF) | 0x80) NEXT(1, 3) } else { /* JIS X 0208 */ WRITE2((code >> 8) | 0x80, (code & 0xFF) | 0x80) NEXT(1, 2) } } return 0; } DECODER(euc_jp) { while (inleft > 0) { unsigned char c = IN1; REQUIRE_OUTBUF(1) if (c < 0x80) { OUT1(c) NEXT(1, 1) continue; } if (c == 0x8e) { /* JIS X 0201 half-width katakana */ unsigned char c2; REQUIRE_INBUF(2) c2 = IN2; if (c2 >= 0xa1 && c2 <= 0xdf) { OUT1(0xfec0 + c2) NEXT(2, 1) } else return 2; } else if (c == 0x8f) { unsigned char c2, c3; REQUIRE_INBUF(3) c2 = IN2; c3 = IN3; /* JIS X 0212 */ TRYMAP_DEC(jisx0212, **outbuf, c2 ^ 0x80, c3 ^ 0x80) { NEXT(3, 1) } else return 3; } else { unsigned char c2; REQUIRE_INBUF(2) c2 = IN2; /* JIS X 0208 */ #ifndef STRICT_BUILD if (c == 0xa1 && c2 == 0xc0) /* FULL-WIDTH REVERSE SOLIDUS */ **outbuf = 0xff3c; else #endif TRYMAP_DEC(jisx0208, **outbuf, c ^ 0x80, c2 ^ 0x80) ; else return 2; NEXT(2, 1) } } return 0; } /* * SHIFT_JIS codec */ ENCODER(shift_jis) { while (inleft > 0) { Py_UNICODE c = IN1; DBCHAR code; unsigned char c1, c2; #ifdef STRICT_BUILD JISX0201_R_ENCODE(c, code) #else if (c < 0x80) code = c; else if (c == 0x00a5) code = 0x5c; /* YEN SIGN */ else if (c == 0x203e) code = 0x7e; /* OVERLINE */ #endif else JISX0201_K_ENCODE(c, code) else UCS4INVALID(c) else code = NOCHAR; if (code < 0x80 || (code >= 0xa1 && code <= 0xdf)) { REQUIRE_OUTBUF(1) OUT1((unsigned char)code) NEXT(1, 1) continue; } REQUIRE_OUTBUF(2) if (code == NOCHAR) { TRYMAP_ENC(jisxcommon, code, c); #ifndef STRICT_BUILD else if (c == 0xff3c) code = 0x2140; /* FULL-WIDTH REVERSE SOLIDUS */ #endif else return 1; if (code & 0x8000) /* MSB set: JIS X 0212 */ return 1; } c1 = code >> 8; c2 = code & 0xff; c2 = (((c1 - 0x21) & 1) ? 0x5e : 0) + (c2 - 0x21); c1 = (c1 - 0x21) >> 1; OUT1(c1 < 0x1f ? c1 + 0x81 : c1 + 0xc1) OUT2(c2 < 0x3f ? c2 + 0x40 : c2 + 0x41) NEXT(1, 2) } return 0; } DECODER(shift_jis) { while (inleft > 0) { unsigned char c = IN1; REQUIRE_OUTBUF(1) #ifdef STRICT_BUILD JISX0201_R_DECODE(c, **outbuf) #else if (c < 0x80) **outbuf = c; #endif else JISX0201_K_DECODE(c, **outbuf) else if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea)){ unsigned char c1, c2; REQUIRE_INBUF(2) c2 = IN2; if (c2 < 0x40 || (c2 > 0x7e && c2 < 0x80) || c2 > 0xfc) return 2; c1 = (c < 0xe0 ? c - 0x81 : c - 0xc1); c2 = (c2 < 0x80 ? c2 - 0x40 : c2 - 0x41); c1 = (2 * c1 + (c2 < 0x5e ? 0 : 1) + 0x21); c2 = (c2 < 0x5e ? c2 : c2 - 0x5e) + 0x21; #ifndef STRICT_BUILD if (c1 == 0x21 && c2 == 0x40) { /* FULL-WIDTH REVERSE SOLIDUS */ OUT1(0xff3c) NEXT(2, 1) continue; } #endif TRYMAP_DEC(jisx0208, **outbuf, c1, c2) { NEXT(2, 1) continue; } else return 2; } else return 2; NEXT(1, 1) /* JIS X 0201 */ } return 0; } /* * SHIFT_JIS-2004 codec */ ENCODER(shift_jis_2004) { while (inleft > 0) { ucs4_t c = IN1; DBCHAR code = NOCHAR; int c1, c2; size_t insize; JISX0201_ENCODE(c, code) else DECODE_SURROGATE(c) if (code < 0x80 || (code >= 0xa1 && code <= 0xdf)) { WRITE1((unsigned char)code) NEXT(1, 1) continue; } REQUIRE_OUTBUF(2) insize = GET_INSIZE(c); if (code == NOCHAR) { if (c <= 0xffff) { EMULATE_JISX0213_2000_ENCODE_BMP(code, c) else TRYMAP_ENC(jisx0213_bmp, code, c) { if (code == MULTIC) { if (inleft < 2) { if (flags & MBENC_FLUSH) { code = find_pairencmap ((ucs2_t)c, 0, jisx0213_pair_encmap, JISX0213_ENCPAIRS); if (code == DBCINV) return 1; } else return MBERR_TOOFEW; } else { code = find_pairencmap( (ucs2_t)c, IN2, jisx0213_pair_encmap, JISX0213_ENCPAIRS); if (code == DBCINV) { code = find_pairencmap( (ucs2_t)c, 0, jisx0213_pair_encmap, JISX0213_ENCPAIRS); if (code == DBCINV) return 1; } else insize = 2; } } } else TRYMAP_ENC(jisxcommon, code, c) { /* abandon JIS X 0212 codes */ if (code & 0x8000) return 1; } else return 1; } else if (c >> 16 == EMPBASE >> 16) { EMULATE_JISX0213_2000_ENCODE_EMP(code, c) else TRYMAP_ENC(jisx0213_emp, code, c&0xffff); else return insize; } else return insize; } c1 = code >> 8; c2 = (code & 0xff) - 0x21; if (c1 & 0x80) { /* Plane 2 */ if (c1 >= 0xee) c1 -= 0x87; else if (c1 >= 0xac || c1 == 0xa8) c1 -= 0x49; else c1 -= 0x43; } else /* Plane 1 */ c1 -= 0x21; if (c1 & 1) c2 += 0x5e; c1 >>= 1; OUT1(c1 + (c1 < 0x1f ? 0x81 : 0xc1)) OUT2(c2 + (c2 < 0x3f ? 0x40 : 0x41)) NEXT(insize, 2) } return 0; } DECODER(shift_jis_2004) { while (inleft > 0) { unsigned char c = IN1; REQUIRE_OUTBUF(1) JISX0201_DECODE(c, **outbuf) else if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xfc)){ unsigned char c1, c2 = IN2; ucs4_t code; REQUIRE_INBUF(2) if (c2 < 0x40 || (c2 > 0x7e && c2 < 0x80) || c2 > 0xfc) return 2; c1 = (c < 0xe0 ? c - 0x81 : c - 0xc1); c2 = (c2 < 0x80 ? c2 - 0x40 : c2 - 0x41); c1 = (2 * c1 + (c2 < 0x5e ? 0 : 1)); c2 = (c2 < 0x5e ? c2 : c2 - 0x5e) + 0x21; if (c1 < 0x5e) { /* Plane 1 */ c1 += 0x21; EMULATE_JISX0213_2000_DECODE_PLANE1(**outbuf, c1, c2) else TRYMAP_DEC(jisx0208, **outbuf, c1, c2) { NEXT_OUT(1) } else TRYMAP_DEC(jisx0213_1_bmp, **outbuf, c1, c2) { NEXT_OUT(1) } else TRYMAP_DEC(jisx0213_1_emp, code, c1, c2) { WRITEUCS4(EMPBASE | code) } else TRYMAP_DEC(jisx0213_pair, code, c1, c2) { WRITE2(code >> 16, code & 0xffff) NEXT_OUT(2) } else return 2; NEXT_IN(2) } else { /* Plane 2 */ if (c1 >= 0x67) c1 += 0x07; else if (c1 >= 0x63 || c1 == 0x5f) c1 -= 0x37; else c1 -= 0x3d; EMULATE_JISX0213_2000_DECODE_PLANE2(**outbuf, c1, c2) else TRYMAP_DEC(jisx0213_2_bmp, **outbuf, c1, c2) ; else TRYMAP_DEC(jisx0213_2_emp, code, c1, c2) { WRITEUCS4(EMPBASE | code) NEXT_IN(2) continue; } else return 2; NEXT(2, 1) } continue; } else return 2; NEXT(1, 1) /* JIS X 0201 */ } return 0; } BEGIN_MAPPINGS_LIST MAPPING_DECONLY(jisx0208) MAPPING_DECONLY(jisx0212) MAPPING_ENCONLY(jisxcommon) MAPPING_DECONLY(jisx0213_1_bmp) MAPPING_DECONLY(jisx0213_2_bmp) MAPPING_ENCONLY(jisx0213_bmp) MAPPING_DECONLY(jisx0213_1_emp) MAPPING_DECONLY(jisx0213_2_emp) MAPPING_ENCONLY(jisx0213_emp) MAPPING_ENCDEC(jisx0213_pair) MAPPING_ENCDEC(cp932ext) END_MAPPINGS_LIST BEGIN_CODECS_LIST CODEC_STATELESS(shift_jis) CODEC_STATELESS(cp932) CODEC_STATELESS(euc_jp) CODEC_STATELESS(shift_jis_2004) CODEC_STATELESS(euc_jis_2004) { "euc_jisx0213", (void *)2000, NULL, _STATELESS_METHODS(euc_jis_2004) }, { "shift_jisx0213", (void *)2000, NULL, _STATELESS_METHODS(shift_jis_2004) }, END_CODECS_LIST I_AM_A_MODULE_FOR(jp) --- NEW FILE: _codecs_kr.c --- /* * _codecs_kr.c: Codecs collection for Korean encodings * * Written by Hye-Shik Chang * $CJKCodecs: _codecs_kr.c,v 1.8 2004/07/07 14:59:26 perky Exp $ */ #include "cjkcodecs.h" #include "mappings_kr.h" /* * EUC-KR codec */ ENCODER(euc_kr) { while (inleft > 0) { Py_UNICODE c = IN1; DBCHAR code; if (c < 0x80) { WRITE1((unsigned char)c) NEXT(1, 1) continue; } UCS4INVALID(c) REQUIRE_OUTBUF(2) TRYMAP_ENC(cp949, code, c); else return 1; if (code & 0x8000) /* MSB set: CP949 */ return 1; OUT1((code >> 8) | 0x80) OUT2((code & 0xFF) | 0x80) NEXT(1, 2) } return 0; } DECODER(euc_kr) { while (inleft > 0) { unsigned char c = IN1; REQUIRE_OUTBUF(1) if (c < 0x80) { OUT1(c) NEXT(1, 1) continue; } REQUIRE_INBUF(2) TRYMAP_DEC(ksx1001, **outbuf, c ^ 0x80, IN2 ^ 0x80) { NEXT(2, 1) } else return 2; } return 0; } /* * CP949 codec */ ENCODER(cp949) { while (inleft > 0) { Py_UNICODE c = IN1; DBCHAR code; if (c < 0x80) { WRITE1((unsigned char)c) NEXT(1, 1) continue; } UCS4INVALID(c) REQUIRE_OUTBUF(2) TRYMAP_ENC(cp949, code, c); else return 1; OUT1((code >> 8) | 0x80) if (code & 0x8000) OUT2(code & 0xFF) /* MSB set: CP949 */ else OUT2((code & 0xFF) | 0x80) /* MSB unset: ks x 1001 */ NEXT(1, 2) } return 0; } DECODER(cp949) { while (inleft > 0) { unsigned char c = IN1; REQUIRE_OUTBUF(1) if (c < 0x80) { OUT1(c) NEXT(1, 1) continue; } REQUIRE_INBUF(2) TRYMAP_DEC(ksx1001, **outbuf, c ^ 0x80, IN2 ^ 0x80); else TRYMAP_DEC(cp949ext, **outbuf, c, IN2); else return 2; NEXT(2, 1) } return 0; } /* * JOHAB codec */ static const unsigned char u2johabidx_choseong[32] = { 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, }; static const unsigned char u2johabidx_jungseong[32] = { 0x03, 0x04, 0x05, 0x06, 0x07, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x1a, 0x1b, 0x1c, 0x1d, }; static const unsigned char u2johabidx_jongseong[32] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, }; static const DBCHAR u2johabjamo[] = { 0x8841, 0x8c41, 0x8444, 0x9041, 0x8446, 0x8447, 0x9441, 0x9841, 0x9c41, 0x844a, 0x844b, 0x844c, 0x844d, 0x844e, 0x844f, 0x8450, 0xa041, 0xa441, 0xa841, 0x8454, 0xac41, 0xb041, 0xb441, 0xb841, 0xbc41, 0xc041, 0xc441, 0xc841, 0xcc41, 0xd041, 0x8461, 0x8481, 0x84a1, 0x84c1, 0x84e1, 0x8541, 0x8561, 0x8581, 0x85a1, 0x85c1, 0x85e1, 0x8641, 0x8661, 0x8681, 0x86a1, 0x86c1, 0x86e1, 0x8741, 0x8761, 0x8781, 0x87a1, }; ENCODER(johab) { while (inleft > 0) { Py_UNICODE c = IN1; DBCHAR code; if (c < 0x80) { WRITE1((unsigned char)c) NEXT(1, 1) continue; } UCS4INVALID(c) REQUIRE_OUTBUF(2) if (c >= 0xac00 && c <= 0xd7a3) { c -= 0xac00; code = 0x8000 | (u2johabidx_choseong[c / 588] << 10) | (u2johabidx_jungseong[(c / 28) % 21] << 5) | u2johabidx_jongseong[c % 28]; } else if (c >= 0x3131 && c <= 0x3163) code = u2johabjamo[c - 0x3131]; else TRYMAP_ENC(cp949, code, c) { unsigned char c1, c2, t2; unsigned short t1; assert((code & 0x8000) == 0); c1 = code >> 8; c2 = code & 0xff; if (((c1 >= 0x21 && c1 <= 0x2c) || (c1 >= 0x4a && c1 <= 0x7d)) && (c2 >= 0x21 && c2 <= 0x7e)) { t1 = (c1 < 0x4a ? (c1 - 0x21 + 0x1b2) : (c1 - 0x21 + 0x197)); t2 = ((t1 & 1) ? 0x5e : 0) + (c2 - 0x21); OUT1(t1 >> 1) OUT2(t2 < 0x4e ? t2 + 0x31 : t2 + 0x43) NEXT(1, 2) continue; } else return 1; } else return 1; OUT1(code >> 8) OUT2(code & 0xff) NEXT(1, 2) } return 0; } #define FILL 0xfd #define NONE 0xff static const unsigned char johabidx_choseong[32] = { NONE, FILL, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, }; static const unsigned char johabidx_jungseong[32] = { NONE, NONE, FILL, 0x00, 0x01, 0x02, 0x03, 0x04, NONE, NONE, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, NONE, NONE, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, NONE, NONE, 0x11, 0x12, 0x13, 0x14, NONE, NONE, }; static const unsigned char johabidx_jongseong[32] = { NONE, FILL, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, NONE, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, NONE, NONE, }; static const unsigned char johabjamo_choseong[32] = { NONE, FILL, 0x31, 0x32, 0x34, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, }; static const unsigned char johabjamo_jungseong[32] = { NONE, NONE, FILL, 0x4f, 0x50, 0x51, 0x52, 0x53, NONE, NONE, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, NONE, NONE, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, NONE, NONE, 0x60, 0x61, 0x62, 0x63, NONE, NONE, }; static const unsigned char johabjamo_jongseong[32] = { NONE, FILL, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, NONE, 0x42, 0x44, 0x45, 0x46, 0x47, 0x48, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, NONE, NONE, }; DECODER(johab) { while (inleft > 0) { unsigned char c = IN1, c2; REQUIRE_OUTBUF(1) if (c < 0x80) { OUT1(c) NEXT(1, 1) continue; } REQUIRE_INBUF(2) c2 = IN2; if (c < 0xd8) { /* johab hangul */ unsigned char c_cho, c_jung, c_jong; unsigned char i_cho, i_jung, i_jong; c_cho = (c >> 2) & 0x1f; c_jung = ((c << 3) | c2 >> 5) & 0x1f; c_jong = c2 & 0x1f; i_cho = johabidx_choseong[c_cho]; i_jung = johabidx_jungseong[c_jung]; i_jong = johabidx_jongseong[c_jong]; if (i_cho == NONE || i_jung == NONE || i_jong == NONE) return 2; /* we don't use U+1100 hangul jamo yet. */ if (i_cho == FILL) { if (i_jung == FILL) { if (i_jong == FILL) OUT1(0x3000) else OUT1(0x3100 | johabjamo_jongseong[c_jong]) } else { if (i_jong == FILL) OUT1(0x3100 | johabjamo_jungseong[c_jung]) else return 2; } } else { if (i_jung == FILL) { if (i_jong == FILL) OUT1(0x3100 | johabjamo_choseong[c_cho]) else return 2; } else OUT1(0xac00 + i_cho * 588 + i_jung * 28 + (i_jong == FILL ? 0 : i_jong)) } NEXT(2, 1) } else { /* KS X 1001 except hangul jamos and syllables */ if (c == 0xdf || c > 0xf9 || c2 < 0x31 || (c2 >= 0x80 && c2 < 0x91) || (c2 & 0x7f) == 0x7f || (c == 0xda && (c2 >= 0xa1 && c2 <= 0xd3))) return 2; else { unsigned char t1, t2; t1 = (c < 0xe0 ? 2 * (c - 0xd9) : 2 * c - 0x197); t2 = (c2 < 0x91 ? c2 - 0x31 : c2 - 0x43); t1 = t1 + (t2 < 0x5e ? 0 : 1) + 0x21; t2 = (t2 < 0x5e ? t2 : t2 - 0x5e) + 0x21; TRYMAP_DEC(ksx1001, **outbuf, t1, t2); else return 2; NEXT(2, 1) } } } return 0; } #undef NONE #undef FILL BEGIN_MAPPINGS_LIST MAPPING_DECONLY(ksx1001) MAPPING_ENCONLY(cp949) MAPPING_DECONLY(cp949ext) END_MAPPINGS_LIST BEGIN_CODECS_LIST CODEC_STATELESS(euc_kr) CODEC_STATELESS(cp949) CODEC_STATELESS(johab) END_CODECS_LIST I_AM_A_MODULE_FOR(kr) --- NEW FILE: _codecs_tw.c --- /* * _codecs_tw.c: Codecs collection for Taiwan's encodings * * Written by Hye-Shik Chang * $CJKCodecs: _codecs_tw.c,v 1.10 2004/07/07 14:59:26 perky Exp $ */ #include "cjkcodecs.h" #include "mappings_tw.h" /* * BIG5 codec */ ENCODER(big5) { while (inleft > 0) { Py_UNICODE c = **inbuf; DBCHAR code; if (c < 0x80) { REQUIRE_OUTBUF(1) **outbuf = (unsigned char)c; NEXT(1, 1) continue; } UCS4INVALID(c) REQUIRE_OUTBUF(2) TRYMAP_ENC(big5, code, c); else return 1; OUT1(code >> 8) OUT2(code & 0xFF) NEXT(1, 2) } return 0; } DECODER(big5) { while (inleft > 0) { unsigned char c = IN1; REQUIRE_OUTBUF(1) if (c < 0x80) { OUT1(c) NEXT(1, 1) continue; } REQUIRE_INBUF(2) TRYMAP_DEC(big5, **outbuf, c, IN2) { NEXT(2, 1) } else return 2; } return 0; } /* * CP950 codec */ ENCODER(cp950) { while (inleft > 0) { Py_UNICODE c = IN1; DBCHAR code; if (c < 0x80) { WRITE1((unsigned char)c) NEXT(1, 1) continue; } UCS4INVALID(c) REQUIRE_OUTBUF(2) TRYMAP_ENC(cp950ext, code, c); else TRYMAP_ENC(big5, code, c); else return 1; OUT1(code >> 8) OUT2(code & 0xFF) NEXT(1, 2) } return 0; } DECODER(cp950) { while (inleft > 0) { unsigned char c = IN1; REQUIRE_OUTBUF(1) if (c < 0x80) { OUT1(c) NEXT(1, 1) continue; } REQUIRE_INBUF(2) TRYMAP_DEC(cp950ext, **outbuf, c, IN2); else TRYMAP_DEC(big5, **outbuf, c, IN2); else return 2; NEXT(2, 1) } return 0; } BEGIN_MAPPINGS_LIST MAPPING_ENCDEC(big5) MAPPING_ENCDEC(cp950ext) END_MAPPINGS_LIST BEGIN_CODECS_LIST CODEC_STATELESS(big5) CODEC_STATELESS(cp950) END_CODECS_LIST I_AM_A_MODULE_FOR(tw) --- NEW FILE: alg_jisx0201.h --- /* $CJKCodecs: alg_jisx0201.h,v 1.2 2004/06/29 05:42:08 perky Exp $ */ #define JISX0201_R_ENCODE(c, assi) \ if ((c) < 0x80 && (c) != 0x5c && (c) != 0x7e) \ (assi) = (c); \ else if ((c) == 0x00a5) (assi) = 0x5c; \ else if ((c) == 0x203e) (assi) = 0x7e; #define JISX0201_K_ENCODE(c, assi) \ if ((c) >= 0xff61 && (c) <= 0xff9f) \ (assi) = (c) - 0xfec0; #define JISX0201_ENCODE(c, assi) \ JISX0201_R_ENCODE(c, assi) \ else JISX0201_K_ENCODE(c, assi) #define JISX0201_R_DECODE(c, assi) \ if ((c) < 0x5c) (assi) = (c); \ else if ((c) == 0x5c) (assi) = 0x00a5; \ else if ((c) < 0x7e) (assi) = (c); \ else if ((c) == 0x7e) (assi) = 0x203e; \ else if ((c) == 0x7f) (assi) = 0x7f; #define JISX0201_K_DECODE(c, assi) \ if ((c) >= 0xa1 && (c) <= 0xdf) \ (assi) = 0xfec0 + (c); #define JISX0201_DECODE(c, assi) \ JISX0201_R_DECODE(c, assi) \ else JISX0201_K_DECODE(c, assi) --- NEW FILE: cjkcodecs.h --- /* * cjkcodecs.h: common header for cjkcodecs * * Written by Hye-Shik Chang * $CJKCodecs: cjkcodecs.h,v 1.6 2004/07/18 15:22:31 perky Exp $ */ #ifndef _CJKCODECS_H_ #define _CJKCODECS_H_ #include "Python.h" #include "multibytecodec.h" #define UNIINV Py_UNICODE_REPLACEMENT_CHARACTER #define NOCHAR 0xFFFF #define MULTIC 0xFFFE #define DBCINV 0xFFFD /* shorter macros to save source size of mapping tables */ #define U UNIINV #define N NOCHAR #define M MULTIC #define D DBCINV struct dbcs_index { const ucs2_t *map; unsigned char bottom, top; }; typedef struct dbcs_index decode_map; struct widedbcs_index { const ucs4_t *map; unsigned char bottom, top; }; typedef struct widedbcs_index widedecode_map; struct unim_index { const DBCHAR *map; unsigned char bottom, top; }; typedef struct unim_index encode_map; struct unim_index_bytebased { const unsigned char *map; unsigned char bottom, top; }; struct dbcs_map { const char *charset; const struct unim_index *encmap; const struct dbcs_index *decmap; }; struct pair_encodemap { ucs4_t uniseq; DBCHAR code; }; static const MultibyteCodec *codec_list; static const struct dbcs_map *mapping_list; #define CODEC_INIT(encoding) \ static int encoding##_codec_init(const void *config) #define ENCODER_INIT(encoding) \ static int encoding##_encode_init( \ MultibyteCodec_State *state, const void *config) #define ENCODER(encoding) \ static int encoding##_encode( \ MultibyteCodec_State *state, const void *config, \ const Py_UNICODE **inbuf, size_t inleft, \ unsigned char **outbuf, size_t outleft, int flags) #define ENCODER_RESET(encoding) \ static int encoding##_encode_reset( \ MultibyteCodec_State *state, const void *config, \ unsigned char **outbuf, size_t outleft) #define DECODER_INIT(encoding) \ static int encoding##_decode_init( \ MultibyteCodec_State *state, const void *config) #define DECODER(encoding) \ static int encoding##_decode( \ MultibyteCodec_State *state, const void *config, \ const unsigned char **inbuf, size_t inleft, \ Py_UNICODE **outbuf, size_t outleft) #define DECODER_RESET(encoding) \ static int encoding##_decode_reset( \ MultibyteCodec_State *state, const void *config) #if Py_UNICODE_SIZE == 4 #define UCS4INVALID(code) \ if ((code) > 0xFFFF) \ return 1; #else #define UCS4INVALID(code) \ if (0) ; #endif #define NEXT_IN(i) \ (*inbuf) += (i); \ (inleft) -= (i); #define NEXT_OUT(o) \ (*outbuf) += (o); \ (outleft) -= (o); #define NEXT(i, o) \ NEXT_IN(i) NEXT_OUT(o) #define REQUIRE_INBUF(n) \ if (inleft < (n)) \ return MBERR_TOOFEW; #define REQUIRE_OUTBUF(n) \ if (outleft < (n)) \ return MBERR_TOOSMALL; #define IN1 ((*inbuf)[0]) #define IN2 ((*inbuf)[1]) #define IN3 ((*inbuf)[2]) #define IN4 ((*inbuf)[3]) #define OUT1(c) ((*outbuf)[0]) = (c); #define OUT2(c) ((*outbuf)[1]) = (c); #define OUT3(c) ((*outbuf)[2]) = (c); #define OUT4(c) ((*outbuf)[3]) = (c); #define WRITE1(c1) \ REQUIRE_OUTBUF(1) \ (*outbuf)[0] = (c1); #define WRITE2(c1, c2) \ REQUIRE_OUTBUF(2) \ (*outbuf)[0] = (c1); \ (*outbuf)[1] = (c2); #define WRITE3(c1, c2, c3) \ REQUIRE_OUTBUF(3) \ (*outbuf)[0] = (c1); \ (*outbuf)[1] = (c2); \ (*outbuf)[2] = (c3); #define WRITE4(c1, c2, c3, c4) \ REQUIRE_OUTBUF(4) \ (*outbuf)[0] = (c1); \ (*outbuf)[1] = (c2); \ (*outbuf)[2] = (c3); \ (*outbuf)[3] = (c4); #if Py_UNICODE_SIZE == 2 # define WRITEUCS4(c) \ REQUIRE_OUTBUF(2) \ (*outbuf)[0] = 0xd800 + (((c) - 0x10000) >> 10); \ (*outbuf)[1] = 0xdc00 + (((c) - 0x10000) & 0x3ff); \ NEXT_OUT(2) #else # define WRITEUCS4(c) \ REQUIRE_OUTBUF(1) \ **outbuf = (Py_UNICODE)(c); \ NEXT_OUT(1) #endif #define _TRYMAP_ENC(m, assi, val) \ if ((m)->map != NULL && (val) >= (m)->bottom && \ (val)<= (m)->top && ((assi) = (m)->map[(val) - \ (m)->bottom]) != NOCHAR) #define TRYMAP_ENC(charset, assi, uni) \ _TRYMAP_ENC(&charset##_encmap[(uni) >> 8], assi, (uni) & 0xff) #define _TRYMAP_DEC(m, assi, val) \ if ((m)->map != NULL && (val) >= (m)->bottom && \ (val)<= (m)->top && ((assi) = (m)->map[(val) - \ (m)->bottom]) != UNIINV) #define TRYMAP_DEC(charset, assi, c1, c2) \ _TRYMAP_DEC(&charset##_decmap[c1], assi, c2) #define _TRYMAP_ENC_MPLANE(m, assplane, asshi, asslo, val) \ if ((m)->map != NULL && (val) >= (m)->bottom && \ (val)<= (m)->top && \ ((assplane) = (m)->map[((val) - (m)->bottom)*3]) != 0 && \ (((asshi) = (m)->map[((val) - (m)->bottom)*3 + 1]), 1) && \ (((asslo) = (m)->map[((val) - (m)->bottom)*3 + 2]), 1)) #define TRYMAP_ENC_MPLANE(charset, assplane, asshi, asslo, uni) \ _TRYMAP_ENC_MPLANE(&charset##_encmap[(uni) >> 8], \ assplane, asshi, asslo, (uni) & 0xff) #define TRYMAP_DEC_MPLANE(charset, assi, plane, c1, c2) \ _TRYMAP_DEC(&charset##_decmap[plane][c1], assi, c2) #if Py_UNICODE_SIZE == 2 #define DECODE_SURROGATE(c) \ if (c >> 10 == 0xd800 >> 10) { /* high surrogate */ \ REQUIRE_INBUF(2) \ if (IN2 >> 10 == 0xdc00 >> 10) { /* low surrogate */ \ c = 0x10000 + ((ucs4_t)(c - 0xd800) << 10) + \ ((ucs4_t)(IN2) - 0xdc00); \ } \ } #define GET_INSIZE(c) ((c) > 0xffff ? 2 : 1) #else #define DECODE_SURROGATE(c) {;} #define GET_INSIZE(c) 1 #endif #define BEGIN_MAPPINGS_LIST static const struct dbcs_map _mapping_list[] = { #define MAPPING_ENCONLY(enc) {#enc, (void*)enc##_encmap, NULL}, #define MAPPING_DECONLY(enc) {#enc, NULL, (void*)enc##_decmap}, #define MAPPING_ENCDEC(enc) {#enc, (void*)enc##_encmap, (void*)enc##_decmap}, #define END_MAPPINGS_LIST \ {"", NULL, NULL} }; \ static const struct dbcs_map *mapping_list = \ (const struct dbcs_map *)_mapping_list; #define BEGIN_CODECS_LIST static const MultibyteCodec _codec_list[] = { #define _STATEFUL_METHODS(enc) \ enc##_encode, \ enc##_encode_init, \ enc##_encode_reset, \ enc##_decode, \ enc##_decode_init, \ enc##_decode_reset, #define _STATELESS_METHODS(enc) \ enc##_encode, NULL, NULL, \ enc##_decode, NULL, NULL, #define CODEC_STATEFUL(enc) { \ #enc, NULL, NULL, \ _STATEFUL_METHODS(enc) \ }, #define CODEC_STATELESS(enc) { \ #enc, NULL, NULL, \ _STATELESS_METHODS(enc) \ }, #define CODEC_STATELESS_WINIT(enc) { \ #enc, NULL, \ enc##_codec_init, \ _STATELESS_METHODS(enc) \ }, #define END_CODECS_LIST \ {"", NULL,} }; \ static const MultibyteCodec *codec_list = \ (const MultibyteCodec *)_codec_list; static PyObject * getmultibytecodec(void) { static PyObject *cofunc = NULL; if (cofunc == NULL) { PyObject *mod = PyImport_ImportModule("_multibytecodec"); if (mod == NULL) return NULL; cofunc = PyObject_GetAttrString(mod, "__create_codec"); Py_DECREF(mod); } return cofunc; } static PyObject * getcodec(PyObject *self, PyObject *encoding) { PyObject *codecobj, *r, *cofunc; const MultibyteCodec *codec; const char *enc; if (!PyString_Check(encoding)) { PyErr_SetString(PyExc_TypeError, "encoding name must be a string."); return NULL; } cofunc = getmultibytecodec(); if (cofunc == NULL) return NULL; enc = PyString_AS_STRING(encoding); for (codec = codec_list; codec->encoding[0]; codec++) if (strcmp(codec->encoding, enc) == 0) break; if (codec->encoding[0] == '\0') { PyErr_SetString(PyExc_LookupError, "no such codec is supported."); return NULL; } codecobj = PyCObject_FromVoidPtr((void *)codec, NULL); if (codecobj == NULL) return NULL; r = PyObject_CallFunctionObjArgs(cofunc, codecobj, NULL); Py_DECREF(codecobj); return r; } static struct PyMethodDef __methods[] = { {"getcodec", (PyCFunction)getcodec, METH_O, ""}, {NULL, NULL}, }; static int register_maps(PyObject *module) { const struct dbcs_map *h; for (h = mapping_list; h->charset[0] != '\0'; h++) { char mhname[256] = "__map_"; int r; strcpy(mhname + sizeof("__map_") - 1, h->charset); r = PyModule_AddObject(module, mhname, PyCObject_FromVoidPtr((void *)h, NULL)); if (r == -1) return -1; } return 0; } #ifdef USING_BINARY_PAIR_SEARCH static DBCHAR find_pairencmap(ucs2_t body, ucs2_t modifier, const struct pair_encodemap *haystack, int haystacksize) { int pos, min, max; ucs4_t value = body << 16 | modifier; min = 0; max = haystacksize; for (pos = haystacksize >> 1; min != max; pos = (min + max) >> 1) if (value < haystack[pos].uniseq) { if (max == pos) break; else max = pos; } else if (value > haystack[pos].uniseq) { if (min == pos) break; else min = pos; } else break; if (value == haystack[pos].uniseq) return haystack[pos].code; else return DBCINV; } #endif #ifdef USING_IMPORTED_MAPS #define IMPORT_MAP(locale, charset, encmap, decmap) \ importmap("_codecs_" #locale, "__map_" #charset, \ (const void**)encmap, (const void**)decmap) static int importmap(const char *modname, const char *symbol, const void **encmap, const void **decmap) { PyObject *o, *mod; mod = PyImport_ImportModule((char *)modname); if (mod == NULL) return -1; o = PyObject_GetAttrString(mod, (char*)symbol); if (o == NULL) goto errorexit; else if (!PyCObject_Check(o)) { PyErr_SetString(PyExc_ValueError, "map data must be a CObject."); goto errorexit; } else { struct dbcs_map *map; map = PyCObject_AsVoidPtr(o); if (encmap != NULL) *encmap = map->encmap; if (decmap != NULL) *decmap = map->decmap; Py_DECREF(o); } Py_DECREF(mod); return 0; errorexit: Py_DECREF(mod); return -1; } #endif #define I_AM_A_MODULE_FOR(loc) \ void \ init_codecs_##loc(void) \ { \ PyObject *m = Py_InitModule("_codecs_" #loc, __methods);\ (void)register_maps(m); \ } #endif --- NEW FILE: emu_jisx0213_2000.h --- /* $CJKCodecs: emu_jisx0213_2000.h,v 1.3 2004/07/08 02:53:37 perky Exp $ */ /* These routines may be quite inefficient, but it's used only to emulate old * standards. */ #ifndef EMULATE_JISX0213_2000_ENCODE_INVALID #define EMULATE_JISX0213_2000_ENCODE_INVALID 1 #endif #define EMULATE_JISX0213_2000_ENCODE_BMP(assi, c) \ if (config == (void *)2000 && ( \ (c) == 0x9B1C || (c) == 0x4FF1 || \ (c) == 0x525D || (c) == 0x541E || \ (c) == 0x5653 || (c) == 0x59F8 || \ (c) == 0x5C5B || (c) == 0x5E77 || \ (c) == 0x7626 || (c) == 0x7E6B)) \ return EMULATE_JISX0213_2000_ENCODE_INVALID; \ else if (config == (void *)2000 && (c) == 0x9B1D) \ (assi) = 0x8000 | 0x7d3b; \ #define EMULATE_JISX0213_2000_ENCODE_EMP(assi, c) \ if (config == (void *)2000 && (c) == 0x20B9F) \ return EMULATE_JISX0213_2000_ENCODE_INVALID; #ifndef EMULATE_JISX0213_2000_DECODE_INVALID #define EMULATE_JISX0213_2000_DECODE_INVALID 2 #endif #define EMULATE_JISX0213_2000_DECODE_PLANE1(assi, c1, c2) \ if (config == (void *)2000 && \ (((c1) == 0x2E && (c2) == 0x21) || \ ((c1) == 0x2F && (c2) == 0x7E) || \ ((c1) == 0x4F && (c2) == 0x54) || \ ((c1) == 0x4F && (c2) == 0x7E) || \ ((c1) == 0x74 && (c2) == 0x27) || \ ((c1) == 0x7E && (c2) == 0x7A) || \ ((c1) == 0x7E && (c2) == 0x7B) || \ ((c1) == 0x7E && (c2) == 0x7C) || \ ((c1) == 0x7E && (c2) == 0x7D) || \ ((c1) == 0x7E && (c2) == 0x7E))) \ return EMULATE_JISX0213_2000_DECODE_INVALID; #define EMULATE_JISX0213_2000_DECODE_PLANE2(assi, c1, c2) \ if (config == (void *)2000 && (c1) == 0x7D && (c2) == 0x3B) \ (assi) = 0x9B1D; --- NEW FILE: mappings_cn.h --- /* * $CJKCodecs: mappings_cn.h,v 1.1 2004/07/07 14:59:27 perky Exp $ */ static const ucs2_t __gb2312_decmap[7482] = { 12288,12289,12290,12539,713,711,168,12291,12293,8213,65374,8214,8230,8216, 8217,8220,8221,12308,12309,12296,12297,12298,12299,12300,12301,12302,12303, 12310,12311,12304,12305,177,215,247,8758,8743,8744,8721,8719,8746,8745,8712, 8759,8730,8869,8741,8736,8978,8857,8747,8750,8801,8780,8776,8765,8733,8800, 8814,8815,8804,8805,8734,8757,8756,9794,9792,176,8242,8243,8451,65284,164, 65504,65505,8240,167,8470,9734,9733,9675,9679,9678,9671,9670,9633,9632,9651, 9650,8251,8594,8592,8593,8595,12307,9352,9353,9354,9355,9356,9357,9358,9359, 9360,9361,9362,9363,9364,9365,9366,9367,9368,9369,9370,9371,9332,9333,9334, 9335,9336,9337,9338,9339,9340,9341,9342,9343,9344,9345,9346,9347,9348,9349, 9350,9351,9312,9313,9314,9315,9316,9317,9318,9319,9320,9321,U,U,12832,12833, 12834,12835,12836,12837,12838,12839,12840,12841,U,U,8544,8545,8546,8547,8548, 8549,8550,8551,8552,8553,8554,8555,65281,65282,65283,65509,65285,65286,65287, 65288,65289,65290,65291,65292,65293,65294,65295,65296,65297,65298,65299,65300, 65301,65302,65303,65304,65305,65306,65307,65308,65309,65310,65311,65312,65313, [...4068 lines suppressed...] 13268,12395},{13270,13382,12397},{13384,13426,12510},{13428,13725,12553},{ 13727,13837,12851},{13839,13849,12962},{13851,14615,12973},{14617,14701,13738 },{14703,14798,13823},{14801,14814,13919},{14816,14962,13933},{14964,15181, 14080},{15183,15469,14298},{15471,15583,14585},{15585,16469,14698},{16471, 16734,15583},{16736,17206,15847},{17208,17323,16318},{17325,17328,16434},{ 17330,17372,16438},{17374,17621,16481},{17623,17995,16729},{17997,18016,17102 },{18018,18210,17122},{18212,18216,17315},{18218,18299,17320},{18301,18316, 17402},{18318,18758,17418},{18760,18809,17859},{18811,18812,17909},{18814, 18817,17911},{18820,18820,17915},{18823,18842,17916},{18844,18846,17936},{ 18848,18869,17939},{18872,19574,17961},{19576,19614,18664},{19620,19730,18703 },{19738,19885,18814},{19887,19967,18962},{40870,55295,19043},{59244,59244, 33469},{59336,59336,33470},{59367,59379,33471},{59413,59413,33484},{59417, 59421,33485},{59423,59429,33490},{59431,59434,33497},{59437,59440,33501},{ 59443,59450,33505},{59452,59458,33513},{59460,59475,33520},{59478,59491,33536 },{59493,63787,33550},{63789,63864,37845},{63866,63892,37921},{63894,63974, 37948},{63976,63984,38029},{63986,64011,38038},{64016,64016,38064},{64018, 64018,38065},{64021,64023,38066},{64025,64030,38069},{64034,64034,38075},{ 64037,64038,38076},{64042,65071,38078},{65074,65074,39108},{65093,65096,39109 },{65107,65107,39113},{65112,65112,39114},{65127,65127,39115},{65132,65280, 39116},{65375,65503,39265},{65510,65535,39394},{0,0,39420}}; --- NEW FILE: mappings_hk.h --- /* * $CJKCodecs: mappings_hk.h,v 1.2 2004/07/07 15:07:23 perky Exp $ */ static const ucs2_t __big5hkscs_decmap[6095] = { 62211,62212,62213,62214,62215,268,62217,209,205,62220,62221,203,8168,62224, 202,62226,62227,62228,62229,270,62231,62232,256,193,461,192,274,201,282,200, 332,211,465,210,62245,7870,62247,7872,202,257,225,462,224,593,275,233,283,232, 299,237,464,236,333,243,466,242,363,250,468,249,470,472,474,U,U,U,U,U,U,U,U,U, U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,476,252,62276,7871,62278, 7873,234,609,62282,62283,41897,4421,U,25866,U,U,20029,28381,40270,37343,U,U, 30517,25745,20250,20264,20392,20822,20852,20892,20964,21153,21160,21307,21326, 21457,21464,22242,22768,22788,22791,22834,22836,23398,23454,23455,23706,24198, 24635,25993,26622,26628,26725,27982,28860,30005,32420,32428,32442,32455,32463, 32479,32518,32567,33402,33487,33647,35270,35774,35810,36710,36711,36718,U,U,U, U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,29713,31996, 32205,26950,31433,21031,U,U,U,U,37260,30904,37214,32956,U,36107,33014,2535,U, U,32927,40647,19661,40393,40460,19518,40438,28686,40458,41267,13761,U,28314, 33342,29977,U,18705,39532,39567,40857,31111,33900,7626,1488,10982,20004,20097, [...2305 lines suppressed...] __big5hkscs_nonbmp_encmap+25830,16,241},{__big5hkscs_nonbmp_encmap+26056,3,201 },{__big5hkscs_nonbmp_encmap+26255,40,77},{__big5hkscs_nonbmp_encmap+26293,5, 213},{__big5hkscs_nonbmp_encmap+26502,115,173},{__big5hkscs_nonbmp_encmap+ 26561,62,246},{__big5hkscs_nonbmp_encmap+26746,6,248},{ __big5hkscs_nonbmp_encmap+26989,35,222},{__big5hkscs_nonbmp_encmap+27177,20, 254},{__big5hkscs_nonbmp_encmap+27412,7,245},{__big5hkscs_nonbmp_encmap+27651, 32,255},{__big5hkscs_nonbmp_encmap+27875,169,169},{__big5hkscs_nonbmp_encmap+ 27876,52,91},{__big5hkscs_nonbmp_encmap+27916,198,203},{ __big5hkscs_nonbmp_encmap+27922,1,169},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ __big5hkscs_nonbmp_encmap+28091,37,205},{__big5hkscs_nonbmp_encmap+28260,148, 212},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}, }; --- NEW FILE: mappings_jisx0213_pair.h --- /* * $CJKCodecs: mappings_jisx0213_pair.h,v 1.2 2004/07/07 15:28:02 perky Exp $ */ #define JISX0213_ENCPAIRS 46 #ifdef EXTERN_JISX0213_PAIR static const struct widedbcs_index *jisx0213_pair_decmap; static const struct pair_encodemap *jisx0213_pair_encmap; #else static const ucs4_t __jisx0213_pair_decmap[49] = { 810234010,810365082,810496154,810627226,810758298,816525466,816656538, 816787610,816918682,817049754,817574042,818163866,818426010,838283418, 15074048,U,U,U,39060224,39060225,42730240,42730241,39387904,39387905,39453440, 39453441,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,48825061,48562921, }; static const struct widedbcs_index jisx0213_pair_decmap[256] = { {0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{__jisx0213_pair_decmap +0,119,123},{__jisx0213_pair_decmap+5,119,126},{__jisx0213_pair_decmap+13,120, 120},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{__jisx0213_pair_decmap+14,68,102},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}, }; static const struct pair_encodemap jisx0213_pair_encmap[JISX0213_ENCPAIRS] = { {0x00e60000,0x295c},{0x00e60300,0x2b44},{0x02540000,0x2b38},{0x02540300,0x2b48 },{0x02540301,0x2b49},{0x02590000,0x2b30},{0x02590300,0x2b4c},{0x02590301, 0x2b4d},{0x025a0000,0x2b43},{0x025a0300,0x2b4e},{0x025a0301,0x2b4f},{ 0x028c0000,0x2b37},{0x028c0300,0x2b4a},{0x028c0301,0x2b4b},{0x02e50000,0x2b60 },{0x02e502e9,0x2b66},{0x02e90000,0x2b64},{0x02e902e5,0x2b65},{0x304b0000, 0x242b},{0x304b309a,0x2477},{0x304d0000,0x242d},{0x304d309a,0x2478},{ 0x304f0000,0x242f},{0x304f309a,0x2479},{0x30510000,0x2431},{0x3051309a,0x247a },{0x30530000,0x2433},{0x3053309a,0x247b},{0x30ab0000,0x252b},{0x30ab309a, 0x2577},{0x30ad0000,0x252d},{0x30ad309a,0x2578},{0x30af0000,0x252f},{ 0x30af309a,0x2579},{0x30b10000,0x2531},{0x30b1309a,0x257a},{0x30b30000,0x2533 },{0x30b3309a,0x257b},{0x30bb0000,0x253b},{0x30bb309a,0x257c},{0x30c40000, 0x2544},{0x30c4309a,0x257d},{0x30c80000,0x2548},{0x30c8309a,0x257e},{ 0x31f70000,0x2675},{0x31f7309a,0x2678}, }; #endif --- NEW FILE: mappings_jp.h --- /* * $CJKCodecs: mappings_jp.h,v 1.3 2004/07/07 17:40:27 perky Exp $ */ static const ucs2_t __jisx0208_decmap[6956] = { 12288,12289,12290,65292,65294,12539,65306,65307,65311,65281,12443,12444,180, 65344,168,65342,65507,65343,12541,12542,12445,12446,12291,20189,12293,12294, 12295,12540,8213,8208,65295,92,12316,8214,65372,8230,8229,8216,8217,8220,8221, 65288,65289,12308,12309,65339,65341,65371,65373,12296,12297,12298,12299,12300, 12301,12302,12303,12304,12305,65291,8722,177,215,247,65309,8800,65308,65310, 8806,8807,8734,8756,9794,9792,176,8242,8243,8451,65509,65284,162,163,65285, 65283,65286,65290,65312,167,9734,9733,9675,9679,9678,9671,9670,9633,9632,9651, 9650,9661,9660,8251,12306,8594,8592,8593,8595,12307,U,U,U,U,U,U,U,U,U,U,U, 8712,8715,8838,8839,8834,8835,8746,8745,U,U,U,U,U,U,U,U,8743,8744,172,8658, 8660,8704,8707,U,U,U,U,U,U,U,U,U,U,U,8736,8869,8978,8706,8711,8801,8786,8810, 8811,8730,8765,8733,8757,8747,8748,U,U,U,U,U,U,U,8491,8240,9839,9837,9834, 8224,8225,182,U,U,U,U,9711,65296,65297,65298,65299,65300,65301,65302,65303, 65304,65305,U,U,U,U,U,U,U,65313,65314,65315,65316,65317,65318,65319,65320, 65321,65322,65323,65324,65325,65326,65327,65328,65329,65330,65331,65332,65333, [...4730 lines suppressed...] __jisx0213_emp_encmap+7993,144,144},{__jisx0213_emp_encmap+7994,207,207},{ __jisx0213_emp_encmap+7995,127,240},{__jisx0213_emp_encmap+8109,25,80},{ __jisx0213_emp_encmap+8165,198,198},{0,0,0},{__jisx0213_emp_encmap+8166,114, 114},{0,0,0},{0,0,0},{__jisx0213_emp_encmap+8167,219,219},{ __jisx0213_emp_encmap+8168,21,233},{__jisx0213_emp_encmap+8381,206,206},{ __jisx0213_emp_encmap+8382,26,249},{__jisx0213_emp_encmap+8606,144,144},{0,0,0 },{__jisx0213_emp_encmap+8607,140,140},{__jisx0213_emp_encmap+8608,55,55},{ __jisx0213_emp_encmap+8609,241,241},{__jisx0213_emp_encmap+8610,2,178},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0}, }; --- NEW FILE: mappings_kr.h --- /* * $CJKCodecs: mappings_kr.h,v 1.1 2004/07/07 14:59:27 perky Exp $ */ static const ucs2_t __ksx1001_decmap[8264] = { 12288,12289,12290,183,8229,8230,168,12291,173,8213,8741,65340,8764,8216,8217, 8220,8221,12308,12309,12296,12297,12298,12299,12300,12301,12302,12303,12304, 12305,177,215,247,8800,8804,8805,8734,8756,176,8242,8243,8451,8491,65504, 65505,65509,9794,9792,8736,8869,8978,8706,8711,8801,8786,167,8251,9734,9733, 9675,9679,9678,9671,9670,9633,9632,9651,9650,9661,9660,8594,8592,8593,8595, 8596,12307,8810,8811,8730,8765,8733,8757,8747,8748,8712,8715,8838,8839,8834, 8835,8746,8745,8743,8744,65506,8658,8660,8704,8707,180,65374,711,728,733,730, 729,184,731,161,191,720,8750,8721,8719,164,8457,8240,9665,9664,9655,9654,9828, 9824,9825,9829,9831,9827,8857,9672,9635,9680,9681,9618,9636,9637,9640,9639, 9638,9641,9832,9743,9742,9756,9758,182,8224,8225,8597,8599,8601,8598,8600, 9837,9833,9834,9836,12927,12828,8470,13255,8482,13250,13272,8481,8364,174, 65281,65282,65283,65284,65285,65286,65287,65288,65289,65290,65291,65292,65293, 65294,65295,65296,65297,65298,65299,65300,65301,65302,65303,65304,65305,65306, 65307,65308,65309,65310,65311,65312,65313,65314,65315,65316,65317,65318,65319, [...3216 lines suppressed...] __cp949_encmap+24279,0,255},{__cp949_encmap+24535,0,255},{__cp949_encmap+24791 ,0,255},{__cp949_encmap+25047,0,255},{__cp949_encmap+25303,0,255},{ __cp949_encmap+25559,0,255},{__cp949_encmap+25815,0,255},{__cp949_encmap+26071 ,0,255},{__cp949_encmap+26327,0,255},{__cp949_encmap+26583,0,255},{ __cp949_encmap+26839,0,255},{__cp949_encmap+27095,0,255},{__cp949_encmap+27351 ,0,255},{__cp949_encmap+27607,0,255},{__cp949_encmap+27863,0,255},{ __cp949_encmap+28119,0,255},{__cp949_encmap+28375,0,255},{__cp949_encmap+28631 ,0,255},{__cp949_encmap+28887,0,255},{__cp949_encmap+29143,0,255},{ __cp949_encmap+29399,0,255},{__cp949_encmap+29655,0,255},{__cp949_encmap+29911 ,0,255},{__cp949_encmap+30167,0,255},{__cp949_encmap+30423,0,255},{ __cp949_encmap+30679,0,255},{__cp949_encmap+30935,0,255},{__cp949_encmap+31191 ,0,255},{__cp949_encmap+31447,0,255},{__cp949_encmap+31703,0,255},{ __cp949_encmap+31959,0,255},{__cp949_encmap+32215,0,255},{__cp949_encmap+32471 ,0,163},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{__cp949_encmap+32635,0,255},{ __cp949_encmap+32891,0,11},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{__cp949_encmap+ 32903,1,230}, }; --- NEW FILE: mappings_tw.h --- /* * $CJKCodecs: mappings_tw.h,v 1.2 2004/07/07 15:07:23 perky Exp $ */ static const ucs2_t __big5_decmap[16702] = { 12288,65292,12289,12290,65294,8226,65307,65306,65311,65281,65072,8230,8229, 65104,65380,65106,183,65108,65109,65110,65111,65372,8211,65073,8212,65075, 9588,65076,65103,65288,65289,65077,65078,65371,65373,65079,65080,12308,12309, 65081,65082,12304,12305,65083,65084,12298,12299,65085,65086,12296,12297,65087, 65088,12300,12301,65089,65090,12302,12303,65091,65092,65113,65114,U,U,U,U,U,U, U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,U,65115,65116,65117, 65118,8216,8217,8220,8221,12317,12318,8245,8242,65283,65286,65290,8251,167, 12291,9675,9679,9651,9650,9678,9734,9733,9671,9670,9633,9632,9661,9660,12963, 8453,8254,65507,65343,717,65097,65098,65101,65102,65099,65100,65119,65120, 65121,65291,65293,215,247,177,8730,65308,65310,65309,8806,8807,8800,8734,8786, 8801,65122,65123,65124,65125,65126,8764,8745,8746,8869,8736,8735,8895,13266, 13265,8747,8750,8757,8756,9792,9794,9793,9737,8593,8595,8592,8594,8598,8599, 8601,8600,8741,8739,65295,65340,65295,65340,65284,165,12306,162,163,65285, 65312,8451,8457,65129,65130,65131,13269,13212,13213,13214,13262,13217,13198, [...2598 lines suppressed...] 82,82},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{__cp950ext_encmap+338,129,129},{0,0,0},{ 0,0,0},{0,0,0},{__cp950ext_encmap+339,167,167},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{__cp950ext_encmap+ 340,207,207},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{__cp950ext_encmap+341,185,185},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{ 0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0 },{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0, 0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{__cp950ext_encmap+342,81,104},{ __cp950ext_encmap+366,15,229}, }; --- NEW FILE: multibytecodec.c --- /* * multibytecodec.c: Common Multibyte Codec Implementation * * Written by Hye-Shik Chang * $CJKCodecs: multibytecodec.c,v 1.13 2004/08/19 16:57:19 perky Exp $ */ #include "Python.h" #include "multibytecodec.h" typedef struct { const Py_UNICODE *inbuf, *inbuf_top, *inbuf_end; unsigned char *outbuf, *outbuf_end; PyObject *excobj, *outobj; } MultibyteEncodeBuffer; typedef struct { const unsigned char *inbuf, *inbuf_top, *inbuf_end; [...1233 lines suppressed...] return (PyObject *)self; errorexit: Py_XDECREF(self); return NULL; } static struct PyMethodDef __methods[] = { {"__create_codec", (PyCFunction)__create_codec, METH_O}, {NULL, NULL}, }; void init_multibytecodec(void) { Py_InitModule("_multibytecodec", __methods); if (PyErr_Occurred()) Py_FatalError("can't initialize the _multibytecodec module"); } --- NEW FILE: multibytecodec.h --- /* * multibytecodec.h: Common Multibyte Codec Implementation * * Written by Hye-Shik Chang * $CJKCodecs: multibytecodec.h,v 1.7 2004/06/27 10:39:28 perky Exp $ */ #ifndef _PYTHON_MULTIBYTECODEC_H_ #define _PYTHON_MULTIBYTECODEC_H_ #ifdef __cplusplus extern "C" { #endif #ifdef uint32_t typedef uint32_t ucs4_t; #else typedef unsigned int ucs4_t; #endif #ifdef uint16_t typedef uint16_t ucs2_t, DBCHAR; #else typedef unsigned short ucs2_t, DBCHAR; #endif typedef union { void *p; int i; unsigned char c[8]; ucs2_t u2[4]; ucs4_t u4[2]; } MultibyteCodec_State; typedef int (*mbcodec_init)(const void *config); typedef int (*mbencode_func)(MultibyteCodec_State *state, const void *config, const Py_UNICODE **inbuf, size_t inleft, unsigned char **outbuf, size_t outleft, int flags); typedef int (*mbencodeinit_func)(MultibyteCodec_State *state, const void *config); typedef int (*mbencodereset_func)(MultibyteCodec_State *state, const void *config, unsigned char **outbuf, size_t outleft); typedef int (*mbdecode_func)(MultibyteCodec_State *state, const void *config, const unsigned char **inbuf, size_t inleft, Py_UNICODE **outbuf, size_t outleft); typedef int (*mbdecodeinit_func)(MultibyteCodec_State *state, const void *config); typedef int (*mbdecodereset_func)(MultibyteCodec_State *state, const void *config); typedef struct { const char *encoding; const void *config; mbcodec_init codecinit; mbencode_func encode; mbencodeinit_func encinit; mbencodereset_func encreset; mbdecode_func decode; mbdecodeinit_func decinit; mbdecodereset_func decreset; } MultibyteCodec; typedef struct { PyObject_HEAD MultibyteCodec *codec; } MultibyteCodecObject; #define MAXDECPENDING 8 typedef struct { PyObject_HEAD MultibyteCodec *codec; MultibyteCodec_State state; unsigned char pending[MAXDECPENDING]; int pendingsize; PyObject *stream, *errors; } MultibyteStreamReaderObject; #define MAXENCPENDING 2 typedef struct { PyObject_HEAD MultibyteCodec *codec; MultibyteCodec_State state; Py_UNICODE pending[MAXENCPENDING]; int pendingsize; PyObject *stream, *errors; } MultibyteStreamWriterObject; /* positive values for illegal sequences */ #define MBERR_TOOSMALL (-1) /* insufficient output buffer space */ #define MBERR_TOOFEW (-2) /* incomplete input buffer */ #define MBERR_INTERNAL (-3) /* internal runtime error */ #define ERROR_STRICT (PyObject *)(1) #define ERROR_IGNORE (PyObject *)(2) #define ERROR_REPLACE (PyObject *)(3) #define ERROR_MAX ERROR_REPLACE #define MBENC_FLUSH 0x0001 /* encode all characters encodable */ #define MBENC_MAX MBENC_FLUSH #ifdef __cplusplus } #endif #endif From kbk at users.sourceforge.net Fri Jan 7 08:08:00 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Fri Jan 7 08:08:03 2005 Subject: [Python-checkins] python/dist/src/PC/example_nt example.sln, NONE, 1.1.4.1 example.vcproj, NONE, 1.1.4.1 readme.txt, 1.11, 1.11.6.1 example.dsp, 1.6, NONE example.dsw, 1.2, NONE Message-ID: Update of /cvsroot/python/python/dist/src/PC/example_nt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12896/PC/example_nt Modified Files: Tag: ast-branch readme.txt Added Files: Tag: ast-branch example.sln example.vcproj Removed Files: Tag: ast-branch example.dsp example.dsw Log Message: Merge MAIN into ast-branch cvs up -kk -j mrg_to_ast-branch_24APR03 -j mrg_to_ast-branch_05JAN05 (date of earlier merge estimated 24Apr03 17:30 UTC, repository tagged) Not merged: Lib/test/test_compile.py, Python/compile.c Refer to Tracker Patch # 1097671 for the merge output and list of conflicts resolved. --- NEW FILE: example.sln --- Microsoft Visual Studio Solution File, Format Version 8.00 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example", "example.vcproj", "{A0608D6F-84ED-44AE-A2A6-A3CC7F4A4030}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject Global GlobalSection(SolutionConfiguration) = preSolution Debug = Debug Release = Release EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution {A0608D6F-84ED-44AE-A2A6-A3CC7F4A4030}.Debug.ActiveCfg = Debug|Win32 {A0608D6F-84ED-44AE-A2A6-A3CC7F4A4030}.Debug.Build.0 = Debug|Win32 {A0608D6F-84ED-44AE-A2A6-A3CC7F4A4030}.Release.ActiveCfg = Release|Win32 {A0608D6F-84ED-44AE-A2A6-A3CC7F4A4030}.Release.Build.0 = Release|Win32 EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection GlobalSection(ExtensibilityAddIns) = postSolution EndGlobalSection EndGlobal --- NEW FILE: example.vcproj --- Index: readme.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/example_nt/readme.txt,v retrieving revision 1.11 retrieving revision 1.11.6.1 diff -u -d -r1.11 -r1.11.6.1 --- readme.txt 15 Dec 2001 22:27:01 -0000 1.11 +++ readme.txt 7 Jan 2005 07:04:22 -0000 1.11.6.1 @@ -3,10 +3,11 @@ This directory contains everything needed (except for the Python distribution!) to build a Python extension module using Microsoft VC++ -("Developer Studio") version 6. It has been tested with VC++ 6.0 on Python -2.2c1. You can also use earlier versions of VC to build Python extensions, -but the sample VC project file (example.dsw in this directory) is in VC 6 -format. +("Developer Studio") version 7.1. It has been tested with VC++ 7.1 on +Python 2.4. You can also use earlier versions of VC to build Python +extensions, but the sample VC project file (example.dsw in this directory) +is in VC 7.1 format. Notice that you need to use the same compiler version +that was used to build Python itself. COPY THIS DIRECTORY! -------------------- @@ -19,10 +20,10 @@ OPEN THE PROJECT ---------------- -From VC 6.x, use the - File -> Open Workspace... +From VC 7.1, use the + File -> Open Solution... dialog (*not* the "File -> Open..." dialog!). Navigate to and select the -file "example.dsw", in the *copy* of the example_nt directory you made +file "example.sln", in the *copy* of the example_nt directory you made above. Click Open. @@ -31,15 +32,12 @@ In order to check that everything is set up right, try building: 1. Select a configuration. This step is optional. Do - Build -> Select Active Configuration... - and select either "example - Win32 Release" or "example - Win32 Debug". + Build -> Configuration Manager... -> Active Solution Configuration + and select either "Release" or "Debug". If you skip this step, you'll use the Debug configuration by default. 2. Build the DLL. Do - Build -> Build example_d.dll - in Debug mode, or - Build -> Build example.dll - in Release mode. + Build -> Build Solution This creates all intermediate and result files in a subdirectory which is called either Debug or Release, depending on which configuration you picked in the preceding step. @@ -96,7 +94,7 @@ Now your options are: -1) Copy example.dsw and example.dsp, rename them to spam.*, and edit them +1) Copy example.sln and example.vcproj, rename them to spam.*, and edit them by hand. or @@ -109,7 +107,8 @@ (This is an annoying little file with only two lines. An alternative approach is to forget about the .def file, and add the option "/export:initspam" somewhere to the Link settings, by manually editing the -"Project Options" box). +"Project -> Properties -> Linker -> Command Line -> Additional Options" +box). You are now all set to build your extension, unless it requires other external libraries, include files, etc. See Python's Extending and @@ -119,47 +118,44 @@ CREATING A BRAND NEW PROJECT ---------------------------- Use the - File -> New... -> Projects -dialog to create a new Project Workspace. Select "Win32 Dynamic-Link -Library", enter the name ("spam"), and make sure the "Location" is set to -the spam directory you have created (which should be a direct subdirectory -of the Python build tree, a sibling of Include and PC). Select Win32 as the -platform (in my version, this is the only choice). Make sure the "Create -new workspace" radio button is selected. Click OK. + File -> New -> Project... +dialog to create a new Project Workspace. Select "Visual C++ Projects/Win32/ +Win32 Project", enter the name ("spam"), and make sure the "Location" is +set to parent of the spam directory you have created (which should be a direct +subdirectory of the Python build tree, a sibling of Include and PC). +In "Application Settings", select "DLL", and "Empty Project". Click OK. + +You should now create the file spam.def as instructed in the previous +section. Add the source files (including the .def file) to the project, +using "Project", "Add Existing Item". Now open the - Project -> Settings... + Project -> spam properties... dialog. (Impressive, isn't it? :-) You only need to change a few settings. Make sure "All Configurations" is selected from the "Settings -for:" dropdown list. Select the "C/C++" tab. Choose the "Preprocessor" +for:" dropdown list. Select the "C/C++" tab. Choose the "General" category in the popup menu at the top. Type the following text in the -entry box labeled "Addditional include directories:" +entry box labeled "Addditional Include Directories:" ..\Include,..\PC -Then, choose the "Input" category in the Link tab, and enter +Then, choose the "General" category in the "Linker" tab, and enter ..\PCbuild -in the "Additional library path:" box. +in the "Additional library Directories" box. -Now you need to add some mode-specific settings: +Now you need to add some mode-specific settings (select "Accept" +when asked to confirm your changes): -Select "Win32 Release" in the "Settings for:" dropdown list. Click the -"Link" tab, choose the "Input" Category, and append "python22.lib" to the -list in the "Object/library modules:" box. +Select "Release" in the "Configuration" dropdown list. Click the +"Link" tab, choose the "Input" Category, and append "python24.lib" to the +list in the "Additional Dependencies" box. -Select "Win32 Debug" in the "Settings for:" dropdown list, and append -"python22_d.lib" to the list in the "Object/library modules:" box. Then -click on the C/C++ tab, select "Code Generation" from the "Category:" -dropdown list, and select "Debug Multithreaded DLL" from the "Use run-time -library:" dropdown list. +Select "Debug" in the "Settings for:" dropdown list, and append +"python24_d.lib" to the list in the Additional Dependencies" box. Then +click on the C/C++ tab, select "Code Generation", and select +"Multi-threaded Debug DLL" from the "Runtime library" dropdown list. -Select "Win32 Release" again from the "Settings for:" dropdown list. -Select "Multithreaded DLL" from the "Use run-time library:" dropdown list. +Select "Release" again from the "Settings for:" dropdown list. +Select "Multi-threaded DLL" from the "Use run-time library:" dropdown list. That's all . - -You should now create the file spam.def as instructed in the previous -section. Then chose the - Insert -> Files into Project... -dialog. Set the pattern to *.* and select both spam.c and spam.def and -click OK. (Inserting them one by one is fine too.) --- example.dsp DELETED --- --- example.dsw DELETED --- From kbk at users.sourceforge.net Fri Jan 7 08:08:02 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Fri Jan 7 08:08:06 2005 Subject: [Python-checkins] python/dist/src/PC .cvsignore, NONE, 1.2.2.1 _subprocess.c, NONE, 1.3.4.1 empty.c, NONE, 1.1.4.1 icons.mak, NONE, 1.1.4.1 icons.rc, NONE, 1.1.4.1 make_versioninfo.c, NONE, 1.1.8.1 tix.diff, NONE, 1.2.4.1 _winreg.c, 1.10.2.1, 1.10.2.2 config.c, 1.34.2.1, 1.34.2.2 dllbase_nt.txt, 1.4.16.1, 1.4.16.2 getpathp.c, 1.27.2.1, 1.27.2.2 msvcrtmodule.c, 1.8, 1.8.2.1 pyconfig.h, 1.11.2.1, 1.11.2.2 python_nt.rc, 1.17.2.1, 1.17.2.2 readme.txt, 1.24, 1.24.18.1 testpy.py, 1.2, 1.2.32.1 winsound.c, 1.10.2.1, 1.10.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/PC In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12896/PC Modified Files: Tag: ast-branch _winreg.c config.c dllbase_nt.txt getpathp.c msvcrtmodule.c pyconfig.h python_nt.rc readme.txt testpy.py winsound.c Added Files: Tag: ast-branch .cvsignore _subprocess.c empty.c icons.mak icons.rc make_versioninfo.c tix.diff Log Message: Merge MAIN into ast-branch cvs up -kk -j mrg_to_ast-branch_24APR03 -j mrg_to_ast-branch_05JAN05 (date of earlier merge estimated 24Apr03 17:30 UTC, repository tagged) Not merged: Lib/test/test_compile.py, Python/compile.c Refer to Tracker Patch # 1097671 for the merge output and list of conflicts resolved. --- NEW FILE: .cvsignore --- python_nt.h python_nt_d.h pythonnt_rc.h pythonnt_rc_d.h --- NEW FILE: _subprocess.c --- /* * support routines for subprocess module * * Currently, this extension module is only required when using the * subprocess module on Windows, but in the future, stubs for other * platforms might be added here as well. * * Copyright (c) 2004 by Fredrik Lundh * Copyright (c) 2004 by Secret Labs AB, http://www.pythonware.com * Copyright (c) 2004 by Peter Astrand * * 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: * * Permission to use, copy, modify, and distribute this software and * its associated documentation for any purpose and without fee is * hereby granted, provided that the above copyright notice appears in * all copies, and that both that copyright notice and this permission * notice appear in supporting documentation, and that the name of the * authors not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior * permission. * * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* TODO: handle unicode command lines? */ /* TODO: handle unicode environment? */ #include "Python.h" #define WINDOWS_LEAN_AND_MEAN #include "windows.h" /* -------------------------------------------------------------------- */ /* handle wrapper. note that this library uses integers when passing handles to a function, and handle wrappers when returning handles. the wrapper is used to provide Detach and Close methods */ typedef struct { PyObject_HEAD HANDLE handle; } sp_handle_object; staticforward PyTypeObject sp_handle_type; static PyObject* sp_handle_new(HANDLE handle) { sp_handle_object* self; self = PyObject_NEW(sp_handle_object, &sp_handle_type); if (self == NULL) return NULL; self->handle = handle; return (PyObject*) self; } static PyObject* sp_handle_detach(sp_handle_object* self, PyObject* args) { HANDLE handle; if (! PyArg_ParseTuple(args, ":Detach")) return NULL; handle = self->handle; self->handle = NULL; /* note: return the current handle, as an integer */ return PyInt_FromLong((long) handle); } static PyObject* sp_handle_close(sp_handle_object* self, PyObject* args) { if (! PyArg_ParseTuple(args, ":Close")) return NULL; if (self->handle != INVALID_HANDLE_VALUE) { CloseHandle(self->handle); self->handle = INVALID_HANDLE_VALUE; } Py_INCREF(Py_None); return Py_None; } static void sp_handle_dealloc(sp_handle_object* self) { if (self->handle != INVALID_HANDLE_VALUE) CloseHandle(self->handle); PyMem_DEL(self); } static PyMethodDef sp_handle_methods[] = { {"Detach", (PyCFunction) sp_handle_detach, 1}, {"Close", (PyCFunction) sp_handle_close, 1}, {NULL, NULL} }; static PyObject* sp_handle_getattr(sp_handle_object* self, char* name) { return Py_FindMethod(sp_handle_methods, (PyObject*) self, name); } static PyObject* sp_handle_as_int(sp_handle_object* self) { return PyInt_FromLong((long) self->handle); } static PyNumberMethods sp_handle_as_number; statichere PyTypeObject sp_handle_type = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "_subprocess_handle", sizeof(sp_handle_object), 0, (destructor) sp_handle_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ (getattrfunc) sp_handle_getattr,/*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ &sp_handle_as_number, /*tp_as_number */ 0, /*tp_as_sequence */ 0, /*tp_as_mapping */ 0 /*tp_hash*/ }; /* -------------------------------------------------------------------- */ /* windows API functions */ static PyObject * sp_GetStdHandle(PyObject* self, PyObject* args) { HANDLE handle; int std_handle; if (! PyArg_ParseTuple(args, "i:GetStdHandle", &std_handle)) return NULL; Py_BEGIN_ALLOW_THREADS handle = GetStdHandle((DWORD) std_handle); Py_END_ALLOW_THREADS if (handle == INVALID_HANDLE_VALUE) return PyErr_SetFromWindowsErr(GetLastError()); if (! handle) { Py_INCREF(Py_None); return Py_None; } /* note: returns integer, not handle object */ return PyInt_FromLong((long) handle); } static PyObject * sp_GetCurrentProcess(PyObject* self, PyObject* args) { if (! PyArg_ParseTuple(args, ":GetCurrentProcess")) return NULL; return sp_handle_new(GetCurrentProcess()); } static PyObject * sp_DuplicateHandle(PyObject* self, PyObject* args) { HANDLE target_handle; BOOL result; long source_process_handle; long source_handle; long target_process_handle; int desired_access; int inherit_handle; int options = 0; if (! PyArg_ParseTuple(args, "lllii|i:DuplicateHandle", &source_process_handle, &source_handle, &target_process_handle, &desired_access, &inherit_handle, &options)) return NULL; Py_BEGIN_ALLOW_THREADS result = DuplicateHandle( (HANDLE) source_process_handle, (HANDLE) source_handle, (HANDLE) target_process_handle, &target_handle, desired_access, inherit_handle, options ); Py_END_ALLOW_THREADS if (! result) return PyErr_SetFromWindowsErr(GetLastError()); return sp_handle_new(target_handle); } static PyObject * sp_CreatePipe(PyObject* self, PyObject* args) { HANDLE read_pipe; HANDLE write_pipe; BOOL result; PyObject* pipe_attributes; /* ignored */ int size; if (! PyArg_ParseTuple(args, "Oi:CreatePipe", &pipe_attributes, &size)) return NULL; Py_BEGIN_ALLOW_THREADS result = CreatePipe(&read_pipe, &write_pipe, NULL, size); Py_END_ALLOW_THREADS if (! result) return PyErr_SetFromWindowsErr(GetLastError()); return Py_BuildValue( "NN", sp_handle_new(read_pipe), sp_handle_new(write_pipe)); } /* helpers for createprocess */ static int getint(PyObject* obj, char* name) { PyObject* value; value = PyObject_GetAttrString(obj, name); if (! value) { PyErr_Clear(); /* FIXME: propagate error? */ return 0; } return (int) PyInt_AsLong(value); } static HANDLE gethandle(PyObject* obj, char* name) { sp_handle_object* value; value = (sp_handle_object*) PyObject_GetAttrString(obj, name); if (! value) { PyErr_Clear(); /* FIXME: propagate error? */ return NULL; } if (value->ob_type != &sp_handle_type) return NULL; return value->handle; } static PyObject* getenvironment(PyObject* environment) { int i, envsize; PyObject* out = NULL; PyObject* keys; PyObject* values; char* p; /* convert environment dictionary to windows enviroment string */ if (! PyMapping_Check(environment)) { PyErr_SetString( PyExc_TypeError, "environment must be dictionary or None"); return NULL; } envsize = PyMapping_Length(environment); keys = PyMapping_Keys(environment); values = PyMapping_Values(environment); if (!keys || !values) goto error; out = PyString_FromStringAndSize(NULL, 2048); if (! out) goto error; p = PyString_AS_STRING(out); for (i = 0; i < envsize; i++) { int ksize, vsize, totalsize; PyObject* key = PyList_GET_ITEM(keys, i); PyObject* value = PyList_GET_ITEM(values, i); if (! PyString_Check(key) || ! PyString_Check(value)) { PyErr_SetString(PyExc_TypeError, "environment can only contain strings"); goto error; } ksize = PyString_GET_SIZE(key); vsize = PyString_GET_SIZE(value); totalsize = (p - PyString_AS_STRING(out)) + ksize + 1 + vsize + 1 + 1; if (totalsize > PyString_GET_SIZE(out)) { int offset = p - PyString_AS_STRING(out); _PyString_Resize(&out, totalsize + 1024); p = PyString_AS_STRING(out) + offset; } memcpy(p, PyString_AS_STRING(key), ksize); p += ksize; *p++ = '='; memcpy(p, PyString_AS_STRING(value), vsize); p += vsize; *p++ = '\0'; } /* add trailing null byte */ *p++ = '\0'; _PyString_Resize(&out, p - PyString_AS_STRING(out)); /* PyObject_Print(out, stdout, 0); */ return out; error: Py_XDECREF(out); Py_XDECREF(keys); Py_XDECREF(values); return NULL; } static PyObject * sp_CreateProcess(PyObject* self, PyObject* args) { BOOL result; PROCESS_INFORMATION pi; STARTUPINFO si; PyObject* environment; char* application_name; char* command_line; PyObject* process_attributes; /* ignored */ PyObject* thread_attributes; /* ignored */ int inherit_handles; int creation_flags; PyObject* env_mapping; char* current_directory; PyObject* startup_info; if (! PyArg_ParseTuple(args, "zzOOiiOzO:CreateProcess", &application_name, &command_line, &process_attributes, &thread_attributes, &inherit_handles, &creation_flags, &env_mapping, ¤t_directory, &startup_info)) return NULL; ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); /* note: we only support a small subset of all SI attributes */ si.dwFlags = getint(startup_info, "dwFlags"); si.wShowWindow = getint(startup_info, "wShowWindow"); si.hStdInput = gethandle(startup_info, "hStdInput"); si.hStdOutput = gethandle(startup_info, "hStdOutput"); si.hStdError = gethandle(startup_info, "hStdError"); if (env_mapping == Py_None) environment = NULL; else { environment = getenvironment(env_mapping); if (! environment) return NULL; } Py_BEGIN_ALLOW_THREADS result = CreateProcess(application_name, command_line, NULL, NULL, inherit_handles, creation_flags, environment ? PyString_AS_STRING(environment) : NULL, current_directory, &si, &pi); Py_END_ALLOW_THREADS Py_XDECREF(environment); if (! result) return PyErr_SetFromWindowsErr(GetLastError()); return Py_BuildValue("NNii", sp_handle_new(pi.hProcess), sp_handle_new(pi.hThread), pi.dwProcessId, pi.dwThreadId); } static PyObject * sp_GetExitCodeProcess(PyObject* self, PyObject* args) { DWORD exit_code; BOOL result; long process; if (! PyArg_ParseTuple(args, "l:GetExitCodeProcess", &process)) return NULL; result = GetExitCodeProcess((HANDLE) process, &exit_code); if (! result) return PyErr_SetFromWindowsErr(GetLastError()); return PyInt_FromLong(exit_code); } static PyObject * sp_WaitForSingleObject(PyObject* self, PyObject* args) { DWORD result; long handle; int milliseconds; if (! PyArg_ParseTuple(args, "li:WaitForSingleObject", &handle, &milliseconds)) return NULL; Py_BEGIN_ALLOW_THREADS result = WaitForSingleObject((HANDLE) handle, (DWORD) milliseconds); Py_END_ALLOW_THREADS if (result == WAIT_FAILED) return PyErr_SetFromWindowsErr(GetLastError()); return PyInt_FromLong((int) result); } static PyObject * sp_GetVersion(PyObject* self, PyObject* args) { if (! PyArg_ParseTuple(args, ":GetVersion")) return NULL; return PyInt_FromLong((int) GetVersion()); } static PyObject * sp_GetModuleFileName(PyObject* self, PyObject* args) { BOOL result; long module; TCHAR filename[MAX_PATH]; if (! PyArg_ParseTuple(args, "l:GetModuleFileName", &module)) return NULL; result = GetModuleFileName((HMODULE)module, filename, MAX_PATH); filename[MAX_PATH-1] = '\0'; if (! result) return PyErr_SetFromWindowsErr(GetLastError()); return PyString_FromString(filename); } static PyMethodDef sp_functions[] = { {"GetStdHandle", sp_GetStdHandle, METH_VARARGS}, {"GetCurrentProcess", sp_GetCurrentProcess, METH_VARARGS}, {"DuplicateHandle", sp_DuplicateHandle, METH_VARARGS}, {"CreatePipe", sp_CreatePipe, METH_VARARGS}, {"CreateProcess", sp_CreateProcess, METH_VARARGS}, {"GetExitCodeProcess", sp_GetExitCodeProcess, METH_VARARGS}, {"WaitForSingleObject", sp_WaitForSingleObject, METH_VARARGS}, {"GetVersion", sp_GetVersion, METH_VARARGS}, {"GetModuleFileName", sp_GetModuleFileName, METH_VARARGS}, {NULL, NULL} }; /* -------------------------------------------------------------------- */ static void defint(PyObject* d, const char* name, int value) { PyObject* v = PyInt_FromLong((long) value); if (v) { PyDict_SetItemString(d, (char*) name, v); Py_DECREF(v); } } #if PY_VERSION_HEX >= 0x02030000 PyMODINIT_FUNC #else DL_EXPORT(void) #endif init_subprocess() { PyObject *d; PyObject *m; /* patch up object descriptors */ sp_handle_type.ob_type = &PyType_Type; sp_handle_as_number.nb_int = (unaryfunc) sp_handle_as_int; m = Py_InitModule("_subprocess", sp_functions); d = PyModule_GetDict(m); /* constants */ defint(d, "STD_INPUT_HANDLE", STD_INPUT_HANDLE); defint(d, "STD_OUTPUT_HANDLE", STD_OUTPUT_HANDLE); defint(d, "STD_ERROR_HANDLE", STD_ERROR_HANDLE); defint(d, "DUPLICATE_SAME_ACCESS", DUPLICATE_SAME_ACCESS); defint(d, "STARTF_USESTDHANDLES", STARTF_USESTDHANDLES); defint(d, "STARTF_USESHOWWINDOW", STARTF_USESHOWWINDOW); defint(d, "SW_HIDE", SW_HIDE); defint(d, "INFINITE", INFINITE); defint(d, "WAIT_OBJECT_0", WAIT_OBJECT_0); defint(d, "CREATE_NEW_CONSOLE", CREATE_NEW_CONSOLE); } --- NEW FILE: empty.c --- #include int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { return 0; } --- NEW FILE: icons.mak --- python_icon.exe: py.res empty.obj link /out:python_icon.exe /machine:x86 /subsystem:windows py.res empty.obj py.res: py.ico pyc.ico pycon.ico icons.rc rc /fo py.res icons.rc empty.obj: empty.c cl /c empty.c --- NEW FILE: icons.rc --- 101 ICON "py.ico" 102 ICON "pyc.ico" 103 ICON "pycon.ico" --- NEW FILE: make_versioninfo.c --- #include #include "patchlevel.h" /* * This program prints out an include file containing fields required to build * the version info resource of pythonxx.dll because the resource compiler * cannot do the arithmetic. */ /* * FIELD3 is the third field of the version number. * This is what we'd like FIELD3 to be: * * #define FIELD3 (PY_MICRO_VERSION*1000 + PY_RELEASE_LEVEL*10 + PY_RELEASE_SERIAL) * * but that neither gives an error nor comes anywhere close to working. * * For 2.4a0, * PY_MICRO_VERSION = 0 * PY_RELEASE_LEVEL = 'alpha' = 0xa * PY_RELEASE_SERIAL = 0 * * gives FIELD3 = 0*1000 + 10*10 + 0 = 100 */ int main(int argc, char **argv) { printf("/* This file created by make_versioninfo.exe */\n"); printf("#define FIELD3 %d\n", PY_MICRO_VERSION*1000 + PY_RELEASE_LEVEL*10 + PY_RELEASE_SERIAL); printf("#define MS_DLL_ID \"%d.%d\"\n", PY_MAJOR_VERSION, PY_MINOR_VERSION); printf("#define PYTHON_DLL_NAME \"python%d%d.dll\"\n", PY_MAJOR_VERSION, PY_MINOR_VERSION); return 0; } --- NEW FILE: tix.diff --- diff -ur tix-8.1.4/win/common.mak tix-8.1.4.new/win/common.mak --- tix-8.1.4/win/common.mak 2002-12-11 07:19:42.000000000 +0100 +++ tix-8.1.4.new/win/common.mak 2004-08-03 21:45:09.859375000 +0200 @@ -18,10 +18,10 @@ # support files # #---------------------------------------------------------------------- -TCL_VER = 8.3 +TCL_VER = 8.4 ITCL_VER = -INSTALLDIR = C:\progra~1\tcl +INSTALLDIR = ..\..\tcltk !IFNDEF TIX_DEBUG NODEBUG = 1 @@ -61,7 +61,7 @@ !IF "$(TCL_VER)" == "8.4" TCLMAJOR=8 TCLMINOR=4 -TCLPATCH=1 +TCLPATCH=7 TMPDIR = tk$(TCL_VER) !ENDIF @@ -176,14 +176,14 @@ $(TMPDIR)\tixWinWm.obj RMDIR = $(TCLDIR)\win\rmd.bat -MKDIR = $(TCLDIR)\win\mkd.bat +MKDIR = mkdir RM = del install: install-binaries install-libraries install-binaries: $(TCLSH) - $(MKDIR) "$(BIN_INSTALL_DIR)" - $(MKDIR) "$(LIB_INSTALL_DIR)" + -$(MKDIR) "$(BIN_INSTALL_DIR)" + -$(MKDIR) "$(LIB_INSTALL_DIR)" @echo installing $(TIXDLL) @copy "$(TIXDLL)" "$(BIN_INSTALL_DIR)" @copy "$(TIXLIB)" "$(LIB_INSTALL_DIR)" diff -ur tix-8.1.4/win/makefile.vc tix-8.1.4.new/win/makefile.vc --- tix-8.1.4/win/makefile.vc 2002-12-02 04:02:54.000000000 +0100 +++ tix-8.1.4.new/win/makefile.vc 2004-08-03 21:42:07.953125000 +0200 @@ -54,12 +54,11 @@ DBGX = d !ENDIF -cc32 = "$(TOOLS32)\bin\cl.exe" -rc32 = "$(TOOLS32_rc)\bin\rc.exe" -link32 = "$(TOOLS32)\bin\link.exe" -include32 = -I"$(TOOLS32)\include" +cc32 = "cl.exe" +rc32 = "rc.exe" +link32 = "link.exe" -TIX_INCLUDES = $(include32) \ +TIX_INCLUDES = \ -I$(ROOT)\win -I$(ROOT)\generic \ -I$(TKDIR)\generic -I$(TKDIR)\win -I$(TKDIR)\xlib \ -I$(TCLDIR)\generic $(ITCL_CFLAGS) @@ -171,7 +170,7 @@ # cvarsdll = -D_X86_=1 -DWIN32 -D_WIN32 -D_MT -D_DLL cflagsdll = $(cvarsdll) -c -W3 -nologo -Fp$(TMPDIR)\ -YX -MD \ - -Oti -Gs -GD + -Oti -Gs -Gd ###################################################################### # Project specific targets @@ -181,7 +180,6 @@ $(DUMPEXTS): $(WINDIR)\winDumpExts.c $(cc32) $(CON_CFLAGS) -Fo$(TMPDIR)\ /c $? - set LIB="$(TOOLS32)\lib" $(link32) $(ldebug) $(conlflags) $(guilibs) -out:$@ \ $(TMPDIR)\winDumpExts.obj @@ -193,7 +191,6 @@ # (ToDo) $(TIXDLL) doesn't have resources to define its icon, etc. # $(TIXDLL): $(TIXOBJS) $(TMPDIR)\tixvc.def - set LIB="$(TOOLS32)\lib" $(link32) $(ldebug) $(dlllflags) -def:$(TMPDIR)\tixvc.def \ $(TKLIBDIR)\$(TKLIB) $(TCLLIBDIR)\$(TCLLIB) $(guilibsdll) \ $(ITCL_LIBS) -out:$@ @<< @@ -202,7 +199,6 @@ $(TIXWISH): $(WISHOBJS) $(TIXOBJS) $(TIXLIB) $(TMPDIR)\tixwish.res - set LIB="$(TOOLS32)\lib" $(link32) $(ldebug) $(guilflags) \ $(WISHOBJS) $(TMPDIR)\tixwish.res $(TIXLIB) \ $(TKLIBDIR)\$(TKLIB) $(TCLLIBDIR)\$(TCLLIB) $(guilibsdll) \ diff -ur tix-8.1.4/win/tk8.4/pkgIndex.tcl tix-8.1.4.new/win/tk8.4/pkgIndex.tcl --- tix-8.1.4/win/tk8.4/pkgIndex.tcl 2002-12-15 04:21:54.000000000 +0100 +++ tix-8.1.4.new/win/tk8.4/pkgIndex.tcl 2004-08-31 08:38:43.921875000 +0200 @@ -15,7 +15,7 @@ # We look in the ../../bin directory (an installed Tcl) lappend dirs ../../bin # We look in the ../../DLLs directory (an installed Python) -lappend dirs ../../Dlls +lappend dirs [file join [file dirname [info nameofexe]] DLLs] # If not, this pkgIndex.tcl will probably fail. Index: _winreg.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/_winreg.c,v retrieving revision 1.10.2.1 retrieving revision 1.10.2.2 diff -u -d -r1.10.2.1 -r1.10.2.2 --- _winreg.c 28 Apr 2003 17:17:56 -0000 1.10.2.1 +++ _winreg.c 7 Jan 2005 07:04:11 -0000 1.10.2.2 @@ -1031,6 +1031,7 @@ PyObject *obKey; int index; long rc; + PyObject *retStr; char *retBuf; DWORD len; @@ -1045,11 +1046,17 @@ return PyErr_SetFromWindowsErrWithFunction(rc, "RegQueryInfoKey"); ++len; /* include null terminator */ - retBuf = (char *)alloca(len); + retStr = PyString_FromStringAndSize(NULL, len); + if (retStr == NULL) + return NULL; + retBuf = PyString_AS_STRING(retStr); - if ((rc = RegEnumKey(hKey, index, retBuf, len)) != ERROR_SUCCESS) + if ((rc = RegEnumKey(hKey, index, retBuf, len)) != ERROR_SUCCESS) { + Py_DECREF(retStr); return PyErr_SetFromWindowsErrWithFunction(rc, "RegEnumKey"); - return Py_BuildValue("s", retBuf); + } + _PyString_Resize(&retStr, strlen(retBuf)); + return retStr; } static PyObject * @@ -1080,8 +1087,14 @@ "RegQueryInfoKey"); ++retValueSize; /* include null terminators */ ++retDataSize; - retValueBuf = (char *)alloca(retValueSize); - retDataBuf = (char *)alloca(retDataSize); + retValueBuf = (char *)PyMem_Malloc(retValueSize); + if (retValueBuf == NULL) + return PyErr_NoMemory(); + retDataBuf = (char *)PyMem_Malloc(retDataSize); + if (retDataBuf == NULL) { + PyMem_Free(retValueBuf); + return PyErr_NoMemory(); + } Py_BEGIN_ALLOW_THREADS rc = RegEnumValue(hKey, @@ -1094,14 +1107,21 @@ &retDataSize); Py_END_ALLOW_THREADS - if (rc != ERROR_SUCCESS) - return PyErr_SetFromWindowsErrWithFunction(rc, - "PyRegEnumValue"); + if (rc != ERROR_SUCCESS) { + retVal = PyErr_SetFromWindowsErrWithFunction(rc, + "PyRegEnumValue"); + goto fail; + } obData = Reg2Py(retDataBuf, retDataSize, typ); - if (obData == NULL) - return NULL; + if (obData == NULL) { + retVal = NULL; + goto fail; + } retVal = Py_BuildValue("sOi", retValueBuf, obData, typ); Py_DECREF(obData); + fail: + PyMem_Free(retValueBuf); + PyMem_Free(retDataBuf); return retVal; } @@ -1206,10 +1226,11 @@ HKEY hKey; PyObject *obKey; char *subKey; - long rc; + PyObject *retStr; char *retBuf; long bufSize = 0; + if (!PyArg_ParseTuple(args, "Oz:QueryValue", &obKey, &subKey)) return NULL; @@ -1219,12 +1240,18 @@ != ERROR_SUCCESS) return PyErr_SetFromWindowsErrWithFunction(rc, "RegQueryValue"); - retBuf = (char *)alloca(bufSize); + retStr = PyString_FromStringAndSize(NULL, bufSize); + if (retStr == NULL) + return NULL; + retBuf = PyString_AS_STRING(retStr); if ((rc = RegQueryValue(hKey, subKey, retBuf, &bufSize)) - != ERROR_SUCCESS) + != ERROR_SUCCESS) { + Py_DECREF(retStr); return PyErr_SetFromWindowsErrWithFunction(rc, "RegQueryValue"); - return Py_BuildValue("s", retBuf); + } + _PyString_Resize(&retStr, strlen(retBuf)); + return retStr; } static PyObject * @@ -1252,13 +1279,18 @@ != ERROR_SUCCESS) return PyErr_SetFromWindowsErrWithFunction(rc, "RegQueryValueEx"); - retBuf = (char *)alloca(bufSize); + retBuf = (char *)PyMem_Malloc(bufSize); + if (retBuf == NULL) + return PyErr_NoMemory(); if ((rc = RegQueryValueEx(hKey, valueName, NULL, &typ, (BYTE *)retBuf, &bufSize)) - != ERROR_SUCCESS) + != ERROR_SUCCESS) { + PyMem_Free(retBuf); return PyErr_SetFromWindowsErrWithFunction(rc, "RegQueryValueEx"); + } obData = Reg2Py(retBuf, bufSize, typ); + PyMem_Free((void *)retBuf); if (obData == NULL) return NULL; result = Py_BuildValue("Oi", obData, typ); Index: config.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/config.c,v retrieving revision 1.34.2.1 retrieving revision 1.34.2.2 diff -u -d -r1.34.2.1 -r1.34.2.2 --- config.c 28 Apr 2003 17:17:56 -0000 1.34.2.1 +++ config.c 7 Jan 2005 07:04:11 -0000 1.34.2.2 @@ -24,7 +24,6 @@ #ifndef MS_WIN64 extern void initrgbimg(void); #endif -extern void initrotor(void); extern void initsignal(void); extern void initsha(void); extern void initstrop(void); @@ -33,19 +32,36 @@ extern void initthread(void); extern void initcStringIO(void); extern void initcPickle(void); -extern void initpcre(void); #ifdef WIN32 extern void initmsvcrt(void); extern void init_locale(void); #endif extern void init_codecs(void); -extern void initxreadlines(void); extern void init_weakref(void); extern void init_hotshot(void); extern void initxxsubtype(void); extern void initzipimport(void); extern void init_random(void); extern void inititertools(void); +extern void initcollections(void); +extern void init_heapq(void); +extern void init_bisect(void); +extern void init_symtable(void); +extern void initmmap(void); +extern void init_csv(void); +extern void init_sre(void); +extern void initparser(void); +extern void init_winreg(void); +extern void initdatetime(void); + +extern void init_multibytecodec(void); +extern void init_codecs_cn(void); +extern void init_codecs_hk(void); +extern void init_codecs_iso2022(void); +extern void init_codecs_jp(void); +extern void init_codecs_kr(void); +extern void init_codecs_tw(void); +extern void init_subprocess(void); /* tools/freeze/makeconfig.py marker for additional "extern" */ /* -- ADDMODULE MARKER 1 -- */ @@ -76,7 +92,6 @@ #ifndef MS_WIN64 {"rgbimg", initrgbimg}, #endif - {"rotor", initrotor}, {"signal", initsignal}, {"sha", initsha}, {"strop", initstrop}, @@ -87,22 +102,41 @@ #endif {"cStringIO", initcStringIO}, {"cPickle", initcPickle}, - {"pcre", initpcre}, #ifdef WIN32 {"msvcrt", initmsvcrt}, {"_locale", init_locale}, #endif + /* XXX Should _subprocess go in a WIN32 block? not WIN64? */ + {"_subprocess", init_subprocess}, {"_codecs", init_codecs}, - {"xreadlines", initxreadlines}, {"_weakref", init_weakref}, {"_hotshot", init_hotshot}, {"_random", init_random}, + {"_bisect", init_bisect}, + {"_heapq", init_heapq}, {"itertools", inititertools}, + {"collections", initcollections}, + {"_symtable", init_symtable}, + {"mmap", initmmap}, + {"_csv", init_csv}, + {"_sre", init_sre}, + {"parser", initparser}, + {"_winreg", init_winreg}, + {"datetime", initdatetime}, {"xxsubtype", initxxsubtype}, {"zipimport", initzipimport}, + /* CJK codecs */ + {"_multibytecodec", init_multibytecodec}, + {"_codecs_cn", init_codecs_cn}, + {"_codecs_hk", init_codecs_hk}, + {"_codecs_iso2022", init_codecs_iso2022}, + {"_codecs_jp", init_codecs_jp}, + {"_codecs_kr", init_codecs_kr}, + {"_codecs_tw", init_codecs_tw}, + /* tools/freeze/makeconfig.py marker for additional "_inittab" entries */ /* -- ADDMODULE MARKER 2 -- */ Index: dllbase_nt.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/dllbase_nt.txt,v retrieving revision 1.4.16.1 retrieving revision 1.4.16.2 diff -u -d -r1.4.16.1 -r1.4.16.2 --- dllbase_nt.txt 28 Apr 2003 17:17:55 -0000 1.4.16.1 +++ dllbase_nt.txt 7 Jan 2005 07:04:11 -0000 1.4.16.2 @@ -15,15 +15,15 @@ Python.dll - 1e000000 - 1e100000 (-1) Standard Extension Modules 1e100000 - 1e200000 "" - - _symtable 1e100000 - 1e110000 - - bsddb 1e180000 - 1e188000 "" + - _symtable 1e100000 - 1e110000 pyd removed in 2.4 + - bsddb 1e180000 - 1e188000 - _tkinter 1e190000 - 1e1A0000 - - parser 1e1A0000 - 1e1B0000 + - parser 1e1A0000 - 1e1B0000 pyd removed in 2.4 - zlib 1e1B0000 - 1e1C0000 - - winreg 1e1C0000 - 1e1D0000 + - winreg 1e1C0000 - 1e1D0000 pyd removed in 2.4 - _socket 1e1D0000 - 1e1E0000 - - _sre 1e1E0000 - 1e1F0000 - - mmap 1e1F0000 - 1e1FFFFF + - _sre 1e1E0000 - 1e1F0000 pyd removed in 2.4 + - mmap 1e1F0000 - 1e1FFFFF pyd removed in 2.4 More standard extensions 1D100000 - 1e000000 - pyexpat 1D100000 - 1D110000 @@ -31,8 +31,8 @@ - unicodedata 1D120000 - 1D160000 - winsound 1D160000 - 1D170000 - bZ2 1D170000 - 1D180000 - - datetime 1D180000 - 1D190000 - - _csv 1D190000 - 1D1A0000 + - datetime 1D180000 - 1D190000 pyd removed in 2.4 + - _csv 1D190000 - 1D1A0000 pyd removed in 2.4 Other extension modules - win32api 1e200000 - 1e220000 Index: getpathp.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/getpathp.c,v retrieving revision 1.27.2.1 retrieving revision 1.27.2.2 diff -u -d -r1.27.2.1 -r1.27.2.2 --- getpathp.c 28 Apr 2003 17:17:55 -0000 1.27.2.1 +++ getpathp.c 7 Jan 2005 07:04:12 -0000 1.27.2.2 @@ -133,7 +133,15 @@ return 0; } -/* guarantees buffer will never overflow MAXPATHLEN+1 bytes */ +/* Add a path component, by appending stuff to buffer. + buffer must have at least MAXPATHLEN + 1 bytes allocated, and contain a + NUL-terminated string with no more than MAXPATHLEN characters (not counting + the trailing NUL). It's a fatal error if it contains a string longer than + that (callers must be careful!). If these requirements are met, it's + guaranteed that buffer will still be a NUL-terminated string with no more + than MAXPATHLEN characters at exit. If stuff is too long, only as much of + stuff as fits will be appended. +*/ static void join(char *buffer, char *stuff) { @@ -145,6 +153,8 @@ if (n > 0 && !is_sep(buffer[n-1]) && n < MAXPATHLEN) buffer[n++] = SEP; } + if (n > MAXPATHLEN) + Py_FatalError("buffer overflow in getpathp.c's joinpath()"); k = strlen(stuff); if (n + k > MAXPATHLEN) k = MAXPATHLEN - n; @@ -366,7 +376,7 @@ dllpath, MAXPATHLEN+1, NULL, NULL); } - wprogpath[MAXPATHLEN]=_T('\0')'; + wprogpath[MAXPATHLEN]=_T('\0'); if (GetModuleFileName(NULL, wprogpath, MAXPATHLEN)) { WideCharToMultiByte(CP_ACP, 0, wprogpath, -1, Index: msvcrtmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/msvcrtmodule.c,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -u -d -r1.8 -r1.8.2.1 --- msvcrtmodule.c 31 Mar 2002 14:37:44 -0000 1.8 +++ msvcrtmodule.c 7 Jan 2005 07:04:12 -0000 1.8.2.1 @@ -217,7 +217,7 @@ {NULL, NULL} }; -__declspec(dllexport) void +PyMODINIT_FUNC initmsvcrt(void) { PyObject *m = Py_InitModule("msvcrt", msvcrt_functions); Index: pyconfig.h =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/pyconfig.h,v retrieving revision 1.11.2.1 retrieving revision 1.11.2.2 diff -u -d -r1.11.2.1 -r1.11.2.2 --- pyconfig.h 28 Apr 2003 17:17:54 -0000 1.11.2.1 +++ pyconfig.h 7 Jan 2005 07:04:12 -0000 1.11.2.2 @@ -4,7 +4,7 @@ /* pyconfig.h. NOT Generated automatically by configure. This is a manually maintained version used for the Watcom, -Borland and and Microsoft Visual C++ compilers. It is a +Borland and Microsoft Visual C++ compilers. It is a standard part of the Python distribution. WINDOWS DEFINES: @@ -28,7 +28,6 @@ */ #include -#define HAVE_LIMITS_H #define HAVE_SYS_UTIME_H #define HAVE_HYPOT #define HAVE_TEMPNAM @@ -99,6 +98,10 @@ #ifdef MS_WIN64 #ifdef _M_IX86 #define COMPILER _Py_PASTE_VERSION("64 bit (Intel)") +#elif defined(_M_IA64) +#define COMPILER _Py_PASTE_VERSION("64 bit (Itanium)") +#elif defined(_M_AMD64) +#define COMPILER _Py_PASTE_VERSION("64 bit (AMD64)") #else #define COMPILER _Py_PASTE_VERSION("64 bit (Unknown)") #endif @@ -115,6 +118,10 @@ typedef int pid_t; #define hypot _hypot +#include +#define Py_IS_NAN _isnan +#define Py_IS_INFINITY(X) (!_finite(X) && !_isnan(X)) + #endif /* _MSC_VER */ /* define some ANSI types that are not defined in earlier Win headers */ @@ -218,9 +225,9 @@ their Makefile (other compilers are generally taken care of by distutils.) */ # ifdef _DEBUG -# pragma comment(lib,"python23_d.lib") +# pragma comment(lib,"python25_d.lib") # else -# pragma comment(lib,"python23.lib") +# pragma comment(lib,"python25.lib") # endif /* _DEBUG */ # endif /* _MSC_VER */ # endif /* Py_BUILD_CORE */ @@ -264,6 +271,15 @@ #define SIZEOF_LONG 4 #define SIZEOF_LONG_LONG 8 +/* VC 7.1 has them and VC 6.0 does not. VC 6.0 has a version number of 1200. + If some compiler does not provide them, modify the #if appropriately. */ +#if defined(_MSC_VER) +#if _MSC_VER > 1200 +#define HAVE_UINTPTR_T 1 +#define HAVE_INTPTR_T 1 +#endif /* _MSC_VER > 1200 */ +#endif /* _MSC_VER */ + #endif /* Fairly standard from here! */ @@ -295,9 +311,6 @@ tzname. */ #define HAVE_TZNAME -/* Define if on MINIX. */ -/* #undef _MINIX */ - /* Define to `int' if doesn't define. */ /* #undef mode_t */ @@ -351,10 +364,6 @@ /* Define if the closedir function returns void instead of int. */ /* #undef VOID_CLOSEDIR */ -/* Define if your contains bad prototypes for exec*() - (as it does on SGI IRIX 4.x) */ -/* #undef BAD_EXEC_PROTOTYPES */ - /* Define if getpgrp() must be called as getpgrp(0) and (consequently) setpgrp() as setpgrp(0, 0). */ /* #undef GETPGRP_HAVE_ARGS */ @@ -372,24 +381,6 @@ (which you can't on SCO ODT 3.0). */ /* #undef SYS_SELECT_WITH_SYS_TIME */ -/* Define if you want to use SGI (IRIX 4) dynamic linking. - This requires the "dl" library by Jack Jansen, - ftp://ftp.cwi.nl/pub/dynload/dl-1.6.tar.Z. - Don't bother on IRIX 5, it already has dynamic linking using SunOS - style shared libraries */ -/* #undef WITH_SGI_DL */ - -/* Define if you want to emulate SGI (IRIX 4) dynamic linking. - This is rumoured to work on VAX (Ultrix), Sun3 (SunOS 3.4), - Sequent Symmetry (Dynix), and Atari ST. - This requires the "dl-dld" library, - ftp://ftp.cwi.nl/pub/dynload/dl-dld-1.1.tar.Z, - as well as the "GNU dld" library, - ftp://ftp.cwi.nl/pub/dynload/dld-3.2.3.tar.Z. - Don't bother on SunOS 4 or 5, they already have dynamic linking using - shared libraries */ -/* #undef WITH_DL_DLD */ - /* Define if you want documentation strings in extension modules */ #define WITH_DOC_STRINGS 1 @@ -422,9 +413,6 @@ /* Use Python's own small-block memory-allocator. */ #define WITH_PYMALLOC 1 -/* Enable \n, \r, \r\n line ends on import; also the 'U' mode flag for open. */ -#define WITH_UNIVERSAL_NEWLINES 1 - /* Define if you have clock. */ /* #define HAVE_CLOCK */ @@ -506,21 +494,12 @@ /* Define if you have the header file. */ #define HAVE_FCNTL_H 1 -/* Define if you have the header file. */ -#define HAVE_SIGNAL_H 1 - -/* Define if you have the header file. */ -#define HAVE_STDARG_H 1 - /* Define if you have the prototypes. */ #define HAVE_STDARG_PROTOTYPES /* Define if you have the header file. */ #define HAVE_STDDEF_H 1 -/* Define if you have the header file. */ -#define HAVE_STDLIB_H 1 - /* Define if you have the header file. */ /* #undef HAVE_SYS_AUDIOIO_H */ Index: python_nt.rc =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/python_nt.rc,v retrieving revision 1.17.2.1 retrieving revision 1.17.2.2 diff -u -d -r1.17.2.1 -r1.17.2.2 --- python_nt.rc 28 Apr 2003 17:17:54 -0000 1.17.2.1 +++ python_nt.rc 7 Jan 2005 07:04:12 -0000 1.17.2.2 @@ -6,42 +6,12 @@ #define MS_WINDOWS #include "modsupport.h" #include "patchlevel.h" - -/* Across releases, change: - * MS_DLL_ID if the minor version number changes. - * PYTHON_DLL_NAME ditto. - * MS_DLL_ID must match PY_VERSION in the Windows install script. - */ -#define MS_DLL_ID "2.3" - -#ifndef PYTHON_DLL_NAME -#define PYTHON_DLL_NAME "python23.dll" +#ifdef _DEBUG +# include "pythonnt_rc_d.h" +#else +# include "pythonnt_rc.h" #endif -/* Nothing below this should need to be changed except for copyright - * notices, company name, and FIELD3. Unfortunately, all attempts - * to get the resource compiler to do arithmetic in macros have - * failed miserably -- it gives syntax errors, ignores operators, - * or does stuff that's simply bizarre. - */ - - -/* This is what we'd like FIELD3 to be: - * - * #define FIELD3 (PY_MICRO_VERSION*1000 + PY_RELEASE_LEVEL*10 + PY_RELEASE_SERIAL) - * - * but that neither gives an error nor comes anywhere close to working. The - * following comment and #define are output from PCbuild\field3.py: - * - * For 2.3b1, - * PY_MICRO_VERSION = 0 - * PY_RELEASE_LEVEL = 'beta' = 0xb - * PY_RELEASE_SERIAL = 1 - * - * and 0*1000 + 11*10 + 1 = 111 - */ -#define FIELD3 111 - /* e.g., 2.1a2 * PY_VERSION comes from patchevel.h */ @@ -87,11 +57,11 @@ BEGIN BLOCK "000004b0" BEGIN - VALUE "CompanyName", "PythonLabs at Zope Corporation\0" + VALUE "CompanyName", "Python Software Foundation\0" VALUE "FileDescription", "Python Core\0" VALUE "FileVersion", PYTHON_VERSION VALUE "InternalName", "Python DLL\0" - VALUE "LegalCopyright", "Copyright © 2001-2003 Python Software Foundation. Copyright © 2000 BeOpen.com. Copyright © 1995-2001 CNRI. Copyright © 1991-1995 SMC.\0" + VALUE "LegalCopyright", "Copyright © 2001-2004 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 Index: readme.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/readme.txt,v retrieving revision 1.24 retrieving revision 1.24.18.1 diff -u -d -r1.24 -r1.24.18.1 --- readme.txt 26 Jul 2001 21:34:59 -0000 1.24 +++ readme.txt 7 Jan 2005 07:04:12 -0000 1.24.18.1 @@ -1,7 +1,7 @@ Welcome to the "PC" subdirectory of the Python distribution *********************************************************** -*** Note: the project files for MS VC++ 6.0 are now in the +*** Note: the project files for MS VC++ 7.1 are now in the *** PCbuild directory. See the file readme.txt there for build *** instructions. There is some information below that might *** still be relevant. @@ -79,6 +79,12 @@ example_nt A subdirectory showing how to build an extension as a DLL. +Visual Studio 6.0 +================= +The subdirectory VC6 contains Visual Studio 6 project files. These +were originally located in the PCBuild directory, but are no longer +maintained. + IBM VisualAge C/C++ for OS/2 ============================ Index: testpy.py =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/testpy.py,v retrieving revision 1.2 retrieving revision 1.2.32.1 diff -u -d -r1.2 -r1.2.32.1 --- testpy.py 19 May 1997 14:16:12 -0000 1.2 +++ testpy.py 7 Jan 2005 07:04:12 -0000 1.2.32.1 @@ -5,28 +5,28 @@ # change this module too. try: - import string + import string except: - print """Could not import the standard "string" module. -Please check your PYTHONPATH environment variable.""" - sys.exit(1) + print """Could not import the standard "string" module. + Please check your PYTHONPATH environment variable.""" + sys.exit(1) try: - import regex_syntax + import regex_syntax except: - print """Could not import the standard "regex_syntax" module. If this is -a PC, you should add the dos_8x3 directory to your PYTHONPATH.""" - sys.exit(1) + print """Could not import the standard "regex_syntax" module. If this is + a PC, you should add the dos_8x3 directory to your PYTHONPATH.""" + sys.exit(1) import os for dir in sys.path: - file = os.path.join(dir, "string.py") - if os.path.isfile(file): - test = os.path.join(dir, "test") - if os.path.isdir(test): - # Add the "test" directory to PYTHONPATH. - sys.path = sys.path + [test] + file = os.path.join(dir, "string.py") + if os.path.isfile(file): + test = os.path.join(dir, "test") + if os.path.isdir(test): + # Add the "test" directory to PYTHONPATH. + sys.path = sys.path + [test] -import regrtest # Standard Python tester. +import regrtest # Standard Python tester. regrtest.main() Index: winsound.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/winsound.c,v retrieving revision 1.10.2.1 retrieving revision 1.10.2.2 diff -u -d -r1.10.2.1 -r1.10.2.2 --- winsound.c 28 Apr 2003 17:17:52 -0000 1.10.2.1 +++ winsound.c 7 Jan 2005 07:04:12 -0000 1.10.2.2 @@ -73,7 +73,7 @@ "\n" "Beep(frequency, duration) - Make a beep through the PC speaker."); -PyObject * +static PyObject * sound_playsound(PyObject *s, PyObject *args) { const char *sound; From kbk at users.sourceforge.net Fri Jan 7 08:08:03 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Fri Jan 7 08:08:08 2005 Subject: [Python-checkins] python/dist/src/Modules/expat expat_external.h, NONE, 1.1.4.1 macconfig.h, NONE, 1.3.4.1 asciitab.h, 1.1.1.1, 1.1.1.1.2.1 expat.h, 1.3.2.1, 1.3.2.2 iasciitab.h, 1.1.1.1, 1.1.1.1.2.1 internal.h, 1.1.6.1, 1.1.6.2 latin1tab.h, 1.1.1.1, 1.1.1.1.2.1 utf8tab.h, 1.1.1.1, 1.1.1.1.2.1 winconfig.h, 1.1.1.1, 1.1.1.1.2.1 xmlparse.c, 1.2.2.1, 1.2.2.2 xmlrole.c, 1.2.2.1, 1.2.2.2 xmltok.c, 1.2.2.1, 1.2.2.2 xmltok.h, 1.1.1.1.2.1, 1.1.1.1.2.2 xmltok_impl.c, 1.1.1.1.2.1, 1.1.1.1.2.2 expat.h.in, 1.1.1.1, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Modules/expat In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12896/Modules/expat Modified Files: Tag: ast-branch asciitab.h expat.h iasciitab.h internal.h latin1tab.h utf8tab.h winconfig.h xmlparse.c xmlrole.c xmltok.c xmltok.h xmltok_impl.c Added Files: Tag: ast-branch expat_external.h macconfig.h Removed Files: Tag: ast-branch expat.h.in Log Message: Merge MAIN into ast-branch cvs up -kk -j mrg_to_ast-branch_24APR03 -j mrg_to_ast-branch_05JAN05 (date of earlier merge estimated 24Apr03 17:30 UTC, repository tagged) Not merged: Lib/test/test_compile.py, Python/compile.c Refer to Tracker Patch # 1097671 for the merge output and list of conflicts resolved. --- NEW FILE: expat_external.h --- /* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd See the file COPYING for copying permission. */ /* External API definitions */ #if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__) #define XML_USE_MSC_EXTENSIONS 1 #endif /* Expat tries very hard to make the API boundary very specifically defined. There are two macros defined to control this boundary; each of these can be defined before including this header to achieve some different behavior, but doing so it not recommended or tested frequently. XMLCALL - The calling convention to use for all calls across the "library boundary." This will default to cdecl, and try really hard to tell the compiler that's what we want. XMLIMPORT - Whatever magic is needed to note that a function is to be imported from a dynamically loaded library (.dll, .so, or .sl, depending on your platform). The XMLCALL macro was added in Expat 1.95.7. The only one which is expected to be directly useful in client code is XMLCALL. Note that on at least some Unix versions, the Expat library must be compiled with the cdecl calling convention as the default since system headers may assume the cdecl convention. */ #ifndef XMLCALL #if defined(XML_USE_MSC_EXTENSIONS) #define XMLCALL __cdecl #elif defined(__GNUC__) && defined(__i386) #define XMLCALL __attribute__((cdecl)) #else /* For any platform which uses this definition and supports more than one calling convention, we need to extend this definition to declare the convention used on that platform, if it's possible to do so. If this is the case for your platform, please file a bug report with information on how to identify your platform via the C pre-processor and how to specify the same calling convention as the platform's malloc() implementation. */ #define XMLCALL #endif #endif /* not defined XMLCALL */ #if !defined(XML_STATIC) && !defined(XMLIMPORT) #ifndef XML_BUILDING_EXPAT /* using Expat from an application */ #ifdef XML_USE_MSC_EXTENSIONS #define XMLIMPORT __declspec(dllimport) #endif #endif #endif /* not defined XML_STATIC */ /* If we didn't define it above, define it away: */ #ifndef XMLIMPORT #define XMLIMPORT #endif #define XMLPARSEAPI(type) XMLIMPORT type XMLCALL #ifdef __cplusplus extern "C" { #endif #ifdef XML_UNICODE_WCHAR_T #define XML_UNICODE #endif #ifdef XML_UNICODE /* Information is UTF-16 encoded. */ #ifdef XML_UNICODE_WCHAR_T typedef wchar_t XML_Char; typedef wchar_t XML_LChar; #else typedef unsigned short XML_Char; typedef char XML_LChar; #endif /* XML_UNICODE_WCHAR_T */ #else /* Information is UTF-8 encoded. */ typedef char XML_Char; typedef char XML_LChar; #endif /* XML_UNICODE */ --- NEW FILE: macconfig.h --- /*================================================================ ** Copyright 2000, Clark Cooper ** All rights reserved. ** ** This is free software. You are permitted to copy, distribute, or modify ** it under the terms of the MIT/X license (contained in the COPYING file ** with this distribution.) ** */ #ifndef MACCONFIG_H #define MACCONFIG_H /* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */ #define BYTEORDER 4321 /* Define to 1 if you have the `bcopy' function. */ #undef HAVE_BCOPY /* Define to 1 if you have the `memmove' function. */ #define HAVE_MEMMOVE /* Define to 1 if you have a working `mmap' system call. */ #undef HAVE_MMAP /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* whether byteorder is bigendian */ #define WORDS_BIGENDIAN /* Define to specify how much context to retain around the current parse point. */ #undef XML_CONTEXT_BYTES /* Define to make parameter entity parsing functionality available. */ #define XML_DTD /* Define to make XML Namespaces functionality available. */ #define XML_NS /* Define to empty if `const' does not conform to ANSI C. */ #undef const /* Define to `long' if does not define. */ #define off_t long /* Define to `unsigned' if does not define. */ #undef size_t #endif /* ifndef MACCONFIG_H */ Index: asciitab.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/expat/asciitab.h,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -u -d -r1.1.1.1 -r1.1.1.1.2.1 --- asciitab.h 11 Feb 2002 23:13:05 -0000 1.1.1.1 +++ asciitab.h 7 Jan 2005 07:03:40 -0000 1.1.1.1.2.1 @@ -1,6 +1,5 @@ -/* -Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd -See the file COPYING for copying permission. +/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd + See the file COPYING for copying permission. */ /* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, Index: expat.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/expat/expat.h,v retrieving revision 1.3.2.1 retrieving revision 1.3.2.2 diff -u -d -r1.3.2.1 -r1.3.2.2 --- expat.h 28 Apr 2003 17:18:25 -0000 1.3.2.1 +++ expat.h 7 Jan 2005 07:03:41 -0000 1.3.2.2 @@ -15,43 +15,11 @@ #endif #include - -#ifndef XMLPARSEAPI -#if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__) -#ifdef XML_STATIC -#define XMLPARSEAPI(type) type __cdecl -#else -#define XMLPARSEAPI(type) __declspec(dllimport) type __cdecl -#endif -#else -#define XMLPARSEAPI(type) type -#endif -#endif /* not defined XMLPARSEAPI */ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef XML_UNICODE_WCHAR_T -#define XML_UNICODE -#endif +#include "expat_external.h" struct XML_ParserStruct; typedef struct XML_ParserStruct *XML_Parser; -#ifdef XML_UNICODE /* Information is UTF-16 encoded. */ -#ifdef XML_UNICODE_WCHAR_T -typedef wchar_t XML_Char; -typedef wchar_t XML_LChar; -#else -typedef unsigned short XML_Char; -typedef char XML_LChar; -#endif /* XML_UNICODE_WCHAR_T */ -#else /* Information is UTF-8 encoded. */ -typedef char XML_Char; -typedef char XML_LChar; -#endif /* XML_UNICODE */ - /* Should this be defined using stdbool.h when C99 is available? */ typedef unsigned char XML_Bool; #define XML_TRUE ((XML_Bool) 1) @@ -73,8 +41,10 @@ enum XML_Status { XML_STATUS_ERROR = 0, #define XML_STATUS_ERROR XML_STATUS_ERROR - XML_STATUS_OK = 1 + XML_STATUS_OK = 1, #define XML_STATUS_OK XML_STATUS_OK + XML_STATUS_SUSPENDED = 2, +#define XML_STATUS_SUSPENDED XML_STATUS_SUSPENDED }; enum XML_Error { @@ -104,7 +74,20 @@ XML_ERROR_UNEXPECTED_STATE, XML_ERROR_ENTITY_DECLARED_IN_PE, XML_ERROR_FEATURE_REQUIRES_XML_DTD, - XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING + XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING, + /* Added in 1.95.7. */ + XML_ERROR_UNBOUND_PREFIX, + /* Added in 1.95.8. */ + XML_ERROR_UNDECLARING_PREFIX, + XML_ERROR_INCOMPLETE_PE, + XML_ERROR_XML_DECL, + XML_ERROR_TEXT_DECL, + XML_ERROR_PUBLICID, + XML_ERROR_SUSPENDED, + XML_ERROR_NOT_SUSPENDED, + XML_ERROR_ABORTED, + XML_ERROR_FINISHED, + XML_ERROR_SUSPEND_PE }; enum XML_Content_Type { @@ -156,9 +139,9 @@ description of the model argument. It's the caller's responsibility to free model when finished with it. */ -typedef void (*XML_ElementDeclHandler) (void *userData, - const XML_Char *name, - XML_Content *model); +typedef void (XMLCALL *XML_ElementDeclHandler) (void *userData, + const XML_Char *name, + XML_Content *model); XMLPARSEAPI(void) XML_SetElementDeclHandler(XML_Parser parser, @@ -172,12 +155,13 @@ value will be NULL in the case of "#REQUIRED". If "isrequired" is true and default is non-NULL, then this is a "#FIXED" default. */ -typedef void (*XML_AttlistDeclHandler) (void *userData, - const XML_Char *elname, - const XML_Char *attname, - const XML_Char *att_type, - const XML_Char *dflt, - int isrequired); +typedef void (XMLCALL *XML_AttlistDeclHandler) ( + void *userData, + const XML_Char *elname, + const XML_Char *attname, + const XML_Char *att_type, + const XML_Char *dflt, + int isrequired); XMLPARSEAPI(void) XML_SetAttlistDeclHandler(XML_Parser parser, @@ -191,10 +175,10 @@ was no standalone parameter in the declaration, that it was given as no, or that it was given as yes. */ -typedef void (*XML_XmlDeclHandler) (void *userData, - const XML_Char *version, - const XML_Char *encoding, - int standalone); +typedef void (XMLCALL *XML_XmlDeclHandler) (void *userData, + const XML_Char *version, + const XML_Char *encoding, + int standalone); XMLPARSEAPI(void) XML_SetXmlDeclHandler(XML_Parser parser, @@ -257,29 +241,31 @@ /* atts is array of name/value pairs, terminated by 0; names and values are 0 terminated. */ -typedef void (*XML_StartElementHandler)(void *userData, - const XML_Char *name, - const XML_Char **atts); +typedef void (XMLCALL *XML_StartElementHandler) (void *userData, + const XML_Char *name, + const XML_Char **atts); -typedef void (*XML_EndElementHandler)(void *userData, - const XML_Char *name); +typedef void (XMLCALL *XML_EndElementHandler) (void *userData, + const XML_Char *name); /* s is not 0 terminated. */ -typedef void (*XML_CharacterDataHandler)(void *userData, - const XML_Char *s, - int len); +typedef void (XMLCALL *XML_CharacterDataHandler) (void *userData, + const XML_Char *s, + int len); /* target and data are 0 terminated */ -typedef void (*XML_ProcessingInstructionHandler)(void *userData, - const XML_Char *target, - const XML_Char *data); +typedef void (XMLCALL *XML_ProcessingInstructionHandler) ( + void *userData, + const XML_Char *target, + const XML_Char *data); /* data is 0 terminated */ -typedef void (*XML_CommentHandler)(void *userData, const XML_Char *data); +typedef void (XMLCALL *XML_CommentHandler) (void *userData, + const XML_Char *data); -typedef void (*XML_StartCdataSectionHandler)(void *userData); -typedef void (*XML_EndCdataSectionHandler)(void *userData); +typedef void (XMLCALL *XML_StartCdataSectionHandler) (void *userData); +typedef void (XMLCALL *XML_EndCdataSectionHandler) (void *userData); /* This is called for any characters in the XML document for which there is no applicable handler. This includes both characters that @@ -294,14 +280,15 @@ default handler: for example, a comment might be split between multiple calls. */ -typedef void (*XML_DefaultHandler)(void *userData, - const XML_Char *s, - int len); +typedef void (XMLCALL *XML_DefaultHandler) (void *userData, + const XML_Char *s, + int len); /* This is called for the start of the DOCTYPE declaration, before any DTD or internal subset is parsed. */ -typedef void (*XML_StartDoctypeDeclHandler)(void *userData, +typedef void (XMLCALL *XML_StartDoctypeDeclHandler) ( + void *userData, const XML_Char *doctypeName, const XML_Char *sysid, const XML_Char *pubid, @@ -311,7 +298,7 @@ closing > is encountered, but after processing any external subset. */ -typedef void (*XML_EndDoctypeDeclHandler)(void *userData); +typedef void (XMLCALL *XML_EndDoctypeDeclHandler)(void *userData); /* This is called for entity declarations. The is_parameter_entity argument will be non-zero if the entity is a parameter entity, zero @@ -331,15 +318,16 @@ Note that is_parameter_entity can't be changed to XML_Bool, since that would break binary compatibility. */ -typedef void (*XML_EntityDeclHandler) (void *userData, - const XML_Char *entityName, - int is_parameter_entity, - const XML_Char *value, - int value_length, - const XML_Char *base, - const XML_Char *systemId, - const XML_Char *publicId, - const XML_Char *notationName); +typedef void (XMLCALL *XML_EntityDeclHandler) ( + void *userData, + const XML_Char *entityName, + int is_parameter_entity, + const XML_Char *value, + int value_length, + const XML_Char *base, + const XML_Char *systemId, + const XML_Char *publicId, + const XML_Char *notationName); XMLPARSEAPI(void) XML_SetEntityDeclHandler(XML_Parser parser, @@ -354,22 +342,24 @@ entityName, systemId and notationName arguments will never be NULL. The other arguments may be. */ -typedef void (*XML_UnparsedEntityDeclHandler)(void *userData, - const XML_Char *entityName, - const XML_Char *base, - const XML_Char *systemId, - const XML_Char *publicId, - const XML_Char *notationName); +typedef void (XMLCALL *XML_UnparsedEntityDeclHandler) ( + void *userData, + const XML_Char *entityName, + const XML_Char *base, + const XML_Char *systemId, + const XML_Char *publicId, + const XML_Char *notationName); /* This is called for a declaration of notation. The base argument is whatever was set by XML_SetBase. The notationName will never be NULL. The other arguments can be. */ -typedef void (*XML_NotationDeclHandler)(void *userData, - const XML_Char *notationName, - const XML_Char *base, - const XML_Char *systemId, - const XML_Char *publicId); +typedef void (XMLCALL *XML_NotationDeclHandler) ( + void *userData, + const XML_Char *notationName, + const XML_Char *base, + const XML_Char *systemId, + const XML_Char *publicId); /* When namespace processing is enabled, these are called once for each namespace declaration. The call to the start and end element @@ -377,12 +367,14 @@ declaration handlers. For an xmlns attribute, prefix will be NULL. For an xmlns="" attribute, uri will be NULL. */ -typedef void (*XML_StartNamespaceDeclHandler)(void *userData, - const XML_Char *prefix, - const XML_Char *uri); +typedef void (XMLCALL *XML_StartNamespaceDeclHandler) ( + void *userData, + const XML_Char *prefix, + const XML_Char *uri); -typedef void (*XML_EndNamespaceDeclHandler)(void *userData, - const XML_Char *prefix); +typedef void (XMLCALL *XML_EndNamespaceDeclHandler) ( + void *userData, + const XML_Char *prefix); /* This is called if the document is not standalone, that is, it has an external subset or a reference to a parameter entity, but does not @@ -393,7 +385,7 @@ conditions above this handler will only be called if the referenced entity was actually read. */ -typedef int (*XML_NotStandaloneHandler)(void *userData); +typedef int (XMLCALL *XML_NotStandaloneHandler) (void *userData); /* This is called for a reference to an external parsed general entity. The referenced entity is not automatically parsed. The @@ -429,11 +421,12 @@ Note that unlike other handlers the first argument is the parser, not userData. */ -typedef int (*XML_ExternalEntityRefHandler)(XML_Parser parser, - const XML_Char *context, - const XML_Char *base, - const XML_Char *systemId, - const XML_Char *publicId); +typedef int (XMLCALL *XML_ExternalEntityRefHandler) ( + XML_Parser parser, + const XML_Char *context, + const XML_Char *base, + const XML_Char *systemId, + const XML_Char *publicId); /* This is called in two situations: 1) An entity reference is encountered for which no declaration @@ -445,9 +438,10 @@ the event would be out of sync with the reporting of the declarations or attribute values */ -typedef void (*XML_SkippedEntityHandler)(void *userData, - const XML_Char *entityName, - int is_parameter_entity); +typedef void (XMLCALL *XML_SkippedEntityHandler) ( + void *userData, + const XML_Char *entityName, + int is_parameter_entity); /* This structure is filled in by the XML_UnknownEncodingHandler to provide information to the parser about encodings that are unknown @@ -504,8 +498,8 @@ typedef struct { int map[256]; void *data; - int (*convert)(void *data, const char *s); - void (*release)(void *data); + int (XMLCALL *convert)(void *data, const char *s); + void (XMLCALL *release)(void *data); } XML_Encoding; /* This is called for an encoding that is unknown to the parser. @@ -523,9 +517,10 @@ If info does not describe a suitable encoding, then the parser will return an XML_UNKNOWN_ENCODING error. */ -typedef int (*XML_UnknownEncodingHandler)(void *encodingHandlerData, - const XML_Char *name, - XML_Encoding *info); +typedef int (XMLCALL *XML_UnknownEncodingHandler) ( + void *encodingHandlerData, + const XML_Char *name, + XML_Encoding *info); XMLPARSEAPI(void) XML_SetElementHandler(XML_Parser parser, @@ -533,10 +528,12 @@ XML_EndElementHandler end); XMLPARSEAPI(void) -XML_SetStartElementHandler(XML_Parser, XML_StartElementHandler); +XML_SetStartElementHandler(XML_Parser parser, + XML_StartElementHandler handler); XMLPARSEAPI(void) -XML_SetEndElementHandler(XML_Parser, XML_EndElementHandler); +XML_SetEndElementHandler(XML_Parser parser, + XML_EndElementHandler handler); XMLPARSEAPI(void) XML_SetCharacterDataHandler(XML_Parser parser, @@ -625,7 +622,8 @@ instead of the parser object. */ XMLPARSEAPI(void) -XML_SetExternalEntityRefHandlerArg(XML_Parser, void *arg); +XML_SetExternalEntityRefHandlerArg(XML_Parser parser, + void *arg); XMLPARSEAPI(void) XML_SetSkippedEntityHandler(XML_Parser parser, @@ -688,6 +686,9 @@ specified in the document. In such a case the parser will call the externalEntityRefHandler with a value of NULL for the systemId argument (the publicId and context arguments will be NULL as well). + Note: For the purpose of checking WFC: Entity Declared, passing + useDTD == XML_TRUE will make the parser behave as if the document + had a DTD with an external subset. Note: If this function is called, then this must be done before the first call to XML_Parse or XML_ParseBuffer, since it will have no effect after that. Returns @@ -751,6 +752,75 @@ XMLPARSEAPI(enum XML_Status) XML_ParseBuffer(XML_Parser parser, int len, int isFinal); +/* Stops parsing, causing XML_Parse() or XML_ParseBuffer() to return. + Must be called from within a call-back handler, except when aborting + (resumable = 0) an already suspended parser. Some call-backs may + still follow because they would otherwise get lost. Examples: + - endElementHandler() for empty elements when stopped in + startElementHandler(), + - endNameSpaceDeclHandler() when stopped in endElementHandler(), + and possibly others. + + Can be called from most handlers, including DTD related call-backs, + except when parsing an external parameter entity and resumable != 0. + Returns XML_STATUS_OK when successful, XML_STATUS_ERROR otherwise. + Possible error codes: + - XML_ERROR_SUSPENDED: when suspending an already suspended parser. + - XML_ERROR_FINISHED: when the parser has already finished. + - XML_ERROR_SUSPEND_PE: when suspending while parsing an external PE. + + When resumable != 0 (true) then parsing is suspended, that is, + XML_Parse() and XML_ParseBuffer() return XML_STATUS_SUSPENDED. + Otherwise, parsing is aborted, that is, XML_Parse() and XML_ParseBuffer() + return XML_STATUS_ERROR with error code XML_ERROR_ABORTED. + + *Note*: + This will be applied to the current parser instance only, that is, if + there is a parent parser then it will continue parsing when the + externalEntityRefHandler() returns. It is up to the implementation of + the externalEntityRefHandler() to call XML_StopParser() on the parent + parser (recursively), if one wants to stop parsing altogether. + + When suspended, parsing can be resumed by calling XML_ResumeParser(). +*/ +XMLPARSEAPI(enum XML_Status) +XML_StopParser(XML_Parser parser, XML_Bool resumable); + +/* Resumes parsing after it has been suspended with XML_StopParser(). + Must not be called from within a handler call-back. Returns same + status codes as XML_Parse() or XML_ParseBuffer(). + Additional error code XML_ERROR_NOT_SUSPENDED possible. + + *Note*: + This must be called on the most deeply nested child parser instance + first, and on its parent parser only after the child parser has finished, + to be applied recursively until the document entity's parser is restarted. + That is, the parent parser will not resume by itself and it is up to the + application to call XML_ResumeParser() on it at the appropriate moment. +*/ +XMLPARSEAPI(enum XML_Status) +XML_ResumeParser(XML_Parser parser); + +enum XML_Parsing { + XML_INITIALIZED, + XML_PARSING, + XML_FINISHED, + XML_SUSPENDED +}; + +typedef struct { + enum XML_Parsing parsing; + XML_Bool finalBuffer; +} XML_ParsingStatus; + +/* Returns status of parser with respect to being initialized, parsing, + finished, or suspended and processing the final buffer. + XXX XML_Parse() and XML_ParseBuffer() should return XML_ParsingStatus, + XXX with XML_FINISHED_OK or XML_FINISHED_ERROR replacing XML_FINISHED +*/ +XMLPARSEAPI(void) +XML_GetParsingStatus(XML_Parser parser, XML_ParsingStatus *status); + /* Creates an XML_Parser object that can parse an external general entity; context is a '\0'-terminated string specifying the parse context; encoding is a '\0'-terminated string giving the name of @@ -813,8 +883,13 @@ /* These functions return information about the current parse location. They may be called from any callback called to report - some parse event; in this case the location is the location of - the first of the sequence of characters that generated the event. + some parse event; in this case the location is the location of the + first of the sequence of characters that generated the event. When + called from callbacks generated by declarations in the document + prologue, the location identified isn't as neatly defined, but will + be within the relevant markup. When called outside of the callback + functions, the position indicated will be just past the last parse + event (regardless of whether there was an associated callback). They may also be called after returning from a call to XML_Parse or XML_ParseBuffer. If the return value is XML_STATUS_ERROR then @@ -920,7 +995,7 @@ */ #define XML_MAJOR_VERSION 1 #define XML_MINOR_VERSION 95 -#define XML_MICRO_VERSION 6 +#define XML_MICRO_VERSION 8 #ifdef __cplusplus } Index: iasciitab.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/expat/iasciitab.h,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -u -d -r1.1.1.1 -r1.1.1.1.2.1 --- iasciitab.h 11 Feb 2002 23:13:05 -0000 1.1.1.1 +++ iasciitab.h 7 Jan 2005 07:03:41 -0000 1.1.1.1.2.1 @@ -1,6 +1,5 @@ -/* -Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd -See the file COPYING for copying permission. +/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd + See the file COPYING for copying permission. */ /* Like asciitab.h, except that 0xD has code BT_S rather than BT_CR */ Index: internal.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/expat/internal.h,v retrieving revision 1.1.6.1 retrieving revision 1.1.6.2 diff -u -d -r1.1.6.1 -r1.1.6.2 --- internal.h 28 Apr 2003 17:18:25 -0000 1.1.6.1 +++ internal.h 7 Jan 2005 07:03:41 -0000 1.1.6.2 @@ -20,17 +20,20 @@ and therefore subject to change. */ -#if defined(__GNUC__) -/* Instability reported with egcs on a RedHat Linux 7.3. - Let's comment it out: +#if defined(__GNUC__) && defined(__i386__) +/* We'll use this version by default only where we know it helps. + + regparm() generates warnings on Solaris boxes. See SF bug #692878. + + Instability reported with egcs on a RedHat Linux 7.3. + Let's comment out: #define FASTCALL __attribute__((stdcall, regparm(3))) and let's try this: */ #define FASTCALL __attribute__((regparm(3))) -#define PTRCALL #define PTRFASTCALL __attribute__((regparm(3))) +#endif -#elif defined(WIN32) /* Using __fastcall seems to have an unexpected negative effect under MS VC++, especially for function pointers, so we won't use it for now on that platform. It may be reconsidered for a future release @@ -38,11 +41,8 @@ Likely reason: __fastcall on Windows is like stdcall, therefore the compiler cannot perform stack optimizations for call clusters. */ -#define FASTCALL -#define PTRCALL -#define PTRFASTCALL -#endif +/* Make sure all of these are defined if they aren't already. */ #ifndef FASTCALL #define FASTCALL Index: latin1tab.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/expat/latin1tab.h,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -u -d -r1.1.1.1 -r1.1.1.1.2.1 --- latin1tab.h 11 Feb 2002 23:13:05 -0000 1.1.1.1 +++ latin1tab.h 7 Jan 2005 07:03:41 -0000 1.1.1.1.2.1 @@ -1,6 +1,5 @@ -/* -Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd -See the file COPYING for copying permission. +/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd + See the file COPYING for copying permission. */ /* 0x80 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, Index: utf8tab.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/expat/utf8tab.h,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -u -d -r1.1.1.1 -r1.1.1.1.2.1 --- utf8tab.h 11 Feb 2002 23:13:05 -0000 1.1.1.1 +++ utf8tab.h 7 Jan 2005 07:03:41 -0000 1.1.1.1.2.1 @@ -1,6 +1,5 @@ -/* -Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd -See the file COPYING for copying permission. +/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd + See the file COPYING for copying permission. */ Index: winconfig.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/expat/winconfig.h,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -u -d -r1.1.1.1 -r1.1.1.1.2.1 --- winconfig.h 11 Feb 2002 23:13:08 -0000 1.1.1.1 +++ winconfig.h 7 Jan 2005 07:03:41 -0000 1.1.1.1.2.1 @@ -5,8 +5,6 @@ ** This is free software. You are permitted to copy, distribute, or modify ** it under the terms of the MIT/X license (contained in the COPYING file ** with this distribution.) -** -** */ #ifndef WINCONFIG_H @@ -21,7 +19,12 @@ #define XML_NS 1 #define XML_DTD 1 -#define XML_BYTE_ORDER 12 #define XML_CONTEXT_BYTES 1024 +/* we will assume all Windows platforms are little endian */ +#define BYTEORDER 1234 + +/* Windows has memmove() available. */ +#define HAVE_MEMMOVE + #endif /* ndef WINCONFIG_H */ Index: xmlparse.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/expat/xmlparse.c,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -u -d -r1.2.2.1 -r1.2.2.2 --- xmlparse.c 28 Apr 2003 17:18:23 -0000 1.2.2.1 +++ xmlparse.c 7 Jan 2005 07:03:41 -0000 1.2.2.2 @@ -4,36 +4,20 @@ #include #include /* memset(), memcpy() */ +#include -#ifdef COMPILED_FROM_DSP +#define XML_BUILDING_EXPAT 1 +#ifdef COMPILED_FROM_DSP #include "winconfig.h" -#define XMLPARSEAPI(type) type __cdecl [...2634 lines suppressed...] @@ -5529,8 +6017,8 @@ int blockSize = (pool->end - pool->start)*2; pool->blocks = (BLOCK *) pool->mem->realloc_fcn(pool->blocks, - (offsetof(BLOCK, s) - + blockSize * sizeof(XML_Char))); + (offsetof(BLOCK, s) + + blockSize * sizeof(XML_Char))); if (pool->blocks == NULL) return XML_FALSE; pool->blocks->size = blockSize; @@ -5546,7 +6034,7 @@ else blockSize *= 2; tem = (BLOCK *)pool->mem->malloc_fcn(offsetof(BLOCK, s) - + blockSize * sizeof(XML_Char)); + + blockSize * sizeof(XML_Char)); if (!tem) return XML_FALSE; tem->size = blockSize; Index: xmlrole.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/expat/xmlrole.c,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -u -d -r1.2.2.1 -r1.2.2.2 --- xmlrole.c 28 Apr 2003 17:18:23 -0000 1.2.2.1 +++ xmlrole.c 7 Jan 2005 07:03:42 -0000 1.2.2.2 @@ -2,16 +2,19 @@ See the file COPYING for copying permission. */ +#include + #ifdef COMPILED_FROM_DSP #include "winconfig.h" #elif defined(MACOS_CLASSIC) #include "macconfig.h" #else -/* Unused - MvL +#ifdef HAVE_EXPAT_CONFIG_H #include -*/ +#endif #endif /* ndef COMPILED_FROM_DSP */ +#include "expat_external.h" #include "internal.h" #include "xmlrole.h" #include "ascii.h" @@ -370,6 +373,8 @@ case XML_TOK_CLOSE_BRACKET: state->handler = doctype5; return XML_ROLE_DOCTYPE_NONE; + case XML_TOK_NONE: + return XML_ROLE_NONE; } return common(state, tok); } Index: xmltok.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/expat/xmltok.c,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -u -d -r1.2.2.1 -r1.2.2.2 --- xmltok.c 28 Apr 2003 17:18:22 -0000 1.2.2.1 +++ xmltok.c 7 Jan 2005 07:03:42 -0000 1.2.2.2 @@ -2,16 +2,19 @@ See the file COPYING for copying permission. */ +#include + #ifdef COMPILED_FROM_DSP #include "winconfig.h" #elif defined(MACOS_CLASSIC) #include "macconfig.h" #else -/* Unused - MvL +#ifdef HAVE_EXPAT_CONFIG_H #include -*/ +#endif #endif /* ndef COMPILED_FROM_DSP */ +#include "expat_external.h" #include "internal.h" #include "xmltok.h" #include "nametab.h" @@ -1233,7 +1236,7 @@ struct unknown_encoding { struct normal_encoding normal; - int (*convert)(void *userData, const char *p); + CONVERTER convert; void *userData; unsigned short utf16[256]; char utf8[256][4]; Index: xmltok.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/expat/xmltok.h,v retrieving revision 1.1.1.1.2.1 retrieving revision 1.1.1.1.2.2 diff -u -d -r1.1.1.1.2.1 -r1.1.1.1.2.2 --- xmltok.h 28 Apr 2003 17:18:22 -0000 1.1.1.1.2.1 +++ xmltok.h 7 Jan 2005 07:03:43 -0000 1.1.1.1.2.2 @@ -281,7 +281,8 @@ int FASTCALL XmlUtf16Encode(int charNumber, unsigned short *buf); int XmlSizeOfUnknownEncoding(void); -typedef int (*CONVERTER)(void *userData, const char *p); + +typedef int (XMLCALL *CONVERTER) (void *userData, const char *p); ENCODING * XmlInitUnknownEncoding(void *mem, Index: xmltok_impl.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/expat/xmltok_impl.c,v retrieving revision 1.1.1.1.2.1 retrieving revision 1.1.1.1.2.2 diff -u -d -r1.1.1.1.2.1 -r1.1.1.1.2.2 --- xmltok_impl.c 28 Apr 2003 17:18:22 -0000 1.1.1.1.2.1 +++ xmltok_impl.c 7 Jan 2005 07:03:43 -0000 1.1.1.1.2.2 @@ -882,7 +882,7 @@ const char **nextTokPtr) { if (ptr == end) - return XML_TOK_PARTIAL; + return -XML_TOK_PERCENT; switch (BYTE_TYPE(enc, ptr)) { CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) case BT_S: case BT_LF: case BT_CR: case BT_PERCNT: --- expat.h.in DELETED --- From kbk at users.sourceforge.net Fri Jan 7 08:08:16 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Fri Jan 7 08:08:23 2005 Subject: [Python-checkins] python/dist/src/Objects dictnotes.txt, NONE, 1.5.6.1 genobject.c, NONE, 1.4.4.1 setobject.c, NONE, 1.31.4.1 abstract.c, 2.103.2.1, 2.103.2.2 bufferobject.c, 2.19.2.1, 2.19.2.2 classobject.c, 2.158.2.1, 2.158.2.2 cobject.c, 2.14, 2.14.2.1 complexobject.c, 2.62.2.1, 2.62.2.2 descrobject.c, 2.27.2.1, 2.27.2.2 dictobject.c, 2.126.2.1, 2.126.2.2 enumobject.c, 1.2.2.1, 1.2.2.2 fileobject.c, 2.164.2.1, 2.164.2.2 floatobject.c, 2.113.2.1, 2.113.2.2 frameobject.c, 2.62.2.2, 2.62.2.3 funcobject.c, 2.55.2.2, 2.55.2.3 intobject.c, 2.84.2.1, 2.84.2.2 iterobject.c, 1.10.2.1, 1.10.2.2 listobject.c, 2.114.2.1, 2.114.2.2 longobject.c, 1.118.2.1, 1.118.2.2 methodobject.c, 2.42.2.1, 2.42.2.2 moduleobject.c, 2.45, 2.45.2.1 object.c, 2.179.2.2, 2.179.2.3 obmalloc.c, 2.45.2.1, 2.45.2.2 rangeobject.c, 2.41.2.1, 2.41.2.2 sliceobject.c, 2.15.2.1, 2.15.2.2 stringobject.c, 2.168.2.1, 2.168.2.2 tupleobject.c, 2.68.2.1, 2.68.2.2 typeobject.c, 2.157.2.2, 2.157.2.3 unicodectype.c, 2.11.18.1, 2.11.18.2 unicodeobject.c, 2.155.2.1, 2.155.2.2 unicodetype_db.h, 1.4.26.1, 1.4.26.2 weakrefobject.c, 1.9.2.1, 1.9.2.2 xxobject.c, 2.20.2.1, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12896/Objects Modified Files: Tag: ast-branch abstract.c bufferobject.c classobject.c cobject.c complexobject.c descrobject.c dictobject.c enumobject.c fileobject.c floatobject.c frameobject.c funcobject.c intobject.c iterobject.c listobject.c longobject.c methodobject.c moduleobject.c object.c obmalloc.c rangeobject.c sliceobject.c stringobject.c tupleobject.c typeobject.c unicodectype.c unicodeobject.c unicodetype_db.h weakrefobject.c Added Files: Tag: ast-branch dictnotes.txt genobject.c setobject.c Removed Files: Tag: ast-branch xxobject.c Log Message: Merge MAIN into ast-branch cvs up -kk -j mrg_to_ast-branch_24APR03 -j mrg_to_ast-branch_05JAN05 (date of earlier merge estimated 24Apr03 17:30 UTC, repository tagged) Not merged: Lib/test/test_compile.py, Python/compile.c Refer to Tracker Patch # 1097671 for the merge output and list of conflicts resolved. --- NEW FILE: dictnotes.txt --- NOTES ON OPTIMIZING DICTIONARIES ================================ Principal Use Cases for Dictionaries ------------------------------------ Passing keyword arguments Typically, one read and one write for 1 to 3 elements. Occurs frequently in normal python code. Class method lookup Dictionaries vary in size with 8 to 16 elements being common. Usually written once with many lookups. When base classes are used, there are many failed lookups followed by a lookup in a base class. Instance attribute lookup and Global variables Dictionaries vary in size. 4 to 10 elements are common. Both reads and writes are common. Builtins Frequent reads. Almost never written. Size 126 interned strings (as of Py2.3b1). A few keys are accessed much more frequently than others. Uniquification Dictionaries of any size. Bulk of work is in creation. Repeated writes to a smaller set of keys. Single read of each key. Some use cases have two consecutive accesses to the same key. * Removing duplicates from a sequence. dict.fromkeys(seqn).keys() * Counting elements in a sequence. for e in seqn: d[e] = d.get(e,0) + 1 * Accumulating references in a dictionary of lists: for pagenumber, page in enumerate(pages): for word in page: d.setdefault(word, []).append(pagenumber) Note, the second example is a use case characterized by a get and set to the same key. There are similar used cases with a __contains__ followed by a get, set, or del to the same key. Part of the justification for d.setdefault is combining the two lookups into one. Membership Testing Dictionaries of any size. Created once and then rarely changes. Single write to each key. Many calls to __contains__() or has_key(). Similar access patterns occur with replacement dictionaries such as with the % formatting operator. Dynamic Mappings Characterized by deletions interspersed with adds and replacements. Performance benefits greatly from the re-use of dummy entries. Data Layout (assuming a 32-bit box with 64 bytes per cache line) ---------------------------------------------------------------- Smalldicts (8 entries) are attached to the dictobject structure and the whole group nearly fills two consecutive cache lines. Larger dicts use the first half of the dictobject structure (one cache line) and a separate, continuous block of entries (at 12 bytes each for a total of 5.333 entries per cache line). Tunable Dictionary Parameters ----------------------------- * PyDict_MINSIZE. Currently set to 8. Must be a power of two. New dicts have to zero-out every cell. Each additional 8 consumes 1.5 cache lines. Increasing improves the sparseness of small dictionaries but costs time to read in the additional cache lines if they are not already in cache. That case is common when keyword arguments are passed. * Maximum dictionary load in PyDict_SetItem. Currently set to 2/3. Increasing this ratio makes dictionaries more dense resulting in more collisions. Decreasing it improves sparseness at the expense of spreading entries over more cache lines and at the cost of total memory consumed. The load test occurs in highly time sensitive code. Efforts to make the test more complex (for example, varying the load for different sizes) have degraded performance. * Growth rate upon hitting maximum load. Currently set to *2. Raising this to *4 results in half the number of resizes, less effort to resize, better sparseness for some (but not all dict sizes), and potentially doubles memory consumption depending on the size of the dictionary. Setting to *4 eliminates every other resize step. Tune-ups should be measured across a broad range of applications and use cases. A change to any parameter will help in some situations and hurt in others. The key is to find settings that help the most common cases and do the least damage to the less common cases. Results will vary dramatically depending on the exact number of keys, whether the keys are all strings, whether reads or writes dominate, the exact hash values of the keys (some sets of values have fewer collisions than others). Any one test or benchmark is likely to prove misleading. While making a dictionary more sparse reduces collisions, it impairs iteration and key listing. Those methods loop over every potential entry. Doubling the size of dictionary results in twice as many non-overlapping memory accesses for keys(), items(), values(), __iter__(), iterkeys(), iteritems(), itervalues(), and update(). Also, every dictionary iterates at least twice, once for the memset() when it is created and once by dealloc(). Results of Cache Locality Experiments ------------------------------------- When an entry is retrieved from memory, 4.333 adjacent entries are also retrieved into a cache line. Since accessing items in cache is *much* cheaper than a cache miss, an enticing idea is to probe the adjacent entries as a first step in collision resolution. Unfortunately, the introduction of any regularity into collision searches results in more collisions than the current random chaining approach. Exploiting cache locality at the expense of additional collisions fails to payoff when the entries are already loaded in cache (the expense is paid with no compensating benefit). This occurs in small dictionaries where the whole dictionary fits into a pair of cache lines. It also occurs frequently in large dictionaries which have a common access pattern where some keys are accessed much more frequently than others. The more popular entries *and* their collision chains tend to remain in cache. To exploit cache locality, change the collision resolution section in lookdict() and lookdict_string(). Set i^=1 at the top of the loop and move the i = (i << 2) + i + perturb + 1 to an unrolled version of the loop. This optimization strategy can be leveraged in several ways: * If the dictionary is kept sparse (through the tunable parameters), then the occurrence of additional collisions is lessened. * If lookdict() and lookdict_string() are specialized for small dicts and for largedicts, then the versions for large_dicts can be given an alternate search strategy without increasing collisions in small dicts which already have the maximum benefit of cache locality. * If the use case for a dictionary is known to have a random key access pattern (as opposed to a more common pattern with a Zipf's law distribution), then there will be more benefit for large dictionaries because any given key is no more likely than another to already be in cache. * In use cases with paired accesses to the same key, the second access is always in cache and gets no benefit from efforts to further improve cache locality. Optimizing the Search of Small Dictionaries ------------------------------------------- If lookdict() and lookdict_string() are specialized for smaller dictionaries, then a custom search approach can be implemented that exploits the small search space and cache locality. * The simplest example is a linear search of contiguous entries. This is simple to implement, guaranteed to terminate rapidly, never searches the same entry twice, and precludes the need to check for dummy entries. * A more advanced example is a self-organizing search so that the most frequently accessed entries get probed first. The organization adapts if the access pattern changes over time. Treaps are ideally suited for self-organization with the most common entries at the top of the heap and a rapid binary search pattern. Most probes and results are all located at the top of the tree allowing them all to be located in one or two cache lines. * Also, small dictionaries may be made more dense, perhaps filling all eight cells to take the maximum advantage of two cache lines. Strategy Pattern ---------------- Consider allowing the user to set the tunable parameters or to select a particular search method. Since some dictionary use cases have known sizes and access patterns, the user may be able to provide useful hints. 1) For example, if membership testing or lookups dominate runtime and memory is not at a premium, the user may benefit from setting the maximum load ratio at 5% or 10% instead of the usual 66.7%. This will sharply curtail the number of collisions but will increase iteration time. The builtin namespace is a prime example of a dictionary that can benefit from being highly sparse. 2) Dictionary creation time can be shortened in cases where the ultimate size of the dictionary is known in advance. The dictionary can be pre-sized so that no resize operations are required during creation. Not only does this save resizes, but the key insertion will go more quickly because the first half of the keys will be inserted into a more sparse environment than before. The preconditions for this strategy arise whenever a dictionary is created from a key or item sequence and the number of *unique* keys is known. 3) If the key space is large and the access pattern is known to be random, then search strategies exploiting cache locality can be fruitful. The preconditions for this strategy arise in simulations and numerical analysis. 4) If the keys are fixed and the access pattern strongly favors some of the keys, then the entries can be stored contiguously and accessed with a linear search or treap. This exploits knowledge of the data, cache locality, and a simplified search routine. It also eliminates the need to test for dummy entries on each probe. The preconditions for this strategy arise in symbol tables and in the builtin dictionary. Readonly Dictionaries --------------------- Some dictionary use cases pass through a build stage and then move to a more heavily exercised lookup stage with no further changes to the dictionary. An idea that emerged on python-dev is to be able to convert a dictionary to a read-only state. This can help prevent programming errors and also provide knowledge that can be exploited for lookup optimization. The dictionary can be immediately rebuilt (eliminating dummy entries), resized (to an appropriate level of sparseness), and the keys can be jostled (to minimize collisions). The lookdict() routine can then eliminate the test for dummy entries (saving about 1/4 of the time spent in the collision resolution loop). An additional possibility is to insert links into the empty spaces so that dictionary iteration can proceed in len(d) steps instead of (mp->mask + 1) steps. Alternatively, a separate tuple of keys can be kept just for iteration. Caching Lookups --------------- The idea is to exploit key access patterns by anticipating future lookups based of previous lookups. The simplest incarnation is to save the most recently accessed entry. This gives optimal performance for use cases where every get is followed by a set or del to the same key. --- NEW FILE: genobject.c --- /* Generator object implementation */ #include "Python.h" #include "frameobject.h" #include "genobject.h" #include "ceval.h" #include "structmember.h" static int gen_traverse(PyGenObject *gen, visitproc visit, void *arg) { return visit((PyObject *)gen->gi_frame, arg); } static void gen_dealloc(PyGenObject *gen) { _PyObject_GC_UNTRACK(gen); if (gen->gi_weakreflist != NULL) PyObject_ClearWeakRefs((PyObject *) gen); Py_DECREF(gen->gi_frame); PyObject_GC_Del(gen); } static PyObject * gen_iternext(PyGenObject *gen) { PyThreadState *tstate = PyThreadState_GET(); PyFrameObject *f = gen->gi_frame; PyObject *result; if (gen->gi_running) { PyErr_SetString(PyExc_ValueError, "generator already executing"); return NULL; } if (f->f_stacktop == NULL) return NULL; /* Generators always return to their most recent caller, not * necessarily their creator. */ Py_XINCREF(tstate->frame); assert(f->f_back == NULL); f->f_back = tstate->frame; gen->gi_running = 1; result = PyEval_EvalFrame(f); gen->gi_running = 0; /* Don't keep the reference to f_back any longer than necessary. It * may keep a chain of frames alive or it could create a reference * cycle. */ assert(f->f_back != NULL); Py_CLEAR(f->f_back); /* If the generator just returned (as opposed to yielding), signal * that the generator is exhausted. */ if (result == Py_None && f->f_stacktop == NULL) { Py_DECREF(result); result = NULL; } return result; } static PyMemberDef gen_memberlist[] = { {"gi_frame", T_OBJECT, offsetof(PyGenObject, gi_frame), RO}, {"gi_running", T_INT, offsetof(PyGenObject, gi_running), RO}, {NULL} /* Sentinel */ }; PyTypeObject PyGen_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, /* ob_size */ "generator", /* tp_name */ sizeof(PyGenObject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ (destructor)gen_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 */ 0, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ 0, /* tp_doc */ (traverseproc)gen_traverse, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ offsetof(PyGenObject, gi_weakreflist), /* tp_weaklistoffset */ PyObject_SelfIter, /* tp_iter */ (iternextfunc)gen_iternext, /* tp_iternext */ 0, /* tp_methods */ gen_memberlist, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ }; PyObject * PyGen_New(PyFrameObject *f) { PyGenObject *gen = PyObject_GC_New(PyGenObject, &PyGen_Type); if (gen == NULL) { Py_DECREF(f); return NULL; } gen->gi_frame = f; gen->gi_running = 0; gen->gi_weakreflist = NULL; _PyObject_GC_TRACK(gen); return (PyObject *)gen; } --- NEW FILE: setobject.c --- #include "Python.h" #include "structmember.h" /* set object implementation written and maintained by Raymond D. Hettinger derived from sets.py written by Greg V. Wilson, Alex Martelli, Guido van Rossum, Raymond Hettinger, and Tim Peters. Copyright (c) 2003 Python Software Foundation. All rights reserved. */ static PyObject * set_update(PySetObject *so, PyObject *other) { PyObject *item, *data, *it; if (PyAnySet_Check(other)) { if (PyDict_Merge(so->data, ((PySetObject *)other)->data, 1) == -1) [...1087 lines suppressed...] frozenset_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ (richcmpfunc)set_richcompare, /* tp_richcompare */ offsetof(PySetObject, weakreflist), /* tp_weaklistoffset */ (getiterfunc)set_iter, /* tp_iter */ 0, /* tp_iternext */ frozenset_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ PyType_GenericAlloc, /* tp_alloc */ frozenset_new, /* tp_new */ PyObject_Del, /* tp_free */ }; Index: abstract.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/abstract.c,v retrieving revision 2.103.2.1 retrieving revision 2.103.2.2 diff -u -d -r2.103.2.1 -r2.103.2.2 --- abstract.c 28 Apr 2003 17:18:21 -0000 2.103.2.1 +++ abstract.c 7 Jan 2005 07:03:43 -0000 2.103.2.2 @@ -636,7 +636,7 @@ } else { return type_error( - "can't multiply sequence to non-int"); + "can't multiply sequence by non-int"); } #if LONG_MAX != INT_MAX if (count > INT_MAX) { @@ -965,8 +965,17 @@ 10); #endif m = o->ob_type->tp_as_number; - if (m && m->nb_int) - return m->nb_int(o); + if (m && m->nb_int) { + PyObject *res = m->nb_int(o); + if (res && (!PyInt_Check(res) && !PyLong_Check(res))) { + PyErr_Format(PyExc_TypeError, + "__int__ returned non-int (type %.200s)", + res->ob_type->tp_name); + Py_DECREF(res); + return NULL; + } + return res; + } if (!PyObject_AsCharBuffer(o, &buffer, &buffer_len)) return int_from_string((char*)buffer, buffer_len); @@ -1022,8 +1031,17 @@ 10); #endif m = o->ob_type->tp_as_number; - if (m && m->nb_long) - return m->nb_long(o); + if (m && m->nb_long) { + PyObject *res = m->nb_long(o); + if (res && (!PyInt_Check(res) && !PyLong_Check(res))) { + PyErr_Format(PyExc_TypeError, + "__long__ returned non-long (type %.200s)", + res->ob_type->tp_name); + Py_DECREF(res); + return NULL; + } + return res; + } if (!PyObject_AsCharBuffer(o, &buffer, &buffer_len)) return long_from_string(buffer, buffer_len); @@ -1047,8 +1065,17 @@ } if (!PyString_Check(o)) { m = o->ob_type->tp_as_number; - if (m && m->nb_float) - return m->nb_float(o); + if (m && m->nb_float) { + PyObject *res = m->nb_float(o); + if (res && !PyFloat_Check(res)) { + PyErr_Format(PyExc_TypeError, + "__float__ returned non-float (type %.200s)", + res->ob_type->tp_name); + Py_DECREF(res); + return NULL; + } + return res; + } } return PyFloat_FromString(o, NULL); } @@ -1058,6 +1085,8 @@ int PySequence_Check(PyObject *s) { + if (s && PyInstance_Check(s)) + return PyObject_HasAttrString(s, "__getitem__"); return s != NULL && s->ob_type->tp_as_sequence && s->ob_type->tp_as_sequence->sq_item != NULL; } @@ -1252,7 +1281,7 @@ return m->sq_ass_item(s, i, o); } - type_error("object doesn't support item assignment"); + type_error("object does not support item assignment"); return -1; } @@ -1380,7 +1409,7 @@ return NULL; /* Guess result size and allocate space. */ - n = PySequence_Size(v); + n = PyObject_Size(v); if (n < 0) { PyErr_Clear(); n = 10; /* arbitrary */ @@ -1398,10 +1427,21 @@ break; } if (j >= n) { - if (n < 500) - n += 10; - else - n += 100; + int oldn = n; + /* The over-allocation strategy can grow a bit faster + than for lists because unlike lists the + over-allocation isn't permanent -- we reclaim + the excess before the end of this routine. + So, grow by ten and then add 25%. + */ + n += 10; + n += n >> 2; + if (n < oldn) { + /* Check for overflow */ + PyErr_NoMemory(); + Py_DECREF(item); + goto Fail; + } if (_PyTuple_Resize(&result, n) != 0) { Py_DECREF(item); goto Fail; @@ -1427,79 +1467,30 @@ PyObject * PySequence_List(PyObject *v) { - PyObject *it; /* iter(v) */ PyObject *result; /* result list */ - int n; /* guess for result list size */ - int i; + PyObject *rv; /* return value from PyList_Extend */ if (v == NULL) return null_error(); - /* Special-case list(a_list), for speed. */ - if (PyList_Check(v)) - return PyList_GetSlice(v, 0, PyList_GET_SIZE(v)); - - /* Get iterator. There may be some low-level efficiency to be gained - * by caching the tp_iternext slot instead of using PyIter_Next() - * later, but premature optimization is the root etc. - */ - it = PyObject_GetIter(v); - if (it == NULL) + result = PyList_New(0); + if (result == NULL) return NULL; - /* Guess a result list size. */ - n = -1; /* unknown */ - if (PySequence_Check(v) && - v->ob_type->tp_as_sequence->sq_length) { - n = PySequence_Size(v); - if (n < 0) - PyErr_Clear(); - } - if (n < 0) - n = 8; /* arbitrary */ - result = PyList_New(n); - if (result == NULL) { - Py_DECREF(it); + rv = _PyList_Extend((PyListObject *)result, v); + if (rv == NULL) { + Py_DECREF(result); return NULL; } - - /* Run iterator to exhaustion. */ - for (i = 0; ; i++) { - PyObject *item = PyIter_Next(it); - if (item == NULL) { - if (PyErr_Occurred()) { - Py_DECREF(result); - result = NULL; - } - break; - } - if (i < n) - PyList_SET_ITEM(result, i, item); /* steals ref */ - else { - int status = PyList_Append(result, item); - Py_DECREF(item); /* append creates a new ref */ - if (status < 0) { - Py_DECREF(result); - result = NULL; - break; - } - } - } - - /* Cut back result list if initial guess was too large. */ - if (i < n && result != NULL) { - if (PyList_SetSlice(result, i, n, (PyObject *)NULL) != 0) { - Py_DECREF(result); - result = NULL; - } - } - Py_DECREF(it); + Py_DECREF(rv); return result; } PyObject * PySequence_Fast(PyObject *v, const char *m) { + PyObject *it; + if (v == NULL) return null_error(); @@ -1508,9 +1499,15 @@ return v; } - v = PySequence_Tuple(v); - if (v == NULL && PyErr_ExceptionMatches(PyExc_TypeError)) - return type_error(m); + it = PyObject_GetIter(v); + if (it == NULL) { + if (PyErr_ExceptionMatches(PyExc_TypeError)) + return type_error(m); + return NULL; + } + + v = PySequence_List(it); + Py_DECREF(it); return v; } @@ -1643,8 +1640,13 @@ int PyMapping_Check(PyObject *o) { - return o && o->ob_type->tp_as_mapping && - o->ob_type->tp_as_mapping->mp_subscript; + if (o && PyInstance_Check(o)) + return PyObject_HasAttrString(o, "__getitem__"); + + return o && o->ob_type->tp_as_mapping && + o->ob_type->tp_as_mapping->mp_subscript && + !(o->ob_type->tp_as_sequence && + o->ob_type->tp_as_sequence->sq_slice); } int @@ -2035,8 +2037,8 @@ return -1; } -int -PyObject_IsInstance(PyObject *inst, PyObject *cls) +static int +recursive_isinstance(PyObject *inst, PyObject *cls, int recursion_depth) { PyObject *icls; static PyObject *__class__ = NULL; @@ -2071,14 +2073,20 @@ } } else if (PyTuple_Check(cls)) { - /* Not a general sequence -- that opens up the road to - recursion and stack overflow. */ int i, n; + if (!recursion_depth) { + PyErr_SetString(PyExc_RuntimeError, + "nest level of tuple too deep"); + return -1; + } + n = PyTuple_GET_SIZE(cls); for (i = 0; i < n; i++) { - retval = PyObject_IsInstance( - inst, PyTuple_GET_ITEM(cls, i)); + retval = recursive_isinstance( + inst, + PyTuple_GET_ITEM(cls, i), + recursion_depth-1); if (retval != 0) break; } @@ -2103,7 +2111,13 @@ } int -PyObject_IsSubclass(PyObject *derived, PyObject *cls) +PyObject_IsInstance(PyObject *inst, PyObject *cls) +{ + return recursive_isinstance(inst, cls, Py_GetRecursionLimit()); +} + +static int +recursive_issubclass(PyObject *derived, PyObject *cls, int recursion_depth) { int retval; @@ -2115,9 +2129,17 @@ if (PyTuple_Check(cls)) { int i; int n = PyTuple_GET_SIZE(cls); + + if (!recursion_depth) { + PyErr_SetString(PyExc_RuntimeError, + "nest level of tuple too deep"); + return -1; + } for (i = 0; i < n; ++i) { - retval = PyObject_IsSubclass( - derived, PyTuple_GET_ITEM(cls, i)); + retval = recursive_issubclass( + derived, + PyTuple_GET_ITEM(cls, i), + recursion_depth-1); if (retval != 0) { /* either found it, or got an error */ return retval; @@ -2143,6 +2165,13 @@ return retval; } +int +PyObject_IsSubclass(PyObject *derived, PyObject *cls) +{ + return recursive_issubclass(derived, cls, Py_GetRecursionLimit()); +} + + PyObject * PyObject_GetIter(PyObject *o) { Index: bufferobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/bufferobject.c,v retrieving revision 2.19.2.1 retrieving revision 2.19.2.2 diff -u -d -r2.19.2.1 -r2.19.2.2 --- bufferobject.c 28 Apr 2003 17:18:21 -0000 2.19.2.1 +++ bufferobject.c 7 Jan 2005 07:03:44 -0000 2.19.2.2 @@ -9,21 +9,68 @@ PyObject *b_base; void *b_ptr; int b_size; + int b_offset; int b_readonly; long b_hash; } PyBufferObject; +static int +get_buf(PyBufferObject *self, void **ptr, int *size) +{ + if (self->b_base == NULL) { + assert (ptr != NULL); + *ptr = self->b_ptr; + *size = self->b_size; + } + else { + int count, offset; + getreadbufferproc proc; + PyBufferProcs *bp = self->b_base->ob_type->tp_as_buffer; + if ((*bp->bf_getsegcount)(self->b_base, NULL) != 1) { + PyErr_SetString(PyExc_TypeError, + "single-segment buffer object expected"); + return 0; + } + if (self->b_readonly) + proc = bp->bf_getreadbuffer; + else + proc = (getreadbufferproc)bp->bf_getwritebuffer; + if ((count = (*proc)(self->b_base, 0, ptr)) < 0) + return 0; + /* apply constraints to the start/end */ + if (self->b_offset > count) + offset = count; + else + offset = self->b_offset; + *(char **)ptr = *(char **)ptr + offset; + if (self->b_size == Py_END_OF_BUFFER) + *size = count; + else + *size = self->b_size; + if (offset + *size > count) + *size = count - offset; + } + return 1; +} + + static PyObject * -_PyBuffer_FromMemory(PyObject *base, void *ptr, int size, int readonly) +buffer_from_memory(PyObject *base, int size, int offset, void *ptr, + int readonly) { PyBufferObject * b; - if ( size < 0 ) { + if (size < 0 && size != Py_END_OF_BUFFER) { PyErr_SetString(PyExc_ValueError, "size must be zero or positive"); return NULL; } + if (offset < 0) { + PyErr_SetString(PyExc_ValueError, + "offset must be zero or positive"); + return NULL; + } b = PyObject_NEW(PyBufferObject, &PyBuffer_Type); if ( b == NULL ) @@ -33,6 +80,7 @@ b->b_base = base; b->b_ptr = ptr; b->b_size = size; + b->b_offset = offset; b->b_readonly = readonly; b->b_hash = -1; @@ -40,43 +88,27 @@ } static PyObject * -_PyBuffer_FromObject(PyObject *base, int offset, int size, - getreadbufferproc proc, int readonly) +buffer_from_object(PyObject *base, int size, int offset, int readonly) { - PyBufferProcs *pb = base->ob_type->tp_as_buffer; - void *p; - int count; - - if ( offset < 0 ) { + if (offset < 0) { PyErr_SetString(PyExc_ValueError, "offset must be zero or positive"); return NULL; } - - if ( (*pb->bf_getsegcount)(base, NULL) != 1 ) - { - PyErr_SetString(PyExc_TypeError, - "single-segment buffer object expected"); - return NULL; + if ( PyBuffer_Check(base) && (((PyBufferObject *)base)->b_base) ) { + /* another buffer, refer to the base object */ + PyBufferObject *b = (PyBufferObject *)base; + if (b->b_size != Py_END_OF_BUFFER) { + int base_size = b->b_size - offset; + if (base_size < 0) + base_size = 0; + if (size == Py_END_OF_BUFFER || size > base_size) + size = base_size; + } + offset += b->b_offset; + base = b->b_base; } - if ( (count = (*proc)(base, 0, &p)) < 0 ) - return NULL; - - /* apply constraints to the start/end */ - if ( size == Py_END_OF_BUFFER || size < 0 ) - size = count; - if ( offset > count ) - offset = count; - if ( offset + size > count ) - size = count - offset; - - /* if the base object is another buffer, then "deref" it, - * except if the base of the other buffer is NULL - */ - if ( PyBuffer_Check(base) && (((PyBufferObject *)base)->b_base) ) - base = ((PyBufferObject *)base)->b_base; - - return _PyBuffer_FromMemory(base, (char *)p + offset, size, readonly); + return buffer_from_memory(base, size, offset, NULL, readonly); } @@ -93,8 +125,7 @@ return NULL; } - return _PyBuffer_FromObject(base, offset, size, - pb->bf_getreadbuffer, 1); + return buffer_from_object(base, size, offset, 1); } PyObject * @@ -110,21 +141,19 @@ return NULL; } - return _PyBuffer_FromObject(base, offset, size, - (getreadbufferproc)pb->bf_getwritebuffer, - 0); + return buffer_from_object(base, size, offset, 0); } PyObject * PyBuffer_FromMemory(void *ptr, int size) { - return _PyBuffer_FromMemory(NULL, ptr, size, 1); + return buffer_from_memory(NULL, size, 0, ptr, 1); } PyObject * PyBuffer_FromReadWriteMemory(void *ptr, int size) { - return _PyBuffer_FromMemory(NULL, ptr, size, 0); + return buffer_from_memory(NULL, size, 0, ptr, 0); } PyObject * @@ -147,6 +176,7 @@ b->b_base = NULL; b->b_ptr = (void *)(b + 1); b->b_size = size; + b->b_offset = 0; b->b_readonly = 0; b->b_hash = -1; @@ -186,12 +216,16 @@ static int buffer_compare(PyBufferObject *self, PyBufferObject *other) { - int len_self = self->b_size; - int len_other = other->b_size; - int min_len = (len_self < len_other) ? len_self : len_other; - int cmp; + void *p1, *p2; + int len_self, len_other, min_len, cmp; + + if (!get_buf(self, &p1, &len_self)) + return -1; + if (!get_buf(other, &p2, &len_other)) + return -1; + min_len = (len_self < len_other) ? len_self : len_other; if (min_len > 0) { - cmp = memcmp(self->b_ptr, other->b_ptr, min_len); + cmp = memcmp(p1, p2, min_len); if (cmp != 0) return cmp; } @@ -211,17 +245,19 @@ self); else return PyString_FromFormat( - "<%s buffer for %p, ptr %p, size %d at %p>", + "<%s buffer for %p, size %d, offset %d at %p>", status, self->b_base, - self->b_ptr, self->b_size, + self->b_offset, self); } static long buffer_hash(PyBufferObject *self) { + void *ptr; + int size; register int len; register unsigned char *p; register long x; @@ -229,19 +265,28 @@ if ( self->b_hash != -1 ) return self->b_hash; + /* XXX potential bugs here, a readonly buffer does not imply that the + * underlying memory is immutable. b_readonly is a necessary but not + * sufficient condition for a buffer to be hashable. Perhaps it would + * be better to only allow hashing if the underlying object is known to + * be immutable (e.g. PyString_Check() is true). Another idea would + * be to call tp_hash on the underlying object and see if it raises + * an error. */ if ( !self->b_readonly ) { - /* ### use different wording, since this is conditional? */ - PyErr_SetString(PyExc_TypeError, "unhashable type"); + PyErr_SetString(PyExc_TypeError, + "writable buffers are not hashable"); return -1; } - len = self->b_size; - p = (unsigned char *) self->b_ptr; + if (!get_buf(self, &ptr, &size)) + return -1; + p = (unsigned char *) ptr; + len = size; x = *p << 7; while (--len >= 0) x = (1000003*x) ^ *p++; - x ^= self->b_size; + x ^= size; if (x == -1) x = -2; self->b_hash = x; @@ -251,7 +296,11 @@ static PyObject * buffer_str(PyBufferObject *self) { - return PyString_FromStringAndSize(self->b_ptr, self->b_size); + void *ptr; + int size; + if (!get_buf(self, &ptr, &size)) + return NULL; + return PyString_FromStringAndSize(ptr, size); } /* Sequence methods */ @@ -259,17 +308,21 @@ static int buffer_length(PyBufferObject *self) { - return self->b_size; + void *ptr; + int size; + if (!get_buf(self, &ptr, &size)) + return -1; + return size; } static PyObject * buffer_concat(PyBufferObject *self, PyObject *other) { PyBufferProcs *pb = other->ob_type->tp_as_buffer; - char *p1; - void *p2; + void *ptr1, *ptr2; + char *p; PyObject *ob; - int count; + int size, count; if ( pb == NULL || pb->bf_getreadbuffer == NULL || @@ -286,23 +339,26 @@ return NULL; } + if (!get_buf(self, &ptr1, &size)) + return NULL; + /* optimize special case */ - if ( self->b_size == 0 ) + if ( size == 0 ) { Py_INCREF(other); return other; } - if ( (count = (*pb->bf_getreadbuffer)(other, 0, &p2)) < 0 ) + if ( (count = (*pb->bf_getreadbuffer)(other, 0, &ptr2)) < 0 ) return NULL; - ob = PyString_FromStringAndSize(NULL, self->b_size + count); - p1 = PyString_AS_STRING(ob); - memcpy(p1, self->b_ptr, self->b_size); - memcpy(p1 + self->b_size, p2, count); + ob = PyString_FromStringAndSize(NULL, size + count); + p = PyString_AS_STRING(ob); + memcpy(p, ptr1, size); + memcpy(p + size, ptr2, count); /* there is an extra byte in the string object, so this is safe */ - p1[self->b_size + count] = '\0'; + p[size + count] = '\0'; return ob; } @@ -312,11 +368,13 @@ { PyObject *ob; register char *p; - void *ptr = self->b_ptr; - int size = self->b_size; + void *ptr; + int size; if ( count < 0 ) count = 0; + if (!get_buf(self, &ptr, &size)) + return NULL; ob = PyString_FromStringAndSize(NULL, size * count); if ( ob == NULL ) return NULL; @@ -337,26 +395,33 @@ static PyObject * buffer_item(PyBufferObject *self, int idx) { - if ( idx < 0 || idx >= self->b_size ) - { + void *ptr; + int size; + if (!get_buf(self, &ptr, &size)) + return NULL; + if ( idx < 0 || idx >= size ) { PyErr_SetString(PyExc_IndexError, "buffer index out of range"); return NULL; } - return PyString_FromStringAndSize((char *)self->b_ptr + idx, 1); + return PyString_FromStringAndSize((char *)ptr + idx, 1); } static PyObject * buffer_slice(PyBufferObject *self, int left, int right) { + void *ptr; + int size; + if (!get_buf(self, &ptr, &size)) + return NULL; if ( left < 0 ) left = 0; if ( right < 0 ) right = 0; - if ( right > self->b_size ) - right = self->b_size; + if ( right > size ) + right = size; if ( right < left ) right = left; - return PyString_FromStringAndSize((char *)self->b_ptr + left, + return PyString_FromStringAndSize((char *)ptr + left, right - left); } @@ -364,7 +429,8 @@ buffer_ass_item(PyBufferObject *self, int idx, PyObject *other) { PyBufferProcs *pb; - void *p; + void *ptr1, *ptr2; + int size; int count; if ( self->b_readonly ) { @@ -373,7 +439,10 @@ return -1; } - if (idx < 0 || idx >= self->b_size) { + if (!get_buf(self, &ptr1, &size)) + return -1; + + if (idx < 0 || idx >= size) { PyErr_SetString(PyExc_IndexError, "buffer assignment index out of range"); return -1; @@ -395,7 +464,7 @@ return -1; } - if ( (count = (*pb->bf_getreadbuffer)(other, 0, &p)) < 0 ) + if ( (count = (*pb->bf_getreadbuffer)(other, 0, &ptr2)) < 0 ) return -1; if ( count != 1 ) { PyErr_SetString(PyExc_TypeError, @@ -403,7 +472,7 @@ return -1; } - ((char *)self->b_ptr)[idx] = *(char *)p; + ((char *)ptr1)[idx] = *(char *)ptr2; return 0; } @@ -411,7 +480,8 @@ buffer_ass_slice(PyBufferObject *self, int left, int right, PyObject *other) { PyBufferProcs *pb; - void *p; + void *ptr1, *ptr2; + int size; int slice_len; int count; @@ -436,17 +506,19 @@ "single-segment buffer object expected"); return -1; } - if ( (count = (*pb->bf_getreadbuffer)(other, 0, &p)) < 0 ) + if (!get_buf(self, &ptr1, &size)) + return -1; + if ( (count = (*pb->bf_getreadbuffer)(other, 0, &ptr2)) < 0 ) return -1; if ( left < 0 ) left = 0; - else if ( left > self->b_size ) - left = self->b_size; + else if ( left > size ) + left = size; if ( right < left ) right = left; - else if ( right > self->b_size ) - right = self->b_size; + else if ( right > size ) + right = size; slice_len = right - left; if ( count != slice_len ) { @@ -457,7 +529,7 @@ } if ( slice_len ) - memcpy((char *)self->b_ptr + left, p, slice_len); + memcpy((char *)ptr1 + left, ptr2, slice_len); return 0; } @@ -467,13 +539,15 @@ static int buffer_getreadbuf(PyBufferObject *self, int idx, void **pp) { + int size; if ( idx != 0 ) { PyErr_SetString(PyExc_SystemError, "accessing non-existent buffer segment"); return -1; } - *pp = self->b_ptr; - return self->b_size; + if (!get_buf(self, pp, &size)) + return -1; + return size; } static int @@ -490,21 +564,29 @@ static int buffer_getsegcount(PyBufferObject *self, int *lenp) { - if ( lenp ) - *lenp = self->b_size; + void *ptr; + int size; + if (!get_buf(self, &ptr, &size)) + return -1; + if (lenp) + *lenp = size; return 1; } static int buffer_getcharbuf(PyBufferObject *self, int idx, const char **pp) { + void *ptr; + int size; if ( idx != 0 ) { PyErr_SetString(PyExc_SystemError, "accessing non-existent buffer segment"); return -1; } - *pp = (const char *)self->b_ptr; - return self->b_size; + if (!get_buf(self, &ptr, &size)) + return -1; + *pp = (const char *)ptr; + return size; } Index: classobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v retrieving revision 2.158.2.1 retrieving revision 2.158.2.2 diff -u -d -r2.158.2.1 -r2.158.2.2 --- classobject.c 28 Apr 2003 17:18:20 -0000 2.158.2.1 +++ classobject.c 7 Jan 2005 07:03:44 -0000 2.158.2.2 @@ -670,13 +670,14 @@ _Py_NewReference((PyObject *)inst); inst->ob_refcnt = refcnt; _PyObject_GC_TRACK(inst); - /* If Py_REF_DEBUG, the original decref dropped _Py_RefTotal, - * but _Py_NewReference bumped it again, so that's a wash. - * If Py_TRACE_REFS, _Py_NewReference re-added self to the - * object chain, so no more to do there either. + /* If Py_REF_DEBUG, _Py_NewReference bumped _Py_RefTotal, so + * we need to undo that. */ + _Py_DEC_REFTOTAL; + /* If Py_TRACE_REFS, _Py_NewReference re-added self to the + * object chain, so no more to do there. * If COUNT_ALLOCS, the original decref bumped tp_frees, and - * _Py_NewReference bumped tp_allocs: both of those need to - * be undone. + * _Py_NewReference bumped tp_allocs: both of those need to be + * undone. */ #ifdef COUNT_ALLOCS --inst->ob_type->tp_frees; @@ -750,7 +751,7 @@ if (!PyErr_ExceptionMatches(PyExc_AttributeError)) return NULL; PyErr_Clear(); - args = Py_BuildValue("(OO)", inst, name); + args = PyTuple_Pack(2, inst, name); if (args == NULL) return NULL; res = PyEval_CallObject(func, args); @@ -847,9 +848,9 @@ if (func == NULL) return instance_setattr1(inst, name, v); if (v == NULL) - args = Py_BuildValue("(OO)", inst, name); + args = PyTuple_Pack(2, inst, name); else - args = Py_BuildValue("(OOO)", inst, name, v); + args = PyTuple_Pack(3, inst, name, v); if (args == NULL) return -1; res = PyEval_CallObject(func, args); @@ -953,6 +954,7 @@ return _Py_HashPointer(inst); } } + Py_XDECREF(func); PyErr_SetString(PyExc_TypeError, "unhashable instance"); return -1; } @@ -1037,7 +1039,7 @@ func = instance_getattr(inst, getitemstr); if (func == NULL) return NULL; - arg = Py_BuildValue("(O)", key); + arg = PyTuple_Pack(1, key); if (arg == NULL) { Py_DECREF(func); return NULL; @@ -1068,9 +1070,9 @@ if (func == NULL) return -1; if (value == NULL) - arg = Py_BuildValue("(O)", key); + arg = PyTuple_Pack(1, key); else - arg = Py_BuildValue("(OO)", key, value); + arg = PyTuple_Pack(2, key, value); if (arg == NULL) { Py_DECREF(func); return -1; @@ -1280,7 +1282,7 @@ if (func) { PyObject *res; int ret; - PyObject *arg = Py_BuildValue("(O)", member); + PyObject *arg = PyTuple_Pack(1, member); if(arg == NULL) { Py_DECREF(func); return -1; @@ -1345,7 +1347,7 @@ Py_INCREF(Py_NotImplemented); return Py_NotImplemented; } - args = Py_BuildValue("(O)", w); + args = PyTuple_Pack(1, w); if (args == NULL) { Py_DECREF(func); return NULL; @@ -1388,7 +1390,7 @@ return generic_binary_op(v, w, opname); } - args = Py_BuildValue("(O)", w); + args = PyTuple_Pack(1, w); if (args == NULL) { Py_DECREF(coercefunc); return NULL; @@ -1473,7 +1475,7 @@ return 1; } /* Has __coerce__ method: call it */ - args = Py_BuildValue("(O)", w); + args = PyTuple_Pack(1, w); if (args == NULL) { return -1; } @@ -1586,7 +1588,7 @@ return 2; } - args = Py_BuildValue("(O)", w); + args = PyTuple_Pack(1, w); if (args == NULL) { Py_DECREF(cmp_func); return -2; @@ -1746,7 +1748,7 @@ func = PyObject_GetAttrString(v, "__pow__"); if (func == NULL) return NULL; - args = Py_BuildValue("(OO)", w, z); + args = PyTuple_Pack(2, w, z); if (args == NULL) { Py_DECREF(func); return NULL; @@ -1785,7 +1787,7 @@ PyErr_Clear(); return instance_pow(v, w, z); } - args = Py_BuildValue("(OO)", w, z); + args = PyTuple_Pack(2, w, z); if (args == NULL) { Py_DECREF(func); return NULL; @@ -1858,7 +1860,7 @@ return res; } - args = Py_BuildValue("(O)", w); + args = PyTuple_Pack(1, w); if (args == NULL) { Py_DECREF(method); return NULL; @@ -1871,9 +1873,6 @@ return res; } -/* Map rich comparison operators to their swapped version, e.g. LT --> GT */ -static int swapped_op[] = {Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, Py_LE}; - static PyObject * instance_richcompare(PyObject *v, PyObject *w, int op) { @@ -1887,7 +1886,7 @@ } if (PyInstance_Check(w)) { - res = half_richcompare(w, v, swapped_op[op]); + res = half_richcompare(w, v, _Py_SwappedOp[op]); if (res != Py_NotImplemented) return res; Py_DECREF(res); @@ -1969,7 +1968,6 @@ static PyObject * instance_call(PyObject *func, PyObject *arg, PyObject *kw) { - PyThreadState *tstate = PyThreadState_GET(); PyObject *res, *call = PyObject_GetAttrString(func, "__call__"); if (call == NULL) { PyInstanceObject *inst = (PyInstanceObject*) func; @@ -1989,14 +1987,13 @@ a() # infinite recursion This bounces between instance_call() and PyObject_Call() without ever hitting eval_frame() (which has the main recursion check). */ - if (tstate->recursion_depth++ > Py_GetRecursionLimit()) { - PyErr_SetString(PyExc_RuntimeError, - "maximum __call__ recursion depth exceeded"); + if (Py_EnterRecursiveCall(" in __call__")) { res = NULL; } - else + else { res = PyObject_Call(call, arg, kw); - tstate->recursion_depth--; + Py_LeaveRecursiveCall(); + } Py_DECREF(call); return res; } @@ -2139,19 +2136,34 @@ {NULL} /* Sentinel */ }; -/* The getattr() implementation for PyMethod objects is similar to - PyObject_GenericGetAttr(), but instead of looking in __dict__ it - asks im_self for the attribute. Then the error handling is a bit - different because we want to preserve the exception raised by the - delegate, unless we have an alternative from our class. */ +/* Christian Tismer argued convincingly that method attributes should + (nearly) always override function attributes. + The one exception is __doc__; there's a default __doc__ which + should only be used for the class, not for instances */ + +static PyObject * +instancemethod_get_doc(PyMethodObject *im, void *context) +{ + static PyObject *docstr; + if (docstr == NULL) { + docstr= PyString_InternFromString("__doc__"); + if (docstr == NULL) + return NULL; + } + return PyObject_GetAttr(im->im_func, docstr); +} + +static PyGetSetDef instancemethod_getset[] = { + {"__doc__", (getter)instancemethod_get_doc, NULL, NULL}, + {0} +}; static PyObject * instancemethod_getattro(PyObject *obj, PyObject *name) { PyMethodObject *im = (PyMethodObject *)obj; PyTypeObject *tp = obj->ob_type; - PyObject *descr = NULL, *res; - descrgetfunc f = NULL; + PyObject *descr = NULL; if (PyType_HasFeature(tp, Py_TPFLAGS_HAVE_CLASS)) { if (tp->tp_dict == NULL) { @@ -2161,30 +2173,17 @@ descr = _PyType_Lookup(tp, name); } - f = NULL; if (descr != NULL) { - f = TP_DESCR_GET(descr->ob_type); - if (f != NULL && PyDescr_IsData(descr)) + descrgetfunc f = TP_DESCR_GET(descr->ob_type); + if (f != NULL) return f(descr, obj, (PyObject *)obj->ob_type); + else { + Py_INCREF(descr); + return descr; + } } - res = PyObject_GetAttr(im->im_func, name); - if (res != NULL || !PyErr_ExceptionMatches(PyExc_AttributeError)) - return res; - - if (f != NULL) { - PyErr_Clear(); - return f(descr, obj, (PyObject *)obj->ob_type); - } - - if (descr != NULL) { - PyErr_Clear(); - Py_INCREF(descr); - return descr; - } - - assert(PyErr_Occurred()); - return NULL; + return PyObject_GetAttr(im->im_func, name); } PyDoc_STRVAR(instancemethod_doc, @@ -2491,7 +2490,7 @@ 0, /* tp_iternext */ 0, /* tp_methods */ instancemethod_memberlist, /* tp_members */ - 0, /* tp_getset */ + instancemethod_getset, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ instancemethod_descr_get, /* tp_descr_get */ Index: cobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/cobject.c,v retrieving revision 2.14 retrieving revision 2.14.2.1 diff -u -d -r2.14 -r2.14.2.1 --- cobject.c 13 Jun 2002 20:32:56 -0000 2.14 +++ cobject.c 7 Jan 2005 07:03:44 -0000 2.14.2.1 @@ -46,9 +46,9 @@ self = PyObject_NEW(PyCObject, &PyCObject_Type); if (self == NULL) return NULL; - self->cobject=cobj; - self->destructor=(destructor1)destr; - self->desc=desc; + self->cobject = cobj; + self->destructor = (destructor1)destr; + self->desc = desc; return (PyObject *)self; } @@ -99,6 +99,20 @@ return r; } +int +PyCObject_SetVoidPtr(PyObject *_self, void *cobj) +{ + PyCObject* self = (PyCObject*)_self; + if (self == NULL || !PyCObject_Check(self) || + self->destructor != NULL) { + PyErr_SetString(PyExc_TypeError, + "Invalid call to PyCObject_SetVoidPtr"); + return 0; + } + self->cobject = cobj; + return 1; +} + static void PyCObject_dealloc(PyCObject *self) { Index: complexobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/complexobject.c,v retrieving revision 2.62.2.1 retrieving revision 2.62.2.2 diff -u -d -r2.62.2.1 -r2.62.2.2 --- complexobject.c 28 Apr 2003 17:18:20 -0000 2.62.2.1 +++ complexobject.c 7 Jan 2005 07:03:44 -0000 2.62.2.2 @@ -272,13 +272,23 @@ static void complex_to_buf(char *buf, int bufsz, PyComplexObject *v, int precision) { - if (v->cval.real == 0.) - PyOS_snprintf(buf, bufsz, "%.*gj", - precision, v->cval.imag); - else - PyOS_snprintf(buf, bufsz, "(%.*g%+.*gj)", - precision, v->cval.real, - precision, v->cval.imag); + char format[32]; + if (v->cval.real == 0.) { + PyOS_snprintf(format, 32, "%%.%ig", precision); + PyOS_ascii_formatd(buf, bufsz, format, v->cval.imag); + strncat(buf, "j", bufsz); + } else { + char re[64], im[64]; + char *fmt; + PyOS_snprintf(format, 32, "%%.%ig", precision); + PyOS_ascii_formatd(re, 64, format, v->cval.real); + PyOS_ascii_formatd(im, 64, format, v->cval.imag); + if (v->cval.imag < 0.) + fmt = "(%s%sj)"; + else + fmt = "(%s+%sj)"; + PyOS_snprintf(buf, bufsz, fmt, re, im); + } } static int @@ -439,7 +449,7 @@ mod = c_diff(v->cval, c_prod(w->cval, div)); d = PyComplex_FromCComplex(div); m = PyComplex_FromCComplex(mod); - z = Py_BuildValue("(OO)", d, m); + z = PyTuple_Pack(2, d, m); Py_XDECREF(d); Py_XDECREF(m); return z; @@ -593,7 +603,7 @@ if (op != Py_EQ && op != Py_NE) { PyErr_SetString(PyExc_TypeError, - "cannot compare complex numbers using <, <=, >, >="); + "no ordering relation is defined for complex numbers"); return NULL; } @@ -610,7 +620,7 @@ complex_int(PyObject *v) { PyErr_SetString(PyExc_TypeError, - "can't convert complex to int; use e.g. int(abs(z))"); + "can't convert complex to int; use int(abs(z))"); return NULL; } @@ -618,7 +628,7 @@ complex_long(PyObject *v) { PyErr_SetString(PyExc_TypeError, - "can't convert complex to long; use e.g. long(abs(z))"); + "can't convert complex to long; use long(abs(z))"); return NULL; } @@ -626,7 +636,7 @@ complex_float(PyObject *v) { PyErr_SetString(PyExc_TypeError, - "can't convert complex to float; use e.g. abs(z)"); + "can't convert complex to float; use abs(z)"); return NULL; } @@ -662,7 +672,6 @@ static PyObject * complex_subtype_from_string(PyTypeObject *type, PyObject *v) { - extern double strtod(const char *, char **); const char *s, *start; char *end; double x=0.0, y=0.0, z; @@ -774,7 +783,7 @@ } errno = 0; PyFPE_START_PROTECT("strtod", return 0) - z = strtod(s, &end) ; + z = PyOS_ascii_strtod(s, &end) ; PyFPE_END_PROTECT(z) if (errno != 0) { PyOS_snprintf(buffer, sizeof(buffer), @@ -831,7 +840,7 @@ &r, &i)) return NULL; - /* Special-case for single argumet that is already complex */ + /* Special-case for single argument that is already complex */ if (PyComplex_CheckExact(r) && i == NULL && type == &PyComplex_Type) { /* Note that we can't know whether it's safe to return @@ -865,7 +874,7 @@ if (f == NULL) PyErr_Clear(); else { - PyObject *args = Py_BuildValue("()"); + PyObject *args = PyTuple_New(0); if (args == NULL) return NULL; r = PyEval_CallObject(f, args); @@ -882,6 +891,9 @@ ((i != NULL) && (nbi == NULL || nbi->nb_float == NULL))) { PyErr_SetString(PyExc_TypeError, "complex() argument must be a string or a number"); + if (own_r) { + Py_DECREF(r); + } return NULL; } if (PyComplex_Check(r)) { Index: descrobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/descrobject.c,v retrieving revision 2.27.2.1 retrieving revision 2.27.2.2 diff -u -d -r2.27.2.1 -r2.27.2.2 --- descrobject.c 28 Apr 2003 17:18:19 -0000 2.27.2.1 +++ descrobject.c 7 Jan 2005 07:03:45 -0000 2.27.2.2 @@ -690,7 +690,7 @@ static int proxy_contains(proxyobject *pp, PyObject *key) { - return PySequence_Contains(pp->dict, key); + return PyDict_Contains(pp->dict, key); } static PySequenceMethods proxy_as_sequence = { @@ -709,7 +709,10 @@ static PyObject * proxy_has_key(proxyobject *pp, PyObject *key) { - return PyInt_FromLong(PySequence_Contains(pp->dict, key)); + int res = PyDict_Contains(pp->dict, key); + if (res < 0) + return NULL; + return PyBool_FromLong(res); } static PyObject * @@ -765,7 +768,7 @@ static PyMethodDef proxy_methods[] = { {"has_key", (PyCFunction)proxy_has_key, METH_O, - PyDoc_STR("D.has_key(k) -> 1 if D has a key k, else 0")}, + PyDoc_STR("D.has_key(k) -> True if D has a key k, else False")}, {"get", (PyCFunction)proxy_get, METH_VARARGS, PyDoc_STR("D.get(k[,d]) -> D[k] if D.has_key(k), else d." " d defaults to None.")}, Index: dictobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/dictobject.c,v retrieving revision 2.126.2.1 retrieving revision 2.126.2.2 diff -u -d -r2.126.2.1 -r2.126.2.2 --- dictobject.c 28 Apr 2003 17:18:19 -0000 2.126.2.1 +++ dictobject.c 7 Jan 2005 07:03:45 -0000 2.126.2.2 @@ -1,6 +1,12 @@ /* Dictionary object implementation using a hash table */ +/* The distribution includes a separate file, Objects/dictnotes.txt, + describing explorations into dictionary design and optimization. + It covers typical dictionary use patterns, the parameters for + tuning dictionaries, and several ideas for possible optimizations. +*/ + #include "Python.h" typedef PyDictEntry dictentry; @@ -146,6 +152,11 @@ INIT_NONZERO_DICT_SLOTS(mp); \ } while(0) +/* Dictionary reuse scheme to save calls to malloc, free, and memset */ +#define MAXFREEDICTS 80 +static PyDictObject *free_dicts[MAXFREEDICTS]; +static int num_free_dicts = 0; + PyObject * PyDict_New(void) { @@ -158,10 +169,23 @@ Py_AtExit(show_counts); #endif } - mp = PyObject_GC_New(dictobject, &PyDict_Type); - if (mp == NULL) - return NULL; - EMPTY_TO_MINSIZE(mp); + if (num_free_dicts) { + mp = free_dicts[--num_free_dicts]; + assert (mp != NULL); + assert (mp->ob_type == &PyDict_Type); + _Py_NewReference((PyObject *)mp); + if (mp->ma_fill) { + EMPTY_TO_MINSIZE(mp); + } + assert (mp->ma_used == 0); + assert (mp->ma_table == mp->ma_smalltable); + assert (mp->ma_mask == PyDict_MINSIZE - 1); + } else { + mp = PyObject_GC_New(dictobject, &PyDict_Type); + if (mp == NULL) + return NULL; + EMPTY_TO_MINSIZE(mp); + } mp->ma_lookup = lookdict_string; #ifdef SHOW_CONVERSION_COUNTS ++created; @@ -525,17 +549,23 @@ Py_INCREF(value); Py_INCREF(key); insertdict(mp, key, hash, value); - /* If we added a key, we can safely resize. Otherwise skip this! - * If fill >= 2/3 size, adjust size. Normally, this doubles the - * size, but it's also possible for the dict to shrink (if ma_fill is - * much larger than ma_used, meaning a lot of dict keys have been - * deleted). + /* If we added a key, we can safely resize. Otherwise just return! + * If fill >= 2/3 size, adjust size. Normally, this doubles or + * quaduples the size, but it's also possible for the dict to shrink + * (if ma_fill is much larger than ma_used, meaning a lot of dict + * keys have been * deleted). + * + * Quadrupling the size improves average dictionary sparseness + * (reducing collisions) at the cost of some memory and iteration + * speed (which loops over every possible entry). It also halves + * the number of expensive resize operations in a growing dictionary. + * + * Very large dictionaries (over 50K items) use doubling instead. + * This may help applications with severe memory constraints. */ - if (mp->ma_used > n_used && mp->ma_fill*3 >= (mp->ma_mask+1)*2) { - if (dictresize(mp, mp->ma_used*2) != 0) - return -1; - } - return 0; + if (!(mp->ma_used > n_used && mp->ma_fill*3 >= (mp->ma_mask+1)*2)) + return 0; + return dictresize(mp, mp->ma_used*(mp->ma_used>50000 ? 2 : 4)); } int @@ -660,23 +690,25 @@ int PyDict_Next(PyObject *op, int *ppos, PyObject **pkey, PyObject **pvalue) { - int i; - register dictobject *mp; + register int i, mask; + register dictentry *ep; + if (!PyDict_Check(op)) return 0; - mp = (dictobject *)op; i = *ppos; if (i < 0) return 0; - while (i <= mp->ma_mask && mp->ma_table[i].me_value == NULL) + ep = ((dictobject *)op)->ma_table; + mask = ((dictobject *)op)->ma_mask; + while (i <= mask && ep[i].me_value == NULL) i++; *ppos = i+1; - if (i > mp->ma_mask) + if (i > mask) return 0; if (pkey) - *pkey = mp->ma_table[i].me_key; + *pkey = ep[i].me_key; if (pvalue) - *pvalue = mp->ma_table[i].me_value; + *pvalue = ep[i].me_value; return 1; } @@ -698,7 +730,10 @@ } if (mp->ma_table != mp->ma_smalltable) PyMem_DEL(mp->ma_table); - mp->ob_type->tp_free((PyObject *)mp); + if (num_free_dicts < MAXFREEDICTS && mp->ob_type == &PyDict_Type) + free_dicts[num_free_dicts++] = mp; + else + mp->ob_type->tp_free((PyObject *)mp); Py_TRASHCAN_SAFE_END(mp) } @@ -870,7 +905,9 @@ dict_keys(register dictobject *mp) { register PyObject *v; - register int i, j, n; + register int i, j; + dictentry *ep; + int mask, n; again: n = mp->ma_used; @@ -884,14 +921,17 @@ Py_DECREF(v); goto again; } - for (i = 0, j = 0; i <= mp->ma_mask; i++) { - if (mp->ma_table[i].me_value != NULL) { - PyObject *key = mp->ma_table[i].me_key; + ep = mp->ma_table; + mask = mp->ma_mask; + for (i = 0, j = 0; i <= mask; i++) { + if (ep[i].me_value != NULL) { + PyObject *key = ep[i].me_key; Py_INCREF(key); PyList_SET_ITEM(v, j, key); j++; } } + assert(j == n); return v; } @@ -899,7 +939,9 @@ dict_values(register dictobject *mp) { register PyObject *v; - register int i, j, n; + register int i, j; + dictentry *ep; + int mask, n; again: n = mp->ma_used; @@ -913,14 +955,17 @@ Py_DECREF(v); goto again; } - for (i = 0, j = 0; i <= mp->ma_mask; i++) { - if (mp->ma_table[i].me_value != NULL) { - PyObject *value = mp->ma_table[i].me_value; + ep = mp->ma_table; + mask = mp->ma_mask; + for (i = 0, j = 0; i <= mask; i++) { + if (ep[i].me_value != NULL) { + PyObject *value = ep[i].me_value; Py_INCREF(value); PyList_SET_ITEM(v, j, value); j++; } } + assert(j == n); return v; } @@ -929,7 +974,9 @@ { register PyObject *v; register int i, j, n; + int mask; PyObject *item, *key, *value; + dictentry *ep; /* Preallocate the list of tuples, to avoid allocations during * the loop over the items, which could trigger GC, which @@ -956,10 +1003,11 @@ goto again; } /* Nothing we do below makes any function calls. */ - for (i = 0, j = 0; i <= mp->ma_mask; i++) { - if (mp->ma_table[i].me_value != NULL) { - key = mp->ma_table[i].me_key; - value = mp->ma_table[i].me_value; + ep = mp->ma_table; + mask = mp->ma_mask; + for (i = 0, j = 0; i <= mask; i++) { + if ((value=ep[i].me_value) != NULL) { + key = ep[i].me_key; item = PyList_GET_ITEM(v, j); Py_INCREF(key); PyTuple_SET_ITEM(item, 0, key); @@ -1017,13 +1065,32 @@ return NULL; } +static int +dict_update_common(PyObject *self, PyObject *args, PyObject *kwds, char *methname) +{ + PyObject *arg = NULL; + int result = 0; + + if (!PyArg_UnpackTuple(args, methname, 0, 1, &arg)) + result = -1; + + else if (arg != NULL) { + if (PyObject_HasAttrString(arg, "keys")) + result = PyDict_Merge(self, arg, 1); + else + result = PyDict_MergeFromSeq2(self, arg, 1); + } + if (result == 0 && kwds != NULL) + result = PyDict_Merge(self, kwds, 1); + return result; +} + static PyObject * -dict_update(PyObject *mp, PyObject *other) +dict_update(PyObject *self, PyObject *args, PyObject *kwds) { - if (PyDict_Update(mp, other) < 0) - return NULL; - Py_INCREF(Py_None); - return Py_None; + if (dict_update_common(self, args, kwds, "update") != -1) + Py_RETURN_NONE; + return NULL; } /* Update unconditionally replaces existing items. @@ -1139,7 +1206,7 @@ * that there will be no (or few) overlapping keys. */ if ((mp->ma_fill + other->ma_used)*3 >= (mp->ma_mask+1)*2) { - if (dictresize(mp, (mp->ma_used + other->ma_used)*3/2) != 0) + if (dictresize(mp, (mp->ma_used + other->ma_used)*2) != 0) return -1; } for (i = 0; i <= other->ma_mask; i++) { @@ -1210,33 +1277,19 @@ PyObject * PyDict_Copy(PyObject *o) { - register dictobject *mp; - register int i; - dictobject *copy; - dictentry *entry; + PyObject *copy; if (o == NULL || !PyDict_Check(o)) { PyErr_BadInternalCall(); return NULL; } - mp = (dictobject *)o; - copy = (dictobject *)PyDict_New(); + copy = PyDict_New(); if (copy == NULL) return NULL; - if (mp->ma_used > 0) { - if (dictresize(copy, mp->ma_used*3/2) != 0) - return NULL; - for (i = 0; i <= mp->ma_mask; i++) { - entry = &mp->ma_table[i]; - if (entry->me_value != NULL) { - Py_INCREF(entry->me_key); - Py_INCREF(entry->me_value); - insertdict(copy, entry->me_key, entry->me_hash, - entry->me_value); - } - } - } - return (PyObject *)copy; + if (PyDict_Merge(copy, o, 1) == 0) + return copy; + Py_DECREF(copy); + return copy; } int @@ -1244,7 +1297,7 @@ { if (mp == NULL || !PyDict_Check(mp)) { PyErr_BadInternalCall(); - return 0; + return -1; } return ((dictobject *)mp)->ma_used; } @@ -1539,8 +1592,7 @@ dict_clear(register dictobject *mp) { PyDict_Clear((PyObject *)mp); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * @@ -1671,57 +1723,37 @@ } -static PyObject *dictiter_new(dictobject *, binaryfunc); - -static PyObject * -select_key(PyObject *key, PyObject *value) -{ - Py_INCREF(key); - return key; -} - -static PyObject * -select_value(PyObject *key, PyObject *value) -{ - Py_INCREF(value); - return value; -} - -static PyObject * -select_item(PyObject *key, PyObject *value) -{ - PyObject *res = PyTuple_New(2); - - if (res != NULL) { - Py_INCREF(key); - Py_INCREF(value); - PyTuple_SET_ITEM(res, 0, key); - PyTuple_SET_ITEM(res, 1, value); - } - return res; -} +extern PyTypeObject PyDictIterKey_Type; /* Forward */ +extern PyTypeObject PyDictIterValue_Type; /* Forward */ +extern PyTypeObject PyDictIterItem_Type; /* Forward */ +static PyObject *dictiter_new(dictobject *, PyTypeObject *); static PyObject * dict_iterkeys(dictobject *dict) { - return dictiter_new(dict, select_key); + return dictiter_new(dict, &PyDictIterKey_Type); } static PyObject * dict_itervalues(dictobject *dict) { - return dictiter_new(dict, select_value); + return dictiter_new(dict, &PyDictIterValue_Type); } static PyObject * dict_iteritems(dictobject *dict) { - return dictiter_new(dict, select_item); + return dictiter_new(dict, &PyDictIterItem_Type); } PyDoc_STRVAR(has_key__doc__, -"D.has_key(k) -> 1 if D has a key k, else 0"); +"D.has_key(k) -> True if D has a key k, else False"); + +PyDoc_STRVAR(contains__doc__, +"D.__contains__(k) -> True if D has a key k, else False"); + +PyDoc_STRVAR(getitem__doc__, "x.__getitem__(y) <==> x[y]"); PyDoc_STRVAR(get__doc__, "D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None."); @@ -1747,7 +1779,8 @@ "D.values() -> list of D's values"); PyDoc_STRVAR(update__doc__, -"D.update(E) -> None. Update D from E: for k in E.keys(): D[k] = E[k]"); +"D.update(E, **F) -> None. Update D from E and F: for k in E: D[k] = E[k]\n\ +(if E has keys else: for (k, v) in E: D[k] = v) then: for k in F: D[k] = F[k]"); PyDoc_STRVAR(fromkeys__doc__, "dict.fromkeys(S[,v]) -> New dict with keys from S and values equal to v.\n\ @@ -1769,6 +1802,10 @@ "D.iteritems() -> an iterator over the (key, value) items of D"); static PyMethodDef mapp_methods[] = { + {"__contains__",(PyCFunction)dict_has_key, METH_O | METH_COEXIST, + contains__doc__}, + {"__getitem__", (PyCFunction)dict_subscript, METH_O | METH_COEXIST, + getitem__doc__}, {"has_key", (PyCFunction)dict_has_key, METH_O, has_key__doc__}, {"get", (PyCFunction)dict_get, METH_VARARGS, @@ -1785,7 +1822,7 @@ items__doc__}, {"values", (PyCFunction)dict_values, METH_NOARGS, values__doc__}, - {"update", (PyCFunction)dict_update, METH_O, + {"update", (PyCFunction)dict_update, METH_VARARGS | METH_KEYWORDS, update__doc__}, {"fromkeys", (PyCFunction)dict_fromkeys, METH_VARARGS | METH_CLASS, fromkeys__doc__}, @@ -1802,10 +1839,11 @@ {NULL, NULL} /* sentinel */ }; -static int -dict_contains(dictobject *mp, PyObject *key) +int +PyDict_Contains(PyObject *op, PyObject *key) { long hash; + dictobject *mp = (dictobject *)op; if (!PyString_CheckExact(key) || (hash = ((PyStringObject *) key)->ob_shash) == -1) { @@ -1825,7 +1863,7 @@ 0, /* sq_slice */ 0, /* sq_ass_item */ 0, /* sq_ass_slice */ - (objobjproc)dict_contains, /* sq_contains */ + (objobjproc)PyDict_Contains, /* sq_contains */ 0, /* sq_inplace_concat */ 0, /* sq_inplace_repeat */ }; @@ -1853,21 +1891,7 @@ static int dict_init(PyObject *self, PyObject *args, PyObject *kwds) { - PyObject *arg = NULL; - int result = 0; - - if (!PyArg_UnpackTuple(args, "dict", 0, 1, &arg)) - result = -1; - - else if (arg != NULL) { - if (PyObject_HasAttrString(arg, "keys")) - result = PyDict_Merge(self, arg, 1); - else - result = PyDict_MergeFromSeq2(self, arg, 1); - } - if (result == 0 && kwds != NULL) - result = PyDict_Merge(self, kwds, 1); - return result; + return dict_update_common(self, args, kwds, "dict"); } static long @@ -1880,7 +1904,7 @@ static PyObject * dict_iter(dictobject *dict) { - return dictiter_new(dict, select_key); + return dictiter_new(dict, &PyDictIterKey_Type); } PyDoc_STRVAR(dictionary_doc, @@ -1979,30 +2003,38 @@ return err; } -/* Dictionary iterator type */ - -extern PyTypeObject PyDictIter_Type; /* Forward */ +/* Dictionary iterator types */ typedef struct { PyObject_HEAD dictobject *di_dict; /* Set to NULL when iterator is exhausted */ int di_used; int di_pos; - binaryfunc di_select; + PyObject* di_result; /* reusable result tuple for iteritems */ + long len; } dictiterobject; static PyObject * -dictiter_new(dictobject *dict, binaryfunc select) +dictiter_new(dictobject *dict, PyTypeObject *itertype) { dictiterobject *di; - di = PyObject_New(dictiterobject, &PyDictIter_Type); + di = PyObject_New(dictiterobject, itertype); if (di == NULL) return NULL; Py_INCREF(dict); di->di_dict = dict; di->di_used = dict->ma_used; di->di_pos = 0; - di->di_select = select; + di->len = dict->ma_used; + if (itertype == &PyDictIterItem_Type) { + di->di_result = PyTuple_Pack(2, Py_None, Py_None); + if (di->di_result == NULL) { + Py_DECREF(di); + return NULL; + } + } + else + di->di_result = NULL; return (PyObject *)di; } @@ -2010,34 +2042,66 @@ dictiter_dealloc(dictiterobject *di) { Py_XDECREF(di->di_dict); + Py_XDECREF(di->di_result); PyObject_Del(di); } -static PyObject *dictiter_iternext(dictiterobject *di) +static int +dictiter_len(dictiterobject *di) { - PyObject *key, *value; + if (di->di_dict != NULL && di->di_used == di->di_dict->ma_used) + return di->len; + return 0; +} - if (di->di_dict == NULL) +static PySequenceMethods dictiter_as_sequence = { + (inquiry)dictiter_len, /* sq_length */ + 0, /* sq_concat */ +}; + +static PyObject *dictiter_iternextkey(dictiterobject *di) +{ + PyObject *key; + register int i, mask; + register dictentry *ep; + dictobject *d = di->di_dict; + + if (d == NULL) return NULL; + assert (PyDict_Check(d)); - if (di->di_used != di->di_dict->ma_used) { + if (di->di_used != d->ma_used) { PyErr_SetString(PyExc_RuntimeError, "dictionary changed size during iteration"); di->di_used = -1; /* Make this state sticky */ return NULL; } - if (PyDict_Next((PyObject *)(di->di_dict), &di->di_pos, &key, &value)) - return (*di->di_select)(key, value); - Py_DECREF(di->di_dict); + i = di->di_pos; + if (i < 0) + goto fail; + ep = d->ma_table; + mask = d->ma_mask; + while (i <= mask && ep[i].me_value == NULL) + i++; + di->di_pos = i+1; + if (i > mask) + goto fail; + di->len--; + key = ep[i].me_key; + Py_INCREF(key); + return key; + +fail: + Py_DECREF(d); di->di_dict = NULL; return NULL; } -PyTypeObject PyDictIter_Type = { +PyTypeObject PyDictIterKey_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, /* ob_size */ - "dictionary-iterator", /* tp_name */ + "dictionary-keyiterator", /* tp_name */ sizeof(dictiterobject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ @@ -2048,7 +2112,7 @@ 0, /* tp_compare */ 0, /* tp_repr */ 0, /* tp_as_number */ - 0, /* tp_as_sequence */ + &dictiter_as_sequence, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ @@ -2063,12 +2127,161 @@ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ PyObject_SelfIter, /* tp_iter */ - (iternextfunc)dictiter_iternext, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ + (iternextfunc)dictiter_iternextkey, /* tp_iternext */ +}; + +static PyObject *dictiter_iternextvalue(dictiterobject *di) +{ + PyObject *value; + register int i, mask; + register dictentry *ep; + dictobject *d = di->di_dict; + + if (d == NULL) + return NULL; + assert (PyDict_Check(d)); + + if (di->di_used != d->ma_used) { + PyErr_SetString(PyExc_RuntimeError, + "dictionary changed size during iteration"); + di->di_used = -1; /* Make this state sticky */ + return NULL; + } + + i = di->di_pos; + mask = d->ma_mask; + if (i < 0 || i > mask) + goto fail; + ep = d->ma_table; + while ((value=ep[i].me_value) == NULL) { + i++; + if (i > mask) + goto fail; + } + di->di_pos = i+1; + di->len--; + Py_INCREF(value); + return value; + +fail: + Py_DECREF(d); + di->di_dict = NULL; + return NULL; +} + +PyTypeObject PyDictIterValue_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, /* ob_size */ + "dictionary-valueiterator", /* tp_name */ + sizeof(dictiterobject), /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + (destructor)dictiter_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + &dictiter_as_sequence, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + 0, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + PyObject_SelfIter, /* tp_iter */ + (iternextfunc)dictiter_iternextvalue, /* tp_iternext */ +}; + +static PyObject *dictiter_iternextitem(dictiterobject *di) +{ + PyObject *key, *value, *result = di->di_result; + register int i, mask; + register dictentry *ep; + dictobject *d = di->di_dict; + + if (d == NULL) + return NULL; + assert (PyDict_Check(d)); + + if (di->di_used != d->ma_used) { + PyErr_SetString(PyExc_RuntimeError, + "dictionary changed size during iteration"); + di->di_used = -1; /* Make this state sticky */ + return NULL; + } + + i = di->di_pos; + if (i < 0) + goto fail; + ep = d->ma_table; + mask = d->ma_mask; + while (i <= mask && ep[i].me_value == NULL) + i++; + di->di_pos = i+1; + if (i > mask) + goto fail; + + if (result->ob_refcnt == 1) { + Py_INCREF(result); + Py_DECREF(PyTuple_GET_ITEM(result, 0)); + Py_DECREF(PyTuple_GET_ITEM(result, 1)); + } else { + result = PyTuple_New(2); + if (result == NULL) + return NULL; + } + di->len--; + key = ep[i].me_key; + value = ep[i].me_value; + Py_INCREF(key); + Py_INCREF(value); + PyTuple_SET_ITEM(result, 0, key); + PyTuple_SET_ITEM(result, 1, value); + return result; + +fail: + Py_DECREF(d); + di->di_dict = NULL; + return NULL; +} + +PyTypeObject PyDictIterItem_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, /* ob_size */ + "dictionary-itemiterator", /* tp_name */ + sizeof(dictiterobject), /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + (destructor)dictiter_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + &dictiter_as_sequence, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + 0, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + PyObject_SelfIter, /* tp_iter */ + (iternextfunc)dictiter_iternextitem, /* tp_iternext */ }; Index: enumobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/enumobject.c,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -u -d -r1.2.2.1 -r1.2.2.2 --- enumobject.c 28 Apr 2003 17:18:19 -0000 1.2.2.1 +++ enumobject.c 7 Jan 2005 07:04:00 -0000 1.2.2.2 @@ -6,6 +6,7 @@ PyObject_HEAD long en_index; /* current index of enumeration */ PyObject* en_sit; /* secondary iterator of enumeration */ + PyObject* en_result; /* result tuple */ } enumobject; PyTypeObject PyEnum_Type; @@ -30,6 +31,12 @@ Py_DECREF(en); return NULL; } + en->en_result = PyTuple_Pack(2, Py_None, Py_None); + if (en->en_result == NULL) { + Py_DECREF(en->en_sit); + Py_DECREF(en); + return NULL; + } return (PyObject *)en; } @@ -38,42 +45,60 @@ { PyObject_GC_UnTrack(en); Py_XDECREF(en->en_sit); + Py_XDECREF(en->en_result); en->ob_type->tp_free(en); } static int enum_traverse(enumobject *en, visitproc visit, void *arg) { - if (en->en_sit) - return visit(en->en_sit, arg); + int err; + + if (en->en_sit) { + err = visit(en->en_sit, arg); + if (err) + return err; + } + if (en->en_result) { + err = visit(en->en_result, arg); + if (err) + return err; + } return 0; } static PyObject * enum_next(enumobject *en) { - PyObject *result; PyObject *next_index; PyObject *next_item; + PyObject *result = en->en_result; + PyObject *it = en->en_sit; - result = PyTuple_New(2); - if (result == NULL) + next_item = (*it->ob_type->tp_iternext)(it); + if (next_item == NULL) return NULL; next_index = PyInt_FromLong(en->en_index); if (next_index == NULL) { - Py_DECREF(result); + Py_DECREF(next_item); return NULL; } - PyTuple_SET_ITEM(result, 0, next_index); + en->en_index++; - next_item = PyIter_Next(en->en_sit); - if (next_item == NULL) { - Py_DECREF(result); - return NULL; + if (result->ob_refcnt == 1) { + Py_INCREF(result); + Py_DECREF(PyTuple_GET_ITEM(result, 0)); + Py_DECREF(PyTuple_GET_ITEM(result, 1)); + } else { + result = PyTuple_New(2); + if (result == NULL) { + Py_DECREF(next_index); + Py_DECREF(next_item); + return NULL; + } } - - en->en_index++; + PyTuple_SET_ITEM(result, 0, next_index); PyTuple_SET_ITEM(result, 1, next_item); return result; } @@ -130,3 +155,150 @@ enum_new, /* tp_new */ PyObject_GC_Del, /* tp_free */ }; + +/* Reversed Object ***************************************************************/ + +typedef struct { + PyObject_HEAD + long index; + PyObject* seq; +} reversedobject; + +static PyObject * +reversed_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + long n; + PyObject *seq; + reversedobject *ro; + + if (!PyArg_UnpackTuple(args, "reversed", 1, 1, &seq)) + return NULL; + + if (PyObject_HasAttrString(seq, "__reversed__")) + return PyObject_CallMethod(seq, "__reversed__", NULL); + + if (!PySequence_Check(seq)) { + PyErr_SetString(PyExc_TypeError, + "argument to reversed() must be a sequence"); + return NULL; + } + + n = PySequence_Size(seq); + if (n == -1) + return NULL; + + ro = (reversedobject *)type->tp_alloc(type, 0); + if (ro == NULL) + return NULL; + + ro->index = n-1; + Py_INCREF(seq); + ro->seq = seq; + return (PyObject *)ro; +} + +static void +reversed_dealloc(reversedobject *ro) +{ + PyObject_GC_UnTrack(ro); + Py_XDECREF(ro->seq); + ro->ob_type->tp_free(ro); +} + +static int +reversed_traverse(reversedobject *ro, visitproc visit, void *arg) +{ + if (ro->seq) + return visit((PyObject *)(ro->seq), arg); + return 0; +} + +static PyObject * +reversed_next(reversedobject *ro) +{ + PyObject *item; + long index = ro->index; + + if (index >= 0) { + item = PySequence_GetItem(ro->seq, index); + if (item != NULL) { + ro->index--; + return item; + } + if (PyErr_ExceptionMatches(PyExc_IndexError) || + PyErr_ExceptionMatches(PyExc_StopIteration)) + PyErr_Clear(); + } + ro->index = -1; + Py_CLEAR(ro->seq); + return NULL; +} + +PyDoc_STRVAR(reversed_doc, +"reversed(sequence) -> reverse iterator over values of the sequence\n" +"\n" +"Return a reverse iterator"); + +static int +reversed_len(reversedobject *ro) +{ + int position, seqsize; + + if (ro->seq == NULL) + return 0; + seqsize = PySequence_Size(ro->seq); + if (seqsize == -1) + return -1; + position = ro->index + 1; + return (seqsize < position) ? 0 : position; +} + +static PySequenceMethods reversed_as_sequence = { + (inquiry)reversed_len, /* sq_length */ + 0, /* sq_concat */ +}; + +PyTypeObject PyReversed_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, /* ob_size */ + "reversed", /* tp_name */ + sizeof(reversedobject), /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + (destructor)reversed_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + &reversed_as_sequence, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + reversed_doc, /* tp_doc */ + (traverseproc)reversed_traverse,/* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + PyObject_SelfIter, /* tp_iter */ + (iternextfunc)reversed_next, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + PyType_GenericAlloc, /* tp_alloc */ + reversed_new, /* tp_new */ + PyObject_GC_Del, /* tp_free */ +}; Index: fileobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/fileobject.c,v retrieving revision 2.164.2.1 retrieving revision 2.164.2.2 diff -u -d -r2.164.2.1 -r2.164.2.2 --- fileobject.c 28 Apr 2003 17:18:18 -0000 2.164.2.1 +++ fileobject.c 7 Jan 2005 07:04:01 -0000 2.164.2.2 @@ -21,17 +21,6 @@ #include #endif /* _MSC_VER */ -#ifdef macintosh -#ifdef USE_GUSI -#define HAVE_FTRUNCATE -#endif -#endif - -#ifdef __MWERKS__ -/* Mwerks fopen() doesn't always set errno */ -#define NO_FOPEN_ERRNO -#endif - #if defined(PYOS_OS2) && defined(PYCC_GCC) #include #endif @@ -52,13 +41,11 @@ #define FUNLOCKFILE(f) #endif -#ifdef WITH_UNIVERSAL_NEWLINES /* Bits in f_newlinetypes */ #define NEWLINE_UNKNOWN 0 /* No newline seen, yet */ #define NEWLINE_CR 1 /* \r newline seen */ #define NEWLINE_LF 2 /* \n newline seen */ #define NEWLINE_CRLF 4 /* \r\n newline seen */ -#endif FILE * PyFile_AsFile(PyObject *f) @@ -96,9 +83,10 @@ #else char *msg = "Is a directory"; #endif - PyObject *exc = PyObject_CallFunction(PyExc_IOError, "(is)", + PyObject *exc = PyObject_CallFunction(PyExc_IOError, "(is)", EISDIR, msg); PyErr_SetObject(PyExc_IOError, exc); + Py_XDECREF(exc); return NULL; } #endif @@ -107,8 +95,8 @@ static PyObject * -fill_file_fields(PyFileObject *f, FILE *fp, char *name, char *mode, - int (*close)(FILE *), PyObject *wname) +fill_file_fields(PyFileObject *f, FILE *fp, PyObject *name, char *mode, + int (*close)(FILE *)) { assert(f != NULL); assert(PyFile_Check(f)); @@ -116,23 +104,22 @@ Py_DECREF(f->f_name); Py_DECREF(f->f_mode); -#ifdef Py_USING_UNICODE - if (wname) - f->f_name = PyUnicode_FromObject(wname); - else -#endif - f->f_name = PyString_FromString(name); + Py_DECREF(f->f_encoding); + + Py_INCREF (name); + f->f_name = name; + f->f_mode = PyString_FromString(mode); f->f_close = close; f->f_softspace = 0; f->f_binary = strchr(mode,'b') != NULL; f->f_buf = NULL; -#ifdef WITH_UNIVERSAL_NEWLINES f->f_univ_newline = (strchr(mode, 'U') != NULL); f->f_newlinetypes = NEWLINE_UNKNOWN; f->f_skipnextlf = 0; -#endif + Py_INCREF(Py_None); + f->f_encoding = Py_None; if (f->f_name == NULL || f->f_mode == NULL) return NULL; @@ -164,59 +151,31 @@ return NULL; } errno = 0; -#ifdef HAVE_FOPENRF - if (*mode == '*') { - FILE *fopenRF(); - f->f_fp = fopenRF(name, mode+1); - } - else -#endif - { -#ifdef WITH_UNIVERSAL_NEWLINES - if (strcmp(mode, "U") == 0 || strcmp(mode, "rU") == 0) - mode = "rb"; -#else - /* Compatibility: specifying U in a Python without universal - ** newlines is allowed, and the file is opened as a normal text - ** file. - */ - if (strcmp(mode, "U") == 0 || strcmp(mode, "rU") == 0) - mode = "r"; -#endif + + if (strcmp(mode, "U") == 0 || strcmp(mode, "rU") == 0) + mode = "rb"; #ifdef MS_WINDOWS - if (PyUnicode_Check(f->f_name)) { - PyObject *wmode; - wmode = PyUnicode_DecodeASCII(mode, strlen(mode), NULL); - if (f->f_name && wmode) { - Py_BEGIN_ALLOW_THREADS - /* PyUnicode_AS_UNICODE OK without thread - lock as it is a simple dereference. */ - f->f_fp = _wfopen(PyUnicode_AS_UNICODE(f->f_name), - PyUnicode_AS_UNICODE(wmode)); - Py_END_ALLOW_THREADS - } - Py_XDECREF(wmode); - } -#endif - if (NULL == f->f_fp && NULL != name) { + if (PyUnicode_Check(f->f_name)) { + PyObject *wmode; + wmode = PyUnicode_DecodeASCII(mode, strlen(mode), NULL); + if (f->f_name && wmode) { Py_BEGIN_ALLOW_THREADS - f->f_fp = fopen(name, mode); + /* PyUnicode_AS_UNICODE OK without thread + lock as it is a simple dereference. */ + f->f_fp = _wfopen(PyUnicode_AS_UNICODE(f->f_name), + PyUnicode_AS_UNICODE(wmode)); Py_END_ALLOW_THREADS } + Py_XDECREF(wmode); } - if (f->f_fp == NULL) { -#ifdef NO_FOPEN_ERRNO - /* Metroworks only, wich does not always sets errno */ - if (errno == 0) { - PyObject *v; - v = Py_BuildValue("(is)", 0, "Cannot open file"); - if (v != NULL) { - PyErr_SetObject(PyExc_IOError, v); - Py_DECREF(v); - } - return NULL; - } #endif + if (NULL == f->f_fp && NULL != name) { + Py_BEGIN_ALLOW_THREADS + f->f_fp = fopen(name, mode); + Py_END_ALLOW_THREADS + } + + if (f->f_fp == NULL) { #ifdef _MSC_VER /* MSVC 6 (Microsoft) leaves errno at 0 for bad mode strings, * across all Windows flavors. When it sets EINVAL varies @@ -234,11 +193,7 @@ PyErr_Format(PyExc_IOError, "invalid mode: %s", mode); else -#ifdef MS_WINDOWS PyErr_SetFromErrnoWithFilenameObject(PyExc_IOError, f->f_name); -#else - PyErr_SetFromErrnoWithFilename(PyExc_IOError, name); -#endif /* MS_WINDOWS */ f = NULL; } if (f != NULL) @@ -252,10 +207,12 @@ PyFileObject *f = (PyFileObject *)PyFile_Type.tp_new(&PyFile_Type, NULL, NULL); if (f != NULL) { - if (fill_file_fields(f, fp, name, mode, close, NULL) == NULL) { + PyObject *o_name = PyString_FromString(name); + if (fill_file_fields(f, fp, o_name, mode, close) == NULL) { Py_DECREF(f); f = NULL; } + Py_DECREF(o_name); } return (PyObject *) f; } @@ -279,29 +236,56 @@ void PyFile_SetBufSize(PyObject *f, int bufsize) { + PyFileObject *file = (PyFileObject *)f; if (bufsize >= 0) { -#ifdef HAVE_SETVBUF int type; switch (bufsize) { case 0: type = _IONBF; break; +#ifdef HAVE_SETVBUF case 1: type = _IOLBF; bufsize = BUFSIZ; break; +#endif default: type = _IOFBF; +#ifndef HAVE_SETVBUF + bufsize = BUFSIZ; +#endif + break; } - setvbuf(((PyFileObject *)f)->f_fp, (char *)NULL, - type, bufsize); + fflush(file->f_fp); + if (type == _IONBF) { + PyMem_Free(file->f_setbuf); + file->f_setbuf = NULL; + } else { + file->f_setbuf = PyMem_Realloc(file->f_setbuf, bufsize); + } +#ifdef HAVE_SETVBUF + setvbuf(file->f_fp, file->f_setbuf, type, bufsize); #else /* !HAVE_SETVBUF */ - if (bufsize <= 1) - setbuf(((PyFileObject *)f)->f_fp, (char *)NULL); + setbuf(file->f_fp, file->f_setbuf); #endif /* !HAVE_SETVBUF */ } } +/* Set the encoding used to output Unicode strings. + Returh 1 on success, 0 on failure. */ + +int +PyFile_SetEncoding(PyObject *f, const char *enc) +{ + PyFileObject *file = (PyFileObject*)f; + PyObject *str = PyString_FromString(enc); + if (!str) + return 0; + Py_DECREF(file->f_encoding); + file->f_encoding = str; + return 1; +} + static PyObject * err_closed(void) { @@ -316,13 +300,24 @@ static void file_dealloc(PyFileObject *f) { + int sts = 0; + if (f->weakreflist != NULL) + PyObject_ClearWeakRefs((PyObject *) f); if (f->f_fp != NULL && f->f_close != NULL) { Py_BEGIN_ALLOW_THREADS - (*f->f_close)(f->f_fp); + sts = (*f->f_close)(f->f_fp); Py_END_ALLOW_THREADS + if (sts == EOF) +#ifdef HAVE_STRERROR + PySys_WriteStderr("close failed: [Errno %d] %s\n", errno, strerror(errno)); +#else + PySys_WriteStderr("close failed: [Errno %d]\n", errno); +#endif } + PyMem_Free(f->f_setbuf); Py_XDECREF(f->f_name); Py_XDECREF(f->f_mode); + Py_XDECREF(f->f_encoding); drop_readahead(f); f->ob_type->tp_free((PyObject *)f); } @@ -365,6 +360,8 @@ } f->f_fp = NULL; } + PyMem_Free(f->f_setbuf); + f->f_setbuf = NULL; if (sts == EOF) return PyErr_SetFromErrno(PyExc_IOError); if (sts != 0) @@ -484,9 +481,7 @@ clearerr(f->f_fp); return NULL; } -#ifdef WITH_UNIVERSAL_NEWLINES f->f_skipnextlf = 0; -#endif Py_INCREF(Py_None); return Py_None; } @@ -496,18 +491,33 @@ static PyObject * file_truncate(PyFileObject *f, PyObject *args) { - int ret; Py_off_t newsize; - PyObject *newsizeobj; + PyObject *newsizeobj = NULL; + Py_off_t initialpos; + int ret; if (f->f_fp == NULL) return err_closed(); - newsizeobj = NULL; if (!PyArg_UnpackTuple(args, "truncate", 0, 1, &newsizeobj)) return NULL; + /* Get current file position. If the file happens to be open for + * update and the last operation was an input operation, C doesn't + * define what the later fflush() will do, but we promise truncate() + * won't change the current position (and fflush() *does* change it + * then at least on Windows). The easiest thing is to capture + * current pos now and seek back to it at the end. + */ + Py_BEGIN_ALLOW_THREADS + errno = 0; + initialpos = _portable_ftell(f->f_fp); + Py_END_ALLOW_THREADS + if (initialpos == -1) + goto onioerror; + /* Set newsize to current postion if newsizeobj NULL, else to the - specified value. */ + * specified value. + */ if (newsizeobj != NULL) { #if !defined(HAVE_LARGEFILE_SUPPORT) newsize = PyInt_AsLong(newsizeobj); @@ -519,17 +529,13 @@ if (PyErr_Occurred()) return NULL; } - else { - /* Default to current position. */ - Py_BEGIN_ALLOW_THREADS - errno = 0; - newsize = _portable_ftell(f->f_fp); - Py_END_ALLOW_THREADS - if (newsize == -1) - goto onioerror; - } + else /* default to current position */ + newsize = initialpos; - /* Flush the file. */ + /* Flush the stream. We're mixing stream-level I/O with lower-level + * I/O, and a flush may be necessary to synch both platform views + * of the current file state. + */ Py_BEGIN_ALLOW_THREADS errno = 0; ret = fflush(f->f_fp); @@ -541,66 +547,47 @@ /* MS _chsize doesn't work if newsize doesn't fit in 32 bits, so don't even try using it. */ { - Py_off_t current; /* current file position */ HANDLE hFile; - int error; - /* current <- current file postion. */ - if (newsizeobj == NULL) - current = newsize; - else { - Py_BEGIN_ALLOW_THREADS - errno = 0; - current = _portable_ftell(f->f_fp); - Py_END_ALLOW_THREADS - if (current == -1) - goto onioerror; - } - - /* Move to newsize. */ - if (current != newsize) { - Py_BEGIN_ALLOW_THREADS - errno = 0; - error = _portable_fseek(f->f_fp, newsize, SEEK_SET) - != 0; - Py_END_ALLOW_THREADS - if (error) - goto onioerror; - } + /* Have to move current pos to desired endpoint on Windows. */ + Py_BEGIN_ALLOW_THREADS + errno = 0; + ret = _portable_fseek(f->f_fp, newsize, SEEK_SET) != 0; + Py_END_ALLOW_THREADS + if (ret) + goto onioerror; /* Truncate. Note that this may grow the file! */ Py_BEGIN_ALLOW_THREADS errno = 0; hFile = (HANDLE)_get_osfhandle(fileno(f->f_fp)); - error = hFile == (HANDLE)-1; - if (!error) { - error = SetEndOfFile(hFile) == 0; - if (error) + ret = hFile == (HANDLE)-1; + if (ret == 0) { + ret = SetEndOfFile(hFile) == 0; + if (ret) errno = EACCES; } Py_END_ALLOW_THREADS - if (error) + if (ret) goto onioerror; - - /* Restore original file position. */ - if (current != newsize) { - Py_BEGIN_ALLOW_THREADS - errno = 0; - error = _portable_fseek(f->f_fp, current, SEEK_SET) - != 0; - Py_END_ALLOW_THREADS - if (error) - goto onioerror; - } } #else Py_BEGIN_ALLOW_THREADS errno = 0; ret = ftruncate(fileno(f->f_fp), newsize); Py_END_ALLOW_THREADS - if (ret != 0) goto onioerror; + if (ret != 0) + goto onioerror; #endif /* !MS_WINDOWS */ + /* Restore original file position. */ + Py_BEGIN_ALLOW_THREADS + errno = 0; + ret = _portable_fseek(f->f_fp, initialpos, SEEK_SET) != 0; + Py_END_ALLOW_THREADS + if (ret) + goto onioerror; + Py_INCREF(Py_None); return Py_None; @@ -627,7 +614,6 @@ clearerr(f->f_fp); return NULL; } -#ifdef WITH_UNIVERSAL_NEWLINES if (f->f_skipnextlf) { int c; c = GETC(f->f_fp); @@ -636,7 +622,6 @@ f->f_skipnextlf = 0; } else if (c != EOF) ungetc(c, f->f_fp); } -#endif #if !defined(HAVE_LARGEFILE_SUPPORT) return PyInt_FromLong(pos); #else @@ -714,12 +699,7 @@ works. We can't use the lseek() value either, because we need to take the amount of buffered data into account. (Yet another reason why stdio stinks. :-) */ -#ifdef USE_GUSI2 - pos = lseek(fileno(f->f_fp), 1L, SEEK_CUR); - pos = lseek(fileno(f->f_fp), -1L, SEEK_CUR); -#else pos = lseek(fileno(f->f_fp), 0L, SEEK_CUR); -#endif if (pos >= 0) { pos = ftell(f->f_fp); } @@ -833,7 +813,7 @@ while (ntodo > 0) { Py_BEGIN_ALLOW_THREADS errno = 0; - nnow = Py_UniversalNewlineFread(ptr+ndone, ntodo, f->f_fp, + nnow = Py_UniversalNewlineFread(ptr+ndone, ntodo, f->f_fp, (PyObject *)f); Py_END_ALLOW_THREADS if (nnow == 0) { @@ -1073,18 +1053,12 @@ size_t used_v_size; /* # used slots in buffer */ size_t increment; /* amount to increment the buffer */ PyObject *v; -#ifdef WITH_UNIVERSAL_NEWLINES int newlinetypes = f->f_newlinetypes; int skipnextlf = f->f_skipnextlf; int univ_newline = f->f_univ_newline; -#endif #if defined(USE_FGETS_IN_GETLINE) -#ifdef WITH_UNIVERSAL_NEWLINES if (n <= 0 && !univ_newline ) -#else - if (n <= 0) -#endif return getline_via_fgets(fp); #endif total_v_size = n > 0 ? n : 100; @@ -1097,15 +1071,14 @@ for (;;) { Py_BEGIN_ALLOW_THREADS FLOCKFILE(fp); -#ifdef WITH_UNIVERSAL_NEWLINES if (univ_newline) { c = 'x'; /* Shut up gcc warning */ while ( buf != end && (c = GETC(fp)) != EOF ) { if (skipnextlf ) { skipnextlf = 0; if (c == '\n') { - /* Seeing a \n here with - * skipnextlf true means we + /* Seeing a \n here with + * skipnextlf true means we * saw a \r before. */ newlinetypes |= NEWLINE_CRLF; @@ -1126,17 +1099,14 @@ if ( c == EOF && skipnextlf ) newlinetypes |= NEWLINE_CR; } else /* If not universal newlines use the normal loop */ -#endif while ((c = GETC(fp)) != EOF && (*buf++ = c) != '\n' && buf != end) ; FUNLOCKFILE(fp); Py_END_ALLOW_THREADS -#ifdef WITH_UNIVERSAL_NEWLINES f->f_newlinetypes = newlinetypes; f->f_skipnextlf = skipnextlf; -#endif if (c == '\n') break; if (c == EOF) { @@ -1202,7 +1172,7 @@ if (reader == NULL) return NULL; if (n <= 0) - args = Py_BuildValue("()"); + args = PyTuple_New(0); else args = Py_BuildValue("(i)", n); if (args == NULL) { @@ -1588,7 +1558,9 @@ "0 (offset from start of file, offset should be >= 0); other values are 1\n" "(move relative to current position, positive or negative), and 2 (move\n" "relative to end of file, usually negative, although many platforms allow\n" -"seeking beyond the end of a file).\n" +"seeking beyond the end of a file). If the file is opened in text mode,\n" +"only offsets returned by tell() are legal. Use of other offsets causes\n" +"undefined behavior." "\n" "Note that not all file objects are seekable."); @@ -1667,6 +1639,8 @@ "file mode ('r', 'U', 'w', 'a', possibly with 'b' or '+' added)"}, {"name", T_OBJECT, OFF(f_name), RO, "file name"}, + {"encoding", T_OBJECT, OFF(f_encoding), RO, + "file encoding"}, /* getattr(f, "closed") is implemented without this table */ {NULL} /* Sentinel */ }; @@ -1676,7 +1650,6 @@ { return PyBool_FromLong((long)(f->f_fp == 0)); } -#ifdef WITH_UNIVERSAL_NEWLINES static PyObject * get_newlines(PyFileObject *f, void *closure) { @@ -1699,20 +1672,17 @@ case NEWLINE_CR|NEWLINE_LF|NEWLINE_CRLF: return Py_BuildValue("(sss)", "\r", "\n", "\r\n"); default: - PyErr_Format(PyExc_SystemError, - "Unknown newlines value 0x%x\n", + PyErr_Format(PyExc_SystemError, + "Unknown newlines value 0x%x\n", f->f_newlinetypes); return NULL; } } -#endif static PyGetSetDef file_getsetlist[] = { {"closed", (getter)get_closed, NULL, "True if the file is closed"}, -#ifdef WITH_UNIVERSAL_NEWLINES - {"newlines", (getter)get_newlines, NULL, + {"newlines", (getter)get_newlines, NULL, "end-of-line convention used in this file"}, -#endif {0}, }; @@ -1725,8 +1695,8 @@ } } -/* Make sure that file has a readahead buffer with at least one byte - (unless at EOF) and no more than bufsize. Returns negative value on +/* Make sure that file has a readahead buffer with at least one byte + (unless at EOF) and no more than bufsize. Returns negative value on error */ static int readahead(PyFileObject *f, int bufsize) @@ -1734,7 +1704,7 @@ int chunksize; if (f->f_buf != NULL) { - if( (f->f_bufend - f->f_bufptr) >= 1) + if( (f->f_bufend - f->f_bufptr) >= 1) return 0; else drop_readahead(f); @@ -1761,8 +1731,8 @@ } /* Used by file_iternext. The returned string will start with 'skip' - uninitialized bytes followed by the remainder of the line. Don't be - horrified by the recursive call: maximum recursion depth is limited by + uninitialized bytes followed by the remainder of the line. Don't be + horrified by the recursive call: maximum recursion depth is limited by logarithmic buffer growth to about 50 even when reading a 1gb line. */ static PyStringObject * @@ -1774,11 +1744,11 @@ int len; if (f->f_buf == NULL) - if (readahead(f, bufsize) < 0) + if (readahead(f, bufsize) < 0) return NULL; len = f->f_bufend - f->f_bufptr; - if (len == 0) + if (len == 0) return (PyStringObject *) PyString_FromStringAndSize(NULL, skip); bufptr = memchr(f->f_bufptr, '\n', len); @@ -1787,7 +1757,7 @@ len = bufptr - f->f_bufptr; s = (PyStringObject *) PyString_FromStringAndSize(NULL, skip+len); - if (s == NULL) + if (s == NULL) return NULL; memcpy(PyString_AS_STRING(s)+skip, f->f_bufptr, len); f->f_bufptr = bufptr; @@ -1851,6 +1821,9 @@ ((PyFileObject *)self)->f_name = not_yet_string; Py_INCREF(not_yet_string); ((PyFileObject *)self)->f_mode = not_yet_string; + Py_INCREF(Py_None); + ((PyFileObject *)self)->f_encoding = Py_None; + ((PyFileObject *)self)->weakreflist = NULL; } return self; } @@ -1881,8 +1854,8 @@ if (PyArg_ParseTupleAndKeywords(args, kwds, "U|si:file", kwlist, &po, &mode, &bufsize)) { wideargument = 1; - if (fill_file_fields(foself, NULL, name, mode, - fclose, po) == NULL) + if (fill_file_fields(foself, NULL, po, mode, + fclose) == NULL) goto Error; } else { /* Drop the argument parsing error as narrow @@ -1893,17 +1866,26 @@ #endif if (!wideargument) { + PyObject *o_name; + if (!PyArg_ParseTupleAndKeywords(args, kwds, "et|si:file", kwlist, Py_FileSystemDefaultEncoding, &name, &mode, &bufsize)) return -1; - if (fill_file_fields(foself, NULL, name, mode, - fclose, NULL) == NULL) + + /* We parse again to get the name as a PyObject */ + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|si:file", kwlist, + &o_name, &mode, &bufsize)) + return -1; + + if (fill_file_fields(foself, NULL, o_name, mode, + fclose) == NULL) goto Error; } if (open_the_file(foself, name, mode) == NULL) goto Error; + foself->f_setbuf = NULL; PyFile_SetBufSize(self, bufsize); goto Done; @@ -1927,7 +1909,6 @@ "If the buffering argument is given, 0 means unbuffered, 1 means line\n" "buffered, and larger numbers specify the buffer size.\n" ) -#ifdef WITH_UNIVERSAL_NEWLINES PyDoc_STR( "Add a 'U' to mode to open the file for input with universal newline\n" "support. Any line ending in the input file will be seen as a '\\n'\n" @@ -1937,7 +1918,6 @@ "\n" "'U' cannot be combined with 'w' or '+' mode.\n" ) -#endif /* WITH_UNIVERSAL_NEWLINES */ PyDoc_STR( "\n" "Note: open() is an alias for file()." @@ -1962,14 +1942,15 @@ 0, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ + /* softspace is writable: we must supply tp_setattro */ + PyObject_GenericSetAttr, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_WEAKREFS, /* tp_flags */ file_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ + offsetof(PyFileObject, weakreflist), /* tp_weaklistoffset */ (getiterfunc)file_getiter, /* tp_iter */ (iternextfunc)file_iternext, /* tp_iternext */ file_methods, /* tp_methods */ @@ -2033,11 +2014,31 @@ } else if (PyFile_Check(f)) { FILE *fp = PyFile_AsFile(f); +#ifdef Py_USING_UNICODE + PyObject *enc = ((PyFileObject*)f)->f_encoding; + int result; +#endif if (fp == NULL) { err_closed(); return -1; } +#ifdef Py_USING_UNICODE + if ((flags & Py_PRINT_RAW) && + PyUnicode_Check(v) && enc != Py_None) { + char *cenc = PyString_AS_STRING(enc); + value = PyUnicode_AsEncodedString(v, cenc, "strict"); + if (value == NULL) + return -1; + } else { + value = v; + Py_INCREF(value); + } + result = PyObject_Print(value, fp, flags); + Py_DECREF(value); + return result; +#else return PyObject_Print(v, fp, flags); +#endif } writer = PyObject_GetAttrString(f, "write"); if (writer == NULL) @@ -2055,7 +2056,7 @@ Py_DECREF(writer); return -1; } - args = Py_BuildValue("(O)", value); + args = PyTuple_Pack(1, value); if (args == NULL) { Py_DECREF(value); Py_DECREF(writer); @@ -2158,7 +2159,6 @@ return fd; } -#ifdef WITH_UNIVERSAL_NEWLINES /* From here on we need access to the real fgets and fread */ #undef fgets #undef fread @@ -2336,4 +2336,3 @@ f->f_skipnextlf = skipnextlf; return dst - buf; } -#endif Index: floatobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/floatobject.c,v retrieving revision 2.113.2.1 retrieving revision 2.113.2.2 diff -u -d -r2.113.2.1 -r2.113.2.2 --- floatobject.c 28 Apr 2003 17:18:18 -0000 2.113.2.1 +++ floatobject.c 7 Jan 2005 07:04:01 -0000 2.113.2.2 @@ -8,21 +8,11 @@ #include -#if !defined(__STDC__) && !defined(macintosh) +#if !defined(__STDC__) extern double fmod(double, double); extern double pow(double, double); #endif -#if defined(sun) && !defined(__SVR4) -/* On SunOS4.1 only libm.a exists. Make sure that references to all - needed math functions exist in the executable, so that dynamic - loading of mathmodule does not fail. */ -double (*_Py_math_funcs_hack[])() = { - acos, asin, atan, atan2, ceil, cos, cosh, exp, fabs, floor, - fmod, log, log10, pow, sin, sinh, sqrt, tan, tanh -}; -#endif - /* Special free list -- see comments for same code in intobject.c. */ #define BLOCK_SIZE 1000 /* 1K less typical malloc overhead */ #define BHEAD_SIZE 8 /* Enough for a 64-bit pointer */ @@ -142,7 +132,7 @@ * key off errno. */ PyFPE_START_PROTECT("strtod", return NULL) - x = strtod(s, (char **)&end); + x = PyOS_ascii_strtod(s, (char **)&end); PyFPE_END_PROTECT(x) errno = 0; /* Believe it or not, Solaris 2.6 can move end *beyond* the null @@ -174,7 +164,7 @@ /* See above -- may have been strtod being anal about denorms. */ PyFPE_START_PROTECT("atof", return NULL) - x = atof(s); + x = PyOS_ascii_atof(s); PyFPE_END_PROTECT(x) errno = 0; /* whether atof ever set errno is undefined */ } @@ -233,6 +223,7 @@ format_float(char *buf, size_t buflen, PyFloatObject *v, int precision) { register char *cp; + char format[32]; /* Subroutine for float_repr and float_print. We want float numbers to be recognizable as such, i.e., they should contain a decimal point or an exponent. @@ -240,7 +231,8 @@ in such cases, we append ".0" to the string. */ assert(PyFloat_Check(v)); - PyOS_snprintf(buf, buflen, "%.*g", precision, v->ob_fval); + PyOS_snprintf(format, 32, "%%.%ig", precision); + PyOS_ascii_formatd(buf, buflen, format, v->ob_fval); cp = buf; if (*cp == '-') cp++; @@ -362,12 +354,234 @@ return PyString_FromString(buf); } -static int -float_compare(PyFloatObject *v, PyFloatObject *w) +/* Comparison is pretty much a nightmare. When comparing float to float, + * we do it as straightforwardly (and long-windedly) as conceivable, so + * that, e.g., Python x == y delivers the same result as the platform + * C x == y when x and/or y is a NaN. + * When mixing float with an integer type, there's no good *uniform* approach. + * Converting the double to an integer obviously doesn't work, since we + * may lose info from fractional bits. Converting the integer to a double + * also has two failure modes: (1) a long int may trigger overflow (too + * large to fit in the dynamic range of a C double); (2) even a C long may have + * more bits than fit in a C double (e.g., on a a 64-bit box long may have + * 63 bits of precision, but a C double probably has only 53), and then + * we can falsely claim equality when low-order integer bits are lost by + * coercion to double. So this part is painful too. + */ + +static PyObject* +float_richcompare(PyObject *v, PyObject *w, int op) { - double i = v->ob_fval; - double j = w->ob_fval; - return (i < j) ? -1 : (i > j) ? 1 : 0; + double i, j; + int r = 0; + + assert(PyFloat_Check(v)); + i = PyFloat_AS_DOUBLE(v); + + /* Switch on the type of w. Set i and j to doubles to be compared, + * and op to the richcomp to use. + */ + if (PyFloat_Check(w)) + j = PyFloat_AS_DOUBLE(w); + + else if (Py_IS_INFINITY(i) || Py_IS_NAN(i)) { + if (PyInt_Check(w) || PyLong_Check(w)) + /* If i is an infinity, its magnitude exceeds any + * finite integer, so it doesn't matter which int we + * compare i with. If i is a NaN, similarly. + */ + j = 0.0; + else + goto Unimplemented; + } + + else if (PyInt_Check(w)) { + long jj = PyInt_AS_LONG(w); + /* In the worst realistic case I can imagine, C double is a + * Cray single with 48 bits of precision, and long has 64 + * bits. + */ +#if SIZEOF_LONG > 6 + unsigned long abs = (unsigned long)(jj < 0 ? -jj : jj); + if (abs >> 48) { + /* Needs more than 48 bits. Make it take the + * PyLong path. + */ + PyObject *result; + PyObject *ww = PyLong_FromLong(jj); + + if (ww == NULL) + return NULL; + result = float_richcompare(v, ww, op); + Py_DECREF(ww); + return result; + } +#endif + j = (double)jj; + assert((long)j == jj); + } + + else if (PyLong_Check(w)) { + int vsign = i == 0.0 ? 0 : i < 0.0 ? -1 : 1; + int wsign = _PyLong_Sign(w); + size_t nbits; + double mant; + int exponent; + + if (vsign != wsign) { + /* Magnitudes are irrelevant -- the signs alone + * determine the outcome. + */ + i = (double)vsign; + j = (double)wsign; + goto Compare; + } + /* The signs are the same. */ + /* Convert w to a double if it fits. In particular, 0 fits. */ + nbits = _PyLong_NumBits(w); + if (nbits == (size_t)-1 && PyErr_Occurred()) { + /* This long is so large that size_t isn't big enough + * to hold the # of bits. Replace with little doubles + * that give the same outcome -- w is so large that + * its magnitude must exceed the magnitude of any + * finite float. + */ + PyErr_Clear(); + i = (double)vsign; + assert(wsign != 0); + j = wsign * 2.0; + goto Compare; + } + if (nbits <= 48) { + j = PyLong_AsDouble(w); + /* It's impossible that <= 48 bits overflowed. */ + assert(j != -1.0 || ! PyErr_Occurred()); + goto Compare; + } + assert(wsign != 0); /* else nbits was 0 */ + assert(vsign != 0); /* if vsign were 0, then since wsign is + * not 0, we would have taken the + * vsign != wsign branch at the start */ + /* We want to work with non-negative numbers. */ + if (vsign < 0) { + /* "Multiply both sides" by -1; this also swaps the + * comparator. + */ + i = -i; + op = _Py_SwappedOp[op]; + } + assert(i > 0.0); + mant = frexp(i, &exponent); + /* exponent is the # of bits in v before the radix point; + * we know that nbits (the # of bits in w) > 48 at this point + */ + if (exponent < 0 || (size_t)exponent < nbits) { + i = 1.0; + j = 2.0; + goto Compare; + } + if ((size_t)exponent > nbits) { + i = 2.0; + j = 1.0; + goto Compare; + } + /* v and w have the same number of bits before the radix + * point. Construct two longs that have the same comparison + * outcome. + */ + { + double fracpart; + double intpart; + PyObject *result = NULL; + PyObject *one = NULL; + PyObject *vv = NULL; + PyObject *ww = w; + + if (wsign < 0) { + ww = PyNumber_Negative(w); + if (ww == NULL) + goto Error; + } + else + Py_INCREF(ww); + + fracpart = modf(i, &intpart); + vv = PyLong_FromDouble(intpart); + if (vv == NULL) + goto Error; + + if (fracpart != 0.0) { + /* Shift left, and or a 1 bit into vv + * to represent the lost fraction. + */ + PyObject *temp; + + one = PyInt_FromLong(1); + if (one == NULL) + goto Error; + + temp = PyNumber_Lshift(ww, one); + if (temp == NULL) + goto Error; + Py_DECREF(ww); + ww = temp; + + temp = PyNumber_Lshift(vv, one); + if (temp == NULL) + goto Error; + Py_DECREF(vv); + vv = temp; + + temp = PyNumber_Or(vv, one); + if (temp == NULL) + goto Error; + Py_DECREF(vv); + vv = temp; + } + + r = PyObject_RichCompareBool(vv, ww, op); + if (r < 0) + goto Error; + result = PyBool_FromLong(r); + Error: + Py_XDECREF(vv); + Py_XDECREF(ww); + Py_XDECREF(one); + return result; + } + } /* else if (PyLong_Check(w)) */ + + else /* w isn't float, int, or long */ + goto Unimplemented; + + Compare: + PyFPE_START_PROTECT("richcompare", return NULL) + switch (op) { + case Py_EQ: + r = i == j; + break; + case Py_NE: + r = i != j; + break; + case Py_LE: + r = i <= j; + break; + case Py_GE: + r = i >= j; + break; + case Py_LT: + r = i < j; + break; + case Py_GT: + r = i > j; + break; + } + PyFPE_END_PROTECT(r) + return PyBool_FromLong(r); + + Unimplemented: + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; } static long @@ -572,10 +786,39 @@ } return PyFloat_FromDouble(0.0); } - if (iv < 0.0 && iw != floor(iw)) { - PyErr_SetString(PyExc_ValueError, - "negative number cannot be raised to a fractional power"); - return NULL; + if (iv < 0.0) { + /* Whether this is an error is a mess, and bumps into libm + * bugs so we have to figure it out ourselves. + */ + if (iw != floor(iw)) { + PyErr_SetString(PyExc_ValueError, "negative number " + "cannot be raised to a fractional power"); + return NULL; + } + /* iw is an exact integer, albeit perhaps a very large one. + * -1 raised to an exact integer should never be exceptional. + * Alas, some libms (chiefly glibc as of early 2003) return + * NaN and set EDOM on pow(-1, large_int) if the int doesn't + * happen to be representable in a *C* integer. That's a + * bug; we let that slide in math.pow() (which currently + * reflects all platform accidents), but not for Python's **. + */ + if (iv == -1.0 && !Py_IS_INFINITY(iw) && iw == iw) { + /* XXX the "iw == iw" was to weed out NaNs. This + * XXX doesn't actually work on all platforms. + */ + /* Return 1 if iw is even, -1 if iw is odd; there's + * no guarantee that any C integral type is big + * enough to hold iw, so we have to check this + * indirectly. + */ + ix = floor(iw * 0.5) * 2.0; + return PyFloat_FromDouble(ix == iw ? 1.0 : -1.0); + } + /* Else iv != -1.0, and overflow or underflow are possible. + * Unless we're to write pow() ourselves, we have to trust + * the platform to do this correctly. + */ } errno = 0; PyFPE_START_PROTECT("pow", return NULL) @@ -583,8 +826,11 @@ PyFPE_END_PROTECT(ix) Py_ADJUST_ERANGE1(ix); if (errno != 0) { - assert(errno == ERANGE); - PyErr_SetFromErrno(PyExc_OverflowError); + /* We don't expect any errno value other than ERANGE, but + * the range of libm bugs appears unbounded. + */ + PyErr_SetFromErrno(errno == ERANGE ? PyExc_OverflowError : + PyExc_ValueError); return NULL; } return PyFloat_FromDouble(ix); @@ -719,8 +965,10 @@ return NULL; assert(PyFloat_CheckExact(tmp)); new = type->tp_alloc(type, 0); - if (new == NULL) + if (new == NULL) { + Py_DECREF(tmp); return NULL; + } ((PyFloatObject *)new)->ob_fval = ((PyFloatObject *)tmp)->ob_fval; Py_DECREF(tmp); return new; @@ -794,7 +1042,7 @@ (printfunc)float_print, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - (cmpfunc)float_compare, /* tp_compare */ + 0, /* tp_compare */ (reprfunc)float_repr, /* tp_repr */ &float_as_number, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -810,7 +1058,7 @@ float_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ - 0, /* tp_richcompare */ + (richcmpfunc)float_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ @@ -832,7 +1080,7 @@ { PyFloatObject *p; PyFloatBlock *list, *next; - int i; + unsigned i; int bc, bf; /* block count, number of freed blocks */ int frem, fsum; /* remaining unfreed floats per block, total */ Index: frameobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/frameobject.c,v retrieving revision 2.62.2.2 retrieving revision 2.62.2.3 diff -u -d -r2.62.2.2 -r2.62.2.3 --- frameobject.c 28 Apr 2003 17:18:18 -0000 2.62.2.2 +++ frameobject.c 7 Jan 2005 07:04:01 -0000 2.62.2.3 @@ -541,11 +541,11 @@ PyFrameObject *back = tstate->frame; PyFrameObject *f; PyObject *builtins; - int extras, ncells, nfrees; + int extras, ncells, nfrees, i; #ifdef Py_DEBUG if (code == NULL || globals == NULL || !PyDict_Check(globals) || - (locals != NULL && !PyDict_Check(locals))) { + (locals != NULL && !PyMapping_Check(locals))) { PyErr_BadInternalCall(); return NULL; } @@ -585,8 +585,10 @@ } if (free_list == NULL) { f = PyObject_GC_NewVar(PyFrameObject, &PyFrame_Type, extras); - if (f == NULL) + if (f == NULL) { + Py_DECREF(builtins); return NULL; + } } else { assert(numfree > 0); @@ -595,8 +597,10 @@ free_list = free_list->f_back; if (f->ob_size < extras) { f = PyObject_GC_Resize(PyFrameObject, f, extras); - if (f == NULL) + if (f == NULL) { + Py_DECREF(builtins); return NULL; + } } _Py_NewReference((PyObject *)f); } @@ -610,7 +614,7 @@ /* Most functions have CO_NEWLOCALS and CO_OPTIMIZED set. */ if ((code->co_flags & (CO_NEWLOCALS | CO_OPTIMIZED)) == (CO_NEWLOCALS | CO_OPTIMIZED)) - locals = NULL; /* PyFrame_Fast2Locals() will set. */ + locals = NULL; /* PyFrame_FastToLocals() will set. */ else if (code->co_flags & CO_NEWLOCALS) { locals = PyDict_New(); if (locals == NULL) { @@ -638,7 +642,9 @@ f->f_nfreevars = nfrees; extras = f->f_nlocals + ncells + nfrees; - memset(f->f_localsplus, 0, extras * sizeof(f->f_localsplus[0])); + /* Tim said it's ok to replace memset */ + for (i=0; if_localsplus[i] = NULL; f->f_valuestack = f->f_localsplus + extras; f->f_stacktop = f->f_valuestack; @@ -683,11 +689,11 @@ if (deref) value = PyCell_GET(value); if (value == NULL) { - if (PyDict_DelItem(dict, key) != 0) + if (PyObject_DelItem(dict, key) != 0) PyErr_Clear(); } else { - if (PyDict_SetItem(dict, key, value) != 0) + if (PyObject_SetItem(dict, key, value) != 0) PyErr_Clear(); } } @@ -700,7 +706,9 @@ int j; for (j = nmap; --j >= 0; ) { PyObject *key = PyTuple_GET_ITEM(map, j); - PyObject *value = PyDict_GetItem(dict, key); + PyObject *value = PyObject_GetItem(dict, key); + if (value == NULL) + PyErr_Clear(); if (deref) { if (value || clear) { if (PyCell_GET(values[j]) != value) { @@ -715,6 +723,7 @@ values[j] = value; } } + Py_XDECREF(value); } } @@ -737,7 +746,7 @@ } } map = f->f_code->co_varnames; - if (!PyDict_Check(locals) || !PyTuple_Check(map)) + if (!PyTuple_Check(map)) return; PyErr_Fetch(&error_type, &error_value, &error_traceback); fast = f->f_localsplus; @@ -745,11 +754,10 @@ if (j > f->f_nlocals) j = f->f_nlocals; if (f->f_nlocals) - map_to_dict(map, j, locals, fast, 0); + map_to_dict(map, j, locals, fast, 0); if (f->f_ncells || f->f_nfreevars) { if (!(PyTuple_Check(f->f_code->co_cellvars) && PyTuple_Check(f->f_code->co_freevars))) { - Py_DECREF(locals); return; } map_to_dict(f->f_code->co_cellvars, @@ -776,7 +784,7 @@ map = f->f_code->co_varnames; if (locals == NULL) return; - if (!PyDict_Check(locals) || !PyTuple_Check(map)) + if (!PyTuple_Check(map)) return; PyErr_Fetch(&error_type, &error_value, &error_traceback); fast = f->f_localsplus; Index: funcobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/funcobject.c,v retrieving revision 2.55.2.2 retrieving revision 2.55.2.3 diff -u -d -r2.55.2.2 -r2.55.2.3 --- funcobject.c 28 Apr 2003 17:18:17 -0000 2.55.2.2 +++ funcobject.c 7 Jan 2005 07:04:01 -0000 2.55.2.3 @@ -11,6 +11,7 @@ { PyFunctionObject *op = PyObject_GC_New(PyFunctionObject, &PyFunction_Type); + static PyObject *__name__ = 0; if (op != NULL) { PyObject *doc; PyObject *consts; @@ -40,7 +41,14 @@ /* __module__: If module name is in globals, use it. Otherwise, use None. */ - module = PyDict_GetItemString(globals, "__name__"); + if (!__name__) { + __name__ = PyString_InternFromString("__name__"); + if (!__name__) { + Py_DECREF(op); + return NULL; + } + } + module = PyDict_GetItem(globals, __name__); if (module) { Py_INCREF(module); op->func_module = module; @@ -148,8 +156,6 @@ #define OFF(x) offsetof(PyFunctionObject, x) -#define RR () - static PyMemberDef func_memberlist[] = { {"func_closure", T_OBJECT, OFF(func_closure), RESTRICTED|READONLY}, @@ -157,8 +163,6 @@ {"__doc__", T_OBJECT, OFF(func_doc), WRITE_RESTRICTED}, {"func_globals", T_OBJECT, OFF(func_globals), RESTRICTED|READONLY}, - {"func_name", T_OBJECT, OFF(func_name), READONLY}, - {"__name__", T_OBJECT, OFF(func_name), READONLY}, {"__module__", T_OBJECT, OFF(func_module), WRITE_RESTRICTED}, {NULL} /* Sentinel */ }; @@ -226,6 +230,7 @@ func_set_code(PyFunctionObject *op, PyObject *value) { PyObject *tmp; + int nfree, nclosure; if (restricted()) return -1; @@ -236,6 +241,17 @@ "func_code must be set to a code object"); return -1; } + nfree = PyCode_GetNumFree((PyCodeObject *)value); + nclosure = (op->func_closure == NULL ? 0 : + PyTuple_GET_SIZE(op->func_closure)); + if (nclosure != nfree) { + PyErr_Format(PyExc_ValueError, + "%s() requires a code object with %d free vars," + " not %d", + PyString_AsString(op->func_name), + nclosure, nfree); + return -1; + } tmp = op->func_code; Py_INCREF(value); op->func_code = value; @@ -244,6 +260,36 @@ } static PyObject * +func_get_name(PyFunctionObject *op) +{ + if (restricted()) + return NULL; + Py_INCREF(op->func_name); + return op->func_name; +} + +static int +func_set_name(PyFunctionObject *op, PyObject *value) +{ + PyObject *tmp; + + if (restricted()) + return -1; + /* Not legal to del f.func_name or to set it to anything + * other than a string object. */ + if (value == NULL || !PyString_Check(value)) { + PyErr_SetString(PyExc_TypeError, + "func_name must be set to a string object"); + return -1; + } + tmp = op->func_name; + Py_INCREF(value); + op->func_name = value; + Py_DECREF(tmp); + return 0; +} + +static PyObject * func_get_defaults(PyFunctionObject *op) { if (restricted()) @@ -285,6 +331,8 @@ (setter)func_set_defaults}, {"func_dict", (getter)func_get_dict, (setter)func_set_dict}, {"__dict__", (getter)func_get_dict, (setter)func_set_dict}, + {"func_name", (getter)func_get_name, (setter)func_set_name}, + {"__name__", (getter)func_get_name, (setter)func_set_name}, {NULL} /* Sentinel */ }; @@ -316,8 +364,11 @@ PyObject *closure = Py_None; PyFunctionObject *newfunc; int nfree, nclosure; + static char *kwlist[] = {"code", "globals", "name", + "argdefs", "closure", 0}; - if (!PyArg_ParseTuple(args, "O!O!|OOO:function", + if (!PyArg_ParseTupleAndKeywords(args, kw, "O!O!|OOO:function", + kwlist, &PyCode_Type, &code, &PyDict_Type, &globals, &name, &defaults, &closure)) @@ -407,8 +458,6 @@ static PyObject* func_repr(PyFunctionObject *op) { - if (op->func_name == Py_None) - return PyString_FromFormat("", op); return PyString_FromFormat("", PyString_AsString(op->func_name), op); @@ -637,6 +686,12 @@ if (!PyArg_UnpackTuple(args, "classmethod", 1, 1, &callable)) return -1; + if (!PyCallable_Check(callable)) { + PyErr_Format(PyExc_TypeError, "'%s' object is not callable", + callable->ob_type->tp_name); + return -1; + } + Py_INCREF(callable); cm->cm_callable = callable; return 0; Index: intobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/intobject.c,v retrieving revision 2.84.2.1 retrieving revision 2.84.2.2 diff -u -d -r2.84.2.1 -r2.84.2.2 --- intobject.c 28 Apr 2003 17:18:17 -0000 2.84.2.1 +++ intobject.c 7 Jan 2005 07:04:02 -0000 2.84.2.2 @@ -10,19 +10,6 @@ return LONG_MAX; /* To initialize sys.maxint */ } -/* Return 1 if exception raised, 0 if caller should retry using longs */ -static int -err_ovf(char *msg) -{ - if (PyErr_Warn(PyExc_OverflowWarning, msg) < 0) { - if (PyErr_ExceptionMatches(PyExc_OverflowWarning)) - PyErr_SetString(PyExc_OverflowError, msg); - return 1; - } - else - return 0; -} - /* Integers are quite normal objects, to make object handling uniform. (Using odd pointers to represent integers would save much space but require extra checks for this special case throughout the code.) @@ -278,7 +265,6 @@ char *end; long x; char buffer[256]; /* For errors */ - int warn = 0; if ((base != 0 && base < 2) || base > 36) { PyErr_SetString(PyExc_ValueError, @@ -292,7 +278,7 @@ if (base == 0 && s[0] == '0') { x = (long) PyOS_strtoul(s, &end, base); if (x < 0) - warn = 1; + return PyLong_FromString(s, pend, base); } else x = PyOS_strtol(s, &end, base); @@ -307,16 +293,8 @@ PyErr_SetString(PyExc_ValueError, buffer); return NULL; } - else if (errno != 0) { - if (err_ovf("string/unicode conversion")) - return NULL; + else if (errno != 0) return PyLong_FromString(s, pend, base); - } - if (warn) { - if (PyErr_Warn(PyExc_FutureWarning, - "int('0...', 0): sign will change in Python 2.4") < 0) - return NULL; - } if (pend) *pend = end; return PyInt_FromLong(x); @@ -402,8 +380,6 @@ x = a + b; if ((x^a) >= 0 || (x^b) >= 0) return PyInt_FromLong(x); - if (err_ovf("integer addition")) - return NULL; return PyLong_Type.tp_as_number->nb_add((PyObject *)v, (PyObject *)w); } @@ -416,8 +392,6 @@ x = a - b; if ((x^a) >= 0 || (x^~b) >= 0) return PyInt_FromLong(x); - if (err_ovf("integer subtraction")) - return NULL; return PyLong_Type.tp_as_number->nb_subtract((PyObject *)v, (PyObject *)w); } @@ -481,8 +455,6 @@ 32 * absdiff <= absprod -- 5 good bits is "close enough" */ if (32.0 * absdiff <= absprod) return PyInt_FromLong(longprod); - else if (err_ovf("integer multiplication")) - return NULL; else return PyLong_Type.tp_as_number->nb_multiply(v, w); } @@ -507,11 +479,8 @@ return DIVMOD_ERROR; } /* (-sys.maxint-1)/-1 is the only overflow case. */ - if (y == -1 && x < 0 && x == -x) { - if (err_ovf("integer division")) - return DIVMOD_ERROR; + if (y == -1 && x < 0 && x == -x) return DIVMOD_OVERFLOW; - } xdivy = x / y; xmody = x - xdivy * y; /* If the signs of x and y differ, and the remainder is non-0, @@ -660,8 +629,6 @@ if (temp == 0) break; /* Avoid ix / 0 */ if (ix / temp != prev) { - if (err_ovf("integer exponentiation")) - return NULL; return PyLong_Type.tp_as_number->nb_power( (PyObject *)v, (PyObject *)w, @@ -672,9 +639,7 @@ if (iw==0) break; prev = temp; temp *= temp; /* Square the value of temp */ - if (prev!=0 && temp/prev!=prev) { - if (err_ovf("integer exponentiation")) - return NULL; + if (prev != 0 && temp / prev != prev) { return PyLong_Type.tp_as_number->nb_power( (PyObject *)v, (PyObject *)w, (PyObject *)z); } @@ -707,10 +672,7 @@ a = v->ob_ival; x = -a; if (a < 0 && x < 0) { - PyObject *o; - if (err_ovf("integer negation")) - return NULL; - o = PyLong_FromLong(a); + PyObject *o = PyLong_FromLong(a); if (o != NULL) { PyObject *result = PyNumber_Negative(o); Py_DECREF(o); @@ -757,6 +719,8 @@ int_lshift(PyIntObject *v, PyIntObject *w) { long a, b, c; + PyObject *vv, *ww, *result; + CONVERT_TO_LONG(v, a); CONVERT_TO_LONG(w, b); if (b < 0) { @@ -766,18 +730,33 @@ if (a == 0 || b == 0) return int_pos(v); if (b >= LONG_BIT) { - if (PyErr_Warn(PyExc_FutureWarning, - "x< ob_ival; - if (x < 0) { - if (PyErr_Warn(PyExc_FutureWarning, - "hex()/oct() of negative int will return " - "a signed string in Python 2.4 and up") < 0) - return NULL; - } - if (x == 0) + if (x < 0) + PyOS_snprintf(buf, sizeof(buf), "-0%lo", -x); + else if (x == 0) strcpy(buf, "0"); else PyOS_snprintf(buf, sizeof(buf), "0%lo", x); @@ -886,13 +861,10 @@ { char buf[100]; long x = v -> ob_ival; - if (x < 0) { - if (PyErr_Warn(PyExc_FutureWarning, - "hex()/oct() of negative int will return " - "a signed string in Python 2.4 and up") < 0) - return NULL; - } - PyOS_snprintf(buf, sizeof(buf), "0x%lx", x); + if (x < 0) + PyOS_snprintf(buf, sizeof(buf), "-0x%lx", -x); + else + PyOS_snprintf(buf, sizeof(buf), "0x%lx", x); return PyString_FromString(buf); } @@ -944,22 +916,20 @@ if (tmp == NULL) return NULL; if (!PyInt_Check(tmp)) { - if (!PyLong_Check(tmp)) { - PyErr_SetString(PyExc_ValueError, - "value must convertable to an int"); - return NULL; - } ival = PyLong_AsLong(tmp); - if (ival == -1 && PyErr_Occurred()) + if (ival == -1 && PyErr_Occurred()) { + Py_DECREF(tmp); return NULL; - + } } else { ival = ((PyIntObject *)tmp)->ob_ival; } new = type->tp_alloc(type, 0); - if (new == NULL) + if (new == NULL) { + Py_DECREF(tmp); return NULL; + } ((PyIntObject *)new)->ob_ival = ival; Py_DECREF(tmp); return new; @@ -1078,7 +1048,7 @@ int ival; #if NSMALLNEGINTS + NSMALLPOSINTS > 0 for (ival = -NSMALLNEGINTS; ival < NSMALLPOSINTS; ival++) { - if ((free_list = fill_free_list()) == NULL) + if (!free_list && (free_list = fill_free_list()) == NULL) return 0; /* PyObject_New is inlined */ v = free_list; Index: iterobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/iterobject.c,v retrieving revision 1.10.2.1 retrieving revision 1.10.2.2 diff -u -d -r1.10.2.1 -r1.10.2.2 --- iterobject.c 28 Apr 2003 17:18:17 -0000 1.10.2.1 +++ iterobject.c 7 Jan 2005 07:04:02 -0000 1.10.2.2 @@ -71,6 +71,27 @@ return NULL; } +static int +iter_len(seqiterobject *it) +{ + int seqsize, len; + + if (it->it_seq) { + seqsize = PySequence_Size(it->it_seq); + if (seqsize == -1) + return -1; + len = seqsize - it->it_index; + if (len >= 0) + return len; + } + return 0; +} + +static PySequenceMethods iter_as_sequence = { + (inquiry)iter_len, /* sq_length */ + 0, /* sq_concat */ +}; + PyTypeObject PySeqIter_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, /* ob_size */ @@ -85,7 +106,7 @@ 0, /* tp_compare */ 0, /* tp_repr */ 0, /* tp_as_number */ - 0, /* tp_as_sequence */ + &iter_as_sequence, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ @@ -171,18 +192,14 @@ return result; /* Common case, fast path */ Py_DECREF(result); if (ok > 0) { - Py_DECREF(it->it_callable); - it->it_callable = NULL; - Py_DECREF(it->it_sentinel); - it->it_sentinel = NULL; + Py_CLEAR(it->it_callable); + Py_CLEAR(it->it_sentinel); } } else if (PyErr_ExceptionMatches(PyExc_StopIteration)) { PyErr_Clear(); - Py_DECREF(it->it_callable); - it->it_callable = NULL; - Py_DECREF(it->it_sentinel); - it->it_sentinel = NULL; + Py_CLEAR(it->it_callable); + Py_CLEAR(it->it_sentinel); } } return NULL; @@ -211,9 +228,9 @@ 0, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ - 0, /* tp_doc */ - (traverseproc)calliter_traverse, /* tp_traverse */ - 0, /* tp_clear */ + 0, /* tp_doc */ + (traverseproc)calliter_traverse, /* tp_traverse */ + 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ PyObject_SelfIter, /* tp_iter */ Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.114.2.1 retrieving revision 2.114.2.2 diff -u -d -r2.114.2.1 -r2.114.2.2 --- listobject.c 28 Apr 2003 17:18:16 -0000 2.114.2.1 +++ listobject.c 7 Jan 2005 07:04:02 -0000 2.114.2.2 @@ -8,79 +8,112 @@ #include /* For size_t */ #endif +/* Ensure ob_item has room for at least newsize elements, and set + * ob_size to newsize. If newsize > ob_size on entry, the content + * of the new slots at exit is undefined heap trash; it's the caller's + * responsiblity to overwrite them with sane values. + * The number of allocated elements may grow, shrink, or stay the same. + * Failure is impossible if newsize <= self.allocated on entry, although + * that partly relies on an assumption that the system realloc() never + * fails when passed a number of bytes <= the number of bytes last [...1688 lines suppressed...] + 0, /* tp_repr */ + 0, /* tp_as_number */ + &listreviter_as_sequence, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ + 0, /* tp_doc */ + (traverseproc)listreviter_traverse, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + PyObject_SelfIter, /* tp_iter */ + (iternextfunc)listreviter_next, /* tp_iternext */ + 0, +}; Index: longobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/longobject.c,v retrieving revision 1.118.2.1 retrieving revision 1.118.2.2 diff -u -d -r1.118.2.1 -r1.118.2.2 --- longobject.c 28 Apr 2003 17:18:13 -0000 1.118.2.1 +++ longobject.c 7 Jan 2005 07:04:03 -0000 1.118.2.2 @@ -12,7 +12,15 @@ * both operands contain more than KARATSUBA_CUTOFF digits (this * being an internal Python long digit, in base BASE). */ -#define KARATSUBA_CUTOFF 35 +#define KARATSUBA_CUTOFF 70 +#define KARATSUBA_SQUARE_CUTOFF (2 * KARATSUBA_CUTOFF) + +/* For exponentiation, use the binary left-to-right algorithm + * unless the exponent contains more than FIVEARY_CUTOFF digits. + * In that case, do 5 bits at a time. The potential drawback is that + * a table of 2**5 intermediate results is computed. + */ +#define FIVEARY_CUTOFF 8 #define ABS(x) ((x) < 0 ? -(x) : (x)) @@ -237,6 +245,15 @@ int i; if (vv == NULL || !PyLong_Check(vv)) { + if (vv != NULL && PyInt_Check(vv)) { + long val = PyInt_AsLong(vv); + if (val < 0) { + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to unsigned long"); + return (unsigned long) -1; + } + return val; + } PyErr_BadInternalCall(); return (unsigned long) -1; } @@ -271,6 +288,8 @@ int i, sign; if (vv == NULL || !PyLong_Check(vv)) { + if (vv != NULL && PyInt_Check(vv)) + return PyInt_AsUnsignedLongMask(vv); PyErr_BadInternalCall(); return (unsigned long) -1; } @@ -1201,8 +1220,8 @@ bits_in_accum = 0; pdigit = z->ob_digit; while (--p >= start) { - unsigned char ch = (unsigned char)*p; - digit k; + int k; + char ch = *p; if (ch <= '9') k = ch - '0'; @@ -1212,8 +1231,8 @@ assert(ch >= 'A'); k = ch - 'A' + 10; } - assert(k < base); - accum |= k << bits_in_accum; + assert(k >= 0 && k < base); + accum |= (twodigits)(k << bits_in_accum); bits_in_accum += bits_per_char; if (bits_in_accum >= SHIFT) { *pdigit++ = (digit)(accum & MASK); @@ -1440,7 +1459,7 @@ digit zz = (digit) (z >> SHIFT); carry += v->ob_digit[i+k] - z + ((twodigits)zz << SHIFT); - v->ob_digit[i+k] = carry & MASK; + v->ob_digit[i+k] = (digit)(carry & MASK); carry = Py_ARITHMETIC_RIGHT_SHIFT(BASE_TWODIGITS_TYPE, carry, SHIFT); carry -= zz; @@ -1459,7 +1478,7 @@ carry = 0; for (i = 0; i < size_w && i+k < size_v; ++i) { carry += v->ob_digit[i+k] + w->ob_digit[i]; - v->ob_digit[i+k] = carry & MASK; + v->ob_digit[i+k] = (digit)(carry & MASK); carry = Py_ARITHMETIC_RIGHT_SHIFT( BASE_TWODIGITS_TYPE, carry, SHIFT); @@ -1717,26 +1736,72 @@ return NULL; memset(z->ob_digit, 0, z->ob_size * sizeof(digit)); - for (i = 0; i < size_a; ++i) { - twodigits carry = 0; - twodigits f = a->ob_digit[i]; - int j; - digit *pz = z->ob_digit + i; + if (a == b) { + /* Efficient squaring per HAC, Algorithm 14.16: + * http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf + * Gives slightly less than a 2x speedup when a == b, + * via exploiting that each entry in the multiplication + * pyramid appears twice (except for the size_a squares). + */ + for (i = 0; i < size_a; ++i) { + twodigits carry; + twodigits f = a->ob_digit[i]; + digit *pz = z->ob_digit + (i << 1); + digit *pa = a->ob_digit + i + 1; + digit *paend = a->ob_digit + size_a; - SIGCHECK({ - Py_DECREF(z); - return NULL; - }) - for (j = 0; j < size_b; ++j) { - carry += *pz + b->ob_digit[j] * f; - *pz++ = (digit) (carry & MASK); + SIGCHECK({ + Py_DECREF(z); + return NULL; + }) + + carry = *pz + f * f; + *pz++ = (digit)(carry & MASK); carry >>= SHIFT; + assert(carry <= MASK); + + /* Now f is added in twice in each column of the + * pyramid it appears. Same as adding f<<1 once. + */ + f <<= 1; + while (pa < paend) { + carry += *pz + *pa++ * f; + *pz++ = (digit)(carry & MASK); + carry >>= SHIFT; + assert(carry <= (MASK << 1)); + } + if (carry) { + carry += *pz; + *pz++ = (digit)(carry & MASK); + carry >>= SHIFT; + } + if (carry) + *pz += (digit)(carry & MASK); + assert((carry >> SHIFT) == 0); } - for (; carry != 0; ++j) { - assert(i+j < z->ob_size); - carry += *pz; - *pz++ = (digit) (carry & MASK); - carry >>= SHIFT; + } + else { /* a is not the same as b -- gradeschool long mult */ + for (i = 0; i < size_a; ++i) { + twodigits carry = 0; + twodigits f = a->ob_digit[i]; + digit *pz = z->ob_digit + i; + digit *pb = b->ob_digit; + digit *pbend = b->ob_digit + size_b; + + SIGCHECK({ + Py_DECREF(z); + return NULL; + }) + + while (pb < pbend) { + carry += *pz + *pb++ * f; + *pz++ = (digit)(carry & MASK); + carry >>= SHIFT; + assert(carry <= MASK); + } + if (carry) + *pz += (digit)(carry & MASK); + assert((carry >> SHIFT) == 0); } } return long_normalize(z); @@ -1816,7 +1881,8 @@ } /* Use gradeschool math when either number is too small. */ - if (asize <= KARATSUBA_CUTOFF) { + i = a == b ? KARATSUBA_SQUARE_CUTOFF : KARATSUBA_CUTOFF; + if (asize <= i) { if (asize == 0) return _PyLong_New(0); else @@ -1837,7 +1903,13 @@ if (kmul_split(a, shift, &ah, &al) < 0) goto fail; assert(ah->ob_size > 0); /* the split isn't degenerate */ - if (kmul_split(b, shift, &bh, &bl) < 0) goto fail; + if (a == b) { + bh = ah; + bl = al; + Py_INCREF(bh); + Py_INCREF(bl); + } + else if (kmul_split(b, shift, &bh, &bl) < 0) goto fail; /* The plan: * 1. Allocate result space (asize + bsize digits: that's always @@ -1906,7 +1978,11 @@ Py_DECREF(al); ah = al = NULL; - if ((t2 = x_add(bh, bl)) == NULL) { + if (a == b) { + t2 = t1; + Py_INCREF(t2); + } + else if ((t2 = x_add(bh, bl)) == NULL) { Py_DECREF(t1); goto fail; } @@ -2078,6 +2154,12 @@ have different signs. We then subtract one from the 'div' part of the outcome to keep the invariant intact. */ +/* Compute + * *pdiv, *pmod = divmod(v, w) + * NULL can be passed for pdiv or pmod, in which case that part of + * the result is simply thrown away. The caller owns a reference to + * each of these it requests (does not pass NULL for). + */ static int l_divmod(PyLongObject *v, PyLongObject *w, PyLongObject **pdiv, PyLongObject **pmod) @@ -2109,44 +2191,43 @@ Py_DECREF(div); div = temp; } - *pdiv = div; - *pmod = mod; + if (pdiv != NULL) + *pdiv = div; + else + Py_DECREF(div); + + if (pmod != NULL) + *pmod = mod; + else + Py_DECREF(mod); + return 0; } static PyObject * long_div(PyObject *v, PyObject *w) { - PyLongObject *a, *b, *div, *mod; + PyLongObject *a, *b, *div; CONVERT_BINOP(v, w, &a, &b); - - if (l_divmod(a, b, &div, &mod) < 0) { - Py_DECREF(a); - Py_DECREF(b); - return NULL; - } + if (l_divmod(a, b, &div, NULL) < 0) + div = NULL; Py_DECREF(a); Py_DECREF(b); - Py_DECREF(mod); return (PyObject *)div; } static PyObject * long_classic_div(PyObject *v, PyObject *w) { - PyLongObject *a, *b, *div, *mod; + PyLongObject *a, *b, *div; CONVERT_BINOP(v, w, &a, &b); - if (Py_DivisionWarningFlag && PyErr_Warn(PyExc_DeprecationWarning, "classic long division") < 0) div = NULL; - else if (l_divmod(a, b, &div, &mod) < 0) + else if (l_divmod(a, b, &div, NULL) < 0) div = NULL; - else - Py_DECREF(mod); - Py_DECREF(a); Py_DECREF(b); return (PyObject *)div; @@ -2197,18 +2278,14 @@ static PyObject * long_mod(PyObject *v, PyObject *w) { - PyLongObject *a, *b, *div, *mod; + PyLongObject *a, *b, *mod; CONVERT_BINOP(v, w, &a, &b); - if (l_divmod(a, b, &div, &mod) < 0) { - Py_DECREF(a); - Py_DECREF(b); - return NULL; - } + if (l_divmod(a, b, NULL, &mod) < 0) + mod = NULL; Py_DECREF(a); Py_DECREF(b); - Py_DECREF(div); return (PyObject *)mod; } @@ -2239,22 +2316,33 @@ return z; } +/* pow(v, w, x) */ static PyObject * long_pow(PyObject *v, PyObject *w, PyObject *x) { - PyLongObject *a, *b; - PyObject *c; - PyLongObject *z, *div, *mod; - int size_b, i; + PyLongObject *a, *b, *c; /* a,b,c = v,w,x */ + int negativeOutput = 0; /* if x<0 return negative output */ + + PyLongObject *z = NULL; /* accumulated result */ + int i, j, k; /* counters */ + PyLongObject *temp = NULL; + /* 5-ary values. If the exponent is large enough, table is + * precomputed so that table[i] == a**i % c for i in range(32). + */ + PyLongObject *table[32] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + + /* a, b, c = v, w, x */ CONVERT_BINOP(v, w, &a, &b); - if (PyLong_Check(x) || Py_None == x) { - c = x; + if (PyLong_Check(x)) { + c = (PyLongObject *)x; Py_INCREF(x); } - else if (PyInt_Check(x)) { - c = PyLong_FromLong(PyInt_AS_LONG(x)); - } + else if (PyInt_Check(x)) + c = (PyLongObject *)PyLong_FromLong(PyInt_AS_LONG(x)); + else if (x == Py_None) + c = NULL; else { Py_DECREF(a); Py_DECREF(b); @@ -2262,95 +2350,154 @@ return Py_NotImplemented; } - if (c != Py_None && ((PyLongObject *)c)->ob_size == 0) { - PyErr_SetString(PyExc_ValueError, - "pow() 3rd argument cannot be 0"); - z = NULL; - goto error; - } - - size_b = b->ob_size; - if (size_b < 0) { - Py_DECREF(a); - Py_DECREF(b); - Py_DECREF(c); - if (x != Py_None) { + if (b->ob_size < 0) { /* if exponent is negative */ + if (c) { PyErr_SetString(PyExc_TypeError, "pow() 2nd argument " - "cannot be negative when 3rd argument specified"); - return NULL; + "cannot be negative when 3rd argument specified"); + goto Error; + } + else { + /* else return a float. This works because we know + that this calls float_pow() which converts its + arguments to double. */ + Py_DECREF(a); + Py_DECREF(b); + return PyFloat_Type.tp_as_number->nb_power(v, w, x); } - /* Return a float. This works because we know that - this calls float_pow() which converts its - arguments to double. */ - return PyFloat_Type.tp_as_number->nb_power(v, w, x); } - z = (PyLongObject *)PyLong_FromLong(1L); - for (i = 0; i < size_b; ++i) { - digit bi = b->ob_digit[i]; - int j; - for (j = 0; j < SHIFT; ++j) { - PyLongObject *temp; + if (c) { + /* if modulus == 0: + raise ValueError() */ + if (c->ob_size == 0) { + PyErr_SetString(PyExc_ValueError, + "pow() 3rd argument cannot be 0"); + goto Error; + } - if (bi & 1) { - temp = (PyLongObject *)long_mul(z, a); - Py_DECREF(z); - if (c!=Py_None && temp!=NULL) { - if (l_divmod(temp,(PyLongObject *)c, - &div,&mod) < 0) { - Py_DECREF(temp); - z = NULL; - goto error; - } - Py_XDECREF(div); - Py_DECREF(temp); - temp = mod; - } - z = temp; - if (z == NULL) - break; - } - bi >>= 1; - if (bi == 0 && i+1 == size_b) - break; - temp = (PyLongObject *)long_mul(a, a); + /* if modulus < 0: + negativeOutput = True + modulus = -modulus */ + if (c->ob_size < 0) { + negativeOutput = 1; + temp = (PyLongObject *)_PyLong_Copy(c); + if (temp == NULL) + goto Error; + Py_DECREF(c); + c = temp; + temp = NULL; + c->ob_size = - c->ob_size; + } + + /* if modulus == 1: + return 0 */ + if ((c->ob_size == 1) && (c->ob_digit[0] == 1)) { + z = (PyLongObject *)PyLong_FromLong(0L); + goto Done; + } + + /* if base < 0: + base = base % modulus + Having the base positive just makes things easier. */ + if (a->ob_size < 0) { + if (l_divmod(a, c, NULL, &temp) < 0) + goto Error; Py_DECREF(a); - if (c!=Py_None && temp!=NULL) { - if (l_divmod(temp, (PyLongObject *)c, &div, - &mod) < 0) { - Py_DECREF(temp); - z = NULL; - goto error; - } - Py_XDECREF(div); - Py_DECREF(temp); - temp = mod; - } a = temp; - if (a == NULL) { - Py_DECREF(z); - z = NULL; - break; - } + temp = NULL; } - if (a == NULL || z == NULL) - break; } - if (c!=Py_None && z!=NULL) { - if (l_divmod(z, (PyLongObject *)c, &div, &mod) < 0) { - Py_DECREF(z); - z = NULL; + + /* At this point a, b, and c are guaranteed non-negative UNLESS + c is NULL, in which case a may be negative. */ + + z = (PyLongObject *)PyLong_FromLong(1L); + if (z == NULL) + goto Error; + + /* Perform a modular reduction, X = X % c, but leave X alone if c + * is NULL. + */ +#define REDUCE(X) \ + if (c != NULL) { \ + if (l_divmod(X, c, NULL, &temp) < 0) \ + goto Error; \ + Py_XDECREF(X); \ + X = temp; \ + temp = NULL; \ + } + + /* Multiply two values, then reduce the result: + result = X*Y % c. If c is NULL, skip the mod. */ +#define MULT(X, Y, result) \ +{ \ + temp = (PyLongObject *)long_mul(X, Y); \ + if (temp == NULL) \ + goto Error; \ + Py_XDECREF(result); \ + result = temp; \ + temp = NULL; \ + REDUCE(result) \ +} + + if (b->ob_size <= FIVEARY_CUTOFF) { + /* Left-to-right binary exponentiation (HAC Algorithm 14.79) */ + /* http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf */ + for (i = b->ob_size - 1; i >= 0; --i) { + digit bi = b->ob_digit[i]; + + for (j = 1 << (SHIFT-1); j != 0; j >>= 1) { + MULT(z, z, z) + if (bi & j) + MULT(z, a, z) + } } - else { - Py_XDECREF(div); - Py_DECREF(z); - z = mod; + } + else { + /* Left-to-right 5-ary exponentiation (HAC Algorithm 14.82) */ + Py_INCREF(z); /* still holds 1L */ + table[0] = z; + for (i = 1; i < 32; ++i) + MULT(table[i-1], a, table[i]) + + for (i = b->ob_size - 1; i >= 0; --i) { + const digit bi = b->ob_digit[i]; + + for (j = SHIFT - 5; j >= 0; j -= 5) { + const int index = (bi >> j) & 0x1f; + for (k = 0; k < 5; ++k) + MULT(z, z, z) + if (index) + MULT(z, table[index], z) + } } } - error: + + if (negativeOutput && (z->ob_size != 0)) { + temp = (PyLongObject *)long_sub(z, c); + if (temp == NULL) + goto Error; + Py_DECREF(z); + z = temp; + temp = NULL; + } + goto Done; + + Error: + if (z != NULL) { + Py_DECREF(z); + z = NULL; + } + /* fall through */ + Done: Py_XDECREF(a); - Py_DECREF(b); - Py_DECREF(c); + Py_XDECREF(b); + Py_XDECREF(c); + Py_XDECREF(temp); + if (b->ob_size > FIVEARY_CUTOFF) { + for (i = 0; i < 32; ++i) + Py_XDECREF(table[i]); + } return (PyObject *)z; } @@ -2794,8 +2941,10 @@ if (n < 0) n = -n; new = (PyLongObject *)type->tp_alloc(type, n); - if (new == NULL) + if (new == NULL) { + Py_DECREF(tmp); return NULL; + } assert(PyLong_Check(new)); new->ob_size = tmp->ob_size; for (i = 0; i < n; i++) Index: methodobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/methodobject.c,v retrieving revision 2.42.2.1 retrieving revision 2.42.2.2 diff -u -d -r2.42.2.1 -r2.42.2.2 --- methodobject.c 28 Apr 2003 17:18:12 -0000 2.42.2.1 +++ methodobject.c 7 Jan 2005 07:04:03 -0000 2.42.2.2 @@ -67,7 +67,7 @@ PyObject *self = PyCFunction_GET_SELF(func); int size; - switch (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC)) { + switch (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)) { case METH_VARARGS: if (kw == NULL || PyDict_Size(kw) == 0) return (*meth)(self, arg); Index: moduleobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/moduleobject.c,v retrieving revision 2.45 retrieving revision 2.45.2.1 diff -u -d -r2.45 -r2.45.2.1 --- moduleobject.c 13 Jun 2002 20:33:01 -0000 2.45 +++ moduleobject.c 7 Jan 2005 07:04:04 -0000 2.45.2.1 @@ -151,7 +151,7 @@ { static char *kwlist[] = {"name", "doc", NULL}; PyObject *dict, *name = Py_None, *doc = Py_None; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "S|O", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, kwds, "S|O:module.__init__", kwlist, &name, &doc)) return -1; dict = m->md_dict; Index: object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.179.2.2 retrieving revision 2.179.2.3 diff -u -d -r2.179.2.2 -r2.179.2.3 --- object.c 28 Apr 2003 17:18:10 -0000 2.179.2.2 +++ object.c 7 Jan 2005 07:04:04 -0000 2.179.2.3 @@ -3,10 +3,6 @@ #include "Python.h" -#ifdef macintosh -#include "macglue.h" -#endif - #ifdef Py_REF_DEBUG long _Py_RefTotal; #endif @@ -150,6 +146,18 @@ #endif /* Py_REF_DEBUG */ +void +Py_IncRef(PyObject *o) +{ + Py_XINCREF(o); +} + +void +Py_DecRef(PyObject *o) +{ + Py_XDECREF(o); +} + PyObject * PyObject_Init(PyObject *op, PyTypeObject *tp) { @@ -468,7 +476,7 @@ ? (t)->tp_richcompare : NULL) /* Map rich comparison operators to their swapped version, e.g. LT --> GT */ -static int swapped_op[] = {Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, Py_LE}; +int _Py_SwappedOp[] = {Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, Py_LE}; /* Try a genuine rich comparison, returning an object. Return: NULL for exception; @@ -486,7 +494,7 @@ if (v->ob_type != w->ob_type && PyType_IsSubtype(w->ob_type, v->ob_type) && (f = RICHCOMPARE(w->ob_type)) != NULL) { - res = (*f)(w, v, swapped_op[op]); + res = (*f)(w, v, _Py_SwappedOp[op]); if (res != Py_NotImplemented) return res; Py_DECREF(res); @@ -498,7 +506,7 @@ Py_DECREF(res); } if ((f = RICHCOMPARE(w->ob_type)) != NULL) { - return (*f)(w, v, swapped_op[op]); + return (*f)(w, v, _Py_SwappedOp[op]); } res = Py_NotImplemented; Py_INCREF(res); @@ -598,33 +606,28 @@ w->ob_type->tp_compare == _PyObject_SlotCompare) return _PyObject_SlotCompare(v, w); - /* Try coercion; if it fails, give up */ + /* If we're here, v and w, + a) are not instances; + b) have different types or a type without tp_compare; and + c) don't have a user-defined tp_compare. + tp_compare implementations in C assume that both arguments + have their type, so we give up if the coercion fails or if + it yields types which are still incompatible (which can + happen with a user-defined nb_coerce). + */ c = PyNumber_CoerceEx(&v, &w); if (c < 0) return -2; if (c > 0) return 2; - - /* Try v's comparison, if defined */ - if ((f = v->ob_type->tp_compare) != NULL) { + f = v->ob_type->tp_compare; + if (f != NULL && f == w->ob_type->tp_compare) { c = (*f)(v, w); Py_DECREF(v); Py_DECREF(w); return adjust_tp_compare(c); } - /* Try w's comparison, if defined */ - if ((f = w->ob_type->tp_compare) != NULL) { - c = (*f)(w, v); /* swapped! */ - Py_DECREF(v); - Py_DECREF(w); - c = adjust_tp_compare(c); - if (c >= -1) - return -c; /* Swapped! */ - else - return c; - } - /* No comparison defined */ Py_DECREF(v); Py_DECREF(w); @@ -696,8 +699,6 @@ Py_uintptr_t)(w->ob_type)) ? -1 : 1; } -#define CHECK_TYPES(o) PyType_HasFeature((o)->ob_type, Py_TPFLAGS_CHECKTYPES) - /* Do a 3-way comparison, by hook or by crook. Return: -2 for an exception (but see below); -1 if v < w; @@ -740,120 +741,6 @@ return default_3way_compare(v, w); } -/* compare_nesting is incremented before calling compare (for - some types) and decremented on exit. If the count exceeds the - nesting limit, enable code to detect circular data structures. - - This is a tunable parameter that should only affect the performance - of comparisons, nothing else. Setting it high makes comparing deeply - nested non-cyclical data structures faster, but makes comparing cyclical - data structures slower. -*/ -#define NESTING_LIMIT 20 - -static int compare_nesting = 0; - -static PyObject* -get_inprogress_dict(void) -{ - static PyObject *key; - PyObject *tstate_dict, *inprogress; - - if (key == NULL) { - key = PyString_InternFromString("cmp_state"); - if (key == NULL) - return NULL; - } - - tstate_dict = PyThreadState_GetDict(); - if (tstate_dict == NULL) { - PyErr_BadInternalCall(); - return NULL; - } - - inprogress = PyDict_GetItem(tstate_dict, key); - if (inprogress == NULL) { - inprogress = PyDict_New(); - if (inprogress == NULL) - return NULL; - if (PyDict_SetItem(tstate_dict, key, inprogress) == -1) { - Py_DECREF(inprogress); - return NULL; - } - Py_DECREF(inprogress); - } - - return inprogress; -} - -/* If the comparison "v op w" is already in progress in this thread, returns - * a borrowed reference to Py_None (the caller must not decref). - * If it's not already in progress, returns "a token" which must eventually - * be passed to delete_token(). The caller must not decref this either - * (delete_token decrefs it). The token must not survive beyond any point - * where v or w may die. - * If an error occurs (out-of-memory), returns NULL. - */ -static PyObject * -check_recursion(PyObject *v, PyObject *w, int op) -{ - PyObject *inprogress; - PyObject *token; - Py_uintptr_t iv = (Py_uintptr_t)v; - Py_uintptr_t iw = (Py_uintptr_t)w; - PyObject *x, *y, *z; - - inprogress = get_inprogress_dict(); - if (inprogress == NULL) - return NULL; - - token = PyTuple_New(3); - if (token == NULL) - return NULL; - - if (iv <= iw) { - PyTuple_SET_ITEM(token, 0, x = PyLong_FromVoidPtr((void *)v)); - PyTuple_SET_ITEM(token, 1, y = PyLong_FromVoidPtr((void *)w)); - if (op >= 0) - op = swapped_op[op]; - } else { - PyTuple_SET_ITEM(token, 0, x = PyLong_FromVoidPtr((void *)w)); - PyTuple_SET_ITEM(token, 1, y = PyLong_FromVoidPtr((void *)v)); - } - PyTuple_SET_ITEM(token, 2, z = PyInt_FromLong((long)op)); - if (x == NULL || y == NULL || z == NULL) { - Py_DECREF(token); - return NULL; - } - - if (PyDict_GetItem(inprogress, token) != NULL) { - Py_DECREF(token); - return Py_None; /* Without INCREF! */ - } - - if (PyDict_SetItem(inprogress, token, token) < 0) { - Py_DECREF(token); - return NULL; - } - - return token; -} - -static void -delete_token(PyObject *token) -{ - PyObject *inprogress; - - if (token == NULL || token == Py_None) - return; - inprogress = get_inprogress_dict(); - if (inprogress == NULL) - PyErr_Clear(); - else - PyDict_DelItem(inprogress, token); - Py_DECREF(token); -} - /* Compare v to w. Return -1 if v < w or exception (PyErr_Occurred() true in latter case). 0 if v == w. @@ -864,47 +751,18 @@ int PyObject_Compare(PyObject *v, PyObject *w) { - PyTypeObject *vtp; int result; -#if defined(USE_STACKCHECK) - if (PyOS_CheckStack()) { - PyErr_SetString(PyExc_MemoryError, "Stack overflow"); - return -1; - } -#endif if (v == NULL || w == NULL) { PyErr_BadInternalCall(); return -1; } if (v == w) return 0; - vtp = v->ob_type; - compare_nesting++; - if (compare_nesting > NESTING_LIMIT && - (vtp->tp_as_mapping || vtp->tp_as_sequence) && - !PyString_CheckExact(v) && - !PyTuple_CheckExact(v)) { - /* try to detect circular data structures */ - PyObject *token = check_recursion(v, w, -1); - - if (token == NULL) { - result = -1; - } - else if (token == Py_None) { - /* already comparing these objects. assume - they're equal until shown otherwise */ - result = 0; - } - else { - result = do_cmp(v, w); - delete_token(token); - } - } - else { - result = do_cmp(v, w); - } - compare_nesting--; + if (Py_EnterRecursiveCall(" in cmp")) + return -1; + result = do_cmp(v, w); + Py_LeaveRecursiveCall(); return result < 0 ? -1 : result; } @@ -975,41 +833,10 @@ PyObject *res; assert(Py_LT <= op && op <= Py_GE); + if (Py_EnterRecursiveCall(" in cmp")) + return NULL; - compare_nesting++; - if (compare_nesting > NESTING_LIMIT && - (v->ob_type->tp_as_mapping || v->ob_type->tp_as_sequence) && - !PyString_CheckExact(v) && - !PyTuple_CheckExact(v)) { - /* try to detect circular data structures */ - PyObject *token = check_recursion(v, w, op); - if (token == NULL) { - res = NULL; - goto Done; - } - else if (token == Py_None) { - /* already comparing these objects with this operator. - assume they're equal until shown otherwise */ - if (op == Py_EQ) - res = Py_True; - else if (op == Py_NE) - res = Py_False; - else { - PyErr_SetString(PyExc_ValueError, - "can't order recursive values"); - res = NULL; - } - Py_XINCREF(res); - } - else { - res = do_richcmp(v, w, op); - delete_token(token); - } - goto Done; - } - - /* No nesting extremism. - If the types are equal, and not old-style instances, try to + /* If the types are equal, and not old-style instances, try to get out cheap (don't bother with coercions etc.). */ if (v->ob_type == w->ob_type && !PyInstance_Check(v)) { cmpfunc fcmp; @@ -1041,7 +868,7 @@ /* Fast path not taken, or couldn't deliver a useful result. */ res = do_richcmp(v, w, op); Done: - compare_nesting--; + Py_LeaveRecursiveCall(); return res; } @@ -1049,9 +876,19 @@ int PyObject_RichCompareBool(PyObject *v, PyObject *w, int op) { - PyObject *res = PyObject_RichCompare(v, w, op); + PyObject *res; int ok; + /* Quick result when objects are the same. + Guarantees that identity implies equality. */ + if (v == w) { + if (op == Py_EQ) + return 1; + else if (op == Py_NE) + return 0; + } + + res = PyObject_RichCompare(v, w, op); if (res == NULL) return -1; if (PyBool_Check(res)) @@ -1063,7 +900,7 @@ } /* Set of hash utility functions to help maintaining the invariant that - iff a==b then hash(a)==hash(b) + if a==b then hash(a)==hash(b) All the utility functions (_Py_Hash*()) return "-1" to signify an error. */ @@ -1080,15 +917,7 @@ * of mapping keys will turn out weird. */ -#ifdef MPW /* MPW C modf expects pointer to extended as second argument */ -{ - extended e; - fractpart = modf(v, &e); - intpart = e; -} -#else fractpart = modf(v, &intpart); -#endif if (fractpart == 0.0) { /* This must return the same hash as an equal int or long. */ if (intpart > LONG_MAX || -intpart > LONG_MAX) { @@ -1342,8 +1171,6 @@ return (PyObject **) ((char *)obj + dictoffset); } -/* Generic GetAttr functions - put these in your tp_[gs]etattro slot */ - PyObject * PyObject_SelfIter(PyObject *obj) { @@ -1351,6 +1178,8 @@ return obj; } +/* Generic GetAttr functions - put these in your tp_[gs]etattro slot */ + PyObject * PyObject_GenericGetAttr(PyObject *obj, PyObject *name) { @@ -1412,12 +1241,15 @@ } } + Py_XINCREF(descr); + f = NULL; if (descr != NULL && PyType_HasFeature(descr->ob_type, Py_TPFLAGS_HAVE_CLASS)) { f = descr->ob_type->tp_descr_get; if (f != NULL && PyDescr_IsData(descr)) { res = f(descr, obj, (PyObject *)obj->ob_type); + Py_DECREF(descr); goto done; } } @@ -1445,6 +1277,7 @@ res = PyDict_GetItem(dict, name); if (res != NULL) { Py_INCREF(res); + Py_XDECREF(descr); goto done; } } @@ -1452,12 +1285,13 @@ if (f != NULL) { res = f(descr, obj, (PyObject *)obj->ob_type); + Py_DECREF(descr); goto done; } if (descr != NULL) { - Py_INCREF(descr); res = descr; + /* descr was already increfed above */ goto done; } @@ -1780,7 +1614,7 @@ PyObject *locals = PyEval_GetLocals(); if (locals == NULL) goto error; - result = PyDict_Keys(locals); + result = PyMapping_Keys(locals); if (result == NULL) goto error; } @@ -1863,6 +1697,11 @@ } assert(result); + if (!PyList_Check(result)) { + PyErr_SetString(PyExc_TypeError, + "Expected keys() to be a list."); + goto error; + } if (PyList_Sort(result) != 0) goto error; else @@ -1961,6 +1800,9 @@ if (PyType_Ready(&PyType_Type) < 0) Py_FatalError("Can't initialize 'type'"); + if (PyType_Ready(&_PyWeakref_RefType) < 0) + Py_FatalError("Can't initialize 'weakref'"); + if (PyType_Ready(&PyBool_Type) < 0) Py_FatalError("Can't initialize 'bool'"); Index: obmalloc.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/obmalloc.c,v retrieving revision 2.45.2.1 retrieving revision 2.45.2.2 diff -u -d -r2.45.2.1 -r2.45.2.2 --- obmalloc.c 28 Apr 2003 17:18:10 -0000 2.45.2.1 +++ obmalloc.c 7 Jan 2005 07:04:04 -0000 2.45.2.2 @@ -534,8 +534,32 @@ * so the (I) < narenas must be false, saving us from trying to index into * a NULL arenas. */ -#define ADDRESS_IN_RANGE(P, I) \ - ((I) < narenas && (uptr)(P) - arenas[I] < (uptr)ARENA_SIZE) +#define Py_ADDRESS_IN_RANGE(P, POOL) \ + ((POOL)->arenaindex < narenas && \ + (uptr)(P) - arenas[(POOL)->arenaindex] < (uptr)ARENA_SIZE) + +/* This is only useful when running memory debuggers such as + * Purify or Valgrind. Uncomment to use. + * +#define Py_USING_MEMORY_DEBUGGER + */ + +#ifdef Py_USING_MEMORY_DEBUGGER + +/* Py_ADDRESS_IN_RANGE may access uninitialized memory by design + * This leads to thousands of spurious warnings when using + * Purify or Valgrind. By making a function, we can easily + * suppress the uninitialized memory reads in this one function. + * So we won't ignore real errors elsewhere. + * + * Disable the macro and use a function. + */ + +#undef Py_ADDRESS_IN_RANGE + +/* Don't make static, to ensure this isn't inlined. */ +int Py_ADDRESS_IN_RANGE(void *P, poolp pool); +#endif /*==========================================================================*/ @@ -651,9 +675,9 @@ UNLOCK(); return (void *)bp; } - /* - * Allocate new pool - */ + /* + * Allocate new pool + */ if (nfreepools) { commit_pool: --nfreepools; @@ -663,9 +687,9 @@ pool->szidx = DUMMY_SIZE_IDX; goto init_pool; } - /* - * Allocate new arena - */ + /* + * Allocate new arena + */ #ifdef WITH_MEMORY_LIMITS if (!(narenas < MAX_ARENAS)) { UNLOCK(); @@ -708,7 +732,7 @@ return; pool = POOL_ADDR(p); - if (ADDRESS_IN_RANGE(p, pool->arenaindex)) { + if (Py_ADDRESS_IN_RANGE(p, pool)) { /* We allocated this address. */ LOCK(); /* @@ -791,7 +815,7 @@ return PyObject_Malloc(nbytes); pool = POOL_ADDR(p); - if (ADDRESS_IN_RANGE(p, pool->arenaindex)) { + if (Py_ADDRESS_IN_RANGE(p, pool)) { /* We're in charge of this block */ size = INDEX2SIZE(pool->szidx); if (nbytes <= size) { @@ -1373,3 +1397,14 @@ } #endif /* PYMALLOC_DEBUG */ + +#ifdef Py_USING_MEMORY_DEBUGGER +/* Make this function last so gcc won't inline it + since the definition is after the reference. */ +int +Py_ADDRESS_IN_RANGE(void *P, poolp pool) +{ + return ((pool->arenaindex) < narenas && + (uptr)(P) - arenas[pool->arenaindex] < (uptr)ARENA_SIZE); +} +#endif Index: rangeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/rangeobject.c,v retrieving revision 2.41.2.1 retrieving revision 2.41.2.2 diff -u -d -r2.41.2.1 -r2.41.2.2 --- rangeobject.c 28 Apr 2003 17:18:09 -0000 2.41.2.1 +++ rangeobject.c 7 Jan 2005 07:04:04 -0000 2.41.2.2 @@ -9,43 +9,6 @@ long len; } rangeobject; -PyObject * -PyRange_New(long start, long len, long step, int reps) -{ - rangeobject *obj; - - if (reps != 1) { - PyErr_SetString(PyExc_ValueError, - "PyRange_New's 'repetitions' argument must be 1"); - return NULL; - } - - obj = PyObject_New(rangeobject, &PyRange_Type); - if (obj == NULL) - return NULL; - - if (len == 0) { - start = 0; - len = 0; - step = 1; - } - else { - long last = start + (len - 1) * step; - if ((step > 0) ? - (last > (PyInt_GetMax() - step)) : - (last < (-1 - PyInt_GetMax() - step))) { - PyErr_SetString(PyExc_OverflowError, - "integer addition"); - return NULL; - } - } - obj->start = start; - obj->len = len; - obj->step = step; - - return (PyObject *) obj; -} - /* Return number of items in range/xrange (lo, hi, step). step > 0 * required. Return a value < 0 if & only if the true value is too * large to fit in a signed long. @@ -78,6 +41,7 @@ static PyObject * range_new(PyTypeObject *type, PyObject *args, PyObject *kw) { + rangeobject *obj; long ilow = 0, ihigh = 0, istep = 1; long n; @@ -106,7 +70,14 @@ "xrange() result has too many items"); return NULL; } - return PyRange_New(ilow, n, istep, 1); + + obj = PyObject_New(rangeobject, &PyRange_Type); + if (obj == NULL) + return NULL; + obj->start = ilow; + obj->len = n; + obj->step = istep; + return (PyObject *) obj; } PyDoc_STRVAR(range_doc, @@ -144,7 +115,7 @@ range_repr(rangeobject *r) { PyObject *rtn; - + if (r->start == 0 && r->step == 1) rtn = PyString_FromFormat("xrange(%ld)", r->start + r->len * r->step); @@ -171,6 +142,15 @@ }; static PyObject * range_iter(PyObject *seq); +static PyObject * range_reverse(PyObject *seq); + +PyDoc_STRVAR(reverse_doc, +"Returns a reverse iterator."); + +static PyMethodDef range_methods[] = { + {"__reversed__", (PyCFunction)range_reverse, METH_NOARGS, reverse_doc}, + {NULL, NULL} /* sentinel */ +}; PyTypeObject PyRange_Type = { PyObject_HEAD_INIT(&PyType_Type) @@ -201,7 +181,7 @@ 0, /* tp_weaklistoffset */ (getiterfunc)range_iter, /* tp_iter */ 0, /* tp_iternext */ - 0, /* tp_methods */ + range_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ @@ -246,13 +226,51 @@ } static PyObject * +range_reverse(PyObject *seq) +{ + rangeiterobject *it; + long start, step, len; + + if (!PyRange_Check(seq)) { + PyErr_BadInternalCall(); + return NULL; + } + it = PyObject_New(rangeiterobject, &Pyrangeiter_Type); + if (it == NULL) + return NULL; + + start = ((rangeobject *)seq)->start; + step = ((rangeobject *)seq)->step; + len = ((rangeobject *)seq)->len; + + it->index = 0; + it->start = start + (len-1) * step; + it->step = -step; + it->len = len; + + return (PyObject *)it; +} + +static PyObject * rangeiter_next(rangeiterobject *r) { - if (r->index < r->len) + if (r->index < r->len) return PyInt_FromLong(r->start + (r->index++) * r->step); return NULL; } +static int +rangeiter_len(rangeiterobject *r) +{ + return r->len - r->index; +} + +static PySequenceMethods rangeiter_as_sequence = { + (inquiry)rangeiter_len, /* sq_length */ + 0, /* sq_concat */ +}; + + static PyTypeObject Pyrangeiter_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, /* ob_size */ @@ -267,7 +285,7 @@ 0, /* tp_compare */ 0, /* tp_repr */ 0, /* tp_as_number */ - 0, /* tp_as_sequence */ + &rangeiter_as_sequence, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ Index: sliceobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/sliceobject.c,v retrieving revision 2.15.2.1 retrieving revision 2.15.2.2 diff -u -d -r2.15.2.1 -r2.15.2.2 --- sliceobject.c 28 Apr 2003 17:18:08 -0000 2.15.2.1 +++ sliceobject.c 7 Jan 2005 07:04:05 -0000 2.15.2.2 @@ -278,6 +278,13 @@ return result; } +static long +slice_hash(PySliceObject *v) +{ + PyErr_SetString(PyExc_TypeError, "unhashable type"); + return -1L; +} + PyTypeObject PySlice_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, /* Number of items for varobject */ @@ -293,7 +300,7 @@ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ - 0, /* tp_hash */ + (hashfunc)slice_hash, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.168.2.1 retrieving revision 2.168.2.2 diff -u -d -r2.168.2.1 -r2.168.2.2 --- stringobject.c 28 Apr 2003 17:18:07 -0000 2.168.2.1 +++ stringobject.c 7 Jan 2005 07:04:05 -0000 2.168.2.2 @@ -8,10 +8,6 @@ int null_strings, one_strings; #endif -#if !defined(HAVE_LIMITS_H) && !defined(UCHAR_MAX) -#define UCHAR_MAX 255 -#endif - static PyStringObject *characters[UCHAR_MAX + 1]; static PyStringObject *nullstring; @@ -74,8 +70,7 @@ } /* Inline PyObject_NewVar */ - op = (PyStringObject *) - PyObject_MALLOC(sizeof(PyStringObject) + size * sizeof(char)); + op = (PyStringObject *)PyObject_MALLOC(sizeof(PyStringObject) + size); if (op == NULL) return PyErr_NoMemory(); PyObject_INIT_VAR(op, &PyString_Type, size); @@ -130,8 +125,7 @@ } /* Inline PyObject_NewVar */ - op = (PyStringObject *) - PyObject_MALLOC(sizeof(PyStringObject) + size * sizeof(char)); + op = (PyStringObject *)PyObject_MALLOC(sizeof(PyStringObject) + size); if (op == NULL) return PyErr_NoMemory(); PyObject_INIT_VAR(op, &PyString_Type, size); @@ -803,7 +797,7 @@ PyString_Repr(PyObject *obj, int smartquotes) { register PyStringObject* op = (PyStringObject*) obj; - size_t newsize = 2 + 4 * op->ob_size * sizeof(char); + size_t newsize = 2 + 4 * op->ob_size; PyObject *v; if (newsize > INT_MAX) { PyErr_SetString(PyExc_OverflowError, @@ -915,8 +909,7 @@ } size = a->ob_size + b->ob_size; /* Inline PyObject_NewVar */ - op = (PyStringObject *) - PyObject_MALLOC(sizeof(PyStringObject) + size * sizeof(char)); + op = (PyStringObject *)PyObject_MALLOC(sizeof(PyStringObject) + size); if (op == NULL) return PyErr_NoMemory(); PyObject_INIT_VAR(op, &PyString_Type, size); @@ -952,9 +945,8 @@ Py_INCREF(a); return (PyObject *)a; } - nbytes = size * sizeof(char); - if (nbytes / sizeof(char) != (size_t)size || - nbytes + sizeof(PyStringObject) <= nbytes) { + nbytes = (size_t)size; + if (nbytes + sizeof(PyStringObject) <= nbytes) { PyErr_SetString(PyExc_OverflowError, "repeated string is too long"); return NULL; @@ -1286,12 +1278,35 @@ #define STRIPNAME(i) (stripformat[i]+3) +#define SPLIT_APPEND(data, left, right) \ + str = PyString_FromStringAndSize((data) + (left), \ + (right) - (left)); \ + if (str == NULL) \ + goto onError; \ + if (PyList_Append(list, str)) { \ + Py_DECREF(str); \ + goto onError; \ + } \ + else \ + Py_DECREF(str); + +#define SPLIT_INSERT(data, left, right) \ + str = PyString_FromStringAndSize((data) + (left), \ + (right) - (left)); \ + if (str == NULL) \ + goto onError; \ + if (PyList_Insert(list, 0, str)) { \ + Py_DECREF(str); \ + goto onError; \ + } \ + else \ + Py_DECREF(str); static PyObject * split_whitespace(const char *s, int len, int maxsplit) { - int i, j, err; - PyObject* item; + int i, j; + PyObject *str; PyObject *list = PyList_New(0); if (list == NULL) @@ -1306,33 +1321,49 @@ if (j < i) { if (maxsplit-- <= 0) break; - item = PyString_FromStringAndSize(s+j, (int)(i-j)); - if (item == NULL) - goto finally; - err = PyList_Append(list, item); - Py_DECREF(item); - if (err < 0) - goto finally; + SPLIT_APPEND(s, j, i); while (i < len && isspace(Py_CHARMASK(s[i]))) i++; j = i; } } if (j < len) { - item = PyString_FromStringAndSize(s+j, (int)(len - j)); - if (item == NULL) - goto finally; - err = PyList_Append(list, item); - Py_DECREF(item); - if (err < 0) - goto finally; + SPLIT_APPEND(s, j, len); } return list; - finally: + onError: Py_DECREF(list); return NULL; } +static PyObject * +split_char(const char *s, int len, char ch, int maxcount) +{ + register int i, j; + PyObject *str; + PyObject *list = PyList_New(0); + + if (list == NULL) + return NULL; + + for (i = j = 0; i < len; ) { + if (s[i] == ch) { + if (maxcount-- <= 0) + break; + SPLIT_APPEND(s, j, i); + i = j = i + 1; + } else + i++; + } + if (j <= len) { + SPLIT_APPEND(s, j, len); + } + return list; + + onError: + Py_DECREF(list); + return NULL; +} PyDoc_STRVAR(split__doc__, "S.split([sep [,maxsplit]]) -> list of strings\n\ @@ -1366,10 +1397,13 @@ #endif else if (PyObject_AsCharBuffer(subobj, &sub, &n)) return NULL; + if (n == 0) { PyErr_SetString(PyExc_ValueError, "empty separator"); return NULL; } + else if (n == 1) + return split_char(s, len, sub[0], maxsplit); list = PyList_New(0); if (list == NULL) @@ -1407,6 +1441,148 @@ return NULL; } +static PyObject * +rsplit_whitespace(const char *s, int len, int maxsplit) +{ + int i, j; + PyObject *str; + PyObject *list = PyList_New(0); + + if (list == NULL) + return NULL; + + for (i = j = len - 1; i >= 0; ) { + while (i >= 0 && isspace(Py_CHARMASK(s[i]))) + i--; + j = i; + while (i >= 0 && !isspace(Py_CHARMASK(s[i]))) + i--; + if (j > i) { + if (maxsplit-- <= 0) + break; + SPLIT_INSERT(s, i + 1, j + 1); + while (i >= 0 && isspace(Py_CHARMASK(s[i]))) + i--; + j = i; + } + } + if (j >= 0) { + SPLIT_INSERT(s, 0, j + 1); + } + return list; + onError: + Py_DECREF(list); + return NULL; +} + +static PyObject * +rsplit_char(const char *s, int len, char ch, int maxcount) +{ + register int i, j; + PyObject *str; + PyObject *list = PyList_New(0); + + if (list == NULL) + return NULL; + + for (i = j = len - 1; i >= 0; ) { + if (s[i] == ch) { + if (maxcount-- <= 0) + break; + SPLIT_INSERT(s, i + 1, j + 1); + j = i = i - 1; + } else + i--; + } + if (j >= -1) { + SPLIT_INSERT(s, 0, j + 1); + } + return list; + + onError: + Py_DECREF(list); + return NULL; +} + +PyDoc_STRVAR(rsplit__doc__, +"S.rsplit([sep [,maxsplit]]) -> list of strings\n\ +\n\ +Return a list of the words in the string S, using sep as the\n\ +delimiter string, starting at the end of the string and working\n\ +to the front. If maxsplit is given, at most maxsplit splits are\n\ +done. If sep is not specified or is None, any whitespace string\n\ +is a separator."); + +static PyObject * +string_rsplit(PyStringObject *self, PyObject *args) +{ + int len = PyString_GET_SIZE(self), n, i, j, err; + int maxsplit = -1; + const char *s = PyString_AS_STRING(self), *sub; + PyObject *list, *item, *subobj = Py_None; + + if (!PyArg_ParseTuple(args, "|Oi:rsplit", &subobj, &maxsplit)) + return NULL; + if (maxsplit < 0) + maxsplit = INT_MAX; + if (subobj == Py_None) + return rsplit_whitespace(s, len, maxsplit); + if (PyString_Check(subobj)) { + sub = PyString_AS_STRING(subobj); + n = PyString_GET_SIZE(subobj); + } +#ifdef Py_USING_UNICODE + else if (PyUnicode_Check(subobj)) + return PyUnicode_RSplit((PyObject *)self, subobj, maxsplit); +#endif + else if (PyObject_AsCharBuffer(subobj, &sub, &n)) + return NULL; + + if (n == 0) { + PyErr_SetString(PyExc_ValueError, "empty separator"); + return NULL; + } + else if (n == 1) + return rsplit_char(s, len, sub[0], maxsplit); + + list = PyList_New(0); + if (list == NULL) + return NULL; + + j = len; + i = j - n; + while (i >= 0) { + if (s[i] == sub[0] && memcmp(s+i, sub, n) == 0) { + if (maxsplit-- <= 0) + break; + item = PyString_FromStringAndSize(s+i+n, (int)(j-i-n)); + if (item == NULL) + goto fail; + err = PyList_Insert(list, 0, item); + Py_DECREF(item); + if (err < 0) + goto fail; + j = i; + i -= n; + } + else + i--; + } + item = PyString_FromStringAndSize(s, j); + if (item == NULL) + goto fail; + err = PyList_Insert(list, 0, item); + Py_DECREF(item); + if (err < 0) + goto fail; + + return list; + + fail: + Py_DECREF(list); + return NULL; +} + PyDoc_STRVAR(join__doc__, "S.join(sequence) -> string\n\ @@ -1442,22 +1618,18 @@ } if (seqlen == 1) { item = PySequence_Fast_GET_ITEM(seq, 0); - if (!PyString_Check(item) && !PyUnicode_Check(item)) { - PyErr_Format(PyExc_TypeError, - "sequence item 0: expected string," - " %.80s found", - item->ob_type->tp_name); + if (PyString_CheckExact(item) || PyUnicode_CheckExact(item)) { + Py_INCREF(item); Py_DECREF(seq); - return NULL; + return item; } - Py_INCREF(item); - Py_DECREF(seq); - return item; } - /* There are at least two things to join. Do a pre-pass to figure out - * the total amount of space we'll need (sz), see whether any argument - * is absurd, and defer to the Unicode join if appropriate. + /* There are at least two things to join, or else we have a subclass + * of the builtin types in the sequence. + * Do a pre-pass to figure out the total amount of space we'll + * need (sz), see whether any argument is absurd, and defer to + * the Unicode join if appropriate. */ for (i = 0; i < seqlen; i++) { const size_t old_sz = sz; @@ -2308,11 +2480,11 @@ PyDoc_STRVAR(replace__doc__, -"S.replace (old, new[, maxsplit]) -> string\n\ +"S.replace (old, new[, count]) -> string\n\ \n\ Return a copy of string S with all occurrences of substring\n\ -old replaced by new. If the optional argument maxsplit is\n\ -given, only the first maxsplit occurrences are replaced."); +old replaced by new. If the optional argument count is\n\ +given, only the first count occurrences are replaced."); static PyObject * string_replace(PyStringObject *self, PyObject *args) @@ -2497,9 +2669,25 @@ { char *encoding = NULL; char *errors = NULL; + PyObject *v; + if (!PyArg_ParseTuple(args, "|ss:encode", &encoding, &errors)) return NULL; - return PyString_AsEncodedObject((PyObject *)self, encoding, errors); + v = PyString_AsEncodedObject((PyObject *)self, encoding, errors); + if (v == NULL) + goto onError; + if (!PyString_Check(v) && !PyUnicode_Check(v)) { + PyErr_Format(PyExc_TypeError, + "encoder did not return a string/unicode object " + "(type=%.400s)", + v->ob_type->tp_name); + Py_DECREF(v); + return NULL; + } + return v; + + onError: + return NULL; } @@ -2518,9 +2706,25 @@ { char *encoding = NULL; char *errors = NULL; + PyObject *v; + if (!PyArg_ParseTuple(args, "|ss:decode", &encoding, &errors)) return NULL; - return PyString_AsDecodedObject((PyObject *)self, encoding, errors); + v = PyString_AsDecodedObject((PyObject *)self, encoding, errors); + if (v == NULL) + goto onError; + if (!PyString_Check(v) && !PyUnicode_Check(v)) { + PyErr_Format(PyExc_TypeError, + "decoder did not return a string/unicode object " + "(type=%.400s)", + v->ob_type->tp_name); + Py_DECREF(v); + return NULL; + } + return v; + + onError: + return NULL; } @@ -2617,16 +2821,18 @@ } PyDoc_STRVAR(ljust__doc__, -"S.ljust(width) -> string\n" +"S.ljust(width[, fillchar]) -> string\n" "\n" "Return S left justified in a string of length width. Padding is\n" -"done using spaces."); +"done using the specified fill character (default is a space)."); static PyObject * string_ljust(PyStringObject *self, PyObject *args) { int width; - if (!PyArg_ParseTuple(args, "i:ljust", &width)) + char fillchar = ' '; + + if (!PyArg_ParseTuple(args, "i|c:ljust", &width, &fillchar)) return NULL; if (PyString_GET_SIZE(self) >= width && PyString_CheckExact(self)) { @@ -2634,21 +2840,23 @@ return (PyObject*) self; } - return pad(self, 0, width - PyString_GET_SIZE(self), ' '); + return pad(self, 0, width - PyString_GET_SIZE(self), fillchar); } PyDoc_STRVAR(rjust__doc__, -"S.rjust(width) -> string\n" +"S.rjust(width[, fillchar]) -> string\n" "\n" "Return S right justified in a string of length width. Padding is\n" -"done using spaces."); +"done using the specified fill character (default is a space)"); static PyObject * string_rjust(PyStringObject *self, PyObject *args) { int width; - if (!PyArg_ParseTuple(args, "i:rjust", &width)) + char fillchar = ' '; + + if (!PyArg_ParseTuple(args, "i|c:rjust", &width, &fillchar)) return NULL; if (PyString_GET_SIZE(self) >= width && PyString_CheckExact(self)) { @@ -2656,23 +2864,24 @@ return (PyObject*) self; } - return pad(self, width - PyString_GET_SIZE(self), 0, ' '); + return pad(self, width - PyString_GET_SIZE(self), 0, fillchar); } PyDoc_STRVAR(center__doc__, -"S.center(width) -> string\n" +"S.center(width[, fillchar]) -> string\n" "\n" -"Return S centered in a string of length width. Padding is done\n" -"using spaces."); +"Return S centered in a string of length width. Padding is\n" +"done using the specified fill character (default is a space)"); static PyObject * string_center(PyStringObject *self, PyObject *args) { int marg, left; int width; + char fillchar = ' '; - if (!PyArg_ParseTuple(args, "i:center", &width)) + if (!PyArg_ParseTuple(args, "i|c:center", &width, &fillchar)) return NULL; if (PyString_GET_SIZE(self) >= width && PyString_CheckExact(self)) { @@ -2683,7 +2892,7 @@ marg = width - PyString_GET_SIZE(self); left = marg / 2 + (marg & width & 1); - return pad(self, left, marg - left, ' '); + return pad(self, left, marg - left, fillchar); } PyDoc_STRVAR(zfill__doc__, @@ -2733,10 +2942,10 @@ } PyDoc_STRVAR(isspace__doc__, -"S.isspace() -> bool\n" -"\n" -"Return True if there are only whitespace characters in S,\n" -"False otherwise."); +"S.isspace() -> bool\n\ +\n\ +Return True if all characters in S are whitespace\n\ +and there is at least one character in S, False otherwise."); static PyObject* string_isspace(PyStringObject *self) @@ -2766,7 +2975,7 @@ PyDoc_STRVAR(isalpha__doc__, "S.isalpha() -> bool\n\ \n\ -Return True if all characters in S are alphabetic\n\ +Return True if all characters in S are alphabetic\n\ and there is at least one character in S, False otherwise."); static PyObject* @@ -2797,7 +3006,7 @@ PyDoc_STRVAR(isalnum__doc__, "S.isalnum() -> bool\n\ \n\ -Return True if all characters in S are alphanumeric\n\ +Return True if all characters in S are alphanumeric\n\ and there is at least one character in S, False otherwise."); static PyObject* @@ -2828,8 +3037,8 @@ PyDoc_STRVAR(isdigit__doc__, "S.isdigit() -> bool\n\ \n\ -Return True if there are only digit characters in S,\n\ -False otherwise."); +Return True if all characters in S are digits\n\ +and there is at least one character in S, False otherwise."); static PyObject* string_isdigit(PyStringObject *self) @@ -2893,7 +3102,7 @@ PyDoc_STRVAR(isupper__doc__, "S.isupper() -> bool\n\ \n\ -Return True if all cased characters in S are uppercase and there is\n\ +Return True if all cased characters in S are uppercase and there is\n\ at least one cased character in S, False otherwise."); static PyObject* @@ -2927,9 +3136,10 @@ PyDoc_STRVAR(istitle__doc__, "S.istitle() -> bool\n\ \n\ -Return True if S is a titlecased string, i.e. uppercase characters\n\ -may only follow uncased characters and lowercase characters only cased\n\ -ones. Return False otherwise."); +Return True if S is a titlecased string and there is at least one\n\ +character in S, i.e. uppercase characters may only follow uncased\n\ +characters and lowercase characters only cased ones. Return False\n\ +otherwise."); static PyObject* string_istitle(PyStringObject *self, PyObject *uncased) @@ -2979,17 +3189,6 @@ Line breaks are not included in the resulting list unless keepends\n\ is given and true."); -#define SPLIT_APPEND(data, left, right) \ - str = PyString_FromStringAndSize(data + left, right - left); \ - if (!str) \ - goto onError; \ - if (PyList_Append(list, str)) { \ - Py_DECREF(str); \ - goto onError; \ - } \ - else \ - Py_DECREF(str); - static PyObject* string_splitlines(PyStringObject *self, PyObject *args) { @@ -3058,6 +3257,7 @@ string.maketrans(). */ {"join", (PyCFunction)string_join, METH_O, join__doc__}, {"split", (PyCFunction)string_split, METH_VARARGS, split__doc__}, + {"rsplit", (PyCFunction)string_rsplit, METH_VARARGS, rsplit__doc__}, {"lower", (PyCFunction)string_lower, METH_NOARGS, lower__doc__}, {"upper", (PyCFunction)string_upper, METH_NOARGS, upper__doc__}, {"islower", (PyCFunction)string_islower, METH_NOARGS, islower__doc__}, @@ -3309,7 +3509,8 @@ register PyObject *v; register PyStringObject *sv; v = *pv; - if (!PyString_Check(v) || v->ob_refcnt != 1 || newsize < 0) { + if (!PyString_Check(v) || v->ob_refcnt != 1 || newsize < 0 || + PyString_CHECK_INTERNED(v)) { *pv = 0; Py_DECREF(v); PyErr_BadInternalCall(); @@ -3319,8 +3520,7 @@ _Py_DEC_REFTOTAL; _Py_ForgetReference(v); *pv = (PyObject *) - PyObject_REALLOC((char *)v, - sizeof(PyStringObject) + newsize * sizeof(char)); + PyObject_REALLOC((char *)v, sizeof(PyStringObject) + newsize); if (*pv == NULL) { PyObject_Del(v); PyErr_NoMemory(); @@ -3330,6 +3530,7 @@ sv = (PyStringObject *) *pv; sv->ob_size = newsize; sv->ob_sval[newsize] = '\0'; + sv->ob_shash = -1; /* invalidate cached hash value */ return 0; } @@ -3406,7 +3607,7 @@ PyOS_snprintf(fmt, sizeof(fmt), "%%%s.%d%c", (flags&F_ALT) ? "#" : "", prec, type); - PyOS_snprintf(buf, buflen, fmt, x); + PyOS_ascii_formatd(buf, buflen, fmt, x); return strlen(buf); } @@ -3559,6 +3760,7 @@ worst case length = 3 + 19 (worst len of INT_MAX on 64-bit machine) + 1 + 1 = 24 */ char fmt[64]; /* plenty big enough! */ + char *sign; long x; x = PyInt_AsLong(v); @@ -3566,12 +3768,13 @@ PyErr_SetString(PyExc_TypeError, "int argument required"); return -1; } - if (x < 0 && type != 'd' && type != 'i') { - if (PyErr_Warn(PyExc_FutureWarning, - "%u/%o/%x/%X of negative int will return " - "a signed string in Python 2.4 and up") < 0) - return -1; + if (x < 0 && type == 'u') { + type = 'd'; } + if (x < 0 && (type == 'x' || type == 'X' || type == 'o')) + sign = "-"; + else + sign = ""; if (prec < 0) prec = 1; @@ -3597,24 +3800,27 @@ * Note that this is the same approach as used in * formatint() in unicodeobject.c */ - PyOS_snprintf(fmt, sizeof(fmt), "0%c%%.%dl%c", - type, prec, type); + PyOS_snprintf(fmt, sizeof(fmt), "%s0%c%%.%dl%c", + sign, type, prec, type); } else { - PyOS_snprintf(fmt, sizeof(fmt), "%%%s.%dl%c", - (flags&F_ALT) ? "#" : "", + PyOS_snprintf(fmt, sizeof(fmt), "%s%%%s.%dl%c", + sign, (flags&F_ALT) ? "#" : "", prec, type); } - /* buf = '+'/'-'/'0'/'0x' + '[0-9]'*max(prec, len(x in octal)) - * worst case buf = '0x' + [0-9]*prec, where prec >= 11 + /* buf = '+'/'-'/'' + '0'/'0x'/'' + '[0-9]'*max(prec, len(x in octal)) + * worst case buf = '-0x' + [0-9]*prec, where prec >= 11 */ - if (buflen <= 13 || buflen <= (size_t)2 + (size_t)prec) { + if (buflen <= 14 || buflen <= (size_t)3 + (size_t)prec) { PyErr_SetString(PyExc_OverflowError, "formatted integer is too long (precision too large?)"); return -1; } - PyOS_snprintf(buf, buflen, fmt, x); + if (sign[0]) + PyOS_snprintf(buf, buflen, fmt, -x); + else + PyOS_snprintf(buf, buflen, fmt, x); return strlen(buf); } @@ -3867,7 +4073,7 @@ } #endif /* Fall through */ - case 'r': + case 'r': if (c == 's') temp = PyObject_Str(v); else @@ -3901,8 +4107,6 @@ prec, c, &pbuf, &len); if (!temp) goto error; - /* unbounded ints can always produce - a sign character! */ sign = 1; } else { @@ -3912,8 +4116,7 @@ flags, prec, c, v); if (len < 0) goto error; - /* only d conversion is signed */ - sign = c == 'd'; + sign = 1; } if (flags & F_ZERO) fill = '0'; @@ -3921,8 +4124,11 @@ case 'e': case 'E': case 'f': + case 'F': case 'g': case 'G': + if (c == 'F') + c = 'f'; pbuf = formatbuf; len = formatfloat(pbuf, sizeof(formatbuf), flags, prec, c, v); @@ -4105,6 +4311,10 @@ PyObject *t; if (s == NULL || !PyString_Check(s)) Py_FatalError("PyString_InternInPlace: strings only please!"); + /* If it's a string subclass, we don't really know what putting + it in the interned dict might do. */ + if (!PyString_CheckExact(s)) + return; if (PyString_CHECK_INTERNED(s)) return; if (interned == NULL) { @@ -4114,36 +4324,22 @@ return; } } - if ((t = PyDict_GetItem(interned, (PyObject *)s)) != NULL) { + t = PyDict_GetItem(interned, (PyObject *)s); + if (t) { Py_INCREF(t); Py_DECREF(*p); *p = t; return; } - /* Ensure that only true string objects appear in the intern dict */ - if (!PyString_CheckExact(s)) { - t = PyString_FromStringAndSize(PyString_AS_STRING(s), - PyString_GET_SIZE(s)); - if (t == NULL) { - PyErr_Clear(); - return; - } - } else { - t = (PyObject*) s; - Py_INCREF(t); - } - if (PyDict_SetItem(interned, t, t) == 0) { - /* The two references in interned are not counted by - refcnt. The string deallocator will take care of this */ - ((PyObject *)t)->ob_refcnt-=2; - PyString_CHECK_INTERNED(t) = SSTATE_INTERNED_MORTAL; - Py_DECREF(*p); - *p = t; + if (PyDict_SetItem(interned, (PyObject *)s, (PyObject *)s) < 0) { + PyErr_Clear(); return; } - Py_DECREF(t); - PyErr_Clear(); + /* The two references in interned are not counted by refcnt. + The string deallocator will take care of this */ + s->ob_refcnt -= 2; + PyString_CHECK_INTERNED(s) = SSTATE_INTERNED_MORTAL; } void Index: tupleobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/tupleobject.c,v retrieving revision 2.68.2.1 retrieving revision 2.68.2.2 diff -u -d -r2.68.2.1 -r2.68.2.2 --- tupleobject.c 28 Apr 2003 17:18:06 -0000 2.68.2.1 +++ tupleobject.c 7 Jan 2005 07:04:06 -0000 2.68.2.2 @@ -27,6 +27,7 @@ PyTuple_New(register int size) { register PyTupleObject *op; + int i; if (size < 0) { PyErr_BadInternalCall(); return NULL; @@ -40,9 +41,7 @@ #endif return (PyObject *) op; } - if (0 < size && size < MAXSAVESIZE && - (op = free_tuples[size]) != NULL) - { + if (size < MAXSAVESIZE && (op = free_tuples[size]) != NULL) { free_tuples[size] = (PyTupleObject *) op->ob_item[0]; num_free_tuples[size]--; #ifdef COUNT_ALLOCS @@ -70,7 +69,8 @@ if (op == NULL) return NULL; } - memset(op->ob_item, 0, sizeof(*op->ob_item) * size); + for (i=0; i < size; i++) + op->ob_item[i] = NULL; #if MAXSAVESIZE > 0 if (size == 0) { free_tuples[0] = op; @@ -130,6 +130,30 @@ return 0; } +PyObject * +PyTuple_Pack(int n, ...) +{ + int i; + PyObject *o; + PyObject *result; + PyObject **items; + va_list vargs; + + va_start(vargs, n); + result = PyTuple_New(n); + if (result == NULL) + return NULL; + items = ((PyTupleObject *)result)->ob_item; + for (i = 0; i < n; i++) { + o = va_arg(vargs, PyObject *); + Py_INCREF(o); + items[i] = o; + } + va_end(vargs); + return result; +} + + /* Methods */ static void @@ -232,21 +256,31 @@ return result; } +/* The addend 82520, was selected from the range(0, 1000000) for + generating the greatest number of prime multipliers for tuples + upto length eight: + + 1082527, 1165049, 1082531, 1165057, 1247581, 1330103, 1082533, + 1330111, 1412633, 1165069, 1247599, 1495177, 1577699 +*/ + static long tuplehash(PyTupleObject *v) { register long x, y; register int len = v->ob_size; register PyObject **p; + long mult = 1000003L; x = 0x345678L; p = v->ob_item; while (--len >= 0) { y = PyObject_Hash(*p++); if (y == -1) return -1; - x = (1000003*x) ^ y; + x = (x ^ y) * mult; + mult += 82520L + len + len; } - x ^= v->ob_size; + x += 97531L; if (x == -1) x = -2; return x; @@ -284,7 +318,9 @@ tupleslice(register PyTupleObject *a, register int ilow, register int ihigh) { register PyTupleObject *np; + PyObject **src, **dest; register int i; + int len; if (ilow < 0) ilow = 0; if (ihigh > a->ob_size) @@ -295,13 +331,16 @@ Py_INCREF(a); return (PyObject *)a; } - np = (PyTupleObject *)PyTuple_New(ihigh - ilow); + len = ihigh - ilow; + np = (PyTupleObject *)PyTuple_New(len); if (np == NULL) return NULL; - for (i = ilow; i < ihigh; i++) { - PyObject *v = a->ob_item[i]; + src = a->ob_item + ilow; + dest = np->ob_item; + for (i = 0; i < len; i++) { + PyObject *v = src[i]; Py_INCREF(v); - np->ob_item[i - ilow] = v; + dest[i] = v; } return (PyObject *)np; } @@ -321,6 +360,7 @@ { register int size; register int i; + PyObject **src, **dest; PyTupleObject *np; if (!PyTuple_Check(bb)) { PyErr_Format(PyExc_TypeError, @@ -336,15 +376,19 @@ if (np == NULL) { return NULL; } + src = a->ob_item; + dest = np->ob_item; for (i = 0; i < a->ob_size; i++) { - PyObject *v = a->ob_item[i]; + PyObject *v = src[i]; Py_INCREF(v); - np->ob_item[i] = v; + dest[i] = v; } + src = b->ob_item; + dest = np->ob_item + a->ob_size; for (i = 0; i < b->ob_size; i++) { - PyObject *v = b->ob_item[i]; + PyObject *v = src[i]; Py_INCREF(v); - np->ob_item[i + a->ob_size] = v; + dest[i] = v; } return (PyObject *)np; #undef b @@ -356,7 +400,7 @@ int i, j; int size; PyTupleObject *np; - PyObject **p; + PyObject **p, **items; if (n < 0) n = 0; if (a->ob_size == 0 || n == 1) { @@ -376,9 +420,10 @@ if (np == NULL) return NULL; p = np->ob_item; + items = a->ob_item; for (i = 0; i < n; i++) { for (j = 0; j < a->ob_size; j++) { - *p = a->ob_item[j]; + *p = items[j]; Py_INCREF(*p); p++; } @@ -557,6 +602,7 @@ int start, stop, step, slicelength, cur, i; PyObject* result; PyObject* it; + PyObject **src, **dest; if (PySlice_GetIndicesEx((PySliceObject*)item, PyTuple_GET_SIZE(self), @@ -570,11 +616,13 @@ else { result = PyTuple_New(slicelength); + src = self->ob_item; + dest = ((PyTupleObject *)result)->ob_item; for (cur = start, i = 0; i < slicelength; cur += step, i++) { - it = PyTuple_GET_ITEM(self, cur); + it = src[cur]; Py_INCREF(it); - PyTuple_SET_ITEM(result, i, it); + dest[i] = it; } return result; @@ -753,8 +801,6 @@ PyErr_BadInternalCall(); return NULL; } - if (seq->ob_type->tp_as_sequence->sq_item != (intargfunc)tupleitem) - return PySeqIter_New(seq); it = PyObject_GC_New(tupleiterobject, &PyTupleIter_Type); if (it == NULL) return NULL; @@ -805,6 +851,19 @@ return NULL; } +static int +tupleiter_len(tupleiterobject *it) +{ + if (it->it_seq) + return PyTuple_GET_SIZE(it->it_seq) - it->it_index; + return 0; +} + +static PySequenceMethods tupleiter_as_sequence = { + (inquiry)tupleiter_len, /* sq_length */ + 0, /* sq_concat */ +}; + PyTypeObject PyTupleIter_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, /* ob_size */ @@ -819,7 +878,7 @@ 0, /* tp_compare */ 0, /* tp_repr */ 0, /* tp_as_number */ - 0, /* tp_as_sequence */ + &tupleiter_as_sequence, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.157.2.2 retrieving revision 2.157.2.3 diff -u -d -r2.157.2.2 -r2.157.2.3 --- typeobject.c 20 Mar 2004 19:46:51 -0000 2.157.2.2 +++ typeobject.c 7 Jan 2005 07:04:06 -0000 2.157.2.3 @@ -87,6 +87,10 @@ if (type->tp_flags & Py_TPFLAGS_HEAPTYPE) { mod = PyDict_GetItemString(type->tp_dict, "__module__"); + if (!mod) { + PyErr_Format(PyExc_AttributeError, "__module__"); + return 0; + } Py_XINCREF(mod); return mod; } @@ -163,7 +167,7 @@ } else { PyObject* tuple; - tuple = Py_BuildValue("OO", subclass, old_mro); + tuple = PyTuple_Pack(2, subclass, old_mro); Py_DECREF(old_mro); if (!tuple) return -1; @@ -258,8 +262,8 @@ for (i = 0; i < PyList_Size(temp); i++) { PyTypeObject* cls; PyObject* mro; - PyArg_ParseTuple(PyList_GET_ITEM(temp, i), - "OO", &cls, &mro); + PyArg_UnpackTuple(PyList_GET_ITEM(temp, i), + "", 2, 2, &cls, &mro); Py_DECREF(cls->tp_mro); cls->tp_mro = mro; Py_INCREF(cls->tp_mro); @@ -303,13 +307,16 @@ return r; bail: + Py_DECREF(type->tp_bases); + Py_DECREF(type->tp_base); + if (type->tp_mro != old_mro) { + Py_DECREF(type->tp_mro); + } + type->tp_bases = old_bases; type->tp_base = old_base; type->tp_mro = old_mro; - Py_DECREF(value); - Py_DECREF(new_base); - return -1; } @@ -636,17 +643,37 @@ ++_PyTrash_delete_nesting; Py_TRASHCAN_SAFE_BEGIN(self); --_PyTrash_delete_nesting; - _PyObject_GC_TRACK(self); /* We'll untrack for real later */ + /* DO NOT restore GC tracking at this point. weakref callbacks + * (if any, and whether directly here or indirectly in something we + * call) may trigger GC, and if self is tracked at that point, it + * will look like trash to GC and GC will try to delete self again. + */ + + /* Find the nearest base with a different tp_dealloc */ + base = type; + while ((basedealloc = base->tp_dealloc) == subtype_dealloc) { + base = base->tp_base; + assert(base); + } + + /* If we added a weaklist, we clear it. Do this *before* calling + the finalizer (__del__), clearing slots, or clearing the instance + dict. */ + + if (type->tp_weaklistoffset && !base->tp_weaklistoffset) + PyObject_ClearWeakRefs(self); /* Maybe call finalizer; exit early if resurrected */ if (type->tp_del) { + _PyObject_GC_TRACK(self); type->tp_del(self); if (self->ob_refcnt > 0) - goto endlabel; + goto endlabel; /* resurrected */ + else + _PyObject_GC_UNTRACK(self); } - /* Find the nearest base with a different tp_dealloc - and clear slots while we're at it */ + /* Clear slots up to the nearest base with a different tp_dealloc */ base = type; while ((basedealloc = base->tp_dealloc) == subtype_dealloc) { if (base->ob_size) @@ -667,15 +694,11 @@ } } - /* If we added weaklist, we clear it */ - if (type->tp_weaklistoffset && !base->tp_weaklistoffset) - PyObject_ClearWeakRefs(self); - - /* Finalize GC if the base doesn't do GC and we do */ - if (!PyType_IS_GC(base)) - _PyObject_GC_UNTRACK(self); - - /* Call the base tp_dealloc() */ + /* Call the base tp_dealloc(); first retrack self if + * basedealloc knows about gc. + */ + if (PyType_IS_GC(base)) + _PyObject_GC_TRACK(self); assert(basedealloc); basedealloc(self); @@ -713,6 +736,16 @@ trashcan begin GC track + Q. Why did the last question say "immediately GC-track again"? + It's nowhere near immediately. + + A. Because the code *used* to re-track immediately. Bad Idea. + self has a refcount of 0, and if gc ever gets its hands on it + (which can happen if any weakref callback gets invoked), it + looks like trash to gc too, and gc also tries to delete self + then. But we're already deleting self. Double dealloction is + a subtle disaster. + Q. Why the bizarre (net-zero) manipulation of _PyTrash_delete_nesting around the trashcan macros? @@ -1594,7 +1627,7 @@ /* Adjust for empty tuple bases */ if (nbases == 0) { - bases = Py_BuildValue("(O)", &PyBaseObject_Type); + bases = PyTuple_Pack(1, &PyBaseObject_Type); if (bases == NULL) return NULL; nbases = 1; @@ -1606,12 +1639,15 @@ /* Calculate best base, and check that all bases are type objects */ base = best_base(bases); - if (base == NULL) + if (base == NULL) { + Py_DECREF(bases); return NULL; + } if (!PyType_HasFeature(base, Py_TPFLAGS_BASETYPE)) { PyErr_Format(PyExc_TypeError, "type '%.100s' is not an acceptable base type", base->tp_name); + Py_DECREF(bases); return NULL; } @@ -1635,22 +1671,24 @@ /* Make it into a tuple */ if (PyString_Check(slots)) - slots = Py_BuildValue("(O)", slots); + slots = PyTuple_Pack(1, slots); else slots = PySequence_Tuple(slots); - if (slots == NULL) + if (slots == NULL) { + Py_DECREF(bases); return NULL; + } assert(PyTuple_Check(slots)); /* Are slots allowed? */ nslots = PyTuple_GET_SIZE(slots); - if (nslots > 0 && base->tp_itemsize != 0 && !PyType_Check(base)) { - /* for the special case of meta types, allow slots */ + if (nslots > 0 && base->tp_itemsize != 0) { PyErr_Format(PyExc_TypeError, "nonempty __slots__ " "not supported for subtype of '%s'", base->tp_name); bad_slots: + Py_DECREF(bases); Py_DECREF(slots); return NULL; } @@ -1756,6 +1794,7 @@ type = (PyTypeObject *)metatype->tp_alloc(metatype, nslots); if (type == NULL) { Py_XDECREF(slots); + Py_DECREF(bases); return NULL; } @@ -1986,6 +2025,7 @@ return meta_get(meta_attribute, (PyObject *)type, (PyObject *)metatype); } + Py_INCREF(meta_attribute); } /* No data descriptor found on metatype. Look in tp_dict of this @@ -1994,6 +2034,9 @@ if (attribute != NULL) { /* Implement descriptor functionality, if any */ descrgetfunc local_get = attribute->ob_type->tp_descr_get; + + Py_XDECREF(meta_attribute); + if (local_get != NULL) { /* NULL 2nd argument indicates the descriptor was * found on the target object itself (or a base) */ @@ -2007,13 +2050,16 @@ /* No attribute found in local __dict__ (or bases): use the * descriptor from the metatype, if any */ - if (meta_get != NULL) - return meta_get(meta_attribute, (PyObject *)type, - (PyObject *)metatype); + if (meta_get != NULL) { + PyObject *res; + res = meta_get(meta_attribute, (PyObject *)type, + (PyObject *)metatype); + Py_DECREF(meta_attribute); + return res; + } /* If an ordinary attribute was found on the metatype, return it now */ if (meta_attribute != NULL) { - Py_INCREF(meta_attribute); return meta_attribute; } @@ -2529,8 +2575,11 @@ if (getstate != NULL) { state = PyObject_CallObject(getstate, NULL); Py_DECREF(getstate); + if (state == NULL) + goto end; } else { + PyErr_Clear(); state = PyObject_GetAttrString(obj, "__dict__"); if (state == NULL) { PyErr_Clear(); @@ -2611,8 +2660,7 @@ PyTuple_SET_ITEM(args2, i+1, v); } - res = Py_BuildValue("(OOOOO)", - newobj, args2, state, listitems, dictitems); + res = PyTuple_Pack(5, newobj, args2, state, listitems, dictitems); end: Py_XDECREF(cls); @@ -2743,8 +2791,9 @@ for (; meth->ml_name != NULL; meth++) { PyObject *descr; - if (PyDict_GetItemString(dict, meth->ml_name)) - continue; + if (PyDict_GetItemString(dict, meth->ml_name) && + !(meth->ml_flags & METH_COEXIST)) + continue; if (meth->ml_flags & METH_CLASS) { if (meth->ml_flags & METH_STATIC) { PyErr_SetString(PyExc_ValueError, @@ -3038,8 +3087,25 @@ COPYSLOT(tp_dictoffset); COPYSLOT(tp_init); COPYSLOT(tp_alloc); - COPYSLOT(tp_free); COPYSLOT(tp_is_gc); + if ((type->tp_flags & Py_TPFLAGS_HAVE_GC) == + (base->tp_flags & Py_TPFLAGS_HAVE_GC)) { + /* They agree about gc. */ + COPYSLOT(tp_free); + } + else if ((type->tp_flags & Py_TPFLAGS_HAVE_GC) && + type->tp_free == NULL && + base->tp_free == _PyObject_Del) { + /* A bit of magic to plug in the correct default + * tp_free function when a derived class adds gc, + * didn't define tp_free, and the base uses the + * default non-gc tp_free. + */ + type->tp_free = PyObject_GC_Del; + } + /* else they didn't agree about gc, and there isn't something + * obvious to be done -- the type is on its own. + */ } } @@ -3071,8 +3137,10 @@ /* Initialize tp_base (defaults to BaseObject unless that's us) */ base = type->tp_base; - if (base == NULL && type != &PyBaseObject_Type) + if (base == NULL && type != &PyBaseObject_Type) { base = type->tp_base = &PyBaseObject_Type; + Py_INCREF(base); + } /* Initialize the base class */ if (base && base->tp_dict == NULL) { @@ -3092,7 +3160,7 @@ if (base == NULL) bases = PyTuple_New(0); else - bases = Py_BuildValue("(O)", base); + bases = PyTuple_Pack(1, base); if (bases == NULL) goto error; type->tp_bases = bases; @@ -3143,6 +3211,19 @@ inherit_slots(type, (PyTypeObject *)b); } + /* Sanity check for tp_free. */ + if (PyType_IS_GC(type) && (type->tp_flags & Py_TPFLAGS_BASETYPE) && + (type->tp_free == NULL || type->tp_free == PyObject_Del)) { + /* This base class needs to call tp_free, but doesn't have + * one, or its tp_free is for non-gc'ed objects. + */ + PyErr_Format(PyExc_TypeError, "type '%.100s' participates in " + "gc and is a base type but has inappropriate " + "tp_free slot", + type->tp_name); + goto error; + } + /* if the type dictionary doesn't contain a __doc__, set it from the tp_doc slot. */ @@ -3240,6 +3321,22 @@ } } +static int +check_num_args(PyObject *ob, int n) +{ + if (!PyTuple_CheckExact(ob)) { + PyErr_SetString(PyExc_SystemError, + "PyArg_UnpackTuple() argument list is not a tuple"); + return 0; + } + if (n == PyTuple_GET_SIZE(ob)) + return 1; + PyErr_Format( + PyExc_TypeError, + "expected %d arguments, got %d", n, PyTuple_GET_SIZE(ob)); + return 0; +} + /* Generic wrappers for overloadable 'operators' such as __getitem__ */ /* There's a wrapper *function* for each distinct function typedef used @@ -3254,7 +3351,7 @@ inquiry func = (inquiry)wrapped; int res; - if (!PyArg_ParseTuple(args, "")) + if (!check_num_args(args, 0)) return NULL; res = (*func)(self); if (res == -1 && PyErr_Occurred()) @@ -3263,13 +3360,28 @@ } static PyObject * +wrap_inquirypred(PyObject *self, PyObject *args, void *wrapped) +{ + inquiry func = (inquiry)wrapped; + int res; + + if (!check_num_args(args, 0)) + return NULL; + res = (*func)(self); + if (res == -1 && PyErr_Occurred()) + return NULL; + return PyBool_FromLong((long)res); +} + +static PyObject * wrap_binaryfunc(PyObject *self, PyObject *args, void *wrapped) { binaryfunc func = (binaryfunc)wrapped; PyObject *other; - if (!PyArg_ParseTuple(args, "O", &other)) + if (!check_num_args(args, 1)) return NULL; + other = PyTuple_GET_ITEM(args, 0); return (*func)(self, other); } @@ -3279,8 +3391,9 @@ binaryfunc func = (binaryfunc)wrapped; PyObject *other; - if (!PyArg_ParseTuple(args, "O", &other)) + if (!check_num_args(args, 1)) return NULL; + other = PyTuple_GET_ITEM(args, 0); if (!(self->ob_type->tp_flags & Py_TPFLAGS_CHECKTYPES) && !PyType_IsSubtype(other->ob_type, self->ob_type)) { Py_INCREF(Py_NotImplemented); @@ -3295,8 +3408,9 @@ binaryfunc func = (binaryfunc)wrapped; PyObject *other; - if (!PyArg_ParseTuple(args, "O", &other)) + if (!check_num_args(args, 1)) return NULL; + other = PyTuple_GET_ITEM(args, 0); if (!(self->ob_type->tp_flags & Py_TPFLAGS_CHECKTYPES) && !PyType_IsSubtype(other->ob_type, self->ob_type)) { Py_INCREF(Py_NotImplemented); @@ -3312,8 +3426,9 @@ PyObject *other, *res; int ok; - if (!PyArg_ParseTuple(args, "O", &other)) + if (!check_num_args(args, 1)) return NULL; + other = PyTuple_GET_ITEM(args, 0); ok = func(&self, &other); if (ok < 0) return NULL; @@ -3341,7 +3456,7 @@ /* Note: This wrapper only works for __pow__() */ - if (!PyArg_ParseTuple(args, "O|O", &other, &third)) + if (!PyArg_UnpackTuple(args, "", 1, 2, &other, &third)) return NULL; return (*func)(self, other, third); } @@ -3355,7 +3470,7 @@ /* Note: This wrapper only works for __pow__() */ - if (!PyArg_ParseTuple(args, "O|O", &other, &third)) + if (!PyArg_UnpackTuple(args, "", 1, 2, &other, &third)) return NULL; return (*func)(other, self, third); } @@ -3365,7 +3480,7 @@ { unaryfunc func = (unaryfunc)wrapped; - if (!PyArg_ParseTuple(args, "")) + if (!check_num_args(args, 0)) return NULL; return (*func)(self); } @@ -3415,7 +3530,7 @@ return NULL; return (*func)(self, i); } - PyArg_ParseTuple(args, "O", &arg); + check_num_args(args, 1); assert(PyErr_Occurred()); return NULL; } @@ -3438,7 +3553,7 @@ int i, res; PyObject *arg, *value; - if (!PyArg_ParseTuple(args, "OO", &arg, &value)) + if (!PyArg_UnpackTuple(args, "", 2, 2, &arg, &value)) return NULL; i = getindex(self, arg); if (i == -1 && PyErr_Occurred()) @@ -3457,8 +3572,9 @@ int i, res; PyObject *arg; - if (!PyArg_ParseTuple(args, "O", &arg)) + if (!check_num_args(args, 1)) return NULL; + arg = PyTuple_GET_ITEM(args, 0); i = getindex(self, arg); if (i == -1 && PyErr_Occurred()) return NULL; @@ -3508,12 +3624,14 @@ int res; PyObject *value; - if (!PyArg_ParseTuple(args, "O", &value)) + if (!check_num_args(args, 1)) return NULL; + value = PyTuple_GET_ITEM(args, 0); res = (*func)(self, value); if (res == -1 && PyErr_Occurred()) return NULL; - return PyInt_FromLong((long)res); + else + return PyBool_FromLong(res); } static PyObject * @@ -3523,7 +3641,7 @@ int res; PyObject *key, *value; - if (!PyArg_ParseTuple(args, "OO", &key, &value)) + if (!PyArg_UnpackTuple(args, "", 2, 2, &key, &value)) return NULL; res = (*func)(self, key, value); if (res == -1 && PyErr_Occurred()) @@ -3539,8 +3657,9 @@ int res; PyObject *key; - if (!PyArg_ParseTuple(args, "O", &key)) + if (!check_num_args(args, 1)) return NULL; + key = PyTuple_GET_ITEM(args, 0); res = (*func)(self, key, NULL); if (res == -1 && PyErr_Occurred()) return NULL; @@ -3555,8 +3674,9 @@ int res; PyObject *other; - if (!PyArg_ParseTuple(args, "O", &other)) + if (!check_num_args(args, 1)) return NULL; + other = PyTuple_GET_ITEM(args, 0); if (other->ob_type->tp_compare != func && !PyType_IsSubtype(other->ob_type, self->ob_type)) { PyErr_Format( @@ -3598,7 +3718,7 @@ int res; PyObject *name, *value; - if (!PyArg_ParseTuple(args, "OO", &name, &value)) + if (!PyArg_UnpackTuple(args, "", 2, 2, &name, &value)) return NULL; if (!hackcheck(self, func, "__setattr__")) return NULL; @@ -3616,8 +3736,9 @@ int res; PyObject *name; - if (!PyArg_ParseTuple(args, "O", &name)) + if (!check_num_args(args, 1)) return NULL; + name = PyTuple_GET_ITEM(args, 0); if (!hackcheck(self, func, "__delattr__")) return NULL; res = (*func)(self, name, NULL); @@ -3633,7 +3754,7 @@ hashfunc func = (hashfunc)wrapped; long res; - if (!PyArg_ParseTuple(args, "")) + if (!check_num_args(args, 0)) return NULL; res = (*func)(self); if (res == -1 && PyErr_Occurred()) @@ -3655,8 +3776,9 @@ richcmpfunc func = (richcmpfunc)wrapped; PyObject *other; - if (!PyArg_ParseTuple(args, "O", &other)) + if (!check_num_args(args, 1)) return NULL; + other = PyTuple_GET_ITEM(args, 0); return (*func)(self, other, op); } @@ -3681,7 +3803,7 @@ unaryfunc func = (unaryfunc)wrapped; PyObject *res; - if (!PyArg_ParseTuple(args, "")) + if (!check_num_args(args, 0)) return NULL; res = (*func)(self); if (res == NULL && !PyErr_Occurred()) @@ -3696,7 +3818,7 @@ PyObject *obj; PyObject *type = NULL; - if (!PyArg_ParseTuple(args, "O|O", &obj, &type)) + if (!PyArg_UnpackTuple(args, "", 1, 2, &obj, &type)) return NULL; if (obj == Py_None) obj = NULL; @@ -3717,7 +3839,7 @@ PyObject *obj, *value; int ret; - if (!PyArg_ParseTuple(args, "OO", &obj, &value)) + if (!PyArg_UnpackTuple(args, "", 2, 2, &obj, &value)) return NULL; ret = (*func)(self, obj, value); if (ret < 0) @@ -3733,8 +3855,9 @@ PyObject *obj; int ret; - if (!PyArg_ParseTuple(args, "O", &obj)) + if (!check_num_args(args, 1)) return NULL; + obj = PyTuple_GET_ITEM(args, 0); ret = (*func)(self, obj, NULL); if (ret < 0) return NULL; @@ -3827,7 +3950,12 @@ func = PyCFunction_New(tp_new_methoddef, (PyObject *)type); if (func == NULL) return -1; - return PyDict_SetItemString(type->tp_dict, "__new__", func); + if (PyDict_SetItemString(type->tp_dict, "__new__", func)) { + Py_DECREF(func); + return -1; + } + Py_DECREF(func); + return 0; } /* Slot wrappers that call the corresponding __foo__ slot. See comments @@ -4049,7 +4177,7 @@ func = lookup_maybe(self, "__contains__", &contains_str); if (func != NULL) { - args = Py_BuildValue("(O)", value); + args = PyTuple_Pack(1, value); if (args == NULL) res = NULL; else { @@ -4149,7 +4277,15 @@ PyObject *temp = PyObject_Call(func, args, NULL); Py_DECREF(args); if (temp != NULL) { - result = PyObject_IsTrue(temp); + if (PyInt_CheckExact(temp) || PyBool_Check(temp)) + result = PyObject_IsTrue(temp); + else { + PyErr_Format(PyExc_TypeError, + "__nonzero__ should return " + "bool or int, returned %s", + temp->ob_type->tp_name); + result = -1; + } Py_DECREF(temp); } } @@ -4256,7 +4392,7 @@ PyErr_Clear(); } else { - args = Py_BuildValue("(O)", other); + args = PyTuple_Pack(1, other); if (args == NULL) res = NULL; else { @@ -4485,7 +4621,7 @@ Py_INCREF(Py_NotImplemented); return Py_NotImplemented; } - args = Py_BuildValue("(O)", other); + args = PyTuple_Pack(1, other); if (args == NULL) res = NULL; else { @@ -4496,9 +4632,6 @@ return res; } -/* Map rich comparison operators to their swapped version, e.g. LT --> GT */ -static int swapped_op[] = {Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, Py_LE}; - static PyObject * slot_tp_richcompare(PyObject *self, PyObject *other, int op) { @@ -4511,7 +4644,7 @@ Py_DECREF(res); } if (other->ob_type->tp_richcompare == slot_tp_richcompare) { - res = half_richcompare(other, self, swapped_op[op]); + res = half_richcompare(other, self, _Py_SwappedOp[op]); if (res != Py_NotImplemented) { return res; } @@ -4697,10 +4830,11 @@ } assert(!PyType_IS_GC(self->ob_type) || _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED); - /* If Py_REF_DEBUG, the original decref dropped _Py_RefTotal, but - * _Py_NewReference bumped it again, so that's a wash. - * If Py_TRACE_REFS, _Py_NewReference re-added self to the object - * chain, so no more to do there either. + /* If Py_REF_DEBUG, _Py_NewReference bumped _Py_RefTotal, so + * we need to undo that. */ + _Py_DEC_REFTOTAL; + /* If Py_TRACE_REFS, _Py_NewReference re-added self to the object + * chain, so no more to do there. * If COUNT_ALLOCS, the original decref bumped tp_frees, and * _Py_NewReference bumped tp_allocs: both of those need to be * undone. @@ -4775,16 +4909,22 @@ SQSLOT("__getitem__", sq_item, slot_sq_item, wrap_sq_item, "x.__getitem__(y) <==> x[y]"), SQSLOT("__getslice__", sq_slice, slot_sq_slice, wrap_intintargfunc, - "x.__getslice__(i, j) <==> x[i:j]"), + "x.__getslice__(i, j) <==> x[i:j]\n\ + \n\ + Use of negative indices is not supported."), SQSLOT("__setitem__", sq_ass_item, slot_sq_ass_item, wrap_sq_setitem, "x.__setitem__(i, y) <==> x[i]=y"), SQSLOT("__delitem__", sq_ass_item, slot_sq_ass_item, wrap_sq_delitem, "x.__delitem__(y) <==> del x[y]"), SQSLOT("__setslice__", sq_ass_slice, slot_sq_ass_slice, wrap_intintobjargproc, - "x.__setslice__(i, j, y) <==> x[i:j]=y"), + "x.__setslice__(i, j, y) <==> x[i:j]=y\n\ + \n\ + Use of negative indices is not supported."), SQSLOT("__delslice__", sq_ass_slice, slot_sq_ass_slice, wrap_delslice, - "x.__delslice__(i, j) <==> del x[i:j]"), + "x.__delslice__(i, j) <==> del x[i:j]\n\ + \n\ + Use of negative indices is not supported."), SQSLOT("__contains__", sq_contains, slot_sq_contains, wrap_objobjproc, "x.__contains__(y) <==> y in x"), SQSLOT("__iadd__", sq_inplace_concat, slot_sq_inplace_concat, @@ -4836,7 +4976,7 @@ UNSLOT("__pos__", nb_positive, slot_nb_positive, wrap_unaryfunc, "+x"), UNSLOT("__abs__", nb_absolute, slot_nb_absolute, wrap_unaryfunc, "abs(x)"), - UNSLOT("__nonzero__", nb_nonzero, slot_nb_nonzero, wrap_inquiry, + UNSLOT("__nonzero__", nb_nonzero, slot_nb_nonzero, wrap_inquirypred, "x != 0"), UNSLOT("__invert__", nb_invert, slot_nb_invert, wrap_unaryfunc, "~x"), BINSLOT("__lshift__", nb_lshift, slot_nb_lshift, "<<"), @@ -5080,7 +5220,7 @@ sanity checks and constructing a new argument list. Cut all that nonsense short -- this speeds up instance creation tremendously. */ - specific = type->tp_new; + specific = (void *)type->tp_new; /* XXX I'm not 100% sure that there isn't a hole in this reasoning that requires additional sanity checks. I'll buy the first person to @@ -5320,7 +5460,7 @@ {"__self__", T_OBJECT, offsetof(superobject, obj), READONLY, "the instance invoking super(); may be None"}, {"__self_class__", T_OBJECT, offsetof(superobject, obj_type), READONLY, - "the type of the the instance invoking super(); may be None"}, + "the type of the instance invoking super(); may be None"}, {0} }; @@ -5400,7 +5540,15 @@ Py_INCREF(res); f = res->ob_type->tp_descr_get; if (f != NULL) { - tmp = f(res, su->obj, + tmp = f(res, + /* Only pass 'obj' param if + this is instance-mode super + (See SF ID #743627) + */ + (su->obj == (PyObject *) + su->obj_type + ? (PyObject *)NULL + : su->obj), (PyObject *)starttype); Py_DECREF(res); res = tmp; @@ -5488,7 +5636,7 @@ return self; } if (su->ob_type != &PySuper_Type) - /* If su is an instance of a subclass of super, + /* If su is not an instance of a subclass of super, call its type */ return PyObject_CallFunction((PyObject *)su->ob_type, "OO", su->type, obj); Index: unicodectype.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodectype.c,v retrieving revision 2.11.18.1 retrieving revision 2.11.18.2 diff -u -d -r2.11.18.1 -r2.11.18.2 --- unicodectype.c 28 Apr 2003 17:18:02 -0000 2.11.18.1 +++ unicodectype.c 7 Jan 2005 07:04:07 -0000 2.11.18.2 @@ -21,12 +21,12 @@ #define UPPER_MASK 0x80 typedef struct { - const unsigned short flags; const Py_UNICODE upper; const Py_UNICODE lower; const Py_UNICODE title; const unsigned char decimal; const unsigned char digit; + const unsigned short flags; } _PyUnicode_TypeRecord; #include "unicodetype_db.h" @@ -36,9 +36,12 @@ { int index; +#ifdef Py_UNICODE_WIDE if (code >= 0x110000) index = 0; - else { + else +#endif + { index = index1[(code>>SHIFT)]; index = index2[(index< according to the @@ -53,7 +53,7 @@ The implementation will keep allocated Unicode memory intact for all objects on the free list having a size less than this - limit. This reduces malloc() overhead for small Unicode objects. + limit. This reduces malloc() overhead for small Unicode objects. [...2608 lines suppressed...] + } pnew->str = PyMem_NEW(Py_UNICODE, n+1); if (pnew->str == NULL) { _Py_ForgetReference((PyObject *)pnew); PyObject_Del(pnew); + Py_DECREF(tmp); return PyErr_NoMemory(); } Py_UNICODE_COPY(pnew->str, tmp->str, n+1); @@ -6769,3 +7271,10 @@ unicode_freelist = NULL; unicode_freelist_size = 0; } + +/* +Local variables: +c-basic-offset: 4 +indent-tabs-mode: nil +End: +*/ Index: unicodetype_db.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/unicodetype_db.h,v retrieving revision 1.4.26.1 retrieving revision 1.4.26.2 diff -u -d -r1.4.26.1 -r1.4.26.2 --- unicodetype_db.h 28 Apr 2003 17:17:59 -0000 1.4.26.1 +++ unicodetype_db.h 7 Jan 2005 07:04:10 -0000 1.4.26.2 @@ -1,132 +1,132 @@ -/* this file was generated by Tools/unicode/makeunicodedata.py 2.2 */ +/* this file was generated by Tools/unicode/makeunicodedata.py 2.3 */ /* a list of unique character type descriptors */ const _PyUnicode_TypeRecord _PyUnicode_TypeRecords[] = { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, - {32, 0, 0, 0, 0, 0}, - {48, 0, 0, 0, 0, 0}, - {6, 0, 0, 0, 0, 0}, - {6, 0, 0, 0, 1, 1}, - {6, 0, 0, 0, 2, 2}, - {6, 0, 0, 0, 3, 3}, - {6, 0, 0, 0, 4, 4}, - {6, 0, 0, 0, 5, 5}, - {6, 0, 0, 0, 6, 6}, - {6, 0, 0, 0, 7, 7}, - {6, 0, 0, 0, 8, 8}, - {6, 0, 0, 0, 9, 9}, - {129, 0, 32, 0, 0, 0}, - {9, 65504, 0, 65504, 0, 0}, - {9, 0, 0, 0, 0, 0}, - {9, 743, 0, 743, 0, 0}, - {9, 121, 0, 121, 0, 0}, - {129, 0, 1, 0, 0, 0}, - {9, 65535, 0, 65535, 0, 0}, - {129, 0, 65337, 0, 0, 0}, - {9, 65304, 0, 65304, 0, 0}, - {129, 0, 65415, 0, 0, 0}, - {9, 65236, 0, 65236, 0, 0}, - {129, 0, 210, 0, 0, 0}, - {129, 0, 206, 0, 0, 0}, - {129, 0, 205, 0, 0, 0}, - {129, 0, 79, 0, 0, 0}, - {129, 0, 202, 0, 0, 0}, - {129, 0, 203, 0, 0, 0}, - {129, 0, 207, 0, 0, 0}, - {9, 97, 0, 97, 0, 0}, - {129, 0, 211, 0, 0, 0}, - {129, 0, 209, 0, 0, 0}, - {129, 0, 213, 0, 0, 0}, - {9, 130, 0, 130, 0, 0}, - {129, 0, 214, 0, 0, 0}, - {129, 0, 218, 0, 0, 0}, - {129, 0, 217, 0, 0, 0}, - {129, 0, 219, 0, 0, 0}, - {1, 0, 0, 0, 0, 0}, - {9, 56, 0, 56, 0, 0}, - {129, 0, 2, 1, 0, 0}, - {65, 65535, 1, 0, 0, 0}, - {9, 65534, 0, 65535, 0, 0}, - {9, 65457, 0, 65457, 0, 0}, - {129, 0, 65439, 0, 0, 0}, - {129, 0, 65480, 0, 0, 0}, - {129, 0, 65406, 0, 0, 0}, - {9, 65326, 0, 65326, 0, 0}, - {9, 65330, 0, 65330, 0, 0}, - {9, 65331, 0, 65331, 0, 0}, - {9, 65334, 0, 65334, 0, 0}, - {9, 65333, 0, 65333, 0, 0}, - {9, 65329, 0, 65329, 0, 0}, - {9, 65327, 0, 65327, 0, 0}, - {9, 65325, 0, 65325, 0, 0}, - {9, 65323, 0, 65323, 0, 0}, - {9, 65322, 0, 65322, 0, 0}, - {9, 65318, 0, 65318, 0, 0}, - {9, 65319, 0, 65319, 0, 0}, - {9, 65317, 0, 65317, 0, 0}, - {0, 84, 0, 84, 0, 0}, - {129, 0, 38, 0, 0, 0}, - {129, 0, 37, 0, 0, 0}, - {129, 0, 64, 0, 0, 0}, - {129, 0, 63, 0, 0, 0}, - {9, 65498, 0, 65498, 0, 0}, - {9, 65499, 0, 65499, 0, 0}, - {9, 65505, 0, 65505, 0, 0}, - {9, 65472, 0, 65472, 0, 0}, - {9, 65473, 0, 65473, 0, 0}, - {9, 65474, 0, 65474, 0, 0}, - {9, 65479, 0, 65479, 0, 0}, - {129, 0, 0, 0, 0, 0}, - {9, 65489, 0, 65489, 0, 0}, - {9, 65482, 0, 65482, 0, 0}, - {9, 65450, 0, 65450, 0, 0}, - {9, 65456, 0, 65456, 0, 0}, - {129, 0, 65476, 0, 0, 0}, - {9, 65440, 0, 65440, 0, 0}, - {129, 0, 80, 0, 0, 0}, - {129, 0, 48, 0, 0, 0}, - {9, 65488, 0, 65488, 0, 0}, - {9, 65477, 0, 65477, 0, 0}, - {9, 8, 0, 8, 0, 0}, - {129, 0, 65528, 0, 0, 0}, - {9, 74, 0, 74, 0, 0}, - {9, 86, 0, 86, 0, 0}, - {9, 100, 0, 100, 0, 0}, - {9, 128, 0, 128, 0, 0}, - {9, 112, 0, 112, 0, 0}, - {9, 126, 0, 126, 0, 0}, - {65, 0, 65528, 0, 0, 0}, - {9, 9, 0, 9, 0, 0}, - {129, 0, 65462, 0, 0, 0}, - {65, 0, 65527, 0, 0, 0}, - {9, 58331, 0, 58331, 0, 0}, - {129, 0, 65450, 0, 0, 0}, - {129, 0, 65436, 0, 0, 0}, - {9, 7, 0, 7, 0, 0}, - {129, 0, 65424, 0, 0, 0}, - {129, 0, 65529, 0, 0, 0}, - {129, 0, 65408, 0, 0, 0}, - {129, 0, 65410, 0, 0, 0}, - {129, 0, 58019, 0, 0, 0}, - {129, 0, 57153, 0, 0, 0}, - {129, 0, 57274, 0, 0, 0}, - {0, 0, 16, 0, 0, 0}, - {0, 65520, 0, 65520, 0, 0}, - {4, 0, 0, 0, 0, 1}, - {4, 0, 0, 0, 0, 2}, - {4, 0, 0, 0, 0, 3}, - {4, 0, 0, 0, 0, 4}, - {4, 0, 0, 0, 0, 5}, - {4, 0, 0, 0, 0, 6}, - {4, 0, 0, 0, 0, 7}, - {4, 0, 0, 0, 0, 8}, - {4, 0, 0, 0, 0, 9}, - {0, 0, 26, 0, 0, 0}, - {0, 65510, 0, 65510, 0, 0}, - {4, 0, 0, 0, 0, 0}, - {129, 0, 40, 0, 0, 0}, - {9, 65496, 0, 65496, 0, 0}, + {0, 0, 0, 0, 0, 32}, + {0, 0, 0, 0, 0, 48}, + {0, 0, 0, 0, 0, 6}, + {0, 0, 0, 1, 1, 6}, + {0, 0, 0, 2, 2, 6}, + {0, 0, 0, 3, 3, 6}, + {0, 0, 0, 4, 4, 6}, + {0, 0, 0, 5, 5, 6}, + {0, 0, 0, 6, 6, 6}, + {0, 0, 0, 7, 7, 6}, + {0, 0, 0, 8, 8, 6}, + {0, 0, 0, 9, 9, 6}, + {0, 32, 0, 0, 0, 129}, + {65504, 0, 65504, 0, 0, 9}, + {0, 0, 0, 0, 0, 9}, + {743, 0, 743, 0, 0, 9}, + {121, 0, 121, 0, 0, 9}, + {0, 1, 0, 0, 0, 129}, + {65535, 0, 65535, 0, 0, 9}, + {0, 65337, 0, 0, 0, 129}, + {65304, 0, 65304, 0, 0, 9}, + {0, 65415, 0, 0, 0, 129}, + {65236, 0, 65236, 0, 0, 9}, + {0, 210, 0, 0, 0, 129}, + {0, 206, 0, 0, 0, 129}, + {0, 205, 0, 0, 0, 129}, + {0, 79, 0, 0, 0, 129}, + {0, 202, 0, 0, 0, 129}, + {0, 203, 0, 0, 0, 129}, + {0, 207, 0, 0, 0, 129}, + {97, 0, 97, 0, 0, 9}, + {0, 211, 0, 0, 0, 129}, + {0, 209, 0, 0, 0, 129}, + {0, 213, 0, 0, 0, 129}, + {130, 0, 130, 0, 0, 9}, + {0, 214, 0, 0, 0, 129}, + {0, 218, 0, 0, 0, 129}, + {0, 217, 0, 0, 0, 129}, + {0, 219, 0, 0, 0, 129}, + {0, 0, 0, 0, 0, 1}, + {56, 0, 56, 0, 0, 9}, + {0, 2, 1, 0, 0, 129}, + {65535, 1, 0, 0, 0, 65}, + {65534, 0, 65535, 0, 0, 9}, + {65457, 0, 65457, 0, 0, 9}, + {0, 65439, 0, 0, 0, 129}, + {0, 65480, 0, 0, 0, 129}, + {0, 65406, 0, 0, 0, 129}, + {65326, 0, 65326, 0, 0, 9}, + {65330, 0, 65330, 0, 0, 9}, + {65331, 0, 65331, 0, 0, 9}, + {65334, 0, 65334, 0, 0, 9}, + {65333, 0, 65333, 0, 0, 9}, + {65329, 0, 65329, 0, 0, 9}, + {65327, 0, 65327, 0, 0, 9}, + {65325, 0, 65325, 0, 0, 9}, + {65323, 0, 65323, 0, 0, 9}, + {65322, 0, 65322, 0, 0, 9}, + {65318, 0, 65318, 0, 0, 9}, + {65319, 0, 65319, 0, 0, 9}, + {65317, 0, 65317, 0, 0, 9}, + {84, 0, 84, 0, 0, 0}, + {0, 38, 0, 0, 0, 129}, + {0, 37, 0, 0, 0, 129}, + {0, 64, 0, 0, 0, 129}, + {0, 63, 0, 0, 0, 129}, + {65498, 0, 65498, 0, 0, 9}, + {65499, 0, 65499, 0, 0, 9}, + {65505, 0, 65505, 0, 0, 9}, + {65472, 0, 65472, 0, 0, 9}, + {65473, 0, 65473, 0, 0, 9}, + {65474, 0, 65474, 0, 0, 9}, + {65479, 0, 65479, 0, 0, 9}, + {0, 0, 0, 0, 0, 129}, + {65489, 0, 65489, 0, 0, 9}, + {65482, 0, 65482, 0, 0, 9}, + {65450, 0, 65450, 0, 0, 9}, + {65456, 0, 65456, 0, 0, 9}, + {0, 65476, 0, 0, 0, 129}, + {65440, 0, 65440, 0, 0, 9}, + {0, 80, 0, 0, 0, 129}, + {0, 48, 0, 0, 0, 129}, + {65488, 0, 65488, 0, 0, 9}, + {65477, 0, 65477, 0, 0, 9}, + {8, 0, 8, 0, 0, 9}, + {0, 65528, 0, 0, 0, 129}, + {74, 0, 74, 0, 0, 9}, + {86, 0, 86, 0, 0, 9}, + {100, 0, 100, 0, 0, 9}, + {128, 0, 128, 0, 0, 9}, + {112, 0, 112, 0, 0, 9}, + {126, 0, 126, 0, 0, 9}, + {0, 65528, 0, 0, 0, 65}, + {9, 0, 9, 0, 0, 9}, + {0, 65462, 0, 0, 0, 129}, + {0, 65527, 0, 0, 0, 65}, + {58331, 0, 58331, 0, 0, 9}, + {0, 65450, 0, 0, 0, 129}, + {0, 65436, 0, 0, 0, 129}, + {7, 0, 7, 0, 0, 9}, + {0, 65424, 0, 0, 0, 129}, + {0, 65529, 0, 0, 0, 129}, + {0, 65408, 0, 0, 0, 129}, + {0, 65410, 0, 0, 0, 129}, + {0, 58019, 0, 0, 0, 129}, + {0, 57153, 0, 0, 0, 129}, + {0, 57274, 0, 0, 0, 129}, + {0, 16, 0, 0, 0, 0}, + {65520, 0, 65520, 0, 0, 0}, + {0, 0, 0, 0, 1, 4}, + {0, 0, 0, 0, 2, 4}, + {0, 0, 0, 0, 3, 4}, + {0, 0, 0, 0, 4, 4}, + {0, 0, 0, 0, 5, 4}, + {0, 0, 0, 0, 6, 4}, + {0, 0, 0, 0, 7, 4}, + {0, 0, 0, 0, 8, 4}, + {0, 0, 0, 0, 9, 4}, + {0, 26, 0, 0, 0, 0}, + {65510, 0, 65510, 0, 0, 0}, + {0, 0, 0, 0, 0, 4}, + {0, 40, 0, 0, 0, 129}, + {65496, 0, 65496, 0, 0, 9}, }; /* type indexes */ Index: weakrefobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/weakrefobject.c,v retrieving revision 1.9.2.1 retrieving revision 1.9.2.2 diff -u -d -r1.9.2.1 -r1.9.2.2 --- weakrefobject.c 28 Apr 2003 17:17:59 -0000 1.9.2.1 +++ weakrefobject.c 7 Jan 2005 07:04:10 -0000 1.9.2.2 @@ -19,6 +19,15 @@ } +static void +init_weakref(PyWeakReference *self, PyObject *ob, PyObject *callback) +{ + self->hash = -1; + self->wr_object = ob; + Py_XINCREF(callback); + self->wr_callback = callback; +} + static PyWeakReference * new_weakref(PyObject *ob, PyObject *callback) { @@ -26,10 +35,7 @@ result = PyObject_GC_New(PyWeakReference, &_PyWeakref_RefType); if (result) { - result->hash = -1; - result->wr_object = ob; - Py_XINCREF(callback); - result->wr_callback = callback; + init_weakref(result, ob, callback); PyObject_GC_Track(result); } return result; @@ -53,24 +59,50 @@ if (*list == self) *list = self->wr_next; self->wr_object = Py_None; - self->wr_callback = NULL; if (self->wr_prev != NULL) self->wr_prev->wr_next = self->wr_next; if (self->wr_next != NULL) self->wr_next->wr_prev = self->wr_prev; self->wr_prev = NULL; self->wr_next = NULL; - Py_XDECREF(callback); + } + if (callback != NULL) { + Py_DECREF(callback); + self->wr_callback = NULL; } } +/* Cyclic gc uses this to *just* clear the passed-in reference, leaving + * the callback intact and uncalled. It must be possible to call self's + * tp_dealloc() after calling this, so self has to be left in a sane enough + * state for that to work. We expect tp_dealloc to decref the callback + * then. The reason for not letting clear_weakref() decref the callback + * right now is that if the callback goes away, that may in turn trigger + * another callback (if a weak reference to the callback exists) -- running + * arbitrary Python code in the middle of gc is a disaster. The convolution + * here allows gc to delay triggering such callbacks until the world is in + * a sane state again. + */ +void +_PyWeakref_ClearRef(PyWeakReference *self) +{ + PyObject *callback; + + assert(self != NULL); + assert(PyWeakref_Check(self)); + /* Preserve and restore the callback around clear_weakref. */ + callback = self->wr_callback; + self->wr_callback = NULL; + clear_weakref(self); + self->wr_callback = callback; +} static void -weakref_dealloc(PyWeakReference *self) +weakref_dealloc(PyObject *self) { - PyObject_GC_UnTrack((PyObject *)self); - clear_weakref(self); - PyObject_GC_Del(self); + PyObject_GC_UnTrack(self); + clear_weakref((PyWeakReference *) self); + self->ob_type->tp_free(self); } @@ -117,7 +149,7 @@ self->hash = PyObject_Hash(PyWeakref_GET_OBJECT(self)); return self->hash; } - + static PyObject * weakref_repr(PyWeakReference *self) @@ -167,6 +199,134 @@ PyWeakref_GET_OBJECT(other), op); } +/* Given the head of an object's list of weak references, extract the + * two callback-less refs (ref and proxy). Used to determine if the + * shared references exist and to determine the back link for newly + * inserted references. + */ +static void +get_basic_refs(PyWeakReference *head, + PyWeakReference **refp, PyWeakReference **proxyp) +{ + *refp = NULL; + *proxyp = NULL; + + if (head != NULL && head->wr_callback == NULL) { + /* We need to be careful that the "basic refs" aren't + subclasses of the main types. That complicates this a + little. */ + if (PyWeakref_CheckRefExact(head)) { + *refp = head; + head = head->wr_next; + } + if (head != NULL + && head->wr_callback == NULL + && PyWeakref_CheckProxy(head)) { + *proxyp = head; + /* head = head->wr_next; */ + } + } +} + +/* Insert 'newref' in the list after 'prev'. Both must be non-NULL. */ +static void +insert_after(PyWeakReference *newref, PyWeakReference *prev) +{ + newref->wr_prev = prev; + newref->wr_next = prev->wr_next; + if (prev->wr_next != NULL) + prev->wr_next->wr_prev = newref; + prev->wr_next = newref; +} + +/* Insert 'newref' at the head of the list; 'list' points to the variable + * that stores the head. + */ +static void +insert_head(PyWeakReference *newref, PyWeakReference **list) +{ + PyWeakReference *next = *list; + + newref->wr_prev = NULL; + newref->wr_next = next; + if (next != NULL) + next->wr_prev = newref; + *list = newref; +} + +static int +parse_weakref_init_args(char *funcname, PyObject *args, PyObject *kwargs, + PyObject **obp, PyObject **callbackp) +{ + /* XXX Should check that kwargs == NULL or is empty. */ + return PyArg_UnpackTuple(args, funcname, 1, 2, obp, callbackp); +} + +static PyObject * +weakref___new__(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyWeakReference *self = NULL; + PyObject *ob, *callback = NULL; + + if (parse_weakref_init_args("__new__", args, kwargs, &ob, &callback)) { + PyWeakReference *ref, *proxy; + PyWeakReference **list; + + if (!PyType_SUPPORTS_WEAKREFS(ob->ob_type)) { + PyErr_Format(PyExc_TypeError, + "cannot create weak reference to '%s' object", + ob->ob_type->tp_name); + return NULL; + } + if (callback == Py_None) + callback = NULL; + list = GET_WEAKREFS_LISTPTR(ob); + get_basic_refs(*list, &ref, &proxy); + if (callback == NULL && type == &_PyWeakref_RefType) { + if (ref != NULL) { + /* We can re-use an existing reference. */ + Py_INCREF(ref); + return (PyObject *)ref; + } + } + /* We have to create a new reference. */ + /* Note: the tp_alloc() can trigger cyclic GC, so the weakref + list on ob can be mutated. This means that the ref and + proxy pointers we got back earlier may have been collected, + so we need to compute these values again before we use + them. */ + self = (PyWeakReference *) (type->tp_alloc(type, 0)); + if (self != NULL) { + init_weakref(self, ob, callback); + if (callback == NULL && type == &_PyWeakref_RefType) { + insert_head(self, list); + } + else { + PyWeakReference *prev; + + get_basic_refs(*list, &ref, &proxy); + prev = (proxy == NULL) ? ref : proxy; + if (prev == NULL) + insert_head(self, list); + else + insert_after(self, prev); + } + } + } + return (PyObject *)self; +} + +static int +weakref___init__(PyObject *self, PyObject *args, PyObject *kwargs) +{ + PyObject *tmp; + + if (parse_weakref_init_args("__init__", args, kwargs, &tmp, &tmp)) + return 0; + else + return 1; +} + PyTypeObject _PyWeakref_RefType = { @@ -175,7 +335,7 @@ "weakref", sizeof(PyWeakReference), 0, - (destructor)weakref_dealloc,/*tp_dealloc*/ + weakref_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -184,18 +344,33 @@ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ - (hashfunc)weakref_hash, /*tp_hash*/ + (hashfunc)weakref_hash, /*tp_hash*/ (ternaryfunc)weakref_call, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_RICHCOMPARE, + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_RICHCOMPARE + | Py_TPFLAGS_BASETYPE, /*tp_flags*/ 0, /*tp_doc*/ (traverseproc)gc_traverse, /*tp_traverse*/ (inquiry)gc_clear, /*tp_clear*/ (richcmpfunc)weakref_richcompare, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + 0, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + (initproc)weakref___init__, /*tp_init*/ + PyType_GenericAlloc, /*tp_alloc*/ + weakref___new__, /*tp_new*/ + PyObject_GC_Del, /*tp_free*/ }; @@ -264,14 +439,6 @@ WRAP_UNARY(proxy_str, PyObject_Str) WRAP_TERNARY(proxy_call, PyEval_CallObjectWithKeywords) -static int -proxy_print(PyWeakReference *proxy, FILE *fp, int flags) -{ - if (!proxy_checkref(proxy)) - return -1; - return PyObject_Print(PyWeakref_GET_OBJECT(proxy), fp, flags); -} - static PyObject * proxy_repr(PyWeakReference *proxy) { @@ -332,12 +499,12 @@ WRAP_BINARY(proxy_ixor, PyNumber_InPlaceXor) WRAP_BINARY(proxy_ior, PyNumber_InPlaceOr) -static int +static int proxy_nonzero(PyWeakReference *proxy) { PyObject *o = PyWeakref_GET_OBJECT(proxy); if (!proxy_checkref(proxy)) - return 1; + return -1; if (o->ob_type->tp_as_number && o->ob_type->tp_as_number->nb_nonzero) return (*o->ob_type->tp_as_number->nb_nonzero)(o); @@ -345,6 +512,15 @@ return 1; } +static void +proxy_dealloc(PyWeakReference *self) +{ + if (self->wr_callback != NULL) + PyObject_GC_UnTrack((PyObject *)self); + clear_weakref(self); + PyObject_GC_Del(self); +} + /* sequence slots */ static PyObject * @@ -389,7 +565,11 @@ { if (!proxy_checkref(proxy)) return -1; - return PyObject_SetItem(PyWeakref_GET_OBJECT(proxy), key, value); + + if (value == NULL) + return PyObject_DelItem(PyWeakref_GET_OBJECT(proxy), key); + else + return PyObject_SetItem(PyWeakref_GET_OBJECT(proxy), key, value); } /* iterator slots */ @@ -474,8 +654,8 @@ sizeof(PyWeakReference), 0, /* methods */ - (destructor)weakref_dealloc, /* tp_dealloc */ - (printfunc)proxy_print, /* tp_print */ + (destructor)proxy_dealloc, /* tp_dealloc */ + 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ proxy_compare, /* tp_compare */ @@ -509,8 +689,8 @@ sizeof(PyWeakReference), 0, /* methods */ - (destructor)weakref_dealloc, /* tp_dealloc */ - (printfunc)proxy_print, /* tp_print */ + (destructor)proxy_dealloc, /* tp_dealloc */ + 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ proxy_compare, /* tp_compare */ @@ -536,56 +716,6 @@ }; -/* Given the head of an object's list of weak references, extract the - * two callback-less refs (ref and proxy). Used to determine if the - * shared references exist and to determine the back link for newly - * inserted references. - */ -static void -get_basic_refs(PyWeakReference *head, - PyWeakReference **refp, PyWeakReference **proxyp) -{ - *refp = NULL; - *proxyp = NULL; - - if (head != NULL && head->wr_callback == NULL) { - if (head->ob_type == &_PyWeakref_RefType) { - *refp = head; - head = head->wr_next; - } - if (head != NULL && head->wr_callback == NULL) { - *proxyp = head; - head = head->wr_next; - } - } -} - -/* Insert 'newref' in the list after 'prev'. Both must be non-NULL. */ -static void -insert_after(PyWeakReference *newref, PyWeakReference *prev) -{ - newref->wr_prev = prev; - newref->wr_next = prev->wr_next; - if (prev->wr_next != NULL) - prev->wr_next->wr_prev = newref; - prev->wr_next = newref; -} - -/* Insert 'newref' at the head of the list; 'list' points to the variable - * that stores the head. - */ -static void -insert_head(PyWeakReference *newref, PyWeakReference **list) -{ - PyWeakReference *next = *list; - - newref->wr_prev = NULL; - newref->wr_next = next; - if (next != NULL) - next->wr_prev = newref; - *list = newref; -} - PyObject * PyWeakref_NewRef(PyObject *ob, PyObject *callback) @@ -602,20 +732,39 @@ } list = GET_WEAKREFS_LISTPTR(ob); get_basic_refs(*list, &ref, &proxy); - if (callback == NULL || callback == Py_None) + if (callback == Py_None) + callback = NULL; + if (callback == NULL) /* return existing weak reference if it exists */ result = ref; if (result != NULL) - Py_XINCREF(result); + Py_INCREF(result); else { + /* Note: new_weakref() can trigger cyclic GC, so the weakref + list on ob can be mutated. This means that the ref and + proxy pointers we got back earlier may have been collected, + so we need to compute these values again before we use + them. */ result = new_weakref(ob, callback); if (result != NULL) { + get_basic_refs(*list, &ref, &proxy); if (callback == NULL) { - insert_head(result, list); + if (ref == NULL) + insert_head(result, list); + else { + /* Someone else added a ref without a callback + during GC. Return that one instead of this one + to avoid violating the invariants of the list + of weakrefs for ob. */ + Py_DECREF(result); + Py_INCREF(ref); + result = ref; + } } else { - PyWeakReference *prev = (proxy == NULL) ? ref : proxy; + PyWeakReference *prev; + prev = (proxy == NULL) ? ref : proxy; if (prev == NULL) insert_head(result, list); else @@ -642,12 +791,19 @@ } list = GET_WEAKREFS_LISTPTR(ob); get_basic_refs(*list, &ref, &proxy); + if (callback == Py_None) + callback = NULL; if (callback == NULL) /* attempt to return an existing weak reference if it exists */ result = proxy; if (result != NULL) - Py_XINCREF(result); + Py_INCREF(result); else { + /* Note: new_weakref() can trigger cyclic GC, so the weakref + list on ob can be mutated. This means that the ref and + proxy pointers we got back earlier may have been collected, + so we need to compute these values again before we use + them. */ result = new_weakref(ob, callback); if (result != NULL) { PyWeakReference *prev; @@ -656,8 +812,19 @@ result->ob_type = &_PyWeakref_CallableProxyType; else result->ob_type = &_PyWeakref_ProxyType; - if (callback == NULL) + get_basic_refs(*list, &ref, &proxy); + if (callback == NULL) { + if (proxy != NULL) { + /* Someone else added a proxy without a callback + during GC. Return that one instead of this one + to avoid violating the invariants of the list + of weakrefs for ob. */ + Py_DECREF(result); + Py_INCREF(result = proxy); + goto skip_insert; + } prev = ref; + } else prev = (proxy == NULL) ? ref : proxy; @@ -665,6 +832,8 @@ insert_head(result, list); else insert_after(result, prev); + skip_insert: + ; } } return (PyObject *) result; @@ -681,7 +850,9 @@ return PyWeakref_GET_OBJECT(ref); } - +/* Note that there's an inlined copy-paste of handle_callback() in gcmodule.c's + * handle_weakrefs(). + */ static void handle_callback(PyWeakReference *ref, PyObject *callback) { @@ -730,8 +901,10 @@ current->wr_callback = NULL; clear_weakref(current); - handle_callback(current, callback); - Py_DECREF(callback); + if (callback != NULL) { + handle_callback(current, callback); + Py_DECREF(callback); + } } else { PyObject *tuple = PyTuple_New(count * 2); @@ -748,10 +921,12 @@ current = next; } for (i = 0; i < count; ++i) { - PyObject *current = PyTuple_GET_ITEM(tuple, i * 2); PyObject *callback = PyTuple_GET_ITEM(tuple, i * 2 + 1); - handle_callback((PyWeakReference *)current, callback); + if (callback != NULL) { + PyObject *current = PyTuple_GET_ITEM(tuple, i * 2); + handle_callback((PyWeakReference *)current, callback); + } } Py_DECREF(tuple); } --- xxobject.c DELETED --- From kbk at users.sourceforge.net Fri Jan 7 07:56:58 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Fri Jan 7 08:54:26 2005 Subject: [Python-checkins] python/dist/src/Doc/commontex .cvsignore, NONE, 1.1.8.1 boilerplate.tex, NONE, 1.3.6.1 copyright.tex, NONE, 1.2.6.1 license.tex, NONE, 1.6.4.1 reportingbugs.tex, NONE, 1.2.6.1 typestruct.h, NONE, 1.1.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/commontex In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12896/Doc/commontex Added Files: Tag: ast-branch .cvsignore boilerplate.tex copyright.tex license.tex reportingbugs.tex typestruct.h Log Message: Merge MAIN into ast-branch cvs up -kk -j mrg_to_ast-branch_24APR03 -j mrg_to_ast-branch_05JAN05 (date of earlier merge estimated 24Apr03 17:30 UTC, repository tagged) Not merged: Lib/test/test_compile.py, Python/compile.c Refer to Tracker Patch # 1097671 for the merge output and list of conflicts resolved. --- NEW FILE: .cvsignore --- patchlevel.tex --- NEW FILE: boilerplate.tex --- \author{Guido van Rossum\\ Fred L. Drake, Jr., editor} \authoraddress{ \strong{Python Software Foundation}\\ Email: \email{docs@python.org} } \date{\today} % XXX update before final release! \input{patchlevel} % include Python version information --- NEW FILE: copyright.tex --- Copyright \copyright{} 2001-2004 Python Software Foundation. All rights reserved. Copyright \copyright{} 2000 BeOpen.com. All rights reserved. Copyright \copyright{} 1995-2000 Corporation for National Research Initiatives. All rights reserved. Copyright \copyright{} 1991-1995 Stichting Mathematisch Centrum. All rights reserved. See the end of this document for complete license and permissions information. --- NEW FILE: license.tex --- \section{History of the software} Python was created in the early 1990s by Guido van Rossum at Stichting Mathematisch Centrum (CWI, see \url{http://www.cwi.nl/}) in the Netherlands as a successor of a language called ABC. Guido remains Python's principal author, although it includes many contributions from others. In 1995, Guido continued his work on Python at the Corporation for National Research Initiatives (CNRI, see \url{http://www.cnri.reston.va.us/}) in Reston, Virginia where he released several versions of the software. In May 2000, Guido and the Python core development team moved to BeOpen.com to form the BeOpen PythonLabs team. In October of the same year, the PythonLabs team moved to Digital Creations (now Zope Corporation; see \url{http://www.zope.com/}). In 2001, the Python Software Foundation (PSF, see \url{http://www.python.org/psf/}) was formed, a non-profit organization created specifically to own Python-related Intellectual Property. Zope Corporation is a sponsoring member of the PSF. All Python releases are Open Source (see \url{http://www.opensource.org/} for the Open Source Definition). Historically, most, but not all, Python releases have also been GPL-compatible; the table below summarizes the various releases. \begin{tablev}{c|c|c|c|c}{textrm}% {Release}{Derived from}{Year}{Owner}{GPL compatible?} \linev{0.9.0 thru 1.2}{n/a}{1991-1995}{CWI}{yes} \linev{1.3 thru 1.5.2}{1.2}{1995-1999}{CNRI}{yes} \linev{1.6}{1.5.2}{2000}{CNRI}{no} \linev{2.0}{1.6}{2000}{BeOpen.com}{no} \linev{1.6.1}{1.6}{2001}{CNRI}{no} \linev{2.1}{2.0+1.6.1}{2001}{PSF}{no} \linev{2.0.1}{2.0+1.6.1}{2001}{PSF}{yes} \linev{2.1.1}{2.1+2.0.1}{2001}{PSF}{yes} \linev{2.2}{2.1.1}{2001}{PSF}{yes} \linev{2.1.2}{2.1.1}{2002}{PSF}{yes} \linev{2.1.3}{2.1.2}{2002}{PSF}{yes} \linev{2.2.1}{2.2}{2002}{PSF}{yes} \linev{2.2.2}{2.2.1}{2002}{PSF}{yes} \linev{2.2.3}{2.2.2}{2002-2003}{PSF}{yes} \linev{2.3}{2.2.2}{2002-2003}{PSF}{yes} \linev{2.3.1}{2.3}{2002-2003}{PSF}{yes} \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} \end{tablev} \note{GPL-compatible doesn't mean that we're distributing Python under the GPL. All Python licenses, unlike the GPL, let you distribute a modified version without making your changes open source. The GPL-compatible licenses make it possible to combine Python with other software that is released under the GPL; the others don't.} Thanks to the many outside volunteers who have worked under Guido's direction to make these releases possible. \section{Terms and conditions for accessing or otherwise using Python} \centerline{\strong{PSF LICENSE AGREEMENT FOR PYTHON \version}} \begin{enumerate} \item This LICENSE AGREEMENT is between the Python Software Foundation (``PSF''), and the Individual or Organization (``Licensee'') accessing and otherwise using Python \version{} software in source or binary form and its associated documentation. \item Subject to the terms and conditions of this License Agreement, PSF hereby grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce, analyze, test, perform and/or display publicly, prepare derivative works, distribute, and otherwise use Python \version{} alone or in any derivative version, provided, however, that PSF's License Agreement and PSF's notice of copyright, i.e., ``Copyright \copyright{} 2001-2004 Python Software Foundation; All Rights Reserved'' are retained in Python \version{} alone or in any derivative version prepared by Licensee. \item In the event Licensee prepares a derivative work that is based on or incorporates Python \version{} or any part thereof, and wants to make the derivative work available to others as provided herein, then Licensee hereby agrees to include in any such work a brief summary of the changes made to Python \version. \item PSF is making Python \version{} available to Licensee on an ``AS IS'' basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON \version{} WILL NOT INFRINGE ANY THIRD PARTY RIGHTS. \item PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON \version{} FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON \version, OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. \item This License Agreement will automatically terminate upon a material breach of its terms and conditions. \item Nothing in this License Agreement shall be deemed to create any relationship of agency, partnership, or joint venture between PSF and Licensee. This License Agreement does not grant permission to use PSF trademarks or trade name in a trademark sense to endorse or promote products or services of Licensee, or any third party. \item By copying, installing or otherwise using Python \version, Licensee agrees to be bound by the terms and conditions of this License Agreement. \end{enumerate} \centerline{\strong{BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0}} \centerline{\strong{BEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1}} \begin{enumerate} \item This LICENSE AGREEMENT is between BeOpen.com (``BeOpen''), having an office at 160 Saratoga Avenue, Santa Clara, CA 95051, and the Individual or Organization (``Licensee'') accessing and otherwise using this software in source or binary form and its associated documentation (``the Software''). \item Subject to the terms and conditions of this BeOpen Python License Agreement, BeOpen hereby grants Licensee a non-exclusive, royalty-free, world-wide license to reproduce, analyze, test, perform and/or display publicly, prepare derivative works, distribute, and otherwise use the Software alone or in any derivative version, provided, however, that the BeOpen Python License is retained in the Software, alone or in any derivative version prepared by Licensee. \item BeOpen is making the Software available to Licensee on an ``AS IS'' basis. BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT INFRINGE ANY THIRD PARTY RIGHTS. \item BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE SOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. \item This License Agreement will automatically terminate upon a material breach of its terms and conditions. \item This License Agreement shall be governed by and interpreted in all respects by the law of the State of California, excluding conflict of law provisions. Nothing in this License Agreement shall be deemed to create any relationship of agency, partnership, or joint venture between BeOpen and Licensee. This License Agreement does not grant permission to use BeOpen trademarks or trade names in a trademark sense to endorse or promote products or services of Licensee, or any third party. As an exception, the ``BeOpen Python'' logos available at http://www.pythonlabs.com/logos.html may be used according to the permissions granted on that web page. \item By copying, installing or otherwise using the software, Licensee agrees to be bound by the terms and conditions of this License Agreement. \end{enumerate} \centerline{\strong{CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1}} \begin{enumerate} \item This LICENSE AGREEMENT is between the Corporation for National Research Initiatives, having an office at 1895 Preston White Drive, Reston, VA 20191 (``CNRI''), and the Individual or Organization (``Licensee'') accessing and otherwise using Python 1.6.1 software in source or binary form and its associated documentation. \item Subject to the terms and conditions of this License Agreement, CNRI hereby grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce, analyze, test, perform and/or display publicly, prepare derivative works, distribute, and otherwise use Python 1.6.1 alone or in any derivative version, provided, however, that CNRI's License Agreement and CNRI's notice of copyright, i.e., ``Copyright \copyright{} 1995-2001 Corporation for National Research Initiatives; All Rights Reserved'' are retained in Python 1.6.1 alone or in any derivative version prepared by Licensee. Alternately, in lieu of CNRI's License Agreement, Licensee may substitute the following text (omitting the quotes): ``Python 1.6.1 is made available subject to the terms and conditions in CNRI's License Agreement. This Agreement together with Python 1.6.1 may be located on the Internet using the following unique, persistent identifier (known as a handle): 1895.22/1013. This Agreement may also be obtained from a proxy server on the Internet using the following URL: \url{http://hdl.handle.net/1895.22/1013}.'' \item In the event Licensee prepares a derivative work that is based on or incorporates Python 1.6.1 or any part thereof, and wants to make the derivative work available to others as provided herein, then Licensee hereby agrees to include in any such work a brief summary of the changes made to Python 1.6.1. \item CNRI is making Python 1.6.1 available to Licensee on an ``AS IS'' basis. CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1.6.1 WILL NOT INFRINGE ANY THIRD PARTY RIGHTS. \item CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON 1.6.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 1.6.1, OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. \item This License Agreement will automatically terminate upon a material breach of its terms and conditions. \item This License Agreement shall be governed by the federal intellectual property law of the United States, including without limitation the federal copyright law, and, to the extent such U.S. federal law does not apply, by the law of the Commonwealth of Virginia, excluding Virginia's conflict of law provisions. Notwithstanding the foregoing, with regard to derivative works based on Python 1.6.1 that incorporate non-separable material that was previously distributed under the GNU General Public License (GPL), the law of the Commonwealth of Virginia shall govern this License Agreement only as to issues arising under or with respect to Paragraphs 4, 5, and 7 of this License Agreement. Nothing in this License Agreement shall be deemed to create any relationship of agency, partnership, or joint venture between CNRI and Licensee. This License Agreement does not grant permission to use CNRI trademarks or trade name in a trademark sense to endorse or promote products or services of Licensee, or any third party. \item By clicking on the ``ACCEPT'' button where indicated, or by copying, installing or otherwise using Python 1.6.1, Licensee agrees to be bound by the terms and conditions of this License Agreement. \end{enumerate} \centerline{ACCEPT} \centerline{\strong{CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2}} Copyright \copyright{} 1991 - 1995, Stichting Mathematisch Centrum Amsterdam, The Netherlands. All rights reserved. Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Stichting Mathematisch Centrum or CWI not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. \section{Licenses and Acknowledgements for Incorporated Software} This section is an incomplete, but growing list of licenses and acknowledgements for third-party software incorporated in the Python distribution. \subsection{Mersenne Twister} The \module{_random} module includes code based on a download from \url{http://www.math.keio.ac.jp/~matumoto/MT2002/emt19937ar.html}. The following are the verbatim comments from the original code: \begin{verbatim} A C-program for MT19937, with initialization improved 2002/1/26. Coded by Takuji Nishimura and Makoto Matsumoto. Before using, initialize the state by using init_genrand(seed) or init_by_array(init_key, key_length). Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names of its contributors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Any feedback is very welcome. http://www.math.keio.ac.jp/matumoto/emt.html email: matumoto@math.keio.ac.jp \end{verbatim} \subsection{Sockets} The \module{socket} module uses the functions, \function{getaddrinfo}, and \function{getnameinfo}, which are coded in separate source files from the WIDE Project, \url{http://www.wide.ad.jp/about/index.html}. \begin{verbatim} Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the project nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND GAI_ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE FOR GAI_ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON GAI_ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN GAI_ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \end{verbatim} \subsection{Floating point exception control} The source for the \module{fpectl} module includes the following notice: \begin{verbatim} --------------------------------------------------------------------- / Copyright (c) 1996. \ | The Regents of the University of California. | | All rights reserved. | | | | Permission to use, copy, modify, and distribute this software for | | any purpose without fee is hereby granted, provided that this en- | | tire notice is included in all copies of any software which is or | | includes a copy or modification of this software and in all | | copies of the supporting documentation for such software. | | | | This work was produced at the University of California, Lawrence | | Livermore National Laboratory under contract no. W-7405-ENG-48 | | between the U.S. Department of Energy and The Regents of the | | University of California for the operation of UC LLNL. | | | | DISCLAIMER | | | | This software was prepared as an account of work sponsored by an | | agency of the United States Government. Neither the United States | | Government nor the University of California nor any of their em- | | ployees, makes any warranty, express or implied, or assumes any | | liability or responsibility for the accuracy, completeness, or | | usefulness of any information, apparatus, product, or process | | disclosed, or represents that its use would not infringe | | privately-owned rights. Reference herein to any specific commer- | | cial products, process, or service by trade name, trademark, | | manufacturer, or otherwise, does not necessarily constitute or | | imply its endorsement, recommendation, or favoring by the United | | States Government or the University of California. The views and | | opinions of authors expressed herein do not necessarily state or | | reflect those of the United States Government or the University | | of California, and shall not be used for advertising or product | \ endorsement purposes. / --------------------------------------------------------------------- \end{verbatim} \subsection{MD5 message digest algorithm} The source code for the \module{md5} module contains the following notice: \begin{verbatim} Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All rights reserved. License to copy and use this software is granted provided that it is identified as the "RSA Data Security, Inc. MD5 Message-Digest Algorithm" in all material mentioning or referencing this software or this function. License is also granted to make and use derivative works provided that such works are identified as "derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm" in all material mentioning or referencing the derived work. RSA Data Security, Inc. makes no representations concerning either the merchantability of this software or the suitability of this software for any particular purpose. It is provided "as is" without express or implied warranty of any kind. These notices must be retained in any copies of any part of this documentation and/or software. \end{verbatim} \subsection{Asynchronous socket services} The \module{asynchat} and \module{asyncore} modules contain the following notice: \begin{verbatim} Copyright 1996 by Sam Rushing All Rights Reserved Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Sam Rushing not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. SAM RUSHING DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SAM RUSHING BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. \end{verbatim} \subsection{Cookie management} The \module{Cookie} module contains the following notice: \begin{verbatim} Copyright 2000 by Timothy O'Malley All Rights Reserved Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Timothy O'Malley not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. Timothy O'Malley DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL Timothy O'Malley BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. \end{verbatim} \subsection{Profiling} The \module{profile} and \module{pstats} modules contain the following notice: \begin{verbatim} Copyright 1994, by InfoSeek Corporation, all rights reserved. Written by James Roskind Permission to use, copy, modify, and distribute this Python software and its associated documentation for any purpose (subject to the restriction in the following sentence) without fee is hereby granted, provided that the above copyright notice appears in all copies, and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of InfoSeek not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. This permission is explicitly restricted to the copying and modification of the software to remain in Python, compiled Python, or other languages (such as C) wherein the modified or derived code is exclusively imported into a Python module. INFOSEEK CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INFOSEEK CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. \end{verbatim} \subsection{Execution tracing} The \module{trace} module contains the following notice: \begin{verbatim} portions copyright 2001, Autonomous Zones Industries, Inc., all rights... err... reserved and offered to the public under the terms of the Python 2.2 license. Author: Zooko O'Whielacronx http://zooko.com/ mailto:zooko@zooko.com Copyright 2000, Mojam Media, Inc., all rights reserved. Author: Skip Montanaro Copyright 1999, Bioreason, Inc., all rights reserved. Author: Andrew Dalke Copyright 1995-1997, Automatrix, Inc., all rights reserved. Author: Skip Montanaro Copyright 1991-1995, Stichting Mathematisch Centrum, all rights reserved. Permission to use, copy, modify, and distribute this Python software and its associated documentation for any purpose without fee is hereby granted, provided that the above copyright notice appears in all copies, and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of neither Automatrix, Bioreason or Mojam Media be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. \end{verbatim} \subsection{UUencode and UUdecode functions} The \module{uu} module contains the following notice: \begin{verbatim} Copyright 1994 by Lance Ellinghouse Cathedral City, California Republic, United States of America. All Rights Reserved Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Lance Ellinghouse not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. LANCE ELLINGHOUSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL LANCE ELLINGHOUSE CENTRUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. Modified by Jack Jansen, CWI, July 1995: - Use binascii module to do the actual line-by-line conversion between ascii and binary. This results in a 1000-fold speedup. The C version is still 5 times faster, though. - Arguments more compliant with python standard \end{verbatim} \subsection{XML Remote Procedure Calls} The \module{xmlrpclib} module contains the following notice: \begin{verbatim} The XML-RPC client interface is Copyright (c) 1999-2002 by Secret Labs AB Copyright (c) 1999-2002 by Fredrik Lundh By obtaining, using, and/or copying this software and/or its associated documentation, you agree that you have read, understood, and will comply with the following terms and conditions: Permission to use, copy, modify, and distribute this software and its associated documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appears in all copies, and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Secret Labs AB or the author not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- ABILITY AND FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. \end{verbatim} --- NEW FILE: reportingbugs.tex --- \label{reporting-bugs} Python is a mature programming language which has established a reputation for stability. In order to maintain this reputation, the developers would like to know of any deficiencies you find in Python or its documentation. Before submitting a report, you will be required to log into SourceForge; this will make it possible for the developers to contact you for additional information if needed. It is not possible to submit a bug report anonymously. All bug reports should be submitted via the Python Bug Tracker on SourceForge (\url{http://sourceforge.net/bugs/?group_id=5470}). The bug tracker offers a Web form which allows pertinent information to be entered and submitted to the developers. The first step in filing a report is to determine whether the problem has already been reported. The advantage in doing so, aside from saving the developers time, is that you learn what has been done to fix it; it may be that the problem has already been fixed for the next release, or additional information is needed (in which case you are welcome to provide it if you can!). To do this, search the bug database using the search box on the left side of the page. If the problem you're reporting is not already in the bug tracker, go back to the Python Bug Tracker (\url{http://sourceforge.net/bugs/?group_id=5470}). Select the ``Submit a Bug'' link at the top of the page to open the bug reporting form. The submission form has a number of fields. The only fields that are required are the ``Summary'' and ``Details'' fields. For the summary, enter a \emph{very} short description of the problem; less than ten words is good. In the Details field, describe the problem in detail, including what you expected to happen and what did happen. Be sure to include the version of Python you used, whether any extension modules were involved, and what hardware and software platform you were using (including version information as appropriate). The only other field that you may want to set is the ``Category'' field, which allows you to place the bug report into a broad category (such as ``Documentation'' or ``Library''). Each bug report will be assigned to a developer who will determine what needs to be done to correct the problem. You will receive an update each time action is taken on the bug. \begin{seealso} \seetitle[http://www-mice.cs.ucl.ac.uk/multimedia/software/documentation/ReportingBugs.html]{How to Report Bugs Effectively}{Article which goes into some detail about how to create a useful bug report. This describes what kind of information is useful and why it is useful.} \seetitle[http://www.mozilla.org/quality/bug-writing-guidelines.html]{Bug Writing Guidelines}{Information about writing a good bug report. Some of this is specific to the Mozilla project, but describes general good practices.} \end{seealso} --- NEW FILE: typestruct.h --- typedef struct _typeobject { PyObject_VAR_HEAD char *tp_name; /* For printing, in format "." */ int tp_basicsize, tp_itemsize; /* For allocation */ /* Methods to implement standard operations */ destructor tp_dealloc; printfunc tp_print; getattrfunc tp_getattr; setattrfunc tp_setattr; cmpfunc tp_compare; reprfunc tp_repr; /* Method suites for standard classes */ PyNumberMethods *tp_as_number; PySequenceMethods *tp_as_sequence; PyMappingMethods *tp_as_mapping; /* More standard operations (here for binary compatibility) */ hashfunc tp_hash; ternaryfunc tp_call; reprfunc tp_str; getattrofunc tp_getattro; setattrofunc tp_setattro; /* Functions to access object as input/output buffer */ PyBufferProcs *tp_as_buffer; /* Flags to define presence of optional/expanded features */ long tp_flags; char *tp_doc; /* Documentation string */ /* Assigned meaning in release 2.0 */ /* call function for all accessible objects */ traverseproc tp_traverse; /* delete references to contained objects */ inquiry tp_clear; /* Assigned meaning in release 2.1 */ /* rich comparisons */ richcmpfunc tp_richcompare; /* weak reference enabler */ long tp_weaklistoffset; /* Added in release 2.2 */ /* Iterators */ getiterfunc tp_iter; iternextfunc tp_iternext; /* Attribute descriptor and subclassing stuff */ struct PyMethodDef *tp_methods; struct PyMemberDef *tp_members; struct PyGetSetDef *tp_getset; struct _typeobject *tp_base; PyObject *tp_dict; descrgetfunc tp_descr_get; descrsetfunc tp_descr_set; long tp_dictoffset; initproc tp_init; allocfunc tp_alloc; newfunc tp_new; freefunc tp_free; /* Low-level free-memory routine */ inquiry tp_is_gc; /* For PyObject_IS_GC */ PyObject *tp_bases; PyObject *tp_mro; /* method resolution order */ PyObject *tp_cache; PyObject *tp_subclasses; PyObject *tp_weaklist; } PyTypeObject; From rhettinger at users.sourceforge.net Fri Jan 7 09:15:47 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jan 7 09:15:49 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1215,1.1216 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32158/Misc Modified Files: NEWS Log Message: SF #75103: imghdr -- identify JPEGs in EXIF format Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1215 retrieving revision 1.1216 diff -u -d -r1.1215 -r1.1216 --- NEWS 2 Jan 2005 06:17:32 -0000 1.1215 +++ NEWS 7 Jan 2005 08:15:41 -0000 1.1216 @@ -33,6 +33,8 @@ Library ------- +- The imghdr module now detects Exif files. + - StringIO.truncate() now correctly adjusts the size attribute. (Bug #951915). From rhettinger at users.sourceforge.net Fri Jan 7 09:16:13 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jan 7 09:16:16 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libimghdr.tex,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32158/Doc/lib Modified Files: libimghdr.tex Log Message: SF #75103: imghdr -- identify JPEGs in EXIF format Index: libimghdr.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libimghdr.tex,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- libimghdr.tex 10 Oct 2000 17:03:45 -0000 1.13 +++ libimghdr.tex 7 Jan 2005 08:15:40 -0000 1.14 @@ -31,11 +31,13 @@ \lineii{'tiff'}{TIFF Files} \lineii{'rast'}{Sun Raster Files} \lineii{'xbm'}{X Bitmap Files} - \lineii{'jpeg'}{JPEG data in JFIF format} + \lineii{'jpeg'}{JPEG data in JFIF or Exif formats} \lineii{'bmp'}{BMP files} \lineii{'png'}{Portable Network Graphics} \end{tableii} +\versionadded[Exif detection]{2.5} + You can extend the list of file types \module{imghdr} can recognize by appending to this variable: From rhettinger at users.sourceforge.net Fri Jan 7 09:16:13 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jan 7 09:16:17 2005 Subject: [Python-checkins] python/dist/src/Lib imghdr.py,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32158/Lib Modified Files: imghdr.py Log Message: SF #75103: imghdr -- identify JPEGs in EXIF format Index: imghdr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/imghdr.py,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- imghdr.py 24 Jan 2001 06:27:27 -0000 1.11 +++ imghdr.py 7 Jan 2005 08:15:40 -0000 1.12 @@ -101,6 +101,13 @@ tests.append(test_jpeg) +def test_exif(h, f): + """JPEG data in Exif format""" + if h[6:10] == 'Exif': + return 'jpeg' + +tests.append(test_exif) + def test_bmp(h, f): if h[:2] == 'BM': return 'bmp' From jackjansen at users.sourceforge.net Fri Jan 7 11:49:38 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Fri Jan 7 11:49:44 2005 Subject: [Python-checkins] python/dist/src configure.in, 1.478, 1.479 configure, 1.465, 1.466 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31264 Modified Files: configure.in configure Log Message: Always set CONFIGURE_MACOSX_DEPLOYMENT_TARGET otherwise it may be set to an empty value and distutils will get confused lateron. Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.478 retrieving revision 1.479 diff -u -d -r1.478 -r1.479 --- configure.in 26 Dec 2004 23:07:35 -0000 1.478 +++ configure.in 7 Jan 2005 10:49:32 -0000 1.479 @@ -1325,11 +1325,11 @@ # Use -undefined dynamic_lookup whenever possible (10.3 and later). # This allows an extension to be used in any Python cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'` + CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}} if test ${MACOSX_DEPLOYMENT_TARGET-${cur_target}} '>' 10.2 then LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup' BLDSHARED="$LDSHARED" - CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}} else LDSHARED='$(CC) $(LDFLAGS) -bundle' if test "$enable_framework" ; then Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.465 retrieving revision 1.466 diff -u -d -r1.465 -r1.466 --- configure 26 Dec 2004 23:07:36 -0000 1.465 +++ configure 7 Jan 2005 10:49:32 -0000 1.466 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 1.477 . +# From configure.in Revision: 1.478 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59 for python 2.5. # @@ -10323,11 +10323,11 @@ # Use -undefined dynamic_lookup whenever possible (10.3 and later). # This allows an extension to be used in any Python cur_target=`sw_vers -productVersion | sed 's/\(10\.[0-9]*\).*/\1/'` + CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}} if test ${MACOSX_DEPLOYMENT_TARGET-${cur_target}} '>' 10.2 then LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup' BLDSHARED="$LDSHARED" - CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}} else LDSHARED='$(CC) $(LDFLAGS) -bundle' if test "$enable_framework" ; then From jackjansen at users.sourceforge.net Fri Jan 7 13:50:14 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Fri Jan 7 13:50:17 2005 Subject: [Python-checkins] python/dist/src/Mac/Tools/IDE PackageManager.py, 1.19, 1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25217 Modified Files: PackageManager.py Log Message: Workaround for the fact that urllib2 doesn't default to "file:" urls. Index: PackageManager.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PackageManager.py,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- PackageManager.py 18 Jul 2004 05:58:14 -0000 1.19 +++ PackageManager.py 7 Jan 2005 12:50:12 -0000 1.20 @@ -181,6 +181,8 @@ filename = EasyDialogs.AskFileForOpen(typeList=("TEXT",)) if filename: filename = urllib.pathname2url(filename) + if filename[:5] != 'file:': + filename = 'file:' + filename self.opendoc(filename) def domenu_openURL(self, *args): From jackjansen at users.sourceforge.net Fri Jan 7 13:56:23 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Fri Jan 7 13:56:26 2005 Subject: [Python-checkins] python/dist/src/Mac/Tools/IDE PackageManager.py, 1.20, 1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26745 Modified Files: PackageManager.py Log Message: Oops, there was a tab in there. Index: PackageManager.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PackageManager.py,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- PackageManager.py 7 Jan 2005 12:50:12 -0000 1.20 +++ PackageManager.py 7 Jan 2005 12:56:21 -0000 1.21 @@ -182,7 +182,7 @@ if filename: filename = urllib.pathname2url(filename) if filename[:5] != 'file:': - filename = 'file:' + filename + filename = 'file:' + filename self.opendoc(filename) def domenu_openURL(self, *args): From jackjansen at users.sourceforge.net Fri Jan 7 13:57:10 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Fri Jan 7 13:57:13 2005 Subject: [Python-checkins] python/dist/src/Mac/Tools/IDE PackageManager.py, 1.14.4.4, 1.14.4.5 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26818 Modified Files: Tag: release23-maint PackageManager.py Log Message: Backport of 1.20: Workaround for the fact that urllib2 doesn't default to "file:" urls. Index: PackageManager.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PackageManager.py,v retrieving revision 1.14.4.4 retrieving revision 1.14.4.5 diff -u -d -r1.14.4.4 -r1.14.4.5 --- PackageManager.py 28 Feb 2004 23:23:57 -0000 1.14.4.4 +++ PackageManager.py 7 Jan 2005 12:57:08 -0000 1.14.4.5 @@ -181,6 +181,8 @@ filename = EasyDialogs.AskFileForOpen(typeList=("TEXT",)) if filename: filename = urllib.pathname2url(filename) + if filename[:5] != 'file:': + filename = 'file:' + filename self.opendoc(filename) def domenu_openURL(self, *args): From jackjansen at users.sourceforge.net Fri Jan 7 13:58:06 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Fri Jan 7 13:58:08 2005 Subject: [Python-checkins] python/dist/src/Mac/Tools/IDE PackageManager.py, 1.19, 1.19.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/Tools/IDE In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27015 Modified Files: Tag: release24-maint PackageManager.py Log Message: Backport of 1.20: Workaround for the fact that urllib2 doesn't default to "file:" urls. Index: PackageManager.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/Tools/IDE/PackageManager.py,v retrieving revision 1.19 retrieving revision 1.19.4.1 diff -u -d -r1.19 -r1.19.4.1 --- PackageManager.py 18 Jul 2004 05:58:14 -0000 1.19 +++ PackageManager.py 7 Jan 2005 12:58:03 -0000 1.19.4.1 @@ -181,6 +181,8 @@ filename = EasyDialogs.AskFileForOpen(typeList=("TEXT",)) if filename: filename = urllib.pathname2url(filename) + if filename[:5] != 'file:': + filename = 'file:' + filename self.opendoc(filename) def domenu_openURL(self, *args): From jackjansen at users.sourceforge.net Fri Jan 7 14:08:43 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Fri Jan 7 14:08:46 2005 Subject: [Python-checkins] python/dist/src configure.in, 1.479, 1.480 configure, 1.466, 1.467 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29280 Modified Files: configure.in configure Log Message: Patch #1097739 by Bob Ippolito: MacOSX: if we cannot use -undefined dynamic_lookup (such as on 10.2 or earlier) we link extension directly against the dynamic library in the framework in stead of against the framework. This will fix building extensions for 2.3 after 2.4 has been installed too. Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.479 retrieving revision 1.480 diff -u -d -r1.479 -r1.480 --- configure.in 7 Jan 2005 10:49:32 -0000 1.479 +++ configure.in 7 Jan 2005 13:08:21 -0000 1.480 @@ -1304,8 +1304,8 @@ LDSHARED='$(CC) $(LDFLAGS) -bundle' if test "$enable_framework" ; then # Link against the framework. All externals should be defined. - BLDSHARED="$LDSHARED "'-Wl,-F. -framework $(PYTHONFRAMEWORK)' - LDSHARED="$LDSHARED "'-Wl,-F$(PYTHONFRAMEWORKPREFIX) -framework $(PYTHONFRAMEWORK)' + BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' else # No framework. Ignore undefined symbols, assuming they come from Python LDSHARED="$LDSHARED -undefined suppress" @@ -1314,8 +1314,8 @@ LDSHARED='$(CC) $(LDFLAGS) -bundle' if test "$enable_framework" ; then # Link against the framework. All externals should be defined. - BLDSHARED="$LDSHARED "'-Wl,-F. -framework $(PYTHONFRAMEWORK)' - LDSHARED="$LDSHARED "'-Wl,-F$(PYTHONFRAMEWORKPREFIX) -framework $(PYTHONFRAMEWORK)' + BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' else # No framework, use the Python app as bundle-loader BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)' @@ -1334,8 +1334,8 @@ LDSHARED='$(CC) $(LDFLAGS) -bundle' if test "$enable_framework" ; then # Link against the framework. All externals should be defined. - BLDSHARED="$LDSHARED "'-Wl,-F. -framework $(PYTHONFRAMEWORK)' - LDSHARED="$LDSHARED "'-Wl,-F$(PYTHONFRAMEWORKPREFIX) -framework $(PYTHONFRAMEWORK)' + BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' else # No framework, use the Python app as bundle-loader BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)' @@ -1427,7 +1427,7 @@ LINKFORSHARED="$extra_undefs" if test "$enable_framework" then - LINKFORSHARED="$LINKFORSHARED -Wl,-F. -framework "'$(PYTHONFRAMEWORK)' + LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' fi LINKFORSHARED="$LINKFORSHARED";; OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";; Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.466 retrieving revision 1.467 diff -u -d -r1.466 -r1.467 --- configure 7 Jan 2005 10:49:32 -0000 1.466 +++ configure 7 Jan 2005 13:08:22 -0000 1.467 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 1.478 . +# From configure.in Revision: 1.479 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59 for python 2.5. # @@ -10302,8 +10302,8 @@ LDSHARED='$(CC) $(LDFLAGS) -bundle' if test "$enable_framework" ; then # Link against the framework. All externals should be defined. - BLDSHARED="$LDSHARED "'-Wl,-F. -framework $(PYTHONFRAMEWORK)' - LDSHARED="$LDSHARED "'-Wl,-F$(PYTHONFRAMEWORKPREFIX) -framework $(PYTHONFRAMEWORK)' + BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' else # No framework. Ignore undefined symbols, assuming they come from Python LDSHARED="$LDSHARED -undefined suppress" @@ -10312,8 +10312,8 @@ LDSHARED='$(CC) $(LDFLAGS) -bundle' if test "$enable_framework" ; then # Link against the framework. All externals should be defined. - BLDSHARED="$LDSHARED "'-Wl,-F. -framework $(PYTHONFRAMEWORK)' - LDSHARED="$LDSHARED "'-Wl,-F$(PYTHONFRAMEWORKPREFIX) -framework $(PYTHONFRAMEWORK)' + BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' else # No framework, use the Python app as bundle-loader BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)' @@ -10332,8 +10332,8 @@ LDSHARED='$(CC) $(LDFLAGS) -bundle' if test "$enable_framework" ; then # Link against the framework. All externals should be defined. - BLDSHARED="$LDSHARED "'-Wl,-F. -framework $(PYTHONFRAMEWORK)' - LDSHARED="$LDSHARED "'-Wl,-F$(PYTHONFRAMEWORKPREFIX) -framework $(PYTHONFRAMEWORK)' + BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' else # No framework, use the Python app as bundle-loader BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)' @@ -10429,7 +10429,7 @@ LINKFORSHARED="$extra_undefs" if test "$enable_framework" then - LINKFORSHARED="$LINKFORSHARED -Wl,-F. -framework "'$(PYTHONFRAMEWORK)' + LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' fi LINKFORSHARED="$LINKFORSHARED";; OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";; From jackjansen at users.sourceforge.net Fri Jan 7 14:13:54 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Fri Jan 7 14:13:56 2005 Subject: [Python-checkins] python/dist/src configure, 1.462.2.3, 1.462.2.4 configure.in, 1.475.2.3, 1.475.2.4 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30843 Modified Files: Tag: release24-maint configure configure.in Log Message: Backport of 1.479: Always set CONFIGURE_MACOSX_DEPLOYMENT_TARGET otherwise it may be set to an empty value and distutils will get confused lateron. Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.462.2.3 retrieving revision 1.462.2.4 diff -u -d -r1.462.2.3 -r1.462.2.4 --- configure 6 Jan 2005 23:15:05 -0000 1.462.2.3 +++ configure 7 Jan 2005 13:13:35 -0000 1.462.2.4 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 1.475.2.2 . +# From configure.in Revision: 1.475.2.3 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59 for python 2.4. # @@ -10323,11 +10323,11 @@ # Use -undefined dynamic_lookup whenever possible (10.3 and later). # This allows an extension to be used in any Python cur_target=`sw_vers -productVersion | sed 's/\(10\.[0-9]*\).*/\1/'` + CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}} if test ${MACOSX_DEPLOYMENT_TARGET-${cur_target}} '>' 10.2 then LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup' BLDSHARED="$LDSHARED" - CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}} else LDSHARED='$(CC) $(LDFLAGS) -bundle' if test "$enable_framework" ; then Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.475.2.3 retrieving revision 1.475.2.4 diff -u -d -r1.475.2.3 -r1.475.2.4 --- configure.in 6 Jan 2005 23:16:01 -0000 1.475.2.3 +++ configure.in 7 Jan 2005 13:13:50 -0000 1.475.2.4 @@ -1325,11 +1325,11 @@ # Use -undefined dynamic_lookup whenever possible (10.3 and later). # This allows an extension to be used in any Python cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'` + CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}} if test ${MACOSX_DEPLOYMENT_TARGET-${cur_target}} '>' 10.2 then LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup' BLDSHARED="$LDSHARED" - CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}} else LDSHARED='$(CC) $(LDFLAGS) -bundle' if test "$enable_framework" ; then From jackjansen at users.sourceforge.net Fri Jan 7 14:17:39 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Fri Jan 7 14:17:42 2005 Subject: [Python-checkins] python/dist/src configure.in, 1.475.2.4, 1.475.2.5 configure, 1.462.2.4, 1.462.2.5 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31766 Modified Files: Tag: release24-maint configure.in configure Log Message: Backport of Patch #1097739 by Bob Ippolito: MacOSX: if we cannot use -undefined dynamic_lookup (such as on 10.2 or earlier) we link extension directly against the dynamic library in the framework in stead of against the framework. This will fix building extensions for 2.3 after 2.4 has been installed too. Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.475.2.4 retrieving revision 1.475.2.5 diff -u -d -r1.475.2.4 -r1.475.2.5 --- configure.in 7 Jan 2005 13:13:50 -0000 1.475.2.4 +++ configure.in 7 Jan 2005 13:17:33 -0000 1.475.2.5 @@ -1304,8 +1304,8 @@ LDSHARED='$(CC) $(LDFLAGS) -bundle' if test "$enable_framework" ; then # Link against the framework. All externals should be defined. - BLDSHARED="$LDSHARED "'-Wl,-F. -framework $(PYTHONFRAMEWORK)' - LDSHARED="$LDSHARED "'-Wl,-F$(PYTHONFRAMEWORKPREFIX) -framework $(PYTHONFRAMEWORK)' + BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' else # No framework. Ignore undefined symbols, assuming they come from Python LDSHARED="$LDSHARED -undefined suppress" @@ -1314,8 +1314,8 @@ LDSHARED='$(CC) $(LDFLAGS) -bundle' if test "$enable_framework" ; then # Link against the framework. All externals should be defined. - BLDSHARED="$LDSHARED "'-Wl,-F. -framework $(PYTHONFRAMEWORK)' - LDSHARED="$LDSHARED "'-Wl,-F$(PYTHONFRAMEWORKPREFIX) -framework $(PYTHONFRAMEWORK)' + BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' else # No framework, use the Python app as bundle-loader BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)' @@ -1334,8 +1334,8 @@ LDSHARED='$(CC) $(LDFLAGS) -bundle' if test "$enable_framework" ; then # Link against the framework. All externals should be defined. - BLDSHARED="$LDSHARED "'-Wl,-F. -framework $(PYTHONFRAMEWORK)' - LDSHARED="$LDSHARED "'-Wl,-F$(PYTHONFRAMEWORKPREFIX) -framework $(PYTHONFRAMEWORK)' + BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' else # No framework, use the Python app as bundle-loader BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)' @@ -1427,7 +1427,7 @@ LINKFORSHARED="$extra_undefs" if test "$enable_framework" then - LINKFORSHARED="$LINKFORSHARED -Wl,-F. -framework "'$(PYTHONFRAMEWORK)' + LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' fi LINKFORSHARED="$LINKFORSHARED";; OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";; Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.462.2.4 retrieving revision 1.462.2.5 diff -u -d -r1.462.2.4 -r1.462.2.5 --- configure 7 Jan 2005 13:13:35 -0000 1.462.2.4 +++ configure 7 Jan 2005 13:17:33 -0000 1.462.2.5 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 1.475.2.3 . +# From configure.in Revision: 1.475.2.4 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59 for python 2.4. # @@ -10302,8 +10302,8 @@ LDSHARED='$(CC) $(LDFLAGS) -bundle' if test "$enable_framework" ; then # Link against the framework. All externals should be defined. - BLDSHARED="$LDSHARED "'-Wl,-F. -framework $(PYTHONFRAMEWORK)' - LDSHARED="$LDSHARED "'-Wl,-F$(PYTHONFRAMEWORKPREFIX) -framework $(PYTHONFRAMEWORK)' + BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' else # No framework. Ignore undefined symbols, assuming they come from Python LDSHARED="$LDSHARED -undefined suppress" @@ -10312,8 +10312,8 @@ LDSHARED='$(CC) $(LDFLAGS) -bundle' if test "$enable_framework" ; then # Link against the framework. All externals should be defined. - BLDSHARED="$LDSHARED "'-Wl,-F. -framework $(PYTHONFRAMEWORK)' - LDSHARED="$LDSHARED "'-Wl,-F$(PYTHONFRAMEWORKPREFIX) -framework $(PYTHONFRAMEWORK)' + BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' else # No framework, use the Python app as bundle-loader BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)' @@ -10332,8 +10332,8 @@ LDSHARED='$(CC) $(LDFLAGS) -bundle' if test "$enable_framework" ; then # Link against the framework. All externals should be defined. - BLDSHARED="$LDSHARED "'-Wl,-F. -framework $(PYTHONFRAMEWORK)' - LDSHARED="$LDSHARED "'-Wl,-F$(PYTHONFRAMEWORKPREFIX) -framework $(PYTHONFRAMEWORK)' + BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' else # No framework, use the Python app as bundle-loader BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)' @@ -10429,7 +10429,7 @@ LINKFORSHARED="$extra_undefs" if test "$enable_framework" then - LINKFORSHARED="$LINKFORSHARED -Wl,-F. -framework "'$(PYTHONFRAMEWORK)' + LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' fi LINKFORSHARED="$LINKFORSHARED";; OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";; From jackjansen at users.sourceforge.net Fri Jan 7 14:43:34 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Fri Jan 7 14:43:36 2005 Subject: [Python-checkins] python/dist/src/Lib/plat-mac pimp.py,1.37,1.38 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-mac In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5281 Modified Files: pimp.py Log Message: Allow relative URLs for included databases and packages. Index: pimp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/pimp.py,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- pimp.py 3 Jan 2005 15:44:18 -0000 1.37 +++ pimp.py 7 Jan 2005 13:43:31 -0000 1.38 @@ -402,18 +402,21 @@ self._maintainer = plistdata.get('Maintainer', '') self._description = plistdata.get('Description', '').strip() self._url = url - self._appendPackages(plistdata['Packages']) + self._appendPackages(plistdata['Packages'], url) others = plistdata.get('Include', []) - for url in others: - self.appendURL(url, included=1) + for o in others: + o = urllib.basejoin(url, o) + self.appendURL(o, included=1) - def _appendPackages(self, packages): + def _appendPackages(self, packages, url): """Given a list of dictionaries containing package descriptions create the PimpPackage objects and append them to our internal storage.""" for p in packages: p = dict(p) + if p.has_key('Download-URL'): + p['Download-URL'] = urllib.basejoin(url, p['Download-URL']) flavor = p.get('Flavor') if flavor == 'source': pkg = PimpPackage_source(self, p) From jackjansen at users.sourceforge.net Fri Jan 7 14:48:53 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Fri Jan 7 14:48:56 2005 Subject: [Python-checkins] python/dist/src/Lib/plat-mac pimp.py, 1.35.4.2, 1.35.4.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-mac In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6269 Modified Files: Tag: release24-maint pimp.py Log Message: Backport of 1.38: Allow relative URLs for included databases and packages. Index: pimp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/pimp.py,v retrieving revision 1.35.4.2 retrieving revision 1.35.4.3 diff -u -d -r1.35.4.2 -r1.35.4.3 --- pimp.py 3 Jan 2005 15:46:45 -0000 1.35.4.2 +++ pimp.py 7 Jan 2005 13:48:49 -0000 1.35.4.3 @@ -402,18 +402,21 @@ self._maintainer = plistdata.get('Maintainer', '') self._description = plistdata.get('Description', '').strip() self._url = url - self._appendPackages(plistdata['Packages']) + self._appendPackages(plistdata['Packages'], url) others = plistdata.get('Include', []) - for url in others: - self.appendURL(url, included=1) + for o in others: + o = urllib.basejoin(url, o) + self.appendURL(o, included=1) - def _appendPackages(self, packages): + def _appendPackages(self, packages, url): """Given a list of dictionaries containing package descriptions create the PimpPackage objects and append them to our internal storage.""" for p in packages: p = dict(p) + if p.has_key('Download-URL'): + p['Download-URL'] = urllib.basejoin(url, p['Download-URL']) flavor = p.get('Flavor') if flavor == 'source': pkg = PimpPackage_source(self, p) From jackjansen at users.sourceforge.net Fri Jan 7 14:48:56 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Fri Jan 7 14:49:00 2005 Subject: [Python-checkins] python/dist/src/Lib/plat-mac pimp.py, 1.27.4.4, 1.27.4.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-mac In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6279 Modified Files: Tag: release23-maint pimp.py Log Message: Backport of 1.38: Allow relative URLs for included databases and packages. Index: pimp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/pimp.py,v retrieving revision 1.27.4.4 retrieving revision 1.27.4.5 diff -u -d -r1.27.4.4 -r1.27.4.5 --- pimp.py 3 Jan 2005 15:46:30 -0000 1.27.4.4 +++ pimp.py 7 Jan 2005 13:48:53 -0000 1.27.4.5 @@ -1,6 +1,6 @@ """Package Install Manager for Python. -This is currently a MacOSX-only strawman implementation. +This is currently a MacOSX-only strawman implementation. Despite other rumours the name stands for "Packman IMPlementation". Tools to allow easy installation of packages. The idea is that there is @@ -27,7 +27,7 @@ import shutil import time -__all__ = ["PimpPreferences", "PimpDatabase", "PimpPackage", "main", +__all__ = ["PimpPreferences", "PimpDatabase", "PimpPackage", "main", "getDefaultDatabase", "PIMP_VERSION", "main"] _scriptExc_NotInstalled = "pimp._scriptExc_NotInstalled" @@ -53,12 +53,12 @@ status = "exp" else: status = "prod" - + major, minor, micro, state, extra = sys.version_info pyvers = '%d.%d' % (major, minor) if micro == 0 and state != 'final': pyvers = pyvers + '%s%d' % (state, extra) - + longplatform = distutils.util.get_platform() osname, release, machine = longplatform.split('-') # For some platforms we may want to differentiate between @@ -95,7 +95,7 @@ def _cmd(output, dir, *cmditems): """Internal routine to run a shell command in a given directory.""" - + cmd = ("cd \"%s\"; " % dir) + " ".join(cmditems) if output: output.write("+ %s\n" % cmd) @@ -113,22 +113,22 @@ class PimpDownloader: """Abstract base class - Downloader for archives""" - + def __init__(self, argument, dir="", watcher=None): self.argument = argument self._dir = dir self._watcher = watcher - + def download(self, url, filename, output=None): return None - + def update(self, str): if self._watcher: return self._watcher.update(str) return True - + class PimpCurlDownloader(PimpDownloader): def download(self, url, filename, output=None): @@ -139,7 +139,7 @@ url) self.update("Downloading %s: finished" % url) return (not exitstatus) - + class PimpUrllibDownloader(PimpDownloader): def download(self, url, filename, output=None): @@ -151,13 +151,13 @@ length = long(download.headers['content-length']) else: length = -1 - + data = download.read(4096) #read 4K at a time dlsize = 0 lasttime = 0 while keepgoing: dlsize = dlsize + len(data) - if len(data) == 0: + if len(data) == 0: #this is our exit condition break output.write(data) @@ -172,12 +172,12 @@ if keepgoing: self.update("Downloading %s: finished" % url) return keepgoing - + class PimpUnpacker: """Abstract base class - Unpacker for archives""" - + _can_rename = False - + def __init__(self, argument, dir="", renames=[], @@ -188,30 +188,30 @@ self._dir = dir self._renames = renames self._watcher = watcher - + def unpack(self, archive, output=None, package=None): return None - + def update(self, str): if self._watcher: return self._watcher.update(str) return True - + class PimpCommandUnpacker(PimpUnpacker): """Unpack archives by calling a Unix utility""" - + _can_rename = False - + def unpack(self, archive, output=None, package=None): cmd = self.argument % archive if _cmd(output, self._dir, cmd): return "unpack command failed" - + class PimpTarUnpacker(PimpUnpacker): """Unpack tarfiles using the builtin tarfile module""" - + _can_rename = True - + def unpack(self, archive, output=None, package=None): tf = tarfile.open(archive, "r") members = tf.getmembers() @@ -254,7 +254,7 @@ names = package.filterExpectedSkips(names) if names: return "Not all files were unpacked: %s" % " ".join(names) - + ARCHIVE_FORMATS = [ (".tar.Z", PimpTarUnpacker, None), (".taz", PimpTarUnpacker, None), @@ -267,8 +267,8 @@ class PimpPreferences: """Container for per-user preferences, such as the database to use and where to install packages.""" - - def __init__(self, + + def __init__(self, flavorOrder=None, downloadDir=None, buildDir=None, @@ -288,10 +288,10 @@ self.buildDir = buildDir self.pimpDatabase = pimpDatabase self.watcher = None - + def setWatcher(self, watcher): self.watcher = watcher - + def setInstallDir(self, installDir=None): if installDir: # Installing to non-standard location. @@ -304,14 +304,14 @@ installDir = DEFAULT_INSTALLDIR self.installLocations = [] self.installDir = installDir - + def isUserInstall(self): return self.installDir != DEFAULT_INSTALLDIR def check(self): """Check that the preferences make sense: directories exist and are writable, the install directory is on sys.path, etc.""" - + rv = "" RWX_OK = os.R_OK|os.W_OK|os.X_OK if not os.path.exists(self.downloadDir): @@ -338,7 +338,7 @@ else: rv += "Warning: Install directory \"%s\" is not on sys.path\n" % self.installDir return rv - + def compareFlavors(self, left, right): """Compare two flavor strings. This is part of your preferences because whether the user prefers installing from source or binary is.""" @@ -349,13 +349,13 @@ if right in self.flavorOrder: return 1 return cmp(left, right) - + class PimpDatabase: """Class representing a pimp database. It can actually contain information from multiple databases through inclusion, but the toplevel database is considered the master, as its maintainer is "responsible" for the contents.""" - + def __init__(self, prefs): self._packages = [] self.preferences = prefs @@ -364,23 +364,23 @@ self._version = "" self._maintainer = "" self._description = "" - + # Accessor functions def url(self): return self._url def version(self): return self._version def maintainer(self): return self._maintainer def description(self): return self._description - + def close(self): """Clean up""" self._packages = [] self.preferences = None - + def appendURL(self, url, included=0): """Append packages from the database with the given URL. Only the first database should specify included=0, so the global information (maintainer, description) get stored.""" - + if url in self._urllist: return self._urllist.append(url) @@ -397,23 +397,26 @@ if not self._version: sys.stderr.write("Warning: database has no Version information\n") elif self._version > PIMP_VERSION: - sys.stderr.write("Warning: database version %s newer than pimp version %s\n" + sys.stderr.write("Warning: database version %s newer than pimp version %s\n" % (self._version, PIMP_VERSION)) self._maintainer = plistdata.get('Maintainer', '') self._description = plistdata.get('Description', '').strip() self._url = url - self._appendPackages(plistdata['Packages']) + self._appendPackages(plistdata['Packages'], url) others = plistdata.get('Include', []) - for url in others: - self.appendURL(url, included=1) - - def _appendPackages(self, packages): + for o in others: + o = urllib.basejoin(url, o) + self.appendURL(o, included=1) + + def _appendPackages(self, packages, url): """Given a list of dictionaries containing package descriptions create the PimpPackage objects and append them to our internal storage.""" - + for p in packages: p = dict(p) + if p.has_key('Download-URL'): + p['Download-URL'] = urllib.basejoin(url, p['Download-URL']) flavor = p.get('Flavor') if flavor == 'source': pkg = PimpPackage_source(self, p) @@ -426,27 +429,27 @@ else: pkg = PimpPackage(self, dict(p)) self._packages.append(pkg) - + def list(self): """Return a list of all PimpPackage objects in the database.""" - + return self._packages - + def listnames(self): """Return a list of names of all packages in the database.""" - + rv = [] for pkg in self._packages: rv.append(pkg.fullname()) rv.sort() return rv - + def dump(self, pathOrFile): """Dump the contents of the database to an XML .plist file. - + The file can be passed as either a file object or a pathname. All data, including included databases, is dumped.""" - + packages = [] for pkg in self._packages: packages.append(pkg.dump()) @@ -458,15 +461,15 @@ } plist = plistlib.Plist(**plistdata) plist.write(pathOrFile) - + def find(self, ident): """Find a package. The package can be specified by name or as a dictionary with name, version and flavor entries. - + Only name is obligatory. If there are multiple matches the best one (higher version number, flavors ordered according to users' preference) is returned.""" - + if type(ident) == str: # Remove ( and ) for pseudo-packages if ident[0] == '(' and ident[-1] == ')': @@ -496,7 +499,7 @@ if not found or found < p: found = p return found - + ALLOWED_KEYS = [ "Name", "Version", @@ -516,7 +519,7 @@ class PimpPackage: """Class representing a single package.""" - + def __init__(self, db, plistdata): self._db = db name = plistdata["Name"] @@ -524,10 +527,10 @@ if not k in ALLOWED_KEYS: sys.stderr.write("Warning: %s: unknown key %s\n" % (name, k)) self._dict = plistdata - + def __getitem__(self, key): return self._dict[key] - + def name(self): return self._dict['Name'] def version(self): return self._dict.get('Version') def flavor(self): return self._dict.get('Flavor') @@ -536,13 +539,13 @@ def homepage(self): return self._dict.get('Home-page') def downloadURL(self): return self._dict.get('Download-URL') def systemwideOnly(self): return self._dict.get('Systemwide-only') - + def fullname(self): """Return the full name "name-version-flavor" of a package. - + If the package is a pseudo-package, something that cannot be installed through pimp, return the name in (parentheses).""" - + rv = self._dict['Name'] if self._dict.has_key('Version'): rv = rv + '-%s' % self._dict['Version'] @@ -552,14 +555,14 @@ # Pseudo-package, show in parentheses rv = '(%s)' % rv return rv - + def dump(self): """Return a dict object containing the information on the package.""" return self._dict - + def __cmp__(self, other): """Compare two packages, where the "better" package sorts lower.""" - + if not isinstance(other, PimpPackage): return cmp(id(self), id(other)) if self.name() != other.name(): @@ -567,15 +570,15 @@ if self.version() != other.version(): return -cmp(self.version(), other.version()) return self._db.preferences.compareFlavors(self.flavor(), other.flavor()) - + def installed(self): """Test wheter the package is installed. - + Returns two values: a status indicator which is one of "yes", "no", "old" (an older version is installed) or "bad" (something went wrong during the install test) and a human readable string which may contain more details.""" - + namespace = { "NotInstalled": _scriptExc_NotInstalled, "OldInstalled": _scriptExc_OldInstalled, @@ -607,16 +610,16 @@ sys.stderr.write("-------------------------------------\n") return "bad", "Package install test got exception" return "yes", "" - + def prerequisites(self): """Return a list of prerequisites for this package. - + The list contains 2-tuples, of which the first item is either a PimpPackage object or None, and the second is a descriptive string. The first item can be None if this package depends on something that isn't pimp-installable, in which case the descriptive string should tell the user what to do.""" - + rv = [] if not self._dict.get('Download-URL'): # For pseudo-packages that are already installed we don't @@ -624,7 +627,7 @@ status, _ = self.installed() if status == "yes": return [] - return [(None, + return [(None, "Package %s cannot be installed automatically, see the description" % self.fullname())] if self.systemwideOnly() and self._db.preferences.isUserInstall(): @@ -650,28 +653,28 @@ descr = pkg.shortdescription() rv.append((pkg, descr)) return rv - - + + def downloadPackageOnly(self, output=None): """Download a single package, if needed. - + An MD5 signature is used to determine whether download is needed, and to test that we actually downloaded what we expected. If output is given it is a file-like object that will receive a log of what happens. - + If anything unforeseen happened the method returns an error message string. """ - + scheme, loc, path, query, frag = urlparse.urlsplit(self._dict['Download-URL']) path = urllib.url2pathname(path) filename = os.path.split(path)[1] - self.archiveFilename = os.path.join(self._db.preferences.downloadDir, filename) + self.archiveFilename = os.path.join(self._db.preferences.downloadDir, filename) if not self._archiveOK(): if scheme == 'manual': return "Please download package manually and save as %s" % self.archiveFilename - downloader = PimpUrllibDownloader(None, self._db.preferences.downloadDir, + downloader = PimpUrllibDownloader(None, self._db.preferences.downloadDir, watcher=self._db.preferences.watcher) if not downloader.download(self._dict['Download-URL'], self.archiveFilename, output): @@ -680,10 +683,10 @@ return "archive not found after download" if not self._archiveOK(): return "archive does not have correct MD5 checksum" - + def _archiveOK(self): """Test an archive. It should exist and the MD5 checksum should be correct.""" - + if not os.path.exists(self.archiveFilename): return 0 if not self._dict.get('MD5Sum'): @@ -692,10 +695,10 @@ data = open(self.archiveFilename, 'rb').read() checksum = md5.new(data).hexdigest() return checksum == self._dict['MD5Sum'] - + def unpackPackageOnly(self, output=None): """Unpack a downloaded package archive.""" - + filename = os.path.split(self.archiveFilename)[1] for ext, unpackerClass, arg in ARCHIVE_FORMATS: if filename[-len(ext):] == ext: @@ -703,43 +706,43 @@ else: return "unknown extension for archive file: %s" % filename self.basename = filename[:-len(ext)] - unpacker = unpackerClass(arg, dir=self._db.preferences.buildDir, + unpacker = unpackerClass(arg, dir=self._db.preferences.buildDir, watcher=self._db.preferences.watcher) rv = unpacker.unpack(self.archiveFilename, output=output) if rv: return rv - + def installPackageOnly(self, output=None): """Default install method, to be overridden by subclasses""" return "%s: This package needs to be installed manually (no support for flavor=\"%s\")" \ % (self.fullname(), self._dict.get(flavor, "")) - + def installSinglePackage(self, output=None): """Download, unpack and install a single package. - + If output is given it should be a file-like object and it will receive a log of what happened.""" - + if not self._dict.get('Download-URL'): return "%s: This package needs to be installed manually (no Download-URL field)" % self.fullname() msg = self.downloadPackageOnly(output) if msg: return "%s: download: %s" % (self.fullname(), msg) - + msg = self.unpackPackageOnly(output) if msg: return "%s: unpack: %s" % (self.fullname(), msg) - + return self.installPackageOnly(output) - + def beforeInstall(self): """Bookkeeping before installation: remember what we have in site-packages""" self._old_contents = os.listdir(self._db.preferences.installDir) - + def afterInstall(self): """Bookkeeping after installation: interpret any new .pth files that have appeared""" - + new_contents = os.listdir(self._db.preferences.installDir) for fn in new_contents: if fn in self._old_contents: @@ -762,7 +765,7 @@ line = os.path.join(self._db.preferences.installDir, line) line = os.path.realpath(line) if not line in sys.path: - sys.path.append(line) + sys.path.append(line) def filterExpectedSkips(self, names): """Return a list that contains only unpexpected skips""" @@ -785,21 +788,21 @@ def unpackPackageOnly(self, output=None): """We don't unpack binary packages until installing""" pass - + def installPackageOnly(self, output=None): """Install a single source package. - + If output is given it should be a file-like object and it will receive a log of what happened.""" - + if self._dict.has_key('Install-command'): return "%s: Binary package cannot have Install-command" % self.fullname() - + if self._dict.has_key('Pre-install-command'): if _cmd(output, '/tmp', self._dict['Pre-install-command']): return "pre-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Pre-install-command']) - + self.beforeInstall() # Install by unpacking @@ -810,7 +813,7 @@ else: return "%s: unknown extension for archive file: %s" % (self.fullname(), filename) self.basename = filename[:-len(ext)] - + install_renames = [] for k, newloc in self._db.preferences.installLocations: if not newloc: @@ -820,22 +823,22 @@ else: return "%s: Don't know installLocation %s" % (self.fullname(), k) install_renames.append((oldloc, newloc)) - + unpacker = unpackerClass(arg, dir="/", renames=install_renames) rv = unpacker.unpack(self.archiveFilename, output=output, package=self) if rv: return rv - + self.afterInstall() - + if self._dict.has_key('Post-install-command'): if _cmd(output, '/tmp', self._dict['Post-install-command']): return "%s: post-install: running \"%s\" failed" % \ (self.fullname(), self._dict['Post-install-command']) return None - - + + class PimpPackage_source(PimpPackage): def unpackPackageOnly(self, output=None): @@ -849,15 +852,15 @@ def installPackageOnly(self, output=None): """Install a single source package. - + If output is given it should be a file-like object and it will receive a log of what happened.""" - + if self._dict.has_key('Pre-install-command'): if _cmd(output, self._buildDirname, self._dict['Pre-install-command']): return "pre-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Pre-install-command']) - + self.beforeInstall() installcmd = self._dict.get('Install-command') if installcmd and self._install_renames: @@ -887,15 +890,15 @@ rv = None shutil.rmtree(unwanted_install_dir) return rv - + self.afterInstall() - + if self._dict.has_key('Post-install-command'): if _cmd(output, self._buildDirname, self._dict['Post-install-command']): return "post-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Post-install-command']) return None - + class PimpPackage_installer(PimpPackage): def unpackPackageOnly(self, output=None): @@ -927,36 +930,36 @@ if _cmd(output, "/tmp", installcmd): return '%s: install command failed (use verbose for details)' % self.fullname() return '%s: downloaded and opened. Install manually and restart Package Manager' % self.archiveFilename - + class PimpInstaller: """Installer engine: computes dependencies and installs packages in the right order.""" - + def __init__(self, db): self._todo = [] self._db = db self._curtodo = [] self._curmessages = [] - + def __contains__(self, package): return package in self._todo - + def _addPackages(self, packages): for package in packages: if not package in self._todo: self._todo.append(package) - + def _prepareInstall(self, package, force=0, recursive=1): """Internal routine, recursive engine for prepareInstall. - + Test whether the package is installed and (if not installed or if force==1) prepend it to the temporary todo list and call ourselves recursively on all prerequisites.""" - + if not force: status, message = package.installed() if status == "yes": - return + return if package in self._todo or package in self._curtodo: return self._curtodo.insert(0, package) @@ -968,17 +971,17 @@ self._prepareInstall(pkg, False, recursive) else: self._curmessages.append("Problem with dependency: %s" % descr) - + def prepareInstall(self, package, force=0, recursive=1): """Prepare installation of a package. - + If the package is already installed and force is false nothing is done. If recursive is true prerequisites are installed first. - + Returns a list of packages (to be passed to install) and a list of messages of any problems encountered. """ - + self._curtodo = [] self._curmessages = [] self._prepareInstall(package, force, recursive) @@ -986,10 +989,10 @@ self._curtodo = [] self._curmessages = [] return rv - + def install(self, packages, output): """Install a list of packages.""" - + self._addPackages(packages) status = [] for pkg in self._todo: @@ -997,12 +1000,12 @@ if msg: status.append(msg) return status - - - + + + def _run(mode, verbose, force, args, prefargs, watcher): """Engine for the main program""" - + prefs = PimpPreferences(**prefargs) if watcher: prefs.setWatcher(watcher) @@ -1011,7 +1014,7 @@ sys.stdout.write(rv) db = PimpDatabase(prefs) db.appendURL(prefs.pimpDatabase) - + if mode == 'dump': db.dump(sys.stdout) elif mode =='list': @@ -1086,7 +1089,7 @@ def main(): """Minimal commandline tool to drive pimp.""" - + import getopt def _help(): print "Usage: pimp [options] -s [package ...] List installed status" @@ -1101,12 +1104,12 @@ print " (default: %s)" % DEFAULT_INSTALLDIR print " -u url URL for database" sys.exit(1) - + class _Watcher: def update(self, msg): sys.stderr.write(msg + '\r') return 1 - + try: opts, args = getopt.getopt(sys.argv[1:], "slifvdD:Vu:") except getopt.GetoptError: @@ -1169,8 +1172,6 @@ (pimp_update.PIMP_VERSION, PIMP_VERSION)) else: from pimp_update import * - + if __name__ == '__main__': main() - - From jackjansen at users.sourceforge.net Fri Jan 7 15:19:37 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Fri Jan 7 15:19:47 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.12, 1.1193.2.13 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13298 Modified Files: Tag: release24-maint NEWS Log Message: Started on Macintosh section. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.12 retrieving revision 1.1193.2.13 diff -u -d -r1.1193.2.12 -r1.1193.2.13 --- NEWS 28 Dec 2004 20:12:30 -0000 1.1193.2.12 +++ NEWS 7 Jan 2005 14:19:30 -0000 1.1193.2.13 @@ -62,7 +62,25 @@ properly, or outdated; the MSI package now does not rely on VB anymore. +Macintosh +--------- + +- Bug #1091468: make frameworkinstall now works with DESTROOT builds + +- On 10.3 and later extensions are built with -undefined dynamic_lookup. + This ensures that extensions can be built in older versions of Python after + a newer framework has been installed. In addition, an extension will not + accidentally pull in another copy of the Python interpreter. + + On 10.2 and earlier (or if MACOSX_DEPLOYMENT_TARGET is set to a value <= 10.2) + extensions are linked directly to the dylib in the framework, in stead + of against the framework itself. This ensures that extensions can be built + in older versions of Python after a newer framework has been installed. +- PackageManager and the underlying pimp.py module have been updated to + version 0.5, which greatly simplifies maintainance of the package + databases. + What's New in Python 2.4 final? =============================== From akuchling at users.sourceforge.net Fri Jan 7 15:34:43 2005 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Fri Jan 7 15:34:46 2005 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew24.tex, 1.127, 1.128 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17628 Modified Files: whatsnew24.tex Log Message: [Bug 1083177] Describe signal() change; add a link Index: whatsnew24.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew24.tex,v retrieving revision 1.127 retrieving revision 1.128 diff -u -d -r1.127 -r1.128 --- whatsnew24.tex 1 Jan 2005 00:28:46 -0000 1.127 +++ whatsnew24.tex 7 Jan 2005 14:34:41 -0000 1.128 @@ -379,9 +379,11 @@ by Kevin D. Smith, Jim Jewett, and Skip Montanaro. Several people wrote patches implementing function decorators, but the one that was actually checked in was patch \#979728, written by Mark Russell.} -\end{seealso} -% XXX add link to decorators module in Wiki +\seeurl{http://www.python.org/moin/PythonDecoratorLibrary} +{This Wiki page contains several examples of decorators.} + +\end{seealso} %====================================================================== @@ -1426,6 +1428,12 @@ Python 2.4's regular expression engine can match this pattern without problems. +\item The \module{signal} module now performs tighter error-checking +on the parameters to the \function{signal.signal()} function. For +example, you can't set a handler on the \constant{SIGKILL} signal; +previous versions of Python would quietly accept this, but 2.4 will +raise a \exception{RuntimeError} exception. + \item Two new functions were added to the \module{socket} module. \function{socketpair()} returns a pair of connected sockets and \function{getservbyport(\var{port})} looks up the service name for a @@ -1724,8 +1732,10 @@ \item \constant{None} is now a constant; code that binds a new value to the name \samp{None} is now a syntax error. -% signal module now raises a RuntimeError on insane calls - e.g. setting a -% handler on SIGKILL +\item The \function{signals.signal()} function now raises a +\exception{RuntimeError} exception for certain illegal values; +previously these errors would pass silently. For example, you can no +longer set a handler on the \constant{SIGKILL} signal. \end{itemize} From akuchling at users.sourceforge.net Fri Jan 7 15:43:42 2005 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Fri Jan 7 15:43:45 2005 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew23.tex, 1.159.4.4, 1.159.4.5 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19765 Modified Files: Tag: release23-maint whatsnew23.tex Log Message: Backport latest version of whatsnew23: fix typos, remove a GC-related item; add an item Index: whatsnew23.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew23.tex,v retrieving revision 1.159.4.4 retrieving revision 1.159.4.5 diff -u -d -r1.159.4.4 -r1.159.4.5 --- whatsnew23.tex 11 Nov 2004 06:16:42 -0000 1.159.4.4 +++ whatsnew23.tex 7 Jan 2005 14:43:39 -0000 1.159.4.5 @@ -3,9 +3,12 @@ % $Id$ \title{What's New in Python 2.3} -\release{1.00} +\release{1.01} \author{A.M.\ Kuchling} -\authoraddress{\email{amk@amk.ca}} +\authoraddress{ + \strong{Python Software Foundation}\\ + Email: \email{amk@amk.ca} +} \begin{document} \maketitle @@ -2136,33 +2139,6 @@ \begin{itemize} -\item The C-level interface to the garbage collector has been changed -to make it easier to write extension types that support garbage -collection and to debug misuses of the functions. -Various functions have slightly different semantics, so a bunch of -functions had to be renamed. Extensions that use the old API will -still compile but will \emph{not} participate in garbage collection, -so updating them for 2.3 should be considered fairly high priority. - -To upgrade an extension module to the new API, perform the following -steps: - -\begin{itemize} - -\item Rename \cfunction{Py_TPFLAGS_GC} to \cfunction{PyTPFLAGS_HAVE_GC}. - -\item Use \cfunction{PyObject_GC_New} or \cfunction{PyObject_GC_NewVar} to -allocate objects, and \cfunction{PyObject_GC_Del} to deallocate them. - -\item Rename \cfunction{PyObject_GC_Init} to \cfunction{PyObject_GC_Track} and -\cfunction{PyObject_GC_Fini} to \cfunction{PyObject_GC_UnTrack}. - -\item Remove \cfunction{PyGC_HEAD_SIZE} from object size calculations. - -\item Remove calls to \cfunction{PyObject_AS_GC} and \cfunction{PyObject_FROM_GC}. - -\end{itemize} - \item The cycle detection implementation used by the garbage collection has proven to be stable, so it's now been made mandatory. You can no longer compile Python without it, and the @@ -2196,6 +2172,11 @@ \code{PyArg_ParseTuple(\var{args}, "")} instead, but this will be slower than using \constant{METH_NOARGS}. +\item \cfunction{PyArg_ParseTuple()} accepts new format characters for various sizes of unsigned integers: \samp{B} for \ctype{unsigned char}, +\samp{H} for \ctype{unsigned short int}, +\samp{I} for \ctype{unsigned int}, +and \samp{K} for \ctype{unsigned long long}. + \item A new function, \cfunction{PyObject_DelItemString(\var{mapping}, char *\var{key})} was added as shorthand for \code{PyObject_DelItem(\var{mapping}, PyString_New(\var{key}))}. @@ -2242,7 +2223,7 @@ On MacOS, most toolbox modules have been weaklinked to improve backward compatibility. This means that modules will no longer fail -to load if a single routine is missing on the curent OS version. +to load if a single routine is missing on the current OS version. Instead calling the missing routine will raise an exception. (Contributed by Jack Jansen.) @@ -2388,7 +2369,7 @@ The author would like to thank the following people for offering suggestions, corrections and assistance with various drafts of this article: Jeff Bauer, Simon Brunning, Brett Cannon, Michael Chermside, -Andrew Dalke, Scott David Daniels, Fred~L. Drake, Jr., David Fraser, +Andrew Dalke, Scott David Daniels, Fred~L. Drake, Jr., David Fraser, Kelly Gerber, Raymond Hettinger, Michael Hudson, Chris Lambert, Detlef Lannert, Martin von~L\"owis, Andrew MacIntyre, Lalo Martins, Chad Netzer, From jackjansen at users.sourceforge.net Fri Jan 7 16:41:17 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Fri Jan 7 16:41:20 2005 Subject: [Python-checkins] python/dist/src/Mac/OSX/Dist build,1.13,1.13.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX/Dist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32466 Modified Files: Tag: release24-maint build Log Message: Starting on the 2.4 MacPython installer. Index: build =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/Dist/build,v retrieving revision 1.13 retrieving revision 1.13.4.1 diff -u -d -r1.13 -r1.13.4.1 --- build 19 Nov 2003 13:53:55 -0000 1.13 +++ build 7 Jan 2005 15:41:14 -0000 1.13.4.1 @@ -1,11 +1,11 @@ #!/bin/sh -e #---------------------------------------------------------------------- -# Build MacPython 2.3 and make an Installer package of it +# Build MacPython 2.4 and make an Installer package of it # TODO: Parameterize the versions, builddirs, etc... # Script configs -PYVERSION=2.4a0 +PYVERSION=2.4.1 PYVER=2.4 BUILDNUM=1 DOCLEANUP=no @@ -19,6 +19,16 @@ ;; esac +if [ ! -e /usr/bin/python ]; then + echo "No /usr/bin/python; this script expects to be run on 10.3 only" + exit 1 +fi +vers=`/usr/bin/python -V 2>&1` +if [ "$vers" != "Python 2.3" ]; then + echo "/usr/bin/python is not version 2.3; this script expects to be run on 10.3 only" + exit 1 +fi + TMPDIR=/tmp/_py #TMPDIR=/projects/_py @@ -29,6 +39,20 @@ PYTHONSRC=$PROGDIR/../../.. WASTEDIR=$PYTHONSRC/../waste +# Check that the Apple Python 2.3 Makefile fixes have been applied on this +# machine +if python $PYTHONSRCDIR/Mac/OSX/fixapplepython23.py -n; then + : +else + echo + echo This installer will also install a fix to Apple-installed 2.3 + echo to make building extensions work in the face of other Pythons. + echo But this system needs to have that fix to be able to put it in the installer. + echo + echo Please run $PYTHONSRCDIR/Mac/OSX/fixapplepython23.py to install the fix. + exit +fi + case x$1 in x) BUILDROOT=$TMPDIR/build @@ -66,12 +90,6 @@ exit fi -# Check if we should build and install the docs, but only if it -# doesn't appear to be done already. TODO: fix this path to be version independent -if [ ! -e "build/temp.darwin-6.3-Power Macintosh-2.3/build-html/build-html idx" ]; then - read -p "Build the Python docs? (y/N)? " builddocs -fi - # If the filesystem is case-sensitive then "python" will be built, but # some parts of the install expect "python.exe which is what is built # on a case-insensitive filesystem. Make a link just in case it is @@ -91,6 +109,10 @@ make DIRMODE=775 EXEMODE=775 FILEMODE=664 DESTDIR=$INSTALLROOT frameworkinstall make DIRMODE=775 EXEMODE=775 FILEMODE=664 DESTDIR=$INSTALLROOT frameworkinstallextras +# Install the Makefile fixes +config=System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config +(cd / ; tar cf - $config/Makefile $config/PantherPythonFix) | (cd $INSTALLROOT; tar xf -) + # Unfortunately all the ...MODE arguments above still don't do the trick. # Cop out, and recursively set everything group-writeable. chmod -R ug+w $INSTALLROOT @@ -121,7 +143,7 @@ python $PYTHONSRC/Mac/scripts/buildpkg.py \ --Title=MacPython-OSX \ --Version=$PYVERSION-$BUILDNUM \ - --Description="Python $PYVERSION for Mac OS X, framework based" \ + --Description="Python $PYVERSION for Mac OS X 10.3, framework based" \ --NeedsAuthorization="YES" \ --Relocatable="NO" \ --InstallOnly="YES" \ From jackjansen at users.sourceforge.net Fri Jan 7 16:41:18 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Fri Jan 7 16:41:22 2005 Subject: [Python-checkins] python/dist/src/Mac/OSX/Dist/resources ReadMe.txt, 1.2, 1.2.4.1 Welcome.rtf, 1.2, 1.2.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX/Dist/resources In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32466/resources Modified Files: Tag: release24-maint ReadMe.txt Welcome.rtf Log Message: Starting on the 2.4 MacPython installer. Index: ReadMe.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/Dist/resources/ReadMe.txt,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -u -d -r1.2 -r1.2.4.1 --- ReadMe.txt 19 Nov 2003 13:53:55 -0000 1.2 +++ ReadMe.txt 7 Jan 2005 15:41:15 -0000 1.2.4.1 @@ -1,6 +1,6 @@ -This package will install MacPython 2.3.2 for Mac OS X -10.2. Installation on the Panther preview may work, on -10.1 or earlier will not work. +This package will install MacPython 2.4.1 for Mac OS X +10.3. Separate installers are available for older versions +of MacOSX, see the homepage, below. Installation requires approximately 20 MB of disk space, ignore the message that it will take zero bytes. @@ -27,6 +27,6 @@ references to other documentation. More information on MacPython can be found at -http://www.cwi.nl/~jack/macpython.html, more +http://www.cwi.nl/~jack/macpython, more information on Python in general at http://www.python.org. Index: Welcome.rtf =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/Dist/resources/Welcome.rtf,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -u -d -r1.2 -r1.2.4.1 --- Welcome.rtf 19 Nov 2003 13:53:55 -0000 1.2 +++ Welcome.rtf 7 Jan 2005 15:41:15 -0000 1.2.4.1 @@ -5,10 +5,10 @@ \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural \f0\fs24 \cf0 This package will install -\f1\b MacPython 2.3 +\f1\b MacPython 2.4.1 \f0\b0 for -\f1\b Mac OS X 10.2 -\f0\b0 . Installation on the Panther preview may work, on 10.1 or earlier will not work.\ +\f1\b Mac OS X 10.3 +\f0\b0 .\ \ MacPython consists of the Python programming language interpreter, plus a set of programs to allow easy access to it for Mac users (an integrated development environment, a Python extension package manager), plus a set of pre-built extension modules that open up specific Macintosh technologies to Python programs (Carbon, AppleScript, Quicktime, more).\ \ From tim_one at users.sourceforge.net Fri Jan 7 17:01:35 2005 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Jan 7 17:01:37 2005 Subject: [Python-checkins] python/dist/src/Tools/i18n makelocalealias.py, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/i18n In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4661/Tools/i18n Modified Files: makelocalealias.py Log Message: Whitespace normalization. Index: makelocalealias.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/i18n/makelocalealias.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- makelocalealias.py 13 Dec 2004 19:56:01 -0000 1.2 +++ makelocalealias.py 7 Jan 2005 16:01:25 -0000 1.3 @@ -62,7 +62,7 @@ print '# updated %r -> %r to %r' % \ (k, olddata[k], data[k]) # Additions are not mentioned - + if __name__ == '__main__': data = locale.locale_alias.copy() data.update(parse(LOCALE_ALIAS)) @@ -71,4 +71,3 @@ print 'locale_alias = {' pprint(data) print '}' - From tim_one at users.sourceforge.net Fri Jan 7 17:01:36 2005 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Jan 7 17:01:39 2005 Subject: [Python-checkins] python/dist/src/Tools/msi msi.py,1.21,1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4661/Tools/msi Modified Files: msi.py Log Message: Whitespace normalization. Index: msi.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/msi/msi.py,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- msi.py 30 Dec 2004 14:08:18 -0000 1.21 +++ msi.py 7 Jan 2005 16:01:32 -0000 1.22 @@ -977,7 +977,7 @@ lib.add_file('python%s%s.lib' % (major, minor)) # Add the mingw-format library if have_mingw: - lib.add_file('libpython%s%s.a' % (major, minor)) + lib.add_file('libpython%s%s.a' % (major, minor)) if have_tcl: # Add Tcl/Tk tcldirs = [(root, '../tcltk/lib', 'tcl')] From tim_one at users.sourceforge.net Fri Jan 7 17:02:02 2005 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Jan 7 17:02:05 2005 Subject: [Python-checkins] python/dist/src/Mac/OSX fixapplepython23.py, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4661/Mac/OSX Modified Files: fixapplepython23.py Log Message: Whitespace normalization. Index: fixapplepython23.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/fixapplepython23.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- fixapplepython23.py 1 Jan 2005 22:33:36 -0000 1.3 +++ fixapplepython23.py 7 Jan 2005 16:01:24 -0000 1.4 @@ -43,12 +43,12 @@ if lines[i][:len(start)] == start: return i return -1 - + def fix(makefile, do_apply): """Fix the Makefile, if required.""" fixed = False lines = open(makefile).readlines() - + for old, new in CHANGES: i = findline(lines, new) if i >= 0: @@ -61,7 +61,7 @@ return 2 lines[i] = new fixed = True - + if fixed: if do_apply: print 'fixapplepython23: Fix to Apple-installed Python 2.3 applied' @@ -74,7 +74,7 @@ else: print 'fixapplepython23: No fix needed, appears to have been applied before' return 0 - + def makescript(filename, compiler): """Create a wrapper script for a compiler""" dirname = os.path.split(filename)[0] @@ -85,7 +85,7 @@ fp.close() os.chmod(filename, 0755) print 'fixapplepython23: Created', filename - + def main(): # Check for -n option if len(sys.argv) > 1 and sys.argv[1] == '-n': @@ -113,7 +113,6 @@ # Finally fix the makefile rv = fix(MAKEFILE, do_apply) sys.exit(rv) - + if __name__ == '__main__': main() - From tim_one at users.sourceforge.net Fri Jan 7 17:02:03 2005 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Jan 7 17:02:05 2005 Subject: [Python-checkins] python/dist/src/Lib/plat-mac bundlebuilder.py, 1.37, 1.38 pimp.py, 1.38, 1.39 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/plat-mac In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4661/Lib/plat-mac Modified Files: bundlebuilder.py pimp.py Log Message: Whitespace normalization. Index: bundlebuilder.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/bundlebuilder.py,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- bundlebuilder.py 27 Dec 2004 15:51:03 -0000 1.37 +++ bundlebuilder.py 7 Jan 2005 16:01:21 -0000 1.38 @@ -110,7 +110,7 @@ # Verbosity level. verbosity = 1 - + # Destination root directory destroot = "" Index: pimp.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/pimp.py,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- pimp.py 7 Jan 2005 13:43:31 -0000 1.38 +++ pimp.py 7 Jan 2005 16:01:22 -0000 1.39 @@ -907,10 +907,10 @@ def installPackageOnly(self, output=None): """Install a single source package. - + If output is given it should be a file-like object and it will receive a log of what happened.""" - + if self._dict.has_key('Post-install-command'): return "%s: Installer package cannot have Post-install-command" % self.fullname() @@ -918,7 +918,7 @@ if _cmd(output, '/tmp', self._dict['Pre-install-command']): return "pre-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Pre-install-command']) - + self.beforeInstall() installcmd = self._dict.get('Install-command') @@ -926,7 +926,7 @@ if '%' in installcmd: installcmd = installcmd % self.archiveFilename else: - installcmd = 'open \"%s\"' % self.archiveFilename + installcmd = 'open \"%s\"' % self.archiveFilename if _cmd(output, "/tmp", installcmd): return '%s: install command failed (use verbose for details)' % self.fullname() return '%s: downloaded and opened. Install manually and restart Package Manager' % self.archiveFilename From tim_one at users.sourceforge.net Fri Jan 7 17:02:03 2005 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Jan 7 17:02:07 2005 Subject: [Python-checkins] python/dist/src/Lib/test inspect_fodder2.py, 1.2, 1.3 test_csv.py, 1.14, 1.15 test_inspect.py, 1.18, 1.19 test_zlib.py, 1.27, 1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4661/Lib/test Modified Files: inspect_fodder2.py test_csv.py test_inspect.py test_zlib.py Log Message: Whitespace normalization. Index: inspect_fodder2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/inspect_fodder2.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- inspect_fodder2.py 12 Dec 2004 16:46:28 -0000 1.2 +++ inspect_fodder2.py 7 Jan 2005 16:01:23 -0000 1.3 @@ -1,25 +1,25 @@ # line 1 def wrap(foo=None): - def wrapper(func): - return func - return wrapper + def wrapper(func): + return func + return wrapper # line 7 def replace(func): - def insteadfunc(): - print 'hello' - return insteadfunc + def insteadfunc(): + print 'hello' + return insteadfunc # line 13 @wrap() @wrap(wrap) def wrapped(): - pass + pass # line 19 @replace def gone(): - pass + pass # line 24 oll = lambda m: m Index: test_csv.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_csv.py,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- test_csv.py 7 Jan 2005 04:42:45 -0000 1.14 +++ test_csv.py 7 Jan 2005 16:01:23 -0000 1.15 @@ -33,7 +33,7 @@ self.assertRaises(TypeError, ctor, arg, quoting=None) # We now allow this, only raising an exception if quoting is needed. # self.assertRaises(TypeError, ctor, arg, quotechar=None) -# self.assertRaises(TypeError, ctor, arg, +# self.assertRaises(TypeError, ctor, arg, # quoting=csv.QUOTE_NONE, escapechar=None) # No longer complains about dialects with invalid attributes [AM] # class BadDialect: Index: test_inspect.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_inspect.py,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- test_inspect.py 12 Dec 2004 16:46:28 -0000 1.18 +++ test_inspect.py 7 Jan 2005 16:01:23 -0000 1.19 @@ -31,11 +31,11 @@ predicates = set([inspect.isbuiltin, inspect.isclass, inspect.iscode, inspect.isframe, inspect.isfunction, inspect.ismethod, inspect.ismodule, inspect.istraceback]) - + def istest(self, predicate, exp): obj = eval(exp) self.failUnless(predicate(obj), '%s(%s)' % (predicate.__name__, exp)) - + for other in self.predicates - set([predicate]): self.failIf(other(obj), 'not %s(%s)' % (other.__name__, exp)) @@ -44,7 +44,7 @@ # Doc/lib/libinspect.tex claims there are 11 such functions count = len(filter(lambda x:x.startswith('is'), dir(inspect))) self.assertEqual(count, 11, "There are %d (not 11) is* functions" % count) - + def test_excluding_predicates(self): self.istest(inspect.isbuiltin, 'sys.exit') self.istest(inspect.isbuiltin, '[].append') @@ -66,7 +66,7 @@ class TestInterpreterStack(IsTestBase): def __init__(self, *args, **kwargs): unittest.TestCase.__init__(self, *args, **kwargs) - + git.abuse(7, 8, 9) def test_abuse_done(self): @@ -76,7 +76,7 @@ def test_stack(self): self.assert_(len(mod.st) >= 5) self.assertEqual(mod.st[0][1:], - (modfile, 16, 'eggs', [' st = inspect.stack()\n'], 0)) + (modfile, 16, 'eggs', [' st = inspect.stack()\n'], 0)) self.assertEqual(mod.st[1][1:], (modfile, 9, 'spam', [' eggs(b + d, c + f)\n'], 0)) self.assertEqual(mod.st[2][1:], @@ -113,7 +113,7 @@ class GetSourceBase(unittest.TestCase): # Subclasses must override. fodderFile = None - + def __init__(self, *args, **kwargs): unittest.TestCase.__init__(self, *args, **kwargs) @@ -126,10 +126,10 @@ def assertSourceEqual(self, obj, top, bottom): self.assertEqual(inspect.getsource(obj), self.sourcerange(top, bottom)) - + class TestRetrievingSourceCode(GetSourceBase): fodderFile = mod - + def test_getclasses(self): classes = inspect.getmembers(mod, inspect.isclass) self.assertEqual(classes, @@ -147,7 +147,7 @@ ] ] ]) - + def test_getfunctions(self): functions = inspect.getmembers(mod, inspect.isfunction) self.assertEqual(functions, [('eggs', mod.eggs), @@ -172,8 +172,8 @@ self.assertSourceEqual(mod.StupidGit, 21, 46) def test_getsourcefile(self): - self.assertEqual(inspect.getsourcefile(mod.spam), modfile) - self.assertEqual(inspect.getsourcefile(git.abuse), modfile) + self.assertEqual(inspect.getsourcefile(mod.spam), modfile) + self.assertEqual(inspect.getsourcefile(git.abuse), modfile) def test_getfile(self): self.assertEqual(inspect.getfile(mod.StupidGit), mod.__file__) @@ -192,38 +192,38 @@ def test_oneline_lambda(self): # Test inspect.getsource with a one-line lambda function. self.assertSourceEqual(mod2.oll, 25, 25) - + def test_threeline_lambda(self): # Test inspect.getsource with a three-line lambda function, # where the second and third lines are _not_ indented. - self.assertSourceEqual(mod2.tll, 28, 30) - + self.assertSourceEqual(mod2.tll, 28, 30) + def test_twoline_indented_lambda(self): # Test inspect.getsource with a two-line lambda function, # where the second line _is_ indented. self.assertSourceEqual(mod2.tlli, 33, 34) - + def test_onelinefunc(self): # Test inspect.getsource with a regular one-line function. self.assertSourceEqual(mod2.onelinefunc, 37, 37) - + def test_manyargs(self): # Test inspect.getsource with a regular function where # the arguments are on two lines and _not_ indented and # the body on the second line with the last arguments. self.assertSourceEqual(mod2.manyargs, 40, 41) - + def test_twolinefunc(self): # Test inspect.getsource with a regular function where # the body is on two lines, following the argument list and # continued on the next line by a \\. self.assertSourceEqual(mod2.twolinefunc, 44, 45) - + def test_lambda_in_list(self): # Test inspect.getsource with a one-line lambda function # defined in a list, indented. self.assertSourceEqual(mod2.a[1], 49, 49) - + def test_anonymous(self): # Test inspect.getsource with a lambda function defined # as argument to another function. @@ -233,7 +233,7 @@ def attrs_wo_objs(cls): return [t[:3] for t in inspect.classify_class_attrs(cls)] -class TestClassesAndFunctions(unittest.TestCase): +class TestClassesAndFunctions(unittest.TestCase): def test_classic_mro(self): # Test classic-class method resolution order. class A: pass @@ -284,7 +284,7 @@ def test_getargspec_sublistofone(self): def sublistOfOne((foo)): return 1 - + self.assertArgSpecEquals(sublistOfOne, [['foo']]) def test_classify_oldstyle(self): @@ -418,4 +418,3 @@ if __name__ == "__main__": test_main() - Index: test_zlib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_zlib.py,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- test_zlib.py 28 Dec 2004 20:10:37 -0000 1.27 +++ test_zlib.py 7 Jan 2005 16:01:24 -0000 1.28 @@ -299,7 +299,7 @@ self.failUnless(co.flush()) # Returns a zlib header dco = zlib.decompressobj() self.assertEqual(dco.flush(), "") # Returns nothing - + def genblock(seed, length, step=1024, generator=random): """length-byte stream of random data from a seed (in step-byte blocks).""" From kbk at users.sourceforge.net Fri Jan 7 18:25:21 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Fri Jan 7 18:25:24 2005 Subject: [Python-checkins] python/dist/src/Python pythonrun.c, 2.161.2.15, 2.161.2.16 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24849/Python Modified Files: Tag: ast-branch pythonrun.c Log Message: Remove extra bracket from conflict merge. Index: pythonrun.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v retrieving revision 2.161.2.15 retrieving revision 2.161.2.16 diff -u -d -r2.161.2.15 -r2.161.2.16 --- pythonrun.c 7 Jan 2005 07:04:57 -0000 2.161.2.15 +++ pythonrun.c 7 Jan 2005 17:25:18 -0000 2.161.2.16 @@ -1444,7 +1444,6 @@ fprintf(stderr, "error=%d\n", err->error); msg = "unknown parsing error"; break; - } } v = Py_BuildValue("(ziiz)", err->filename, err->lineno, err->offset, err->text); From arigo at users.sourceforge.net Fri Jan 7 19:10:56 2005 From: arigo at users.sourceforge.net (arigo@users.sourceforge.net) Date: Fri Jan 7 19:10:59 2005 Subject: [Python-checkins] python/dist/src/Python compile.c,2.338,2.339 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3790 Modified Files: compile.c Log Message: Re-running python with/without the -Qnew flag uses incorrectly optimized bytecodes from the previously saved .pyc files. Fixed by disabling the static optimization of BINARY_DIVIDE between two constants. Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.338 retrieving revision 2.339 diff -u -d -r2.338 -r2.339 --- compile.c 2 Jan 2005 06:17:33 -0000 2.338 +++ compile.c 7 Jan 2005 18:10:51 -0000 2.339 @@ -468,12 +468,9 @@ newconst = PyNumber_Multiply(v, w); break; case BINARY_DIVIDE: - if (!_Py_QnewFlag) { - newconst = PyNumber_Divide(v, w); - break; - } - /* -Qnew is in effect: fall through to - BINARY_TRUE_DIVIDE */ + /* XXX care is needed to fold this operation statically: + the result might depend on the run-time presence of the -Qnew flag */ + return 0; case BINARY_TRUE_DIVIDE: newconst = PyNumber_TrueDivide(v, w); break; From rhettinger at users.sourceforge.net Fri Jan 7 19:35:00 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Jan 7 19:35:03 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_peepholer.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-serv9394 Modified Files: test_peepholer.py Log Message: Remove test for BINARY_DIVIDE. Index: test_peepholer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_peepholer.py,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- test_peepholer.py 2 Jan 2005 06:17:32 -0000 1.6 +++ test_peepholer.py 7 Jan 2005 18:34:56 -0000 1.7 @@ -109,7 +109,6 @@ ('a="abc" + "def"', "('abcdef')"), # check string ops ('a = 3**4', '(81)'), # binary power ('a = 3*4', '(12)'), # binary multiply - ('a = 13/4.0', '(3.25)'), # binary divide ('a = 13//4', '(3)'), # binary floor divide ('a = 14%4', '(2)'), # binary modulo ('a = 2+3', '(5)'), # binary add From bcannon at users.sourceforge.net Sat Jan 8 03:44:04 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Jan 8 03:44:07 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1216,1.1217 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24321/Misc Modified Files: NEWS Log Message: In _DummyThread objects the lock stored in __block (allocated thanks to _Thread.__init__) was never used. This is a waste since locks use OS primitives that are in limited supply. So the lock is deleted in _DummyThread.__init__ . Closes bug #1089632. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1216 retrieving revision 1.1217 diff -u -d -r1.1216 -r1.1217 --- NEWS 7 Jan 2005 08:15:41 -0000 1.1216 +++ NEWS 8 Jan 2005 02:43:53 -0000 1.1217 @@ -33,6 +33,11 @@ Library ------- +- _DummyThread objects in the threading module now delete self.__block that is + inherited from _Thread since it uses up a lock allocated by 'thread'. The + lock primitives tend to be limited in number and thus should not be wasted on + a _DummyThread object. Fixes bug #1089632. + - The imghdr module now detects Exif files. - StringIO.truncate() now correctly adjusts the size attribute. From bcannon at users.sourceforge.net Sat Jan 8 03:44:26 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Jan 8 03:44:29 2005 Subject: [Python-checkins] python/dist/src/Lib threading.py,1.45,1.46 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24321/Lib Modified Files: threading.py Log Message: In _DummyThread objects the lock stored in __block (allocated thanks to _Thread.__init__) was never used. This is a waste since locks use OS primitives that are in limited supply. So the lock is deleted in _DummyThread.__init__ . Closes bug #1089632. Index: threading.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/threading.py,v retrieving revision 1.45 retrieving revision 1.46 diff -u -d -r1.45 -r1.46 --- threading.py 21 Jul 2004 03:36:52 -0000 1.45 +++ threading.py 8 Jan 2005 02:43:51 -0000 1.46 @@ -653,6 +653,7 @@ def __init__(self): Thread.__init__(self, name=_newname("Dummy-%d")) + del self._Thread__block self._Thread__started = True _active_limbo_lock.acquire() _active[_get_ident()] = self From tim_one at users.sourceforge.net Sat Jan 8 07:03:20 2005 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sat Jan 8 07:03:23 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_threading.py, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32327/Lib/test Modified Files: test_threading.py Log Message: Converted to a unittest. Added checks that the bounded semaphore actually does what it's supposed to do. Index: test_threading.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_threading.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- test_threading.py 23 Jul 2002 19:04:06 -0000 1.3 +++ test_threading.py 8 Jan 2005 06:03:17 -0000 1.4 @@ -1,55 +1,91 @@ # Very rudimentary test of threading module -# Create a bunch of threads, let each do some work, wait until all are done - +import test.test_support from test.test_support import verbose import random import threading import time +import unittest -# This takes about n/3 seconds to run (about n/3 clumps of tasks, times -# about 1 second per clump). -numtasks = 10 - -# no more than 3 of the 10 can run at once -sema = threading.BoundedSemaphore(value=3) -mutex = threading.RLock() -running = 0 +# A trivial mutable counter. +class Counter(object): + def __init__(self): + self.value = 0 + def inc(self): + self.value += 1 + def dec(self): + self.value -= 1 + def get(self): + return self.value class TestThread(threading.Thread): + def __init__(self, name, testcase, sema, mutex, nrunning): + threading.Thread.__init__(self, name=name) + self.testcase = testcase + self.sema = sema + self.mutex = mutex + self.nrunning = nrunning + def run(self): - global running delay = random.random() * 2 if verbose: print 'task', self.getName(), 'will run for', delay, 'sec' - sema.acquire() - mutex.acquire() - running = running + 1 + + self.sema.acquire() + + self.mutex.acquire() + self.nrunning.inc() if verbose: - print running, 'tasks are running' - mutex.release() + print self.nrunning.get(), 'tasks are running' + self.testcase.assert_(self.nrunning.get() <= 3) + self.mutex.release() + time.sleep(delay) if verbose: print 'task', self.getName(), 'done' - mutex.acquire() - running = running - 1 + + self.mutex.acquire() + self.nrunning.dec() + self.testcase.assert_(self.nrunning.get() >= 0) if verbose: - print self.getName(), 'is finished.', running, 'tasks are running' - mutex.release() - sema.release() + print self.getName(), 'is finished.', self.nrunning.get(), \ + 'tasks are running' + self.mutex.release() -threads = [] -def starttasks(): - for i in range(numtasks): - t = TestThread(name=""%i) - threads.append(t) - t.start() + self.sema.release() -starttasks() +class ThreadTests(unittest.TestCase): -if verbose: - print 'waiting for all tasks to complete' -for t in threads: - t.join() -if verbose: - print 'all tasks done' + # Create a bunch of threads, let each do some work, wait until all are + # done. + def test_various_ops(self): + # This takes about n/3 seconds to run (about n/3 clumps of tasks, + # times about 1 second per clump). + NUMTASKS = 10 + + # no more than 3 of the 10 can run at once + sema = threading.BoundedSemaphore(value=3) + mutex = threading.RLock() + numrunning = Counter() + + threads = [] + + for i in range(NUMTASKS): + t = TestThread(""%i, self, sema, mutex, numrunning) + threads.append(t) + t.start() + + if verbose: + print 'waiting for all tasks to complete' + for t in threads: + t.join() + if verbose: + print 'all tasks done' + self.assertEqual(numrunning.get(), 0) + + +def test_main(): + test.test_support.run_unittest(ThreadTests) + +if __name__ == "__main__": + test_main() From tim_one at users.sourceforge.net Sat Jan 8 08:30:45 2005 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sat Jan 8 08:30:48 2005 Subject: [Python-checkins] python/dist/src/Lib threading.py,1.46,1.47 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21399/Lib Modified Files: threading.py Log Message: threading._DummyThread.__init__(): document obscure new code. test_threading.test_foreign_thread(): new test does a basic check that "foreign" threads can using the threading module, and that they create a _DummyThread instance in at least one use case. This isn't a very good test, since a thread created by thread.start_new_thread() isn't particularly "foreign". Index: threading.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/threading.py,v retrieving revision 1.46 retrieving revision 1.47 diff -u -d -r1.46 -r1.47 --- threading.py 8 Jan 2005 02:43:51 -0000 1.46 +++ threading.py 8 Jan 2005 07:30:42 -0000 1.47 @@ -358,7 +358,7 @@ # Active thread administration _active_limbo_lock = _allocate_lock() -_active = {} +_active = {} # maps thread id to Thread object _limbo = {} @@ -643,8 +643,9 @@ # Dummy thread class to represent threads not started here. -# These aren't garbage collected when they die, -# nor can they be waited for. +# These aren't garbage collected when they die, nor can they be waited for. +# If they invoke anything in threading.py that calls currentThread(), they +# leave an entry in the _active dict forever after. # Their purpose is to return *something* from currentThread(). # They are marked as daemon threads so we won't wait for them # when we exit (conform previous semantics). @@ -653,7 +654,12 @@ def __init__(self): Thread.__init__(self, name=_newname("Dummy-%d")) + + # Thread.__block consumes an OS-level locking primitive, which + # can never be used by a _DummyThread. Since a _DummyThread + # instance is immortal, that's bad, so release this resource. del self._Thread__block + self._Thread__started = True _active_limbo_lock.acquire() _active[_get_ident()] = self From tim_one at users.sourceforge.net Sat Jan 8 08:30:45 2005 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sat Jan 8 08:30:49 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_threading.py, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21399/Lib/test Modified Files: test_threading.py Log Message: threading._DummyThread.__init__(): document obscure new code. test_threading.test_foreign_thread(): new test does a basic check that "foreign" threads can using the threading module, and that they create a _DummyThread instance in at least one use case. This isn't a very good test, since a thread created by thread.start_new_thread() isn't particularly "foreign". Index: test_threading.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_threading.py,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- test_threading.py 8 Jan 2005 06:03:17 -0000 1.4 +++ test_threading.py 8 Jan 2005 07:30:42 -0000 1.5 @@ -4,6 +4,7 @@ from test.test_support import verbose import random import threading +import thread import time import unittest @@ -78,11 +79,31 @@ if verbose: print 'waiting for all tasks to complete' for t in threads: - t.join() + t.join(NUMTASKS) + self.assert_(not t.isAlive()) if verbose: print 'all tasks done' self.assertEqual(numrunning.get(), 0) + def test_foreign_thread(self): + # Check that a "foreign" thread can use the threading module. + def f(mutex): + # Acquiring an RLock forces an entry for the foreign + # thread to get made in the threading._active map. + r = threading.RLock() + r.acquire() + r.release() + mutex.release() + + mutex = threading.Lock() + mutex.acquire() + tid = thread.start_new_thread(f, (mutex,)) + # Wait for the thread to finish. + mutex.acquire() + self.assert_(tid in threading._active) + self.assert_(isinstance(threading._active[tid], + threading._DummyThread)) + del threading._active[tid] def test_main(): test.test_support.run_unittest(ThreadTests) From jlgijsbers at users.sourceforge.net Sat Jan 8 13:31:31 2005 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sat Jan 8 13:31:34 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libshutil.tex,1.15,1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv819/Doc/lib Modified Files: libshutil.tex Log Message: Patch #1094015: * Use os.makedirs() instead os.mkdir(). (bug #975763) * Use copystat() to copy directory bits (bug #1048878) Index: libshutil.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libshutil.tex,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- libshutil.tex 14 Jul 2004 00:48:58 -0000 1.15 +++ libshutil.tex 8 Jan 2005 12:31:28 -0000 1.16 @@ -67,8 +67,10 @@ \begin{funcdesc}{copytree}{src, dst\optional{, symlinks}} Recursively copy an entire directory tree rooted at \var{src}. The destination directory, named by \var{dst}, must not already exist; - it will be created. Individual files are copied using - \function{copy2()}. If \var{symlinks} is true, symbolic links in + it will be created as well as missing parent directories. + Permissions and times of directories are copied with \function{copystat()}, + individual files are copied using \function{copy2()}. + If \var{symlinks} is true, symbolic links in the source tree are represented as symbolic links in the new tree; if false or omitted, the contents of the linked files are copied to the new tree. If exception(s) occur, an Error is raised @@ -76,8 +78,14 @@ The source code for this should be considered an example rather than a tool. -\versionchanged[Error is raised if any exceptions occur during copying, -rather than printing a message]{2.3} + + \versionchanged[Error is raised if any exceptions occur during copying, + rather than printing a message]{2.3} + + \versionchanged[Create intermediate directories needed to create \var{dst}, + rather than raising an error. Copy permissions and times of directories using + \function{copystat()}]{2.5} + \end{funcdesc} \begin{funcdesc}{rmtree}{path\optional{, ignore_errors\optional{, onerror}}} From jlgijsbers at users.sourceforge.net Sat Jan 8 13:31:31 2005 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sat Jan 8 13:31:35 2005 Subject: [Python-checkins] python/dist/src/Lib shutil.py,1.34,1.35 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv819/Lib Modified Files: shutil.py Log Message: Patch #1094015: * Use os.makedirs() instead os.mkdir(). (bug #975763) * Use copystat() to copy directory bits (bug #1048878) Index: shutil.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/shutil.py,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- shutil.py 31 Oct 2004 12:05:31 -0000 1.34 +++ shutil.py 8 Jan 2005 12:31:29 -0000 1.35 @@ -108,7 +108,8 @@ """ names = os.listdir(src) - os.mkdir(dst) + os.makedirs(dst) + copystat(src, dst) errors = [] for name in names: srcname = os.path.join(src, name) From jlgijsbers at users.sourceforge.net Sat Jan 8 14:13:22 2005 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sat Jan 8 14:13:24 2005 Subject: [Python-checkins] python/dist/src/Lib glob.py,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8739/Lib Modified Files: glob.py Log Message: Patch #943206: `glob.glob()` currently calls itself recursively to build a list of matches of the dirname part of the pattern and then filters by the basename part. This is effectively BFS. ``glob.glob('*/*/*/*/*/foo')`` will build a huge list of all directories 5 levels deep even if only a handful of them contain a ``foo`` entry. A generator-based recusion would never have to store these list at once by implementing DFS. This patch converts the `glob` function to an `iglob` recursive generator . `glob()` now just returns ``list(iglob(pattern))``. I also cleaned up the code a bit (reduced duplicate `has_magic()` checks and created a second `glob0` helper func so that the main loop need not be duplicated). Thanks to Cherniavsky Beni for the patch! Index: glob.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/glob.py,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- glob.py 30 Aug 2004 10:19:54 -0000 1.11 +++ glob.py 8 Jan 2005 13:13:14 -0000 1.12 @@ -4,7 +4,7 @@ import fnmatch import re -__all__ = ["glob"] +__all__ = ["glob", "iglob"] def glob(pathname): """Return a list of paths matching a pathname pattern. @@ -12,35 +12,42 @@ The pattern may contain simple shell-style wildcards a la fnmatch. """ + return list(iglob(pathname)) + +def iglob(pathname): + """Return a list of paths matching a pathname pattern. + + The pattern may contain simple shell-style wildcards a la fnmatch. + + """ if not has_magic(pathname): if os.path.lexists(pathname): - return [pathname] - else: - return [] + yield pathname + return dirname, basename = os.path.split(pathname) if not dirname: - return glob1(os.curdir, basename) - elif has_magic(dirname): - list = glob(dirname) + for name in glob1(os.curdir, basename): + yield name + return + if has_magic(dirname): + dirs = iglob(dirname) else: - list = [dirname] - if not has_magic(basename): - result = [] - for dirname in list: - if basename or os.path.isdir(dirname): - name = os.path.join(dirname, basename) - if os.path.lexists(name): - result.append(name) + dirs = [dirname] + if has_magic(basename): + glob_in_dir = glob1 else: - result = [] - for dirname in list: - sublist = glob1(dirname, basename) - for name in sublist: - result.append(os.path.join(dirname, name)) - return result + glob_in_dir = glob0 + for dirname in dirs: + for name in glob_in_dir(dirname, basename): + yield os.path.join(dirname, name) + +# These 2 helper functions non-recursively glob inside a literal directory. +# They return a list of basenames. `glob1` accepts a pattern while `glob0` +# takes a literal basename (so it only has to check for its existence). def glob1(dirname, pattern): - if not dirname: dirname = os.curdir + if not dirname: + dirname = os.curdir try: names = os.listdir(dirname) except os.error: @@ -49,6 +56,17 @@ names=filter(lambda x: x[0]!='.',names) return fnmatch.filter(names,pattern) +def glob0(dirname, basename): + if basename == '': + # `os.path.split()` returns an empty basename for paths ending with a + # directory separator. 'q*x/' should match only directories. + if os.isdir(dirname): + return [basename] + else: + if os.path.lexists(os.path.join(dirname, basename)): + return [basename] + return [] + magic_check = re.compile('[*?[]') From jlgijsbers at users.sourceforge.net Sat Jan 8 14:13:22 2005 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sat Jan 8 14:13:25 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_glob.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-serv8739/Lib/test Modified Files: test_glob.py Log Message: Patch #943206: `glob.glob()` currently calls itself recursively to build a list of matches of the dirname part of the pattern and then filters by the basename part. This is effectively BFS. ``glob.glob('*/*/*/*/*/foo')`` will build a huge list of all directories 5 levels deep even if only a handful of them contain a ``foo`` entry. A generator-based recusion would never have to store these list at once by implementing DFS. This patch converts the `glob` function to an `iglob` recursive generator . `glob()` now just returns ``list(iglob(pattern))``. I also cleaned up the code a bit (reduced duplicate `has_magic()` checks and created a second `glob0` helper func so that the main loop need not be duplicated). Thanks to Cherniavsky Beni for the patch! Index: test_glob.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_glob.py,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- test_glob.py 30 Aug 2004 10:19:56 -0000 1.8 +++ test_glob.py 8 Jan 2005 13:13:19 -0000 1.9 @@ -61,7 +61,9 @@ else: pattern = os.path.join(*parts) p = os.path.join(self.tempdir, pattern) - return glob.glob(p) + res = glob.glob(p) + self.assertEqual(list(glob.iglob(p)), res) + return res def assertSequencesEqual_noorder(self, l1, l2): self.assertEqual(set(l1), set(l2)) From jlgijsbers at users.sourceforge.net Sat Jan 8 14:13:47 2005 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sat Jan 8 14:13:49 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libglob.tex,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8739/Doc/lib Modified Files: libglob.tex Log Message: Patch #943206: `glob.glob()` currently calls itself recursively to build a list of matches of the dirname part of the pattern and then filters by the basename part. This is effectively BFS. ``glob.glob('*/*/*/*/*/foo')`` will build a huge list of all directories 5 levels deep even if only a handful of them contain a ``foo`` entry. A generator-based recusion would never have to store these list at once by implementing DFS. This patch converts the `glob` function to an `iglob` recursive generator . `glob()` now just returns ``list(iglob(pattern))``. I also cleaned up the code a bit (reduced duplicate `has_magic()` checks and created a second `glob0` helper func so that the main loop need not be duplicated). Thanks to Cherniavsky Beni for the patch! Index: libglob.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libglob.tex,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- libglob.tex 30 Aug 2004 10:19:53 -0000 1.13 +++ libglob.tex 8 Jan 2005 13:13:14 -0000 1.14 @@ -16,7 +16,7 @@ \index{filenames!pathname expansion} \begin{funcdesc}{glob}{pathname} -Returns a possibly-empty list of path names that match \var{pathname}, +Return a possibly-empty list of path names that match \var{pathname}, which must be a string containing a path specification. \var{pathname} can be either absolute (like \file{/usr/src/Python-1.5/Makefile}) or relative (like @@ -24,6 +24,12 @@ Broken symlinks are included in the results (as in the shell). \end{funcdesc} +\begin{funcdesc}{iglob}{pathname} +Return an iterator which yields the same values as \function{glob()} +without actually storing them all simultaneously. +\versionadded{2.5} +\end{funcdesc} + For example, consider a directory containing only the following files: \file{1.gif}, \file{2.txt}, and \file{card.gif}. \function{glob()} will produce the following results. Notice how any leading components From jlgijsbers at users.sourceforge.net Sat Jan 8 14:28:56 2005 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sat Jan 8 14:28:58 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_glob.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-serv11756 Modified Files: test_glob.py Log Message: Clean up tests by reusing functions from other modules: * replace deltree with shutil.rmtree() * replace mkdirs with os.makedirs() * fold touchfile into GlobTests.mktemp() Index: test_glob.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_glob.py,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- test_glob.py 8 Jan 2005 13:13:19 -0000 1.9 +++ test_glob.py 8 Jan 2005 13:28:54 -0000 1.10 @@ -2,35 +2,7 @@ from test.test_support import run_unittest, TESTFN import glob import os - -def mkdirs(fname): - if os.path.exists(fname) or fname == '': - return - base, file = os.path.split(fname) - mkdirs(base) - os.mkdir(fname) - -def touchfile(fname): - base, file = os.path.split(fname) - mkdirs(base) - f = open(fname, 'w') - f.close() - -def deltree(fname): - for f in os.listdir(fname): - fullname = os.path.join(fname, f) - if os.path.isdir(fullname): - deltree(fullname) - else: - try: - os.unlink(fullname) - except: - pass - try: - os.rmdir(fname) - except: - pass - +import shutil class GlobTests(unittest.TestCase): @@ -38,7 +10,12 @@ return os.path.normpath(os.path.join(self.tempdir, *parts)) def mktemp(self, *parts): - touchfile(self.norm(*parts)) + filename = self.norm(*parts) + base, file = os.path.split(filename) + if not os.path.exists(base): + os.makedirs(base) + f = open(filename, 'w') + f.close() def setUp(self): self.tempdir = TESTFN+"_dir" @@ -53,7 +30,7 @@ os.symlink(self.norm('broken'), self.norm('sym2')) def tearDown(self): - deltree(self.tempdir) + shutil.rmtree(self.tempdir) def glob(self, *parts): if len(parts) == 1: From jlgijsbers at users.sourceforge.net Sat Jan 8 14:56:50 2005 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sat Jan 8 14:56:53 2005 Subject: [Python-checkins] python/dist/src/Lib cgi.py,1.82,1.83 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16282 Modified Files: cgi.py Log Message: Patch #1079734: remove dependencies on (deprecated) rfc822 and mimetools modules, replacing with email. Thanks to Josh Hoyt for the patch! Index: cgi.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cgi.py,v retrieving revision 1.82 retrieving revision 1.83 diff -u -d -r1.82 -r1.83 --- cgi.py 31 Dec 2004 21:59:02 -0000 1.82 +++ cgi.py 8 Jan 2005 13:56:36 -0000 1.83 @@ -38,8 +38,7 @@ import sys import os import urllib -import mimetools -import rfc822 +import email.Parser import UserDict try: from cStringIO import StringIO @@ -108,6 +107,8 @@ # Parsing functions # ================= +_header_parser = email.Parser.HeaderParser() + # Maximum input we will accept when REQUEST_METHOD is POST # 0 ==> unlimited input maxlen = 0 @@ -237,7 +238,7 @@ Arguments: fp : input file - pdict: dictionary containing other parameters of conten-type header + pdict: dictionary containing other parameters of content-type header Returns a dictionary just like parse_qs(): keys are the field names, each value is a list of values for that field. This is easy to use but not @@ -270,7 +271,7 @@ data = None if terminator: # At start of next part. Read headers first. - headers = mimetools.Message(fp) + headers = _header_parser.parse(fp) clength = headers.getheader('content-length') if clength: try: @@ -407,8 +408,9 @@ disposition_options: dictionary of corresponding options - headers: a dictionary(-like) object (sometimes rfc822.Message or a - subclass thereof) containing *all* headers + headers: a dictionary(-like) object (sometimes + email.Message.Message or a subclass thereof) containing *all* + headers The class is subclassable, mostly for the purpose of overriding the make_file() method, which is called internally to come up with @@ -650,7 +652,7 @@ environ, keep_blank_values, strict_parsing) # Throw first part away while not part.done: - headers = rfc822.Message(self.fp) + headers = _header_parser.parse(self.fp) part = klass(self.fp, headers, ib, environ, keep_blank_values, strict_parsing) self.list.append(part) From jlgijsbers at users.sourceforge.net Sat Jan 8 15:12:30 2005 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sat Jan 8 15:12:33 2005 Subject: [Python-checkins] python/dist/src/Lib smtplib.py,1.66,1.67 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19343 Modified Files: smtplib.py Log Message: Replace rfc822.parseaddr with email.Utils.parseaddr. The implementation is still the same, so there should be no backwards-compatibility problems. Index: smtplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/smtplib.py,v retrieving revision 1.66 retrieving revision 1.67 diff -u -d -r1.66 -r1.67 --- smtplib.py 6 Dec 2004 21:25:26 -0000 1.66 +++ smtplib.py 8 Jan 2005 14:12:27 -0000 1.67 @@ -43,7 +43,7 @@ import socket import re -import rfc822 +import email.Utils import base64 import hmac from email.base64MIME import encode as encode_base64 @@ -171,7 +171,7 @@ """ m = (None, None) try: - m=rfc822.parseaddr(addr)[1] + m = email.Utils.parseaddr(addr)[1] except AttributeError: pass if m == (None, None): # Indicates parse failure or AttributeError From jlgijsbers at users.sourceforge.net Sat Jan 8 21:16:47 2005 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sat Jan 8 21:16:51 2005 Subject: [Python-checkins] python/dist/src/Lib pydoc.py,1.101,1.102 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2190 Modified Files: pydoc.py Log Message: Patch #936774: unify the display of data descriptors, including slots, properties, and custom descriptors. * removed special handling of properties * added special handling of data descriptors - All data descriptors are grouped together in a section. For each item, the attribute name and doc string, if present, is displayed. * disabled display of __slots__ attribute - since slots are descriptors, they are listed in the section described above Thanks to John Belmonte for the patch! Index: pydoc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pydoc.py,v retrieving revision 1.101 retrieving revision 1.102 diff -u -d -r1.101 -r1.102 --- pydoc.py 1 Jan 2005 07:51:01 -0000 1.101 +++ pydoc.py 8 Jan 2005 20:16:43 -0000 1.102 @@ -154,7 +154,7 @@ """Decide whether to show documentation on a variable.""" # Certain special names are redundant. if name in ['__builtins__', '__doc__', '__file__', '__path__', - '__module__', '__name__']: return 0 + '__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: @@ -163,6 +163,14 @@ else: return not name.startswith('_') +def classify_class_attrs(object): + """Wrap inspect.classify_class_attrs, with fixup for data descriptors.""" + def fixup((name, kind, cls, value)): + if inspect.isdatadescriptor(value): + kind = 'data descriptor' + return name, kind, cls, value + return map(fixup, inspect.classify_class_attrs(object)) + # ----------------------------------------------------- module manipulation def ispackage(path): @@ -718,13 +726,13 @@ push('\n') return attrs - def spillproperties(msg, attrs, predicate): + def spilldescriptors(msg, attrs, predicate): ok, attrs = _split_list(attrs, predicate) if ok: hr.maybe() push(msg) for name, kind, homecls, value in ok: - push(self._docproperty(name, value, mod)) + push(self._docdescriptor(name, value, mod)) return attrs def spilldata(msg, attrs, predicate): @@ -749,7 +757,7 @@ return attrs attrs = filter(lambda (name, kind, cls, value): visiblename(name), - inspect.classify_class_attrs(object)) + classify_class_attrs(object)) mdict = {} for key, kind, homecls, value in attrs: mdict[key] = anchor = '#' + name + '-' + key @@ -788,8 +796,8 @@ lambda t: t[1] == 'class method') attrs = spill('Static methods %s' % tag, attrs, lambda t: t[1] == 'static method') - attrs = spillproperties('Properties %s' % tag, attrs, - lambda t: t[1] == 'property') + attrs = spilldescriptors('Data descriptors %s' % tag, attrs, + lambda t: t[1] == 'data descriptor') attrs = spilldata('Data and other attributes %s' % tag, attrs, lambda t: t[1] == 'data') assert attrs == [] @@ -871,7 +879,7 @@ doc = doc and '
%s
' % doc return '
%s
%s
\n' % (decl, doc) - def _docproperty(self, name, value, mod): + def _docdescriptor(self, name, value, mod): results = [] push = results.append @@ -880,20 +888,13 @@ if value.__doc__ is not None: doc = self.markup(value.__doc__, self.preformat) push('
%s
\n' % doc) - for attr, tag in [('fget', 'get'), - ('fset', 'set'), - ('fdel', 'delete')]: - func = getattr(value, attr) - if func is not None: - base = self.document(func, tag, mod) - push('
%s
\n' % base) push('\n') return ''.join(results) def docproperty(self, object, name=None, mod=None, cl=None): """Produce html documentation for a property.""" - return self._docproperty(name, object, mod) + return self._docdescriptor(name, object, mod) def docother(self, object, name=None, mod=None, *ignored): """Produce HTML documentation for a data object.""" @@ -1143,13 +1144,13 @@ name, mod, object)) return attrs - def spillproperties(msg, attrs, predicate): + def spilldescriptors(msg, attrs, predicate): ok, attrs = _split_list(attrs, predicate) if ok: hr.maybe() push(msg) for name, kind, homecls, value in ok: - push(self._docproperty(name, value, mod)) + push(self._docdescriptor(name, value, mod)) return attrs def spilldata(msg, attrs, predicate): @@ -1167,7 +1168,7 @@ return attrs attrs = filter(lambda (name, kind, cls, value): visiblename(name), - inspect.classify_class_attrs(object)) + classify_class_attrs(object)) while attrs: if mro: thisclass = mro.popleft() @@ -1195,8 +1196,8 @@ lambda t: t[1] == 'class method') attrs = spill("Static methods %s:\n" % tag, attrs, lambda t: t[1] == 'static method') - attrs = spillproperties("Properties %s:\n" % tag, attrs, - lambda t: t[1] == 'property') + attrs = spilldescriptors("Data descriptors %s:\n" % tag, attrs, + lambda t: t[1] == 'data descriptor') attrs = spilldata("Data and other attributes %s:\n" % tag, attrs, lambda t: t[1] == 'data') assert attrs == [] @@ -1254,33 +1255,22 @@ doc = getdoc(object) or '' return decl + '\n' + (doc and rstrip(self.indent(doc)) + '\n') - def _docproperty(self, name, value, mod): + def _docdescriptor(self, name, value, mod): results = [] push = results.append if name: - push(name) - need_blank_after_doc = 0 + push(self.bold(name)) + push('\n') doc = getdoc(value) or '' if doc: push(self.indent(doc)) - need_blank_after_doc = 1 - for attr, tag in [('fget', ''), - ('fset', ''), - ('fdel', '')]: - func = getattr(value, attr) - if func is not None: - if need_blank_after_doc: - push('') - need_blank_after_doc = 0 - base = self.document(func, tag, mod) - push(self.indent(base)) - - return '\n'.join(results) + push('\n') + return ''.join(results) def docproperty(self, object, name=None, mod=None, cl=None): """Produce text documentation for a property.""" - return self._docproperty(name, object, mod) + return self._docdescriptor(name, object, mod) def docother(self, object, name=None, mod=None, maxlen=None, doc=None): """Produce text documentation for a data object.""" From montanaro at users.sourceforge.net Sat Jan 8 22:57:00 2005 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Sat Jan 8 22:57:04 2005 Subject: [Python-checkins] python/dist/src/Misc gdbinit,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21826 Modified Files: gdbinit Log Message: Add definitions for "up" and "down" commands that print/display the current Python file/line when the current C execution frame is inside PyEval_EvalFrame. These are commented out by default because GDB sometimes crashes as a result (seems like a GDB bug). Add a pyframe command that displays the current Python stack frame. If the marked lines are uncommented, it will also cause Emacs/XEmacs to display the current file/line. Index: gdbinit =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/gdbinit,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- gdbinit 17 Nov 2004 16:04:15 -0000 1.8 +++ gdbinit 8 Jan 2005 21:56:43 -0000 1.9 @@ -43,6 +43,28 @@ end end +# A rewrite of the Python interpreter's line number calculator in GDB's +# command language +define lineno + set $__co = f->f_code + set $__lasti = f->f_lasti + set $__sz = ((PyStringObject *)$__co->co_lnotab)->ob_size/2 + set $__p = (unsigned char *)((PyStringObject *)$__co->co_lnotab)->ob_sval + set $__li = $__co->co_firstlineno + set $__ad = 0 + while ($__sz-1 >= 0) + set $__sz = $__sz - 1 + set $__ad = $__ad + *$__p + set $__p = $__p + 1 + if ($__ad > $__lasti) + break + end + set $__li = $__li + *$__p + set $__p = $__p + 1 + end + printf "%d", $__li +end + # print the current frame - verbose define pyframev pyframe @@ -52,7 +74,35 @@ define pyframe set $__fn = (char *)((PyStringObject *)co->co_filename)->ob_sval set $__n = (char *)((PyStringObject *)co->co_name)->ob_sval - printf "%s (%d): %s\n", $__fn, f->f_lineno, $__n + printf "%s (", $__fn + lineno + printf "): %s\n", $__n +### Uncomment these lines when using from within Emacs/XEmacs so it will +### automatically track/display the current Python source line +# printf "%c%c%s:", 032, 032, $__fn +# lineno +# printf ":1\n" +end + +### Use these at your own risk. It appears that a bug in gdb causes it +### to crash in certain circumstances. + +#define up +# up-silently 1 +# printframe +#end + +#define down +# down-silently 1 +# printframe +#end + +define printframe + if $pc > PyEval_EvalFrame && $pc < PyEval_EvalCodeEx + pyframe + else + frame + end end # Here's a somewhat fragile way to print the entire Python stack from gdb. @@ -64,7 +114,7 @@ # interpreter, but the test can be extended by an interested party). If # Py_Main <= $pc <= Py_GetArgcArv is true, $pc is in Py_Main(), so the while # tests succeeds as long as it's not true. In a similar fashion the if -# statement tests to see if we are in eval_frame(). +# statement tests to see if we are in PyEval_EvalFrame(). # print the entire Python call stack define pystack From montanaro at users.sourceforge.net Sat Jan 8 22:59:01 2005 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Sat Jan 8 22:59:03 2005 Subject: [Python-checkins] python/dist/src/Python ceval.c,2.419,2.420 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22317 Modified Files: ceval.c Log Message: comment tweak Index: ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.419 retrieving revision 2.420 diff -u -d -r2.419 -r2.420 --- ceval.c 23 Nov 2004 18:06:08 -0000 2.419 +++ ceval.c 8 Jan 2005 21:58:58 -0000 2.420 @@ -2499,7 +2499,7 @@ /* this is gonna seem *real weird*, but if you put some other code between PyEval_EvalFrame() and PyEval_EvalCodeEx() you will need to adjust - the test in the if statement in Misc/gdbinit:ppystack */ + the test in the if statement in Misc/gdbinit:pystack* */ PyObject * PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, From jlgijsbers at users.sourceforge.net Sun Jan 9 01:13:08 2005 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sun Jan 9 01:13:11 2005 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.266,1.267 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17663 Modified Files: tut.tex Log Message: Bug #1098497: various small typo's, grammar and markup nits. Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.266 retrieving revision 1.267 diff -u -d -r1.266 -r1.267 --- tut.tex 1 Jan 2005 00:28:44 -0000 1.266 +++ tut.tex 9 Jan 2005 00:12:48 -0000 1.267 @@ -75,7 +75,7 @@ If you ever wrote a large shell script, you probably know this feeling: you'd love to add yet another feature, but it's already so slow, and so big, and so complicated; or the feature involves a system -call or other function that is only accessible from C \ldots Usually +call or other function that is only accessible from C\ldots\ Usually the problem at hand isn't serious enough to warrant rewriting the script in C; perhaps the problem requires variable-length strings or other data types (like sorted lists of file names) that are easy in @@ -313,7 +313,7 @@ the hash, or pound, character, \character{\#}, is used to start a comment in Python. -The script can be given a executable mode, or permission, using the +The script can be given an executable mode, or permission, using the \program{chmod} command: \begin{verbatim} @@ -852,7 +852,7 @@ Unicode has the advantage of providing one ordinal for every character in every script used in modern and ancient texts. Previously, there -were only 256 possible ordinals for script characters and texts were +were only 256 possible ordinals for script characters. Texts were typically bound to a code page which mapped the ordinals to script characters. This lead to very much confusion especially with respect to internationalization (usually written as \samp{i18n} --- @@ -867,7 +867,7 @@ u'Hello World !' \end{verbatim} -The small \character{u} in front of the quote indicates that an +The small \character{u} in front of the quote indicates that a Unicode string is supposed to be created. If you want to include special characters in the string, you can do so by using the Python \emph{Unicode-Escape} encoding. The following example shows how: From jlgijsbers at users.sourceforge.net Sun Jan 9 01:36:55 2005 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sun Jan 9 01:36:59 2005 Subject: [Python-checkins] python/dist/src/Doc/lib xmldom.tex,1.26,1.27 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22512 Modified Files: xmldom.tex Log Message: Patch #1051321 (fixes bugs 1010196, 1013525), by Mike Brown: * Document hasFeature(), createDocument(), CreateDocumentType(), hasAttribute(), hasAttributeNS(). * In the documentation for createDocument(), it is now stated that the Python DOM API allows implementations to forego creation of the document element child node, if no namespace and local name arguments are given. (This possibility is left open and unaddressed in the W3C spec). * Addition by me: use 'name' rather than 'attname', for consistency with the DOM specification and the Python DOM API implementation. Index: xmldom.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/xmldom.tex,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- xmldom.tex 1 Jan 2005 00:28:43 -0000 1.26 +++ xmldom.tex 9 Jan 2005 00:36:53 -0000 1.27 @@ -84,8 +84,8 @@ \seetitle[http://pyxml.sourceforge.net]{PyXML}{Users that require a full-featured implementation of DOM should use the PyXML package.} - \seetitle[http://cgi.omg.org/cgi-bin/doc?orbos/99-08-02.pdf]{CORBA - Scripting with Python} + \seetitle[http://www.omg.org/docs/formal/02-11-05.pdf]{Python + Language Mapping Specification} {This specifies the mapping from OMG IDL to Python.} \end{seealso} @@ -213,6 +213,24 @@ \class{DOMImplementation} as well. \begin{methoddesc}[DOMImplementation]{hasFeature}{feature, version} +Return true if the feature identified by the pair of strings +\var{feature} and \var{version} is implemented. +\end{methoddesc} + +\begin{methoddesc}[DOMImplementation]{createDocument}{namespaceUri, qualifiedName, doctype} +Return a new \class{Document} object (the root of the DOM), with a +child \class{Element} object having the given \var{namespaceUri} and +\var{qualifiedName}. The \var{doctype} must be a \class{DocumentType} +object created by \method{createDocumentType()}, or \code{None}. +In the Python DOM API, the first two arguments can also be \code{None} +in order to indicate that no \class{Element} child is to be created. +\end{methoddesc} + +\begin{methoddesc}[DOMImplementation]{createDocumentType}{qualifiedName, publicId, systemId} +Return a new \class{DocumentType} object that encapsulates the given +\var{qualifiedName}, \var{publicId}, and \var{systemId} strings, +representing the information contained in an XML document type +declaration. \end{methoddesc} @@ -545,8 +563,19 @@ Same as equivalent method in the \class{Document} class. \end{methoddesc} -\begin{methoddesc}[Element]{getAttribute}{attname} -Return an attribute value as a string. +\begin{methoddesc}[Element]{hasAttribute}{name} +Returns true if the element has an attribute named by \var{name}. +\end{methoddesc} + +\begin{methoddesc}[Element]{hasAttributeNS}{namespaceURI, localName} +Returns true if the element has an attribute named by +\var{namespaceURI} and \var{localName}. +\end{methoddesc} + +\begin{methoddesc}[Element]{getAttribute}{name} +Return the value of the attribute named by \var{name} as a +string. If no such attribute exists, an empty string is returned, +as if the attribute had no value. \end{methoddesc} \begin{methoddesc}[Element]{getAttributeNode}{attrname} @@ -555,8 +584,9 @@ \end{methoddesc} \begin{methoddesc}[Element]{getAttributeNS}{namespaceURI, localName} -Return an attribute value as a string, given a \var{namespaceURI} and -\var{localName}. +Return the value of the attribute named by \var{namespaceURI} and +\var{localName} as a string. If no such attribute exists, an empty +string is returned, as if the attribute had no value. \end{methoddesc} \begin{methoddesc}[Element]{getAttributeNodeNS}{namespaceURI, localName} @@ -564,7 +594,7 @@ \var{localName}. \end{methoddesc} -\begin{methoddesc}[Element]{removeAttribute}{attname} +\begin{methoddesc}[Element]{removeAttribute}{name} Remove an attribute by name. No exception is raised if there is no matching attribute. \end{methoddesc} @@ -579,7 +609,7 @@ qname. No exception is raised if there is no matching attribute. \end{methoddesc} -\begin{methoddesc}[Element]{setAttribute}{attname, value} +\begin{methoddesc}[Element]{setAttribute}{name, value} Set an attribute value from a string. \end{methoddesc} @@ -886,8 +916,13 @@ \keyword{readonly} may not restrict write access in all DOM implementations. -Additionally, the accessor functions are not required. If provided, +In the Python DOM API, accessor functions are not required. If provided, they should take the form defined by the Python IDL mapping, but these methods are considered unnecessary since the attributes are accessible directly from Python. ``Set'' accessors should never be provided for \keyword{readonly} attributes. + +The IDL definitions do not fully embody the requirements of the W3C DOM +API, such as the notion of certain objects, such as the return value of +\method{getElementsByTagName()}, being ``live''. The Python DOM API +does not require implementations to enforce such requirements. From jlgijsbers at users.sourceforge.net Sun Jan 9 01:39:09 2005 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sun Jan 9 01:39:12 2005 Subject: [Python-checkins] python/dist/src/Doc/lib xmldom.tex, 1.25.2.1, 1.25.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22846 Modified Files: Tag: release24-maint xmldom.tex Log Message: Backport patch #1051321 (fixes bugs 1010196, 1013525), by Mike Brown: * Document hasFeature(), createDocument(), CreateDocumentType(), hasAttribute(), hasAttributeNS(). * In the documentation for createDocument(), it is now stated that the Python DOM API allows implementations to forego creation of the document element child node, if no namespace and local name arguments are given. (This possibility is left open and unaddressed in the W3C spec). * Addition by me: use 'name' rather than 'attname', for consistency with the DOM specification and the Python DOM API implementation. Index: xmldom.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/xmldom.tex,v retrieving revision 1.25.2.1 retrieving revision 1.25.2.2 diff -u -d -r1.25.2.1 -r1.25.2.2 --- xmldom.tex 1 Jan 2005 00:34:53 -0000 1.25.2.1 +++ xmldom.tex 9 Jan 2005 00:39:06 -0000 1.25.2.2 @@ -84,8 +84,8 @@ \seetitle[http://pyxml.sourceforge.net]{PyXML}{Users that require a full-featured implementation of DOM should use the PyXML package.} - \seetitle[http://cgi.omg.org/cgi-bin/doc?orbos/99-08-02.pdf]{CORBA - Scripting with Python} + \seetitle[http://www.omg.org/docs/formal/02-11-05.pdf]{Python + Language Mapping Specification} {This specifies the mapping from OMG IDL to Python.} \end{seealso} @@ -213,6 +213,24 @@ \class{DOMImplementation} as well. \begin{methoddesc}[DOMImplementation]{hasFeature}{feature, version} +Return true if the feature identified by the pair of strings +\var{feature} and \var{version} is implemented. +\end{methoddesc} + +\begin{methoddesc}[DOMImplementation]{createDocument}{namespaceUri, qualifiedName, doctype} +Return a new \class{Document} object (the root of the DOM), with a +child \class{Element} object having the given \var{namespaceUri} and +\var{qualifiedName}. The \var{doctype} must be a \class{DocumentType} +object created by \method{createDocumentType()}, or \code{None}. +In the Python DOM API, the first two arguments can also be \code{None} +in order to indicate that no \class{Element} child is to be created. +\end{methoddesc} + +\begin{methoddesc}[DOMImplementation]{createDocumentType}{qualifiedName, publicId, systemId} +Return a new \class{DocumentType} object that encapsulates the given +\var{qualifiedName}, \var{publicId}, and \var{systemId} strings, +representing the information contained in an XML document type +declaration. \end{methoddesc} @@ -545,8 +563,19 @@ Same as equivalent method in the \class{Document} class. \end{methoddesc} -\begin{methoddesc}[Element]{getAttribute}{attname} -Return an attribute value as a string. +\begin{methoddesc}[Element]{hasAttribute}{name} +Returns true if the element has an attribute named by \var{name}. +\end{methoddesc} + +\begin{methoddesc}[Element]{hasAttributeNS}{namespaceURI, localName} +Returns true if the element has an attribute named by +\var{namespaceURI} and \var{localName}. +\end{methoddesc} + +\begin{methoddesc}[Element]{getAttribute}{name} +Return the value of the attribute named by \var{name} as a +string. If no such attribute exists, an empty string is returned, +as if the attribute had no value. \end{methoddesc} \begin{methoddesc}[Element]{getAttributeNode}{attrname} @@ -555,8 +584,9 @@ \end{methoddesc} \begin{methoddesc}[Element]{getAttributeNS}{namespaceURI, localName} -Return an attribute value as a string, given a \var{namespaceURI} and -\var{localName}. +Return the value of the attribute named by \var{namespaceURI} and +\var{localName} as a string. If no such attribute exists, an empty +string is returned, as if the attribute had no value. \end{methoddesc} \begin{methoddesc}[Element]{getAttributeNodeNS}{namespaceURI, localName} @@ -564,7 +594,7 @@ \var{localName}. \end{methoddesc} -\begin{methoddesc}[Element]{removeAttribute}{attname} +\begin{methoddesc}[Element]{removeAttribute}{name} Remove an attribute by name. No exception is raised if there is no matching attribute. \end{methoddesc} @@ -579,7 +609,7 @@ qname. No exception is raised if there is no matching attribute. \end{methoddesc} -\begin{methoddesc}[Element]{setAttribute}{attname, value} +\begin{methoddesc}[Element]{setAttribute}{name, value} Set an attribute value from a string. \end{methoddesc} @@ -886,8 +916,13 @@ \keyword{readonly} may not restrict write access in all DOM implementations. -Additionally, the accessor functions are not required. If provided, +In the Python DOM API, accessor functions are not required. If provided, they should take the form defined by the Python IDL mapping, but these methods are considered unnecessary since the attributes are accessible directly from Python. ``Set'' accessors should never be provided for \keyword{readonly} attributes. + +The IDL definitions do not fully embody the requirements of the W3C DOM +API, such as the notion of certain objects, such as the return value of +\method{getElementsByTagName()}, being ``live''. The Python DOM API +does not require implementations to enforce such requirements. From jlgijsbers at users.sourceforge.net Sun Jan 9 02:58:05 2005 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sun Jan 9 02:58:08 2005 Subject: [Python-checkins] python/dist/src/Lib profile.py,1.58,1.59 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5785 Modified Files: profile.py Log Message: Move code in __name__ == '__main__' block into main() function, rewrite code so there's no need to subclass OptionParser. Index: profile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/profile.py,v retrieving revision 1.58 retrieving revision 1.59 diff -u -d -r1.58 -r1.59 --- profile.py 12 Jul 2004 23:38:01 -0000 1.58 +++ profile.py 9 Jan 2005 01:58:02 -0000 1.59 @@ -583,31 +583,29 @@ def Stats(*args): print 'Report generating functions are in the "pstats" module\a' - -# When invoked as main program, invoke the profiler on a script -if __name__ == '__main__': +def main(): usage = "profile.py [-o output_file_path] [-s sort] scriptfile [arg] ..." - if not sys.argv[1:]: - print "Usage: ", usage - sys.exit(2) - - class ProfileParser(OptionParser): - def __init__(self, usage): - OptionParser.__init__(self) - self.usage = usage - - parser = ProfileParser(usage) + parser = OptionParser(usage=usage) parser.allow_interspersed_args = False parser.add_option('-o', '--outfile', dest="outfile", help="Save stats to ", default=None) parser.add_option('-s', '--sort', dest="sort", help="Sort order when printing to stdout, based on pstats.Stats class", default=-1) - + + if not sys.argv[1:]: + parser.print_usage() + sys.exit(2) + (options, args) = parser.parse_args() sys.argv[:] = args - + if (len(sys.argv) > 0): sys.path.insert(0, os.path.dirname(sys.argv[0])) run('execfile(%r)' % (sys.argv[0],), options.outfile, options.sort) else: - print "Usage: ", usage + parser.print_usage() + return parser + +# When invoked as main program, invoke the profiler on a script +if __name__ == '__main__': + main() From jlgijsbers at users.sourceforge.net Sun Jan 9 06:51:52 2005 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sun Jan 9 06:52:02 2005 Subject: [Python-checkins] python/dist/src/Lib urllib2.py,1.78,1.79 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16010 Modified Files: urllib2.py Log Message: Patch #1095362: replace hardcoded test for POST/GET with call to get_method, removing some duplication and gaining some flexibility in the process. Index: urllib2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib2.py,v retrieving revision 1.78 retrieving revision 1.79 diff -u -d -r1.78 -r1.79 --- urllib2.py 22 Dec 2004 14:27:19 -0000 1.78 +++ urllib2.py 9 Jan 2005 05:51:49 -0000 1.79 @@ -859,7 +859,7 @@ entdig = None A1 = "%s:%s:%s" % (user, realm, pw) - A2 = "%s:%s" % (req.has_data() and 'POST' or 'GET', + A2 = "%s:%s" % (req.get_method(), # XXX selector: what about proxies and full urls req.get_selector()) if qop == 'auth': From jlgijsbers at users.sourceforge.net Sun Jan 9 06:53:29 2005 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sun Jan 9 06:53:32 2005 Subject: [Python-checkins] python/dist/src/Lib urllib2.py,1.77,1.77.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16375 Modified Files: Tag: release24-maint urllib2.py Log Message: Backport patch #1095362: replace hardcoded test for POST/GET with call to get_method, removing some duplication and gaining some flexibility in the process. Index: urllib2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urllib2.py,v retrieving revision 1.77 retrieving revision 1.77.2.1 diff -u -d -r1.77 -r1.77.2.1 --- urllib2.py 11 Oct 2004 13:53:07 -0000 1.77 +++ urllib2.py 9 Jan 2005 05:53:27 -0000 1.77.2.1 @@ -856,7 +856,7 @@ entdig = None A1 = "%s:%s:%s" % (user, realm, pw) - A2 = "%s:%s" % (req.has_data() and 'POST' or 'GET', + A2 = "%s:%s" % (req.get_method(), # XXX selector: what about proxies and full urls req.get_selector()) if qop == 'auth': From jlgijsbers at users.sourceforge.net Sun Jan 9 16:29:12 2005 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sun Jan 9 16:29:16 2005 Subject: [Python-checkins] python/dist/src/Lib urlparse.py,1.46,1.47 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28840 Modified Files: urlparse.py Log Message: Patch #712317: In URLs such as http://www.example.com?query=spam, treat '?' as a delimiter. Previously, the 'network location' ( in RFC 2396) would become 'www.example.com?query=spam', while RFC 2396 does not allow a '?' in . See bug #548176 for further discussion. Index: urlparse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urlparse.py,v retrieving revision 1.46 retrieving revision 1.47 diff -u -d -r1.46 -r1.47 --- urlparse.py 31 Dec 2004 19:15:26 -0000 1.46 +++ urlparse.py 9 Jan 2005 15:29:10 -0000 1.47 @@ -63,6 +63,15 @@ i = url.find(';') return url[:i], url[i+1:] +def _splitnetloc(url, start=0): + for c in '/?#': # the order is important! + delim = url.find(c, start) + if delim >= 0: + break + else: + delim = len(url) + return url[start:delim], url[delim:] + def urlsplit(url, scheme='', allow_fragments=1): """Parse a URL into 5 components: :///?# @@ -82,13 +91,7 @@ scheme = url[:i].lower() url = url[i+1:] if url[:2] == '//': - i = url.find('/', 2) - if i < 0: - i = url.find('#') - if i < 0: - i = len(url) - netloc = url[2:i] - url = url[i:] + netloc, url = _splitnetloc(url, 2) if allow_fragments and '#' in url: url, fragment = url.split('#', 1) if '?' in url: @@ -101,12 +104,8 @@ break else: scheme, url = url[:i].lower(), url[i+1:] - if scheme in uses_netloc: - if url[:2] == '//': - i = url.find('/', 2) - if i < 0: - i = len(url) - netloc, url = url[2:i], url[i:] + if scheme in uses_netloc and url[:2] == '//': + netloc, url = _splitnetloc(url, 2) if allow_fragments and scheme in uses_fragment and '#' in url: url, fragment = url.split('#', 1) if scheme in uses_query and '?' in url: From jlgijsbers at users.sourceforge.net Sun Jan 9 16:29:12 2005 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sun Jan 9 16:29:16 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_urlparse.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-serv28840/test Modified Files: test_urlparse.py Log Message: Patch #712317: In URLs such as http://www.example.com?query=spam, treat '?' as a delimiter. Previously, the 'network location' ( in RFC 2396) would become 'www.example.com?query=spam', while RFC 2396 does not allow a '?' in . See bug #548176 for further discussion. Index: test_urlparse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_urlparse.py,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- test_urlparse.py 12 Oct 2003 04:38:06 -0000 1.13 +++ test_urlparse.py 9 Jan 2005 15:29:10 -0000 1.14 @@ -8,20 +8,22 @@ RFC2396_BASE = "http://a/b/c/d;p?q" class UrlParseTestCase(unittest.TestCase): - def test_frags(self): - for url, parsed, split in [ - ('http://www.python.org', - ('http', 'www.python.org', '', '', '', ''), - ('http', 'www.python.org', '', '', '')), - ('http://www.python.org#abc', - ('http', 'www.python.org', '', '', '', 'abc'), - ('http', 'www.python.org', '', '', 'abc')), - ('http://www.python.org/#abc', - ('http', 'www.python.org', '/', '', '', 'abc'), - ('http', 'www.python.org', '/', '', 'abc')), - (RFC1808_BASE, - ('http', 'a', '/b/c/d', 'p', 'q', 'f'), - ('http', 'a', '/b/c/d;p', 'q', 'f')), + + def checkRoundtrips(self, url, parsed, split): + result = urlparse.urlparse(url) + self.assertEqual(result, parsed) + # put it back together and it should be the same + result2 = urlparse.urlunparse(result) + self.assertEqual(result2, url) + + # check the roundtrip using urlsplit() as well + result = urlparse.urlsplit(url) + self.assertEqual(result, split) + result2 = urlparse.urlunsplit(result) + self.assertEqual(result2, url) + + def test_roundtrips(self): + testcases = [ ('file:///tmp/junk.txt', ('file', '', '/tmp/junk.txt', '', '', ''), ('file', '', '/tmp/junk.txt', '', '')), @@ -29,20 +31,41 @@ ('imap', 'mail.python.org', '/mbox1', '', '', ''), ('imap', 'mail.python.org', '/mbox1', '', '')), ('mms://wms.sys.hinet.net/cts/Drama/09006251100.asf', - ('mms', 'wms.sys.hinet.net', '/cts/Drama/09006251100.asf', '', '', ''), - ('mms', 'wms.sys.hinet.net', '/cts/Drama/09006251100.asf', '', '')), - ]: - result = urlparse.urlparse(url) - self.assertEqual(result, parsed) - # put it back together and it should be the same - result2 = urlparse.urlunparse(result) - self.assertEqual(result2, url) + ('mms', 'wms.sys.hinet.net', '/cts/Drama/09006251100.asf', + '', '', ''), + ('mms', 'wms.sys.hinet.net', '/cts/Drama/09006251100.asf', + '', '')), + ] + for url, parsed, split in testcases: + self.checkRoundtrips(url, parsed, split) - # check the roundtrip using urlsplit() as well - result = urlparse.urlsplit(url) - self.assertEqual(result, split) - result2 = urlparse.urlunsplit(result) - self.assertEqual(result2, url) + def test_http_roundtrips(self): + # urlparse.urlsplit treats 'http:' as an optimized special case, + # so we test both 'http:' and 'https:' in all the following. + # Three cheers for white box knowledge! + testcases = [ + ('://www.python.org', + ('www.python.org', '', '', '', ''), + ('www.python.org', '', '', '')), + ('://www.python.org#abc', + ('www.python.org', '', '', '', 'abc'), + ('www.python.org', '', '', 'abc')), + ('://www.python.org?q=abc', + ('www.python.org', '', '', 'q=abc', ''), + ('www.python.org', '', 'q=abc', '')), + ('://www.python.org/#abc', + ('www.python.org', '/', '', '', 'abc'), + ('www.python.org', '/', '', 'abc')), + ('://a/b/c/d;p?q#f', + ('a', '/b/c/d', 'p', 'q', 'f'), + ('a', '/b/c/d;p', 'q', 'f')), + ] + for scheme in ('http', 'https'): + for url, parsed, split in testcases: + url = scheme + url + parsed = (scheme,) + parsed + split = (scheme,) + split + self.checkRoundtrips(url, parsed, split) def checkJoin(self, base, relurl, expected): self.assertEqual(urlparse.urljoin(base, relurl), expected, From jlgijsbers at users.sourceforge.net Sun Jan 9 16:32:40 2005 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sun Jan 9 16:32:43 2005 Subject: [Python-checkins] python/dist/src/Lib urlparse.py,1.45,1.45.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29436 Modified Files: Tag: release24-maint urlparse.py Log Message: Backport patch #712317: In URLs such as http://www.example.com?query=spam, treat '?' as a delimiter. Previously, the 'network location' ( in RFC 2396) would become 'www.example.com?query=spam', while RFC 2396 does not allow a '?' in . See bug #548176 for further discussion. Index: urlparse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/urlparse.py,v retrieving revision 1.45 retrieving revision 1.45.4.1 diff -u -d -r1.45 -r1.45.4.1 --- urlparse.py 29 Jun 2004 04:02:39 -0000 1.45 +++ urlparse.py 9 Jan 2005 15:32:37 -0000 1.45.4.1 @@ -63,6 +63,15 @@ i = url.find(';') return url[:i], url[i+1:] +def _splitnetloc(url, start=0): + for c in '/?#': # the order is important! + delim = url.find(c, start) + if delim >= 0: + break + else: + delim = len(url) + return url[start:delim], url[delim:] + def urlsplit(url, scheme='', allow_fragments=1): """Parse a URL into 5 components: :///?# @@ -82,13 +91,7 @@ scheme = url[:i].lower() url = url[i+1:] if url[:2] == '//': - i = url.find('/', 2) - if i < 0: - i = url.find('#') - if i < 0: - i = len(url) - netloc = url[2:i] - url = url[i:] + netloc, url = _splitnetloc(url, 2) if allow_fragments and '#' in url: url, fragment = url.split('#', 1) if '?' in url: @@ -101,12 +104,8 @@ break else: scheme, url = url[:i].lower(), url[i+1:] - if scheme in uses_netloc: - if url[:2] == '//': - i = url.find('/', 2) - if i < 0: - i = len(url) - netloc, url = url[2:i], url[i:] + if scheme in uses_netloc and url[:2] == '//': + netloc, url = _splitnetloc(url, 2) if allow_fragments and scheme in uses_fragment and '#' in url: url, fragment = url.split('#', 1) if scheme in uses_query and '?' in url: From jlgijsbers at users.sourceforge.net Sun Jan 9 16:32:40 2005 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sun Jan 9 16:32:44 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_urlparse.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-serv29436/test Modified Files: Tag: release24-maint test_urlparse.py Log Message: Backport patch #712317: In URLs such as http://www.example.com?query=spam, treat '?' as a delimiter. Previously, the 'network location' ( in RFC 2396) would become 'www.example.com?query=spam', while RFC 2396 does not allow a '?' in . See bug #548176 for further discussion. Index: test_urlparse.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_urlparse.py,v retrieving revision 1.13 retrieving revision 1.13.4.1 diff -u -d -r1.13 -r1.13.4.1 --- test_urlparse.py 12 Oct 2003 04:38:06 -0000 1.13 +++ test_urlparse.py 9 Jan 2005 15:32:37 -0000 1.13.4.1 @@ -8,20 +8,22 @@ RFC2396_BASE = "http://a/b/c/d;p?q" class UrlParseTestCase(unittest.TestCase): - def test_frags(self): - for url, parsed, split in [ - ('http://www.python.org', - ('http', 'www.python.org', '', '', '', ''), - ('http', 'www.python.org', '', '', '')), - ('http://www.python.org#abc', - ('http', 'www.python.org', '', '', '', 'abc'), - ('http', 'www.python.org', '', '', 'abc')), - ('http://www.python.org/#abc', - ('http', 'www.python.org', '/', '', '', 'abc'), - ('http', 'www.python.org', '/', '', 'abc')), - (RFC1808_BASE, - ('http', 'a', '/b/c/d', 'p', 'q', 'f'), - ('http', 'a', '/b/c/d;p', 'q', 'f')), + + def checkRoundtrips(self, url, parsed, split): + result = urlparse.urlparse(url) + self.assertEqual(result, parsed) + # put it back together and it should be the same + result2 = urlparse.urlunparse(result) + self.assertEqual(result2, url) + + # check the roundtrip using urlsplit() as well + result = urlparse.urlsplit(url) + self.assertEqual(result, split) + result2 = urlparse.urlunsplit(result) + self.assertEqual(result2, url) + + def test_roundtrips(self): + testcases = [ ('file:///tmp/junk.txt', ('file', '', '/tmp/junk.txt', '', '', ''), ('file', '', '/tmp/junk.txt', '', '')), @@ -29,20 +31,41 @@ ('imap', 'mail.python.org', '/mbox1', '', '', ''), ('imap', 'mail.python.org', '/mbox1', '', '')), ('mms://wms.sys.hinet.net/cts/Drama/09006251100.asf', - ('mms', 'wms.sys.hinet.net', '/cts/Drama/09006251100.asf', '', '', ''), - ('mms', 'wms.sys.hinet.net', '/cts/Drama/09006251100.asf', '', '')), - ]: - result = urlparse.urlparse(url) - self.assertEqual(result, parsed) - # put it back together and it should be the same - result2 = urlparse.urlunparse(result) - self.assertEqual(result2, url) + ('mms', 'wms.sys.hinet.net', '/cts/Drama/09006251100.asf', + '', '', ''), + ('mms', 'wms.sys.hinet.net', '/cts/Drama/09006251100.asf', + '', '')), + ] + for url, parsed, split in testcases: + self.checkRoundtrips(url, parsed, split) - # check the roundtrip using urlsplit() as well - result = urlparse.urlsplit(url) - self.assertEqual(result, split) - result2 = urlparse.urlunsplit(result) - self.assertEqual(result2, url) + def test_http_roundtrips(self): + # urlparse.urlsplit treats 'http:' as an optimized special case, + # so we test both 'http:' and 'https:' in all the following. + # Three cheers for white box knowledge! + testcases = [ + ('://www.python.org', + ('www.python.org', '', '', '', ''), + ('www.python.org', '', '', '')), + ('://www.python.org#abc', + ('www.python.org', '', '', '', 'abc'), + ('www.python.org', '', '', 'abc')), + ('://www.python.org?q=abc', + ('www.python.org', '', '', 'q=abc', ''), + ('www.python.org', '', 'q=abc', '')), + ('://www.python.org/#abc', + ('www.python.org', '/', '', '', 'abc'), + ('www.python.org', '/', '', 'abc')), + ('://a/b/c/d;p?q#f', + ('a', '/b/c/d', 'p', 'q', 'f'), + ('a', '/b/c/d;p', 'q', 'f')), + ] + for scheme in ('http', 'https'): + for url, parsed, split in testcases: + url = scheme + url + parsed = (scheme,) + parsed + split = (scheme,) + split + self.checkRoundtrips(url, parsed, split) def checkJoin(self, base, relurl, expected): self.assertEqual(urlparse.urljoin(base, relurl), expected, From kbk at users.sourceforge.net Sun Jan 9 19:49:45 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Sun Jan 9 19:49:49 2005 Subject: [Python-checkins] python/dist/src/Include symtable.h, 2.9.18.11, 2.9.18.12 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7890/Include Modified Files: Tag: ast-branch symtable.h Log Message: Put st_tmpname back in symtable until JH has a chance to look at the situation. Index: symtable.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/symtable.h,v retrieving revision 2.9.18.11 retrieving revision 2.9.18.12 diff -u -d -r2.9.18.11 -r2.9.18.12 --- symtable.h 7 Jan 2005 06:57:42 -0000 2.9.18.11 +++ symtable.h 9 Jan 2005 18:49:43 -0000 2.9.18.12 @@ -18,6 +18,7 @@ PyObject *st_global; /* borrowed ref to MODULE in st_symbols */ int st_nblocks; /* number of blocks */ char *st_private; /* name of current class or NULL */ + int st_tmpname; /* temporary name counter */ PyFutureFeatures *st_future; /* module's future features */ }; From andrewmcnamara at users.sourceforge.net Mon Jan 10 02:04:43 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Mon Jan 10 02:04:47 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_csv.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-serv2676/Lib/test Modified Files: test_csv.py Log Message: Fix parsing of csv files with escapes (escape character previously would be left in stream). Index: test_csv.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_csv.py,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- test_csv.py 7 Jan 2005 16:01:23 -0000 1.15 +++ test_csv.py 10 Jan 2005 01:04:40 -0000 1.16 @@ -227,10 +227,10 @@ self.assertRaises(csv.Error, self._read_test, ['a,b\r\nc,d'], []) def test_read_escape(self): - self._read_test(['a,\\b,c'], [['a', '\\b', 'c']], escapechar='\\') + self._read_test(['a,\\b,c'], [['a', 'b', 'c']], escapechar='\\') self._read_test(['a,b\\,c'], [['a', 'b,c']], escapechar='\\') self._read_test(['a,"b\\,c"'], [['a', 'b,c']], escapechar='\\') - self._read_test(['a,"b,\\c"'], [['a', 'b,\\c']], escapechar='\\') + self._read_test(['a,"b,\\c"'], [['a', 'b,c']], escapechar='\\') self._read_test(['a,"b,c\\""'], [['a', 'b,c"']], escapechar='\\') self._read_test(['a,"b,c"\\'], [['a', 'b,c\\']], escapechar='\\') From andrewmcnamara at users.sourceforge.net Mon Jan 10 02:04:43 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Mon Jan 10 02:04:48 2005 Subject: [Python-checkins] python/dist/src/Modules _csv.c,1.18,1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2676/Modules Modified Files: _csv.c Log Message: Fix parsing of csv files with escapes (escape character previously would be left in stream). Index: _csv.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_csv.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- _csv.c 7 Jan 2005 06:46:50 -0000 1.18 +++ _csv.c 10 Jan 2005 01:04:40 -0000 1.19 @@ -584,10 +584,6 @@ break; case ESCAPED_CHAR: - if (c != dialect->escapechar && - c != dialect->delimiter && - c != dialect->quotechar) - parse_add_char(self, dialect->escapechar); parse_add_char(self, c); self->state = IN_FIELD; break; @@ -642,10 +638,6 @@ break; case ESCAPE_IN_QUOTED_FIELD: - if (c != dialect->escapechar && - c != dialect->delimiter && - c != dialect->quotechar) - parse_add_char(self, dialect->escapechar); parse_add_char(self, c); self->state = IN_QUOTED_FIELD; break; From andrewmcnamara at users.sourceforge.net Mon Jan 10 03:09:44 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Mon Jan 10 03:09:48 2005 Subject: [Python-checkins] python/dist/src/Modules _csv.c,1.19,1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15750/Modules Modified Files: _csv.c Log Message: Add missing PyObject_GC_Track and PyObject_GC_UnTrack calls to csv reader and writer objects (other GC infrastructure already in place). Index: _csv.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_csv.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- _csv.c 10 Jan 2005 01:04:40 -0000 1.19 +++ _csv.c 10 Jan 2005 02:09:41 -0000 1.20 @@ -776,6 +776,7 @@ static void Reader_dealloc(ReaderObj *self) { + PyObject_GC_UnTrack(self); Py_XDECREF(self->dialect); Py_XDECREF(self->input_iter); Py_XDECREF(self->fields); @@ -909,6 +910,7 @@ return NULL; } + PyObject_GC_Track(self); return (PyObject *)self; } @@ -1234,6 +1236,7 @@ static void Writer_dealloc(WriterObj *self) { + PyObject_GC_UnTrack(self); Py_XDECREF(self->dialect); Py_XDECREF(self->writeline); if (self->rec != NULL) @@ -1349,6 +1352,7 @@ Py_DECREF(self); return NULL; } + PyObject_GC_Track(self); return (PyObject *)self; } From jlgijsbers at users.sourceforge.net Mon Jan 10 10:07:26 2005 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Mon Jan 10 10:07:29 2005 Subject: [Python-checkins] python/dist/src/Lib profile.py, 1.59, 1.60 profile.doc, 1.3, NONE Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30683 Modified Files: profile.py Removed Files: profile.doc Log Message: Bug #489256: remove out of date and out of place profile.doc, and let profile.help() point at the library reference instead of profile.doc. Index: profile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/profile.py,v retrieving revision 1.59 retrieving revision 1.60 diff -u -d -r1.59 -r1.60 --- profile.py 9 Jan 2005 01:58:02 -0000 1.59 +++ profile.py 10 Jan 2005 09:07:22 -0000 1.60 @@ -4,8 +4,6 @@ # # Based on prior profile module by Sjoerd Mullender... # which was hacked somewhat by: Guido van Rossum -# -# See profile.doc for more information """Class for profiling Python code.""" @@ -94,18 +92,10 @@ else: return prof.print_stats() -# print help +# Backwards compatibility. def help(): - for dirname in sys.path: - fullname = os.path.join(dirname, 'profile.doc') - if os.path.exists(fullname): - sts = os.system('${PAGER-more} ' + fullname) - if sts: print '*** Pager exit status:', sts - break - else: - print 'Sorry, can\'t find the help file "profile.doc"', - print 'along the Python search path.' - + print "Documentation for the profile module can be found " + print "in the Python Library Reference, section 'The Python Profiler'." if os.name == "mac": import MacOS --- profile.doc DELETED --- From jlgijsbers at users.sourceforge.net Mon Jan 10 10:27:20 2005 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Mon Jan 10 10:27:23 2005 Subject: [Python-checkins] python/dist/src/Lib SimpleHTTPServer.py, 1.22, 1.22.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2084 Modified Files: Tag: release24-maint SimpleHTTPServer.py Log Message: Backport for bug #839496: always read files in binary mode. Opening files in text mode may cause newline translations, making the actual size of the content transmitted *less* than the content-length. Index: SimpleHTTPServer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/SimpleHTTPServer.py,v retrieving revision 1.22 retrieving revision 1.22.2.1 diff -u -d -r1.22 -r1.22.2.1 --- SimpleHTTPServer.py 21 Aug 2004 10:43:29 -0000 1.22 +++ SimpleHTTPServer.py 10 Jan 2005 09:27:17 -0000 1.22.2.1 @@ -70,12 +70,11 @@ else: return self.list_directory(path) ctype = self.guess_type(path) - if ctype.startswith('text/'): - mode = 'r' - else: - mode = 'rb' try: - f = open(path, mode) + # Always read in binary mode. Opening files in text mode may cause + # newline translations, making the actual size of the content + # transmitted *less* than the content-length! + f = open(path, 'rb') except IOError: self.send_error(404, "File not found") return None From doerwalter at users.sourceforge.net Mon Jan 10 13:01:42 2005 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Mon Jan 10 13:01:45 2005 Subject: [Python-checkins] python/dist/src/Lib codecs.py,1.36,1.37 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1246/Lib Modified Files: codecs.py Log Message: Fix and test for SF bug #1098990: codec readline() splits lines apart. Index: codecs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/codecs.py,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- codecs.py 21 Dec 2004 22:24:00 -0000 1.36 +++ codecs.py 10 Jan 2005 12:01:38 -0000 1.37 @@ -322,9 +322,9 @@ line = line0withend else: line = line0withoutend - break + break # we didn't get anything or this was our only try - elif not data or size is not None: + if not data or size is not None: if line and not keepends: line = line.splitlines(False)[0] break From doerwalter at users.sourceforge.net Mon Jan 10 13:01:43 2005 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Mon Jan 10 13:01:46 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_codecs.py, 1.17, 1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1246/Lib/test Modified Files: test_codecs.py Log Message: Fix and test for SF bug #1098990: codec readline() splits lines apart. Index: test_codecs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_codecs.py,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- test_codecs.py 29 Dec 2004 16:04:38 -0000 1.17 +++ test_codecs.py 10 Jan 2005 12:01:39 -0000 1.18 @@ -108,6 +108,36 @@ writer.write(u"foo\r\n") self.assertEqual(reader.readline(keepends=True), u"foo\r\n") + def test_bug1098990_a(self): + s1 = u"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy\r\n" + s2 = u"offending line: ladfj askldfj klasdj fskla dfzaskdj fasklfj laskd fjasklfzzzzaa%whereisthis!!!\r\n" + s3 = u"next line.\r\n" + + s = (s1+s2+s3).encode(self.encoding) + stream = StringIO.StringIO(s) + reader = codecs.getreader(self.encoding)(stream) + self.assertEqual(reader.readline(), s1) + self.assertEqual(reader.readline(), s2) + self.assertEqual(reader.readline(), s3) + self.assertEqual(reader.readline(), u"") + + def test_bug1098990_b(self): + s1 = u"aaaaaaaaaaaaaaaaaaaaaaaa\r\n" + s2 = u"bbbbbbbbbbbbbbbbbbbbbbbb\r\n" + s3 = u"stillokay:bbbbxx\r\n" + s4 = u"broken!!!!badbad\r\n" + s5 = u"againokay.\r\n" + + s = (s1+s2+s3+s4+s5).encode(self.encoding) + stream = StringIO.StringIO(s) + reader = codecs.getreader(self.encoding)(stream) + self.assertEqual(reader.readline(), s1) + self.assertEqual(reader.readline(), s2) + self.assertEqual(reader.readline(), s3) + self.assertEqual(reader.readline(), s4) + self.assertEqual(reader.readline(), s5) + self.assertEqual(reader.readline(), u"") + class UTF16Test(ReadTest): encoding = "utf-16" From andrewmcnamara at users.sourceforge.net Mon Jan 10 13:22:51 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Mon Jan 10 13:22:53 2005 Subject: [Python-checkins] python/dist/src/Modules _csv.c,1.20,1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5700/Modules Modified Files: _csv.c Log Message: Where a string is desired, test for PyBaseString_Type derived type, rather than using PyString_Check/PyUnicode_Check. Index: _csv.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_csv.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- _csv.c 10 Jan 2005 02:09:41 -0000 1.20 +++ _csv.c 10 Jan 2005 12:22:48 -0000 1.21 @@ -39,6 +39,9 @@ #endif /* end 2.2 compatibility macros */ +#define IS_BASESTRING(o) \ + PyObject_TypeCheck(o, &PyBaseString_Type) + static PyObject *error_obj; /* CSV exception */ static PyObject *dialects; /* Dialect registry */ @@ -230,11 +233,7 @@ else { if (src == Py_None) *target = NULL; - else if (!PyString_Check(src) -#ifdef Py_USING_UNICODE - && !PyUnicode_Check(src) -#endif - ) { + else if (!IS_BASESTRING(src)) { PyErr_Format(PyExc_TypeError, "\"%s\" must be an string", name); return -1; @@ -298,11 +297,7 @@ { Py_INCREF(dialect); /* If dialect is a string, look it up in our registry */ - if (PyString_Check(dialect) -#ifdef Py_USING_UNICODE - || PyUnicode_Check(dialect) -#endif - ) { + if (IS_BASESTRING(dialect)) { PyObject * new_dia; new_dia = get_dialect_from_registry(dialect); Py_DECREF(dialect); @@ -1372,11 +1367,7 @@ if (!PyArg_UnpackTuple(args, "", 2, 2, &name_obj, &dialect_obj)) return NULL; - if (!PyString_Check(name_obj) -#ifdef Py_USING_UNICODE -&& !PyUnicode_Check(name_obj) -#endif -) { + if (!IS_BASESTRING(name_obj)) { PyErr_SetString(PyExc_TypeError, "dialect name must be a string or unicode"); return NULL; From andrewmcnamara at users.sourceforge.net Mon Jan 10 13:25:14 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Mon Jan 10 13:25:17 2005 Subject: [Python-checkins] python/dist/src/Modules _csv.c,1.21,1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6651/Modules Modified Files: _csv.c Log Message: When parsing args that return a single character, treat null string the same as None. Index: _csv.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_csv.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- _csv.c 10 Jan 2005 12:22:48 -0000 1.21 +++ _csv.c 10 Jan 2005 12:25:11 -0000 1.22 @@ -207,7 +207,7 @@ if (src == NULL) *target = dflt; else { - if (src == Py_None) + if (src == Py_None || PyString_Size(src) == 0) *target = '\0'; else if (!PyString_Check(src) || PyString_Size(src) != 1) { PyErr_Format(PyExc_TypeError, From doerwalter at users.sourceforge.net Mon Jan 10 13:26:02 2005 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Mon Jan 10 13:26:05 2005 Subject: [Python-checkins] python/dist/src/Lib codecs.py,1.35.2.1,1.35.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7055/Lib Modified Files: Tag: release24-maint codecs.py Log Message: Backport checkin: Fix and test for SF bug #1098990: codec readline() splits lines apart. Index: codecs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/codecs.py,v retrieving revision 1.35.2.1 retrieving revision 1.35.2.2 diff -u -d -r1.35.2.1 -r1.35.2.2 --- codecs.py 21 Dec 2004 22:35:23 -0000 1.35.2.1 +++ codecs.py 10 Jan 2005 12:26:00 -0000 1.35.2.2 @@ -322,9 +322,9 @@ line = line0withend else: line = line0withoutend - break + break # we didn't get anything or this was our only try - elif not data or size is not None: + if not data or size is not None: if line and not keepends: line = line.splitlines(False)[0] break From doerwalter at users.sourceforge.net Mon Jan 10 13:26:02 2005 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Mon Jan 10 13:26:06 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_codecs.py, 1.15.2.1, 1.15.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7055/Lib/test Modified Files: Tag: release24-maint test_codecs.py Log Message: Backport checkin: Fix and test for SF bug #1098990: codec readline() splits lines apart. Index: test_codecs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_codecs.py,v retrieving revision 1.15.2.1 retrieving revision 1.15.2.2 diff -u -d -r1.15.2.1 -r1.15.2.2 --- test_codecs.py 21 Dec 2004 22:35:24 -0000 1.15.2.1 +++ test_codecs.py 10 Jan 2005 12:26:00 -0000 1.15.2.2 @@ -108,6 +108,36 @@ writer.write(u"foo\r\n") self.assertEqual(reader.readline(keepends=True), u"foo\r\n") + def test_bug1098990_a(self): + s1 = u"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy\r\n" + s2 = u"offending line: ladfj askldfj klasdj fskla dfzaskdj fasklfj laskd fjasklfzzzzaa%whereisthis!!!\r\n" + s3 = u"next line.\r\n" + + s = (s1+s2+s3).encode(self.encoding) + stream = StringIO.StringIO(s) + reader = codecs.getreader(self.encoding)(stream) + self.assertEqual(reader.readline(), s1) + self.assertEqual(reader.readline(), s2) + self.assertEqual(reader.readline(), s3) + self.assertEqual(reader.readline(), u"") + + def test_bug1098990_b(self): + s1 = u"aaaaaaaaaaaaaaaaaaaaaaaa\r\n" + s2 = u"bbbbbbbbbbbbbbbbbbbbbbbb\r\n" + s3 = u"stillokay:bbbbxx\r\n" + s4 = u"broken!!!!badbad\r\n" + s5 = u"againokay.\r\n" + + s = (s1+s2+s3+s4+s5).encode(self.encoding) + stream = StringIO.StringIO(s) + reader = codecs.getreader(self.encoding)(stream) + self.assertEqual(reader.readline(), s1) + self.assertEqual(reader.readline(), s2) + self.assertEqual(reader.readline(), s3) + self.assertEqual(reader.readline(), s4) + self.assertEqual(reader.readline(), s5) + self.assertEqual(reader.readline(), u"") + class UTF16Test(ReadTest): encoding = "utf-16" From aleax at users.sourceforge.net Mon Jan 10 15:31:38 2005 From: aleax at users.sourceforge.net (aleax@users.sourceforge.net) Date: Mon Jan 10 15:31:46 2005 Subject: [Python-checkins] python/nondist/peps pep-0246.txt,1.5,1.6 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv414 Modified Files: pep-0246.txt Log Message: PEP 246 rewritten Index: pep-0246.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0246.txt,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- pep-0246.txt 13 Jul 2002 01:12:40 -0000 1.5 +++ pep-0246.txt 10 Jan 2005 14:31:35 -0000 1.6 @@ -6,50 +6,83 @@ Status: Draft Type: Standards Track Created: 21-Mar-2001 -Python-Version: 2.2 -Post-History: 29-Mar-2001 +Python-Version: 2.5 +Post-History: 29-Mar-2001, 10-Jan-2005 Abstract [...1006 lines suppressed...] - [7] http://mail.python.org/pipermail/python-list/2001-March/035136.html + [3] http://www.artima.com/weblogs/index.jsp?blogger=guido - [8] http://mail.python.org/pipermail/python-list/2001-March/035197.html + [4] http://www.artima.com/weblogs/viewpost.jsp?thread=87182 - [9] PEP 234, Iterators, Yee, Van Rossum - http://www.python.org/peps/pep-0234.txt + [5] http://peak.telecommunity.com/PyProtocols.html Copyright @@ -545,4 +731,6 @@ Local Variables: mode: indented-text indent-tabs-mode: nil +sentence-end-double-space: t +fill-column: 70 End: From tim_one at users.sourceforge.net Mon Jan 10 17:48:40 2005 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Jan 10 17:48:44 2005 Subject: [Python-checkins] python/dist/src/Lib profile.py,1.60,1.61 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29237/Lib Modified Files: profile.py Log Message: Whitespace normalization. Index: profile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/profile.py,v retrieving revision 1.60 retrieving revision 1.61 diff -u -d -r1.60 -r1.61 --- profile.py 10 Jan 2005 09:07:22 -0000 1.60 +++ profile.py 10 Jan 2005 16:48:37 -0000 1.61 @@ -581,14 +581,14 @@ help="Save stats to ", default=None) parser.add_option('-s', '--sort', dest="sort", help="Sort order when printing to stdout, based on pstats.Stats class", default=-1) - + if not sys.argv[1:]: parser.print_usage() sys.exit(2) - + (options, args) = parser.parse_args() sys.argv[:] = args - + if (len(sys.argv) > 0): sys.path.insert(0, os.path.dirname(sys.argv[0])) run('execfile(%r)' % (sys.argv[0],), options.outfile, options.sort) From andrewmcnamara at users.sourceforge.net Tue Jan 11 00:17:38 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Tue Jan 11 00:17:41 2005 Subject: [Python-checkins] python/dist/src/Modules _csv.c,1.22,1.23 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21350/Modules Modified Files: _csv.c Log Message: Only set error string when dict lookup found no matching key (was setting it for all failures, potentially masking other exceptions). Index: _csv.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_csv.c,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- _csv.c 10 Jan 2005 12:25:11 -0000 1.22 +++ _csv.c 10 Jan 2005 23:17:35 -0000 1.23 @@ -127,9 +127,12 @@ PyObject *dialect_obj; dialect_obj = PyDict_GetItem(dialects, name_obj); - if (dialect_obj == NULL) - return PyErr_Format(error_obj, "unknown dialect"); - Py_INCREF(dialect_obj); + if (dialect_obj == NULL) { + if (!PyErr_Occurred()) + PyErr_Format(error_obj, "unknown dialect"); + } + else + Py_INCREF(dialect_obj); return dialect_obj; } From andrewmcnamara at users.sourceforge.net Tue Jan 11 02:07:26 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Tue Jan 11 02:07:30 2005 Subject: [Python-checkins] python/dist/src/Modules _csv.c,1.23,1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12152/Modules Modified Files: _csv.c Log Message: Factor out the code for making a dialect instance. Index: _csv.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_csv.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- _csv.c 10 Jan 2005 23:17:35 -0000 1.23 +++ _csv.c 11 Jan 2005 01:07:23 -0000 1.24 @@ -496,6 +496,24 @@ 0, /* tp_free */ }; +/* + * Return an instance of the dialect type, given a Python instance or kwarg + * description of the dialect + */ +static PyObject * +_call_dialect(PyObject *dialect_inst, PyObject *kwargs) +{ + PyObject *ctor_args; + PyObject *dialect; + + ctor_args = Py_BuildValue(dialect_inst ? "(O)" : "()", dialect_inst); + if (ctor_args == NULL) + return NULL; + dialect = PyObject_Call((PyObject *)&Dialect_Type, ctor_args, kwargs); + Py_DECREF(ctor_args); + return dialect; +} + static void parse_save_field(ReaderObj *self) { @@ -862,7 +880,7 @@ static PyObject * csv_reader(PyObject *module, PyObject *args, PyObject *keyword_args) { - PyObject * iterator, * dialect = NULL, *ctor_args; + PyObject * iterator, * dialect = NULL; ReaderObj * self = PyObject_GC_New(ReaderObj, &Reader_Type); if (!self) @@ -890,14 +908,7 @@ Py_DECREF(self); return NULL; } - ctor_args = Py_BuildValue(dialect ? "(O)" : "()", dialect); - if (ctor_args == NULL) { - Py_DECREF(self); - return NULL; - } - self->dialect = (DialectObj *)PyObject_Call((PyObject *)&Dialect_Type, - ctor_args, keyword_args); - Py_DECREF(ctor_args); + self->dialect = (DialectObj *)_call_dialect(dialect, keyword_args); if (self->dialect == NULL) { Py_DECREF(self); return NULL; @@ -1313,7 +1324,7 @@ static PyObject * csv_writer(PyObject *module, PyObject *args, PyObject *keyword_args) { - PyObject * output_file, * dialect = NULL, *ctor_args; + PyObject * output_file, * dialect = NULL; WriterObj * self = PyObject_GC_New(WriterObj, &Writer_Type); if (!self) @@ -1338,14 +1349,7 @@ Py_DECREF(self); return NULL; } - ctor_args = Py_BuildValue(dialect ? "(O)" : "()", dialect); - if (ctor_args == NULL) { - Py_DECREF(self); - return NULL; - } - self->dialect = (DialectObj *)PyObject_Call((PyObject *)&Dialect_Type, - ctor_args, keyword_args); - Py_DECREF(ctor_args); + self->dialect = (DialectObj *)_call_dialect(dialect, keyword_args); if (self->dialect == NULL) { Py_DECREF(self); return NULL; From andrewmcnamara at users.sourceforge.net Tue Jan 11 02:28:35 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Tue Jan 11 02:28:38 2005 Subject: [Python-checkins] python/dist/src/Modules _csv.c,1.24,1.25 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16542/Modules Modified Files: _csv.c Log Message: Allow dialect-describing keywords to be supplied to register_dialect, record objects of internal dialect type, rather than instances of python objects. Index: _csv.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_csv.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- _csv.c 11 Jan 2005 01:07:23 -0000 1.24 +++ _csv.c 11 Jan 2005 01:28:24 -0000 1.25 @@ -1368,42 +1368,26 @@ } static PyObject * -csv_register_dialect(PyObject *module, PyObject *args) +csv_register_dialect(PyObject *module, PyObject *args, PyObject *kwargs) { - PyObject *name_obj, *dialect_obj; + PyObject *name_obj, *dialect_obj = NULL; + PyObject *dialect; - if (!PyArg_UnpackTuple(args, "", 2, 2, &name_obj, &dialect_obj)) + if (!PyArg_UnpackTuple(args, "", 1, 2, &name_obj, &dialect_obj)) return NULL; if (!IS_BASESTRING(name_obj)) { PyErr_SetString(PyExc_TypeError, "dialect name must be a string or unicode"); return NULL; } - Py_INCREF(dialect_obj); - /* A class rather than an instance? Instantiate */ - if (PyObject_TypeCheck(dialect_obj, &PyClass_Type)) { - PyObject * new_dia; - new_dia = PyObject_CallFunction(dialect_obj, ""); - Py_DECREF(dialect_obj); - if (new_dia == NULL) - return NULL; - dialect_obj = new_dia; - } - /* Make sure we finally have an instance */ - if (!PyInstance_Check(dialect_obj)) { - PyErr_SetString(PyExc_TypeError, "dialect must be an instance"); - Py_DECREF(dialect_obj); - return NULL; - } - if (PyObject_SetAttrString(dialect_obj, "_name", name_obj) < 0) { - Py_DECREF(dialect_obj); - return NULL; - } - if (PyDict_SetItem(dialects, name_obj, dialect_obj) < 0) { - Py_DECREF(dialect_obj); + dialect = _call_dialect(dialect_obj, kwargs); + if (dialect == NULL) + return NULL; + if (PyDict_SetItem(dialects, name_obj, dialect) < 0) { + Py_DECREF(dialect); return NULL; } - Py_DECREF(dialect_obj); + Py_DECREF(dialect); Py_INCREF(Py_None); return Py_None; } @@ -1538,7 +1522,7 @@ { "list_dialects", (PyCFunction)csv_list_dialects, METH_NOARGS, csv_list_dialects_doc}, { "register_dialect", (PyCFunction)csv_register_dialect, - METH_VARARGS, csv_register_dialect_doc}, + METH_VARARGS | METH_KEYWORDS, csv_register_dialect_doc}, { "unregister_dialect", (PyCFunction)csv_unregister_dialect, METH_O, csv_unregister_dialect_doc}, { "get_dialect", (PyCFunction)csv_get_dialect, From andrewmcnamara at users.sourceforge.net Tue Jan 11 02:28:35 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Tue Jan 11 02:28:39 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_csv.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-serv16542/Lib/test Modified Files: test_csv.py Log Message: Allow dialect-describing keywords to be supplied to register_dialect, record objects of internal dialect type, rather than instances of python objects. Index: test_csv.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_csv.py,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- test_csv.py 10 Jan 2005 01:04:40 -0000 1.16 +++ test_csv.py 11 Jan 2005 01:28:33 -0000 1.17 @@ -272,13 +272,22 @@ expected_dialects.sort() csv.register_dialect(name, myexceltsv) try: - self.failUnless(isinstance(csv.get_dialect(name), myexceltsv)) + self.failUnless(csv.get_dialect(name).delimiter, '\t') got_dialects = csv.list_dialects() got_dialects.sort() self.assertEqual(expected_dialects, got_dialects) finally: csv.unregister_dialect(name) + def test_register_kwargs(self): + name = 'fedcba' + csv.register_dialect(name, delimiter=';') + try: + self.failUnless(csv.get_dialect(name).delimiter, '\t') + self.failUnless(list(csv.reader('X;Y;Z', name)), ['X', 'Y', 'Z']) + finally: + csv.unregister_dialect(name) + def test_incomplete_dialect(self): class myexceltsv(csv.Dialect): delimiter = "\t" From andrewmcnamara at users.sourceforge.net Tue Jan 11 03:18:39 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Tue Jan 11 03:18:42 2005 Subject: [Python-checkins] python/dist/src/Modules _csv.c,1.25,1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25624/Modules Modified Files: _csv.c Log Message: No longer attempt to instantiate python classes describing dialects. This was done because we were previously performing validation of the dialect from python, but this is now down within the C module. Also, the method we were using to detect classes did not work with new-style classes. Index: _csv.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_csv.c,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- _csv.c 11 Jan 2005 01:28:24 -0000 1.25 +++ _csv.c 11 Jan 2005 02:18:35 -0000 1.26 @@ -288,40 +288,6 @@ self->ob_type->tp_free((PyObject *)self); } -/* - * Return a new reference to a dialect instance - * - * If given a string, looks up the name in our dialect registry - * If given a class, instantiate (which runs python validity checks) - * If given an instance, return a new reference to the instance - */ -static PyObject * -dialect_instantiate(PyObject *dialect) -{ - Py_INCREF(dialect); - /* If dialect is a string, look it up in our registry */ - if (IS_BASESTRING(dialect)) { - PyObject * new_dia; - new_dia = get_dialect_from_registry(dialect); - Py_DECREF(dialect); - return new_dia; - } - /* A class rather than an instance? Instantiate */ - if (PyObject_TypeCheck(dialect, &PyClass_Type)) { - PyObject * new_dia; - new_dia = PyObject_CallFunction(dialect, ""); - Py_DECREF(dialect); - return new_dia; - } - /* Make sure we finally have an instance */ - if (!PyInstance_Check(dialect)) { - PyErr_SetString(PyExc_TypeError, "dialect must be an instance"); - Py_DECREF(dialect); - return NULL; - } - return dialect; -} - static char *dialect_kws[] = { "dialect", "delimiter", @@ -371,9 +337,12 @@ Py_XINCREF(skipinitialspace); Py_XINCREF(strict); if (dialect != NULL) { - dialect = dialect_instantiate(dialect); - if (dialect == NULL) - goto err; + if (IS_BASESTRING(dialect)) { + dialect = get_dialect_from_registry(dialect); + if (dialect == NULL) + goto err; + } else + Py_INCREF(dialect); #define DIALECT_GETATTR(v, n) \ if (v == NULL) \ v = PyObject_GetAttrString(dialect, n) From andrewmcnamara at users.sourceforge.net Tue Jan 11 03:18:39 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Tue Jan 11 03:18:45 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_csv.py,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25624/Lib/test Modified Files: test_csv.py Log Message: No longer attempt to instantiate python classes describing dialects. This was done because we were previously performing validation of the dialect from python, but this is now down within the C module. Also, the method we were using to detect classes did not work with new-style classes. Index: test_csv.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_csv.py,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- test_csv.py 11 Jan 2005 01:28:33 -0000 1.17 +++ test_csv.py 11 Jan 2005 02:18:36 -0000 1.18 @@ -24,25 +24,12 @@ self.assertRaises(TypeError, ctor, arg, delimiter = 0) self.assertRaises(TypeError, ctor, arg, delimiter = 'XX') self.assertRaises(csv.Error, ctor, arg, 'foo') - self.assertRaises(TypeError, ctor, arg, None) self.assertRaises(TypeError, ctor, arg, delimiter=None) self.assertRaises(TypeError, ctor, arg, delimiter=1) self.assertRaises(TypeError, ctor, arg, quotechar=1) self.assertRaises(TypeError, ctor, arg, lineterminator=None) self.assertRaises(TypeError, ctor, arg, lineterminator=1) self.assertRaises(TypeError, ctor, arg, quoting=None) -# We now allow this, only raising an exception if quoting is needed. -# self.assertRaises(TypeError, ctor, arg, quotechar=None) -# self.assertRaises(TypeError, ctor, arg, -# quoting=csv.QUOTE_NONE, escapechar=None) -# No longer complains about dialects with invalid attributes [AM] -# class BadDialect: -# bad_attr = 0 -# self.assertRaises(AttributeError, csv.reader, [], BadDialect) - class BadClass: - def __init__(self): - raise IOError - self.assertRaises(IOError, csv.reader, [], BadClass) def test_reader_arg_valid(self): self._test_arg_valid(csv.reader, []) @@ -258,11 +245,6 @@ self.assertRaises(csv.Error, csv.unregister_dialect, "nonesuch") self.assertRaises(TypeError, csv.register_dialect, None) self.assertRaises(TypeError, csv.register_dialect, None, None) - self.assertRaises(TypeError, csv.register_dialect, "nonesuch", None) - class bogus: - def __init__(self): - raise KeyError - self.assertRaises(KeyError, csv.register_dialect, "nonesuch", bogus) def test_registry(self): class myexceltsv(csv.excel): From andrewmcnamara at users.sourceforge.net Tue Jan 11 03:23:01 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Tue Jan 11 03:23:04 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_csv.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-serv26712/Lib/test Modified Files: test_csv.py Log Message: Replace python-coded validation of csv dialect with a call to the C dialect type (which has a better idea of what is and isn't valid). Index: test_csv.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_csv.py,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- test_csv.py 11 Jan 2005 02:18:36 -0000 1.18 +++ test_csv.py 11 Jan 2005 02:22:47 -0000 1.19 @@ -727,10 +727,6 @@ mydialect.quoting = None self.assertRaises(csv.Error, mydialect) - mydialect.quoting = csv.QUOTE_NONE - mydialect.escapechar = None - self.assertRaises(csv.Error, mydialect) - mydialect.doublequote = True mydialect.quoting = csv.QUOTE_ALL mydialect.quotechar = '"' From andrewmcnamara at users.sourceforge.net Tue Jan 11 03:23:20 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Tue Jan 11 03:23:23 2005 Subject: [Python-checkins] python/dist/src/Lib csv.py,1.12,1.13 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26712/Lib Modified Files: csv.py Log Message: Replace python-coded validation of csv dialect with a call to the C dialect type (which has a better idea of what is and isn't valid). Index: csv.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/csv.py,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- csv.py 7 Jan 2005 04:42:45 -0000 1.12 +++ csv.py 11 Jan 2005 02:22:46 -0000 1.13 @@ -8,6 +8,7 @@ unregister_dialect, get_dialect, list_dialects, \ QUOTE_MINIMAL, QUOTE_ALL, QUOTE_NONNUMERIC, QUOTE_NONE, \ __doc__ +from _csv import Dialect as _Dialect try: from cStringIO import StringIO @@ -41,48 +42,14 @@ def __init__(self): if self.__class__ != Dialect: self._valid = True - errors = self._validate() - if errors != []: - raise Error, "Dialect did not validate: %s" % ", ".join(errors) + self._validate() def _validate(self): - errors = [] - if not self._valid: - errors.append("can't directly instantiate Dialect class") - - if self.delimiter is None: - errors.append("delimiter character not set") - elif (not isinstance(self.delimiter, str) or - len(self.delimiter) > 1): - errors.append("delimiter must be one-character string") - - if self.quotechar is None: - if self.quoting != QUOTE_NONE: - errors.append("quotechar not set") - elif (not isinstance(self.quotechar, str) or - len(self.quotechar) > 1): - errors.append("quotechar must be one-character string") - - if self.lineterminator is None: - errors.append("lineterminator not set") - elif not isinstance(self.lineterminator, str): - errors.append("lineterminator must be a string") - - if self.doublequote not in (True, False) and self.quoting != QUOTE_NONE: - errors.append("doublequote parameter must be True or False") - - if self.skipinitialspace not in (True, False): - errors.append("skipinitialspace parameter must be True or False") - - if self.quoting is None: - errors.append("quoting parameter not set") - - if self.quoting is QUOTE_NONE: - if (not isinstance(self.escapechar, (unicode, str)) or - len(self.escapechar) > 1): - errors.append("escapechar must be a one-character string or unicode object") - - return errors + try: + _Dialect(self) + except TypeError, e: + # We do this for compatibility with py2.3 + raise Error(str(e)) class excel(Dialect): """Describe the usual properties of Excel-generated CSV files.""" From rhettinger at users.sourceforge.net Tue Jan 11 04:03:30 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Jan 11 04:03:33 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1217,1.1218 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1421/Misc Modified Files: NEWS Log Message: SF 1098985: set objects cannot be marshalled Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1217 retrieving revision 1.1218 diff -u -d -r1.1217 -r1.1218 --- NEWS 8 Jan 2005 02:43:53 -0000 1.1217 +++ NEWS 11 Jan 2005 03:03:08 -0000 1.1218 @@ -16,6 +16,8 @@ - The peephole optimizer now performs simple constant folding in expressions: (2+3) --> (5). +- set and frozenset objects can now be marshalled. SF #1098985. + Extension Modules ----------------- From rhettinger at users.sourceforge.net Tue Jan 11 04:03:31 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Jan 11 04:03:35 2005 Subject: [Python-checkins] python/dist/src/Python marshal.c,1.80,1.81 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1421/Python Modified Files: marshal.c Log Message: SF 1098985: set objects cannot be marshalled Index: marshal.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/marshal.c,v retrieving revision 1.80 retrieving revision 1.81 diff -u -d -r1.80 -r1.81 --- marshal.c 20 Dec 2004 12:25:57 -0000 1.80 +++ marshal.c 11 Jan 2005 03:03:27 -0000 1.81 @@ -35,6 +35,8 @@ #define TYPE_CODE 'c' #define TYPE_UNICODE 'u' #define TYPE_UNKNOWN '?' +#define TYPE_SET '<' +#define TYPE_FROZENSET '>' typedef struct { FILE *fp; @@ -258,6 +260,38 @@ } w_object((PyObject *)NULL, p); } + else if (PyAnySet_Check(v)) { + int pos; + PyObject *value, *it; + + if (PyObject_TypeCheck(v, &PySet_Type)) + w_byte(TYPE_SET, p); + else + w_byte(TYPE_FROZENSET, p); + n = PyObject_Size(v); + if (n == -1) { + p->depth--; + p->error = 1; + return; + } + w_long((long)n, p); + it = PyObject_GetIter(v); + if (it == NULL) { + p->depth--; + p->error = 1; + return; + } + while ((value = PyIter_Next(it)) != NULL) { + w_object(value, p); + Py_DECREF(value); + } + Py_DECREF(it); + if (PyErr_Occurred()) { + p->depth--; + p->error = 1; + return; + } + } else if (PyCode_Check(v)) { PyCodeObject *co = (PyCodeObject *)v; w_byte(TYPE_CODE, p); @@ -406,7 +440,7 @@ { /* NULL is a valid return value, it does not necessarily means that an exception is set. */ - PyObject *v, *v2; + PyObject *v, *v2, *v3; long i, n; int type = r_byte(p); @@ -635,6 +669,37 @@ } return v; + case TYPE_SET: + case TYPE_FROZENSET: + n = r_long(p); + if (n < 0) { + PyErr_SetString(PyExc_ValueError, "bad marshal data"); + return NULL; + } + v = PyTuple_New((int)n); + if (v == NULL) + return v; + for (i = 0; i < n; i++) { + v2 = r_object(p); + if ( v2 == NULL ) { + if (!PyErr_Occurred()) + PyErr_SetString(PyExc_TypeError, + "NULL object in marshal data"); + Py_DECREF(v); + v = NULL; + break; + } + PyTuple_SET_ITEM(v, (int)i, v2); + } + if (type == TYPE_SET) + v3 = PyObject_CallFunctionObjArgs( + (PyObject *)&PySet_Type, v, NULL); + else + v3 = PyObject_CallFunctionObjArgs( + (PyObject *)&PyFrozenSet_Type, v, NULL); + Py_DECREF(v); + return v3; + case TYPE_CODE: if (PyEval_GetRestricted()) { PyErr_SetString(PyExc_RuntimeError, From rhettinger at users.sourceforge.net Tue Jan 11 04:03:40 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Jan 11 04:03:43 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_marshal.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1421/Lib/test Modified Files: test_marshal.py Log Message: SF 1098985: set objects cannot be marshalled Index: test_marshal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_marshal.py,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- test_marshal.py 20 Dec 2004 12:25:56 -0000 1.7 +++ test_marshal.py 11 Jan 2005 03:03:06 -0000 1.8 @@ -170,6 +170,18 @@ self.assertEqual(t, new) os.unlink(test_support.TESTFN) + def test_sets(self): + for constructor in (set, frozenset): + t = constructor(self.d.keys()) + new = marshal.loads(marshal.dumps(t)) + self.assertEqual(t, new) + self.assert_(isinstance(new, constructor)) + self.assertNotEqual(id(t), id(new)) + marshal.dump(t, file(test_support.TESTFN, "wb")) + marshal.load(file(test_support.TESTFN, "rb")) + self.assertEqual(t, new) + os.unlink(test_support.TESTFN) + class BugsTestCase(unittest.TestCase): def test_bug_5888452(self): # Simple-minded check for SF 588452: Debug build crashes From andrewmcnamara at users.sourceforge.net Tue Jan 11 05:49:56 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Tue Jan 11 05:50:00 2005 Subject: [Python-checkins] python/dist/src/Modules _csv.c,1.26,1.27 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22014/Modules Modified Files: _csv.c Log Message: Now that internal dialect type is immutable, and the dialect registry only contains instances of the dialect type, we can refer directly to the dialect instances rather than creating new ones. In other words, if the dialect comes from the registry, and we apply no further modifications, the reader/writer can use the dialect object directly. Index: _csv.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_csv.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- _csv.c 11 Jan 2005 02:18:35 -0000 1.26 +++ _csv.c 11 Jan 2005 04:49:53 -0000 1.27 @@ -301,11 +301,12 @@ NULL }; -static int -dialect_init(DialectObj * self, PyObject * args, PyObject * kwargs) +static PyObject * +dialect_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) { - int ret = -1; - PyObject *dialect = NULL; + DialectObj *self; + PyObject *ret = NULL; + PyObject *dialect = NULL; PyObject *delimiter = NULL; PyObject *doublequote = NULL; PyObject *escapechar = NULL; @@ -326,7 +327,35 @@ "ing, &skipinitialspace, &strict)) - return -1; + return NULL; + + if (dialect != NULL) { + if (IS_BASESTRING(dialect)) { + dialect = get_dialect_from_registry(dialect); + if (dialect == NULL) + return NULL; + } + else + Py_INCREF(dialect); + /* Can we reuse this instance? */ + if (PyObject_TypeCheck(dialect, &Dialect_Type) && + delimiter == 0 && + doublequote == 0 && + escapechar == 0 && + lineterminator == 0 && + quotechar == 0 && + quoting == 0 && + skipinitialspace == 0 && + strict == 0) + return dialect; + } + + self = (DialectObj *)type->tp_alloc(type, 0); + if (self == NULL) { + Py_XDECREF(dialect); + return NULL; + } + self->lineterminator = NULL; Py_XINCREF(delimiter); Py_XINCREF(doublequote); @@ -337,16 +366,9 @@ Py_XINCREF(skipinitialspace); Py_XINCREF(strict); if (dialect != NULL) { - if (IS_BASESTRING(dialect)) { - dialect = get_dialect_from_registry(dialect); - if (dialect == NULL) - goto err; - } else - Py_INCREF(dialect); #define DIALECT_GETATTR(v, n) \ if (v == NULL) \ v = PyObject_GetAttrString(dialect, n) - DIALECT_GETATTR(delimiter, "delimiter"); DIALECT_GETATTR(doublequote, "doublequote"); DIALECT_GETATTR(escapechar, "escapechar"); @@ -356,7 +378,6 @@ DIALECT_GETATTR(skipinitialspace, "skipinitialspace"); DIALECT_GETATTR(strict, "strict"); PyErr_Clear(); - Py_DECREF(dialect); } /* check types and convert to C values */ @@ -387,12 +408,13 @@ goto err; } if (self->lineterminator == 0) { - PyErr_SetString(PyExc_TypeError, "lineterminator must be set"); + PyErr_SetString(PyExc_TypeError, "lineterminator must be set"); goto err; } - ret = 0; + ret = (PyObject *)self; err: + Py_XDECREF(dialect); Py_XDECREF(delimiter); Py_XDECREF(doublequote); Py_XDECREF(escapechar); @@ -401,18 +423,7 @@ Py_XDECREF(quoting); Py_XDECREF(skipinitialspace); Py_XDECREF(strict); - return ret; -} - -static PyObject * -dialect_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) -{ - DialectObj *self; - self = (DialectObj *)type->tp_alloc(type, 0); - if (self != NULL) { - self->lineterminator = NULL; - } - return (PyObject *)self; + return ret; } @@ -459,8 +470,8 @@ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ - (initproc)dialect_init, /* tp_init */ - PyType_GenericAlloc, /* tp_alloc */ + 0, /* tp_init */ + 0, /* tp_alloc */ dialect_new, /* tp_new */ 0, /* tp_free */ }; From andrewmcnamara at users.sourceforge.net Tue Jan 11 08:32:05 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Tue Jan 11 08:32:08 2005 Subject: [Python-checkins] python/dist/src/Lib csv.py,1.13,1.14 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18525/Lib Modified Files: csv.py Log Message: Set an upper limit on the size of the field buffer, raise an exception when this limit is reached. Limit defaults to 128k, and is changed by module set_field_limit() method. Previously, an unmatched quote character could result in the entire file being read into the field buffer, potentially exhausting virtual memory. Index: csv.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/csv.py,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- csv.py 11 Jan 2005 02:22:46 -0000 1.13 +++ csv.py 11 Jan 2005 07:32:02 -0000 1.14 @@ -6,6 +6,7 @@ import re from _csv import Error, __version__, writer, reader, register_dialect, \ unregister_dialect, get_dialect, list_dialects, \ + set_field_limit, \ QUOTE_MINIMAL, QUOTE_ALL, QUOTE_NONNUMERIC, QUOTE_NONE, \ __doc__ from _csv import Dialect as _Dialect From andrewmcnamara at users.sourceforge.net Tue Jan 11 08:32:06 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Tue Jan 11 08:32:09 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_csv.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-serv18525/Lib/test Modified Files: test_csv.py Log Message: Set an upper limit on the size of the field buffer, raise an exception when this limit is reached. Limit defaults to 128k, and is changed by module set_field_limit() method. Previously, an unmatched quote character could result in the entire file being read into the field buffer, potentially exhausting virtual memory. Index: test_csv.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_csv.py,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- test_csv.py 11 Jan 2005 02:22:47 -0000 1.19 +++ test_csv.py 11 Jan 2005 07:32:02 -0000 1.20 @@ -229,10 +229,17 @@ quoting=csv.QUOTE_NONE, escapechar='\\') def test_read_bigfield(self): - # This exercises the buffer realloc functionality - bigstring = 'X' * 50000 + # This exercises the buffer realloc functionality and field size + # limits. + size = 50000 + bigstring = 'X' * size bigline = '%s,%s' % (bigstring, bigstring) self._read_test([bigline], [[bigstring, bigstring]]) + csv.set_field_limit(size) + self._read_test([bigline], [[bigstring, bigstring]]) + self.assertEqual(csv.set_field_limit(), size) + csv.set_field_limit(size-1) + self.assertRaises(csv.Error, self._read_test, [bigline], []) class TestDialectRegistry(unittest.TestCase): def test_registry_badargs(self): From andrewmcnamara at users.sourceforge.net Tue Jan 11 08:32:06 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Tue Jan 11 08:32:10 2005 Subject: [Python-checkins] python/dist/src/Modules _csv.c,1.27,1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18525/Modules Modified Files: _csv.c Log Message: Set an upper limit on the size of the field buffer, raise an exception when this limit is reached. Limit defaults to 128k, and is changed by module set_field_limit() method. Previously, an unmatched quote character could result in the entire file being read into the field buffer, potentially exhausting virtual memory. Index: _csv.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_csv.c,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- _csv.c 11 Jan 2005 04:49:53 -0000 1.27 +++ _csv.c 11 Jan 2005 07:32:02 -0000 1.28 @@ -44,6 +44,7 @@ static PyObject *error_obj; /* CSV exception */ static PyObject *dialects; /* Dialect registry */ +static long field_limit = 128 * 1024; /* max parsed field size */ typedef enum { START_RECORD, START_FIELD, ESCAPED_CHAR, IN_FIELD, @@ -527,15 +528,21 @@ return 1; } -static void +static int parse_add_char(ReaderObj *self, char c) { + if (self->field_len >= field_limit) { + PyErr_Format(error_obj, "field larger than field limit (%ld)", + field_limit); + return -1; + } if (self->field_len == self->field_size && !parse_grow_buff(self)) - return; + return -1; self->field[self->field_len++] = c; + return 0; } -static void +static int parse_process_char(ReaderObj *self, char c) { DialectObj *dialect = self->dialect; @@ -574,13 +581,15 @@ } else { /* begin new unquoted field */ - parse_add_char(self, c); + if (parse_add_char(self, c) < 0) + return -1; self->state = IN_FIELD; } break; case ESCAPED_CHAR: - parse_add_char(self, c); + if (parse_add_char(self, c) < 0) + return -1; self->state = IN_FIELD; break; @@ -602,7 +611,8 @@ } else { /* normal character - save in field */ - parse_add_char(self, c); + if (parse_add_char(self, c) < 0) + return -1; } break; @@ -610,7 +620,8 @@ /* in quoted field */ if (c == '\n') { /* end of line - save '\n' in field */ - parse_add_char(self, '\n'); + if (parse_add_char(self, '\n') < 0) + return -1; } else if (c == dialect->escapechar) { /* Possible escape character */ @@ -629,12 +640,14 @@ } else { /* normal character - save in field */ - parse_add_char(self, c); + if (parse_add_char(self, c) < 0) + return -1; } break; case ESCAPE_IN_QUOTED_FIELD: - parse_add_char(self, c); + if (parse_add_char(self, c) < 0) + return -1; self->state = IN_QUOTED_FIELD; break; @@ -643,7 +656,8 @@ if (dialect->quoting != QUOTE_NONE && c == dialect->quotechar) { /* save "" as " */ - parse_add_char(self, c); + if (parse_add_char(self, c) < 0) + return -1; self->state = IN_QUOTED_FIELD; } else if (c == dialect->delimiter) { @@ -657,7 +671,8 @@ self->state = START_RECORD; } else if (!dialect->strict) { - parse_add_char(self, c); + if (parse_add_char(self, c) < 0) + return -1; self->state = IN_FIELD; } else { @@ -666,10 +681,12 @@ PyErr_Format(error_obj, "%c expected after %c", dialect->delimiter, dialect->quotechar); + return -1; } break; } + return 0; } /* @@ -754,13 +771,15 @@ return PyErr_Format(error_obj, "newline inside string"); } - parse_process_char(self, c); - if (PyErr_Occurred()) { - Py_DECREF(lineobj); - return NULL; - } - } - parse_process_char(self, '\n'); + if (parse_process_char(self, c) < 0) { + Py_DECREF(lineobj); + return NULL; + } + } + if (parse_process_char(self, '\n') < 0) { + Py_DECREF(lineobj); + return NULL; + } Py_DECREF(lineobj); } while (self->state != START_RECORD); @@ -1387,6 +1406,25 @@ return get_dialect_from_registry(name_obj); } +static PyObject * +csv_set_field_limit(PyObject *module, PyObject *args) +{ + PyObject *new_limit = NULL; + long old_limit = field_limit; + + if (!PyArg_UnpackTuple(args, "set_field_limit", 0, 1, &new_limit)) + return NULL; + if (new_limit != NULL) { + if (!PyInt_Check(new_limit)) { + PyErr_Format(PyExc_TypeError, + "limit must be an integer"); + return NULL; + } + field_limit = PyInt_AsLong(new_limit); + } + return PyInt_FromLong(old_limit); +} + /* * MODULE */ @@ -1494,20 +1532,29 @@ "Delete the name/dialect mapping associated with a string name.\n" " csv.unregister_dialect(name)"); +PyDoc_STRVAR(csv_set_field_limit_doc, +"Sets an upper limit on parsed fields.\n" +" csv.set_field_limit([limit])\n" +"\n" +"Returns old limit. If limit is not given, no new limit is set and\n" +"the old limit is returned"); + static struct PyMethodDef csv_methods[] = { - { "reader", (PyCFunction)csv_reader, - METH_VARARGS | METH_KEYWORDS, csv_reader_doc}, - { "writer", (PyCFunction)csv_writer, - METH_VARARGS | METH_KEYWORDS, csv_writer_doc}, - { "list_dialects", (PyCFunction)csv_list_dialects, - METH_NOARGS, csv_list_dialects_doc}, - { "register_dialect", (PyCFunction)csv_register_dialect, + { "reader", (PyCFunction)csv_reader, + METH_VARARGS | METH_KEYWORDS, csv_reader_doc}, + { "writer", (PyCFunction)csv_writer, + METH_VARARGS | METH_KEYWORDS, csv_writer_doc}, + { "list_dialects", (PyCFunction)csv_list_dialects, + METH_NOARGS, csv_list_dialects_doc}, + { "register_dialect", (PyCFunction)csv_register_dialect, METH_VARARGS | METH_KEYWORDS, csv_register_dialect_doc}, - { "unregister_dialect", (PyCFunction)csv_unregister_dialect, - METH_O, csv_unregister_dialect_doc}, - { "get_dialect", (PyCFunction)csv_get_dialect, - METH_O, csv_get_dialect_doc}, - { NULL, NULL } + { "unregister_dialect", (PyCFunction)csv_unregister_dialect, + METH_O, csv_unregister_dialect_doc}, + { "get_dialect", (PyCFunction)csv_get_dialect, + METH_O, csv_get_dialect_doc}, + { "set_field_limit", (PyCFunction)csv_set_field_limit, + METH_VARARGS, csv_set_field_limit_doc}, + { NULL, NULL } }; PyMODINIT_FUNC From jackjansen at users.sourceforge.net Tue Jan 11 14:49:09 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Tue Jan 11 14:49:13 2005 Subject: [Python-checkins] python/dist/src Makefile.pre.in, 1.136.6.5, 1.136.6.6 configure, 1.416.4.17, 1.416.4.18 configure.in, 1.427.4.16, 1.427.4.17 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29714 Modified Files: Tag: release23-maint Makefile.pre.in configure configure.in Log Message: Backport of fixes for #887242 and #1097739: If $MACOSX_DEPLOYMENT_TARGET is set, and >= 10.3, during configure we setup extensions to link with dynamic lookup. We also record the value in the Makefile, and distutils uses the same value to build extension modules. If MACOSX_DEPLOYMENT_TARGET is not set it defaults to the current OSX version. If we cannot use -undefined dynamic_lookup (such as on 10.2 or earlier) we link extensions directly against the dynamic library in the framework in stead of against the framework. This will fix building extensions for 2.3 after 2.4 has been installed too. Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.pre.in,v retrieving revision 1.136.6.5 retrieving revision 1.136.6.6 diff -u -d -r1.136.6.5 -r1.136.6.6 --- Makefile.pre.in 26 Sep 2004 17:26:16 -0000 1.136.6.5 +++ Makefile.pre.in 11 Jan 2005 13:48:52 -0000 1.136.6.6 @@ -107,6 +107,9 @@ PYTHONFRAMEWORKDIR= @PYTHONFRAMEWORKDIR@ PYTHONFRAMEWORKPREFIX= @PYTHONFRAMEWORKPREFIX@ PYTHONFRAMEWORKINSTALLDIR= @PYTHONFRAMEWORKINSTALLDIR@ +# Deployment target selected during configure, to be checked +# by distutils +CONFIGURE_MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@ # Options to enable prebinding (for fast startup) OTHER_LIBTOOL_OPT = -prebind -seg1addr 0x10000000 Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.416.4.17 retrieving revision 1.416.4.18 diff -u -d -r1.416.4.17 -r1.416.4.18 --- configure 18 Sep 2004 10:06:26 -0000 1.416.4.17 +++ configure 11 Jan 2005 13:48:52 -0000 1.416.4.18 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 1.427.4.15 . +# From configure.in Revision: 1.427.4.16 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59 for python 2.3. # @@ -310,7 +310,7 @@ # include #endif" -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS VERSION SOVERSION CONFIG_ARGS PYTHONFRAMEWORK PYTHONFRAMEWORKDIR PYTHONFRAMEWORKPREFIX PYTHONFRAMEWORKINSTALLDIR MACHDEP SGI_ABI EXTRAPLATDIR EXTRAMACHDEPPATH CXX MAINOBJ EXEEXT CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC OBJEXT CPP EGREP BUILDEXEEXT LIBRARY LDLIBRARY DLLLIBRARY BLDLIBRARY LDLIBRARYDIR INSTSONAME RUNSHARED LINKCC RANLIB ac_ct_RANLIB AR INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LN OPT BASECFLAGS LIBTOOL_CRUFT SO LDSHARED BLDSHARED CCSHARED LINKFORSHARED CFLAGSFORSHARED SHLIBS USE_SIGNAL_MODULE SIGNAL_OBJS USE_THREAD_MODULE LDLAST THREADOBJ DLINCLDIR DYNLOADFILE MACHDEP_OBJS TRUE LIBOBJS HAVE_GETHOSTBYNAME_R_6_ARG HAVE_GETHOSTBYNAME_R_5_ARG HAVE_GETHOSTBYNAME_R_3_ARG HAVE_GETHOSTBYNAME_R HAVE_GETHOSTBYNAME LIBM LIBC UNICODE_OBJS THREADHEADERS SRCDIRS LTLIBOBJS' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS VERSION SOVERSION CONFIG_ARGS PYTHONFRAMEWORK PYTHONFRAMEWORKDIR PYTHONFRAMEWORKPREFIX PYTHONFRAMEWORKINSTALLDIR MACHDEP SGI_ABI EXTRAPLATDIR EXTRAMACHDEPPATH CONFIGURE_MACOSX_DEPLOYMENT_TARGET CXX MAINOBJ EXEEXT CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC OBJEXT CPP EGREP BUILDEXEEXT LIBRARY LDLIBRARY DLLLIBRARY BLDLIBRARY LDLIBRARYDIR INSTSONAME RUNSHARED LINKCC RANLIB ac_ct_RANLIB AR INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LN OPT BASECFLAGS LIBTOOL_CRUFT SO LDSHARED BLDSHARED CCSHARED LINKFORSHARED CFLAGSFORSHARED SHLIBS USE_SIGNAL_MODULE SIGNAL_OBJS USE_THREAD_MODULE LDLAST THREADOBJ DLINCLDIR DYNLOADFILE MACHDEP_OBJS TRUE LIBOBJS HAVE_GETHOSTBYNAME_R_6_ARG HAVE_GETHOSTBYNAME_R_5_ARG HAVE_GETHOSTBYNAME_R_3_ARG HAVE_GETHOSTBYNAME_R HAVE_GETHOSTBYNAME LIBM LIBC UNICODE_OBJS THREADHEADERS SRCDIRS LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. @@ -1573,6 +1573,12 @@ echo "$as_me:$LINENO: result: $EXTRAPLATDIR" >&5 echo "${ECHO_T}$EXTRAPLATDIR" >&6 +# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET, +# it may influence the way we can build extensions, so distutils +# needs to check it + +CONFIGURE_MACOSX_DEPLOYMENT_TARGET= + # checks for alternative programs # compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just @@ -10969,21 +10975,45 @@ LDSHARED='$(CC) $(LDFLAGS) -bundle' if test "$enable_framework" ; then # Link against the framework. All externals should be defined. - LDSHARED="$LDSHARED "'-framework $(PYTHONFRAMEWORK)' + BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' else # No framework. Ignore undefined symbols, assuming they come from Python LDSHARED="$LDSHARED -undefined suppress" fi ;; - Darwin/*) + Darwin/1.4*|Darwin/5.*|Darwin/6.*) LDSHARED='$(CC) $(LDFLAGS) -bundle' if test "$enable_framework" ; then # Link against the framework. All externals should be defined. - LDSHARED="$LDSHARED "'-framework $(PYTHONFRAMEWORK)' + BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' else # No framework, use the Python app as bundle-loader BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)' LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)' fi ;; + Darwin/*) + # Use -undefined dynamic_lookup whenever possible (10.3 and later). + # This allows an extension to be used in any Python + cur_target=`sw_vers -productVersion | sed 's/\(10\.[0-9]*\).*/\1/'` + CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}} + if test ${MACOSX_DEPLOYMENT_TARGET-${cur_target}} '>' 10.2 + then + LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup' + BLDSHARED="$LDSHARED" + else + LDSHARED='$(CC) $(LDFLAGS) -bundle' + if test "$enable_framework" ; then + # Link against the framework. All externals should be defined. + BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + else + # No framework, use the Python app as bundle-loader + BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)' + LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)' + fi + fi + ;; Linux*|GNU*) LDSHARED='$(CC) -shared';; dgux*) LDSHARED="ld -G";; BSD/OS*/4*) LDSHARED="gcc -shared";; @@ -11075,7 +11105,7 @@ LINKFORSHARED="$extra_undefs -framework System" if test "$enable_framework" then - LINKFORSHARED="$LINKFORSHARED -framework Python" + LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' fi LINKFORSHARED="$LINKFORSHARED $extra_frameworks";; OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";; @@ -21394,6 +21424,7 @@ s,@SGI_ABI@,$SGI_ABI,;t t s,@EXTRAPLATDIR@,$EXTRAPLATDIR,;t t s,@EXTRAMACHDEPPATH@,$EXTRAMACHDEPPATH,;t t +s,@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@,$CONFIGURE_MACOSX_DEPLOYMENT_TARGET,;t t s,@CXX@,$CXX,;t t s,@MAINOBJ@,$MAINOBJ,;t t s,@EXEEXT@,$EXEEXT,;t t Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.427.4.16 retrieving revision 1.427.4.17 diff -u -d -r1.427.4.16 -r1.427.4.17 --- configure.in 18 Sep 2004 10:06:32 -0000 1.427.4.16 +++ configure.in 11 Jan 2005 13:49:00 -0000 1.427.4.17 @@ -220,6 +220,12 @@ fi AC_MSG_RESULT($EXTRAPLATDIR) +# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET, +# it may influence the way we can build extensions, so distutils +# needs to check it +AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET) +CONFIGURE_MACOSX_DEPLOYMENT_TARGET= + # checks for alternative programs # compiler flags are generated in two sets, BASECFLAGS and OPT. OPT is just @@ -1273,21 +1279,45 @@ LDSHARED='$(CC) $(LDFLAGS) -bundle' if test "$enable_framework" ; then # Link against the framework. All externals should be defined. - LDSHARED="$LDSHARED "'-framework $(PYTHONFRAMEWORK)' + BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' else # No framework. Ignore undefined symbols, assuming they come from Python LDSHARED="$LDSHARED -undefined suppress" fi ;; - Darwin/*) + Darwin/1.4*|Darwin/5.*|Darwin/6.*) LDSHARED='$(CC) $(LDFLAGS) -bundle' if test "$enable_framework" ; then # Link against the framework. All externals should be defined. - LDSHARED="$LDSHARED "'-framework $(PYTHONFRAMEWORK)' + BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' else # No framework, use the Python app as bundle-loader BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)' LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)' fi ;; + Darwin/*) + # Use -undefined dynamic_lookup whenever possible (10.3 and later). + # This allows an extension to be used in any Python + cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'` + CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}} + if test ${MACOSX_DEPLOYMENT_TARGET-${cur_target}} '>' 10.2 + then + LDSHARED='$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup' + BLDSHARED="$LDSHARED" + else + LDSHARED='$(CC) $(LDFLAGS) -bundle' + if test "$enable_framework" ; then + # Link against the framework. All externals should be defined. + BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' + else + # No framework, use the Python app as bundle-loader + BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)' + LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)' + fi + fi + ;; Linux*|GNU*) LDSHARED='$(CC) -shared';; dgux*) LDSHARED="ld -G";; BSD/OS*/4*) LDSHARED="gcc -shared";; @@ -1375,7 +1405,7 @@ LINKFORSHARED="$extra_undefs -framework System" if test "$enable_framework" then - LINKFORSHARED="$LINKFORSHARED -framework Python" + LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' fi LINKFORSHARED="$LINKFORSHARED $extra_frameworks";; OpenUNIX*|UnixWare*) LINKFORSHARED="-Wl,-Bexport";; From jackjansen at users.sourceforge.net Tue Jan 11 14:49:19 2005 From: jackjansen at users.sourceforge.net (jackjansen@users.sourceforge.net) Date: Tue Jan 11 14:49:24 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils sysconfig.py, 1.57, 1.57.12.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29714/Lib/distutils Modified Files: Tag: release23-maint sysconfig.py Log Message: Backport of fixes for #887242 and #1097739: If $MACOSX_DEPLOYMENT_TARGET is set, and >= 10.3, during configure we setup extensions to link with dynamic lookup. We also record the value in the Makefile, and distutils uses the same value to build extension modules. If MACOSX_DEPLOYMENT_TARGET is not set it defaults to the current OSX version. If we cannot use -undefined dynamic_lookup (such as on 10.2 or earlier) we link extensions directly against the dynamic library in the framework in stead of against the framework. This will fix building extensions for 2.3 after 2.4 has been installed too. Index: sysconfig.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/sysconfig.py,v retrieving revision 1.57 retrieving revision 1.57.12.1 diff -u -d -r1.57 -r1.57.12.1 --- sysconfig.py 10 Feb 2003 14:02:33 -0000 1.57 +++ sysconfig.py 11 Jan 2005 13:49:02 -0000 1.57.12.1 @@ -355,7 +355,21 @@ raise DistutilsPlatformError(my_msg) - + # On MacOSX we need to check the setting of the environment variable + # MACOSX_DEPLOYMENT_TARGET: configure bases some choices on it so + # it needs to be compatible. + # If it isn't set we set it to the configure-time value + if sys.platform == 'darwin' and g.has_key('CONFIGURE_MACOSX_DEPLOYMENT_TARGET'): + cfg_target = g['CONFIGURE_MACOSX_DEPLOYMENT_TARGET'] + cur_target = os.getenv('MACOSX_DEPLOYMENT_TARGET', '') + if cur_target == '': + cur_target = cfg_target + os.putenv('MACOSX_DEPLOYMENT_TARGET', cfg_target) + if cfg_target != cur_target: + my_msg = ('$MACOSX_DEPLOYMENT_TARGET mismatch: now "%s" but "%s" during configure' + % (cur_target, cfg_target)) + raise DistutilsPlatformError(my_msg) + # On AIX, there are wrong paths to the linker scripts in the Makefile # -- these paths are relative to the Python source, but when installed # the scripts are in another directory. From rhettinger at users.sourceforge.net Tue Jan 11 16:33:08 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Jan 11 16:33:13 2005 Subject: [Python-checkins] python/dist/src/Lib tempfile.py,1.60,1.61 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22102 Modified Files: tempfile.py Log Message: SF bug #1099516: tempfile files not types.FileType Clarified that the returned object is file-like rather than an actual file. Index: tempfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tempfile.py,v retrieving revision 1.60 retrieving revision 1.61 diff -u -d -r1.60 -r1.61 --- tempfile.py 18 Jul 2004 23:58:16 -0000 1.60 +++ tempfile.py 11 Jan 2005 15:33:03 -0000 1.61 @@ -414,9 +414,9 @@ 'bufsize' -- the buffer size argument to os.fdopen (default -1). The file is created as mkstemp() would do it. - Returns a file object; the name of the file is accessible as - file.name. The file will be automatically deleted when it is - closed. + Returns an object with a file-like interface; the name of the file + is accessible as file.name. The file will be automatically deleted + when it is closed. """ if dir is None: @@ -451,8 +451,8 @@ 'bufsize' -- the buffer size argument to os.fdopen (default -1). The file is created as mkstemp() would do it. - Returns a file object. The file has no name, and will cease to - exist when it is closed. + Returns an object with a file-like interface. The file has no + name, and will cease to exist when it is closed. """ if dir is None: From rhettinger at users.sourceforge.net Tue Jan 11 16:38:45 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Jan 11 16:38:49 2005 Subject: [Python-checkins] python/dist/src/Lib tempfile.py,1.60,1.60.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23598 Modified Files: Tag: release24-maint tempfile.py Log Message: SF bug #1099516: tempfile files not types.FileType Clarified that the returned object is file-like rather than an actual file. Index: tempfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tempfile.py,v retrieving revision 1.60 retrieving revision 1.60.4.1 diff -u -d -r1.60 -r1.60.4.1 --- tempfile.py 18 Jul 2004 23:58:16 -0000 1.60 +++ tempfile.py 11 Jan 2005 15:38:41 -0000 1.60.4.1 @@ -414,9 +414,9 @@ 'bufsize' -- the buffer size argument to os.fdopen (default -1). The file is created as mkstemp() would do it. - Returns a file object; the name of the file is accessible as - file.name. The file will be automatically deleted when it is - closed. + Returns an object with a file-like interface; the name of the file + is accessible as file.name. The file will be automatically deleted + when it is closed. """ if dir is None: @@ -451,8 +451,8 @@ 'bufsize' -- the buffer size argument to os.fdopen (default -1). The file is created as mkstemp() would do it. - Returns a file object. The file has no name, and will cease to - exist when it is closed. + Returns an object with a file-like interface. The file has no + name, and will cease to exist when it is closed. """ if dir is None: From rhettinger at users.sourceforge.net Tue Jan 11 17:11:18 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Jan 11 17:11:24 2005 Subject: [Python-checkins] python/dist/src/Doc/tut glossary.tex,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31242 Modified Files: glossary.tex Log Message: Add duck-typing to the glossary. Index: glossary.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/glossary.tex,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- glossary.tex 2 Dec 2004 07:29:43 -0000 1.10 +++ glossary.tex 11 Jan 2005 16:11:13 -0000 1.11 @@ -85,6 +85,17 @@ can be any object with a \method{__hash__()} function, not just integers starting from zero. Called a hash in Perl. +\index{duck-typing} +\item{duck-typing} +Pythonic programming style that determines an object's type by inspection +of its method or attribute signature rather than by explicit relationship +to some type object ("If it looks like a duck and quacks like a duck, it +must be a duck.") By emphasizing interfaces rather than specific types, +well-designed code improves its flexibility by allowing polymorphic +substitution. Duck-typing avoids tests using \function{type()} or +\function{isinstance()}. Instead, it typically employs +\function{hasattr()} tests or {}\emph{EAFP} programming. + \index{EAFP} \item[EAFP] Easier to ask for forgiveness than permission. This common Python From rhettinger at users.sourceforge.net Tue Jan 11 17:14:58 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Jan 11 17:15:02 2005 Subject: [Python-checkins] python/dist/src/Doc/tut glossary.tex, 1.9.4.1, 1.9.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32405 Modified Files: Tag: release24-maint glossary.tex Log Message: Add duck-typing to the glossary. Index: glossary.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/glossary.tex,v retrieving revision 1.9.4.1 retrieving revision 1.9.4.2 diff -u -d -r1.9.4.1 -r1.9.4.2 --- glossary.tex 2 Dec 2004 08:57:19 -0000 1.9.4.1 +++ glossary.tex 11 Jan 2005 16:14:55 -0000 1.9.4.2 @@ -85,6 +85,17 @@ can be any object with a \method{__hash__()} function, not just integers starting from zero. Called a hash in Perl. +\index{duck-typing} +\item{duck-typing} +Pythonic programming style that determines an object's type by inspection +of its method or attribute signature rather than by explicit relationship +to some type object ("If it looks like a duck and quacks like a duck, it +must be a duck.") By emphasizing interfaces rather than specific types, +well-designed code improves its flexibility by allowing polymorphic +substitution. Duck-typing avoids tests using \function{type()} or +\function{isinstance()}. Instead, it typically employs +\function{hasattr()} tests or {}\emph{EAFP} programming. + \index{EAFP} \item[EAFP] Easier to ask for forgiveness than permission. This common Python From kbk at users.sourceforge.net Tue Jan 11 20:29:44 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Tue Jan 11 20:29:49 2005 Subject: [Python-checkins] python/dist/src/Lib/idlelib configHandler.py, 1.35, 1.36 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9898 Modified Files: configHandler.py Log Message: Improve error handling when .idlerc can't be created. Index: configHandler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/configHandler.py,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- configHandler.py 6 Jun 2004 01:29:22 -0000 1.35 +++ configHandler.py 11 Jan 2005 19:29:39 -0000 1.36 @@ -193,26 +193,28 @@ """ Creates (if required) and returns a filesystem directory for storing user config files. + """ - cfgDir='.idlerc' - userDir=os.path.expanduser('~') - if userDir != '~': #'HOME' exists as a key in os.environ + cfgDir = '.idlerc' + userDir = os.path.expanduser('~') + if userDir != '~': # expanduser() found user home dir if not os.path.exists(userDir): - warn=('\n Warning: HOME environment variable points to\n '+ - userDir+'\n but the path does not exist.\n') + warn = ('\n Warning: os.path.expanduser("~") points to\n '+ + userDir+',\n but the path does not exist.\n') sys.stderr.write(warn) - userDir='~' - if userDir=='~': #we still don't have a home directory - #traditionally idle has defaulted to os.getcwd(), is this adeqate? - userDir = os.getcwd() #hack for no real homedir - userDir=os.path.join(userDir,cfgDir) + userDir = '~' + if userDir == "~": # still no path to home! + # traditionally IDLE has defaulted to os.getcwd(), is this adequate? + userDir = os.getcwd() + userDir = os.path.join(userDir, cfgDir) if not os.path.exists(userDir): - try: #make the config dir if it doesn't exist yet + try: os.mkdir(userDir) - except IOError: - warn=('\n Warning: unable to create user config directory\n '+ - userDir+'\n') + except (OSError, IOError): + warn = ('\n Warning: unable to create user config directory\n'+ + userDir+'\n Check path and permissions.\n Exiting!\n\n') sys.stderr.write(warn) + raise SystemExit return userDir def GetOption(self, configType, section, option, default=None, type=None, From andrewmcnamara at users.sourceforge.net Wed Jan 12 02:16:38 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Wed Jan 12 02:16:42 2005 Subject: [Python-checkins] python/dist/src/Modules _csv.c,1.28,1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22437/Modules Modified Files: _csv.c Log Message: Add belt and braces check of PyString_AsString return. Index: _csv.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_csv.c,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- _csv.c 11 Jan 2005 07:32:02 -0000 1.28 +++ _csv.c 12 Jan 2005 01:16:35 -0000 1.29 @@ -1098,6 +1098,7 @@ join_append_lineterminator(WriterObj *self) { int terminator_len; + char *terminator; terminator_len = PyString_Size(self->dialect->lineterminator); @@ -1105,10 +1106,10 @@ if (!join_check_rec_size(self, self->rec_len + terminator_len)) return 0; - memmove(self->rec + self->rec_len, - /* should not be NULL */ - PyString_AsString(self->dialect->lineterminator), - terminator_len); + terminator = PyString_AsString(self->dialect->lineterminator); + if (terminator == NULL) + return 0; + memmove(self->rec + self->rec_len, terminator, terminator_len); self->rec_len += terminator_len; return 1; From andrewmcnamara at users.sourceforge.net Wed Jan 12 02:55:25 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Wed Jan 12 02:55:29 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_csv.py,1.20,1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30273/Lib/test Modified Files: test_csv.py Log Message: Improve test coverage fractionally. Index: test_csv.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_csv.py,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- test_csv.py 11 Jan 2005 07:32:02 -0000 1.20 +++ test_csv.py 12 Jan 2005 01:55:21 -0000 1.21 @@ -30,6 +30,8 @@ self.assertRaises(TypeError, ctor, arg, lineterminator=None) self.assertRaises(TypeError, ctor, arg, lineterminator=1) self.assertRaises(TypeError, ctor, arg, quoting=None) + self.assertRaises(TypeError, ctor, arg, + quoting=csv.QUOTE_ALL, quotechar='') def test_reader_arg_valid(self): self._test_arg_valid(csv.reader, []) @@ -231,15 +233,21 @@ def test_read_bigfield(self): # This exercises the buffer realloc functionality and field size # limits. - size = 50000 - bigstring = 'X' * size - bigline = '%s,%s' % (bigstring, bigstring) - self._read_test([bigline], [[bigstring, bigstring]]) - csv.set_field_limit(size) - self._read_test([bigline], [[bigstring, bigstring]]) - self.assertEqual(csv.set_field_limit(), size) - csv.set_field_limit(size-1) - self.assertRaises(csv.Error, self._read_test, [bigline], []) + limit = csv.set_field_limit() + try: + size = 50000 + bigstring = 'X' * size + bigline = '%s,%s' % (bigstring, bigstring) + self._read_test([bigline], [[bigstring, bigstring]]) + csv.set_field_limit(size) + self._read_test([bigline], [[bigstring, bigstring]]) + self.assertEqual(csv.set_field_limit(), size) + csv.set_field_limit(size-1) + self.assertRaises(csv.Error, self._read_test, [bigline], []) + self.assertRaises(TypeError, csv.set_field_limit, None) + self.assertRaises(TypeError, csv.set_field_limit, 1, None) + finally: + csv.set_field_limit(limit) class TestDialectRegistry(unittest.TestCase): def test_registry_badargs(self): @@ -252,6 +260,12 @@ self.assertRaises(csv.Error, csv.unregister_dialect, "nonesuch") self.assertRaises(TypeError, csv.register_dialect, None) self.assertRaises(TypeError, csv.register_dialect, None, None) + self.assertRaises(TypeError, csv.register_dialect, "nonesuch", 0, 0) + self.assertRaises(TypeError, csv.register_dialect, "nonesuch", + badargument=None) + self.assertRaises(TypeError, csv.register_dialect, "nonesuch", + quoting=None) + self.assertRaises(TypeError, csv.register_dialect, []) def test_registry(self): class myexceltsv(csv.excel): From andrewmcnamara at users.sourceforge.net Wed Jan 12 04:25:39 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Wed Jan 12 04:25:43 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1218,1.1219 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13389/Misc Modified Files: NEWS Log Message: Add news about csv module updates. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1218 retrieving revision 1.1219 diff -u -d -r1.1218 -r1.1219 --- NEWS 11 Jan 2005 03:03:08 -0000 1.1218 +++ NEWS 12 Jan 2005 03:25:27 -0000 1.1219 @@ -35,6 +35,34 @@ Library ------- +- Enhancements to the csv module: + + + Dialects are now validated by the underlying C code, better + reflecting it's capabilities, and improving it's compliance with + PEP 305. + + Dialect parameter parsing has been re-implemented to improve error + reporting. + + quotechar=None and quoting=QUOTE_NONE now work the way PEP 305 + dictates. + + the parser now removes the escapechar prefix from escaped characters. + + Dialect classes passed to the module are no longer instantiated by + the module before being parsed (the former validation scheme required + this, but the mechanism was unreliable). + + The dialect registry now contains instances of the internal + C-coded dialect type, rather than references to python objects. + + the internal c-coded dialect type is now immutable. + + register_dialect now accepts the same keyword dialect specifications + as the reader and writer, allowing the user to register dialects + without first creating a dialect class. + + a configurable limit to the size of parsed fields has been added - + previously, an unmatched quote character could result in the entire + file being read into the field buffer before an error was reported. + + A new module method csv.set_field_limit() has been added that sets + the parser field size limit (returning the former limit). The initial + limit is 128kB. + + reader and writer objects were not being registered with the cyclic-GC. + This has been fixed. + - _DummyThread objects in the threading module now delete self.__block that is inherited from _Thread since it uses up a lock allocated by 'thread'. The lock primitives tend to be limited in number and thus should not be wasted on From andrewmcnamara at users.sourceforge.net Wed Jan 12 04:45:12 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Wed Jan 12 04:45:15 2005 Subject: [Python-checkins] python/dist/src/Lib csv.py,1.14,1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16240/Lib Modified Files: csv.py Log Message: Rename csv.set_field_limit to csv.field_size_limit (since it both sets and gets). Index: csv.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/csv.py,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- csv.py 11 Jan 2005 07:32:02 -0000 1.14 +++ csv.py 12 Jan 2005 03:45:00 -0000 1.15 @@ -6,7 +6,7 @@ import re from _csv import Error, __version__, writer, reader, register_dialect, \ unregister_dialect, get_dialect, list_dialects, \ - set_field_limit, \ + field_size_limit, \ QUOTE_MINIMAL, QUOTE_ALL, QUOTE_NONNUMERIC, QUOTE_NONE, \ __doc__ from _csv import Dialect as _Dialect From andrewmcnamara at users.sourceforge.net Wed Jan 12 04:45:13 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Wed Jan 12 04:45:16 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1219,1.1220 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16240/Misc Modified Files: NEWS Log Message: Rename csv.set_field_limit to csv.field_size_limit (since it both sets and gets). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1219 retrieving revision 1.1220 diff -u -d -r1.1219 -r1.1220 --- NEWS 12 Jan 2005 03:25:27 -0000 1.1219 +++ NEWS 12 Jan 2005 03:45:10 -0000 1.1220 @@ -57,7 +57,7 @@ + a configurable limit to the size of parsed fields has been added - previously, an unmatched quote character could result in the entire file being read into the field buffer before an error was reported. - + A new module method csv.set_field_limit() has been added that sets + + A new module method csv.field_size_limit() has been added that sets the parser field size limit (returning the former limit). The initial limit is 128kB. + reader and writer objects were not being registered with the cyclic-GC. From andrewmcnamara at users.sourceforge.net Wed Jan 12 04:45:28 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Wed Jan 12 04:45:32 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_csv.py,1.21,1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16240/Lib/test Modified Files: test_csv.py Log Message: Rename csv.set_field_limit to csv.field_size_limit (since it both sets and gets). Index: test_csv.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_csv.py,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- test_csv.py 12 Jan 2005 01:55:21 -0000 1.21 +++ test_csv.py 12 Jan 2005 03:45:09 -0000 1.22 @@ -233,21 +233,21 @@ def test_read_bigfield(self): # This exercises the buffer realloc functionality and field size # limits. - limit = csv.set_field_limit() + limit = csv.field_size_limit() try: size = 50000 bigstring = 'X' * size bigline = '%s,%s' % (bigstring, bigstring) self._read_test([bigline], [[bigstring, bigstring]]) - csv.set_field_limit(size) + csv.field_size_limit(size) self._read_test([bigline], [[bigstring, bigstring]]) - self.assertEqual(csv.set_field_limit(), size) - csv.set_field_limit(size-1) + self.assertEqual(csv.field_size_limit(), size) + csv.field_size_limit(size-1) self.assertRaises(csv.Error, self._read_test, [bigline], []) - self.assertRaises(TypeError, csv.set_field_limit, None) - self.assertRaises(TypeError, csv.set_field_limit, 1, None) + self.assertRaises(TypeError, csv.field_size_limit, None) + self.assertRaises(TypeError, csv.field_size_limit, 1, None) finally: - csv.set_field_limit(limit) + csv.field_size_limit(limit) class TestDialectRegistry(unittest.TestCase): def test_registry_badargs(self): From andrewmcnamara at users.sourceforge.net Wed Jan 12 04:45:33 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Wed Jan 12 04:45:36 2005 Subject: [Python-checkins] python/dist/src/Modules _csv.c,1.29,1.30 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16240/Modules Modified Files: _csv.c Log Message: Rename csv.set_field_limit to csv.field_size_limit (since it both sets and gets). Index: _csv.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_csv.c,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- _csv.c 12 Jan 2005 01:16:35 -0000 1.29 +++ _csv.c 12 Jan 2005 03:45:00 -0000 1.30 @@ -1408,12 +1408,12 @@ } static PyObject * -csv_set_field_limit(PyObject *module, PyObject *args) +csv_field_size_limit(PyObject *module, PyObject *args) { PyObject *new_limit = NULL; long old_limit = field_limit; - if (!PyArg_UnpackTuple(args, "set_field_limit", 0, 1, &new_limit)) + if (!PyArg_UnpackTuple(args, "field_size_limit", 0, 1, &new_limit)) return NULL; if (new_limit != NULL) { if (!PyInt_Check(new_limit)) { @@ -1533,9 +1533,9 @@ "Delete the name/dialect mapping associated with a string name.\n" " csv.unregister_dialect(name)"); -PyDoc_STRVAR(csv_set_field_limit_doc, +PyDoc_STRVAR(csv_field_size_limit_doc, "Sets an upper limit on parsed fields.\n" -" csv.set_field_limit([limit])\n" +" csv.field_size_limit([limit])\n" "\n" "Returns old limit. If limit is not given, no new limit is set and\n" "the old limit is returned"); @@ -1553,8 +1553,8 @@ METH_O, csv_unregister_dialect_doc}, { "get_dialect", (PyCFunction)csv_get_dialect, METH_O, csv_get_dialect_doc}, - { "set_field_limit", (PyCFunction)csv_set_field_limit, - METH_VARARGS, csv_set_field_limit_doc}, + { "field_size_limit", (PyCFunction)csv_field_size_limit, + METH_VARARGS, csv_field_size_limit_doc}, { NULL, NULL } }; From andrewmcnamara at users.sourceforge.net Wed Jan 12 08:44:44 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Wed Jan 12 08:44:48 2005 Subject: [Python-checkins] python/dist/src/Modules _csv.c,1.30,1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19456/Modules Modified Files: _csv.c Log Message: When using QUOTE_NONNUMERIC, we now test for "numericness" with PyNumber_Check, rather than trying to convert to a float. Reimplemented writer - now raises exceptions when it sees a quotechar but neither doublequote or escapechar are set. Doublequote results are now more consistent (eg, single quote should generate """", rather than "", which is ambiguous). Index: _csv.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_csv.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- _csv.c 12 Jan 2005 03:45:00 -0000 1.30 +++ _csv.c 12 Jan 2005 07:44:41 -0000 1.31 @@ -944,81 +944,65 @@ { DialectObj *dialect = self->dialect; int i, rec_len; + char *lineterm; + +#define ADDCH(c) \ + do {\ + if (copy_phase) \ + self->rec[rec_len] = c;\ + rec_len++;\ + } while(0) + + lineterm = PyString_AsString(dialect->lineterminator); + if (lineterm == NULL) + return -1; rec_len = self->rec_len; - /* If this is not the first field we need a field separator. - */ - if (self->num_fields > 0) { - if (copy_phase) - self->rec[rec_len] = dialect->delimiter; - rec_len++; - } - /* Handle preceding quote. - */ - switch (dialect->quoting) { - case QUOTE_ALL: - *quoted = 1; - if (copy_phase) - self->rec[rec_len] = dialect->quotechar; - rec_len++; - break; - case QUOTE_MINIMAL: - case QUOTE_NONNUMERIC: - /* We only know about quoted in the copy phase. - */ - if (copy_phase && *quoted) { - self->rec[rec_len] = dialect->quotechar; - rec_len++; - } - break; - case QUOTE_NONE: - break; - } - /* Copy/count field data. - */ + /* If this is not the first field we need a field separator */ + if (self->num_fields > 0) + ADDCH(dialect->delimiter); + + /* Handle preceding quote */ + if (copy_phase && *quoted) + ADDCH(dialect->quotechar); + + /* Copy/count field data */ for (i = 0;; i++) { char c = field[i]; + int want_escape = 0; if (c == '\0') break; - /* If in doublequote mode we escape quote chars with a - * quote. - */ - if (dialect->quoting != QUOTE_NONE && - c == dialect->quotechar && dialect->doublequote) { - if (copy_phase) - self->rec[rec_len] = dialect->quotechar; - *quoted = 1; - rec_len++; - } - /* Some special characters need to be escaped. If we have a - * quote character switch to quoted field instead of escaping - * individual characters. - */ - if (!*quoted - && (c == dialect->delimiter || - c == dialect->escapechar || - c == '\n' || c == '\r')) { - if (dialect->quoting != QUOTE_NONE) - *quoted = 1; - else if (dialect->escapechar) { - if (copy_phase) - self->rec[rec_len] = dialect->escapechar; - rec_len++; - } + if (c == dialect->delimiter || + c == dialect->escapechar || + c == dialect->quotechar || + strchr(lineterm, c)) { + if (dialect->quoting == QUOTE_NONE) + want_escape = 1; else { - PyErr_Format(error_obj, - "delimiter must be quoted or escaped"); - return -1; + if (c == dialect->quotechar) { + if (dialect->doublequote) + ADDCH(dialect->quotechar); + else + want_escape = 1; + } + if (!want_escape) + *quoted = 1; + } + if (want_escape) { + if (!dialect->escapechar) { + PyErr_Format(error_obj, + "need to escape, but no escapechar set"); + return -1; + } + ADDCH(dialect->escapechar); } } /* Copy field character into record buffer. */ - if (copy_phase) - self->rec[rec_len] = c; - rec_len++; + ADDCH(c); } /* If field is empty check if it needs to be quoted. @@ -1033,20 +1017,14 @@ *quoted = 1; } - /* Handle final quote character on field. - */ if (*quoted) { if (copy_phase) - self->rec[rec_len] = dialect->quotechar; + ADDCH(dialect->quotechar); else - /* Didn't know about leading quote until we found it - * necessary in field data - compensate for it now. - */ - rec_len++; - rec_len++; + rec_len += 2; } - return rec_len; +#undef ADDCH } static int @@ -1146,18 +1124,16 @@ if (field == NULL) return NULL; - quoted = 0; - if (dialect->quoting == QUOTE_NONNUMERIC) { - PyObject *num; - - num = PyNumber_Float(field); - if (num == NULL) { - quoted = 1; - PyErr_Clear(); - } - else { - Py_DECREF(num); - } + switch (dialect->quoting) { + case QUOTE_NONNUMERIC: + quoted = !PyNumber_Check(field); + break; + case QUOTE_ALL: + quoted = 1; + break; + default: + quoted = 0; + break; } if (PyString_Check(field)) { From andrewmcnamara at users.sourceforge.net Wed Jan 12 08:44:45 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Wed Jan 12 08:44:49 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_csv.py,1.22,1.23 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19456/Lib/test Modified Files: test_csv.py Log Message: When using QUOTE_NONNUMERIC, we now test for "numericness" with PyNumber_Check, rather than trying to convert to a float. Reimplemented writer - now raises exceptions when it sees a quotechar but neither doublequote or escapechar are set. Doublequote results are now more consistent (eg, single quote should generate """", rather than "", which is ambiguous). Index: test_csv.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_csv.py,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- test_csv.py 12 Jan 2005 03:45:09 -0000 1.22 +++ test_csv.py 12 Jan 2005 07:44:42 -0000 1.23 @@ -152,25 +152,35 @@ (bigstring, bigstring)) def test_write_quoting(self): - self._write_test(['a','1','p,q'], 'a,1,"p,q"') + self._write_test(['a',1,'p,q'], 'a,1,"p,q"') self.assertRaises(csv.Error, self._write_test, - ['a','1','p,q'], 'a,1,"p,q"', + ['a',1,'p,q'], 'a,1,p,q', quoting = csv.QUOTE_NONE) - self._write_test(['a','1','p,q'], 'a,1,"p,q"', + self._write_test(['a',1,'p,q'], 'a,1,"p,q"', quoting = csv.QUOTE_MINIMAL) - self._write_test(['a','1','p,q'], '"a",1,"p,q"', + self._write_test(['a',1,'p,q'], '"a",1,"p,q"', quoting = csv.QUOTE_NONNUMERIC) - self._write_test(['a','1','p,q'], '"a","1","p,q"', + self._write_test(['a',1,'p,q'], '"a","1","p,q"', quoting = csv.QUOTE_ALL) def test_write_escape(self): - self._write_test(['a','1','p,q'], 'a,1,"p,q"', + self._write_test(['a',1,'p,q'], 'a,1,"p,q"', escapechar='\\') -# FAILED - needs to be fixed [am]: -# self._write_test(['a','1','p,"q"'], 'a,1,"p,\\"q\\"', -# escapechar='\\', doublequote = 0) - self._write_test(['a','1','p,q'], 'a,1,p\\,q', + self.assertRaises(csv.Error, + self._write_test, + ['a',1,'p,"q"'], 'a,1,"p,\\"q\\""', + escapechar=None, doublequote=False) + self._write_test(['a',1,'p,"q"'], 'a,1,"p,\\"q\\""', + escapechar='\\', doublequote = False) + self._write_test(['"'], '""""', + escapechar='\\', quoting = csv.QUOTE_MINIMAL) + self._write_test(['"'], '\\"', + escapechar='\\', quoting = csv.QUOTE_MINIMAL, + doublequote = False) + self._write_test(['"'], '\\"', + escapechar='\\', quoting = csv.QUOTE_NONE) + self._write_test(['a',1,'p,q'], 'a,1,p\\,q', escapechar='\\', quoting = csv.QUOTE_NONE) def test_writerows(self): From andrewmcnamara at users.sourceforge.net Wed Jan 12 08:44:47 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Wed Jan 12 08:44:50 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1220,1.1221 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19456/Misc Modified Files: NEWS Log Message: When using QUOTE_NONNUMERIC, we now test for "numericness" with PyNumber_Check, rather than trying to convert to a float. Reimplemented writer - now raises exceptions when it sees a quotechar but neither doublequote or escapechar are set. Doublequote results are now more consistent (eg, single quote should generate """", rather than "", which is ambiguous). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1220 retrieving revision 1.1221 diff -u -d -r1.1220 -r1.1221 --- NEWS 12 Jan 2005 03:45:10 -0000 1.1220 +++ NEWS 12 Jan 2005 07:44:42 -0000 1.1221 @@ -45,6 +45,9 @@ + quotechar=None and quoting=QUOTE_NONE now work the way PEP 305 dictates. + the parser now removes the escapechar prefix from escaped characters. + + QUOTE_NONNUMERIC now tests for numeric objects, rather than attempting + to cast to float. + + writer doublequote handling improved. + Dialect classes passed to the module are no longer instantiated by the module before being parsed (the former validation scheme required this, but the mechanism was unreliable). From andrewmcnamara at users.sourceforge.net Wed Jan 12 09:16:21 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Wed Jan 12 09:16:24 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_csv.py,1.23,1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25379/Lib/test Modified Files: test_csv.py Log Message: Fix logic problem in quoting=csv.QUOTE_ALL, quotechar=None check, add test. Index: test_csv.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_csv.py,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- test_csv.py 12 Jan 2005 07:44:42 -0000 1.23 +++ test_csv.py 12 Jan 2005 08:16:17 -0000 1.24 @@ -32,6 +32,8 @@ self.assertRaises(TypeError, ctor, arg, quoting=None) self.assertRaises(TypeError, ctor, arg, quoting=csv.QUOTE_ALL, quotechar='') + self.assertRaises(TypeError, ctor, arg, + quoting=csv.QUOTE_ALL, quotechar=None) def test_reader_arg_valid(self): self._test_arg_valid(csv.reader, []) From andrewmcnamara at users.sourceforge.net Wed Jan 12 09:16:21 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Wed Jan 12 09:16:25 2005 Subject: [Python-checkins] python/dist/src/Modules _csv.c,1.31,1.32 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25379/Modules Modified Files: _csv.c Log Message: Fix logic problem in quoting=csv.QUOTE_ALL, quotechar=None check, add test. Index: _csv.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_csv.c,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- _csv.c 12 Jan 2005 07:44:41 -0000 1.31 +++ _csv.c 12 Jan 2005 08:16:06 -0000 1.32 @@ -401,7 +401,7 @@ PyErr_SetString(PyExc_TypeError, "delimiter must be set"); goto err; } - if (quotechar == Py_None && self->quoting != QUOTE_NONE) + if (quotechar == Py_None && quoting == NULL) self->quoting = QUOTE_NONE; if (self->quoting != QUOTE_NONE && self->quotechar == 0) { PyErr_SetString(PyExc_TypeError, From andrewmcnamara at users.sourceforge.net Wed Jan 12 10:45:20 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Wed Jan 12 10:45:25 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_csv.py,1.24,1.25 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9797/Lib/test Modified Files: test_csv.py Log Message: When quoting=QUOTE_NONNUMERIC, the reader now casts unquoted fields to floats. Index: test_csv.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_csv.py,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- test_csv.py 12 Jan 2005 08:16:17 -0000 1.24 +++ test_csv.py 12 Jan 2005 09:45:17 -0000 1.25 @@ -241,6 +241,12 @@ quotechar=None, escapechar='\\') self._read_test(['1,",3,",5'], [['1', '"', '3', '"', '5']], quoting=csv.QUOTE_NONE, escapechar='\\') + # will this fail where locale uses comma for decimals? + self._read_test([',3,"5",7.3'], [['', 3, '5', 7.3]], + quoting=csv.QUOTE_NONNUMERIC) + self.assertRaises(ValueError, self._read_test, + ['abc,3'], [[]], + quoting=csv.QUOTE_NONNUMERIC) def test_read_bigfield(self): # This exercises the buffer realloc functionality and field size From andrewmcnamara at users.sourceforge.net Wed Jan 12 10:45:37 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Wed Jan 12 10:45:41 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1221,1.1222 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9797/Misc Modified Files: NEWS Log Message: When quoting=QUOTE_NONNUMERIC, the reader now casts unquoted fields to floats. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1221 retrieving revision 1.1222 diff -u -d -r1.1221 -r1.1222 --- NEWS 12 Jan 2005 07:44:42 -0000 1.1221 +++ NEWS 12 Jan 2005 09:45:18 -0000 1.1222 @@ -45,8 +45,11 @@ + quotechar=None and quoting=QUOTE_NONE now work the way PEP 305 dictates. + the parser now removes the escapechar prefix from escaped characters. - + QUOTE_NONNUMERIC now tests for numeric objects, rather than attempting - to cast to float. + + when quoting=QUOTE_NONNUMERIC, the writer now tests for numeric + objects, rather than attempting to cast to float, and using the + success of that as the determinator. + + when quoting=QUOTE_NONNUMERIC, the reader now casts unquoted fields + to floats. + writer doublequote handling improved. + Dialect classes passed to the module are no longer instantiated by the module before being parsed (the former validation scheme required From andrewmcnamara at users.sourceforge.net Wed Jan 12 10:45:50 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Wed Jan 12 10:45:54 2005 Subject: [Python-checkins] python/dist/src/Modules _csv.c,1.32,1.33 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9797/Modules Modified Files: _csv.c Log Message: When quoting=QUOTE_NONNUMERIC, the reader now casts unquoted fields to floats. Index: _csv.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_csv.c,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- _csv.c 12 Jan 2005 08:16:06 -0000 1.32 +++ _csv.c 12 Jan 2005 09:45:16 -0000 1.33 @@ -97,6 +97,7 @@ int field_size; /* size of allocated buffer */ int field_len; /* length of current field */ int had_parse_error; /* did we have a parse error? */ + int numeric_field; /* treat field as numeric */ } ReaderObj; staticforward PyTypeObject Reader_Type; @@ -495,17 +496,30 @@ return dialect; } -static void +static int parse_save_field(ReaderObj *self) { PyObject *field; field = PyString_FromStringAndSize(self->field, self->field_len); - if (field != NULL) { - PyList_Append(self->fields, field); - Py_XDECREF(field); - } + if (field == NULL) + return -1; self->field_len = 0; + if (self->numeric_field) { + PyObject *tmp; + + self->numeric_field = 0; + tmp = PyNumber_Float(field); + if (tmp == NULL) { + Py_DECREF(field); + return -1; + } + Py_DECREF(field); + field = tmp; + } + PyList_Append(self->fields, field); + Py_DECREF(field); + return 0; } static int @@ -529,6 +543,22 @@ } static int +parse_reset(ReaderObj *self) +{ + if (self->fields) { + Py_DECREF(self->fields); + } + self->fields = PyList_New(0); + if (self->fields == NULL) + return -1; + self->field_len = 0; + self->state = START_RECORD; + self->had_parse_error = 0; + self->numeric_field = 0; + return 0; +} + +static int parse_add_char(ReaderObj *self, char c) { if (self->field_len >= field_limit) { @@ -560,7 +590,8 @@ /* expecting field */ if (c == '\n') { /* save empty field - return [fields] */ - parse_save_field(self); + if (parse_save_field(self) < 0) + return -1; self->state = START_RECORD; } else if (c == dialect->quotechar && @@ -577,10 +608,13 @@ ; else if (c == dialect->delimiter) { /* save empty field */ - parse_save_field(self); + if (parse_save_field(self) < 0) + return -1; } else { /* begin new unquoted field */ + if (dialect->quoting == QUOTE_NONNUMERIC) + self->numeric_field = 1; if (parse_add_char(self, c) < 0) return -1; self->state = IN_FIELD; @@ -597,7 +631,8 @@ /* in unquoted field */ if (c == '\n') { /* end of line - return [fields] */ - parse_save_field(self); + if (parse_save_field(self) < 0) + return -1; self->state = START_RECORD; } else if (c == dialect->escapechar) { @@ -606,7 +641,8 @@ } else if (c == dialect->delimiter) { /* save field - wait for new field */ - parse_save_field(self); + if (parse_save_field(self) < 0) + return -1; self->state = START_FIELD; } else { @@ -662,12 +698,14 @@ } else if (c == dialect->delimiter) { /* save field - wait for new field */ - parse_save_field(self); + if (parse_save_field(self) < 0) + return -1; self->state = START_FIELD; } else if (c == '\n') { /* end of line - return [fields] */ - parse_save_field(self); + if (parse_save_field(self) < 0) + return -1; self->state = START_RECORD; } else if (!dialect->strict) { @@ -716,15 +754,11 @@ return NULL; } - if (self->had_parse_error) { - if (self->fields) { - Py_XDECREF(self->fields); - } - self->fields = PyList_New(0); - self->field_len = 0; - self->state = START_RECORD; - self->had_parse_error = 0; - } + if (self->had_parse_error) + if (parse_reset(self) < 0) { + Py_DECREF(lineobj); + return NULL; + } line = PyString_AsString(lineobj); if (line == NULL) { @@ -886,15 +920,15 @@ return NULL; self->dialect = NULL; - self->input_iter = self->fields = NULL; - self->fields = NULL; self->input_iter = NULL; - self->had_parse_error = 0; self->field = NULL; self->field_size = 0; - self->field_len = 0; - self->state = START_RECORD; + + if (parse_reset(self) < 0) { + Py_DECREF(self); + return NULL; + } if (!PyArg_UnpackTuple(args, "", 1, 2, &iterator, &dialect)) { Py_DECREF(self); @@ -912,11 +946,6 @@ Py_DECREF(self); return NULL; } - self->fields = PyList_New(0); - if (self->fields == NULL) { - Py_DECREF(self); - return NULL; - } PyObject_GC_Track(self); return (PyObject *)self; From andrewmcnamara at users.sourceforge.net Wed Jan 12 12:17:23 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Wed Jan 12 12:17:28 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1222,1.1223 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27851/Misc Modified Files: NEWS Log Message: Add counting of source iterator lines to the reader object - handy for user error messages (otherwise difficult to do without instrumenting the source). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1222 retrieving revision 1.1223 diff -u -d -r1.1222 -r1.1223 --- NEWS 12 Jan 2005 09:45:18 -0000 1.1222 +++ NEWS 12 Jan 2005 11:17:16 -0000 1.1223 @@ -66,6 +66,10 @@ + A new module method csv.field_size_limit() has been added that sets the parser field size limit (returning the former limit). The initial limit is 128kB. + + A line_num attribute has been added to the reader object, which tracks + the number of lines read from the source iterator. This is not + the same as the number of records returned, as records can span + multiple lines. + reader and writer objects were not being registered with the cyclic-GC. This has been fixed. From andrewmcnamara at users.sourceforge.net Wed Jan 12 12:17:48 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Wed Jan 12 12:17:52 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_csv.py,1.25,1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27851/Lib/test Modified Files: test_csv.py Log Message: Add counting of source iterator lines to the reader object - handy for user error messages (otherwise difficult to do without instrumenting the source). Index: test_csv.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_csv.py,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- test_csv.py 12 Jan 2005 09:45:17 -0000 1.25 +++ test_csv.py 12 Jan 2005 11:17:15 -0000 1.26 @@ -242,7 +242,7 @@ self._read_test(['1,",3,",5'], [['1', '"', '3', '"', '5']], quoting=csv.QUOTE_NONE, escapechar='\\') # will this fail where locale uses comma for decimals? - self._read_test([',3,"5",7.3'], [['', 3, '5', 7.3]], + self._read_test([',3,"5",7.3, 9'], [['', 3, '5', 7.3, 9]], quoting=csv.QUOTE_NONNUMERIC) self.assertRaises(ValueError, self._read_test, ['abc,3'], [[]], @@ -267,6 +267,18 @@ finally: csv.field_size_limit(limit) + def test_read_linenum(self): + r = csv.reader(['line,1', 'line,2', 'line,3']) + self.assertEqual(r.line_num, 0) + r.next() + self.assertEqual(r.line_num, 1) + r.next() + self.assertEqual(r.line_num, 2) + r.next() + self.assertEqual(r.line_num, 3) + self.assertRaises(StopIteration, r.next) + self.assertEqual(r.line_num, 3) + class TestDialectRegistry(unittest.TestCase): def test_registry_badargs(self): self.assertRaises(TypeError, csv.list_dialects, None) From andrewmcnamara at users.sourceforge.net Wed Jan 12 12:17:48 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Wed Jan 12 12:17:54 2005 Subject: [Python-checkins] python/dist/src/Modules _csv.c,1.33,1.34 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27851/Modules Modified Files: _csv.c Log Message: Add counting of source iterator lines to the reader object - handy for user error messages (otherwise difficult to do without instrumenting the source). Index: _csv.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_csv.c,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- _csv.c 12 Jan 2005 09:45:16 -0000 1.33 +++ _csv.c 12 Jan 2005 11:17:14 -0000 1.34 @@ -98,6 +98,7 @@ int field_len; /* length of current field */ int had_parse_error; /* did we have a parse error? */ int numeric_field; /* treat field as numeric */ + unsigned long line_num; /* Source-file line number */ } ReaderObj; staticforward PyTypeObject Reader_Type; @@ -734,6 +735,7 @@ static struct PyMemberDef Reader_memberlist[] = { { "dialect", T_OBJECT, R_OFF(dialect), RO }, + { "line_num", T_ULONG, R_OFF(line_num), RO }, { NULL } }; @@ -753,6 +755,7 @@ "newline inside string"); return NULL; } + ++self->line_num; if (self->had_parse_error) if (parse_reset(self) < 0) { @@ -924,6 +927,7 @@ self->input_iter = NULL; self->field = NULL; self->field_size = 0; + self->line_num = 0; if (parse_reset(self) < 0) { Py_DECREF(self); From andrewmcnamara at users.sourceforge.net Wed Jan 12 12:39:54 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Wed Jan 12 12:39:56 2005 Subject: [Python-checkins] python/dist/src/Modules _csv.c,1.34,1.35 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32713/Modules Modified Files: _csv.c Log Message: Improve wording of parser error message. Index: _csv.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_csv.c,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- _csv.c 12 Jan 2005 11:17:14 -0000 1.34 +++ _csv.c 12 Jan 2005 11:39:50 -0000 1.35 @@ -717,7 +717,7 @@ else { /* illegal */ self->had_parse_error = 1; - PyErr_Format(error_obj, "%c expected after %c", + PyErr_Format(error_obj, "'%c' expected after '%c'", dialect->delimiter, dialect->quotechar); return -1; @@ -1354,7 +1354,7 @@ self->writeline = PyObject_GetAttrString(output_file, "write"); if (self->writeline == NULL || !PyCallable_Check(self->writeline)) { PyErr_SetString(PyExc_TypeError, - "argument 1 must be an instance with a write method"); + "argument 1 must have a \"write\" method"); Py_DECREF(self); return NULL; } From andrewmcnamara at users.sourceforge.net Wed Jan 12 12:48:01 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Wed Jan 12 12:48:05 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libcsv.tex,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1801/Doc/lib Modified Files: libcsv.tex Log Message: Many updates to csv module doco. Index: libcsv.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcsv.tex,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- libcsv.tex 5 Jan 2005 06:58:15 -0000 1.17 +++ libcsv.tex 12 Jan 2005 11:47:57 -0000 1.18 @@ -50,11 +50,12 @@ The \module{csv} module defines the following functions: \begin{funcdesc}{reader}{csvfile\optional{, - dialect=\code{'excel'}\optional{, fmtparam}}} + dialect=\code{'excel'}}\optional{, fmtparam}} Return a reader object which will iterate over lines in the given {}\var{csvfile}. \var{csvfile} can be any object which supports the iterator protocol and returns a string each time its \method{next} -method is called. If \var{csvfile} is a file object, it must be opened with +method is called - file objects and list objects are both suitable. +If \var{csvfile} is a file object, it must be opened with the 'b' flag on platforms where that makes a difference. An optional {}\var{dialect} parameter can be given which is used to define a set of parameters specific to a particular CSV @@ -71,7 +72,7 @@ \end{funcdesc} \begin{funcdesc}{writer}{csvfile\optional{, - dialect=\code{'excel'}\optional{, fmtparam}}} + dialect=\code{'excel'}}\optional{, fmtparam}} Return a writer object responsible for converting the user's data into delimited strings on the given file-like object. \var{csvfile} can be any object with a \function{write} method. If \var{csvfile} is a file object, @@ -94,9 +95,14 @@ with \function{str()} before being written. \end{funcdesc} -\begin{funcdesc}{register_dialect}{name, dialect} -Associate \var{dialect} with \var{name}. \var{dialect} must be a subclass -of \class{csv.Dialect}. \var{name} must be a string or Unicode object. +\begin{funcdesc}{register_dialect}{name\optional{, dialect}\optional{, fmtparam}} +Associate \var{dialect} with \var{name}. \var{name} must be a string +or Unicode object. The dialect can be specified either by passing a +sub-class of \class{Dialect}, or by \var{fmtparam} keyword arguments, +or both, with keyword arguments overriding parameters of the dialect. +For more information about the dialect and formatting parameters, see +section~\ref{csv-fmt-params}, ``Dialects and Formatting Parameters'' +for details of these parameters. \end{funcdesc} \begin{funcdesc}{unregister_dialect}{name} @@ -114,6 +120,12 @@ Return the names of all registered dialects. \end{funcdesc} +\begin{funcdesc}{field_size_limit}{\optional{new_limit}} + Returns the current maximum field size allowed by the parser. If + \var{new_limit} is given, this becomes the new limit. + \versionadded{2.5} +\end{funcdesc} + The \module{csv} module defines the following classes: @@ -208,19 +220,25 @@ \begin{datadesc}{QUOTE_MINIMAL} Instructs \class{writer} objects to only quote those fields which contain -the current \var{delimiter} or begin with the current \var{quotechar}. +special characters such as \var{delimiter}, \var{quotechar} or any of the +characters in \var{lineterminator}. \end{datadesc} \begin{datadesc}{QUOTE_NONNUMERIC} -Instructs \class{writer} objects to quote all non-numeric fields. +Instructs \class{writer} objects to quote all non-numeric +fields. + +Instructs the reader to convert all non-quoted fields to type \var{float}. \end{datadesc} \begin{datadesc}{QUOTE_NONE} Instructs \class{writer} objects to never quote fields. When the current \var{delimiter} occurs in output data it is preceded by the current -\var{escapechar} character. When \constant{QUOTE_NONE} is in effect, it -is an error not to have a single-character \var{escapechar} defined, even if -no data to be written contains the \var{delimiter} character. +\var{escapechar} character. If \var{escapechar} is not set, the writer +will raise \exception{Error} if any characters that require escaping +are encountered. + +Instructs \class{reader} to perform no special processing of quote characters. \end{datadesc} @@ -250,32 +268,43 @@ \end{memberdesc} \begin{memberdesc}[Dialect]{doublequote} -Controls how instances of \var{quotechar} appearing inside a field should be -themselves be quoted. When \constant{True}, the character is doubled. -When \constant{False}, the \var{escapechar} must be a one-character string -which is used as a prefix to the \var{quotechar}. It defaults to -\constant{True}. +Controls how instances of \var{quotechar} appearing inside a field should +be themselves be quoted. When \constant{True}, the character is doubled. +When \constant{False}, the \var{escapechar} is used as a prefix to the +\var{quotechar}. It defaults to \constant{True}. + +On output, if \var{doublequote} is \constant{False} and no +\var{escapechar} is set, \exception{Error} is raised if a \var{quotechar} +is found in a field. \end{memberdesc} \begin{memberdesc}[Dialect]{escapechar} -A one-character string used to escape the \var{delimiter} if \var{quoting} -is set to \constant{QUOTE_NONE}. It defaults to \constant{None}. +A one-character string used by the writer to escape the \var{delimiter} if +\var{quoting} is set to \constant{QUOTE_NONE} and the \var{quotechar} +if \var{doublequote} is \constant{False}. On reading, the \var{escapechar} +removes any special meaning from the following character. It defaults +to \constant{None}, which disables escaping. \end{memberdesc} \begin{memberdesc}[Dialect]{lineterminator} -The string used to terminate lines in the CSV file. It defaults to -\code{'\e r\e n'}. +The string used to terminate lines produced by the \class{writer}. +It defaults to \code{'\e r\e n'}. + +\note{The \class{reader} is hard-coded to recognise either \code{'\e r'} +or \code{'\e n'} as end-of-line, and ignores \var{lineterminator}. This +behavior may change in the future.} \end{memberdesc} \begin{memberdesc}[Dialect]{quotechar} -A one-character string used to quote elements containing the \var{delimiter} -or which start with the \var{quotechar}. It defaults to \code{'"'}. +A one-character string used to quote fields containing special characters, +such as the \var{delimiter} or \var{quotechar}, or which contain new-line +characters. It defaults to \code{'"'}. \end{memberdesc} \begin{memberdesc}[Dialect]{quoting} -Controls when quotes should be generated by the writer. It can take on any -of the \constant{QUOTE_*} constants (see section~\ref{csv-contents}) -and defaults to \constant{QUOTE_MINIMAL}. +Controls when quotes should be generated by the writer and recognised +by the reader. It can take on any of the \constant{QUOTE_*} constants +(see section~\ref{csv-contents}) and defaults to \constant{QUOTE_MINIMAL}. \end{memberdesc} \begin{memberdesc}[Dialect]{skipinitialspace} @@ -294,6 +323,17 @@ according to the current dialect. \end{methoddesc} +Reader objects have the following public attributes: + +\begin{memberdesc}[csv reader]{dialect} +A read-only description of the dialect in use by the parser. +\end{memberdesc} + +\begin{memberdesc}[csv reader]{line_num} + The number of lines read from the source iterator. This is not the same + as the number of records returned, as records can span multiple lines. +\end{memberdesc} + \subsection{Writer Objects} @@ -317,10 +357,17 @@ according to the current dialect. \end{methoddesc} +Writer objects have the following public attribute: + +\begin{memberdesc}[csv writer]{dialect} +A read-only description of the dialect in use by the writer. +\end{memberdesc} + + \subsection{Examples} -The ``Hello, world'' of csv reading is +The simplest example of reading a CSV file: \begin{verbatim} import csv @@ -329,20 +376,51 @@ print row \end{verbatim} -To print just the first and last columns of each row try +Reading a file with an alternate format: \begin{verbatim} import csv -reader = csv.reader(open("some.csv", "rb")) +reader = csv.reader(open("passwd", "rb"), delimiter=':', quoting=csv.QUOTE_NONE) for row in reader: - print row[0], row[-1] + print row \end{verbatim} -The corresponding simplest possible writing example is +The corresponding simplest possible writing example is: \begin{verbatim} import csv writer = csv.writer(open("some.csv", "wb")) -for row in someiterable: - writer.writerow(row) +writer.writerows(someiterable) +\end{verbatim} + +Registering a new dialect: + +\begin{verbatim} +import csv + +csv.register_dialect('unixpwd', delimiter=':', quoting=csv.QUOTE_NONE) + +reader = csv.reader(open("passwd", "rb"), 'unixpwd') \end{verbatim} + +A slightly more advanced use of the reader - catching and reporting errors: + +\begin{verbatim} +import csv, sys +filename = "some.csv" +reader = csv.reader(open(filename, "rb")) +try: + for row in reader: + print row +except csv.Error, e: + sys.exit('file %s, line %d: %s' % (filename, reader.line_num, e)) +\end{verbatim} + +And while the module doesn't directly support parsing strings, it can +easily be done: + +\begin{verbatim} +import csv +print csv.reader(['one,two,three'])[0] +\end{verbatim} + From fdrake at users.sourceforge.net Wed Jan 12 17:01:13 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jan 12 17:01:21 2005 Subject: [Python-checkins] python/dist/src/Python marshal.c,1.81,1.82 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26603 Modified Files: marshal.c Log Message: remove unused variable Index: marshal.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/marshal.c,v retrieving revision 1.81 retrieving revision 1.82 diff -u -d -r1.81 -r1.82 --- marshal.c 11 Jan 2005 03:03:27 -0000 1.81 +++ marshal.c 12 Jan 2005 16:00:55 -0000 1.82 @@ -261,7 +261,6 @@ w_object((PyObject *)NULL, p); } else if (PyAnySet_Check(v)) { - int pos; PyObject *value, *it; if (PyObject_TypeCheck(v, &PySet_Type)) From fdrake at users.sourceforge.net Wed Jan 12 20:11:52 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jan 12 20:11:57 2005 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex,1.267,1.268 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4495/tut Modified Files: tut.tex Log Message: fix typo Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.267 retrieving revision 1.268 diff -u -d -r1.267 -r1.268 --- tut.tex 9 Jan 2005 00:12:48 -0000 1.267 +++ tut.tex 12 Jan 2005 19:11:45 -0000 1.268 @@ -4781,7 +4781,7 @@ Despite the modules names, no direct knowledge or handling of XML is needed. \item The \ulink{\module{email}}{../lib/module-email.html} package is a library for managing email messages, including MIME and other RFC 2822-based message - documents. Unlike \module{smptlib} and \module{poplib} which actually send + documents. Unlike \module{smtplib} and \module{poplib} which actually send and receive messages, the email package has a complete toolset for building or decoding complex message structures (including attachments) and for implementing internet encoding and header protocols. From fdrake at users.sourceforge.net Wed Jan 12 20:14:59 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jan 12 20:15:02 2005 Subject: [Python-checkins] python/dist/src/Doc/tut tut.tex, 1.261.2.2, 1.261.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tut In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5343/tut Modified Files: Tag: release24-maint tut.tex Log Message: fix typo Index: tut.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v retrieving revision 1.261.2.2 retrieving revision 1.261.2.3 diff -u -d -r1.261.2.2 -r1.261.2.3 --- tut.tex 1 Jan 2005 00:34:56 -0000 1.261.2.2 +++ tut.tex 12 Jan 2005 19:14:55 -0000 1.261.2.3 @@ -4781,7 +4781,7 @@ Despite the names, no direct knowledge or handling of XML is needed. \item The \ulink{\module{email}}{../lib/module-email.html} package is a library for managing email messages, including MIME and other RFC 2822-based message - documents. Unlike \module{smptlib} and \module{poplib} which actually send + documents. Unlike \module{smtplib} and \module{poplib} which actually send and receive messages, the email package has a complete toolset for building or decoding complex message structures (including attachments) and for implementing internet encoding and header protocols. From montanaro at users.sourceforge.net Thu Jan 13 05:12:33 2005 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Thu Jan 13 05:12:36 2005 Subject: [Python-checkins] python/dist/src/Misc ACKS, 1.291, 1.292 NEWS, 1.1223, 1.1224 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27707/Misc Modified Files: ACKS NEWS Log Message: Add strptime() constructor to datetime class. Thanks to Josh Spoerri for the changes. Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/ACKS,v retrieving revision 1.291 retrieving revision 1.292 diff -u -d -r1.291 -r1.292 --- ACKS 3 Dec 2004 08:33:32 -0000 1.291 +++ ACKS 13 Jan 2005 04:12:27 -0000 1.292 @@ -548,6 +548,7 @@ Paul Sokolovsky Clay Spence Per Spilling +Joshua Spoerri Noah Spurrier Oliver Steele Greg Stein Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1223 retrieving revision 1.1224 diff -u -d -r1.1223 -r1.1224 --- NEWS 12 Jan 2005 11:17:16 -0000 1.1223 +++ NEWS 13 Jan 2005 04:12:28 -0000 1.1224 @@ -31,6 +31,8 @@ This allows islice() to work more readily with slices: islice(s.start, s.stop, s.step) +- datetime.datetime() now has a strptime class method which can be used to + create datetime object using a string and format. Library ------- From montanaro at users.sourceforge.net Thu Jan 13 05:12:36 2005 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Thu Jan 13 05:12:39 2005 Subject: [Python-checkins] python/dist/src/Modules datetimemodule.c, 1.76, 1.77 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27707/Modules Modified Files: datetimemodule.c Log Message: Add strptime() constructor to datetime class. Thanks to Josh Spoerri for the changes. Index: datetimemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/datetimemodule.c,v retrieving revision 1.76 retrieving revision 1.77 diff -u -d -r1.76 -r1.77 --- datetimemodule.c 19 Dec 2004 20:13:24 -0000 1.76 +++ datetimemodule.c 13 Jan 2005 04:12:31 -0000 1.77 @@ -3798,6 +3798,46 @@ return result; } +/* Return new datetime from time.strptime(). */ +static PyObject * +datetime_strptime(PyObject *cls, PyObject *args) +{ + PyObject *result = NULL, *obj, *module; + const char *string, *format; + + if (!PyArg_ParseTuple(args, "ss:strptime", &string, &format)) + return NULL; + + if ((module = PyImport_ImportModule("time")) == NULL) + return NULL; + obj = PyObject_CallMethod(module, "strptime", "ss", string, format); + Py_DECREF(module); + + if (obj != NULL) { + int i, good_timetuple = 1; + long int ia[6]; + if (PySequence_Check(obj) && PySequence_Size(obj) >= 6) + for (i=0; i < 6; i++) { + PyObject *p = PySequence_GetItem(obj, i); + if (PyInt_Check(p)) + ia[i] = PyInt_AsLong(p); + else + good_timetuple = 0; + Py_DECREF(p); + } + else + good_timetuple = 0; + if (good_timetuple) + result = PyObject_CallFunction(cls, "iiiiii", + ia[0], ia[1], ia[2], ia[3], ia[4], ia[5]); + else + PyErr_SetString(PyExc_ValueError, + "unexpected value from time.strptime"); + Py_DECREF(obj); + } + return result; +} + /* Return new datetime from date/datetime and time arguments. */ static PyObject * datetime_combine(PyObject *cls, PyObject *args, PyObject *kw) @@ -4419,6 +4459,11 @@ PyDoc_STR("timestamp -> UTC datetime from a POSIX timestamp " "(like time.time()).")}, + {"strptime", (PyCFunction)datetime_strptime, + METH_VARARGS | METH_CLASS, + PyDoc_STR("string, format -> new datetime parsed from a string " + "(like time.strptime()).")}, + {"combine", (PyCFunction)datetime_combine, METH_VARARGS | METH_KEYWORDS | METH_CLASS, PyDoc_STR("date, time -> datetime with same date and time fields")}, From montanaro at users.sourceforge.net Thu Jan 13 05:12:59 2005 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Thu Jan 13 05:13:02 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libdatetime.tex, 1.53, 1.54 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27707/Doc/Lib Modified Files: libdatetime.tex Log Message: Add strptime() constructor to datetime class. Thanks to Josh Spoerri for the changes. Index: libdatetime.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdatetime.tex,v retrieving revision 1.53 retrieving revision 1.54 diff -u -d -r1.53 -r1.54 --- libdatetime.tex 15 Nov 2004 03:50:16 -0000 1.53 +++ libdatetime.tex 13 Jan 2005 04:12:26 -0000 1.54 @@ -624,6 +624,15 @@ ignored. \end{methoddesc} +\begin{methoddesc}{strptime}{date_string, format} + Return a \class{datetime} corresponding to \var{date_string}, parsed + according to \var{format}. This is equivalent to + \code{datetime(*(time.strptime(date_string, + format)[0:6]))}. \exception{ValueError} is raised if the date_string and + format can't be parsed by \function{time.strptime()} or if it returns a + value which isn't a time tuple. +\end{methoddesc} + Class attributes: \begin{memberdesc}{min} From montanaro at users.sourceforge.net Thu Jan 13 05:13:00 2005 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Thu Jan 13 05:13:03 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_datetime.py, 1.49, 1.50 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27707/Lib/test Modified Files: test_datetime.py Log Message: Add strptime() constructor to datetime class. Thanks to Josh Spoerri for the changes. Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_datetime.py,v retrieving revision 1.49 retrieving revision 1.50 diff -u -d -r1.49 -r1.50 --- test_datetime.py 16 Sep 2004 01:30:47 -0000 1.49 +++ test_datetime.py 13 Jan 2005 04:12:27 -0000 1.50 @@ -1421,6 +1421,15 @@ # Else try again a few times. self.failUnless(abs(from_timestamp - from_now) <= tolerance) + def test_strptime(self): + import time + + string = '2004-12-01 13:02:47' + format = '%Y-%m-%d %H:%M:%S' + expected = self.theclass(*(time.strptime(string, format)[0:6])) + got = self.theclass.strptime(string, format) + self.assertEqual(expected, got) + def test_more_timetuple(self): # This tests fields beyond those tested by the TestDate.test_timetuple. t = self.theclass(2004, 12, 31, 6, 22, 33) From vsajip at users.sourceforge.net Thu Jan 13 09:23:59 2005 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Thu Jan 13 09:24:02 2005 Subject: [Python-checkins] python/dist/src/Lib/logging handlers.py, 1.19, 1.20 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/logging In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4147 Modified Files: handlers.py Log Message: Improved SysLogHandler error recovery (patch by Erik Forsberg) Index: handlers.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/logging/handlers.py,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- handlers.py 3 Oct 2004 19:12:07 -0000 1.19 +++ handlers.py 13 Jan 2005 08:23:56 -0000 1.20 @@ -555,14 +555,7 @@ self.address = address self.facility = facility if type(address) == types.StringType: - self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) - # syslog may require either DGRAM or STREAM sockets - try: - self.socket.connect(address) - except socket.error: - self.socket.close() - self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) - self.socket.connect(address) + self._connect_unixsocket(address) self.unixsocket = 1 else: self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) @@ -570,6 +563,16 @@ self.formatter = None + def _connect_unixsocket(self, address): + self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) + # syslog may require either DGRAM or STREAM sockets + try: + self.socket.connect(address) + except socket.error: + self.socket.close() + self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + self.socket.connect(address) + # curious: when talking to the unix-domain '/dev/log' socket, a # zero-terminator seems to be required. this string is placed # into a class variable so that it can be overridden if @@ -615,7 +618,11 @@ msg) try: if self.unixsocket: - self.socket.send(msg) + try: + self.socket.send(msg) + except socket.error: + self._connect_unixsocket(self.address) + self.socket.send(msg) else: self.socket.sendto(msg, self.address) except: From andrewmcnamara at users.sourceforge.net Thu Jan 13 12:31:02 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Thu Jan 13 12:31:05 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1224,1.1225 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5733/Misc Modified Files: NEWS Log Message: Moved reader \r and \n processing from the iterator to the state machine - this allows for better handling of newline characters in quoted fields (and hopefully resolves Bug 967934). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1224 retrieving revision 1.1225 diff -u -d -r1.1224 -r1.1225 --- NEWS 13 Jan 2005 04:12:28 -0000 1.1224 +++ NEWS 13 Jan 2005 11:30:54 -0000 1.1225 @@ -48,10 +48,11 @@ dictates. + the parser now removes the escapechar prefix from escaped characters. + when quoting=QUOTE_NONNUMERIC, the writer now tests for numeric - objects, rather than attempting to cast to float, and using the - success of that as the determinator. + types, rather than any object than can be represented as a numeric. + when quoting=QUOTE_NONNUMERIC, the reader now casts unquoted fields to floats. + + reader now allows \r characters to be quoted (previously it only allowed + \n to be quoted). + writer doublequote handling improved. + Dialect classes passed to the module are no longer instantiated by the module before being parsed (the former validation scheme required From andrewmcnamara at users.sourceforge.net Thu Jan 13 12:31:27 2005 From: andrewmcnamara at users.sourceforge.net (andrewmcnamara@users.sourceforge.net) Date: Thu Jan 13 12:31:31 2005 Subject: [Python-checkins] python/dist/src/Modules _csv.c,1.35,1.36 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5733/Modules Modified Files: _csv.c Log Message: Moved reader \r and \n processing from the iterator to the state machine - this allows for better handling of newline characters in quoted fields (and hopefully resolves Bug 967934). Index: _csv.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_csv.c,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- _csv.c 12 Jan 2005 11:39:50 -0000 1.35 +++ _csv.c 13 Jan 2005 11:30:53 -0000 1.36 @@ -48,7 +48,8 @@ typedef enum { START_RECORD, START_FIELD, ESCAPED_CHAR, IN_FIELD, - IN_QUOTED_FIELD, ESCAPE_IN_QUOTED_FIELD, QUOTE_IN_QUOTED_FIELD + IN_QUOTED_FIELD, ESCAPE_IN_QUOTED_FIELD, QUOTE_IN_QUOTED_FIELD, + EAT_CRNL } ParserState; typedef enum { @@ -96,7 +97,6 @@ char *field; /* build current field in here */ int field_size; /* size of allocated buffer */ int field_len; /* length of current field */ - int had_parse_error; /* did we have a parse error? */ int numeric_field; /* treat field as numeric */ unsigned long line_num; /* Source-file line number */ } ReaderObj; @@ -497,6 +497,9 @@ return dialect; } +/* + * READER + */ static int parse_save_field(ReaderObj *self) { @@ -544,22 +547,6 @@ } static int -parse_reset(ReaderObj *self) -{ - if (self->fields) { - Py_DECREF(self->fields); - } - self->fields = PyList_New(0); - if (self->fields == NULL) - return -1; - self->field_len = 0; - self->state = START_RECORD; - self->had_parse_error = 0; - self->numeric_field = 0; - return 0; -} - -static int parse_add_char(ReaderObj *self, char c) { if (self->field_len >= field_limit) { @@ -581,19 +568,23 @@ switch (self->state) { case START_RECORD: /* start of record */ - if (c == '\n') + if (c == '\0') /* empty line - return [] */ break; + else if (c == '\n' || c == '\r') { + self->state = EAT_CRNL; + break; + } /* normal character - handle as START_FIELD */ self->state = START_FIELD; /* fallthru */ case START_FIELD: /* expecting field */ - if (c == '\n') { + if (c == '\n' || c == '\r' || c == '\0') { /* save empty field - return [fields] */ if (parse_save_field(self) < 0) return -1; - self->state = START_RECORD; + self->state = (c == '\0' ? START_RECORD : EAT_CRNL); } else if (c == dialect->quotechar && dialect->quoting != QUOTE_NONE) { @@ -623,6 +614,8 @@ break; case ESCAPED_CHAR: + if (c == '\0') + c = '\n'; if (parse_add_char(self, c) < 0) return -1; self->state = IN_FIELD; @@ -630,11 +623,11 @@ case IN_FIELD: /* in unquoted field */ - if (c == '\n') { + if (c == '\n' || c == '\r' || c == '\0') { /* end of line - return [fields] */ if (parse_save_field(self) < 0) return -1; - self->state = START_RECORD; + self->state = (c == '\0' ? START_RECORD : EAT_CRNL); } else if (c == dialect->escapechar) { /* possible escaped character */ @@ -655,11 +648,8 @@ case IN_QUOTED_FIELD: /* in quoted field */ - if (c == '\n') { - /* end of line - save '\n' in field */ - if (parse_add_char(self, '\n') < 0) - return -1; - } + if (c == '\0') + ; else if (c == dialect->escapechar) { /* Possible escape character */ self->state = ESCAPE_IN_QUOTED_FIELD; @@ -683,6 +673,8 @@ break; case ESCAPE_IN_QUOTED_FIELD: + if (c == '\0') + c = '\n'; if (parse_add_char(self, c) < 0) return -1; self->state = IN_QUOTED_FIELD; @@ -703,11 +695,11 @@ return -1; self->state = START_FIELD; } - else if (c == '\n') { + else if (c == '\n' || c == '\r' || c == '\0') { /* end of line - return [fields] */ if (parse_save_field(self) < 0) return -1; - self->state = START_RECORD; + self->state = (c == '\0' ? START_RECORD : EAT_CRNL); } else if (!dialect->strict) { if (parse_add_char(self, c) < 0) @@ -716,7 +708,6 @@ } else { /* illegal */ - self->had_parse_error = 1; PyErr_Format(error_obj, "'%c' expected after '%c'", dialect->delimiter, dialect->quotechar); @@ -724,104 +715,83 @@ } break; + case EAT_CRNL: + if (c == '\n' || c == '\r') + ; + else if (c == '\0') + self->state = START_RECORD; + else { + PyErr_Format(error_obj, "new-line character seen in unquoted field - do you need to open the file in universal-newline mode?"); + return -1; + } + break; + } return 0; } -/* - * READER - */ -#define R_OFF(x) offsetof(ReaderObj, x) - -static struct PyMemberDef Reader_memberlist[] = { - { "dialect", T_OBJECT, R_OFF(dialect), RO }, - { "line_num", T_ULONG, R_OFF(line_num), RO }, - { NULL } -}; +static int +parse_reset(ReaderObj *self) +{ + Py_XDECREF(self->fields); + self->fields = PyList_New(0); + if (self->fields == NULL) + return -1; + self->field_len = 0; + self->state = START_RECORD; + self->numeric_field = 0; + return 0; +} static PyObject * Reader_iternext(ReaderObj *self) { PyObject *lineobj; - PyObject *fields; - char *line; + PyObject *fields = NULL; + char *line, c; + int linelen; + if (parse_reset(self) < 0) + return NULL; do { lineobj = PyIter_Next(self->input_iter); if (lineobj == NULL) { /* End of input OR exception */ if (!PyErr_Occurred() && self->field_len != 0) - return PyErr_Format(error_obj, - "newline inside string"); + PyErr_Format(error_obj, + "newline inside string"); return NULL; } ++self->line_num; - if (self->had_parse_error) - if (parse_reset(self) < 0) { - Py_DECREF(lineobj); - return NULL; - } line = PyString_AsString(lineobj); + linelen = PyString_Size(lineobj); - if (line == NULL) { + if (line == NULL || linelen < 0) { Py_DECREF(lineobj); return NULL; } - if (strlen(line) < (size_t)PyString_GET_SIZE(lineobj)) { - self->had_parse_error = 1; - Py_DECREF(lineobj); - return PyErr_Format(error_obj, - "string with NUL bytes"); - } - - /* Process line of text - send '\n' to processing code to - represent end of line. End of line which is not at end of - string is an error. */ - while (*line) { - char c; - - c = *line++; - if (c == '\r') { - c = *line++; - if (c == '\0') - /* macintosh end of line */ - break; - if (c == '\n') { - c = *line++; - if (c == '\0') - /* DOS end of line */ - break; - } - self->had_parse_error = 1; - Py_DECREF(lineobj); - return PyErr_Format(error_obj, - "newline inside string"); - } - if (c == '\n') { - c = *line++; - if (c == '\0') - /* unix end of line */ - break; - self->had_parse_error = 1; - Py_DECREF(lineobj); - return PyErr_Format(error_obj, - "newline inside string"); - } + while (linelen--) { + c = *line++; + if (c == '\0') { + Py_DECREF(lineobj); + PyErr_Format(error_obj, + "line contains NULL byte"); + goto err; + } if (parse_process_char(self, c) < 0) { Py_DECREF(lineobj); - return NULL; + goto err; } } - if (parse_process_char(self, '\n') < 0) { - Py_DECREF(lineobj); - return NULL; - } Py_DECREF(lineobj); + if (parse_process_char(self, 0) < 0) + goto err; } while (self->state != START_RECORD); fields = self->fields; - self->fields = PyList_New(0); + self->fields = NULL; +err: return fields; } @@ -875,6 +845,14 @@ static struct PyMethodDef Reader_methods[] = { { NULL, NULL } }; +#define R_OFF(x) offsetof(ReaderObj, x) + +static struct PyMemberDef Reader_memberlist[] = { + { "dialect", T_OBJECT, R_OFF(dialect), RO }, + { "line_num", T_ULONG, R_OFF(line_num), RO }, + { NULL } +}; + static PyTypeObject Reader_Type = { PyObject_HEAD_INIT(NULL) From tim_one at users.sourceforge.net Thu Jan 13 18:37:41 2005 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Jan 13 18:37:44 2005 Subject: [Python-checkins] python/dist/src/Lib/idlelib configHandler.py, 1.36, 1.37 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16104/Lib/idlelib Modified Files: configHandler.py Log Message: Whitespace normalization. Index: configHandler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/configHandler.py,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- configHandler.py 11 Jan 2005 19:29:39 -0000 1.36 +++ configHandler.py 13 Jan 2005 17:37:38 -0000 1.37 @@ -193,7 +193,7 @@ """ Creates (if required) and returns a filesystem directory for storing user config files. - + """ cfgDir = '.idlerc' userDir = os.path.expanduser('~') From tim_one at users.sourceforge.net Thu Jan 13 18:37:41 2005 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Jan 13 18:37:45 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_csv.py,1.26,1.27 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16104/Lib/test Modified Files: test_csv.py Log Message: Whitespace normalization. Index: test_csv.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_csv.py,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- test_csv.py 12 Jan 2005 11:17:15 -0000 1.26 +++ test_csv.py 13 Jan 2005 17:37:38 -0000 1.27 @@ -30,9 +30,9 @@ self.assertRaises(TypeError, ctor, arg, lineterminator=None) self.assertRaises(TypeError, ctor, arg, lineterminator=1) self.assertRaises(TypeError, ctor, arg, quoting=None) - self.assertRaises(TypeError, ctor, arg, + self.assertRaises(TypeError, ctor, arg, quoting=csv.QUOTE_ALL, quotechar='') - self.assertRaises(TypeError, ctor, arg, + self.assertRaises(TypeError, ctor, arg, quoting=csv.QUOTE_ALL, quotechar=None) def test_reader_arg_valid(self): @@ -172,15 +172,15 @@ self.assertRaises(csv.Error, self._write_test, ['a',1,'p,"q"'], 'a,1,"p,\\"q\\""', - escapechar=None, doublequote=False) + escapechar=None, doublequote=False) self._write_test(['a',1,'p,"q"'], 'a,1,"p,\\"q\\""', escapechar='\\', doublequote = False) - self._write_test(['"'], '""""', + self._write_test(['"'], '""""', escapechar='\\', quoting = csv.QUOTE_MINIMAL) - self._write_test(['"'], '\\"', + self._write_test(['"'], '\\"', escapechar='\\', quoting = csv.QUOTE_MINIMAL, doublequote = False) - self._write_test(['"'], '\\"', + self._write_test(['"'], '\\"', escapechar='\\', quoting = csv.QUOTE_NONE) self._write_test(['a',1,'p,q'], 'a,1,p\\,q', escapechar='\\', quoting = csv.QUOTE_NONE) @@ -244,7 +244,7 @@ # will this fail where locale uses comma for decimals? self._read_test([',3,"5",7.3, 9'], [['', 3, '5', 7.3, 9]], quoting=csv.QUOTE_NONNUMERIC) - self.assertRaises(ValueError, self._read_test, + self.assertRaises(ValueError, self._read_test, ['abc,3'], [[]], quoting=csv.QUOTE_NONNUMERIC) From tim_one at users.sourceforge.net Thu Jan 13 22:06:33 2005 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Thu Jan 13 22:06:38 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libdatetime.tex, 1.54, 1.55 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31706 Modified Files: libdatetime.tex Log Message: Gave the new datetime.strptime() a versionadded blurb. Index: libdatetime.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdatetime.tex,v retrieving revision 1.54 retrieving revision 1.55 diff -u -d -r1.54 -r1.55 --- libdatetime.tex 13 Jan 2005 04:12:26 -0000 1.54 +++ libdatetime.tex 13 Jan 2005 21:06:25 -0000 1.55 @@ -631,6 +631,8 @@ format)[0:6]))}. \exception{ValueError} is raised if the date_string and format can't be parsed by \function{time.strptime()} or if it returns a value which isn't a time tuple. + + \versionadded{2.5} \end{methoddesc} Class attributes: From jvr at users.sourceforge.net Fri Jan 14 20:01:14 2005 From: jvr at users.sourceforge.net (jvr@users.sourceforge.net) Date: Fri Jan 14 20:01:17 2005 Subject: [Python-checkins] python/nondist/peps pep-0246.txt,1.6,1.7 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14053 Modified Files: pep-0246.txt Log Message: fixed a couple of typos Index: pep-0246.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0246.txt,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- pep-0246.txt 10 Jan 2005 14:31:35 -0000 1.6 +++ pep-0246.txt 14 Jan 2005 19:01:09 -0000 1.7 @@ -325,12 +325,12 @@ def f(X): X = adapt(X, Y) - # continue by using X according to protocol X + # continue by using X according to protocol Y In [4], the BDFL has proposed introducing the syntax: def f(X: Y): - # continue by using X according to protocol X + # continue by using X according to protocol Y to be a handy shortcut for exactly this typical use of adapt, and, as a basis for experimentation until the parser has been modified @@ -338,7 +338,7 @@ @arguments(Y) def f(X): - # continue by using X according to protocol X + # continue by using X according to protocol Y These BDFL ideas are fully compatible with this proposal, as are other of Guido's suggestions in the same blog. @@ -615,7 +615,7 @@ appropriate adapter, but even then searching for the adapter and figuring out how to deploy the adapter takes time. - This technique enables supplierrs to work with each other + This technique enables suppliers to work with each other directly, by implementing __conform__ or __adapt__ as necessary. This frees the integrator from making their own adapters. In essence, this allows the components to have a From luciagomes8475z at hotmail.com Sat Jan 15 02:29:10 2005 From: luciagomes8475z at hotmail.com (Lucia Gomes) Date: Sat Jan 15 02:29:09 2005 Subject: [Python-checkins] listagem de e-mails Message-ID: <20050115012909.5097C1E4008@bag.python.org> Mais Emails, venda online de listas de email, fazemos mala direta e propaganda de sua empresa ou neg?cio para milh?es de emails. Temos listas de email Mala Direta, Mala-Direta, Cadastro de Emails, Lista de Emails, Mailing List, Milh?es de Emails, Programas de Envio de Email, Email Bombers, Extratores de Email, Listas Segmentadas de Email, Emails Segmentados, Emails em Massa, E-mails http://www.estacion.de/maladireta Temos listas de email Mala Direta, Mala-Direta, Cadastro de Emails, Lista de Emails, Mailing List, Milh?es de Emails, Programas de Envio de Email, Email Bombers, Extratores de Email, Listas Segmentadas de Email, Emails Segmentados, Emails em Massa, E-mails http://www.estacion.de/maladireta From gvanrossum at users.sourceforge.net Sat Jan 15 06:06:12 2005 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Sat Jan 15 06:06:15 2005 Subject: [Python-checkins] python/nondist/peps pep-0246.txt,1.7,1.8 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2813 Modified Files: pep-0246.txt Log Message: Correct the intention for basestring. Index: pep-0246.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0246.txt,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- pep-0246.txt 14 Jan 2005 19:01:09 -0000 1.7 +++ pep-0246.txt 15 Jan 2005 05:06:09 -0000 1.8 @@ -65,10 +65,10 @@ blessed by the BDFL (Benevolent Dictator for Life). The same can be said for the alternative technique based on checking 'isinstance' (the built-in class "basestring" exists specifically - to let you use 'isinstance' to check if an object "is something - like a string"). Neither approach is easily and generally - extensible to other protocols, defined by applications and third - party frameworks, outside of the standard Python core. + to let you use 'isinstance' to check if an object "is a [built-in] + string"). Neither approach is easily and generally extensible to + other protocols, defined by applications and third party + frameworks, outside of the standard Python core. Even more important than checking if an object already supports a given protocol can be the task of obtaining a suitable adapter From gvanrossum at users.sourceforge.net Sun Jan 16 01:12:39 2005 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Sun Jan 16 01:12:42 2005 Subject: [Python-checkins] python/dist/src/Demo/newmetaclasses Eiffel.py, 1.6, 1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Demo/newmetaclasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26476 Modified Files: Eiffel.py Log Message: Use decorators. Index: Eiffel.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/newmetaclasses/Eiffel.py,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Eiffel.py 18 Jul 2004 05:56:07 -0000 1.6 +++ Eiffel.py 16 Jan 2005 00:12:35 -0000 1.7 @@ -9,6 +9,7 @@ return super(EiffelBaseMetaClass, meta).__new__(meta, name, bases, dict) + @classmethod def convert_methods(cls, dict): """Replace functions in dict with EiffelMethod wrappers. @@ -30,11 +31,10 @@ if pre or post: dict[k] = cls.make_eiffel_method(dict[m], pre, post) - convert_methods = classmethod(convert_methods) - class EiffelMetaClass1(EiffelBaseMetaClass): # an implementation of the "eiffel" meta class that uses nested functions + @staticmethod def make_eiffel_method(func, pre, post): def method(self, *args, **kwargs): if pre: @@ -49,8 +49,6 @@ return method - make_eiffel_method = staticmethod(make_eiffel_method) - class EiffelMethodWrapper: def __init__(self, inst, descr): From gvanrossum at users.sourceforge.net Sun Jan 16 01:14:55 2005 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Sun Jan 16 01:14:59 2005 Subject: [Python-checkins] python/dist/src/Lib UserDict.py,1.28,1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27076 Modified Files: UserDict.py Log Message: Use decorators. Index: UserDict.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/UserDict.py,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- UserDict.py 27 May 2004 09:41:04 -0000 1.28 +++ UserDict.py 16 Jan 2005 00:14:52 -0000 1.29 @@ -63,12 +63,12 @@ return self.data.popitem() def __contains__(self, key): return key in self.data + @classmethod def fromkeys(cls, iterable, value=None): d = cls() for key in iterable: d[key] = value return d - fromkeys = classmethod(fromkeys) class IterableUserDict(UserDict): def __iter__(self): From gvanrossum at users.sourceforge.net Sun Jan 16 01:16:16 2005 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Sun Jan 16 01:16:19 2005 Subject: [Python-checkins] python/dist/src/Lib tarfile.py,1.22,1.23 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27534 Modified Files: tarfile.py Log Message: Use decorators. Index: tarfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tarfile.py,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- tarfile.py 31 Dec 2004 19:15:26 -0000 1.22 +++ tarfile.py 16 Jan 2005 00:16:11 -0000 1.23 @@ -656,6 +656,7 @@ def __repr__(self): return "<%s %r at %#x>" % (self.__class__.__name__,self.name,id(self)) + @classmethod def frombuf(cls, buf): """Construct a TarInfo object from a 512 byte string buffer. """ @@ -699,8 +700,6 @@ tarinfo.name += "/" return tarinfo - frombuf = classmethod(frombuf) - def tobuf(self): """Return a tar header block as a 512 byte string. """ @@ -858,6 +857,7 @@ # the super-constructor. A sub-constructor is registered and made available # by adding it to the mapping in OPEN_METH. + @classmethod def open(cls, name=None, mode="r", fileobj=None, bufsize=20*512): """Open a tar archive for reading, writing or appending. Return an appropriate TarFile class. @@ -923,8 +923,7 @@ raise ValueError, "undiscernible mode" - open = classmethod(open) - + @classmethod def taropen(cls, name, mode="r", fileobj=None): """Open uncompressed tar archive name for reading or writing. """ @@ -932,8 +931,7 @@ raise ValueError, "mode must be 'r', 'a' or 'w'" return cls(name, mode, fileobj) - taropen = classmethod(taropen) - + @classmethod def gzopen(cls, name, mode="r", fileobj=None, compresslevel=9): """Open gzip compressed tar archive name for reading or writing. Appending is not allowed. @@ -970,8 +968,7 @@ t._extfileobj = False return t - gzopen = classmethod(gzopen) - + @classmethod def bz2open(cls, name, mode="r", fileobj=None, compresslevel=9): """Open bzip2 compressed tar archive name for reading or writing. Appending is not allowed. @@ -1002,8 +999,6 @@ t._extfileobj = False return t - bz2open = classmethod(bz2open) - # All *open() methods are registered here. OPEN_METH = { "tar": "taropen", # uncompressed tar From gvanrossum at users.sourceforge.net Sun Jan 16 01:21:32 2005 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Sun Jan 16 01:21:35 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_builtin.py, 1.38, 1.39 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29517 Modified Files: test_builtin.py Log Message: Use decorators. Index: test_builtin.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_builtin.py,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- test_builtin.py 7 Dec 2004 21:17:46 -0000 1.38 +++ test_builtin.py 16 Jan 2005 00:21:28 -0000 1.39 @@ -1274,17 +1274,18 @@ self.assertRaises(ValueError, unichr, sys.maxunicode+1) self.assertRaises(TypeError, unichr) + # We don't want self in vars(), so these are static methods + + @staticmethod def get_vars_f0(): return vars() - # we don't want self in vars(), so use staticmethod - get_vars_f0 = staticmethod(get_vars_f0) + @staticmethod def get_vars_f2(): BuiltinTest.get_vars_f0() a = 1 b = 2 return vars() - get_vars_f2 = staticmethod(get_vars_f2) def test_vars(self): self.assertEqual(set(vars()), set(dir())) From gvanrossum at users.sourceforge.net Sun Jan 16 01:25:49 2005 From: gvanrossum at users.sourceforge.net (gvanrossum@users.sourceforge.net) Date: Sun Jan 16 01:25:54 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_datetime.py, 1.50, 1.51 test_descr.py, 1.202, 1.203 test_descrtut.py, 1.20, 1.21 test_doctest2.py, 1.6, 1.7 test_userdict.py, 1.20, 1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30315 Modified Files: test_datetime.py test_descr.py test_descrtut.py test_doctest2.py test_userdict.py Log Message: Use descriptors. Index: test_datetime.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_datetime.py,v retrieving revision 1.50 retrieving revision 1.51 diff -u -d -r1.50 -r1.51 --- test_datetime.py 13 Jan 2005 04:12:27 -0000 1.50 +++ test_datetime.py 16 Jan 2005 00:25:30 -0000 1.51 @@ -446,9 +446,9 @@ def test_subclass_timedelta(self): class T(timedelta): + @staticmethod def from_td(td): return T(td.days, td.seconds, td.microseconds) - from_td = staticmethod(from_td) def as_hours(self): sum = (self.days * 24 + Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.202 retrieving revision 1.203 diff -u -d -r1.202 -r1.203 --- test_descr.py 7 Aug 2004 20:30:03 -0000 1.202 +++ test_descr.py 16 Jan 2005 00:25:31 -0000 1.203 @@ -691,13 +691,13 @@ class _instance(object): pass class M2(object): + @staticmethod def __new__(cls, name, bases, dict): self = object.__new__(cls) self.name = name self.bases = bases self.dict = dict return self - __new__ = staticmethod(__new__) def __call__(self): it = _instance() # Early binding of methods @@ -2071,9 +2071,9 @@ aProp = property(lambda self: "foo") class Sub(Base): + @classmethod def test(klass): return super(Sub,klass).aProp - test = classmethod(test) veris(Sub.test(), Base.aProp) Index: test_descrtut.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descrtut.py,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- test_descrtut.py 2 Jul 2004 06:41:05 -0000 1.20 +++ test_descrtut.py 16 Jan 2005 00:25:31 -0000 1.21 @@ -246,9 +246,9 @@ >>> class C: ... + ... @staticmethod ... def foo(x, y): ... print "staticmethod", x, y - ... foo = staticmethod(foo) >>> C.foo(1, 2) staticmethod 1 2 @@ -260,9 +260,9 @@ implicit first argument that is the *class* for which they are invoked. >>> class C: + ... @classmethod ... def foo(cls, y): ... print "classmethod", cls, y - ... foo = classmethod(foo) >>> C.foo(1) classmethod test.test_descrtut.C 1 @@ -286,10 +286,10 @@ But notice this: >>> class E(C): + ... @classmethod ... def foo(cls, y): # override C.foo ... print "E.foo() called" ... C.foo(y) - ... foo = classmethod(foo) >>> E.foo(1) E.foo() called Index: test_doctest2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest2.py,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- test_doctest2.py 13 Oct 2004 14:15:32 -0000 1.6 +++ test_doctest2.py 16 Jan 2005 00:25:31 -0000 1.7 @@ -80,6 +80,7 @@ -12 """) + @staticmethod def statm(): """ A static method. @@ -91,8 +92,7 @@ """ return 666 - statm = staticmethod(statm) - + @classmethod def clsm(cls, val): """ A class method. @@ -104,8 +104,6 @@ """ return val - clsm = classmethod(clsm) - def test_main(): from test import test_doctest2 EXPECTED = 19 Index: test_userdict.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_userdict.py,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- test_userdict.py 2 Jun 2004 18:42:25 -0000 1.20 +++ test_userdict.py 16 Jan 2005 00:25:31 -0000 1.21 @@ -191,12 +191,12 @@ for key, value in self.iteritems(): d[key] = value return d + @classmethod def fromkeys(cls, keys, value=None): d = cls() for key in keys: d[key] = value return d - fromkeys = classmethod(fromkeys) class UserDictMixinTest(mapping_tests.TestMappingProtocol): type2test = SeqDict From loewis at users.sourceforge.net Sun Jan 16 09:41:04 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Jan 16 09:41:08 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1225,1.1226 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19604/Misc Modified Files: NEWS Log Message: Added SEEK_* constants. Fixes #711830. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1225 retrieving revision 1.1226 diff -u -d -r1.1225 -r1.1226 --- NEWS 13 Jan 2005 11:30:54 -0000 1.1225 +++ NEWS 16 Jan 2005 08:40:58 -0000 1.1226 @@ -37,6 +37,8 @@ Library ------- +- os.{SEEK_SET, SEEK_CUR, SEEK_END} have been added for convenience. + - Enhancements to the csv module: + Dialects are now validated by the underlying C code, better From loewis at users.sourceforge.net Sun Jan 16 09:41:31 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Jan 16 09:41:34 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libos.tex,1.148,1.149 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19604/Doc/lib Modified Files: libos.tex Log Message: Added SEEK_* constants. Fixes #711830. Index: libos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.148 retrieving revision 1.149 diff -u -d -r1.148 -r1.149 --- libos.tex 7 Jan 2005 02:50:22 -0000 1.148 +++ libos.tex 16 Jan 2005 08:40:58 -0000 1.149 @@ -636,6 +636,15 @@ Availability: Windows. \end{datadesc} +\begin{datadesc}{SEEK_SET} +\dataline{SEEK_CUR} +\dataline{SEEK_END} +Parameteters to the \function{lseek()} function. +Their values are 0, 1, and 2, respectively. +Availability: Windows, Macintosh, \UNIX. +\versionadded{2.5} +\end{datadesc} + \subsection{Files and Directories \label{os-file-dir}} \begin{funcdesc}{access}{path, mode} From loewis at users.sourceforge.net Sun Jan 16 09:41:31 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Jan 16 09:41:35 2005 Subject: [Python-checkins] python/dist/src/Lib os.py,1.83,1.84 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19604/Lib Modified Files: os.py Log Message: Added SEEK_* constants. Fixes #711830. Index: os.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/os.py,v retrieving revision 1.83 retrieving revision 1.84 diff -u -d -r1.83 -r1.84 --- os.py 11 Oct 2004 18:12:15 -0000 1.83 +++ os.py 16 Jan 2005 08:40:57 -0000 1.84 @@ -29,7 +29,8 @@ # Note: more names are added to __all__ later. __all__ = ["altsep", "curdir", "pardir", "sep", "pathsep", "linesep", - "defpath", "name", "path", "devnull"] + "defpath", "name", "path", "devnull", + "SEEK_SET", "SEEK_CUR", "SEEK_END"] def _get_exports_list(module): try: @@ -135,6 +136,12 @@ del _names +# Python uses fixed values for the SEEK_ constants; they are mapped +# to native constants if necessary in posixmodule.c +SEEK_SET = 0 +SEEK_CUR = 1 +SEEK_END = 2 + #' # Super directory utilities. From loewis at users.sourceforge.net Sun Jan 16 09:57:42 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Jan 16 09:57:46 2005 Subject: [Python-checkins] python/dist/src/Modules posixmodule.c, 2.331, 2.332 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22162/Modules Modified Files: posixmodule.c Log Message: Default stat_float_times to true. Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.331 retrieving revision 2.332 diff -u -d -r2.331 -r2.332 --- posixmodule.c 18 Dec 2004 09:51:05 -0000 2.331 +++ posixmodule.c 16 Jan 2005 08:57:38 -0000 2.332 @@ -789,7 +789,7 @@ /* If true, st_?time is float. */ -static int _stat_float_times = 0; +static int _stat_float_times = 1; PyDoc_STRVAR(stat_float_times__doc__, "stat_float_times([newval]) -> oldval\n\n\ From loewis at users.sourceforge.net Sun Jan 16 09:57:43 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Jan 16 09:57:47 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1226,1.1227 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22162/Misc Modified Files: NEWS Log Message: Default stat_float_times to true. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1226 retrieving revision 1.1227 diff -u -d -r1.1226 -r1.1227 --- NEWS 16 Jan 2005 08:40:58 -0000 1.1226 +++ NEWS 16 Jan 2005 08:57:28 -0000 1.1227 @@ -22,6 +22,8 @@ Extension Modules ----------------- +- stat_float_times is now True. + - array.array objects are now picklable. - the cPickle module no longer accepts the deprecated None option in the From loewis at users.sourceforge.net Sun Jan 16 09:57:42 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Jan 16 09:57:49 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libos.tex,1.149,1.150 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22162/Doc/lib Modified Files: libos.tex Log Message: Default stat_float_times to true. Index: libos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.149 retrieving revision 1.150 diff -u -d -r1.149 -r1.150 --- libos.tex 16 Jan 2005 08:40:58 -0000 1.149 +++ libos.tex 16 Jan 2005 08:57:39 -0000 1.150 @@ -1012,17 +1012,13 @@ it is False, future calls return ints. If newval is omitted, return the current setting. -For compatibility with older Python versions, accessing -\class{stat_result} as a tuple always returns integers. For -compatibility with Python 2.2, accessing the time stamps by field name -also returns integers. Applications that want to determine the -fractions of a second in a time stamp can use this function to have -time stamps represented as floats. Whether they will actually observe -non-zero fractions depends on the system. +\versionchanged[Python now returns float values by default. Applications +which do not work correctly with floating point time stamps can use +this function to restore the old behaviour]{2.5} -Future Python releases will change the default of this setting; -applications that cannot deal with floating point time stamps can then -use this function to turn the feature off. +The resolution of the timestamps (i.e. the smallest possible fraction) +depends on the system. Some systems only support second resolution; +on these systems, the fraction will always be zero. It is recommended that this setting is only changed at program startup time in the \var{__main__} module; libraries should never change this From jlgijsbers at users.sourceforge.net Sun Jan 16 14:04:34 2005 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sun Jan 16 14:04:38 2005 Subject: [Python-checkins] python/dist/src/Lib smtplib.py,1.67,1.68 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3331 Modified Files: smtplib.py Log Message: Patch #1100140: improved smtp connect debugging Don't print the same (host, port) tuple thrice when debugging, but first print (host, port), then (ip, port) and then the error message. Index: smtplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/smtplib.py,v retrieving revision 1.67 retrieving revision 1.68 diff -u -d -r1.67 -r1.68 --- smtplib.py 8 Jan 2005 14:12:27 -0000 1.67 +++ smtplib.py 16 Jan 2005 13:04:30 -0000 1.68 @@ -290,10 +290,10 @@ af, socktype, proto, canonname, sa = res try: self.sock = socket.socket(af, socktype, proto) - if self.debuglevel > 0: print>>stderr, 'connect:', (host, port) + if self.debuglevel > 0: print>>stderr, 'connect:', sa self.sock.connect(sa) except socket.error, msg: - if self.debuglevel > 0: print>>stderr, 'connect fail:', (host, port) + if self.debuglevel > 0: print>>stderr, 'connect fail:', msg if self.sock: self.sock.close() self.sock = None From nnorwitz at users.sourceforge.net Sun Jan 16 16:15:00 2005 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Sun Jan 16 16:15:04 2005 Subject: [Python-checkins] python/dist/src/Python ast.c,1.1.2.53,1.1.2.54 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24515/Python Modified Files: Tag: ast-branch ast.c Log Message: Get imports working after merge...still needs lots of cleanup Index: ast.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/Attic/ast.c,v retrieving revision 1.1.2.53 retrieving revision 1.1.2.54 diff -u -d -r1.1.2.53 -r1.1.2.54 --- ast.c 23 Apr 2004 18:25:26 -0000 1.1.2.53 +++ ast.c 16 Jan 2005 15:14:57 -0000 1.1.2.54 @@ -1670,19 +1670,23 @@ ast_for_import_stmt(struct compiling *c, const node *n) { /* - import_stmt: 'import' dotted_as_name (',' dotted_as_name)* - | 'from' dotted_name 'import' ('*' - | import_as_name (',' import_as_name)*) + import_stmt: import_name | import_from + import_name: 'import' dotted_as_names + import_from: 'from' dotted_name 'import' ('*' | + '(' import_as_names ')' | + import_as_names) */ int i; asdl_seq *aliases; REQ(n, import_stmt); + n = CHILD(n, 0); if (STR(CHILD(n, 0))[0] == 'i') { /* import */ - aliases = asdl_seq_new(NCH(n) / 2); + n = CHILD(n, 1); + aliases = asdl_seq_new((NCH(n) + 1) / 2); if (!aliases) return NULL; - for (i = 1; i < NCH(n); i += 2) { + for (i = 0; i < NCH(n); i += 2) { alias_ty import_alias = alias_for_import_name(CHILD(n, i)); if (!import_alias) { asdl_seq_free(aliases); @@ -1694,15 +1698,44 @@ } else if (STR(CHILD(n, 0))[0] == 'f') { /* from */ stmt_ty import; + int n_children; + const char *from_modules; alias_ty mod = alias_for_import_name(CHILD(n, 1)); if (!mod) return NULL; - aliases = asdl_seq_new((NCH(n) - 2) / 2); + + /* XXX this needs to be cleaned up */ + + from_modules = STR(CHILD(n, 3)); + if (!from_modules || from_modules[0] == '*') + n = CHILD(n, 3); /* from ... import x, y, z */ + else if (from_modules[0] == '(') + n = CHILD(n, 4); /* from ... import (x, y, z) */ + else + return NULL; + + n_children = NCH(n); + if (from_modules && from_modules[0] == '*') + n_children = 1; + + aliases = asdl_seq_new((n_children + 1) / 2); if (!aliases) { free(mod); /* XXX proper way to free alias_ty structs? */ return NULL; } - for (i = 3; i <= NCH(n); i += 2) { + + /* handle "from ... import *" special b/c there's no children */ + if (from_modules && from_modules[0] == '*') { + alias_ty import_alias = alias_for_import_name(n); + if (!import_alias) { + asdl_seq_free(aliases); + free(mod); + return NULL; + } + asdl_seq_APPEND(aliases, import_alias); + } + + for (i = 0; i < NCH(n); i += 2) { alias_ty import_alias = alias_for_import_name(CHILD(n, i)); if (!import_alias) { asdl_seq_free(aliases); From nnorwitz at users.sourceforge.net Sun Jan 16 18:09:14 2005 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Sun Jan 16 18:09:16 2005 Subject: [Python-checkins] python/dist/src/Parser Python.asdl, 1.1.2.7, 1.1.2.8 asdl_c.py, 1.1.2.3, 1.1.2.4 Message-ID: Update of /cvsroot/python/python/dist/src/Parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14168/Parser Modified Files: Tag: ast-branch Python.asdl asdl_c.py Log Message: Handle generator comps a little, lots more to do to get working Index: Python.asdl =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/Attic/Python.asdl,v retrieving revision 1.1.2.7 retrieving revision 1.1.2.8 diff -u -d -r1.1.2.7 -r1.1.2.8 --- Python.asdl 28 Mar 2003 02:05:27 -0000 1.1.2.7 +++ Python.asdl 16 Jan 2005 17:09:11 -0000 1.1.2.8 @@ -52,7 +52,8 @@ | UnaryOp(unaryop op, expr operand) | Lambda(arguments args, expr body) | Dict(expr* keys, expr *values) - | ListComp(expr elt, listcomp* generators) + | ListComp(expr elt, comprehension* generators) + | GeneratorComp(expr elt, comprehension* generators) -- need sequences for compare to distinguish between -- x < 4 < 3 and (x < 4) < 3 | Compare(expr left, cmpop* ops, expr* comparators) @@ -85,7 +86,7 @@ cmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIn - listcomp = (expr target, expr iter, expr* ifs) + comprehension = (expr target, expr iter, expr* ifs) -- not sure what to call the first argument for raise and except Index: asdl_c.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/Attic/asdl_c.py,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -d -r1.1.2.3 -r1.1.2.4 --- asdl_c.py 13 Apr 2004 14:54:43 -0000 1.1.2.3 +++ asdl_c.py 16 Jan 2005 17:09:11 -0000 1.1.2.4 @@ -44,7 +44,10 @@ padding = "" while len(cur) > size: i = cur.rfind(' ', 0, size) - assert i != -1, "Impossible line to reflow: %s" % `s` + # XXX this should be fixed for real + if i == -1 and 'GeneratorComp' in cur: + i = size + 3 + assert i != -1, "Impossible line %d to reflow: %s" % (size, `s`) lines.append(padding + cur[:i]) if len(lines) == 1: # find new size based on brace From nnorwitz at users.sourceforge.net Sun Jan 16 18:09:14 2005 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Sun Jan 16 18:09:18 2005 Subject: [Python-checkins] python/dist/src/Include Python-ast.h, 1.1.2.8, 1.1.2.9 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14168/Include Modified Files: Tag: ast-branch Python-ast.h Log Message: Handle generator comps a little, lots more to do to get working Index: Python-ast.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/Attic/Python-ast.h,v retrieving revision 1.1.2.8 retrieving revision 1.1.2.9 diff -u -d -r1.1.2.8 -r1.1.2.9 --- Python-ast.h 13 Apr 2004 14:58:35 -0000 1.1.2.8 +++ Python-ast.h 16 Jan 2005 17:09:11 -0000 1.1.2.9 @@ -24,7 +24,7 @@ typedef enum _cmpop { Eq=1, NotEq=2, Lt=3, LtE=4, Gt=5, GtE=6, Is=7, IsNot=8, In=9, NotIn=10 } cmpop_ty; -typedef struct _listcomp *listcomp_ty; +typedef struct _comprehension *comprehension_ty; typedef struct _excepthandler *excepthandler_ty; @@ -178,10 +178,10 @@ struct _expr { enum { BoolOp_kind=1, BinOp_kind=2, UnaryOp_kind=3, Lambda_kind=4, - Dict_kind=5, ListComp_kind=6, Compare_kind=7, Call_kind=8, - Repr_kind=9, Num_kind=10, Str_kind=11, Attribute_kind=12, - Subscript_kind=13, Name_kind=14, List_kind=15, Tuple_kind=16 - } kind; + Dict_kind=5, ListComp_kind=6, GeneratorComp_kind=7, + Compare_kind=8, Call_kind=9, Repr_kind=10, Num_kind=11, + Str_kind=12, Attribute_kind=13, Subscript_kind=14, + Name_kind=15, List_kind=16, Tuple_kind=17 } kind; union { struct { boolop_ty op; @@ -215,6 +215,11 @@ } ListComp; struct { + expr_ty elt; + asdl_seq *generators; + } GeneratorComp; + + struct { expr_ty left; asdl_seq *ops; asdl_seq *comparators; @@ -291,7 +296,7 @@ } v; }; -struct _listcomp { +struct _comprehension { expr_ty target; expr_ty iter; asdl_seq *ifs; @@ -358,6 +363,7 @@ expr_ty Lambda(arguments_ty args, expr_ty body); expr_ty Dict(asdl_seq * keys, asdl_seq * values); expr_ty ListComp(expr_ty elt, asdl_seq * generators); +expr_ty GeneratorComp(expr_ty elt, asdl_seq * generators); expr_ty Compare(expr_ty left, asdl_seq * ops, asdl_seq * comparators); expr_ty Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty starargs, expr_ty kwargs); @@ -373,7 +379,8 @@ slice_ty Slice(expr_ty lower, expr_ty upper, expr_ty step); slice_ty ExtSlice(asdl_seq * dims); slice_ty Index(expr_ty value); -listcomp_ty listcomp(expr_ty target, expr_ty iter, asdl_seq * ifs); +comprehension_ty comprehension(expr_ty target, expr_ty iter, asdl_seq * + ifs); excepthandler_ty excepthandler(expr_ty type, expr_ty name, asdl_seq * body); arguments_ty arguments(asdl_seq * args, identifier vararg, identifier kwarg, asdl_seq * defaults); @@ -388,7 +395,7 @@ void free_operator(operator_ty); void free_unaryop(unaryop_ty); void free_cmpop(cmpop_ty); -void free_listcomp(listcomp_ty); +void free_comprehension(comprehension_ty); void free_excepthandler(excepthandler_ty); void free_arguments(arguments_ty); void free_keyword(keyword_ty); @@ -402,7 +409,7 @@ int marshal_write_operator(PyObject **, int *, operator_ty); int marshal_write_unaryop(PyObject **, int *, unaryop_ty); int marshal_write_cmpop(PyObject **, int *, cmpop_ty); -int marshal_write_listcomp(PyObject **, int *, listcomp_ty); +int marshal_write_comprehension(PyObject **, int *, comprehension_ty); int marshal_write_excepthandler(PyObject **, int *, excepthandler_ty); int marshal_write_arguments(PyObject **, int *, arguments_ty); int marshal_write_keyword(PyObject **, int *, keyword_ty); From nnorwitz at users.sourceforge.net Sun Jan 16 18:09:15 2005 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Sun Jan 16 18:09:19 2005 Subject: [Python-checkins] python/dist/src/Python Python-ast.c, 1.1.2.8, 1.1.2.9 ast.c, 1.1.2.54, 1.1.2.55 newcompile.c, 1.1.2.100, 1.1.2.101 symtable.c, 2.10.8.29, 2.10.8.30 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14168/Python Modified Files: Tag: ast-branch Python-ast.c ast.c newcompile.c symtable.c Log Message: Handle generator comps a little, lots more to do to get working Index: Python-ast.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/Attic/Python-ast.c,v retrieving revision 1.1.2.8 retrieving revision 1.1.2.9 diff -u -d -r1.1.2.8 -r1.1.2.9 --- Python-ast.c 13 Apr 2004 14:58:35 -0000 1.1.2.8 +++ Python-ast.c 16 Jan 2005 17:09:11 -0000 1.1.2.9 @@ -650,6 +650,26 @@ } expr_ty +GeneratorComp(expr_ty elt, asdl_seq * generators) +{ + expr_ty p; + if (!elt) { + PyErr_SetString(PyExc_ValueError, + "field elt is required for GeneratorComp"); + return NULL; + } + p = (expr_ty)malloc(sizeof(*p)); + if (!p) { + PyErr_SetString(PyExc_MemoryError, "no memory"); + return NULL; + } + p->kind = GeneratorComp_kind; + p->v.GeneratorComp.elt = elt; + p->v.GeneratorComp.generators = generators; + return p; +} + +expr_ty Compare(expr_ty left, asdl_seq * ops, asdl_seq * comparators) { expr_ty p; @@ -940,21 +960,21 @@ return p; } -listcomp_ty -listcomp(expr_ty target, expr_ty iter, asdl_seq * ifs) +comprehension_ty +comprehension(expr_ty target, expr_ty iter, asdl_seq * ifs) { - listcomp_ty p; + comprehension_ty p; if (!target) { PyErr_SetString(PyExc_ValueError, - "field target is required for listcomp"); + "field target is required for comprehension"); return NULL; } if (!iter) { PyErr_SetString(PyExc_ValueError, - "field iter is required for listcomp"); + "field iter is required for comprehension"); return NULL; } - p = (listcomp_ty)malloc(sizeof(*p)); + p = (comprehension_ty)malloc(sizeof(*p)); if (!p) { PyErr_SetString(PyExc_MemoryError, "no memory"); return NULL; @@ -1278,7 +1298,14 @@ seq = o->v.ListComp.generators; n = asdl_seq_LEN(seq); for (i = 0; i < n; i++) - free_listcomp(asdl_seq_GET(seq, i)); + free_comprehension(asdl_seq_GET(seq, i)); + break; + case GeneratorComp_kind: + free_expr(o->v.GeneratorComp.elt); + seq = o->v.GeneratorComp.generators; + n = asdl_seq_LEN(seq); + for (i = 0; i < n; i++) + free_comprehension(asdl_seq_GET(seq, i)); break; case Compare_kind: free_expr(o->v.Compare.left); @@ -1400,7 +1427,7 @@ } void -free_listcomp(listcomp_ty o) +free_comprehension(comprehension_ty o) { int i, n; asdl_seq *seq; @@ -1817,11 +1844,24 @@ i++) { void *elt = asdl_seq_GET(o->v.ListComp.generators, i); - marshal_write_listcomp(buf, off, elt); + marshal_write_comprehension(buf, off, elt); } break; - case Compare_kind: + case GeneratorComp_kind: marshal_write_int(buf, off, 7); + marshal_write_expr(buf, off, o->v.GeneratorComp.elt); + marshal_write_int(buf, off, + asdl_seq_LEN(o->v.GeneratorComp.generators)); + + for (i = 0; i < + asdl_seq_LEN(o->v.GeneratorComp.generators); i++) { + void *elt = + asdl_seq_GET(o->v.GeneratorComp.generators, i); + marshal_write_comprehension(buf, off, elt); + } + break; + case Compare_kind: + marshal_write_int(buf, off, 8); marshal_write_expr(buf, off, o->v.Compare.left); marshal_write_int(buf, off, asdl_seq_LEN(o->v.Compare.ops)); for (i = 0; i < asdl_seq_LEN(o->v.Compare.ops); i++) { @@ -1838,7 +1878,7 @@ } break; case Call_kind: - marshal_write_int(buf, off, 8); + marshal_write_int(buf, off, 9); marshal_write_expr(buf, off, o->v.Call.func); marshal_write_int(buf, off, asdl_seq_LEN(o->v.Call.args)); for (i = 0; i < asdl_seq_LEN(o->v.Call.args); i++) { @@ -1865,36 +1905,36 @@ marshal_write_int(buf, off, 0); break; case Repr_kind: - marshal_write_int(buf, off, 9); + marshal_write_int(buf, off, 10); marshal_write_expr(buf, off, o->v.Repr.value); break; case Num_kind: - marshal_write_int(buf, off, 10); + marshal_write_int(buf, off, 11); marshal_write_object(buf, off, o->v.Num.n); break; case Str_kind: - marshal_write_int(buf, off, 11); + marshal_write_int(buf, off, 12); marshal_write_string(buf, off, o->v.Str.s); break; case Attribute_kind: - marshal_write_int(buf, off, 12); + marshal_write_int(buf, off, 13); marshal_write_expr(buf, off, o->v.Attribute.value); marshal_write_identifier(buf, off, o->v.Attribute.attr); marshal_write_expr_context(buf, off, o->v.Attribute.ctx); break; case Subscript_kind: - marshal_write_int(buf, off, 13); + marshal_write_int(buf, off, 14); marshal_write_expr(buf, off, o->v.Subscript.value); marshal_write_slice(buf, off, o->v.Subscript.slice); marshal_write_expr_context(buf, off, o->v.Subscript.ctx); break; case Name_kind: - marshal_write_int(buf, off, 14); + marshal_write_int(buf, off, 15); marshal_write_identifier(buf, off, o->v.Name.id); marshal_write_expr_context(buf, off, o->v.Name.ctx); break; case List_kind: - marshal_write_int(buf, off, 15); + marshal_write_int(buf, off, 16); marshal_write_int(buf, off, asdl_seq_LEN(o->v.List.elts)); for (i = 0; i < asdl_seq_LEN(o->v.List.elts); i++) { void *elt = asdl_seq_GET(o->v.List.elts, i); @@ -1903,7 +1943,7 @@ marshal_write_expr_context(buf, off, o->v.List.ctx); break; case Tuple_kind: - marshal_write_int(buf, off, 16); + marshal_write_int(buf, off, 17); marshal_write_int(buf, off, asdl_seq_LEN(o->v.Tuple.elts)); for (i = 0; i < asdl_seq_LEN(o->v.Tuple.elts); i++) { void *elt = asdl_seq_GET(o->v.Tuple.elts, i); @@ -2104,7 +2144,7 @@ } int -marshal_write_listcomp(PyObject **buf, int *off, listcomp_ty o) +marshal_write_comprehension(PyObject **buf, int *off, comprehension_ty o) { int i; marshal_write_expr(buf, off, o->target); Index: ast.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/Attic/ast.c,v retrieving revision 1.1.2.54 retrieving revision 1.1.2.55 diff -u -d -r1.1.2.54 -r1.1.2.55 --- ast.c 16 Jan 2005 15:14:57 -0000 1.1.2.54 +++ ast.c 16 Jan 2005 17:09:11 -0000 1.1.2.55 @@ -757,7 +757,7 @@ ch = CHILD(n, 1); for (i = 0; i < n_fors; i++) { - listcomp_ty lc; + comprehension_ty lc; asdl_seq *t; expr_ty expression; @@ -777,9 +777,9 @@ } if (asdl_seq_LEN(t) == 1) - lc = listcomp(asdl_seq_GET(t, 0), expression, NULL); + lc = comprehension(asdl_seq_GET(t, 0), expression, NULL); else - lc = listcomp(Tuple(t, Store), expression, NULL); + lc = comprehension(Tuple(t, Store), expression, NULL); if (!lc) { asdl_seq_free(listcomps); @@ -1279,10 +1279,10 @@ /* arglist: (argument ',')* (argument [',']| '*' test [',' '**' test] | '**' test) - argument: [test '='] test # Really [keyword '='] test + argument: [test '='] test [gen_for] # Really [keyword '='] test */ - int i, nargs, nkeywords; + int i, nargs, nkeywords, ngens; asdl_seq *args = NULL; asdl_seq *keywords = NULL; expr_ty vararg = NULL, kwarg = NULL; @@ -1291,11 +1291,14 @@ nargs = 0; nkeywords = 0; + ngens = 0; for (i = 0; i < NCH(n); i++) if (TYPE(CHILD(n, i)) == argument) { if (NCH(CHILD(n, i)) == 1) nargs++; - else + else if (TYPE(CHILD(CHILD(n, i), 1)) == gen_for) + ngens++; + else nkeywords++; } @@ -1317,6 +1320,9 @@ goto error; asdl_seq_SET(args, nargs++, e); } + else if (TYPE(CHILD(CHILD(n, 0), 1)) == gen_for) { + /* XXX handle generator comp */ + } else { keyword_ty kw; identifier key; Index: newcompile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/Attic/newcompile.c,v retrieving revision 1.1.2.100 retrieving revision 1.1.2.101 diff -u -d -r1.1.2.100 -r1.1.2.101 --- newcompile.c 24 Apr 2004 03:54:02 -0000 1.1.2.100 +++ newcompile.c 16 Jan 2005 17:09:12 -0000 1.1.2.101 @@ -2303,7 +2303,7 @@ /* generate code for the iterator, then each of the ifs, and then write to the element */ - listcomp_ty l; + comprehension_ty l; int start, anchor, skip, if_cleanup, i, n; start = compiler_new_block(c); @@ -2393,6 +2393,13 @@ } static int +compiler_generatorcomp(struct compiler *c, expr_ty e) +{ + /* XXX handle */ + return 0; +} + +static int compiler_visit_keyword(struct compiler *c, keyword_ty k) { ADDOP_O(c, LOAD_CONST, k->arg, consts); @@ -2454,6 +2461,8 @@ break; case ListComp_kind: return compiler_listcomp(c, e); + case GeneratorComp_kind: + return compiler_generatorcomp(c, e); case Compare_kind: return compiler_compare(c, e); case Call_kind: Index: symtable.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/symtable.c,v retrieving revision 2.10.8.29 retrieving revision 2.10.8.30 diff -u -d -r2.10.8.29 -r2.10.8.30 --- symtable.c 7 Jan 2005 07:04:59 -0000 2.10.8.29 +++ symtable.c 16 Jan 2005 17:09:12 -0000 2.10.8.30 @@ -160,7 +160,7 @@ static int symtable_visit_arguments(struct symtable *st, arguments_ty); static int symtable_visit_excepthandler(struct symtable *st, excepthandler_ty); static int symtable_visit_alias(struct symtable *st, alias_ty); -static int symtable_visit_listcomp(struct symtable *st, listcomp_ty); +static int symtable_visit_comprehension(struct symtable *st, comprehension_ty); static int symtable_visit_keyword(struct symtable *st, keyword_ty); static int symtable_visit_slice(struct symtable *st, slice_ty); static int symtable_visit_params(struct symtable *st, asdl_seq *args, int top); @@ -919,8 +919,9 @@ if (e->v.Lambda.args->defaults) VISIT_SEQ(st, expr, e->v.Lambda.args->defaults); /* XXX how to get line numbers for expressions */ - symtable_enter_block(st, GET_IDENTIFIER(lambda), - FunctionBlock, (void *)e, 0); + if (!symtable_enter_block(st, GET_IDENTIFIER(lambda), + FunctionBlock, (void *)e, 0)) + return 0; VISIT(st, arguments, e->v.Lambda.args); VISIT(st, expr, e->v.Lambda.body); symtable_exit_block(st, (void *)e); @@ -940,7 +941,21 @@ if (!symtable_add_def(st, tmp, DEF_LOCAL)) return 0; VISIT(st, expr, e->v.ListComp.elt); - VISIT_SEQ(st, listcomp, e->v.ListComp.generators); + VISIT_SEQ(st, comprehension, e->v.ListComp.generators); + break; + } + case GeneratorComp_kind: { + char tmpname[256]; + identifier tmp; + + /* XXX this is correct/complete */ + tmp = PyString_FromString(""); + if (!symtable_enter_block(st, tmp, FunctionBlock, + (void *)e, 0)) + return 0; + VISIT(st, expr, e->v.GeneratorComp.elt); + VISIT_SEQ(st, comprehension, e->v.GeneratorComp.generators); + symtable_exit_block(st, (void *)e); break; } case Compare_kind: @@ -1102,7 +1117,7 @@ static int -symtable_visit_listcomp(struct symtable *st, listcomp_ty lc) +symtable_visit_comprehension(struct symtable *st, comprehension_ty lc) { VISIT(st, expr, lc->target); VISIT(st, expr, lc->iter); From montanaro at users.sourceforge.net Sun Jan 16 20:31:48 2005 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Sun Jan 16 20:31:51 2005 Subject: [Python-checkins] python/dist/src/Lib reconvert.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9436 Modified Files: reconvert.py Log Message: allow triple-quoted string output from reconvert.quote() Index: reconvert.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/reconvert.py,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- reconvert.py 6 Apr 2004 19:42:34 -0000 1.7 +++ reconvert.py 16 Jan 2005 19:31:40 -0000 1.8 @@ -166,7 +166,7 @@ if q in s and altq not in s: q = altq else: - assert quote in ('"', "'") + assert quote in ('"', "'", '"""', "'''") q = quote res = q for c in s: From montanaro at users.sourceforge.net Sun Jan 16 21:48:30 2005 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Sun Jan 16 21:48:34 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1227,1.1228 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24099/Misc Modified Files: NEWS Log Message: Document the reconvert module. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1227 retrieving revision 1.1228 diff -u -d -r1.1227 -r1.1228 --- NEWS 16 Jan 2005 08:57:28 -0000 1.1227 +++ NEWS 16 Jan 2005 20:48:24 -0000 1.1228 @@ -124,6 +124,8 @@ - Bug #1083110: ``zlib.decompress.flush()`` would segfault if called immediately after creating the object, without any intervening ``.decompress()`` calls. +- The reconvert.quote function can now emit triple-quoted strings. The + reconvert module now has some simple documentation. Build ----- From montanaro at users.sourceforge.net Sun Jan 16 21:48:31 2005 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Sun Jan 16 21:48:35 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libreconvert.tex, NONE, 1.1 lib.tex, 1.234, 1.235 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24099/Doc/lib Modified Files: lib.tex Added Files: libreconvert.tex Log Message: Document the reconvert module. --- NEW FILE: libreconvert.tex --- \section{\module{reconvert} --- Convert regular expressions from regex to re form} \declaremodule{standard}{reconvert} \moduleauthor{Andrew M. Kuchling}{amk@amk.ca} \sectionauthor{Skip Montanaro}{skip@pobox.com} \modulesynopsis{Convert regex-, emacs- or sed-style regular expressions to re-style syntax.} This module provides a facility to convert regular expressions from the syntax used by the deprecated \module{regex} module to those used by the newer \module{re} module. Because of similarity between the regular expression syntax of \code{sed(1)} and \code{emacs(1)} and the \module{regex} module, it is also helpful to convert patterns written for those tools to \module{re} patterns. When used as a script, a Python string literal (or any other expression evaluating to a string) is read from stdin, and the translated expression is written to stdout as a string literal. Unless stdout is a tty, no trailing newline is written to stdout. This is done so that it can be used with Emacs \code{C-U M-|} (shell-command-on-region) which filters the region through the shell command. \begin{seealso} \seetitle{Mastering Regular Expressions}{Book on regular expressions by Jeffrey Friedl, published by O'Reilly. The second edition of the book no longer covers Python at all, but the first edition covered writing good regular expression patterns in great detail.} \end{seealso} \subsection{Module Contents} \nodename{Contents of Module reconvert} The module defines two functions and a handful of constants. \begin{funcdesc}{convert}{pattern\optional{, syntax=None}} Convert a \var{pattern} representing a \module{regex}-stype regular expression into a \module{re}-style regular expression. The optional \var{syntax} parameter is a bitwise-or'd set of flags that control what constructs are converted. See below for a description of the various constants. \end{funcdesc} \begin{funcdesc}{quote}{s\optional{, quote=None}} Convert a string object to a quoted string literal. This is similar to \function{repr} but will return a "raw" string (r'...' or r"...") when the string contains backslashes, instead of doubling all backslashes. The resulting string does not always evaluate to the same string as the original; however it will do just the right thing when passed into re.compile(). The optional second argument forces the string quote; it must be a single character which is a valid Python string quote. Note that prior to Python 2.5 this would not accept triple-quoted string delimiters. \end{funcdesc} \begin{datadesc}{RE_NO_BK_PARENS} Suppress paren conversion. This should be omitted when converting \code{sed}-style or \code{emacs}-style regular expressions. \end{datadesc} \begin{datadesc}{RE_NO_BK_VBAR} Suppress vertical bar conversion. This should be omitted when converting \code{sed}-style or \code{emacs}-style regular expressions. \end{datadesc} \begin{datadesc}{RE_BK_PLUS_QM} Enable conversion of \code{+} and \code{?} characters. This should be added to the \var{syntax} arg of \function{convert} when converting \code{sed}-style regular expressions and omitted when converting \code{emacs}-style regular expressions. \end{datadesc} \begin{datadesc}{RE_NEWLINE_OR} When set, newline characters are replaced by \code{|}. \end{datadesc} Index: lib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/lib.tex,v retrieving revision 1.234 retrieving revision 1.235 diff -u -d -r1.234 -r1.235 --- lib.tex 6 Dec 2004 12:29:56 -0000 1.234 +++ lib.tex 16 Jan 2005 20:48:27 -0000 1.235 @@ -106,6 +106,7 @@ \input{libstrings} % String Services \input{libstring} \input{libre} +\input{libreconvert} \input{libstruct} \input{libdifflib} \input{libfpformat} From aimacintyre at users.sourceforge.net Mon Jan 17 13:16:38 2005 From: aimacintyre at users.sourceforge.net (aimacintyre@users.sourceforge.net) Date: Mon Jan 17 13:16:42 2005 Subject: [Python-checkins] python/dist/src/Python thread_os2.h,2.16,2.17 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4649 Modified Files: thread_os2.h Log Message: make thread stack size compile-time tunable on OS/2 Index: thread_os2.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_os2.h,v retrieving revision 2.16 retrieving revision 2.17 diff -u -d -r2.16 -r2.17 --- thread_os2.h 4 Dec 2002 12:29:37 -0000 2.16 +++ thread_os2.h 17 Jan 2005 12:16:36 -0000 2.17 @@ -14,6 +14,10 @@ long PyThread_get_thread_ident(void); #endif +#if !defined(THREAD_STACK_SIZE) +#define THREAD_STACK_SIZE 0x10000 +#endif + /* * Initialization of the C package, should not be needed. */ @@ -31,7 +35,7 @@ int aThread; int success = 0; - aThread = _beginthread(func,NULL,65536,arg); + aThread = _beginthread(func, NULL, THREAD_STACK_SIZE, arg); if (aThread == -1) { success = -1; From aimacintyre at users.sourceforge.net Mon Jan 17 13:18:15 2005 From: aimacintyre at users.sourceforge.net (aimacintyre@users.sourceforge.net) Date: Mon Jan 17 13:18:19 2005 Subject: [Python-checkins] python/dist/src/PC/os2emx Makefile,1.18,1.19 Message-ID: Update of /cvsroot/python/python/dist/src/PC/os2emx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5005 Modified Files: Makefile Log Message: make thread stack size compile-time tunable on OS/2, increase main stack Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/os2emx/Makefile,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- Makefile 3 Oct 2004 08:11:29 -0000 1.18 +++ Makefile 17 Jan 2005 12:18:12 -0000 1.19 @@ -129,10 +129,26 @@ AR= ar endif + +# === Build time resource settings === + # EMX's default number of file handles is 40, which is sometimes insufficient # (the tempfile regression test tries to create 100 temporary files) NFILES=250 +# The default stack size for child threads is 64k bytes, which is +# insufficient for some applications which do a lot of work in threads +# (such as Zope, especially in conjunction with Plone). +# Note that this setting is distinct from the stack size for the main +# thread, which is set via the %.def rule below. +# EMX documents that the thread stack size should be at least 32768 bytes; +# for Zope/Plone at least 128k bytes is recommended. +# Uncomment & adjust the next line to override the default stack size: +#CFLAGS+= -DTHREAD_STACK_SIZE=0x20000 + + +# === The environment === + # Source file paths SRCPATH=.;../../Python;../../Parser;../../Objects;../../Include;../../Modules # Python contains the central core, containing the builtins and interpreter. @@ -215,7 +231,7 @@ @echo Creating .DEF file: $@ @echo NAME $(notdir $*) $(EXETYPE.$(notdir $*).exe) >$@ @echo DESCRIPTION $(DQUOTE)$(DESCRIPTION.$(notdir $*).exe)$(DQUOTE) >>$@ - @echo STACKSIZE 1572864 >>$@ + @echo STACKSIZE 2097152 >>$@ # Output file names PYTHON_VER= 2.4 From aimacintyre at users.sourceforge.net Mon Jan 17 13:19:26 2005 From: aimacintyre at users.sourceforge.net (aimacintyre@users.sourceforge.net) Date: Mon Jan 17 13:19:29 2005 Subject: [Python-checkins] python/dist/src/Python thread_os2.h, 2.16, 2.16.18.1 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5367 Modified Files: Tag: release24-maint thread_os2.h Log Message: make thread stack size compile-time tunable on OS/2 Index: thread_os2.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_os2.h,v retrieving revision 2.16 retrieving revision 2.16.18.1 diff -u -d -r2.16 -r2.16.18.1 --- thread_os2.h 4 Dec 2002 12:29:37 -0000 2.16 +++ thread_os2.h 17 Jan 2005 12:19:24 -0000 2.16.18.1 @@ -14,6 +14,10 @@ long PyThread_get_thread_ident(void); #endif +#if !defined(THREAD_STACK_SIZE) +#define THREAD_STACK_SIZE 0x10000 +#endif + /* * Initialization of the C package, should not be needed. */ @@ -31,7 +35,7 @@ int aThread; int success = 0; - aThread = _beginthread(func,NULL,65536,arg); + aThread = _beginthread(func, NULL, THREAD_STACK_SIZE, arg); if (aThread == -1) { success = -1; From aimacintyre at users.sourceforge.net Mon Jan 17 13:20:35 2005 From: aimacintyre at users.sourceforge.net (aimacintyre@users.sourceforge.net) Date: Mon Jan 17 13:20:38 2005 Subject: [Python-checkins] python/dist/src/PC/os2emx Makefile,1.18,1.18.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/PC/os2emx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5588 Modified Files: Tag: release24-maint Makefile Log Message: backport: make thread stack size compile-time tunable on OS/2, incr main stack Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/os2emx/Makefile,v retrieving revision 1.18 retrieving revision 1.18.2.1 diff -u -d -r1.18 -r1.18.2.1 --- Makefile 3 Oct 2004 08:11:29 -0000 1.18 +++ Makefile 17 Jan 2005 12:20:31 -0000 1.18.2.1 @@ -129,10 +129,26 @@ AR= ar endif + +# === Build time resource settings === + # EMX's default number of file handles is 40, which is sometimes insufficient # (the tempfile regression test tries to create 100 temporary files) NFILES=250 +# The default stack size for child threads is 64k bytes, which is +# insufficient for some applications which do a lot of work in threads +# (such as Zope, especially in conjunction with Plone). +# Note that this setting is distinct from the stack size for the main +# thread, which is set via the %.def rule below. +# EMX documents that the thread stack size should be at least 32768 bytes; +# for Zope/Plone at least 128k bytes is recommended. +# Uncomment & adjust the next line to override the default stack size: +#CFLAGS+= -DTHREAD_STACK_SIZE=0x20000 + + +# === The environment === + # Source file paths SRCPATH=.;../../Python;../../Parser;../../Objects;../../Include;../../Modules # Python contains the central core, containing the builtins and interpreter. @@ -215,7 +231,7 @@ @echo Creating .DEF file: $@ @echo NAME $(notdir $*) $(EXETYPE.$(notdir $*).exe) >$@ @echo DESCRIPTION $(DQUOTE)$(DESCRIPTION.$(notdir $*).exe)$(DQUOTE) >>$@ - @echo STACKSIZE 1572864 >>$@ + @echo STACKSIZE 2097152 >>$@ # Output file names PYTHON_VER= 2.4 From aimacintyre at users.sourceforge.net Mon Jan 17 13:21:47 2005 From: aimacintyre at users.sourceforge.net (aimacintyre@users.sourceforge.net) Date: Mon Jan 17 13:21:52 2005 Subject: [Python-checkins] python/dist/src/Python thread_os2.h, 2.16, 2.16.14.1 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5801 Modified Files: Tag: release23-maint thread_os2.h Log Message: backport: make thread stack size compile-time tunable on OS/2 Index: thread_os2.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_os2.h,v retrieving revision 2.16 retrieving revision 2.16.14.1 diff -u -d -r2.16 -r2.16.14.1 --- thread_os2.h 4 Dec 2002 12:29:37 -0000 2.16 +++ thread_os2.h 17 Jan 2005 12:21:28 -0000 2.16.14.1 @@ -14,6 +14,10 @@ long PyThread_get_thread_ident(void); #endif +#if !defined(THREAD_STACK_SIZE) +#define THREAD_STACK_SIZE 0x10000 +#endif + /* * Initialization of the C package, should not be needed. */ @@ -31,7 +35,7 @@ int aThread; int success = 0; - aThread = _beginthread(func,NULL,65536,arg); + aThread = _beginthread(func, NULL, THREAD_STACK_SIZE, arg); if (aThread == -1) { success = -1; From aimacintyre at users.sourceforge.net Mon Jan 17 13:22:41 2005 From: aimacintyre at users.sourceforge.net (aimacintyre@users.sourceforge.net) Date: Mon Jan 17 13:22:44 2005 Subject: [Python-checkins] python/dist/src/PC/os2emx Makefile, 1.14.6.2, 1.14.6.3 Message-ID: Update of /cvsroot/python/python/dist/src/PC/os2emx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6081 Modified Files: Tag: release23-maint Makefile Log Message: backport: make thread stack size compile-time tunable on OS/2, incr main stack Index: Makefile =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/os2emx/Makefile,v retrieving revision 1.14.6.2 retrieving revision 1.14.6.3 diff -u -d -r1.14.6.2 -r1.14.6.3 --- Makefile 20 Feb 2004 12:00:06 -0000 1.14.6.2 +++ Makefile 17 Jan 2005 12:22:38 -0000 1.14.6.3 @@ -131,10 +131,26 @@ AR= ar endif + +# === Build time resource settings === + # EMX's default number of file handles is 40, which is sometimes insufficient # (the tempfile regression test tries to create 100 temporary files) NFILES=250 +# The default stack size for child threads is 64k bytes, which is +# insufficient for some applications which do a lot of work in threads +# (such as Zope, especially in conjunction with Plone). +# Note that this setting is distinct from the stack size for the main +# thread, which is set via the %.def rule below. +# EMX documents that the thread stack size should be at least 32768 bytes; +# for Zope/Plone at least 128k bytes is recommended. +# Uncomment & adjust the next line to override the default stack size: +#CFLAGS+= -DTHREAD_STACK_SIZE=0x20000 + + +# === The environment === + # Source file paths SRCPATH=.;../../Python;../../Parser;../../Objects;../../Include;../../Modules # Python contains the central core, containing the builtins and interpreter. @@ -217,7 +233,7 @@ @echo Creating .DEF file: $@ @echo NAME $(notdir $*) $(EXETYPE.$(notdir $*).exe) >$@ @echo DESCRIPTION $(DQUOTE)$(DESCRIPTION.$(notdir $*).exe)$(DQUOTE) >>$@ - @echo STACKSIZE 1572864 >>$@ + @echo STACKSIZE 2097152 >>$@ # Output file names PYTHON_VER= 2.3 From aimacintyre at users.sourceforge.net Mon Jan 17 14:06:35 2005 From: aimacintyre at users.sourceforge.net (aimacintyre@users.sourceforge.net) Date: Mon Jan 17 14:06:38 2005 Subject: [Python-checkins] python/dist/src/PC/os2emx README.os2emx, 1.7.6.2, 1.7.6.3 Message-ID: Update of /cvsroot/python/python/dist/src/PC/os2emx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14732 Modified Files: Tag: release23-maint README.os2emx Log Message: update in readiness for 2.3.5 release Index: README.os2emx =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/os2emx/README.os2emx,v retrieving revision 1.7.6.2 retrieving revision 1.7.6.3 diff -u -d -r1.7.6.2 -r1.7.6.3 --- README.os2emx 11 Apr 2004 12:13:53 -0000 1.7.6.2 +++ README.os2emx 17 Jan 2005 13:06:27 -0000 1.7.6.3 @@ -1,24 +1,20 @@ -This is a port of Python 2.3.4 to OS/2 using the EMX development tools +This is a port of Python 2.3.5 to OS/2 using the EMX development tools ========================================================================= What's new since the previous release ------------------------------------- -- AF_UNIX (Unix domain, or local IPC) sockets now supported. -- a core-dump causing bug associated with file buffers has been - fixed. -- added support for os.spawnvp(), os.spawnvpe(), os.spawnlp() - and os.spawnlpe(). +- thread stack size is now a compile-time tunable Licenses and info about Python and EMX -------------------------------------- -Please read the file README.Python-2.3.3 included in this package for -information about Python 2.3.3. This file is the README file from the -Python 2.3.3 source distribution available via http://www.python.org/ -and its mirrors. The file LICENCE.Python-2.3.3 is the text of the Licence -from the Python 2.3.3 source distribution. +Please read the file README.Python-2.3.5 included in this package for +information about Python 2.3.5. This file is the README file from the +Python 2.3.5 source distribution available via http://www.python.org/ +and its mirrors. The file LICENCE.Python-2.3.5 is the text of the Licence +from the Python 2.3.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 @@ -80,7 +76,7 @@ - GNU Readline (Kai Uwe Rommel's port available from Hobbes or LEO, v2.1) - GNU GDBM (Kai Uwe Rommel's port available from Hobbes or LEO, v1.7.3) - zlib (derived from Hung-Chi Chu's port of v1.1.3, v1.1.4) -- expat (distributed with Python, v1.95.6) +- expat (distributed with Python, v1.95.7) - GNU MP (Peter Meerwald's port available from LEO, v2.0.2) - GNU UFC (Kai Uwe Rommel's port available from LEO, v2.0.4) @@ -153,7 +149,7 @@ Upstream source patches: -No updates to the Python 2.3.3 release have become available. +No updates to the Python 2.3.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 @@ -162,7 +158,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.3.3 source distribution is included +library code included with the Python 2.3.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 @@ -177,7 +173,7 @@ also been omitted. All subdirectories omitted from the binary archive can be reconstituted -from the Python 2.3.3 source distribution, if desired. +from the Python 2.3.5 source distribution, if desired. Support for building Python extensions: @@ -195,15 +191,15 @@ --------- This port is packaged as follows: -- python-2.3.3-os2emx-bin-03????.zip (binaries, library modules) -- python-2.3.3-os2emx-src-03???? (patches+makefiles for non-Python code) +- python-2.3.5-os2emx-bin-03????.zip (binaries, library modules) +- python-2.3.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.3.3 +Documentation for the Python language, as well as the Python 2.3.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/). @@ -257,8 +253,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.3.3 source -distribution by changing to the Python 2.3.3 home directory and executing the +You can execute the regression tests included with the Python 2.3.5 source +distribution by changing to the Python 2.3.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); @@ -304,7 +300,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.3.3). + (eg /usr/local/lib/python2.3.5). If you want Python to find its library without the PYTHONHOME environment variable set, set the value of the Makefile variable @@ -642,6 +638,18 @@ - unlike Unix, the socket endpoints don't exist in the filesystem; - by default, sockets are in binary mode. +26. Threads have separate stacks from the primary thread, and the +thread stack has been hardcoded to 64k bytes. As this is insufficient +for some applications, such as Zope/Plone, the thread stack size has +been made a compile-time tunable. + +The Makefile contains a commented out statement that, when uncommented, +will set the thread stack size to 128k bytes. The value used should be +adjusted to suit the requirements. The EMX documentation indicates +that thread stack size should be at least 32768 (32k) bytes, but the +default value of 64k bytes should be considered a practical minimum. + + ... probably other issues that I've not encountered, or don't remember :-( If you encounter other difficulties with this port, which can be @@ -665,7 +673,9 @@ - the BDFL, Guido van Rossum, and crew for Python; - Dr David Mertz, for trying out a pre-release of this port; - the Python-list/comp.lang.python community; -- John Poltorak, for input about pwd/grp. +- John Poltorak, for input about pwd/grp; +- Ted Sikora & John Poltorak for persisting in bringing Mailman + Zope & Plone to OS/2. Contact ------- @@ -681,4 +691,4 @@ E-mail: andymac@bullseye.apana.org.au, or andymac@pcug.org.au Web: http://www.andymac.org/ -11 April, 2004. +17 January, 2005. From kbk at users.sourceforge.net Mon Jan 17 21:07:00 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Mon Jan 17 21:07:04 2005 Subject: [Python-checkins] python/dist/src/Lib/idlelib configHandler.py, 1.31.8.1, 1.31.8.2 NEWS.txt, 1.23.4.9, 1.23.4.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31754 Modified Files: Tag: release23-maint configHandler.py NEWS.txt Log Message: Improve error handling when .idlerc can't be created. This is a partial backport of configHandler.py, Revision 1.36, 11Jan05. Index: configHandler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/configHandler.py,v retrieving revision 1.31.8.1 retrieving revision 1.31.8.2 diff -u -d -r1.31.8.1 -r1.31.8.2 --- configHandler.py 30 Mar 2004 04:06:59 -0000 1.31.8.1 +++ configHandler.py 17 Jan 2005 20:06:47 -0000 1.31.8.2 @@ -209,10 +209,11 @@ if not os.path.exists(userDir): try: #make the config dir if it doesn't exist yet os.mkdir(userDir) - except IOError: + except (OSError, IOError): warn=('\n Warning: unable to create user config directory\n '+ userDir+'\n') sys.stderr.write(warn) + raise SystemExit return userDir def GetOption(self, configType, section, option, default=None, type=None): Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.23.4.9 retrieving revision 1.23.4.10 diff -u -d -r1.23.4.9 -r1.23.4.10 --- NEWS.txt 23 Dec 2004 04:26:55 -0000 1.23.4.9 +++ NEWS.txt 17 Jan 2005 20:06:47 -0000 1.23.4.10 @@ -1,7 +1,10 @@ What's New in IDLE 1.0.4? ========================= -*Release date: XX-Dec-2004* +*Release date: XX-Jan-2005* + +- Improve error handling when .idlerc can't be created. This is a partial + backport of configHandler.py, Revision 1.36, 11Jan05. - The GUI was hanging if the shell window was closed while a raw_input() was pending. Restored the quit() of the readline() mainloop(). From kbk at users.sourceforge.net Mon Jan 17 21:35:07 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Mon Jan 17 21:35:19 2005 Subject: [Python-checkins] python/dist/src/Lib/idlelib EditorWindow.py, 1.53.6.1, 1.53.6.2 NEWS.txt, 1.23.4.10, 1.23.4.11 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5555 Modified Files: Tag: release23-maint EditorWindow.py NEWS.txt Log Message: If an extension can't be loaded, print warning and skip it instead of erroring out. Index: EditorWindow.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/EditorWindow.py,v retrieving revision 1.53.6.1 retrieving revision 1.53.6.2 diff -u -d -r1.53.6.1 -r1.53.6.2 --- EditorWindow.py 22 Sep 2003 14:56:11 -0000 1.53.6.1 +++ EditorWindow.py 17 Jan 2005 20:34:45 -0000 1.53.6.2 @@ -770,7 +770,11 @@ return idleConf.GetExtensions() def load_extension(self, name): - mod = __import__(name, globals(), locals(), []) + try: + mod = __import__(name, globals(), locals(), []) + except ImportError: + print "\nFailed to import extension: ", name + return None cls = getattr(mod, name) ins = cls(self) self.extensions[name] = ins Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.23.4.10 retrieving revision 1.23.4.11 diff -u -d -r1.23.4.10 -r1.23.4.11 --- NEWS.txt 17 Jan 2005 20:06:47 -0000 1.23.4.10 +++ NEWS.txt 17 Jan 2005 20:34:49 -0000 1.23.4.11 @@ -3,6 +3,9 @@ *Release date: XX-Jan-2005* +- If an extension can't be loaded, print warning and skip it instead of + erroring out. + - Improve error handling when .idlerc can't be created. This is a partial backport of configHandler.py, Revision 1.36, 11Jan05. From kbk at users.sourceforge.net Mon Jan 17 22:08:37 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Mon Jan 17 22:08:41 2005 Subject: [Python-checkins] python/dist/src setup.py,1.171.6.2,1.171.6.3 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13270 Modified Files: Tag: release23-maint setup.py Log Message: Backport Patch #850977: Detect Tk on FreeBSD and OpenBSD. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.171.6.2 retrieving revision 1.171.6.3 diff -u -d -r1.171.6.2 -r1.171.6.3 --- setup.py 21 Oct 2003 20:01:21 -0000 1.171.6.2 +++ setup.py 17 Jan 2005 21:07:49 -0000 1.171.6.3 @@ -960,17 +960,25 @@ # Now check for the header files if tklib and tcllib: - # Check for the include files on Debian, where + # Check for the include files on Debian and {Free,Open}BSD, where # they're put in /usr/include/{tcl,tk}X.Y - debian_tcl_include = [ '/usr/include/tcl' + version ] - debian_tk_include = [ '/usr/include/tk' + version ] + \ - debian_tcl_include - tcl_includes = find_file('tcl.h', inc_dirs, debian_tcl_include) - tk_includes = find_file('tk.h', inc_dirs, debian_tk_include) + dotversion = version + if '.' not in dotversion and "bsd" in sys.platform.lower(): + # OpenBSD and FreeBSD use Tcl/Tk library names like libtcl83.a, + # but the include subdirs are named like .../include/tcl8.3. + dotversion = dotversion[:-1] + '.' + dotversion[-1] + tcl_include_sub = [] + tk_include_sub = [] + for dir in inc_dirs: + tcl_include_sub += [dir + os.sep + "tcl" + dotversion] + tk_include_sub += [dir + os.sep + "tk" + dotversion] + tk_include_sub += tcl_include_sub + tcl_includes = find_file('tcl.h', inc_dirs, tcl_include_sub) + tk_includes = find_file('tk.h', inc_dirs, tk_include_sub) if (tcllib is None or tklib is None or tcl_includes is None or tk_includes is None): - # Something's missing, so give up + self.announce("INFO: Can't locate Tcl/Tk libs and/or headers", 2) return # OK... everything seems to be present for Tcl/Tk. From kbk at users.sourceforge.net Mon Jan 17 22:08:56 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Mon Jan 17 22:09:02 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.161, 1.831.4.162 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13270/Misc Modified Files: Tag: release23-maint NEWS Log Message: Backport Patch #850977: Detect Tk on FreeBSD and OpenBSD. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.161 retrieving revision 1.831.4.162 diff -u -d -r1.831.4.161 -r1.831.4.162 --- NEWS 4 Jan 2005 16:07:04 -0000 1.831.4.161 +++ NEWS 17 Jan 2005 21:07:52 -0000 1.831.4.162 @@ -7,7 +7,7 @@ What's New in Python 2.3.5? =========================== -*Release date: xx-xxx-2004* +*Release date: xx-xxx-2005* Core and builtins ----------------- @@ -162,6 +162,8 @@ Build ----- +- Patch #850977: Detect Tk on FreeBSD and OpenBSD. + - Bug #1034496: Use -h instead of -soname for Solaris compatibility. - Patch #973204: Use -rpath instead of -R for runtime_library_dirs From kbk at users.sourceforge.net Tue Jan 18 01:55:18 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Tue Jan 18 01:55:22 2005 Subject: [Python-checkins] python/dist/src/Lib/idlelib EditorWindow.py, 1.63, 1.64 NEWS.txt, 1.51, 1.52 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28685 Modified Files: EditorWindow.py NEWS.txt Log Message: If an extension can't be loaded, print warning and skip it instead of erroring out. Index: EditorWindow.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/EditorWindow.py,v retrieving revision 1.63 retrieving revision 1.64 diff -u -d -r1.63 -r1.64 --- EditorWindow.py 21 Dec 2004 22:10:31 -0000 1.63 +++ EditorWindow.py 18 Jan 2005 00:54:57 -0000 1.64 @@ -744,7 +744,11 @@ return idleConf.GetExtensions(editor_only=True) def load_extension(self, name): - mod = __import__(name, globals(), locals(), []) + try: + mod = __import__(name, globals(), locals(), []) + except ImportError: + print "\nFailed to import extension: ", name + return cls = getattr(mod, name) keydefs = idleConf.GetExtensionBindings(name) if hasattr(cls, "menudefs"): @@ -762,7 +766,6 @@ methodname = methodname + "_event" if hasattr(ins, methodname): self.text.bind(vevent, getattr(ins, methodname)) - return ins def apply_bindings(self, keydefs=None): if keydefs is None: Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.51 retrieving revision 1.52 diff -u -d -r1.51 -r1.52 --- NEWS.txt 23 Dec 2004 04:20:59 -0000 1.51 +++ NEWS.txt 18 Jan 2005 00:54:58 -0000 1.52 @@ -3,6 +3,9 @@ *Release date: XX-XXX-2005* +- If an extension can't be loaded, print warning and skip it instead of + erroring out. + - The GUI was hanging if the shell window was closed while a raw_input() was pending. Restored the quit() of the readline() mainloop(). http://mail.python.org/pipermail/idle-dev/2004-December/002307.html @@ -142,7 +145,7 @@ *Release date: 29-Jul-2003* -- Added a banner to the shell discussimg warnings possibly raised by personal +- Added a banner to the shell discussing warnings possibly raised by personal firewall software. Added same comment to README.txt. From mwh at users.sourceforge.net Tue Jan 18 16:26:15 2005 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue Jan 18 16:26:18 2005 Subject: [Python-checkins] python/dist/src/Python errors.c,2.82,2.83 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29391 Modified Files: errors.c Log Message: -X died some time ago; remove a tiny bit of associated cruft. Index: errors.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/errors.c,v retrieving revision 2.82 retrieving revision 2.83 diff -u -d -r2.82 -r2.83 --- errors.c 24 Mar 2004 22:22:11 -0000 2.82 +++ errors.c 18 Jan 2005 15:26:11 -0000 2.83 @@ -535,10 +535,6 @@ } if (base == NULL) base = PyExc_Exception; - if (!PyClass_Check(base)) { - /* Must be using string-based standard exceptions (-X) */ - return PyString_FromString(name); - } if (dict == NULL) { dict = mydict = PyDict_New(); if (dict == NULL) From mwh at users.sourceforge.net Tue Jan 18 16:54:03 2005 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue Jan 18 16:54:07 2005 Subject: [Python-checkins] python/dist/src/Misc SpecialBuilds.txt,1.16,1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3791/Misc Modified Files: SpecialBuilds.txt Log Message: tweaks, small updates Index: SpecialBuilds.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/SpecialBuilds.txt,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- SpecialBuilds.txt 12 Aug 2004 18:19:17 -0000 1.16 +++ SpecialBuilds.txt 18 Jan 2005 15:53:59 -0000 1.17 @@ -207,14 +207,14 @@ --------------------------------------------------------------------------- LLTRACE introduced well before 1.0 -Compile in support of Low Level TRACE-ing of the main interpreter loop. +Compile in support for Low Level TRACE-ing of the main interpreter loop. -When this preprocessor symbol is defined, before eval_frame -(eval_code2 before 2.2) executes a frame's code it checks the frame's -global namespace for a variable "__lltrace__". If such a variable is -found, mounds of information about what the interpreter is doing are -sprayed to stdout, such as every opcode and opcode argument and values -pushed onto and popped off the value stack. +When this preprocessor symbol is defined, before PyEval_EvalFrame +(eval_frame in 2.3 and 2.2, eval_code2 before that) executes a frame's code +it checks the frame's global namespace for a variable "__lltrace__". If +such a variable is found, mounds of information about what the interpreter +is doing are sprayed to stdout, such as every opcode and opcode argument +and values pushed onto and popped off the value stack. Not useful very often, but very useful when needed. @@ -245,8 +245,8 @@ On the PowerPC the rate at which the time base register is incremented is not defined by the architecture specification, so you'll need to -find the manual for your specific processor. For the 750CX, 750CXe, -750FX (all sold as the G3) we find: +find the manual for your specific processor. For the 750CX, 750CXe +and 750FX (all sold as the G3) we find: The time base counter is clocked at a frequency that is one-fourth that of the bus clock. From mwh at users.sourceforge.net Tue Jan 18 16:56:19 2005 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Tue Jan 18 16:56:22 2005 Subject: [Python-checkins] python/dist/src/Python ceval.c,2.420,2.421 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4034/Python Modified Files: ceval.c Log Message: Change the name of the macro used by --with-tsc builds to the less inscrutable READ_TIMESTAMP. Index: ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.420 retrieving revision 2.421 diff -u -d -r2.420 -r2.421 --- ceval.c 8 Jan 2005 21:58:58 -0000 2.420 +++ ceval.c 18 Jan 2005 15:56:11 -0000 2.421 @@ -17,8 +17,10 @@ #include #ifndef WITH_TSC -#define rdtscll(var) -#else /*WITH_TSC defined*/ + +#define READ_TIMESTAMP(var) + +#else typedef unsigned long long uint64; @@ -26,7 +28,7 @@ section should work for GCC on any PowerPC platform, irrespective of OS. POWER? Who knows :-) */ -#define rdtscll(var) ppc_getcounter(&var) +#define READ_TIMESTAMP(var) ppc_getcounter(&var) static void ppc_getcounter(uint64 *v) @@ -45,9 +47,10 @@ ((long*)(v))[1] = tb; } -#else /* this section is for linux/x86 */ +#else /* this is for linux/x86 (and probably any other GCC/x86 combo) */ -#include +#define READ_TIMESTAMP(val) \ + __asm__ __volatile__("rdtsc" : "=A" (val)) #endif @@ -575,10 +578,10 @@ uint64 inst0, inst1, loop0, loop1, intr0 = 0, intr1 = 0; int ticked = 0; - rdtscll(inst0); - rdtscll(inst1); - rdtscll(loop0); - rdtscll(loop1); + READ_TIMESTAMP(inst0); + READ_TIMESTAMP(inst1); + READ_TIMESTAMP(loop0); + READ_TIMESTAMP(loop1); /* shut up the compiler */ opcode = 0; @@ -748,7 +751,7 @@ or a continue, preventing inst1 from being set on the way out of the loop. */ - rdtscll(inst1); + READ_TIMESTAMP(inst1); loop1 = inst1; } dump_tsc(opcode, ticked, inst0, inst1, loop0, loop1, @@ -757,7 +760,7 @@ inst1 = 0; intr0 = 0; intr1 = 0; - rdtscll(loop0); + READ_TIMESTAMP(loop0); #endif assert(stack_pointer >= f->f_valuestack); /* else underflow */ assert(STACK_LEVEL() <= f->f_stacksize); /* else overflow */ @@ -879,7 +882,7 @@ #endif /* Main switch on opcode */ - rdtscll(inst0); + READ_TIMESTAMP(inst0); switch (opcode) { @@ -1638,9 +1641,9 @@ v = SECOND(); u = THIRD(); STACKADJ(-3); - rdtscll(intr0); + READ_TIMESTAMP(intr0); err = exec_statement(f, u, v, w); - rdtscll(intr1); + READ_TIMESTAMP(intr1); Py_DECREF(u); Py_DECREF(v); Py_DECREF(w); @@ -2016,9 +2019,9 @@ x = NULL; break; } - rdtscll(intr0); + READ_TIMESTAMP(intr0); x = PyEval_CallObject(x, w); - rdtscll(intr1); + READ_TIMESTAMP(intr1); Py_DECREF(w); SET_TOP(x); if (x != NULL) continue; @@ -2032,9 +2035,9 @@ "no locals found during 'import *'"); break; } - rdtscll(intr0); + READ_TIMESTAMP(intr0); err = import_all_from(x, v); - rdtscll(intr1); + READ_TIMESTAMP(intr1); PyFrame_LocalsToFast(f, 0); Py_DECREF(v); if (err == 0) continue; @@ -2043,9 +2046,9 @@ case IMPORT_FROM: w = GETITEM(names, oparg); v = TOP(); - rdtscll(intr0); + READ_TIMESTAMP(intr0); x = import_from(v, w); - rdtscll(intr1); + READ_TIMESTAMP(intr1); PUSH(x); if (x != NULL) continue; break; @@ -2199,9 +2202,9 @@ } else Py_INCREF(func); sp = stack_pointer; - rdtscll(intr0); + READ_TIMESTAMP(intr0); x = ext_do_call(func, &sp, flags, na, nk); - rdtscll(intr1); + READ_TIMESTAMP(intr1); stack_pointer = sp; Py_DECREF(func); @@ -2314,7 +2317,7 @@ on_error: - rdtscll(inst1); + READ_TIMESTAMP(inst1); /* Quickly continue if no error occurred */ @@ -2327,7 +2330,7 @@ "XXX undetected error\n"); else { #endif - rdtscll(loop1); + READ_TIMESTAMP(loop1); continue; /* Normal, fast path */ #ifdef CHECKEXC } @@ -2446,7 +2449,7 @@ if (why != WHY_NOT) break; - rdtscll(loop1); + READ_TIMESTAMP(loop1); } /* main loop */ @@ -3543,9 +3546,9 @@ else { PyObject *callargs; callargs = load_args(pp_stack, na); - rdtscll(*pintr0); + READ_TIMESTAMP(*pintr0); C_TRACE(x=PyCFunction_Call(func,callargs,NULL)); - rdtscll(*pintr1); + READ_TIMESTAMP(*pintr1); Py_XDECREF(callargs); } } else { @@ -3563,12 +3566,12 @@ n++; } else Py_INCREF(func); - rdtscll(*pintr0); + READ_TIMESTAMP(*pintr0); if (PyFunction_Check(func)) x = fast_function(func, pp_stack, n, na, nk); else x = do_call(func, pp_stack, na, nk); - rdtscll(*pintr1); + READ_TIMESTAMP(*pintr1); Py_DECREF(func); } From kbk at users.sourceforge.net Wed Jan 19 01:23:19 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Wed Jan 19 01:23:24 2005 Subject: [Python-checkins] python/dist/src/Lib/idlelib EditorWindow.py, 1.64, 1.65 NEWS.txt, 1.52, 1.53 PyShell.py, 1.94, 1.95 ScriptBinding.py, 1.28, 1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15261 Modified Files: EditorWindow.py NEWS.txt PyShell.py ScriptBinding.py Log Message: 1. Polish tabbing code. 2. Restore use of set_indentation_params(), was dead code since Autoindent.py was merged into EditorWindow.py. 3. Make usetabs, indentwidth, tabwidth, context_use_ps1 instance vars and set in EditorWindow.__init__() 4. In PyShell.__init__() set usetabs, indentwidth and context_use_ps1 explicitly (config() is eliminated). 5. Add Tabnanny check when Module is Run/F5, not just when Checked. 6. Discourage using an indent width other than 8 when using tabs to indent Python code. M EditorWindow.py M NEWS.txt M PyShell.py M ScriptBinding.py Index: EditorWindow.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/EditorWindow.py,v retrieving revision 1.64 retrieving revision 1.65 diff -u -d -r1.64 -r1.65 --- EditorWindow.py 18 Jan 2005 00:54:57 -0000 1.64 +++ EditorWindow.py 19 Jan 2005 00:22:54 -0000 1.65 @@ -165,6 +165,38 @@ text.pack(side=TOP, fill=BOTH, expand=1) text.focus_set() + # usetabs true -> literal tab characters are used by indent and + # dedent cmds, possibly mixed with spaces if + # indentwidth is not a multiple of tabwidth, + # which will cause Tabnanny to nag! + # false -> tab characters are converted to spaces by indent + # and dedent cmds, and ditto TAB keystrokes + self.usetabs = False + + # indentwidth is the number of characters per logical indent level. + # Recommended Python default indent is four spaces. + self.indentwidth = 4 + + # tabwidth is the display width of a literal tab character. + # CAUTION: telling Tk to use anything other than its default + # tab setting causes it to use an entirely different tabbing algorithm, + # treating tab stops as fixed distances from the left margin. + # Nobody expects this, so for now tabwidth should never be changed. + self.tabwidth = 8 # for IDLE use, must remain 8 until Tk is fixed. + # indentwidth should be 8 when usetabs is True. + + # If context_use_ps1 is true, parsing searches back for a ps1 line; + # else searches for a popular (if, def, ...) Python stmt. + self.context_use_ps1 = False + + # When searching backwards for a reliable place to begin parsing, + # first start num_context_lines[0] lines back, then + # num_context_lines[1] lines back if that didn't work, and so on. + # The last value should be huge (larger than the # of lines in a + # conceivable file). + # Making the initial values larger slows things down more often. + self.num_context_lines = 50, 500, 5000000 + self.per = per = self.Percolator(text) if self.ispythonsource(filename): self.color = color = self.ColorDelegator() @@ -196,6 +228,8 @@ io.set_filename(filename) self.saved_change_hook() + self.set_indentation_params(self.ispythonsource(filename)) + self.load_extensions() menu = self.menudict.get('windows') @@ -214,10 +248,6 @@ self.askinteger = tkSimpleDialog.askinteger self.showerror = tkMessageBox.showerror - if self.extensions.has_key('AutoIndent'): - self.extensions['AutoIndent'].set_indentation_params( - self.ispythonsource(filename)) - def new_callback(self, event): dirname, basename = self.io.defaultfilename() self.flist.new(dirname) @@ -881,62 +911,19 @@ "n" * newtabwidth) text.configure(tabs=pixels) -### begin autoindent code ### - - # usetabs true -> literal tab characters are used by indent and - # dedent cmds, possibly mixed with spaces if - # indentwidth is not a multiple of tabwidth - # false -> tab characters are converted to spaces by indent - # and dedent cmds, and ditto TAB keystrokes - # indentwidth is the number of characters per logical indent level. - # tabwidth is the display width of a literal tab character. - # CAUTION: telling Tk to use anything other than its default - # tab setting causes it to use an entirely different tabbing algorithm, - # treating tab stops as fixed distances from the left margin. - # Nobody expects this, so for now tabwidth should never be changed. - usetabs = 0 - indentwidth = 4 - tabwidth = 8 # for IDLE use, must remain 8 until Tk is fixed - - # If context_use_ps1 is true, parsing searches back for a ps1 line; - # else searches for a popular (if, def, ...) Python stmt. - context_use_ps1 = 0 - - # When searching backwards for a reliable place to begin parsing, - # first start num_context_lines[0] lines back, then - # num_context_lines[1] lines back if that didn't work, and so on. - # The last value should be huge (larger than the # of lines in a - # conceivable file). - # Making the initial values larger slows things down more often. - num_context_lines = 50, 500, 5000000 - - def config(self, **options): - for key, value in options.items(): - if key == 'usetabs': - self.usetabs = value - elif key == 'indentwidth': - self.indentwidth = value - elif key == 'tabwidth': - self.tabwidth = value - elif key == 'context_use_ps1': - self.context_use_ps1 = value - else: - raise KeyError, "bad option name: %r" % (key,) - # If ispythonsource and guess are true, guess a good value for # indentwidth based on file content (if possible), and if # indentwidth != tabwidth set usetabs false. # In any case, adjust the Text widget's view of what a tab # character means. - def set_indentation_params(self, ispythonsource, guess=1): + def set_indentation_params(self, ispythonsource, guess=True): if guess and ispythonsource: i = self.guess_indent() if 2 <= i <= 8: self.indentwidth = i if self.indentwidth != self.tabwidth: - self.usetabs = 0 - + self.usetabs = False self.set_tabwidth(self.tabwidth) def smart_backspace_event(self, event): @@ -988,8 +975,9 @@ # if intraline selection: # delete it # elif multiline selection: - # do indent-region & return - # indent one level + # do indent-region + # else: + # indent one level text = self.text first, last = self.get_selection_indices() text.undo_block_start() @@ -1005,6 +993,7 @@ # only whitespace to the left self.reindent_to(effective + self.indentwidth) else: + # tab to the next 'stop' within or to right of line's text: if self.usetabs: pad = '\t' else: @@ -1178,28 +1167,34 @@ def toggle_tabs_event(self, event): if self.askyesno( "Toggle tabs", - "Turn tabs " + ("on", "off")[self.usetabs] + "?", + "Turn tabs " + ("on", "off")[self.usetabs] + + "?\nIndent width " + + ("will be", "remains at")[self.usetabs] + " 8.", parent=self.text): self.usetabs = not self.usetabs + # Try to prevent mixed tabs/spaces. + # User must reset indent width manually after using tabs + # if he insists on getting into trouble. + self.indentwidth = 8 return "break" - # XXX this isn't bound to anything -- see class tabwidth comments - def change_tabwidth_event(self, event): - new = self._asktabwidth() - if new != self.tabwidth: - self.tabwidth = new - self.set_indentation_params(0, guess=0) - return "break" + # XXX this isn't bound to anything -- see tabwidth comments +## def change_tabwidth_event(self, event): +## new = self._asktabwidth() +## if new != self.tabwidth: +## self.tabwidth = new +## self.set_indentation_params(0, guess=0) +## return "break" def change_indentwidth_event(self, event): new = self.askinteger( "Indent width", - "New indent width (2-16)", + "New indent width (2-16)\n(Always use 8 when using tabs)", parent=self.text, initialvalue=self.indentwidth, minvalue=2, maxvalue=16) - if new and new != self.indentwidth: + if new and new != self.indentwidth and not self.usetabs: self.indentwidth = new return "break" Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.52 retrieving revision 1.53 diff -u -d -r1.52 -r1.53 --- NEWS.txt 18 Jan 2005 00:54:58 -0000 1.52 +++ NEWS.txt 19 Jan 2005 00:22:57 -0000 1.53 @@ -3,6 +3,14 @@ *Release date: XX-XXX-2005* +- Discourage using an indent width other than 8 when using tabs to indent + Python code. + +- Restore use of EditorWindow.set_indentation_params(), was dead code since + Autoindent was merged into EditorWindow. + +- Add Tabnanny check before Run/F5, not just when Checking module. + - If an extension can't be loaded, print warning and skip it instead of erroring out. Index: PyShell.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/PyShell.py,v retrieving revision 1.94 retrieving revision 1.95 diff -u -d -r1.94 -r1.95 --- PyShell.py 23 Dec 2004 04:20:59 -0000 1.94 +++ PyShell.py 19 Jan 2005 00:22:58 -0000 1.95 @@ -795,7 +795,11 @@ import __builtin__ __builtin__.quit = __builtin__.exit = "To exit, type Ctrl-D." # - self.config(usetabs=1, indentwidth=8, context_use_ps1=1) +## self.config(usetabs=1, indentwidth=8, context_use_ps1=1) + self.usetabs = True + # indentwidth must be 8 when using tabs. See note in EditorWindow: + self.indentwidth = 8 + self.context_use_ps1 = True # text = self.text text.configure(wrap="char") Index: ScriptBinding.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/ScriptBinding.py,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- ScriptBinding.py 4 Jul 2004 01:25:56 -0000 1.28 +++ ScriptBinding.py 19 Jan 2005 00:22:59 -0000 1.29 @@ -138,6 +138,8 @@ filename = self.getfilename() if not filename: return + if not self.tabnanny(filename): + return code = self.checksyntax(filename) if not code: return From kbk at users.sourceforge.net Wed Jan 19 02:44:12 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Wed Jan 19 02:44:16 2005 Subject: [Python-checkins] python/dist/src/Lib/idlelib NEWS.txt, 1.23.4.11, 1.23.4.12 idlever.py, 1.15.4.5, 1.15.4.6 rpc.py, 1.26, 1.26.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32372 Modified Files: Tag: release23-maint NEWS.txt idlever.py rpc.py Log Message: Backport rpc.py rev 1.28 dating from 21Jan04 rpc.py:SocketIO - Large modules were generating large pickles when downloaded to the execution server. The return of the OK response from the subprocess initialization was interfering and causing the sending socket to be not ready. Add an IO ready test to fix this. Moved the polling IO ready test into pollpacket(). Fix typo in rpc.py, s/b "pickle.PicklingError" not "pickle.UnpicklingError". idlever.py should be 1.0.4 to align with NEWS.txt. There was no IDLE release at 2.3.1 which accounts for the unsync. M NEWS.txt M idlever.py M rpc.py Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.23.4.11 retrieving revision 1.23.4.12 diff -u -d -r1.23.4.11 -r1.23.4.12 --- NEWS.txt 17 Jan 2005 20:34:49 -0000 1.23.4.11 +++ NEWS.txt 19 Jan 2005 01:44:06 -0000 1.23.4.12 @@ -3,6 +3,14 @@ *Release date: XX-Jan-2005* +- rpc.py:SocketIO - Large modules were generating large pickles when downloaded + to the execution server. The return of the OK response from the subprocess + initialization was interfering and causing the sending socket to be not + ready. Add an IO ready test to fix this. Moved the polling IO ready test + into pollpacket(). (Backporting rpc.py rev 1.28 21Jan04) + +- Fix typo in rpc.py, s/b "pickle.PicklingError" not "pickle.UnpicklingError". + - If an extension can't be loaded, print warning and skip it instead of erroring out. Index: idlever.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/idlever.py,v retrieving revision 1.15.4.5 retrieving revision 1.15.4.6 diff -u -d -r1.15.4.5 -r1.15.4.6 --- idlever.py 23 Dec 2004 04:33:50 -0000 1.15.4.5 +++ idlever.py 19 Jan 2005 01:44:06 -0000 1.15.4.6 @@ -1 +1 @@ -IDLE_VERSION = "1.0.5" +IDLE_VERSION = "1.0.4" Index: rpc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/rpc.py,v retrieving revision 1.26 retrieving revision 1.26.8.1 diff -u -d -r1.26 -r1.26.8.1 --- rpc.py 5 Jun 2003 23:51:28 -0000 1.26 +++ rpc.py 19 Jan 2005 01:44:06 -0000 1.26.8.1 @@ -320,23 +320,20 @@ self.debug("putmessage:%d:" % message[0]) try: s = pickle.dumps(message) - except pickle.UnpicklingError: + except pickle.PicklingError: print >>sys.__stderr__, "Cannot pickle:", `message` raise s = struct.pack(" 0: try: - n = self.sock.send(s) + r, w, x = select.select([], [self.sock], []) + n = self.sock.send(s[:BUFSIZE]) except (AttributeError, socket.error): # socket was closed raise IOError else: s = s[n:] - def ioready(self, wait): - r, w, x = select.select([self.sock.fileno()], [], [], wait) - return len(r) - buffer = "" bufneed = 4 bufstate = 0 # meaning: 0 => reading count; 1 => reading data @@ -344,7 +341,8 @@ def pollpacket(self, wait): self._stage0() if len(self.buffer) < self.bufneed: - if not self.ioready(wait): + r, w, x = select.select([self.sock.fileno()], [], [], wait) + if len(r) == 0: return None try: s = self.sock.recv(BUFSIZE) @@ -377,7 +375,7 @@ return None try: message = pickle.loads(packet) - except: + except pickle.UnpicklingError: print >>sys.__stderr__, "-----------------------" print >>sys.__stderr__, "cannot unpickle packet:", `packet` traceback.print_stack(file=sys.__stderr__) From fdrake at users.sourceforge.net Wed Jan 19 04:24:00 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jan 19 04:24:03 2005 Subject: [Python-checkins] python/dist/src/Doc/lib tkinter.tex,1.28,1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22345/Doc/lib Modified Files: tkinter.tex Log Message: remove spurious line from widget variables example (closes SF patch #1094815) Index: tkinter.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/tkinter.tex,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- tkinter.tex 1 Jan 2005 00:28:43 -0000 1.28 +++ tkinter.tex 19 Jan 2005 03:23:57 -0000 1.29 @@ -621,7 +621,6 @@ self.entrythingy = Entry() self.entrythingy.pack() - self.button.pack() # here is the application variable self.contents = StringVar() # set it to some value From fdrake at users.sourceforge.net Wed Jan 19 04:25:48 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jan 19 04:25:51 2005 Subject: [Python-checkins] python/dist/src/Doc/lib tkinter.tex, 1.27.2.1, 1.27.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22759/Doc/lib Modified Files: Tag: release24-maint tkinter.tex Log Message: remove spurious line from widget variables example (closes SF patch #1094815) Index: tkinter.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/tkinter.tex,v retrieving revision 1.27.2.1 retrieving revision 1.27.2.2 diff -u -d -r1.27.2.1 -r1.27.2.2 --- tkinter.tex 1 Jan 2005 00:34:53 -0000 1.27.2.1 +++ tkinter.tex 19 Jan 2005 03:25:46 -0000 1.27.2.2 @@ -621,7 +621,6 @@ self.entrythingy = Entry() self.entrythingy.pack() - self.button.pack() # here is the application variable self.contents = StringVar() # set it to some value From fdrake at users.sourceforge.net Wed Jan 19 04:27:21 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jan 19 04:27:24 2005 Subject: [Python-checkins] python/dist/src/Doc/lib tkinter.tex, 1.22, 1.22.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23118/Doc/lib Modified Files: Tag: release23-maint tkinter.tex Log Message: remove spurious line from widget variables example (closes SF patch #1094815) Index: tkinter.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/tkinter.tex,v retrieving revision 1.22 retrieving revision 1.22.4.1 diff -u -d -r1.22 -r1.22.4.1 --- tkinter.tex 28 Jul 2003 14:39:13 -0000 1.22 +++ tkinter.tex 19 Jan 2005 03:27:18 -0000 1.22.4.1 @@ -608,7 +608,6 @@ self.entrythingy = Entry() self.entrythingy.pack() - self.button.pack() # here is the application variable self.contents = StringVar() # set it to some value From fdrake at users.sourceforge.net Wed Jan 19 04:39:20 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jan 19 04:39:23 2005 Subject: [Python-checkins] python/dist/src/Doc/mac scripting.tex,1.3,1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/mac In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25737/Doc/mac Modified Files: scripting.tex Log Message: fix a bunch of spelling errors (closes SF patch #1104868) Index: scripting.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/mac/scripting.tex,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- scripting.tex 14 Dec 2003 15:02:54 -0000 1.3 +++ scripting.tex 19 Jan 2005 03:39:17 -0000 1.4 @@ -1,7 +1,7 @@ \chapter{MacPython OSA Modules \label{scripting}} Python has a fairly complete implementation of the Open Scripting -Architecure (OSA, also commonly referred to as AppleScript), allowing +Architecture (OSA, also commonly referred to as AppleScript), allowing you to control scriptable applications from your Python program, and with a fairly pythonic interface. From fdrake at users.sourceforge.net Wed Jan 19 04:39:20 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jan 19 04:39:24 2005 Subject: [Python-checkins] python/dist/src/Doc/ref ref5.tex,1.87,1.88 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25737/Doc/ref Modified Files: ref5.tex Log Message: fix a bunch of spelling errors (closes SF patch #1104868) Index: ref5.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref5.tex,v retrieving revision 1.87 retrieving revision 1.88 diff -u -d -r1.87 -r1.88 --- ref5.tex 1 Jan 2005 00:28:43 -0000 1.87 +++ ref5.tex 19 Jan 2005 03:39:16 -0000 1.88 @@ -960,7 +960,7 @@ object is a member of a set if the set is a sequence and contains an element equal to that object. However, it is possible for an object to support membership tests without being a sequence. In particular, -dictionaries support memership testing as a nicer way of spelling +dictionaries support membership testing as a nicer way of spelling \code{\var{key} in \var{dict}}; other mapping types may follow suit. For the list and tuple types, \code{\var{x} in \var{y}} is true if and From fdrake at users.sourceforge.net Wed Jan 19 04:39:20 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jan 19 04:39:25 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libdatetime.tex, 1.55, 1.56 libmmap.tex, 1.9, 1.10 libos.tex, 1.150, 1.151 libstdwin.tex, 1.26, 1.27 libxmlrpclib.tex, 1.20, 1.21 tkinter.tex, 1.29, 1.30 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25737/Doc/lib Modified Files: libdatetime.tex libmmap.tex libos.tex libstdwin.tex libxmlrpclib.tex tkinter.tex Log Message: fix a bunch of spelling errors (closes SF patch #1104868) Index: libdatetime.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdatetime.tex,v retrieving revision 1.55 retrieving revision 1.56 diff -u -d -r1.55 -r1.56 --- libdatetime.tex 13 Jan 2005 21:06:25 -0000 1.55 +++ libdatetime.tex 19 Jan 2005 03:39:16 -0000 1.56 @@ -23,7 +23,7 @@ time adjustment. Whether a naive \class{datetime} object represents Coordinated Universal Time (UTC), local time, or time in some other timezone is purely up to the program, just like it's up to the program -whether a particular number represents meters, miles, or mass. Naive +whether a particular number represents metres, miles, or mass. Naive \class{datetime} objects are easy to understand and to work with, at the cost of ignoring some aspects of reality. Index: libmmap.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libmmap.tex,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- libmmap.tex 6 Jun 2004 16:51:46 -0000 1.9 +++ libmmap.tex 19 Jan 2005 03:39:16 -0000 1.10 @@ -35,7 +35,7 @@ taken from the specified file. Assignment to an \constant{ACCESS_READ} memory map raises a \exception{TypeError} exception. Assignment to an \constant{ACCESS_WRITE} memory map -affects both memory and the underlying file. Assigment to an +affects both memory and the underlying file. Assignment to an \constant{ACCESS_COPY} memory map affects memory but does not update the underlying file. Index: libos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.150 retrieving revision 1.151 diff -u -d -r1.150 -r1.151 --- libos.tex 16 Jan 2005 08:57:39 -0000 1.150 +++ libos.tex 19 Jan 2005 03:39:16 -0000 1.151 @@ -639,7 +639,7 @@ \begin{datadesc}{SEEK_SET} \dataline{SEEK_CUR} \dataline{SEEK_END} -Parameteters to the \function{lseek()} function. +Parameters to the \function{lseek()} function. Their values are 0, 1, and 2, respectively. Availability: Windows, Macintosh, \UNIX. \versionadded{2.5} Index: libstdwin.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdwin.tex,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- libstdwin.tex 12 Aug 2003 00:01:16 -0000 1.26 +++ libstdwin.tex 19 Jan 2005 03:39:16 -0000 1.27 @@ -114,7 +114,7 @@ \end{funcdesc} \begin{funcdesc}{getscrmm}{} -Return the screen size in millimeters. +Return the screen size in millimetres. \end{funcdesc} \begin{funcdesc}{fetchcolor}{colorname} Index: libxmlrpclib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libxmlrpclib.tex,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- libxmlrpclib.tex 1 Jan 2005 00:28:43 -0000 1.20 +++ libxmlrpclib.tex 19 Jan 2005 03:39:16 -0000 1.21 @@ -5,7 +5,7 @@ \moduleauthor{Fredrik Lundh}{fredrik@pythonware.com} \sectionauthor{Eric S. Raymond}{esr@snark.thyrsus.com} -% Not everyting is documented yet. It might be good to describe +% Not everything is documented yet. It might be good to describe % Marshaller, Unmarshaller, getparser, dumps, loads, and Transport. \versionadded{2.2} Index: tkinter.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/tkinter.tex,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- tkinter.tex 19 Jan 2005 03:23:57 -0000 1.29 +++ tkinter.tex 19 Jan 2005 03:39:16 -0000 1.30 @@ -731,7 +731,7 @@ Screen distances can be specified in either pixels or absolute distances. Pixels are given as numbers and absolute distances as strings, with the trailing character denoting units: \code{c} -for centimeters, \code{i} for inches, \code{m} for millimeters, +for centimetres, \code{i} for inches, \code{m} for millimetres, \code{p} for printer's points. For example, 3.5 inches is expressed as \code{"3.5i"}. From fdrake at users.sourceforge.net Wed Jan 19 04:42:12 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jan 19 04:42:15 2005 Subject: [Python-checkins] python/dist/src/Doc/ref ref5.tex, 1.86.2.1, 1.86.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26451/Doc/ref Modified Files: Tag: release24-maint ref5.tex Log Message: fix a bunch of spelling errors (closes SF patch #1104868) Index: ref5.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref5.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 --- ref5.tex 1 Jan 2005 00:34:55 -0000 1.86.2.1 +++ ref5.tex 19 Jan 2005 03:42:09 -0000 1.86.2.2 @@ -960,7 +960,7 @@ object is a member of a set if the set is a sequence and contains an element equal to that object. However, it is possible for an object to support membership tests without being a sequence. In particular, -dictionaries support memership testing as a nicer way of spelling +dictionaries support membership testing as a nicer way of spelling \code{\var{key} in \var{dict}}; other mapping types may follow suit. For the list and tuple types, \code{\var{x} in \var{y}} is true if and From fdrake at users.sourceforge.net Wed Jan 19 04:42:12 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jan 19 04:42:16 2005 Subject: [Python-checkins] python/dist/src/Doc/mac scripting.tex, 1.3, 1.3.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/mac In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26451/Doc/mac Modified Files: Tag: release24-maint scripting.tex Log Message: fix a bunch of spelling errors (closes SF patch #1104868) Index: scripting.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/mac/scripting.tex,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -u -d -r1.3 -r1.3.4.1 --- scripting.tex 14 Dec 2003 15:02:54 -0000 1.3 +++ scripting.tex 19 Jan 2005 03:42:10 -0000 1.3.4.1 @@ -1,7 +1,7 @@ \chapter{MacPython OSA Modules \label{scripting}} Python has a fairly complete implementation of the Open Scripting -Architecure (OSA, also commonly referred to as AppleScript), allowing +Architecture (OSA, also commonly referred to as AppleScript), allowing you to control scriptable applications from your Python program, and with a fairly pythonic interface. From fdrake at users.sourceforge.net Wed Jan 19 04:42:13 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jan 19 04:42:19 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libdatetime.tex, 1.53, 1.53.2.1 libmmap.tex, 1.9, 1.9.4.1 libstdwin.tex, 1.26, 1.26.4.1 libxmlrpclib.tex, 1.18.2.2, 1.18.2.3 tkinter.tex, 1.27.2.2, 1.27.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26451/Doc/lib Modified Files: Tag: release24-maint libdatetime.tex libmmap.tex libstdwin.tex libxmlrpclib.tex tkinter.tex Log Message: fix a bunch of spelling errors (closes SF patch #1104868) Index: libdatetime.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdatetime.tex,v retrieving revision 1.53 retrieving revision 1.53.2.1 diff -u -d -r1.53 -r1.53.2.1 --- libdatetime.tex 15 Nov 2004 03:50:16 -0000 1.53 +++ libdatetime.tex 19 Jan 2005 03:42:09 -0000 1.53.2.1 @@ -23,7 +23,7 @@ time adjustment. Whether a naive \class{datetime} object represents Coordinated Universal Time (UTC), local time, or time in some other timezone is purely up to the program, just like it's up to the program -whether a particular number represents meters, miles, or mass. Naive +whether a particular number represents metres, miles, or mass. Naive \class{datetime} objects are easy to understand and to work with, at the cost of ignoring some aspects of reality. Index: libmmap.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libmmap.tex,v retrieving revision 1.9 retrieving revision 1.9.4.1 diff -u -d -r1.9 -r1.9.4.1 --- libmmap.tex 6 Jun 2004 16:51:46 -0000 1.9 +++ libmmap.tex 19 Jan 2005 03:42:09 -0000 1.9.4.1 @@ -35,7 +35,7 @@ taken from the specified file. Assignment to an \constant{ACCESS_READ} memory map raises a \exception{TypeError} exception. Assignment to an \constant{ACCESS_WRITE} memory map -affects both memory and the underlying file. Assigment to an +affects both memory and the underlying file. Assignment to an \constant{ACCESS_COPY} memory map affects memory but does not update the underlying file. Index: libstdwin.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdwin.tex,v retrieving revision 1.26 retrieving revision 1.26.4.1 diff -u -d -r1.26 -r1.26.4.1 --- libstdwin.tex 12 Aug 2003 00:01:16 -0000 1.26 +++ libstdwin.tex 19 Jan 2005 03:42:09 -0000 1.26.4.1 @@ -114,7 +114,7 @@ \end{funcdesc} \begin{funcdesc}{getscrmm}{} -Return the screen size in millimeters. +Return the screen size in millimetres. \end{funcdesc} \begin{funcdesc}{fetchcolor}{colorname} Index: libxmlrpclib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libxmlrpclib.tex,v retrieving revision 1.18.2.2 retrieving revision 1.18.2.3 diff -u -d -r1.18.2.2 -r1.18.2.3 --- libxmlrpclib.tex 1 Jan 2005 00:34:53 -0000 1.18.2.2 +++ libxmlrpclib.tex 19 Jan 2005 03:42:09 -0000 1.18.2.3 @@ -5,7 +5,7 @@ \moduleauthor{Fredrik Lundh}{fredrik@pythonware.com} \sectionauthor{Eric S. Raymond}{esr@snark.thyrsus.com} -% Not everyting is documented yet. It might be good to describe +% Not everything is documented yet. It might be good to describe % Marshaller, Unmarshaller, getparser, dumps, loads, and Transport. \versionadded{2.2} Index: tkinter.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/tkinter.tex,v retrieving revision 1.27.2.2 retrieving revision 1.27.2.3 diff -u -d -r1.27.2.2 -r1.27.2.3 --- tkinter.tex 19 Jan 2005 03:25:46 -0000 1.27.2.2 +++ tkinter.tex 19 Jan 2005 03:42:09 -0000 1.27.2.3 @@ -731,7 +731,7 @@ Screen distances can be specified in either pixels or absolute distances. Pixels are given as numbers and absolute distances as strings, with the trailing character denoting units: \code{c} -for centimeters, \code{i} for inches, \code{m} for millimeters, +for centimetres, \code{i} for inches, \code{m} for millimetres, \code{p} for printer's points. For example, 3.5 inches is expressed as \code{"3.5i"}. From fdrake at users.sourceforge.net Wed Jan 19 04:45:42 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jan 19 04:45:45 2005 Subject: [Python-checkins] python/dist/src/Doc/ref ref5.tex, 1.76.10.5, 1.76.10.6 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27206/Doc/ref Modified Files: Tag: release23-maint ref5.tex Log Message: fix a bunch of spelling errors (closes SF patch #1104868) Index: ref5.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref5.tex,v retrieving revision 1.76.10.5 retrieving revision 1.76.10.6 diff -u -d -r1.76.10.5 -r1.76.10.6 --- ref5.tex 11 Nov 2004 06:16:42 -0000 1.76.10.5 +++ ref5.tex 19 Jan 2005 03:45:38 -0000 1.76.10.6 @@ -911,7 +911,7 @@ object is a member of a set if the set is a sequence and contains an element equal to that object. However, it is possible for an object to support membership tests without being a sequence. In particular, -dictionaries support memership testing as a nicer way of spelling +dictionaries support membership testing as a nicer way of spelling \code{\var{key} in \var{dict}}; other mapping types may follow suit. For the list and tuple types, \code{\var{x} in \var{y}} is true if and From fdrake at users.sourceforge.net Wed Jan 19 04:45:42 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jan 19 04:45:46 2005 Subject: [Python-checkins] python/dist/src/Doc/mac scripting.tex, 1.2.10.1, 1.2.10.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/mac In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27206/Doc/mac Modified Files: Tag: release23-maint scripting.tex Log Message: fix a bunch of spelling errors (closes SF patch #1104868) Index: scripting.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/mac/scripting.tex,v retrieving revision 1.2.10.1 retrieving revision 1.2.10.2 diff -u -d -r1.2.10.1 -r1.2.10.2 --- scripting.tex 15 Dec 2003 15:46:04 -0000 1.2.10.1 +++ scripting.tex 19 Jan 2005 03:45:39 -0000 1.2.10.2 @@ -1,7 +1,7 @@ \chapter{MacPython OSA Modules \label{scripting}} Python has a fairly complete implementation of the Open Scripting -Architecure (OSA, also commonly referred to as AppleScript), allowing +Architecture (OSA, also commonly referred to as AppleScript), allowing you to control scriptable applications from your Python program, and with a fairly pythonic interface. From fdrake at users.sourceforge.net Wed Jan 19 04:45:42 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jan 19 04:45:47 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libdatetime.tex, 1.49.8.3, 1.49.8.4 libmmap.tex, 1.8.24.1, 1.8.24.2 libstdwin.tex, 1.25.26.1, 1.25.26.2 libxmlrpclib.tex, 1.13.12.1, 1.13.12.2 tkinter.tex, 1.22.4.1, 1.22.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27206/Doc/lib Modified Files: Tag: release23-maint libdatetime.tex libmmap.tex libstdwin.tex libxmlrpclib.tex tkinter.tex Log Message: fix a bunch of spelling errors (closes SF patch #1104868) Index: libdatetime.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdatetime.tex,v retrieving revision 1.49.8.3 retrieving revision 1.49.8.4 diff -u -d -r1.49.8.3 -r1.49.8.4 --- libdatetime.tex 6 Sep 2003 05:36:56 -0000 1.49.8.3 +++ libdatetime.tex 19 Jan 2005 03:45:38 -0000 1.49.8.4 @@ -23,7 +23,7 @@ time adjustment. Whether a naive \class{datetime} object represents Coordinated Universal Time (UTC), local time, or time in some other timezone is purely up to the program, just like it's up to the program -whether a particular number represents meters, miles, or mass. Naive +whether a particular number represents metres, miles, or mass. Naive \class{datetime} objects are easy to understand and to work with, at the cost of ignoring some aspects of reality. Index: libmmap.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libmmap.tex,v retrieving revision 1.8.24.1 retrieving revision 1.8.24.2 diff -u -d -r1.8.24.1 -r1.8.24.2 --- libmmap.tex 6 Jun 2004 16:54:15 -0000 1.8.24.1 +++ libmmap.tex 19 Jan 2005 03:45:38 -0000 1.8.24.2 @@ -35,7 +35,7 @@ taken from the specified file. Assignment to an \constant{ACCESS_READ} memory map raises a \exception{TypeError} exception. Assignment to an \constant{ACCESS_WRITE} memory map -affects both memory and the underlying file. Assigment to an +affects both memory and the underlying file. Assignment to an \constant{ACCESS_COPY} memory map affects memory but does not update the underlying file. Index: libstdwin.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdwin.tex,v retrieving revision 1.25.26.1 retrieving revision 1.25.26.2 diff -u -d -r1.25.26.1 -r1.25.26.2 --- libstdwin.tex 11 Aug 2003 23:43:04 -0000 1.25.26.1 +++ libstdwin.tex 19 Jan 2005 03:45:38 -0000 1.25.26.2 @@ -114,7 +114,7 @@ \end{funcdesc} \begin{funcdesc}{getscrmm}{} -Return the screen size in millimeters. +Return the screen size in millimetres. \end{funcdesc} \begin{funcdesc}{fetchcolor}{colorname} Index: libxmlrpclib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libxmlrpclib.tex,v retrieving revision 1.13.12.1 retrieving revision 1.13.12.2 diff -u -d -r1.13.12.1 -r1.13.12.2 --- libxmlrpclib.tex 12 May 2004 03:03:45 -0000 1.13.12.1 +++ libxmlrpclib.tex 19 Jan 2005 03:45:38 -0000 1.13.12.2 @@ -5,7 +5,7 @@ \moduleauthor{Fredrik Lundh}{fredrik@pythonware.com} \sectionauthor{Eric S. Raymond}{esr@snark.thyrsus.com} -% Not everyting is documented yet. It might be good to describe +% Not everything is documented yet. It might be good to describe % Marshaller, Unmarshaller, getparser, dumps, loads, and Transport. \versionadded{2.2} Index: tkinter.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/tkinter.tex,v retrieving revision 1.22.4.1 retrieving revision 1.22.4.2 diff -u -d -r1.22.4.1 -r1.22.4.2 --- tkinter.tex 19 Jan 2005 03:27:18 -0000 1.22.4.1 +++ tkinter.tex 19 Jan 2005 03:45:38 -0000 1.22.4.2 @@ -718,7 +718,7 @@ Screen distances can be specified in either pixels or absolute distances. Pixels are given as numbers and absolute distances as strings, with the trailing character denoting units: \code{c} -for centimeters, \code{i} for inches, \code{m} for millimeters, +for centimetres, \code{i} for inches, \code{m} for millimetres, \code{p} for printer's points. For example, 3.5 inches is expressed as \code{"3.5i"}. From kbk at users.sourceforge.net Wed Jan 19 05:12:41 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Wed Jan 19 05:12:44 2005 Subject: [Python-checkins] python/dist/src/Lib/idlelib EditorWindow.py, 1.53.6.2, 1.53.6.3 NEWS.txt, 1.23.4.12, 1.23.4.13 configHelpSourceEdit.py, 1.6, 1.6.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31514 Modified Files: Tag: release23-maint EditorWindow.py NEWS.txt configHelpSourceEdit.py Log Message: Backport EditorWindow rev 1.60 configHelpSourceEdit rev 1.7 15Jul04 checking sys.platform for substring 'win' was breaking IDLE docs on Mac (darwin). Also, Mac Safari browser requires full file:// URIs. SF 900580. M EditorWindow.py M NEWS.txt M configHelpSourceEdit.py Index: EditorWindow.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/EditorWindow.py,v retrieving revision 1.53.6.2 retrieving revision 1.53.6.3 diff -u -d -r1.53.6.2 -r1.53.6.3 --- EditorWindow.py 17 Jan 2005 20:34:45 -0000 1.53.6.2 +++ EditorWindow.py 19 Jan 2005 04:12:37 -0000 1.53.6.3 @@ -60,7 +60,7 @@ basepath = '/usr/share/doc/' # standard location dochome = os.path.join(basepath, pyver, 'Doc', 'index.html') - elif sys.platform.count('win') or sys.platform.count('nt'): + elif sys.platform[:3] == 'win': # Try the HTMLHelp file chmpath = os.path.join(sys.prefix, 'Doc', 'Python%d%d.chm' % sys.version_info[:2]) @@ -311,20 +311,11 @@ textView.TextViewer(self.top,'Help',fn) def python_docs(self, event=None): - if sys.platform.count('win') or sys.platform.count('nt'): + if sys.platform[:3] == 'win': os.startfile(self.help_url) - return "break" else: webbrowser.open(self.help_url) - return "break" - - def display_docs(self, url): - if not (url.startswith('www') or url.startswith('http')): - url = os.path.normpath(url) - if sys.platform.count('win') or sys.platform.count('nt'): - os.startfile(url) - else: - webbrowser.open(url) + return "break" def cut(self,event): self.text.event_generate("<>") @@ -575,7 +566,12 @@ def __extra_help_callback(self, helpfile): "Create a callback with the helpfile value frozen at definition time" def display_extra_help(helpfile=helpfile): - self.display_docs(helpfile) + if not (helpfile.startswith('www') or helpfile.startswith('http')): + url = os.path.normpath(helpfile) + if sys.platform[:3] == 'win': + os.startfile(helpfile) + else: + webbrowser.open(helpfile) return display_extra_help def UpdateRecentFilesList(self,newFile=None): Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.23.4.12 retrieving revision 1.23.4.13 diff -u -d -r1.23.4.12 -r1.23.4.13 --- NEWS.txt 19 Jan 2005 01:44:06 -0000 1.23.4.12 +++ NEWS.txt 19 Jan 2005 04:12:38 -0000 1.23.4.13 @@ -3,6 +3,10 @@ *Release date: XX-Jan-2005* +- checking sys.platform for substring 'win' was breaking IDLE docs on Mac + (darwin). Also, Mac Safari browser requires full file:// URIs. Backport of + fix for SF 900580. + - rpc.py:SocketIO - Large modules were generating large pickles when downloaded to the execution server. The return of the OK response from the subprocess initialization was interfering and causing the sending socket to be not Index: configHelpSourceEdit.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/configHelpSourceEdit.py,v retrieving revision 1.6 retrieving revision 1.6.8.1 diff -u -d -r1.6 -r1.6.8.1 --- configHelpSourceEdit.py 27 Jan 2003 02:36:18 -0000 1.6 +++ configHelpSourceEdit.py 19 Jan 2005 04:12:38 -0000 1.6.8.1 @@ -1,6 +1,7 @@ "Dialog to specify or edit the parameters for a user configured help source." import os +import sys from Tkinter import * import tkMessageBox @@ -84,7 +85,7 @@ dir, base = os.path.split(path) else: base = None - if sys.platform.count('win') or sys.platform.count('nt'): + if sys.platform[:3] == 'win': dir = os.path.join(os.path.dirname(sys.executable), 'Doc') if not os.path.isdir(dir): dir = os.getcwd() @@ -127,19 +128,30 @@ self.entryPath.focus_set() pathOk = False elif path.startswith('www.') or path.startswith('http'): - pathOk = True - elif not os.path.exists(path): - tkMessageBox.showerror(title='File Path Error', - message='Help file path does not exist.', - parent=self) - self.entryPath.focus_set() - pathOk = False + pass + else: + if path[:5] == 'file:': + path = path[5:] + if not os.path.exists(path): + tkMessageBox.showerror(title='File Path Error', + message='Help file path does not exist.', + parent=self) + self.entryPath.focus_set() + pathOk = False return pathOk def Ok(self, event=None): if self.MenuOk() and self.PathOk(): self.result = (self.menu.get().strip(), self.path.get().strip()) + if sys.platform == 'darwin': + path = self.result[1] + if (path.startswith('www') or path.startswith('file:') + or path.startswith('http:')): + pass + else: + # Mac Safari insists on using the URI form for local files + self.result[1] = "file://" + path self.destroy() def Cancel(self, event=None): From fdrake at users.sourceforge.net Wed Jan 19 05:13:17 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jan 19 05:13:20 2005 Subject: [Python-checkins] python/dist/src/Doc/api init.tex,1.21,1.21.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32229/api Modified Files: Tag: release24-maint init.tex Log Message: Clean up discussion of new C thread idiom (closes SF patch #1031233; modified) Index: init.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/init.tex,v retrieving revision 1.21 retrieving revision 1.21.2.1 diff -u -d -r1.21 -r1.21.2.1 --- init.tex 11 Oct 2004 02:40:35 -0000 1.21 +++ init.tex 19 Jan 2005 04:13:14 -0000 1.21.2.1 @@ -455,19 +455,10 @@ pointer, release the lock, and finally free their thread state data structure. -When creating a thread data structure, you need to provide an -interpreter state data structure. The interpreter state data -structure holds global data that is shared by all threads in an -interpreter, for example the module administration -(\code{sys.modules}). Depending on your needs, you can either create -a new interpreter state data structure, or share the interpreter state -data structure used by the Python main thread (to access the latter, -you must obtain the thread state and access its \member{interp} member; -this must be done by a thread that is created by Python or by the main -thread after Python is initialized). - -Assuming you have access to an interpreter object, the typical idiom -for calling into Python from a C thread is +Beginning with version 2.3, threads can now take advantage of the +\cfunction{PyGILState_*()} functions to do all of the above +automatically. The typical idiom for calling into Python from a C +thread is now: \begin{verbatim} PyGILState_STATE gstate; @@ -481,6 +472,13 @@ PyGILState_Release(gstate); \end{verbatim} +Note that the \cfunction{PyGILState_*()} functions assume there is only +one global interpreter (created automatically by +\cfunction{Py_Initialize()}). Python still supports the creation of +additional interpreters (using \cfunction{Py_NewInterpreter()}), but +mixing multiple interpreters and the \cfunction{PyGILState_*()} API is +unsupported. + \begin{ctypedesc}{PyInterpreterState} This data structure represents the state shared by a number of cooperating threads. Threads belonging to the same interpreter From fdrake at users.sourceforge.net Wed Jan 19 05:18:42 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jan 19 05:18:46 2005 Subject: [Python-checkins] python/dist/src/Doc/api init.tex,1.21,1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv803 Modified Files: init.tex Log Message: Clean up discussion of new C thread idiom (closes SF patch #1031233; modified) Index: init.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/init.tex,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- init.tex 11 Oct 2004 02:40:35 -0000 1.21 +++ init.tex 19 Jan 2005 04:18:39 -0000 1.22 @@ -455,19 +455,10 @@ pointer, release the lock, and finally free their thread state data structure. -When creating a thread data structure, you need to provide an -interpreter state data structure. The interpreter state data -structure holds global data that is shared by all threads in an -interpreter, for example the module administration -(\code{sys.modules}). Depending on your needs, you can either create -a new interpreter state data structure, or share the interpreter state -data structure used by the Python main thread (to access the latter, -you must obtain the thread state and access its \member{interp} member; -this must be done by a thread that is created by Python or by the main -thread after Python is initialized). - -Assuming you have access to an interpreter object, the typical idiom -for calling into Python from a C thread is +Beginning with version 2.3, threads can now take advantage of the +\cfunction{PyGILState_*()} functions to do all of the above +automatically. The typical idiom for calling into Python from a C +thread is now: \begin{verbatim} PyGILState_STATE gstate; @@ -481,6 +472,13 @@ PyGILState_Release(gstate); \end{verbatim} +Note that the \cfunction{PyGILState_*()} functions assume there is only +one global interpreter (created automatically by +\cfunction{Py_Initialize()}). Python still supports the creation of +additional interpreters (using \cfunction{Py_NewInterpreter()}), but +mixing multiple interpreters and the \cfunction{PyGILState_*()} API is +unsupported. + \begin{ctypedesc}{PyInterpreterState} This data structure represents the state shared by a number of cooperating threads. Threads belonging to the same interpreter From fdrake at users.sourceforge.net Wed Jan 19 05:44:26 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jan 19 05:44:29 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libimaplib.tex,1.31,1.32 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6018/Doc/lib Modified Files: libimaplib.tex Log Message: Description of args to IMAP4.store() in imaplib (closes SF patch #1084092; modified per comments in SF) Index: libimaplib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libimaplib.tex,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- libimaplib.tex 1 Jan 2005 00:28:37 -0000 1.31 +++ libimaplib.tex 19 Jan 2005 04:44:07 -0000 1.32 @@ -143,6 +143,13 @@ is the header of the response, and the second part contains the data (ie: 'literal' value). +The \var{message_set} options to commands below is a string specifying one +or more messages to be acted upon. It may be a simple message number +(\code{'1'}), a range of message numbers (\code{'2:4'}), or a group of +non-contiguous ranges separated by commas (\code{'1:3,6:9'}). A range +can contain an asterisk to indicate an infinite upper bound +(\code{'3:*'}). + An \class{IMAP4} instance has the following methods: @@ -389,7 +396,18 @@ \end{methoddesc} \begin{methoddesc}{store}{message_set, command, flag_list} - Alters flag dispositions for messages in mailbox. + Alters flag dispositions for messages in mailbox. \var{command} is + specified by section 6.4.6 of \rfc{2060} as being one of "FLAGS", "+FLAGS", + or "-FLAGS", optionally with a suffix of ".SILENT". + + For example, to set the delete flag on all messages: + +\begin{verbatim} +typ, data = M.search(None, 'ALL') +for num in data[0].split(): + M.store(num, '+FLAGS', '\\Deleted') +M.expunge() +\end{verbatim} \end{methoddesc} \begin{methoddesc}{subscribe}{mailbox} @@ -473,5 +491,6 @@ for num in data[0].split(): typ, data = M.fetch(num, '(RFC822)') print 'Message %s\n%s\n' % (num, data[0][1]) +M.close() M.logout() \end{verbatim} From fdrake at users.sourceforge.net Wed Jan 19 05:47:53 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jan 19 05:47:57 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libimaplib.tex, 1.30.4.1, 1.30.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6779/Doc/lib Modified Files: Tag: release24-maint libimaplib.tex Log Message: Description of args to IMAP4.store() in imaplib (closes SF patch #1084092; modified per comments in SF) Index: libimaplib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libimaplib.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 --- libimaplib.tex 1 Jan 2005 00:34:53 -0000 1.30.4.1 +++ libimaplib.tex 19 Jan 2005 04:47:50 -0000 1.30.4.2 @@ -143,6 +143,13 @@ is the header of the response, and the second part contains the data (ie: 'literal' value). +The \var{message_set} options to commands below is a string specifying one +or more messages to be acted upon. It may be a simple message number +(\code{'1'}), a range of message numbers (\code{'2:4'}), or a group of +non-contiguous ranges separated by commas (\code{'1:3,6:9'}). A range +can contain an asterisk to indicate an infinite upper bound +(\code{'3:*'}). + An \class{IMAP4} instance has the following methods: @@ -389,7 +396,18 @@ \end{methoddesc} \begin{methoddesc}{store}{message_set, command, flag_list} - Alters flag dispositions for messages in mailbox. + Alters flag dispositions for messages in mailbox. \var{command} is + specified by section 6.4.6 of \rfc{2060} as being one of "FLAGS", "+FLAGS", + or "-FLAGS", optionally with a suffix of ".SILENT". + + For example, to set the delete flag on all messages: + +\begin{verbatim} +typ, data = M.search(None, 'ALL') +for num in data[0].split(): + M.store(num, '+FLAGS', '\\Deleted') +M.expunge() +\end{verbatim} \end{methoddesc} \begin{methoddesc}{subscribe}{mailbox} @@ -473,5 +491,6 @@ for num in data[0].split(): typ, data = M.fetch(num, '(RFC822)') print 'Message %s\n%s\n' % (num, data[0][1]) +M.close() M.logout() \end{verbatim} From fdrake at users.sourceforge.net Wed Jan 19 05:49:30 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jan 19 05:49:33 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libimaplib.tex, 1.24, 1.24.12.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7199/Doc/lib Modified Files: Tag: release23-maint libimaplib.tex Log Message: Description of args to IMAP4.store() in imaplib (closes SF patch #1084092; modified per comments in SF) Index: libimaplib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libimaplib.tex,v retrieving revision 1.24 retrieving revision 1.24.12.1 diff -u -d -r1.24 -r1.24.12.1 --- libimaplib.tex 27 Mar 2003 16:59:38 -0000 1.24 +++ libimaplib.tex 19 Jan 2005 04:49:26 -0000 1.24.12.1 @@ -134,6 +134,13 @@ is the header of the response, and the second part contains the data (ie: 'literal' value). +The \var{message_set} options to commands below is a string specifying one +or more messages to be acted upon. It may be a simple message number +(\code{'1'}), a range of message numbers (\code{'2:4'}), or a group of +non-contiguous ranges separated by commas (\code{'1:3,6:9'}). A range +can contain an asterisk to indicate an infinite upper bound +(\code{'3:*'}). + An \class{IMAP4} instance has the following methods: @@ -348,7 +355,18 @@ \end{methoddesc} \begin{methoddesc}{store}{message_set, command, flag_list} - Alters flag dispositions for messages in mailbox. + Alters flag dispositions for messages in mailbox. \var{command} is + specified by section 6.4.6 of \rfc{2060} as being one of "FLAGS", "+FLAGS", + or "-FLAGS", optionally with a suffix of ".SILENT". + + For example, to set the delete flag on all messages: + +\begin{verbatim} +typ, data = M.search(None, 'ALL') +for num in data[0].split(): + M.store(num, '+FLAGS', '\\Deleted') +M.expunge() +\end{verbatim} \end{methoddesc} \begin{methoddesc}{subscribe}{mailbox} @@ -409,5 +427,6 @@ for num in data[0].split(): typ, data = M.fetch(num, '(RFC822)') print 'Message %s\n%s\n' % (num, data[0][1]) +M.close() M.logout() \end{verbatim} From fdrake at users.sourceforge.net Wed Jan 19 06:42:53 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jan 19 06:42:55 2005 Subject: [Python-checkins] python/dist/src/Doc Makefile.deps,1.121,1.122 Message-ID: Update of /cvsroot/python/python/dist/src/Doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17480 Modified Files: Makefile.deps Log Message: documentation for the zipimport module using contributed patch (closes SF bug #853800; markup adjusted) Index: Makefile.deps =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile.deps,v retrieving revision 1.121 retrieving revision 1.122 diff -u -d -r1.121 -r1.122 --- Makefile.deps 6 Dec 2004 12:29:55 -0000 1.121 +++ Makefile.deps 19 Jan 2005 05:42:50 -0000 1.122 @@ -125,6 +125,7 @@ lib/libmarshal.tex \ lib/libwarnings.tex \ lib/libimp.tex \ + lib/libzipimport.tex \ lib/libpkgutil.tex \ lib/libparser.tex \ lib/libbltin.tex \ From fdrake at users.sourceforge.net Wed Jan 19 06:42:53 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jan 19 06:42:57 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libzipimport.tex, NONE, 1.1 lib.tex, 1.235, 1.236 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17480/lib Modified Files: lib.tex Added Files: libzipimport.tex Log Message: documentation for the zipimport module using contributed patch (closes SF bug #853800; markup adjusted) --- NEW FILE: libzipimport.tex --- \section{\module{zipimport} --- Import modules from Zip archives} \declaremodule{standard}{zipimport} \modulesynopsis{support for importing Python modules from ZIP archives.} \moduleauthor{Just van Rossum}{just@letterror.com} \versionadded{2.3} This module adds the ability to import Python modules (\file{*.py}, \file{*.py[co]}) and packages from ZIP-format archives. It is usually not needed to use the \module{zipimport} module explicitly; it is automatically used by the builtin \keyword{import} mechanism for \code{sys.path} items that are paths to ZIP archives. Typically, \code{sys.path} is a list of directory names as strings. This module also allows an item of \code{sys.path} to be a string naming a ZIP file archive. The ZIP archive can contain a subdirectory structure to support package imports, and a path within the archive can be specified to only import from a subdirectory. For example, the path \file{/tmp/example.zip/lib/} would only import from the \file{lib/} subdirectory within the archive. Any files may be present in the ZIP archive, but only files \file{.py} and \file{.py[co]} are available for import. ZIP import of dynamic modules (\file{.pyd}, \file{.so}) is disallowed. Note that if an archive only contains \file{.py} files, Python will not attempt to modify the archive by adding the corresponding \file{.pyc} or \file{.pyo} file, meaning that if a ZIP archive doesn't contain \file{.pyc} files, importing may be rather slow. Using the built-in \function{reload()} function will fail if called on a module loaded from a ZIP archive; it is unlikely that \function{reload()} would be needed, since this would imply that the ZIP has been altered during runtime. The available attributes of this module are: \begin{excdesc}{ZipImporterError} Exception raised by zipimporter objects. It's a subclass of \exception{ImportError}, so it can be caught as \exception{ImportError}, too. \end{excdesc} \begin{classdesc*}{zipimporter} The class for importing ZIP files. See ``\citetitle{zipimporter Objects}'' (section \ref{zipimporter-objects}) for constructor details. \end{classdesc*} \begin{seealso} \seetitle[http://www.pkware.com/appnote.html]{PKZIP Application Note}{Documentation on the ZIP file format by Phil Katz, the creator of the format and algorithms used.} \seepep{0273}{Import Modules from Zip Archives}{Written by James C. Ahlstrom, who also provided an implementation. Python 2.3 follows the specification in PEP 273, but uses an implementation written by Just van Rossum that uses the import hooks described in PEP 302.} \seepep{0302}{New Import Hooks}{The PEP to add the import hooks that help this module work.} \end{seealso} \subsection{zipimporter Objects \label{zipimporter-objects}} \begin{classdesc}{zipimporter}{archivepath} Create a new zipimporter instance. \var{archivepath} must be a path to a zipfile. \class{ZipImportError} is raised if \var{archivepath} doesn't point to a valid ZIP archive. \end{classdesc} \begin{methoddesc}{find_module}{fullname\optional{, path}} Search for a module specified by \var{fullname}. \var{fullname} must be the fully qualified (dotted) module name. It returns the zipimporter instance itself if the module was found, or \constant{None} if it wasn't. The optional \var{path} argument is ignored---it's there for compatibility with the importer protocol. \end{methoddesc} \begin{methoddesc}{get_code}{fullname} Return the code object for the specified module. Raise \class{ZipImportError} if the module couldn't be found. \end{methoddesc} \begin{methoddesc}{get_data}{pathname} Return the data associated with \var{pathname}. Raise \exception{IOError} if the file wasn't found. \end{methoddesc} \begin{methoddesc}{get_source}{fullname} Return the source code for the specified module. Raise \class{ZipImportError} if the module couldn't be found, return \constant{None} if the archive does contain the module, but has no source for it. \end{methoddesc} \begin{methoddesc}{is_package}{fullname} Return True if the module specified by \var{fullname} is a package. Raise \class{ZipImportError} if the module couldn't be found. \end{methoddesc} \begin{methoddesc}{load_module}{fullname} Load the module specified by \var{fullname}. \var{fullname} must be the fully qualified (dotted) module name. It returns the imported module, or raises \class{ZipImportError} if it wasn't found. \end{methoddesc} \subsection{Examples} \nodename{zipimport Examples} Here is an example that imports a module from a ZIP archive - note that the \module{zipimport} module is not explicitly used. \begin{verbatim} $ unzip -l /tmp/example.zip Archive: /tmp/example.zip Length Date Time Name -------- ---- ---- ---- 8467 11-26-02 22:30 jwzthreading.py -------- ------- 8467 1 file $ ./python Python 2.3 (#1, Aug 1 2003, 19:54:32) >>> import sys >>> sys.path.insert(0, '/tmp/example.zip') # Add .zip file to front of path >>> import jwzthreading >>> jwzthreading.__file__ '/tmp/example.zip/jwzthreading.py' \end{verbatim} Index: lib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/lib.tex,v retrieving revision 1.235 retrieving revision 1.236 diff -u -d -r1.235 -r1.236 --- lib.tex 16 Jan 2005 20:48:27 -0000 1.235 +++ lib.tex 19 Jan 2005 05:42:51 -0000 1.236 @@ -91,6 +91,7 @@ \input{libmarshal} \input{libwarnings} \input{libimp} +\input{libzipimport} \input{libpkgutil} \input{libcode} \input{libcodeop} From kbk at users.sourceforge.net Wed Jan 19 06:53:35 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Wed Jan 19 06:53:38 2005 Subject: [Python-checkins] python/dist/src/Lib/idlelib NEWS.txt, 1.23.4.13, 1.23.4.14 configDialog.py, 1.55, 1.55.6.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19376 Modified Files: Tag: release23-maint NEWS.txt configDialog.py Log Message: Backport configDialog.py rev 1.60: Saving a Keyset w/o making changes (by using the "Save as New Custom Key Set" button) caused IDLE to fail on restart (no new keyset was created in config-keys.cfg). Also true for Theme/highlights. Python Bug 1064535. M NEWS.txt M configDialog.py Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.23.4.13 retrieving revision 1.23.4.14 diff -u -d -r1.23.4.13 -r1.23.4.14 --- NEWS.txt 19 Jan 2005 04:12:38 -0000 1.23.4.13 +++ NEWS.txt 19 Jan 2005 05:53:32 -0000 1.23.4.14 @@ -3,6 +3,10 @@ *Release date: XX-Jan-2005* +- Saving a Keyset w/o making changes (by using the "Save as New Custom Key Set" + button) caused IDLE to fail on restart (no new keyset was created in + config-keys.cfg). Also true for Theme/highlights. Python Bug 1064535. + - checking sys.platform for substring 'win' was breaking IDLE docs on Mac (darwin). Also, Mac Safari browser requires full file:// URIs. Backport of fix for SF 900580. Index: configDialog.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/configDialog.py,v retrieving revision 1.55 retrieving revision 1.55.6.1 diff -u -d -r1.55 -r1.55.6.1 --- configDialog.py 9 Jul 2003 18:48:24 -0000 1.55 +++ configDialog.py 19 Jan 2005 05:53:32 -0000 1.55.6.1 @@ -1143,6 +1143,9 @@ cfgTypeHasChanges = True if cfgTypeHasChanges: idleConf.userCfg[configType].Save() + for configType in ['keys', 'highlight']: + # save these even if unchanged! + idleConf.userCfg[configType].Save() self.ResetChangedItems() #clear the changed items dict def ActivateConfigChanges(self): From fdrake at users.sourceforge.net Wed Jan 19 06:54:38 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jan 19 06:54:41 2005 Subject: [Python-checkins] python/dist/src/Doc Makefile.deps, 1.119, 1.119.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19736 Modified Files: Tag: release24-maint Makefile.deps Log Message: documentation for the zipimport module using contributed patch (closes SF bug #853800; markup adjusted) Index: Makefile.deps =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile.deps,v retrieving revision 1.119 retrieving revision 1.119.2.1 diff -u -d -r1.119 -r1.119.2.1 --- Makefile.deps 24 Nov 2004 14:57:04 -0000 1.119 +++ Makefile.deps 19 Jan 2005 05:54:35 -0000 1.119.2.1 @@ -125,6 +125,7 @@ lib/libmarshal.tex \ lib/libwarnings.tex \ lib/libimp.tex \ + lib/libzipimport.tex \ lib/libpkgutil.tex \ lib/libparser.tex \ lib/libbltin.tex \ From fdrake at users.sourceforge.net Wed Jan 19 06:54:39 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jan 19 06:54:44 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libzipimport.tex, NONE, 1.1.2.1 lib.tex, 1.231, 1.231.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19736/lib Modified Files: Tag: release24-maint lib.tex Added Files: Tag: release24-maint libzipimport.tex Log Message: documentation for the zipimport module using contributed patch (closes SF bug #853800; markup adjusted) --- NEW FILE: libzipimport.tex --- \section{\module{zipimport} --- Import modules from Zip archives} \declaremodule{standard}{zipimport} \modulesynopsis{support for importing Python modules from ZIP archives.} \moduleauthor{Just van Rossum}{just@letterror.com} \versionadded{2.3} This module adds the ability to import Python modules (\file{*.py}, \file{*.py[co]}) and packages from ZIP-format archives. It is usually not needed to use the \module{zipimport} module explicitly; it is automatically used by the builtin \keyword{import} mechanism for \code{sys.path} items that are paths to ZIP archives. Typically, \code{sys.path} is a list of directory names as strings. This module also allows an item of \code{sys.path} to be a string naming a ZIP file archive. The ZIP archive can contain a subdirectory structure to support package imports, and a path within the archive can be specified to only import from a subdirectory. For example, the path \file{/tmp/example.zip/lib/} would only import from the \file{lib/} subdirectory within the archive. Any files may be present in the ZIP archive, but only files \file{.py} and \file{.py[co]} are available for import. ZIP import of dynamic modules (\file{.pyd}, \file{.so}) is disallowed. Note that if an archive only contains \file{.py} files, Python will not attempt to modify the archive by adding the corresponding \file{.pyc} or \file{.pyo} file, meaning that if a ZIP archive doesn't contain \file{.pyc} files, importing may be rather slow. Using the built-in \function{reload()} function will fail if called on a module loaded from a ZIP archive; it is unlikely that \function{reload()} would be needed, since this would imply that the ZIP has been altered during runtime. The available attributes of this module are: \begin{excdesc}{ZipImporterError} Exception raised by zipimporter objects. It's a subclass of \exception{ImportError}, so it can be caught as \exception{ImportError}, too. \end{excdesc} \begin{classdesc*}{zipimporter} The class for importing ZIP files. See ``\citetitle{zipimporter Objects}'' (section \ref{zipimporter-objects}) for constructor details. \end{classdesc*} \begin{seealso} \seetitle[http://www.pkware.com/appnote.html]{PKZIP Application Note}{Documentation on the ZIP file format by Phil Katz, the creator of the format and algorithms used.} \seepep{0273}{Import Modules from Zip Archives}{Written by James C. Ahlstrom, who also provided an implementation. Python 2.3 follows the specification in PEP 273, but uses an implementation written by Just van Rossum that uses the import hooks described in PEP 302.} \seepep{0302}{New Import Hooks}{The PEP to add the import hooks that help this module work.} \end{seealso} \subsection{zipimporter Objects \label{zipimporter-objects}} \begin{classdesc}{zipimporter}{archivepath} Create a new zipimporter instance. \var{archivepath} must be a path to a zipfile. \class{ZipImportError} is raised if \var{archivepath} doesn't point to a valid ZIP archive. \end{classdesc} \begin{methoddesc}{find_module}{fullname\optional{, path}} Search for a module specified by \var{fullname}. \var{fullname} must be the fully qualified (dotted) module name. It returns the zipimporter instance itself if the module was found, or \constant{None} if it wasn't. The optional \var{path} argument is ignored---it's there for compatibility with the importer protocol. \end{methoddesc} \begin{methoddesc}{get_code}{fullname} Return the code object for the specified module. Raise \class{ZipImportError} if the module couldn't be found. \end{methoddesc} \begin{methoddesc}{get_data}{pathname} Return the data associated with \var{pathname}. Raise \exception{IOError} if the file wasn't found. \end{methoddesc} \begin{methoddesc}{get_source}{fullname} Return the source code for the specified module. Raise \class{ZipImportError} if the module couldn't be found, return \constant{None} if the archive does contain the module, but has no source for it. \end{methoddesc} \begin{methoddesc}{is_package}{fullname} Return True if the module specified by \var{fullname} is a package. Raise \class{ZipImportError} if the module couldn't be found. \end{methoddesc} \begin{methoddesc}{load_module}{fullname} Load the module specified by \var{fullname}. \var{fullname} must be the fully qualified (dotted) module name. It returns the imported module, or raises \class{ZipImportError} if it wasn't found. \end{methoddesc} \subsection{Examples} \nodename{zipimport Examples} Here is an example that imports a module from a ZIP archive - note that the \module{zipimport} module is not explicitly used. \begin{verbatim} $ unzip -l /tmp/example.zip Archive: /tmp/example.zip Length Date Time Name -------- ---- ---- ---- 8467 11-26-02 22:30 jwzthreading.py -------- ------- 8467 1 file $ ./python Python 2.3 (#1, Aug 1 2003, 19:54:32) >>> import sys >>> sys.path.insert(0, '/tmp/example.zip') # Add .zip file to front of path >>> import jwzthreading >>> jwzthreading.__file__ '/tmp/example.zip/jwzthreading.py' \end{verbatim} Index: lib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/lib.tex,v retrieving revision 1.231 retrieving revision 1.231.2.1 diff -u -d -r1.231 -r1.231.2.1 --- lib.tex 17 Oct 2004 16:29:48 -0000 1.231 +++ lib.tex 19 Jan 2005 05:54:36 -0000 1.231.2.1 @@ -91,6 +91,7 @@ \input{libmarshal} \input{libwarnings} \input{libimp} +\input{libzipimport} \input{libpkgutil} \input{libcode} \input{libcodeop} From fdrake at users.sourceforge.net Wed Jan 19 07:03:32 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jan 19 07:03:36 2005 Subject: [Python-checkins] python/dist/src/Doc Makefile.deps, 1.110.8.3, 1.110.8.4 Message-ID: Update of /cvsroot/python/python/dist/src/Doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21353 Modified Files: Tag: release23-maint Makefile.deps Log Message: documentation for the zipimport module using contributed patch (closes SF bug #853800; markup adjusted) Index: Makefile.deps =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile.deps,v retrieving revision 1.110.8.3 retrieving revision 1.110.8.4 diff -u -d -r1.110.8.3 -r1.110.8.4 --- Makefile.deps 5 Dec 2003 16:44:01 -0000 1.110.8.3 +++ Makefile.deps 19 Jan 2005 06:03:27 -0000 1.110.8.4 @@ -124,6 +124,7 @@ lib/libmarshal.tex \ lib/libwarnings.tex \ lib/libimp.tex \ + lib/libzipimport.tex \ lib/libpkgutil.tex \ lib/libparser.tex \ lib/libbltin.tex \ From fdrake at users.sourceforge.net Wed Jan 19 07:03:34 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jan 19 07:03:38 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libzipimport.tex, NONE, 1.1.4.1 lib.tex, 1.223, 1.223.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21353/lib Modified Files: Tag: release23-maint lib.tex Added Files: Tag: release23-maint libzipimport.tex Log Message: documentation for the zipimport module using contributed patch (closes SF bug #853800; markup adjusted) --- NEW FILE: libzipimport.tex --- \section{\module{zipimport} --- Import modules from Zip archives} \declaremodule{standard}{zipimport} \modulesynopsis{support for importing Python modules from ZIP archives.} \moduleauthor{Just van Rossum}{just@letterror.com} \versionadded{2.3} This module adds the ability to import Python modules (\file{*.py}, \file{*.py[co]}) and packages from ZIP-format archives. It is usually not needed to use the \module{zipimport} module explicitly; it is automatically used by the builtin \keyword{import} mechanism for \code{sys.path} items that are paths to ZIP archives. Typically, \code{sys.path} is a list of directory names as strings. This module also allows an item of \code{sys.path} to be a string naming a ZIP file archive. The ZIP archive can contain a subdirectory structure to support package imports, and a path within the archive can be specified to only import from a subdirectory. For example, the path \file{/tmp/example.zip/lib/} would only import from the \file{lib/} subdirectory within the archive. Any files may be present in the ZIP archive, but only files \file{.py} and \file{.py[co]} are available for import. ZIP import of dynamic modules (\file{.pyd}, \file{.so}) is disallowed. Note that if an archive only contains \file{.py} files, Python will not attempt to modify the archive by adding the corresponding \file{.pyc} or \file{.pyo} file, meaning that if a ZIP archive doesn't contain \file{.pyc} files, importing may be rather slow. Using the built-in \function{reload()} function will fail if called on a module loaded from a ZIP archive; it is unlikely that \function{reload()} would be needed, since this would imply that the ZIP has been altered during runtime. The available attributes of this module are: \begin{excdesc}{ZipImporterError} Exception raised by zipimporter objects. It's a subclass of \exception{ImportError}, so it can be caught as \exception{ImportError}, too. \end{excdesc} \begin{classdesc*}{zipimporter} The class for importing ZIP files. See ``\citetitle{zipimporter Objects}'' (section \ref{zipimporter-objects}) for constructor details. \end{classdesc*} \begin{seealso} \seetitle[http://www.pkware.com/appnote.html]{PKZIP Application Note}{Documentation on the ZIP file format by Phil Katz, the creator of the format and algorithms used.} \seepep{0273}{Import Modules from Zip Archives}{Written by James C. Ahlstrom, who also provided an implementation. Python 2.3 follows the specification in PEP 273, but uses an implementation written by Just van Rossum that uses the import hooks described in PEP 302.} \seepep{0302}{New Import Hooks}{The PEP to add the import hooks that help this module work.} \end{seealso} \subsection{zipimporter Objects \label{zipimporter-objects}} \begin{classdesc}{zipimporter}{archivepath} Create a new zipimporter instance. \var{archivepath} must be a path to a zipfile. \class{ZipImportError} is raised if \var{archivepath} doesn't point to a valid ZIP archive. \end{classdesc} \begin{methoddesc}{find_module}{fullname\optional{, path}} Search for a module specified by \var{fullname}. \var{fullname} must be the fully qualified (dotted) module name. It returns the zipimporter instance itself if the module was found, or \constant{None} if it wasn't. The optional \var{path} argument is ignored---it's there for compatibility with the importer protocol. \end{methoddesc} \begin{methoddesc}{get_code}{fullname} Return the code object for the specified module. Raise \class{ZipImportError} if the module couldn't be found. \end{methoddesc} \begin{methoddesc}{get_data}{pathname} Return the data associated with \var{pathname}. Raise \exception{IOError} if the file wasn't found. \end{methoddesc} \begin{methoddesc}{get_source}{fullname} Return the source code for the specified module. Raise \class{ZipImportError} if the module couldn't be found, return \constant{None} if the archive does contain the module, but has no source for it. \end{methoddesc} \begin{methoddesc}{is_package}{fullname} Return True if the module specified by \var{fullname} is a package. Raise \class{ZipImportError} if the module couldn't be found. \end{methoddesc} \begin{methoddesc}{load_module}{fullname} Load the module specified by \var{fullname}. \var{fullname} must be the fully qualified (dotted) module name. It returns the imported module, or raises \class{ZipImportError} if it wasn't found. \end{methoddesc} \subsection{Examples} \nodename{zipimport Examples} Here is an example that imports a module from a ZIP archive - note that the \module{zipimport} module is not explicitly used. \begin{verbatim} $ unzip -l /tmp/example.zip Archive: /tmp/example.zip Length Date Time Name -------- ---- ---- ---- 8467 11-26-02 22:30 jwzthreading.py -------- ------- 8467 1 file $ ./python Python 2.3 (#1, Aug 1 2003, 19:54:32) >>> import sys >>> sys.path.insert(0, '/tmp/example.zip') # Add .zip file to front of path >>> import jwzthreading >>> jwzthreading.__file__ '/tmp/example.zip/jwzthreading.py' \end{verbatim} Index: lib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/lib.tex,v retrieving revision 1.223 retrieving revision 1.223.8.1 diff -u -d -r1.223 -r1.223.8.1 --- lib.tex 14 Jul 2003 12:13:27 -0000 1.223 +++ lib.tex 19 Jan 2005 06:03:29 -0000 1.223.8.1 @@ -91,6 +91,7 @@ \input{libmarshal} \input{libwarnings} \input{libimp} +\input{libzipimport} \input{libpkgutil} \input{libcode} \input{libcodeop} From fdrake at users.sourceforge.net Wed Jan 19 07:23:41 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jan 19 07:23:44 2005 Subject: [Python-checkins] python/dist/src Makefile.pre.in,1.148,1.148.2.1 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25435 Modified Files: Tag: release24-maint Makefile.pre.in Log Message: install distutils.tests on Unix (contributed patch) (closes SF bug #1093173) Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.pre.in,v retrieving revision 1.148 retrieving revision 1.148.2.1 diff -u -d -r1.148 -r1.148.2.1 --- Makefile.pre.in 26 Sep 2004 17:26:55 -0000 1.148 +++ Makefile.pre.in 19 Jan 2005 06:23:38 -0000 1.148.2.1 @@ -661,7 +661,8 @@ test/decimaltestdata \ encodings email email/test email/test/data compiler hotshot \ logging bsddb bsddb/test csv idlelib idlelib/Icons \ - distutils distutils/command $(XMLLIBSUBDIRS) curses $(MACHDEPS) + distutils distutils/command distutils/tests $(XMLLIBSUBDIRS) \ + curses $(MACHDEPS) libinstall: $(BUILDPYTHON) $(srcdir)/Lib/$(PLATDIR) @for i in $(SCRIPTDIR) $(LIBDEST); \ do \ From kbk at users.sourceforge.net Wed Jan 19 07:23:55 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Wed Jan 19 07:23:58 2005 Subject: [Python-checkins] python/dist/src/Lib/idlelib NEWS.txt, 1.23.4.14, 1.23.4.15 run.py, 1.25.8.2, 1.25.8.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25411 Modified Files: Tag: release23-maint NEWS.txt run.py Log Message: On OpenBSD, terminating IDLE with ctrl-c from the command line caused a stuck subprocess MainThread because only the SocketThread was exiting. M NEWS.txt M run.py Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.23.4.14 retrieving revision 1.23.4.15 diff -u -d -r1.23.4.14 -r1.23.4.15 --- NEWS.txt 19 Jan 2005 05:53:32 -0000 1.23.4.14 +++ NEWS.txt 19 Jan 2005 06:23:51 -0000 1.23.4.15 @@ -3,13 +3,15 @@ *Release date: XX-Jan-2005* +- On OpenBSD, terminating IDLE with ctrl-c from the command line caused a + stuck subprocess MainThread because only the SocketThread was exiting. + - Saving a Keyset w/o making changes (by using the "Save as New Custom Key Set" button) caused IDLE to fail on restart (no new keyset was created in config-keys.cfg). Also true for Theme/highlights. Python Bug 1064535. - checking sys.platform for substring 'win' was breaking IDLE docs on Mac - (darwin). Also, Mac Safari browser requires full file:// URIs. Backport of - fix for SF 900580. + (darwin). Also, Mac Safari browser requires full file:// URIs. SF 900580. - rpc.py:SocketIO - Large modules were generating large pickles when downloaded to the execution server. The return of the OK response from the subprocess Index: run.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/run.py,v retrieving revision 1.25.8.2 retrieving revision 1.25.8.3 diff -u -d -r1.25.8.2 -r1.25.8.3 --- run.py 6 Jun 2004 17:41:41 -0000 1.25.8.2 +++ run.py 19 Jan 2005 06:23:51 -0000 1.25.8.3 @@ -196,6 +196,7 @@ Interrupt the MainThread and exit server if link is dropped. """ + global quitting try: raise except SystemExit: @@ -214,7 +215,8 @@ traceback.print_exc(file=erf) print>>erf, '\n*** Unrecoverable, server exiting!' print>>erf, '-'*40 - exit() + quitting = True + thread.interrupt_main() class MyHandler(rpc.RPCHandler): From fdrake at users.sourceforge.net Wed Jan 19 07:25:01 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jan 19 07:25:04 2005 Subject: [Python-checkins] python/dist/src Makefile.pre.in,1.149,1.150 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25781 Modified Files: Makefile.pre.in Log Message: install distutils.tests on Unix (contributed patch) (closes SF bug #1093173) Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.pre.in,v retrieving revision 1.149 retrieving revision 1.150 diff -u -d -r1.149 -r1.150 --- Makefile.pre.in 7 Dec 2004 00:42:58 -0000 1.149 +++ Makefile.pre.in 19 Jan 2005 06:24:58 -0000 1.150 @@ -664,7 +664,8 @@ test/decimaltestdata \ encodings email email/test email/test/data compiler hotshot \ logging bsddb bsddb/test csv idlelib idlelib/Icons \ - distutils distutils/command $(XMLLIBSUBDIRS) curses $(MACHDEPS) + distutils distutils/command distutils/tests $(XMLLIBSUBDIRS) \ + curses $(MACHDEPS) libinstall: $(BUILDPYTHON) $(srcdir)/Lib/$(PLATDIR) @for i in $(SCRIPTDIR) $(LIBDEST); \ do \ From fdrake at users.sourceforge.net Wed Jan 19 08:22:16 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jan 19 08:22:19 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libsets.tex, 1.11.16.3, 1.11.16.4 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5192/lib Modified Files: Tag: release23-maint libsets.tex Log Message: fix typeset of vertical bar for PDF format (closes SF bug #1008998) Index: libsets.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsets.tex,v retrieving revision 1.11.16.3 retrieving revision 1.11.16.4 diff -u -d -r1.11.16.3 -r1.11.16.4 --- libsets.tex 7 Dec 2003 11:06:31 -0000 1.11.16.3 +++ libsets.tex 19 Jan 2005 07:22:13 -0000 1.11.16.4 @@ -79,7 +79,7 @@ {test whether every element in \var{t} is in \var{s}} \hline - \lineiii{\var{s}.union(\var{t})}{\var{s} | \var{t}} + \lineiii{\var{s}.union(\var{t})}{\var{s} \textbar{} \var{t}} {new set with elements from both \var{s} and \var{t}} \lineiii{\var{s}.intersection(\var{t})}{\var{s} \&\ \var{t}} {new set with elements common to \var{s} and \var{t}} @@ -131,7 +131,7 @@ \begin{tableiii}{c|c|l}{code}{Operation}{Equivalent}{Result} \lineiii{\var{s}.union_update(\var{t})} - {\var{s} |= \var{t}} + {\var{s} \textbar= \var{t}} {return set \var{s} with elements added from \var{t}} \lineiii{\var{s}.intersection_update(\var{t})} {\var{s} \&= \var{t}} From fdrake at users.sourceforge.net Wed Jan 19 08:23:38 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jan 19 08:23:41 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libsets.tex, 1.15, 1.15.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5478/lib Modified Files: Tag: release24-maint libsets.tex Log Message: fix typeset of vertical bar for PDF format (closes SF bug #1008998) Index: libsets.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsets.tex,v retrieving revision 1.15 retrieving revision 1.15.4.1 diff -u -d -r1.15 -r1.15.4.1 --- libsets.tex 26 Nov 2003 17:52:45 -0000 1.15 +++ libsets.tex 19 Jan 2005 07:23:35 -0000 1.15.4.1 @@ -79,7 +79,7 @@ {test whether every element in \var{t} is in \var{s}} \hline - \lineiii{\var{s}.union(\var{t})}{\var{s} | \var{t}} + \lineiii{\var{s}.union(\var{t})}{\var{s} \textbar{} \var{t}} {new set with elements from both \var{s} and \var{t}} \lineiii{\var{s}.intersection(\var{t})}{\var{s} \&\ \var{t}} {new set with elements common to \var{s} and \var{t}} @@ -131,7 +131,7 @@ \begin{tableiii}{c|c|l}{code}{Operation}{Equivalent}{Result} \lineiii{\var{s}.union_update(\var{t})} - {\var{s} |= \var{t}} + {\var{s} \textbar= \var{t}} {return set \var{s} with elements added from \var{t}} \lineiii{\var{s}.intersection_update(\var{t})} {\var{s} \&= \var{t}} From fdrake at users.sourceforge.net Wed Jan 19 08:24:36 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Wed Jan 19 08:24:40 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libsets.tex,1.15,1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5678/lib Modified Files: libsets.tex Log Message: fix typeset of vertical bar for PDF format (closes SF bug #1008998) Index: libsets.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsets.tex,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- libsets.tex 26 Nov 2003 17:52:45 -0000 1.15 +++ libsets.tex 19 Jan 2005 07:24:34 -0000 1.16 @@ -79,7 +79,7 @@ {test whether every element in \var{t} is in \var{s}} \hline - \lineiii{\var{s}.union(\var{t})}{\var{s} | \var{t}} + \lineiii{\var{s}.union(\var{t})}{\var{s} \textbar{} \var{t}} {new set with elements from both \var{s} and \var{t}} \lineiii{\var{s}.intersection(\var{t})}{\var{s} \&\ \var{t}} {new set with elements common to \var{s} and \var{t}} @@ -131,7 +131,7 @@ \begin{tableiii}{c|c|l}{code}{Operation}{Equivalent}{Result} \lineiii{\var{s}.union_update(\var{t})} - {\var{s} |= \var{t}} + {\var{s} \textbar= \var{t}} {return set \var{s} with elements added from \var{t}} \lineiii{\var{s}.intersection_update(\var{t})} {\var{s} \&= \var{t}} From kbk at users.sourceforge.net Wed Jan 19 18:13:13 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Wed Jan 19 18:13:17 2005 Subject: [Python-checkins] python/dist/src/Lib/idlelib NEWS.txt, 1.49.2.1, 1.49.2.2 configHandler.py, 1.35, 1.35.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23540 Modified Files: Tag: release24-maint NEWS.txt configHandler.py Log Message: Improve error handling when .idlerc can't be created (warn and exit) Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.49.2.1 retrieving revision 1.49.2.2 diff -u -d -r1.49.2.1 -r1.49.2.2 --- NEWS.txt 23 Dec 2004 04:32:25 -0000 1.49.2.1 +++ NEWS.txt 19 Jan 2005 17:12:45 -0000 1.49.2.2 @@ -1,7 +1,9 @@ What's New in IDLE 1.1.1? ======================= -*Release date: XX-DEC-2004* +*Release date: XX-JAN-2005* + +- Improve error handling when .idlerc can't be created (warn and exit) - The GUI was hanging if the shell window was closed while a raw_input() was pending. Restored the quit() of the readline() mainloop(). Index: configHandler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/configHandler.py,v retrieving revision 1.35 retrieving revision 1.35.4.1 diff -u -d -r1.35 -r1.35.4.1 --- configHandler.py 6 Jun 2004 01:29:22 -0000 1.35 +++ configHandler.py 19 Jan 2005 17:12:49 -0000 1.35.4.1 @@ -193,26 +193,28 @@ """ Creates (if required) and returns a filesystem directory for storing user config files. + """ - cfgDir='.idlerc' - userDir=os.path.expanduser('~') - if userDir != '~': #'HOME' exists as a key in os.environ + cfgDir = '.idlerc' + userDir = os.path.expanduser('~') + if userDir != '~': # expanduser() found user home dir if not os.path.exists(userDir): - warn=('\n Warning: HOME environment variable points to\n '+ - userDir+'\n but the path does not exist.\n') + warn = ('\n Warning: os.path.expanduser("~") points to\n '+ + userDir+',\n but the path does not exist.\n') sys.stderr.write(warn) - userDir='~' - if userDir=='~': #we still don't have a home directory - #traditionally idle has defaulted to os.getcwd(), is this adeqate? - userDir = os.getcwd() #hack for no real homedir - userDir=os.path.join(userDir,cfgDir) + userDir = '~' + if userDir == "~": # still no path to home! + # traditionally IDLE has defaulted to os.getcwd(), is this adequate? + userDir = os.getcwd() + userDir = os.path.join(userDir, cfgDir) if not os.path.exists(userDir): - try: #make the config dir if it doesn't exist yet + try: os.mkdir(userDir) - except IOError: - warn=('\n Warning: unable to create user config directory\n '+ - userDir+'\n') + except (OSError, IOError): + warn = ('\n Warning: unable to create user config directory\n'+ + userDir+'\n Check path and permissions.\n Exiting!\n\n') sys.stderr.write(warn) + raise SystemExit return userDir def GetOption(self, configType, section, option, default=None, type=None, From kbk at users.sourceforge.net Wed Jan 19 18:25:24 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Wed Jan 19 18:25:29 2005 Subject: [Python-checkins] python/dist/src/Lib/idlelib EditorWindow.py, 1.62, 1.62.2.1 NEWS.txt, 1.49.2.2, 1.49.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26431 Modified Files: Tag: release24-maint EditorWindow.py NEWS.txt Log Message: If an extension can't be loaded, print warning and skip it instead of erroring out. Index: EditorWindow.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/EditorWindow.py,v retrieving revision 1.62 retrieving revision 1.62.2.1 diff -u -d -r1.62 -r1.62.2.1 --- EditorWindow.py 22 Aug 2004 05:14:31 -0000 1.62 +++ EditorWindow.py 19 Jan 2005 17:24:46 -0000 1.62.2.1 @@ -744,7 +744,11 @@ return idleConf.GetExtensions(editor_only=True) def load_extension(self, name): - mod = __import__(name, globals(), locals(), []) + try: + mod = __import__(name, globals(), locals(), []) + except ImportError: + print "\nFailed to import extension: ", name + return None cls = getattr(mod, name) keydefs = idleConf.GetExtensionBindings(name) if hasattr(cls, "menudefs"): Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.49.2.2 retrieving revision 1.49.2.3 diff -u -d -r1.49.2.2 -r1.49.2.3 --- NEWS.txt 19 Jan 2005 17:12:45 -0000 1.49.2.2 +++ NEWS.txt 19 Jan 2005 17:25:05 -0000 1.49.2.3 @@ -3,6 +3,9 @@ *Release date: XX-JAN-2005* +- If an extension can't be loaded, print warning and skip it instead of + erroring out. + - Improve error handling when .idlerc can't be created (warn and exit) - The GUI was hanging if the shell window was closed while a raw_input() From theller at users.sourceforge.net Thu Jan 20 20:14:34 2005 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Thu Jan 20 20:14:37 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils/command install.py, 1.72, 1.73 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32371 Modified Files: install.py Log Message: Fix [ 1103844 ] fix distutils.install.dump_dirs() with negated options. Will backport myself. Index: install.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/install.py,v retrieving revision 1.72 retrieving revision 1.73 diff -u -d -r1.72 -r1.73 --- install.py 10 Nov 2004 22:23:15 -0000 1.72 +++ install.py 20 Jan 2005 19:14:17 -0000 1.73 @@ -352,8 +352,13 @@ opt_name = opt[0] if opt_name[-1] == "=": opt_name = opt_name[0:-1] - opt_name = string.translate(opt_name, longopt_xlate) - val = getattr(self, opt_name) + if self.negative_opt.has_key(opt_name): + opt_name = string.translate(self.negative_opt[opt_name], + longopt_xlate) + val = not getattr(self, opt_name) + else: + opt_name = string.translate(opt_name, longopt_xlate) + val = getattr(self, opt_name) print " %s: %s" % (opt_name, val) From theller at users.sourceforge.net Thu Jan 20 20:15:44 2005 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Thu Jan 20 20:15:46 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils/command install.py, 1.72, 1.72.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32599 Modified Files: Tag: release24-maint install.py Log Message: Fix [ 1103844 ] fix distutils.install.dump_dirs() with negated options. Backport from trunk. Index: install.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/install.py,v retrieving revision 1.72 retrieving revision 1.72.2.1 diff -u -d -r1.72 -r1.72.2.1 --- install.py 10 Nov 2004 22:23:15 -0000 1.72 +++ install.py 20 Jan 2005 19:15:39 -0000 1.72.2.1 @@ -352,8 +352,13 @@ opt_name = opt[0] if opt_name[-1] == "=": opt_name = opt_name[0:-1] - opt_name = string.translate(opt_name, longopt_xlate) - val = getattr(self, opt_name) + if self.negative_opt.has_key(opt_name): + opt_name = string.translate(self.negative_opt[opt_name], + longopt_xlate) + val = not getattr(self, opt_name) + else: + opt_name = string.translate(opt_name, longopt_xlate) + val = getattr(self, opt_name) print " %s: %s" % (opt_name, val) From theller at users.sourceforge.net Thu Jan 20 20:16:33 2005 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Thu Jan 20 20:16:37 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils/command install.py, 1.67, 1.67.14.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv438 Modified Files: Tag: release23-maint install.py Log Message: Fix [ 1103844 ] fix distutils.install.dump_dirs() with negated options. Backport from trunk. Index: install.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/install.py,v retrieving revision 1.67 retrieving revision 1.67.14.1 diff -u -d -r1.67 -r1.67.14.1 --- install.py 19 Nov 2002 13:12:28 -0000 1.67 +++ install.py 20 Jan 2005 19:16:27 -0000 1.67.14.1 @@ -356,8 +356,13 @@ opt_name = opt[0] if opt_name[-1] == "=": opt_name = opt_name[0:-1] - opt_name = string.translate(opt_name, longopt_xlate) - val = getattr(self, opt_name) + if self.negative_opt.has_key(opt_name): + opt_name = string.translate(self.negative_opt[opt_name], + longopt_xlate) + val = not getattr(self, opt_name) + else: + opt_name = string.translate(opt_name, longopt_xlate) + val = getattr(self, opt_name) print " %s: %s" % (opt_name, val) From theller at users.sourceforge.net Thu Jan 20 20:20:51 2005 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Thu Jan 20 20:20:54 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1228,1.1229 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1369 Modified Files: NEWS Log Message: distutils/command/install.py change. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1228 retrieving revision 1.1229 diff -u -d -r1.1228 -r1.1229 --- NEWS 16 Jan 2005 20:48:24 -0000 1.1228 +++ NEWS 20 Jan 2005 19:20:16 -0000 1.1229 @@ -39,6 +39,8 @@ Library ------- +- Bug #1103844: fix distutils.install.dump_dirs() with negated options. + - os.{SEEK_SET, SEEK_CUR, SEEK_END} have been added for convenience. - Enhancements to the csv module: From theller at users.sourceforge.net Thu Jan 20 20:21:35 2005 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Thu Jan 20 20:21:38 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.13, 1.1193.2.14 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1621 Modified Files: Tag: release24-maint NEWS Log Message: distutils/command/install.py change. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.13 retrieving revision 1.1193.2.14 diff -u -d -r1.1193.2.13 -r1.1193.2.14 --- NEWS 7 Jan 2005 14:19:30 -0000 1.1193.2.13 +++ NEWS 20 Jan 2005 19:21:24 -0000 1.1193.2.14 @@ -22,6 +22,8 @@ Library ------- +- Bug #1103844: fix distutils.install.dump_dirs() with negated options. + - Bug #1067732: wininst --install-script doesn't leave residual files anymore. - StringIO.truncate() now correctly adjusts the size attribute. From theller at users.sourceforge.net Thu Jan 20 20:22:15 2005 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Thu Jan 20 20:22:18 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.162, 1.831.4.163 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1771 Modified Files: Tag: release23-maint NEWS Log Message: distutils/command/install.py change. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.162 retrieving revision 1.831.4.163 diff -u -d -r1.831.4.162 -r1.831.4.163 --- NEWS 17 Jan 2005 21:07:52 -0000 1.831.4.162 +++ NEWS 20 Jan 2005 19:22:12 -0000 1.831.4.163 @@ -73,6 +73,8 @@ Library ------- +- Bug #1103844: fix distutils.install.dump_dirs() with negated options. + - Bug #1067732: wininst --install-script doesn't leave residual files anymore. - Bug #1045381: strptime() now uses %U and %W for date calculations if the year From theller at users.sourceforge.net Thu Jan 20 20:25:28 2005 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Thu Jan 20 20:25:31 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils __init__.py, 1.26, 1.26.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2353 Modified Files: Tag: release24-maint __init__.py Log Message: Some bugs have been fixed in distutils, so increment the last part of the version number. For the distutils version numbering scheme, see http://mail.python.org/pipermail/distutils-sig/2005-January/004368.html Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/__init__.py,v retrieving revision 1.26 retrieving revision 1.26.2.1 diff -u -d -r1.26 -r1.26.2.1 --- __init__.py 10 Nov 2004 22:23:13 -0000 1.26 +++ __init__.py 20 Jan 2005 19:25:24 -0000 1.26.2.1 @@ -12,4 +12,4 @@ __revision__ = "$Id$" -__version__ = "2.4.0" +__version__ = "2.4.1" From theller at users.sourceforge.net Thu Jan 20 20:28:47 2005 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Thu Jan 20 20:28:49 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils __init__.py, 1.23, 1.23.14.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3082 Modified Files: Tag: release23-maint __init__.py Log Message: At least one bug has been fixed in distutils, so increment the last part of the version number. For the distutils version numbering scheme, see http://mail.python.org/pipermail/distutils-sig/2005-January/004368.html Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/__init__.py,v retrieving revision 1.23 retrieving revision 1.23.14.1 diff -u -d -r1.23 -r1.23.14.1 --- __init__.py 19 Nov 2002 13:12:26 -0000 1.23 +++ __init__.py 20 Jan 2005 19:28:44 -0000 1.23.14.1 @@ -12,4 +12,4 @@ __revision__ = "$Id$" -__version__ = "1.0.3" +__version__ = "1.0.4" From doerwalter at users.sourceforge.net Fri Jan 21 22:16:54 2005 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Fri Jan 21 22:16:57 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_array.py,1.31,1.32 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26707/Lib/test Modified Files: test_array.py Log Message: Add a slice test with high < low. Index: test_array.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_array.py,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- test_array.py 16 Dec 2004 16:23:40 -0000 1.31 +++ test_array.py 21 Jan 2005 21:16:51 -0000 1.32 @@ -428,6 +428,11 @@ ) self.assertEqual( + a[2:1], + array.array(self.typecode) + ) + + self.assertEqual( a[1000:], array.array(self.typecode) ) From bcannon at users.sourceforge.net Sat Jan 22 05:39:26 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Jan 22 05:39:30 2005 Subject: [Python-checkins] python/nondist/peps pep-3000.txt,1.9,1.10 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28238 Modified Files: pep-3000.txt Log Message: Mention the planned removal of unbound methods. Index: pep-3000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-3000.txt,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- pep-3000.txt 11 Dec 2004 18:06:27 -0000 1.9 +++ pep-3000.txt 22 Jan 2005 04:39:23 -0000 1.10 @@ -78,6 +78,7 @@ * String exceptions [2]_ * ```x```: use ``repr(x)`` [2]_ * The ``<>`` operator (use ``!=`` instead) [3]_ +* Unbound methods [7]_ Built-ins @@ -138,6 +139,9 @@ .. [6] python-dev email ("Comparing heterogeneous types") http://mail.python.org/pipermail/python-dev/2004-June/045111.html +.. [7] python-dev email ("Let's get rid of unbound methods") + http://mail.python.org/pipermail/python-dev/2005-January/050625.html + Copyright ========= From loewis at users.sourceforge.net Sun Jan 23 10:19:23 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Jan 23 10:19:26 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_os.py,1.27,1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19682/Lib/test Modified Files: test_os.py Log Message: Truncate st_?time before comparing it with ST_?TIME in the tests. Index: test_os.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_os.py,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- test_os.py 29 Aug 2004 18:47:31 -0000 1.27 +++ test_os.py 23 Jan 2005 09:19:20 -0000 1.28 @@ -111,7 +111,11 @@ for name in dir(stat): if name[:3] == 'ST_': attr = name.lower() - self.assertEquals(getattr(result, attr), + if name.endswith("TIME"): + def trunc(x): return int(x) + else: + def trunc(x): return x + self.assertEquals(trunc(getattr(result, attr)), result[getattr(stat, name)]) self.assert_(attr in members) From loewis at users.sourceforge.net Sun Jan 23 10:19:24 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Jan 23 10:19:30 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libos.tex,1.151,1.152 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19682/Doc/lib Modified Files: libos.tex Log Message: Truncate st_?time before comparing it with ST_?TIME in the tests. Index: libos.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libos.tex,v retrieving revision 1.151 retrieving revision 1.152 diff -u -d -r1.151 -r1.152 --- libos.tex 19 Jan 2005 03:39:16 -0000 1.151 +++ libos.tex 23 Jan 2005 09:19:22 -0000 1.152 @@ -1012,6 +1012,9 @@ it is False, future calls return ints. If newval is omitted, return the current setting. +For compatibility with older Python versions, accessing +\class{stat_result} as a tuple always returns integers. + \versionchanged[Python now returns float values by default. Applications which do not work correctly with floating point time stamps can use this function to restore the old behaviour]{2.5} From loewis at users.sourceforge.net Sun Jan 23 10:19:24 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Jan 23 10:19:31 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1229,1.1230 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19682/Misc Modified Files: NEWS Log Message: Truncate st_?time before comparing it with ST_?TIME in the tests. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1229 retrieving revision 1.1230 diff -u -d -r1.1229 -r1.1230 --- NEWS 20 Jan 2005 19:20:16 -0000 1.1229 +++ NEWS 23 Jan 2005 09:19:20 -0000 1.1230 @@ -151,6 +151,7 @@ Tests ----- +- In test_os, st_?time is now truncated before comparing it with ST_?TIME. Mac --- From loewis at users.sourceforge.net Sun Jan 23 10:27:25 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Jan 23 10:27:29 2005 Subject: [Python-checkins] python/dist/src/Doc Makefile.deps,1.122,1.123 Message-ID: Update of /cvsroot/python/python/dist/src/Doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21361/Doc Modified Files: Makefile.deps Log Message: Patch #579435: Shadow Password Support Module Index: Makefile.deps =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/Makefile.deps,v retrieving revision 1.122 retrieving revision 1.123 diff -u -d -r1.122 -r1.123 --- Makefile.deps 19 Jan 2005 05:42:50 -0000 1.122 +++ Makefile.deps 23 Jan 2005 09:27:22 -0000 1.123 @@ -164,6 +164,7 @@ lib/libposix.tex \ lib/libposixpath.tex \ lib/libpwd.tex \ + lib/libspwd.tex \ lib/libgrp.tex \ lib/libcrypt.tex \ lib/libdbm.tex \ From loewis at users.sourceforge.net Sun Jan 23 10:27:25 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Jan 23 10:27:30 2005 Subject: [Python-checkins] python/dist/src configure, 1.467, 1.468 configure.in, 1.480, 1.481 pyconfig.h.in, 1.105, 1.106 setup.py, 1.211, 1.212 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21361 Modified Files: configure configure.in pyconfig.h.in setup.py Log Message: Patch #579435: Shadow Password Support Module Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.467 retrieving revision 1.468 diff -u -d -r1.467 -r1.468 --- configure 7 Jan 2005 13:08:22 -0000 1.467 +++ configure 23 Jan 2005 09:27:17 -0000 1.468 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 1.479 . +# From configure.in Revision: 1.480 . # 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 [...2053 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. */ @@ -21065,6 +20854,12 @@ 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 Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.480 retrieving revision 1.481 diff -u -d -r1.480 -r1.481 --- configure.in 7 Jan 2005 13:08:21 -0000 1.480 +++ configure.in 23 Jan 2005 09:27:22 -0000 1.481 @@ -960,7 +960,7 @@ # checks for header files AC_HEADER_STDC -AC_CHECK_HEADERS(curses.h dlfcn.h fcntl.h grp.h langinfo.h \ +AC_CHECK_HEADERS(curses.h dlfcn.h fcntl.h grp.h shadow.h langinfo.h \ libintl.h ncurses.h poll.h pthread.h \ stropts.h termios.h thread.h \ unistd.h utime.h \ @@ -2076,7 +2076,7 @@ AC_CHECK_FUNCS(alarm bind_textdomain_codeset chown clock confstr ctermid \ execv fork fpathconf ftime ftruncate \ gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \ - getpriority getpwent getsid getwd \ + getpriority getpwent getspnam getspent getsid getwd \ kill killpg lchown lstat mkfifo mknod mktime \ mremap nice pathconf pause plock poll pthread_init \ putenv readlink realpath \ Index: pyconfig.h.in =================================================================== RCS file: /cvsroot/python/python/dist/src/pyconfig.h.in,v retrieving revision 1.105 retrieving revision 1.106 diff -u -d -r1.105 -r1.106 --- pyconfig.h.in 13 Oct 2004 15:30:55 -0000 1.105 +++ pyconfig.h.in 23 Jan 2005 09:27:22 -0000 1.106 @@ -215,6 +215,12 @@ /* Define to 1 if you have the `getsid' function. */ #undef HAVE_GETSID +/* Define to 1 if you have the `getspent' function. */ +#undef HAVE_GETSPENT + +/* Define to 1 if you have the `getspnam' function. */ +#undef HAVE_GETSPNAM + /* Define to 1 if you have the `gettimeofday' function. */ #undef HAVE_GETTIMEOFDAY @@ -419,6 +425,9 @@ /* Define to 1 if you have the `setvbuf' function. */ #undef HAVE_SETVBUF +/* Define to 1 if you have the header file. */ +#undef HAVE_SHADOW_H + /* Define to 1 if you have the `sigaction' function. */ #undef HAVE_SIGACTION Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.211 retrieving revision 1.212 diff -u -d -r1.211 -r1.212 --- setup.py 2 Jan 2005 21:54:07 -0000 1.211 +++ setup.py 23 Jan 2005 09:27:22 -0000 1.212 @@ -388,6 +388,8 @@ exts.append( Extension('pwd', ['pwdmodule.c']) ) # grp(3) exts.append( Extension('grp', ['grpmodule.c']) ) + # spwd, shadow passwords + exts.append( Extension('spwd', ['spwdmodule.c']) ) # select(2); not on ancient System V exts.append( Extension('select', ['selectmodule.c']) ) From loewis at users.sourceforge.net Sun Jan 23 10:27:26 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Jan 23 10:27:32 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libspwd.tex, NONE, 1.1 lib.tex, 1.236, 1.237 libpwd.tex, 1.14, 1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21361/Doc/lib Modified Files: lib.tex libpwd.tex Added Files: libspwd.tex Log Message: Patch #579435: Shadow Password Support Module --- NEW FILE: libspwd.tex --- \section{\module{spwd} --- The shadow password database} \declaremodule{builtin}{spwd} \platform{Unix} \modulesynopsis{The shadow password database (\function{getspnam()} and friends).} This module provides access to the \UNIX{} shadow password database. It is available on various Unix versions. You must have enough privileges to access the shadow password database (this usually means you have to be root). Shadow password database entries are reported as a tuple-like object, whose attributes correspond to the members of the \code{spwd} structure (Attribute field below, see \code{}): \begin{tableiii}{r|l|l}{textrm}{Index}{Attribute}{Meaning} \lineiii{0}{\code{sp_nam}}{Login name} \lineiii{1}{\code{sp_pwd}}{Encrypted password} \lineiii{2}{\code{sp_lstchg}}{Date of last change} \lineiii{3}{\code{sp_min}}{Minimal number of days between changes} \lineiii{4}{\code{sp_max}}{Maximum number of days between changes} \lineiii{5}{\code{sp_warn}}{Number of days before password expires to warn user about it} \lineiii{6}{\code{sp_inact}}{Number of days after password expires until account is blocked} \lineiii{7}{\code{sp_expire}}{Number of days since 1970-01-01 until account is disabled} \lineiii{8}{\code{sp_flag}}{Reserved} \end{tableiii} The sp_nam and sp_pwd items are strings, all others are integers. \exception{KeyError} is raised if the entry asked for cannot be found. It defines the following items: \begin{funcdesc}{getspnam}{name} Return the shadow password database entry for the given user name. \end{funcdesc} \begin{funcdesc}{getspall}{} Return a list of all available shadow password database entries, in arbitrary order. \end{funcdesc} \begin{seealso} \seemodule{pwd}{An interface to the normal password database, similar to this.} \end{seealso} Index: lib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/lib.tex,v retrieving revision 1.236 retrieving revision 1.237 diff -u -d -r1.236 -r1.237 --- lib.tex 19 Jan 2005 05:42:51 -0000 1.236 +++ lib.tex 23 Jan 2005 09:27:23 -0000 1.237 @@ -193,6 +193,7 @@ \input{libunix} % UNIX Specific Services \input{libposix} \input{libpwd} +\input{libspwd} \input{libgrp} \input{libcrypt} \input{libdl} Index: libpwd.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpwd.tex,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- libpwd.tex 1 Mar 2002 10:47:36 -0000 1.14 +++ libpwd.tex 23 Jan 2005 09:27:23 -0000 1.15 @@ -50,4 +50,5 @@ \begin{seealso} \seemodule{grp}{An interface to the group database, similar to this.} + \seemodule{spwd}{An interface to the shadow password database, similar to this.} \end{seealso} From loewis at users.sourceforge.net Sun Jan 23 10:27:26 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Jan 23 10:27:33 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1230,1.1231 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21361/Misc Modified Files: NEWS Log Message: Patch #579435: Shadow Password Support Module Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1230 retrieving revision 1.1231 diff -u -d -r1.1230 -r1.1231 --- NEWS 23 Jan 2005 09:19:20 -0000 1.1230 +++ NEWS 23 Jan 2005 09:27:23 -0000 1.1231 @@ -22,6 +22,8 @@ Extension Modules ----------------- +- The spwd has been added, allowing access to the shadow password database. + - stat_float_times is now True. - array.array objects are now picklable. From loewis at users.sourceforge.net Sun Jan 23 10:27:26 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Jan 23 10:27:34 2005 Subject: [Python-checkins] python/dist/src/Modules spwdmodule.c, NONE, 1.1 Setup.dist, 1.48, 1.49 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21361/Modules Modified Files: Setup.dist Added Files: spwdmodule.c Log Message: Patch #579435: Shadow Password Support Module --- NEW FILE: spwdmodule.c --- /* UNIX shadow password file access module */ /* A lot of code has been taken from pwdmodule.c */ /* For info also see http://www.unixpapa.com/incnote/passwd.html */ #include "Python.h" #include "structseq.h" #include #ifdef HAVE_SHADOW_H #include #endif PyDoc_STRVAR(spwd__doc__, "This module provides access to the Unix shadow password database.\n\ It is available on various Unix versions.\n\ \n\ Shadow password database entries are reported as 9-tuples of type struct_spwd,\n\ containing the following items from the password database (see `'):\n\ sp_namp, sp_pwdp, sp_lstchg, sp_min, sp_max, sp_warn, sp_inact, sp_expire, sp_flag.\n\ The sp_namp and sp_pwdp are strings, the rest are integers.\n\ An exception is raised if the entry asked for cannot be found.\n\ You have to be root to be able to use this module."); #if defined(HAVE_GETSPNAM) || defined(HAVE_GETSPENT) static PyStructSequence_Field struct_spwd_type_fields[] = { {"sp_nam", "login name"}, {"sp_pwd", "encrypted password"}, {"sp_lstchg", "date of last change"}, {"sp_min", "min #days between changes"}, {"sp_max", "max #days between changes"}, {"sp_warn", "#days before pw expires to warn user about it"}, {"sp_inact", "#days after pw expires until account is blocked"}, {"sp_expire", "#days since 1970-01-01 until account is disabled"}, {"sp_flag", "reserved"}, {0} }; PyDoc_STRVAR(struct_spwd__doc__, "spwd.struct_spwd: Results from getsp*() routines.\n\n\ This object may be accessed either as a 9-tuple of\n\ (sp_nam,sp_pwd,sp_lstchg,sp_min,sp_max,sp_warn,sp_inact,sp_expire,sp_flag)\n\ or via the object attributes as named in the above tuple."); static PyStructSequence_Desc struct_spwd_type_desc = { "spwd.struct_spwd", struct_spwd__doc__, struct_spwd_type_fields, 9, }; static PyTypeObject StructSpwdType; static void sets(PyObject *v, int i, char* val) { if (val) PyStructSequence_SET_ITEM(v, i, PyString_FromString(val)); else { PyStructSequence_SET_ITEM(v, i, Py_None); Py_INCREF(Py_None); } } static PyObject *mkspent(struct spwd *p) { int setIndex = 0; PyObject *v = PyStructSequence_New(&StructSpwdType); if (v == NULL) return NULL; #define SETI(i,val) PyStructSequence_SET_ITEM(v, i, PyInt_FromLong((long) val)) #define SETS(i,val) sets(v, i, val) SETS(setIndex++, p->sp_namp); SETS(setIndex++, p->sp_pwdp); SETI(setIndex++, p->sp_lstchg); SETI(setIndex++, p->sp_min); SETI(setIndex++, p->sp_max); SETI(setIndex++, p->sp_warn); SETI(setIndex++, p->sp_inact); SETI(setIndex++, p->sp_expire); SETI(setIndex++, p->sp_flag); #undef SETS #undef SETI if (PyErr_Occurred()) { Py_XDECREF(v); return NULL; } return v; } #endif /* HAVE_GETSPNAM || HAVE_GETSPENT */ #ifdef HAVE_GETSPNAM PyDoc_STRVAR(spwd_getspnam__doc__, "getspnam(name) -> (sp_namp, sp_pwdp, sp_lstchg, sp_min, sp_max,\n\ sp_warn, sp_inact, sp_expire, sp_flag)\n\ Return the shadow password database entry for the given user name.\n\ See spwd.__doc__ for more on shadow password database entries."); static PyObject* spwd_getspnam(PyObject *self, PyObject *args) { char *name; struct spwd *p; if (!PyArg_ParseTuple(args, "s:getspnam", &name)) return NULL; if ((p = getspnam(name)) == NULL) { PyErr_SetString(PyExc_KeyError, "getspnam(): name not found"); return NULL; } return mkspent(p); } PyDoc_STRVAR(spwd_getspall__doc__, "getspall() -> list_of_entries\n\ Return a list of all available shadow password database entries, \ in arbitrary order.\n\ See spwd.__doc__ for more on shadow password database entries."); #endif /* HAVE_GETSPNAM */ #ifdef HAVE_GETSPENT static PyObject * spwd_getspall(PyObject *self, PyObject *args) { PyObject *d; struct spwd *p; // if (!PyArg_NoArgs(args)) // return NULL; if ((d = PyList_New(0)) == NULL) return NULL; setspent(); while ((p = getspent()) != NULL) { PyObject *v = mkspent(p); if (v == NULL || PyList_Append(d, v) != 0) { Py_XDECREF(v); Py_DECREF(d); endspent(); return NULL; } Py_DECREF(v); } endspent(); return d; } #endif /* HAVE_GETSPENT */ static PyMethodDef spwd_methods[] = { #ifdef HAVE_GETSPNAM {"getspnam", spwd_getspnam, METH_VARARGS, spwd_getspnam__doc__}, #endif #ifdef HAVE_GETSPENT {"getspall", spwd_getspall, METH_NOARGS, spwd_getspall__doc__}, #endif {NULL, NULL} /* sentinel */ }; PyMODINIT_FUNC initspwd(void) { PyObject *m; m=Py_InitModule3("spwd", spwd_methods, spwd__doc__); PyStructSequence_InitType(&StructSpwdType, &struct_spwd_type_desc); Py_INCREF((PyObject *) &StructSpwdType); PyModule_AddObject(m, "struct_spwd", (PyObject *) &StructSpwdType); } Index: Setup.dist =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Setup.dist,v retrieving revision 1.48 retrieving revision 1.49 diff -u -d -r1.48 -r1.49 --- Setup.dist 31 Aug 2004 13:50:12 -0000 1.48 +++ Setup.dist 23 Jan 2005 09:27:24 -0000 1.49 @@ -183,6 +183,7 @@ #fcntl fcntlmodule.c # fcntl(2) and ioctl(2) #pwd pwdmodule.c # pwd(3) +#spwd spwdmodule.c # spwd(3) #grp grpmodule.c # grp(3) #select selectmodule.c # select(2); not on ancient System V From loewis at users.sourceforge.net Sun Jan 23 10:41:52 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Jan 23 10:41:55 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1231,1.1232 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25022/Misc Modified Files: NEWS Log Message: Flush std{in,out,err} before closing it. Fixes #1074011. Will backport to 2.4 and 2.3. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1231 retrieving revision 1.1232 diff -u -d -r1.1231 -r1.1232 --- NEWS 23 Jan 2005 09:27:23 -0000 1.1231 +++ NEWS 23 Jan 2005 09:41:49 -0000 1.1232 @@ -10,6 +10,9 @@ Core and builtins ----------------- +- Bug #1074011: closing sys.std{in,out,err} now causes a flush() and + an ferror() call. + - min() and max() now support key= arguments with the same meaning as in list.sort(). From loewis at users.sourceforge.net Sun Jan 23 10:41:52 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Jan 23 10:41:56 2005 Subject: [Python-checkins] python/dist/src/Python sysmodule.c,2.126,2.127 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25022/Python Modified Files: sysmodule.c Log Message: Flush std{in,out,err} before closing it. Fixes #1074011. Will backport to 2.4 and 2.3. Index: sysmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v retrieving revision 2.126 retrieving revision 2.127 diff -u -d -r2.126 -r2.127 --- sysmodule.c 12 Aug 2004 18:19:17 -0000 2.126 +++ sysmodule.c 23 Jan 2005 09:41:49 -0000 2.127 @@ -927,6 +927,13 @@ ) /* end of sys_doc */ ; +static int +_check_and_flush (FILE *stream) +{ + int prev_fail = ferror (stream); + return fflush (stream) || prev_fail ? EOF : 0; +} + PyObject * _PySys_Init(void) { @@ -940,9 +947,9 @@ m = Py_InitModule3("sys", sys_methods, sys_doc); sysdict = PyModule_GetDict(m); - sysin = PyFile_FromFile(stdin, "", "r", NULL); - sysout = PyFile_FromFile(stdout, "", "w", NULL); - syserr = PyFile_FromFile(stderr, "", "w", NULL); + sysin = PyFile_FromFile(stdin, "", "r", _check_and_flush); + sysout = PyFile_FromFile(stdout, "", "w", _check_and_flush); + syserr = PyFile_FromFile(stderr, "", "w", _check_and_flush); if (PyErr_Occurred()) return NULL; #ifdef MS_WINDOWS From loewis at users.sourceforge.net Sun Jan 23 10:50:16 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Jan 23 10:50:20 2005 Subject: [Python-checkins] python/dist/src/Python sysmodule.c, 2.126, 2.126.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26502/Python Modified Files: Tag: release24-maint sysmodule.c Log Message: Flush std{in,out,err} before closing it. Fixes #1074011. Index: sysmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v retrieving revision 2.126 retrieving revision 2.126.2.1 diff -u -d -r2.126 -r2.126.2.1 --- sysmodule.c 12 Aug 2004 18:19:17 -0000 2.126 +++ sysmodule.c 23 Jan 2005 09:50:14 -0000 2.126.2.1 @@ -927,6 +927,13 @@ ) /* end of sys_doc */ ; +static int +_check_and_flush (FILE *stream) +{ + int prev_fail = ferror (stream); + return fflush (stream) || prev_fail ? EOF : 0; +} + PyObject * _PySys_Init(void) { @@ -940,9 +947,9 @@ m = Py_InitModule3("sys", sys_methods, sys_doc); sysdict = PyModule_GetDict(m); - sysin = PyFile_FromFile(stdin, "", "r", NULL); - sysout = PyFile_FromFile(stdout, "", "w", NULL); - syserr = PyFile_FromFile(stderr, "", "w", NULL); + sysin = PyFile_FromFile(stdin, "", "r", _check_and_flush); + sysout = PyFile_FromFile(stdout, "", "w", _check_and_flush); + syserr = PyFile_FromFile(stderr, "", "w", _check_and_flush); if (PyErr_Occurred()) return NULL; #ifdef MS_WINDOWS From loewis at users.sourceforge.net Sun Jan 23 10:50:17 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Jan 23 10:50:21 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.14, 1.1193.2.15 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26502/Misc Modified Files: Tag: release24-maint NEWS Log Message: Flush std{in,out,err} before closing it. Fixes #1074011. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.14 retrieving revision 1.1193.2.15 diff -u -d -r1.1193.2.14 -r1.1193.2.15 --- NEWS 20 Jan 2005 19:21:24 -0000 1.1193.2.14 +++ NEWS 23 Jan 2005 09:50:12 -0000 1.1193.2.15 @@ -12,6 +12,9 @@ Core and builtins ----------------- +- Bug #1074011: closing sys.std{in,out,err} now causes a flush() and + an ferror() call. + - Bug #1085744: Add missing overflow check to PySequence_Tuple(). Make resize schedule linear (amortized). From loewis at users.sourceforge.net Sun Jan 23 10:50:48 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Jan 23 10:50:51 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.163, 1.831.4.164 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26642/Misc Modified Files: Tag: release23-maint NEWS Log Message: Flush std{in,out,err} before closing it. Fixes #1074011. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.163 retrieving revision 1.831.4.164 diff -u -d -r1.831.4.163 -r1.831.4.164 --- NEWS 20 Jan 2005 19:22:12 -0000 1.831.4.163 +++ NEWS 23 Jan 2005 09:50:31 -0000 1.831.4.164 @@ -12,6 +12,9 @@ Core and builtins ----------------- +- Bug #1074011: closing sys.std{in,out,err} now causes a flush() and + an ferror() call. + - Bug #1055820 Cyclic garbage collection was not protecting against that calling a live weakref to a piece of cyclic trash could resurrect an insane mutation of the trash if any Python code ran during gc (via From loewis at users.sourceforge.net Sun Jan 23 10:50:48 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Jan 23 10:50:53 2005 Subject: [Python-checkins] python/dist/src/Python sysmodule.c, 2.120.6.1, 2.120.6.2 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26642/Python Modified Files: Tag: release23-maint sysmodule.c Log Message: Flush std{in,out,err} before closing it. Fixes #1074011. Index: sysmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v retrieving revision 2.120.6.1 retrieving revision 2.120.6.2 diff -u -d -r2.120.6.1 -r2.120.6.2 --- sysmodule.c 9 Aug 2003 09:48:29 -0000 2.120.6.1 +++ sysmodule.c 23 Jan 2005 09:50:32 -0000 2.120.6.2 @@ -896,6 +896,13 @@ ) /* end of sys_doc */ ; +static int +_check_and_flush (FILE *stream) +{ + int prev_fail = ferror (stream); + return fflush (stream) || prev_fail ? EOF : 0; +} + PyObject * _PySys_Init(void) { @@ -909,9 +916,9 @@ m = Py_InitModule3("sys", sys_methods, sys_doc); sysdict = PyModule_GetDict(m); - sysin = PyFile_FromFile(stdin, "", "r", NULL); - sysout = PyFile_FromFile(stdout, "", "w", NULL); - syserr = PyFile_FromFile(stderr, "", "w", NULL); + sysin = PyFile_FromFile(stdin, "", "r", _check_and_flush); + sysout = PyFile_FromFile(stdout, "", "w", _check_and_flush); + syserr = PyFile_FromFile(stderr, "", "w", _check_and_flush); if (PyErr_Occurred()) return NULL; #ifdef MS_WINDOWS From jlgijsbers at users.sourceforge.net Sun Jan 23 13:20:18 2005 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sun Jan 23 13:20:21 2005 Subject: [Python-checkins] python/dist/src/Lib shutil.py,1.35,1.36 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25483 Modified Files: shutil.py Log Message: shutil.copytree: move copystat call for the directory after the loop copying files inside the directory, as that loop changes the atime and mtime. Index: shutil.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/shutil.py,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- shutil.py 8 Jan 2005 12:31:29 -0000 1.35 +++ shutil.py 23 Jan 2005 12:20:15 -0000 1.36 @@ -109,7 +109,6 @@ """ names = os.listdir(src) os.makedirs(dst) - copystat(src, dst) errors = [] for name in names: srcname = os.path.join(src, name) @@ -125,6 +124,7 @@ # XXX What about devices, sockets etc.? except (IOError, os.error), why: errors.append((srcname, dstname, why)) + copystat(src, dst) if errors: raise Error, errors From fdrake at users.sourceforge.net Sun Jan 23 16:16:14 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Sun Jan 23 16:16:17 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1232,1.1233 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10235 Modified Files: NEWS Log Message: add missing word Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1232 retrieving revision 1.1233 diff -u -d -r1.1232 -r1.1233 --- NEWS 23 Jan 2005 09:41:49 -0000 1.1232 +++ NEWS 23 Jan 2005 15:16:08 -0000 1.1233 @@ -25,7 +25,8 @@ Extension Modules ----------------- -- The spwd has been added, allowing access to the shadow password database. +- The spwd module has been added, allowing access to the shadow password + database. - stat_float_times is now True. From fdrake at users.sourceforge.net Sun Jan 23 23:14:19 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Sun Jan 23 23:14:21 2005 Subject: [Python-checkins] python/dist/src/Doc/tools mkpkglist,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22566/tools Modified Files: mkpkglist Log Message: include each row in the package table, even if there are no packages for that row; the row is commented out in that case (this makes it easier to modify the table after generation) Index: mkpkglist =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tools/mkpkglist,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- mkpkglist 11 May 2004 14:37:55 -0000 1.5 +++ mkpkglist 23 Jan 2005 22:14:16 -0000 1.6 @@ -67,14 +67,17 @@ have_tgz = isfile(tgz_fn) have_bz2 = isfile(bz2_fn) - if have_zip or have_tgz or have_bz2: - print " %s" % name - - print get_file_cell(prefix, ".zip", have_zip) - print get_file_cell(prefix, ".tgz", have_tgz) - print get_file_cell(prefix, ".tar.bz2", have_bz2) + have_some = have_zip or have_tgz or have_bz2 - print " " + if not have_some: + print " " print '''\ From nnorwitz at users.sourceforge.net Tue Jan 25 00:34:03 2005 From: nnorwitz at users.sourceforge.net (nnorwitz@users.sourceforge.net) Date: Tue Jan 25 00:34:06 2005 Subject: [Python-checkins] python/dist/src/Modules spwdmodule.c,1.1,1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11382/Modules Modified Files: spwdmodule.c Log Message: Put docstring for getspall into same #ifdef block as function definition Remove C++ (C99) style comments Index: spwdmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/spwdmodule.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- spwdmodule.c 23 Jan 2005 09:27:24 -0000 1.1 +++ spwdmodule.c 24 Jan 2005 23:33:51 -0000 1.2 @@ -121,23 +121,21 @@ return mkspent(p); } +#endif /* HAVE_GETSPNAM */ + +#ifdef HAVE_GETSPENT + PyDoc_STRVAR(spwd_getspall__doc__, "getspall() -> list_of_entries\n\ Return a list of all available shadow password database entries, \ in arbitrary order.\n\ See spwd.__doc__ for more on shadow password database entries."); -#endif /* HAVE_GETSPNAM */ - -#ifdef HAVE_GETSPENT - static PyObject * spwd_getspall(PyObject *self, PyObject *args) { PyObject *d; struct spwd *p; -// if (!PyArg_NoArgs(args)) -// return NULL; if ((d = PyList_New(0)) == NULL) return NULL; setspent(); From fdrake at users.sourceforge.net Tue Jan 25 08:53:39 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Jan 25 08:53:43 2005 Subject: [Python-checkins] python/dist/src/Include patchlevel.h, 2.74.4.12, 2.74.4.13 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5517 Modified Files: Tag: release23-maint patchlevel.h Log Message: bump version number to prepare for a release Index: patchlevel.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/patchlevel.h,v retrieving revision 2.74.4.12 retrieving revision 2.74.4.13 diff -u -d -r2.74.4.12 -r2.74.4.13 --- patchlevel.h 9 Jun 2004 14:56:12 -0000 2.74.4.12 +++ patchlevel.h 25 Jan 2005 07:53:30 -0000 2.74.4.13 @@ -22,11 +22,11 @@ #define PY_MAJOR_VERSION 2 #define PY_MINOR_VERSION 3 #define PY_MICRO_VERSION 5 -#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_ALPHA -#define PY_RELEASE_SERIAL 0 +#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_GAMMA +#define PY_RELEASE_SERIAL 1 /* Version as a string */ -#define PY_VERSION "2.3.5a0" +#define PY_VERSION "2.3.5c1" /* 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 rhettinger at users.sourceforge.net Tue Jan 25 11:21:22 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Jan 25 11:21:25 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libstdtypes.tex, 1.172, 1.173 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1608 Modified Files: libstdtypes.tex Log Message: SF bug #1105286: Undocumented implicit strip() in split(None) string method Clarify the behavior when a string begins or ends with whitespace. Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.172 retrieving revision 1.173 diff -u -d -r1.172 -r1.173 --- libstdtypes.tex 1 Jan 2005 00:28:43 -0000 1.172 +++ libstdtypes.tex 25 Jan 2005 10:21:19 -0000 1.173 @@ -738,7 +738,9 @@ Return a list of the words in the string, using \var{sep} as the delimiter string. If \var{maxsplit} is given, at most \var{maxsplit} splits are done, the \emph{rightmost} ones. If \var{sep} is not specified -or \code{None}, any whitespace string is a separator. +or \code{None}, any whitespace string is a separator. Except for splitting +from the right, \method{rsplit()} behaves like \method{split()} which +is described in detail below. \versionadded{2.4} \end{methoddesc} @@ -765,11 +767,13 @@ separator returns an empty list. If \var{sep} is not specified or is \code{None}, a different splitting -algorithm is applied. Words are separated by arbitrary length strings of -whitespace characters (spaces, tabs, newlines, returns, and formfeeds). -Consecutive whitespace delimiters are treated as a single delimiter -(\samp{'1 2 3'.split()} returns \samp{['1', '2', '3']}). Splitting an -empty string returns \samp{['']}. +algorithm is applied. First, whitespace characters (spaces, tabs, +newlines, returns, and formfeeds) are stripped from both ends. Then, +words are separated by arbitrary length strings of whitespace +characters. Consecutive whitespace delimiters are treated as a single +delimiter (\samp{'1 2 3'.split()} returns \samp{['1', '2', '3']}). +Splitting an empty string or a string consisting of just whitespace +will return \samp{['']}. \end{methoddesc} \begin{methoddesc}[string]{splitlines}{\optional{keepends}} From rhettinger at users.sourceforge.net Tue Jan 25 11:28:50 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Jan 25 11:28:52 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libstdtypes.tex, 1.170.2.2, 1.170.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3666 Modified Files: Tag: release24-maint libstdtypes.tex Log Message: SF bug #1105286: Undocumented implicit strip() in split(None) string method Clarify the behavior when a string begins or ends with whitespace. Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.170.2.2 retrieving revision 1.170.2.3 diff -u -d -r1.170.2.2 -r1.170.2.3 --- libstdtypes.tex 1 Jan 2005 00:34:53 -0000 1.170.2.2 +++ libstdtypes.tex 25 Jan 2005 10:28:47 -0000 1.170.2.3 @@ -738,7 +738,9 @@ Return a list of the words in the string, using \var{sep} as the delimiter string. If \var{maxsplit} is given, at most \var{maxsplit} splits are done, the \emph{rightmost} ones. If \var{sep} is not specified -or \code{None}, any whitespace string is a separator. +or \code{None}, any whitespace string is a separator. Except for splitting +from the right, \method{rsplit()} behaves like \method{split()} which +is described in detail below. \versionadded{2.4} \end{methoddesc} @@ -765,11 +767,13 @@ separator returns an empty list. If \var{sep} is not specified or is \code{None}, a different splitting -algorithm is applied. Words are separated by arbitrary length strings of -whitespace characters (spaces, tabs, newlines, returns, and formfeeds). -Consecutive whitespace delimiters are treated as a single delimiter -(\samp{'1 2 3'.split()} returns \samp{['1', '2', '3']}). Splitting an -empty string returns \samp{['']}. +algorithm is applied. First, whitespace characters (spaces, tabs, +newlines, returns, and formfeeds) are stripped from both ends. Then, +words are separated by arbitrary length strings of whitespace +characters. Consecutive whitespace delimiters are treated as a single +delimiter (\samp{'1 2 3'.split()} returns \samp{['1', '2', '3']}). +Splitting an empty string or a string consisting of just whitespace +will return \samp{['']}. \end{methoddesc} \begin{methoddesc}[string]{splitlines}{\optional{keepends}} From anthonybaxter at users.sourceforge.net Tue Jan 25 13:39:35 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Jan 25 13:39:38 2005 Subject: [Python-checkins] python/dist/src/Python getcopyright.c, 1.17.12.2, 1.17.12.3 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2352/Python Modified Files: Tag: release23-maint getcopyright.c Log Message: happy new year! Index: getcopyright.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/getcopyright.c,v retrieving revision 1.17.12.2 retrieving revision 1.17.12.3 diff -u -d -r1.17.12.2 -r1.17.12.3 --- getcopyright.c 13 May 2004 11:54:38 -0000 1.17.12.2 +++ getcopyright.c 25 Jan 2005 12:39:22 -0000 1.17.12.3 @@ -4,7 +4,7 @@ static char cprt[] = "\ -Copyright (c) 2001-2004 Python Software Foundation.\n\ +Copyright (c) 2001-2005 Python Software Foundation.\n\ All Rights Reserved.\n\ \n\ Copyright (c) 2000 BeOpen.com.\n\ From anthonybaxter at users.sourceforge.net Tue Jan 25 13:39:54 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Jan 25 13:39:57 2005 Subject: [Python-checkins] python/dist/src README,1.177.4.11,1.177.4.12 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2352 Modified Files: Tag: release23-maint README Log Message: happy new year! Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/README,v retrieving revision 1.177.4.11 retrieving revision 1.177.4.12 diff -u -d -r1.177.4.11 -r1.177.4.12 --- README 25 May 2004 18:43:25 -0000 1.177.4.11 +++ README 25 Jan 2005 12:39:19 -0000 1.177.4.12 @@ -1,7 +1,7 @@ -This is Python version 2.3.4 +This is Python version 2.3.5 ============================ -Copyright (c) 2001, 2002, 2003, 2004 Python Software Foundation. +Copyright (c) 2001, 2002, 2003, 2004, 2005 Python Software Foundation. All rights reserved. Copyright (c) 2000 BeOpen.com. From anthonybaxter at users.sourceforge.net Tue Jan 25 13:40:03 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Jan 25 13:40:05 2005 Subject: [Python-checkins] python/dist/src README,1.185,1.186 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2483 Modified Files: README Log Message: happy new year! (on the trunk) Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/README,v retrieving revision 1.185 retrieving revision 1.186 diff -u -d -r1.185 -r1.186 --- README 24 Dec 2004 08:28:28 -0000 1.185 +++ README 25 Jan 2005 12:40:00 -0000 1.186 @@ -1,7 +1,7 @@ -This is Python version 2.4 alpha 3 +This is Python version 2.5 alpha 0 ================================== -Copyright (c) 2001, 2002, 2003, 2004 Python Software Foundation. +Copyright (c) 2001, 2002, 2003, 2004, 2005 Python Software Foundation. All rights reserved. Copyright (c) 2000 BeOpen.com. From anthonybaxter at users.sourceforge.net Tue Jan 25 13:40:03 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Jan 25 13:40:07 2005 Subject: [Python-checkins] python/dist/src/Python getcopyright.c,1.18,1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2483/Python Modified Files: getcopyright.c Log Message: happy new year! (on the trunk) Index: getcopyright.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/getcopyright.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- getcopyright.c 13 May 2004 11:54:19 -0000 1.18 +++ getcopyright.c 25 Jan 2005 12:40:01 -0000 1.19 @@ -4,7 +4,7 @@ static char cprt[] = "\ -Copyright (c) 2001-2004 Python Software Foundation.\n\ +Copyright (c) 2001-2005 Python Software Foundation.\n\ All Rights Reserved.\n\ \n\ Copyright (c) 2000 BeOpen.com.\n\ From anthonybaxter at users.sourceforge.net Tue Jan 25 13:43:59 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Jan 25 13:44:03 2005 Subject: [Python-checkins] python/dist/src README,1.184.2.2,1.184.2.3 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3336 Modified Files: Tag: release24-maint README Log Message: happy new year! (2.4 branch) Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/README,v retrieving revision 1.184.2.2 retrieving revision 1.184.2.3 diff -u -d -r1.184.2.2 -r1.184.2.3 --- README 24 Dec 2004 08:27:20 -0000 1.184.2.2 +++ README 25 Jan 2005 12:43:57 -0000 1.184.2.3 @@ -1,7 +1,7 @@ -This is Python version 2.4 alpha 3 -================================== +This is Python version 2.4 +========================== -Copyright (c) 2001, 2002, 2003, 2004 Python Software Foundation. +Copyright (c) 2001, 2002, 2003, 2004, 2005 Python Software Foundation. All rights reserved. Copyright (c) 2000 BeOpen.com. From anthonybaxter at users.sourceforge.net Tue Jan 25 13:43:59 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Jan 25 13:44:04 2005 Subject: [Python-checkins] python/dist/src/Python getcopyright.c, 1.18, 1.18.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3336/Python Modified Files: Tag: release24-maint getcopyright.c Log Message: happy new year! (2.4 branch) Index: getcopyright.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/getcopyright.c,v retrieving revision 1.18 retrieving revision 1.18.4.1 diff -u -d -r1.18 -r1.18.4.1 --- getcopyright.c 13 May 2004 11:54:19 -0000 1.18 +++ getcopyright.c 25 Jan 2005 12:43:57 -0000 1.18.4.1 @@ -4,7 +4,7 @@ static char cprt[] = "\ -Copyright (c) 2001-2004 Python Software Foundation.\n\ +Copyright (c) 2001-2005 Python Software Foundation.\n\ All Rights Reserved.\n\ \n\ Copyright (c) 2000 BeOpen.com.\n\ From anthonybaxter at users.sourceforge.net Tue Jan 25 13:51:45 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Jan 25 13:51:47 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.164, 1.831.4.165 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4812/Misc Modified Files: Tag: release23-maint NEWS Log Message: pre-release bits Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.164 retrieving revision 1.831.4.165 diff -u -d -r1.831.4.164 -r1.831.4.165 --- NEWS 23 Jan 2005 09:50:31 -0000 1.831.4.164 +++ NEWS 25 Jan 2005 12:51:39 -0000 1.831.4.165 @@ -4,10 +4,10 @@ (editors: check NEWS.help for information about editing NEWS using ReST.) -What's New in Python 2.3.5? -=========================== +What's New in Python 2.3.5rc1? +============================== -*Release date: xx-xxx-2005* +*Release date: 26-JAN-2005* Core and builtins ----------------- @@ -76,6 +76,9 @@ Library ------- +- copy.py fixed to first lookup __copy__ from the instance being copied, + rather than only looking at the type - this was broken in 2.3. + - Bug #1103844: fix distutils.install.dump_dirs() with negated options. - Bug #1067732: wininst --install-script doesn't leave residual files anymore. From anthonybaxter at users.sourceforge.net Tue Jan 25 13:51:45 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Jan 25 13:51:49 2005 Subject: [Python-checkins] python/dist/src/Lib/idlelib NEWS.txt, 1.23.4.15, 1.23.4.16 idlever.py, 1.15.4.6, 1.15.4.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4812/Lib/idlelib Modified Files: Tag: release23-maint NEWS.txt idlever.py Log Message: pre-release bits Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.23.4.15 retrieving revision 1.23.4.16 diff -u -d -r1.23.4.15 -r1.23.4.16 --- NEWS.txt 19 Jan 2005 06:23:51 -0000 1.23.4.15 +++ NEWS.txt 25 Jan 2005 12:51:42 -0000 1.23.4.16 @@ -1,7 +1,7 @@ -What's New in IDLE 1.0.4? -========================= +What's New in IDLE 1.0.4rc1? +============================ -*Release date: XX-Jan-2005* +*Release date: 26-Jan-2005* - On OpenBSD, terminating IDLE with ctrl-c from the command line caused a stuck subprocess MainThread because only the SocketThread was exiting. Index: idlever.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/idlever.py,v retrieving revision 1.15.4.6 retrieving revision 1.15.4.7 diff -u -d -r1.15.4.6 -r1.15.4.7 --- idlever.py 19 Jan 2005 01:44:06 -0000 1.15.4.6 +++ idlever.py 25 Jan 2005 12:51:43 -0000 1.15.4.7 @@ -1 +1 @@ -IDLE_VERSION = "1.0.4" +IDLE_VERSION = "1.0.5c1" From anthonybaxter at users.sourceforge.net Tue Jan 25 13:51:45 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Jan 25 13:51:50 2005 Subject: [Python-checkins] python/dist/src/PCbuild BUILDno.txt, 1.51.4.7, 1.51.4.8 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4812/PCbuild Modified Files: Tag: release23-maint BUILDno.txt Log Message: pre-release bits Index: BUILDno.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/BUILDno.txt,v retrieving revision 1.51.4.7 retrieving revision 1.51.4.8 diff -u -d -r1.51.4.7 -r1.51.4.8 --- BUILDno.txt 25 May 2004 18:43:54 -0000 1.51.4.7 +++ BUILDno.txt 25 Jan 2005 12:51:43 -0000 1.51.4.8 @@ -33,6 +33,22 @@ Windows Python BUILD numbers ---------------------------- + 61 2.3.5c1 + 26-Jan-2005 + 60 2.4 + 29-Nov-2004 + 59 2.4.0c1 + 7-Nov-2004 + 58 2.4.0b2 + 2-Nov-2004 + 57 2.4.0b1 + 15-Oct-2004 + 56 2.4.0a3 + 2-Sep-2004 + 55 2.4.0a2 + 4-Aug-2004 + 54 2.4.0a1 + 8-Jul-2004 53 2.3.4 (final) 27-May-2004 52 2.3.4c1 From anthonybaxter at users.sourceforge.net Tue Jan 25 13:52:21 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Jan 25 13:52:24 2005 Subject: [Python-checkins] python/dist/src/Lib copy.py,1.42,1.42.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4976/Lib Modified Files: Tag: release23-maint copy.py Log Message: copy.py fixed to first lookup __copy__ from the instance being copied, rather than only looking at the type - this was broken in 2.3. Index: copy.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/copy.py,v retrieving revision 1.42 retrieving revision 1.42.8.1 diff -u -d -r1.42 -r1.42.8.1 --- copy.py 14 Jun 2003 07:10:06 -0000 1.42 +++ copy.py 25 Jan 2005 12:52:18 -0000 1.42.8.1 @@ -62,6 +62,15 @@ __all__ = ["Error", "copy", "deepcopy"] +def _getspecial(cls, name): + for basecls in cls.__mro__: + try: + return basecls.__dict__[name] + except: + pass + else: + return None + def copy(x): """Shallow copy operation on arbitrary Python objects. @@ -74,7 +83,7 @@ if copier: return copier(x) - copier = getattr(cls, "__copy__", None) + copier = _getspecial(cls, "__copy__") if copier: return copier(x) @@ -90,6 +99,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) @@ -185,9 +197,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: @@ -201,6 +213,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 anthonybaxter at users.sourceforge.net Tue Jan 25 13:52:21 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Jan 25 13:52:25 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_copy.py, 1.11, 1.11.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4976/Lib/test Modified Files: Tag: release23-maint test_copy.py Log Message: copy.py fixed to first lookup __copy__ from the instance being copied, rather than only looking at the type - this was broken in 2.3. Index: test_copy.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_copy.py,v retrieving revision 1.11 retrieving revision 1.11.8.1 diff -u -d -r1.11 -r1.11.8.1 --- test_copy.py 14 Jun 2003 07:10:06 -0000 1.11 +++ test_copy.py 25 Jan 2005 12:52:18 -0000 1.11.8.1 @@ -166,8 +166,64 @@ x = C(42) self.assertEqual(copy.copy(x), x) - # The deepcopy() method + # 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 metaclass-confusion + 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) + + + # The deepcopy() method def test_deepcopy_basic(self): x = 42 y = copy.deepcopy(x) From anthonybaxter at users.sourceforge.net Tue Jan 25 13:52:21 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Jan 25 13:52:26 2005 Subject: [Python-checkins] python/dist/src/Modules _testcapimodule.c, 1.24, 1.24.10.1 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4976/Modules Modified Files: Tag: release23-maint _testcapimodule.c Log Message: copy.py fixed to first lookup __copy__ from the instance being copied, rather than only looking at the type - this was broken in 2.3. Index: _testcapimodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_testcapimodule.c,v retrieving revision 1.24 retrieving revision 1.24.10.1 diff -u -d -r1.24 -r1.24.10.1 --- _testcapimodule.c 24 Apr 2003 16:14:27 -0000 1.24 +++ _testcapimodule.c 25 Jan 2005 12:52:18 -0000 1.24.10.1 @@ -587,6 +587,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}, @@ -613,9 +776,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);} @@ -624,6 +789,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 anthonybaxter at users.sourceforge.net Tue Jan 25 14:08:18 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Jan 25 14:08:20 2005 Subject: [Python-checkins] python/dist/src/Lib/idlelib NEWS.txt, 1.23.4.16, 1.23.4.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8830/Lib/idlelib Modified Files: Tag: release23-maint NEWS.txt Log Message: 1.0.5, to match the python patchlevel Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.23.4.16 retrieving revision 1.23.4.17 diff -u -d -r1.23.4.16 -r1.23.4.17 --- NEWS.txt 25 Jan 2005 12:51:42 -0000 1.23.4.16 +++ NEWS.txt 25 Jan 2005 13:08:15 -0000 1.23.4.17 @@ -1,4 +1,4 @@ -What's New in IDLE 1.0.4rc1? +What's New in IDLE 1.0.5rc1? ============================ *Release date: 26-Jan-2005* From fdrake at users.sourceforge.net Tue Jan 25 16:16:52 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Jan 25 16:16:54 2005 Subject: [Python-checkins] python/dist/src/Doc/commontex boilerplate.tex, 1.1.2.9, 1.1.2.10 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/commontex In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10654/commontex Modified Files: Tag: release23-maint boilerplate.tex Log Message: set the release date Index: boilerplate.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/commontex/boilerplate.tex,v retrieving revision 1.1.2.9 retrieving revision 1.1.2.10 diff -u -d -r1.1.2.9 -r1.1.2.10 --- boilerplate.tex 9 Jun 2004 14:58:21 -0000 1.1.2.9 +++ boilerplate.tex 25 Jan 2005 15:16:49 -0000 1.1.2.10 @@ -5,6 +5,6 @@ Email: \email{docs@python.org} } -\date{\today} -%\date{May 20, 2004} % XXX update before final release! +%\date{\today} +\date{January 26, 2005} % XXX update before final release! \input{patchlevel} % include Python version information From theller at users.sourceforge.net Tue Jan 25 20:47:58 2005 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Tue Jan 25 20:48:03 2005 Subject: [Python-checkins] python/dist/src/PC/bdist_wininst install.c, 1.1.14.8, 1.1.14.9 Message-ID: Update of /cvsroot/python/python/dist/src/PC/bdist_wininst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13043 Modified Files: Tag: release23-maint install.c Log Message: Set PYTHONHOME before loading Python, so that sys.path will be set correctly. Index: install.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/bdist_wininst/install.c,v retrieving revision 1.1.14.8 retrieving revision 1.1.14.9 diff -u -d -r1.1.14.8 -r1.1.14.9 --- install.c 22 Dec 2004 15:46:01 -0000 1.1.14.8 +++ install.c 25 Jan 2005 19:47:48 -0000 1.1.14.9 @@ -1511,8 +1511,14 @@ { char fullpath[_MAX_PATH]; char subkey_name[80]; + char buffer[260 + 12]; LONG size = sizeof(fullpath); - HINSTANCE h = LoadLibrary(fname); + 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 Tue Jan 25 21:46:56 2005 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Tue Jan 25 21:46:59 2005 Subject: [Python-checkins] python/dist/src/PC/bdist_wininst install.c, 1.1.14.9, 1.1.14.10 Message-ID: Update of /cvsroot/python/python/dist/src/PC/bdist_wininst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27706 Modified Files: Tag: release23-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. (I would be very gratefull if someone proofreads the patch, at least). Index: install.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/bdist_wininst/install.c,v retrieving revision 1.1.14.9 retrieving revision 1.1.14.10 diff -u -d -r1.1.14.9 -r1.1.14.10 --- install.c 25 Jan 2005 19:47:48 -0000 1.1.14.9 +++ install.c 25 Jan 2005 20:46:48 -0000 1.1.14.10 @@ -87,6 +87,11 @@ #include #include #include +#include +#include +#include +#include +#include #include "archive.h" @@ -573,7 +578,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. */ @@ -583,7 +588,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 *, PyImport_ImportModule, (char *)); DECLPROC(hPython, int, PyObject_SetAttrString, @@ -599,10 +604,10 @@ PyObject *mod; int result = 0; - FILE *fp; + int fh; if (!Py_Initialize || !PySys_SetArgv - || !PyRun_SimpleFile || !Py_Finalize) + || !PyRun_SimpleString || !Py_Finalize) return 1; if (!PyImport_ImportModule || !PyObject_SetAttrString @@ -622,13 +627,12 @@ 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; } - SetDlgItemText(hDialog, IDC_INFO, "Running Script..."); Py_Initialize(); @@ -647,10 +651,22 @@ } 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 Tue Jan 25 23:05:56 2005 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Tue Jan 25 23:05:58 2005 Subject: [Python-checkins] python/dist/src/PCbuild pythoncore.dsp, 1.48.4.7, 1.48.4.8 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14563 Modified Files: Tag: release23-maint pythoncore.dsp Log Message: Build number for 2.3.5c1 is 61. Index: pythoncore.dsp =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/Attic/pythoncore.dsp,v retrieving revision 1.48.4.7 retrieving revision 1.48.4.8 diff -u -d -r1.48.4.7 -r1.48.4.8 --- pythoncore.dsp 25 May 2004 18:43:54 -0000 1.48.4.7 +++ pythoncore.dsp 25 Jan 2005 22:05:22 -0000 1.48.4.8 @@ -258,7 +258,7 @@ # Begin Source File SOURCE=..\Modules\getbuildinfo.c -# ADD CPP /D BUILD=53 +# ADD CPP /D BUILD=61 # End Source File # Begin Source File From theller at users.sourceforge.net Tue Jan 25 23:08:24 2005 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Tue Jan 25 23:08:26 2005 Subject: [Python-checkins] python/dist/src/PCbuild python20.wse, 1.133.4.9, 1.133.4.10 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15087 Modified Files: Tag: release23-maint python20.wse Log Message: Installer changes for 2.3.5c1. Index: python20.wse =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/python20.wse,v retrieving revision 1.133.4.9 retrieving revision 1.133.4.10 diff -u -d -r1.133.4.9 -r1.133.4.10 --- python20.wse 25 May 2004 18:50:10 -0000 1.133.4.9 +++ python20.wse 25 Jan 2005 22:07:51 -0000 1.133.4.10 @@ -1,7 +1,7 @@ Document Type: WSE item: Global Version=9.0 - Title=Python 2.3.4 + Title=Python 2.3.5c1 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,11 +20,11 @@ Patch Memory=4000 MIF PDF Version=1.0 MIF SMS Version=2.0 - EXE Filename=Python-2.3.4.exe + EXE Filename=Python-2.3.5c1.exe Dialogs Version=8 - Version File=2.3.4 + Version File=2.3.5c1 Version Description=Python Programming Language - Version Copyright=©2001-2004 Python Software Foundation + Version Copyright=©2001-2005 Python Software Foundation Version Company=Python Software Foundation Crystal Format=10111100101100000010001001001001 Step View=&All @@ -81,7 +81,7 @@ end item: Set Variable Variable=PYVER_STRING - Value=2.3.4 + Value=2.3.5c1 end item: Remark end From theller at users.sourceforge.net Tue Jan 25 23:09:34 2005 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Tue Jan 25 23:09:36 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils/command wininst.exe, 1.1.16.5, 1.1.16.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15379 Modified Files: Tag: release23-maint wininst.exe Log Message: Recompiled after source changes. Index: wininst.exe =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/Attic/wininst.exe,v retrieving revision 1.1.16.5 retrieving revision 1.1.16.6 diff -u -d -r1.1.16.5 -r1.1.16.6 Binary files /tmp/cvsPFNThW and /tmp/cvsEYF8HK differ From anthonybaxter at users.sourceforge.net Wed Jan 26 05:56:23 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Wed Jan 26 05:56:25 2005 Subject: [Python-checkins] python/dist/src LICENSE,1.26.8.5,1.26.8.6 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23499 Modified Files: Tag: release23-maint LICENSE Log Message: added 2.3.5 Index: LICENSE =================================================================== RCS file: /cvsroot/python/python/dist/src/LICENSE,v retrieving revision 1.26.8.5 retrieving revision 1.26.8.6 diff -u -d -r1.26.8.5 -r1.26.8.6 --- LICENSE 12 May 2004 18:04:42 -0000 1.26.8.5 +++ LICENSE 26 Jan 2005 04:55:57 -0000 1.26.8.6 @@ -47,6 +47,7 @@ 2.3.2 2.3.1 2002-2003 PSF yes 2.3.3 2.3.2 2002-2003 PSF yes 2.3.4 2.3.3 2004 PSF yes + 2.3.5 2.3.4 2004-2005 PSF yes Footnotes: From rhettinger at users.sourceforge.net Wed Jan 26 13:50:07 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Jan 26 13:50:10 2005 Subject: [Python-checkins] python/dist/src/Python compile.c,2.339,2.340 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23965/python Modified Files: compile.c Log Message: Do not fold a constant if a large sequence will result. Saves space in the presence of code like: (None,)*10000 Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.339 retrieving revision 2.340 diff -u -d -r2.339 -r2.340 --- compile.c 7 Jan 2005 18:10:51 -0000 2.339 +++ compile.c 26 Jan 2005 12:50:04 -0000 2.340 @@ -444,12 +444,16 @@ The consts table must still be in list form so that the new constant can be appended. Called with codestr pointing to the first LOAD_CONST. - Abandons the transformation if the folding fails (i.e. 1+'a'). */ + Abandons the transformation if the folding fails (i.e. 1+'a'). + If the new constant is a sequence, only folds when the size + is below a threshold value. That keeps pyc files from + becoming large in the presence of code like: (None,)*1000. +*/ static int fold_binops_on_constants(unsigned char *codestr, PyObject *consts) { PyObject *newconst, *v, *w; - int len_consts, opcode; + int len_consts, opcode, size; /* Pre-conditions */ assert(PyList_CheckExact(consts)); @@ -468,8 +472,8 @@ newconst = PyNumber_Multiply(v, w); break; case BINARY_DIVIDE: - /* XXX care is needed to fold this operation statically: - the result might depend on the run-time presence of the -Qnew flag */ + /* Cannot fold this operation statically since + the result can depend on the run-time presence of the -Qnew flag */ return 0; case BINARY_TRUE_DIVIDE: newconst = PyNumber_TrueDivide(v, w); @@ -513,6 +517,13 @@ PyErr_Clear(); return 0; } + size = PyObject_Size(newconst); + if (size == -1) + PyErr_Clear(); + else if (size > 20) { + Py_DECREF(newconst); + return 0; + } /* Append folded constant into consts table */ len_consts = PyList_GET_SIZE(consts); @@ -733,7 +744,6 @@ LOAD_CONST c1 LOAD_CONST c2 BINOP --> LOAD_CONST binop(c1,c2) */ case BINARY_POWER: case BINARY_MULTIPLY: - case BINARY_DIVIDE: case BINARY_TRUE_DIVIDE: case BINARY_FLOOR_DIVIDE: case BINARY_MODULO: From rhettinger at users.sourceforge.net Wed Jan 26 13:50:08 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Jan 26 13:50:14 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_peepholer.py, 1.7, 1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23965/lib/test Modified Files: test_peepholer.py Log Message: Do not fold a constant if a large sequence will result. Saves space in the presence of code like: (None,)*10000 Index: test_peepholer.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_peepholer.py,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- test_peepholer.py 7 Jan 2005 18:34:56 -0000 1.7 +++ test_peepholer.py 26 Jan 2005 12:50:05 -0000 1.8 @@ -129,6 +129,10 @@ self.assert_('(2)' in asm) self.assert_("('b')" in asm) + # Verify that large sequences do not result from folding + asm = dis_single('a="x"*1000') + self.assert_('(1000)' in asm) + def test_elim_extra_return(self): # RETURN LOAD_CONST None RETURN --> RETURN def f(x): From rhettinger at users.sourceforge.net Wed Jan 26 23:40:11 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Jan 26 23:40:15 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libstdtypes.tex, 1.173, 1.174 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9933 Modified Files: libstdtypes.tex Log Message: SF bug #1108303: fix .split() maxsplit doc Docs incorrectly stated that maxsplit=0 would cause unlimited splitting. Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.173 retrieving revision 1.174 diff -u -d -r1.173 -r1.174 --- libstdtypes.tex 25 Jan 2005 10:21:19 -0000 1.173 +++ libstdtypes.tex 26 Jan 2005 22:40:08 -0000 1.174 @@ -757,7 +757,7 @@ Return a list of the words in the string, using \var{sep} as the delimiter string. If \var{maxsplit} is given, at most \var{maxsplit} splits are done. (thus, the list will have at most \code{\var{maxsplit}+1} -elements). If \var{maxsplit} is not specified or is zero, then there +elements). If \var{maxsplit} is not specified, then there is no limit on the number of splits (all possible splits are made). Consecutive delimiters are not grouped together and are deemed to delimit empty strings (for example, \samp{'1,,2'.split(',')} From rhettinger at users.sourceforge.net Wed Jan 26 23:46:30 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Jan 26 23:46:32 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libstdtypes.tex, 1.170.2.3, 1.170.2.4 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11818 Modified Files: Tag: release24-maint libstdtypes.tex Log Message: SF bug #1108303: fix .split() maxsplit doc Docs incorrectly stated that maxsplit=0 would cause unlimited splitting. Index: libstdtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libstdtypes.tex,v retrieving revision 1.170.2.3 retrieving revision 1.170.2.4 diff -u -d -r1.170.2.3 -r1.170.2.4 --- libstdtypes.tex 25 Jan 2005 10:28:47 -0000 1.170.2.3 +++ libstdtypes.tex 26 Jan 2005 22:46:26 -0000 1.170.2.4 @@ -757,7 +757,7 @@ Return a list of the words in the string, using \var{sep} as the delimiter string. If \var{maxsplit} is given, at most \var{maxsplit} splits are done. (thus, the list will have at most \code{\var{maxsplit}+1} -elements). If \var{maxsplit} is not specified or is zero, then there +elements). If \var{maxsplit} is not specified, then there is no limit on the number of splits (all possible splits are made). Consecutive delimiters are not grouped together and are deemed to delimit empty strings (for example, \samp{'1,,2'.split(',')} From loewis at users.sourceforge.net Thu Jan 27 19:55:09 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Jan 27 19:55:23 2005 Subject: [Python-checkins] python/dist/src/Python sysmodule.c, 2.120.6.2, 2.120.6.3 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22415/Python Modified Files: Tag: release23-maint sysmodule.c Log Message: Partially revert #1074011; don't try to fflush stdin. Index: sysmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v retrieving revision 2.120.6.2 retrieving revision 2.120.6.3 diff -u -d -r2.120.6.2 -r2.120.6.3 --- sysmodule.c 23 Jan 2005 09:50:32 -0000 2.120.6.2 +++ sysmodule.c 27 Jan 2005 18:55:06 -0000 2.120.6.3 @@ -916,7 +916,16 @@ m = Py_InitModule3("sys", sys_methods, sys_doc); sysdict = PyModule_GetDict(m); - sysin = PyFile_FromFile(stdin, "", "r", _check_and_flush); + /* Closing the standard FILE* if sys.std* goes aways causes problems + * for embedded Python usages. Closing them when somebody explicitly + * invokes .close() might be possible, but the FAQ promises they get + * never closed. However, we still need to get write errors when + * writing fails (e.g. because stdout is redirected), so we flush the + * streams and check for errors before the file objects are deleted. + * On OS X, fflush()ing stdin causes an error, so we exempt stdin + * from that procedure. + */ + sysin = PyFile_FromFile(stdin, "", "r", NULL); sysout = PyFile_FromFile(stdout, "", "w", _check_and_flush); syserr = PyFile_FromFile(stderr, "", "w", _check_and_flush); if (PyErr_Occurred()) From loewis at users.sourceforge.net Thu Jan 27 19:55:09 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Jan 27 19:55:24 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.831.4.165, 1.831.4.166 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22415/Misc Modified Files: Tag: release23-maint NEWS Log Message: Partially revert #1074011; don't try to fflush stdin. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.831.4.165 retrieving revision 1.831.4.166 diff -u -d -r1.831.4.165 -r1.831.4.166 --- NEWS 25 Jan 2005 12:51:39 -0000 1.831.4.165 +++ NEWS 27 Jan 2005 18:55:01 -0000 1.831.4.166 @@ -4,6 +4,15 @@ (editors: check NEWS.help for information about editing NEWS using ReST.) +What's New in Python 2.3.5? +============================== + +*Release date: XX-XXX-2005* + +Core and builtins +----------------- +- Partially revert the fix for #1074011; don't try to fflush stdin anymore. + What's New in Python 2.3.5rc1? ============================== From loewis at users.sourceforge.net Thu Jan 27 19:56:19 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Jan 27 19:56:21 2005 Subject: [Python-checkins] python/dist/src/Python sysmodule.c,2.127,2.128 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22685/Python Modified Files: sysmodule.c Log Message: Partially revert #1074011; don't try to fflush stdin. Backported to 2.3 and 2.4. Index: sysmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v retrieving revision 2.127 retrieving revision 2.128 diff -u -d -r2.127 -r2.128 --- sysmodule.c 23 Jan 2005 09:41:49 -0000 2.127 +++ sysmodule.c 27 Jan 2005 18:56:16 -0000 2.128 @@ -947,7 +947,16 @@ m = Py_InitModule3("sys", sys_methods, sys_doc); sysdict = PyModule_GetDict(m); - sysin = PyFile_FromFile(stdin, "", "r", _check_and_flush); + /* Closing the standard FILE* if sys.std* goes aways causes problems + * for embedded Python usages. Closing them when somebody explicitly + * invokes .close() might be possible, but the FAQ promises they get + * never closed. However, we still need to get write errors when + * writing fails (e.g. because stdout is redirected), so we flush the + * streams and check for errors before the file objects are deleted. + * On OS X, fflush()ing stdin causes an error, so we exempt stdin + * from that procedure. + */ + sysin = PyFile_FromFile(stdin, "", "r", NULL); sysout = PyFile_FromFile(stdout, "", "w", _check_and_flush); syserr = PyFile_FromFile(stderr, "", "w", _check_and_flush); if (PyErr_Occurred()) From loewis at users.sourceforge.net Thu Jan 27 19:56:19 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Jan 27 19:56:22 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1233,1.1234 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22685/Misc Modified Files: NEWS Log Message: Partially revert #1074011; don't try to fflush stdin. Backported to 2.3 and 2.4. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1233 retrieving revision 1.1234 diff -u -d -r1.1233 -r1.1234 --- NEWS 23 Jan 2005 15:16:08 -0000 1.1233 +++ NEWS 27 Jan 2005 18:56:15 -0000 1.1234 @@ -10,7 +10,7 @@ Core and builtins ----------------- -- Bug #1074011: closing sys.std{in,out,err} now causes a flush() and +- Bug #1074011: closing sys.std{out,err} now causes a flush() and an ferror() call. - min() and max() now support key= arguments with the same meaning as in From loewis at users.sourceforge.net Thu Jan 27 19:58:50 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Jan 27 19:58:52 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.15, 1.1193.2.16 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23271/Misc Modified Files: Tag: release24-maint NEWS Log Message: Partially revert #1074011; don't try to fflush stdin. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.15 retrieving revision 1.1193.2.16 diff -u -d -r1.1193.2.15 -r1.1193.2.16 --- NEWS 23 Jan 2005 09:50:12 -0000 1.1193.2.15 +++ NEWS 27 Jan 2005 18:58:29 -0000 1.1193.2.16 @@ -12,7 +12,7 @@ Core and builtins ----------------- -- Bug #1074011: closing sys.std{in,out,err} now causes a flush() and +- Bug #1074011: closing sys.std{out,err} now causes a flush() and an ferror() call. - Bug #1085744: Add missing overflow check to PySequence_Tuple(). From loewis at users.sourceforge.net Thu Jan 27 19:59:03 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Jan 27 19:59:06 2005 Subject: [Python-checkins] python/dist/src/Python sysmodule.c, 2.126.2.1, 2.126.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23271/Python Modified Files: Tag: release24-maint sysmodule.c Log Message: Partially revert #1074011; don't try to fflush stdin. Index: sysmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v retrieving revision 2.126.2.1 retrieving revision 2.126.2.2 diff -u -d -r2.126.2.1 -r2.126.2.2 --- sysmodule.c 23 Jan 2005 09:50:14 -0000 2.126.2.1 +++ sysmodule.c 27 Jan 2005 18:58:30 -0000 2.126.2.2 @@ -947,7 +947,16 @@ m = Py_InitModule3("sys", sys_methods, sys_doc); sysdict = PyModule_GetDict(m); - sysin = PyFile_FromFile(stdin, "", "r", _check_and_flush); + /* Closing the standard FILE* if sys.std* goes aways causes problems + * for embedded Python usages. Closing them when somebody explicitly + * invokes .close() might be possible, but the FAQ promises they get + * never closed. However, we still need to get write errors when + * writing fails (e.g. because stdout is redirected), so we flush the + * streams and check for errors before the file objects are deleted. + * On OS X, fflush()ing stdin causes an error, so we exempt stdin + * from that procedure. + */ + sysin = PyFile_FromFile(stdin, "", "r", NULL); sysout = PyFile_FromFile(stdout, "", "w", _check_and_flush); syserr = PyFile_FromFile(stderr, "", "w", _check_and_flush); if (PyErr_Occurred()) From bcannon at users.sourceforge.net Thu Jan 27 23:48:33 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Thu Jan 27 23:48:37 2005 Subject: [Python-checkins] python/dist/src/Lib threading.py,1.47,1.48 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15668/Lib Modified Files: threading.py Log Message: Fixed typo in verbose output. Closes bug #1110998. Thanks Matthew Bogosian. Index: threading.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/threading.py,v retrieving revision 1.47 retrieving revision 1.48 diff -u -d -r1.47 -r1.48 --- threading.py 8 Jan 2005 07:30:42 -0000 1.47 +++ threading.py 27 Jan 2005 22:48:30 -0000 1.48 @@ -102,7 +102,7 @@ self.__owner = me self.__count = 1 if __debug__: - self._note("%s.acquire(%s): initial succes", self, blocking) + self._note("%s.acquire(%s): initial success", self, blocking) else: if __debug__: self._note("%s.acquire(%s): failure", self, blocking) From bcannon at users.sourceforge.net Thu Jan 27 23:49:44 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Thu Jan 27 23:49:48 2005 Subject: [Python-checkins] python/dist/src/Lib threading.py,1.45,1.45.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16033/Lib Modified Files: Tag: release24-maint threading.py Log Message: Fixed typo in verbose output for RLock acquire. Fixes bug #1110998. Index: threading.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/threading.py,v retrieving revision 1.45 retrieving revision 1.45.4.1 diff -u -d -r1.45 -r1.45.4.1 --- threading.py 21 Jul 2004 03:36:52 -0000 1.45 +++ threading.py 27 Jan 2005 22:49:39 -0000 1.45.4.1 @@ -102,7 +102,7 @@ self.__owner = me self.__count = 1 if __debug__: - self._note("%s.acquire(%s): initial succes", self, blocking) + self._note("%s.acquire(%s): initial success", self, blocking) else: if __debug__: self._note("%s.acquire(%s): failure", self, blocking) From bcannon at users.sourceforge.net Thu Jan 27 23:52:12 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Thu Jan 27 23:52:15 2005 Subject: [Python-checkins] python/dist/src/Lib threading.py, 1.38.6.4, 1.38.6.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16561/Lib Modified Files: Tag: release23-maint threading.py Log Message: Fix typo in verbose output for RLock when the initial lock acquisition occurs. Closes bug #1110998. Index: threading.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/threading.py,v retrieving revision 1.38.6.4 retrieving revision 1.38.6.5 diff -u -d -r1.38.6.4 -r1.38.6.5 --- threading.py 21 Jul 2004 05:08:32 -0000 1.38.6.4 +++ threading.py 27 Jan 2005 22:52:09 -0000 1.38.6.5 @@ -102,7 +102,7 @@ self.__owner = me self.__count = 1 if __debug__: - self._note("%s.acquire(%s): initial succes", self, blocking) + self._note("%s.acquire(%s): initial success", self, blocking) else: if __debug__: self._note("%s.acquire(%s): failure", self, blocking) From kbk at users.sourceforge.net Fri Jan 28 01:16:19 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Fri Jan 28 01:16:22 2005 Subject: [Python-checkins] python/dist/src/Lib/idlelib EditorWindow.py, 1.65, 1.66 NEWS.txt, 1.53, 1.54 config-keys.def, 1.21, 1.22 configHandler.py, 1.37, 1.38 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5316 Modified Files: EditorWindow.py NEWS.txt config-keys.def configHandler.py Log Message: Add keybindings for del-word-left and del-word-right. M EditorWindow.py M NEWS.txt M config-keys.def M configHandler.py Index: EditorWindow.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/EditorWindow.py,v retrieving revision 1.65 retrieving revision 1.66 diff -u -d -r1.65 -r1.66 --- EditorWindow.py 19 Jan 2005 00:22:54 -0000 1.65 +++ EditorWindow.py 28 Jan 2005 00:16:15 -0000 1.66 @@ -141,6 +141,8 @@ text.bind("<>",self.change_indentwidth_event) text.bind("", self.move_at_edge_if_selection(0)) text.bind("", self.move_at_edge_if_selection(1)) + text.bind("<>", self.del_word_left) + text.bind("<>", self.del_word_right) if flist: flist.inversedict[self] = key @@ -386,6 +388,14 @@ pass return move_at_edge + def del_word_left(self, event): + self.text.event_generate('') + return "break" + + def del_word_right(self, event): + self.text.event_generate('') + return "break" + def find_event(self, event): SearchDialog.find(self.text) return "break" Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.53 retrieving revision 1.54 diff -u -d -r1.53 -r1.54 --- NEWS.txt 19 Jan 2005 00:22:57 -0000 1.53 +++ NEWS.txt 28 Jan 2005 00:16:16 -0000 1.54 @@ -3,17 +3,24 @@ *Release date: XX-XXX-2005* +- Add keybindings for del-word-left and del-word-right. + - Discourage using an indent width other than 8 when using tabs to indent Python code. - Restore use of EditorWindow.set_indentation_params(), was dead code since - Autoindent was merged into EditorWindow. + Autoindent was merged into EditorWindow. This allows IDLE to conform to the + indentation width of a loaded file. (But it still will not switch to tabs + even if the file uses tabs.) Any change in indent width is local to that + window. - Add Tabnanny check before Run/F5, not just when Checking module. - If an extension can't be loaded, print warning and skip it instead of erroring out. +- Improve error handling when .idlerc can't be created (warn and exit). + - The GUI was hanging if the shell window was closed while a raw_input() was pending. Restored the quit() of the readline() mainloop(). http://mail.python.org/pipermail/idle-dev/2004-December/002307.html Index: config-keys.def =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/config-keys.def,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- config-keys.def 17 Aug 2004 08:01:19 -0000 1.21 +++ config-keys.def 28 Jan 2005 00:16:16 -0000 1.22 @@ -55,6 +55,8 @@ untabify-region= toggle-tabs= change-indentwidth= +del-word-left= +del-word-right= [IDLE Classic Unix] copy= @@ -104,6 +106,8 @@ untabify-region= toggle-tabs= change-indentwidth= +del-word-left= +del-word-right= [IDLE Classic Mac] copy= @@ -153,3 +157,5 @@ untabify-region= toggle-tabs= change-indentwidth= +del-word-left= +del-word-right= Index: configHandler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/configHandler.py,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- configHandler.py 13 Jan 2005 17:37:38 -0000 1.37 +++ configHandler.py 28 Jan 2005 00:16:16 -0000 1.38 @@ -579,7 +579,9 @@ '<>': [''], '<>': [''], '<>': [''], - '<>': [''] + '<>': [''], + '<>': [''], + '<>': [''] } if keySetName: for event in keyBindings.keys(): From loewis at users.sourceforge.net Sat Jan 29 14:29:25 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sat Jan 29 14:29:29 2005 Subject: [Python-checkins] python/dist/src/Lib os.py,1.84,1.85 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6194/Lib Modified Files: os.py Log Message: Revert os.py 1.75, and directly implement update. Fixes #1110478 and #1100235. Index: os.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/os.py,v retrieving revision 1.84 retrieving revision 1.85 diff -u -d -r1.84 -r1.85 --- os.py 16 Jan 2005 08:40:57 -0000 1.84 +++ os.py 29 Jan 2005 13:29:22 -0000 1.85 @@ -442,6 +442,17 @@ return key.upper() in self.data def get(self, key, failobj=None): return self.data.get(key.upper(), failobj) + def update(self, dict=None, **kwargs): + if dict: + try: + items = dict.items() + except AttributeError: + # List of (key, value) + items = dict + for k, v in items: + self[k] = v + if kwargs: + self.update(kwargs) def copy(self): return dict(self) @@ -453,6 +464,17 @@ def __setitem__(self, key, item): putenv(key, item) self.data[key] = item + def update(self, dict=None, **kwargs): + if dict: + try: + items = dict.items() + except AttributeError: + # List of (key, value) + items = dict + for k, v in items: + self[k] = v + if kwargs: + self.update(kwargs) try: unsetenv except NameError: From loewis at users.sourceforge.net Sat Jan 29 14:29:25 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sat Jan 29 14:29:31 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_os.py,1.28,1.29 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6194/Lib/test Modified Files: test_os.py Log Message: Revert os.py 1.75, and directly implement update. Fixes #1110478 and #1100235. Index: test_os.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_os.py,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- test_os.py 23 Jan 2005 09:19:20 -0000 1.28 +++ test_os.py 29 Jan 2005 13:29:23 -0000 1.29 @@ -226,6 +226,13 @@ os.environ.clear() os.environ.update(self.__save) + # Bug 1110478 + def test_update(self): + if os.path.exists("/bin/sh"): + os.environ.update(HELLO="World") + value = os.popen("/bin/sh -c 'echo $HELLO'").read().strip() + self.assertEquals(value, "World") + class WalkTests(unittest.TestCase): """Tests for os.walk().""" From loewis at users.sourceforge.net Sat Jan 29 14:29:28 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sat Jan 29 14:29:33 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1234,1.1235 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6194/Misc Modified Files: NEWS Log Message: Revert os.py 1.75, and directly implement update. Fixes #1110478 and #1100235. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1234 retrieving revision 1.1235 diff -u -d -r1.1234 -r1.1235 --- NEWS 27 Jan 2005 18:56:15 -0000 1.1234 +++ NEWS 29 Jan 2005 13:29:23 -0000 1.1235 @@ -45,6 +45,8 @@ Library ------- +- Bug #1110478: Revert os.environ.update to do putenv again. + - Bug #1103844: fix distutils.install.dump_dirs() with negated options. - os.{SEEK_SET, SEEK_CUR, SEEK_END} have been added for convenience. From loewis at users.sourceforge.net Sat Jan 29 14:33:30 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sat Jan 29 14:33:33 2005 Subject: [Python-checkins] python/dist/src/Lib os.py,1.83,1.83.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7293/Lib Modified Files: Tag: release24-maint os.py Log Message: Revert os.py 1.75, and directly implement update. Fixes #1110478 and #1100235. Index: os.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/os.py,v retrieving revision 1.83 retrieving revision 1.83.2.1 diff -u -d -r1.83 -r1.83.2.1 --- os.py 11 Oct 2004 18:12:15 -0000 1.83 +++ os.py 29 Jan 2005 13:33:23 -0000 1.83.2.1 @@ -435,6 +435,17 @@ return key.upper() in self.data def get(self, key, failobj=None): return self.data.get(key.upper(), failobj) + def update(self, dict=None, **kwargs): + if dict: + try: + items = dict.items() + except AttributeError: + # List of (key, value) + items = dict + for k, v in items: + self[k] = v + if kwargs: + self.update(kwargs) def copy(self): return dict(self) @@ -446,6 +457,17 @@ def __setitem__(self, key, item): putenv(key, item) self.data[key] = item + def update(self, dict=None, **kwargs): + if dict: + try: + items = dict.items() + except AttributeError: + # List of (key, value) + items = dict + for k, v in items: + self[k] = v + if kwargs: + self.update(kwargs) try: unsetenv except NameError: From loewis at users.sourceforge.net Sat Jan 29 14:33:31 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sat Jan 29 14:33:36 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.16, 1.1193.2.17 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7293/Misc Modified Files: Tag: release24-maint NEWS Log Message: Revert os.py 1.75, and directly implement update. Fixes #1110478 and #1100235. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.16 retrieving revision 1.1193.2.17 diff -u -d -r1.1193.2.16 -r1.1193.2.17 --- NEWS 27 Jan 2005 18:58:29 -0000 1.1193.2.16 +++ NEWS 29 Jan 2005 13:33:27 -0000 1.1193.2.17 @@ -25,6 +25,8 @@ Library ------- +- Bug #1110478: Revert os.environ.update to do putenv again. + - Bug #1103844: fix distutils.install.dump_dirs() with negated options. - Bug #1067732: wininst --install-script doesn't leave residual files anymore. From bwarsaw at users.sourceforge.net Sat Jan 29 19:25:04 2005 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Sat Jan 29 19:25:07 2005 Subject: [Python-checkins] python/nondist/peps pep-0000.txt, 1.297, 1.298 pep-0215.txt, 1.3, 1.4 pep-0278.txt, 1.9, 1.10 pep-0292.txt, 1.15, 1.16 pep-0318.txt, 1.35, 1.36 pep-0324.txt, 1.7, 1.8 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6250 Modified Files: pep-0000.txt pep-0215.txt pep-0278.txt pep-0292.txt pep-0318.txt pep-0324.txt Log Message: Jim Jewett points out that PEPs 278, 292, 318, and 324 can be marked as Final, and that 215 can be marked as Rejected. Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.297 retrieving revision 1.298 diff -u -d -r1.297 -r1.298 --- pep-0000.txt 11 Dec 2004 20:24:11 -0000 1.297 +++ pep-0000.txt 29 Jan 2005 18:24:59 -0000 1.298 @@ -65,14 +65,12 @@ S 252 Making Types Look More Like Classes GvR S 253 Subtyping Built-in Types GvR SA 309 Partial Function Application Harris - SA 318 Decorators for Functions and Methods Smith, et al SA 328 Imports: Multi-Line and Absolute/Relative Aahz Open PEPs (under consideration) I 206 2.0 Batteries Included Zadka S 209 Adding Multidimensional Arrays Barrett, Oliphant - S 215 String Interpolation Yee S 228 Reworking Python's Numeric Model Zadka, GvR S 237 Unifying Long Integers and Integers Zadka, GvR S 239 Adding a Rational Type to Python Craig, Zadka @@ -91,14 +89,12 @@ S 274 Dict Comprehensions Warsaw S 275 Switching on Multiple Values Lemburg S 276 Simple Iterator for ints Althoff - S 278 Universal Newline Support Jansen S 280 Optimizing access to globals GvR S 281 Loop Counter Iteration with range and xrange Hetland S 284 Integer for-loops Eppstein, Ewing S 286 Enhanced Argument Tuples von Loewis I 287 reStructuredText Docstring Format Goodger S 288 Generators Attributes and Exceptions Hettinger - S 292 Simpler String Substitutions Warsaw S 294 Type Names in the types Module Tirosh S 297 Support for System Upgrades Lemburg S 298 The Locked Buffer Interface Heller @@ -115,7 +111,6 @@ S 319 Python Synchronize/Asynchronize Block Pelletier S 321 Date/Time Parsing and Formatting Kuchling S 323 Copyable Iterators Martelli - S 324 subprocess - New process module Astrand S 325 Resource-Release Support for Generators Pedroni S 330 Python Bytecode Verification Pelletier S 331 Locale-Independent Float/String conversions Reis @@ -162,17 +157,21 @@ SF 264 Future statements in simulated shells Hudson SF 273 Import Modules from Zip Archives Ahlstrom SF 277 Unicode file name support for Windows NT Hodgson + SF 278 Universal Newline Support Jansen SF 279 The enumerate() built-in function Hettinger SF 282 A Logging System Sajip, Mick IF 283 Python 2.3 Release Schedule GvR SF 285 Adding a bool type GvR SF 289 Generator Expressions Hettinger + SF 292 Simpler String Substitutions Warsaw 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 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 SF 322 Reverse Iteration Hettinger + SF 324 subprocess - New process module Astrand SF 327 Decimal Data Type Batista Empty PEPs (or containing only an abstract) @@ -186,6 +185,7 @@ SD 211 Adding A New Outer Product Operator Wilson SD 212 Loop Counter Iteration Schneider-Kamp SD 213 Attribute Access Handlers Prescod + SR 215 String Interpolation Yee IR 216 Docstring Format Zadka SD 219 Stackless Python McMillan SD 222 Web Library Enhancements Kuchling @@ -249,7 +249,7 @@ SD 212 Loop Counter Iteration Schneider-Kamp SD 213 Attribute Access Handlers Prescod SF 214 Extended Print Statement Warsaw - SD 215 String Interpolation Yee + SR 215 String Interpolation Yee IR 216 Docstring Format Zadka SF 217 Display Hook for Interactive Use Zadka SF 218 Adding a Built-In Set Object Type Wilson, Hettinger @@ -312,7 +312,7 @@ S 275 Switching on Multiple Values Lemburg S 276 Simple Iterator for ints Althoff SF 277 Unicode file name support for Windows NT Hodgson - S 278 Universal Newline Support Jansen + SF 278 Universal Newline Support Jansen SF 279 The enumerate() built-in function Hettinger S 280 Optimizing access to globals GvR S 281 Loop Counter Iteration with range and xrange Hetland @@ -326,7 +326,7 @@ SF 289 Generator Expressions Hettinger I 290 Code Migration and Modernization Hettinger I 291 Backward Compatibility for Standard Library Norwitz - S 292 Simpler String Substitutions Warsaw + SF 292 Simpler String Substitutions Warsaw SF 293 Codec Error Handling Callbacks Dörwald S 294 Type Names in the types Module Tirosh SR 295 Interpretation of multiline string constants Koltsov @@ -351,13 +351,13 @@ S 315 Enhanced While Loop Carroll SD 316 Programming by Contract for Python Way SR 317 Eliminate Implicit Exception Instantiation Taschuk - SA 318 Decorators for Functions and Methods Smith, et al + SF 318 Decorators for Functions and Methods Smith, et al S 319 Python Synchronize/Asynchronize Block Pelletier IF 320 Python 2.4 Release Schedule Warsaw, et al S 321 Date/Time Parsing and Formatting Kuchling SF 322 Reverse Iteration Hettinger S 323 Copyable Iterators Martelli - S 324 subprocess - New POSIX process module Astrand + SF 324 subprocess - New POSIX process module Astrand S 325 Resource-Release Support for Generators Pedroni SR 326 A Case for Top and Bottom Values Carlson, Reedy SF 327 Decimal Data Type Batista Index: pep-0215.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0215.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- pep-0215.txt 30 Jan 2001 17:09:53 -0000 1.3 +++ pep-0215.txt 29 Jan 2005 18:24:59 -0000 1.4 @@ -2,11 +2,12 @@ Title: String Interpolation Version: $Revision$ Author: ping@lfw.org (Ka-Ping Yee) -Status: Draft +Status: Rejected Type: Standards Track Python-Version: 2.1 Created: 24-Jul-2000 Post-History: +Replaced-By: 292 Abstract Index: pep-0278.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0278.txt,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- pep-0278.txt 6 May 2004 04:17:58 -0000 1.9 +++ pep-0278.txt 29 Jan 2005 18:24:59 -0000 1.10 @@ -3,7 +3,7 @@ Version: $Revision$ Last-Modified: $Date$ Author: jack@cwi.nl (Jack Jansen) -Status: Draft +Status: Final Type: Standards Track Created: 14-Jan-2002 Python-Version: 2.3 Index: pep-0292.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0292.txt,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- pep-0292.txt 18 Sep 2004 20:53:35 -0000 1.15 +++ pep-0292.txt 29 Jan 2005 18:24:59 -0000 1.16 @@ -3,7 +3,7 @@ Version: $Revision$ Last-Modified: $Date$ Author: barry@python.org (Barry A. Warsaw) -Status: Draft +Status: Final Type: Standards Track Created: 18-Jun-2002 Python-Version: 2.4 Index: pep-0318.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0318.txt,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- pep-0318.txt 14 Sep 2004 07:34:23 -0000 1.35 +++ pep-0318.txt 29 Jan 2005 18:24:59 -0000 1.36 @@ -3,7 +3,7 @@ Version: $Revision$ Last-Modified: $Date$ Author: Kevin D. Smith, Jim Jewett, Skip Montanaro, Anthony Baxter -Status: Draft +Status: Final Type: Standards Track Content-Type: text/x-rst Created: 05-Jun-2003 Index: pep-0324.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0324.txt,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- pep-0324.txt 27 Nov 2004 07:44:10 -0000 1.7 +++ pep-0324.txt 29 Jan 2005 18:24:59 -0000 1.8 @@ -3,7 +3,7 @@ Version: $Revision$ Last-Modified: $Date$ Author: Peter Astrand -Status: Draft +Status: Final Type: Standards Track (library) Created: 19-Nov-2003 Content-Type: text/plain From jlgijsbers at users.sourceforge.net Sat Jan 29 20:49:38 2005 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sat Jan 29 20:49:41 2005 Subject: [Python-checkins] python/dist/src/Doc/lib tkinter.tex,1.30,1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26648 Modified Files: tkinter.tex Log Message: Bug #1108490: fix broken link. Index: tkinter.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/tkinter.tex,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- tkinter.tex 19 Jan 2005 03:39:16 -0000 1.30 +++ tkinter.tex 29 Jan 2005 19:49:34 -0000 1.31 @@ -1353,7 +1353,7 @@ \item \ulink{Compound} -{http://tix.sourceforge.net/dist/current/man/html/TixCmd/compound.html} +{http://tix.sourceforge.net/dist/current/man/html/TixCmd/compound.htm} image types can be used to create images that consists of multiple horizontal lines; each line is composed of a series of items (texts, bitmaps, images or spaces) arranged from left to right. For example, a From jlgijsbers at users.sourceforge.net Sat Jan 29 20:54:48 2005 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sat Jan 29 20:54:52 2005 Subject: [Python-checkins] python/dist/src/Doc/lib tkinter.tex, 1.27.2.3, 1.27.2.4 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27820 Modified Files: Tag: release24-maint tkinter.tex Log Message: Backport for bug #1108490: fix broken link. Index: tkinter.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/tkinter.tex,v retrieving revision 1.27.2.3 retrieving revision 1.27.2.4 diff -u -d -r1.27.2.3 -r1.27.2.4 --- tkinter.tex 19 Jan 2005 03:42:09 -0000 1.27.2.3 +++ tkinter.tex 29 Jan 2005 19:54:45 -0000 1.27.2.4 @@ -1353,7 +1353,7 @@ \item \ulink{Compound} -{http://tix.sourceforge.net/dist/current/man/html/TixCmd/compound.html} +{http://tix.sourceforge.net/dist/current/man/html/TixCmd/compound.htm} image types can be used to create images that consists of multiple horizontal lines; each line is composed of a series of items (texts, bitmaps, images or spaces) arranged from left to right. For example, a From bwarsaw at users.sourceforge.net Sun Jan 30 04:08:05 2005 From: bwarsaw at users.sourceforge.net (bwarsaw@users.sourceforge.net) Date: Sun Jan 30 04:08:09 2005 Subject: [Python-checkins] python/nondist/peps pep-0000.txt, 1.298, 1.299 pep-0252.txt, 1.19, 1.20 pep-0253.txt, 1.18, 1.19 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19458 Modified Files: pep-0000.txt pep-0252.txt pep-0253.txt Log Message: Marking PEPs 252 and 253 as final, with GvR's approval. Includes an editor's note about the accuracy of the description in the PEP. Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.298 retrieving revision 1.299 diff -u -d -r1.298 -r1.299 --- pep-0000.txt 29 Jan 2005 18:24:59 -0000 1.298 +++ pep-0000.txt 30 Jan 2005 03:08:02 -0000 1.299 @@ -62,8 +62,6 @@ Accepted PEPs (accepted; may not be implemented yet) - S 252 Making Types Look More Like Classes GvR - S 253 Subtyping Built-in Types GvR SA 309 Partial Function Application Harris SA 328 Imports: Multi-Line and Absolute/Relative Aahz @@ -150,6 +148,8 @@ SF 241 Metadata for Python Software Packages Kuchling SF 250 Using site-packages on Windows Moore IF 251 Python 2.2 Release Schedule Warsaw, GvR + SF 252 Making Types Look More Like Classes GvR + SF 253 Subtyping Built-in Types GvR SF 255 Simple Generators Schemenauer, et al SF 260 Simplify xrange() GvR SF 261 Support for "wide" Unicode characters Prescod @@ -286,8 +286,8 @@ IF 249 Python Database API Specification v2.0 Lemburg SF 250 Using site-packages on Windows Moore IF 251 Python 2.2 Release Schedule Warsaw, GvR - S 252 Making Types Look More Like Classes GvR - S 253 Subtyping Built-in Types GvR + SF 252 Making Types Look More Like Classes GvR + SF 253 Subtyping Built-in Types GvR S 254 Making Classes Look More Like Types GvR SF 255 Simple Generators Schemenauer, et al S 256 Docstring Processing System Framework Goodger Index: pep-0252.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0252.txt,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- pep-0252.txt 4 Oct 2001 04:58:56 -0000 1.19 +++ pep-0252.txt 30 Jan 2005 03:08:02 -0000 1.20 @@ -2,7 +2,7 @@ Title: Making Types Look More Like Classes Version: $Revision$ Author: guido@python.org (Guido van Rossum) -Status: Draft +Status: Final Type: Standards Track Python-Version: 2.2 Created: 19-Apr-2001 @@ -27,6 +27,9 @@ Based on the generalized descriptor API, this PEP also introduces a way to declare class methods and static methods. + [Editor's note: the ideas described in this PEP have been incorporated + into Python. The PEP no longer accurately describes the implementation.] + Introduction Index: pep-0253.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0253.txt,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- pep-0253.txt 19 Oct 2001 18:17:00 -0000 1.18 +++ pep-0253.txt 30 Jan 2005 03:08:02 -0000 1.19 @@ -2,7 +2,7 @@ Title: Subtyping Built-in Types Version: $Revision$ Author: guido@python.org (Guido van Rossum) -Status: Draft +Status: Final Type: Standards Track Python-Version: 2.2 Created: 14-May-2001 @@ -13,6 +13,9 @@ This PEP proposes additions to the type object API that will allow the creation of subtypes of built-in types, in C and in Python. + [Editor's note: the ideas described in this PEP have been incorporated + into Python. The PEP no longer accurately describes the implementation.] + Introduction From kbk at users.sourceforge.net Mon Jan 31 04:34:29 2005 From: kbk at users.sourceforge.net (kbk@users.sourceforge.net) Date: Mon Jan 31 04:34:37 2005 Subject: [Python-checkins] python/dist/src/Lib/idlelib EditorWindow.py, 1.66, 1.67 NEWS.txt, 1.54, 1.55 configDialog.py, 1.60, 1.61 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12586 Modified Files: EditorWindow.py NEWS.txt configDialog.py Log Message: 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 tabs for the current EditorWindow via the Format menu) but IDLE will encourage indentation via spaces. Enable setting the indentation width using the Options dialog. Bug # 783877 Remove some commented out old code from configDialog.py (related to old methods for invoking the HelpBrowser). M EditorWindow.py M NEWS.txt M configHandler.py Index: EditorWindow.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/EditorWindow.py,v retrieving revision 1.66 retrieving revision 1.67 diff -u -d -r1.66 -r1.67 --- EditorWindow.py 28 Jan 2005 00:16:15 -0000 1.66 +++ EditorWindow.py 31 Jan 2005 03:34:26 -0000 1.67 @@ -157,12 +157,12 @@ vbar['command'] = text.yview vbar.pack(side=RIGHT, fill=Y) text['yscrollcommand'] = vbar.set - fontWeight='normal' - if idleConf.GetOption('main','EditorWindow','font-bold',type='bool'): + fontWeight = 'normal' + if idleConf.GetOption('main', 'EditorWindow', 'font-bold', type='bool'): fontWeight='bold' - text.config(font=(idleConf.GetOption('main','EditorWindow','font'), - idleConf.GetOption('main','EditorWindow','font-size'), - fontWeight)) + text.config(font=(idleConf.GetOption('main', 'EditorWindow', 'font'), + idleConf.GetOption('main', 'EditorWindow', 'font-size'), + fontWeight)) text_frame.pack(side=LEFT, fill=BOTH, expand=1) text.pack(side=TOP, fill=BOTH, expand=1) text.focus_set() @@ -173,19 +173,23 @@ # which will cause Tabnanny to nag! # false -> tab characters are converted to spaces by indent # and dedent cmds, and ditto TAB keystrokes - self.usetabs = False - - # indentwidth is the number of characters per logical indent level. - # Recommended Python default indent is four spaces. - self.indentwidth = 4 + # Although use-spaces=0 can be configured manually in config-main.def, + # configuration of tabs v. spaces is not supported in the configuration + # dialog. IDLE promotes the preferred Python indentation: use spaces! + usespaces = idleConf.GetOption('main', 'Indent', 'use-spaces', type='bool') + self.usetabs = not usespaces # tabwidth is the display width of a literal tab character. # CAUTION: telling Tk to use anything other than its default # tab setting causes it to use an entirely different tabbing algorithm, # treating tab stops as fixed distances from the left margin. # Nobody expects this, so for now tabwidth should never be changed. - self.tabwidth = 8 # for IDLE use, must remain 8 until Tk is fixed. - # indentwidth should be 8 when usetabs is True. + self.tabwidth = 8 # must remain 8 until Tk is fixed. + + # indentwidth is the number of screen characters per indent level. + # The recommended Python indentation is four spaces. + self.indentwidth = self.tabwidth + self.set_notabs_indentwidth() # If context_use_ps1 is true, parsing searches back for a ps1 line; # else searches for a popular (if, def, ...) Python stmt. @@ -583,6 +587,13 @@ accel=get_accelerator(keydefs, event) menu.entryconfig(index,accelerator=accel) + def set_notabs_indentwidth(self): + "Update the indentwidth if changed and not using tabs in this window" + # Called from configDialog.py + if not self.usetabs: + self.indentwidth = idleConf.GetOption('main', 'Indent','num-spaces', + type='int') + def reset_help_menu_entries(self): "Update the additional help entries on the Help menu" help_list = idleConf.GetAllExtraHelpSourcesList() Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.54 retrieving revision 1.55 diff -u -d -r1.54 -r1.55 --- NEWS.txt 28 Jan 2005 00:16:16 -0000 1.54 +++ NEWS.txt 31 Jan 2005 03:34:26 -0000 1.55 @@ -3,6 +3,15 @@ *Release date: XX-XXX-2005* +- 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 + tabs for the current EditorWindow via the Format menu) but IDLE will + encourage indentation via spaces. + +- Enable setting the indentation width using the Options dialog. + Bug # 783877 + - Add keybindings for del-word-left and del-word-right. - Discourage using an indent width other than 8 when using tabs to indent Index: configDialog.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/configDialog.py,v retrieving revision 1.60 retrieving revision 1.61 diff -u -d -r1.60 -r1.61 --- configDialog.py 16 Nov 2004 21:28:36 -0000 1.60 +++ configDialog.py 31 Jan 2005 03:34:26 -0000 1.61 @@ -6,7 +6,7 @@ and default window size. Define additional help sources. Note that tab width in IDLE is currently fixed at eight due to Tk issues. -Refer to comment in EditorWindow autoindent code for details. +Refer to comments in EditorWindow autoindent code for details. """ from Tkinter import * @@ -21,9 +21,7 @@ from configHelpSourceEdit import GetHelpSourceDialog class ConfigDialog(Toplevel): - """ - configuration dialog for idle - """ + def __init__(self,parent,title): Toplevel.__init__(self, parent) self.configure(borderwidth=5) @@ -93,8 +91,6 @@ self.fontBold=BooleanVar(self) self.fontName=StringVar(self) self.spaceNum=IntVar(self) - #self.tabCols=IntVar(self) - self.indentBySpaces=BooleanVar(self) self.editFont=tkFont.Font(self,('courier',10,'normal')) ##widget creation #body frame @@ -124,25 +120,12 @@ text='AaBbCcDdEe\nFfGgHhIiJjK\n1234567890\n#:+=(){}[]', justify=LEFT,font=self.editFont) #frameIndent - labelIndentTitle=Label(frameIndent,text='Set Indentation Defaults') - frameIndentType=Frame(frameIndent) frameIndentSize=Frame(frameIndent) - labelIndentTypeTitle=Label(frameIndentType, - text='Choose indentation type :') - radioUseSpaces=Radiobutton(frameIndentType,variable=self.indentBySpaces, - value=1,text='Tab key inserts spaces') - radioUseTabs=Radiobutton(frameIndentType,variable=self.indentBySpaces, - value=0,text='Tab key inserts tabs') - labelIndentSizeTitle=Label(frameIndentSize, - text='Choose indentation size :') - labelSpaceNumTitle=Label(frameIndentSize,justify=LEFT, - text='indent width') - self.scaleSpaceNum=Scale(frameIndentSize,variable=self.spaceNum, - orient='horizontal',tickinterval=2,from_=2,to=16) - #labeltabColsTitle=Label(frameIndentSize,justify=LEFT, - # text='when tab key inserts tabs,\ncolumns per tab') - #self.scaleTabCols=Scale(frameIndentSize,variable=self.tabCols, - # orient='horizontal',tickinterval=2,from_=2,to=8) + labelSpaceNumTitle=Label(frameIndentSize, justify=LEFT, + text='Python Standard: 4 Spaces!') + self.scaleSpaceNum=Scale(frameIndentSize, variable=self.spaceNum, + label='Indentation Width', orient='horizontal', + tickinterval=2, from_=2, to=16) #widget packing #body frameFont.pack(side=LEFT,padx=5,pady=10,expand=TRUE,fill=BOTH) @@ -160,17 +143,9 @@ frameFontSample.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=BOTH) self.labelFontSample.pack(expand=TRUE,fill=BOTH) #frameIndent - labelIndentTitle.pack(side=TOP,anchor=W,padx=5,pady=5) - frameIndentType.pack(side=TOP,padx=5,fill=X) frameIndentSize.pack(side=TOP,padx=5,pady=5,fill=BOTH) - labelIndentTypeTitle.pack(side=TOP,anchor=W,padx=5,pady=5) - radioUseSpaces.pack(side=TOP,anchor=W,padx=5) - radioUseTabs.pack(side=TOP,anchor=W,padx=5) - labelIndentSizeTitle.pack(side=TOP,anchor=W,padx=5,pady=5) labelSpaceNumTitle.pack(side=TOP,anchor=W,padx=5) self.scaleSpaceNum.pack(side=TOP,padx=5,fill=X) - #labeltabColsTitle.pack(side=TOP,anchor=W,padx=5) - #self.scaleTabCols.pack(side=TOP,padx=5,fill=X) return frame def CreatePageHighlight(self): @@ -390,7 +365,6 @@ radioEncNone=Radiobutton(frameEncoding,variable=self.encoding, value="none",text="None") #frameHelp - ##labelHelpTitle=Label(frameHelp,text='Help Options') frameHelpList=Frame(frameHelp) frameHelpListButtons=Frame(frameHelpList) labelHelpListTitle=Label(frameHelpList,text='Additional Help Sources:') @@ -406,13 +380,6 @@ width=8,command=self.HelpListItemAdd) self.buttonHelpListRemove=Button(frameHelpListButtons,text='Remove', state=DISABLED,width=8,command=self.HelpListItemRemove) - # the following is better handled by the BROWSER environment - # variable under unix/linux - #checkHelpBrowser=Checkbutton(frameHelp,variable=self.userHelpBrowser, - # onvalue=1,offvalue=0,text='user specified (html) help browser:', - # command=self.OnCheckUserHelpBrowser) - #self.entryHelpBrowser=Entry(frameHelp,textvariable=self.helpBrowser, - # width=40) #widget packing #body frameRun.pack(side=TOP,padx=5,pady=5,fill=X) @@ -446,7 +413,6 @@ radioEncUTF8.pack(side=RIGHT,anchor=E,pady=5) radioEncLocale.pack(side=RIGHT,anchor=E,pady=5) #frameHelp - ##labelHelpTitle.pack(side=TOP,anchor=W,padx=5,pady=5) frameHelpListButtons.pack(side=RIGHT,padx=5,pady=5,fill=Y) frameHelpList.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=BOTH) labelHelpListTitle.pack(side=TOP,anchor=W) @@ -455,8 +421,6 @@ self.buttonHelpListEdit.pack(side=TOP,anchor=W,pady=5) self.buttonHelpListAdd.pack(side=TOP,anchor=W) self.buttonHelpListRemove.pack(side=TOP,anchor=W,pady=5) - #checkHelpBrowser.pack(side=TOP,anchor=W,padx=5) - #self.entryHelpBrowser.pack(side=TOP,anchor=W,padx=5,pady=5) return frame def AttachVarCallbacks(self): @@ -464,8 +428,6 @@ self.fontName.trace_variable('w',self.VarChanged_fontName) self.fontBold.trace_variable('w',self.VarChanged_fontBold) self.spaceNum.trace_variable('w',self.VarChanged_spaceNum) - #self.tabCols.trace_variable('w',self.VarChanged_tabCols) - self.indentBySpaces.trace_variable('w',self.VarChanged_indentBySpaces) self.colour.trace_variable('w',self.VarChanged_colour) self.builtinTheme.trace_variable('w',self.VarChanged_builtinTheme) self.customTheme.trace_variable('w',self.VarChanged_customTheme) @@ -494,18 +456,10 @@ value=self.fontBold.get() self.AddChangedItem('main','EditorWindow','font-bold',value) - def VarChanged_indentBySpaces(self,*params): - value=self.indentBySpaces.get() - self.AddChangedItem('main','Indent','use-spaces',value) - def VarChanged_spaceNum(self,*params): value=self.spaceNum.get() self.AddChangedItem('main','Indent','num-spaces',value) - #def VarChanged_tabCols(self,*params): - # value=self.tabCols.get() - # self.AddChangedItem('main','Indent','tab-cols',value) - def VarChanged_colour(self,*params): self.OnNewColourSet() @@ -912,12 +866,6 @@ self.textHighlightSample.tag_config(element, **colours) self.SetColourSample() -## def OnCheckUserHelpBrowser(self): -## if self.userHelpBrowser.get(): -## self.entryHelpBrowser.config(state=NORMAL) -## else: -## self.entryHelpBrowser.config(state=DISABLED) - def HelpSourceSelected(self,event): self.SetHelpListButtonStates() @@ -996,17 +944,10 @@ self.SetFontSample() def LoadTabCfg(self): - ##indent type radiobuttons - spaceIndent=idleConf.GetOption('main','Indent','use-spaces', - default=1,type='bool') - self.indentBySpaces.set(spaceIndent) ##indent sizes spaceNum=idleConf.GetOption('main','Indent','num-spaces', default=4,type='int') - #tabCols=idleConf.GetOption('main','Indent','tab-cols', - # default=4,type='int') self.spaceNum.set(spaceNum) - #self.tabCols.set(tabCols) def LoadThemeCfg(self): ##current theme type radiobutton @@ -1096,11 +1037,6 @@ for helpItem in self.userHelpList: self.listHelp.insert(END,helpItem[0]) self.SetHelpListButtonStates() - #self.userHelpBrowser.set(idleConf.GetOption('main','General', - # 'user-help-browser',default=0,type='bool')) - #self.helpBrowser.set(idleConf.GetOption('main','General', - # 'user-help-browser-command',default='')) - #self.OnCheckUserHelpBrowser() def LoadConfigs(self): """ @@ -1171,17 +1107,12 @@ self.ResetChangedItems() #clear the changed items dict def ActivateConfigChanges(self): - #things that need to be done to make - #applied config changes dynamic: - #update editor/shell font and repaint - #dynamically update indentation setttings - #update theme and repaint - #update keybindings and re-bind - #update user help sources menu + "Dynamically apply configuration changes" winInstances=self.parent.instance_dict.keys() for instance in winInstances: instance.ResetColorizer() instance.ResetFont() + instance.set_notabs_indentwidth() instance.ResetKeybindings() instance.reset_help_menu_entries() From mwh at users.sourceforge.net Mon Jan 31 18:02:07 2005 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Mon Jan 31 18:02:10 2005 Subject: [Python-checkins] python/dist/src/Modules posixmodule.c, 2.332, 2.333 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21253 Modified Files: posixmodule.c Log Message: Fix [ 1077106 ] Negative numbers to os.read() cause segfault Sorry for sitting on this for so long! Is there a chance it could make 2.3.5? Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.332 retrieving revision 2.333 diff -u -d -r2.332 -r2.333 --- posixmodule.c 16 Jan 2005 08:57:38 -0000 2.332 +++ posixmodule.c 31 Jan 2005 17:01:59 -0000 2.333 @@ -5349,6 +5349,10 @@ PyObject *buffer; if (!PyArg_ParseTuple(args, "ii:read", &fd, &size)) return NULL; + if (size < 0) { + errno = EINVAL; + return posix_error(); + } buffer = PyString_FromStringAndSize((char *)NULL, size); if (buffer == NULL) return NULL; From mwh at users.sourceforge.net Mon Jan 31 18:09:27 2005 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Mon Jan 31 18:09:30 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1235,1.1236 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24013/Misc Modified Files: NEWS Log Message: More bug #1077106 stuff, sorry -- modem induced impatiece! This should go on whatever bugfix branches the other fetches up on. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1235 retrieving revision 1.1236 diff -u -d -r1.1235 -r1.1236 --- NEWS 29 Jan 2005 13:29:23 -0000 1.1235 +++ NEWS 31 Jan 2005 17:09:20 -0000 1.1236 @@ -21,6 +21,8 @@ - set and frozenset objects can now be marshalled. SF #1098985. +- Bug #1077106: Poor argument checking could cause memory corruption + in calls to os.read(). Extension Modules ----------------- From mwh at users.sourceforge.net Mon Jan 31 18:09:28 2005 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Mon Jan 31 18:09:36 2005 Subject: [Python-checkins] python/dist/src/Objects stringobject.c, 2.226, 2.227 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24013/Objects Modified Files: stringobject.c Log Message: More bug #1077106 stuff, sorry -- modem induced impatiece! This should go on whatever bugfix branches the other fetches up on. Index: stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.226 retrieving revision 2.227 diff -u -d -r2.226 -r2.227 --- stringobject.c 26 Oct 2004 01:52:37 -0000 2.226 +++ stringobject.c 31 Jan 2005 17:09:25 -0000 2.227 @@ -52,6 +52,7 @@ PyString_FromStringAndSize(const char *str, int size) { register PyStringObject *op; + assert(size >= 0); if (size == 0 && (op = nullstring) != NULL) { #ifdef COUNT_ALLOCS null_strings++;