From akuchling at users.sourceforge.net Tue Mar 1 01:53:48 2005 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Tue Mar 1 01:53:52 2005 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew25.tex, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14628 Modified Files: whatsnew25.tex Log Message: Note various changes that need to be described Index: whatsnew25.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew25.tex,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- whatsnew25.tex 3 Dec 2004 15:16:40 -0000 1.4 +++ whatsnew25.tex 1 Mar 2005 00:53:46 -0000 1.5 @@ -26,8 +26,9 @@ %====================================================================== +\section{PEP 309: Partial Function Application} -% Large, PEP-level features and changes should be described here. +XXX describe this PEP. %====================================================================== @@ -54,6 +55,8 @@ print max(L) \end{verbatim} +% XXX also supported by heapq.nsmallest() and heapq.nlargest(). + (Contributed by Steven Bethard and Raymond Hettinger.) \end{itemize} @@ -84,7 +87,23 @@ \begin{itemize} -\item Descriptions go here. +% the cPickle module no longer accepts the deprecated None option in the +% args tuple returned by __reduce__(). + +% csv module improvements + +% datetime.datetime() now has a strptime class method which can be used to +% create datetime object using a string and format. + +% itertools.islice() now accepts None for the start and step arguments. + +\item New module: \module{spwd} provides functions for accessing the +shadow password database on systems that support it. +% XXX give example + +% XXX os.stat_float_times is now True + +% os.{SEEK_SET, SEEK_CUR, SEEK_END} have been added for convenience. \end{itemize} @@ -137,7 +156,11 @@ \begin{itemize} -\item Everything is all in the details! +\item Some old deprecated modules (\module{statcache}, \module{tzparse}, + \module{whrandom}) have been moved to \file{Lib/lib-old}. +% XXX note how to get them back + +% the pickle module no longer uses the deprecated bin parameter. \end{itemize} From bcannon at users.sourceforge.net Tue Mar 1 04:12:29 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Tue Mar 1 04:12:31 2005 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.33,1.34 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23426/Lib Modified Files: decimal.py Log Message: Fix small grammatical error in a docstring. Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- decimal.py 6 Feb 2005 06:57:07 -0000 1.33 +++ decimal.py 1 Mar 2005 03:12:26 -0000 1.34 @@ -1414,7 +1414,7 @@ return float(str(self)) def __int__(self): - """Converts self to a int, truncating if necessary.""" + """Converts self to an int, truncating if necessary.""" if self._is_special: if self._isnan(): context = getcontext() From bcannon at users.sourceforge.net Tue Mar 1 04:15:54 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Tue Mar 1 04:15:56 2005 Subject: [Python-checkins] python/dist/src/Lib/test test__locale.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-serv23998/Lib/test Modified Files: test__locale.py Log Message: Make test__locale more fine-grained. Now test localeconv and nl_langinfo individually as tests. Also improved output when the test fails. Index: test__locale.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test__locale.py,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- test__locale.py 8 Sep 2004 02:02:41 -0000 1.8 +++ test__locale.py 1 Mar 2005 03:15:50 -0000 1.9 @@ -11,9 +11,14 @@ 'da_DK', 'nn_NO', 'cs_CZ', 'de_LU', 'es_BO', 'sq_AL', 'sk_SK', 'fr_CH', 'de_DE', 'sr_YU', 'br_FR', 'nl_BE', 'sv_FI', 'pl_PL', 'fr_CA', 'fo_FO', 'bs_BA', 'fr_LU', 'kl_GL', 'fa_IR', 'de_BE', 'sv_SE', 'it_CH', 'uk_UA', - 'eu_ES', 'vi_VN', 'af_ZA', 'nb_NO', 'en_DK', 'tg_TJ', + 'eu_ES', 'vi_VN', 'af_ZA', 'nb_NO', 'en_DK', 'tg_TJ', 'en_US', 'es_ES.ISO8859-1', 'fr_FR.ISO8859-15', 'ru_RU.KOI8-R', 'ko_KR.eucKR'] +# List known locale values to test against when available. +# Dict formatted as `` : (, )``. If a +# value is not known, use '' . +known_numerics = {'fr_FR' : (',', ''), 'en_US':('.', ',')} + class _LocaleTests(unittest.TestCase): def setUp(self): @@ -22,7 +27,50 @@ def tearDown(self): setlocale(LC_NUMERIC, self.oldlocale) - def test_lc_numeric(self): + # Want to know what value was calculated, what it was compared against, + # what function was used for the calculation, what type of data was used, + # the locale that was supposedly set, and the actual locale that is set. + lc_numeric_err_msg = "%s != %s (%s for %s; set to %s, using %s)" + + def numeric_tester(self, calc_type, calc_value, data_type, used_locale): + """Compare calculation against known value, if available""" + try: + set_locale = setlocale(LC_NUMERIC) + except Error: + set_locale = "" + known_value = known_numerics.get(used_locale, + ('', ''))[data_type is 'thousands_sep'] + if known_value and calc_value: + self.assertEquals(calc_value, known_value, + self.lc_numeric_err_msg % ( + calc_value, known_value, + calc_type, data_type, set_locale, + used_locale)) + + def test_lc_numeric_nl_langinfo(self): + # Test nl_langinfo against known values + for loc in candidate_locales: + try: + setlocale(LC_NUMERIC, loc) + except Error: + continue + for li, lc in ((RADIXCHAR, "decimal_point"), + (THOUSEP, "thousands_sep")): + self.numeric_tester('nl_langinfo', nl_langinfo(li), lc, loc) + + def test_lc_numeric_localeconv(self): + # Test localeconv against known values + for loc in candidate_locales: + try: + setlocale(LC_NUMERIC, loc) + except Error: + continue + for li, lc in ((RADIXCHAR, "decimal_point"), + (THOUSEP, "thousands_sep")): + self.numeric_tester('localeconv', localeconv()[lc], lc, loc) + + def test_lc_numeric_basic(self): + # Test nl_langinfo against localeconv for loc in candidate_locales: try: setlocale(LC_NUMERIC, loc) @@ -32,18 +80,17 @@ (THOUSEP, "thousands_sep")): nl_radixchar = nl_langinfo(li) li_radixchar = localeconv()[lc] - # Both with seeing what the locale is set to in order to detect - # when setlocale lies and says it accepted the locale setting - # but in actuality didn't use it (as seen in OS X 10.3) try: set_locale = setlocale(LC_NUMERIC) except Error: set_locale = "" self.assertEquals(nl_radixchar, li_radixchar, - "%s != %s (%s); " - "supposed to be %s, set to %s" % - (nl_radixchar, li_radixchar, lc, - loc, set_locale)) + "%s (nl_langinfo) != %s (localeconv) " + "(set to %s, using %s)" % ( + nl_radixchar, li_radixchar, + loc, set_locale)) + + def test_main(): run_unittest(_LocaleTests) From bcannon at users.sourceforge.net Tue Mar 1 04:16:37 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Tue Mar 1 04:16:40 2005 Subject: [Python-checkins] python/dist/src/Modules _localemodule.c, 2.50, 2.51 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24319/Modules Modified Files: _localemodule.c Log Message: Fix grammatical typo in a comment. Index: _localemodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_localemodule.c,v retrieving revision 2.50 retrieving revision 2.51 diff -u -d -r2.50 -r2.51 --- _localemodule.c 22 Nov 2004 13:02:30 -0000 2.50 +++ _localemodule.c 1 Mar 2005 03:16:34 -0000 2.51 @@ -426,7 +426,7 @@ /* XXX which one is mac-latin2? */ } if (!name) { - /* This leaks a an object. */ + /* This leaks an object. */ name = CFStringConvertEncodingToIANACharSetName(enc); } return (char *)CFStringGetCStringPtr(name, 0); From loewis at users.sourceforge.net Tue Mar 1 09:09:36 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Mar 1 09:09:39 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1247,1.1248 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv496/Misc Modified Files: NEWS Log Message: Patch #1121234: Properly cleanup _exit and tkerror commands. Will backport to 2.4. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1247 retrieving revision 1.1248 diff -u -d -r1.1247 -r1.1248 --- NEWS 28 Feb 2005 19:39:23 -0000 1.1247 +++ NEWS 1 Mar 2005 08:09:28 -0000 1.1248 @@ -59,6 +59,8 @@ Library ------- +- Patch #1121234: Properly cleanup _exit and tkerror commands. + - Patch #1049151: xdrlib now unpacks booleans as True or False. - Fixed bug in a NameError bug in cookielib. Patch #1116583. From loewis at users.sourceforge.net Tue Mar 1 09:10:01 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Mar 1 09:10:07 2005 Subject: [Python-checkins] python/dist/src/Lib/lib-tk Tkinter.py, 1.181, 1.182 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/lib-tk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv496/Lib/lib-tk Modified Files: Tkinter.py Log Message: Patch #1121234: Properly cleanup _exit and tkerror commands. Will backport to 2.4. Index: Tkinter.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/Tkinter.py,v retrieving revision 1.181 retrieving revision 1.182 diff -u -d -r1.181 -r1.182 --- Tkinter.py 3 Aug 2004 18:36:25 -0000 1.181 +++ Tkinter.py 1 Mar 2005 08:09:27 -0000 1.182 @@ -1599,8 +1599,15 @@ raise RuntimeError, \ "Tk 4.0 or higher is required; found Tk %s" \ % str(TkVersion) + # Create and register the tkerror and exit commands + # We need to inline parts of _register here, _ register + # would register differently-named commands. + if self._tclCommands is None: + self._tclCommands = [] self.tk.createcommand('tkerror', _tkerror) self.tk.createcommand('exit', _exit) + self._tclCommands.append('tkerror') + self._tclCommands.append('exit') if _support_default_root and not _default_root: _default_root = self self.protocol("WM_DELETE_WINDOW", self.destroy) From loewis at users.sourceforge.net Tue Mar 1 09:10:08 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Mar 1 09:10:12 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.22, 1.1193.2.23 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv637/Misc Modified Files: Tag: release24-maint NEWS Log Message: Patch #1121234: Properly cleanup _exit and tkerror commands. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.22 retrieving revision 1.1193.2.23 diff -u -d -r1.1193.2.22 -r1.1193.2.23 --- NEWS 27 Feb 2005 20:34:00 -0000 1.1193.2.22 +++ NEWS 1 Mar 2005 08:09:57 -0000 1.1193.2.23 @@ -35,6 +35,8 @@ Library ------- +- Patch #1121234: Properly cleanup _exit and tkerror commands. + - Applied a security fix to SimpleXMLRPCserver (PSF-2005-001). This disables recursive traversal through instance attributes, which can be exploited in various ways. From loewis at users.sourceforge.net Tue Mar 1 09:10:52 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Mar 1 09:10:55 2005 Subject: [Python-checkins] python/dist/src/Lib/lib-tk Tkinter.py, 1.181, 1.181.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/lib-tk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv881/Lib/lib-tk Modified Files: Tag: release24-maint Tkinter.py Log Message: Patch #1121234: Properly cleanup _exit and tkerror commands. Index: Tkinter.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/Tkinter.py,v retrieving revision 1.181 retrieving revision 1.181.2.1 diff -u -d -r1.181 -r1.181.2.1 --- Tkinter.py 3 Aug 2004 18:36:25 -0000 1.181 +++ Tkinter.py 1 Mar 2005 08:10:49 -0000 1.181.2.1 @@ -1599,8 +1599,15 @@ raise RuntimeError, \ "Tk 4.0 or higher is required; found Tk %s" \ % str(TkVersion) + # Create and register the tkerror and exit commands + # We need to inline parts of _register here, _ register + # would register differently-named commands. + if self._tclCommands is None: + self._tclCommands = [] self.tk.createcommand('tkerror', _tkerror) self.tk.createcommand('exit', _exit) + self._tclCommands.append('tkerror') + self._tclCommands.append('exit') if _support_default_root and not _default_root: _default_root = self self.protocol("WM_DELETE_WINDOW", self.destroy) From montanaro at users.sourceforge.net Wed Mar 2 05:29:25 2005 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Wed Mar 2 05:29:28 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libpwd.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-serv4552 Modified Files: libpwd.tex Log Message: Improve (?) description of system dependence of access to the pw_passwd field on systems that support shadow passwords. Index: libpwd.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpwd.tex,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- libpwd.tex 23 Jan 2005 09:27:23 -0000 1.15 +++ libpwd.tex 2 Mar 2005 04:29:23 -0000 1.16 @@ -29,9 +29,12 @@ contains a password encrypted with a DES derived algorithm (see module \refmodule{crypt}\refbimodindex{crypt}). However most modern unices use a so-called \emph{shadow password} system. On those unices the -field \code{pw_passwd} only contains a asterisk (\code{'*'}) or the +\var{pw_passwd} field only contains an asterisk (\code{'*'}) or the letter \character{x} where the encrypted password is stored in a file -\file{/etc/shadow} which is not world readable.} +\file{/etc/shadow} which is not world readable. Whether the \var{pw_passwd} +field contains anything useful is system-dependent. If available, the +\module{spwd} module should be used where access to the encrypted password +is required.} It defines the following items: From montanaro at users.sourceforge.net Wed Mar 2 05:31:40 2005 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Wed Mar 2 05:31:43 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libpwd.tex, 1.14, 1.14.22.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5307 Modified Files: Tag: release24-maint libpwd.tex Log Message: Backport the non-spwd part of the change on head. Index: libpwd.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpwd.tex,v retrieving revision 1.14 retrieving revision 1.14.22.1 diff -u -d -r1.14 -r1.14.22.1 --- libpwd.tex 1 Mar 2002 10:47:36 -0000 1.14 +++ libpwd.tex 2 Mar 2005 04:31:38 -0000 1.14.22.1 @@ -29,9 +29,10 @@ contains a password encrypted with a DES derived algorithm (see module \refmodule{crypt}\refbimodindex{crypt}). However most modern unices use a so-called \emph{shadow password} system. On those unices the -field \code{pw_passwd} only contains a asterisk (\code{'*'}) or the +\var{pw_passwd} field only contains an asterisk (\code{'*'}) or the letter \character{x} where the encrypted password is stored in a file -\file{/etc/shadow} which is not world readable.} +\file{/etc/shadow} which is not world readable. Whether the \var{pw_passwd} +field contains anything useful is system-dependent.} It defines the following items: From pierslauder at users.sourceforge.net Wed Mar 2 10:13:48 2005 From: pierslauder at users.sourceforge.net (pierslauder@users.sourceforge.net) Date: Wed Mar 2 10:13:52 2005 Subject: [Python-checkins] python/dist/src/Lib imaplib.py,1.74,1.75 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24700/dist/src/Lib Modified Files: imaplib.py Log Message: Fix bug in InternalDate regexp that failed to allow leading 0 in day - courtesy of Rimon Barr Index: imaplib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/imaplib.py,v retrieving revision 1.74 retrieving revision 1.75 diff -u -d -r1.74 -r1.75 --- imaplib.py 8 Oct 2004 04:05:39 -0000 1.74 +++ imaplib.py 2 Mar 2005 09:13:45 -0000 1.75 @@ -81,7 +81,7 @@ Continuation = re.compile(r'\+( (?P.*))?') Flags = re.compile(r'.*FLAGS \((?P[^\)]*)\)') InternalDate = re.compile(r'.*INTERNALDATE "' - r'(?P[ 123][0-9])-(?P[A-Z][a-z][a-z])-(?P[0-9][0-9][0-9][0-9])' + r'(?P[ 0123][0-9])-(?P[A-Z][a-z][a-z])-(?P[0-9][0-9][0-9][0-9])' r' (?P[0-9][0-9]):(?P[0-9][0-9]):(?P[0-9][0-9])' r' (?P[-+])(?P[0-9][0-9])(?P[0-9][0-9])' r'"') From rhettinger at users.sourceforge.net Wed Mar 2 16:10:41 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Mar 2 16:10:44 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libfunctional.tex, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17079 Modified Files: libfunctional.tex Log Message: Noted that the module is new in version 2.5. Index: libfunctional.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfunctional.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- libfunctional.tex 28 Feb 2005 19:39:23 -0000 1.1 +++ libfunctional.tex 2 Mar 2005 15:10:38 -0000 1.2 @@ -9,6 +9,7 @@ \modulesynopsis{Higher-order functions and operations on callable objects.} +\versionadded{2.5} The \module{functional} module is for higher-order functions: functions that act on or return other functions. In general, any callable object can From bcannon at users.sourceforge.net Thu Mar 3 08:01:54 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Thu Mar 3 08:01:57 2005 Subject: [Python-checkins] python/dist/src/Python compile.c,2.347,2.348 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14611/Python Modified Files: compile.c Log Message: Silence a gcc warning about putting in parentheses around && expressions mixed with || expressions. Also clarifies intend of 'if' conditional. Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.347 retrieving revision 2.348 diff -u -d -r2.347 -r2.348 --- compile.c 23 Feb 2005 13:37:55 -0000 2.347 +++ compile.c 3 Mar 2005 07:01:48 -0000 2.348 @@ -778,13 +778,14 @@ h = i - 3 * j; if (h >= 0 && j <= lastlc && - (opcode == BUILD_TUPLE && - ISBASICBLOCK(blocks, h, 3*(j+1)) || - opcode == BUILD_LIST && + ((opcode == BUILD_TUPLE && + ISBASICBLOCK(blocks, h, 3*(j+1))) || + (opcode == BUILD_LIST && codestr[i+3]==COMPARE_OP && ISBASICBLOCK(blocks, h, 3*(j+2)) && - (GETARG(codestr,i+3)==6 || GETARG(codestr,i+3)==7)) && - tuple_of_constants(&codestr[h], j, consts)) { + (GETARG(codestr,i+3)==6 || + GETARG(codestr,i+3)==7))) && + tuple_of_constants(&codestr[h], j, consts)) { assert(codestr[i] == LOAD_CONST); cumlc = 1; break; From loewis at users.sourceforge.net Thu Mar 3 09:12:34 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 09:12:37 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1248,1.1249 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29339/Misc Modified Files: NEWS Log Message: Patch #1104111: Alter setup.py --help and --help-commands. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1248 retrieving revision 1.1249 diff -u -d -r1.1248 -r1.1249 --- NEWS 1 Mar 2005 08:09:28 -0000 1.1248 +++ NEWS 3 Mar 2005 08:12:27 -0000 1.1249 @@ -59,6 +59,8 @@ Library ------- +- Patch #1104111: Alter setup.py --help and --help-commands. + - Patch #1121234: Properly cleanup _exit and tkerror commands. - Patch #1049151: xdrlib now unpacks booleans as True or False. From loewis at users.sourceforge.net Thu Mar 3 09:13:01 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 09:13:06 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils/command clean.py, 1.16, 1.17 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29339/Lib/distutils/command Modified Files: clean.py Log Message: Patch #1104111: Alter setup.py --help and --help-commands. Index: clean.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/clean.py,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- clean.py 10 Nov 2004 22:23:15 -0000 1.16 +++ clean.py 3 Mar 2005 08:12:27 -0000 1.17 @@ -15,7 +15,7 @@ class clean (Command): - description = "clean up output of 'build' command" + description = "clean up temporary files from 'build' command" user_options = [ ('build-base=', 'b', "base build directory (default: 'build.build-base')"), From loewis at users.sourceforge.net Thu Mar 3 09:13:01 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 09:13:06 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils dist.py,1.72,1.73 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29339/Lib/distutils Modified Files: dist.py Log Message: Patch #1104111: Alter setup.py --help and --help-commands. Index: dist.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/dist.py,v retrieving revision 1.72 retrieving revision 1.73 diff -u -d -r1.72 -r1.73 --- dist.py 10 Nov 2004 22:23:14 -0000 1.72 +++ dist.py 3 Mar 2005 08:12:26 -0000 1.73 @@ -59,6 +59,15 @@ ('help', 'h', "show detailed help message"), ] + # 'common_usage' is a short (2-3 line) string describing the common + # usage of the setup script. + common_usage = """\ +Common commands: (see '--help-commands' for more) + + setup.py build will build the package underneath 'build/' + setup.py install will install the package +""" + # options that are not propagated to the commands display_options = [ ('help-commands', None, @@ -608,7 +617,7 @@ else: options = self.global_options parser.set_option_table(options) - parser.print_help("Global options:") + parser.print_help(self.common_usage + "\nGlobal options:") print if display_options: From loewis at users.sourceforge.net Thu Mar 3 09:17:45 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 09:17:48 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_tarfile.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-serv30564/Lib/test Modified Files: test_tarfile.py Log Message: Patch #1107973: tarfile.ExFileObject iterators. Index: test_tarfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_tarfile.py,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- test_tarfile.py 25 Oct 2004 03:19:41 -0000 1.16 +++ test_tarfile.py 3 Mar 2005 08:17:33 -0000 1.17 @@ -91,6 +91,16 @@ self.assert_(lines1 == lines2, "_FileObject.readline() does not work correctly") + def test_iter(self): + # Test iteration over ExFileObject. + if self.sep != "|": + filename = "0-REGTYPE-TEXT" + self.tar.extract(filename, dirname()) + lines1 = file(os.path.join(dirname(), filename), "rU").readlines() + lines2 = [line for line in self.tar.extractfile(filename)] + self.assert_(lines1 == lines2, + "ExFileObject iteration does not work correctly") + def test_seek(self): """Test seek() method of _FileObject, incl. random reading. """ From loewis at users.sourceforge.net Thu Mar 3 09:17:45 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 09:17:49 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1249,1.1250 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30564/Misc Modified Files: NEWS Log Message: Patch #1107973: tarfile.ExFileObject iterators. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1249 retrieving revision 1.1250 diff -u -d -r1.1249 -r1.1250 --- NEWS 3 Mar 2005 08:12:27 -0000 1.1249 +++ NEWS 3 Mar 2005 08:17:42 -0000 1.1250 @@ -59,6 +59,8 @@ Library ------- +- Patch #1107973: Allow to iterate over the lines of a tarfile.ExFileObject. + - Patch #1104111: Alter setup.py --help and --help-commands. - Patch #1121234: Properly cleanup _exit and tkerror commands. From loewis at users.sourceforge.net Thu Mar 3 09:18:05 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 09:18:09 2005 Subject: [Python-checkins] python/dist/src/Lib tarfile.py,1.23,1.24 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30564/Lib Modified Files: tarfile.py Log Message: Patch #1107973: tarfile.ExFileObject iterators. Index: tarfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tarfile.py,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- tarfile.py 16 Jan 2005 00:16:11 -0000 1.23 +++ tarfile.py 3 Mar 2005 08:17:32 -0000 1.24 @@ -616,6 +616,22 @@ """Close the file object. """ self.closed = True + + def __iter__(self): + """Get an iterator over the file object. + """ + if self.closed: + raise ValueError("I/O operation on closed file") + return self + + def next(self): + """Get the next item from the file iterator. + """ + result = self.readline() + if not result: + raise StopIteration + return result + #class ExFileObject #------------------ From loewis at users.sourceforge.net Thu Mar 3 09:35:24 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 09:35:28 2005 Subject: [Python-checkins] python/dist/src/Lib gzip.py,1.42,1.43 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3086/Lib Modified Files: gzip.py Log Message: Patch #1110248: SYNC_FLUSH the zlib buffer for GZipFile.flush. Partially fixes #1110242. Index: gzip.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/gzip.py,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- gzip.py 27 Jul 2004 21:05:21 -0000 1.42 +++ gzip.py 3 Mar 2005 08:35:21 -0000 1.43 @@ -331,7 +331,10 @@ return self.close() - def flush(self): + def flush(self,zlib_mode=zlib.Z_SYNC_FLUSH): + if self.mode == WRITE: + # Ensure the compressor's buffer is flushed + self.fileobj.write(self.compress.flush(zlib_mode)) self.fileobj.flush() def fileno(self): From loewis at users.sourceforge.net Thu Mar 3 09:35:26 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 09:35:30 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1250,1.1251 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3086/Misc Modified Files: NEWS Log Message: Patch #1110248: SYNC_FLUSH the zlib buffer for GZipFile.flush. Partially fixes #1110242. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1250 retrieving revision 1.1251 diff -u -d -r1.1250 -r1.1251 --- NEWS 3 Mar 2005 08:17:42 -0000 1.1250 +++ NEWS 3 Mar 2005 08:35:22 -0000 1.1251 @@ -59,6 +59,8 @@ Library ------- +- Patch #1110248: SYNC_FLUSH the zlib buffer for GZipFile.flush. + - Patch #1107973: Allow to iterate over the lines of a tarfile.ExFileObject. - Patch #1104111: Alter setup.py --help and --help-commands. From loewis at users.sourceforge.net Thu Mar 3 10:24:08 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 10:24:11 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.23, 1.1193.2.24 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15407/Misc Modified Files: Tag: release24-maint NEWS Log Message: Clear internal call error in 'L' format. Fixes #723201. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.23 retrieving revision 1.1193.2.24 diff -u -d -r1.1193.2.23 -r1.1193.2.24 --- NEWS 1 Mar 2005 08:09:57 -0000 1.1193.2.23 +++ NEWS 3 Mar 2005 09:24:04 -0000 1.1193.2.24 @@ -12,6 +12,8 @@ Core and builtins ----------------- +- Bug #723201: Raise a TypeError for passing bad objects to 'L' format. + - Bug #1124295: the __name__ attribute of file objects was inadvertently made inaccessible in restricted mode. From loewis at users.sourceforge.net Thu Mar 3 10:24:09 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 10:24:13 2005 Subject: [Python-checkins] python/dist/src/Python getargs.c,2.102,2.102.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15407/Python Modified Files: Tag: release24-maint getargs.c Log Message: Clear internal call error in 'L' format. Fixes #723201. Index: getargs.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/getargs.c,v retrieving revision 2.102 retrieving revision 2.102.2.1 diff -u -d -r2.102 -r2.102.2.1 --- getargs.c 7 Aug 2004 17:57:16 -0000 2.102 +++ getargs.c 3 Mar 2005 09:24:05 -0000 2.102.2.1 @@ -610,6 +610,7 @@ PY_LONG_LONG *p = va_arg( *p_va, PY_LONG_LONG * ); PY_LONG_LONG ival = PyLong_AsLongLong( arg ); if( ival == (PY_LONG_LONG)-1 && PyErr_Occurred() ) { + PyErr_Clear(); return converterr("long", arg, msgbuf, bufsize); } else { *p = ival; From loewis at users.sourceforge.net Thu Mar 3 10:24:36 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 10:24:40 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_capi.py, 1.8, 1.8.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15407/Lib/test Modified Files: Tag: release24-maint test_capi.py Log Message: Clear internal call error in 'L' format. Fixes #723201. Index: test_capi.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_capi.py,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -u -d -r1.8 -r1.8.2.1 --- test_capi.py 26 Aug 2004 05:23:19 -0000 1.8 +++ test_capi.py 3 Mar 2005 09:24:03 -0000 1.8.2.1 @@ -1,7 +1,7 @@ # Run the _testcapi module tests (tests for the Python/C API): by defn, # these are all functions _testcapi exports whose name begins with 'test_'. -import sys +import sys, unittest from test import test_support import _testcapi @@ -35,6 +35,12 @@ raise test_support.TestFailed, \ "Couldn't find main thread correctly in the list" +# Tests which use _testcapi helpers +class OtherTests(unittest.TestCase): + def test_exc_L(self): + # This used to raise a SystemError(bad internal call) + self.assertRaises(TypeError, _testcapi.getargs_L, "String") + try: _testcapi._test_thread_state have_thread_state = True @@ -46,3 +52,9 @@ import threading t=threading.Thread(target=TestThreadState) t.start() + +def test_main(): + test_support.run_unittest(OtherTests) + +if __name__=='__main__': + test_main() From loewis at users.sourceforge.net Thu Mar 3 10:24:45 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 10:24:49 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_capi.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-serv15710/Lib/test Modified Files: test_capi.py Log Message: Clear internal call error in 'L' format. Fixes #723201. Backported to 2.4. Index: test_capi.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_capi.py,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- test_capi.py 26 Aug 2004 05:23:19 -0000 1.8 +++ test_capi.py 3 Mar 2005 09:24:38 -0000 1.9 @@ -1,7 +1,7 @@ # Run the _testcapi module tests (tests for the Python/C API): by defn, # these are all functions _testcapi exports whose name begins with 'test_'. -import sys +import sys, unittest from test import test_support import _testcapi @@ -35,6 +35,12 @@ raise test_support.TestFailed, \ "Couldn't find main thread correctly in the list" +# Tests which use _testcapi helpers +class OtherTests(unittest.TestCase): + def test_exc_L(self): + # This used to raise a SystemError(bad internal call) + self.assertRaises(TypeError, _testcapi.getargs_L, "String") + try: _testcapi._test_thread_state have_thread_state = True @@ -46,3 +52,9 @@ import threading t=threading.Thread(target=TestThreadState) t.start() + +def test_main(): + test_support.run_unittest(OtherTests) + +if __name__=='__main__': + test_main() From loewis at users.sourceforge.net Thu Mar 3 10:24:46 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 10:24:50 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1251,1.1252 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15710/Misc Modified Files: NEWS Log Message: Clear internal call error in 'L' format. Fixes #723201. Backported to 2.4. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1251 retrieving revision 1.1252 diff -u -d -r1.1251 -r1.1252 --- NEWS 3 Mar 2005 08:35:22 -0000 1.1251 +++ NEWS 3 Mar 2005 09:24:38 -0000 1.1252 @@ -10,6 +10,8 @@ Core and builtins ----------------- +- Bug #723201: Raise a TypeError for passing bad objects to 'L' format. + - Bug #1124295: the __name__ attribute of file objects was inadvertently made inaccessible in restricted mode. From loewis at users.sourceforge.net Thu Mar 3 10:24:46 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 10:24:50 2005 Subject: [Python-checkins] python/dist/src/Python getargs.c,2.102,2.103 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15710/Python Modified Files: getargs.c Log Message: Clear internal call error in 'L' format. Fixes #723201. Backported to 2.4. Index: getargs.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/getargs.c,v retrieving revision 2.102 retrieving revision 2.103 diff -u -d -r2.102 -r2.103 --- getargs.c 7 Aug 2004 17:57:16 -0000 2.102 +++ getargs.c 3 Mar 2005 09:24:38 -0000 2.103 @@ -610,6 +610,7 @@ PY_LONG_LONG *p = va_arg( *p_va, PY_LONG_LONG * ); PY_LONG_LONG ival = PyLong_AsLongLong( arg ); if( ival == (PY_LONG_LONG)-1 && PyErr_Occurred() ) { + PyErr_Clear(); return converterr("long", arg, msgbuf, bufsize); } else { *p = ival; From loewis at users.sourceforge.net Thu Mar 3 10:45:35 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 10:45:38 2005 Subject: [Python-checkins] python/dist/src/Lib/bsddb __init__.py, 1.15, 1.15.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/bsddb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20945/Lib/bsddb Modified Files: Tag: release24-maint __init__.py Log Message: Patch #1112812: Make bsddb/__init__.py more friendly for modulefinder. Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/bsddb/__init__.py,v retrieving revision 1.15 retrieving revision 1.15.4.1 diff -u -d -r1.15 -r1.15.4.1 --- __init__.py 27 Jun 2004 22:56:42 -0000 1.15 +++ __init__.py 3 Mar 2005 09:45:32 -0000 1.15.4.1 @@ -65,9 +65,9 @@ # iterator interface is dynamically defined and added using a mixin # class. old python can't tokenize it due to the yield keyword. if sys.version >= '2.3': + import UserDict + from weakref import ref exec """ -import UserDict -from weakref import ref class _iter_mixin(UserDict.DictMixin): def _make_iter_cursor(self): cur = self.db.cursor() From loewis at users.sourceforge.net Thu Mar 3 10:45:36 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 10:45:39 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.24, 1.1193.2.25 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20945/Misc Modified Files: Tag: release24-maint NEWS Log Message: Patch #1112812: Make bsddb/__init__.py more friendly for modulefinder. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.24 retrieving revision 1.1193.2.25 diff -u -d -r1.1193.2.24 -r1.1193.2.25 --- NEWS 3 Mar 2005 09:24:04 -0000 1.1193.2.24 +++ NEWS 3 Mar 2005 09:45:32 -0000 1.1193.2.25 @@ -37,6 +37,8 @@ Library ------- +- Patch #1112812: Make bsddb/__init__.py more friendly for modulefinder. + - Patch #1121234: Properly cleanup _exit and tkerror commands. - Applied a security fix to SimpleXMLRPCserver (PSF-2005-001). This From loewis at users.sourceforge.net Thu Mar 3 10:46:11 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 10:46:13 2005 Subject: [Python-checkins] python/dist/src/Lib/bsddb __init__.py,1.15,1.16 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/bsddb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21064/Lib/bsddb Modified Files: __init__.py Log Message: Patch #1112812: Make bsddb/__init__.py more friendly for modulefinder. Backported to 2.4. Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/bsddb/__init__.py,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- __init__.py 27 Jun 2004 22:56:42 -0000 1.15 +++ __init__.py 3 Mar 2005 09:46:06 -0000 1.16 @@ -65,9 +65,9 @@ # iterator interface is dynamically defined and added using a mixin # class. old python can't tokenize it due to the yield keyword. if sys.version >= '2.3': + import UserDict + from weakref import ref exec """ -import UserDict -from weakref import ref class _iter_mixin(UserDict.DictMixin): def _make_iter_cursor(self): cur = self.db.cursor() From loewis at users.sourceforge.net Thu Mar 3 10:46:14 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 10:46:17 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1252,1.1253 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21064/Misc Modified Files: NEWS Log Message: Patch #1112812: Make bsddb/__init__.py more friendly for modulefinder. Backported to 2.4. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1252 retrieving revision 1.1253 diff -u -d -r1.1252 -r1.1253 --- NEWS 3 Mar 2005 09:24:38 -0000 1.1252 +++ NEWS 3 Mar 2005 09:46:07 -0000 1.1253 @@ -61,6 +61,8 @@ Library ------- +- Patch #1112812: Make bsddb/__init__.py more friendly for modulefinder. + - Patch #1110248: SYNC_FLUSH the zlib buffer for GZipFile.flush. - Patch #1107973: Allow to iterate over the lines of a tarfile.ExFileObject. From loewis at users.sourceforge.net Thu Mar 3 11:05:40 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 11:05:43 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libuu.tex, 1.12.20.1, 1.12.20.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26580 Modified Files: Tag: release24-maint libuu.tex Log Message: Document quiet parameter to decode. Fixes #803413. Index: libuu.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libuu.tex,v retrieving revision 1.12.20.1 retrieving revision 1.12.20.2 diff -u -d -r1.12.20.1 -r1.12.20.2 --- libuu.tex 1 Jan 2005 00:34:53 -0000 1.12.20.1 +++ libuu.tex 3 Mar 2005 10:05:37 -0000 1.12.20.2 @@ -31,13 +31,17 @@ respectively. \end{funcdesc} -\begin{funcdesc}{decode}{in_file\optional{, out_file\optional{, mode}}} +\begin{funcdesc}{decode}{in_file\optional{, out_file\optional{, mode\optional{, quiet}}}} This call decodes uuencoded file \var{in_file} placing the result on file \var{out_file}. If \var{out_file} is a pathname, \var{mode} is used to set the permission bits if the file must be created. Defaults for \var{out_file} and \var{mode} are taken from the uuencode header. However, if the file specified in the header already exists, a \exception{uu.Error} is raised. + + \function{decode} may print a warning to stderr if the input was produced + by an incorrect uuencoder and Python could recover from that error. + Setting \var{quiet} to True silences this warning. \end{funcdesc} \begin{excclassdesc}{Error}{} From loewis at users.sourceforge.net Thu Mar 3 11:06:08 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 11:06:09 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libuu.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-serv26755 Modified Files: libuu.tex Log Message: Document quiet parameter to decode. Fixes #803413. Index: libuu.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libuu.tex,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- libuu.tex 1 Jan 2005 00:28:43 -0000 1.13 +++ libuu.tex 3 Mar 2005 10:06:05 -0000 1.14 @@ -31,13 +31,17 @@ respectively. \end{funcdesc} -\begin{funcdesc}{decode}{in_file\optional{, out_file\optional{, mode}}} +\begin{funcdesc}{decode}{in_file\optional{, out_file\optional{, mode\optional{, quiet}}}} This call decodes uuencoded file \var{in_file} placing the result on file \var{out_file}. If \var{out_file} is a pathname, \var{mode} is used to set the permission bits if the file must be created. Defaults for \var{out_file} and \var{mode} are taken from the uuencode header. However, if the file specified in the header already exists, a \exception{uu.Error} is raised. + + \function{decode} may print a warning to stderr if the input was produced + by an incorrect uuencoder and Python could recover from that error. + Setting \var{quiet} to True silences this warning. \end{funcdesc} \begin{excclassdesc}{Error}{} From loewis at users.sourceforge.net Thu Mar 3 11:47:40 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 11:47:44 2005 Subject: [Python-checkins] python/dist/src/Lib cookielib.py,1.4.2.1,1.4.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4377/Lib Modified Files: Tag: release24-maint cookielib.py Log Message: Patch #1117339: Add cookielib special name tests. Index: cookielib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cookielib.py,v retrieving revision 1.4.2.1 retrieving revision 1.4.2.2 diff -u -d -r1.4.2.1 -r1.4.2.2 --- cookielib.py 5 Feb 2005 01:33:16 -0000 1.4.2.1 +++ cookielib.py 3 Mar 2005 10:47:38 -0000 1.4.2.2 @@ -448,7 +448,7 @@ for ns_header in ns_headers: pairs = [] version_set = False - for param in re.split(r";\s*", ns_header): + for ii, param in enumerate(re.split(r";\s*", ns_header)): param = param.rstrip() if param == "": continue if "=" not in param: @@ -460,7 +460,7 @@ else: k, v = re.split(r"\s*=\s*", param, 1) k = k.lstrip() - if k is not None: + if ii != 0: lc = k.lower() if lc in known_attrs: k = lc From loewis at users.sourceforge.net Thu Mar 3 11:47:40 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 11:47:44 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_cookielib.py, 1.1, 1.1.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4377/Lib/test Modified Files: Tag: release24-maint test_cookielib.py Log Message: Patch #1117339: Add cookielib special name tests. Index: test_cookielib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_cookielib.py,v retrieving revision 1.1 retrieving revision 1.1.4.1 diff -u -d -r1.1 -r1.1.4.1 --- test_cookielib.py 31 May 2004 18:22:40 -0000 1.1 +++ test_cookielib.py 3 Mar 2005 10:47:38 -0000 1.1.4.1 @@ -103,13 +103,23 @@ from cookielib import parse_ns_headers # quotes should be stripped - expected = [[('expires', 2209069412L), ('version', '0')]] + expected = [[('foo', 'bar'), ('expires', 2209069412L), ('version', '0')]] for hdr in [ - 'expires=01 Jan 2040 22:23:32 GMT', - 'expires="01 Jan 2040 22:23:32 GMT"', + 'foo=bar; expires=01 Jan 2040 22:23:32 GMT', + 'foo=bar; expires="01 Jan 2040 22:23:32 GMT"', ]: self.assertEquals(parse_ns_headers([hdr]), expected) + def test_parse_ns_headers_special_names(self): + # names such as 'expires' are not special in first name=value pair + # of Set-Cookie: header + from cookielib import parse_ns_headers + + # Cookie with name 'expires' + hdr = 'expires=01 Jan 2040 22:23:32 GMT' + expected = [[("expires", "01 Jan 2040 22:23:32 GMT"), ("version", "0")]] + self.assertEquals(parse_ns_headers([hdr]), expected) + def test_join_header_words(self): from cookielib import join_header_words @@ -370,6 +380,19 @@ self.assert_(foo.expires is None) self.assert_(spam.expires is None) + def test_ns_parser_special_names(self): + # names such as 'expires' are not special in first name=value pair + # of Set-Cookie: header + from cookielib import CookieJar + + c = CookieJar() + interact_netscape(c, "http://www.acme.com/", 'expires=eggs') + interact_netscape(c, "http://www.acme.com/", 'version=eggs; spam=eggs') + + cookies = c._cookies["www.acme.com"]["/"] + self.assert_('expires' in cookies) + self.assert_('version' in cookies) + def test_expires(self): from cookielib import time2netscape, CookieJar From loewis at users.sourceforge.net Thu Mar 3 11:47:41 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 11:47:46 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.25, 1.1193.2.26 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4377/Misc Modified Files: Tag: release24-maint NEWS Log Message: Patch #1117339: Add cookielib special name tests. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.25 retrieving revision 1.1193.2.26 diff -u -d -r1.1193.2.25 -r1.1193.2.26 --- NEWS 3 Mar 2005 09:45:32 -0000 1.1193.2.25 +++ NEWS 3 Mar 2005 10:47:38 -0000 1.1193.2.26 @@ -37,6 +37,8 @@ Library ------- +- Patch #1117339: Add cookielib special name tests. + - Patch #1112812: Make bsddb/__init__.py more friendly for modulefinder. - Patch #1121234: Properly cleanup _exit and tkerror commands. From loewis at users.sourceforge.net Thu Mar 3 11:48:14 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 11:48:18 2005 Subject: [Python-checkins] python/dist/src/Lib cookielib.py,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4491/Lib Modified Files: cookielib.py Log Message: Patch #1117339: Add cookielib special name tests. Backported to 2.4. Index: cookielib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cookielib.py,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- cookielib.py 7 Feb 2005 14:16:09 -0000 1.7 +++ cookielib.py 3 Mar 2005 10:48:12 -0000 1.8 @@ -447,7 +447,7 @@ for ns_header in ns_headers: pairs = [] version_set = False - for param in re.split(r";\s*", ns_header): + for ii, param in enumerate(re.split(r";\s*", ns_header)): param = param.rstrip() if param == "": continue if "=" not in param: @@ -459,7 +459,7 @@ else: k, v = re.split(r"\s*=\s*", param, 1) k = k.lstrip() - if k is not None: + if ii != 0: lc = k.lower() if lc in known_attrs: k = lc From loewis at users.sourceforge.net Thu Mar 3 11:48:15 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 11:48:18 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_cookielib.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4491/Lib/test Modified Files: test_cookielib.py Log Message: Patch #1117339: Add cookielib special name tests. Backported to 2.4. Index: test_cookielib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_cookielib.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- test_cookielib.py 31 May 2004 18:22:40 -0000 1.1 +++ test_cookielib.py 3 Mar 2005 10:48:12 -0000 1.2 @@ -103,13 +103,23 @@ from cookielib import parse_ns_headers # quotes should be stripped - expected = [[('expires', 2209069412L), ('version', '0')]] + expected = [[('foo', 'bar'), ('expires', 2209069412L), ('version', '0')]] for hdr in [ - 'expires=01 Jan 2040 22:23:32 GMT', - 'expires="01 Jan 2040 22:23:32 GMT"', + 'foo=bar; expires=01 Jan 2040 22:23:32 GMT', + 'foo=bar; expires="01 Jan 2040 22:23:32 GMT"', ]: self.assertEquals(parse_ns_headers([hdr]), expected) + def test_parse_ns_headers_special_names(self): + # names such as 'expires' are not special in first name=value pair + # of Set-Cookie: header + from cookielib import parse_ns_headers + + # Cookie with name 'expires' + hdr = 'expires=01 Jan 2040 22:23:32 GMT' + expected = [[("expires", "01 Jan 2040 22:23:32 GMT"), ("version", "0")]] + self.assertEquals(parse_ns_headers([hdr]), expected) + def test_join_header_words(self): from cookielib import join_header_words @@ -370,6 +380,19 @@ self.assert_(foo.expires is None) self.assert_(spam.expires is None) + def test_ns_parser_special_names(self): + # names such as 'expires' are not special in first name=value pair + # of Set-Cookie: header + from cookielib import CookieJar + + c = CookieJar() + interact_netscape(c, "http://www.acme.com/", 'expires=eggs') + interact_netscape(c, "http://www.acme.com/", 'version=eggs; spam=eggs') + + cookies = c._cookies["www.acme.com"]["/"] + self.assert_('expires' in cookies) + self.assert_('version' in cookies) + def test_expires(self): from cookielib import time2netscape, CookieJar From loewis at users.sourceforge.net Thu Mar 3 11:48:16 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 11:48:20 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1253,1.1254 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4491/Misc Modified Files: NEWS Log Message: Patch #1117339: Add cookielib special name tests. Backported to 2.4. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1253 retrieving revision 1.1254 diff -u -d -r1.1253 -r1.1254 --- NEWS 3 Mar 2005 09:46:07 -0000 1.1253 +++ NEWS 3 Mar 2005 10:48:12 -0000 1.1254 @@ -61,6 +61,8 @@ Library ------- +- Patch #1117339: Add cookielib special name tests. + - Patch #1112812: Make bsddb/__init__.py more friendly for modulefinder. - Patch #1110248: SYNC_FLUSH the zlib buffer for GZipFile.flush. From loewis at users.sourceforge.net Thu Mar 3 11:55:59 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 11:56:02 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_cookielib.py, 1.1.4.1, 1.1.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5901/Lib/test Modified Files: Tag: release24-maint test_cookielib.py Log Message: Patch #1117454: Remove code to special-case cookies without values in LWPCookieJar. Index: test_cookielib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_cookielib.py,v retrieving revision 1.1.4.1 retrieving revision 1.1.4.2 diff -u -d -r1.1.4.1 -r1.1.4.2 --- test_cookielib.py 3 Mar 2005 10:47:38 -0000 1.1.4.1 +++ test_cookielib.py 3 Mar 2005 10:55:52 -0000 1.1.4.2 @@ -231,6 +231,24 @@ return cookie_hdr +class FileCookieJarTests(TestCase): + def test_lwp_valueless_cookie(self): + # cookies with no value should be saved and loaded consistently + from cookielib import LWPCookieJar + filename = test_support.TESTFN + c = LWPCookieJar() + interact_netscape(c, "http://www.acme.com/", 'boo') + self.assertEqual(c._cookies["www.acme.com"]["/"]["boo"].value, None) + try: + c.save(filename, ignore_discard=True) + c = LWPCookieJar() + c.load(filename, ignore_discard=True) + finally: + try: os.unlink(filename) + except OSError: pass + self.assertEqual(c._cookies["www.acme.com"]["/"]["boo"].value, None) + + class CookieTests(TestCase): # XXX # Get rid of string comparisons where not actually testing str / repr. @@ -1636,6 +1654,7 @@ DateTimeTests, HeaderTests, CookieTests, + FileCookieJarTests, LWPCookieTests, ) From loewis at users.sourceforge.net Thu Mar 3 11:56:01 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 11:56:03 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.26, 1.1193.2.27 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5901/Misc Modified Files: Tag: release24-maint NEWS Log Message: Patch #1117454: Remove code to special-case cookies without values in LWPCookieJar. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.26 retrieving revision 1.1193.2.27 diff -u -d -r1.1193.2.26 -r1.1193.2.27 --- NEWS 3 Mar 2005 10:47:38 -0000 1.1193.2.26 +++ NEWS 3 Mar 2005 10:55:57 -0000 1.1193.2.27 @@ -37,6 +37,9 @@ Library ------- +- Patch #1117454: Remove code to special-case cookies without values + in LWPCookieJar. + - Patch #1117339: Add cookielib special name tests. - Patch #1112812: Make bsddb/__init__.py more friendly for modulefinder. From loewis at users.sourceforge.net Thu Mar 3 11:56:22 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 11:56:25 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1254,1.1255 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6051/Misc Modified Files: NEWS Log Message: Patch #1117454: Remove code to special-case cookies without values in LWPCookieJar. Backported to 2.4. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1254 retrieving revision 1.1255 diff -u -d -r1.1254 -r1.1255 --- NEWS 3 Mar 2005 10:48:12 -0000 1.1254 +++ NEWS 3 Mar 2005 10:56:19 -0000 1.1255 @@ -61,6 +61,9 @@ Library ------- +- Patch #1117454: Remove code to special-case cookies without values + in LWPCookieJar. + - Patch #1117339: Add cookielib special name tests. - Patch #1112812: Make bsddb/__init__.py more friendly for modulefinder. From loewis at users.sourceforge.net Thu Mar 3 11:56:24 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 11:56:27 2005 Subject: [Python-checkins] python/dist/src/Lib _LWPCookieJar.py, 1.2, 1.2.2.1 _MozillaCookieJar.py, 1.3, 1.3.2.1 cookielib.py, 1.4.2.2, 1.4.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5901/Lib Modified Files: Tag: release24-maint _LWPCookieJar.py _MozillaCookieJar.py cookielib.py Log Message: Patch #1117454: Remove code to special-case cookies without values in LWPCookieJar. Index: _LWPCookieJar.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/_LWPCookieJar.py,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -d -r1.2 -r1.2.2.1 --- _LWPCookieJar.py 31 Aug 2004 11:38:12 -0000 1.2 +++ _LWPCookieJar.py 3 Mar 2005 10:55:51 -0000 1.2.2.1 @@ -115,13 +115,6 @@ for data in split_header_words([line]): name, value = data[0] - # name and value are an exception here, since a plain "foo" - # (with no "=", unlike "bar=foo") means a cookie with no - # name and value "foo". With all other cookie-attributes, - # the situation is reversed: "foo" means an attribute named - # "foo" with no value! - if value is None: - name, value = value, name standard = {} rest = {} for k in boolean_attrs: Index: _MozillaCookieJar.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/_MozillaCookieJar.py,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -d -r1.3 -r1.3.2.1 --- _MozillaCookieJar.py 1 Sep 2004 13:10:31 -0000 1.3 +++ _MozillaCookieJar.py 3 Mar 2005 10:55:52 -0000 1.3.2.1 @@ -73,6 +73,9 @@ secure = (secure == "TRUE") domain_specified = (domain_specified == "TRUE") if name == "": + # cookies.txt regards 'Set-Cookie: foo' as a cookie + # with no name, whereas cookielib regards it as a + # cookie with no value. name = value value = None Index: cookielib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cookielib.py,v retrieving revision 1.4.2.2 retrieving revision 1.4.2.3 diff -u -d -r1.4.2.2 -r1.4.2.3 --- cookielib.py 3 Mar 2005 10:47:38 -0000 1.4.2.2 +++ cookielib.py 3 Mar 2005 10:55:52 -0000 1.4.2.3 @@ -452,11 +452,7 @@ param = param.rstrip() if param == "": continue if "=" not in param: - if param.lower() in known_attrs: - k, v = param, None - else: - # cookie with missing value - k, v = param, None + k, v = param, None else: k, v = re.split(r"\s*=\s*", param, 1) k = k.lstrip() From loewis at users.sourceforge.net Thu Mar 3 11:57:39 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 11:57:42 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_cookielib.py, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6257/Lib/test Modified Files: test_cookielib.py Log Message: Patch #1117454: Remove code to special-case cookies without values in LWPCookieJar. Backported to 2.4. Index: test_cookielib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_cookielib.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- test_cookielib.py 3 Mar 2005 10:48:12 -0000 1.2 +++ test_cookielib.py 3 Mar 2005 10:57:37 -0000 1.3 @@ -231,6 +231,24 @@ return cookie_hdr +class FileCookieJarTests(TestCase): + def test_lwp_valueless_cookie(self): + # cookies with no value should be saved and loaded consistently + from cookielib import LWPCookieJar + filename = test_support.TESTFN + c = LWPCookieJar() + interact_netscape(c, "http://www.acme.com/", 'boo') + self.assertEqual(c._cookies["www.acme.com"]["/"]["boo"].value, None) + try: + c.save(filename, ignore_discard=True) + c = LWPCookieJar() + c.load(filename, ignore_discard=True) + finally: + try: os.unlink(filename) + except OSError: pass + self.assertEqual(c._cookies["www.acme.com"]["/"]["boo"].value, None) + + class CookieTests(TestCase): # XXX # Get rid of string comparisons where not actually testing str / repr. @@ -1636,6 +1654,7 @@ DateTimeTests, HeaderTests, CookieTests, + FileCookieJarTests, LWPCookieTests, ) From loewis at users.sourceforge.net Thu Mar 3 11:57:39 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 11:57:42 2005 Subject: [Python-checkins] python/dist/src/Lib _LWPCookieJar.py, 1.2, 1.3 _MozillaCookieJar.py, 1.3, 1.4 cookielib.py, 1.8, 1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6257/Lib Modified Files: _LWPCookieJar.py _MozillaCookieJar.py cookielib.py Log Message: Patch #1117454: Remove code to special-case cookies without values in LWPCookieJar. Backported to 2.4. Index: _LWPCookieJar.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/_LWPCookieJar.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- _LWPCookieJar.py 31 Aug 2004 11:38:12 -0000 1.2 +++ _LWPCookieJar.py 3 Mar 2005 10:57:36 -0000 1.3 @@ -115,13 +115,6 @@ for data in split_header_words([line]): name, value = data[0] - # name and value are an exception here, since a plain "foo" - # (with no "=", unlike "bar=foo") means a cookie with no - # name and value "foo". With all other cookie-attributes, - # the situation is reversed: "foo" means an attribute named - # "foo" with no value! - if value is None: - name, value = value, name standard = {} rest = {} for k in boolean_attrs: Index: _MozillaCookieJar.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/_MozillaCookieJar.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- _MozillaCookieJar.py 1 Sep 2004 13:10:31 -0000 1.3 +++ _MozillaCookieJar.py 3 Mar 2005 10:57:36 -0000 1.4 @@ -73,6 +73,9 @@ secure = (secure == "TRUE") domain_specified = (domain_specified == "TRUE") if name == "": + # cookies.txt regards 'Set-Cookie: foo' as a cookie + # with no name, whereas cookielib regards it as a + # cookie with no value. name = value value = None Index: cookielib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/cookielib.py,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- cookielib.py 3 Mar 2005 10:48:12 -0000 1.8 +++ cookielib.py 3 Mar 2005 10:57:36 -0000 1.9 @@ -451,11 +451,7 @@ param = param.rstrip() if param == "": continue if "=" not in param: - if param.lower() in known_attrs: - k, v = param, None - else: - # cookie with missing value - k, v = param, None + k, v = param, None else: k, v = re.split(r"\s*=\s*", param, 1) k = k.lstrip() From loewis at users.sourceforge.net Thu Mar 3 12:08:05 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 12:08:07 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils sysconfig.py, 1.62, 1.63 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8831/Lib/distutils Modified Files: sysconfig.py Log Message: Patch #1046831: Use get_python_version where appropriate in sysconfig.py. Index: sysconfig.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/sysconfig.py,v retrieving revision 1.62 retrieving revision 1.63 diff -u -d -r1.62 -r1.63 --- sysconfig.py 26 Dec 2004 23:07:48 -0000 1.62 +++ sysconfig.py 3 Mar 2005 11:08:02 -0000 1.63 @@ -34,7 +34,7 @@ del argv0_path, landmark -def get_python_version (): +def get_python_version(): """Return a string containing the major and minor Python version, leaving off the patchlevel. Sample return values could be '1.5' or '2.2'. @@ -65,7 +65,7 @@ if not os.path.exists(inc_dir): inc_dir = os.path.join(os.path.dirname(base), "Include") return inc_dir - return os.path.join(prefix, "include", "python" + sys.version[:3]) + return os.path.join(prefix, "include", "python" + get_python_version()) elif os.name == "nt": return os.path.join(prefix, "include") elif os.name == "mac": @@ -110,7 +110,7 @@ if standard_lib: return os.path.join(prefix, "Lib") else: - if sys.version < "2.2": + if get_python_version() < "2.2": return prefix else: return os.path.join(PREFIX, "Lib", "site-packages") @@ -189,7 +189,7 @@ inc_dir = os.curdir else: inc_dir = get_python_inc(plat_specific=1) - if sys.version < '2.2': + if get_python_version() < '2.2': config_h = 'config.h' else: # The name of the config.h file changed in 2.2 @@ -378,7 +378,7 @@ if python_build: g['LDSHARED'] = g['BLDSHARED'] - elif sys.version < '2.1': + elif get_python_version() < '2.1': # The following two branches are for 1.5.2 compatibility. if sys.platform == 'aix4': # what about AIX 3.x ? # Linker script is in the config directory, not in Modules as the @@ -405,7 +405,7 @@ # it's taken care of for them by the 'build_ext.get_libraries()' # method.) g['LDSHARED'] = ("%s -L%s/lib -lpython%s" % - (linkerscript, PREFIX, sys.version[0:3])) + (linkerscript, PREFIX, get_python_version())) global _config_vars _config_vars = g From loewis at users.sourceforge.net Thu Mar 3 12:08:07 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 12:08:10 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1255,1.1256 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8831/Misc Modified Files: NEWS Log Message: Patch #1046831: Use get_python_version where appropriate in sysconfig.py. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1255 retrieving revision 1.1256 diff -u -d -r1.1255 -r1.1256 --- NEWS 3 Mar 2005 10:56:19 -0000 1.1255 +++ NEWS 3 Mar 2005 11:08:03 -0000 1.1256 @@ -61,6 +61,8 @@ Library ------- +- Patch #1046831: Use get_python_version where appropriate in sysconfig.py. + - Patch #1117454: Remove code to special-case cookies without values in LWPCookieJar. From loewis at users.sourceforge.net Thu Mar 3 12:22:47 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 12:22:50 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1256,1.1257 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12697/Misc Modified Files: NEWS Log Message: Patches #749830, #1144555: allow UNIX mmap size to default to current file size. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1256 retrieving revision 1.1257 diff -u -d -r1.1256 -r1.1257 --- NEWS 3 Mar 2005 11:08:03 -0000 1.1256 +++ NEWS 3 Mar 2005 11:22:41 -0000 1.1257 @@ -36,6 +36,9 @@ Extension Modules ----------------- +- Patches #749830, #1144555: allow UNIX mmap size to default to current + file size. + - Added functional.partial(). See PEP309. - Patch #1093585: raise a ValueError for negative history items in readline. From loewis at users.sourceforge.net Thu Mar 3 12:22:48 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 12:22:51 2005 Subject: [Python-checkins] python/dist/src/Modules mmapmodule.c,2.48,2.49 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12697/Modules Modified Files: mmapmodule.c Log Message: Patches #749830, #1144555: allow UNIX mmap size to default to current file size. Index: mmapmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/mmapmodule.c,v retrieving revision 2.48 retrieving revision 2.49 diff -u -d -r2.48 -r2.49 --- mmapmodule.c 19 May 2004 14:39:08 -0000 2.48 +++ mmapmodule.c 3 Mar 2005 11:22:44 -0000 2.49 @@ -896,11 +896,14 @@ /* on OpenVMS we must ensure that all bytes are written to the file */ fsync(fd); # endif - if (fstat(fd, &st) == 0 && S_ISREG(st.st_mode) && - (size_t)map_size > st.st_size) { - PyErr_SetString(PyExc_ValueError, - "mmap length is greater than file size"); - return NULL; + if (fstat(fd, &st) == 0 && S_ISREG(st.st_mode)) { + if (map_size == 0) { + map_size = (int)st.st_size; + } else if ((size_t)map_size > st.st_size) { + PyErr_SetString(PyExc_ValueError, + "mmap length is greater than file size"); + return NULL; + } } #endif m_obj = PyObject_New (mmap_object, &mmap_object_type); From loewis at users.sourceforge.net Thu Mar 3 12:23:13 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 12:23:15 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libmmap.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-serv12697/Doc/lib Modified Files: libmmap.tex Log Message: Patches #749830, #1144555: allow UNIX mmap size to default to current file size. Index: libmmap.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libmmap.tex,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- libmmap.tex 19 Jan 2005 03:39:16 -0000 1.10 +++ libmmap.tex 3 Mar 2005 11:22:41 -0000 1.11 @@ -62,8 +62,10 @@ prot\optional{, access}}}} \strong{(\UNIX{} version)} Maps \var{length} bytes from the file specified by the file descriptor \var{fileno}, and returns a mmap - object. - + object. If \var{length} is \code{0}, the maximum length of the map + will be the current size of the file when \function{mmap(} is + called. + \var{flags} specifies the nature of the mapping. \constant{MAP_PRIVATE} creates a private copy-on-write mapping, so changes to the contents of the mmap object will be private to this From loewis at users.sourceforge.net Thu Mar 3 12:23:13 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 12:23:18 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_mmap.py,1.30,1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12697/Lib/test Modified Files: test_mmap.py Log Message: Patches #749830, #1144555: allow UNIX mmap size to default to current file size. Index: test_mmap.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_mmap.py,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- test_mmap.py 13 Jan 2003 21:38:45 -0000 1.30 +++ test_mmap.py 3 Mar 2005 11:22:41 -0000 1.31 @@ -311,7 +311,43 @@ finally: os.unlink(TESTFN) + # test mapping of entire file by passing 0 for map length + if hasattr(os, "stat"): + print " Ensuring that passing 0 as map length sets map size to current file size." + f = open(TESTFN, "w+") + + try: + f.write(2**16 * 'm') # Arbitrary character + f.close() + + f = open(TESTFN, "rb+") + mf = mmap.mmap(f.fileno(), 0) + verify(len(mf) == 2**16, "Map size should equal file size.") + vereq(mf.read(2**16), 2**16 * "m") + mf.close() + f.close() + finally: + os.unlink(TESTFN) + + # test mapping of entire file by passing 0 for map length + if hasattr(os, "stat"): + print " Ensuring that passing 0 as map length sets map size to current file size." + f = open(TESTFN, "w+") + try: + f.write(2**16 * 'm') # Arbitrary character + f.close() + + f = open(TESTFN, "rb+") + mf = mmap.mmap(f.fileno(), 0) + verify(len(mf) == 2**16, "Map size should equal file size.") + vereq(mf.read(2**16), 2**16 * "m") + mf.close() + f.close() + + finally: + os.unlink(TESTFN) + print ' Test passed' test_both() From loewis at users.sourceforge.net Thu Mar 3 12:23:14 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 12:23:18 2005 Subject: [Python-checkins] python/dist/src/Lib/test/output test_mmap, 1.9, 1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12697/Lib/test/output Modified Files: test_mmap Log Message: Patches #749830, #1144555: allow UNIX mmap size to default to current file size. Index: test_mmap =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_mmap,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- test_mmap 5 Sep 2002 21:48:06 -0000 1.9 +++ test_mmap 3 Mar 2005 11:22:41 -0000 1.10 @@ -31,4 +31,6 @@ Modifying copy-on-write memory map. Ensuring copy-on-write maps cannot be resized. Ensuring invalid access parameter raises exception. + Ensuring that passing 0 as map length sets map size to current file size. + Ensuring that passing 0 as map length sets map size to current file size. Test passed From loewis at users.sourceforge.net Thu Mar 3 12:39:50 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 12:39:53 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1257,1.1258 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16299/Misc Modified Files: NEWS Log Message: Patch #645894: Use getrusage for computing the time consumption in profile.py if available. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1257 retrieving revision 1.1258 diff -u -d -r1.1257 -r1.1258 --- NEWS 3 Mar 2005 11:22:41 -0000 1.1257 +++ NEWS 3 Mar 2005 11:39:45 -0000 1.1258 @@ -64,6 +64,9 @@ Library ------- +- Patch #645894: Use getrusage for computing the time consumption in + profile.py if available. + - Patch #1046831: Use get_python_version where appropriate in sysconfig.py. - Patch #1117454: Remove code to special-case cookies without values From loewis at users.sourceforge.net Thu Mar 3 12:40:18 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 12:40:21 2005 Subject: [Python-checkins] python/dist/src/Lib profile.py,1.61,1.62 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16299/Lib Modified Files: profile.py Log Message: Patch #645894: Use getrusage for computing the time consumption in profile.py if available. Index: profile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/profile.py,v retrieving revision 1.61 retrieving revision 1.62 diff -u -d -r1.61 -r1.62 --- profile.py 10 Jan 2005 16:48:37 -0000 1.61 +++ profile.py 3 Mar 2005 11:39:44 -0000 1.62 @@ -107,6 +107,20 @@ t = timer() return t[0] + t[1] +# Using getrusage(3) is better than clock(3) if available: +# on some systems (e.g. FreeBSD), getrusage has a higher resolution +# Furthermore, on a POSIX system, returns microseconds, which +# wrap around after 36min. +_has_res = 0 +try: + import resource + resgetrusage = lambda: resource.getrusage(resource.RUSAGE_SELF) + def _get_time_resource(timer=resgetrusage): + t = timer() + return t[0] + t[1] + _has_res = 1 +except ImportError: + pass class Profile: """Profiler class. @@ -159,8 +173,12 @@ bias = self.bias self.bias = bias # Materialize in local dict for lookup speed. - if timer is None: - if os.name == 'mac': + if not timer: + if _has_res: + self.timer = resgetrusage + self.dispatcher = self.trace_dispatch + self.get_time = _get_time_resource + elif os.name == 'mac': self.timer = MacOS.GetTicks self.dispatcher = self.trace_dispatch_mac self.get_time = _get_time_mac From loewis at users.sourceforge.net Thu Mar 3 12:45:47 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 12:45:50 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1258,1.1259 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17432/Misc Modified Files: NEWS Log Message: Patch #802188: better parser error message for non-EOL following line cont. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1258 retrieving revision 1.1259 diff -u -d -r1.1258 -r1.1259 --- NEWS 3 Mar 2005 11:39:45 -0000 1.1258 +++ NEWS 3 Mar 2005 11:45:34 -0000 1.1259 @@ -10,6 +10,9 @@ Core and builtins ----------------- +- Patch #802188: Report characters after line continuation character + ('\') with a specific error message. + - Bug #723201: Raise a TypeError for passing bad objects to 'L' format. - Bug #1124295: the __name__ attribute of file objects was From loewis at users.sourceforge.net Thu Mar 3 12:45:47 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 12:45:51 2005 Subject: [Python-checkins] python/dist/src/Parser tokenizer.c,2.76,2.77 Message-ID: Update of /cvsroot/python/python/dist/src/Parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17432/Parser Modified Files: tokenizer.c Log Message: Patch #802188: better parser error message for non-EOL following line cont. Index: tokenizer.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/tokenizer.c,v retrieving revision 2.76 retrieving revision 2.77 diff -u -d -r2.76 -r2.77 --- tokenizer.c 4 Aug 2004 17:36:41 -0000 2.76 +++ tokenizer.c 3 Mar 2005 11:45:45 -0000 2.77 @@ -1413,7 +1413,7 @@ if (c == '\\') { c = tok_nextc(tok); if (c != '\n') { - tok->done = E_TOKEN; + tok->done = E_LINECONT; tok->cur = tok->inp; return ERRORTOKEN; } From loewis at users.sourceforge.net Thu Mar 3 12:45:48 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 12:45:52 2005 Subject: [Python-checkins] python/dist/src/Python pythonrun.c,2.211,2.212 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17432/Python Modified Files: pythonrun.c Log Message: Patch #802188: better parser error message for non-EOL following line cont. Index: pythonrun.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v retrieving revision 2.211 retrieving revision 2.212 diff -u -d -r2.211 -r2.212 --- pythonrun.c 13 Oct 2004 14:48:50 -0000 2.211 +++ pythonrun.c 3 Mar 2005 11:45:45 -0000 2.212 @@ -1484,6 +1484,9 @@ msg = "unknown decode error"; break; } + case E_LINECONT: + msg = "unexpected character after line continuation character"; + break; default: fprintf(stderr, "error=%d\n", err->error); msg = "unknown parsing error"; From loewis at users.sourceforge.net Thu Mar 3 12:46:07 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 12:46:10 2005 Subject: [Python-checkins] python/dist/src/Include errcode.h,2.16,2.17 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17432/Include Modified Files: errcode.h Log Message: Patch #802188: better parser error message for non-EOL following line cont. Index: errcode.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/errcode.h,v retrieving revision 2.16 retrieving revision 2.17 diff -u -d -r2.16 -r2.17 --- errcode.h 15 Aug 2002 01:20:16 -0000 2.16 +++ errcode.h 3 Mar 2005 11:45:33 -0000 2.17 @@ -28,6 +28,7 @@ #define E_DECODE 22 /* Error in decoding into Unicode */ #define E_EOFS 23 /* EOF in triple-quoted string */ #define E_EOLS 24 /* EOL in single-quoted string */ +#define E_LINECONT 25 /* Unexpected characters after a line continuation */ #ifdef __cplusplus } From loewis at users.sourceforge.net Thu Mar 3 13:26:23 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 13:26:26 2005 Subject: [Python-checkins] python/dist/src/Objects longobject.c, 1.165, 1.165.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26793/Objects Modified Files: Tag: release24-maint longobject.c Log Message: Revert previous checkin on getargs 'L' code. Try to convert all numbers in PyLong_AsLongLong, and update test suite accordingly. Index: longobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/longobject.c,v retrieving revision 1.165 retrieving revision 1.165.2.1 diff -u -d -r1.165 -r1.165.2.1 --- longobject.c 20 Sep 2004 06:14:54 -0000 1.165 +++ longobject.c 3 Mar 2005 12:26:05 -0000 1.165.2.1 @@ -783,9 +783,30 @@ return -1; } if (!PyLong_Check(vv)) { + PyNumberMethods *nb; + PyObject *io; if (PyInt_Check(vv)) return (PY_LONG_LONG)PyInt_AsLong(vv); - PyErr_BadInternalCall(); + if ((nb = vv->ob_type->tp_as_number) == NULL || + nb->nb_int == NULL) { + PyErr_SetString(PyExc_TypeError, "an integer is required"); + return -1; + } + io = (*nb->nb_int) (vv); + if (io == NULL) + return -1; + if (PyInt_Check(io)) { + bytes = PyInt_AsLong(io); + Py_DECREF(io); + return bytes; + } + if (PyLong_Check(io)) { + bytes = PyLong_AsLongLong(io); + Py_DECREF(io); + return bytes; + } + Py_DECREF(io); + PyErr_SetString(PyExc_TypeError, "integer conversion failed"); return -1; } From loewis at users.sourceforge.net Thu Mar 3 13:26:23 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 13:26:28 2005 Subject: [Python-checkins] python/dist/src/Python getargs.c, 2.102.2.1, 2.102.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26793/Python Modified Files: Tag: release24-maint getargs.c Log Message: Revert previous checkin on getargs 'L' code. Try to convert all numbers in PyLong_AsLongLong, and update test suite accordingly. Index: getargs.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/getargs.c,v retrieving revision 2.102.2.1 retrieving revision 2.102.2.2 diff -u -d -r2.102.2.1 -r2.102.2.2 --- getargs.c 3 Mar 2005 09:24:05 -0000 2.102.2.1 +++ getargs.c 3 Mar 2005 12:26:20 -0000 2.102.2.2 @@ -610,7 +610,6 @@ PY_LONG_LONG *p = va_arg( *p_va, PY_LONG_LONG * ); PY_LONG_LONG ival = PyLong_AsLongLong( arg ); if( ival == (PY_LONG_LONG)-1 && PyErr_Occurred() ) { - PyErr_Clear(); return converterr("long", arg, msgbuf, bufsize); } else { *p = ival; From loewis at users.sourceforge.net Thu Mar 3 13:26:37 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 13:26:40 2005 Subject: [Python-checkins] python/dist/src/Objects longobject.c,1.165,1.166 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27103/Objects Modified Files: longobject.c Log Message: Revert previous checkin on getargs 'L' code. Try to convert all numbers in PyLong_AsLongLong, and update test suite accordingly. Backported to 2.4. Index: longobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/longobject.c,v retrieving revision 1.165 retrieving revision 1.166 diff -u -d -r1.165 -r1.166 --- longobject.c 20 Sep 2004 06:14:54 -0000 1.165 +++ longobject.c 3 Mar 2005 12:26:34 -0000 1.166 @@ -783,9 +783,30 @@ return -1; } if (!PyLong_Check(vv)) { + PyNumberMethods *nb; + PyObject *io; if (PyInt_Check(vv)) return (PY_LONG_LONG)PyInt_AsLong(vv); - PyErr_BadInternalCall(); + if ((nb = vv->ob_type->tp_as_number) == NULL || + nb->nb_int == NULL) { + PyErr_SetString(PyExc_TypeError, "an integer is required"); + return -1; + } + io = (*nb->nb_int) (vv); + if (io == NULL) + return -1; + if (PyInt_Check(io)) { + bytes = PyInt_AsLong(io); + Py_DECREF(io); + return bytes; + } + if (PyLong_Check(io)) { + bytes = PyLong_AsLongLong(io); + Py_DECREF(io); + return bytes; + } + Py_DECREF(io); + PyErr_SetString(PyExc_TypeError, "integer conversion failed"); return -1; } From loewis at users.sourceforge.net Thu Mar 3 13:26:37 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 13:26:41 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_capi.py, 1.9, 1.10 test_getargs2.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-serv27103/Lib/test Modified Files: test_capi.py test_getargs2.py Log Message: Revert previous checkin on getargs 'L' code. Try to convert all numbers in PyLong_AsLongLong, and update test suite accordingly. Backported to 2.4. Index: test_capi.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_capi.py,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- test_capi.py 3 Mar 2005 09:24:38 -0000 1.9 +++ test_capi.py 3 Mar 2005 12:26:34 -0000 1.10 @@ -1,7 +1,7 @@ # Run the _testcapi module tests (tests for the Python/C API): by defn, # these are all functions _testcapi exports whose name begins with 'test_'. -import sys, unittest +import sys from test import test_support import _testcapi @@ -35,12 +35,6 @@ raise test_support.TestFailed, \ "Couldn't find main thread correctly in the list" -# Tests which use _testcapi helpers -class OtherTests(unittest.TestCase): - def test_exc_L(self): - # This used to raise a SystemError(bad internal call) - self.assertRaises(TypeError, _testcapi.getargs_L, "String") - try: _testcapi._test_thread_state have_thread_state = True @@ -52,9 +46,3 @@ import threading t=threading.Thread(target=TestThreadState) t.start() - -def test_main(): - test_support.run_unittest(OtherTests) - -if __name__=='__main__': - test_main() Index: test_getargs2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_getargs2.py,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- test_getargs2.py 1 May 2003 17:45:37 -0000 1.5 +++ test_getargs2.py 3 Mar 2005 12:26:34 -0000 1.6 @@ -187,16 +187,10 @@ def test_L(self): from _testcapi import getargs_L # L returns 'long long', and does range checking (LLONG_MIN ... LLONG_MAX) - - # XXX There's a bug in getargs.c, format code "L": - # If you pass something else than a Python long, you - # get "Bad argument to internal function". - - # So these three tests are commented out: - -## self.failUnlessEqual(3, getargs_L(3.14)) -## self.failUnlessEqual(99, getargs_L(Long())) -## self.failUnlessEqual(99, getargs_L(Int())) + self.failUnlessRaises(TypeError, getargs_L, "Hello") + self.failUnlessEqual(3, getargs_L(3.14)) + self.failUnlessEqual(99, getargs_L(Long())) + self.failUnlessEqual(99, getargs_L(Int())) self.assertRaises(OverflowError, getargs_L, LLONG_MIN-1) self.failUnlessEqual(LLONG_MIN, getargs_L(LLONG_MIN)) From loewis at users.sourceforge.net Thu Mar 3 13:26:38 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 13:26:41 2005 Subject: [Python-checkins] python/dist/src/Python getargs.c,2.103,2.104 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27103/Python Modified Files: getargs.c Log Message: Revert previous checkin on getargs 'L' code. Try to convert all numbers in PyLong_AsLongLong, and update test suite accordingly. Backported to 2.4. Index: getargs.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/getargs.c,v retrieving revision 2.103 retrieving revision 2.104 diff -u -d -r2.103 -r2.104 --- getargs.c 3 Mar 2005 09:24:38 -0000 2.103 +++ getargs.c 3 Mar 2005 12:26:35 -0000 2.104 @@ -610,7 +610,6 @@ PY_LONG_LONG *p = va_arg( *p_va, PY_LONG_LONG * ); PY_LONG_LONG ival = PyLong_AsLongLong( arg ); if( ival == (PY_LONG_LONG)-1 && PyErr_Occurred() ) { - PyErr_Clear(); return converterr("long", arg, msgbuf, bufsize); } else { *p = ival; From loewis at users.sourceforge.net Thu Mar 3 13:26:38 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 3 13:26:43 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_capi.py, 1.8.2.1, 1.8.2.2 test_getargs2.py, 1.5, 1.5.12.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26793/Lib/test Modified Files: Tag: release24-maint test_capi.py test_getargs2.py Log Message: Revert previous checkin on getargs 'L' code. Try to convert all numbers in PyLong_AsLongLong, and update test suite accordingly. Index: test_capi.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_capi.py,v retrieving revision 1.8.2.1 retrieving revision 1.8.2.2 diff -u -d -r1.8.2.1 -r1.8.2.2 --- test_capi.py 3 Mar 2005 09:24:03 -0000 1.8.2.1 +++ test_capi.py 3 Mar 2005 12:26:05 -0000 1.8.2.2 @@ -1,7 +1,7 @@ # Run the _testcapi module tests (tests for the Python/C API): by defn, # these are all functions _testcapi exports whose name begins with 'test_'. -import sys, unittest +import sys from test import test_support import _testcapi @@ -35,12 +35,6 @@ raise test_support.TestFailed, \ "Couldn't find main thread correctly in the list" -# Tests which use _testcapi helpers -class OtherTests(unittest.TestCase): - def test_exc_L(self): - # This used to raise a SystemError(bad internal call) - self.assertRaises(TypeError, _testcapi.getargs_L, "String") - try: _testcapi._test_thread_state have_thread_state = True @@ -52,9 +46,3 @@ import threading t=threading.Thread(target=TestThreadState) t.start() - -def test_main(): - test_support.run_unittest(OtherTests) - -if __name__=='__main__': - test_main() Index: test_getargs2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_getargs2.py,v retrieving revision 1.5 retrieving revision 1.5.12.1 diff -u -d -r1.5 -r1.5.12.1 --- test_getargs2.py 1 May 2003 17:45:37 -0000 1.5 +++ test_getargs2.py 3 Mar 2005 12:26:05 -0000 1.5.12.1 @@ -187,16 +187,10 @@ def test_L(self): from _testcapi import getargs_L # L returns 'long long', and does range checking (LLONG_MIN ... LLONG_MAX) - - # XXX There's a bug in getargs.c, format code "L": - # If you pass something else than a Python long, you - # get "Bad argument to internal function". - - # So these three tests are commented out: - -## self.failUnlessEqual(3, getargs_L(3.14)) -## self.failUnlessEqual(99, getargs_L(Long())) -## self.failUnlessEqual(99, getargs_L(Int())) + self.failUnlessRaises(TypeError, getargs_L, "Hello") + self.failUnlessEqual(3, getargs_L(3.14)) + self.failUnlessEqual(99, getargs_L(Long())) + self.failUnlessEqual(99, getargs_L(Int())) self.assertRaises(OverflowError, getargs_L, LLONG_MIN-1) self.failUnlessEqual(LLONG_MIN, getargs_L(LLONG_MIN)) From rhettinger at users.sourceforge.net Thu Mar 3 17:45:21 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Mar 3 17:45:25 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1259,1.1260 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2761/Misc Modified Files: NEWS Log Message: SF bug #1155938: Missing None check for __init__(). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1259 retrieving revision 1.1260 diff -u -d -r1.1259 -r1.1260 --- NEWS 3 Mar 2005 11:45:34 -0000 1.1259 +++ NEWS 3 Mar 2005 16:45:16 -0000 1.1260 @@ -10,6 +10,9 @@ Core and builtins ----------------- +- Bug #1155938: new style classes did not check that __init__() was + returning None. + - Patch #802188: Report characters after line continuation character ('\') with a specific error message. From rhettinger at users.sourceforge.net Thu Mar 3 17:45:22 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Mar 3 17:45:27 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_descr.py, 1.203, 1.204 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2761/Lib/test Modified Files: test_descr.py Log Message: SF bug #1155938: Missing None check for __init__(). Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.203 retrieving revision 1.204 diff -u -d -r1.203 -r1.204 --- test_descr.py 16 Jan 2005 00:25:31 -0000 1.203 +++ test_descr.py 3 Mar 2005 16:45:19 -0000 1.204 @@ -3965,6 +3965,18 @@ import gc; gc.collect() vereq(hasattr(c, 'attr'), False) +def test_init(): + # SF 1155938 + class Foo(object): + def __init__(self): + return 10 + try: + Foo() + except TypeError: + pass + else: + raise TestFailed, "did not test __init__() for None return" + def test_main(): weakref_segfault() # Must be first, somehow @@ -4058,6 +4070,7 @@ carloverre() filefault() vicious_descriptor_nonsense() + test_init() if verbose: print "All OK" From rhettinger at users.sourceforge.net Thu Mar 3 17:45:23 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Mar 3 17:45:27 2005 Subject: [Python-checkins] python/dist/src/Objects typeobject.c,2.264,2.265 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2761/Objects Modified Files: typeobject.c Log Message: SF bug #1155938: Missing None check for __init__(). Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.264 retrieving revision 2.265 diff -u -d -r2.264 -r2.265 --- typeobject.c 23 Sep 2004 02:39:37 -0000 2.264 +++ typeobject.c 3 Mar 2005 16:45:19 -0000 2.265 @@ -4753,6 +4753,12 @@ Py_DECREF(meth); if (res == NULL) return -1; + if (res != Py_None) { + PyErr_SetString(PyExc_TypeError, + "__init__() should return None"); + Py_DECREF(res); + return -1; + } Py_DECREF(res); return 0; } From rhettinger at users.sourceforge.net Thu Mar 3 17:55:55 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Mar 3 17:55:58 2005 Subject: [Python-checkins] python/dist/src/Objects typeobject.c, 2.264, 2.264.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6024/Objects Modified Files: Tag: release24-maint typeobject.c Log Message: SF bug #1155938: Missing None check for __init__(). Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.264 retrieving revision 2.264.2.1 diff -u -d -r2.264 -r2.264.2.1 --- typeobject.c 23 Sep 2004 02:39:37 -0000 2.264 +++ typeobject.c 3 Mar 2005 16:55:48 -0000 2.264.2.1 @@ -4753,6 +4753,12 @@ Py_DECREF(meth); if (res == NULL) return -1; + if (res != Py_None) { + PyErr_SetString(PyExc_TypeError, + "__init__() should return None"); + Py_DECREF(res); + return -1; + } Py_DECREF(res); return 0; } From rhettinger at users.sourceforge.net Thu Mar 3 17:55:55 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Mar 3 17:55:58 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_descr.py, 1.202, 1.202.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6024/Lib/test Modified Files: Tag: release24-maint test_descr.py Log Message: SF bug #1155938: Missing None check for __init__(). Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.202 retrieving revision 1.202.2.1 diff -u -d -r1.202 -r1.202.2.1 --- test_descr.py 7 Aug 2004 20:30:03 -0000 1.202 +++ test_descr.py 3 Mar 2005 16:55:53 -0000 1.202.2.1 @@ -3965,6 +3965,18 @@ import gc; gc.collect() vereq(hasattr(c, 'attr'), False) +def test_init(): + # SF 1155938 + class Foo(object): + def __init__(self): + return 10 + try: + Foo() + except TypeError: + pass + else: + raise TestFailed, "did not test __init__() for None return" + def test_main(): weakref_segfault() # Must be first, somehow @@ -4058,6 +4070,7 @@ carloverre() filefault() vicious_descriptor_nonsense() + test_init() if verbose: print "All OK" From rhettinger at users.sourceforge.net Thu Mar 3 17:56:23 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Mar 3 17:56:26 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.27, 1.1193.2.28 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6024/Misc Modified Files: Tag: release24-maint NEWS Log Message: SF bug #1155938: Missing None check for __init__(). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.27 retrieving revision 1.1193.2.28 diff -u -d -r1.1193.2.27 -r1.1193.2.28 --- NEWS 3 Mar 2005 10:55:57 -0000 1.1193.2.27 +++ NEWS 3 Mar 2005 16:55:47 -0000 1.1193.2.28 @@ -12,6 +12,9 @@ Core and builtins ----------------- +- Bug #1155938: new style classes did not verify that __init__() + returns None. + - Bug #723201: Raise a TypeError for passing bad objects to 'L' format. - Bug #1124295: the __name__ attribute of file objects was From fdrake at users.sourceforge.net Thu Mar 3 18:24:22 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu Mar 3 18:24:25 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libuu.tex, 1.12.20.2, 1.12.20.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14471 Modified Files: Tag: release24-maint libuu.tex Log Message: minor edits: - function names marked with \function should include parentheses - "standard error" instead of "stderr" for text - a boolean parameter takes true or false values, not just True or False Index: libuu.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libuu.tex,v retrieving revision 1.12.20.2 retrieving revision 1.12.20.3 diff -u -d -r1.12.20.2 -r1.12.20.3 --- libuu.tex 3 Mar 2005 10:05:37 -0000 1.12.20.2 +++ libuu.tex 3 Mar 2005 17:24:20 -0000 1.12.20.3 @@ -39,9 +39,10 @@ the uuencode header. However, if the file specified in the header already exists, a \exception{uu.Error} is raised. - \function{decode} may print a warning to stderr if the input was produced - by an incorrect uuencoder and Python could recover from that error. - Setting \var{quiet} to True silences this warning. + \function{decode()} may print a warning to standard error if the + input was produced by an incorrect uuencoder and Python could + recover from that error. Setting \var{quiet} to a true value + silences this warning. \end{funcdesc} \begin{excclassdesc}{Error}{} From fdrake at users.sourceforge.net Thu Mar 3 18:25:07 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu Mar 3 18:25:09 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libuu.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-serv14764 Modified Files: libuu.tex Log Message: minor edits: - function names marked with \function should include parentheses - "standard error" instead of "stderr" for text - a boolean parameter takes true or false values, not just True or False Index: libuu.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libuu.tex,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- libuu.tex 3 Mar 2005 10:06:05 -0000 1.14 +++ libuu.tex 3 Mar 2005 17:25:04 -0000 1.15 @@ -39,9 +39,10 @@ the uuencode header. However, if the file specified in the header already exists, a \exception{uu.Error} is raised. - \function{decode} may print a warning to stderr if the input was produced - by an incorrect uuencoder and Python could recover from that error. - Setting \var{quiet} to True silences this warning. + \function{decode()} may print a warning to standard error if the + input was produced by an incorrect uuencoder and Python could + recover from that error. Setting \var{quiet} to a true value + silences this warning. \end{funcdesc} \begin{excclassdesc}{Error}{} From astrand at users.sourceforge.net Thu Mar 3 21:24:30 2005 From: astrand at users.sourceforge.net (astrand@users.sourceforge.net) Date: Thu Mar 3 21:24:34 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_subprocess.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-serv2316 Modified Files: test_subprocess.py Log Message: Added three more testcases: Using communicate with only one of stdin/stdout/stderr redirected. Index: test_subprocess.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_subprocess.py,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- test_subprocess.py 1 Jan 2005 09:36:35 -0000 1.17 +++ test_subprocess.py 3 Mar 2005 20:24:28 -0000 1.18 @@ -248,6 +248,29 @@ env=newenv) self.assertEqual(p.stdout.read(), "orange") + def test_communicate_stdin(self): + p = subprocess.Popen([sys.executable, "-c", + 'import sys; sys.exit(sys.stdin.read() == "pear")'], + stdin=subprocess.PIPE) + p.communicate("pear") + self.assertEqual(p.returncode, 1) + + def test_communicate_stdout(self): + p = subprocess.Popen([sys.executable, "-c", + 'import sys; sys.stdout.write("pineapple")'], + stdout=subprocess.PIPE) + (stdout, stderr) = p.communicate() + self.assertEqual(stdout, "pineapple") + self.assertEqual(stderr, None) + + def test_communicate_stderr(self): + p = subprocess.Popen([sys.executable, "-c", + 'import sys; sys.stderr.write("pineapple")'], + stderr=subprocess.PIPE) + (stdout, stderr) = p.communicate() + self.assertEqual(stdout, None) + self.assertEqual(stderr, "pineapple") + def test_communicate(self): p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' \ From astrand at users.sourceforge.net Thu Mar 3 21:29:03 2005 From: astrand at users.sourceforge.net (astrand@users.sourceforge.net) Date: Thu Mar 3 21:29:08 2005 Subject: [Python-checkins] python/dist/src/Lib subprocess.py,1.17,1.18 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3791 Modified Files: subprocess.py Log Message: Optimization for communicate(): If only one of stdin/stdout/stderr is redirected, using select() or threads is unnecessary. Index: subprocess.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/subprocess.py,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- subprocess.py 21 Feb 2005 08:13:02 -0000 1.17 +++ subprocess.py 3 Mar 2005 20:28:59 -0000 1.18 @@ -619,6 +619,33 @@ data = data.replace("\r", "\n") return data + def communicate(self, input=None): + """Interact with process: Send data to stdin. Read data from + stdout and stderr, until end-of-file is reached. Wait for + process to terminate. The optional input argument should be a + string to be sent to the child process, or None, if no data + should be sent to the child. + + communicate() returns a tuple (stdout, stderr).""" + + # Optimization: If we are only using one pipe, or no pipe at + # all, using select() or threads is unnecessary. + if [self.stdin, self.stdout, self.stderr].count(None) >= 2: + stdout = None + stderr = None + if self.stdin: + if input: + self.stdin.write(input) + self.stdin.close() + elif self.stdout: + stdout = self.stdout.read() + elif self.stderr: + stderr = self.stderr.read() + self.wait() + return (stdout, stderr) + + return self._communicate(input) + if mswindows: # @@ -811,14 +838,7 @@ buffer.append(fh.read()) - def communicate(self, input=None): - """Interact with process: Send data to stdin. Read data from - stdout and stderr, until end-of-file is reached. Wait for - process to terminate. The optional input argument should be a - string to be sent to the child process, or None, if no data - should be sent to the child. - - communicate() returns a tuple (stdout, stderr).""" + def _communicate(self, input): stdout = None # Return stderr = None # Return @@ -1066,14 +1086,7 @@ return self.returncode - def communicate(self, input=None): - """Interact with process: Send data to stdin. Read data from - stdout and stderr, until end-of-file is reached. Wait for - process to terminate. The optional input argument should be a - string to be sent to the child process, or None, if no data - should be sent to the child. - - communicate() returns a tuple (stdout, stderr).""" + def _communicate(self, input): read_set = [] write_set = [] stdout = None # Return From astrand at users.sourceforge.net Thu Mar 3 21:47:40 2005 From: astrand at users.sourceforge.net (astrand@users.sourceforge.net) Date: Thu Mar 3 21:47:44 2005 Subject: [Python-checkins] python/dist/src/Lib/test regrtest.py, 1.165, 1.166 test_subprocess.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-serv9368/Lib/test Modified Files: regrtest.py test_subprocess.py Log Message: Only run extensive subprocess tests if -usubprocess to regrtest is specified. Fixes #1124637 Index: regrtest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v retrieving revision 1.165 retrieving revision 1.166 diff -u -d -r1.165 -r1.166 --- regrtest.py 13 Nov 2004 11:13:35 -0000 1.165 +++ regrtest.py 3 Mar 2005 20:47:37 -0000 1.166 @@ -93,6 +93,8 @@ in the standard library and test suite. This takes a long time. + subprocess Run all tests for the subprocess module. + To enable all resources except one, use '-uall,-'. For example, to run all the tests except for the bsddb tests, give the option '-uall,-bsddb'. @@ -136,7 +138,7 @@ from test import test_support RESOURCE_NAMES = ('audio', 'curses', 'largefile', 'network', 'bsddb', - 'decimal', 'compiler') + 'decimal', 'compiler', 'subprocess') def usage(code, msg=''): Index: test_subprocess.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_subprocess.py,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- test_subprocess.py 3 Mar 2005 20:24:28 -0000 1.18 +++ test_subprocess.py 3 Mar 2005 20:47:37 -0000 1.19 @@ -382,9 +382,10 @@ def test_no_leaking(self): # Make sure we leak no resources - max_handles = 1026 # too much for most UNIX systems - if mswindows: - max_handles = 65 # a full test is too slow on Windows + if test_support.is_resource_enabled("subprocess") and not mswindows: + max_handles = 1026 # too much for most UNIX systems + else: + max_handles = 65 for i in range(max_handles): p = subprocess.Popen([sys.executable, "-c", "import sys;sys.stdout.write(sys.stdin.read())"], From astrand at users.sourceforge.net Thu Mar 3 21:51:35 2005 From: astrand at users.sourceforge.net (astrand@users.sourceforge.net) Date: Thu Mar 3 21:51:37 2005 Subject: [Python-checkins] python/dist/src/Lib/test regrtest.py, 1.165, 1.165.2.1 test_subprocess.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-serv10490/Lib/test Modified Files: Tag: release24-maint regrtest.py test_subprocess.py Log Message: Only run extensive subprocess tests if -usubprocess to regrtest is specified. Fixes #1124637 Index: regrtest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v retrieving revision 1.165 retrieving revision 1.165.2.1 diff -u -d -r1.165 -r1.165.2.1 --- regrtest.py 13 Nov 2004 11:13:35 -0000 1.165 +++ regrtest.py 3 Mar 2005 20:51:32 -0000 1.165.2.1 @@ -93,6 +93,8 @@ in the standard library and test suite. This takes a long time. + subprocess Run all tests for the subprocess module. + To enable all resources except one, use '-uall,-'. For example, to run all the tests except for the bsddb tests, give the option '-uall,-bsddb'. @@ -136,7 +138,7 @@ from test import test_support RESOURCE_NAMES = ('audio', 'curses', 'largefile', 'network', 'bsddb', - 'decimal', 'compiler') + 'decimal', 'compiler', 'subprocess') def usage(code, msg=''): Index: test_subprocess.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_subprocess.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_subprocess.py 5 Dec 2004 20:05:04 -0000 1.15.2.1 +++ test_subprocess.py 3 Mar 2005 20:51:32 -0000 1.15.2.2 @@ -343,9 +343,10 @@ def test_no_leaking(self): # Make sure we leak no resources - max_handles = 1026 # too much for most UNIX systems - if mswindows: - max_handles = 65 # a full test is too slow on Windows + if test_support.is_resource_enabled("subprocess") and not mswindows: + max_handles = 1026 # too much for most UNIX systems + else: + max_handles = 65 for i in range(max_handles): p = subprocess.Popen([sys.executable, "-c", "import sys;sys.stdout.write(sys.stdin.read())"], From astrand at users.sourceforge.net Thu Mar 3 22:10:26 2005 From: astrand at users.sourceforge.net (astrand@users.sourceforge.net) Date: Thu Mar 3 22:10:29 2005 Subject: [Python-checkins] python/dist/src/Lib subprocess.py,1.18,1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15926 Modified Files: subprocess.py Log Message: Corrected bug in list2cmdline wrt backslashes. Fixes #1083306. Index: subprocess.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/subprocess.py,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- subprocess.py 3 Mar 2005 20:28:59 -0000 1.18 +++ subprocess.py 3 Mar 2005 21:10:23 -0000 1.19 @@ -532,6 +532,7 @@ result.extend(bs_buf) if needquote: + result.extend(bs_buf) result.append('"') return ''.join(result) From astrand at users.sourceforge.net Thu Mar 3 22:11:09 2005 From: astrand at users.sourceforge.net (astrand@users.sourceforge.net) Date: Thu Mar 3 22:11:14 2005 Subject: [Python-checkins] python/dist/src/Lib subprocess.py, 1.8.2.3, 1.8.2.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16164 Modified Files: Tag: release24-maint subprocess.py Log Message: Corrected bug in list2cmdline wrt backslashes. Fixes #1083306. Index: subprocess.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/subprocess.py,v retrieving revision 1.8.2.3 retrieving revision 1.8.2.4 diff -u -d -r1.8.2.3 -r1.8.2.4 --- subprocess.py 1 Jan 2005 09:32:16 -0000 1.8.2.3 +++ subprocess.py 3 Mar 2005 21:11:06 -0000 1.8.2.4 @@ -490,6 +490,7 @@ result.extend(bs_buf) if needquote: + result.extend(bs_buf) result.append('"') return ''.join(result) From loewis at users.sourceforge.net Fri Mar 4 00:00:29 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Mar 4 00:00:32 2005 Subject: [Python-checkins] python/dist/src/Python structmember.c,2.24,2.25 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14423/Python Modified Files: structmember.c Log Message: Patch #1115086: support PY_LONGLONG in structmember. Index: structmember.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/structmember.c,v retrieving revision 2.24 retrieving revision 2.25 diff -u -d -r2.24 -r2.25 --- structmember.c 20 Nov 2003 01:44:58 -0000 2.24 +++ structmember.c 3 Mar 2005 23:00:26 -0000 2.25 @@ -118,6 +118,14 @@ PyErr_SetString(PyExc_AttributeError, l->name); Py_XINCREF(v); break; +#ifdef HAVE_LONG_LONG + case T_LONGLONG: + v = PyLong_FromLongLong(*(PY_LONG_LONG *)addr); + break; + case T_ULONGLONG: + v = PyLong_FromUnsignedLongLong(*(unsigned PY_LONG_LONG *)addr); + break; +#endif /* HAVE_LONG_LONG */ default: PyErr_SetString(PyExc_SystemError, "bad memberdescr type"); v = NULL; @@ -246,6 +254,30 @@ return -1; } break; +#ifdef HAVE_LONG_LONG + case T_LONGLONG: + if (!PyLong_Check(v)) { + PyErr_BadArgument(); + return -1; + } else { + *(PY_LONG_LONG*)addr = PyLong_AsLongLong(v); + if ((*addr == -1) && PyErr_Occurred()) { + return -1; + } + } + break; + case T_ULONGLONG: + if (!PyLong_Check(v)) { + PyErr_BadArgument(); + return -1; + } else { + *(unsigned PY_LONG_LONG*)addr = PyLong_AsUnsignedLongLong(v); + if ((*addr == -1) && PyErr_Occurred()) { + return -1; + } + } + break; +#endif /* HAVE_LONG_LONG */ default: PyErr_Format(PyExc_SystemError, "bad memberdescr type for %s", l->name); From loewis at users.sourceforge.net Fri Mar 4 00:00:29 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Mar 4 00:00:33 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1260,1.1261 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14423/Misc Modified Files: NEWS Log Message: Patch #1115086: support PY_LONGLONG in structmember. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1260 retrieving revision 1.1261 diff -u -d -r1.1260 -r1.1261 --- NEWS 3 Mar 2005 16:45:16 -0000 1.1260 +++ NEWS 3 Mar 2005 23:00:20 -0000 1.1261 @@ -10,6 +10,8 @@ Core and builtins ----------------- +- Patch #1115086: Support PY_LONGLONG in structmember. + - Bug #1155938: new style classes did not check that __init__() was returning None. From loewis at users.sourceforge.net Fri Mar 4 00:00:52 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Mar 4 00:00:56 2005 Subject: [Python-checkins] python/dist/src/Include structmember.h,2.22,2.23 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14423/Include Modified Files: structmember.h Log Message: Patch #1115086: support PY_LONGLONG in structmember. Index: structmember.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/structmember.h,v retrieving revision 2.22 retrieving revision 2.23 diff -u -d -r2.22 -r2.23 --- structmember.h 10 Feb 2004 16:50:18 -0000 2.22 +++ structmember.h 3 Mar 2005 23:00:20 -0000 2.23 @@ -65,6 +65,10 @@ #define T_OBJECT_EX 16 /* Like T_OBJECT, but raises AttributeError when the value is NULL, instead of converting to None. */ +#ifdef HAVE_LONG_LONG +#define T_LONGLONG 17 +#define T_ULONGLONG 18 +#endif /* HAVE_LONG_LONG */ /* Flags */ #define READONLY 1 From loewis at users.sourceforge.net Fri Mar 4 00:07:24 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Mar 4 00:07:27 2005 Subject: [Python-checkins] python/dist/src/Doc/doc doc.tex,1.91,1.92 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16351 Modified Files: doc.tex Log Message: Patch #1107221: Updated "Working on Cygwin" section. Will backport to 2.4. Index: doc.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/doc/doc.tex,v retrieving revision 1.91 retrieving revision 1.92 diff -u -d -r1.91 -r1.92 --- doc.tex 1 Jan 2005 00:28:30 -0000 1.91 +++ doc.tex 3 Mar 2005 23:07:21 -0000 1.92 @@ -1878,31 +1878,42 @@ \subsection{Working on Cygwin \label{cygwin}} Installing the required tools under Cygwin under Cygwin can be a - little tedious, if only because many packages are more difficult - to install under Cygwin. + little tedious. Most of the required packages can be installed + using Cygwin's graphical installer, while netpbm and \LaTeX2HTML + must be installed from source. + + Start with a reasonably modern version of Cygwin. If you haven't + upgraded for a few years, now would be a good time. Using the Cygwin installer, make sure your Cygwin installation includes Perl, Python, and the \TeX{} packages. Perl and Python - are located under \menuselection{Interpreters} in the installer. - The \TeX{} packages are located in the \menuselection{Text} - section; installing the \code{tetex-beta}, \code{texmf}, - \code{texmf-base}, and \code{texmf-extra} ensures that all the - required packages are available. (There may be a more minimal - set, but I've not spent time trying to minimize the installation.) + are located under the \menuselection{Interpreters} heading. The + \TeX{} packages are located under the \menuselection{Text} + heading, and are named \code{tetex-*}. To ensure that all + required packages are available, install every \code{tetex} + package, except \code{tetex-x11}. (There may be a more minimal + set, but I've not spent time trying to minimize the installation.) The netpbm package is used by \LaTeX2HTML, and \emph{must} be installed before \LaTeX2HTML can be successfully installed, even - though they will never be used for most Python documentation. - References to download locations are located in the \ulink{netpbm - README}{http://netpbm.sourceforge.net/README}. Install according - to the instructions. + though its features will not be used for most Python + documentation. References to download locations are located in + the \ulink{netpbm README}{http://netpbm.sourceforge.net/README}. + Install from the latest stable source distribution according to + the instructions. (Note that binary packages of netpbm are + sometimes available, but these may not work correctly with + \LaTeX2HTML.) \LaTeX2HTML can be installed from the source archive, but only - after munging one of the files in the distribution. Edit the file - \file{L2hos.pm} in the top level of the unpacked distribution; - near the bottom of the file, change the text - \code{\$\textasciicircum{}O} with the text \code{'unix'}. Proceed - using this command to build and install the software: + after munging one of the files in the distribution. Download the + source archive from the \LaTeX2HTML website + \url{http://www.latex2html.org/} (or one of the many alternate + sites) and unpack it to a build directory. In the top level of + this build directory there will be a file named \file{L2hos.pm}. + Open \file{L2hos.pm} in an editor, and near the bottom of the file + replace the text \code{\$\textasciicircum{}O} with the text + \code{'unix'}. Proceed using this command to build and install + the software: \begin{verbatim} % ./configure && make install From loewis at users.sourceforge.net Fri Mar 4 00:07:50 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Mar 4 00:07:52 2005 Subject: [Python-checkins] python/dist/src/Doc/doc doc.tex, 1.90.2.1, 1.90.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16580 Modified Files: Tag: release24-maint doc.tex Log Message: Patch #1107221: Updated "Working on Cygwin" section. Index: doc.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/doc/doc.tex,v retrieving revision 1.90.2.1 retrieving revision 1.90.2.2 diff -u -d -r1.90.2.1 -r1.90.2.2 --- doc.tex 1 Jan 2005 00:34:52 -0000 1.90.2.1 +++ doc.tex 3 Mar 2005 23:07:47 -0000 1.90.2.2 @@ -1878,31 +1878,42 @@ \subsection{Working on Cygwin \label{cygwin}} Installing the required tools under Cygwin under Cygwin can be a - little tedious, if only because many packages are more difficult - to install under Cygwin. + little tedious. Most of the required packages can be installed + using Cygwin's graphical installer, while netpbm and \LaTeX2HTML + must be installed from source. + + Start with a reasonably modern version of Cygwin. If you haven't + upgraded for a few years, now would be a good time. Using the Cygwin installer, make sure your Cygwin installation includes Perl, Python, and the \TeX{} packages. Perl and Python - are located under \menuselection{Interpreters} in the installer. - The \TeX{} packages are located in the \menuselection{Text} - section; installing the \code{tetex-beta}, \code{texmf}, - \code{texmf-base}, and \code{texmf-extra} ensures that all the - required packages are available. (There may be a more minimal - set, but I've not spent time trying to minimize the installation.) + are located under the \menuselection{Interpreters} heading. The + \TeX{} packages are located under the \menuselection{Text} + heading, and are named \code{tetex-*}. To ensure that all + required packages are available, install every \code{tetex} + package, except \code{tetex-x11}. (There may be a more minimal + set, but I've not spent time trying to minimize the installation.) The netpbm package is used by \LaTeX2HTML, and \emph{must} be installed before \LaTeX2HTML can be successfully installed, even - though they will never be used for most Python documentation. - References to download locations are located in the \ulink{netpbm - README}{http://netpbm.sourceforge.net/README}. Install according - to the instructions. + though its features will not be used for most Python + documentation. References to download locations are located in + the \ulink{netpbm README}{http://netpbm.sourceforge.net/README}. + Install from the latest stable source distribution according to + the instructions. (Note that binary packages of netpbm are + sometimes available, but these may not work correctly with + \LaTeX2HTML.) \LaTeX2HTML can be installed from the source archive, but only - after munging one of the files in the distribution. Edit the file - \file{L2hos.pm} in the top level of the unpacked distribution; - near the bottom of the file, change the text - \code{\$\textasciicircum{}O} with the text \code{'unix'}. Proceed - using this command to build and install the software: + after munging one of the files in the distribution. Download the + source archive from the \LaTeX2HTML website + \url{http://www.latex2html.org/} (or one of the many alternate + sites) and unpack it to a build directory. In the top level of + this build directory there will be a file named \file{L2hos.pm}. + Open \file{L2hos.pm} in an editor, and near the bottom of the file + replace the text \code{\$\textasciicircum{}O} with the text + \code{'unix'}. Proceed using this command to build and install + the software: \begin{verbatim} % ./configure && make install From loewis at users.sourceforge.net Fri Mar 4 00:12:45 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Mar 4 00:12:47 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1261,1.1262 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17730/Misc Modified Files: NEWS Log Message: Patch #1103407: Properly deal with tarfile iterators when untarring symbolic links on Windows. Fixes #1100429. Will backport to 2.4. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1261 retrieving revision 1.1262 diff -u -d -r1.1261 -r1.1262 --- NEWS 3 Mar 2005 23:00:20 -0000 1.1261 +++ NEWS 3 Mar 2005 23:12:32 -0000 1.1262 @@ -72,6 +72,9 @@ Library ------- +- Patch #1103407: Properly deal with tarfile iterators when untarring + symbolic links on Windows. + - Patch #645894: Use getrusage for computing the time consumption in profile.py if available. From loewis at users.sourceforge.net Fri Mar 4 00:12:45 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Mar 4 00:12:48 2005 Subject: [Python-checkins] python/dist/src/Lib tarfile.py,1.24,1.25 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17730/Lib Modified Files: tarfile.py Log Message: Patch #1103407: Properly deal with tarfile iterators when untarring symbolic links on Windows. Fixes #1100429. Will backport to 2.4. Index: tarfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tarfile.py,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- tarfile.py 3 Mar 2005 08:17:32 -0000 1.24 +++ tarfile.py 3 Mar 2005 23:12:42 -0000 1.25 @@ -1851,6 +1851,7 @@ """Construct a TarIter object. """ self.tarfile = tarfile + self.index = 0 def __iter__(self): """Return iterator object. """ @@ -1859,10 +1860,20 @@ """Return the next item using TarFile's next() method. When all members have been read, set TarFile as _loaded. """ - tarinfo = self.tarfile.next() - if not tarinfo: - self.tarfile._loaded = True - raise StopIteration + # Fix for SF #1100429: Under rare circumstances it can + # happen that getmembers() is called during iteration, + # which will cause TarIter to stop prematurely. + if not self.tarfile._loaded: + tarinfo = self.tarfile.next() + if not tarinfo: + self.tarfile._loaded = True + raise StopIteration + else: + try: + tarinfo = self.tarfile.members[self.index] + except IndexError: + raise StopIteration + self.index += 1 return tarinfo # Helper classes for sparse file support From loewis at users.sourceforge.net Fri Mar 4 00:15:10 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Mar 4 00:15:12 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.28, 1.1193.2.29 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18416/Misc Modified Files: Tag: release24-maint NEWS Log Message: Patch #1103407: Properly deal with tarfile iterators when untarring symbolic links on Windows. Fixes #1100429. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.28 retrieving revision 1.1193.2.29 diff -u -d -r1.1193.2.28 -r1.1193.2.29 --- NEWS 3 Mar 2005 16:55:47 -0000 1.1193.2.28 +++ NEWS 3 Mar 2005 23:15:04 -0000 1.1193.2.29 @@ -40,6 +40,9 @@ Library ------- +- Patch #1103407: Properly deal with tarfile iterators when untarring + symbolic links on Windows. + - Patch #1117454: Remove code to special-case cookies without values in LWPCookieJar. From loewis at users.sourceforge.net Fri Mar 4 00:15:36 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Mar 4 00:15:38 2005 Subject: [Python-checkins] python/dist/src/Lib tarfile.py,1.21,1.21.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18416/Lib Modified Files: Tag: release24-maint tarfile.py Log Message: Patch #1103407: Properly deal with tarfile iterators when untarring symbolic links on Windows. Fixes #1100429. Index: tarfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tarfile.py,v retrieving revision 1.21 retrieving revision 1.21.2.1 diff -u -d -r1.21 -r1.21.2.1 --- tarfile.py 20 Oct 2004 11:48:42 -0000 1.21 +++ tarfile.py 3 Mar 2005 23:15:03 -0000 1.21.2.1 @@ -1840,6 +1840,7 @@ """Construct a TarIter object. """ self.tarfile = tarfile + self.index = 0 def __iter__(self): """Return iterator object. """ @@ -1848,10 +1849,20 @@ """Return the next item using TarFile's next() method. When all members have been read, set TarFile as _loaded. """ - tarinfo = self.tarfile.next() - if not tarinfo: - self.tarfile._loaded = True - raise StopIteration + # Fix for SF #1100429: Under rare circumstances it can + # happen that getmembers() is called during iteration, + # which will cause TarIter to stop prematurely. + if not self.tarfile._loaded: + tarinfo = self.tarfile.next() + if not tarinfo: + self.tarfile._loaded = True + raise StopIteration + else: + try: + tarinfo = self.tarfile.members[self.index] + except IndexError: + raise StopIteration + self.index += 1 return tarinfo # Helper classes for sparse file support From rhettinger at users.sourceforge.net Fri Mar 4 05:47:07 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Mar 4 05:47:11 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_descr.py, 1.202.2.1, 1.202.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6375/Lib/test Modified Files: Tag: release24-maint test_descr.py Log Message: Convert "__init__ should return None" from an exception to a warning. Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.202.2.1 retrieving revision 1.202.2.2 diff -u -d -r1.202.2.1 -r1.202.2.2 --- test_descr.py 3 Mar 2005 16:55:53 -0000 1.202.2.1 +++ test_descr.py 4 Mar 2005 04:47:04 -0000 1.202.2.2 @@ -3965,17 +3965,23 @@ import gc; gc.collect() vereq(hasattr(c, 'attr'), False) +import warnings + def test_init(): # SF 1155938 class Foo(object): def __init__(self): return 10 + + oldfilters = warnings.filters + warnings.filterwarnings("error", category=RuntimeWarning) try: Foo() - except TypeError: + except RuntimeWarning: pass else: raise TestFailed, "did not test __init__() for None return" + warnings.filters = oldfilters def test_main(): From rhettinger at users.sourceforge.net Fri Mar 4 05:47:06 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Mar 4 05:47:12 2005 Subject: [Python-checkins] python/dist/src/Objects typeobject.c, 2.264.2.1, 2.264.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6375/Objects Modified Files: Tag: release24-maint typeobject.c Log Message: Convert "__init__ should return None" from an exception to a warning. Index: typeobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v retrieving revision 2.264.2.1 retrieving revision 2.264.2.2 diff -u -d -r2.264.2.1 -r2.264.2.2 --- typeobject.c 3 Mar 2005 16:55:48 -0000 2.264.2.1 +++ typeobject.c 4 Mar 2005 04:47:03 -0000 2.264.2.2 @@ -4754,10 +4754,11 @@ if (res == NULL) return -1; if (res != Py_None) { - PyErr_SetString(PyExc_TypeError, - "__init__() should return None"); - Py_DECREF(res); - return -1; + if (PyErr_Warn(PyExc_RuntimeWarning, + "__init__() should return None") == -1) { + Py_DECREF(res); + return -1; + } } Py_DECREF(res); return 0; From loewis at users.sourceforge.net Fri Mar 4 14:50:20 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Mar 4 14:50:24 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1262,1.1263 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10541/Misc Modified Files: NEWS Log Message: Patch #1075887: Don't require MSVC in distutils if there is nothing to build. Will backport to 2.4 Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1262 retrieving revision 1.1263 diff -u -d -r1.1262 -r1.1263 --- NEWS 3 Mar 2005 23:12:32 -0000 1.1262 +++ NEWS 4 Mar 2005 13:50:17 -0000 1.1263 @@ -72,6 +72,9 @@ Library ------- +- Patch #1075887: Don't require MSVC in distutils if there is nothing + to build. + - Patch #1103407: Properly deal with tarfile iterators when untarring symbolic links on Windows. From loewis at users.sourceforge.net Fri Mar 4 14:50:20 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Mar 4 14:50:25 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils msvccompiler.py, 1.64, 1.65 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10541/Lib/distutils Modified Files: msvccompiler.py Log Message: Patch #1075887: Don't require MSVC in distutils if there is nothing to build. Will backport to 2.4 Index: msvccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/msvccompiler.py,v retrieving revision 1.64 retrieving revision 1.65 diff -u -d -r1.64 -r1.65 --- msvccompiler.py 28 Nov 2004 01:10:01 -0000 1.64 +++ msvccompiler.py 4 Mar 2005 13:50:16 -0000 1.65 @@ -211,6 +211,9 @@ self.__macros = MacroExpander(self.__version) else: self.__root = r"Software\Microsoft\Devstudio" + self.initialized = False + + def initialize(self): self.__paths = self.get_msvc_paths("path") if len (self.__paths) == 0: @@ -290,6 +293,7 @@ output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, extra_postargs=None, depends=None): + if not self.initialized: self.initialize() macros, objects, extra_postargs, pp_opts, build = \ self._setup_compile(output_dir, macros, include_dirs, sources, depends, extra_postargs) @@ -381,6 +385,7 @@ debug=0, target_lang=None): + if not self.initialized: self.initialize() (objects, output_dir) = self._fix_object_args (objects, output_dir) output_filename = \ self.library_filename (output_libname, output_dir=output_dir) @@ -414,6 +419,7 @@ build_temp=None, target_lang=None): + if not self.initialized: self.initialize() (objects, output_dir) = self._fix_object_args (objects, output_dir) (libraries, library_dirs, runtime_library_dirs) = \ self._fix_lib_args (libraries, library_dirs, runtime_library_dirs) From loewis at users.sourceforge.net Fri Mar 4 14:51:57 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Mar 4 14:52:00 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils msvccompiler.py, 1.64, 1.64.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11092/Lib/distutils Modified Files: Tag: release24-maint msvccompiler.py Log Message: Patch #1075887: Don't require MSVC in distutils if there is nothing to build. Will backport to 2.4 Index: msvccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/msvccompiler.py,v retrieving revision 1.64 retrieving revision 1.64.2.1 diff -u -d -r1.64 -r1.64.2.1 --- msvccompiler.py 28 Nov 2004 01:10:01 -0000 1.64 +++ msvccompiler.py 4 Mar 2005 13:51:55 -0000 1.64.2.1 @@ -211,6 +211,9 @@ self.__macros = MacroExpander(self.__version) else: self.__root = r"Software\Microsoft\Devstudio" + self.initialized = False + + def initialize(self): self.__paths = self.get_msvc_paths("path") if len (self.__paths) == 0: @@ -290,6 +293,7 @@ output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, extra_postargs=None, depends=None): + if not self.initialized: self.initialize() macros, objects, extra_postargs, pp_opts, build = \ self._setup_compile(output_dir, macros, include_dirs, sources, depends, extra_postargs) @@ -381,6 +385,7 @@ debug=0, target_lang=None): + if not self.initialized: self.initialize() (objects, output_dir) = self._fix_object_args (objects, output_dir) output_filename = \ self.library_filename (output_libname, output_dir=output_dir) @@ -414,6 +419,7 @@ build_temp=None, target_lang=None): + if not self.initialized: self.initialize() (objects, output_dir) = self._fix_object_args (objects, output_dir) (libraries, library_dirs, runtime_library_dirs) = \ self._fix_lib_args (libraries, library_dirs, runtime_library_dirs) From loewis at users.sourceforge.net Fri Mar 4 14:51:59 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Mar 4 14:52:02 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.29, 1.1193.2.30 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11092/Misc Modified Files: Tag: release24-maint NEWS Log Message: Patch #1075887: Don't require MSVC in distutils if there is nothing to build. Will backport to 2.4 Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.29 retrieving revision 1.1193.2.30 diff -u -d -r1.1193.2.29 -r1.1193.2.30 --- NEWS 3 Mar 2005 23:15:04 -0000 1.1193.2.29 +++ NEWS 4 Mar 2005 13:51:55 -0000 1.1193.2.30 @@ -40,6 +40,9 @@ Library ------- +- Patch #1075887: Don't require MSVC in distutils if there is nothing + to build. + - Patch #1103407: Properly deal with tarfile iterators when untarring symbolic links on Windows. From mwh at users.sourceforge.net Fri Mar 4 15:33:35 2005 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Fri Mar 4 15:33:39 2005 Subject: [Python-checkins] python/dist/src/Doc/ref ref4.tex, 1.37, 1.38 ref7.tex, 1.42, 1.43 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23191 Modified Files: ref4.tex ref7.tex Log Message: Updates to the exceptions documentation (this is my patch #1156102). Index: ref4.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref4.tex,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- ref4.tex 11 Dec 2003 19:45:53 -0000 1.37 +++ ref4.tex 4 Mar 2005 14:33:32 -0000 1.38 @@ -182,16 +182,20 @@ \exception{SystemExit}\withsubitem{(built-in exception)}{\ttindex{SystemExit}}. -Exceptions are identified by class instances. -Selection of a matching except clause is based on object identity. -The \keyword{except} clause must reference the same class or a base -class of it. +Exceptions are identified by class instances. The \keyword{except} +clause is selected depending on the class of the instance: it must +reference the class of the instance or a base class thereof. The +instance can be received by the handler and can carry additional +information about the exceptional condition. -When an exception is raised, an object (maybe \code{None}) is passed -as the exception's \emph{value}; this object does not affect the -selection of an exception handler, but is passed to the selected -exception handler as additional information. For class exceptions, -this object must be an instance of the exception class being raised. +Exceptions can also be identified by strings, in which case the +\keyword{except} clause is selected by object identity. An arbitrary +value can be raised along with the identifying string which can be +passed to the handler. + +\deprecated{2.5}{String exceptions should not be used in new code. +They will not be supported in a future version of Python. Old code +should be rewritten to use class exceptions instead.} \begin{notice}[warning] Messages to exceptions are not part of the Python API. Their contents may Index: ref7.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref7.tex,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- ref7.tex 2 Nov 2004 19:18:20 -0000 1.42 +++ ref7.tex 4 Mar 2005 14:33:32 -0000 1.43 @@ -223,11 +223,11 @@ except clause with an expression, that expression is evaluated, and the clause matches the exception if the resulting object is ``compatible'' with the exception. An object is compatible with an exception if it -is either the object that identifies the exception, or (for exceptions -that are classes) it is a base class of the exception, or it is a -tuple containing an item that is compatible with the exception. Note -that the object identities must match, i.e. it must be the same -object, not just an object with the same value. +is the class or a base class of the exception object, a tuple +containing an item compatible with the exception, or, in the +(deprecated) case of string exceptions, is the raised string itself +(note that the object identities must match, i.e. it must be the same +string object, not just a string with the same value). \kwindex{except} If no except clause matches the exception, the search for an exception @@ -239,14 +239,14 @@ on the call stack (it is treated as if the entire \keyword{try} statement raised the exception). -When a matching except clause is found, the exception's parameter is -assigned to the target specified in that except clause, if present, -and the except clause's suite is executed. All except clauses must -have an executable block. When the end of this block -is reached, execution continues normally after the entire try -statement. (This means that if two nested handlers exist for the same -exception, and the exception occurs in the try clause of the inner -handler, the outer handler will not handle the exception.) +When a matching except clause is found, the exception is assigned to +the target specified in that except clause, if present, and the except +clause's suite is executed. All except clauses must have an +executable block. When the end of this block is reached, execution +continues normally after the entire try statement. (This means that +if two nested handlers exist for the same exception, and the exception +occurs in the try clause of the inner handler, the outer handler will +not handle the exception.) Before an except clause's suite is executed, details about the exception are assigned to three variables in the From loewis at users.sourceforge.net Fri Mar 4 15:37:03 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Mar 4 15:37:07 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1263,1.1264 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24249/Misc Modified Files: NEWS Log Message: Patches #925152, #1118602: Avoid reading after the end of the buffer in pyexpat.GetInputContext. Will backport to 2.4. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1263 retrieving revision 1.1264 diff -u -d -r1.1263 -r1.1264 --- NEWS 4 Mar 2005 13:50:17 -0000 1.1263 +++ NEWS 4 Mar 2005 14:37:00 -0000 1.1264 @@ -44,6 +44,9 @@ Extension Modules ----------------- +- Patches #925152, #1118602: Avoid reading after the end of the buffer + in pyexpat.GetInputContext. + - Patches #749830, #1144555: allow UNIX mmap size to default to current file size. From loewis at users.sourceforge.net Fri Mar 4 15:37:04 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Mar 4 15:37:07 2005 Subject: [Python-checkins] python/dist/src/Modules pyexpat.c,2.89,2.90 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24249/Modules Modified Files: pyexpat.c Log Message: Patches #925152, #1118602: Avoid reading after the end of the buffer in pyexpat.GetInputContext. Will backport to 2.4. Index: pyexpat.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/pyexpat.c,v retrieving revision 2.89 retrieving revision 2.90 diff -u -d -r2.89 -r2.90 --- pyexpat.c 13 Oct 2004 19:50:11 -0000 2.89 +++ pyexpat.c 4 Mar 2005 14:37:01 -0000 2.90 @@ -1082,7 +1082,7 @@ = XML_GetInputContext(self->itself, &offset, &size); if (buffer != NULL) - result = PyString_FromStringAndSize(buffer + offset, size); + result = PyString_FromStringAndSize(buffer + offset, size - offset); else { result = Py_None; Py_INCREF(result); From loewis at users.sourceforge.net Fri Mar 4 15:38:10 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Mar 4 15:38:13 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.30, 1.1193.2.31 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24523/Misc Modified Files: Tag: release24-maint NEWS Log Message: Patches #925152, #1118602: Avoid reading after the end of the buffer in pyexpat.GetInputContext. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.30 retrieving revision 1.1193.2.31 diff -u -d -r1.1193.2.30 -r1.1193.2.31 --- NEWS 4 Mar 2005 13:51:55 -0000 1.1193.2.30 +++ NEWS 4 Mar 2005 14:38:06 -0000 1.1193.2.31 @@ -33,6 +33,9 @@ Extension Modules ----------------- +- Patches #925152, #1118602: Avoid reading after the end of the buffer + in pyexpat.GetInputContext. + - Patch #1093585: raise a ValueError for negative history items in readline. {remove_history,replace_history} From loewis at users.sourceforge.net Fri Mar 4 15:38:25 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Mar 4 15:38:29 2005 Subject: [Python-checkins] python/dist/src/Modules pyexpat.c,2.89,2.89.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24523/Modules Modified Files: Tag: release24-maint pyexpat.c Log Message: Patches #925152, #1118602: Avoid reading after the end of the buffer in pyexpat.GetInputContext. Index: pyexpat.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/pyexpat.c,v retrieving revision 2.89 retrieving revision 2.89.2.1 diff -u -d -r2.89 -r2.89.2.1 --- pyexpat.c 13 Oct 2004 19:50:11 -0000 2.89 +++ pyexpat.c 4 Mar 2005 14:38:07 -0000 2.89.2.1 @@ -1082,7 +1082,7 @@ = XML_GetInputContext(self->itself, &offset, &size); if (buffer != NULL) - result = PyString_FromStringAndSize(buffer + offset, size); + result = PyString_FromStringAndSize(buffer + offset, size - offset); else { result = Py_None; Py_INCREF(result); From loewis at users.sourceforge.net Fri Mar 4 20:40:37 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Mar 4 20:40:41 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libtarfile.tex,1.7,1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22139/Doc/lib Modified Files: libtarfile.tex Log Message: Patch #1043890: tarfile: add extractall() method. Index: libtarfile.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libtarfile.tex,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- libtarfile.tex 11 Sep 2004 16:50:05 -0000 1.7 +++ libtarfile.tex 4 Mar 2005 19:40:34 -0000 1.8 @@ -196,12 +196,29 @@ more available. \end{methoddesc} +\begin{methoddesc}{extractall}{\optional{path\optional{, members}}} + Extract all members from the archive to the current working directory + or directory \var{path}. If optional \var{members} is given, it must be + a subset of the list returned by \method{getmembers()}. + Directory informations like owner, modification time and permissions are + set after all members have been extracted. This is done to work around two + problems: A directory's modification time is reset each time a file is + created in it. And, if a directory's permissions do not allow writing, + extracting files to it will fail. + \versionadded{2.5} +\end{methoddesc} + \begin{methoddesc}{extract}{member\optional{, path}} Extract a member from the archive to the current working directory, using its full name. Its file information is extracted as accurately as possible. \var{member} may be a filename or a \class{TarInfo} object. You can specify a different directory using \var{path}. + \begin{notice} + Because the \method{extract()} method allows random access to a tar + archive there are some issues you must take care of yourself. See the + description for \method{extractall()} above. + \end{notice} \end{methoddesc} \begin{methoddesc}{extractfile}{member} @@ -416,6 +433,14 @@ \subsection{Examples \label{tar-examples}} +How to extract an entire tar archive to the current working directory: +\begin{verbatim} +import tarfile +tar = tarfile.open("sample.tar.gz") +tar.extractall() +tar.close() +\end{verbatim} + How to create an uncompressed tar archive from a list of filenames: \begin{verbatim} import tarfile From loewis at users.sourceforge.net Fri Mar 4 20:40:37 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Mar 4 20:40:42 2005 Subject: [Python-checkins] python/dist/src/Lib tarfile.py,1.25,1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22139/Lib Modified Files: tarfile.py Log Message: Patch #1043890: tarfile: add extractall() method. Index: tarfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tarfile.py,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- tarfile.py 3 Mar 2005 23:12:42 -0000 1.25 +++ tarfile.py 4 Mar 2005 19:40:34 -0000 1.26 @@ -1321,6 +1321,47 @@ self.members.append(tarinfo) + def extractall(self, path=".", members=None): + """Extract all members from the archive to the current working + directory and set owner, modification time and permissions on + directories afterwards. `path' specifies a different directory + to extract to. `members' is optional and must be a subset of the + list returned by getmembers(). + """ + directories = [] + + if members is None: + members = self + + for tarinfo in members: + if tarinfo.isdir(): + # Extract directory with a safe mode, so that + # all files below can be extracted as well. + try: + os.makedirs(os.path.join(path, tarinfo.name), 0777) + except EnvironmentError: + pass + directories.append(tarinfo) + else: + self.extract(tarinfo, path) + + # Reverse sort directories. + directories.sort(lambda a, b: cmp(a.name, b.name)) + directories.reverse() + + # Set correct owner, mtime and filemode on directories. + for tarinfo in directories: + path = os.path.join(path, tarinfo.name) + try: + self.chown(tarinfo, path) + self.utime(tarinfo, path) + self.chmod(tarinfo, path) + except ExtractError, e: + if self.errorlevel > 1: + raise + else: + self._dbg(1, "tarfile: %s" % e) + def extract(self, member, path=""): """Extract a member from the archive to the current working directory, using its full name. Its file information is extracted as accurately From loewis at users.sourceforge.net Fri Mar 4 20:40:38 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Mar 4 20:40:42 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1264,1.1265 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22139/Misc Modified Files: NEWS Log Message: Patch #1043890: tarfile: add extractall() method. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1264 retrieving revision 1.1265 diff -u -d -r1.1264 -r1.1265 --- NEWS 4 Mar 2005 14:37:00 -0000 1.1264 +++ NEWS 4 Mar 2005 19:40:34 -0000 1.1265 @@ -75,6 +75,8 @@ Library ------- +- Patch #1043890: Add extractall method to tarfile. + - Patch #1075887: Don't require MSVC in distutils if there is nothing to build. From loewis at users.sourceforge.net Fri Mar 4 20:40:38 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Fri Mar 4 20:40:43 2005 Subject: [Python-checkins] python/dist/src/Python import.c,2.240,2.241 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22139/Python Modified Files: import.c Log Message: Patch #1043890: tarfile: add extractall() method. Index: import.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/import.c,v retrieving revision 2.240 retrieving revision 2.241 diff -u -d -r2.240 -r2.241 --- import.c 7 Oct 2004 06:46:25 -0000 2.240 +++ import.c 4 Mar 2005 19:40:35 -0000 2.241 @@ -898,9 +898,9 @@ /* Forward */ -static PyObject *load_module(char *, FILE *, char *, int, PyObject *); +static PyObject *load_module(char *, FILE *, PyObject *, int, PyObject *); static struct filedescr *find_module(char *, char *, PyObject *, - char *, size_t, FILE **, PyObject **); + PyObject **, FILE **, PyObject **); static struct _frozen *find_frozen(char *name); /* Load a package and return its module object WITH INCREMENTED [...1000 lines suppressed...] fob, pathname, fdp->suffix, fdp->mode, fdp->type); + Py_XDECREF(fname); Py_DECREF(fob); return ret; } @@ -2691,7 +2699,13 @@ if (fp == NULL) return NULL; } - return load_module(name, fp, pathname, type, NULL); + { + PyObject *result; + PyObject *fname = PyString_FromString(pathname); + result = load_module(name, fp, fname, type, NULL); + Py_DECREF(fname); + return result; + } } static PyObject * From gward at users.sourceforge.net Sat Mar 5 03:38:35 2005 From: gward at users.sourceforge.net (gward@users.sourceforge.net) Date: Sat Mar 5 03:38:39 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_textwrap.py, 1.27, 1.27.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9623/Lib/test Modified Files: Tag: release24-maint test_textwrap.py Log Message: SF #1149508: ensure textwrap handles hyphenated numbers correctly, eg. "2004-03-04" is not broken across lines. Index: test_textwrap.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_textwrap.py,v retrieving revision 1.27 retrieving revision 1.27.4.1 diff -u -d -r1.27 -r1.27.4.1 --- test_textwrap.py 8 Jul 2004 04:22:19 -0000 1.27 +++ test_textwrap.py 5 Mar 2005 02:38:33 -0000 1.27.4.1 @@ -165,6 +165,24 @@ ["this-is-a-useful-feature-for-reformatting-", "posts-from-tim-peters'ly"]) + def test_hyphenated_numbers(self): + # Test that hyphenated numbers (eg. dates) are not broken like words. + text = ("Python 1.0.0 was released on 1994-01-26. Python 1.0.1 was\n" + "released on 1994-02-15.") + + self.check_wrap(text, 30, ['Python 1.0.0 was released on', + '1994-01-26. Python 1.0.1 was', + 'released on 1994-02-15.']) + self.check_wrap(text, 40, ['Python 1.0.0 was released on 1994-01-26.', + 'Python 1.0.1 was released on 1994-02-15.']) + + text = "I do all my shopping at 7-11." + self.check_wrap(text, 25, ["I do all my shopping at", + "7-11."]) + self.check_wrap(text, 27, ["I do all my shopping at", + "7-11."]) + self.check_wrap(text, 29, ["I do all my shopping at 7-11."]) + def test_em_dash(self): # Test text with em-dashes text = "Em-dashes should be written -- thus." From gward at users.sourceforge.net Sat Mar 5 03:38:35 2005 From: gward at users.sourceforge.net (gward@users.sourceforge.net) Date: Sat Mar 5 03:38:40 2005 Subject: [Python-checkins] python/dist/src/Lib textwrap.py,1.35,1.35.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9623/Lib Modified Files: Tag: release24-maint textwrap.py Log Message: SF #1149508: ensure textwrap handles hyphenated numbers correctly, eg. "2004-03-04" is not broken across lines. Index: textwrap.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/textwrap.py,v retrieving revision 1.35 retrieving revision 1.35.4.1 diff -u -d -r1.35 -r1.35.4.1 --- textwrap.py 3 Jun 2004 01:59:40 -0000 1.35 +++ textwrap.py 5 Mar 2005 02:38:32 -0000 1.35.4.1 @@ -78,9 +78,10 @@ # splits into # Hello/ /there/ /--/ /you/ /goof-/ball,/ /use/ /the/ /-b/ /option! # (after stripping out empty strings). - wordsep_re = re.compile(r'(\s+|' # any whitespace - r'[^\s\w]*\w{2,}-(?=\w{2,})|' # hyphenated words - r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))') # em-dash + wordsep_re = re.compile( + r'(\s+|' # any whitespace + r'[^\s\w]*\w+[a-zA-Z]-(?=\w+[a-zA-Z])|' # hyphenated words + r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))') # em-dash # XXX this is not locale- or charset-aware -- string.lowercase # is US-ASCII only (and therefore English-only) From gward at users.sourceforge.net Sat Mar 5 03:48:08 2005 From: gward at users.sourceforge.net (gward@users.sourceforge.net) Date: Sat Mar 5 03:48:12 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.31, 1.1193.2.32 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11407 Modified Files: Tag: release24-maint NEWS Log Message: Mention SF #1149508 (textwrap and hyphenated numbers). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.31 retrieving revision 1.1193.2.32 diff -u -d -r1.1193.2.31 -r1.1193.2.32 --- NEWS 4 Mar 2005 14:38:06 -0000 1.1193.2.31 +++ NEWS 5 Mar 2005 02:48:03 -0000 1.1193.2.32 @@ -89,6 +89,10 @@ - Bug #1083110: ``zlib.decompress.flush()`` would segfault if called immediately after creating the object, without any intervening ``.decompress()`` calls. +- Bug #1149508: ``textwrap`` now handles hyphenated numbers (eg. "2004-03-05") + correctly. + + Build ----- From gward at users.sourceforge.net Sat Mar 5 03:53:19 2005 From: gward at users.sourceforge.net (gward@users.sourceforge.net) Date: Sat Mar 5 03:53:22 2005 Subject: [Python-checkins] python/dist/src/Lib textwrap.py,1.36,1.37 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12862/Lib Modified Files: textwrap.py Log Message: SF #1149508: ensure textwrap handles hyphenated numbers correctly, eg. "2004-03-04" is not broken across lines. (Merged from 2.4 branch.) Index: textwrap.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/textwrap.py,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- textwrap.py 3 Jan 2005 07:14:12 -0000 1.36 +++ textwrap.py 5 Mar 2005 02:53:16 -0000 1.37 @@ -78,9 +78,10 @@ # splits into # Hello/ /there/ /--/ /you/ /goof-/ball,/ /use/ /the/ /-b/ /option! # (after stripping out empty strings). - wordsep_re = re.compile(r'(\s+|' # any whitespace - r'[^\s\w]*\w{2,}-(?=\w{2,})|' # hyphenated words - r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))') # em-dash + wordsep_re = re.compile( + r'(\s+|' # any whitespace + r'[^\s\w]*\w+[a-zA-Z]-(?=\w+[a-zA-Z])|' # hyphenated words + r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))') # em-dash # XXX this is not locale- or charset-aware -- string.lowercase # is US-ASCII only (and therefore English-only) From gward at users.sourceforge.net Sat Mar 5 03:53:20 2005 From: gward at users.sourceforge.net (gward@users.sourceforge.net) Date: Sat Mar 5 03:53:22 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_textwrap.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-serv12862/Lib/test Modified Files: test_textwrap.py Log Message: SF #1149508: ensure textwrap handles hyphenated numbers correctly, eg. "2004-03-04" is not broken across lines. (Merged from 2.4 branch.) Index: test_textwrap.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_textwrap.py,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- test_textwrap.py 8 Jul 2004 04:22:19 -0000 1.27 +++ test_textwrap.py 5 Mar 2005 02:53:17 -0000 1.28 @@ -165,6 +165,24 @@ ["this-is-a-useful-feature-for-reformatting-", "posts-from-tim-peters'ly"]) + def test_hyphenated_numbers(self): + # Test that hyphenated numbers (eg. dates) are not broken like words. + text = ("Python 1.0.0 was released on 1994-01-26. Python 1.0.1 was\n" + "released on 1994-02-15.") + + self.check_wrap(text, 30, ['Python 1.0.0 was released on', + '1994-01-26. Python 1.0.1 was', + 'released on 1994-02-15.']) + self.check_wrap(text, 40, ['Python 1.0.0 was released on 1994-01-26.', + 'Python 1.0.1 was released on 1994-02-15.']) + + text = "I do all my shopping at 7-11." + self.check_wrap(text, 25, ["I do all my shopping at", + "7-11."]) + self.check_wrap(text, 27, ["I do all my shopping at", + "7-11."]) + self.check_wrap(text, 29, ["I do all my shopping at 7-11."]) + def test_em_dash(self): # Test text with em-dashes text = "Em-dashes should be written -- thus." From gward at users.sourceforge.net Sat Mar 5 03:53:20 2005 From: gward at users.sourceforge.net (gward@users.sourceforge.net) Date: Sat Mar 5 03:53:25 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1265,1.1266 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12862/Misc Modified Files: NEWS Log Message: SF #1149508: ensure textwrap handles hyphenated numbers correctly, eg. "2004-03-04" is not broken across lines. (Merged from 2.4 branch.) Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1265 retrieving revision 1.1266 diff -u -d -r1.1265 -r1.1266 --- NEWS 4 Mar 2005 19:40:34 -0000 1.1265 +++ NEWS 5 Mar 2005 02:53:17 -0000 1.1266 @@ -206,6 +206,10 @@ - ``UserString.MutableString`` now supports negative indices in ``__setitem__`` and ``__delitem__`` +- Bug #1149508: ``textwrap`` now handles hyphenated numbers (eg. "2004-03-05") + correctly. + + Build ----- From bcannon at users.sourceforge.net Sat Mar 5 06:28:47 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Mar 5 06:28:53 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils msvccompiler.py, 1.65, 1.66 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13945/Lib/distutils Modified Files: msvccompiler.py Log Message: Remove a tab so that whitespace usage is consistent. Index: msvccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/msvccompiler.py,v retrieving revision 1.65 retrieving revision 1.66 diff -u -d -r1.65 -r1.66 --- msvccompiler.py 4 Mar 2005 13:50:16 -0000 1.65 +++ msvccompiler.py 5 Mar 2005 05:28:45 -0000 1.66 @@ -293,7 +293,7 @@ output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, extra_postargs=None, depends=None): - if not self.initialized: self.initialize() + if not self.initialized: self.initialize() macros, objects, extra_postargs, pp_opts, build = \ self._setup_compile(output_dir, macros, include_dirs, sources, depends, extra_postargs) From bcannon at users.sourceforge.net Sat Mar 5 06:32:16 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Mar 5 06:32:20 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils msvccompiler.py, 1.66, 1.67 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14856/Lib/distutils Modified Files: msvccompiler.py Log Message: Remove some more tab usage to prevent an error when run as ``python -tt``. Index: msvccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/msvccompiler.py,v retrieving revision 1.66 retrieving revision 1.67 diff -u -d -r1.66 -r1.67 --- msvccompiler.py 5 Mar 2005 05:28:45 -0000 1.66 +++ msvccompiler.py 5 Mar 2005 05:32:14 -0000 1.67 @@ -385,7 +385,7 @@ debug=0, target_lang=None): - if not self.initialized: self.initialize() + if not self.initialized: self.initialize() (objects, output_dir) = self._fix_object_args (objects, output_dir) output_filename = \ self.library_filename (output_libname, output_dir=output_dir) @@ -419,7 +419,7 @@ build_temp=None, target_lang=None): - if not self.initialized: self.initialize() + if not self.initialized: self.initialize() (objects, output_dir) = self._fix_object_args (objects, output_dir) (libraries, library_dirs, runtime_library_dirs) = \ self._fix_lib_args (libraries, library_dirs, runtime_library_dirs) From bcannon at users.sourceforge.net Sat Mar 5 06:52:24 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Mar 5 06:52:35 2005 Subject: [Python-checkins] python/dist/src/Misc vimrc,1.4,1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18803/Misc Modified Files: vimrc Log Message: Add a highlight group for denoting bad whitespace. Also added a match rule for leading tabs in a line when in Python mode. Also fixed some grammatical errors in the comments. Index: vimrc =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/vimrc,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- vimrc 6 Nov 2004 19:56:45 -0000 1.4 +++ vimrc 5 Mar 2005 05:52:21 -0000 1.5 @@ -9,12 +9,11 @@ " " All setting are protected by 'au' ('autocmd') statements. Only files ending " in .py or .pyw will trigger the Python settings while files ending in *.c or -" *.h will trigger the C settings. This make the file "safe" in terms of only +" *.h will trigger the C settings. This makes the file "safe" in terms of only " adjusting settings for Python and C files. " " Only basic settings needed to enforce the style guidelines are set. " Some suggested options are listed but commented out at the end of this file. -" " Number of spaces to use for an indent. @@ -39,6 +38,12 @@ au BufRead,BufNewFile *.c,*.h set noexpandtab au BufRead,BufNewFile Makefile* set noexpandtab +" Use the below highlight group when displaying bad whitespace is desired +highlight BadWhitespace ctermbg=red guibg=red + +" Display tabs at the beginning of a line in Python mode as bad +au BufRead,BufNewFile *.py,*.pyw match BadWhitespace /^\t\+/ + " Wrap text after a certain number of characters " Python: 79 " C: 79 @@ -67,7 +72,7 @@ " Set the default file encoding to UTF-8: ``set encoding=utf-8`` -" Put a marker at the beginning of the file to differentiate between UTF and +" Puts a marker at the beginning of the file to differentiate between UTF and " UCS encoding (WARNING: can trick shells into thinking a text file is actually " a binary file when executing the text file): ``set bomb`` @@ -79,9 +84,11 @@ " Folding based on indentation: ``set foldmethod=indent`` -" Make trailing whitespace explicit: -"highlight WhitespaceEOL ctermbg=red guibg=red -"match WhitespaceEOL /\s\+$/ -" or -"set list listchars=trail:- +" Make trailing whitespace explicit (left off since this will automatically +" insert the highlight or characters *as you type*, which can get annoying): +"``match BadWhitespace /\s\+$/`` +" +" or, for a non-colored, character-based solution: +" +"``set list listchars=trail:-`` From bcannon at users.sourceforge.net Sat Mar 5 07:40:55 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Mar 5 07:40:58 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_subprocess.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-serv28634/Lib/test Modified Files: test_subprocess.py Log Message: Tweak test_communicate_stderr so that it works when run under a pydebug build. Index: test_subprocess.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_subprocess.py,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- test_subprocess.py 3 Mar 2005 20:47:37 -0000 1.19 +++ test_subprocess.py 5 Mar 2005 06:40:52 -0000 1.20 @@ -269,7 +269,9 @@ stderr=subprocess.PIPE) (stdout, stderr) = p.communicate() self.assertEqual(stdout, None) - self.assertEqual(stderr, "pineapple") + # When running with a pydebug build, the # of references is outputted + # to stderr, so just check if stderr at least started with "pinapple" + self.assert_(stderr.startswith("pineapple")) def test_communicate(self): p = subprocess.Popen([sys.executable, "-c", From bcannon at users.sourceforge.net Sat Mar 5 07:47:58 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Mar 5 07:48:04 2005 Subject: [Python-checkins] python/dist/src/Grammar Grammar,1.52,1.53 Message-ID: Update of /cvsroot/python/python/dist/src/Grammar In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30194/Grammar Modified Files: Grammar Log Message: Allow classes to be defined with empty parentheses. This means that ``class C(): pass`` is no longer a syntax error. Index: Grammar =================================================================== RCS file: /cvsroot/python/python/dist/src/Grammar/Grammar,v retrieving revision 1.52 retrieving revision 1.53 diff -u -d -r1.52 -r1.53 --- Grammar 31 Aug 2004 10:07:00 -0000 1.52 +++ Grammar 5 Mar 2005 06:47:56 -0000 1.53 @@ -99,7 +99,7 @@ testlist_safe: test [(',' test)+ [',']] dictmaker: test ':' test (',' test ':' test)* [','] -classdef: 'class' NAME ['(' testlist ')'] ':' suite +classdef: 'class' NAME ['(' [testlist] ')'] ':' suite arglist: (argument ',')* (argument [',']| '*' test [',' '**' test] | '**' test) argument: [test '='] test [gen_for] # Really [keyword '='] test From bcannon at users.sourceforge.net Sat Mar 5 07:47:59 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Mar 5 07:48:04 2005 Subject: [Python-checkins] python/dist/src/Python graminit.c, 2.38, 2.39 compile.c, 2.348, 2.349 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30194/Python Modified Files: graminit.c compile.c Log Message: Allow classes to be defined with empty parentheses. This means that ``class C(): pass`` is no longer a syntax error. Index: graminit.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/graminit.c,v retrieving revision 2.38 retrieving revision 2.39 diff -u -d -r2.38 -r2.39 --- graminit.c 31 Aug 2004 10:07:13 -0000 2.38 +++ graminit.c 5 Mar 2005 06:47:56 -0000 2.39 @@ -1426,26 +1426,27 @@ {13, 3}, {21, 4}, }; -static arc arcs_67_3[1] = { +static arc arcs_67_3[2] = { {9, 5}, + {15, 6}, }; static arc arcs_67_4[1] = { - {22, 6}, + {22, 7}, }; static arc arcs_67_5[1] = { - {15, 7}, + {15, 6}, }; static arc arcs_67_6[1] = { - {0, 6}, + {21, 4}, }; static arc arcs_67_7[1] = { - {21, 4}, + {0, 7}, }; static state states_67[8] = { {1, arcs_67_0}, {1, arcs_67_1}, {2, arcs_67_2}, - {1, arcs_67_3}, + {2, arcs_67_3}, {1, arcs_67_4}, {1, arcs_67_5}, {1, arcs_67_6}, Index: compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.348 retrieving revision 2.349 diff -u -d -r2.348 -r2.349 --- compile.c 3 Mar 2005 07:01:48 -0000 2.348 +++ compile.c 5 Mar 2005 06:47:57 -0000 2.349 @@ -4624,7 +4624,7 @@ char *name; REQ(n, classdef); - /* classdef: class NAME ['(' testlist ')'] ':' suite */ + /* classdef: class NAME ['(' [testlist] ')'] ':' suite */ if ((v = PyString_InternFromString(STR(CHILD(n, 1)))) == NULL) { c->c_errors++; return; @@ -4635,7 +4635,8 @@ com_push(c, 1); Py_DECREF(v); /* Push the tuple of base classes on the stack */ - if (TYPE(CHILD(n, 2)) != LPAR) { + if (TYPE(CHILD(n, 2)) != LPAR || + TYPE(CHILD(n, 3)) == RPAR) { com_addoparg(c, BUILD_TUPLE, 0); com_push(c, 1); } From bcannon at users.sourceforge.net Sat Mar 5 07:48:00 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Mar 5 07:48:05 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1266,1.1267 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30194/Misc Modified Files: NEWS Log Message: Allow classes to be defined with empty parentheses. This means that ``class C(): pass`` is no longer a syntax error. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1266 retrieving revision 1.1267 diff -u -d -r1.1266 -r1.1267 --- NEWS 5 Mar 2005 02:53:17 -0000 1.1266 +++ NEWS 5 Mar 2005 06:47:57 -0000 1.1267 @@ -10,6 +10,9 @@ Core and builtins ----------------- +- Defining a class with empty parentheses is now allowed + (e.g., ``class C(): pass`` is no longer a syntax error) + - Patch #1115086: Support PY_LONGLONG in structmember. - Bug #1155938: new style classes did not check that __init__() was From loewis at users.sourceforge.net Sat Mar 5 13:47:44 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sat Mar 5 13:47:49 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libtarfile.tex,1.8,1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9777/Doc/lib Modified Files: libtarfile.tex Log Message: Patch #918101: Add tarfile open mode r|* for auto-detection of the stream compression; add, for symmetry reasons, r:* as a synonym of r. Index: libtarfile.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libtarfile.tex,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- libtarfile.tex 4 Mar 2005 19:40:34 -0000 1.8 +++ libtarfile.tex 5 Mar 2005 12:47:41 -0000 1.9 @@ -32,7 +32,7 @@ it defaults to \code{'r'}. Here is a full list of mode combinations: \begin{tableii}{c|l}{code}{mode}{action} - \lineii{'r'}{Open for reading with transparent compression (recommended).} + \lineii{'r' or 'r:*'}{Open for reading with transparent compression (recommended).} \lineii{'r:'}{Open for reading exclusively without compression.} \lineii{'r:gz'}{Open for reading with gzip compression.} \lineii{'r:bz2'}{Open for reading with bzip2 compression.} @@ -65,6 +65,7 @@ (section~\ref{tar-examples}). The currently possible modes: \begin{tableii}{c|l}{code}{Mode}{Action} + \lineii{'r|*'}{Open a \emph{stream} of tar blocks for reading with transparent compression.} \lineii{'r|'}{Open a \emph{stream} of uncompressed tar blocks for reading.} \lineii{'r|gz'}{Open a gzip compressed \emph{stream} for reading.} \lineii{'r|bz2'}{Open a bzip2 compressed \emph{stream} for reading.} From loewis at users.sourceforge.net Sat Mar 5 13:47:44 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sat Mar 5 13:47:49 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_tarfile.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-serv9777/Lib/test Modified Files: test_tarfile.py Log Message: Patch #918101: Add tarfile open mode r|* for auto-detection of the stream compression; add, for symmetry reasons, r:* as a synonym of r. Index: test_tarfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_tarfile.py,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- test_tarfile.py 3 Mar 2005 08:17:33 -0000 1.17 +++ test_tarfile.py 5 Mar 2005 12:47:42 -0000 1.18 @@ -181,6 +181,18 @@ stream.close() +class ReadAsteriskTest(ReadTest): + + def setUp(self): + mode = self.mode + self.sep + "*" + self.tar = tarfile.open(tarname(self.comp), mode) + +class ReadStreamAsteriskTest(ReadStreamTest): + + def setUp(self): + mode = self.mode + self.sep + "*" + self.tar = tarfile.open(tarname(self.comp), mode) + class WriteTest(BaseTest): mode = 'w' @@ -336,6 +348,11 @@ comp = "gz" class WriteStreamTestGzip(WriteStreamTest): comp = "gz" +class ReadAsteriskTestGzip(ReadAsteriskTest): + comp = "gz" +class ReadStreamAsteriskTestGzip(ReadStreamAsteriskTest): + comp = "gz" + # Filemode test cases @@ -355,6 +372,10 @@ comp = "bz2" class WriteStreamTestBzip2(WriteStreamTestGzip): comp = "bz2" + class ReadAsteriskTestBzip2(ReadAsteriskTest): + comp = "bz2" + class ReadStreamAsteriskTestBzip2(ReadStreamAsteriskTest): + comp = "bz2" # If importing gzip failed, discard the Gzip TestCases. if not gzip: @@ -375,6 +396,8 @@ FileModeTest, ReadTest, ReadStreamTest, + ReadAsteriskTest, + ReadStreamAsteriskTest, WriteTest, WriteStreamTest, WriteGNULongTest, @@ -386,13 +409,15 @@ if gzip: tests.extend([ ReadTestGzip, ReadStreamTestGzip, - WriteTestGzip, WriteStreamTestGzip + WriteTestGzip, WriteStreamTestGzip, + ReadAsteriskTestGzip, ReadStreamAsteriskTestGzip ]) if bz2: tests.extend([ ReadTestBzip2, ReadStreamTestBzip2, - WriteTestBzip2, WriteStreamTestBzip2 + WriteTestBzip2, WriteStreamTestBzip2, + ReadAsteriskTestBzip2, ReadStreamAsteriskTestBzip2 ]) try: test_support.run_unittest(*tests) From loewis at users.sourceforge.net Sat Mar 5 13:47:46 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sat Mar 5 13:47:50 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1267,1.1268 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9777/Misc Modified Files: NEWS Log Message: Patch #918101: Add tarfile open mode r|* for auto-detection of the stream compression; add, for symmetry reasons, r:* as a synonym of r. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1267 retrieving revision 1.1268 diff -u -d -r1.1267 -r1.1268 --- NEWS 5 Mar 2005 06:47:57 -0000 1.1267 +++ NEWS 5 Mar 2005 12:47:42 -0000 1.1268 @@ -78,6 +78,9 @@ Library ------- +- Patch #918101: Add tarfile open mode r|* for auto-detection of the + stream compression; add, for symmetry reasons, r:* as a synonym of r. + - Patch #1043890: Add extractall method to tarfile. - Patch #1075887: Don't require MSVC in distutils if there is nothing From loewis at users.sourceforge.net Sat Mar 5 13:47:44 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sat Mar 5 13:47:51 2005 Subject: [Python-checkins] python/dist/src/Lib tarfile.py,1.26,1.27 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9777/Lib Modified Files: tarfile.py Log Message: Patch #918101: Add tarfile open mode r|* for auto-detection of the stream compression; add, for symmetry reasons, r:* as a synonym of r. Index: tarfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tarfile.py,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- tarfile.py 4 Mar 2005 19:40:34 -0000 1.26 +++ tarfile.py 5 Mar 2005 12:47:42 -0000 1.27 @@ -274,7 +274,7 @@ _Stream is intended to be used only internally. """ - def __init__(self, name, mode, type, fileobj, bufsize): + def __init__(self, name, mode, comptype, fileobj, bufsize): """Construct a _Stream object. """ self._extfileobj = True @@ -282,16 +282,22 @@ fileobj = _LowLevelFile(name, mode) self._extfileobj = False - self.name = name or "" - self.mode = mode - self.type = type - self.fileobj = fileobj - self.bufsize = bufsize - self.buf = "" - self.pos = 0L - self.closed = False + if comptype == '*': + # Enable transparent compression detection for the + # stream interface + fileobj = _StreamProxy(fileobj) + comptype = fileobj.getcomptype() - if type == "gz": + self.name = name or "" + self.mode = mode + self.comptype = comptype + self.fileobj = fileobj + self.bufsize = bufsize + self.buf = "" + self.pos = 0L + self.closed = False + + if comptype == "gz": try: import zlib except ImportError: @@ -303,7 +309,7 @@ else: self._init_write_gz() - if type == "bz2": + if comptype == "bz2": try: import bz2 except ImportError: @@ -315,7 +321,7 @@ self.cmp = bz2.BZ2Compressor() def __del__(self): - if not self.closed: + if hasattr(self, "closed") and not self.closed: self.close() def _init_write_gz(self): @@ -334,10 +340,10 @@ def write(self, s): """Write string s to the stream. """ - if self.type == "gz": + if self.comptype == "gz": self.crc = self.zlib.crc32(s, self.crc) self.pos += len(s) - if self.type != "tar": + if self.comptype != "tar": s = self.cmp.compress(s) self.__write(s) @@ -357,12 +363,16 @@ if self.closed: return - if self.mode == "w" and self.type != "tar": + if self.mode == "w" and self.comptype != "tar": self.buf += self.cmp.flush() + if self.mode == "w" and self.buf: + blocks, remainder = divmod(len(self.buf), self.bufsize) + if remainder > 0: + self.buf += NUL * (self.bufsize - remainder) self.fileobj.write(self.buf) self.buf = "" - if self.type == "gz": + if self.comptype == "gz": self.fileobj.write(struct.pack(" Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8174 Modified Files: pep-3000.txt Log Message: Make some very minor changes for consistency. Index: pep-3000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-3000.txt,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- pep-3000.txt 22 Jan 2005 04:39:23 -0000 1.10 +++ pep-3000.txt 5 Mar 2005 19:32:57 -0000 1.11 @@ -84,9 +84,7 @@ Built-ins ========= -Changes: - -* make ``range()`` return an iterator +* Make ``range()`` return an iterator * Relevant functions should consume iterators (e.g. ``min()``, ``max()``) From bcannon at users.sourceforge.net Sat Mar 5 20:38:45 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Mar 5 20:38:47 2005 Subject: [Python-checkins] python/nondist/peps pep-3000.txt,1.11,1.12 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9499 Modified Files: pep-3000.txt Log Message: Add mention of trunc() and its companion, __trunc__(). Index: pep-3000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-3000.txt,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- pep-3000.txt 5 Mar 2005 19:32:57 -0000 1.11 +++ pep-3000.txt 5 Mar 2005 19:38:42 -0000 1.12 @@ -87,6 +87,9 @@ * Make ``range()`` return an iterator * Relevant functions should consume iterators (e.g. ``min()``, ``max()``) +* Introduce ``trunc()``, which would call the ``__trunc__()`` method on its + argument; suggested use if for objects like float where calling ``__int__()`` + has data loss, but an integral representation is still desired [8]_ To be removed: @@ -140,6 +143,10 @@ .. [7] python-dev email ("Let's get rid of unbound methods") http://mail.python.org/pipermail/python-dev/2005-January/050625.html +.. [8] python-dev email( "Fixing _PyEval_SliceIndex so that integer-like + objects can be used") + http://mail.python.org/pipermail/python-dev/2005-February/051674.html + Copyright ========= From gward at users.sourceforge.net Mon Mar 7 02:10:51 2005 From: gward at users.sourceforge.net (gward@users.sourceforge.net) Date: Mon Mar 7 02:10:55 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_descr.py, 1.202.2.2, 1.202.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20221/Lib/test Modified Files: Tag: release24-maint test_descr.py Log Message: Ensure that warnings.filters is properly restored after fiddling with it (this was breaking test_warnings). Index: test_descr.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v retrieving revision 1.202.2.2 retrieving revision 1.202.2.3 diff -u -d -r1.202.2.2 -r1.202.2.3 --- test_descr.py 4 Mar 2005 04:47:04 -0000 1.202.2.2 +++ test_descr.py 7 Mar 2005 01:10:33 -0000 1.202.2.3 @@ -3973,15 +3973,18 @@ def __init__(self): return 10 - oldfilters = warnings.filters - warnings.filterwarnings("error", category=RuntimeWarning) + oldfilters = warnings.filters[:] try: - Foo() - except RuntimeWarning: pass - else: - raise TestFailed, "did not test __init__() for None return" - warnings.filters = oldfilters + warnings.filterwarnings("error", category=RuntimeWarning) + try: + Foo() + except RuntimeWarning: + pass + else: + raise TestFailed, "did not test __init__() for None return" + finally: + warnings.filters = oldfilters def test_main(): From gward at users.sourceforge.net Mon Mar 7 02:32:05 2005 From: gward at users.sourceforge.net (gward@users.sourceforge.net) Date: Mon Mar 7 02:32:10 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_ossaudiodev.py, 1.8, 1.8.10.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25666/Lib/test Modified Files: Tag: release24-maint test_ossaudiodev.py Log Message: SF #818006: add useful read-only attributes to oss_audio_device object: 'closed', 'name', and 'mode' (as recommended by http://python.org/doc/current/lib/bltin-file-objects.html). Index: test_ossaudiodev.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_ossaudiodev.py,v retrieving revision 1.8 retrieving revision 1.8.10.1 diff -u -d -r1.8 -r1.8.10.1 --- test_ossaudiodev.py 2 Jul 2003 14:05:08 -0000 1.8 +++ test_ossaudiodev.py 7 Mar 2005 01:32:02 -0000 1.8.10.1 @@ -56,6 +56,19 @@ dsp.getptr() dsp.fileno() + # Make sure the read-only attributes work. + assert dsp.closed is False, "dsp.closed is not False" + assert dsp.name == "/dev/dsp" + assert dsp.mode == 'w', "bad dsp.mode: %r" % dsp.mode + + # And make sure they're really read-only. + for attr in ('closed', 'name', 'mode'): + try: + setattr(dsp, attr, 42) + raise RuntimeError("dsp.%s not read-only" % attr) + except TypeError: + pass + # set parameters based on .au file headers dsp.setparameters(AFMT_S16_NE, nchannels, rate) t1 = time.time() @@ -65,9 +78,7 @@ t2 = time.time() print "elapsed time: %.1f sec" % (t2-t1) -def test_setparameters(): - dsp = ossaudiodev.open("w") - +def test_setparameters(dsp): # Two configurations for testing: # config1 (8-bit, mono, 8 kHz) should work on even the most # ancient and crufty sound card, but maybe not on special- @@ -96,11 +107,16 @@ assert result == (fmt, channels, rate), \ "setparameters%r: returned %r" % (config + result) +def test_bad_setparameters(dsp): + # Now try some configurations that are presumably bogus: eg. 300 # channels currently exceeds even Hollywood's ambitions, and # negative sampling rate is utter nonsense. setparameters() should # accept these in non-strict mode, returning something other than # was requested, but should barf in strict mode. + fmt = AFMT_S16_NE + rate = 44100 + channels = 2 for config in [(fmt, 300, rate), # ridiculous nchannels (fmt, -5, rate), # impossible nchannels (fmt, channels, -50), # impossible rate @@ -119,6 +135,16 @@ def test(): (data, rate, ssize, nchannels) = read_sound_file(findfile('audiotest.au')) play_sound_file(data, rate, ssize, nchannels) - test_setparameters() + + dsp = ossaudiodev.open("w") + try: + test_setparameters(dsp) + + # Disabled because it fails under Linux 2.6 with ALSA's OSS + # emulation layer. + #test_bad_setparameters(dsp) + finally: + dsp.close() + assert dsp.closed is True, "dsp.closed is not True" test() From gward at users.sourceforge.net Mon Mar 7 02:32:05 2005 From: gward at users.sourceforge.net (gward@users.sourceforge.net) Date: Mon Mar 7 02:32:10 2005 Subject: [Python-checkins] python/dist/src/Modules ossaudiodev.c, 1.35, 1.35.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25666/Modules Modified Files: Tag: release24-maint ossaudiodev.c Log Message: SF #818006: add useful read-only attributes to oss_audio_device object: 'closed', 'name', and 'mode' (as recommended by http://python.org/doc/current/lib/bltin-file-objects.html). Index: ossaudiodev.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/ossaudiodev.c,v retrieving revision 1.35 retrieving revision 1.35.4.1 diff -u -d -r1.35 -r1.35.4.1 --- ossaudiodev.c 11 May 2004 01:34:55 -0000 1.35 +++ ossaudiodev.c 7 Mar 2005 01:32:02 -0000 1.35.4.1 @@ -46,11 +46,12 @@ typedef struct { PyObject_HEAD; - int fd; /* The open file */ - int mode; /* file mode */ - int icount; /* Input count */ - int ocount; /* Output count */ - uint32_t afmts; /* Audio formats supported by hardware */ + char *devicename; /* name of the device file */ + int fd; /* file descriptor */ + int mode; /* file mode (O_RDONLY, etc.) */ + int icount; /* input count */ + int ocount; /* output count */ + uint32_t afmts; /* audio formats supported by hardware */ } oss_audio_t; typedef struct { @@ -74,7 +75,7 @@ { oss_audio_t *self; int fd, afmts, imode; - char *basedev = NULL; + char *devicename = NULL; char *mode = NULL; /* Two ways to call open(): @@ -82,11 +83,11 @@ open(mode) (for backwards compatibility) because the *first* argument is optional, parsing args is a wee bit tricky. */ - if (!PyArg_ParseTuple(arg, "s|s:open", &basedev, &mode)) + if (!PyArg_ParseTuple(arg, "s|s:open", &devicename, &mode)) return NULL; if (mode == NULL) { /* only one arg supplied */ - mode = basedev; - basedev = NULL; + mode = devicename; + devicename = NULL; } if (strcmp(mode, "r") == 0) @@ -102,18 +103,18 @@ /* Open the correct device: either the 'device' argument, or the AUDIODEV environment variable, or "/dev/dsp". */ - if (basedev == NULL) { /* called with one arg */ - basedev = getenv("AUDIODEV"); - if (basedev == NULL) /* $AUDIODEV not set */ - basedev = "/dev/dsp"; + if (devicename == NULL) { /* called with one arg */ + devicename = getenv("AUDIODEV"); + if (devicename == NULL) /* $AUDIODEV not set */ + devicename = "/dev/dsp"; } /* Open with O_NONBLOCK to avoid hanging on devices that only allow one open at a time. This does *not* affect later I/O; OSS provides a special ioctl() for non-blocking read/write, which is exposed via oss_nonblock() below. */ - if ((fd = open(basedev, imode|O_NONBLOCK)) == -1) { - PyErr_SetFromErrnoWithFilename(PyExc_IOError, basedev); + if ((fd = open(devicename, imode|O_NONBLOCK)) == -1) { + PyErr_SetFromErrnoWithFilename(PyExc_IOError, devicename); return NULL; } @@ -121,12 +122,12 @@ expected write() semantics. */ if (fcntl(fd, F_SETFL, 0) == -1) { close(fd); - PyErr_SetFromErrnoWithFilename(PyExc_IOError, basedev); + PyErr_SetFromErrnoWithFilename(PyExc_IOError, devicename); return NULL; } if (ioctl(fd, SNDCTL_DSP_GETFMTS, &afmts) == -1) { - PyErr_SetFromErrnoWithFilename(PyExc_IOError, basedev); + PyErr_SetFromErrnoWithFilename(PyExc_IOError, devicename); return NULL; } /* Create and initialize the object */ @@ -134,6 +135,7 @@ close(fd); return NULL; } + self->devicename = devicename; self->fd = fd; self->mode = imode; self->icount = self->ocount = 0; @@ -158,22 +160,22 @@ static oss_mixer_t * newossmixerobject(PyObject *arg) { - char *basedev = NULL; + char *devicename = NULL; int fd; oss_mixer_t *self; - if (!PyArg_ParseTuple(arg, "|s", &basedev)) { + if (!PyArg_ParseTuple(arg, "|s", &devicename)) { return NULL; } - if (basedev == NULL) { - basedev = getenv("MIXERDEV"); - if (basedev == NULL) /* MIXERDEV not set */ - basedev = "/dev/mixer"; + if (devicename == NULL) { + devicename = getenv("MIXERDEV"); + if (devicename == NULL) /* MIXERDEV not set */ + devicename = "/dev/mixer"; } - if ((fd = open(basedev, O_RDWR)) == -1) { - PyErr_SetFromErrnoWithFilename(PyExc_IOError, basedev); + if ((fd = open(devicename, O_RDWR)) == -1) { + PyErr_SetFromErrnoWithFilename(PyExc_IOError, devicename); return NULL; } @@ -827,7 +829,33 @@ static PyObject * oss_getattr(oss_audio_t *self, char *name) { - return Py_FindMethod(oss_methods, (PyObject *)self, name); + PyObject * rval = NULL; + if (strcmp(name, "closed") == 0) { + rval = (self->fd == -1) ? Py_True : Py_False; + Py_INCREF(rval); + } + else if (strcmp(name, "name") == 0) { + rval = PyString_FromString(self->devicename); + } + else if (strcmp(name, "mode") == 0) { + /* No need for a "default" in this switch: from newossobject(), + self->mode can only be one of these three values. */ + switch(self->mode) { + case O_RDONLY: + rval = PyString_FromString("r"); + break; + case O_RDWR: + rval = PyString_FromString("rw"); + break; + case O_WRONLY: + rval = PyString_FromString("w"); + break; + } + } + else { + rval = Py_FindMethod(oss_methods, (PyObject *)self, name); + } + return rval; } static PyObject * From gward at users.sourceforge.net Mon Mar 7 02:32:06 2005 From: gward at users.sourceforge.net (gward@users.sourceforge.net) Date: Mon Mar 7 02:32:12 2005 Subject: [Python-checkins] python/dist/src/Lib/test/output test_ossaudiodev, 1.2, 1.2.12.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25666/Lib/test/output Modified Files: Tag: release24-maint test_ossaudiodev Log Message: SF #818006: add useful read-only attributes to oss_audio_device object: 'closed', 'name', and 'mode' (as recommended by http://python.org/doc/current/lib/bltin-file-objects.html). Index: test_ossaudiodev =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_ossaudiodev,v retrieving revision 1.2 retrieving revision 1.2.12.1 diff -u -d -r1.2 -r1.2.12.1 --- test_ossaudiodev 29 May 2003 01:29:28 -0000 1.2 +++ test_ossaudiodev 7 Mar 2005 01:32:03 -0000 1.2.12.1 @@ -1,6 +1,3 @@ test_ossaudiodev playing test sound file... -elapsed time: 2.9 sec -setparameters: got OSSAudioError as expected -setparameters: got OSSAudioError as expected -setparameters: got OSSAudioError as expected +elapsed time: 3.1 sec From gward at users.sourceforge.net Mon Mar 7 02:32:06 2005 From: gward at users.sourceforge.net (gward@users.sourceforge.net) Date: Mon Mar 7 02:32:13 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libossaudiodev.tex, 1.12.4.1, 1.12.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25666/Doc/lib Modified Files: Tag: release24-maint libossaudiodev.tex Log Message: SF #818006: add useful read-only attributes to oss_audio_device object: 'closed', 'name', and 'mode' (as recommended by http://python.org/doc/current/lib/bltin-file-objects.html). Index: libossaudiodev.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libossaudiodev.tex,v retrieving revision 1.12.4.1 retrieving revision 1.12.4.2 diff -u -d -r1.12.4.1 -r1.12.4.2 --- libossaudiodev.tex 1 Jan 2005 00:34:53 -0000 1.12.4.1 +++ libossaudiodev.tex 7 Mar 2005 01:32:03 -0000 1.12.4.2 @@ -115,7 +115,7 @@ as flexible in all cases. The audio device objects returned by \function{open()} define the -following methods: +following methods and (read-only) attributes: \begin{methoddesc}[audio device]{close}{} Explicitly close the audio device. When you are done writing to or @@ -289,6 +289,21 @@ buffer to be played without blocking. \end{methoddesc} +Audio device objects also support several read-only attributes: + +\begin{memberdesc}[audio device]{closed}{} +Boolean indicating whether the device has been closed. +\end{memberdesc} + +\begin{memberdesc}[audio device]{name}{} +String containing the name of the device file. +\end{memberdesc} + +\begin{memberdesc}[audio device]{mode}{} +The I/O mode for the file, either \code{"r"}, \code{"rw"}, or \code{"w"}. +\end{memberdesc} + + \subsection{Mixer Device Objects \label{mixer-device-objects}} The mixer object provides two file-like methods: From gward at users.sourceforge.net Mon Mar 7 02:41:13 2005 From: gward at users.sourceforge.net (gward@users.sourceforge.net) Date: Mon Mar 7 02:41:17 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libossaudiodev.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-serv27811/Doc/lib Modified Files: libossaudiodev.tex Log Message: SF #818006: merge from release24-maint branch: add useful read-only attributes to oss_audio_device object: 'closed', 'name', and 'mode'. Index: libossaudiodev.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libossaudiodev.tex,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- libossaudiodev.tex 1 Jan 2005 00:28:37 -0000 1.13 +++ libossaudiodev.tex 7 Mar 2005 01:41:11 -0000 1.14 @@ -115,7 +115,7 @@ as flexible in all cases. The audio device objects returned by \function{open()} define the -following methods: +following methods and (read-only) attributes: \begin{methoddesc}[audio device]{close}{} Explicitly close the audio device. When you are done writing to or @@ -289,6 +289,21 @@ buffer to be played without blocking. \end{methoddesc} +Audio device objects also support several read-only attributes: + +\begin{memberdesc}[audio device]{closed}{} +Boolean indicating whether the device has been closed. +\end{memberdesc} + +\begin{memberdesc}[audio device]{name}{} +String containing the name of the device file. +\end{memberdesc} + +\begin{memberdesc}[audio device]{mode}{} +The I/O mode for the file, either \code{"r"}, \code{"rw"}, or \code{"w"}. +\end{memberdesc} + + \subsection{Mixer Device Objects \label{mixer-device-objects}} The mixer object provides two file-like methods: From gward at users.sourceforge.net Mon Mar 7 02:41:14 2005 From: gward at users.sourceforge.net (gward@users.sourceforge.net) Date: Mon Mar 7 02:41:19 2005 Subject: [Python-checkins] python/dist/src/Lib/test/output test_ossaudiodev, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test/output In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27811/Lib/test/output Modified Files: test_ossaudiodev Log Message: SF #818006: merge from release24-maint branch: add useful read-only attributes to oss_audio_device object: 'closed', 'name', and 'mode'. Index: test_ossaudiodev =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/output/test_ossaudiodev,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- test_ossaudiodev 29 May 2003 01:29:28 -0000 1.2 +++ test_ossaudiodev 7 Mar 2005 01:41:11 -0000 1.3 @@ -1,6 +1,3 @@ test_ossaudiodev playing test sound file... -elapsed time: 2.9 sec -setparameters: got OSSAudioError as expected -setparameters: got OSSAudioError as expected -setparameters: got OSSAudioError as expected +elapsed time: 3.1 sec From gward at users.sourceforge.net Mon Mar 7 02:41:42 2005 From: gward at users.sourceforge.net (gward@users.sourceforge.net) Date: Mon Mar 7 02:41:46 2005 Subject: [Python-checkins] python/dist/src/Modules ossaudiodev.c,1.35,1.36 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27811/Modules Modified Files: ossaudiodev.c Log Message: SF #818006: merge from release24-maint branch: add useful read-only attributes to oss_audio_device object: 'closed', 'name', and 'mode'. Index: ossaudiodev.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/ossaudiodev.c,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- ossaudiodev.c 11 May 2004 01:34:55 -0000 1.35 +++ ossaudiodev.c 7 Mar 2005 01:41:09 -0000 1.36 @@ -46,11 +46,12 @@ typedef struct { PyObject_HEAD; - int fd; /* The open file */ - int mode; /* file mode */ - int icount; /* Input count */ - int ocount; /* Output count */ - uint32_t afmts; /* Audio formats supported by hardware */ + char *devicename; /* name of the device file */ + int fd; /* file descriptor */ + int mode; /* file mode (O_RDONLY, etc.) */ + int icount; /* input count */ + int ocount; /* output count */ + uint32_t afmts; /* audio formats supported by hardware */ } oss_audio_t; typedef struct { @@ -74,7 +75,7 @@ { oss_audio_t *self; int fd, afmts, imode; - char *basedev = NULL; + char *devicename = NULL; char *mode = NULL; /* Two ways to call open(): @@ -82,11 +83,11 @@ open(mode) (for backwards compatibility) because the *first* argument is optional, parsing args is a wee bit tricky. */ - if (!PyArg_ParseTuple(arg, "s|s:open", &basedev, &mode)) + if (!PyArg_ParseTuple(arg, "s|s:open", &devicename, &mode)) return NULL; if (mode == NULL) { /* only one arg supplied */ - mode = basedev; - basedev = NULL; + mode = devicename; + devicename = NULL; } if (strcmp(mode, "r") == 0) @@ -102,18 +103,18 @@ /* Open the correct device: either the 'device' argument, or the AUDIODEV environment variable, or "/dev/dsp". */ - if (basedev == NULL) { /* called with one arg */ - basedev = getenv("AUDIODEV"); - if (basedev == NULL) /* $AUDIODEV not set */ - basedev = "/dev/dsp"; + if (devicename == NULL) { /* called with one arg */ + devicename = getenv("AUDIODEV"); + if (devicename == NULL) /* $AUDIODEV not set */ + devicename = "/dev/dsp"; } /* Open with O_NONBLOCK to avoid hanging on devices that only allow one open at a time. This does *not* affect later I/O; OSS provides a special ioctl() for non-blocking read/write, which is exposed via oss_nonblock() below. */ - if ((fd = open(basedev, imode|O_NONBLOCK)) == -1) { - PyErr_SetFromErrnoWithFilename(PyExc_IOError, basedev); + if ((fd = open(devicename, imode|O_NONBLOCK)) == -1) { + PyErr_SetFromErrnoWithFilename(PyExc_IOError, devicename); return NULL; } @@ -121,12 +122,12 @@ expected write() semantics. */ if (fcntl(fd, F_SETFL, 0) == -1) { close(fd); - PyErr_SetFromErrnoWithFilename(PyExc_IOError, basedev); + PyErr_SetFromErrnoWithFilename(PyExc_IOError, devicename); return NULL; } if (ioctl(fd, SNDCTL_DSP_GETFMTS, &afmts) == -1) { - PyErr_SetFromErrnoWithFilename(PyExc_IOError, basedev); + PyErr_SetFromErrnoWithFilename(PyExc_IOError, devicename); return NULL; } /* Create and initialize the object */ @@ -134,6 +135,7 @@ close(fd); return NULL; } + self->devicename = devicename; self->fd = fd; self->mode = imode; self->icount = self->ocount = 0; @@ -158,22 +160,22 @@ static oss_mixer_t * newossmixerobject(PyObject *arg) { - char *basedev = NULL; + char *devicename = NULL; int fd; oss_mixer_t *self; - if (!PyArg_ParseTuple(arg, "|s", &basedev)) { + if (!PyArg_ParseTuple(arg, "|s", &devicename)) { return NULL; } - if (basedev == NULL) { - basedev = getenv("MIXERDEV"); - if (basedev == NULL) /* MIXERDEV not set */ - basedev = "/dev/mixer"; + if (devicename == NULL) { + devicename = getenv("MIXERDEV"); + if (devicename == NULL) /* MIXERDEV not set */ + devicename = "/dev/mixer"; } - if ((fd = open(basedev, O_RDWR)) == -1) { - PyErr_SetFromErrnoWithFilename(PyExc_IOError, basedev); + if ((fd = open(devicename, O_RDWR)) == -1) { + PyErr_SetFromErrnoWithFilename(PyExc_IOError, devicename); return NULL; } @@ -827,7 +829,33 @@ static PyObject * oss_getattr(oss_audio_t *self, char *name) { - return Py_FindMethod(oss_methods, (PyObject *)self, name); + PyObject * rval = NULL; + if (strcmp(name, "closed") == 0) { + rval = (self->fd == -1) ? Py_True : Py_False; + Py_INCREF(rval); + } + else if (strcmp(name, "name") == 0) { + rval = PyString_FromString(self->devicename); + } + else if (strcmp(name, "mode") == 0) { + /* No need for a "default" in this switch: from newossobject(), + self->mode can only be one of these three values. */ + switch(self->mode) { + case O_RDONLY: + rval = PyString_FromString("r"); + break; + case O_RDWR: + rval = PyString_FromString("rw"); + break; + case O_WRONLY: + rval = PyString_FromString("w"); + break; + } + } + else { + rval = Py_FindMethod(oss_methods, (PyObject *)self, name); + } + return rval; } static PyObject * From gward at users.sourceforge.net Mon Mar 7 02:41:43 2005 From: gward at users.sourceforge.net (gward@users.sourceforge.net) Date: Mon Mar 7 02:41:48 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_ossaudiodev.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-serv27811/Lib/test Modified Files: test_ossaudiodev.py Log Message: SF #818006: merge from release24-maint branch: add useful read-only attributes to oss_audio_device object: 'closed', 'name', and 'mode'. Index: test_ossaudiodev.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_ossaudiodev.py,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- test_ossaudiodev.py 2 Jul 2003 14:05:08 -0000 1.8 +++ test_ossaudiodev.py 7 Mar 2005 01:41:10 -0000 1.9 @@ -56,6 +56,19 @@ dsp.getptr() dsp.fileno() + # Make sure the read-only attributes work. + assert dsp.closed is False, "dsp.closed is not False" + assert dsp.name == "/dev/dsp" + assert dsp.mode == 'w', "bad dsp.mode: %r" % dsp.mode + + # And make sure they're really read-only. + for attr in ('closed', 'name', 'mode'): + try: + setattr(dsp, attr, 42) + raise RuntimeError("dsp.%s not read-only" % attr) + except TypeError: + pass + # set parameters based on .au file headers dsp.setparameters(AFMT_S16_NE, nchannels, rate) t1 = time.time() @@ -65,9 +78,7 @@ t2 = time.time() print "elapsed time: %.1f sec" % (t2-t1) -def test_setparameters(): - dsp = ossaudiodev.open("w") - +def test_setparameters(dsp): # Two configurations for testing: # config1 (8-bit, mono, 8 kHz) should work on even the most # ancient and crufty sound card, but maybe not on special- @@ -96,11 +107,16 @@ assert result == (fmt, channels, rate), \ "setparameters%r: returned %r" % (config + result) +def test_bad_setparameters(dsp): + # Now try some configurations that are presumably bogus: eg. 300 # channels currently exceeds even Hollywood's ambitions, and # negative sampling rate is utter nonsense. setparameters() should # accept these in non-strict mode, returning something other than # was requested, but should barf in strict mode. + fmt = AFMT_S16_NE + rate = 44100 + channels = 2 for config in [(fmt, 300, rate), # ridiculous nchannels (fmt, -5, rate), # impossible nchannels (fmt, channels, -50), # impossible rate @@ -119,6 +135,16 @@ def test(): (data, rate, ssize, nchannels) = read_sound_file(findfile('audiotest.au')) play_sound_file(data, rate, ssize, nchannels) - test_setparameters() + + dsp = ossaudiodev.open("w") + try: + test_setparameters(dsp) + + # Disabled because it fails under Linux 2.6 with ALSA's OSS + # emulation layer. + #test_bad_setparameters(dsp) + finally: + dsp.close() + assert dsp.closed is True, "dsp.closed is not True" test() From gward at users.sourceforge.net Tue Mar 8 02:08:46 2005 From: gward at users.sourceforge.net (gward@users.sourceforge.net) Date: Tue Mar 8 02:08:49 2005 Subject: [Python-checkins] python/dist/src/Doc/ref ref3.tex, 1.121.2.1, 1.121.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17476 Modified Files: Tag: release24-maint ref3.tex Log Message: SF #1156412: document the __new__() static method. Index: ref3.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref3.tex,v retrieving revision 1.121.2.1 retrieving revision 1.121.2.2 diff -u -d -r1.121.2.1 -r1.121.2.2 --- ref3.tex 1 Jan 2005 00:34:55 -0000 1.121.2.1 +++ ref3.tex 8 Mar 2005 01:08:42 -0000 1.121.2.2 @@ -1052,6 +1052,35 @@ \subsection{Basic customization\label{customization}} +\begin{methoddesc}[object]{__new__}{cls\optional{, \moreargs}} +Called to create a new instance of class \var{cls}. \method{__new__()} +is a static method (special-cased so you need not declare it as such) +that takes the class of which an instance was requested as its first +argument. The remaining arguments are those passed to the object +constructor expression (the call to the class). The return value of +\method{__new__()} should be the new object instance (usually an +instance of \var{cls}). + +Typical implementations create a new instance of the class by invoking +the superclass's \method{__new__()} method using +\samp{super(\var{currentclass}, \var{cls}).__new__(\var{cls}[, ...])} +with appropriate arguments and then modifying the newly-created instance +as necessary before returning it. + +If \method{__new__()} returns an instance of \var{cls}, then the new +instance's \method{__init__()} method will be invoked like +\samp{__init__(\var{self}[, ...])}, where \var{self} is the new instance +and the remaining arguments are the same as were passed to +\method{__new__()}. + +If \method{__new__()} does not return an instance of \var{cls}, then the +new instance's \method{__init__()} method will not be invoked. + +\method{__new__()} is intended mainly to allow subclasses of +immutable types (like int, str, or tuple) to customize instance +creation. +\end{methoddesc} + \begin{methoddesc}[object]{__init__}{self\optional{, \moreargs}} Called\indexii{class}{constructor} when the instance is created. The arguments are those passed to the class constructor expression. If a From gward at users.sourceforge.net Tue Mar 8 02:10:23 2005 From: gward at users.sourceforge.net (gward@users.sourceforge.net) Date: Tue Mar 8 02:10:26 2005 Subject: [Python-checkins] python/dist/src/Doc/ref ref3.tex,1.122,1.123 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/ref In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17807/ref Modified Files: ref3.tex Log Message: SF #1156412: document the __new__() static method (merge from release24-maint branch). Index: ref3.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref3.tex,v retrieving revision 1.122 retrieving revision 1.123 diff -u -d -r1.122 -r1.123 --- ref3.tex 1 Jan 2005 00:28:43 -0000 1.122 +++ ref3.tex 8 Mar 2005 01:10:20 -0000 1.123 @@ -1052,6 +1052,35 @@ \subsection{Basic customization\label{customization}} +\begin{methoddesc}[object]{__new__}{cls\optional{, \moreargs}} +Called to create a new instance of class \var{cls}. \method{__new__()} +is a static method (special-cased so you need not declare it as such) +that takes the class of which an instance was requested as its first +argument. The remaining arguments are those passed to the object +constructor expression (the call to the class). The return value of +\method{__new__()} should be the new object instance (usually an +instance of \var{cls}). + +Typical implementations create a new instance of the class by invoking +the superclass's \method{__new__()} method using +\samp{super(\var{currentclass}, \var{cls}).__new__(\var{cls}[, ...])} +with appropriate arguments and then modifying the newly-created instance +as necessary before returning it. + +If \method{__new__()} returns an instance of \var{cls}, then the new +instance's \method{__init__()} method will be invoked like +\samp{__init__(\var{self}[, ...])}, where \var{self} is the new instance +and the remaining arguments are the same as were passed to +\method{__new__()}. + +If \method{__new__()} does not return an instance of \var{cls}, then the +new instance's \method{__init__()} method will not be invoked. + +\method{__new__()} is intended mainly to allow subclasses of +immutable types (like int, str, or tuple) to customize instance +creation. +\end{methoddesc} + \begin{methoddesc}[object]{__init__}{self\optional{, \moreargs}} Called\indexii{class}{constructor} when the instance is created. The arguments are those passed to the class constructor expression. If a From rhettinger at users.sourceforge.net Tue Mar 8 07:14:53 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Mar 8 07:14:56 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_functional.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23159/Lib/test Modified Files: test_functional.py Log Message: Make functional.partial() more closely match the spec by emulating some useful features of regular functions: * Made weak referencable. * Allow attribute access so a user can set __name__, __doc__, etc. Index: test_functional.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_functional.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- test_functional.py 28 Feb 2005 19:39:23 -0000 1.1 +++ test_functional.py 8 Mar 2005 06:14:51 -0000 1.2 @@ -1,6 +1,7 @@ import functional import unittest from test import test_support +from weakref import proxy @staticmethod def PythonPartial(func, *args, **keywords): @@ -116,6 +117,22 @@ self.assertRaises(ZeroDivisionError, self.thetype(f), 1, 0) self.assertRaises(ZeroDivisionError, self.thetype(f, y=0), 1) + def test_attributes(self): + p = self.thetype(hex) + try: + del p.__dict__ + except TypeError: + pass + else: + self.fail('partial object allowed __dict__ to be deleted') + + def test_weakref(self): + f = self.thetype(int, base=16) + p = proxy(f) + self.assertEqual(f.func, p.func) + f = None + self.assertRaises(ReferenceError, getattr, p, 'func') + class PartialSubclass(functional.partial): pass From rhettinger at users.sourceforge.net Tue Mar 8 07:14:53 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Mar 8 07:14:57 2005 Subject: [Python-checkins] python/dist/src/Modules functionalmodule.c, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23159/Modules Modified Files: functionalmodule.c Log Message: Make functional.partial() more closely match the spec by emulating some useful features of regular functions: * Made weak referencable. * Allow attribute access so a user can set __name__, __doc__, etc. Index: functionalmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/functionalmodule.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- functionalmodule.c 28 Feb 2005 19:39:43 -0000 1.1 +++ functionalmodule.c 8 Mar 2005 06:14:51 -0000 1.2 @@ -16,6 +16,8 @@ PyObject *fn; PyObject *args; PyObject *kw; + PyObject *dict; + PyObject *weakreflist; /* List of weak references */ } partialobject; static PyTypeObject partial_type; @@ -63,6 +65,9 @@ Py_INCREF(Py_None); } + pto->weakreflist = NULL; + pto->dict = NULL; + return (PyObject *)pto; } @@ -70,9 +75,12 @@ partial_dealloc(partialobject *pto) { PyObject_GC_UnTrack(pto); + if (pto->weakreflist != NULL) + PyObject_ClearWeakRefs((PyObject *) pto); Py_XDECREF(pto->fn); Py_XDECREF(pto->args); Py_XDECREF(pto->kw); + Py_XDECREF(pto->dict); pto->ob_type->tp_free(pto); } @@ -128,6 +136,7 @@ Py_VISIT(pto->fn); Py_VISIT(pto->args); Py_VISIT(pto->kw); + Py_VISIT(pto->dict); return 0; } @@ -146,6 +155,47 @@ {NULL} /* Sentinel */ }; +static PyObject * +partial_get_dict(partialobject *pto) +{ + if (pto->dict == NULL) { + pto->dict = PyDict_New(); + if (pto->dict == NULL) + return NULL; + } + Py_INCREF(pto->dict); + return pto->dict; +} + +static int +partial_set_dict(partialobject *pto, PyObject *value) +{ + PyObject *tmp; + + /* It is illegal to del p.__dict__ */ + if (value == NULL) { + PyErr_SetString(PyExc_TypeError, + "a partial object's dictionary may not be deleted"); + return -1; + } + /* Can only set __dict__ to a dictionary */ + if (!PyDict_Check(value)) { + PyErr_SetString(PyExc_TypeError, + "setting partial object's dictionary to a non-dict"); + return -1; + } + tmp = pto->dict; + Py_INCREF(value); + pto->dict = value; + Py_XDECREF(tmp); + return 0; +} + +static PyGetSetDef partail_getsetlist[] = { + {"__dict__", (getter)partial_get_dict, (setter)partial_set_dict}, + {NULL} /* Sentinel */ +}; + static PyTypeObject partial_type = { PyObject_HEAD_INIT(NULL) 0, /* ob_size */ @@ -166,25 +216,25 @@ (ternaryfunc)partial_call, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ + PyObject_GenericSetAttr, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_BASETYPE, /* tp_flags */ + Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_WEAKREFS, /* tp_flags */ partial_doc, /* tp_doc */ (traverseproc)partial_traverse, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ + offsetof(partialobject, weakreflist), /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ partial_memberlist, /* tp_members */ - 0, /* tp_getset */ + partail_getsetlist, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ + offsetof(partialobject, dict), /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ partial_new, /* tp_new */ From rhettinger at users.sourceforge.net Tue Mar 8 08:15:41 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Mar 8 08:15:46 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libfunctional.tex, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2858 Modified Files: libfunctional.tex Log Message: Make functional.partial() more closely match the spec by emulating some useful features of regular functions: * Made weak referencable. * Allow attribute access so a user can set __name__, __doc__, etc. Index: libfunctional.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfunctional.tex,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- libfunctional.tex 2 Mar 2005 15:10:38 -0000 1.2 +++ libfunctional.tex 8 Mar 2005 07:15:36 -0000 1.3 @@ -44,6 +44,7 @@ two: \begin{verbatim} >>> basetwo = partial(int, base=2) + >>> basetwo.__doc__('Convert base 2 string to an int.') >>> basetwo('10010') 18 \end{verbatim} @@ -71,3 +72,10 @@ The keyword arguments that will be supplied when the \class{partial} object is called. \end{memberdesc} + +\class{partial} objects are like \class{function} objects in that they are +callable, weak referencable, and can have attributes. There are some +important differences. For instance, the \member{__name__} and +\member{__doc__} attributes are not created automatically. Also, +\class{partial} objects defined in classes behave like static methods and +do not transform into bound methods during instance attribute look-up. From loewis at users.sourceforge.net Tue Mar 8 10:10:34 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Mar 8 10:10:38 2005 Subject: [Python-checkins] python/dist/src/Modules posixmodule.c, 2.333, 2.334 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28182/Modules Modified Files: posixmodule.c Log Message: Convert file names of posix.access according to the file system encoding. Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.333 retrieving revision 2.334 diff -u -d -r2.333 -r2.334 --- posixmodule.c 31 Jan 2005 17:01:59 -0000 2.333 +++ posixmodule.c 8 Mar 2005 09:10:29 -0000 2.334 @@ -1113,7 +1113,8 @@ PyErr_Clear(); } #endif - if (!PyArg_ParseTuple(args, "si:access", &path, &mode)) + if (!PyArg_ParseTuple(args, "eti:access", + Py_FileSystemDefaultEncoding, &path, &mode)) return NULL; Py_BEGIN_ALLOW_THREADS res = access(path, mode); From loewis at users.sourceforge.net Tue Mar 8 10:10:33 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Mar 8 10:10:39 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_unicode_file.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-serv28182/Lib/test Modified Files: test_unicode_file.py Log Message: Convert file names of posix.access according to the file system encoding. Index: test_unicode_file.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode_file.py,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- test_unicode_file.py 7 Nov 2004 19:57:35 -0000 1.16 +++ test_unicode_file.py 8 Mar 2005 09:10:28 -0000 1.17 @@ -44,8 +44,10 @@ def _do_single(self, filename): self.failUnless(os.path.exists(filename)) self.failUnless(os.path.isfile(filename)) + self.failUnless(os.access(filename, os.R_OK)) self.failUnless(os.path.exists(os.path.abspath(filename))) self.failUnless(os.path.isfile(os.path.abspath(filename))) + self.failUnless(os.access(os.path.abspath(filename), os.R_OK)) os.chmod(filename, 0777) os.utime(filename, None) os.utime(filename, (time.time(), time.time())) From loewis at users.sourceforge.net Tue Mar 8 10:11:02 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Mar 8 10:11:06 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1268,1.1269 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28182/Misc Modified Files: NEWS Log Message: Convert file names of posix.access according to the file system encoding. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1268 retrieving revision 1.1269 diff -u -d -r1.1268 -r1.1269 --- NEWS 5 Mar 2005 12:47:42 -0000 1.1268 +++ NEWS 8 Mar 2005 09:10:12 -0000 1.1269 @@ -47,6 +47,8 @@ Extension Modules ----------------- +- os.access now supports Unicode path names on non-Win32 systems. + - Patches #925152, #1118602: Avoid reading after the end of the buffer in pyexpat.GetInputContext. From loewis at users.sourceforge.net Tue Mar 8 16:03:11 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Mar 8 16:03:16 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1269,1.1270 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25449/Misc Modified Files: NEWS Log Message: Build with --disable-unicode again. Fixes #1158607. Will backport to 2.4. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1269 retrieving revision 1.1270 diff -u -d -r1.1269 -r1.1270 --- NEWS 8 Mar 2005 09:10:12 -0000 1.1269 +++ NEWS 8 Mar 2005 15:03:01 -0000 1.1270 @@ -221,6 +221,8 @@ Build ----- +- Bug #1158607: Build with --disable-unicode again. + - spwdmodule.c is built only if either HAVE_GETSPNAM or HAVE_HAVE_GETSPENT is defined. Discovered as a result of not being able to build on OS X. From loewis at users.sourceforge.net Tue Mar 8 16:03:29 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Mar 8 16:03:33 2005 Subject: [Python-checkins] python/dist/src/Modules _codecsmodule.c, 2.20, 2.21 _tkinter.c, 1.168, 1.169 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25449/Modules Modified Files: _codecsmodule.c _tkinter.c Log Message: Build with --disable-unicode again. Fixes #1158607. Will backport to 2.4. Index: _codecsmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_codecsmodule.c,v retrieving revision 2.20 retrieving revision 2.21 diff -u -d -r2.20 -r2.21 --- _codecsmodule.c 7 Sep 2004 20:24:22 -0000 2.20 +++ _codecsmodule.c 8 Mar 2005 15:03:08 -0000 2.21 @@ -104,8 +104,15 @@ if (!PyArg_ParseTuple(args, "O|ss:encode", &v, &encoding, &errors)) return NULL; +#ifdef Py_USING_UNICODE if (encoding == NULL) encoding = PyUnicode_GetDefaultEncoding(); +#else + if (encoding == NULL) { + PyErr_SetString(PyExc_ValueError, "no encoding specified"); + return NULL; + } +#endif /* Encode via the codec registry */ v = PyCodec_Encode(v, encoding, errors); @@ -137,8 +144,15 @@ if (!PyArg_ParseTuple(args, "O|ss:decode", &v, &encoding, &errors)) return NULL; +#ifdef Py_USING_UNICODE if (encoding == NULL) encoding = PyUnicode_GetDefaultEncoding(); +#else + if (encoding == NULL) { + PyErr_SetString(PyExc_ValueError, "no encoding specified"); + return NULL; + } +#endif /* Decode via the codec registry */ v = PyCodec_Decode(v, encoding, errors); Index: _tkinter.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_tkinter.c,v retrieving revision 1.168 retrieving revision 1.169 diff -u -d -r1.168 -r1.169 --- _tkinter.c 13 Nov 2004 11:13:35 -0000 1.168 +++ _tkinter.c 8 Mar 2005 15:03:08 -0000 1.169 @@ -838,8 +838,10 @@ }; static PyMethodDef PyTclObject_methods[] = { +#ifdef Py_USING_UNICODE {"__unicode__", (PyCFunction)PyTclObject_unicode, METH_NOARGS, PyTclObject_unicode__doc__}, +#endif {0} }; @@ -991,7 +993,7 @@ } } #else - res = PyString_FromStringAndSize(value->bytes, value->length); + result = PyString_FromStringAndSize(value->bytes, value->length); #endif return result; } From loewis at users.sourceforge.net Tue Mar 8 16:03:31 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Mar 8 16:03:35 2005 Subject: [Python-checkins] python/dist/src setup.py,1.214,1.215 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25449 Modified Files: setup.py Log Message: Build with --disable-unicode again. Fixes #1158607. Will backport to 2.4. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.214 retrieving revision 1.215 diff -u -d -r1.214 -r1.215 --- setup.py 28 Feb 2005 19:39:22 -0000 1.214 +++ setup.py 8 Mar 2005 15:02:37 -0000 1.215 @@ -799,11 +799,12 @@ )) # Hye-Shik Chang's CJKCodecs modules. - exts.append(Extension('_multibytecodec', - ['cjkcodecs/multibytecodec.c'])) - for loc in ('kr', 'jp', 'cn', 'tw', 'hk', 'iso2022'): - exts.append(Extension('_codecs_' + loc, - ['cjkcodecs/_codecs_%s.c' % loc])) + if have_unicode: + exts.append(Extension('_multibytecodec', + ['cjkcodecs/multibytecodec.c'])) + for loc in ('kr', 'jp', 'cn', 'tw', 'hk', 'iso2022'): + exts.append(Extension('_codecs_' + loc, + ['cjkcodecs/_codecs_%s.c' % loc])) # Dynamic loading module if sys.maxint == 0x7fffffff: From loewis at users.sourceforge.net Tue Mar 8 16:03:32 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Mar 8 16:03:37 2005 Subject: [Python-checkins] python/dist/src/Lib codecs.py, 1.37, 1.38 copy.py, 1.44, 1.45 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25449/Lib Modified Files: codecs.py copy.py Log Message: Build with --disable-unicode again. Fixes #1158607. Will backport to 2.4. Index: codecs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/codecs.py,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- codecs.py 10 Jan 2005 12:01:38 -0000 1.37 +++ codecs.py 8 Mar 2005 15:02:58 -0000 1.38 @@ -720,11 +720,19 @@ ### error handlers -strict_errors = lookup_error("strict") -ignore_errors = lookup_error("ignore") -replace_errors = lookup_error("replace") -xmlcharrefreplace_errors = lookup_error("xmlcharrefreplace") -backslashreplace_errors = lookup_error("backslashreplace") +try: + strict_errors = lookup_error("strict") + ignore_errors = lookup_error("ignore") + replace_errors = lookup_error("replace") + xmlcharrefreplace_errors = lookup_error("xmlcharrefreplace") + backslashreplace_errors = lookup_error("backslashreplace") +except LookupError: + # In --disable-unicode builds, these error handler are missing + strict_errors = None + ignore_errors = None + replace_errors = None + xmlcharrefreplace_errors = None + backslashreplace_errors = None # Tell modulefinder that using codecs probably needs the encodings # package Index: copy.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/copy.py,v retrieving revision 1.44 retrieving revision 1.45 diff -u -d -r1.44 -r1.45 --- copy.py 7 Feb 2005 14:16:09 -0000 1.44 +++ copy.py 8 Mar 2005 15:02:59 -0000 1.45 @@ -202,12 +202,12 @@ d[bool] = _deepcopy_atomic try: d[complex] = _deepcopy_atomic -except AttributeError: +except NameError: pass d[str] = _deepcopy_atomic try: d[unicode] = _deepcopy_atomic -except AttributeError: +except NameError: pass try: d[types.CodeType] = _deepcopy_atomic From loewis at users.sourceforge.net Tue Mar 8 16:03:34 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Mar 8 16:03:38 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_support.py, 1.62, 1.63 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25449/Lib/test Modified Files: test_support.py Log Message: Build with --disable-unicode again. Fixes #1158607. Will backport to 2.4. Index: test_support.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_support.py,v retrieving revision 1.62 retrieving revision 1.63 diff -u -d -r1.62 -r1.63 --- test_support.py 18 Jan 2004 20:29:55 -0000 1.62 +++ test_support.py 8 Mar 2005 15:03:00 -0000 1.63 @@ -144,7 +144,7 @@ TESTFN_UNICODE_UNENCODEABLE = None else: # Japanese characters (I think - from bug 846133) - TESTFN_UNICODE_UNENCODEABLE = u"@test-\u5171\u6709\u3055\u308c\u308b" + TESTFN_UNICODE_UNENCODEABLE = eval('u"@test-\u5171\u6709\u3055\u308c\u308b"') try: # XXX - Note - should be using TESTFN_ENCODING here - but for # Windows, "mbcs" currently always operates as if in From loewis at users.sourceforge.net Tue Mar 8 16:05:19 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Mar 8 16:05:22 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_support.py, 1.62, 1.62.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26176/Lib/test Modified Files: Tag: release24-maint test_support.py Log Message: Build with --disable-unicode again. Fixes #1158607. Index: test_support.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_support.py,v retrieving revision 1.62 retrieving revision 1.62.4.1 diff -u -d -r1.62 -r1.62.4.1 --- test_support.py 18 Jan 2004 20:29:55 -0000 1.62 +++ test_support.py 8 Mar 2005 15:05:15 -0000 1.62.4.1 @@ -144,7 +144,7 @@ TESTFN_UNICODE_UNENCODEABLE = None else: # Japanese characters (I think - from bug 846133) - TESTFN_UNICODE_UNENCODEABLE = u"@test-\u5171\u6709\u3055\u308c\u308b" + TESTFN_UNICODE_UNENCODEABLE = eval('u"@test-\u5171\u6709\u3055\u308c\u308b"') try: # XXX - Note - should be using TESTFN_ENCODING here - but for # Windows, "mbcs" currently always operates as if in From loewis at users.sourceforge.net Tue Mar 8 16:05:21 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Mar 8 16:05:31 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.32, 1.1193.2.33 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26176/Misc Modified Files: Tag: release24-maint NEWS Log Message: Build with --disable-unicode again. Fixes #1158607. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.32 retrieving revision 1.1193.2.33 diff -u -d -r1.1193.2.32 -r1.1193.2.33 --- NEWS 5 Mar 2005 02:48:03 -0000 1.1193.2.32 +++ NEWS 8 Mar 2005 15:05:15 -0000 1.1193.2.33 @@ -96,6 +96,8 @@ Build ----- +- Bug #1158607: Build with --disable-unicode again. + - term.h is now properly detected again. - Check for tzset no longer dependent on tm->tm_zone to exist in the struct From loewis at users.sourceforge.net Tue Mar 8 16:05:25 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Mar 8 16:05:32 2005 Subject: [Python-checkins] python/dist/src/Modules _codecsmodule.c, 2.20, 2.20.2.1 _tkinter.c, 1.168, 1.168.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26176/Modules Modified Files: Tag: release24-maint _codecsmodule.c _tkinter.c Log Message: Build with --disable-unicode again. Fixes #1158607. Index: _codecsmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_codecsmodule.c,v retrieving revision 2.20 retrieving revision 2.20.2.1 diff -u -d -r2.20 -r2.20.2.1 --- _codecsmodule.c 7 Sep 2004 20:24:22 -0000 2.20 +++ _codecsmodule.c 8 Mar 2005 15:05:17 -0000 2.20.2.1 @@ -104,8 +104,15 @@ if (!PyArg_ParseTuple(args, "O|ss:encode", &v, &encoding, &errors)) return NULL; +#ifdef Py_USING_UNICODE if (encoding == NULL) encoding = PyUnicode_GetDefaultEncoding(); +#else + if (encoding == NULL) { + PyErr_SetString(PyExc_ValueError, "no encoding specified"); + return NULL; + } +#endif /* Encode via the codec registry */ v = PyCodec_Encode(v, encoding, errors); @@ -137,8 +144,15 @@ if (!PyArg_ParseTuple(args, "O|ss:decode", &v, &encoding, &errors)) return NULL; +#ifdef Py_USING_UNICODE if (encoding == NULL) encoding = PyUnicode_GetDefaultEncoding(); +#else + if (encoding == NULL) { + PyErr_SetString(PyExc_ValueError, "no encoding specified"); + return NULL; + } +#endif /* Decode via the codec registry */ v = PyCodec_Decode(v, encoding, errors); Index: _tkinter.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_tkinter.c,v retrieving revision 1.168 retrieving revision 1.168.2.1 diff -u -d -r1.168 -r1.168.2.1 --- _tkinter.c 13 Nov 2004 11:13:35 -0000 1.168 +++ _tkinter.c 8 Mar 2005 15:05:18 -0000 1.168.2.1 @@ -838,8 +838,10 @@ }; static PyMethodDef PyTclObject_methods[] = { +#ifdef Py_USING_UNICODE {"__unicode__", (PyCFunction)PyTclObject_unicode, METH_NOARGS, PyTclObject_unicode__doc__}, +#endif {0} }; @@ -991,7 +993,7 @@ } } #else - res = PyString_FromStringAndSize(value->bytes, value->length); + result = PyString_FromStringAndSize(value->bytes, value->length); #endif return result; } From loewis at users.sourceforge.net Tue Mar 8 16:05:47 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Mar 8 16:05:52 2005 Subject: [Python-checkins] python/dist/src/Lib codecs.py,1.35.2.2,1.35.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26176/Lib Modified Files: Tag: release24-maint codecs.py Log Message: Build with --disable-unicode again. Fixes #1158607. Index: codecs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/codecs.py,v retrieving revision 1.35.2.2 retrieving revision 1.35.2.3 diff -u -d -r1.35.2.2 -r1.35.2.3 --- codecs.py 10 Jan 2005 12:26:00 -0000 1.35.2.2 +++ codecs.py 8 Mar 2005 15:05:14 -0000 1.35.2.3 @@ -720,11 +720,19 @@ ### error handlers -strict_errors = lookup_error("strict") -ignore_errors = lookup_error("ignore") -replace_errors = lookup_error("replace") -xmlcharrefreplace_errors = lookup_error("xmlcharrefreplace") -backslashreplace_errors = lookup_error("backslashreplace") +try: + strict_errors = lookup_error("strict") + ignore_errors = lookup_error("ignore") + replace_errors = lookup_error("replace") + xmlcharrefreplace_errors = lookup_error("xmlcharrefreplace") + backslashreplace_errors = lookup_error("backslashreplace") +except LookupError: + # In --disable-unicode builds, these error handler are missing + strict_errors = None + ignore_errors = None + replace_errors = None + xmlcharrefreplace_errors = None + backslashreplace_errors = None # Tell modulefinder that using codecs probably needs the encodings # package From loewis at users.sourceforge.net Tue Mar 8 16:05:47 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Mar 8 16:05:53 2005 Subject: [Python-checkins] python/dist/src setup.py,1.204.2.1,1.204.2.2 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26176 Modified Files: Tag: release24-maint setup.py Log Message: Build with --disable-unicode again. Fixes #1158607. Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.204.2.1 retrieving revision 1.204.2.2 diff -u -d -r1.204.2.1 -r1.204.2.2 --- setup.py 19 Dec 2004 22:25:32 -0000 1.204.2.1 +++ setup.py 8 Mar 2005 15:05:14 -0000 1.204.2.2 @@ -770,11 +770,12 @@ )) # Hye-Shik Chang's CJKCodecs modules. - exts.append(Extension('_multibytecodec', - ['cjkcodecs/multibytecodec.c'])) - for loc in ('kr', 'jp', 'cn', 'tw', 'hk', 'iso2022'): - exts.append(Extension('_codecs_' + loc, - ['cjkcodecs/_codecs_%s.c' % loc])) + if have_unicode: + exts.append(Extension('_multibytecodec', + ['cjkcodecs/multibytecodec.c'])) + for loc in ('kr', 'jp', 'cn', 'tw', 'hk', 'iso2022'): + exts.append(Extension('_codecs_' + loc, + ['cjkcodecs/_codecs_%s.c' % loc])) # Dynamic loading module if sys.maxint == 0x7fffffff: From gward at users.sourceforge.net Wed Mar 9 01:55:21 2005 From: gward at users.sourceforge.net (gward@users.sourceforge.net) Date: Wed Mar 9 01:55:27 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_ossaudiodev.py, 1.8.10.1, 1.8.10.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24519/Lib/test Modified Files: Tag: release24-maint test_ossaudiodev.py Log Message: SF #818006: revert addition of 'closed', 'mode', and 'name' attributes to oss_audio_device objects. Index: test_ossaudiodev.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_ossaudiodev.py,v retrieving revision 1.8.10.1 retrieving revision 1.8.10.2 diff -u -d -r1.8.10.1 -r1.8.10.2 --- test_ossaudiodev.py 7 Mar 2005 01:32:02 -0000 1.8.10.1 +++ test_ossaudiodev.py 9 Mar 2005 00:55:18 -0000 1.8.10.2 @@ -56,19 +56,6 @@ dsp.getptr() dsp.fileno() - # Make sure the read-only attributes work. - assert dsp.closed is False, "dsp.closed is not False" - assert dsp.name == "/dev/dsp" - assert dsp.mode == 'w', "bad dsp.mode: %r" % dsp.mode - - # And make sure they're really read-only. - for attr in ('closed', 'name', 'mode'): - try: - setattr(dsp, attr, 42) - raise RuntimeError("dsp.%s not read-only" % attr) - except TypeError: - pass - # set parameters based on .au file headers dsp.setparameters(AFMT_S16_NE, nchannels, rate) t1 = time.time() @@ -145,6 +132,5 @@ #test_bad_setparameters(dsp) finally: dsp.close() - assert dsp.closed is True, "dsp.closed is not True" test() From gward at users.sourceforge.net Wed Mar 9 01:55:21 2005 From: gward at users.sourceforge.net (gward@users.sourceforge.net) Date: Wed Mar 9 01:55:27 2005 Subject: [Python-checkins] python/dist/src/Modules ossaudiodev.c, 1.35.4.1, 1.35.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24519/Modules Modified Files: Tag: release24-maint ossaudiodev.c Log Message: SF #818006: revert addition of 'closed', 'mode', and 'name' attributes to oss_audio_device objects. Index: ossaudiodev.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/ossaudiodev.c,v retrieving revision 1.35.4.1 retrieving revision 1.35.4.2 diff -u -d -r1.35.4.1 -r1.35.4.2 --- ossaudiodev.c 7 Mar 2005 01:32:02 -0000 1.35.4.1 +++ ossaudiodev.c 9 Mar 2005 00:55:18 -0000 1.35.4.2 @@ -46,12 +46,11 @@ typedef struct { PyObject_HEAD; - char *devicename; /* name of the device file */ - int fd; /* file descriptor */ - int mode; /* file mode (O_RDONLY, etc.) */ - int icount; /* input count */ - int ocount; /* output count */ - uint32_t afmts; /* audio formats supported by hardware */ + int fd; /* The open file */ + int mode; /* file mode */ + int icount; /* Input count */ + int ocount; /* Output count */ + uint32_t afmts; /* Audio formats supported by hardware */ } oss_audio_t; typedef struct { @@ -75,7 +74,7 @@ { oss_audio_t *self; int fd, afmts, imode; - char *devicename = NULL; + char *basedev = NULL; char *mode = NULL; /* Two ways to call open(): @@ -83,11 +82,11 @@ open(mode) (for backwards compatibility) because the *first* argument is optional, parsing args is a wee bit tricky. */ - if (!PyArg_ParseTuple(arg, "s|s:open", &devicename, &mode)) + if (!PyArg_ParseTuple(arg, "s|s:open", &basedev, &mode)) return NULL; if (mode == NULL) { /* only one arg supplied */ - mode = devicename; - devicename = NULL; + mode = basedev; + basedev = NULL; } if (strcmp(mode, "r") == 0) @@ -103,18 +102,18 @@ /* Open the correct device: either the 'device' argument, or the AUDIODEV environment variable, or "/dev/dsp". */ - if (devicename == NULL) { /* called with one arg */ - devicename = getenv("AUDIODEV"); - if (devicename == NULL) /* $AUDIODEV not set */ - devicename = "/dev/dsp"; + if (basedev == NULL) { /* called with one arg */ + basedev = getenv("AUDIODEV"); + if (basedev == NULL) /* $AUDIODEV not set */ + basedev = "/dev/dsp"; } /* Open with O_NONBLOCK to avoid hanging on devices that only allow one open at a time. This does *not* affect later I/O; OSS provides a special ioctl() for non-blocking read/write, which is exposed via oss_nonblock() below. */ - if ((fd = open(devicename, imode|O_NONBLOCK)) == -1) { - PyErr_SetFromErrnoWithFilename(PyExc_IOError, devicename); + if ((fd = open(basedev, imode|O_NONBLOCK)) == -1) { + PyErr_SetFromErrnoWithFilename(PyExc_IOError, basedev); return NULL; } @@ -122,12 +121,12 @@ expected write() semantics. */ if (fcntl(fd, F_SETFL, 0) == -1) { close(fd); - PyErr_SetFromErrnoWithFilename(PyExc_IOError, devicename); + PyErr_SetFromErrnoWithFilename(PyExc_IOError, basedev); return NULL; } if (ioctl(fd, SNDCTL_DSP_GETFMTS, &afmts) == -1) { - PyErr_SetFromErrnoWithFilename(PyExc_IOError, devicename); + PyErr_SetFromErrnoWithFilename(PyExc_IOError, basedev); return NULL; } /* Create and initialize the object */ @@ -135,7 +134,6 @@ close(fd); return NULL; } - self->devicename = devicename; self->fd = fd; self->mode = imode; self->icount = self->ocount = 0; @@ -160,22 +158,22 @@ static oss_mixer_t * newossmixerobject(PyObject *arg) { - char *devicename = NULL; + char *basedev = NULL; int fd; oss_mixer_t *self; - if (!PyArg_ParseTuple(arg, "|s", &devicename)) { + if (!PyArg_ParseTuple(arg, "|s", &basedev)) { return NULL; } - if (devicename == NULL) { - devicename = getenv("MIXERDEV"); - if (devicename == NULL) /* MIXERDEV not set */ - devicename = "/dev/mixer"; + if (basedev == NULL) { + basedev = getenv("MIXERDEV"); + if (basedev == NULL) /* MIXERDEV not set */ + basedev = "/dev/mixer"; } - if ((fd = open(devicename, O_RDWR)) == -1) { - PyErr_SetFromErrnoWithFilename(PyExc_IOError, devicename); + if ((fd = open(basedev, O_RDWR)) == -1) { + PyErr_SetFromErrnoWithFilename(PyExc_IOError, basedev); return NULL; } @@ -829,33 +827,7 @@ static PyObject * oss_getattr(oss_audio_t *self, char *name) { - PyObject * rval = NULL; - if (strcmp(name, "closed") == 0) { - rval = (self->fd == -1) ? Py_True : Py_False; - Py_INCREF(rval); - } - else if (strcmp(name, "name") == 0) { - rval = PyString_FromString(self->devicename); - } - else if (strcmp(name, "mode") == 0) { - /* No need for a "default" in this switch: from newossobject(), - self->mode can only be one of these three values. */ - switch(self->mode) { - case O_RDONLY: - rval = PyString_FromString("r"); - break; - case O_RDWR: - rval = PyString_FromString("rw"); - break; - case O_WRONLY: - rval = PyString_FromString("w"); - break; - } - } - else { - rval = Py_FindMethod(oss_methods, (PyObject *)self, name); - } - return rval; + return Py_FindMethod(oss_methods, (PyObject *)self, name); } static PyObject * From gward at users.sourceforge.net Wed Mar 9 01:55:39 2005 From: gward at users.sourceforge.net (gward@users.sourceforge.net) Date: Wed Mar 9 01:55:44 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libossaudiodev.tex, 1.12.4.2, 1.12.4.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24519/Doc/lib Modified Files: Tag: release24-maint libossaudiodev.tex Log Message: SF #818006: revert addition of 'closed', 'mode', and 'name' attributes to oss_audio_device objects. Index: libossaudiodev.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libossaudiodev.tex,v retrieving revision 1.12.4.2 retrieving revision 1.12.4.3 diff -u -d -r1.12.4.2 -r1.12.4.3 --- libossaudiodev.tex 7 Mar 2005 01:32:03 -0000 1.12.4.2 +++ libossaudiodev.tex 9 Mar 2005 00:55:19 -0000 1.12.4.3 @@ -115,7 +115,7 @@ as flexible in all cases. The audio device objects returned by \function{open()} define the -following methods and (read-only) attributes: +following methods: \begin{methoddesc}[audio device]{close}{} Explicitly close the audio device. When you are done writing to or @@ -289,21 +289,6 @@ buffer to be played without blocking. \end{methoddesc} -Audio device objects also support several read-only attributes: - -\begin{memberdesc}[audio device]{closed}{} -Boolean indicating whether the device has been closed. -\end{memberdesc} - -\begin{memberdesc}[audio device]{name}{} -String containing the name of the device file. -\end{memberdesc} - -\begin{memberdesc}[audio device]{mode}{} -The I/O mode for the file, either \code{"r"}, \code{"rw"}, or \code{"w"}. -\end{memberdesc} - - \subsection{Mixer Device Objects \label{mixer-device-objects}} The mixer object provides two file-like methods: From montanaro at users.sourceforge.net Wed Mar 9 03:57:35 2005 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Wed Mar 9 03:57:39 2005 Subject: [Python-checkins] python/dist/src/Doc/lib liburllib.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-serv24541 Modified Files: liburllib.tex Log Message: Correct description/example of how to override User-agent. Index: liburllib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liburllib.tex,v retrieving revision 1.54 retrieving revision 1.55 diff -u -d -r1.54 -r1.55 --- liburllib.tex 13 Jul 2004 14:03:31 -0000 1.54 +++ liburllib.tex 9 Mar 2005 02:57:26 -0000 1.55 @@ -160,8 +160,8 @@ import urllib class AppURLopener(urllib.FancyURLopener): + version = "App/1.7" def __init__(self, *args): - self.version = "App/1.7" urllib.FancyURLopener.__init__(self, *args) urllib._urlopener = AppURLopener() @@ -243,9 +243,9 @@ \mailheader{User-Agent} header of \samp{urllib/\var{VVV}}, where \var{VVV} is the \module{urllib} version number. Applications can define their own \mailheader{User-Agent} header by subclassing -\class{URLopener} or \class{FancyURLopener} and setting the instance -attribute \member{version} to an appropriate string value before the -\method{open()} method is called. +\class{URLopener} or \class{FancyURLopener} and setting the class +attribute \member{version} to an appropriate string value in the +subclass definition. The optional \var{proxies} parameter should be a dictionary mapping scheme names to proxy URLs, where an empty dictionary turns proxies From montanaro at users.sourceforge.net Wed Mar 9 03:57:58 2005 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Wed Mar 9 03:58:03 2005 Subject: [Python-checkins] python/dist/src/Doc/lib liburllib.tex, 1.54, 1.54.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24601 Modified Files: Tag: release24-maint liburllib.tex Log Message: backport from head Index: liburllib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liburllib.tex,v retrieving revision 1.54 retrieving revision 1.54.4.1 diff -u -d -r1.54 -r1.54.4.1 --- liburllib.tex 13 Jul 2004 14:03:31 -0000 1.54 +++ liburllib.tex 9 Mar 2005 02:57:55 -0000 1.54.4.1 @@ -160,8 +160,8 @@ import urllib class AppURLopener(urllib.FancyURLopener): + version = "App/1.7" def __init__(self, *args): - self.version = "App/1.7" urllib.FancyURLopener.__init__(self, *args) urllib._urlopener = AppURLopener() @@ -243,9 +243,9 @@ \mailheader{User-Agent} header of \samp{urllib/\var{VVV}}, where \var{VVV} is the \module{urllib} version number. Applications can define their own \mailheader{User-Agent} header by subclassing -\class{URLopener} or \class{FancyURLopener} and setting the instance -attribute \member{version} to an appropriate string value before the -\method{open()} method is called. +\class{URLopener} or \class{FancyURLopener} and setting the class +attribute \member{version} to an appropriate string value in the +subclass definition. The optional \var{proxies} parameter should be a dictionary mapping scheme names to proxy URLs, where an empty dictionary turns proxies From montanaro at users.sourceforge.net Wed Mar 9 04:01:35 2005 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Wed Mar 9 04:01:38 2005 Subject: [Python-checkins] python/dist/src/Doc/lib liburllib.tex,1.55,1.56 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25353 Modified Files: liburllib.tex Log Message: hmmm... moving def'n of version makes the __init__ unnecessary for the example Index: liburllib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liburllib.tex,v retrieving revision 1.55 retrieving revision 1.56 diff -u -d -r1.55 -r1.56 --- liburllib.tex 9 Mar 2005 02:57:26 -0000 1.55 +++ liburllib.tex 9 Mar 2005 03:01:31 -0000 1.56 @@ -161,8 +161,6 @@ class AppURLopener(urllib.FancyURLopener): version = "App/1.7" - def __init__(self, *args): - urllib.FancyURLopener.__init__(self, *args) urllib._urlopener = AppURLopener() \end{verbatim} From montanaro at users.sourceforge.net Wed Mar 9 04:02:19 2005 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Wed Mar 9 04:02:23 2005 Subject: [Python-checkins] python/dist/src/Doc/lib liburllib.tex, 1.54.4.1, 1.54.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25524 Modified Files: Tag: release24-maint liburllib.tex Log Message: backport Index: liburllib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liburllib.tex,v retrieving revision 1.54.4.1 retrieving revision 1.54.4.2 diff -u -d -r1.54.4.1 -r1.54.4.2 --- liburllib.tex 9 Mar 2005 02:57:55 -0000 1.54.4.1 +++ liburllib.tex 9 Mar 2005 03:02:17 -0000 1.54.4.2 @@ -161,8 +161,6 @@ class AppURLopener(urllib.FancyURLopener): version = "App/1.7" - def __init__(self, *args): - urllib.FancyURLopener.__init__(self, *args) urllib._urlopener = AppURLopener() \end{verbatim} From anthonybaxter at users.sourceforge.net Wed Mar 9 12:45:52 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Wed Mar 9 12:45:56 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils msvccompiler.py, 1.64.2.1, 1.64.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19573/Lib/distutils Modified Files: Tag: release24-maint msvccompiler.py Log Message: tabstop delenda est Index: msvccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/msvccompiler.py,v retrieving revision 1.64.2.1 retrieving revision 1.64.2.2 diff -u -d -r1.64.2.1 -r1.64.2.2 --- msvccompiler.py 4 Mar 2005 13:51:55 -0000 1.64.2.1 +++ msvccompiler.py 9 Mar 2005 11:45:49 -0000 1.64.2.2 @@ -293,7 +293,7 @@ output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, extra_postargs=None, depends=None): - if not self.initialized: self.initialize() + if not self.initialized: self.initialize() macros, objects, extra_postargs, pp_opts, build = \ self._setup_compile(output_dir, macros, include_dirs, sources, depends, extra_postargs) @@ -385,7 +385,7 @@ debug=0, target_lang=None): - if not self.initialized: self.initialize() + if not self.initialized: self.initialize() (objects, output_dir) = self._fix_object_args (objects, output_dir) output_filename = \ self.library_filename (output_libname, output_dir=output_dir) @@ -419,7 +419,7 @@ build_temp=None, target_lang=None): - if not self.initialized: self.initialize() + if not self.initialized: self.initialize() (objects, output_dir) = self._fix_object_args (objects, output_dir) (libraries, library_dirs, runtime_library_dirs) = \ self._fix_lib_args (libraries, library_dirs, runtime_library_dirs) From anthonybaxter at users.sourceforge.net Wed Mar 9 12:51:43 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Wed Mar 9 12:51:46 2005 Subject: [Python-checkins] python/dist/src/PCbuild BUILDno.txt,1.65,1.66 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20996/PCbuild Modified Files: BUILDno.txt Log Message: ported buildnos to trunk Index: BUILDno.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/BUILDno.txt,v retrieving revision 1.65 retrieving revision 1.66 diff -u -d -r1.65 -r1.66 --- BUILDno.txt 29 Nov 2004 09:57:14 -0000 1.65 +++ BUILDno.txt 9 Mar 2005 11:51:40 -0000 1.66 @@ -33,6 +33,12 @@ Windows Python BUILD numbers ---------------------------- + 63 2.4.1c1 + 10-Mar-2005 + 62 2.3.5 + 08-Feb-2005 + 61 2.3.5c1 + 26-Jan-2005 60 2.4 29-Nov-2004 59 2.4.0c1 From anthonybaxter at users.sourceforge.net Wed Mar 9 12:54:30 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Wed Mar 9 12:54:34 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.33, 1.1193.2.34 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21539/Misc Modified Files: Tag: release24-maint NEWS Log Message: pre-release magic Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.33 retrieving revision 1.1193.2.34 diff -u -d -r1.1193.2.33 -r1.1193.2.34 --- NEWS 8 Mar 2005 15:05:15 -0000 1.1193.2.33 +++ NEWS 9 Mar 2005 11:54:25 -0000 1.1193.2.34 @@ -4,10 +4,10 @@ (editors: check NEWS.help for information about editing NEWS using ReST.) -What's New in Python 2.4.1? -=========================== +What's New in Python 2.4.1c1? +============================= -*Release date: xx-xxx-2005* +*Release date: 10-MAR-2005* Core and builtins ----------------- From anthonybaxter at users.sourceforge.net Wed Mar 9 12:54:31 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Wed Mar 9 12:54:35 2005 Subject: [Python-checkins] python/dist/src/Misc/RPM python-2.4.spec, 1.8.2.1, 1.8.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Misc/RPM In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21539/Misc/RPM Modified Files: Tag: release24-maint python-2.4.spec Log Message: pre-release magic Index: python-2.4.spec =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/RPM/python-2.4.spec,v retrieving revision 1.8.2.1 retrieving revision 1.8.2.2 diff -u -d -r1.8.2.1 -r1.8.2.2 --- python-2.4.spec 5 Jan 2005 15:53:54 -0000 1.8.2.1 +++ python-2.4.spec 9 Mar 2005 11:54:28 -0000 1.8.2.2 @@ -33,9 +33,9 @@ ################################# %define name python -%define version 2.4 +%define version 2.4.1 %define libvers 2.4 -%define release 3pydotorg +%define release 1pydotorg %define __prefix /usr # kludge to get around rpm define weirdness From anthonybaxter at users.sourceforge.net Wed Mar 9 12:54:32 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Wed Mar 9 12:54:37 2005 Subject: [Python-checkins] python/dist/src/PCbuild BUILDno.txt, 1.65, 1.65.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21539/PCbuild Modified Files: Tag: release24-maint BUILDno.txt Log Message: pre-release magic Index: BUILDno.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/BUILDno.txt,v retrieving revision 1.65 retrieving revision 1.65.2.1 diff -u -d -r1.65 -r1.65.2.1 --- BUILDno.txt 29 Nov 2004 09:57:14 -0000 1.65 +++ BUILDno.txt 9 Mar 2005 11:54:29 -0000 1.65.2.1 @@ -33,6 +33,12 @@ Windows Python BUILD numbers ---------------------------- + 63 2.4.1c1 + 10-Mar-2005 + 62 2.3.5 + 08-Feb-2005 + 61 2.3.5c1 + 26-Jan-2005 60 2.4 29-Nov-2004 59 2.4.0c1 From anthonybaxter at users.sourceforge.net Wed Mar 9 12:54:57 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Wed Mar 9 12:55:00 2005 Subject: [Python-checkins] python/dist/src/Include patchlevel.h, 2.83.2.2, 2.83.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21539/Include Modified Files: Tag: release24-maint patchlevel.h Log Message: pre-release magic Index: patchlevel.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/patchlevel.h,v retrieving revision 2.83.2.2 retrieving revision 2.83.2.3 diff -u -d -r2.83.2.2 -r2.83.2.3 --- patchlevel.h 5 Dec 2004 07:45:17 -0000 2.83.2.2 +++ patchlevel.h 9 Mar 2005 11:54:24 -0000 2.83.2.3 @@ -22,11 +22,11 @@ #define PY_MAJOR_VERSION 2 #define PY_MINOR_VERSION 4 #define PY_MICRO_VERSION 1 -#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.4.1a0" +#define PY_VERSION "2.4.1c1" /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. Use this for numeric comparisons, e.g. #if PY_VERSION_HEX >= ... */ From anthonybaxter at users.sourceforge.net Wed Mar 9 12:54:57 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Wed Mar 9 12:55:01 2005 Subject: [Python-checkins] python/dist/src/Lib/idlelib NEWS.txt, 1.49.2.3, 1.49.2.4 idlever.py, 1.22.2.1, 1.22.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21539/Lib/idlelib Modified Files: Tag: release24-maint NEWS.txt idlever.py Log Message: pre-release magic Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.49.2.3 retrieving revision 1.49.2.4 diff -u -d -r1.49.2.3 -r1.49.2.4 --- NEWS.txt 19 Jan 2005 17:25:05 -0000 1.49.2.3 +++ NEWS.txt 9 Mar 2005 11:54:24 -0000 1.49.2.4 @@ -1,7 +1,7 @@ -What's New in IDLE 1.1.1? -======================= +What's New in IDLE 1.1.1c1? +=========================== -*Release date: XX-JAN-2005* +*Release date: 10-MAR-2005* - 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.22.2.1 retrieving revision 1.22.2.2 diff -u -d -r1.22.2.1 -r1.22.2.2 --- idlever.py 23 Dec 2004 04:32:25 -0000 1.22.2.1 +++ idlever.py 9 Mar 2005 11:54:24 -0000 1.22.2.2 @@ -1 +1 @@ -IDLE_VERSION = "1.1.1" +IDLE_VERSION = "1.1.1c1" From rhettinger at users.sourceforge.net Wed Mar 9 17:38:49 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Mar 9 17:38:54 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1270,1.1271 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1975/Misc Modified Files: NEWS Log Message: operator.itemgetter() and operator.attrgetter() now support extraction of multiple fields. This provides direct support for sorting by multiple keys. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1270 retrieving revision 1.1271 diff -u -d -r1.1270 -r1.1271 --- NEWS 8 Mar 2005 15:03:01 -0000 1.1270 +++ NEWS 9 Mar 2005 16:38:31 -0000 1.1271 @@ -47,6 +47,10 @@ Extension Modules ----------------- +- operator.itemgetter() and operator.attrgetter() now support retrieving + multiple fields. This provides direct support for sorting on multiple + keys (primary, secondary, etc). + - os.access now supports Unicode path names on non-Win32 systems. - Patches #925152, #1118602: Avoid reading after the end of the buffer From rhettinger at users.sourceforge.net Wed Mar 9 17:38:49 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Mar 9 17:38:56 2005 Subject: [Python-checkins] python/dist/src/Modules operator.c,2.29,2.30 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1975/Modules Modified Files: operator.c Log Message: operator.itemgetter() and operator.attrgetter() now support extraction of multiple fields. This provides direct support for sorting by multiple keys. Index: operator.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/operator.c,v retrieving revision 2.29 retrieving revision 2.30 diff -u -d -r2.29 -r2.30 --- operator.c 4 Dec 2003 22:17:49 -0000 2.29 +++ operator.c 9 Mar 2005 16:38:46 -0000 2.30 @@ -256,6 +256,7 @@ typedef struct { PyObject_HEAD + int nitems; PyObject *item; } itemgetterobject; @@ -266,9 +267,14 @@ { itemgetterobject *ig; PyObject *item; + int nitems; - if (!PyArg_UnpackTuple(args, "itemgetter", 1, 1, &item)) - return NULL; + nitems = PyTuple_GET_SIZE(args); + if (nitems <= 1) { + if (!PyArg_UnpackTuple(args, "itemgetter", 1, 1, &item)) + return NULL; + } else + item = args; /* create itemgetterobject structure */ ig = PyObject_GC_New(itemgetterobject, &itemgetter_type); @@ -277,6 +283,7 @@ Py_INCREF(item); ig->item = item; + ig->nitems = nitems; PyObject_GC_Track(ig); return (PyObject *)ig; @@ -301,18 +308,40 @@ static PyObject * itemgetter_call(itemgetterobject *ig, PyObject *args, PyObject *kw) { - PyObject * obj; + PyObject *obj, *result; + int i, nitems=ig->nitems; if (!PyArg_UnpackTuple(args, "itemgetter", 1, 1, &obj)) return NULL; - return PyObject_GetItem(obj, ig->item); + if (nitems == 1) + return PyObject_GetItem(obj, ig->item); + + assert(PyTuple_Check(ig->item)); + assert(PyTuple_GET_SIZE(ig->item) == nitems); + + result = PyTuple_New(nitems); + if (result == NULL) + return NULL; + + for (i=0 ; i < nitems ; i++) { + PyObject *item, *val; + item = PyTuple_GET_ITEM(ig->item, i); + val = PyObject_GetItem(obj, item); + if (val == NULL) { + Py_DECREF(result); + return NULL; + } + PyTuple_SET_ITEM(result, i, val); + } + return result; } PyDoc_STRVAR(itemgetter_doc, -"itemgetter(item) --> itemgetter object\n\ +"itemgetter(item, ...) --> itemgetter object\n\ \n\ -Return a callable object that fetches the given item from its operand.\n\ -After, f=itemgetter(2), the call f(b) returns b[2]."); +Return a callable object that fetches the given item(s) from its operand.\n\ +After, f=itemgetter(2), the call f(r) returns r[2].\n\ +After, g=itemgetter(2,5,3), the call g(r) returns (r[2], r[5], r[3])"); static PyTypeObject itemgetter_type = { PyObject_HEAD_INIT(NULL) @@ -363,6 +392,7 @@ typedef struct { PyObject_HEAD + int nattrs; PyObject *attr; } attrgetterobject; @@ -373,9 +403,14 @@ { attrgetterobject *ag; PyObject *attr; + int nattrs; - if (!PyArg_UnpackTuple(args, "attrgetter", 1, 1, &attr)) - return NULL; + nattrs = PyTuple_GET_SIZE(args); + if (nattrs <= 1) { + if (!PyArg_UnpackTuple(args, "attrgetter", 1, 1, &attr)) + return NULL; + } else + attr = args; /* create attrgetterobject structure */ ag = PyObject_GC_New(attrgetterobject, &attrgetter_type); @@ -384,6 +419,7 @@ Py_INCREF(attr); ag->attr = attr; + ag->nattrs = nattrs; PyObject_GC_Track(ag); return (PyObject *)ag; @@ -408,18 +444,40 @@ static PyObject * attrgetter_call(attrgetterobject *ag, PyObject *args, PyObject *kw) { - PyObject * obj; + PyObject *obj, *result; + int i, nattrs=ag->nattrs; if (!PyArg_UnpackTuple(args, "attrgetter", 1, 1, &obj)) return NULL; - return PyObject_GetAttr(obj, ag->attr); + if (ag->nattrs == 1) + return PyObject_GetAttr(obj, ag->attr); + + assert(PyTuple_Check(ag->attr)); + assert(PyTuple_GET_SIZE(ag->attr) == nattrs); + + result = PyTuple_New(nattrs); + if (result == NULL) + return NULL; + + for (i=0 ; i < nattrs ; i++) { + PyObject *attr, *val; + attr = PyTuple_GET_ITEM(ag->attr, i); + val = PyObject_GetAttr(obj, attr); + if (val == NULL) { + Py_DECREF(result); + return NULL; + } + PyTuple_SET_ITEM(result, i, val); + } + return result; } PyDoc_STRVAR(attrgetter_doc, -"attrgetter(attr) --> attrgetter object\n\ +"attrgetter(attr, ...) --> attrgetter object\n\ \n\ -Return a callable object that fetches the given attribute from its operand.\n\ -After, f=attrgetter('name'), the call f(b) returns b.name."); +Return a callable object that fetches the given attribute(s) from its operand.\n\ +After, f=attrgetter('name'), the call f(r) returns r.name.\n\ +After, g=attrgetter('name', 'date'), the call g(r) returns (r.name, r.date)."); static PyTypeObject attrgetter_type = { PyObject_HEAD_INIT(NULL) From rhettinger at users.sourceforge.net Wed Mar 9 17:38:50 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Mar 9 17:38:57 2005 Subject: [Python-checkins] python/dist/src/Doc/lib liboperator.tex, 1.32, 1.33 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1975/Doc/lib Modified Files: liboperator.tex Log Message: operator.itemgetter() and operator.attrgetter() now support extraction of multiple fields. This provides direct support for sorting by multiple keys. Index: liboperator.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liboperator.tex,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- liboperator.tex 1 Jan 2005 00:28:37 -0000 1.32 +++ liboperator.tex 9 Mar 2005 16:38:48 -0000 1.33 @@ -306,24 +306,31 @@ \method{itertools.groupby()}, or other functions that expect a function argument. -\begin{funcdesc}{attrgetter}{attr} +\begin{funcdesc}{attrgetter}{attr\optional{, args...}} Return a callable object that fetches \var{attr} from its operand. +If more than one attribute is requested, returns a tuple of attributes. After, \samp{f=attrgetter('name')}, the call \samp{f(b)} returns -\samp{b.name}. +\samp{b.name}. After, \samp{f=attrgetter('name', 'date')}, the call +\samp{f(b)} returns \samp{(b.name, b.date)}. \versionadded{2.4} +\versionchanged[Added support for multiple attributes]{2.5} \end{funcdesc} -\begin{funcdesc}{itemgetter}{item} +\begin{funcdesc}{itemgetter}{item\optional{, args...}} Return a callable object that fetches \var{item} from its operand. +If more than one item is requested, returns a tuple of items. After, \samp{f=itemgetter(2)}, the call \samp{f(b)} returns \samp{b[2]}. +After, \samp{f=itemgetter(2,5,3)}, the call \samp{f(b)} returns +\samp{(b[2], b[5], b[3])}. \versionadded{2.4} +\versionchanged[Added support for multiple item extraction]{2.5} \end{funcdesc} Examples: \begin{verbatim} ->>> from operator import * +>>> from operator import itemgetter >>> inventory = [('apple', 3), ('banana', 2), ('pear', 5), ('orange', 1)] >>> getcount = itemgetter(1) >>> map(getcount, inventory) From rhettinger at users.sourceforge.net Wed Mar 9 17:38:50 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Mar 9 17:38:58 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_operator.py, 1.14, 1.15 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1975/Lib/test Modified Files: test_operator.py Log Message: operator.itemgetter() and operator.attrgetter() now support extraction of multiple fields. This provides direct support for sorting by multiple keys. Index: test_operator.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_operator.py,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- test_operator.py 1 Nov 2004 17:10:19 -0000 1.14 +++ test_operator.py 9 Mar 2005 16:38:47 -0000 1.15 @@ -324,7 +324,14 @@ f = operator.attrgetter(2) self.assertRaises(TypeError, f, a) self.assertRaises(TypeError, operator.attrgetter) - self.assertRaises(TypeError, operator.attrgetter, 1, 2) + + # multiple gets + record = A() + record.x = 'X' + record.y = 'Y' + record.z = 'Z' + self.assertEqual(operator.attrgetter('x','z','y')(record), ('X', 'Z', 'Y')) + self.assertRaises(TypeError, operator.attrgetter('x', (), 'y'), record) class C(object): def __getattr(self, name): @@ -346,7 +353,6 @@ f = operator.itemgetter('name') self.assertRaises(TypeError, f, a) self.assertRaises(TypeError, operator.itemgetter) - self.assertRaises(TypeError, operator.itemgetter, 1, 2) d = dict(key='val') f = operator.itemgetter('key') @@ -361,9 +367,29 @@ self.assertEqual(sorted(inventory, key=getcount), [('orange', 1), ('banana', 2), ('apple', 3), ('pear', 5)]) -def test_main(): - test_support.run_unittest(OperatorTestCase) + # multiple gets + data = map(str, range(20)) + self.assertEqual(operator.itemgetter(2,10,5)(data), ('2', '10', '5')) + self.assertRaises(TypeError, operator.itemgetter(2, 'x', 5), data) + + +def test_main(verbose=None): + import sys + test_classes = ( + OperatorTestCase, + ) + test_support.run_unittest(*test_classes) + + # verify reference counting + if verbose and hasattr(sys, "gettotalrefcount"): + import gc + counts = [None] * 5 + for i in xrange(len(counts)): + test_support.run_unittest(*test_classes) + gc.collect() + counts[i] = sys.gettotalrefcount() + print counts if __name__ == "__main__": - test_main() + test_main(verbose=True) From fdrake at acm.org Wed Mar 9 17:48:50 2005 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Wed Mar 9 17:48:55 2005 Subject: [Python-checkins] python/dist/src/Lib/idlelib NEWS.txt, 1.49.2.3, 1.49.2.4 idlever.py, 1.22.2.1, 1.22.2.2 In-Reply-To: References: Message-ID: <200503091148.50639.fdrake@acm.org> On Wednesday 09 March 2005 06:54, anthonybaxter@users.sourceforge.net wrote: > RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v ... > -What's New in IDLE 1.1.1? > -======================= > +What's New in IDLE 1.1.1c1? ... > RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/idlever.py,v > -IDLE_VERSION = "1.1.1" > +IDLE_VERSION = "1.1.1c1" Shouldn't this progress from 1.1.1 to 1.1.2c1? Otherwise it's moving backward. -Fred -- Fred L. Drake, Jr. From aimacintyre at users.sourceforge.net Wed Mar 9 23:21:13 2005 From: aimacintyre at users.sourceforge.net (aimacintyre@users.sourceforge.net) Date: Wed Mar 9 23:21:17 2005 Subject: [Python-checkins] python/dist/src setup.py,1.215,1.216 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29399 Modified Files: setup.py Log Message: add support for another DB library naming convention (FreeBSD ports) Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.215 retrieving revision 1.216 diff -u -d -r1.215 -r1.216 --- setup.py 8 Mar 2005 15:02:37 -0000 1.215 +++ setup.py 9 Mar 2005 22:21:08 -0000 1.216 @@ -598,7 +598,9 @@ # XXX should we -ever- look for a dbX name? Do any # systems really not name their library by version and # symlink to more general names? - for dblib in (('db-%d.%d' % db_ver), ('db%d' % db_ver[0])): + for dblib in (('db-%d.%d' % db_ver), + ('db%d%d' % db_ver), + ('db%d' % db_ver[0])): dblib_file = self.compiler.find_library_file( db_dirs_to_check + lib_dirs, dblib ) if dblib_file: From aimacintyre at users.sourceforge.net Wed Mar 9 23:27:27 2005 From: aimacintyre at users.sourceforge.net (aimacintyre@users.sourceforge.net) Date: Wed Mar 9 23:27:29 2005 Subject: [Python-checkins] python/dist/src setup.py,1.204.2.2,1.204.2.3 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31422 Modified Files: Tag: release24-maint setup.py Log Message: backport v1.216: add support for another DB library naming convention \n(FreeBSD ports) - patch #1146231 Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.204.2.2 retrieving revision 1.204.2.3 diff -u -d -r1.204.2.2 -r1.204.2.3 --- setup.py 8 Mar 2005 15:05:14 -0000 1.204.2.2 +++ setup.py 9 Mar 2005 22:27:24 -0000 1.204.2.3 @@ -569,7 +569,9 @@ # XXX should we -ever- look for a dbX name? Do any # systems really not name their library by version and # symlink to more general names? - for dblib in (('db-%d.%d' % db_ver), ('db%d' % db_ver[0])): + for dblib in (('db-%d.%d' % db_ver), + ('db%d%d' % db_ver), + ('db%d' % db_ver[0])): dblib_file = self.compiler.find_library_file( db_dirs_to_check + lib_dirs, dblib ) if dblib_file: From rhettinger at users.sourceforge.net Thu Mar 10 00:46:14 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Mar 10 00:46:18 2005 Subject: [Python-checkins] python/dist/src/Modules Setup.dist,1.49,1.50 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20810 Modified Files: Setup.dist Log Message: SF bug #1160187: Setup file needs entries for collections, itertools, strop Index: Setup.dist =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Setup.dist,v retrieving revision 1.49 retrieving revision 1.50 diff -u -d -r1.49 -r1.50 --- Setup.dist 23 Jan 2005 09:27:24 -0000 1.49 +++ Setup.dist 9 Mar 2005 23:46:11 -0000 1.50 @@ -170,6 +170,10 @@ #operator operator.c # operator.add() and similar goodies #_weakref _weakref.c # basic weak reference support #_testcapi _testcapimodule.c # Python C API test module +#_random _randommodule.c # Random number generator +#collections collectionsmodule.c # Container types +#itertools itertoolsmodule.c # Functions creating iterators for efficient looping +#strop stropmodule.c # String manipulations #unicodedata unicodedata.c # static Unicode character database From rhettinger at users.sourceforge.net Thu Mar 10 00:47:46 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Mar 10 00:47:50 2005 Subject: [Python-checkins] python/dist/src/Modules Setup.dist,1.48,1.48.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21362 Modified Files: Tag: release24-maint Setup.dist Log Message: SF bug #1160187: Setup file needs entries for collections, itertools, strop Index: Setup.dist =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/Setup.dist,v retrieving revision 1.48 retrieving revision 1.48.2.1 diff -u -d -r1.48 -r1.48.2.1 --- Setup.dist 31 Aug 2004 13:50:12 -0000 1.48 +++ Setup.dist 9 Mar 2005 23:47:44 -0000 1.48.2.1 @@ -170,6 +170,10 @@ #operator operator.c # operator.add() and similar goodies #_weakref _weakref.c # basic weak reference support #_testcapi _testcapimodule.c # Python C API test module +#_random _randommodule.c # Random number generator +#collections collectionsmodule.c # Container types +#itertools itertoolsmodule.c # Functions creating iterators for efficient looping +#strop stropmodule.c # String manipulations #unicodedata unicodedata.c # static Unicode character database From fdrake at users.sourceforge.net Thu Mar 10 04:47:27 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu Mar 10 04:47:31 2005 Subject: [Python-checkins] python/dist/src/Doc/dist dist.tex, 1.86.2.2, 1.86.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/dist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18834/Doc/dist Modified Files: Tag: release24-maint dist.tex Log Message: correct several markup errors caught by the GNU info conversion Index: dist.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/dist/dist.tex,v retrieving revision 1.86.2.2 retrieving revision 1.86.2.3 diff -u -d -r1.86.2.2 -r1.86.2.3 --- dist.tex 13 Feb 2005 22:56:35 -0000 1.86.2.2 +++ dist.tex 10 Mar 2005 03:47:24 -0000 1.86.2.3 @@ -2134,9 +2134,9 @@ the contents of the config files or command-line. \var{script_name} is a file that will be run with \function{execfile()} -\var{sys.argv[0]} will be replaced with \var{script} for the duration of the +\code{sys.argv[0]} will be replaced with \var{script} for the duration of the call. \var{script_args} is a list of strings; if supplied, -\var{sys.argv[1:]} will be replaced by \var{script_args} for the duration +\code{sys.argv[1:]} will be replaced by \var{script_args} for the duration of the call. \var{stop_after} tells \function{setup()} when to stop processing; possible @@ -2257,22 +2257,24 @@ \end{funcdesc} \begin{funcdesc}{gen_preprocess_options}{macros, include_dirs} -Generate C pre-processor options (-D, -U, -I) as used by at least +Generate C pre-processor options (\programopt{-D}, \programopt{-U}, +\programopt{-I}) as used by at least two types of compilers: the typical \UNIX{} compiler and Visual \Cpp. -\var{macros} is the usual thing, a list of 1- or 2-tuples, where \var{(name,)} -means undefine (-U) macro \var{name}, and \var{(name,value)} means define (-D) -macro \var{name} to \var{value}. \var{include_dirs} is just a list of directory -names to be added to the header file search path (-I). Returns a list -of command-line options suitable for either \UNIX{} compilers or Visual -\Cpp. +\var{macros} is the usual thing, a list of 1- or 2-tuples, where +\code{(\var{name},)} means undefine (\programopt{-U}) macro \var{name}, +and \code{(\var{name}, \var{value})} means define (\programopt{-D}) +macro \var{name} to \var{value}. \var{include_dirs} is just a list of +directory names to be added to the header file search path (\programopt{-I}). +Returns a list of command-line options suitable for either \UNIX{} compilers +or Visual \Cpp. \end{funcdesc} \begin{funcdesc}{get_default_compiler}{osname, platform} Determine the default compiler to use for the given platform. -\var{osname} should be one of the standard Python OS names (i.e. the -ones returned by \var{os.name}) and \var{platform} the common value -returned by \var{sys.platform} for the platform in question. +\var{osname} should be one of the standard Python OS names (i.e.\ the +ones returned by \code{os.name}) and \var{platform} the common value +returned by \code{sys.platform} for the platform in question. The default values are \code{os.name} and \code{sys.platform} in case the parameters are not given. @@ -2504,7 +2506,8 @@ \file{build/foo/bar.o}. \var{macros}, if given, must be a list of macro definitions. A macro -definition is either a \var{(name, value)} 2-tuple or a \var{(name,)} 1-tuple. +definition is either a \code{(\var{name}, \var{value})} 2-tuple or a +\code{(\var{name},)} 1-tuple. The former defines a macro; if the value is \code{None}, the macro is defined without an explicit value. The 1-tuple case undefines a macro. Later definitions/redefinitions/undefinitions take @@ -2517,7 +2520,7 @@ \var{debug} is a boolean; if true, the compiler will be instructed to output debug symbols in (or alongside) the object file(s). -\var{extra_preargs} and \var{extra_postargs} are implementation- dependent. +\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 prepend/append to the compiler command @@ -2791,8 +2794,8 @@ \end{funcdesc} \begin{funcdesc}{make_tarball}{base_name, base_dir\optional{, compress=\code{'gzip'}, verbose=\code{0}, dry_run=\code{0}}}'Create an (optional compressed) archive as a tar file from all files in and under \var{base_dir}. \var{compress} must be \code{'gzip'} (the default), -\code{'compress'}, \code{'bzip2'}, or \code{None}. Both \code{'tar'} -and the compression utility named by \var{'compress'} must be on the +\code{'compress'}, \code{'bzip2'}, or \code{None}. Both \program{tar} +and the compression utility named by \var{compress} must be on the default program search path, so this is probably \UNIX-specific. The output tar file will be named \file{\var{base_dir}.tar}, possibly plus the appropriate compression extension (\file{.gz}, \file{.bz2} or @@ -2881,7 +2884,7 @@ Copy an entire directory tree \var{src} to a new location \var{dst}. Both \var{src} and \var{dst} must be directory names. If \var{src} is not a directory, raise \exception{DistutilsFileError}. If \var{dst} does -not exist, it is created with \var{mkpath()}. The end result of the +not exist, it is created with \function{mkpath()}. The end result of the copy is that every file in \var{src} is copied to \var{dst}, and directories under \var{src} are recursively copied to \var{dst}. Return the list of files that were copied or might have been copied, @@ -2901,7 +2904,7 @@ \begin{funcdesc}{remove_tree}{directory\optional{verbose=\code{0}, dry_run=\code{0}}} Recursively remove \var{directory} and all files and directories underneath -it. Any errors are ignored (apart from being reported to \code{stdout} if +it. Any errors are ignored (apart from being reported to \code{sys.stdout} if \var{verbose} is true). \end{funcdesc} @@ -2929,7 +2932,7 @@ to \code{'hard'} or \code{'sym'}; if it is \code{None} (the default), files are copied. Don't set \var{link} on systems that don't support it: \function{copy_file()} doesn't check if hard or symbolic linking is -available. It uses \var{_copy_file_contents()} to copy file contents. +available. It uses \function{_copy_file_contents()} to copy file contents. Return a tuple \samp{(dest_name, copied)}: \var{dest_name} is the actual name of the output file, and \var{copied} is true if the file was copied @@ -3294,11 +3297,11 @@ something that provides \method{readline()} and \method{close()} methods). It is recommended that you supply at least \var{filename}, so that \class{TextFile} can include it in warning messages. If -\var{file} is not supplied, TextFile creates its own using the -\var{open()} builtin. +\var{file} is not supplied, \class{TextFile} creates its own using the +\function{open()} built-in function. The options are all boolean, and affect the values returned by -\var{readline()} +\method{readline()} \begin{tableiii}{c|l|l}{option name}{option name}{description}{default} \lineiii{strip_comments}{ From fdrake at users.sourceforge.net Thu Mar 10 04:48:17 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu Mar 10 04:48:21 2005 Subject: [Python-checkins] python/dist/src/Doc/dist dist.tex,1.88,1.89 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/dist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19002/Doc/dist Modified Files: dist.tex Log Message: correct several markup errors caught by the GNU info conversion (ported from release24-maint branch revision 1.86.2.3) Index: dist.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/dist/dist.tex,v retrieving revision 1.88 retrieving revision 1.89 diff -u -d -r1.88 -r1.89 --- dist.tex 13 Feb 2005 22:50:02 -0000 1.88 +++ dist.tex 10 Mar 2005 03:48:14 -0000 1.89 @@ -2134,9 +2134,9 @@ the contents of the config files or command-line. \var{script_name} is a file that will be run with \function{execfile()} -\var{sys.argv[0]} will be replaced with \var{script} for the duration of the +\code{sys.argv[0]} will be replaced with \var{script} for the duration of the call. \var{script_args} is a list of strings; if supplied, -\var{sys.argv[1:]} will be replaced by \var{script_args} for the duration +\code{sys.argv[1:]} will be replaced by \var{script_args} for the duration of the call. \var{stop_after} tells \function{setup()} when to stop processing; possible @@ -2257,22 +2257,24 @@ \end{funcdesc} \begin{funcdesc}{gen_preprocess_options}{macros, include_dirs} -Generate C pre-processor options (-D, -U, -I) as used by at least +Generate C pre-processor options (\programopt{-D}, \programopt{-U}, +\programopt{-I}) as used by at least two types of compilers: the typical \UNIX{} compiler and Visual \Cpp. -\var{macros} is the usual thing, a list of 1- or 2-tuples, where \var{(name,)} -means undefine (-U) macro \var{name}, and \var{(name,value)} means define (-D) -macro \var{name} to \var{value}. \var{include_dirs} is just a list of directory -names to be added to the header file search path (-I). Returns a list -of command-line options suitable for either \UNIX{} compilers or Visual -\Cpp. +\var{macros} is the usual thing, a list of 1- or 2-tuples, where +\code{(\var{name},)} means undefine (\programopt{-U}) macro \var{name}, +and \code{(\var{name}, \var{value})} means define (\programopt{-D}) +macro \var{name} to \var{value}. \var{include_dirs} is just a list of +directory names to be added to the header file search path (\programopt{-I}). +Returns a list of command-line options suitable for either \UNIX{} compilers +or Visual \Cpp. \end{funcdesc} \begin{funcdesc}{get_default_compiler}{osname, platform} Determine the default compiler to use for the given platform. -\var{osname} should be one of the standard Python OS names (i.e. the -ones returned by \var{os.name}) and \var{platform} the common value -returned by \var{sys.platform} for the platform in question. +\var{osname} should be one of the standard Python OS names (i.e.\ the +ones returned by \code{os.name}) and \var{platform} the common value +returned by \code{sys.platform} for the platform in question. The default values are \code{os.name} and \code{sys.platform} in case the parameters are not given. @@ -2504,7 +2506,8 @@ \file{build/foo/bar.o}. \var{macros}, if given, must be a list of macro definitions. A macro -definition is either a \var{(name, value)} 2-tuple or a \var{(name,)} 1-tuple. +definition is either a \code{(\var{name}, \var{value})} 2-tuple or a +\code{(\var{name},)} 1-tuple. The former defines a macro; if the value is \code{None}, the macro is defined without an explicit value. The 1-tuple case undefines a macro. Later definitions/redefinitions/undefinitions take @@ -2517,7 +2520,7 @@ \var{debug} is a boolean; if true, the compiler will be instructed to output debug symbols in (or alongside) the object file(s). -\var{extra_preargs} and \var{extra_postargs} are implementation- dependent. +\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 prepend/append to the compiler command @@ -2791,8 +2794,8 @@ \end{funcdesc} \begin{funcdesc}{make_tarball}{base_name, base_dir\optional{, compress=\code{'gzip'}, verbose=\code{0}, dry_run=\code{0}}}'Create an (optional compressed) archive as a tar file from all files in and under \var{base_dir}. \var{compress} must be \code{'gzip'} (the default), -\code{'compress'}, \code{'bzip2'}, or \code{None}. Both \code{'tar'} -and the compression utility named by \var{'compress'} must be on the +\code{'compress'}, \code{'bzip2'}, or \code{None}. Both \program{tar} +and the compression utility named by \var{compress} must be on the default program search path, so this is probably \UNIX-specific. The output tar file will be named \file{\var{base_dir}.tar}, possibly plus the appropriate compression extension (\file{.gz}, \file{.bz2} or @@ -2881,7 +2884,7 @@ Copy an entire directory tree \var{src} to a new location \var{dst}. Both \var{src} and \var{dst} must be directory names. If \var{src} is not a directory, raise \exception{DistutilsFileError}. If \var{dst} does -not exist, it is created with \var{mkpath()}. The end result of the +not exist, it is created with \function{mkpath()}. The end result of the copy is that every file in \var{src} is copied to \var{dst}, and directories under \var{src} are recursively copied to \var{dst}. Return the list of files that were copied or might have been copied, @@ -2901,7 +2904,7 @@ \begin{funcdesc}{remove_tree}{directory\optional{verbose=\code{0}, dry_run=\code{0}}} Recursively remove \var{directory} and all files and directories underneath -it. Any errors are ignored (apart from being reported to \code{stdout} if +it. Any errors are ignored (apart from being reported to \code{sys.stdout} if \var{verbose} is true). \end{funcdesc} @@ -2929,7 +2932,7 @@ to \code{'hard'} or \code{'sym'}; if it is \code{None} (the default), files are copied. Don't set \var{link} on systems that don't support it: \function{copy_file()} doesn't check if hard or symbolic linking is -available. It uses \var{_copy_file_contents()} to copy file contents. +available. It uses \function{_copy_file_contents()} to copy file contents. Return a tuple \samp{(dest_name, copied)}: \var{dest_name} is the actual name of the output file, and \var{copied} is true if the file was copied @@ -3294,11 +3297,11 @@ something that provides \method{readline()} and \method{close()} methods). It is recommended that you supply at least \var{filename}, so that \class{TextFile} can include it in warning messages. If -\var{file} is not supplied, TextFile creates its own using the -\var{open()} builtin. +\var{file} is not supplied, \class{TextFile} creates its own using the +\function{open()} built-in function. The options are all boolean, and affect the values returned by -\var{readline()} +\method{readline()} \begin{tableiii}{c|l|l}{option name}{option name}{description}{default} \lineiii{strip_comments}{ From fdrake at users.sourceforge.net Thu Mar 10 04:57:05 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu Mar 10 04:57:10 2005 Subject: [Python-checkins] python/dist/src/Doc/tools py2texi.el, 1.10, 1.10.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20616/Doc/tools Modified Files: Tag: release24-maint py2texi.el Log Message: add missing entries from GNU info conversion table Index: py2texi.el =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tools/py2texi.el,v retrieving revision 1.10 retrieving revision 1.10.4.1 diff -u -d -r1.10 -r1.10.4.1 --- py2texi.el 17 Jul 2004 14:43:32 -0000 1.10 +++ py2texi.el 10 Mar 2005 03:57:02 -0000 1.10.4.1 @@ -260,6 +260,7 @@ ("funclineni" 2 "@item \\1 \\2") ("function" 1 "@code{\\1}") ("grammartoken" 1 "@code{\\1}") + ("guilabel" 1 "@strong{\\1}") ("hline" 0 "") ("ifhtml" 0 (concat "@" (setq last-if "ifinfo"))) ("iftexi" 0 (concat "@" (setq last-if "ifinfo"))) @@ -353,6 +354,7 @@ (py2texi-backslash-quote (match-string 2 str))) "@node \\1\n@section \\1\n")))) ("sectionauthor" 2 "") + ("seelink" 3 "\n@table @url\n@item @strong{\\1}\n(\\2)\n\\3\n@end table\n") ("seemodule" 2 "@ref{\\1} \\2") ("seepep" 3 "\n@table @strong\n@item PEP\\1 \\2\n\\3\n@end table\n") ("seerfc" 3 "\n@table @strong\n@item RFC\\1 \\2\n\\3\n@end table\n") From fdrake at users.sourceforge.net Thu Mar 10 04:59:38 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu Mar 10 04:59:41 2005 Subject: [Python-checkins] python/dist/src/Doc/tools py2texi.el,1.10,1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21132/Doc/tools Modified Files: py2texi.el Log Message: add missing entries from GNU info conversion table (ported from release24-maint branch revision 1.10.4.1) Index: py2texi.el =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tools/py2texi.el,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- py2texi.el 17 Jul 2004 14:43:32 -0000 1.10 +++ py2texi.el 10 Mar 2005 03:59:35 -0000 1.11 @@ -260,6 +260,7 @@ ("funclineni" 2 "@item \\1 \\2") ("function" 1 "@code{\\1}") ("grammartoken" 1 "@code{\\1}") + ("guilabel" 1 "@strong{\\1}") ("hline" 0 "") ("ifhtml" 0 (concat "@" (setq last-if "ifinfo"))) ("iftexi" 0 (concat "@" (setq last-if "ifinfo"))) @@ -353,6 +354,7 @@ (py2texi-backslash-quote (match-string 2 str))) "@node \\1\n@section \\1\n")))) ("sectionauthor" 2 "") + ("seelink" 3 "\n@table @url\n@item @strong{\\1}\n(\\2)\n\\3\n@end table\n") ("seemodule" 2 "@ref{\\1} \\2") ("seepep" 3 "\n@table @strong\n@item PEP\\1 \\2\n\\3\n@end table\n") ("seerfc" 3 "\n@table @strong\n@item RFC\\1 \\2\n\\3\n@end table\n") From fdrake at users.sourceforge.net Thu Mar 10 05:01:18 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu Mar 10 05:01:20 2005 Subject: [Python-checkins] python/dist/src/Doc/texinputs python.sty, 1.111, 1.112 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/texinputs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21607 Modified Files: python.sty Log Message: fix broken usage comment Index: python.sty =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/texinputs/python.sty,v retrieving revision 1.111 retrieving revision 1.112 diff -u -d -r1.111 -r1.112 --- python.sty 1 Dec 2004 06:30:31 -0000 1.111 +++ python.sty 10 Mar 2005 04:01:14 -0000 1.112 @@ -1202,7 +1202,7 @@ } \fi -% \seelink{url}{link text} +% \seelink{url}{link text}{why it's interesting} \newcommand{\py@seelink}[3]{% \par \begin{fulllineitems} From fdrake at users.sourceforge.net Thu Mar 10 05:04:16 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu Mar 10 05:04:19 2005 Subject: [Python-checkins] python/dist/src/Doc/texinputs python.sty, 1.110.2.1, 1.110.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/texinputs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22517 Modified Files: Tag: release24-maint python.sty Log Message: fix broken usage comment (ported from trunk revision 1.112) Index: python.sty =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/texinputs/python.sty,v retrieving revision 1.110.2.1 retrieving revision 1.110.2.2 diff -u -d -r1.110.2.1 -r1.110.2.2 --- python.sty 1 Dec 2004 06:29:51 -0000 1.110.2.1 +++ python.sty 10 Mar 2005 04:04:13 -0000 1.110.2.2 @@ -1202,7 +1202,7 @@ } \fi -% \seelink{url}{link text} +% \seelink{url}{link text}{why it's interesting} \newcommand{\py@seelink}[3]{% \par \begin{fulllineitems} From anthonybaxter at users.sourceforge.net Thu Mar 10 05:51:50 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Thu Mar 10 05:51:54 2005 Subject: [Python-checkins] python/dist/src/PCbuild pythoncore.vcproj, 1.25, 1.25.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1529 Modified Files: Tag: release24-maint pythoncore.vcproj Log Message: bump buildno for 2.4c1 Index: pythoncore.vcproj =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pythoncore.vcproj,v retrieving revision 1.25 retrieving revision 1.25.2.1 diff -u -d -r1.25 -r1.25.2.1 --- pythoncore.vcproj 29 Nov 2004 09:57:14 -0000 1.25 +++ pythoncore.vcproj 10 Mar 2005 04:51:47 -0000 1.25.2.1 @@ -1385,7 +1385,7 @@ Name="VCCLCompilerTool" Optimization="2" AdditionalIncludeDirectories="" - PreprocessorDefinitions="BUILD=60"/> + PreprocessorDefinitions="BUILD=63"/> @@ -1393,7 +1393,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="" - PreprocessorDefinitions="BUILD=60"/> + PreprocessorDefinitions="BUILD=63"/> @@ -1401,7 +1401,7 @@ Name="VCCLCompilerTool" Optimization="2" AdditionalIncludeDirectories="" - PreprocessorDefinitions="BUILD=60"/> + PreprocessorDefinitions="BUILD=63"/> Update of /cvsroot/python/python/dist/src/Doc/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3141/Doc/tools Modified Files: Tag: release24-maint py2texi.el Log Message: - fix generated Texinfo markup for \deprecated - add support for additional markup: \leq, \textbar, \textit - add a comment about the non-support for the Euro character Index: py2texi.el =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tools/py2texi.el,v retrieving revision 1.10.4.1 retrieving revision 1.10.4.2 diff -u -d -r1.10.4.1 -r1.10.4.2 --- py2texi.el 10 Mar 2005 03:57:02 -0000 1.10.4.1 +++ py2texi.el 10 Mar 2005 04:59:14 -0000 1.10.4.2 @@ -238,7 +238,7 @@ ("dataline" 1 (progn (setq findex t) "@item \\1\n@findex \\1\n")) ("date" 1 "\\1") ("declaremodule" 2 (progn (setq cindex t) "@label{\\2}@cindex{\\2}")) - ("deprecated" 2 "@emph{This is deprecated in Python \\1. \\2}") + ("deprecated" 2 "@emph{This is deprecated in Python \\1. \\2}\n\n") ("dfn" 1 "@dfn{\\1}") ("documentclass" 1 py2texi-magic) ("e" 0 "@backslash{}") @@ -279,6 +279,7 @@ ("large" 0 "") ("ldots" 0 "@dots{}") ("leftline" 1 "\\1") + ("leq" 0 "<=") ("lineii" 2 "@item \\1 @tab \\2") ("lineiii" 3 "@item \\1 @tab \\2 @tab \\3") ("lineiv" 4 "@item \\1 @tab \\2 @tab \\3 @tab \\4") @@ -380,7 +381,15 @@ ("textasciitilde" 0 "~") ("textasciicircum" 0 "^") ("textbackslash" 0 "@backslash{}") + ("textbar" 0 "|") + ; Some common versions of Texinfo don't support @euro yet: + ; ("texteuro" 0 "@euro{}") + ; Unfortunately, this alternate spelling doesn't actually apply to + ; the usage found in Python Tutorial, which actually requires a + ; Euro symbol to make sense, so this is commented out as well. + ; ("texteuro" 0 "Euro ") ("textgreater" 0 ">") + ("textit" 1 "@i{\\1}") ("textless" 0 "<") ("textrm" 1 "\\1") ("texttt" 1 "@code{\\1}") From fdrake at users.sourceforge.net Thu Mar 10 06:02:21 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu Mar 10 06:02:25 2005 Subject: [Python-checkins] python/dist/src/Doc/tools py2texi.el,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3863/Doc/tools Modified Files: py2texi.el Log Message: - fix generated Texinfo markup for \deprecated - add support for additional markup: \leq, \textbar, \textit - add a comment about the non-support for the Euro character (ported from release24-maint branch release 1.10.4.2) Index: py2texi.el =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/tools/py2texi.el,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- py2texi.el 10 Mar 2005 03:59:35 -0000 1.11 +++ py2texi.el 10 Mar 2005 05:02:18 -0000 1.12 @@ -238,7 +238,7 @@ ("dataline" 1 (progn (setq findex t) "@item \\1\n@findex \\1\n")) ("date" 1 "\\1") ("declaremodule" 2 (progn (setq cindex t) "@label{\\2}@cindex{\\2}")) - ("deprecated" 2 "@emph{This is deprecated in Python \\1. \\2}") + ("deprecated" 2 "@emph{This is deprecated in Python \\1. \\2}\n\n") ("dfn" 1 "@dfn{\\1}") ("documentclass" 1 py2texi-magic) ("e" 0 "@backslash{}") @@ -279,6 +279,7 @@ ("large" 0 "") ("ldots" 0 "@dots{}") ("leftline" 1 "\\1") + ("leq" 0 "<=") ("lineii" 2 "@item \\1 @tab \\2") ("lineiii" 3 "@item \\1 @tab \\2 @tab \\3") ("lineiv" 4 "@item \\1 @tab \\2 @tab \\3 @tab \\4") @@ -380,7 +381,15 @@ ("textasciitilde" 0 "~") ("textasciicircum" 0 "^") ("textbackslash" 0 "@backslash{}") + ("textbar" 0 "|") + ; Some common versions of Texinfo don't support @euro yet: + ; ("texteuro" 0 "@euro{}") + ; Unfortunately, this alternate spelling doesn't actually apply to + ; the usage found in Python Tutorial, which actually requires a + ; Euro symbol to make sense, so this is commented out as well. + ; ("texteuro" 0 "Euro ") ("textgreater" 0 ">") + ("textit" 1 "@i{\\1}") ("textless" 0 "<") ("textrm" 1 "\\1") ("texttt" 1 "@code{\\1}") From anthonybaxter at users.sourceforge.net Thu Mar 10 14:45:42 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Thu Mar 10 14:45:47 2005 Subject: [Python-checkins] python/dist/src LICENSE,1.33,1.33.2.1 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16239 Modified Files: Tag: release24-maint LICENSE Log Message: damn. Index: LICENSE =================================================================== RCS file: /cvsroot/python/python/dist/src/LICENSE,v retrieving revision 1.33 retrieving revision 1.33.2.1 diff -u -d -r1.33 -r1.33.2.1 --- LICENSE 26 Oct 2004 14:38:48 -0000 1.33 +++ LICENSE 10 Mar 2005 13:45:23 -0000 1.33.2.1 @@ -47,7 +47,9 @@ 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 2005 PSF yes 2.4 2.3 2004 PSF yes + 2.4.1 2.4.1 2005 PSF yes Footnotes: From anthonybaxter at users.sourceforge.net Thu Mar 10 14:47:19 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Thu Mar 10 14:47:23 2005 Subject: [Python-checkins] python/dist/src LICENSE,1.33,1.34 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16680 Modified Files: LICENSE Log Message: merge from branches Index: LICENSE =================================================================== RCS file: /cvsroot/python/python/dist/src/LICENSE,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- LICENSE 26 Oct 2004 14:38:48 -0000 1.33 +++ LICENSE 10 Mar 2005 13:47:17 -0000 1.34 @@ -47,7 +47,9 @@ 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 2005 PSF yes 2.4 2.3 2004 PSF yes + 2.4.1 2.4 2005 PSF yes Footnotes: @@ -83,9 +85,9 @@ prepare derivative works, distribute, and otherwise use Python alone or in any derivative version, provided, however, that PSF's License Agreement and PSF's notice of copyright, i.e., "Copyright (c) -2001, 2002, 2003, 2004 Python Software Foundation; All Rights Reserved" -are retained in Python alone or in any derivative version prepared -by Licensee. +2001, 2002, 2003, 2004, 2005 Python Software Foundation; All Rights +Reserved" are retained in Python alone or in any derivative version +prepared by Licensee. 3. In the event Licensee prepares a derivative work that is based on or incorporates Python or any part thereof, and wants to make From bcannon at users.sourceforge.net Fri Mar 11 01:04:20 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Fri Mar 11 01:04:22 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libsocket.tex,1.88,1.89 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16661/Doc/lib Modified Files: libsocket.tex Log Message: Fix test for socket.getfqdn() to also include the name returned by socket.gethostname() in the check for a valid return. Also clarified docs (official and docstring) that the value from gethostname() is returned if gethostbyaddr() doesn't do the job. Index: libsocket.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsocket.tex,v retrieving revision 1.88 retrieving revision 1.89 diff -u -d -r1.88 -r1.89 --- libsocket.tex 26 Aug 2004 00:51:16 -0000 1.88 +++ libsocket.tex 11 Mar 2005 00:04:17 -0000 1.89 @@ -202,8 +202,8 @@ host. To find the fully qualified name, the hostname returned by \function{gethostbyaddr()} is checked, then aliases for the host, if available. The first name which includes a period is selected. In -case no fully qualified domain name is available, the hostname is -returned. +case no fully qualified domain name is available, the hostname as +returned by \function{gethostname()} is returned. \versionadded{2.0} \end{funcdesc} From bcannon at users.sourceforge.net Fri Mar 11 01:04:20 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Fri Mar 11 01:04:25 2005 Subject: [Python-checkins] python/dist/src/Lib socket.py,1.45,1.46 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16661/Lib Modified Files: socket.py Log Message: Fix test for socket.getfqdn() to also include the name returned by socket.gethostname() in the check for a valid return. Also clarified docs (official and docstring) that the value from gethostname() is returned if gethostbyaddr() doesn't do the job. Index: socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/socket.py,v retrieving revision 1.45 retrieving revision 1.46 diff -u -d -r1.45 -r1.46 --- socket.py 9 Aug 2004 04:51:40 -0000 1.45 +++ socket.py 11 Mar 2005 00:04:16 -0000 1.46 @@ -102,7 +102,7 @@ First the hostname returned by gethostbyaddr() is checked, then possibly existing aliases. In case no FQDN is available, hostname - is returned. + from gethostname() is returned. """ name = name.strip() if not name or name == '0.0.0.0': From bcannon at users.sourceforge.net Fri Mar 11 01:04:21 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Fri Mar 11 01:04:26 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_socket.py, 1.77, 1.78 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16661/Lib/test Modified Files: test_socket.py Log Message: Fix test for socket.getfqdn() to also include the name returned by socket.gethostname() in the check for a valid return. Also clarified docs (official and docstring) that the value from gethostname() is returned if gethostbyaddr() doesn't do the job. Index: test_socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v retrieving revision 1.77 retrieving revision 1.78 diff -u -d -r1.77 -r1.78 --- test_socket.py 20 Nov 2004 21:10:07 -0000 1.77 +++ test_socket.py 11 Mar 2005 00:04:17 -0000 1.78 @@ -267,7 +267,7 @@ except socket.error: # Probably a similar problem as above; skip this test return - all_host_names = [hname] + aliases + all_host_names = [hostname, hname] + aliases fqhn = socket.getfqdn() if not fqhn in all_host_names: self.fail("Error testing host resolution mechanisms.") From bcannon at users.sourceforge.net Fri Mar 11 01:56:25 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Fri Mar 11 01:56:30 2005 Subject: [Python-checkins] python/nondist/peps pep-3000.txt,1.12,1.13 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31197 Modified Files: pep-3000.txt Log Message: Add references to Guido's "The fate of reduce() in Python 3000" blog entry for the removal of 'map', 'filter', 'reduce', and 'lambda'. Index: pep-3000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-3000.txt,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- pep-3000.txt 5 Mar 2005 19:38:42 -0000 1.12 +++ pep-3000.txt 11 Mar 2005 00:56:22 -0000 1.13 @@ -74,10 +74,10 @@ To be removed: -* The ``lambda`` statement [1]_ -* String exceptions [2]_ +* The ``lambda`` statement: use nested functions [1]_, [9]_ +* String exceptions: use instances of an Exception class [2]_ * ```x```: use ``repr(x)`` [2]_ -* The ``<>`` operator (use ``!=`` instead) [3]_ +* The ``<>`` operator: use ``!=`` instead [3]_ * Unbound methods [7]_ @@ -102,9 +102,9 @@ * ``execfile()``, ``reload()``: use ``exec()`` [2]_ * ``input()``: use ``eval(sys.stdin.readline())`` [2]_ * ``intern()``, ``id()``: put in ``sys`` [2]_ -* ``map()``, ``filter()``: use list comprehensions instead [1]_ +* ``map()``, ``filter()``: use list comprehensions instead [1]_, [9]_ +* ``reduce()``: write a loop instead [2]_, [9]_ * ``raw_input()``: use ``sys.stdin.readline()`` [2]_ -* ``reduce()``: write a loop instead [2]_ * ``xrange()``: use ``range()`` instead [1]_ @@ -147,6 +147,9 @@ objects can be used") http://mail.python.org/pipermail/python-dev/2005-February/051674.html +.. [9] Guido's blog ("The fate of reduce() in Python 3000") + http://www.artima.com/weblogs/viewpost.jsp?thread=98196 + Copyright ========= From rhettinger at users.sourceforge.net Fri Mar 11 07:46:50 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Mar 11 07:46:55 2005 Subject: [Python-checkins] python/dist/src/Lib inspect.py,1.60,1.61 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16083 Modified Files: inspect.py Log Message: Apply itemgetter() instead of lambda. Index: inspect.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/inspect.py,v retrieving revision 1.60 retrieving revision 1.61 diff -u -d -r1.60 -r1.61 --- inspect.py 6 Feb 2005 06:57:07 -0000 1.60 +++ inspect.py 11 Mar 2005 06:46:45 -0000 1.61 @@ -29,6 +29,7 @@ __date__ = '1 Jan 2001' import sys, os, types, string, re, dis, imp, tokenize, linecache +from operator import attrgetter # ----------------------------------------------------------- type-checking def ismodule(object): @@ -567,7 +568,7 @@ def walktree(classes, children, parent): """Recursive helper function for getclasstree().""" results = [] - classes.sort(key=lambda c: (c.__module__, c.__name__)) + classes.sort(key=attrgetter('__module__', '__name__')) for c in classes: results.append((c, c.__bases__)) if c in children: From rhettinger at users.sourceforge.net Fri Mar 11 07:48:52 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Mar 11 07:48:55 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_functional.py, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16418/lib/test Modified Files: test_functional.py Log Message: Test partial() with bound/unbound methods. Index: test_functional.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_functional.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- test_functional.py 8 Mar 2005 06:14:51 -0000 1.2 +++ test_functional.py 11 Mar 2005 06:48:49 -0000 1.3 @@ -133,7 +133,13 @@ f = None self.assertRaises(ReferenceError, getattr, p, 'func') - + def test_with_bound_and_unbound_methods(self): + data = map(str, range(10)) + join = self.thetype(str.join, '') + self.assertEqual(join(data), '0123456789') + join = self.thetype(''.join) + self.assertEqual(join(data), '0123456789') + class PartialSubclass(functional.partial): pass From rhettinger at users.sourceforge.net Fri Mar 11 07:49:45 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Mar 11 07:49:48 2005 Subject: [Python-checkins] python/dist/src/Python bltinmodule.c,2.320,2.321 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16483/Python Modified Files: bltinmodule.c Log Message: Add two new functions, any() and all(). Index: bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.320 retrieving revision 2.321 diff -u -d -r2.320 -r2.321 --- bltinmodule.c 7 Dec 2004 00:25:35 -0000 2.320 +++ bltinmodule.c 11 Mar 2005 06:49:40 -0000 2.321 @@ -68,6 +68,69 @@ \n\ Return the absolute value of the argument."); +static PyObject * +builtin_all(PyObject *self, PyObject *v) +{ + PyObject *it, *item; + + it = PyObject_GetIter(v); + if (it == NULL) + return NULL; + + while ((item = PyIter_Next(it)) != NULL) { + int cmp = PyObject_IsTrue(item); + Py_DECREF(item); + if (cmp < 0) { + Py_DECREF(it); + return NULL; + } + if (cmp == 0) { + Py_DECREF(it); + Py_RETURN_FALSE; + } + } + Py_DECREF(it); + if (PyErr_Occurred()) + return NULL; + Py_RETURN_TRUE; +} + +PyDoc_STRVAR(all_doc, +"all(iterable) -> bool\n\ +\n\ +Return True if bool(x) is True for all values x in the iterable."); + +static PyObject * +builtin_any(PyObject *self, PyObject *v) +{ + PyObject *it, *item; + + it = PyObject_GetIter(v); + if (it == NULL) + return NULL; + + while ((item = PyIter_Next(it)) != NULL) { + int cmp = PyObject_IsTrue(item); + Py_DECREF(item); + if (cmp < 0) { + Py_DECREF(it); + return NULL; + } + if (cmp == 1) { + Py_DECREF(it); + Py_RETURN_TRUE; + } + } + Py_DECREF(it); + if (PyErr_Occurred()) + return NULL; + Py_RETURN_FALSE; +} + +PyDoc_STRVAR(any_doc, +"any(iterable) -> bool\n\ +\n\ +Return True if bool(x) is True for any x in the iterable."); static PyObject * builtin_apply(PyObject *self, PyObject *args) @@ -2125,6 +2188,8 @@ static PyMethodDef builtin_methods[] = { {"__import__", builtin___import__, METH_VARARGS, import_doc}, {"abs", builtin_abs, METH_O, abs_doc}, + {"all", builtin_all, METH_O, all_doc}, + {"any", builtin_any, METH_O, any_doc}, {"apply", builtin_apply, METH_VARARGS, apply_doc}, {"callable", builtin_callable, METH_O, callable_doc}, {"chr", builtin_chr, METH_VARARGS, chr_doc}, From rhettinger at users.sourceforge.net Fri Mar 11 07:50:06 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Mar 11 07:50:09 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libfuncs.tex,1.179,1.180 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16483/Doc/lib Modified Files: libfuncs.tex Log Message: Add two new functions, any() and all(). Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.179 retrieving revision 1.180 diff -u -d -r1.179 -r1.180 --- libfuncs.tex 7 Jan 2005 04:33:44 -0000 1.179 +++ libfuncs.tex 11 Mar 2005 06:49:32 -0000 1.180 @@ -60,6 +60,32 @@ complex number, its magnitude is returned. \end{funcdesc} +\begin{funcdesc}{all}{iterable} + Return True if all elements of the \var{iterable} are true. + Equivalent to: + \begin{verbatim} + def all(iterable): + for element in iterable: + if not element: + return False + return True + \end{verbatim} + \versionadded{2.5} +\end{funcdesc} + +\begin{funcdesc}{any}{iterable} + Return True if any element of the \var{iterable} is true. + Equivalent to: + \begin{verbatim} + def any(iterable): + for element in iterable: + if element: + return True + return False + \end{verbatim} + \versionadded{2.5} +\end{funcdesc} + \begin{funcdesc}{basestring}{} This abstract type is the superclass for \class{str} and \class{unicode}. It cannot be called or instantiated, but it can be used to test whether From rhettinger at users.sourceforge.net Fri Mar 11 07:50:06 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Mar 11 07:50:12 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_builtin.py, 1.39, 1.40 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16483/Lib/test Modified Files: test_builtin.py Log Message: Add two new functions, any() and all(). Index: test_builtin.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_builtin.py,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- test_builtin.py 16 Jan 2005 00:21:28 -0000 1.39 +++ test_builtin.py 11 Mar 2005 06:49:33 -0000 1.40 @@ -92,6 +92,14 @@ (unichr(0x200), ValueError), ] +class TestFailingBool: + def __nonzero__(self): + raise RuntimeError + +class TestFailingIter: + def __iter__(self): + raise RuntimeError + class BuiltinTest(unittest.TestCase): def test_import(self): @@ -117,6 +125,34 @@ # str self.assertRaises(TypeError, abs, 'a') + def test_all(self): + self.assertEqual(all([2, 4, 6]), True) + self.assertEqual(all([2, None, 6]), False) + self.assertRaises(RuntimeError, all, [2, TestFailingBool(), 6]) + self.assertRaises(RuntimeError, all, TestFailingIter()) + self.assertRaises(TypeError, all, 10) # Non-iterable + self.assertRaises(TypeError, all) # No args + self.assertRaises(TypeError, all, [2, 4, 6], []) # Too many args + self.assertEqual(all([]), True) # Empty iterator + S = [50, 60] + self.assertEqual(all(x > 42 for x in S), True) + S = [50, 40, 60] + self.assertEqual(all(x > 42 for x in S), False) + + def test_any(self): + self.assertEqual(any([None, None, None]), False) + self.assertEqual(any([None, 4, None]), True) + self.assertRaises(RuntimeError, any, [None, TestFailingBool(), 6]) + self.assertRaises(RuntimeError, all, TestFailingIter()) + self.assertRaises(TypeError, any, 10) # Non-iterable + self.assertRaises(TypeError, any) # No args + self.assertRaises(TypeError, any, [2, 4, 6], []) # Too many args + self.assertEqual(any([]), False) # Empty iterator + S = [40, 60, 30] + self.assertEqual(any(x > 42 for x in S), True) + S = [10, 20, 30] + self.assertEqual(any(x > 42 for x in S), False) + def test_apply(self): def f0(*args): self.assertEqual(args, ()) From rhettinger at users.sourceforge.net Fri Mar 11 07:50:13 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Mar 11 07:50:16 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1271,1.1272 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16483/Misc Modified Files: NEWS Log Message: Add two new functions, any() and all(). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1271 retrieving revision 1.1272 diff -u -d -r1.1271 -r1.1272 --- NEWS 9 Mar 2005 16:38:31 -0000 1.1271 +++ NEWS 11 Mar 2005 06:49:34 -0000 1.1272 @@ -10,6 +10,8 @@ Core and builtins ----------------- +- Added two new builtins, any() and all(). + - Defining a class with empty parentheses is now allowed (e.g., ``class C(): pass`` is no longer a syntax error) From tim_one at users.sourceforge.net Fri Mar 11 18:21:00 2005 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Mar 11 18:21:04 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.34, 1.1193.2.35 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17973/Misc Modified Files: Tag: release24-maint NEWS Log Message: Bug #1160802: Can't build Zope on Windows w/ 2.4.1c1. MSVCCompiler.initialize(): set self.initialized to True, as suggested by AMK. Else we keep growing the PATH endlessly, with each new C extension built, until putenv() complains. This doesn't appear to be an issue on the HEAD (MSVCCompiler initializes itself via __init__() on the HEAD). Also added a "2.4.1c2" section to NEWS. Not meant to imply that Anthony will do a 2.4.1c2 release, just needed to a place to put the news about the MSVCCompiler bugfix. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.34 retrieving revision 1.1193.2.35 diff -u -d -r1.1193.2.34 -r1.1193.2.35 --- NEWS 9 Mar 2005 11:54:25 -0000 1.1193.2.34 +++ NEWS 11 Mar 2005 17:20:43 -0000 1.1193.2.35 @@ -4,6 +4,24 @@ (editors: check NEWS.help for information about editing NEWS using ReST.) +What's New in Python 2.4.1c2? +============================= + +*Release date: DD-MAR-2005* + +Library +------- + +- Bug #1160802: can't build Zope on Windows with 2.4.1c1. The + ``MSVCCompiler`` class in distutils forgot to record that it was + initialized, and continued adding redundant entries to the system + ``PATH`` environment variable until ``putenv()`` complained about the + size. This only affected building projects with many C extensions, + and only on Windows using Microsoft's compiler. This wasn't visible + before because a bugfix first included in 2.4.1c1 provoked it (bug + #1110478: revert os.environ.update to do putenv again). + + What's New in Python 2.4.1c1? ============================= @@ -20,7 +38,7 @@ - Bug #1124295: the __name__ attribute of file objects was inadvertently made inaccessible in restricted mode. -- Bug #1074011: closing sys.std{out,err} now causes a flush() and +- Bug #1074011: closing sys.std{out,err} now causes a flush() and an ferror() call. - Bug #1085744: Add missing overflow check to PySequence_Tuple(). @@ -124,9 +142,9 @@ - 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 + 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 @@ -144,7 +162,7 @@ Mac OS 9 and change to reflect the state for OS X. Closes patch #1095802. Thanks Jack Jansen. - + What's New in Python 2.4 final? =============================== From tim_one at users.sourceforge.net Fri Mar 11 18:21:16 2005 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Fri Mar 11 18:21:20 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils msvccompiler.py, 1.64.2.2, 1.64.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17973/Lib/distutils Modified Files: Tag: release24-maint msvccompiler.py Log Message: Bug #1160802: Can't build Zope on Windows w/ 2.4.1c1. MSVCCompiler.initialize(): set self.initialized to True, as suggested by AMK. Else we keep growing the PATH endlessly, with each new C extension built, until putenv() complains. This doesn't appear to be an issue on the HEAD (MSVCCompiler initializes itself via __init__() on the HEAD). Also added a "2.4.1c2" section to NEWS. Not meant to imply that Anthony will do a 2.4.1c2 release, just needed to a place to put the news about the MSVCCompiler bugfix. Index: msvccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/msvccompiler.py,v retrieving revision 1.64.2.2 retrieving revision 1.64.2.3 diff -u -d -r1.64.2.2 -r1.64.2.3 --- msvccompiler.py 9 Mar 2005 11:45:49 -0000 1.64.2.2 +++ msvccompiler.py 11 Mar 2005 17:20:41 -0000 1.64.2.3 @@ -255,6 +255,8 @@ ] self.ldflags_static = [ '/nologo'] + self.initialized = True + # -- Worker methods ------------------------------------------------ From rhettinger at users.sourceforge.net Fri Mar 11 23:17:32 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Mar 11 23:17:36 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libitertools.tex, 1.33, 1.34 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1726/Doc/lib Modified Files: libitertools.tex Log Message: Revised the itertools quantifier recipes to match the performance of the new builtins. Index: libitertools.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libitertools.tex,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- libitertools.tex 5 Dec 2004 09:25:48 -0000 1.33 +++ libitertools.tex 11 Mar 2005 22:17:29 -0000 1.34 @@ -461,26 +461,26 @@ "Returns the nth item" return list(islice(iterable, n, n+1)) -def all(seq, pred=bool): - "Returns True if pred(x) is True for every element in the iterable" +def all(seq, pred=None): + "Returns True if pred(x) is true for every element in the iterable" for elem in ifilterfalse(pred, seq): return False return True -def any(seq, pred=bool): - "Returns True if pred(x) is True for at least one element in the iterable" +def any(seq, pred=None): + "Returns True if pred(x) is true for at least one element in the iterable" for elem in ifilter(pred, seq): return True return False -def no(seq, pred=bool): - "Returns True if pred(x) is False for every element in the iterable" +def no(seq, pred=None): + "Returns True if pred(x) is false for every element in the iterable" for elem in ifilter(pred, seq): return False return True -def quantify(seq, pred=bool): - "Count how many times the predicate is True in the sequence" +def quantify(seq, pred=None): + "Count how many times the predicate is true in the sequence" return sum(imap(pred, seq)) def padnone(seq): From rhettinger at users.sourceforge.net Fri Mar 11 23:17:33 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Mar 11 23:17:39 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_itertools.py, 1.37, 1.38 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1726/Lib/test Modified Files: test_itertools.py Log Message: Revised the itertools quantifier recipes to match the performance of the new builtins. Index: test_itertools.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_itertools.py,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- test_itertools.py 5 Dec 2004 09:25:49 -0000 1.37 +++ test_itertools.py 11 Mar 2005 22:17:30 -0000 1.38 @@ -799,26 +799,26 @@ ... "Returns the nth item" ... return list(islice(iterable, n, n+1)) ->>> def all(seq, pred=bool): -... "Returns True if pred(x) is True for every element in the iterable" +>>> def all(seq, pred=None): +... "Returns True if pred(x) is true for every element in the iterable" ... for elem in ifilterfalse(pred, seq): ... return False ... return True ->>> def any(seq, pred=bool): -... "Returns True if pred(x) is True for at least one element in the iterable" +>>> def any(seq, pred=None): +... "Returns True if pred(x) is true for at least one element in the iterable" ... for elem in ifilter(pred, seq): ... return True ... return False ->>> def no(seq, pred=bool): -... "Returns True if pred(x) is False for every element in the iterable" +>>> def no(seq, pred=None): +... "Returns True if pred(x) is false for every element in the iterable" ... for elem in ifilter(pred, seq): ... return False ... return True ->>> def quantify(seq, pred=bool): -... "Count how many times the predicate is True in the sequence" +>>> def quantify(seq, pred=None): +... "Count how many times the predicate is true in the sequence" ... return sum(imap(pred, seq)) >>> def padnone(seq): From bcannon at users.sourceforge.net Sat Mar 12 07:15:58 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Mar 12 07:16:03 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_socket.py, 1.77, 1.77.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21638/Lib/test Modified Files: Tag: release24-maint test_socket.py Log Message: Fix test_socket's test for socket.getfqdn() to also accept the result from socket.gethostname() as a valid return value. Also clarified the docs as they were a little hazy on the subject matter. Index: test_socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_socket.py,v retrieving revision 1.77 retrieving revision 1.77.2.1 diff -u -d -r1.77 -r1.77.2.1 --- test_socket.py 20 Nov 2004 21:10:07 -0000 1.77 +++ test_socket.py 12 Mar 2005 06:15:55 -0000 1.77.2.1 @@ -267,7 +267,7 @@ except socket.error: # Probably a similar problem as above; skip this test return - all_host_names = [hname] + aliases + all_host_names = [hostname, hname] + aliases fqhn = socket.getfqdn() if not fqhn in all_host_names: self.fail("Error testing host resolution mechanisms.") From bcannon at users.sourceforge.net Sat Mar 12 07:16:00 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Mar 12 07:16:04 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.35, 1.1193.2.36 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21638/Misc Modified Files: Tag: release24-maint NEWS Log Message: Fix test_socket's test for socket.getfqdn() to also accept the result from socket.gethostname() as a valid return value. Also clarified the docs as they were a little hazy on the subject matter. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.35 retrieving revision 1.1193.2.36 diff -u -d -r1.1193.2.35 -r1.1193.2.36 --- NEWS 11 Mar 2005 17:20:43 -0000 1.1193.2.35 +++ NEWS 12 Mar 2005 06:15:56 -0000 1.1193.2.36 @@ -22,6 +22,14 @@ #1110478: revert os.environ.update to do putenv again). +Tests +----- + +- Fix the test for socket.getfqdn() in test_socket to also consider the host + name returned by socket.gethostname() a valid return value for getfqdn(). + Also clarified the wording of docs and docstring that this is the case. + + What's New in Python 2.4.1c1? ============================= From bcannon at users.sourceforge.net Sat Mar 12 07:16:27 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Mar 12 07:16:30 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libsocket.tex, 1.88, 1.88.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21638/Doc/lib Modified Files: Tag: release24-maint libsocket.tex Log Message: Fix test_socket's test for socket.getfqdn() to also accept the result from socket.gethostname() as a valid return value. Also clarified the docs as they were a little hazy on the subject matter. Index: libsocket.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libsocket.tex,v retrieving revision 1.88 retrieving revision 1.88.2.1 diff -u -d -r1.88 -r1.88.2.1 --- libsocket.tex 26 Aug 2004 00:51:16 -0000 1.88 +++ libsocket.tex 12 Mar 2005 06:15:54 -0000 1.88.2.1 @@ -202,8 +202,8 @@ host. To find the fully qualified name, the hostname returned by \function{gethostbyaddr()} is checked, then aliases for the host, if available. The first name which includes a period is selected. In -case no fully qualified domain name is available, the hostname is -returned. +case no fully qualified domain name is available, the hostname as +returned by \function{gethostname()} is returned. \versionadded{2.0} \end{funcdesc} From bcannon at users.sourceforge.net Sat Mar 12 07:16:28 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Mar 12 07:16:33 2005 Subject: [Python-checkins] python/dist/src/Lib socket.py,1.45,1.45.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21638/Lib Modified Files: Tag: release24-maint socket.py Log Message: Fix test_socket's test for socket.getfqdn() to also accept the result from socket.gethostname() as a valid return value. Also clarified the docs as they were a little hazy on the subject matter. Index: socket.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/socket.py,v retrieving revision 1.45 retrieving revision 1.45.2.1 diff -u -d -r1.45 -r1.45.2.1 --- socket.py 9 Aug 2004 04:51:40 -0000 1.45 +++ socket.py 12 Mar 2005 06:15:55 -0000 1.45.2.1 @@ -102,7 +102,7 @@ First the hostname returned by gethostbyaddr() is checked, then possibly existing aliases. In case no FQDN is available, hostname - is returned. + as returned by gethostname() is returned. """ name = name.strip() if not name or name == '0.0.0.0': From jlgijsbers at users.sourceforge.net Sat Mar 12 17:37:14 2005 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sat Mar 12 17:37:18 2005 Subject: [Python-checkins] python/dist/src/Lib/test inspect_fodder2.py, 1.3, 1.4 test_inspect.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-serv2176/test Modified Files: inspect_fodder2.py test_inspect.py Log Message: Patch #1159931/bug #1143895: inspect.getsource failed when functions, etc., had comments after the colon, and some other cases. This patch take a simpler approach that doesn't rely on looking for a ':'. Thanks Simon Percivall! Index: inspect_fodder2.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/inspect_fodder2.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- inspect_fodder2.py 7 Jan 2005 16:01:23 -0000 1.3 +++ inspect_fodder2.py 12 Mar 2005 16:37:11 -0000 1.4 @@ -53,3 +53,14 @@ def setfunc(func): globals()["anonymous"] = func setfunc(lambda x, y: x*y) + +# line 57 +def with_comment(): # hello + world + +# line 61 +multiline_sig = [ + lambda (x, + y): x+y, + None, + ] Index: test_inspect.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_inspect.py,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- test_inspect.py 7 Jan 2005 16:01:23 -0000 1.19 +++ test_inspect.py 12 Mar 2005 16:37:11 -0000 1.20 @@ -229,6 +229,15 @@ # as argument to another function. self.assertSourceEqual(mod2.anonymous, 55, 55) +class TestBuggyCases(GetSourceBase): + fodderFile = mod2 + + def test_with_comment(self): + self.assertSourceEqual(mod2.with_comment, 58, 59) + + def test_multiline_sig(self): + self.assertSourceEqual(mod2.multiline_sig[0], 63, 64) + # Helper for testing classify_class_attrs. def attrs_wo_objs(cls): return [t[:3] for t in inspect.classify_class_attrs(cls)] @@ -414,6 +423,7 @@ def test_main(): run_unittest(TestDecorators, TestRetrievingSourceCode, TestOneliners, + TestBuggyCases, TestInterpreterStack, TestClassesAndFunctions, TestPredicates) if __name__ == "__main__": From jlgijsbers at users.sourceforge.net Sat Mar 12 17:37:14 2005 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sat Mar 12 17:37:19 2005 Subject: [Python-checkins] python/dist/src/Lib inspect.py,1.61,1.62 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2176 Modified Files: inspect.py Log Message: Patch #1159931/bug #1143895: inspect.getsource failed when functions, etc., had comments after the colon, and some other cases. This patch take a simpler approach that doesn't rely on looking for a ':'. Thanks Simon Percivall! Index: inspect.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/inspect.py,v retrieving revision 1.61 retrieving revision 1.62 diff -u -d -r1.61 -r1.62 --- inspect.py 11 Mar 2005 06:46:45 -0000 1.61 +++ inspect.py 12 Mar 2005 16:37:08 -0000 1.62 @@ -504,6 +504,7 @@ """Provide a tokeneater() method to detect the end of a code block.""" def __init__(self): self.indent = 0 + self.islambda = False self.started = False self.passline = False self.last = 0 @@ -511,11 +512,8 @@ def tokeneater(self, type, token, (srow, scol), (erow, ecol), line): if not self.started: if token in ("def", "class", "lambda"): - lastcolon = line.rfind(":") - if lastcolon: - oneline = re.search(r"\w", line[lastcolon:]) - if oneline and line[-2:] != "\\\n": - raise EndOfBlock, srow + if token == "lambda": + self.islambda = True self.started = True self.passline = True elif type == tokenize.NEWLINE: @@ -523,6 +521,8 @@ self.last = srow elif self.passline: pass + elif self.islambda: + raise EndOfBlock, self.last elif type == tokenize.INDENT: self.indent = self.indent + 1 self.passline = True From jlgijsbers at users.sourceforge.net Sat Mar 12 17:38:42 2005 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sat Mar 12 17:38:47 2005 Subject: [Python-checkins] python/dist/src/Lib inspect.py,1.58.2.1,1.58.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3224 Modified Files: Tag: release24-maint inspect.py Log Message: Backport of patch #1159931/bug #1143895: inspect.getsource failed when functions, etc., had comments after the colon, and some other cases. This patch take a simpler approach that doesn't rely on looking for a ':'. Test cases are not backported, as test_inspect.py has been rewritten using unittest on the trunk. Thanks Simon Percivall! Index: inspect.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/inspect.py,v retrieving revision 1.58.2.1 retrieving revision 1.58.2.2 diff -u -d -r1.58.2.1 -r1.58.2.2 --- inspect.py 31 Dec 2004 09:45:37 -0000 1.58.2.1 +++ inspect.py 12 Mar 2005 16:38:39 -0000 1.58.2.2 @@ -503,6 +503,7 @@ """Provide a tokeneater() method to detect the end of a code block.""" def __init__(self): self.indent = 0 + self.islambda = False self.started = False self.passline = False self.last = 0 @@ -510,11 +511,8 @@ def tokeneater(self, type, token, (srow, scol), (erow, ecol), line): if not self.started: if token in ("def", "class", "lambda"): - lastcolon = line.rfind(":") - if lastcolon: - oneline = re.search(r"\w", line[lastcolon:]) - if oneline and line[-2:] != "\\\n": - raise EndOfBlock, srow + if token == "lambda": + self.islambda = True self.started = True self.passline = True elif type == tokenize.NEWLINE: @@ -522,6 +520,8 @@ self.last = srow elif self.passline: pass + elif self.islambda: + raise EndOfBlock, self.last elif type == tokenize.INDENT: self.indent = self.indent + 1 self.passline = True From jlgijsbers at users.sourceforge.net Sat Mar 12 17:48:53 2005 From: jlgijsbers at users.sourceforge.net (jlgijsbers@users.sourceforge.net) Date: Sat Mar 12 17:48:57 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_inspect.py, 1.16, 1.16.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5299 Modified Files: Tag: release24-maint test_inspect.py Log Message: Patch #1159931: a test case for the buggy cases fixed by the last checkin. Index: test_inspect.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_inspect.py,v retrieving revision 1.16 retrieving revision 1.16.2.1 diff -u -d -r1.16 -r1.16.2.1 --- test_inspect.py 18 Aug 2004 12:40:31 -0000 1.16 +++ test_inspect.py 12 Mar 2005 16:48:50 -0000 1.16.2.1 @@ -26,7 +26,7 @@ docstring.""" # line 27 - def abuse(self, a, b, c): + def abuse(self, a, b, c): # a comment """Another \tdocstring From tim_one at users.sourceforge.net Sat Mar 12 20:06:01 2005 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Sat Mar 12 20:06:05 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils msvccompiler.py, 1.67, 1.68 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11712/Lib/distutils Modified Files: msvccompiler.py Log Message: Port bugfix from 2.4 maint. Bug #1160802: Can't build Zope on Windows w/ 2.4.1c1. MSVCCompiler.initialize(): set self.initialized to True, as suggested by AMK. Else we keep growing the PATH endlessly, with each new C extension built, until putenv() complains. No change to NEWS because the patch that created this bug is also new for 2.5a1 (so there's no change here to any code yet released from HEAD). Index: msvccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/msvccompiler.py,v retrieving revision 1.67 retrieving revision 1.68 diff -u -d -r1.67 -r1.68 --- msvccompiler.py 5 Mar 2005 05:32:14 -0000 1.67 +++ msvccompiler.py 12 Mar 2005 19:05:58 -0000 1.68 @@ -255,6 +255,7 @@ ] self.ldflags_static = [ '/nologo'] + self.initialized = True # -- Worker methods ------------------------------------------------ From vsajip at users.sourceforge.net Sun Mar 13 10:54:40 2005 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Sun Mar 13 10:54:45 2005 Subject: [Python-checkins] python/dist/src/Lib/logging __init__.py, 1.25, 1.26 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/logging In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29824 Modified Files: __init__.py Log Message: Added optional encoding argument to file handlers. Made traceback import unconditional, to avoid lock contention problems which occur when logging from custom importers (SF patch #1158052) Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/logging/__init__.py,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- __init__.py 18 Feb 2005 11:53:32 -0000 1.25 +++ __init__.py 13 Mar 2005 09:54:31 -0000 1.26 @@ -1,4 +1,4 @@ -# Copyright 2001-2004 by Vinay Sajip. All Rights Reserved. +# Copyright 2001-2005 by Vinay Sajip. All Rights Reserved. # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose and without fee is hereby granted, @@ -26,7 +26,12 @@ To use, simply 'import logging' and log away! """ -import sys, os, types, time, string, cStringIO +import sys, os, types, time, string, cStringIO, traceback + +try: + import codecs +except ImportError: + codecs = None try: import thread @@ -37,7 +42,7 @@ __author__ = "Vinay Sajip " __status__ = "beta" __version__ = "0.4.9.6" -__date__ = "03 February 2005" +__date__ = "12 March 2005" #--------------------------------------------------------------------------- # Miscellaneous module data @@ -92,6 +97,7 @@ # loggers are initialized with NOTSET so that they will log all messages, even # at user-defined levels. # + CRITICAL = 50 FATAL = CRITICAL ERROR = 40 @@ -368,7 +374,6 @@ This default implementation just uses traceback.print_exception() """ - import traceback sio = cStringIO.StringIO() traceback.print_exception(ei[0], ei[1], ei[2], None, sio) s = sio.getvalue() @@ -674,7 +679,6 @@ The record which was being processed is passed in to this method. """ if raiseExceptions: - import traceback ei = sys.exc_info() traceback.print_exception(ei[0], ei[1], ei[2], None, sys.stderr) del ei @@ -731,11 +735,17 @@ """ A handler class which writes formatted logging records to disk files. """ - def __init__(self, filename, mode="a"): + def __init__(self, filename, mode='a', encoding=None): """ Open the specified file and use it as the stream for logging. """ - StreamHandler.__init__(self, open(filename, mode)) + if codecs is None: + encoding = None + if encoding is None: + stream = open(filename, mode) + else: + stream = codecs.open(filename, mode, encoding) + StreamHandler.__init__(self, stream) #keep the absolute path, otherwise derived classes which use this #may come a cropper when the current directory changes self.baseFilename = os.path.abspath(filename) @@ -1164,7 +1174,7 @@ filename Specifies that a FileHandler be created, using the specified filename, rather than a StreamHandler. filemode Specifies the mode to open the file, if filename is specified - (if filemode is unspecified, it defaults to "a"). + (if filemode is unspecified, it defaults to 'a'). format Use the specified format string for the handler. datefmt Use the specified date/time format. level Set the root logger level to the specified level. @@ -1181,7 +1191,7 @@ if len(root.handlers) == 0: filename = kwargs.get("filename") if filename: - mode = kwargs.get("filemode", "a") + mode = kwargs.get("filemode", 'a') hdlr = FileHandler(filename, mode) else: stream = kwargs.get("stream") From vsajip at users.sourceforge.net Sun Mar 13 10:56:39 2005 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Sun Mar 13 10:56:44 2005 Subject: [Python-checkins] python/dist/src/Lib/logging handlers.py, 1.20, 1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/logging In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30422 Modified Files: handlers.py Log Message: Added optional encoding argument to file handlers. Index: handlers.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/logging/handlers.py,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- handlers.py 13 Jan 2005 08:23:56 -0000 1.20 +++ handlers.py 13 Mar 2005 09:56:36 -0000 1.21 @@ -1,4 +1,4 @@ -# Copyright 2001-2004 by Vinay Sajip. All Rights Reserved. +# Copyright 2001-2005 by Vinay Sajip. All Rights Reserved. # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose and without fee is hereby granted, @@ -29,6 +29,11 @@ import sys, logging, socket, types, os, string, cPickle, struct, time, glob +try: + import codecs +except ImportError: + codecs = None + # # Some constants... # @@ -45,11 +50,15 @@ Not meant to be instantiated directly. Instead, use RotatingFileHandler or TimedRotatingFileHandler. """ - def __init__(self, filename, mode): + def __init__(self, filename, mode, encoding=None): """ Use the specified filename for streamed logging """ - logging.FileHandler.__init__(self, filename, mode) + if codecs is None: + encoding = None + logging.FileHandler.__init__(self, filename, mode, encoding) + self.mode = mode + self.encoding = encoding def emit(self, record): """ @@ -70,7 +79,7 @@ Handler for logging to a set of files, which switches from one file to the next when the current file reaches a certain size. """ - def __init__(self, filename, mode="a", maxBytes=0, backupCount=0): + def __init__(self, filename, mode='a', maxBytes=0, backupCount=0, encoding=None): """ Open the specified file and use it as the stream for logging. @@ -91,10 +100,9 @@ If maxBytes is zero, rollover never occurs. """ - self.mode = mode if maxBytes > 0: - self.mode = "a" # doesn't make sense otherwise! - BaseRotatingHandler.__init__(self, filename, self.mode) + mode = 'a' # doesn't make sense otherwise! + BaseRotatingHandler.__init__(self, filename, mode, encoding) self.maxBytes = maxBytes self.backupCount = backupCount @@ -118,7 +126,10 @@ os.remove(dfn) os.rename(self.baseFilename, dfn) #print "%s -> %s" % (self.baseFilename, dfn) - self.stream = open(self.baseFilename, "w") + if self.encoding: + self.stream = codecs.open(self.baseFilename, 'w', self.encoding) + else: + self.stream = open(self.baseFilename, 'w') def shouldRollover(self, record): """ @@ -142,8 +153,8 @@ If backupCount is > 0, when rollover is done, no more than backupCount files are kept - the oldest ones are deleted. """ - def __init__(self, filename, when='h', interval=1, backupCount=0): - BaseRotatingHandler.__init__(self, filename, 'a') + def __init__(self, filename, when='h', interval=1, backupCount=0, encoding=None): + BaseRotatingHandler.__init__(self, filename, 'a', encoding) self.when = string.upper(when) self.backupCount = backupCount # Calculate the real rollover interval, which is just the number of @@ -262,7 +273,10 @@ s.sort() os.remove(s[0]) #print "%s -> %s" % (self.baseFilename, dfn) - self.stream = open(self.baseFilename, "w") + if self.encoding: + self.stream = codecs.open(self.baseFilename, 'w', self.encoding) + else: + self.stream = open(self.baseFilename, 'w') self.rolloverAt = int(time.time()) + self.interval class SocketHandler(logging.Handler): From vsajip at users.sourceforge.net Sun Mar 13 10:57:49 2005 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Sun Mar 13 10:57:54 2005 Subject: [Python-checkins] python/dist/src/Lib/logging config.py,1.11,1.12 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/logging In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30814 Modified Files: config.py Log Message: Made traceback unconditional, to avoid lock contention problems when logging errors occur in a custom importer (SF path #1158052). Index: config.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/logging/config.py,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- config.py 18 Feb 2005 11:54:46 -0000 1.11 +++ config.py 13 Mar 2005 09:57:46 -0000 1.12 @@ -1,4 +1,4 @@ -# Copyright 2001-2004 by Vinay Sajip. All Rights Reserved. +# Copyright 2001-2005 by Vinay Sajip. All Rights Reserved. # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose and without fee is hereby granted, @@ -27,7 +27,7 @@ To use, simply 'import logging' and log away! """ -import sys, logging, logging.handlers, string, socket, struct, os +import sys, logging, logging.handlers, string, socket, struct, os, traceback try: import thread @@ -195,7 +195,6 @@ for log in existing: root.manager.loggerDict[log].disabled = 1 except: - import traceback ei = sys.exc_info() traceback.print_exception(ei[0], ei[1], ei[2], None, sys.stderr) del ei From loewis at users.sourceforge.net Sun Mar 13 23:18:28 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Mar 13 23:18:34 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.36, 1.1193.2.37 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12704/Misc Modified Files: Tag: release24-maint NEWS Log Message: Backport of change to os.access to encode Unicode file names with the file system encoding. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.36 retrieving revision 1.1193.2.37 diff -u -d -r1.1193.2.36 -r1.1193.2.37 --- NEWS 12 Mar 2005 06:15:56 -0000 1.1193.2.36 +++ NEWS 13 Mar 2005 22:18:22 -0000 1.1193.2.37 @@ -29,6 +29,11 @@ name returned by socket.gethostname() a valid return value for getfqdn(). Also clarified the wording of docs and docstring that this is the case. +Extensions Modules +------------------ + +- os.access now supports Unicode path names on non-Win32 systems. + What's New in Python 2.4.1c1? ============================= From loewis at users.sourceforge.net Sun Mar 13 23:18:30 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Mar 13 23:18:36 2005 Subject: [Python-checkins] python/dist/src/Modules posixmodule.c, 2.329.2.2, 2.329.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12704/Modules Modified Files: Tag: release24-maint posixmodule.c Log Message: Backport of change to os.access to encode Unicode file names with the file system encoding. Index: posixmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.329.2.2 retrieving revision 2.329.2.3 diff -u -d -r2.329.2.2 -r2.329.2.3 --- posixmodule.c 18 Dec 2004 09:48:40 -0000 2.329.2.2 +++ posixmodule.c 13 Mar 2005 22:18:26 -0000 2.329.2.3 @@ -1113,7 +1113,8 @@ PyErr_Clear(); } #endif - if (!PyArg_ParseTuple(args, "si:access", &path, &mode)) + if (!PyArg_ParseTuple(args, "eti:access", + Py_FileSystemDefaultEncoding, &path, &mode)) return NULL; Py_BEGIN_ALLOW_THREADS res = access(path, mode); From loewis at users.sourceforge.net Sun Mar 13 23:18:55 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Sun Mar 13 23:18:59 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_unicode_file.py, 1.16, 1.16.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12704/Lib/test Modified Files: Tag: release24-maint test_unicode_file.py Log Message: Backport of change to os.access to encode Unicode file names with the file system encoding. Index: test_unicode_file.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode_file.py,v retrieving revision 1.16 retrieving revision 1.16.2.1 diff -u -d -r1.16 -r1.16.2.1 --- test_unicode_file.py 7 Nov 2004 19:57:35 -0000 1.16 +++ test_unicode_file.py 13 Mar 2005 22:18:21 -0000 1.16.2.1 @@ -44,8 +44,10 @@ def _do_single(self, filename): self.failUnless(os.path.exists(filename)) self.failUnless(os.path.isfile(filename)) + self.failUnless(os.access(filename, os.R_OK)) self.failUnless(os.path.exists(os.path.abspath(filename))) self.failUnless(os.path.isfile(os.path.abspath(filename))) + self.failUnless(os.access(os.path.abspath(filename), os.R_OK)) os.chmod(filename, 0777) os.utime(filename, None) os.utime(filename, (time.time(), time.time())) From loewis at users.sourceforge.net Mon Mar 14 18:17:07 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Mar 14 18:17:12 2005 Subject: [Python-checkins] python/dist/src/Tools/msi msi.py, 1.16.2.5, 1.16.2.6 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12140 Modified Files: Tag: release24-maint msi.py Log Message: Add more UUIDs. Update custom actions for Itanium Index: msi.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/msi/msi.py,v retrieving revision 1.16.2.5 retrieving revision 1.16.2.6 diff -u -d -r1.16.2.5 -r1.16.2.6 --- msi.py 30 Dec 2004 14:09:14 -0000 1.16.2.5 +++ msi.py 14 Mar 2005 17:17:04 -0000 1.16.2.6 @@ -81,6 +81,11 @@ '2.4.121': '{75508821-a8e9-40a8-95bd-dbe6033ddbea}', # 2.4c1 '2.4.122': '{83a9118b-4bdd-473b-afc3-bcb142feca9e}', # 2.4c2 '2.4.150': '{82d9302e-f209-4805-b548-52087047483a}', # 2.4.0 + '2.4.1121':'{be027411-8e6b-4440-a29b-b07df0690230}', # 2.4.1c1 + '2.4.1122':'{02818752-48bf-4074-a281-7a4114c4f1b1}', # 2.4.1c2 + '2.4.1150':'{4d4f5346-7e4a-40b5-9387-fdb6181357fc}', # 2.4.1 + '2.4.2121':'{5ef9d6b6-df78-45d2-ab09-14786a3c5a99}', # 2.4.2c1 + '2.4.2150':'{b191e49c-ea23-43b2-b28a-14e0784069b8}', # 2.4.2 } if snapshot: @@ -346,11 +351,17 @@ raise "'nmake /f msisupport.mak' failed" add_data(db, "Binary", [("Script", msilib.Binary("msisupport.dll"))]) # See "Custom Action Type 1" + if msilib.Win64: + CheckDir = "CheckDir" + UpdateEditIdle = "UpdateEditIDLE" + else: + CheckDir = "_CheckDir@4" + UpdateEditIDLE = "_UpdateEditIDLE@4" add_data(db, "CustomAction", - [("CheckDir", 1, "Script", "_CheckDir@4")]) + [("CheckDir", 1, "Script", CheckDir)]) if have_tcl: add_data(db, "CustomAction", - [("UpdateEditIDLE", 1, "Script", "_UpdateEditIDLE@4")]) + [("UpdateEditIDLE", 1, "Script", UpdateEditIDLE)]) # UI customization properties add_data(db, "Property", From loewis at users.sourceforge.net Mon Mar 14 18:20:16 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Mar 14 18:20:20 2005 Subject: [Python-checkins] python/dist/src/Tools/msi msi.py,1.22,1.23 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13064 Modified Files: msi.py Log Message: Add more UUIDs. Update custom actions for Itanium. Backported to 2.4 Index: msi.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/msi/msi.py,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- msi.py 7 Jan 2005 16:01:32 -0000 1.22 +++ msi.py 14 Mar 2005 17:20:13 -0000 1.23 @@ -81,6 +81,11 @@ '2.4.121': '{75508821-a8e9-40a8-95bd-dbe6033ddbea}', # 2.4c1 '2.4.122': '{83a9118b-4bdd-473b-afc3-bcb142feca9e}', # 2.4c2 '2.4.150': '{82d9302e-f209-4805-b548-52087047483a}', # 2.4.0 + '2.4.1121':'{be027411-8e6b-4440-a29b-b07df0690230}', # 2.4.1c1 + '2.4.1122':'{02818752-48bf-4074-a281-7a4114c4f1b1}', # 2.4.1c2 + '2.4.1150':'{4d4f5346-7e4a-40b5-9387-fdb6181357fc}', # 2.4.1 + '2.4.2121':'{5ef9d6b6-df78-45d2-ab09-14786a3c5a99}', # 2.4.2c1 + '2.4.2150':'{b191e49c-ea23-43b2-b28a-14e0784069b8}', # 2.4.2 } if snapshot: @@ -346,11 +351,17 @@ raise "'nmake /f msisupport.mak' failed" add_data(db, "Binary", [("Script", msilib.Binary("msisupport.dll"))]) # See "Custom Action Type 1" + if msilib.Win64: + CheckDir = "CheckDir" + UpdateEditIdle = "UpdateEditIDLE" + else: + CheckDir = "_CheckDir@4" + UpdateEditIDLE = "_UpdateEditIDLE@4" add_data(db, "CustomAction", - [("CheckDir", 1, "Script", "_CheckDir@4")]) + [("CheckDir", 1, "Script", CheckDir)]) if have_tcl: add_data(db, "CustomAction", - [("UpdateEditIDLE", 1, "Script", "_UpdateEditIDLE@4")]) + [("UpdateEditIDLE", 1, "Script", UpdateEditIDLE)]) # UI customization properties add_data(db, "Property", From doerwalter at users.sourceforge.net Mon Mar 14 20:20:23 2005 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Mon Mar 14 20:20:29 2005 Subject: [Python-checkins] python/dist/src/Lib codecs.py,1.35.2.3,1.35.2.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14630/Lib Modified Files: Tag: release24-maint codecs.py Log Message: Backport checkin: Reset internal buffers when seek() is called. This fixes SF bug #1156259. Index: codecs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/codecs.py,v retrieving revision 1.35.2.3 retrieving revision 1.35.2.4 diff -u -d -r1.35.2.3 -r1.35.2.4 --- codecs.py 8 Mar 2005 15:05:14 -0000 1.35.2.3 +++ codecs.py 14 Mar 2005 19:20:15 -0000 1.35.2.4 @@ -356,7 +356,17 @@ from decoding errors. """ - pass + self.bytebuffer = "" + self.charbuffer = u"" + self.atcr = False + + def seek(self, offset, whence): + """ Set the input stream's current position. + + Resets the codec buffers used for keeping state. + """ + self.reset() + self.stream.seek(offset, whence) def next(self): From doerwalter at users.sourceforge.net Mon Mar 14 20:20:23 2005 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Mon Mar 14 20:20:31 2005 Subject: [Python-checkins] python/dist/src/Lib/encodings utf_16.py, 1.5, 1.5.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/encodings In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14630/Lib/encodings Modified Files: Tag: release24-maint utf_16.py Log Message: Backport checkin: Reset internal buffers when seek() is called. This fixes SF bug #1156259. Index: utf_16.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/encodings/utf_16.py,v retrieving revision 1.5 retrieving revision 1.5.2.1 diff -u -d -r1.5 -r1.5.2.1 --- utf_16.py 7 Sep 2004 20:24:21 -0000 1.5 +++ utf_16.py 14 Mar 2005 19:20:18 -0000 1.5.2.1 @@ -31,6 +31,13 @@ class StreamReader(codecs.StreamReader): + def reset(self): + codecs.StreamReader.reset(self) + try: + del self.decode + except AttributeError: + pass + def decode(self, input, errors='strict'): (object, consumed, byteorder) = \ codecs.utf_16_ex_decode(input, errors, 0, False) From doerwalter at users.sourceforge.net Mon Mar 14 20:20:23 2005 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Mon Mar 14 20:20:32 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_codecs.py, 1.15.2.2, 1.15.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14630/Lib/test Modified Files: Tag: release24-maint test_codecs.py Log Message: Backport checkin: Reset internal buffers when seek() is called. This fixes SF bug #1156259. Index: test_codecs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_codecs.py,v retrieving revision 1.15.2.2 retrieving revision 1.15.2.3 diff -u -d -r1.15.2.2 -r1.15.2.3 --- test_codecs.py 10 Jan 2005 12:26:00 -0000 1.15.2.2 +++ test_codecs.py 14 Mar 2005 19:20:19 -0000 1.15.2.3 @@ -24,6 +24,17 @@ return s class ReadTest(unittest.TestCase): + def test_seek(self): + # all codecs should be able to encode these + s = u"%s\n%s\n" % (100*u"abc123", 100*u"def456") + encoding = self.encoding + reader = codecs.getreader(encoding)(StringIO.StringIO(s.encode(encoding))) + for t in xrange(5): + # Test that calling seek resets the internal codec state and buffers + reader.seek(0, 0) + line = reader.readline() + self.assertEqual(s[:len(line)], line) + def check_partial(self, input, partialresults): # get a StreamReader for the encoding and feed the bytestring version # of input to the reader byte by byte. Read every available from From doerwalter at users.sourceforge.net Mon Mar 14 20:25:45 2005 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Mon Mar 14 20:25:49 2005 Subject: [Python-checkins] python/dist/src/Lib codecs.py,1.39,1.40 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16113/Lib Modified Files: codecs.py Log Message: Add default value for "whence" argument. Index: codecs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/codecs.py,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- codecs.py 14 Mar 2005 19:06:25 -0000 1.39 +++ codecs.py 14 Mar 2005 19:25:41 -0000 1.40 @@ -360,7 +360,7 @@ self.charbuffer = u"" self.atcr = False - def seek(self, offset, whence): + def seek(self, offset, whence=0): """ Set the input stream's current position. Resets the codec buffers used for keeping state. From doerwalter at users.sourceforge.net Mon Mar 14 20:26:51 2005 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Mon Mar 14 20:26:57 2005 Subject: [Python-checkins] python/dist/src/Lib codecs.py,1.35.2.4,1.35.2.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16424/Lib Modified Files: Tag: release24-maint codecs.py Log Message: Backport checkin: Add default value for "whence" argument. Index: codecs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/codecs.py,v retrieving revision 1.35.2.4 retrieving revision 1.35.2.5 diff -u -d -r1.35.2.4 -r1.35.2.5 --- codecs.py 14 Mar 2005 19:20:15 -0000 1.35.2.4 +++ codecs.py 14 Mar 2005 19:26:47 -0000 1.35.2.5 @@ -360,7 +360,7 @@ self.charbuffer = u"" self.atcr = False - def seek(self, offset, whence): + def seek(self, offset, whence=0): """ Set the input stream's current position. Resets the codec buffers used for keeping state. From loewis at users.sourceforge.net Mon Mar 14 22:23:56 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Mar 14 22:24:07 2005 Subject: [Python-checkins] python/dist/src configure.in, 1.482, 1.483 configure, 1.469, 1.470 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17774 Modified Files: configure.in configure Log Message: Configure bug reporting address. Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.482 retrieving revision 1.483 diff -u -d -r1.482 -r1.483 --- configure.in 10 Feb 2005 20:45:37 -0000 1.482 +++ configure.in 14 Mar 2005 21:23:31 -0000 1.483 @@ -5,7 +5,7 @@ AC_REVISION($Revision$) AC_PREREQ(2.53) -AC_INIT(python, PYTHON_VERSION) +AC_INIT(python, PYTHON_VERSION, http://www.python.org/python-bugs) AC_CONFIG_SRCDIR([Include/object.h]) AC_CONFIG_HEADER(pyconfig.h) Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.469 retrieving revision 1.470 diff -u -d -r1.469 -r1.470 --- configure 10 Feb 2005 20:45:41 -0000 1.469 +++ configure 14 Mar 2005 21:23:33 -0000 1.470 @@ -1,8 +1,10 @@ #! /bin/sh -# From configure.in Revision: 1.481 . +# From configure.in Revision: 1.482 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59 for python 2.5. # +# Report bugs to . +# # Copyright (C) 2003 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. @@ -270,7 +272,7 @@ PACKAGE_TARNAME='python' PACKAGE_VERSION='2.5' PACKAGE_STRING='python 2.5' -PACKAGE_BUGREPORT='' +PACKAGE_BUGREPORT='http://www.python.org/python-bugs' ac_unique_file="Include/object.h" # Factoring default headers for most tests. @@ -888,6 +890,7 @@ Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. +Report bugs to . _ACEOF fi @@ -4669,9 +4672,9 @@ echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX -## --------------------------------- ## -## Report this to the python lists. ## -## --------------------------------- ## +## ------------------------------------------------ ## +## Report this to http://www.python.org/python-bugs ## +## ------------------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 @@ -5202,9 +5205,9 @@ echo "$as_me: WARNING: sys/mkdev.h: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX -## --------------------------------- ## -## Report this to the python lists. ## -## --------------------------------- ## +## ------------------------------------------------ ## +## Report this to http://www.python.org/python-bugs ## +## ------------------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 @@ -5350,9 +5353,9 @@ echo "$as_me: WARNING: sys/sysmacros.h: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX -## --------------------------------- ## -## Report this to the python lists. ## -## --------------------------------- ## +## ------------------------------------------------ ## +## Report this to http://www.python.org/python-bugs ## +## ------------------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 @@ -11431,9 +11434,9 @@ echo "$as_me: WARNING: cthreads.h: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX -## --------------------------------- ## -## Report this to the python lists. ## -## --------------------------------- ## +## ------------------------------------------------ ## +## Report this to http://www.python.org/python-bugs ## +## ------------------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 @@ -11586,9 +11589,9 @@ echo "$as_me: WARNING: mach/cthreads.h: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX -## --------------------------------- ## -## Report this to the python lists. ## -## --------------------------------- ## +## ------------------------------------------------ ## +## Report this to http://www.python.org/python-bugs ## +## ------------------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 @@ -11918,9 +11921,9 @@ echo "$as_me: WARNING: atheos/threads.h: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX -## --------------------------------- ## -## Report this to the python lists. ## -## --------------------------------- ## +## ------------------------------------------------ ## +## Report this to http://www.python.org/python-bugs ## +## ------------------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 @@ -12068,9 +12071,9 @@ echo "$as_me: WARNING: kernel/OS.h: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX -## --------------------------------- ## -## Report this to the python lists. ## -## --------------------------------- ## +## ------------------------------------------------ ## +## Report this to http://www.python.org/python-bugs ## +## ------------------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 @@ -18254,9 +18257,9 @@ echo "$as_me: WARNING: wchar.h: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX -## --------------------------------- ## -## Report this to the python lists. ## -## --------------------------------- ## +## ------------------------------------------------ ## +## Report this to http://www.python.org/python-bugs ## +## ------------------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 @@ -19752,7 +19755,8 @@ fi # Before we can test tzset, we need to check if struct tm has a tm_zone -# and/or if we support tzname[] +# (which is not required by ISO C or UNIX spec) and/or if we support +# tzname[] echo "$as_me:$LINENO: checking for struct tm.tm_zone" >&5 echo $ECHO_N "checking for struct tm.tm_zone... $ECHO_C" >&6 if test "${ac_cv_member_struct_tm_tm_zone+set}" = set; then @@ -19944,7 +19948,7 @@ fi -# tzset(3) exists and works like we expect it to +# check tzset(3) exists and works like we expect it to echo "$as_me:$LINENO: checking for working tzset()" >&5 echo $ECHO_N "checking for working tzset()... $ECHO_C" >&6 if test "${ac_cv_working_tzset+set}" = set; then @@ -19974,12 +19978,15 @@ /* Note that we need to ensure that not only does tzset(3) do 'something' with localtime, but it works as documented in the library reference and as expected by the test suite. + This includes making sure that tzname is set properly if + tm->tm_zone does not exist since it is the alternative way + of getting timezone info. Red Hat 6.2 doesn't understand the southern hemisphere - after New Year's Day; it thinks swaps on that day. + after New Year's Day. */ - time_t groundhogday = 1044144000; /* GMT-based; well, it's a colony */ + time_t groundhogday = 1044144000; /* GMT-based */ time_t midyear = groundhogday + (365 * 24 * 3600 / 2); putenv("TZ=UTC+0"); From loewis at users.sourceforge.net Mon Mar 14 22:24:58 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Mar 14 22:25:17 2005 Subject: [Python-checkins] python/dist/src configure.in, 1.475.2.6, 1.475.2.7 configure, 1.462.2.6, 1.462.2.7 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17925 Modified Files: Tag: release24-maint configure.in configure Log Message: Configure bug reporting address. Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.475.2.6 retrieving revision 1.475.2.7 diff -u -d -r1.475.2.6 -r1.475.2.7 --- configure.in 10 Feb 2005 22:46:33 -0000 1.475.2.6 +++ configure.in 14 Mar 2005 21:24:51 -0000 1.475.2.7 @@ -5,7 +5,7 @@ AC_REVISION($Revision$) AC_PREREQ(2.53) -AC_INIT(python, PYTHON_VERSION) +AC_INIT(python, PYTHON_VERSION, http://www.python.org/python-bugs) AC_CONFIG_SRCDIR([Include/object.h]) AC_CONFIG_HEADER(pyconfig.h) Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.462.2.6 retrieving revision 1.462.2.7 diff -u -d -r1.462.2.6 -r1.462.2.7 --- configure 10 Feb 2005 22:46:35 -0000 1.462.2.6 +++ configure 14 Mar 2005 21:24:51 -0000 1.462.2.7 @@ -1,8 +1,10 @@ #! /bin/sh -# From configure.in Revision: 1.475.2.5 . +# From configure.in Revision: 1.475.2.6 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59 for python 2.4. # +# Report bugs to . +# # Copyright (C) 2003 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. @@ -270,7 +272,7 @@ PACKAGE_TARNAME='python' PACKAGE_VERSION='2.4' PACKAGE_STRING='python 2.4' -PACKAGE_BUGREPORT='' +PACKAGE_BUGREPORT='http://www.python.org/python-bugs' ac_unique_file="Include/object.h" # Factoring default headers for most tests. @@ -888,6 +890,7 @@ Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. +Report bugs to . _ACEOF fi @@ -4668,9 +4671,9 @@ echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX -## --------------------------------- ## -## Report this to the python lists. ## -## --------------------------------- ## +## ------------------------------------------------ ## +## Report this to http://www.python.org/python-bugs ## +## ------------------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 @@ -5201,9 +5204,9 @@ echo "$as_me: WARNING: sys/mkdev.h: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX -## --------------------------------- ## -## Report this to the python lists. ## -## --------------------------------- ## +## ------------------------------------------------ ## +## Report this to http://www.python.org/python-bugs ## +## ------------------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 @@ -5349,9 +5352,9 @@ echo "$as_me: WARNING: sys/sysmacros.h: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX -## --------------------------------- ## -## Report this to the python lists. ## -## --------------------------------- ## +## ------------------------------------------------ ## +## Report this to http://www.python.org/python-bugs ## +## ------------------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 @@ -11430,9 +11433,9 @@ echo "$as_me: WARNING: cthreads.h: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX -## --------------------------------- ## -## Report this to the python lists. ## -## --------------------------------- ## +## ------------------------------------------------ ## +## Report this to http://www.python.org/python-bugs ## +## ------------------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 @@ -11585,9 +11588,9 @@ echo "$as_me: WARNING: mach/cthreads.h: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX -## --------------------------------- ## -## Report this to the python lists. ## -## --------------------------------- ## +## ------------------------------------------------ ## +## Report this to http://www.python.org/python-bugs ## +## ------------------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 @@ -11917,9 +11920,9 @@ echo "$as_me: WARNING: atheos/threads.h: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX -## --------------------------------- ## -## Report this to the python lists. ## -## --------------------------------- ## +## ------------------------------------------------ ## +## Report this to http://www.python.org/python-bugs ## +## ------------------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 @@ -12067,9 +12070,9 @@ echo "$as_me: WARNING: kernel/OS.h: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX -## --------------------------------- ## -## Report this to the python lists. ## -## --------------------------------- ## +## ------------------------------------------------ ## +## Report this to http://www.python.org/python-bugs ## +## ------------------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 @@ -18251,9 +18254,9 @@ echo "$as_me: WARNING: wchar.h: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX -## --------------------------------- ## -## Report this to the python lists. ## -## --------------------------------- ## +## ------------------------------------------------ ## +## Report this to http://www.python.org/python-bugs ## +## ------------------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 From loewis at users.sourceforge.net Tue Mar 15 01:37:49 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Mar 15 01:37:52 2005 Subject: [Python-checkins] python/dist/src/Tools/msi msi.py, 1.16.2.6, 1.16.2.7 msilib.py, 1.4, 1.4.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3263 Modified Files: Tag: release24-maint msi.py msilib.py Log Message: Reuse componentids for *.dll across minor releases. Indicate to the user when this is an upgrade installation. Make CHM file non-advertised. Index: msi.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/msi/msi.py,v retrieving revision 1.16.2.6 retrieving revision 1.16.2.7 diff -u -d -r1.16.2.6 -r1.16.2.7 --- msi.py 14 Mar 2005 17:17:04 -0000 1.16.2.6 +++ msi.py 15 Mar 2005 00:37:45 -0000 1.16.2.7 @@ -122,6 +122,20 @@ 'parser.pyd', ]) +# Well-known component UUIDs +# These are needed for SharedDLLs reference counter; if +# a different UUID was used for each incarnation of, say, +# python24.dll, an upgrade would set the reference counter +# from 1 to 2 (due to what I consider a bug in MSI) +# Using the same UUID is fine since these files are versioned, +# so Installer will always keep the newest version. +msvcr71_uuid = "{8666C8DD-D0B4-4B42-928E-A69E32FA5D4D}" +pythondll_uuid = { + "24":"{9B81E618-2301-4035-AC77-75D9ABEB7301}", + "25":"{2e41b118-38bd-4c1b-a840-6977efd1b911}" + } [major+minor] + + # Build the mingw import library, libpythonXY.a # This requires 'nm' and 'dlltool' executables on your PATH def build_mingw_lib(lib_file, def_file, dll_file, mingw_lib): @@ -220,6 +234,7 @@ # accordingly. add_data(db, "Property", [("UpgradeCode", uc), ("WhichUsers", "ALL"), + ("ProductLine", "Python%s%s" % (major, minor)), ]) db.Commit() return db @@ -378,6 +393,7 @@ [("DlgFont8", "Tahoma", 9, None, 0), ("DlgFontBold8", "Tahoma", 8, None, 1), #bold ("VerdanaBold10", "Verdana", 10, None, 1), + ("VerdanaRed9", "Verdana", 9, 255, 0), ]) compileargs = r"-Wi [TARGETDIR]Lib\compileall.py -f -x badsyntax [TARGETDIR]Lib" @@ -566,6 +582,9 @@ seldlg = PyDialog(db, "SelectDirectoryDlg", x, y, w, h, modal, title, "Next", "Next", "Cancel") seldlg.title("Select Destination Directory") + c = seldlg.text("Existing", 135, 25, 235, 30, 0x30003, + "{\VerdanaRed9}This update will replace your existing [ProductLine] installation.") + c.condition("Hide", 'REMOVEOLDVERSION="" and REMOVEOLDSNAPSHOT=""') seldlg.text("Description", 135, 50, 220, 40, 0x30003, "Please select a directory for the [ProductName] files.") @@ -865,7 +884,7 @@ dlldir = PyDirectory(db, cab, root, srcdir, "DLLDIR", ".") pydll = "python%s%s.dll" % (major, minor) pydllsrc = srcdir + "/PCBuild/" + pydll - dlldir.start_component("DLLDIR", flags = 8, keyfile = pydll) + dlldir.start_component("DLLDIR", flags = 8, keyfile = pydll, uuid = pythondll_uuid) installer = msilib.MakeInstaller() pyversion = installer.FileVersion(pydllsrc, 0) if not snapshot: @@ -877,7 +896,7 @@ language=installer.FileVersion(pydllsrc, 1)) # XXX determine dependencies version, lang = extract_msvcr71() - dlldir.start_component("msvcr71", flags=8, keyfile="msvcr71.dll") + dlldir.start_component("msvcr71", flags=8, keyfile="msvcr71.dll", uuid=msvcr71_uuid) dlldir.add_file("msvcr71.dll", src=os.path.abspath("msvcr71.dll"), version=version, language=lang) tmpfiles.append("msvcr71.dll") @@ -988,7 +1007,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')] @@ -1047,6 +1066,8 @@ # msidbComponentAttributesRegistryKeyPath = 4 [("REGISTRY", msilib.gen_uuid(), "TARGETDIR", 4, None, "InstallPath"), + ("REGISTRY.doc", msilib.gen_uuid(), "TARGETDIR", 4, None, + "Documentation"), ("REGISTRY.def", msilib.gen_uuid(), "TARGETDIR", 4, None, None)] + tcldata) # See "FeatureComponents Table". @@ -1062,6 +1083,7 @@ tcldata = [(tcltk.id, "pythonw.exe")] add_data(db, "FeatureComponents", [(default_feature.id, "REGISTRY"), + (htmlfiles.id, "REGISTRY.doc"), (ext_feature.id, "REGISTRY.def")] + tcldata ) @@ -1130,7 +1152,7 @@ ("PythonPath", -1, prefix+r"\PythonPath", "", r"[TARGETDIR]Lib;[TARGETDIR]DLLs;[TARGETDIR]Lib\lib-tk", "REGISTRY"), ("Documentation", -1, prefix+r"\Help\Main Python Documentation", "", - r"[TARGETDIR]Doc\Python%s%s.chm" % (major, minor), "REGISTRY"), + r"[TARGETDIR]Doc\Python%s%s.chm" % (major, minor), "REGISTRY.doc"), ("Modules", -1, prefix+r"\Modules", "+", None, "REGISTRY"), ("AppPaths", -1, r"Software\Microsoft\Windows\CurrentVersion\App Paths\Python.exe", "", r"[TARGETDIR]Python.exe", "REGISTRY.def") @@ -1154,9 +1176,14 @@ [# Advertised shortcuts: targets are features, not files ("Python", "MenuDir", "PYTHON|Python (command line)", "python.exe", default_feature.id, None, None, None, "python_icon.exe", 2, None, "TARGETDIR"), - ("Manual", "MenuDir", "MANUAL|Python Manuals", "documentation", - htmlfiles.id, None, None, None, None, None, None, None), + # Advertising the Manual breaks on (some?) Win98, and the shortcut lacks an + # icon first. + #("Manual", "MenuDir", "MANUAL|Python Manuals", "documentation", + # htmlfiles.id, None, None, None, None, None, None, None), ## Non-advertised shortcuts: must be associated with a registry component + ("Manual", "MenuDir", "MANUAL|Python Manuals", "REGISTRY.doc", + "[#Python%s%s.chm]" % (major,minor), None, + None, None, None, None, None, None), ("Uninstall", "MenuDir", "UNINST|Uninstall Python", "REGISTRY", SystemFolderName+"msiexec", "/x%s" % product_code, None, None, None, None, None, None), Index: msilib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/msi/msilib.py,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -d -r1.4 -r1.4.2.1 --- msilib.py 10 Sep 2004 11:55:32 -0000 1.4 +++ msilib.py 15 Mar 2005 00:37:45 -0000 1.4.2.1 @@ -445,7 +445,7 @@ blogical = None add_data(db, "Directory", [(logical, blogical, default)]) - def start_component(self, component = None, feature = None, flags = None, keyfile = None): + def start_component(self, component = None, feature = None, flags = None, keyfile = None, uuid=None): """Add an entry to the Component table, and make this component the current for this directory. If no component name is given, the directory name is used. If no feature is given, the current feature is used. If no flags are given, the directory's default @@ -453,7 +453,10 @@ table.""" if flags is None: flags = self.componentflags - uuid = gen_uuid() + if uuid is None: + uuid = gen_uuid() + else: + uuid = uuid.upper() if component is None: component = self.logical self.component = component From loewis at users.sourceforge.net Tue Mar 15 01:39:43 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Mar 15 01:39:47 2005 Subject: [Python-checkins] python/dist/src/Tools/msi msi.py, 1.23, 1.24 msilib.py, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3736 Modified Files: msi.py msilib.py Log Message: Reuse componentids for *.dll across minor releases. Indicate to the user when this is an upgrade installation. Make CHM file non-advertised. Backported to 2.4. Index: msi.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/msi/msi.py,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- msi.py 14 Mar 2005 17:20:13 -0000 1.23 +++ msi.py 15 Mar 2005 00:39:40 -0000 1.24 @@ -122,6 +122,20 @@ 'parser.pyd', ]) +# Well-known component UUIDs +# These are needed for SharedDLLs reference counter; if +# a different UUID was used for each incarnation of, say, +# python24.dll, an upgrade would set the reference counter +# from 1 to 2 (due to what I consider a bug in MSI) +# Using the same UUID is fine since these files are versioned, +# so Installer will always keep the newest version. +msvcr71_uuid = "{8666C8DD-D0B4-4B42-928E-A69E32FA5D4D}" +pythondll_uuid = { + "24":"{9B81E618-2301-4035-AC77-75D9ABEB7301}", + "25":"{2e41b118-38bd-4c1b-a840-6977efd1b911}" + } [major+minor] + + # Build the mingw import library, libpythonXY.a # This requires 'nm' and 'dlltool' executables on your PATH def build_mingw_lib(lib_file, def_file, dll_file, mingw_lib): @@ -220,6 +234,7 @@ # accordingly. add_data(db, "Property", [("UpgradeCode", uc), ("WhichUsers", "ALL"), + ("ProductLine", "Python%s%s" % (major, minor)), ]) db.Commit() return db @@ -378,6 +393,7 @@ [("DlgFont8", "Tahoma", 9, None, 0), ("DlgFontBold8", "Tahoma", 8, None, 1), #bold ("VerdanaBold10", "Verdana", 10, None, 1), + ("VerdanaRed9", "Verdana", 9, 255, 0), ]) compileargs = r"-Wi [TARGETDIR]Lib\compileall.py -f -x badsyntax [TARGETDIR]Lib" @@ -566,6 +582,9 @@ seldlg = PyDialog(db, "SelectDirectoryDlg", x, y, w, h, modal, title, "Next", "Next", "Cancel") seldlg.title("Select Destination Directory") + c = seldlg.text("Existing", 135, 25, 235, 30, 0x30003, + "{\VerdanaRed9}This update will replace your existing [ProductLine] installation.") + c.condition("Hide", 'REMOVEOLDVERSION="" and REMOVEOLDSNAPSHOT=""') seldlg.text("Description", 135, 50, 220, 40, 0x30003, "Please select a directory for the [ProductName] files.") @@ -865,7 +884,7 @@ dlldir = PyDirectory(db, cab, root, srcdir, "DLLDIR", ".") pydll = "python%s%s.dll" % (major, minor) pydllsrc = srcdir + "/PCBuild/" + pydll - dlldir.start_component("DLLDIR", flags = 8, keyfile = pydll) + dlldir.start_component("DLLDIR", flags = 8, keyfile = pydll, uuid = pythondll_uuid) installer = msilib.MakeInstaller() pyversion = installer.FileVersion(pydllsrc, 0) if not snapshot: @@ -877,7 +896,7 @@ language=installer.FileVersion(pydllsrc, 1)) # XXX determine dependencies version, lang = extract_msvcr71() - dlldir.start_component("msvcr71", flags=8, keyfile="msvcr71.dll") + dlldir.start_component("msvcr71", flags=8, keyfile="msvcr71.dll", uuid=msvcr71_uuid) dlldir.add_file("msvcr71.dll", src=os.path.abspath("msvcr71.dll"), version=version, language=lang) tmpfiles.append("msvcr71.dll") @@ -1047,6 +1066,8 @@ # msidbComponentAttributesRegistryKeyPath = 4 [("REGISTRY", msilib.gen_uuid(), "TARGETDIR", 4, None, "InstallPath"), + ("REGISTRY.doc", msilib.gen_uuid(), "TARGETDIR", 4, None, + "Documentation"), ("REGISTRY.def", msilib.gen_uuid(), "TARGETDIR", 4, None, None)] + tcldata) # See "FeatureComponents Table". @@ -1062,6 +1083,7 @@ tcldata = [(tcltk.id, "pythonw.exe")] add_data(db, "FeatureComponents", [(default_feature.id, "REGISTRY"), + (htmlfiles.id, "REGISTRY.doc"), (ext_feature.id, "REGISTRY.def")] + tcldata ) @@ -1130,7 +1152,7 @@ ("PythonPath", -1, prefix+r"\PythonPath", "", r"[TARGETDIR]Lib;[TARGETDIR]DLLs;[TARGETDIR]Lib\lib-tk", "REGISTRY"), ("Documentation", -1, prefix+r"\Help\Main Python Documentation", "", - r"[TARGETDIR]Doc\Python%s%s.chm" % (major, minor), "REGISTRY"), + r"[TARGETDIR]Doc\Python%s%s.chm" % (major, minor), "REGISTRY.doc"), ("Modules", -1, prefix+r"\Modules", "+", None, "REGISTRY"), ("AppPaths", -1, r"Software\Microsoft\Windows\CurrentVersion\App Paths\Python.exe", "", r"[TARGETDIR]Python.exe", "REGISTRY.def") @@ -1154,9 +1176,14 @@ [# Advertised shortcuts: targets are features, not files ("Python", "MenuDir", "PYTHON|Python (command line)", "python.exe", default_feature.id, None, None, None, "python_icon.exe", 2, None, "TARGETDIR"), - ("Manual", "MenuDir", "MANUAL|Python Manuals", "documentation", - htmlfiles.id, None, None, None, None, None, None, None), + # Advertising the Manual breaks on (some?) Win98, and the shortcut lacks an + # icon first. + #("Manual", "MenuDir", "MANUAL|Python Manuals", "documentation", + # htmlfiles.id, None, None, None, None, None, None, None), ## Non-advertised shortcuts: must be associated with a registry component + ("Manual", "MenuDir", "MANUAL|Python Manuals", "REGISTRY.doc", + "[#Python%s%s.chm]" % (major,minor), None, + None, None, None, None, None, None), ("Uninstall", "MenuDir", "UNINST|Uninstall Python", "REGISTRY", SystemFolderName+"msiexec", "/x%s" % product_code, None, None, None, None, None, None), Index: msilib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Tools/msi/msilib.py,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- msilib.py 10 Sep 2004 11:55:32 -0000 1.4 +++ msilib.py 15 Mar 2005 00:39:40 -0000 1.5 @@ -445,7 +445,7 @@ blogical = None add_data(db, "Directory", [(logical, blogical, default)]) - def start_component(self, component = None, feature = None, flags = None, keyfile = None): + def start_component(self, component = None, feature = None, flags = None, keyfile = None, uuid=None): """Add an entry to the Component table, and make this component the current for this directory. If no component name is given, the directory name is used. If no feature is given, the current feature is used. If no flags are given, the directory's default @@ -453,7 +453,10 @@ table.""" if flags is None: flags = self.componentflags - uuid = gen_uuid() + if uuid is None: + uuid = gen_uuid() + else: + uuid = uuid.upper() if component is None: component = self.logical self.component = component From bcannon at users.sourceforge.net Tue Mar 15 05:06:05 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Tue Mar 15 05:06:11 2005 Subject: [Python-checkins] python/nondist/peps pep-3000.txt,1.13,1.14 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22604 Modified Files: pep-3000.txt Log Message: sum()'s second argument is returned if the first argument is empty, otherwise it is ignored. Index: pep-3000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-3000.txt,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- pep-3000.txt 11 Mar 2005 00:56:22 -0000 1.13 +++ pep-3000.txt 15 Mar 2005 04:06:02 -0000 1.14 @@ -90,14 +90,15 @@ * Introduce ``trunc()``, which would call the ``__trunc__()`` method on its argument; suggested use if for objects like float where calling ``__int__()`` has data loss, but an integral representation is still desired [8]_ +* The second argument to ``sum()`` will returned if the first argument is + empty, otherwise it is ignored [10]_ To be removed: * ``apply()``: use ``f(*args, **kw)`` instead [2]_ * ``buffer()``: must die (use a bytes() type instead) [2]_ * ``callable()``: just call the object and catch the exception [2]_ -* ``compile()``: put in ``sys`` (or perhaps in a module of its own) - [2]_ +* ``compile()``: put in ``sys`` (or perhaps in a module of its own) [2]_ * ``coerce()``: no longer needed [2]_ * ``execfile()``, ``reload()``: use ``exec()`` [2]_ * ``input()``: use ``eval(sys.stdin.readline())`` [2]_ @@ -143,13 +144,16 @@ .. [7] python-dev email ("Let's get rid of unbound methods") http://mail.python.org/pipermail/python-dev/2005-January/050625.html -.. [8] python-dev email( "Fixing _PyEval_SliceIndex so that integer-like +.. [8] python-dev email ("Fixing _PyEval_SliceIndex so that integer-like objects can be used") http://mail.python.org/pipermail/python-dev/2005-February/051674.html .. [9] Guido's blog ("The fate of reduce() in Python 3000") http://www.artima.com/weblogs/viewpost.jsp?thread=98196 +.. [10] python-dev email ("Rationale for sum()'s design?") + http://mail.python.org/pipermail/python-dev/2005-March/052183.html + Copyright ========= From rhettinger at users.sourceforge.net Tue Mar 15 05:59:21 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Mar 15 05:59:25 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_decimal.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-serv2896/Lib/test Modified Files: test_decimal.py Log Message: Bug #1163325: "special" decimals aren't hashable Index: test_decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decimal.py,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- test_decimal.py 18 Dec 2004 19:07:19 -0000 1.16 +++ test_decimal.py 15 Mar 2005 04:59:17 -0000 1.17 @@ -811,6 +811,9 @@ hash(Decimal(23)) #the same hash that to an int self.assertEqual(hash(Decimal(23)), hash(23)) + self.assertRaises(TypeError, hash, Decimal('NaN')) + self.assert_(hash(Decimal('Inf'))) + self.assert_(hash(Decimal('-Inf'))) def test_min_and_max_methods(self): From rhettinger at users.sourceforge.net Tue Mar 15 05:59:20 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Mar 15 05:59:26 2005 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.34,1.35 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2896/Lib Modified Files: decimal.py Log Message: Bug #1163325: "special" decimals aren't hashable Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- decimal.py 1 Mar 2005 03:12:26 -0000 1.34 +++ decimal.py 15 Mar 2005 04:59:16 -0000 1.35 @@ -728,6 +728,10 @@ # Decimal integers must hash the same as the ints # Non-integer decimals are normalized and hashed as strings # Normalization assures that hast(100E-1) == hash(10) + if self._is_special: + if self._isnan(): + raise TypeError('Cannot hash a NaN value.') + return hash(str(self)) i = int(self) if self == Decimal(i): return hash(i) From rhettinger at users.sourceforge.net Tue Mar 15 05:59:49 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Tue Mar 15 05:59:53 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1272,1.1273 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2896/Misc Modified Files: NEWS Log Message: Bug #1163325: "special" decimals aren't hashable Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1272 retrieving revision 1.1273 diff -u -d -r1.1272 -r1.1273 --- NEWS 11 Mar 2005 06:49:34 -0000 1.1272 +++ NEWS 15 Mar 2005 04:59:13 -0000 1.1273 @@ -86,6 +86,9 @@ Library ------- +- Bug #1163325: Decimal infinities failed to hash. Attempting to + hash a NaN raised an InvalidOperation instead of a TypeError. + - Patch #918101: Add tarfile open mode r|* for auto-detection of the stream compression; add, for symmetry reasons, r:* as a synonym of r. From fdrake at users.sourceforge.net Tue Mar 15 16:52:13 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Mar 15 16:52:19 2005 Subject: [Python-checkins] python/dist/src/Lib mimetypes.py,1.30,1.31 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1541 Modified Files: mimetypes.py Log Message: add two more extensions: - .wsdl --> Web Service Definition Language - .xpdl --> XML Process Definition Language Index: mimetypes.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/mimetypes.py,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- mimetypes.py 19 Dec 2003 18:15:10 -0000 1.30 +++ mimetypes.py 15 Mar 2005 15:52:08 -0000 1.31 @@ -443,12 +443,14 @@ '.vcf' : 'text/x-vcard', '.wav' : 'audio/x-wav', '.wiz' : 'application/msword', + '.wsdl' : 'application/xml', '.xbm' : 'image/x-xbitmap', '.xlb' : 'application/vnd.ms-excel', # Duplicates :( '.xls' : 'application/excel', '.xls' : 'application/vnd.ms-excel', '.xml' : 'text/xml', + '.xpdl' : 'application/xml', '.xpm' : 'image/x-xpixmap', '.xsl' : 'application/xml', '.xwd' : 'image/x-xwindowdump', From bcannon at users.sourceforge.net Tue Mar 15 20:43:38 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Tue Mar 15 20:43:42 2005 Subject: [Python-checkins] python/nondist/peps pep-3000.txt,1.14,1.15 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1165 Modified Files: pep-3000.txt Log Message: Back out sum() change. Index: pep-3000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-3000.txt,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- pep-3000.txt 15 Mar 2005 04:06:02 -0000 1.14 +++ pep-3000.txt 15 Mar 2005 19:43:34 -0000 1.15 @@ -15,9 +15,8 @@ ======== This PEP describes the changes currently envisioned in Python 3.0 -(also called Python 3000), a -hypothetical future release of Python that can break backwards -compatibility with the existing body of Python code. +(also called Python 3000), a hypothetical future release of Python that +can break backwards compatibility with the existing body of Python code. The list of features included in this document is subject to change and isn't binding on the Python development community; features may be @@ -90,8 +89,6 @@ * Introduce ``trunc()``, which would call the ``__trunc__()`` method on its argument; suggested use if for objects like float where calling ``__int__()`` has data loss, but an integral representation is still desired [8]_ -* The second argument to ``sum()`` will returned if the first argument is - empty, otherwise it is ignored [10]_ To be removed: @@ -151,9 +148,6 @@ .. [9] Guido's blog ("The fate of reduce() in Python 3000") http://www.artima.com/weblogs/viewpost.jsp?thread=98196 -.. [10] python-dev email ("Rationale for sum()'s design?") - http://mail.python.org/pipermail/python-dev/2005-March/052183.html - Copyright ========= From rhettinger at users.sourceforge.net Wed Mar 16 00:36:22 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Mar 16 00:36:27 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_decimal.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-serv32366/lib/test Modified Files: Tag: release24-maint test_decimal.py Log Message: Decimal special values did not hash properly. Index: test_decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decimal.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_decimal.py 18 Dec 2004 19:12:11 -0000 1.15.2.1 +++ test_decimal.py 15 Mar 2005 23:36:19 -0000 1.15.2.2 @@ -811,6 +811,9 @@ hash(Decimal(23)) #the same hash that to an int self.assertEqual(hash(Decimal(23)), hash(23)) + self.assertRaises(TypeError, hash, Decimal('NaN')) + self.assert_(hash(Decimal('Inf'))) + self.assert_(hash(Decimal('-Inf'))) def test_min_and_max_methods(self): From rhettinger at users.sourceforge.net Wed Mar 16 00:36:22 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Mar 16 00:36:28 2005 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.31.2.1,1.31.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32366/lib Modified Files: Tag: release24-maint decimal.py Log Message: Decimal special values did not hash properly. Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.31.2.1 retrieving revision 1.31.2.2 diff -u -d -r1.31.2.1 -r1.31.2.2 --- decimal.py 18 Dec 2004 19:12:11 -0000 1.31.2.1 +++ decimal.py 15 Mar 2005 23:36:19 -0000 1.31.2.2 @@ -728,6 +728,10 @@ # Decimal integers must hash the same as the ints # Non-integer decimals are normalized and hashed as strings # Normalization assures that hast(100E-1) == hash(10) + if self._is_special: + if self._isnan(): + raise TypeError('Cannot hash a NaN value.') + return hash(str(self)) i = int(self) if self == Decimal(i): return hash(i) From rhettinger at users.sourceforge.net Wed Mar 16 00:36:22 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Wed Mar 16 00:36:28 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.37, 1.1193.2.38 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32366/Misc Modified Files: Tag: release24-maint NEWS Log Message: Decimal special values did not hash properly. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.37 retrieving revision 1.1193.2.38 diff -u -d -r1.1193.2.37 -r1.1193.2.38 --- NEWS 13 Mar 2005 22:18:22 -0000 1.1193.2.37 +++ NEWS 15 Mar 2005 23:36:16 -0000 1.1193.2.38 @@ -12,6 +12,9 @@ Library ------- +- Bug #1163325: Decimal infinities failed to hash. Attempting to + hash a NaN raised an InvalidOperation instead of a TypeError. + - Bug #1160802: can't build Zope on Windows with 2.4.1c1. The ``MSVCCompiler`` class in distutils forgot to record that it was initialized, and continued adding redundant entries to the system From montanaro at users.sourceforge.net Wed Mar 16 04:51:59 2005 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Wed Mar 16 04:52:07 2005 Subject: [Python-checkins] python/dist/src/Lib codecs.py,1.40,1.41 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21140/Lib Modified Files: codecs.py Log Message: typo Index: codecs.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/codecs.py,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- codecs.py 14 Mar 2005 19:25:41 -0000 1.40 +++ codecs.py 16 Mar 2005 03:51:56 -0000 1.41 @@ -576,7 +576,7 @@ Note: The wrapped version will only accept the object format defined by the codecs, i.e. Unicode objects for most builtin - codecs. Output is also codec dependent and will usually by + codecs. Output is also codec dependent and will usually be Unicode as well. Files are always opened in binary mode, even if no binary mode From anthonybaxter at users.sourceforge.net Wed Mar 16 05:13:31 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Wed Mar 16 05:13:36 2005 Subject: [Python-checkins] python/dist/src/Python thread_pthread.h, 2.53, 2.53.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25872 Modified Files: Tag: release24-maint thread_pthread.h Log Message: Patch #1163249 - Correctly handle _POSIX_SEMAPHORES == -1 to mean no support for posix semaphores. Index: thread_pthread.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_pthread.h,v retrieving revision 2.53 retrieving revision 2.53.4.1 diff -u -d -r2.53 -r2.53.4.1 --- thread_pthread.h 7 Jul 2004 17:44:12 -0000 2.53 +++ thread_pthread.h 16 Mar 2005 04:13:29 -0000 2.53.4.1 @@ -16,9 +16,13 @@ family of functions must indicate this by defining _POSIX_SEMAPHORES. */ #ifdef _POSIX_SEMAPHORES +#if _POSIX_SEMAPHORES == -1 +#define HAVE_BROKEN_POSIX_SEMAPHORES +#else #include #include #endif +#endif #if !defined(pthread_attr_default) # define pthread_attr_default ((pthread_attr_t *)NULL) From anthonybaxter at users.sourceforge.net Wed Mar 16 05:15:11 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Wed Mar 16 05:15:13 2005 Subject: [Python-checkins] python/dist/src/Python thread_pthread.h, 2.53, 2.54 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26367 Modified Files: thread_pthread.h Log Message: Patch #1163249 - Correctly handle _POSIX_SEMAPHORES == -1 to mean no support for posix semaphores. Index: thread_pthread.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_pthread.h,v retrieving revision 2.53 retrieving revision 2.54 diff -u -d -r2.53 -r2.54 --- thread_pthread.h 7 Jul 2004 17:44:12 -0000 2.53 +++ thread_pthread.h 16 Mar 2005 04:15:07 -0000 2.54 @@ -16,9 +16,13 @@ family of functions must indicate this by defining _POSIX_SEMAPHORES. */ #ifdef _POSIX_SEMAPHORES +#if _POSIX_SEMAPHORES == -1 +#define HAVE_BROKEN_POSIX_SEMAPHORES +#else #include #include #endif +#endif #if !defined(pthread_attr_default) # define pthread_attr_default ((pthread_attr_t *)NULL) From anthonybaxter at users.sourceforge.net Wed Mar 16 15:34:26 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Wed Mar 16 15:34:30 2005 Subject: [Python-checkins] python/dist/src/PCbuild BUILDno.txt, 1.65.2.1, 1.65.2.2 pythoncore.vcproj, 1.25.2.1, 1.25.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30736/PCbuild Modified Files: Tag: release24-maint BUILDno.txt pythoncore.vcproj Log Message: 2.4.1rc2 setup Index: BUILDno.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/BUILDno.txt,v retrieving revision 1.65.2.1 retrieving revision 1.65.2.2 diff -u -d -r1.65.2.1 -r1.65.2.2 --- BUILDno.txt 9 Mar 2005 11:54:29 -0000 1.65.2.1 +++ BUILDno.txt 16 Mar 2005 14:34:23 -0000 1.65.2.2 @@ -33,6 +33,8 @@ Windows Python BUILD numbers ---------------------------- + 64 2.4.1c2 + 17-Mar-2005 63 2.4.1c1 10-Mar-2005 62 2.3.5 Index: pythoncore.vcproj =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pythoncore.vcproj,v retrieving revision 1.25.2.1 retrieving revision 1.25.2.2 diff -u -d -r1.25.2.1 -r1.25.2.2 --- pythoncore.vcproj 10 Mar 2005 04:51:47 -0000 1.25.2.1 +++ pythoncore.vcproj 16 Mar 2005 14:34:23 -0000 1.25.2.2 @@ -1385,7 +1385,7 @@ Name="VCCLCompilerTool" Optimization="2" AdditionalIncludeDirectories="" - PreprocessorDefinitions="BUILD=63"/> + PreprocessorDefinitions="BUILD=64"/> @@ -1393,7 +1393,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="" - PreprocessorDefinitions="BUILD=63"/> + PreprocessorDefinitions="BUILD=64"/> @@ -1401,7 +1401,7 @@ Name="VCCLCompilerTool" Optimization="2" AdditionalIncludeDirectories="" - PreprocessorDefinitions="BUILD=63"/> + PreprocessorDefinitions="BUILD=64"/> Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30736/Lib/idlelib Modified Files: Tag: release24-maint NEWS.txt idlever.py Log Message: 2.4.1rc2 setup Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.49.2.4 retrieving revision 1.49.2.5 diff -u -d -r1.49.2.4 -r1.49.2.5 --- NEWS.txt 9 Mar 2005 11:54:24 -0000 1.49.2.4 +++ NEWS.txt 16 Mar 2005 14:34:22 -0000 1.49.2.5 @@ -1,3 +1,9 @@ +What's New in IDLE 1.1.1c2? +=========================== + +*Release date: 17-MAR-2005* + + What's New in IDLE 1.1.1c1? =========================== Index: idlever.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/idlever.py,v retrieving revision 1.22.2.2 retrieving revision 1.22.2.3 diff -u -d -r1.22.2.2 -r1.22.2.3 --- idlever.py 9 Mar 2005 11:54:24 -0000 1.22.2.2 +++ idlever.py 16 Mar 2005 14:34:23 -0000 1.22.2.3 @@ -1 +1 @@ -IDLE_VERSION = "1.1.1c1" +IDLE_VERSION = "1.1.1c2" From anthonybaxter at users.sourceforge.net Wed Mar 16 15:34:53 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Wed Mar 16 15:34:57 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.38, 1.1193.2.39 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30736/Misc Modified Files: Tag: release24-maint NEWS Log Message: 2.4.1rc2 setup Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.38 retrieving revision 1.1193.2.39 diff -u -d -r1.1193.2.38 -r1.1193.2.39 --- NEWS 15 Mar 2005 23:36:16 -0000 1.1193.2.38 +++ NEWS 16 Mar 2005 14:34:12 -0000 1.1193.2.39 @@ -7,7 +7,7 @@ What's New in Python 2.4.1c2? ============================= -*Release date: DD-MAR-2005* +*Release date: 17-MAR-2005* Library ------- @@ -24,6 +24,7 @@ before because a bugfix first included in 2.4.1c1 provoked it (bug #1110478: revert os.environ.update to do putenv again). +- Bug #1156259: Seeking in codecs.reader was broken, now fixed. Tests ----- From bcannon at users.sourceforge.net Wed Mar 16 21:20:21 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Wed Mar 16 21:20:27 2005 Subject: [Python-checkins] python/dist/src/Python compile.txt, 1.1.2.8, 1.1.2.9 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14411/Python Modified Files: Tag: ast-branch compile.txt Log Message: Add a ton of XXX comments on where information is lacking or where work needs to be done on the doc. Added an empty "Known Bugs/Issues" section to act as a place to note where current things are broken. Added a "ToDo" section on known things that need to be worked on that are not explicit bugs. Index: compile.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/Attic/compile.txt,v retrieving revision 1.1.2.8 retrieving revision 1.1.2.9 diff -u -d -r1.1.2.8 -r1.1.2.9 --- compile.txt 15 Oct 2003 06:26:13 -0000 1.1.2.8 +++ compile.txt 16 Mar 2005 20:20:18 -0000 1.1.2.9 @@ -18,10 +18,13 @@ The definition describes the structure of statements, expressions, and several specialized types, like list comprehensions and exception handlers. Most definitions in the AST correspond to a particular -source construct, like an if statement or an attribute lookup. The +source construct, like an 'if' statement or an attribute lookup. The definition is independent of its realization in any particular programming language. +XXX Is byte stream format what marshal_* fxns create? +XXX no AST->python yet, right? + The AST has concrete representations in Python and C. There is also representation as a byte stream, so that AST objects can be passed between Python and C. (ASDL calls this format the pickle format, but @@ -32,6 +35,7 @@ The following fragment of the Python abstract syntax demonstrates the approach. +XXX update example once decorators in :: module Python @@ -76,7 +80,7 @@ } It also generates a series of constructor functions that generate a -``stmt_ty`` with the appropriate initialization. The ``kind`` field +``stmt_ty`` struct with the appropriate initialization. The ``kind`` field specifies which component of the union is initialized. The ``FunctionDef`` C function sets ``kind`` to ``FunctionDef_kind`` and initializes the ``name``, ``args``, and ``body`` fields. @@ -84,8 +88,10 @@ CST to AST ---------- +XXX Make sure basic flow of execution is covered + The parser generates a concrete syntax tree represented by a ``node -*`` defined in ``Include/node.h``. Node indexing starts at 0. Every +*`` as defined in ``Include/node.h``. Node indexing starts at 0. Every token that can have whitespace surrounding it is its own token. This means that something like "else:" is actually two tokens: 'else' and ':'. @@ -96,7 +102,7 @@ mod_ty PyAST_FromNode(const node *n); It does this by calling various functions in the file that all have the -name ast_for_xxx where xxx is what the rule of the grammar (as defined +name ast_for_xx where xx is what the rule of the grammar (as defined in ``Grammar/Grammar``) that the function handles (alias_for_import_name is the exception to this). These in turn call the constructor functions as defined by the ASDL grammar to create the nodes of the AST. @@ -124,12 +130,17 @@ Code Generation and Basic Blocks -------------------------------- +XXX Reformat: general discussion of basic blocks and compiler ideas (namespace +generation, etc.), then discuss code structure and helper functions XXX Describe the structure of the code generator, the types involved, and the helper functions and macros. +XXX Make sure flow of execution (namespace resolution, etc.) is covered after +explanation of macros/functions - for each ast type (mod, stmt, expr, ...), define a function with a switch statement. inline code generation for simple things, - call function compiler_xxx where xxx is kind name for others. + call the function compiler_xx where xx is the kind of type in question for + others. The macros used to emit specific opcodes and to generate code for generic node types use string concatenation to produce calls to the @@ -153,10 +164,18 @@ Code is generated using a simple, basic block interface. - each block has a single entry point + * means code in basic block always starts executing at a single place + * does not exclude multiple blocks pointing to the same entry point - possibly multiple exit points - when generating jumps, always jump to a block - for a code unit, blocks are identified by its int id +Thus the basic blocks are used to model control flow through an application. +This is often called a CFG (control flow graph). It is directed and can +contain cycles in subgraphs since modeling loops does require it. + +Below are are macros and functions used for managing basic blocks: + - NEW_BLOCK() -- create block and set it as current - NEXT_BLOCK() -- NEW_BLOCK() plus jump from current block - compiler_new_block() -- create a block but don't use it @@ -171,24 +190,26 @@ ADDOP_O(c, opcode, oparg, namespace) -- oparg is a PyObject * , namespace is the name of a code object member that contains the set of objects. For example, - ADDOP_O(c, LOAD_CONST, obj, consts) + ``ADDOP_O(c, LOAD_CONST, obj, consts)`` will make sure that obj is in co_consts and that the opcode argument will be an index into co_consts. The valid names are consts, names, varnames, ... + ADDOP_NAME(c, op, o, type) -- XXX - - Explain what each namespace is for. + XXX Explain what each namespace is for. - ADDOP_JABS() -- oparg is an absolute jump to block id - ADDOP_JREL() -- oparg is a relative jump to block id + ADDOP_JABS(XXX) -- oparg is an absolute jump to block id + ADDOP_JREL(XXX) -- oparg is a relative jump to block id XXX no need for JABS() and JREL(), always computed at the end from block id - symbol table pass and compiler_nameop() +XXX Code Objects ------------ -XXX Describe Python code objects. +XXX Describe Python code objects: fields, etc. Files ----- @@ -211,13 +232,15 @@ + Python/ - Python-ast.c - Creates C structs corresponding to the ASDL types. + Creates C structs corresponding to the ASDL types. Also contains code + for marshaling AST nodes (core ASDL types have marshaling code in + asdl.c). "File automatically generated by ../Parser/asdl_c.py". - asdl.c Contains code to handle the ASDL sequence type. Also has code to handle marshalling the core ASDL types, such as number and - identifier. + identifier. used by Python-ast.c for marshaling AST nodes. - ast.c Converts Python's concrete syntax tree into the abstract syntax tree. @@ -241,6 +264,37 @@ - ast.h Declares PyAST_FromNode() external (from ../Python/ast.c). +Known Bugs/Issues +----------------- + +XXX + +ToDo +---- + ++ Grammar support (Parser/Python.asdl, Parser/asdl_c.py) + - decorators + - empty base class list (``class Class(): pass``) + - AST->Python object support ++ CST->AST support (Python/ast.c) + - decorators + - generator expressions ++ AST->bytecode support (Python/newcompile.c) + - decorators + - generator expressions ++ Stdlib support + - AST->Python access? + - rewrite compiler package to mirror AST structure? ++ Documentation + - flesh out this doc + * compiler concepts covered + * structure and flow of all steps clearly explained + * break up into more sections/subsections ++ Universal + - make sure entire test suite passes + - fix memory leaks + - make sure return types are properly checked for errors + References ---------- From fdrake at users.sourceforge.net Thu Mar 17 00:43:29 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu Mar 17 00:43:34 2005 Subject: [Python-checkins] python/dist/src/Include patchlevel.h, 2.83.2.3, 2.83.2.4 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26040/Include Modified Files: Tag: release24-maint patchlevel.h Log Message: update patchlevel Index: patchlevel.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/patchlevel.h,v retrieving revision 2.83.2.3 retrieving revision 2.83.2.4 diff -u -d -r2.83.2.3 -r2.83.2.4 --- patchlevel.h 9 Mar 2005 11:54:24 -0000 2.83.2.3 +++ patchlevel.h 16 Mar 2005 23:43:21 -0000 2.83.2.4 @@ -23,7 +23,7 @@ #define PY_MINOR_VERSION 4 #define PY_MICRO_VERSION 1 #define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_GAMMA -#define PY_RELEASE_SERIAL 1 +#define PY_RELEASE_SERIAL 2 /* Version as a string */ #define PY_VERSION "2.4.1c1" From anthonybaxter at users.sourceforge.net Thu Mar 17 04:06:59 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Thu Mar 17 04:07:04 2005 Subject: [Python-checkins] python/dist/src/Include patchlevel.h, 2.83.2.4, 2.83.2.5 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3194/Include Modified Files: Tag: release24-maint patchlevel.h Log Message: 2.4.1c2 Index: patchlevel.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/patchlevel.h,v retrieving revision 2.83.2.4 retrieving revision 2.83.2.5 diff -u -d -r2.83.2.4 -r2.83.2.5 --- patchlevel.h 16 Mar 2005 23:43:21 -0000 2.83.2.4 +++ patchlevel.h 17 Mar 2005 03:06:56 -0000 2.83.2.5 @@ -26,7 +26,7 @@ #define PY_RELEASE_SERIAL 2 /* Version as a string */ -#define PY_VERSION "2.4.1c1" +#define PY_VERSION "2.4.1c2" /* 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 doerwalter at users.sourceforge.net Fri Mar 18 11:28:29 2005 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Fri Mar 18 11:28:34 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1273,1.1274 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13080/Misc Modified Files: NEWS Log Message: Fix typo. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1273 retrieving revision 1.1274 diff -u -d -r1.1273 -r1.1274 --- NEWS 15 Mar 2005 04:59:13 -0000 1.1273 +++ NEWS 18 Mar 2005 10:28:24 -0000 1.1274 @@ -1199,7 +1199,7 @@ - Optimized list resize operations to make fewer calls to the system realloc(). Significantly speeds up list appends, list pops, - list comprehensions, and the list contructor (when the input iterable + list comprehensions, and the list constructor (when the input iterable length is not known). - Changed the internal list over-allocation scheme. For larger lists, From doerwalter at users.sourceforge.net Fri Mar 18 11:59:20 2005 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Fri Mar 18 11:59:24 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.39, 1.1193.2.40 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20424/Misc Modified Files: Tag: release24-maint NEWS Log Message: Fix typo. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.39 retrieving revision 1.1193.2.40 diff -u -d -r1.1193.2.39 -r1.1193.2.40 --- NEWS 16 Mar 2005 14:34:12 -0000 1.1193.2.39 +++ NEWS 18 Mar 2005 10:59:04 -0000 1.1193.2.40 @@ -1100,7 +1100,7 @@ - Optimized list resize operations to make fewer calls to the system realloc(). Significantly speeds up list appends, list pops, - list comprehensions, and the list contructor (when the input iterable + list comprehensions, and the list constructor (when the input iterable length is not known). - Changed the internal list over-allocation scheme. For larger lists, From montanaro at users.sourceforge.net Fri Mar 18 17:56:40 2005 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Fri Mar 18 17:56:43 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libcsv.tex,1.18,1.19 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22325 Modified Files: libcsv.tex Log Message: add UnicodeReader and UnicodeWriter example classes Index: libcsv.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcsv.tex,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- libcsv.tex 12 Jan 2005 11:47:57 -0000 1.18 +++ libcsv.tex 18 Mar 2005 16:56:37 -0000 1.19 @@ -424,3 +424,38 @@ print csv.reader(['one,two,three'])[0] \end{verbatim} +The \module{csv} module doesn't directly support reading and writing +Unicode, but it is 8-bit clean save for some problems with \ASCII{} NUL +characters, so you can write classes that handle the encoding and decoding +for you as long as you avoid encodings like utf-16 that use NULs. + +\begin{verbatim} +import csv + +class UnicodeReader: + def __init__(self, f, dialect=csv.excel, encoding="utf-8", **kwds): + self.reader = csv.reader(f, dialect=dialect, **kwds) + self.encoding = encoding + + def next(self): + row = self.reader.next() + return [unicode(s, self.encoding) for s in row] + + def __iter__(self): + return self + +class UnicodeWriter: + def __init__(self, f, dialect=csv.excel, encoding="utf-8", **kwds): + self.writer = csv.writer(f, dialect=dialect, **kwds) + self.encoding = encoding + + def writerow(self, row): + self.writer.writerow([s.encode("utf-8") for s in row]) + + def writerows(self, rows): + for row in rows: + self.writerow(row) +\end{verbatim} + +They should work just like the \class{csv.reader} and \class{csv.writer} +classes but add an \var{encoding} parameter. From rhettinger at users.sourceforge.net Fri Mar 18 22:20:26 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Mar 18 22:20:30 2005 Subject: [Python-checkins] python/dist/src/Modules collectionsmodule.c, 1.36, 1.37 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27128/Modules Modified Files: collectionsmodule.c Log Message: Add a remove() method to collections.deque objects. Index: collectionsmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/collectionsmodule.c,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- collectionsmodule.c 9 Nov 2004 07:27:34 -0000 1.36 +++ collectionsmodule.c 18 Mar 2005 21:20:23 -0000 1.37 @@ -368,6 +368,41 @@ return deque->len; } +static PyObject * +deque_remove(dequeobject *deque, PyObject *value) +{ + int i, n=deque->len; + + for (i=0 ; ileftblock->data[deque->leftindex]; + int cmp = PyObject_RichCompareBool(item, value, Py_EQ); + if (cmp > 0) { + PyObject *tgt; + if (deque->len != n) { + PyErr_SetString(PyExc_IndexError, + "deque mutated during remove()."); + return NULL; + } + tgt = deque_popleft(deque, NULL); + assert (tgt != NULL); + Py_DECREF(tgt); + if (_deque_rotate(deque, i) == -1) + return NULL; + Py_RETURN_NONE; + } + else if (cmp < 0) { + _deque_rotate(deque, i); + return NULL; + } + _deque_rotate(deque, -1); + } + PyErr_SetString(PyExc_ValueError, "deque.remove(x): x not in deque"); + return NULL; +} + +PyDoc_STRVAR(remove_doc, +"D.remove(value) -- remove first occurrence of value."); + static int deque_clear(dequeobject *deque) { @@ -764,7 +799,7 @@ METH_NOARGS, copy_doc}, {"extend", (PyCFunction)deque_extend, METH_O, extend_doc}, - {"extendleft", (PyCFunction)deque_extendleft, + {"extendleft", (PyCFunction)deque_extendleft, METH_O, extendleft_doc}, {"pop", (PyCFunction)deque_pop, METH_NOARGS, pop_doc}, @@ -772,6 +807,8 @@ METH_NOARGS, popleft_doc}, {"__reduce__", (PyCFunction)deque_reduce, METH_NOARGS, reduce_doc}, + {"remove", (PyCFunction)deque_remove, + METH_O, remove_doc}, {"__reversed__", (PyCFunction)deque_reviter, METH_NOARGS, reversed_doc}, {"rotate", (PyCFunction)deque_rotate, From rhettinger at users.sourceforge.net Fri Mar 18 22:20:26 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Mar 18 22:20:31 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1274,1.1275 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27128/Misc Modified Files: NEWS Log Message: Add a remove() method to collections.deque objects. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1274 retrieving revision 1.1275 diff -u -d -r1.1274 -r1.1275 --- NEWS 18 Mar 2005 10:28:24 -0000 1.1274 +++ NEWS 18 Mar 2005 21:20:19 -0000 1.1275 @@ -49,6 +49,8 @@ Extension Modules ----------------- +- collections.deque objects now support a remove() method. + - operator.itemgetter() and operator.attrgetter() now support retrieving multiple fields. This provides direct support for sorting on multiple keys (primary, secondary, etc). From rhettinger at users.sourceforge.net Fri Mar 18 22:20:51 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Mar 18 22:20:55 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libcollections.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-serv27128/Doc/lib Modified Files: libcollections.tex Log Message: Add a remove() method to collections.deque objects. Index: libcollections.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcollections.tex,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- libcollections.tex 12 Jun 2004 07:59:40 -0000 1.10 +++ libcollections.tex 18 Mar 2005 21:20:18 -0000 1.11 @@ -64,6 +64,12 @@ If no elements are present, raises a \exception{IndexError}. \end{methoddesc} +\begin{methoddesc}{remove}{value} + Removed the first occurrence of \var{value}. If not found, + raises a \exception{ValueError}. + \versionadded{2.5} +\end{methoddesc} + \begin{methoddesc}{rotate}{n} Rotate the deque \var{n} steps to the right. If \var{n} is negative, rotate to the left. Rotating one step to the right From rhettinger at users.sourceforge.net Fri Mar 18 22:20:52 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Fri Mar 18 22:20:56 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_deque.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-serv27128/Lib/test Modified Files: test_deque.py Log Message: Add a remove() method to collections.deque objects. Index: test_deque.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_deque.py,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- test_deque.py 9 Nov 2004 07:27:35 -0000 1.18 +++ test_deque.py 18 Mar 2005 21:20:19 -0000 1.19 @@ -14,6 +14,17 @@ raise SyntaxError yield 1 +class BadCmp: + def __eq__(self, other): + raise RuntimeError + +class MutateCmp: + def __init__(self, deque): + self.deque = deque + def __eq__(self, other): + self.deque.clear() + return True + class TestBasic(unittest.TestCase): def test_basics(self): @@ -197,6 +208,30 @@ d.clear() # clear an emtpy deque self.assertEqual(list(d), []) + def test_remove(self): + d = deque('abcdefghcij') + d.remove('c') + self.assertEqual(d, deque('abdefghcij')) + d.remove('c') + self.assertEqual(d, deque('abdefghij')) + self.assertRaises(ValueError, d.remove, 'c') + self.assertEqual(d, deque('abdefghij')) + + # Handle comparision errors + d = deque(['a', 'b', BadCmp(), 'c']) + e = deque(d) + self.assertRaises(RuntimeError, d.remove, 'c') + for x, y in zip(d, e): + # verify that original order and values are retained. + self.assert_(x is y) + + # Handle evil mutator + d = deque(['ab']) + d.extend([MutateCmp(d), 'c']) + e = deque(d) + self.assertRaises(IndexError, d.remove, 'c') + self.assertEqual(d, deque()) + def test_repr(self): d = deque(xrange(200)) e = eval(repr(d)) From rhettinger at users.sourceforge.net Sat Mar 19 01:01:02 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Mar 19 01:01:06 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_deque.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-serv17096/Lib/test Modified Files: test_deque.py Log Message: Apply remove's mutation test after every equality test. Index: test_deque.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_deque.py,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- test_deque.py 18 Mar 2005 21:20:19 -0000 1.19 +++ test_deque.py 19 Mar 2005 00:00:51 -0000 1.20 @@ -19,11 +19,12 @@ raise RuntimeError class MutateCmp: - def __init__(self, deque): + def __init__(self, deque, result): self.deque = deque + self.result = result def __eq__(self, other): self.deque.clear() - return True + return self.result class TestBasic(unittest.TestCase): @@ -226,11 +227,11 @@ self.assert_(x is y) # Handle evil mutator - d = deque(['ab']) - d.extend([MutateCmp(d), 'c']) - e = deque(d) - self.assertRaises(IndexError, d.remove, 'c') - self.assertEqual(d, deque()) + for match in (True, False): + d = deque(['ab']) + d.extend([MutateCmp(d, match), 'c']) + self.assertRaises(IndexError, d.remove, 'c') + self.assertEqual(d, deque()) def test_repr(self): d = deque(xrange(200)) From rhettinger at users.sourceforge.net Sat Mar 19 01:01:35 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Mar 19 01:01:37 2005 Subject: [Python-checkins] python/dist/src/Modules collectionsmodule.c, 1.37, 1.38 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17096/Modules Modified Files: collectionsmodule.c Log Message: Apply remove's mutation test after every equality test. Index: collectionsmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/collectionsmodule.c,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- collectionsmodule.c 18 Mar 2005 21:20:23 -0000 1.37 +++ collectionsmodule.c 19 Mar 2005 00:00:48 -0000 1.38 @@ -376,14 +376,14 @@ for (i=0 ; ileftblock->data[deque->leftindex]; int cmp = PyObject_RichCompareBool(item, value, Py_EQ); + + if (deque->len != n) { + PyErr_SetString(PyExc_IndexError, + "deque mutated during remove()."); + return NULL; + } if (cmp > 0) { - PyObject *tgt; - if (deque->len != n) { - PyErr_SetString(PyExc_IndexError, - "deque mutated during remove()."); - return NULL; - } - tgt = deque_popleft(deque, NULL); + PyObject *tgt = deque_popleft(deque, NULL); assert (tgt != NULL); Py_DECREF(tgt); if (_deque_rotate(deque, i) == -1) From bcannon at users.sourceforge.net Sat Mar 19 16:23:56 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Sat Mar 19 16:23:58 2005 Subject: [Python-checkins] python/nondist/peps pep-0301.txt,1.9,1.10 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3414 Modified Files: pep-0301.txt Log Message: Mark as final (cleared by Richard Jones). Index: pep-0301.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0301.txt,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- pep-0301.txt 28 Sep 2004 01:05:40 -0000 1.9 +++ pep-0301.txt 19 Mar 2005 15:23:53 -0000 1.10 @@ -3,7 +3,7 @@ Version: $Revision$ Last-Modified: $Date$ Author: Richard Jones -Status: Draft +Status: Final Type: Standards Track Content-Type: text/x-rst Created: 24-Oct-2002 From rhettinger at users.sourceforge.net Sat Mar 19 17:27:36 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sat Mar 19 17:27:38 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libfuncs.tex,1.180,1.181 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14767 Modified Files: libfuncs.tex Log Message: Fill-in missing argspec. Index: libfuncs.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v retrieving revision 1.180 retrieving revision 1.181 diff -u -d -r1.180 -r1.181 --- libfuncs.tex 11 Mar 2005 06:49:32 -0000 1.180 +++ libfuncs.tex 19 Mar 2005 16:27:33 -0000 1.181 @@ -683,7 +683,7 @@ \versionchanged[Added support for the optional \var{key} argument]{2.5} \end{funcdesc} -\begin{funcdesc}{min}{s\optional{, args...}} +\begin{funcdesc}{min}{s\optional{, args...}\optional{key}} With a single argument \var{s}, return the smallest item of a non-empty sequence (such as a string, tuple or list). With more than one argument, return the smallest of the arguments. From gward at users.sourceforge.net Sat Mar 19 17:28:39 2005 From: gward at users.sourceforge.net (gward@users.sourceforge.net) Date: Sat Mar 19 17:28:42 2005 Subject: [Python-checkins] python/dist/src/Doc/lib liboptparse.tex, 1.18.2.1, 1.18.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14925/lib Modified Files: Tag: release24-maint liboptparse.tex Log Message: Beef up optparse reference docs -- now much closer to documenting the full API of Optik 1.5a2 (which is what's included with Python 2.4.x). Closes SF #1099324, partially addresses SF #993601. Index: liboptparse.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liboptparse.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 --- liboptparse.tex 31 Dec 2004 01:08:17 -0000 1.18.2.1 +++ liboptparse.tex 19 Mar 2005 16:28:37 -0000 1.18.2.2 @@ -35,9 +35,9 @@ \end{verbatim} As it parses the command line, \code{optparse} sets attributes of the -\var{options} object returned by \method{parse{\_}args()} based on user-supplied +\code{options} object returned by \method{parse{\_}args()} based on user-supplied command-line values. When \method{parse{\_}args()} returns from parsing this -command line, \var{options.filename} will be \code{"outfile"} and +command line, \code{options.filename} will be \code{"outfile"} and \code{options.verbose} will be \code{False}. \code{optparse} supports both long and short options, allows short options to be merged together, and allows options to be associated with their arguments in a variety of @@ -287,12 +287,12 @@ \method{parse{\_}args()} returns two values: \begin{itemize} \item {} -\var{options}, an object containing values for all of your options{---}e.g. if \code{"-{}-file"} takes a single string argument, then -\var{options.file} will be the filename supplied by the user, or +\code{options}, an object containing values for all of your options{---}e.g. if \code{"-{}-file"} takes a single string argument, then +\code{options.file} will be the filename supplied by the user, or \code{None} if the user did not supply that option \item {} -\var{args}, the list of positional arguments leftover after parsing +\code{args}, the list of positional arguments leftover after parsing options \end{itemize} @@ -309,7 +309,7 @@ adding new actions is an advanced topic covered in section~\ref{optparse-extending}, Extending \module{optparse}. Most actions tell \module{optparse} to store a value in some variable{---}for example, take a string from the command line and store it in an -attribute of \var{options}. +attribute of \code{options}. If you don't specify an option action, \module{optparse} defaults to \code{store}. @@ -333,8 +333,8 @@ \end{verbatim} When \module{optparse} sees the option string \code{"-f"}, it consumes the next -argument, \code{"foo.txt"}, and stores it in \var{options.filename}. So, -after this call to \method{parse{\_}args()}, \var{options.filename} is +argument, \code{"foo.txt"}, and stores it in \code{options.filename}. So, +after this call to \method{parse{\_}args()}, \code{options.filename} is \code{"foo.txt"}. Some other option types supported by \module{optparse} are \code{int} and \code{float}. @@ -379,7 +379,7 @@ Flag options{---}set a variable to true or false when a particular option is seen{---}are quite common. \module{optparse} supports them with two separate actions, \code{store{\_}true} and \code{store{\_}false}. For example, you might have a -\var{verbose} flag that is turned on with \code{"-v"} and off with \code{"-q"}: +\code{verbose} flag that is turned on with \code{"-v"} and off with \code{"-q"}: \begin{verbatim} parser.add_option("-v", action="store_true", dest="verbose") parser.add_option("-q", action="store_false", dest="verbose") @@ -421,7 +421,7 @@ destination, which is assigned before the command line is parsed. First, consider the verbose/quiet example. If we want \module{optparse} to set -\var{verbose} to \code{True} unless \code{"-q"} is seen, then we can do this: +\code{verbose} to \code{True} unless \code{"-q"} is seen, then we can do this: \begin{verbatim} parser.add_option("-v", action="store_true", dest="verbose", default=True) parser.add_option("-q", action="store_false", dest="verbose") @@ -441,7 +441,7 @@ parser.add_option("-q", action="store_false", dest="verbose", default=True) \end{verbatim} -Again, the default value for \var{verbose} will be \code{True}: the last +Again, the default value for \code{verbose} will be \code{True}: the last default value supplied for any particular destination is the one that counts. @@ -566,7 +566,7 @@ parser = OptionParser(usage="%prog [-f] [-q]", version="%prog 1.0") \end{verbatim} -Note that \code{"{\%}prog"} is expanded just like it is in \var{usage}. Apart +Note that \code{"{\%}prog"} is expanded just like it is in \code{usage}. Apart from that, \code{version} can contain anything you like. When you supply it, \module{optparse} automatically adds a \code{"-{}-version"} option to your parser. If it encounters this option on the command line, it expands your @@ -580,7 +580,7 @@ \end{verbatim} -\subsubsection{How \module{optparse} handles errors\label{optparse-how-optik-handles-errors}} +\subsubsection{How \module{optparse} handles errors\label{optparse-how-optparse-handles-errors}} There are two broad classes of errors that \module{optparse} has to worry about: programmer errors and user errors. Programmer errors are usually @@ -665,6 +665,60 @@ \subsection{Reference Guide\label{optparse-reference-guide}} +\subsubsection{Creating the parser\label{optparse-creating-parser}} + +The first step in using \module{optparse} is to create an OptionParser instance: +\begin{verbatim} +parser = OptionParser(...) +\end{verbatim} + +The OptionParser constructor has no required arguments, but a number of +optional keyword arguments. You should always pass them as keyword +arguments, i.e. do not rely on the order in which the arguments are +declared. +\begin{quote} +\begin{description} +\item[\code{usage} (default: \code{"{\%}prog {[}options]"})] +The usage summary to print when your program is run incorrectly or +with a help option. When \module{optparse} prints the usage string, it expands +\code{{\%}prog} to \code{os.path.basename(sys.argv{[}0])} (or to \code{prog} if +you passed that keyword argument). To suppress a usage message, +pass the special value \code{optparse.SUPPRESS{\_}USAGE}. +\item[\code{option{\_}list} (default: \code{{[}]})] +A list of Option objects to populate the parser with. The options +in \code{option{\_}list} are added after any options in +\code{standard{\_}option{\_}list} (a class attribute that may be set by +OptionParser subclasses), but before any version or help options. +Deprecated; use \method{add{\_}option()} after creating the parser instead. +\item[\code{option{\_}class} (default: optparse.Option)] +Class to use when adding options to the parser in \method{add{\_}option()}. +\item[\code{version} (default: \code{None})] +A version string to print when the user supplies a version option. +If you supply a true value for \code{version}, \module{optparse} automatically adds +a version option with the single option string \code{"-{}-version"}. The +substring \code{"{\%}prog"} is expanded the same as for \code{usage}. +\item[\code{conflict{\_}handler} (default: \code{"error"})] +Specifies what to do when options with conflicting option strings +are added to the parser; see section~\ref{optparse-conflicts-between-options}, Conflicts between options. +\item[\code{description} (default: \code{None})] +A paragraph of text giving a brief overview of your program. \module{optparse} +reformats this paragraph to fit the current terminal width and +prints it when the user requests help (after \code{usage}, but before +the list of options). +\item[\code{formatter} (default: a new IndentedHelpFormatter)] +An instance of optparse.HelpFormatter that will be used for +printing help text. \module{optparse} provides two concrete classes for this +purpose: IndentedHelpFormatter and TitledHelpFormatter. +\item[\code{add{\_}help{\_}option} (default: \code{True})] +If true, \module{optparse} will add a help option (with option strings \code{"-h"} +and \code{"-{}-help"}) to the parser. +\item[\code{prog}] +The string to use when expanding \code{"{\%}prog"} in \code{usage} and +\code{version} instead of \code{os.path.basename(sys.argv{[}0])}. +\end{description} +\end{quote} + + \subsubsection{Populating the parser\label{optparse-populating-parser}} There are several ways to populate the parser with options. The @@ -708,38 +762,34 @@ specify any number of short or long option strings, but you must specify at least one overall option string. -The canonical way to create an Option instance is by calling -\function{make{\_}option()}, so that is what will be shown here. However, the -most common and convenient way is to use \code{parser.add{\_}option()}. Note -that \function{make{\_}option()} and \code{parser.add{\_}option()} have identical call -signatures: +The canonical way to create an Option instance is with the +\method{add{\_}option()} method of \class{OptionParser}: \begin{verbatim} -make_option(opt_str, ..., attr=value, ...) -parser.add_option(opt_str, ..., attr=value, ...) +parser.add_option(opt_str[, ...], attr=value, ...) \end{verbatim} To define an option with only a short option string: \begin{verbatim} -make_option("-f", attr=value, ...) +parser.add_option("-f", attr=value, ...) \end{verbatim} And to define an option with only a long option string: \begin{verbatim} -make_option("--foo", attr=value, ...) +parser.add_option("--foo", attr=value, ...) \end{verbatim} -The \code{attr=value} keyword arguments define option attributes, -i.e. attributes of the Option object. The most important option -attribute is \member{action}, and it largely determines what other attributes -are relevant or required. If you pass irrelevant option attributes, or -fail to pass required ones, \module{optparse} raises an OptionError exception -explaining your mistake. +The keyword arguments define attributes of the new Option object. The +most important option attribute is \member{action}, and it largely determines +which other attributes are relevant or required. If you pass irrelevant +option attributes, or fail to pass required ones, \module{optparse} raises an +OptionError exception explaining your mistake. -An options's \emph{action} determines what \module{optparse} does when it encounters -this option on the command-line. The actions hard-coded into \module{optparse} are: +An options's \emph{action} determines what \module{optparse} does when it encounters this +option on the command-line. The standard option actions hard-coded into +\module{optparse} are: \begin{description} \item[\code{store}] -store this option's argument {[}default] +store this option's argument (default) \item[\code{store{\_}const}] store a constant value \item[\code{store{\_}true}] @@ -762,24 +812,25 @@ below.) As you can see, most actions involve storing or updating a value -somewhere. \module{optparse} always creates an instance of \code{optparse.Values} -specifically for this purpose; we refer to this instance as \var{options}. -Option arguments (and various other values) are stored as attributes of -this object, according to the \member{dest} (destination) option attribute. +somewhere. \module{optparse} always creates a special object for this, +conventionally called \code{options} (it happens to be an instance of +\code{optparse.Values}). Option arguments (and various other values) are +stored as attributes of this object, according to the \member{dest} +(destination) option attribute. For example, when you call \begin{verbatim} parser.parse_args() \end{verbatim} -one of the first things \module{optparse} does is create the \var{options} object: +one of the first things \module{optparse} does is create the \code{options} object: \begin{verbatim} options = Values() \end{verbatim} If one of the options in this parser is defined with \begin{verbatim} -make_option("-f", "--file", action="store", type="string", dest="filename") +parser.add_option("-f", "--file", action="store", type="string", dest="filename") \end{verbatim} and the command-line being parsed includes any of the following: @@ -790,8 +841,7 @@ --file foo \end{verbatim} -then \module{optparse}, on seeing the \programopt{-f} or \longprogramopt{file} option, will do the -equivalent of +then \module{optparse}, on seeing this option, will do the equivalent of \begin{verbatim} options.filename = "foo" \end{verbatim} @@ -939,14 +989,9 @@ \code{callback} {[}required: \code{callback}; relevant: \member{type}, \code{nargs}, \code{callback{\_}args}, \code{callback{\_}kwargs}] -Call the function specified by \code{callback}. The signature of -this function should be +Call the function specified by \code{callback}, which is called as \begin{verbatim} -func(option : Option, - opt : string, - value : any, - parser : OptionParser, - *args, **kwargs) +func(option, opt_str, value, parser, *args, **kwargs) \end{verbatim} See section~\ref{optparse-option-callbacks}, Option Callbacks for more detail. @@ -956,7 +1001,7 @@ Prints a complete help message for all the options in the current option parser. The help message is constructed from -the \var{usage} string passed to OptionParser's constructor and +the \code{usage} string passed to OptionParser's constructor and the \member{help} string passed to every option. If no \member{help} string is supplied for an option, it will still be @@ -1030,11 +1075,49 @@ \code{choice} options are a subtype of \code{string} options. The \code{choices} option attribute (a sequence of strings) defines the set of allowed -option arguments. \code{optparse.option.check{\_}choice()} compares +option arguments. \code{optparse.check{\_}choice()} compares user-supplied option arguments against this master list and raises OptionValueError if an invalid string is given. +\subsubsection{Parsing arguments\label{optparse-parsing-arguments}} + +The whole point of creating and populating an OptionParser is to call +its \method{parse{\_}args()} method: +\begin{verbatim} +(options, args) = parser.parse_args(args=None, options=None) +\end{verbatim} + +where the input parameters are +\begin{description} +\item[\code{args}] +the list of arguments to process (\code{sys.argv{[}1:]} by default) +\item[\code{options}] +object to store option arguments in (a new instance of +optparse.Values by default) +\end{description} + +and the return values are +\begin{description} +\item[\code{options}] +the same object as was passed in as \code{options}, or the new +optparse.Values instance created by \module{optparse} +\item[\code{args}] +the leftover positional arguments after all options have been +processed +\end{description} + +The most common usage is to supply neither keyword argument. If you +supply a \code{values} object, it will be repeatedly modified with a +\code{setattr()} call for every option argument written to an option +destination, and finally returned by \method{parse{\_}args()}. + +If \method{parse{\_}args()} encounters any errors in the argument list, it calls +the OptionParser's \method{error()} method with an appropriate end-user error +message. This ultimately terminates your process with an exit status of +2 (the traditional \UNIX{} exit status for command-line errors). + + \subsubsection{Querying and manipulating your option parser\label{optparse-querying-manipulating-option-parser}} Sometimes, it's useful to poke around your option parser and see what's @@ -1050,7 +1133,6 @@ If the OptionParser has an option corresponding to \code{opt{\_}str}, that option is removed. If that option provided any other option strings, all of those option strings become invalid. - If \code{opt{\_}str} does not occur in any option belonging to this OptionParser, raises ValueError. \end{description} @@ -1074,15 +1156,15 @@ mechanism. You can set the conflict-handling mechanism either in the constructor: \begin{verbatim} -parser = OptionParser(..., conflict_handler="...") +parser = OptionParser(..., conflict_handler=handler) \end{verbatim} or with a separate call: \begin{verbatim} -parser.set_conflict_handler("...") +parser.set_conflict_handler(handler) \end{verbatim} -The available conflict-handling mechanisms are: +The available conflict handlers are: \begin{quote} \begin{description} \item[\code{error} (default)] @@ -1131,6 +1213,67 @@ -n, --noisy be noisy --dry-run new dry-run option \end{verbatim} + + +\subsubsection{Other methods\label{optparse-other-methods}} + +OptionParser supports several other public methods: +\begin{itemize} +\item {} +\code{set{\_}usage(usage)} + +Set the usage string according to the rules described above for the +\code{usage} constructor keyword argument. Passing \code{None} sets the +default usage string; use \code{SUPPRESS{\_}USAGE} to suppress a usage +message. + +\item {} +\code{enable{\_}interspersed{\_}args()}, \code{disable{\_}interspersed{\_}args()} + +Enable/disable positional arguments interspersed with options, similar +to GNU getopt (enabled by default). For example, if \code{"-a"} and +\code{"-b"} are both simple options that take no arguments, \module{optparse} +normally accepts this syntax: +\begin{verbatim} +prog -a arg1 -b arg2 +\end{verbatim} + +and treats it as equivalent to +\begin{verbatim} +prog -a -b arg1 arg2 +\end{verbatim} + +To disable this feature, call \code{disable{\_}interspersed{\_}args()}. This +restores traditional \UNIX{} syntax, where option parsing stops with the +first non-option argument. + +\item {} +\code{set{\_}defaults(dest=value, ...)} + +Set default values for several option destinations at once. Using +\method{set{\_}defaults()} is the preferred way to set default values for +options, since multiple options can share the same destination. For +example, if several ``mode'' options all set the same destination, any +one of them can set the default, and the last one wins: +\begin{verbatim} +parser.add_option("--advanced", action="store_const", + dest="mode", const="advanced", + default="novice") # overridden below +parser.add_option("--novice", action="store_const", + dest="mode", const="novice", + default="advanced") # overrides above setting +\end{verbatim} + +To avoid this confusion, use \method{set{\_}defaults()}: +\begin{verbatim} +parse.set_defaults(mode="advanced") +parser.add_option("--advanced", action="store_const", + dest="mode", const="advanced") +parser.add_option("--novice", action="store_const", + dest="mode", const="novice") +\end{verbatim} + +\end{itemize} % $Id$ @@ -1234,7 +1377,7 @@ the current list of leftover arguments, ie. arguments that have been consumed but are neither options nor option arguments. Feel free to modify \code{parser.largs}, e.g. by adding more -arguments to it. (This list will become \var{args}, the second +arguments to it. (This list will become \code{args}, the second return value of \method{parse{\_}args()}.) \item[\code{parser.rargs}] the current list of remaining arguments, ie. with \code{opt{\_}str} and From gward at users.sourceforge.net Sat Mar 19 18:04:37 2005 From: gward at users.sourceforge.net (gward@users.sourceforge.net) Date: Sat Mar 19 18:04:41 2005 Subject: [Python-checkins] python/dist/src/Doc/lib liboptparse.tex, 1.18.2.2, 1.18.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4871/lib Modified Files: Tag: release24-maint liboptparse.tex Log Message: List all option attributes (closes SF #993601). Index: liboptparse.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liboptparse.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 --- liboptparse.tex 19 Mar 2005 16:28:37 -0000 1.18.2.2 +++ liboptparse.tex 19 Mar 2005 17:04:33 -0000 1.18.2.3 @@ -1052,6 +1052,87 @@ \end{itemize} +\subsubsection{Option attributes\label{optparse-option-attributes}} + +The following option attributes may be passed as keyword arguments +to \code{parser.add{\_}option()}. If you pass an option attribute +that is not relevant to a particular option, or fail to pass a required +option attribute, \module{optparse} raises OptionError. +\begin{itemize} +\item {} +\member{action} (default: \code{"store"}) + +Determines \module{optparse}'s behaviour when this option is seen on the command +line; the available options are documented above. + +\item {} +\member{type} (default: \code{"string"}) + +The argument type expected by this option (e.g., \code{"string"} or +\code{"int"}); the available option types are documented below. + +\item {} +\member{dest} (default: derived from option strings) + +If the option's action implies writing or modifying a value somewhere, +this tells \module{optparse} where to write it: \member{dest} names an attribute of the +\code{options} object that \module{optparse} builds as it parses the command line. + +\item {} +\code{default} (deprecated) + +The value to use for this option's destination if the option is not +seen on the command line. Deprecated; use \code{parser.set{\_}defaults()} +instead. + +\item {} +\code{nargs} (default: 1) + +How many arguments of type \member{type} should be consumed when this +option is seen. If {\textgreater} 1, \module{optparse} will store a tuple of values to +\member{dest}. + +\item {} +\code{const} + +For actions that store a constant value, the constant value to store. + +\item {} +\code{choices} + +For options of type \code{"choice"}, the list of strings the user +may choose from. + +\item {} +\code{callback} + +For options with action \code{"callback"}, the callable to call when this +option is seen. See section~\ref{optparse-option-callbacks}, Option Callbacks for detail on the arguments +passed to \code{callable}. + +\item {} +\code{callback{\_}args}, \code{callback{\_}kwargs} + +Additional positional and keyword arguments to pass to \code{callback} +after the four standard callback arguments. + +\item {} +\member{help} + +Help text to print for this option when listing all available options +after the user supplies a \member{help} option (such as \code{"-{}-help"}). +If no help text is supplied, the option will be listed without help +text. To hide this option, use the special value \code{SUPPRESS{\_}HELP}. + +\item {} +\code{metavar} (default: derived from option strings) + +Stand-in for the option argument(s) to use when printing help text. +See section~\ref{optparse-tutorial}, the tutorial for an example. + +\end{itemize} + + \subsubsection{Standard option types\label{optparse-standard-option-types}} \module{optparse} has six built-in option types: \code{string}, \code{int}, \code{long}, From gward at users.sourceforge.net Sat Mar 19 18:05:51 2005 From: gward at users.sourceforge.net (gward@users.sourceforge.net) Date: Sat Mar 19 18:05:53 2005 Subject: [Python-checkins] python/dist/src/Doc/lib liboptparse.tex, 1.18.2.3, 1.18.2.4 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5466/lib Modified Files: Tag: release24-maint liboptparse.tex Log Message: Regenerate from Optik reST source to ensure CVS Id tags are up-to-date. From gward at users.sourceforge.net Sat Mar 19 18:15:06 2005 From: gward at users.sourceforge.net (gward@users.sourceforge.net) Date: Sat Mar 19 18:15:14 2005 Subject: [Python-checkins] python/dist/src/Doc/lib liboptparse.tex, 1.18.2.4, 1.18.2.5 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10723/lib Modified Files: Tag: release24-maint liboptparse.tex Log Message: SF #1086675: restore "Extending optparse" section (which was dropped in Python 2.4). Index: liboptparse.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liboptparse.tex,v retrieving revision 1.18.2.4 retrieving revision 1.18.2.5 diff -u -d -r1.18.2.4 -r1.18.2.5 --- liboptparse.tex 19 Mar 2005 17:05:48 -0000 1.18.2.4 +++ liboptparse.tex 19 Mar 2005 17:15:03 -0000 1.18.2.5 @@ -1648,3 +1648,247 @@ \code{"-c"}. Fixing this is left as an exercise for the reader. % $Id$ + +\subsection{Extending \module{optparse}\label{optparse-extending-optparse}} + +Since the two major controlling factors in how \module{optparse} interprets +command-line options are the action and type of each option, the most +likely direction of extension is to add new actions and new types. + +Also, the \code{examples/} directory of the source distribution includes +several demonstrations of extending \module{optparse} in different ways: e.g. a +case-insensitive option parser, or two kinds of option parsers that +implement ``required options''. + + +\subsubsection{Adding new types\label{optparse-adding-new-types}} + +To add new types, you need to define your own subclass of \module{optparse}'s Option +class. This class has a couple of attributes that define \module{optparse}'s types: +\member{TYPES} and \member{TYPE{\_}CHECKER}. + +\member{TYPES} is a tuple of type names; in your subclass, simply define a new +tuple \member{TYPES} that builds on the standard one. + +\member{TYPE{\_}CHECKER} is a dictionary mapping type names to type-checking +functions. A type-checking function has the following signature: +\begin{verbatim} +def check_mytype(option, opt, value) +\end{verbatim} + +where \code{option} is an \class{Option} instance, \code{opt} is an option string +(e.g., \code{"-f"}), and \code{value} is the string from the command line that +must be checked and converted to your desired type. \code{check{\_}mytype()} +should return an object of the hypothetical type \code{mytype}. The value +returned by a type-checking function will wind up in the OptionValues +instance returned by \method{OptionParser.parse{\_}args()}, or be passed to a +callback as the \code{value} parameter. + +Your type-checking function should raise OptionValueError if it +encounters any problems. OptionValueError takes a single string +argument, which is passed as-is to OptionParser's \method{error()} method, +which in turn prepends the program name and the string \code{"error:"} and +prints everything to stderr before terminating the process. + +Here's a silly example that demonstrates adding a \code{complex} option +type to parse Python-style complex numbers on the command line. (This +is even sillier than it used to be, because \module{optparse} 1.3 added built-in +support for complex numbers, but never mind.) + +First, the necessary imports: +\begin{verbatim} +from copy import copy +from optparse import Option, OptionValueError +\end{verbatim} + +You need to define your type-checker first, since it's referred to later +(in the \member{TYPE{\_}CHECKER} class attribute of your Option subclass): +\begin{verbatim} +def check_complex(option, opt, value): + try: + return complex(value) + except ValueError: + raise OptionValueError( + "option %s: invalid complex value: %r" % (opt, value)) +\end{verbatim} + +Finally, the Option subclass: +\begin{verbatim} +class MyOption (Option): + TYPES = Option.TYPES + ("complex",) + TYPE_CHECKER = copy(Option.TYPE_CHECKER) + TYPE_CHECKER["complex"] = check_complex +\end{verbatim} + +(If we didn't make a \function{copy()} of \member{Option.TYPE{\_}CHECKER}, we would end +up modifying the \member{TYPE{\_}CHECKER} attribute of \module{optparse}'s Option class. +This being Python, nothing stops you from doing that except good manners +and common sense.) + +That's it! Now you can write a script that uses the new option type +just like any other \module{optparse}-based script, except you have to instruct your +OptionParser to use MyOption instead of Option: +\begin{verbatim} +parser = OptionParser(option_class=MyOption) +parser.add_option("-c", type="complex") +\end{verbatim} + +Alternately, you can build your own option list and pass it to +OptionParser; if you don't use \method{add{\_}option()} in the above way, you +don't need to tell OptionParser which option class to use: +\begin{verbatim} +option_list = [MyOption("-c", action="store", type="complex", dest="c")] +parser = OptionParser(option_list=option_list) +\end{verbatim} + + +\subsubsection{Adding new actions\label{optparse-adding-new-actions}} + +Adding new actions is a bit trickier, because you have to understand +that \module{optparse} has a couple of classifications for actions: +\begin{description} +\item[``store'' actions] +actions that result in \module{optparse} storing a value to an attribute of the +current OptionValues instance; these options require a \member{dest} +attribute to be supplied to the Option constructor +\item[``typed'' actions] +actions that take a value from the command line and expect it to be +of a certain type; or rather, a string that can be converted to a +certain type. These options require a \member{type} attribute to the +Option constructor. +\end{description} + +These are overlapping sets: some default ``store'' actions are \code{store}, +\code{store{\_}const}, \code{append}, and \code{count}, while the default ``typed'' +actions are \code{store}, \code{append}, and \code{callback}. + +When you add an action, you need to decide if it's a ``store'' action, a +``typed'' action, neither, or both. Three class attributes of +Option (or your Option subclass) control this: +\begin{description} +\item[\member{ACTIONS}] +all actions must be listed in ACTIONS +\item[\member{STORE{\_}ACTIONS}] +``store'' actions are additionally listed here +\item[\member{TYPED{\_}ACTIONS}] +``typed'' actions are additionally listed here +\end{description} + +In order to actually implement your new action, you must override +Option's \method{take{\_}action()} method and add a case that recognizes your +action. + +For example, let's add an \code{extend} action. This is similar to the +standard \code{append} action, but instead of taking a single value from +the command-line and appending it to an existing list, \code{extend} will +take multiple values in a single comma-delimited string, and extend an +existing list with them. That is, if \code{"-{}-names"} is an \code{extend} +option of type \code{string}, the command line +\begin{verbatim} +--names=foo,bar --names blah --names ding,dong +\end{verbatim} + +would result in a list +\begin{verbatim} +["foo", "bar", "blah", "ding", "dong"] +\end{verbatim} + +Again we define a subclass of Option: +\begin{verbatim} +class MyOption (Option): + + ACTIONS = Option.ACTIONS + ("extend",) + STORE_ACTIONS = Option.STORE_ACTIONS + ("extend",) + TYPED_ACTIONS = Option.TYPED_ACTIONS + ("extend",) + + def take_action(self, action, dest, opt, value, values, parser): + if action == "extend": + lvalue = value.split(",") + values.ensure_value(dest, []).extend(lvalue) + else: + Option.take_action( + self, action, dest, opt, value, values, parser) +\end{verbatim} + +Features of note: +\begin{itemize} +\item {} +\code{extend} both expects a value on the command-line and stores that +value somewhere, so it goes in both \member{STORE{\_}ACTIONS} and +\member{TYPED{\_}ACTIONS} + +\item {} +\method{MyOption.take{\_}action()} implements just this one new action, and +passes control back to \method{Option.take{\_}action()} for the standard +\module{optparse} actions + +\item {} +\code{values} is an instance of the optparse{\_}parser.Values class, +which provides the very useful \method{ensure{\_}value()} method. +\method{ensure{\_}value()} is essentially \function{getattr()} with a safety valve; +it is called as +\begin{verbatim} +values.ensure_value(attr, value) +\end{verbatim} + +If the \code{attr} attribute of \code{values} doesn't exist or is None, then +ensure{\_}value() first sets it to \code{value}, and then returns 'value. +This is very handy for actions like \code{extend}, \code{append}, and +\code{count}, all of which accumulate data in a variable and expect that +variable to be of a certain type (a list for the first two, an integer +for the latter). Using \method{ensure{\_}value()} means that scripts using +your action don't have to worry about setting a default value for the +option destinations in question; they can just leave the default as +None and \method{ensure{\_}value()} will take care of getting it right when +it's needed. + +\end{itemize} + + +\subsubsection{Other reasons to extend \module{optparse}\label{optparse-other-reasons-to-extend-optparse}} + +Adding new types and new actions are the big, obvious reasons why you +might want to extend \module{optparse}. I can think of at least two other areas to +play with. + +First, the simple one: OptionParser tries to be helpful by calling +\function{sys.exit()} when appropriate, i.e. when there's an error on the +command line or when the user requests help. In the former case, the +traditional course of letting the script crash with a traceback is +unacceptable; it will make users think there's a bug in your script when +they make a command-line error. In the latter case, there's generally +not much point in carrying on after printing a help message. + +If this behaviour bothers you, it shouldn't be too hard to ``fix'' it. +You'll have to +\newcounter{listcnt1} +\begin{list}{\arabic{listcnt1})} +{ +\usecounter{listcnt1} +\setlength{\rightmargin}{\leftmargin} +} +\item {} +subclass OptionParser and override \method{error()} + +\item {} +subclass Option and override \method{take{\_}action()}{---}you'll +need to provide your own handling of the \member{help} action that +doesn't call \function{sys.exit()} + +\end{list} + +The second, much more complex, possibility is to override the +command-line syntax implemented by \module{optparse}. In this case, you'd leave the +whole machinery of option actions and types alone, but rewrite the code +that processes \var{sys.argv}. You'll need to subclass OptionParser in any +case; depending on how radical a rewrite you want, you'll probably need +to override one or all of \method{parse{\_}args()}, \method{{\_}process{\_}long{\_}opt()}, and +\method{{\_}process{\_}short{\_}opts()}. + +Both of these are left as an exercise for the reader. I have not tried +to implement either myself, since I'm quite happy with \module{optparse}'s default +behaviour (naturally). + +Happy hacking, and don't forget: Use the Source, Luke. +% $Id$ + From doko at users.sourceforge.net Sun Mar 20 15:16:05 2005 From: doko at users.sourceforge.net (doko@users.sourceforge.net) Date: Sun Mar 20 15:16:08 2005 Subject: [Python-checkins] python/dist/src/Misc python.man,1.31,1.32 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20657/Misc Modified Files: python.man Log Message: fix two typos in python(1) Index: python.man =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/python.man,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- python.man 7 Oct 2004 12:30:54 -0000 1.31 +++ python.man 20 Mar 2005 14:16:03 -0000 1.32 @@ -253,7 +253,7 @@ .I command may contain multiple statements separated by newlines. Leading whitespace is significant in Python statements! -In non-interactive mode, the entire input is parsed befored it is +In non-interactive mode, the entire input is parsed before it is executed. .PP If available, the script name and additional arguments thereafter are @@ -330,7 +330,7 @@ Augments the default search path for module files. The format is the same as the shell's $PATH: one or more directory pathnames separated by colons. -Non-existant directories are silently ignored. +Non-existent directories are silently ignored. The default search path is installation dependent, but generally begins with ${prefix}/lib/python (see PYTHONHOME above). The default search path is always appended to $PYTHONPATH. From doko at users.sourceforge.net Sun Mar 20 15:18:06 2005 From: doko at users.sourceforge.net (doko@users.sourceforge.net) Date: Sun Mar 20 15:18:08 2005 Subject: [Python-checkins] python/dist/src/Misc python.man,1.31,1.31.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22061/Misc Modified Files: Tag: release24-maint python.man Log Message: fix two typos in python(1) Index: python.man =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/python.man,v retrieving revision 1.31 retrieving revision 1.31.2.1 diff -u -d -r1.31 -r1.31.2.1 --- python.man 7 Oct 2004 12:30:54 -0000 1.31 +++ python.man 20 Mar 2005 14:18:04 -0000 1.31.2.1 @@ -253,7 +253,7 @@ .I command may contain multiple statements separated by newlines. Leading whitespace is significant in Python statements! -In non-interactive mode, the entire input is parsed befored it is +In non-interactive mode, the entire input is parsed before it is executed. .PP If available, the script name and additional arguments thereafter are @@ -330,7 +330,7 @@ Augments the default search path for module files. The format is the same as the shell's $PATH: one or more directory pathnames separated by colons. -Non-existant directories are silently ignored. +Non-existent directories are silently ignored. The default search path is installation dependent, but generally begins with ${prefix}/lib/python (see PYTHONHOME above). The default search path is always appended to $PYTHONPATH. From fdrake at users.sourceforge.net Sun Mar 20 16:57:40 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Sun Mar 20 16:57:43 2005 Subject: [Python-checkins] python/nondist/peps pep-0314.txt,1.18,1.19 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20639 Modified Files: pep-0314.txt Log Message: add a way to spell that a specific version of an individual module or package is being provided; this is useful for omnibus packages Index: pep-0314.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0314.txt,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- pep-0314.txt 3 Feb 2005 12:30:44 -0000 1.18 +++ pep-0314.txt 20 Mar 2005 15:57:37 -0000 1.19 @@ -239,11 +239,12 @@ Provides (multiple use) - Each entry contains a string describing a package or - module that will be provided by this package once it is - installed. These strings should match the ones used in - Requirements fields. Version declarations cannot be supplied; - instead the package's version number will be used. + Each entry contains a string describing a package or module that + will be provided by this package once it is installed. These + strings should match the ones used in Requirements fields. A + version declaration may be supplied (without a comparison + operator); the package's version number will be implied if none + is specified. Example: @@ -251,6 +252,7 @@ Provides: xml.utils Provides: xml.utils.iso8601 Provides: xml.dom + Provides: xmltools (1.3) Obsoletes (multiple use) From fdrake at users.sourceforge.net Sun Mar 20 16:59:06 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Sun Mar 20 16:59:09 2005 Subject: [Python-checkins] python/nondist/peps pep-0314.txt,1.19,1.20 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21810 Modified Files: pep-0314.txt Log Message: fix spelling of pyexpat's name Index: pep-0314.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0314.txt,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- pep-0314.txt 20 Mar 2005 15:57:37 -0000 1.19 +++ pep-0314.txt 20 Mar 2005 15:59:04 -0000 1.20 @@ -234,7 +234,7 @@ Requires: re Requires: sys Requires: zlib - Requires: pyexpat (>1.0) + Requires: xml.parsers.expat (>1.0) Requires: psycopg Provides (multiple use) From goodger at users.sourceforge.net Sun Mar 20 19:30:15 2005 From: goodger at users.sourceforge.net (goodger@users.sourceforge.net) Date: Sun Mar 20 19:30:18 2005 Subject: [Python-checkins] python/nondist/peps pep-0000.txt,1.301,1.302 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23384 Modified Files: pep-0000.txt Log Message: updated PEP 301 status; added encoding to Emacs stanza Index: pep-0000.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v retrieving revision 1.301 retrieving revision 1.302 diff -u -d -r1.301 -r1.302 --- pep-0000.txt 28 Feb 2005 19:53:29 -0000 1.301 +++ pep-0000.txt 20 Mar 2005 18:30:12 -0000 1.302 @@ -97,7 +97,6 @@ S 297 Support for System Upgrades Lemburg S 298 The Locked Buffer Interface Heller S 299 Special __main__() function in modules Epler - S 301 Package Index and Metadata for Distutils Jones S 302 New Import Hooks JvR S 303 Extend divmod() for Multiple Divisors Bellman S 304 Controlling Generation of Bytecode Files Montanaro @@ -165,6 +164,7 @@ SF 289 Generator Expressions Hettinger SF 292 Simpler String Substitutions Warsaw SF 293 Codec Error Handling Callbacks Dörwald + SF 301 Package Index and Metadata for Distutils Jones SF 305 CSV File API Montanaro, et al SF 307 Extensions to the pickle protocol GvR, Peters SF 309 Partial Function Application Harris @@ -335,7 +335,7 @@ S 297 Support for System Upgrades Lemburg S 298 The Locked Buffer Interface Heller S 299 Special __main__() function in modules Epler - S 301 Package Index and Metadata for Distutils Jones + SF 301 Package Index and Metadata for Distutils Jones S 302 New Import Hooks JvR S 303 Extend divmod() for Multiple Divisors Bellman S 304 Controlling Generation of Bytecode Files Montanaro @@ -495,4 +495,5 @@ indent-tabs-mode: nil sentence-end-double-space: t fill-column: 70 +coding: latin-1 End: From akuchling at users.sourceforge.net Sun Mar 20 20:26:33 2005 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sun Mar 20 20:26:38 2005 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew25.tex, 1.5, 1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27147 Modified Files: whatsnew25.tex Log Message: Describe various things Index: whatsnew25.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew25.tex,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- whatsnew25.tex 1 Mar 2005 00:53:46 -0000 1.5 +++ whatsnew25.tex 20 Mar 2005 19:26:30 -0000 1.6 @@ -41,7 +41,7 @@ \item The \function{min()} and \function{max()} built-in functions gained a \code{key} keyword argument analogous to the \code{key} -argument for \function{sort()}. This argument supplies a function +argument for \method{sort()}. This argument supplies a function that takes a single argument and is called for every value in the list; \function{min()}/\function{max()} will return the element with the smallest/largest return value from this function. @@ -55,10 +55,17 @@ print max(L) \end{verbatim} -% XXX also supported by heapq.nsmallest() and heapq.nlargest(). - (Contributed by Steven Bethard and Raymond Hettinger.) +\item The list of base classes in a class definition can now be empty. +As an example, this is now legal: + +\begin{verbatim} +class C(): + pass +\end{verbatim} +(Implemented by Brett Cannon.) + \end{itemize} @@ -95,17 +102,48 @@ % datetime.datetime() now has a strptime class method which can be used to % create datetime object using a string and format. +\item The \function{nsmallest()} and +\function{nlargest()} functions in the \module{heapq} module +now support a \code{key} keyword argument similar to the one +provided by the \function{min()}/\function{max()} functions +and the \method{sort()} methods. For example: +Example: + +\begin{verbatim} +>>> import heapq +>>> L = ["short", 'medium', 'longest', 'longer still'] +>>> heapq.nsmallest(2, L) # Return two lowest elements, lexicographically +['longer still', 'longest'] +>>> heapq.nsmallest(2, L, key=len) # Return two shortest elements +['short', 'medium'] +\end{verbatim} + +(Contributed by Raymond Hettinger.) + % itertools.islice() now accepts None for the start and step arguments. \item New module: \module{spwd} provides functions for accessing the shadow password database on systems that support it. % XXX give example -% XXX os.stat_float_times is now True +\item The \module{os} module underwent a number of changes. The +\member{stat_float_times} variable now defaults to true, meaning that +\function{os.stat()} will now return time values as floats. (This +doesn't necessarily mean that \function{os.stat()} will return times +that are precise to fractions of a second; not all systems support +such precision.) + +Also, constants named \member{os.SEEK_SET}, \member{os.SEEK_CUR}, and +\member{os.SEEK_END} have been added; these are the parameters to the +\function{os.lseek()} function. + +\item The \class{TarFile} class in the \module{tarfile} module now has +a \method{extractall()} method that extracts all members from the +archive into the current working directory. It's also possible to set +a different directory as the extraction target, and to unpack only a +subset of the archive's members. (Contributed by Lars Gust\"abel.) -% os.{SEEK_SET, SEEK_CUR, SEEK_END} have been added for convenience. -\end{itemize} %====================================================================== From akuchling at users.sourceforge.net Sun Mar 20 20:52:20 2005 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sun Mar 20 20:52:22 2005 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew25.tex, 1.6, 1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11740 Modified Files: whatsnew25.tex Log Message: Add item Index: whatsnew25.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew25.tex,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- whatsnew25.tex 20 Mar 2005 19:26:30 -0000 1.6 +++ whatsnew25.tex 20 Mar 2005 19:52:18 -0000 1.7 @@ -120,7 +120,17 @@ (Contributed by Raymond Hettinger.) -% itertools.islice() now accepts None for the start and step arguments. +\item The \function{itertools.islice()} function now accepts +\code{None} for the start and step arguments. This makes it more +compatible with the attributes of slice objects, so that you can now write +the following: + +\begin{verbatim} +s = slice(5) # Create slice object +itertools.islice(iterable, s.start, s.stop, s.step) +\end{verbatim} + +(Contributed by Raymond Hettinger.) \item New module: \module{spwd} provides functions for accessing the shadow password database on systems that support it. From akuchling at users.sourceforge.net Sun Mar 20 21:06:52 2005 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sun Mar 20 21:06:55 2005 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew25.tex, 1.7, 1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19921 Modified Files: whatsnew25.tex Log Message: Describe how to get back lib-old; if this isn't the best way, please let me know Index: whatsnew25.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew25.tex,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- whatsnew25.tex 20 Mar 2005 19:52:18 -0000 1.7 +++ whatsnew25.tex 20 Mar 2005 20:06:49 -0000 1.8 @@ -206,7 +206,20 @@ \item Some old deprecated modules (\module{statcache}, \module{tzparse}, \module{whrandom}) have been moved to \file{Lib/lib-old}. -% XXX note how to get them back +You can get access to these modules again by adding the directory +to your \code{sys.path}: + +\begin{verbatim} +import os +from distutils import sysconfig + +lib_dir = sysconfig.get_python_lib(standard_lib=True) +old_dir = os.path.join(lib_dir, 'lib-old') +sys.path.append(old_dir) +\end{verbatim} + +Doing so is discouraged, however; it's better to update any code that +still uses these modules. % the pickle module no longer uses the deprecated bin parameter. From akuchling at users.sourceforge.net Sun Mar 20 21:47:04 2005 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sun Mar 20 21:47:09 2005 Subject: [Python-checkins] python/nondist/peps pep-0291.txt,1.13,1.14 Message-ID: Update of /cvsroot/python/python/nondist/peps In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11750 Modified Files: pep-0291.txt Log Message: After some discussion at the distutils sprint at PyCon 2005, it seems that no one really wants to make a new standalone release of Distutils. Given that, there's no reason for Distutils code to preserve backward compatibility, so I am removing the requirement for 2.1 compatibility. (Jython doesn't use Distutils. Samuele Pedroni observes that if Jython does use it someday, that version of Jython will likely support 2.2/2.3 features. So Jython isn't a reason to keep 2.1 compatibility.) Index: pep-0291.txt =================================================================== RCS file: /cvsroot/python/python/nondist/peps/pep-0291.txt,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- pep-0291.txt 10 Nov 2004 08:22:51 -0000 1.13 +++ pep-0291.txt 20 Mar 2005 20:47:01 -0000 1.14 @@ -81,7 +81,6 @@ Barry Warsaw compiler Jeremy Hylton 2.1 decimal Raymond Hettinger 2.3 [2] - distutils Andrew Kuchling 2.1 email Barry Warsaw 2.1 / 2.3 [1] logging Vinay Sajip 1.5.2 sre Fredrik Lundh 2.1 From akuchling at users.sourceforge.net Sun Mar 20 22:42:06 2005 From: akuchling at users.sourceforge.net (akuchling@users.sourceforge.net) Date: Sun Mar 20 22:42:09 2005 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew25.tex, 1.8, 1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17448 Modified Files: whatsnew25.tex Log Message: Write part of PEP 309 section Index: whatsnew25.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew25.tex,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- whatsnew25.tex 20 Mar 2005 20:06:49 -0000 1.8 +++ whatsnew25.tex 20 Mar 2005 21:42:04 -0000 1.9 @@ -28,7 +28,28 @@ %====================================================================== \section{PEP 309: Partial Function Application} -XXX describe this PEP. +For programs written in a functional style, it can be useful to +construct variants of existing functions that have some of the +parameters filled in. This is called ``partial function application''. +The new \module{functional} module contains a \class{partial} class +that provides partial application. + +The \module{functional} module is intended to contain tools for +functional-style programming. Currently it only contains +\class{partial}, but new functions will probably be added in future +versions of Python. + +% XXX write rest of this +% XXX add example from my GTk programming + + +\begin{seealso} + +\seepep{309}{Partial Function Application}{PEP proposed and written by +Peter Harris; implemented by Hye-Shik Chang, with adaptations by +Raymond Hettinger.} + +\end{seealso} %====================================================================== From fdrake at users.sourceforge.net Sun Mar 20 23:17:04 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Sun Mar 20 23:17:07 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils versionpredicate.py, NONE, 1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5161 Added Files: versionpredicate.py Log Message: helper code, mostly from Andy Harrington, for PEP 314 completion --- NEW FILE: versionpredicate.py --- """Module for parsing and testing package version predicate strings. """ import re import version import operator re_validPackage = re.compile(r"(?i)^\s*([a-z_]\w*(?:\.[a-z_]\w*)*)(.*)") # (package) (rest) re_paren = re.compile(r"^\s*\((.*)\)\s*$") # (list) inside of parentheses re_splitComparison = re.compile(r"^\s*(<=|>=|<|>|!=|==)\s*([^\s,]+)\s*$") # (comp) (version) def splitUp(pred): """Parse a single version comparison. Return (comparison string, StrictVersion) """ res = re_splitComparison.match(pred) if not res: raise ValueError, "Bad package restriction syntax: " + pred comp, verStr = res.groups() return (comp, version.StrictVersion(verStr)) compmap = {"<": operator.lt, "<=": operator.le, "==": operator.eq, ">": operator.gt, ">=": operator.ge, "!=": operator.ne} class VersionPredicate: """Parse and test package version predicates. >>> v = VersionPredicate("pyepat.abc (>1.0, <3333.3a1, !=1555.1b3)") >>> print v pyepat.abc (> 1.0, < 3333.3a1, != 1555.1b3) >>> v.satisfied_by("1.1") True >>> v.satisfied_by("1.4") True >>> v.satisfied_by("1.0") False >>> v.satisfied_by("4444.4") False >>> v.satisfied_by("1555.1b3") False >>> v = VersionPredicate("pat( == 0.1 ) ") >>> v.satisfied_by("0.1") True >>> v.satisfied_by("0.2") False >>> v = VersionPredicate("p1.p2.p3.p4(>=1.0, <=1.3a1, !=1.2zb3)") Traceback (most recent call last): ... ValueError: invalid version number '1.2zb3' """ def __init__(self, versionPredicateStr): """Parse a version predicate string. """ # Fields: # name: package name # pred: list of (comparison string, StrictVersion) versionPredicateStr = versionPredicateStr.strip() if not versionPredicateStr: raise ValueError, "Empty package restriction" match = re_validPackage.match(versionPredicateStr) if not match: raise ValueError, "Bad package name in " + versionPredicateStr self.name, paren = match.groups() paren = paren.strip() if paren: match = re_paren.match(paren) if not match: raise ValueError, "Expected parenthesized list: " + paren str = match.groups()[0] self.pred = [splitUp(aPred) for aPred in str.split(",")] if not self.pred: raise ValueError("Empty Parenthesized list in %r" % versionPredicateStr ) else: self.pred=[] def __str__(self): if self.pred: seq = [cond + " " + str(ver) for cond, ver in self.pred] return self.name + " (" + ", ".join(seq) + ")" else: return self.name def satisfied_by(self, version): """True if version is compatible with all the predicates in self. The parameter version must be acceptable to the StrictVersion constructor. It may be either a string or StrictVersion. """ for cond, ver in self.pred: if not compmap[cond](version, ver): return False return True def check_provision(value): m = re.match("[a-zA-Z_]\w*(\.[a-zA-Z_]\w*)*(\s*\([^)]+\))?$", value) if not m: raise ValueError("illegal provides specification: %r" % value) From fdrake at users.sourceforge.net Sun Mar 20 23:17:05 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Sun Mar 20 23:17:08 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils/tests test_versionpredicate.py, NONE, 1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5161/tests Added Files: test_versionpredicate.py Log Message: helper code, mostly from Andy Harrington, for PEP 314 completion --- NEW FILE: test_versionpredicate.py --- """Tests harness for distutils.versionpredicate. """ import distutils.versionpredicate import doctest def test_suite(): return doctest.DocTestSuite(distutils.versionpredicate) From fdrake at users.sourceforge.net Sun Mar 20 23:19:48 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Sun Mar 20 23:19:51 2005 Subject: [Python-checkins] python/dist/src/Doc/dist dist.tex,1.89,1.90 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/dist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6803/Doc/dist Modified Files: dist.tex Log Message: PEP 314 implementation (client side): added support for the provides, requires, and obsoletes metadata fields Index: dist.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/dist/dist.tex,v retrieving revision 1.89 retrieving revision 1.90 diff -u -d -r1.89 -r1.90 --- dist.tex 10 Mar 2005 03:48:14 -0000 1.89 +++ dist.tex 20 Mar 2005 22:19:46 -0000 1.90 @@ -631,7 +631,83 @@ will automatically add \code{initmodule} to the list of exported symbols. +\section{Relationships between Distributions and Packages} + +A distribution may relate to packages in three specific ways: + +\begin{enumerate} + \item It can require packages or modules. + + \item It can provide packages or modules. + + \item It can obsolete packages or modules. +\end{enumerate} + +These relationships can be specified using keyword arguments to the +\function{distutils.core.setup()} function. + +Dependencies on other Python modules and packages can be specified by +supplying the \var{requires} keyword argument to \function{setup()}. +The value must be a list of strings. Each string specifies a package +that is required, and optionally what versions are sufficient. + +To specify that any version of a module or package is required, the +string should consist entirely of the module or package name. +Examples include \code{'mymodule'} and \code{'xml.parsers.expat'}. + +If specific versions are required, a sequence of qualifiers can be +supplied in parentheses. Each qualifier may consist of a comparison +operator and a version number. The accepted comparison operators are: + +\begin{verbatim} +< > == +<= >= != +\end{verbatim} + +These can be combined by using multiple qualifiers separated by commas +(and optional whitespace). In this case, all of the qualifiers must +be matched; a logical AND is used to combine the evaluations. + +Let's look at a bunch of examples: + +\begin{tableii}{l|l}{code}{Requires Expression}{Explanation} + \lineii{==1.0} {Only version \code{1.0} is compatible} + \lineii{>1.0, !=1.5.1, <2.0} {Any version after \code{1.0} and before + \code{2.0} is compatible, except + \code{1.5.1}} +\end{tableii} + +Now that we can specify dependencies, we also need to be able to +specify what we provide that other distributions can require. This is +done using the \var{provides} keyword argument to \function{setup()}. +The value for this keyword is a list of strings, each of which names a +Python module or package, and optionally identifies the version. If +the version is not specified, it is assumed to match that of the +distribution. + +Some examples: + +\begin{tableii}{l|l}{code}{Provides Expression}{Explanation} + \lineii{mypkg} {Provide \code{mypkg}, using the distribution version} + \lineii{mypkg (1.1} {Provide \code{mypkg} version 1.1, regardless of the + distribution version} +\end{tableii} + +A package can declare that it obsoletes other packages using the +\var{obsoletes} keyword argument. The value for this is similar to +that of the \var{requires} keyword: a list of strings giving module or +package specifiers. Each specifier consists of a module or package +name optionally followed by one or more version qualifiers. Version +qualifiers are given in parentheses after the module or package name. + +The versions identified by the qualifiers are those that are obsoleted +by the distribution being described. If no qualifiers are given, all +versions of the named module or package are understood to be +obsoleted. + + \section{Installing Scripts} + So far we have been dealing with pure and non-pure Python modules, which are usually not run by themselves but imported by scripts. From fdrake at users.sourceforge.net Sun Mar 20 23:19:48 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Sun Mar 20 23:19:52 2005 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew25.tex, 1.9, 1.10 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6803/Doc/whatsnew Modified Files: whatsnew25.tex Log Message: PEP 314 implementation (client side): added support for the provides, requires, and obsoletes metadata fields Index: whatsnew25.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew25.tex,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- whatsnew25.tex 20 Mar 2005 21:42:04 -0000 1.9 +++ whatsnew25.tex 20 Mar 2005 22:19:46 -0000 1.10 @@ -53,6 +53,14 @@ %====================================================================== +\section{PEP 314: Metadata for Python Software Packages v1.1} + +XXX describe this PEP. + distutils \function{setup()} now supports the \var{provides}, + \var{requires}, \var{obsoletes} keywords. + + +%====================================================================== \section{Other Language Changes} Here are all of the changes that Python 2.5 makes to the core Python From fdrake at users.sourceforge.net Sun Mar 20 23:19:49 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Sun Mar 20 23:19:53 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils/command register.py, 1.7, 1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6803/Lib/distutils/command Modified Files: register.py Log Message: PEP 314 implementation (client side): added support for the provides, requires, and obsoletes metadata fields Index: register.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/register.py,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- register.py 18 Jul 2004 06:14:43 -0000 1.7 +++ register.py 20 Mar 2005 22:19:47 -0000 1.8 @@ -231,7 +231,13 @@ 'platform': meta.get_platforms(), 'classifiers': meta.get_classifiers(), 'download_url': meta.get_download_url(), + # PEP 314 + 'provides': meta.get_provides(), + 'requires': meta.get_requires(), + 'obsoletes': meta.get_obsoletes(), } + if data['provides'] or data['requires'] or data['obsoletes']: + data['metadata_version'] = '1.1' return data def post_to_server(self, data, auth=None): From fdrake at users.sourceforge.net Sun Mar 20 23:19:49 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Sun Mar 20 23:19:55 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils core.py, 1.64, 1.65 dist.py, 1.73, 1.74 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6803/Lib/distutils Modified Files: core.py dist.py Log Message: PEP 314 implementation (client side): added support for the provides, requires, and obsoletes metadata fields Index: core.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/core.py,v retrieving revision 1.64 retrieving revision 1.65 diff -u -d -r1.64 -r1.65 --- core.py 10 Nov 2004 22:23:14 -0000 1.64 +++ core.py 20 Mar 2005 22:19:46 -0000 1.65 @@ -47,7 +47,9 @@ 'name', 'version', 'author', 'author_email', 'maintainer', 'maintainer_email', 'url', 'license', 'description', 'long_description', 'keywords', - 'platforms', 'classifiers', 'download_url',) + 'platforms', 'classifiers', 'download_url', + 'requires', 'provides', 'obsoletes', + ) # Legal keyword arguments for the Extension constructor extension_keywords = ('name', 'sources', 'include_dirs', Index: dist.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/dist.py,v retrieving revision 1.73 retrieving revision 1.74 diff -u -d -r1.73 -r1.74 --- dist.py 3 Mar 2005 08:12:26 -0000 1.73 +++ dist.py 20 Mar 2005 22:19:46 -0000 1.74 @@ -106,6 +106,12 @@ "print the list of classifiers"), ('keywords', None, "print the list of keywords"), + ('provides', None, + "print the list of packages/modules provided"), + ('requires', None, + "print the list of packages/modules required"), + ('obsoletes', None, + "print the list of packages/modules made obsolete") ] display_option_names = map(lambda x: translate_longopt(x[0]), display_options) @@ -210,7 +216,6 @@ # distribution options. if attrs: - # Pull out the set of command options and work on them # specifically. Note that this order guarantees that aliased # command options will override any supplied redundantly @@ -235,7 +240,9 @@ # Now work on the rest of the attributes. Any attribute that's # not already defined is invalid! for (key,val) in attrs.items(): - if hasattr(self.metadata, key): + if hasattr(self.metadata, "set_" + key): + getattr(self.metadata, "set_" + key)(val) + elif hasattr(self.metadata, key): setattr(self.metadata, key, val) elif hasattr(self, key): setattr(self, key, val) @@ -678,7 +685,8 @@ value = getattr(self.metadata, "get_"+opt)() if opt in ['keywords', 'platforms']: print string.join(value, ',') - elif opt == 'classifiers': + elif opt in ('classifiers', 'provides', 'requires', + 'obsoletes'): print string.join(value, '\n') else: print value @@ -1024,7 +1032,10 @@ "license", "description", "long_description", "keywords", "platforms", "fullname", "contact", "contact_email", "license", "classifiers", - "download_url") + "download_url", + # PEP 314 + "provides", "requires", "obsoletes", + ) def __init__ (self): self.name = None @@ -1041,40 +1052,58 @@ self.platforms = None self.classifiers = None self.download_url = None + # PEP 314 + self.provides = None + self.requires = None + self.obsoletes = None def write_pkg_info (self, base_dir): """Write the PKG-INFO file into the release tree. """ - pkg_info = open( os.path.join(base_dir, 'PKG-INFO'), 'w') - pkg_info.write('Metadata-Version: 1.0\n') - pkg_info.write('Name: %s\n' % self.get_name() ) - pkg_info.write('Version: %s\n' % self.get_version() ) - pkg_info.write('Summary: %s\n' % self.get_description() ) - pkg_info.write('Home-page: %s\n' % self.get_url() ) - pkg_info.write('Author: %s\n' % self.get_contact() ) - pkg_info.write('Author-email: %s\n' % self.get_contact_email() ) - pkg_info.write('License: %s\n' % self.get_license() ) + self.write_pkg_file(pkg_info) + + pkg_info.close() + + # write_pkg_info () + + def write_pkg_file (self, file): + """Write the PKG-INFO format data to a file object. + """ + version = '1.0' + if self.provides or self.requires or self.obsoletes: + version = '1.1' + + file.write('Metadata-Version: %s\n' % version) + file.write('Name: %s\n' % self.get_name() ) + file.write('Version: %s\n' % self.get_version() ) + file.write('Summary: %s\n' % self.get_description() ) + file.write('Home-page: %s\n' % self.get_url() ) + file.write('Author: %s\n' % self.get_contact() ) + file.write('Author-email: %s\n' % self.get_contact_email() ) + file.write('License: %s\n' % self.get_license() ) if self.download_url: - pkg_info.write('Download-URL: %s\n' % self.download_url) + file.write('Download-URL: %s\n' % self.download_url) long_desc = rfc822_escape( self.get_long_description() ) - pkg_info.write('Description: %s\n' % long_desc) + file.write('Description: %s\n' % long_desc) keywords = string.join( self.get_keywords(), ',') if keywords: - pkg_info.write('Keywords: %s\n' % keywords ) - - for platform in self.get_platforms(): - pkg_info.write('Platform: %s\n' % platform ) + file.write('Keywords: %s\n' % keywords ) - for classifier in self.get_classifiers(): - pkg_info.write('Classifier: %s\n' % classifier ) + self._write_list(file, 'Platform', self.get_platforms()) + self._write_list(file, 'Classifier', self.get_classifiers()) - pkg_info.close() + # PEP 314 + self._write_list(file, 'Requires', self.get_requires()) + self._write_list(file, 'Provides', self.get_provides()) + self._write_list(file, 'Obsoletes', self.get_obsoletes()) - # write_pkg_info () + def _write_list (self, file, name, values): + for value in values: + file.write('%s: %s\n' % (name, value)) # -- Metadata query methods ---------------------------------------- @@ -1134,6 +1163,40 @@ def get_download_url(self): return self.download_url or "UNKNOWN" + # PEP 314 + + def get_requires(self): + return self.requires or [] + + def set_requires(self, value): + import distutils.versionpredicate + for v in value: + distutils.versionpredicate.VersionPredicate(v) + self.requires = value + + def get_provides(self): + return self.provides or [] + + def set_provides(self, value): + value = [v.strip() for v in value] + for v in value: + import distutils.versionpredicate + ver = distutils.versionpredicate.check_provision(v) + if ver: + import distutils.version + sv = distutils.version.StrictVersion() + sv.parse(ver.strip()[1:-1]) + self.provides = value + + def get_obsoletes(self): + return self.obsoletes or [] + + def set_obsoletes(self, value): + import distutils.versionpredicate + for v in value: + distutils.versionpredicate.VersionPredicate(v) + self.obsoletes = value + # class DistributionMetadata From fdrake at users.sourceforge.net Sun Mar 20 23:19:49 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Sun Mar 20 23:19:56 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils/tests test_dist.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6803/Lib/distutils/tests Modified Files: test_dist.py Log Message: PEP 314 implementation (client side): added support for the provides, requires, and obsoletes metadata fields Index: test_dist.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/tests/test_dist.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- test_dist.py 3 Aug 2004 16:37:40 -0000 1.1 +++ test_dist.py 20 Mar 2005 22:19:47 -0000 1.2 @@ -4,6 +4,7 @@ import distutils.dist import os import shutil +import StringIO import sys import tempfile import unittest @@ -96,5 +97,93 @@ os.unlink(TESTFN) +class MetadataTestCase(unittest.TestCase): + + def test_simple_metadata(self): + attrs = {"name": "package", + "version": "1.0"} + dist = distutils.dist.Distribution(attrs) + meta = self.format_metadata(dist) + self.assert_("Metadata-Version: 1.0" in meta) + self.assert_("provides:" not in meta.lower()) + self.assert_("requires:" not in meta.lower()) + self.assert_("obsoletes:" not in meta.lower()) + + def test_provides(self): + attrs = {"name": "package", + "version": "1.0", + "provides": ["package", "package.sub"]} + dist = distutils.dist.Distribution(attrs) + self.assertEqual(dist.metadata.get_provides(), + ["package", "package.sub"]) + self.assertEqual(dist.get_provides(), + ["package", "package.sub"]) + meta = self.format_metadata(dist) + self.assert_("Metadata-Version: 1.1" in meta) + self.assert_("requires:" not in meta.lower()) + self.assert_("obsoletes:" not in meta.lower()) + + def test_provides_illegal(self): + self.assertRaises(ValueError, + distutils.dist.Distribution, + {"name": "package", + "version": "1.0", + "provides": ["my.pkg (splat)"]}) + + def test_requires(self): + attrs = {"name": "package", + "version": "1.0", + "requires": ["other", "another (==1.0)"]} + dist = distutils.dist.Distribution(attrs) + self.assertEqual(dist.metadata.get_requires(), + ["other", "another (==1.0)"]) + self.assertEqual(dist.get_requires(), + ["other", "another (==1.0)"]) + meta = self.format_metadata(dist) + self.assert_("Metadata-Version: 1.1" in meta) + self.assert_("provides:" not in meta.lower()) + self.assert_("Requires: other" in meta) + self.assert_("Requires: another (==1.0)" in meta) + self.assert_("obsoletes:" not in meta.lower()) + + def test_requires_illegal(self): + self.assertRaises(ValueError, + distutils.dist.Distribution, + {"name": "package", + "version": "1.0", + "requires": ["my.pkg (splat)"]}) + + def test_obsoletes(self): + attrs = {"name": "package", + "version": "1.0", + "obsoletes": ["other", "another (<1.0)"]} + dist = distutils.dist.Distribution(attrs) + self.assertEqual(dist.metadata.get_obsoletes(), + ["other", "another (<1.0)"]) + self.assertEqual(dist.get_obsoletes(), + ["other", "another (<1.0)"]) + meta = self.format_metadata(dist) + self.assert_("Metadata-Version: 1.1" in meta) + self.assert_("provides:" not in meta.lower()) + self.assert_("requires:" not in meta.lower()) + self.assert_("Obsoletes: other" in meta) + self.assert_("Obsoletes: another (<1.0)" in meta) + + def test_obsoletes_illegal(self): + self.assertRaises(ValueError, + distutils.dist.Distribution, + {"name": "package", + "version": "1.0", + "obsoletes": ["my.pkg (splat)"]}) + + def format_metadata(self, dist): + sio = StringIO.StringIO() + dist.metadata.write_pkg_file(sio) + return sio.getvalue() + + def test_suite(): - return unittest.makeSuite(DistributionTestCase) + suite = unittest.TestSuite() + suite.addTest(unittest.makeSuite(DistributionTestCase)) + suite.addTest(unittest.makeSuite(MetadataTestCase)) + return suite From bcannon at users.sourceforge.net Mon Mar 21 00:26:48 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Mon Mar 21 00:26:50 2005 Subject: [Python-checkins] python/dist/src Makefile.pre.in, 1.86.2.5, 1.86.2.6 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13192 Modified Files: Tag: ast-branch Makefile.pre.in Log Message: Regenerate Python/Python-ast.c and Include/Python-ast.h when Parser/asdl.py or Parser/asdl_c.py is modified. Should probably add SPARK dependencies as well but not sure if it needs to be used to explicitly regen anything. Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.pre.in,v retrieving revision 1.86.2.5 retrieving revision 1.86.2.6 diff -u -d -r1.86.2.5 -r1.86.2.6 --- Makefile.pre.in 7 Jan 2005 06:56:36 -0000 1.86.2.5 +++ Makefile.pre.in 20 Mar 2005 23:26:45 -0000 1.86.2.6 @@ -222,6 +222,7 @@ AST_C= $(srcdir)/Python/Python-ast.c AST_ASDL= $(srcdir)/Parser/Python.asdl +ASDLGEN_FILES= $(srcdir)/Parser/asdl.py $(srcdir)/Parser/asdl_c.py # XXX Note that a build now requires Python exist before the build starts ASDLGEN= $(srcdir)/Parser/asdl_c.py -h $(srcdir)/Include -c $(srcdir)/Python @@ -469,7 +470,7 @@ Parser/tokenizer_pgen.o: $(srcdir)/Parser/tokenizer.c -$(AST_H) $(AST_C): $(AST_ASDL) +$(AST_H) $(AST_C): $(AST_ASDL) $(ASDLGEN_FILES) $(ASDLGEN) $(AST_ASDL) Python/compile.o Python/symtable.o: $(GRAMMAR_H) $(AST_H) From bcannon at users.sourceforge.net Mon Mar 21 00:41:01 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Mon Mar 21 00:41:05 2005 Subject: [Python-checkins] python/dist/src/Parser asdl_c.py,1.1.2.4,1.1.2.5 Message-ID: Update of /cvsroot/python/python/dist/src/Parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15588/Parser Modified Files: Tag: ast-branch asdl_c.py Log Message: Fix Python/asdl_c.py so that generated files Include/Python-ast.h and Python/Python-ast.c do proper casting so that the files now compile. Also removed warning about ambiguous 'if' and 'else' blocks by putting in curly braces. Closes bug #1102710. Thanks logistix. Index: asdl_c.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Parser/Attic/asdl_c.py,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -d -r1.1.2.4 -r1.1.2.5 --- asdl_c.py 16 Jan 2005 17:09:11 -0000 1.1.2.4 +++ asdl_c.py 20 Mar 2005 23:40:58 -0000 1.1.2.5 @@ -9,7 +9,7 @@ import asdl TABSIZE = 8 -MAX_COL = 76 +MAX_COL = 80 def get_c_type(name): """Return a string for the C name of the type. @@ -416,19 +416,22 @@ # don't call free_TYPE() for them. elif field.opt: - emit("if (%s)" % value, 0) + emit("if (%s) {" % value, 0) self.free(field, value, depth + 1) + emit("}", 0) else: self.free(field, value, depth) def free(self, field, value, depth): - if str(field.type) in ("identifier", "string"): - self.emit("Py_DECREF(%s);" % value, depth) + if str(field.type) in ("identifier", "string", "object"): + ctype = get_c_type(field.type) + self.emit("Py_DECREF((%s)%s);" % (ctype, value), depth) elif str(field.type) == "bool": return else: print >> sys.stderr, field.type - self.emit("free_%s(%s);" % (field.type, value), depth) + ctype = get_c_type(field.type) + self.emit("free_%s((%s)%s);" % (field.type, ctype, value), depth) class MarshalFunctionVisitor(PickleVisitor): @@ -490,15 +493,18 @@ emit("marshal_write_int(buf, off, asdl_seq_LEN(%s));" % value, 0) emit("for (i = 0; i < asdl_seq_LEN(%s); i++) {" % value, 0) emit("void *elt = asdl_seq_GET(%s, i);" % value, 1); - emit("marshal_write_%s(buf, off, elt);" % field.type, 1) + ctype = get_c_type(field.type); + emit("marshal_write_%s(buf, off, (%s)elt);" % (field.type, + ctype), 1) emit("}", 0) elif field.opt: emit("if (%s) {" % value, 0) emit("marshal_write_int(buf, off, 1);", 1) emit("marshal_write_%s(buf, off, %s);" % (field.type, value), 1) emit("}", 0) - emit("else", 0) + emit("else {", 0) emit("marshal_write_int(buf, off, 0);", 1) + emit("}", 0) else: emit("marshal_write_%s(buf, off, %s);" % (field.type, value), 0) From bcannon at users.sourceforge.net Mon Mar 21 00:41:02 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Mon Mar 21 00:41:06 2005 Subject: [Python-checkins] python/dist/src/Python Python-ast.c, 1.1.2.9, 1.1.2.10 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15588/Python Modified Files: Tag: ast-branch Python-ast.c Log Message: Fix Python/asdl_c.py so that generated files Include/Python-ast.h and Python/Python-ast.c do proper casting so that the files now compile. Also removed warning about ambiguous 'if' and 'else' blocks by putting in curly braces. Closes bug #1102710. Thanks logistix. Index: Python-ast.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/Attic/Python-ast.c,v retrieving revision 1.1.2.9 retrieving revision 1.1.2.10 diff -u -d -r1.1.2.9 -r1.1.2.10 --- Python-ast.c 16 Jan 2005 17:09:11 -0000 1.1.2.9 +++ Python-ast.c 20 Mar 2005 23:40:59 -0000 1.1.2.10 @@ -1,4 +1,4 @@ -/* File automatically generated by Parser/asdl_c.py */ +/* File automatically generated by ./Parser/asdl_c.py */ #include "Python.h" #include "Python-ast.h" @@ -324,8 +324,7 @@ } stmt_ty -TryExcept(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse, int - lineno) [...1040 lines suppressed...] + } marshal_write_int(buf, off, asdl_seq_LEN(o->defaults)); for (i = 0; i < asdl_seq_LEN(o->defaults); i++) { void *elt = asdl_seq_GET(o->defaults, i); - marshal_write_expr(buf, off, elt); + marshal_write_expr(buf, off, (expr_ty)elt); } return 1; } @@ -2226,8 +2241,9 @@ marshal_write_int(buf, off, 1); marshal_write_identifier(buf, off, o->asname); } - else + else { marshal_write_int(buf, off, 0); + } return 1; } From bcannon at users.sourceforge.net Mon Mar 21 00:41:02 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Mon Mar 21 00:41:07 2005 Subject: [Python-checkins] python/dist/src/Include Python-ast.h, 1.1.2.9, 1.1.2.10 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15588/Include Modified Files: Tag: ast-branch Python-ast.h Log Message: Fix Python/asdl_c.py so that generated files Include/Python-ast.h and Python/Python-ast.c do proper casting so that the files now compile. Also removed warning about ambiguous 'if' and 'else' blocks by putting in curly braces. Closes bug #1102710. Thanks logistix. Index: Python-ast.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/Attic/Python-ast.h,v retrieving revision 1.1.2.9 retrieving revision 1.1.2.10 diff -u -d -r1.1.2.9 -r1.1.2.10 --- Python-ast.h 16 Jan 2005 17:09:11 -0000 1.1.2.9 +++ Python-ast.h 20 Mar 2005 23:40:58 -0000 1.1.2.10 @@ -1,4 +1,4 @@ -/* File automatically generated by Parser/asdl_c.py */ +/* File automatically generated by ./Parser/asdl_c.py */ #include "asdl.h" @@ -15,14 +15,14 @@ typedef enum _boolop { And=1, Or=2 } boolop_ty; -typedef enum _operator { Add=1, Sub=2, Mult=3, Div=4, Mod=5, Pow=6, - LShift=7, RShift=8, BitOr=9, BitXor=10, BitAnd=11, - FloorDiv=12 } operator_ty; +typedef enum _operator { Add=1, Sub=2, Mult=3, Div=4, Mod=5, Pow=6, LShift=7, + RShift=8, BitOr=9, BitXor=10, BitAnd=11, FloorDiv=12 } + operator_ty; typedef enum _unaryop { Invert=1, Not=2, UAdd=3, USub=4 } unaryop_ty; -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 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 _comprehension *comprehension_ty; @@ -59,13 +59,12 @@ struct _stmt { enum { FunctionDef_kind=1, ClassDef_kind=2, Return_kind=3, - Yield_kind=4, Delete_kind=5, Assign_kind=6, - AugAssign_kind=7, Print_kind=8, For_kind=9, While_kind=10, - If_kind=11, Raise_kind=12, TryExcept_kind=13, - TryFinally_kind=14, Assert_kind=15, Import_kind=16, - ImportFrom_kind=17, Exec_kind=18, Global_kind=19, - Expr_kind=20, Pass_kind=21, Break_kind=22, Continue_kind=23 - } kind; + Yield_kind=4, Delete_kind=5, Assign_kind=6, AugAssign_kind=7, + Print_kind=8, For_kind=9, While_kind=10, If_kind=11, + Raise_kind=12, TryExcept_kind=13, TryFinally_kind=14, + Assert_kind=15, Import_kind=16, ImportFrom_kind=17, + Exec_kind=18, Global_kind=19, Expr_kind=20, Pass_kind=21, + Break_kind=22, Continue_kind=23 } kind; union { struct { identifier name; @@ -180,8 +179,8 @@ enum { BoolOp_kind=1, BinOp_kind=2, UnaryOp_kind=3, Lambda_kind=4, 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; + Str_kind=12, Attribute_kind=13, Subscript_kind=14, Name_kind=15, + List_kind=16, Tuple_kind=17 } kind; union { struct { boolop_ty op; @@ -276,8 +275,8 @@ }; struct _slice { - enum { Ellipsis_kind=1, Slice_kind=2, ExtSlice_kind=3, Index_kind=4 - } kind; + enum { Ellipsis_kind=1, Slice_kind=2, ExtSlice_kind=3, Index_kind=4 } + kind; union { struct { expr_ty lower; @@ -329,24 +328,23 @@ mod_ty Interactive(asdl_seq * body); mod_ty Expression(expr_ty body); mod_ty Suite(asdl_seq * body); -stmt_ty FunctionDef(identifier name, arguments_ty args, asdl_seq * body, - int lineno); +stmt_ty FunctionDef(identifier name, arguments_ty args, asdl_seq * body, int + lineno); stmt_ty ClassDef(identifier name, asdl_seq * bases, asdl_seq * body, int lineno); stmt_ty Return(expr_ty value, int lineno); stmt_ty Yield(expr_ty value, int lineno); stmt_ty Delete(asdl_seq * targets, int lineno); stmt_ty Assign(asdl_seq * targets, expr_ty value, int lineno); -stmt_ty AugAssign(expr_ty target, operator_ty op, expr_ty value, int - lineno); +stmt_ty AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno); stmt_ty Print(expr_ty dest, asdl_seq * values, bool nl, int lineno); -stmt_ty For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * - orelse, int lineno); +stmt_ty For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * orelse, + int lineno); stmt_ty While(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno); stmt_ty If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno); stmt_ty Raise(expr_ty type, expr_ty inst, expr_ty tback, int lineno); -stmt_ty TryExcept(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse, - int lineno); +stmt_ty TryExcept(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse, int + lineno); stmt_ty TryFinally(asdl_seq * body, asdl_seq * finalbody, int lineno); stmt_ty Assert(expr_ty test, expr_ty msg, int lineno); stmt_ty Import(asdl_seq * names, int lineno); @@ -379,11 +377,10 @@ slice_ty Slice(expr_ty lower, expr_ty upper, expr_ty step); slice_ty ExtSlice(asdl_seq * dims); slice_ty Index(expr_ty value); -comprehension_ty comprehension(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); +arguments_ty arguments(asdl_seq * args, identifier vararg, identifier kwarg, + asdl_seq * defaults); keyword_ty keyword(identifier arg, expr_ty value); alias_ty alias(identifier name, identifier asname); void free_mod(mod_ty); From bcannon at users.sourceforge.net Mon Mar 21 01:00:57 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Mon Mar 21 01:01:00 2005 Subject: [Python-checkins] python/dist/src/Python ast.c,1.1.2.55,1.1.2.56 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4474/Python Modified Files: Tag: ast-branch ast.c Log Message: Fix handling large octal numbers. Applies #1166879. Thanks Nick Coghlan. Index: ast.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/Attic/ast.c,v retrieving revision 1.1.2.55 retrieving revision 1.1.2.56 diff -u -d -r1.1.2.55 -r1.1.2.56 --- ast.c 16 Jan 2005 17:09:11 -0000 1.1.2.55 +++ ast.c 21 Mar 2005 00:00:54 -0000 1.1.2.56 @@ -2344,8 +2344,14 @@ #endif if (*end == 'l' || *end == 'L') return PyLong_FromString((char *)s, (char **)0, 0); - if (s[0] == '0') + if (s[0] == '0') { x = (long) PyOS_strtoul((char *)s, (char **)&end, 0); + if (x < 0 && errno == 0) { + return PyLong_FromString((char *)s, + (char **)0, + 0); + } + } else x = PyOS_strtol((char *)s, (char **)&end, 0); if (*end == '\0') { From fdrake at users.sourceforge.net Mon Mar 21 06:47:14 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Mon Mar 21 06:47:16 2005 Subject: [Python-checkins] python/dist/src/Doc/whatsnew whatsnew25.tex, 1.10, 1.11 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/whatsnew In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28465 Modified Files: whatsnew25.tex Log Message: fix environment broken in revision 1.6 Index: whatsnew25.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew25.tex,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- whatsnew25.tex 20 Mar 2005 22:19:46 -0000 1.10 +++ whatsnew25.tex 21 Mar 2005 05:47:11 -0000 1.11 @@ -182,6 +182,7 @@ a different directory as the extraction target, and to unpack only a subset of the archive's members. (Contributed by Lars Gust\"abel.) +\end{itemize} From fdrake at users.sourceforge.net Mon Mar 21 06:51:03 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Mon Mar 21 06:51:05 2005 Subject: [Python-checkins] python/dist/src/Doc/inst inst.tex,1.60,1.61 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/inst In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31021 Modified Files: inst.tex Log Message: fix obscure markup error, wrapping a long line Index: inst.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/inst/inst.tex,v retrieving revision 1.60 retrieving revision 1.61 diff -u -d -r1.60 -r1.61 --- inst.tex 13 Feb 2005 22:50:03 -0000 1.60 +++ inst.tex 21 Mar 2005 05:51:01 -0000 1.61 @@ -757,8 +757,8 @@ \label{config-filenames} The names and locations of the configuration files vary slightly across -platforms. On \UNIX and Mac OS X, the three configuration files (in the order they -are processed) are: +platforms. On \UNIX{} and Mac OS X, the three configuration files (in +the order they are processed) are: \begin{tableiii}{l|l|c}{textrm} {Type of file}{Location and filename}{Notes} \lineiii{system}{\filenq{\filevar{prefix}/lib/python\filevar{ver}/distutils/distutils.cfg}}{(1)} From fdrake at users.sourceforge.net Mon Mar 21 07:36:35 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Mon Mar 21 07:36:38 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils dist.py, 1.74, 1.75 versionpredicate.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25688 Modified Files: dist.py versionpredicate.py Log Message: - rename check_provision() to split_revision() - fix indentation to conform to the Python style guide - add more tests and documentation Index: dist.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/dist.py,v retrieving revision 1.74 retrieving revision 1.75 diff -u -d -r1.74 -r1.75 --- dist.py 20 Mar 2005 22:19:46 -0000 1.74 +++ dist.py 21 Mar 2005 06:36:32 -0000 1.75 @@ -1181,11 +1181,7 @@ value = [v.strip() for v in value] for v in value: import distutils.versionpredicate - ver = distutils.versionpredicate.check_provision(v) - if ver: - import distutils.version - sv = distutils.version.StrictVersion() - sv.parse(ver.strip()[1:-1]) + distutils.versionpredicate.split_provision(v) self.provides = value def get_obsoletes(self): Index: versionpredicate.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/versionpredicate.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- versionpredicate.py 20 Mar 2005 22:17:02 -0000 1.1 +++ versionpredicate.py 21 Mar 2005 06:36:32 -0000 1.2 @@ -1,9 +1,10 @@ """Module for parsing and testing package version predicate strings. """ import re -import version +import distutils.version import operator + re_validPackage = re.compile(r"(?i)^\s*([a-z_]\w*(?:\.[a-z_]\w*)*)(.*)") # (package) (rest) @@ -11,93 +12,153 @@ re_splitComparison = re.compile(r"^\s*(<=|>=|<|>|!=|==)\s*([^\s,]+)\s*$") # (comp) (version) + def splitUp(pred): - """Parse a single version comparison. - Return (comparison string, StrictVersion) - """ - res = re_splitComparison.match(pred) - if not res: - raise ValueError, "Bad package restriction syntax: " + pred - comp, verStr = res.groups() - return (comp, version.StrictVersion(verStr)) + """Parse a single version comparison. + + Return (comparison string, StrictVersion) + """ + res = re_splitComparison.match(pred) + if not res: + raise ValueError("bad package restriction syntax: %r" % pred) + comp, verStr = res.groups() + return (comp, distutils.version.StrictVersion(verStr)) compmap = {"<": operator.lt, "<=": operator.le, "==": operator.eq, ">": operator.gt, ">=": operator.ge, "!=": operator.ne} class VersionPredicate: - """Parse and test package version predicates. + """Parse and test package version predicates. - >>> v = VersionPredicate("pyepat.abc (>1.0, <3333.3a1, !=1555.1b3)") - >>> print v - pyepat.abc (> 1.0, < 3333.3a1, != 1555.1b3) - >>> v.satisfied_by("1.1") - True - >>> v.satisfied_by("1.4") - True - >>> v.satisfied_by("1.0") - False - >>> v.satisfied_by("4444.4") - False - >>> v.satisfied_by("1555.1b3") - False - >>> v = VersionPredicate("pat( == 0.1 ) ") - >>> v.satisfied_by("0.1") - True - >>> v.satisfied_by("0.2") - False - >>> v = VersionPredicate("p1.p2.p3.p4(>=1.0, <=1.3a1, !=1.2zb3)") - Traceback (most recent call last): - ... - ValueError: invalid version number '1.2zb3' + >>> v = VersionPredicate('pyepat.abc (>1.0, <3333.3a1, !=1555.1b3)') - """ + The `name` attribute provides the full dotted name that is given:: - def __init__(self, versionPredicateStr): - """Parse a version predicate string. - """ - # Fields: - # name: package name - # pred: list of (comparison string, StrictVersion) + >>> v.name + 'pyepat.abc' - versionPredicateStr = versionPredicateStr.strip() - if not versionPredicateStr: - raise ValueError, "Empty package restriction" - match = re_validPackage.match(versionPredicateStr) - if not match: - raise ValueError, "Bad package name in " + versionPredicateStr - self.name, paren = match.groups() - paren = paren.strip() - if paren: - match = re_paren.match(paren) - if not match: - raise ValueError, "Expected parenthesized list: " + paren - str = match.groups()[0] - self.pred = [splitUp(aPred) for aPred in str.split(",")] - if not self.pred: - raise ValueError("Empty Parenthesized list in %r" - % versionPredicateStr ) - else: - self.pred=[] + The str() of a `VersionPredicate` provides a normalized + human-readable version of the expression:: - def __str__(self): - if self.pred: - seq = [cond + " " + str(ver) for cond, ver in self.pred] - return self.name + " (" + ", ".join(seq) + ")" - else: - return self.name + >>> print v + pyepat.abc (> 1.0, < 3333.3a1, != 1555.1b3) - def satisfied_by(self, version): - """True if version is compatible with all the predicates in self. - The parameter version must be acceptable to the StrictVersion - constructor. It may be either a string or StrictVersion. - """ - for cond, ver in self.pred: - if not compmap[cond](version, ver): - return False - return True + The `satisfied_by()` method can be used to determine with a given + version number is included in the set described by the version + restrictions:: + >>> v.satisfied_by('1.1') + True + >>> v.satisfied_by('1.4') + True + >>> v.satisfied_by('1.0') + False + >>> v.satisfied_by('4444.4') + False + >>> v.satisfied_by('1555.1b3') + False -def check_provision(value): - m = re.match("[a-zA-Z_]\w*(\.[a-zA-Z_]\w*)*(\s*\([^)]+\))?$", value) + `VersionPredicate` is flexible in accepting extra whitespace:: + + >>> v = VersionPredicate(' pat( == 0.1 ) ') + >>> v.name + 'pat' + >>> v.satisfied_by('0.1') + True + >>> v.satisfied_by('0.2') + False + + If any version numbers passed in do not conform to the + restrictions of `StrictVersion`, a `ValueError` is raised:: + + >>> v = VersionPredicate('p1.p2.p3.p4(>=1.0, <=1.3a1, !=1.2zb3)') + Traceback (most recent call last): + ... + ValueError: invalid version number '1.2zb3' + + It the module or package name given does not conform to what's + allowed as a legal module or package name, `ValueError` is + raised:: + + >>> v = VersionPredicate('foo-bar') + Traceback (most recent call last): + ... + ValueError: expected parenthesized list: '-bar' + + >>> v = VersionPredicate('foo bar (12.21)') + Traceback (most recent call last): + ... + ValueError: expected parenthesized list: 'bar (12.21)' + + """ + + def __init__(self, versionPredicateStr): + """Parse a version predicate string. + """ + # Fields: + # name: package name + # pred: list of (comparison string, StrictVersion) + + versionPredicateStr = versionPredicateStr.strip() + if not versionPredicateStr: + raise ValueError("empty package restriction") + match = re_validPackage.match(versionPredicateStr) + if not match: + raise ValueError("bad package name in %r" % versionPredicateStr) + self.name, paren = match.groups() + paren = paren.strip() + if paren: + match = re_paren.match(paren) + if not match: + raise ValueError("expected parenthesized list: %r" % paren) + str = match.groups()[0] + self.pred = [splitUp(aPred) for aPred in str.split(",")] + if not self.pred: + raise ValueError("empty parenthesized list in %r" + % versionPredicateStr) + else: + self.pred=[] + + def __str__(self): + if self.pred: + seq = [cond + " " + str(ver) for cond, ver in self.pred] + return self.name + " (" + ", ".join(seq) + ")" + else: + return self.name + + def satisfied_by(self, version): + """True if version is compatible with all the predicates in self. + The parameter version must be acceptable to the StrictVersion + constructor. It may be either a string or StrictVersion. + """ + for cond, ver in self.pred: + if not compmap[cond](version, ver): + return False + return True + + +_provision_rx = None + +def split_provision(value): + """Return the name and optional version number of a provision. + + The version number, if given, will be returned as a `StrictVersion` + instance, otherwise it will be `None`. + + >>> split_provision('mypkg') + ('mypkg', None) + >>> split_provision(' mypkg( 1.2 ) ') + ('mypkg', StrictVersion ('1.2')) + """ + global _provision_rx + if _provision_rx is None: + _provision_rx = re.compile( + "([a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*)(?:\s*\(\s*([^)\s]+)\s*\))?$") + value = value.strip() + m = _provision_rx.match(value) if not m: raise ValueError("illegal provides specification: %r" % value) + ver = m.group(2) or None + if ver: + ver = distutils.version.StrictVersion(ver) + return m.group(1), ver From theller at python.net Mon Mar 21 16:08:57 2005 From: theller at python.net (Thomas Heller) Date: Mon Mar 21 16:09:07 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils/tests test_dist.py, 1.1, 1.2 In-Reply-To: (fdrake@users.sourceforge.net's message of "Sun, 20 Mar 2005 14:19:49 -0800") References: Message-ID: <8y4hniie.fsf@python.net> fdrake@users.sourceforge.net writes: > PEP 314 implementation (client side): I'm not sure where I should post this, but shouldn't there be a way to specify the encoding of the metadata? There are people (not me, fortunately), with umlauts in their names, for example. Thomas From jhylton at gmail.com Mon Mar 21 16:21:21 2005 From: jhylton at gmail.com (Jeremy Hylton) Date: Mon Mar 21 16:21:25 2005 Subject: [Python-Dev] Re: [Python-checkins] python/dist/src/Lib/distutils/tests test_dist.py, 1.1, 1.2 In-Reply-To: <8y4hniie.fsf@python.net> References: <8y4hniie.fsf@python.net> Message-ID: On Mon, 21 Mar 2005 16:08:57 +0100, Thomas Heller wrote: > fdrake@users.sourceforge.net writes: > > > PEP 314 implementation (client side): > > I'm not sure where I should post this, but shouldn't there be a way to > specify the encoding of the metadata? There are people (not me, > fortunately), with umlauts in their names, for example. UTF-8 as the default would accommodate most uses, but it does seem essential to have some way of specifying an encoding. Jeremy From bcannon at users.sourceforge.net Mon Mar 21 20:27:45 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Mon Mar 21 20:27:47 2005 Subject: [Python-checkins] python/dist/src/PCbuild pythoncore.vcproj, 1.26.2.1, 1.26.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29116/PCbuild Modified Files: Tag: ast-branch pythoncore.vcproj Log Message: Fix MSVC project files and removed a forward declaration of a static array to allow building on Windows. Closes patch #742621. Thanks logistix. Index: pythoncore.vcproj =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pythoncore.vcproj,v retrieving revision 1.26.2.1 retrieving revision 1.26.2.2 diff -u -d -r1.26.2.1 -r1.26.2.2 --- pythoncore.vcproj 7 Jan 2005 07:04:32 -0000 1.26.2.1 +++ pythoncore.vcproj 21 Mar 2005 19:27:39 -0000 1.26.2.2 @@ -3,6 +3,7 @@ ProjectType="Visual C++" Version="7.10" Name="pythoncore" + ProjectGUID="{7AFA1F0B-A8A1-455A-A832-BF263404BBEF}" SccProjectName="pythoncore" SccLocalPath=".."> @@ -478,6 +479,12 @@ + + + + @@ -802,34 +809,10 @@ + RelativePath="..\Objects\codeobject.c"> - - - - - - - - - + RelativePath="..\Modules\collectionsmodule.c"> @@ -1186,6 +1169,9 @@ + + @@ -1621,6 +1607,9 @@ + + @@ -2275,6 +2264,9 @@ + + @@ -2410,9 +2402,6 @@ - - @@ -2440,6 +2429,9 @@ + + @@ -2524,6 +2516,9 @@ RelativePath="..\Python\pystrtod.c"> + + @@ -3064,31 +3059,7 @@ - - - - - - - - - + RelativePath="..\Parser\tokenizer_pgen.c"> From bcannon at users.sourceforge.net Mon Mar 21 20:27:45 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Mon Mar 21 20:27:50 2005 Subject: [Python-checkins] python/dist/src/Python newcompile.c, 1.1.2.103, 1.1.2.104 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29116/Python Modified Files: Tag: ast-branch newcompile.c Log Message: Fix MSVC project files and removed a forward declaration of a static array to allow building on Windows. Closes patch #742621. Thanks logistix. Index: newcompile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/Attic/newcompile.c,v retrieving revision 1.1.2.103 retrieving revision 1.1.2.104 diff -u -d -r1.1.2.103 -r1.1.2.104 --- newcompile.c 19 Feb 2005 03:42:35 -0000 1.1.2.103 +++ newcompile.c 21 Mar 2005 19:27:42 -0000 1.1.2.104 @@ -190,7 +190,154 @@ static PyCodeObject *assemble(struct compiler *, int addNone); -static char *opnames[]; + +static char *opnames[] = { + "STOP_CODE", + "POP_TOP", + "ROT_TWO", + "ROT_THREE", + "DUP_TOP", + "ROT_FOUR", + "<6>", + "<7>", + "<8>", + "<9>", + "UNARY_POSITIVE", + "UNARY_NEGATIVE", + "UNARY_NOT", + "UNARY_CONVERT", + "<14>", + "UNARY_INVERT", + "<16>", + "<17>", + "<18>", + "BINARY_POWER", + "BINARY_MULTIPLY", + "BINARY_DIVIDE", + "BINARY_MODULO", + "BINARY_ADD", + "BINARY_SUBTRACT", + "BINARY_SUBSCR", + "BINARY_FLOOR_DIVIDE", + "BINARY_TRUE_DIVIDE", + "INPLACE_FLOOR_DIVIDE", + "INPLACE_TRUE_DIVIDE", + "SLICE+0", + "SLICE+1", + "SLICE+2", + "SLICE+3", + "<34>", + "<35>", + "<36>", + "<37>", + "<38>", + "<39>", + "STORE_SLICE+0", + "STORE_SLICE+1", + "STORE_SLICE+2", + "STORE_SLICE+3", + "<44>", + "<45>", + "<46>", + "<47>", + "<48>", + "<49>", + "DELETE_SLICE+0", + "DELETE_SLICE+1", + "DELETE_SLICE+2", + "DELETE_SLICE+3", + "<54>", + "INPLACE_ADD", + "INPLACE_SUBTRACT", + "INPLACE_MULTIPLY", + "INPLACE_DIVIDE", + "INPLACE_MODULO", + "STORE_SUBSCR", + "DELETE_SUBSCR", + "BINARY_LSHIFT", + "BINARY_RSHIFT", + "BINARY_AND", + "BINARY_XOR", + "BINARY_OR", + "INPLACE_POWER", + "GET_ITER", + "<69>", + "PRINT_EXPR", + "PRINT_ITEM", + "PRINT_NEWLINE", + "PRINT_ITEM_TO", + "PRINT_NEWLINE_TO", + "INPLACE_LSHIFT", + "INPLACE_RSHIFT", + "INPLACE_AND", + "INPLACE_XOR", + "INPLACE_OR", + "BREAK_LOOP", + "<81>", + "LOAD_LOCALS", + "RETURN_VALUE", + "IMPORT_STAR", + "EXEC_STMT", + "YIELD_VALUE", + "POP_BLOCK", + "END_FINALLY", + "BUILD_CLASS", + "STORE_NAME", + "DELETE_NAME", + "UNPACK_SEQUENCE", + "FOR_ITER", + "<94>", + "STORE_ATTR", + "DELETE_ATTR", + "STORE_GLOBAL", + "DELETE_GLOBAL", + "DUP_TOPX", + "LOAD_CONST", + "LOAD_NAME", + "BUILD_TUPLE", + "BUILD_LIST", + "BUILD_MAP", + "LOAD_ATTR", + "COMPARE_OP", + "IMPORT_NAME", + "IMPORT_FROM", + "<109>", + "JUMP_FORWARD", + "JUMP_IF_FALSE", + "JUMP_IF_TRUE", + "JUMP_ABSOLUTE", + "<114>", + "<115>", + "LOAD_GLOBAL", + "<117>", + "<118>", + "CONTINUE_LOOP", + "SETUP_LOOP", + "SETUP_EXCEPT", + "SETUP_FINALLY", + "<123>", + "LOAD_FAST", + "STORE_FAST", + "DELETE_FAST", + "<127>", + "<128>", + "<129>", + "RAISE_VARARGS", + "CALL_FUNCTION", + "MAKE_FUNCTION", + "BUILD_SLICE", + "MAKE_CLOSURE", + "LOAD_CLOSURE", + "LOAD_DEREF", + "STORE_DEREF", + "<138>", + "<139>", + "CALL_FUNCTION_VAR", + "CALL_FUNCTION_KW", + "CALL_FUNCTION_VAR_KW", + "EXTENDED_ARG", +}; + static PyObject *__doc__; PyObject * @@ -3310,149 +3457,4 @@ return co; } -static char *opnames[] = { - "STOP_CODE", - "POP_TOP", - "ROT_TWO", - "ROT_THREE", - "DUP_TOP", - "ROT_FOUR", - "<6>", - "<7>", - "<8>", - "<9>", - "UNARY_POSITIVE", - "UNARY_NEGATIVE", - "UNARY_NOT", - "UNARY_CONVERT", - "<14>", - "UNARY_INVERT", - "<16>", - "<17>", - "<18>", - "BINARY_POWER", - "BINARY_MULTIPLY", - "BINARY_DIVIDE", - "BINARY_MODULO", - "BINARY_ADD", - "BINARY_SUBTRACT", - "BINARY_SUBSCR", - "BINARY_FLOOR_DIVIDE", - "BINARY_TRUE_DIVIDE", - "INPLACE_FLOOR_DIVIDE", - "INPLACE_TRUE_DIVIDE", - "SLICE+0", - "SLICE+1", - "SLICE+2", - "SLICE+3", - "<34>", - "<35>", - "<36>", - "<37>", - "<38>", - "<39>", - "STORE_SLICE+0", - "STORE_SLICE+1", - "STORE_SLICE+2", - "STORE_SLICE+3", - "<44>", - "<45>", - "<46>", - "<47>", - "<48>", - "<49>", - "DELETE_SLICE+0", - "DELETE_SLICE+1", - "DELETE_SLICE+2", - "DELETE_SLICE+3", - "<54>", - "INPLACE_ADD", - "INPLACE_SUBTRACT", - "INPLACE_MULTIPLY", - "INPLACE_DIVIDE", - "INPLACE_MODULO", - "STORE_SUBSCR", - "DELETE_SUBSCR", - "BINARY_LSHIFT", - "BINARY_RSHIFT", - "BINARY_AND", - "BINARY_XOR", - "BINARY_OR", - "INPLACE_POWER", - "GET_ITER", - "<69>", - "PRINT_EXPR", - "PRINT_ITEM", - "PRINT_NEWLINE", - "PRINT_ITEM_TO", - "PRINT_NEWLINE_TO", - "INPLACE_LSHIFT", - "INPLACE_RSHIFT", - "INPLACE_AND", - "INPLACE_XOR", - "INPLACE_OR", - "BREAK_LOOP", - "<81>", - "LOAD_LOCALS", - "RETURN_VALUE", - "IMPORT_STAR", - "EXEC_STMT", - "YIELD_VALUE", - "POP_BLOCK", - "END_FINALLY", - "BUILD_CLASS", - "STORE_NAME", - "DELETE_NAME", - "UNPACK_SEQUENCE", - "FOR_ITER", - "<94>", - "STORE_ATTR", - "DELETE_ATTR", - "STORE_GLOBAL", - "DELETE_GLOBAL", - "DUP_TOPX", - "LOAD_CONST", - "LOAD_NAME", - "BUILD_TUPLE", - "BUILD_LIST", - "BUILD_MAP", - "LOAD_ATTR", - "COMPARE_OP", - "IMPORT_NAME", - "IMPORT_FROM", - "<109>", - "JUMP_FORWARD", - "JUMP_IF_FALSE", - "JUMP_IF_TRUE", - "JUMP_ABSOLUTE", - "<114>", - "<115>", - "LOAD_GLOBAL", - "<117>", - "<118>", - "CONTINUE_LOOP", - "SETUP_LOOP", - "SETUP_EXCEPT", - "SETUP_FINALLY", - "<123>", - "LOAD_FAST", - "STORE_FAST", - "DELETE_FAST", - "<127>", - "<128>", - "<129>", - "RAISE_VARARGS", - "CALL_FUNCTION", - "MAKE_FUNCTION", - "BUILD_SLICE", - "MAKE_CLOSURE", - "LOAD_CLOSURE", - "LOAD_DEREF", - "STORE_DEREF", - "<138>", - "<139>", - "CALL_FUNCTION_VAR", - "CALL_FUNCTION_KW", - "CALL_FUNCTION_VAR_KW", - "EXTENDED_ARG", -}; + From bcannon at users.sourceforge.net Mon Mar 21 20:28:12 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Mon Mar 21 20:28:15 2005 Subject: [Python-checkins] python/dist/src/PC config.c,1.34.2.2,1.34.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/PC In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29116/PC Modified Files: Tag: ast-branch config.c Log Message: Fix MSVC project files and removed a forward declaration of a static array to allow building on Windows. Closes patch #742621. Thanks logistix. Index: config.c =================================================================== RCS file: /cvsroot/python/python/dist/src/PC/config.c,v retrieving revision 1.34.2.2 retrieving revision 1.34.2.3 diff -u -d -r1.34.2.2 -r1.34.2.3 --- config.c 7 Jan 2005 07:04:11 -0000 1.34.2.2 +++ config.c 21 Mar 2005 19:27:37 -0000 1.34.2.3 @@ -121,7 +121,6 @@ {"mmap", initmmap}, {"_csv", init_csv}, {"_sre", init_sre}, - {"parser", initparser}, {"_winreg", init_winreg}, {"datetime", initdatetime}, From montanaro at users.sourceforge.net Mon Mar 21 20:39:33 2005 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Mon Mar 21 20:39:37 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libxmlrpclib.tex, 1.21, 1.22 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3594/dist/src/Doc/lib Modified Files: libxmlrpclib.tex Log Message: correct ontosys url - closes 1167329 Index: libxmlrpclib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libxmlrpclib.tex,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- libxmlrpclib.tex 19 Jan 2005 03:39:16 -0000 1.21 +++ libxmlrpclib.tex 21 Mar 2005 19:39:16 -0000 1.22 @@ -32,7 +32,7 @@ default behaviour is for \code{None} to raise a \exception{TypeError}. This is a commonly-used extension to the XML-RPC specification, but isn't supported by all clients and servers; see -\url{http://ontosys.com/xml-rpc/extensions.html} for a description. +\url{http://ontosys.com/xml-rpc/extensions.php} for a description. Both the HTTP and HTTPS transports support the URL syntax extension for HTTP Basic Authentication: \code{http://user:pass@host:port/path}. The From montanaro at users.sourceforge.net Mon Mar 21 20:40:15 2005 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Mon Mar 21 20:40:18 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libxmlrpclib.tex, 1.18.2.3, 1.18.2.4 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4090/dist/src/Doc/lib Modified Files: Tag: release24-maint libxmlrpclib.tex Log Message: correct ontosys url - closes 1167329 Index: libxmlrpclib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libxmlrpclib.tex,v retrieving revision 1.18.2.3 retrieving revision 1.18.2.4 diff -u -d -r1.18.2.3 -r1.18.2.4 --- libxmlrpclib.tex 19 Jan 2005 03:42:09 -0000 1.18.2.3 +++ libxmlrpclib.tex 21 Mar 2005 19:40:03 -0000 1.18.2.4 @@ -32,7 +32,7 @@ default behaviour is for \code{None} to raise a \exception{TypeError}. This is a commonly-used extension to the XML-RPC specification, but isn't supported by all clients and servers; see -\url{http://ontosys.com/xml-rpc/extensions.html} for a description. +\url{http://ontosys.com/xml-rpc/extensions.php} for a description. Both the HTTP and HTTPS transports support the URL syntax extension for HTTP Basic Authentication: \code{http://user:pass@host:port/path}. The From montanaro at users.sourceforge.net Mon Mar 21 20:43:01 2005 From: montanaro at users.sourceforge.net (montanaro@users.sourceforge.net) Date: Mon Mar 21 20:43:04 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libxmlrpclib.tex, 1.13.12.2, 1.13.12.3 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5487/dist/src/Doc/lib Modified Files: Tag: release23-maint libxmlrpclib.tex Log Message: correct ontosys url - closes 1167329 Index: libxmlrpclib.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libxmlrpclib.tex,v retrieving revision 1.13.12.2 retrieving revision 1.13.12.3 diff -u -d -r1.13.12.2 -r1.13.12.3 --- libxmlrpclib.tex 19 Jan 2005 03:45:38 -0000 1.13.12.2 +++ libxmlrpclib.tex 21 Mar 2005 19:42:52 -0000 1.13.12.3 @@ -32,7 +32,7 @@ default behaviour is for \code{None} to raise a \exception{TypeError}. This is a commonly-used extension to the XML-RPC specification, but isn't supported by all clients and servers; see -\url{http://ontosys.com/xml-rpc/extensions.html} for a description. +\url{http://ontosys.com/xml-rpc/extensions.php} for a description. Both the HTTP and HTTPS transports support the URL syntax extension for HTTP Basic Authentication: \code{http://user:pass@host:port/path}. The From pje at users.sourceforge.net Mon Mar 21 20:50:49 2005 From: pje at users.sourceforge.net (pje@users.sourceforge.net) Date: Mon Mar 21 20:50:52 2005 Subject: [Python-checkins] python/nondist/sandbox/setuptools/setuptools/command bdist_egg.py, NONE, 1.1 __init__.py, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8059/setuptools/command Modified Files: __init__.py Added Files: bdist_egg.py Log Message: Add 'bdist_egg' command/format to allow creating "Python Eggs" (see http://peak.telecommunity.com/DevCenter/PythonEggs for details). This version only supports pure libraries and does not support user-defined metadata. But it's sufficient to make .egg files that can be placed on PYTHONPATH and used. --- NEW FILE: bdist_egg.py --- """setuptools.command.bdist_egg Build .egg distributions""" # This module should be kept compatible with Python 2.1 import os from distutils.core import Command from distutils.util import get_platform from distutils.dir_util import create_tree, remove_tree, ensure_relative,mkpath from distutils.errors import * from distutils import log class bdist_egg(Command): description = "create an \"egg\" distribution" user_options = [('bdist-dir=', 'd', "temporary directory for creating the distribution"), ('plat-name=', 'p', "platform name to embed in generated filenames " "(default: %s)" % get_platform()), ('keep-temp', 'k', "keep the pseudo-installation tree around after " + "creating the distribution archive"), ('dist-dir=', 'd', "directory to put final built distributions in"), ('skip-build', None, "skip rebuilding everything (for testing/debugging)"), ('relative', None, "build the archive using relative paths" "(default: false)"), ] boolean_options = ['keep-temp', 'skip-build', 'relative'] def initialize_options (self): self.bdist_dir = None self.plat_name = None self.keep_temp = 0 self.dist_dir = None self.skip_build = 0 self.relative = 0 # initialize_options() def finalize_options (self): if self.bdist_dir is None: bdist_base = self.get_finalized_command('bdist').bdist_base self.bdist_dir = os.path.join(bdist_base, 'egg') self.set_undefined_options('bdist', ('dist_dir', 'dist_dir'), ('plat_name', 'plat_name')) # finalize_options() def run (self): if not self.skip_build: self.run_command('build') install = self.reinitialize_command('install_lib', reinit_subcommands=1) install.install_dir = self.bdist_dir install.skip_build = self.skip_build install.warn_dir = 0 log.info("installing to %s" % self.bdist_dir) self.run_command('install_lib') # And make an archive relative to the root of the # pseudo-installation tree. archive_basename = "%s-%s" % (self.distribution.get_fullname(), self.plat_name) # OS/2 objects to any ":" characters in a filename (such as when # a timestamp is used in a version) so change them to hyphens. if os.name == "os2": archive_basename = archive_basename.replace(":", "-") pseudoinstall_root = os.path.join(self.dist_dir, archive_basename) archive_root = self.bdist_dir # Make the EGG-INFO directory log.info("creating EGG-INFO files") egg_info = os.path.join(archive_root,'EGG-INFO') self.mkpath(egg_info) if not self.dry_run: self.distribution.metadata.write_pkg_info(egg_info) # Make the archive make_zipfile(pseudoinstall_root+'.egg', archive_root, verbose=self.verbose, dry_run=self.dry_run) if not self.keep_temp: remove_tree(self.bdist_dir, dry_run=self.dry_run) # run() # class bdist_egg def make_zipfile (zip_filename, base_dir, verbose=0, dry_run=0): """Create a zip file from all the files under 'base_dir'. The output zip file will be named 'base_dir' + ".zip". Uses either the "zipfile" Python module (if available) or the InfoZIP "zip" utility (if installed and found on the default search path). If neither tool is available, raises DistutilsExecError. Returns the name of the output zip file. """ import zipfile mkpath(os.path.dirname(zip_filename), dry_run=dry_run) # If zipfile module is not available, try spawning an external # 'zip' command. log.info("creating '%s' and adding '%s' to it", zip_filename, base_dir) def visit (z, dirname, names): for name in names: path = os.path.normpath(os.path.join(dirname, name)) if os.path.isfile(path): p = path[len(base_dir)+1:] z.write(path, p) log.info("adding '%s'" % p) if not dry_run: z = zipfile.ZipFile(zip_filename, "w", compression=zipfile.ZIP_DEFLATED) os.path.walk(base_dir, visit, z) z.close() return zip_filename # make_zipfile () Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command/__init__.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- __init__.py 5 Apr 2004 20:21:53 -0000 1.2 +++ __init__.py 21 Mar 2005 19:50:46 -0000 1.3 @@ -1,6 +1,6 @@ import distutils.command -__all__ = ['test', 'depends'] +__all__ = ['test', 'depends', 'bdist_egg'] # Make our commands available as though they were part of the distutils @@ -9,3 +9,11 @@ distutils.command.__all__.extend( [cmd for cmd in __all__ if cmd not in distutils.command.__all__] ) + +from distutils.command.bdist import bdist + +if 'egg' not in bdist.format_commands: + bdist.format_command['egg'] = ('bdist_egg', "Python .egg file") + bdist.format_commands.append('egg') + +del bdist From pje at users.sourceforge.net Mon Mar 21 21:12:36 2005 From: pje at users.sourceforge.net (pje@users.sourceforge.net) Date: Mon Mar 21 21:12:39 2005 Subject: [Python-checkins] python/nondist/sandbox/setuptools/setuptools/command bdist_egg.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18583/setuptools/command Modified Files: bdist_egg.py Log Message: Add python version to egg filename. Index: bdist_egg.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command/bdist_egg.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- bdist_egg.py 21 Mar 2005 19:50:46 -0000 1.1 +++ bdist_egg.py 21 Mar 2005 20:12:33 -0000 1.2 @@ -8,6 +8,7 @@ from distutils.core import Command from distutils.util import get_platform from distutils.dir_util import create_tree, remove_tree, ensure_relative,mkpath +from distutils.sysconfig import get_python_version from distutils.errors import * from distutils import log @@ -74,8 +75,8 @@ # And make an archive relative to the root of the # pseudo-installation tree. - archive_basename = "%s-%s" % (self.distribution.get_fullname(), - self.plat_name) + archive_basename = "%s-py%s-%s" % (self.distribution.get_fullname(), + get_python_version(),self.plat_name) # OS/2 objects to any ":" characters in a filename (such as when # a timestamp is used in a version) so change them to hyphens. From bcannon at users.sourceforge.net Mon Mar 21 21:41:55 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Mon Mar 21 21:41:58 2005 Subject: [Python-checkins] python/dist/src/Misc vimrc,1.5,1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31961/Misc Modified Files: vimrc Log Message: Add comment about optional option for keeping indentation level from previous line. Index: vimrc =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/vimrc,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- vimrc 5 Mar 2005 05:52:21 -0000 1.5 +++ vimrc 21 Mar 2005 20:41:51 -0000 1.6 @@ -80,7 +80,8 @@ "``let python_highlight_all=1`` "``syntax on`` -" Automatically indent: ``filetype indent on`` +" Automatically indent based on file type: ``filetype indent on`` +" Keep indentation level from previous line: ``set autoindent`` " Folding based on indentation: ``set foldmethod=indent`` From pje at users.sourceforge.net Mon Mar 21 21:42:14 2005 From: pje at users.sourceforge.net (pje@users.sourceforge.net) Date: Mon Mar 21 21:42:18 2005 Subject: [Python-checkins] python/nondist/sandbox/setuptools/setuptools/command bdist_egg.py, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31636/setuptools/command Modified Files: bdist_egg.py Log Message: Allow user-supplied metadata from EGG-INFO.in directory (directory name can be overridden with a command-line option). Index: bdist_egg.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command/bdist_egg.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- bdist_egg.py 21 Mar 2005 20:12:33 -0000 1.2 +++ bdist_egg.py 21 Mar 2005 20:41:57 -0000 1.3 @@ -16,7 +16,10 @@ description = "create an \"egg\" distribution" - user_options = [('bdist-dir=', 'd', + user_options = [('egg-info=', 'e', + "directory containing EGG-INFO for the distribution " + "(default: EGG-INFO.in)"), + ('bdist-dir=', 'd', "temporary directory for creating the distribution"), ('plat-name=', 'p', "platform name to embed in generated filenames " @@ -37,6 +40,7 @@ def initialize_options (self): + self.egg_info = None self.bdist_dir = None self.plat_name = None self.keep_temp = 0 @@ -49,6 +53,12 @@ def finalize_options (self): + if self.egg_info is None and os.path.isdir('EGG-INFO.in'): + self.egg_info = 'EGG-INFO.in' + + elif self.egg_info: + self.ensure_dirname('egg_info') + if self.bdist_dir is None: bdist_base = self.get_finalized_command('bdist').bdist_base self.bdist_dir = os.path.join(bdist_base, 'egg') @@ -91,6 +101,12 @@ egg_info = os.path.join(archive_root,'EGG-INFO') self.mkpath(egg_info) + if self.egg_info: + for filename in os.listdir(self.egg_info): + path = os.path.join(self.egg_info,filename) + if os.path.isfile(path): + self.copy_file(path,os.path.join(egg_info,filename)) + if not self.dry_run: self.distribution.metadata.write_pkg_info(egg_info) From loewis at users.sourceforge.net Mon Mar 21 21:56:44 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Mar 21 21:56:47 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1275,1.1276 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6855/Misc Modified Files: NEWS Log Message: Add the upload command. Make all dist commands register their outputs with the distribution object. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1275 retrieving revision 1.1276 diff -u -d -r1.1275 -r1.1276 --- NEWS 18 Mar 2005 21:20:19 -0000 1.1275 +++ NEWS 21 Mar 2005 20:56:35 -0000 1.1276 @@ -88,6 +88,9 @@ Library ------- +- distutils.commands.upload was added to support uploading distribution + files to PyPI. + - Bug #1163325: Decimal infinities failed to hash. Attempting to hash a NaN raised an InvalidOperation instead of a TypeError. From loewis at users.sourceforge.net Mon Mar 21 21:57:02 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Mar 21 21:57:04 2005 Subject: [Python-checkins] python/dist/src/Doc/dist dist.tex,1.90,1.91 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/dist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6855/Doc/dist Modified Files: dist.tex Log Message: Add the upload command. Make all dist commands register their outputs with the distribution object. Index: dist.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/dist/dist.tex,v retrieving revision 1.90 retrieving revision 1.91 diff -u -d -r1.90 -r1.91 --- dist.tex 20 Mar 2005 22:19:46 -0000 1.90 +++ dist.tex 21 Mar 2005 20:56:27 -0000 1.91 @@ -1715,7 +1715,37 @@ versions, the Hidden property should be set to yes. This must be edited through the web interface. +\section{The .pypirc file} +\label{pypirc} + +The format of the \file{.pypirc} file is formated as follows: + +\begin{verbatim} +[server-login] +repository: +username: +password: +\end{verbatim} +\var{repository} can be ommitted and defaults to +\code{http://www.python.org/pypi}. + +\chapter{Uploading Packages to the Package Index} +\label{package-upload} + +The Python Package Index (PyPI) not only stores the package info, but also +the package data if the author of the package wishes to. The distutils +command \command{upload} pushes the distribution files to PyPI. + +The command is invokes immediately after building one or more distribution +files, e.g. as + +\begin{verbatim} +python setup.py sdist bdist_wininst upload +\end{verbatim} + +The \command{upload} command uses the username and password stored in +in the file \file{$HOME/.pypirc}, see \ref{pypirc}. \chapter{Examples} \label{examples} @@ -2055,6 +2085,11 @@ implemented by the class \class{distcmds.bdist_openpkg.bdist_openpkg} or \class{buildcmds.bdist_openpkg.bdist_openpkg}. +\section{Adding new distribution types} + +Commands that create distributions (i.e. files in the dist directory) +need to add (command, filename) pairs to \var{self.distribution.dist_files} +so that \command{upload} can upload it to PyPI. \chapter{Command Reference} \label{reference} From loewis at users.sourceforge.net Mon Mar 21 21:57:03 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Mar 21 21:57:06 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils dist.py,1.75,1.76 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6855/Lib/distutils Modified Files: dist.py Log Message: Add the upload command. Make all dist commands register their outputs with the distribution object. Index: dist.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/dist.py,v retrieving revision 1.75 retrieving revision 1.76 diff -u -d -r1.75 -r1.76 --- dist.py 21 Mar 2005 06:36:32 -0000 1.75 +++ dist.py 21 Mar 2005 20:56:30 -0000 1.76 @@ -177,6 +177,11 @@ # command_options = { command_name : { option : (source, value) } } self.command_options = {} + # 'dist_files' is the list of (command, file) that have been created + # by any dist commands run so far. This is filled regardless + # of whether the run is dry or not. + self.dist_files = [] + # These options are really the business of various commands, rather # than of the Distribution itself. We provide aliases for them in # Distribution as a convenience to the developer. From loewis at users.sourceforge.net Mon Mar 21 21:57:08 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Mar 21 21:57:10 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils/command upload.py, NONE, 1.1 bdist_dumb.py, 1.25, 1.26 bdist_rpm.py, 1.46, 1.47 bdist_wininst.py, 1.56, 1.57 sdist.py, 1.59, 1.60 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6855/Lib/distutils/command Modified Files: bdist_dumb.py bdist_rpm.py bdist_wininst.py sdist.py Added Files: upload.py Log Message: Add the upload command. Make all dist commands register their outputs with the distribution object. --- NEW FILE: upload.py --- """distutils.command.upload Implements the Distutils 'upload' subcommand (upload package to PyPI).""" Index: bdist_dumb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_dumb.py,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- bdist_dumb.py 10 Nov 2004 22:23:14 -0000 1.25 +++ bdist_dumb.py 21 Mar 2005 20:56:30 -0000 1.26 @@ -117,8 +117,9 @@ ensure_relative(install.install_base)) # Make the archive - self.make_archive(pseudoinstall_root, - self.format, root_dir=archive_root) + filename = self.make_archive(pseudoinstall_root, + self.format, root_dir=archive_root) + self.distribution.dist_files.append(('bdist_dumb', filename)) if not self.keep_temp: remove_tree(self.bdist_dir, dry_run=self.dry_run) Index: bdist_rpm.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_rpm.py,v retrieving revision 1.46 retrieving revision 1.47 diff -u -d -r1.46 -r1.47 --- bdist_rpm.py 10 Nov 2004 22:23:14 -0000 1.46 +++ bdist_rpm.py 21 Mar 2005 20:56:31 -0000 1.47 @@ -297,12 +297,14 @@ # Make a source distribution and copy to SOURCES directory with # optional icon. + saved_dist_files = self.distributuion.dist_files[:] sdist = self.reinitialize_command('sdist') if self.use_bzip2: sdist.formats = ['bztar'] else: sdist.formats = ['gztar'] self.run_command('sdist') + self.distribution.dist_files = saved_dist_files source = sdist.get_archive_files()[0] source_dir = rpm_dir['SOURCES'] @@ -355,6 +357,7 @@ assert len(rpms) == 1, \ "unexpected number of RPM files found: %s" % rpms self.move_file(rpms[0], self.dist_dir) + self.distribution.dist_files.append(('bdist_rpm', rpms[0])) if debuginfo: self.move_file(debuginfo[0], self.dist_dir) # run() Index: bdist_wininst.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_wininst.py,v retrieving revision 1.56 retrieving revision 1.57 diff -u -d -r1.56 -r1.57 --- bdist_wininst.py 10 Nov 2004 22:23:14 -0000 1.56 +++ bdist_wininst.py 21 Mar 2005 20:56:31 -0000 1.57 @@ -162,6 +162,8 @@ root_dir=self.bdist_dir) # create an exe containing the zip-file self.create_exe(arcname, fullname, self.bitmap) + self.distribution.dist_files.append(('bdist_wininst', + self.get_installer_filename())) # remove the zip-file again log.debug("removing temporary file '%s'", arcname) os.remove(arcname) Index: sdist.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/sdist.py,v retrieving revision 1.59 retrieving revision 1.60 diff -u -d -r1.59 -r1.60 --- sdist.py 10 Nov 2004 22:23:15 -0000 1.59 +++ sdist.py 21 Mar 2005 20:56:34 -0000 1.60 @@ -449,6 +449,7 @@ for fmt in self.formats: file = self.make_archive(base_name, fmt, base_dir=base_dir) archive_files.append(file) + self.distribution.dist_files.append(('sdist',file)) self.archive_files = archive_files From loewis at users.sourceforge.net Mon Mar 21 22:01:15 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Mar 21 22:01:17 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils/command upload.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9500 Modified Files: upload.py Log Message: Actually add the implementation of the command. Index: upload.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/upload.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- upload.py 21 Mar 2005 20:56:35 -0000 1.1 +++ upload.py 21 Mar 2005 21:00:59 -0000 1.2 @@ -2,3 +2,153 @@ Implements the Distutils 'upload' subcommand (upload package to PyPI).""" +from distutils.errors import * +from distutils.core import Command +from md5 import md5 +from distutils.sysconfig import get_python_version +from distutils import log +import os +import platform +import ConfigParser +import httplib +import base64 +import urlparse +import cStringIO as StringIO + +class upload(Command): + + description = "upload binary package to PyPI" + + DEFAULT_REPOSITORY = 'http://www.python.org/pypi' + + user_options = [ + ('repository=', 'r', + "url of repository [default: %s]" % DEFAULT_REPOSITORY), + ('show-response', None, + 'display full response text from server'), + ] + boolean_options = ['show-response'] + + def initialize_options(self): + self.username = '' + self.password = '' + self.repository = '' + self.show_response = 0 + + def finalize_options(self): + if os.environ.has_key('HOME'): + rc = os.path.join(os.environ['HOME'], '.pypirc') + if os.path.exists(rc): + self.announce('Using PyPI login from %s' % rc) + config = ConfigParser.ConfigParser({ + 'username':'', + 'password':'', + 'repository':''}) + config.read(rc) + if not self.repository: + self.repository = config.get('server-login', 'repository') + if not self.username: + self.username = config.get('server-login', 'username') + if not self.password: + self.password = config.get('server-login', 'password') + if not self.repository: + self.repository = self.DEFAULT_REPOSITORY + + def run(self): + if not self.distribution.dist_files: + raise DistutilsOptionError("No dist file created in earlier command") + for command, filename in self.distribution.dist_files: + self.upload_file(command, filename) + + def upload_file(self, command, filename): + + # Fill in the data + content = open(filename).read() + data = { + ':action':'file_upload', + 'name':self.distribution.get_name(), + 'version':self.distribution.get_version(), + 'content':(os.path.basename(filename),content), + 'filetype':command, + 'pyversion':get_python_version(), + 'md5_digest':md5(content).hexdigest(), + } + comment = '' + if command == 'bdist_rpm': + dist, version, id = platform.dist() + if dist: + comment = 'built for %s %s' % (dist, version) + elif command == 'bdist_dumb': + comment = 'built for %s' % platform.platform(terse=1) + data['comment'] = comment + + # set up the authentication + auth = "Basic " + base64.encodestring(self.username + ":" + self.password).strip() + + # Build up the MIME payload for the POST data + boundary = '--------------GHSKFJDLGDS7543FJKLFHRE75642756743254' + sep_boundary = '\n--' + boundary + end_boundary = sep_boundary + '--' + body = StringIO.StringIO() + for key, value in data.items(): + # handle multiple entries for the same name + if type(value) != type([]): + value = [value] + for value in value: + if type(value) is tuple: + fn = ';filename="%s"' % value[0] + value = value[1] + else: + fn = "" + value = str(value) + body.write(sep_boundary) + body.write('\nContent-Disposition: form-data; name="%s"'%key) + body.write(fn) + body.write("\n\n") + body.write(value) + if value and value[-1] == '\r': + body.write('\n') # write an extra newline (lurve Macs) + body.write(end_boundary) + body.write("\n") + body = body.getvalue() + + self.announce("Submitting %s to %s" % (filename, self.repository), log.INFO) + + # build the Request + # We can't use urllib2 since we need to send the Basic + # auth right with the first request + schema, netloc, url, params, query, fragments = \ + urlparse.urlparse(self.repository) + assert not params and not query and not fragments + if schema == 'http': + http = httplib.HTTPConnection(netloc) + elif schema == 'https': + http = httplib.HTTPSConnection(netloc) + else: + raise AssertionError, "unsupported schema "+schema + + data = '' + loglevel = log.INFO + try: + http.connect() + http.putrequest("POST", url) + http.putheader('Content-type', + 'multipart/form-data; boundary=%s'%boundary) + http.putheader('Content-length', str(len(body))) + http.putheader('Authorization', auth) + http.endheaders() + http.send(body) + except socket.error, e: + self.announce(e.msg, log.ERROR) + return + + r = http.getresponse() + if r.status == 200: + self.announce('Server response (%s): %s' % (r.status, r.reason), + log.INFO) + else: + self.announce('Upload failed (%s): %s' % (r.status, r.reason), + log.INFO) + if self.show_response: + print '-'*75, r.read(), '-'*75 + From doerwalter at users.sourceforge.net Mon Mar 21 22:31:49 2005 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Mon Mar 21 22:31:52 2005 Subject: [Python-checkins] python/dist/src/Lib/test list_tests.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-serv23804/Lib/test Modified Files: list_tests.py Log Message: Add list tests that ensure that remove() removes the first occurrence. (Copied from test_deque.py as suggested by Jim Jewett in SF bug #1166274) Index: list_tests.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/list_tests.py,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- list_tests.py 30 Sep 2004 07:47:20 -0000 1.5 +++ list_tests.py 21 Mar 2005 21:31:47 -0000 1.6 @@ -309,6 +309,26 @@ a = self.type2test([0, 1, 2, 3]) self.assertRaises(BadExc, a.remove, BadCmp()) + class BadCmp2: + def __eq__(self, other): + raise BadExc() + + d = self.type2test('abcdefghcij') + d.remove('c') + self.assertEqual(d, self.type2test('abdefghcij')) + d.remove('c') + self.assertEqual(d, self.type2test('abdefghij')) + self.assertRaises(ValueError, d.remove, 'c') + self.assertEqual(d, self.type2test('abdefghij')) + + # Handle comparison errors + d = self.type2test(['a', 'b', BadCmp2(), 'c']) + e = self.type2test(d) + self.assertRaises(BadExc, d.remove, 'c') + for x, y in zip(d, e): + # verify that original order and values are retained. + self.assert_(x is y) + def test_count(self): a = self.type2test([0, 1, 2])*3 self.assertEqual(a.count(0), 3) From pje at users.sourceforge.net Tue Mar 22 01:15:06 2005 From: pje at users.sourceforge.net (pje@users.sourceforge.net) Date: Tue Mar 22 01:15:26 2005 Subject: [Python-checkins] python/nondist/sandbox/setuptools/setuptools/command bdist_egg.py, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9953/setuptools/command Modified Files: bdist_egg.py Log Message: Create stub loaders for C extensions, so that the actual dynamic library can be extracted from the egg. Index: bdist_egg.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command/bdist_egg.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- bdist_egg.py 21 Mar 2005 20:41:57 -0000 1.3 +++ bdist_egg.py 22 Mar 2005 00:15:03 -0000 1.4 @@ -2,7 +2,7 @@ Build .egg distributions""" -# This module should be kept compatible with Python 2.1 +# This module should be kept compatible with Python 2.3 import os from distutils.core import Command @@ -69,7 +69,22 @@ # finalize_options() + def write_stub(self, resource, pyfile): + f = open(pyfile,'w') + f.write('\n'.join([ + "def __bootstrap__():", + " global __bootstrap__, __loader__, __file__", + " import sys, pkg_resources", + " __file__ = pkg_resources.resource_filename(__name__,%r)" + % resource, + " del __bootstrap__, __loader__", + " reload(sys.modules[__name__])", + "__bootstrap__()", + "" # terminal \n + ])) + f.close() + def run (self): if not self.skip_build: @@ -80,13 +95,32 @@ install.skip_build = self.skip_build install.warn_dir = 0 + ext_outputs = \ + install._mutate_outputs(self.distribution.has_ext_modules(), + 'build_ext', 'build_lib', + '') log.info("installing to %s" % self.bdist_dir) self.run_command('install_lib') + to_compile = [] + for ext_name in ext_outputs: + filename,ext = os.path.splitext(ext_name) + pyfile = os.path.join(self.bdist_dir, filename + '.py') + log.info("creating stub loader for %s" % ext_name) + if not self.dry_run: + self.write_stub(os.path.basename(ext_name), pyfile) + to_compile.append(pyfile) + + if to_compile: + install.byte_compile(to_compile) + # And make an archive relative to the root of the # pseudo-installation tree. - archive_basename = "%s-py%s-%s" % (self.distribution.get_fullname(), - get_python_version(),self.plat_name) + archive_basename = "%s-py%s" % (self.distribution.get_fullname(), + get_python_version()) + + if ext_outputs: + archive_basename += "-" + self.plat_name # OS/2 objects to any ":" characters in a filename (such as when # a timestamp is used in a version) so change them to hyphens. @@ -97,7 +131,7 @@ archive_root = self.bdist_dir # Make the EGG-INFO directory - log.info("creating EGG-INFO files") + log.info("creating EGG-INFO directory") egg_info = os.path.join(archive_root,'EGG-INFO') self.mkpath(egg_info) @@ -106,10 +140,20 @@ path = os.path.join(self.egg_info,filename) if os.path.isfile(path): self.copy_file(path,os.path.join(egg_info,filename)) - + + log.info("writing EGG-INFO/PKG-INFO") if not self.dry_run: self.distribution.metadata.write_pkg_info(egg_info) + if ext_outputs: + log.info("writing EGG-INFO/native_libs.txt") + if not self.dry_run: + libs_file = open( + os.path.join(egg_info,"native_libs.txt"),'wt') + libs_file.write('\n'.join(ext_outputs)) + libs_file.write('\n') + libs_file.close() + # Make the archive make_zipfile(pseudoinstall_root+'.egg', archive_root, verbose=self.verbose, From fdrake at users.sourceforge.net Tue Mar 22 05:09:40 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Mar 22 05:09:43 2005 Subject: [Python-checkins] python/dist/src/Doc/dist dist.tex,1.91,1.92 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/dist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17007 Modified Files: dist.tex Log Message: - fix markup bugs - more consistent markup - elaborate a couple of points Index: dist.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/dist/dist.tex,v retrieving revision 1.91 retrieving revision 1.92 diff -u -d -r1.91 -r1.92 --- dist.tex 21 Mar 2005 20:56:27 -0000 1.91 +++ dist.tex 22 Mar 2005 04:09:37 -0000 1.92 @@ -1738,14 +1738,20 @@ command \command{upload} pushes the distribution files to PyPI. The command is invokes immediately after building one or more distribution -files, e.g. as +files. For example, the command \begin{verbatim} python setup.py sdist bdist_wininst upload \end{verbatim} +will cause the source distribution and the Windows installer to be +uploaded to PyPI. Note that these will be uploaded even if they are +built using an earlier invocation of \file{setup.py}, but that only +distributions named on the command line for the invocation including +the \command{upload} command are uploaded. + The \command{upload} command uses the username and password stored in -in the file \file{$HOME/.pypirc}, see \ref{pypirc}. +in the file \file{\$HOME/.pypirc}, see section~\ref{pypirc}. \chapter{Examples} \label{examples} @@ -2087,9 +2093,12 @@ \section{Adding new distribution types} -Commands that create distributions (i.e. files in the dist directory) -need to add (command, filename) pairs to \var{self.distribution.dist_files} -so that \command{upload} can upload it to PyPI. +Commands that create distributions (files in the \file{dist/} +directory) need to add \code{(\var{command}, \var{filename})} pairs to +\code{self.distribution.dist_files} so that \command{upload} can +upload it to PyPI. The \var{filename} in the pair contains no path +information, only the name of the file itself. In dry-run mode, pairs +should still be added to represent what would have been created. \chapter{Command Reference} \label{reference} From fdrake at users.sourceforge.net Tue Mar 22 06:43:22 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Mar 22 06:43:26 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils versionpredicate.py, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3152/Lib/distutils Modified Files: versionpredicate.py Log Message: fix Python style guide conformance Index: versionpredicate.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/versionpredicate.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- versionpredicate.py 21 Mar 2005 06:36:32 -0000 1.2 +++ versionpredicate.py 22 Mar 2005 05:43:18 -0000 1.3 @@ -117,7 +117,7 @@ raise ValueError("empty parenthesized list in %r" % versionPredicateStr) else: - self.pred=[] + self.pred = [] def __str__(self): if self.pred: From doerwalter at users.sourceforge.net Tue Mar 22 12:22:41 2005 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Tue Mar 22 12:22:44 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_deque.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-serv15848/Lib/test Modified Files: test_deque.py Log Message: Fix typo. Index: test_deque.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_deque.py,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- test_deque.py 19 Mar 2005 00:00:51 -0000 1.20 +++ test_deque.py 22 Mar 2005 11:22:38 -0000 1.21 @@ -218,7 +218,7 @@ self.assertRaises(ValueError, d.remove, 'c') self.assertEqual(d, deque('abdefghij')) - # Handle comparision errors + # Handle comparison errors d = deque(['a', 'b', BadCmp(), 'c']) e = deque(d) self.assertRaises(RuntimeError, d.remove, 'c') From loewis at users.sourceforge.net Tue Mar 22 16:51:17 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Mar 22 16:51:21 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils/command upload.py, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28622 Modified Files: upload.py Log Message: Upload GPG signature. Index: upload.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/upload.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- upload.py 21 Mar 2005 21:00:59 -0000 1.2 +++ upload.py 22 Mar 2005 15:51:14 -0000 1.3 @@ -4,9 +4,10 @@ from distutils.errors import * from distutils.core import Command -from md5 import md5 from distutils.sysconfig import get_python_version +from distutils.spawn import spawn from distutils import log +from md5 import md5 import os import platform import ConfigParser @@ -26,14 +27,17 @@ "url of repository [default: %s]" % DEFAULT_REPOSITORY), ('show-response', None, 'display full response text from server'), + ('sign', 's', + 'sign files to upload using gpg'), ] - boolean_options = ['show-response'] + boolean_options = ['show-response', 'sign'] def initialize_options(self): self.username = '' self.password = '' self.repository = '' self.show_response = 0 + self.sign = False def finalize_options(self): if os.environ.has_key('HOME'): @@ -61,11 +65,16 @@ self.upload_file(command, filename) def upload_file(self, command, filename): + # Sign if requested + if self.sign: + spawn(("gpg", "--sign", "-a", filename), + dry_run=self.dry_run) # Fill in the data content = open(filename).read() data = { ':action':'file_upload', + 'protcol_version':'1', 'name':self.distribution.get_name(), 'version':self.distribution.get_version(), 'content':(os.path.basename(filename),content), @@ -82,6 +91,10 @@ comment = 'built for %s' % platform.platform(terse=1) data['comment'] = comment + if self.sign: + data['gpg_signature'] = (os.path.basename(filename) + ".asc", + open(filename+".asc").read()) + # set up the authentication auth = "Basic " + base64.encodestring(self.username + ":" + self.password).strip() @@ -148,7 +161,7 @@ log.INFO) else: self.announce('Upload failed (%s): %s' % (r.status, r.reason), - log.INFO) + log.ERROR) if self.show_response: print '-'*75, r.read(), '-'*75 From pje at users.sourceforge.net Tue Mar 22 19:56:03 2005 From: pje at users.sourceforge.net (pje@users.sourceforge.net) Date: Tue Mar 22 19:56:06 2005 Subject: [Python-checkins] python/nondist/sandbox/setuptools/setuptools/command bdist_egg.py, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19371/setuptools/command Modified Files: bdist_egg.py Log Message: Fix bootstrap loader so extracted files don't have to be on sys.path. Index: bdist_egg.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command/bdist_egg.py,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- bdist_egg.py 22 Mar 2005 00:15:03 -0000 1.4 +++ bdist_egg.py 22 Mar 2005 18:55:59 -0000 1.5 @@ -74,11 +74,11 @@ f.write('\n'.join([ "def __bootstrap__():", " global __bootstrap__, __loader__, __file__", - " import sys, pkg_resources", + " import sys, pkg_resources, imp", " __file__ = pkg_resources.resource_filename(__name__,%r)" % resource, " del __bootstrap__, __loader__", - " reload(sys.modules[__name__])", + " imp.load_dynamic(__name__,__file__)", "__bootstrap__()", "" # terminal \n ])) From loewis at users.sourceforge.net Tue Mar 22 21:32:46 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Mar 22 21:32:49 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils/command upload.py, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32654 Modified Files: upload.py Log Message: Don't set the Python version for sdist uploads. Index: upload.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/upload.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- upload.py 22 Mar 2005 15:51:14 -0000 1.3 +++ upload.py 22 Mar 2005 20:32:41 -0000 1.4 @@ -89,6 +89,8 @@ comment = 'built for %s %s' % (dist, version) elif command == 'bdist_dumb': comment = 'built for %s' % platform.platform(terse=1) + elif command == 'sdist': + data['pyversion'] = '' data['comment'] = comment if self.sign: From loewis at users.sourceforge.net Tue Mar 22 23:23:31 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Tue Mar 22 23:23:34 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils/command bdist_wininst.py, 1.57, 1.58 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21928 Modified Files: bdist_wininst.py Log Message: Fix registration of output file. Index: bdist_wininst.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_wininst.py,v retrieving revision 1.57 retrieving revision 1.58 diff -u -d -r1.57 -r1.58 --- bdist_wininst.py 21 Mar 2005 20:56:31 -0000 1.57 +++ bdist_wininst.py 22 Mar 2005 22:23:29 -0000 1.58 @@ -163,7 +163,7 @@ # create an exe containing the zip-file self.create_exe(arcname, fullname, self.bitmap) self.distribution.dist_files.append(('bdist_wininst', - self.get_installer_filename())) + self.get_installer_filename(fullname))) # remove the zip-file again log.debug("removing temporary file '%s'", arcname) os.remove(arcname) From doerwalter at users.sourceforge.net Tue Mar 22 23:43:34 2005 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Tue Mar 22 23:43:37 2005 Subject: [Python-checkins] python/dist/src/Lib/test seq_tests.py, 1.3, 1.4 test_deque.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-serv1888/Lib/test Modified Files: seq_tests.py test_deque.py Log Message: Add tests for tuple, list and UserList that initialize the object from various iterables. (Copied from test_deque.py as suggested by Jim Jewett in SF bug #1166274) Index: seq_tests.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/seq_tests.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- seq_tests.py 30 Sep 2004 07:47:20 -0000 1.3 +++ seq_tests.py 22 Mar 2005 22:43:27 -0000 1.4 @@ -5,6 +5,85 @@ import unittest from test import test_support +# Various iterables +# This is used for checking the constructor (here and in test_deque.py) +def iterfunc(seqn): + 'Regular generator' + for i in seqn: + yield i + +class Sequence: + 'Sequence using __getitem__' + def __init__(self, seqn): + self.seqn = seqn + def __getitem__(self, i): + return self.seqn[i] + +class IterFunc: + 'Sequence using iterator protocol' + def __init__(self, seqn): + self.seqn = seqn + self.i = 0 + def __iter__(self): + return self + def next(self): + if self.i >= len(self.seqn): raise StopIteration + v = self.seqn[self.i] + self.i += 1 + return v + +class IterGen: + 'Sequence using iterator protocol defined with a generator' + def __init__(self, seqn): + self.seqn = seqn + self.i = 0 + def __iter__(self): + for val in self.seqn: + yield val + +class IterNextOnly: + 'Missing __getitem__ and __iter__' + def __init__(self, seqn): + self.seqn = seqn + self.i = 0 + def next(self): + if self.i >= len(self.seqn): raise StopIteration + v = self.seqn[self.i] + self.i += 1 + return v + +class IterNoNext: + 'Iterator missing next()' + def __init__(self, seqn): + self.seqn = seqn + self.i = 0 + def __iter__(self): + return self + +class IterGenExc: + 'Test propagation of exceptions' + def __init__(self, seqn): + self.seqn = seqn + self.i = 0 + def __iter__(self): + return self + def next(self): + 3 // 0 + +class IterFuncStop: + 'Test immediate stop' + def __init__(self, seqn): + pass + def __iter__(self): + return self + def next(self): + raise StopIteration + +from itertools import chain, imap +def itermulti(seqn): + 'Test multiple tiers of iterators' + return chain(imap(lambda x:x, iterfunc(IterGen(Sequence(seqn))))) + class CommonTest(unittest.TestCase): # The type to be tested type2test = None @@ -40,6 +119,17 @@ vv = self.type2test(s) self.assertEqual(len(vv), len(s)) + # Create from various iteratables + for s in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5)): + for g in (Sequence, IterFunc, IterGen, + itermulti, iterfunc): + self.assertEqual(self.type2test(g(s)), self.type2test(s)) + self.assertEqual(self.type2test(IterFuncStop(s)), self.type2test()) + self.assertEqual(self.type2test(c for c in "123"), self.type2test("123")) + self.assertRaises(TypeError, self.type2test, IterNextOnly(s)) + self.assertRaises(TypeError, self.type2test, IterNoNext(s)) + self.assertRaises(ZeroDivisionError, self.type2test, IterGenExc(s)) + def test_truth(self): self.assert_(not self.type2test()) self.assert_(self.type2test([42])) Index: test_deque.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_deque.py,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- test_deque.py 22 Mar 2005 11:22:38 -0000 1.21 +++ test_deque.py 22 Mar 2005 22:43:28 -0000 1.22 @@ -1,6 +1,6 @@ from collections import deque import unittest -from test import test_support +from test import test_support, seq_tests from weakref import proxy import copy import cPickle as pickle @@ -378,93 +378,17 @@ d.append(1) gc.collect() -def R(seqn): - 'Regular generator' - for i in seqn: - yield i - -class G: - 'Sequence using __getitem__' - def __init__(self, seqn): - self.seqn = seqn - def __getitem__(self, i): - return self.seqn[i] - -class I: - 'Sequence using iterator protocol' - def __init__(self, seqn): - self.seqn = seqn - self.i = 0 - def __iter__(self): - return self - def next(self): - if self.i >= len(self.seqn): raise StopIteration - v = self.seqn[self.i] - self.i += 1 - return v - -class Ig: - 'Sequence using iterator protocol defined with a generator' - def __init__(self, seqn): - self.seqn = seqn - self.i = 0 - def __iter__(self): - for val in self.seqn: - yield val - -class X: - 'Missing __getitem__ and __iter__' - def __init__(self, seqn): - self.seqn = seqn - self.i = 0 - def next(self): - if self.i >= len(self.seqn): raise StopIteration - v = self.seqn[self.i] - self.i += 1 - return v - -class N: - 'Iterator missing next()' - def __init__(self, seqn): - self.seqn = seqn - self.i = 0 - def __iter__(self): - return self - -class E: - 'Test propagation of exceptions' - def __init__(self, seqn): - self.seqn = seqn - self.i = 0 - def __iter__(self): - return self - def next(self): - 3 // 0 - -class S: - 'Test immediate stop' - def __init__(self, seqn): - pass - def __iter__(self): - return self - def next(self): - raise StopIteration - -from itertools import chain, imap -def L(seqn): - 'Test multiple tiers of iterators' - return chain(imap(lambda x:x, R(Ig(G(seqn))))) - - class TestVariousIteratorArgs(unittest.TestCase): def test_constructor(self): for s in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5)): - for g in (G, I, Ig, S, L, R): + for g in (seq_tests.Sequence, seq_tests.IterFunc, + seq_tests.IterGen, seq_tests.IterFuncStop, + seq_tests.itermulti, seq_tests.iterfunc): self.assertEqual(list(deque(g(s))), list(g(s))) - self.assertRaises(TypeError, deque, X(s)) - self.assertRaises(TypeError, deque, N(s)) - self.assertRaises(ZeroDivisionError, deque, E(s)) + self.assertRaises(TypeError, deque, seq_tests.IterNextOnly(s)) + self.assertRaises(TypeError, deque, seq_tests.IterNoNext(s)) + self.assertRaises(ZeroDivisionError, deque, seq_tests.IterGenExc(s)) def test_iter_with_altered_data(self): d = deque('abcdefg') From loewis at users.sourceforge.net Wed Mar 23 00:02:57 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Mar 23 00:02:59 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils/command upload.py, 1.4, 1.5 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13241 Modified Files: upload.py Log Message: Make the signature detached. Index: upload.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/upload.py,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- upload.py 22 Mar 2005 20:32:41 -0000 1.4 +++ upload.py 22 Mar 2005 23:02:54 -0000 1.5 @@ -67,7 +67,7 @@ def upload_file(self, command, filename): # Sign if requested if self.sign: - spawn(("gpg", "--sign", "-a", filename), + spawn(("gpg", "--detach-sign", "-a", filename), dry_run=self.dry_run) # Fill in the data From pje at users.sourceforge.net Wed Mar 23 01:42:55 2005 From: pje at users.sourceforge.net (pje@users.sourceforge.net) Date: Wed Mar 23 01:42:59 2005 Subject: [Python-checkins] python/nondist/sandbox/setuptools pkg_resources.py, NONE, 1.1 setup.py, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setuptools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4329 Modified Files: setup.py Added Files: pkg_resources.py Log Message: Add a working pkg_resources implementation that handles extraction and basic support for non-egg resources. Still a lot to do, but this version is capable of not only extracting and running C extensions, it can even find its own runtime (pkg_resources) if it's included in the egg. --- NEW FILE: pkg_resources.py --- """\ Package resource API -------------------- A resource is a logical file contained within a package, or a logical subdirectory thereof. The package resource API expects resource names to have their path parts separated with ``/``, *not* whatever the local path separator is. Do not use os.path operations to manipulate resource names being passed into the API. The package resource API is designed to work with normal filesystem packages, .egg files, and unpacked .egg files. It can also work in a limited way with .zip files and with custom PEP 302 loaders that support the ``get_data()`` method. """ __all__ = [ 'register_loader_type', 'get_provider', 'IResourceProvider', 'ResourceManager', 'iter_distributions', 'require', 'resource_string', 'resource_stream', 'resource_filename', 'set_extraction_path', 'cleanup_resources', # 'glob_resources' ] import sys,os,zipimport,time _provider_factories = {} def register_loader_type(loader_type, provider_factory): """Register `provider_factory` to make providers for `loader_type` `loader_type` is the type or class of a PEP 302 ``module.__loader__``, and `provider_factory` is a function that, passed a *module* object, returns an ``IResourceProvider`` for that module. """ _provider_factories[loader_type] = provider_factory def get_provider(moduleName): """Return an IResourceProvider for the named module""" module = sys.modules[moduleName] loader = getattr(module,'__loader__',None) return _find_adapter(_provider_factories,loader)(module) class IResourceProvider: """An object that provides access to package resources""" def get_resource_filename(manager,resource_name): """Return a true filesystem path for `resource_name` `manager` must be an ``IResourceManager``""" def get_resource_stream(manager,resource_name): """Return a readable file-like object for `resource_name` `manager` must be an ``IResourceManager``""" def get_resource_string(manager,resource_name): """Return a string containing the contents of `resource_name` `manager` must be an ``IResourceManager``""" def has_resource(resource_name): """Does the package contain the named resource?""" def has_metadata(name): """Does the package's distribution contain the named metadata?""" def get_metadata(name): """The named metadata resource as a string""" def get_metadata_lines(name): """The named metadata resource as a filtered list of stripped lines""" # XXX list_resources? glob_resources? class ResourceManager: """Manage resource extraction and packages""" extraction_path = None def __init__(self): self.cached_files = [] def resource_exists(self,package_name,resource_name): """Does the named resource exist in the named package?""" return get_provider(package_name).has_resource(self,resource_name) def resource_filename(self,package_name,resource_name): """Return a true filesystem path for specified resource""" return get_provider(package_name).get_resource_filename(self,resource_name) def resource_stream(self,package_name,resource_name): """Return a readable file-like object for specified resource""" return get_provider(package_name).get_resource_stream(self,resource_name) def resource_string(self,package_name,resource_name): """Return specified resource as a string""" return get_provider(package_name).get_resource_string(self,resource_name) def get_cache_path(self, archive_name, names=()): """Return absolute location in cache for `archive_name` and `names` The parent directory of the resulting path will be created if it does not already exist. `archive_name` should be the base filename of the enclosing egg (which may not be the name of the enclosing zipfile!), including the ".egg" extension. `names`, if provided, should be a sequence of path name parts "under" the egg's extraction location. This method should only be called by resource providers that need to obtain an extraction location, and only for names they intend to extract, as it tracks the generated names for possible cleanup later. """ extract_path = self.extraction_path extract_path = extract_path or os.path.expanduser('~/.python-eggs') target_path = os.path.join(extract_path, archive_name, *names) _ensure_directory(target_path) self.cached_files.append(target_path) return target_path def require(self,requirement,path=None): """Ensure a distribution matching `requirement` is on ``sys.path`` The `requirement` and `path` arguments are the same as for the ``iter_distributions()`` method, but `requirement` is not optional for `require`, since you must specify the desired distribution name. """ for dist in self.iter_distributions(requirement,path): dist.require() return else: pass #raise ImportError( # "No distributions found matching "+repr(requirement) #) # XXX Not yet implemented def postprocess(self, filename): """Perform any platform-specific postprocessing of file `filename` This is where Mac header rewrites should be done; other platforms don't have anything special they should do. Resource providers should call this method after successfully extracting a compressed resource. They should not call it on resources that are already in the filesystem. """ # print "postprocessing",filename # XXX def iter_distributions(self,requirement=None,path=None): """Iterate over distributions in `path` matching `requirement` The `path` is a sequence of ``sys.path`` items. If not supplied, ``sys.path`` is used. The `requirement` is an optional string specifying the name of the desired distribution. """ return () # XXX def set_extraction_path(self, path): """Set the base path where resources will be extracted to, if needed. If not set, this defaults to ``os.expanduser("~/.python-eggs")``. Resources are extracted to subdirectories of this path based upon information given by the ``IResourceProvider``. You may set this to a temporary directory, but then you must call ``cleanup_resources()`` to delete the extracted files when done. There is no guarantee that ``cleanup_resources()`` will be able to remove all extracted files. (Note: you may not change the extraction path for a given resource manager once resources have been extracted, unless you first call ``cleanup_resources()``.) """ if self.cached_files: raise ValueError( "Can't change extraction path, files already extracted" ) self.extraction_path = path def cleanup_resources(self, force=False): """ Delete all extracted resource files and directories, returning a list of the file and directory names that could not be successfully removed. This function does not have any concurrency protection, so it should generally only be called when the extraction path is a temporary directory exclusive to a single process. This method is not automatically called; you must call it explicitly or register it as an ``atexit`` function if you wish to ensure cleanup of a temporary directory used for extractions. """ # XXX class DefaultProvider: """Provides access to package resources in the filesystem""" egg_info = None def __init__(self,module): self.module = module self.loader = getattr(module,'__loader__',None) self.module_path = os.path.dirname(module.__file__) def get_resource_filename(self,manager,resource_name): return self._fn(resource_name) def get_resource_stream(self,manager,resource_name): return open(self._fn(resource_name),'rb') def get_resource_string(manager,resource_name): return self._get(self._fn(resource_name)) def has_resource(self,resource_name): return self._has(self._fn(resource_name)) def has_metadata(self,name): if not self.egg_info: raise NotImplementedError("Only .egg supports metadata") return self._has(os.path.join(self.egg_info,*name.split('/'))) def get_metadata(self,name): if not self.egg_info: raise NotImplementedError("Only .egg supports metadata") return self._get(os.path.join(self.egg_info,*name.split('/'))) def get_metadata_lines(self,name): return [ line.strip() for line in self.get_metadata(name).splitlines() if line.strip() ] def _has(self,path): return os.path.exists(path) def _get(self,path): stream = open(path,'rb') try: return stream.read() finally: stream.close() def _fn(self,resource_name): return os.path.join(self.module_path, *resource_name.split('/')) register_loader_type(type(None), DefaultProvider) class NullProvider(DefaultProvider): """Try to implement resource support for arbitrary PEP 302 loaders""" def _has(self,path): raise NotImplementedError( "Can't perform this operation for unregistered loader type" ) def _get(self,path): if hasattr(self.loader, 'get_data'): return self.loader.get_data(path) raise NotImplementedError( "Can't perform this operation for loaders without 'get_data()'" ) register_loader_type(object, NullProvider) class ZipProvider(DefaultProvider): """Resource support for zips and eggs""" egg_name = None eagers = None def __init__(self,module): self.module = module self.loader = module.__loader__ self.zipinfo = zipimport._zip_directory_cache[self.loader.archive] self.zip_pre = self.loader.archive+os.sep path = self.module_path = os.path.dirname(module.__file__) old = None self.prefix = [] while path!=old: if path.lower().endswith('.egg'): self.egg_name = os.path.basename(path) self.egg_info = os.path.join(path,'EGG-INFO') break old = path path, base = os.path.split(path) self.prefix.append(base) def _short_name(self,path): if path.startswith(self.zip_pre): return path[len(self.zip_pre):] return path def _has(self,path): return self._short_name(path) in self.zipinfo def _get(self,path): return self.loader.get_data(path) def get_resource_stream(self, manager, resource_name): from cStringIO import StringIO return StringIO(self.get_resource_string(manager, resource_name)) def _extract_resource(self,manager,resource_name): parts = resource_name.split('/') zip_path = os.path.join(self.module_path, *parts) zip_stat = self.zipinfo[os.path.join(*self.prefix+parts)] t,d,size = zip_stat[5],zip_stat[6],zip_stat[3] date_time = ( (d>>9)+1980, (d>>5)&0xF, d&0x1F, (t&0xFFFF)>>11, (t>>5)&0x3F, (t&0x1F) * 2, 0, 0, -1 ) timestamp = time.mktime(date_time) real_path = manager.get_cache_path(self.egg_name, self.prefix+parts) if os.path.isfile(real_path): stat = os.stat(real_path) if stat.st_size==size and stat.st_mtime==timestamp: # size and stamp match, don't bother extracting return real_path # print "extracting", zip_path data = self.loader.get_data(zip_path) open(real_path,'wb').write(data) os.utime(real_path,(timestamp,timestamp)) manager.postprocess(real_path) return real_path def _get_eager_resources(self): if self.eagers is None: eagers = [] for name in 'native_libs.txt', 'eager_resources.txt': if self.has_metadata(name): eagers.extend(self.get_metadata_lines(name)) self.eagers = eagers return self.eagers def get_resource_filename(self,manager,resource_name): if not self.egg_name: raise NotImplementedError( "resource_filename() only supported for .egg, not .zip" ) # should lock for extraction here eagers = self._get_eager_resources() if resource_name in eagers: for name in eagers: self._extract_resource(manager,name) return self._extract_resource(manager,resource_name) register_loader_type(zipimport.zipimporter, ZipProvider) def _get_mro(cls): """Get an mro for a type or classic class""" if not isinstance(cls,type): class cls(cls,object): pass return cls.__mro__[1:] return cls.__mro__ def _find_adapter(registry,ob): """Return an adapter factory for `ob` from `registry`""" for t in _get_mro(getattr(ob,'__class__',type(ob))): if t in registry: return registry[t] def _ensure_directory(path): dirname = os.path.dirname(path) if not os.path.isdir(dirname): os.makedirs(dirname) # Set up global resource manager _manager = ResourceManager() for name in dir(_manager): if not name.startswith('_'): globals()[name] = getattr(_manager,name) Index: setup.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/setup.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- setup.py 20 Mar 2004 20:52:11 -0000 1.2 +++ setup.py 23 Mar 2005 00:42:52 -0000 1.3 @@ -22,6 +22,6 @@ Require('PyUnit', None, 'unittest', "http://pyunit.sf.net/"), ], packages = find_packages(), - py_modules = ['setuptools_boot'], + py_modules = ['setuptools_boot', 'pkg_resources'], ) From doerwalter at users.sourceforge.net Wed Mar 23 11:39:01 2005 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Wed Mar 23 11:39:09 2005 Subject: [Python-checkins] python/dist/src/Doc/dist dist.tex,1.92,1.93 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/dist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20697/Doc/dist Modified Files: dist.tex Log Message: Fix typo. Index: dist.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/dist/dist.tex,v retrieving revision 1.92 retrieving revision 1.93 diff -u -d -r1.92 -r1.93 --- dist.tex 22 Mar 2005 04:09:37 -0000 1.92 +++ dist.tex 23 Mar 2005 10:38:59 -0000 1.93 @@ -1737,7 +1737,7 @@ the package data if the author of the package wishes to. The distutils command \command{upload} pushes the distribution files to PyPI. -The command is invokes immediately after building one or more distribution +The command is invoked immediately after building one or more distribution files. For example, the command \begin{verbatim} From bcannon at users.sourceforge.net Wed Mar 23 16:51:35 2005 From: bcannon at users.sourceforge.net (bcannon@users.sourceforge.net) Date: Wed Mar 23 16:51:38 2005 Subject: [Python-checkins] python/dist/src/Python compile.txt, 1.1.2.9, 1.1.2.10 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23056/Python Modified Files: Tag: ast-branch compile.txt Log Message: Heavy rewrite, fleshing out high-level ideas with low-level details of implementation. Thanks to all who helped edit this doc at the PyCon 2005 sprint. Index: compile.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/Attic/compile.txt,v retrieving revision 1.1.2.9 retrieving revision 1.1.2.10 diff -u -d -r1.1.2.9 -r1.1.2.10 --- compile.txt 16 Mar 2005 20:20:18 -0000 1.1.2.9 +++ compile.txt 23 Mar 2005 15:51:25 -0000 1.1.2.10 @@ -1,42 +1,125 @@ Developer Notes for Python Compiler =================================== -Parsing -------- -XXX Fill in +Table of Contents +----------------- -Abstract Syntax Tree (AST) --------------------------- +- Scope + Defines the limits of the change +- Parse Trees + Describes the local (Python) concept +- Abstract Syntax Trees (AST) + Describes the AST technology used +- Parse Tree to AST + Defines the transform approach +- Control Flow Graphs + Defines the creation of "basic blocks" +- AST to CFG to Bytecode + Tracks the flow from AST to bytecode +- Code Objects + Pointer to making bytecode "executable" +- Modified Files + Files added/modified/removed from CPython compiler +- ToDo + Work yet remaining (before complete) +- References + Academic and technical references to technology used. -The abstract syntax tree (AST) is a high-level description of the -program structure with the syntactic details of the source text -removed. It is specified using the Zephyr Abstract Syntax Definition -Language (ASDL) [Wang97]_. -The Python definition is found in the file ``Parser/Python.asdl``. +Scope +----- -The definition describes the structure of statements, expressions, and -several specialized types, like list comprehensions and exception -handlers. Most definitions in the AST correspond to a particular -source construct, like an 'if' statement or an attribute lookup. The -definition is independent of its realization in any particular -programming language. +Historically (through 2.4), compilation from source code to bytecode +involved two steps: -XXX Is byte stream format what marshal_* fxns create? -XXX no AST->python yet, right? +1. Parse the source code into a parse tree (Parser/pgen.c) +2. Emit bytecode based on the parse tree (Python/compile.c) -The AST has concrete representations in Python and C. There is also -representation as a byte stream, so that AST objects can be passed -between Python and C. (ASDL calls this format the pickle format, but -I avoid that term to avoid confusion with Python pickles.) Each -programming language has a generic representation for ASDL and a tool -to generate a code for a specific abstract syntax. +Historically, this is not how a standard compiler works. The usual +steps for compilation are: -The following fragment of the Python abstract syntax demonstrates the -approach. +1. Parse source code into a parse tree (Parser/pgen.c) +2. Transform parse tree into an Abstract Syntax Tree (Python/ast.c) +3. Transform AST into a Control Flow Graph (Python/newcompile.c) +4. Emit bytecode based on the Control Flow Graph (Python/newcompile.c) -XXX update example once decorators in -:: +Starting with Python 2.5, the above steps are now used. This change +was done to simplify compilation by breaking it down to two steps. +The purpose of this document is to outline how the lattter three steps +of the process works. + +This document does not touch on how parsing works beyond what is needed +to explain what is needed for compilation. It is also not exahaustive +in terms of the how the entire system works. You will most likely need +to read some source to have an exact understanding of all details. + + +Parse Trees +----------- + +Python's parser is an LL(1) parser mostly based off of the +implementation laid out in the Dragon Book [Aho86]_. + +The grammar file for Python can be found in Grammar/Grammar with the +numeric value of grammar rules are stored in Include/graminit.h. The +numeric values for types of tokens (literal tokens, such as ``:``, +numbers, etc.) are kept in Include/token.h). The parse tree made up of +``node *`` structs (as defined in Include/node.h). + +Querying data from the node structs can be done with the following +macros (which are all defined in Include/token.h): + +- ``CHILD(node *, int)`` + Returns the nth child of the node using zero-offset indexing +- ``RCHILD(node *, int)`` + Returns the nth child of the node from the right side; use + negative numbers! +- ``NCH(node *)`` + Number of children the node has +- ``STR(node *)`` + String representation of the node; e.g., will return ``:`` for a + COLON token +- ``TYPE(node *)`` + The type of node as specified in ``Include/graminit.h`` +- ``REQ(node *, TYPE)`` + Assert that the node is the type that is expected +- ``LINENO(node *)`` + retrieve the line number of the source code that led to the + creation of the parse rule; defined in Python/ast.c + +To tie all of this example, consider the rule for 'while':: + + while_stmt: 'while' test ':' suite ['else' ':' suite] + +The node representing this will have ``TYPE(node) == while_stmt`` and +the number of children can be 4 or 7 depending on if there is an 'else' +statement. To access what should be the first ':' and require it be an +actual ':' token, `(REQ(CHILD(node, 2), COLON)``. + + +Abstract Syntax Trees (AST) +--------------------------- + +The abstract syntax tree (AST) is a high-level representation of the +program structure without the necessity of containing the source code; +it can be thought of a abstract representation of the source code. The +specification of the AST nodes is specified using the Zephyr Abstract +Syntax Definition Language (ASDL) [Wang97]_. + +The definition of the AST nodes for Python is found in the file +Parser/Python.asdl . + +Each AST node (representing statements, expressions, and several +specialized types, like list comprehensions and exception handlers) is +defined by the ASDL. Most definitions in the AST correspond to a +particular source construct, such as an 'if' statement or an attribute +lookup. The definition is independent of its realization in any +particular programming language. + +The following fragment of the Python ASDL construct demonstrates the +approach and syntax:: + + XXX update example once decorators in module Python { @@ -45,17 +128,25 @@ attributes (int lineno) } -The preceding example describes three different kinds of statements -- -a function definition and return and yield statement. The function -definition has three arguments -- its name, its argument list, and -zero or more statements that make up its body. The return statement -has an optional expression that is the return value. The yield -statement requires an expression. +The preceding example describes three different kinds of statements; +function definitions, return statements, and yield statements. All +three kinds are considered of type stmt as shown by '|' separating the +various kinds. They all take arguments of various kinds and amounts. -The statement definitions above generate the following C structure -type. +Modifiers on the argument type specify the number of values needed; '?' +means it is optional, '*' means 0 or more, no modifier means only one +value for the argument and it is required. FunctionDef, for instance, +takes an identifier for the name, 'arguments' for args, and zero or more +stmt arguments for 'body'. -:: +Do notice that something like 'arguments', which is a node type, is +represented as a single AST node and not as a sequence of nodes as with +stmt as one might expect. + +All three kinds also have an 'attributes' argument; this is shown by the +fact that 'attributes' lacks a '|' before it. + +The statement definitions above generate the following C structure type:: typedef struct _stmt *stmt_ty; @@ -79,140 +170,225 @@ int lineno; } -It also generates a series of constructor functions that generate a -``stmt_ty`` struct with the appropriate initialization. The ``kind`` field -specifies which component of the union is initialized. The -``FunctionDef`` C function sets ``kind`` to ``FunctionDef_kind`` and -initializes the ``name``, ``args``, and ``body`` fields. +Also generated are a series of constructor functions that allocate (in +this case) a stmt_ty struct with the appropriate initialization. The +'kind' field specifies which component of the union is initialized. The +FunctionDef() constructor function sets 'kind' to FunctionDef_kind and +initializes the 'name', 'args', 'body', and 'attributes' fields. -CST to AST ----------- -XXX Make sure basic flow of execution is covered +Parse Tree to AST +----------------- -The parser generates a concrete syntax tree represented by a ``node -*`` as defined in ``Include/node.h``. Node indexing starts at 0. Every -token that can have whitespace surrounding it is its own token. This -means that something like "else:" is actually two tokens: 'else' and -':'. +The AST is generated from the parse tree in (see Python/ast.c) using the +function:: -The abstract syntax is generated -from the concrete syntax in ``Python/ast.c`` using the function:: + mod_ty PyAST_FromNode(const node *n); - mod_ty PyAST_FromNode(const node *n); +The function begins a tree walk of the parse tree, creating various AST +nodes as it goes along. It does this by allocating all new nodes it +needs, calling the proper AST node creation functions for any required +supporting functions, and connecting them as needed. -It does this by calling various functions in the file that all have the -name ast_for_xx where xx is what the rule of the grammar (as defined -in ``Grammar/Grammar``) that the function handles (alias_for_import_name -is the exception to this). These in turn call the constructor functions -as defined by the ASDL grammar to create the nodes of the AST. +Do realize that there is no automated nor symbolic connection between +the grammar specification and the nodes in the parse tree. No help is +directly provided by the parse tree as in yacc. -Common macros used to manipulate ``node *`` structs as defined in -``Include/node.h``: - - CHILD(node, n) -- Returns the nth child of node using zero-offset - indexing - - NCH(node) -- Number of children node has - - STR(node) -- String representation of node - - TYPE(node) -- The type of node as listed in ``Include/graminit.h`` - - REQ(node, type) -- Assert that the node is the type that is expected +For instance, one must keep track of +which node in the parse tree one is working with (e.g., if you are +working with an 'if' statement you need to watch out for the ':' token +to find the end of the conditional). No help is directly provided by +the parse tree as in yacc. -Function and macros for creating and using ``asdl_seq *`` types -as found in Python/asdl.c and Include/asdl.h: - - asdl_seq_new(int) -- Allocate memory for an asdl_seq for length - 'size' - - asdl_seq_free(asdl_seq *) -- Free asdl_seq struct - - asdl_seq_GET(seq, pos) -- Get item held at 'pos' - - asdl_seq_SET(seq, pos, val) -- Set 'seq' at 'pos' to 'val' - - asdl_seq_APPEND(seq, val) -- Set the end of 'seq' to 'val' - - asdl_seq_LEN(seq) -- Return the length of 'seq' +The functions called to generate AST nodes from the parse tree all have +the name ast_for_xx where xx is what the grammar rule that the function +handles (alias_for_import_name is the exception to this). These in turn +call the constructor functions as defined by the ASDL grammar and +contained in Python/Python-ast.c (which was generated by +Parser/asdl_c.py) to create the nodes of the AST. This all leads to a +sequence of AST nodes stored in asdl_seq structs. -Code Generation and Basic Blocks --------------------------------- +Function and macros for creating and using ``asdl_seq *`` types as found +in Python/asdl.c and Include/asdl.h: -XXX Reformat: general discussion of basic blocks and compiler ideas (namespace -generation, etc.), then discuss code structure and helper functions -XXX Describe the structure of the code generator, the types involved, -and the helper functions and macros. -XXX Make sure flow of execution (namespace resolution, etc.) is covered after -explanation of macros/functions +- ``asdl_seq_new(int)`` + Allocate memory for an asdl_seq for length 'size' +- ``asdl_seq_free(asdl_seq *)`` + Free asdl_seq struct +- ``asdl_seq_GET(asdl_seq *seq, int pos)`` + Get item held at 'pos' +- ``asdl_seq_SET(asdl_seq *seq, int pos, void *val)`` + Set 'pos' in 'seq' to 'val' +- ``asdl_seq_APPEND(asdl_seq *seq, void *val)`` + Set the end of 'seq' to 'val' +- ``asdl_seq_LEN(asdl_seq *)`` + Return the length of 'seq' -- for each ast type (mod, stmt, expr, ...), define a function with a - switch statement. inline code generation for simple things, - call the function compiler_xx where xx is the kind of type in question for - others. +If you are working with statements, you must also worry about keeping +track of what line number generated the statement. Currently the line +number is passed as the last parameter to each stmt_ty function. -The macros used to emit specific opcodes and to generate code for -generic node types use string concatenation to produce calls to the -appropriate C function for the type of the object. -The VISIT macro generates code for an arbitrary node type, by calling -an appropriate compiler_visit_TYPE function. The VISIT_SEQ macro -calls the visit function for each element of a sequence. The VISIT -macros take three arguments: +Control Flow Graphs +------------------- - - the current struct compiler - - the name of the node's type (expr, stmt, ...) - - the actual node reference +A control flow graph (often referenced by its acronym, CFG) is a +directed graph that models the flow of a program using basic blocks that +contain the intermediate representation (abbreviated "IR", and in this +case is Python bytecode) within the blocks. Basic blocks themselves are +a block of IR that has a single entry point but possibly multiple exit +points. The single entry point is the key to basic blocks; it all has +to do with jumps. An entry point is the target of something that +changes control flow (such as a function call or a jump) while exit +points are instructions that would change the flow of the program (such +as jumps and 'return' statements). What this means is that a basic +block is a chunk of code that starts at the entry point and runs to an +exit point or the end of the block. + +As an example, consider an 'if' statement with an 'else' block. The +guard on the 'if' is a basic block which is pointed to by the basic +block containing the code leading to the 'if' statement. The 'if' +statement block contains jumps (which are exit points) to the true body +of the 'if' and the 'else' body (which may be NULL), each of which are +their own basic blocks. Both of those blocks in turn point to the +basic block representing the code following the entire 'if' statement. -The name of the node's type correspond to the names in the asdl -definition. The string concatenation is used to allow a single VISIT -macro to generate calls with the correct type. +CFGs are usually one step away from final code output. Code is directly +generated from the basic blocks (with jump targets adjusted based on the +output order) by doing a post-order depth-first search on the CFG +following the edges. -- all functions return true on success, false on failure -Code is generated using a simple, basic block interface. +AST to CFG to Bytecode +---------------------- - - each block has a single entry point - * means code in basic block always starts executing at a single place - * does not exclude multiple blocks pointing to the same entry point - - possibly multiple exit points - - when generating jumps, always jump to a block - - for a code unit, blocks are identified by its int id +With the AST created, the next step is to create the CFG. The first step +is to convert the AST to Python bytecode without having jump targets +resolved to specific offsets (this is calculated when the CFG goes to +final bytecode). Essentially, this transforms the AST into Python +bytecode, but with control flow represented by the edges of the CFG. -Thus the basic blocks are used to model control flow through an application. -This is often called a CFG (control flow graph). It is directed and can -contain cycles in subgraphs since modeling loops does require it. +Conversion is done in two passes. The first creates the namespace +(variables can be classified as local, free/cell for closures, or +global) creates CFG with the namespace info. With that done the second +pass is done which essentially flattens the CFG into a list and +calculates jump offsets for final output of bytecode. -Below are are macros and functions used for managing basic blocks: +The conversion process is initiated by a call to the function in +Python/newcompile.c:: -- NEW_BLOCK() -- create block and set it as current -- NEXT_BLOCK() -- NEW_BLOCK() plus jump from current block -- compiler_new_block() -- create a block but don't use it - (used for generating jumps) + PyCodeObject * PyAST_Compile(mod_ty, const char *, PyCompilerFlags); -- There are five macros for generating opcodes in the current basic - block. Each takes the current struct compiler * as the first - argument and an opcode name as the second argument. +This function does both the conversion of the AST to a CFG and +outputting final bytecode from the CFG. The AST to CFG step is handled +mostly by the two functions called by PyAST_Compile():: - ADDOP(c, opcode) -- opcode with no arguments - ADDOP_I(c, opcode, oparg) -- oparg is a C int - ADDOP_O(c, opcode, oparg, namespace) -- oparg is a PyObject * , - namespace is the name of a code object member that contains - the set of objects. For example, - ``ADDOP_O(c, LOAD_CONST, obj, consts)`` - will make sure that obj is in co_consts and that the opcode - argument will be an index into co_consts. The valid names - are consts, names, varnames, ... - ADDOP_NAME(c, op, o, type) -- XXX + struct symtable * PySymtable_Build(mod_ty, const char *, + PyFutureFeatures); + PyCodeObject * compiler_mod(struct compiler *, mod_ty); - XXX Explain what each namespace is for. +The former is in Python/symtable.c while the latter is in +Python/newcompile.c . - ADDOP_JABS(XXX) -- oparg is an absolute jump to block id - ADDOP_JREL(XXX) -- oparg is a relative jump to block id - XXX no need for JABS() and JREL(), always computed at the - end from block id +PySymtable_Build() begins by entering the starting code block for the +AST (passed-in) and then calling the proper symtable_visit_xx function +(with xx being the AST node type). Next, the AST tree is walked with +the various code blocks that delineate the reach of a local variable +as blocks are entered and exited:: + + static int symtable_enter_block(struct symtable *, identifier, + block_ty, void *, int); + static int symtable_exit_block(struct symtable *, void *); + +Once the symbol table is created, it is time for CFG creation, whose +code is in Python/newcompile.c . This is handled by several functions +that break the task down by various AST node types. The functions are +all named compiler_visit_xx where xx is the name of the node type (such +as stmt, expr, etc.). Each function receives a ``struct compiler *`` +and xx_ty where xx is the AST node type. Typically these functions +consist of a large 'switch' statement, branching based on the kind of +node type passed to it. Simple things are handled inline in the +'switch' statement with more complex transformations farmed out to other +functions named compiler_xx with xx being a descriptive name of what is +being handled. + +When transforming an arbitrary AST node, use the VISIT macro:: + + VISIT(struct compiler *, , ); + +The appropriate compiler_visit_xx function is called, based on the value +passed in for (so ``VISIT(c, expr, node)`` calls +``compiler_visit_expr(c, node)``). The VISIT_SEQ macro is very similar, + but is called on AST node sequences (those values that were created as +arguments to a node that used the '*' modifier). There is also +VISIT_SLICE just for handling slices:: + + VISIT_SLICE(struct compiler *, slice_ty, expr_context_ty); + +Emission of bytecode is handled by the following macros: + +- ``ADDOP(struct compiler *c, int op)`` + add 'op' as an opcode +- ``ADDOP_I(struct compiler *c, int op, int oparg)`` + add 'op' with an 'oparg' argument +- ``ADDOP_O(struct compiler *c, int op, PyObject *type, PyObject *obj)`` + add 'op' with the proper argument based on the position of obj in + 'type', but with no handling of mangled names; used for when you + need to do named lookups of objects such as globals, consts, or + parameters where name mangling is not possible and the scope of the + name is known +- ``ADDOP_NAME(struct compiler *, int, PyObject *, PyObject *)`` + just like ADDOP_O, but name mangling is also handled; used for + attribute loading or importing based on name +- ``ADDOP_JABS(struct compiling *c, int op, basicblock b)`` + create an absolute jump to the basic block 'b' +- ``ADDOP_JREL(struct compiling *c, int op, basicblock b)`` + create a relative jump to the basic block 'b' + +Several helper functions that will emit bytecode and are named +compiler_xx() where xx is what the function helps with (list, boolop + etc.). A rather useful one is:: + + static int compiler_nameop(struct compiler *, identifier, + expr_context_ty); + +This function looks up the scope of a variable and, based on the +expression context, emits the proper opcode to load, store, or delete +the variable. + +As for handling the line number on which a statement is defined, is +handled by compiler_visit_stmt() and thus is not a worry. + +In addition to emitting bytecode based on the AST node, handling the +creation of basic blocks must be done. Below are the macros and +functions used for managing basic blocks: + +- ``NEW_BLOCK(struct compiler *)`` + create block and set it as current +- ``NEXT_BLOCK(struct compiler *)`` + basically NEW_BLOCK() plus jump from current block +- ``compiler_new_block(struct compiler *)`` + create a block but don't use it (used for generating jumps) + +Once the CFG is created, it must be flattened and then final emission of +bytecode occurs. Flattening is handled using a post-order depth-first +search. Once flattened, jump offsets are backpatched based on the +flattening and then a PyCodeObject file is created. All of this is +handled by calling:: + + PyCodeObject * assemble(struct compiler *, int); -- symbol table pass and compiler_nameop() -XXX Code Objects ------------ -XXX Describe Python code objects: fields, etc. +In the end, one ends up with a PyCodeObject which is defined in +Include/code.h . And with that you now have executable Python bytecode! -Files ------ + +Modified Files +-------------- + Parser/ @@ -224,7 +400,8 @@ Language." Uses SPARK_ to parse the ASDL files. - asdl_c.py - "Generate C code from an ASDL description." + "Generate C code from an ASDL description." Generates + ../Python/Python-ast.c and ../Include/Python-ast.h . - spark.py SPARK_ parser generator @@ -232,10 +409,10 @@ + Python/ - Python-ast.c - Creates C structs corresponding to the ASDL types. Also contains code - for marshaling AST nodes (core ASDL types have marshaling code in - asdl.c). - "File automatically generated by ../Parser/asdl_c.py". + Creates C structs corresponding to the ASDL types. Also + contains code for marshaling AST nodes (core ASDL types have + marshaling code in asdl.c). "File automatically generated by + ../Parser/asdl_c.py". - asdl.c Contains code to handle the ASDL sequence type. Also has code @@ -243,7 +420,7 @@ identifier. used by Python-ast.c for marshaling AST nodes. - ast.c - Converts Python's concrete syntax tree into the abstract syntax tree. + Converts Python's parse tree into the abstract syntax tree. - compile.txt This file. @@ -264,10 +441,6 @@ - ast.h Declares PyAST_FromNode() external (from ../Python/ast.c). -Known Bugs/Issues ------------------ - -XXX ToDo ---- @@ -275,8 +448,7 @@ + Grammar support (Parser/Python.asdl, Parser/asdl_c.py) - decorators - empty base class list (``class Class(): pass``) - - AST->Python object support -+ CST->AST support (Python/ast.c) ++ parse tree->AST support (Python/ast.c) - decorators - generator expressions + AST->bytecode support (Python/newcompile.c) @@ -287,23 +459,27 @@ - rewrite compiler package to mirror AST structure? + Documentation - flesh out this doc - * compiler concepts covered - * structure and flow of all steps clearly explained - * break up into more sections/subsections + * byte stream output + Universal - make sure entire test suite passes - fix memory leaks - make sure return types are properly checked for errors + - no gcc warnings References ---------- +.. [Aho86] Alfred V. Aho, Ravi Sethi, Jeffrey D. Ullman. + `Compilers: Principles, Techniques, and Tools`, + http://www.amazon.com/exec/obidos/tg/detail/-/0201100886/104-0162389-6419108 + .. [Wang97] Daniel C. Wang, Andrew W. Appel, Jeff L. Korn, and Chris S. Serra. `The Zephyr Abstract Syntax Description Language.`_ In Proceedings of the Conference on Domain-Specific Languages, pp. 213--227, 1997. .. _The Zephyr Abstract Syntax Description Language.: - http://www.cs.princeton.edu/~danwang/Papers/dsl97/dsl97-abstract.html. + http://www.cs.princeton.edu/~danwang/Papers/dsl97/dsl97.html .. _SPARK: http://pages.cpsc.ucalgary.ca/~aycock/spark/ + From loewis at users.sourceforge.net Wed Mar 23 19:54:42 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Mar 23 19:54:45 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils dist.py,1.76,1.77 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11294 Modified Files: dist.py Log Message: Make dist_files a triple, with the Python target version included, so that bdist_wininst can specify 'any'. Index: dist.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/dist.py,v retrieving revision 1.76 retrieving revision 1.77 diff -u -d -r1.76 -r1.77 --- dist.py 21 Mar 2005 20:56:30 -0000 1.76 +++ dist.py 23 Mar 2005 18:54:04 -0000 1.77 @@ -177,9 +177,15 @@ # command_options = { command_name : { option : (source, value) } } self.command_options = {} - # 'dist_files' is the list of (command, file) that have been created - # by any dist commands run so far. This is filled regardless - # of whether the run is dry or not. + # 'dist_files' is the list of (command, pyversion, file) that + # have been created by any dist commands run so far. This is + # filled regardless of whether the run is dry or not. pyversion + # gives sysconfig.get_python_version() if the dist file is + # specific to a Python version, 'any' if it is good for all + # Python versions on the target platform, and '' for a source + # file. pyversion should not be used to specify minimum or + # maximum required Python versions; use the metainfo for that + # instead. self.dist_files = [] # These options are really the business of various commands, rather From loewis at users.sourceforge.net Wed Mar 23 19:55:37 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Mar 23 19:55:39 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils/command bdist_dumb.py, 1.26, 1.27 bdist_rpm.py, 1.47, 1.48 bdist_wininst.py, 1.58, 1.59 sdist.py, 1.60, 1.61 upload.py, 1.5, 1.6 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11294/command Modified Files: bdist_dumb.py bdist_rpm.py bdist_wininst.py sdist.py upload.py Log Message: Make dist_files a triple, with the Python target version included, so that bdist_wininst can specify 'any'. Index: bdist_dumb.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_dumb.py,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- bdist_dumb.py 21 Mar 2005 20:56:30 -0000 1.26 +++ bdist_dumb.py 23 Mar 2005 18:54:08 -0000 1.27 @@ -13,6 +13,7 @@ from distutils.util import get_platform from distutils.dir_util import create_tree, remove_tree, ensure_relative from distutils.errors import * +from distutils.sysconfig import get_python_version from distutils import log class bdist_dumb (Command): @@ -119,7 +120,12 @@ # Make the archive filename = self.make_archive(pseudoinstall_root, self.format, root_dir=archive_root) - self.distribution.dist_files.append(('bdist_dumb', filename)) + if self.distribution.has_ext_modules(): + pyversion = get_python_version() + else: + pyversion = 'any' + self.distribution.dist_files.append(('bdist_dumb', pyversion, + filename)) if not self.keep_temp: remove_tree(self.bdist_dir, dry_run=self.dry_run) Index: bdist_rpm.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_rpm.py,v retrieving revision 1.47 retrieving revision 1.48 diff -u -d -r1.47 -r1.48 --- bdist_rpm.py 21 Mar 2005 20:56:31 -0000 1.47 +++ bdist_rpm.py 23 Mar 2005 18:54:10 -0000 1.48 @@ -15,6 +15,7 @@ from distutils.util import get_platform from distutils.file_util import write_file from distutils.errors import * +from distutils.sysconfig import get_python_version from distutils import log class bdist_rpm (Command): @@ -346,6 +347,10 @@ srpms = glob.glob(os.path.join(rpm_dir['SRPMS'], "*.rpm")) assert len(srpms) == 1, \ "unexpected number of SRPM files found: %s" % srpms + dist_file = ('bdist_rpm', '', + os.path.join(self.dist_dir, + os.path.basename(srpms[0]))) + self.distribution.dist_files.append(dist_file) self.move_file(srpms[0], self.dist_dir) if not self.source_only: @@ -356,9 +361,15 @@ rpms.remove(debuginfo[0]) assert len(rpms) == 1, \ "unexpected number of RPM files found: %s" % rpms + dist_file = ('bdist_rpm', get_python_version(), + os.path.join(self.dist_dir, + os.path.basename(rpms[0]))) + self.distribution.dist_files.append(dist_file) self.move_file(rpms[0], self.dist_dir) - self.distribution.dist_files.append(('bdist_rpm', rpms[0])) if debuginfo: + dist_file = ('bdist_rpm', get_python_version(), + os.path.join(self.dist_dir, + os.path.basename(debuginfo[0]))) self.move_file(debuginfo[0], self.dist_dir) # run() Index: bdist_wininst.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_wininst.py,v retrieving revision 1.58 retrieving revision 1.59 diff -u -d -r1.58 -r1.59 --- bdist_wininst.py 22 Mar 2005 22:23:29 -0000 1.58 +++ bdist_wininst.py 23 Mar 2005 18:54:13 -0000 1.59 @@ -162,7 +162,11 @@ root_dir=self.bdist_dir) # create an exe containing the zip-file self.create_exe(arcname, fullname, self.bitmap) - self.distribution.dist_files.append(('bdist_wininst', + if self.distribution.has_ext_modules(): + pyversion = get_python_version() + else: + pyversion = 'any' + self.distribution.dist_files.append(('bdist_wininst', pyversion, self.get_installer_filename(fullname))) # remove the zip-file again log.debug("removing temporary file '%s'", arcname) Index: sdist.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/sdist.py,v retrieving revision 1.60 retrieving revision 1.61 diff -u -d -r1.60 -r1.61 --- sdist.py 21 Mar 2005 20:56:34 -0000 1.60 +++ sdist.py 23 Mar 2005 18:54:35 -0000 1.61 @@ -449,7 +449,7 @@ for fmt in self.formats: file = self.make_archive(base_name, fmt, base_dir=base_dir) archive_files.append(file) - self.distribution.dist_files.append(('sdist',file)) + self.distribution.dist_files.append(('sdist', '', file)) self.archive_files = archive_files Index: upload.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/upload.py,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- upload.py 22 Mar 2005 23:02:54 -0000 1.5 +++ upload.py 23 Mar 2005 18:54:36 -0000 1.6 @@ -4,7 +4,6 @@ from distutils.errors import * from distutils.core import Command -from distutils.sysconfig import get_python_version from distutils.spawn import spawn from distutils import log from md5 import md5 @@ -61,10 +60,10 @@ def run(self): if not self.distribution.dist_files: raise DistutilsOptionError("No dist file created in earlier command") - for command, filename in self.distribution.dist_files: - self.upload_file(command, filename) + for command, pyversion, filename in self.distribution.dist_files: + self.upload_file(command, pyversion, filename) - def upload_file(self, command, filename): + def upload_file(self, command, pyversion, filename): # Sign if requested if self.sign: spawn(("gpg", "--detach-sign", "-a", filename), @@ -79,7 +78,7 @@ 'version':self.distribution.get_version(), 'content':(os.path.basename(filename),content), 'filetype':command, - 'pyversion':get_python_version(), + 'pyversion':pyversion, 'md5_digest':md5(content).hexdigest(), } comment = '' @@ -89,8 +88,6 @@ comment = 'built for %s %s' % (dist, version) elif command == 'bdist_dumb': comment = 'built for %s' % platform.platform(terse=1) - elif command == 'sdist': - data['pyversion'] = '' data['comment'] = comment if self.sign: From loewis at users.sourceforge.net Wed Mar 23 23:17:05 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Wed Mar 23 23:17:07 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils/command bdist_rpm.py, 1.48, 1.49 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10299 Modified Files: bdist_rpm.py Log Message: Make SRPMs pyversion 'any'. Index: bdist_rpm.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_rpm.py,v retrieving revision 1.48 retrieving revision 1.49 diff -u -d -r1.48 -r1.49 --- bdist_rpm.py 23 Mar 2005 18:54:10 -0000 1.48 +++ bdist_rpm.py 23 Mar 2005 22:16:22 -0000 1.49 @@ -347,7 +347,7 @@ srpms = glob.glob(os.path.join(rpm_dir['SRPMS'], "*.rpm")) assert len(srpms) == 1, \ "unexpected number of SRPM files found: %s" % srpms - dist_file = ('bdist_rpm', '', + dist_file = ('bdist_rpm', 'any', os.path.join(self.dist_dir, os.path.basename(srpms[0]))) self.distribution.dist_files.append(dist_file) From fdrake at users.sourceforge.net Thu Mar 24 07:17:27 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu Mar 24 07:17:29 2005 Subject: [Python-checkins] python/dist/src/Doc/tests - New directory Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20996/tests Log Message: Directory /cvsroot/python/python/dist/src/Doc/tests added to the repository From fdrake at users.sourceforge.net Thu Mar 24 07:21:40 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu Mar 24 07:21:42 2005 Subject: [Python-checkins] python/dist/src/Doc/tests math.tex,NONE,1.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23521/tests Added Files: math.tex Log Message: clean up the underscore mess for the typeset formats so that subscripts work in math displays (thanks to Bo Peng on the Doc-SIG) --- NEW FILE: math.tex --- \documentclass{howto} \title{Test of python.sty with math} \begin{document} \maketitle \section{Subscripts in Math Mode} This contains an inline formula containing a subscript: $H_20$. This display doesn't make sense, but contains a subscript as well: $$\sum_1^2 = a_x$$ \end{document} From fdrake at users.sourceforge.net Thu Mar 24 07:21:40 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu Mar 24 07:21:43 2005 Subject: [Python-checkins] python/dist/src/Doc ACKS,1.40,1.41 Message-ID: Update of /cvsroot/python/python/dist/src/Doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23521 Modified Files: ACKS Log Message: clean up the underscore mess for the typeset formats so that subscripts work in math displays (thanks to Bo Peng on the Doc-SIG) Index: ACKS =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/ACKS,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- ACKS 30 Jul 2003 02:55:27 -0000 1.40 +++ ACKS 24 Mar 2005 06:21:37 -0000 1.41 @@ -23,7 +23,7 @@ A. Amoroso Pehr Anderson Oliver Andrich -Jesús Cea Avión +Jesús Cea Avión Daniel Barclay Chris Barker Don Bashford @@ -54,7 +54,7 @@ Carey Evans Martijn Faassen Carl Feynman -Hernán Martínez Foffani +Hernán Martínez Foffani Stefan Franke Jim Fulton Peter Funk @@ -71,7 +71,7 @@ Mark Hammond Harald Hanche-Olsen Manus Hand -Gerhard Häring +Gerhard Häring Travis B. Hartwell Janko Hauser Bernhard Herzog @@ -108,11 +108,11 @@ Detlef Lannert Piers Lauder Glyph Lefkowitz -Marc-André Lemburg +Marc-André Lemburg Ulf A. Lindgren Everett Lipman Mirko Liss -Martin von Löwis +Martin von Löwis Fredrik Lundh Jeff MacDonald John Machin @@ -136,11 +136,12 @@ William Park Joonas Paalasmaa Harri Pasanen +Bo Peng Tim Peters Christopher Petrilli Justin D. Pettit Chris Phoenix -François Pinard +François Pinard Paul Prescod Eric S. Raymond Edward K. Ream From fdrake at users.sourceforge.net Thu Mar 24 07:21:41 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu Mar 24 07:21:46 2005 Subject: [Python-checkins] python/dist/src/Doc/texinputs underscore.sty, NONE, 1.1 python.sty, 1.112, 1.113 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/texinputs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23521/texinputs Modified Files: python.sty Added Files: underscore.sty Log Message: clean up the underscore mess for the typeset formats so that subscripts work in math displays (thanks to Bo Peng on the Doc-SIG) --- NEW FILE: underscore.sty --- % underscore.sty 12-Oct-2001 Donald Arseneau asnd@triumf.ca % Make the "_" character print as "\textunderscore" in text. % Copyright 1998,2001 Donald Arseneau; Distribute freely if unchanged. % Instructions follow after the definitions. \ProvidesPackage{underscore}[2001/10/12] \begingroup \catcode`\_=\active \gdef_{% \relax % No relax gives a small vulnerability in alignments \ifx\if@safe@actives\iftrue % must be outermost test! \string_% \else \ifx\protect\@typeset@protect \ifmmode \sb \else \BreakableUnderscore \fi \else \ifx\protect\@unexpandable@protect \noexpand_% \else \protect_% \fi\fi \fi} \endgroup % At begin: set catcode; fix \long \ttdefault so I can use it in comparisons; \AtBeginDocument{% {\immediate\write\@auxout{\catcode\number\string`\_ \string\active}}% \catcode\string`\_\string=\active \edef\ttdefault{\ttdefault}% } \newcommand{\BreakableUnderscore}{\leavevmode\nobreak\hskip\z@skip \ifx\f@family\ttdefault \string_\else \textunderscore\fi \usc@dischyph\nobreak\hskip\z@skip} \DeclareRobustCommand{\_}{% \ifmmode \nfss@text{\textunderscore}\else \BreakableUnderscore \fi} \let\usc@dischyph\@dischyph \DeclareOption{nohyphen}{\def\usc@dischyph{\discretionary{}{}{}}} \DeclareOption{strings}{\catcode`\_=\active} \ProcessOptions \ifnum\catcode`\_=\active\else \endinput \fi %%%%%%%% Redefine commands that use character strings %%%%%%%% \@ifundefined{UnderscoreCommands}{\let\UnderscoreCommands\@empty}{} \expandafter\def\expandafter\UnderscoreCommands\expandafter{% \UnderscoreCommands \do\include \do\includeonly \do\@input \do\@iinput \do\InputIfFileExists \do\ref \do\pageref \do\newlabel \do\bibitem \do\@bibitem \do\cite \do\nocite \do\bibcite } % Macro to redefine a macro to pre-process its string argument % with \protect -> \string. \def\do#1{% Avoid double processing if user includes command twice! \@ifundefined{US\string_\expandafter\@gobble\string#1}{% \edef\@tempb{\meaning#1}% Check if macro is just a protection shell... \def\@tempc{\protect}% \edef\@tempc{\meaning\@tempc\string#1\space\space}% \ifx\@tempb\@tempc % just a shell: hook into the protected inner command \expandafter\do \csname \expandafter\@gobble\string#1 \expandafter\endcsname \else % Check if macro takes an optional argument \def\@tempc{\@ifnextchar[}% \edef\@tempa{\def\noexpand\@tempa####1\meaning\@tempc}% \@tempa##2##3\@tempa{##2\relax}% \edef\@tempb{\meaning#1\meaning\@tempc}% \edef\@tempc{\noexpand\@tempd \csname US\string_\expandafter\@gobble\string#1\endcsname}% \if \expandafter\@tempa\@tempb \relax 12\@tempa % then no optional arg \@tempc #1\US@prot \else % There is optional arg \@tempc #1\US@protopt \fi \fi }{}} \def\@tempd#1#2#3{\let#1#2\def#2{#3#1}} \def\US@prot#1#2{\let\@@protect\protect \let\protect\string \edef\US@temp##1{##1{#2}}\restore@protect\US@temp#1} \def\US@protopt#1{\@ifnextchar[{\US@protarg#1}{\US@prot#1}} \def\US@protarg #1[#2]{\US@prot{{#1[#2]}}} \UnderscoreCommands \let\do\relax \let\@tempd\relax % un-do %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \endinput underscore.sty 12-Oct-2001 Donald Arseneau Features: ~~~~~~~~~ \_ prints an underscore so that the hyphenation of constituent words is not affected and hyphenation is permitted after the underscore. For example, "compound\_fracture" hyphenates as com- pound_- frac- ture. If you prefer the underscore to break without a hyphen (but still with the same rules for explicit hyphen-breaks) then use the [nohyphen] package option. A simple _ acts just like \_ in text mode, but makes a subscript in math mode: activation_energy $E_a$ Both forms use an underscore character if the font encoding contains one (e.g., "\usepackage[T1]{fontenc}" or typewriter fonts in any encoding), but they use a rule if the there is no proper character. Deficiencies: ~~~~~~~~~~~~~ The skips and penalties ruin any kerning with the underscore character (when a character is used). However, there doesn't seem to be much, if any, such kerning in the ec fonts, and there is never any kerning with a rule. You must avoid "_" in file names and in cite or ref tags, or you must use the babel package, with its active-character controls, or you must give the [strings] option, which attempts to redefine several commands (and may not work perfectly). Even without the [strings] option or babel, you can use occasional underscores like: "\include{file\string_name}". Option: [strings] ~~~~~~~~~~~~~~~~~ The default operation is quite simple and needs no customization; but you must avoid using "_" in any place where LaTeX uses an argument as a string of characters for some control function or as a name. These include the tags for \cite and \ref, file names for \input, \include, and \includegraphics, environment names, counter names, and placement parameters (like "[t]"). The problem with these contexts is that they are `moving arguments' but LaTeX does not `switch on' the \protect mechanism for them. If you need to use the underscore character in these places, the package option [strings] is provided to redefine commands taking a string argument so that the argument is protected (with \protect -> \string). The list of commands is given in "\UnderscoreCommands", with "\do" before each, covering \cite, \ref, \input, and their variants. Not included are many commands regarding font names, everything with counter names, environment names, page styles, and versions of \ref and \cite defined by external packages (e.g. \vref and \citeyear). You can add to the list of supported commands by defining \UnderscoreCommands before loading this package; e.g. \usepackage{chicago} \newcommand{\UnderscoreCommands}{% (\cite already done) \do\citeNP \do\citeA \do\citeANP \do\citeN \do\shortcite \do\shortciteNP \do\shortciteA \do\shortciteANP \do\shortciteN \do\citeyear \do\citeyearNP } \usepackage[strings]{underscore} Not all commands can be supported this way! Only commands that take a string argument *first* can be protected. One optional argument before the string argument is also permitted, as exemplified by \cite: both \cite{tags} and \cite[text]{tags} are allowed. A command like \@addtoreset which takes two counter names as arguments could not be protected by adding it to \UnderscoreCommands. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! When you use the [strings] option, you must load this package !! !! last (or nearly last). !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! There are two reasons: 1) The redefinitions done for protection must come after other packages define their customized versions of those commands. 2) The [strings] option requires the _ character to be activated immediately in order for the cite and ref tags to be read properly from the .aux file as plain strings, and this catcode setting might disrupt other packages. The babel package implements a protection mechanism for many commands, and will be a complete fix for most documents without the [strings] option. Many add-on packages are compatible with babel, so they will get the strings protection also. However, there are several commands that are not covered by babel, but can easily be supported by the [strings] and \UnderscoreCommands mechanism. Beware that using both [strings] and babel may lead to conflicts, but does appear to work (load babel last). Implementation Notes: ~~~~~~~~~~~~~~~~~~~~~ The first setting of "_" to be an active character is performed in a local group so as to not interfere with other packages. The catcode setting is repeated with \AtBeginDocument so the definition is in effect for the text. However, the catcode setting is repeated immediately when the [strings] option is detected. The definition of the active "_" is essentially: \ifmmode \sb \else \BreakableUnderscore \fi where "\sb" retains the normal subscript meaning of "_" and where "\BreakableUnderscore" is essentially "\_". The rest of the definition handles the "\protect"ion without causing \relax to be inserted before the character. \BreakableUnderscore uses "\nobreak\hskip\z@skip" to separate the underscore from surrounding words, thus allowing TeX to hyphenate them, but preventing free breaks around the underscore. Next, it checks the current font family, and uses the underscore character from tt fonts or otherwise \textunderscore (which is a character or rule depending on the font encoding). After the underscore, it inserts a discretionary hyphenation point as "\usc@dischyph", which is usually just "\-" except that it still works in the tabbing environment, although it will give "\discretionary{}{}{}" under the [nohyphen] option. After that, another piece of non-breaking interword glue is inserted. Ordinarily, the comparison "\ifx\f@family\ttdefault" will always fail because \ttdefault is `long' where \f@family is not (boooo hisss), but \ttdefault is redefined to be non-long by "\AtBeginDocument". The "\_" command is then defined to use "\BreakableUnderscore". If the [strings] option is not given, then that is all! Under the [strings] option, the list of special commands is processed to: - retain the original command as \US_command (\US_ref) - redefine the command as \US@prot\US_command for ordinary commands (\ref -> \US@prot\US_ref) or as \US@protopt\US_command when an optional argument is possible (\bibitem -> \US@protopt\US_bibitem). - self-protecting commands (\cite) retain their self-protection. Diagnosing the state of the pre-existing command is done by painful contortions involving \meaning. \US@prot and \US@protopt read the argument, process it with \protect enabled, then invoke the saved \US_command. Modifications: ~~~~~~~~~~~~~~ 12-Oct-2001 Babel (safe@actives) compatibility and [nohyphen] option. Test file integrity: ASCII 32-57, 58-126: !"#$%&'()*+,-./0123456789 :;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ Index: python.sty =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/texinputs/python.sty,v retrieving revision 1.112 retrieving revision 1.113 diff -u -d -r1.112 -r1.113 --- python.sty 10 Mar 2005 04:01:14 -0000 1.112 +++ python.sty 24 Mar 2005 06:21:38 -0000 1.113 @@ -7,6 +7,7 @@ [1998/01/11 LaTeX package (Python markup)] \RequirePackage{longtable} +\RequirePackage{underscore} % Uncomment these two lines to ignore the paper size and make the page % size more like a typical published manual. @@ -541,28 +542,6 @@ {\reset@font\normalsize\py@HeaderFamily}} -% This gets the underscores closer to the right width; the only change -% from standard LaTeX is the width specified. - -\DeclareTextCommandDefault{\textunderscore}{% - \leavevmode \kern.06em\vbox{\hrule\@width.55em}} - -% Underscore hack (only act like subscript operator if in math mode) -% -% The following is due to Mark Wooding (the old version didn't work with -% Latex 2e. - -\DeclareRobustCommand\hackscore{% - \ifmmode_\else\textunderscore\fi% -} -\begingroup -\catcode`\_\active -\def\next{% - \AtBeginDocument{\catcode`\_\active\def_{\hackscore{}}}% -} -\expandafter\endgroup\next - - % Now for a lot of semantically-loaded environments that do a ton of magical % things to get the right formatting and index entries for the stuff in % Python modules and C API. From fdrake at users.sourceforge.net Thu Mar 24 08:00:07 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Thu Mar 24 08:00:21 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils/command bdist_rpm.py, 1.49, 1.50 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10770/Lib/distutils/command Modified Files: bdist_rpm.py Log Message: minor cleanup Index: bdist_rpm.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_rpm.py,v retrieving revision 1.49 retrieving revision 1.50 diff -u -d -r1.49 -r1.50 --- bdist_rpm.py 23 Mar 2005 22:16:22 -0000 1.49 +++ bdist_rpm.py 24 Mar 2005 07:00:05 -0000 1.50 @@ -348,31 +348,30 @@ assert len(srpms) == 1, \ "unexpected number of SRPM files found: %s" % srpms dist_file = ('bdist_rpm', 'any', - os.path.join(self.dist_dir, - os.path.basename(srpms[0]))) + self._dist_path(srpms[0])) self.distribution.dist_files.append(dist_file) self.move_file(srpms[0], self.dist_dir) if not self.source_only: rpms = glob.glob(os.path.join(rpm_dir['RPMS'], "*/*.rpm")) - debuginfo = glob.glob(os.path.join(rpm_dir['RPMS'], \ + debuginfo = glob.glob(os.path.join(rpm_dir['RPMS'], "*/*debuginfo*.rpm")) if debuginfo: rpms.remove(debuginfo[0]) assert len(rpms) == 1, \ "unexpected number of RPM files found: %s" % rpms dist_file = ('bdist_rpm', get_python_version(), - os.path.join(self.dist_dir, - os.path.basename(rpms[0]))) + self._dist_path(rpms[0]) self.distribution.dist_files.append(dist_file) self.move_file(rpms[0], self.dist_dir) if debuginfo: dist_file = ('bdist_rpm', get_python_version(), - os.path.join(self.dist_dir, - os.path.basename(debuginfo[0]))) + self._dist_path(debuginfo[0]) self.move_file(debuginfo[0], self.dist_dir) # run() + def _dist_path(self, path): + return os.path.join(self.dist_dir, os.path.basename(path)) def _make_spec_file(self): """Generate the text of an RPM spec file and return it as a From theller at users.sourceforge.net Thu Mar 24 08:45:56 2005 From: theller at users.sourceforge.net (theller@users.sourceforge.net) Date: Thu Mar 24 08:46:00 2005 Subject: [Python-checkins] python/dist/src/Doc/api newtypes.tex,1.34,1.35 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/api In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2849 Modified Files: newtypes.tex Log Message: Function signatures for tp_descr_get and tp_descr_set. Index: newtypes.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/api/newtypes.tex,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- newtypes.tex 7 Aug 2004 20:17:48 -0000 1.34 +++ newtypes.tex 24 Mar 2005 07:45:53 -0000 1.35 @@ -1106,6 +1106,13 @@ \begin{cmemberdesc}{PyTypeObject}{descrgetfunc}{tp_descr_get} An optional pointer to a "descriptor get" function. + + The function signature is + +\begin{verbatim} +PyObject * tp_descr_get(PyObject *self, PyObject *obj, PyObject *type); +\end{verbatim} + XXX blah, blah. This field is inherited by subtypes. @@ -1114,9 +1121,16 @@ \begin{cmemberdesc}{PyTypeObject}{descrsetfunc}{tp_descr_set} An optional pointer to a "descriptor set" function. - XXX blah, blah. + The function signature is + +\begin{verbatim} +int tp_descr_set(PyObject *self, PyObject *obj, PyObject *value); +\end{verbatim} This field is inherited by subtypes. + + XXX blah, blah. + \end{cmemberdesc} \begin{cmemberdesc}{PyTypeObject}{long}{tp_dictoffset} From etrepum at users.sourceforge.net Thu Mar 24 20:21:55 2005 From: etrepum at users.sourceforge.net (etrepum@users.sourceforge.net) Date: Thu Mar 24 20:21:58 2005 Subject: [Python-checkins] python/nondist/sandbox/setuptools pkg_resources.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setuptools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18600 Modified Files: pkg_resources.py Log Message: Reformat pkg_resources in PEP 8 style Index: pkg_resources.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/pkg_resources.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- pkg_resources.py 23 Mar 2005 00:42:52 -0000 1.1 +++ pkg_resources.py 24 Mar 2005 19:21:53 -0000 1.2 @@ -13,6 +13,12 @@ .zip files and with custom PEP 302 loaders that support the ``get_data()`` method. """ + +import sys +import os +import time +import zipimport + __all__ = [ 'register_loader_type', 'get_provider', 'IResourceProvider', 'ResourceManager', 'iter_distributions', 'require', 'resource_string', @@ -20,7 +26,6 @@ 'cleanup_resources', # 'glob_resources' ] -import sys,os,zipimport,time _provider_factories = {} def register_loader_type(loader_type, provider_factory): @@ -32,28 +37,28 @@ """ _provider_factories[loader_type] = provider_factory + def get_provider(moduleName): """Return an IResourceProvider for the named module""" module = sys.modules[moduleName] - loader = getattr(module,'__loader__',None) - return _find_adapter(_provider_factories,loader)(module) + loader = getattr(module, '__loader__', None) + return _find_adapter(_provider_factories, loader)(module) class IResourceProvider: - """An object that provides access to package resources""" - def get_resource_filename(manager,resource_name): + def get_resource_filename(manager, resource_name): """Return a true filesystem path for `resource_name` `manager` must be an ``IResourceManager``""" - def get_resource_stream(manager,resource_name): + def get_resource_stream(manager, resource_name): """Return a readable file-like object for `resource_name` `manager` must be an ``IResourceManager``""" - def get_resource_string(manager,resource_name): + def get_resource_string(manager, resource_name): """Return a string containing the contents of `resource_name` `manager` must be an ``IResourceManager``""" @@ -68,18 +73,11 @@ """The named metadata resource as a string""" def get_metadata_lines(name): - """The named metadata resource as a filtered list of stripped lines""" - + """The named metadata resource as a filtered iterator of stripped lines""" # XXX list_resources? glob_resources? - - - - - - class ResourceManager: """Manage resource extraction and packages""" @@ -88,38 +86,21 @@ def __init__(self): self.cached_files = [] - def resource_exists(self,package_name,resource_name): + def resource_exists(self, package_name, resource_name): """Does the named resource exist in the named package?""" - return get_provider(package_name).has_resource(self,resource_name) + return get_provider(package_name).has_resource(self, resource_name) - def resource_filename(self,package_name,resource_name): + def resource_filename(self, package_name, resource_name): """Return a true filesystem path for specified resource""" - return get_provider(package_name).get_resource_filename(self,resource_name) + return get_provider(package_name).get_resource_filename(self, resource_name) - def resource_stream(self,package_name,resource_name): + def resource_stream(self, package_name, resource_name): """Return a readable file-like object for specified resource""" - return get_provider(package_name).get_resource_stream(self,resource_name) + return get_provider(package_name).get_resource_stream(self, resource_name) - def resource_string(self,package_name,resource_name): + def resource_string(self, package_name, resource_name): """Return specified resource as a string""" - return get_provider(package_name).get_resource_string(self,resource_name) - - - - - - - - - - - - - - - - - + return get_provider(package_name).get_resource_string(self, resource_name) def get_cache_path(self, archive_name, names=()): """Return absolute location in cache for `archive_name` and `names` @@ -141,27 +122,22 @@ self.cached_files.append(target_path) return target_path - - def require(self,requirement,path=None): + def require(self, requirement, path=None): """Ensure a distribution matching `requirement` is on ``sys.path`` The `requirement` and `path` arguments are the same as for the ``iter_distributions()`` method, but `requirement` is not optional for `require`, since you must specify the desired distribution name. """ - for dist in self.iter_distributions(requirement,path): + for dist in self.iter_distributions(requirement, path): dist.require() return else: - pass #raise ImportError( - # "No distributions found matching "+repr(requirement) + pass + #raise ImportError( + # "No distributions found matching " + repr(requirement) #) - - - - - # XXX Not yet implemented def postprocess(self, filename): @@ -174,10 +150,10 @@ extracting a compressed resource. They should not call it on resources that are already in the filesystem. """ - # print "postprocessing",filename # XXX - + # XXX + # print "postprocessing", filename - def iter_distributions(self,requirement=None,path=None): + def iter_distributions(self, requirement=None, path=None): """Iterate over distributions in `path` matching `requirement` The `path` is a sequence of ``sys.path`` items. If not supplied, @@ -186,22 +162,8 @@ The `requirement` is an optional string specifying the name of the desired distribution. """ - return () # XXX - - - - - - - - - - - - - - - + # XXX + return () def set_extraction_path(self, path): """Set the base path where resources will be extracted to, if needed. @@ -236,12 +198,7 @@ directory used for extractions. """ # XXX - - - - - - + pass class DefaultProvider: @@ -249,166 +206,152 @@ egg_info = None - def __init__(self,module): + def __init__(self, module): self.module = module - self.loader = getattr(module,'__loader__',None) + self.loader = getattr(module, '__loader__',None) self.module_path = os.path.dirname(module.__file__) - def get_resource_filename(self,manager,resource_name): + def get_resource_filename(self, manager, resource_name): return self._fn(resource_name) - def get_resource_stream(self,manager,resource_name): - return open(self._fn(resource_name),'rb') + def get_resource_stream(self, manager, resource_name): + return open(self._fn(resource_name), 'rb') - def get_resource_string(manager,resource_name): + def get_resource_string(self, manager, resource_name): return self._get(self._fn(resource_name)) - def has_resource(self,resource_name): + def has_resource(self, resource_name): return self._has(self._fn(resource_name)) - def has_metadata(self,name): + def has_metadata(self, name): if not self.egg_info: raise NotImplementedError("Only .egg supports metadata") - return self._has(os.path.join(self.egg_info,*name.split('/'))) + return self._has(os.path.join(self.egg_info, *name.split('/'))) - def get_metadata(self,name): + def get_metadata(self, name): if not self.egg_info: raise NotImplementedError("Only .egg supports metadata") - return self._get(os.path.join(self.egg_info,*name.split('/'))) - - def get_metadata_lines(self,name): - return [ - line.strip() for line in self.get_metadata(name).splitlines() - if line.strip() - ] - - + return self._get(os.path.join(self.egg_info, *name.split('/'))) + def get_metadata_lines(self, name): + for line in self.get_metadata(name).splitlines(): + line = line.strip() + if line: + yield line - def _has(self,path): + def _has(self, path): return os.path.exists(path) - def _get(self,path): - stream = open(path,'rb') + def _get(self, path): + stream = open(path, 'rb') try: return stream.read() finally: stream.close() - def _fn(self,resource_name): + def _fn(self, resource_name): return os.path.join(self.module_path, *resource_name.split('/')) register_loader_type(type(None), DefaultProvider) - class NullProvider(DefaultProvider): """Try to implement resource support for arbitrary PEP 302 loaders""" - def _has(self,path): + def _has(self, path): raise NotImplementedError( "Can't perform this operation for unregistered loader type" ) - def _get(self,path): - if hasattr(self.loader, 'get_data'): - return self.loader.get_data(path) - raise NotImplementedError( - "Can't perform this operation for loaders without 'get_data()'" - ) + def _get(self, path): + get_data = getattr(self.loader, 'get_data', None) + if get_data is None: + raise NotImplementedError( + "Can't perform this operation for loaders without 'get_data()'" + ) + return get_data(path) register_loader_type(object, NullProvider) - - - - class ZipProvider(DefaultProvider): """Resource support for zips and eggs""" egg_name = None - eagers = None + eagers = None - def __init__(self,module): + def __init__(self, module): self.module = module self.loader = module.__loader__ self.zipinfo = zipimport._zip_directory_cache[self.loader.archive] - self.zip_pre = self.loader.archive+os.sep + self.zip_pre = self.loader.archive + os.sep path = self.module_path = os.path.dirname(module.__file__) old = None self.prefix = [] - while path!=old: + while path != old: if path.lower().endswith('.egg'): self.egg_name = os.path.basename(path) - self.egg_info = os.path.join(path,'EGG-INFO') + self.egg_info = os.path.join(path, 'EGG-INFO') break old = path path, base = os.path.split(path) self.prefix.append(base) - def _short_name(self,path): + def _short_name(self, path): if path.startswith(self.zip_pre): return path[len(self.zip_pre):] return path - def _has(self,path): + def _has(self, path): return self._short_name(path) in self.zipinfo - def _get(self,path): + def _get(self, path): return self.loader.get_data(path) def get_resource_stream(self, manager, resource_name): from cStringIO import StringIO return StringIO(self.get_resource_string(manager, resource_name)) - - - def _extract_resource(self,manager,resource_name): + def _extract_resource(self, manager, resource_name): parts = resource_name.split('/') zip_path = os.path.join(self.module_path, *parts) - zip_stat = self.zipinfo[os.path.join(*self.prefix+parts)] - t,d,size = zip_stat[5],zip_stat[6],zip_stat[3] + zip_stat = self.zipinfo[os.path.join(*(self.prefix + parts))] + t, d, size = zip_stat[5], zip_stat[6], zip_stat[3] date_time = ( - (d>>9)+1980, (d>>5)&0xF, d&0x1F, (t&0xFFFF)>>11, (t>>5)&0x3F, - (t&0x1F) * 2, 0, 0, -1 + (d >> 9) + 1980, (d >> 5) & 0xF, d & 0x1F, + (t & 0xFFFF) >> 11, (t >> 5) & 0x3F, + (t & 0x1F) * 2, 0, 0, -1 ) timestamp = time.mktime(date_time) real_path = manager.get_cache_path(self.egg_name, self.prefix+parts) if os.path.isfile(real_path): stat = os.stat(real_path) - if stat.st_size==size and stat.st_mtime==timestamp: + if stat.st_size == size and stat.st_mtime == timestamp: # size and stamp match, don't bother extracting return real_path # print "extracting", zip_path data = self.loader.get_data(zip_path) - open(real_path,'wb').write(data) - os.utime(real_path,(timestamp,timestamp)) + open(real_path, 'wb').write(data) + os.utime(real_path, (timestamp, timestamp)) manager.postprocess(real_path) return real_path def _get_eager_resources(self): if self.eagers is None: eagers = [] - for name in 'native_libs.txt', 'eager_resources.txt': + for name in ('native_libs.txt', 'eager_resources.txt'): if self.has_metadata(name): eagers.extend(self.get_metadata_lines(name)) self.eagers = eagers return self.eagers - - - - - - - def get_resource_filename(self,manager,resource_name): + def get_resource_filename(self, manager, resource_name): if not self.egg_name: raise NotImplementedError( "resource_filename() only supported for .egg, not .zip" @@ -418,47 +361,25 @@ eagers = self._get_eager_resources() if resource_name in eagers: for name in eagers: - self._extract_resource(manager,name) + self._extract_resource(manager, name) - return self._extract_resource(manager,resource_name) + return self._extract_resource(manager, resource_name) register_loader_type(zipimport.zipimporter, ZipProvider) - - - - - - - - - - - - - - - - - - - - - - - def _get_mro(cls): """Get an mro for a type or classic class""" - if not isinstance(cls,type): - class cls(cls,object): pass + if not isinstance(cls, type): + cls = type('', (cls, object), {}) return cls.__mro__[1:] return cls.__mro__ -def _find_adapter(registry,ob): + +def _find_adapter(registry, ob): """Return an adapter factory for `ob` from `registry`""" - for t in _get_mro(getattr(ob,'__class__',type(ob))): + for t in _get_mro(getattr(ob, '__class__', type(ob))): if t in registry: return registry[t] @@ -469,24 +390,12 @@ os.makedirs(dirname) - # Set up global resource manager _manager = ResourceManager() -for name in dir(_manager): - if not name.startswith('_'): - globals()[name] = getattr(_manager,name) - - - - - - - - - - - - - +def _initialize(g): + for name in dir(_manager): + if not name.startswith('_'): + g[name] = getattr(_manager, name) +_initialize(globals()) From etrepum at users.sourceforge.net Thu Mar 24 20:26:56 2005 From: etrepum at users.sourceforge.net (etrepum@users.sourceforge.net) Date: Thu Mar 24 20:26:58 2005 Subject: [Python-checkins] python/nondist/sandbox/setuptools pkg_resources.py, 1.2, 1.3 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setuptools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22045 Modified Files: pkg_resources.py Log Message: import StringIO at module level Index: pkg_resources.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/pkg_resources.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- pkg_resources.py 24 Mar 2005 19:21:53 -0000 1.2 +++ pkg_resources.py 24 Mar 2005 19:26:54 -0000 1.3 @@ -18,6 +18,10 @@ import os import time import zipimport +try: + from cStringIO import StringIO +except ImportError: + from StringIO import StringIO __all__ = [ 'register_loader_type', 'get_provider', 'IResourceProvider', @@ -312,7 +316,6 @@ return self.loader.get_data(path) def get_resource_stream(self, manager, resource_name): - from cStringIO import StringIO return StringIO(self.get_resource_string(manager, resource_name)) def _extract_resource(self, manager, resource_name): From loewis at users.sourceforge.net Thu Mar 24 20:40:59 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Thu Mar 24 20:41:03 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils/command upload.py, 1.6, 1.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30502 Modified Files: upload.py Log Message: Add missing socket import Index: upload.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/upload.py,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- upload.py 23 Mar 2005 18:54:36 -0000 1.6 +++ upload.py 24 Mar 2005 19:40:57 -0000 1.7 @@ -8,6 +8,7 @@ from distutils import log from md5 import md5 import os +import socket import platform import ConfigParser import httplib From etrepum at users.sourceforge.net Thu Mar 24 21:29:27 2005 From: etrepum at users.sourceforge.net (etrepum@users.sourceforge.net) Date: Thu Mar 24 21:29:31 2005 Subject: [Python-checkins] python/nondist/sandbox/setuptools pkg_resources.py, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/nondist/sandbox/setuptools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26249 Modified Files: pkg_resources.py Log Message: Specify and implement # comments in get_metadata_lines A few more PEP 8 formatting fixes for pkg_resources Index: pkg_resources.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/setuptools/pkg_resources.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- pkg_resources.py 24 Mar 2005 19:26:54 -0000 1.3 +++ pkg_resources.py 24 Mar 2005 20:29:19 -0000 1.4 @@ -77,7 +77,9 @@ """The named metadata resource as a string""" def get_metadata_lines(name): - """The named metadata resource as a filtered iterator of stripped lines""" + """The named metadata resource as a filtered iterator of + stripped (of # comments and whitespace) lines + """ # XXX list_resources? glob_resources? @@ -96,15 +98,18 @@ def resource_filename(self, package_name, resource_name): """Return a true filesystem path for specified resource""" - return get_provider(package_name).get_resource_filename(self, resource_name) + return get_provider(package_name).get_resource_filename(self, + resource_name) def resource_stream(self, package_name, resource_name): """Return a readable file-like object for specified resource""" - return get_provider(package_name).get_resource_stream(self, resource_name) + return get_provider(package_name).get_resource_stream(self, + resource_name) def resource_string(self, package_name, resource_name): """Return specified resource as a string""" - return get_provider(package_name).get_resource_string(self, resource_name) + return get_provider(package_name).get_resource_string(self, + resource_name) def get_cache_path(self, archive_name, names=()): """Return absolute location in cache for `archive_name` and `names` @@ -212,7 +217,7 @@ def __init__(self, module): self.module = module - self.loader = getattr(module, '__loader__',None) + self.loader = getattr(module, '__loader__', None) self.module_path = os.path.dirname(module.__file__) def get_resource_filename(self, manager, resource_name): @@ -240,7 +245,7 @@ def get_metadata_lines(self, name): for line in self.get_metadata(name).splitlines(): line = line.strip() - if line: + if not line.startswith('#'): yield line def _has(self, path): @@ -329,7 +334,7 @@ (t & 0x1F) * 2, 0, 0, -1 ) timestamp = time.mktime(date_time) - real_path = manager.get_cache_path(self.egg_name, self.prefix+parts) + real_path = manager.get_cache_path(self.egg_name, self.prefix + parts) if os.path.isfile(real_path): stat = os.stat(real_path) From rhettinger at users.sourceforge.net Sun Mar 27 05:04:56 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Mar 27 05:04:59 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_weakref.py, 1.42, 1.43 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6538/Lib/test Modified Files: test_weakref.py Log Message: SF bug #1770766: weakref proxy has incorrect __nonzero__ behavior. Index: test_weakref.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_weakref.py,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- test_weakref.py 8 Jul 2004 01:22:31 -0000 1.42 +++ test_weakref.py 27 Mar 2005 03:04:53 -0000 1.43 @@ -271,6 +271,12 @@ del f[0] self.assertEqual(f.result, 0) + def test_proxy_bool(self): + # Test clearing of SF bug #1170766 + class List(list): pass + lyst = List() + self.assertEqual(bool(weakref.proxy(lyst)), bool(lyst)) + def test_getweakrefcount(self): o = C() ref1 = weakref.ref(o) From rhettinger at users.sourceforge.net Sun Mar 27 05:04:57 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Mar 27 05:05:02 2005 Subject: [Python-checkins] python/dist/src/Objects weakrefobject.c, 1.20, 1.21 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6538/Objects Modified Files: weakrefobject.c Log Message: SF bug #1770766: weakref proxy has incorrect __nonzero__ behavior. Index: weakrefobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/weakrefobject.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- weakrefobject.c 30 Oct 2004 23:09:22 -0000 1.20 +++ weakrefobject.c 27 Mar 2005 03:04:54 -0000 1.21 @@ -505,11 +505,7 @@ PyObject *o = PyWeakref_GET_OBJECT(proxy); if (!proxy_checkref(proxy)) 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); - else - return 1; + return PyObject_IsTrue(o); } static void From rhettinger at users.sourceforge.net Sun Mar 27 12:47:41 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Mar 27 12:47:45 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_decimal.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-serv11467/Lib/test Modified Files: test_decimal.py Log Message: * Fix decimal's handling of foreign types. Now returns NotImplemented instead of raising a TypeError. Allows other types to successfully implement __radd__() style methods. * Remove future division import from test suite. * Remove test suite's shadowing of __builtin__.dir(). Index: test_decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decimal.py,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- test_decimal.py 15 Mar 2005 04:59:17 -0000 1.17 +++ test_decimal.py 27 Mar 2005 10:47:39 -0000 1.18 @@ -24,8 +24,6 @@ with the corresponding argument. """ -from __future__ import division - import unittest import glob import os, sys @@ -54,9 +52,9 @@ else: file = __file__ testdir = os.path.dirname(file) or os.curdir -dir = testdir + os.sep + TESTDATADIR + os.sep +directory = testdir + os.sep + TESTDATADIR + os.sep -skip_expected = not os.path.isdir(dir) +skip_expected = not os.path.isdir(directory) # Make sure it actually raises errors when not expected and caught in flags # Slower, since it runs some things several times. @@ -109,7 +107,6 @@ Changed for unittest. """ def setUp(self): - global dir self.context = Context() for key in DefaultContext.traps.keys(): DefaultContext.traps[key] = 1 @@ -302,11 +299,11 @@ # Dynamically build custom test definition for each file in the test # directory and add the definitions to the DecimalTest class. This # procedure insures that new files do not get skipped. -for filename in os.listdir(dir): +for filename in os.listdir(directory): if '.decTest' not in filename: continue head, tail = filename.split('.') - tester = lambda self, f=filename: self.eval_file(dir + f) + tester = lambda self, f=filename: self.eval_file(directory + f) setattr(DecimalTest, 'test_' + head, tester) del filename, head, tail, tester @@ -476,6 +473,52 @@ def test_implicit_from_Decimal(self): self.assertEqual(Decimal(5) + Decimal(45), Decimal(50)) + def test_rop(self): + # Allow other classes to be trained to interact with Decimals + class E: + def __divmod__(self, other): + return 'divmod ' + str(other) + def __rdivmod__(self, other): + return str(other) + ' rdivmod' + def __lt__(self, other): + return 'lt ' + str(other) + def __gt__(self, other): + return 'gt ' + str(other) + def __le__(self, other): + return 'le ' + str(other) + def __ge__(self, other): + return 'ge ' + str(other) + def __eq__(self, other): + return 'eq ' + str(other) + def __ne__(self, other): + return 'ne ' + str(other) + + self.assertEqual(divmod(E(), Decimal(10)), 'divmod 10') + self.assertEqual(divmod(Decimal(10), E()), '10 rdivmod') + self.assertEqual(eval('Decimal(10) < E()'), 'gt 10') + self.assertEqual(eval('Decimal(10) > E()'), 'lt 10') + self.assertEqual(eval('Decimal(10) <= E()'), 'ge 10') + self.assertEqual(eval('Decimal(10) >= E()'), 'le 10') + self.assertEqual(eval('Decimal(10) == E()'), 'eq 10') + self.assertEqual(eval('Decimal(10) != E()'), 'ne 10') + + # insert operator methods and then exercise them + for sym, lop, rop in ( + ('+', '__add__', '__radd__'), + ('-', '__sub__', '__rsub__'), + ('*', '__mul__', '__rmul__'), + ('/', '__div__', '__rdiv__'), + ('%', '__mod__', '__rmod__'), + ('//', '__floordiv__', '__rfloordiv__'), + ('**', '__pow__', '__rpow__'), + ): + + setattr(E, lop, lambda self, other: 'str' + lop + str(other)) + setattr(E, rop, lambda self, other: str(other) + rop + 'str') + self.assertEqual(eval('E()' + sym + 'Decimal(10)'), + 'str' + lop + '10') + self.assertEqual(eval('Decimal(10)' + sym + 'E()'), + '10' + rop + 'str') class DecimalArithmeticOperatorsTest(unittest.TestCase): '''Unit tests for all arithmetic operators, binary and unary.''' From rhettinger at users.sourceforge.net Sun Mar 27 12:47:41 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Mar 27 12:47:46 2005 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.35,1.36 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11467/Lib Modified Files: decimal.py Log Message: * Fix decimal's handling of foreign types. Now returns NotImplemented instead of raising a TypeError. Allows other types to successfully implement __radd__() style methods. * Remove future division import from test suite. * Remove test suite's shadowing of __builtin__.dir(). Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- decimal.py 15 Mar 2005 04:59:16 -0000 1.35 +++ decimal.py 27 Mar 2005 10:47:38 -0000 1.36 @@ -645,6 +645,8 @@ def __cmp__(self, other, context=None): other = _convert_other(other) + if other is NotImplemented: + return other if self._is_special or other._is_special: ans = self._check_nans(other, context) @@ -696,12 +698,12 @@ def __eq__(self, other): if not isinstance(other, (Decimal, int, long)): - return False + return NotImplemented return self.__cmp__(other) == 0 def __ne__(self, other): if not isinstance(other, (Decimal, int, long)): - return True + return NotImplemented return self.__cmp__(other) != 0 def compare(self, other, context=None): @@ -714,6 +716,8 @@ Like __cmp__, but returns Decimal instances. """ other = _convert_other(other) + if other is NotImplemented: + return other #compare(NaN, NaN) = NaN if (self._is_special or other and other._is_special): @@ -919,6 +923,8 @@ -INF + INF (or the reverse) cause InvalidOperation errors. """ other = _convert_other(other) + if other is NotImplemented: + return other if context is None: context = getcontext() @@ -1006,6 +1012,8 @@ def __sub__(self, other, context=None): """Return self + (-other)""" other = _convert_other(other) + if other is NotImplemented: + return other if self._is_special or other._is_special: ans = self._check_nans(other, context=context) @@ -1023,6 +1031,8 @@ def __rsub__(self, other, context=None): """Return other + (-self)""" other = _convert_other(other) + if other is NotImplemented: + return other tmp = Decimal(self) tmp._sign = 1 - tmp._sign @@ -1068,6 +1078,8 @@ (+-) INF * 0 (or its reverse) raise InvalidOperation. """ other = _convert_other(other) + if other is NotImplemented: + return other if context is None: context = getcontext() @@ -1140,6 +1152,10 @@ computing the other value are not raised. """ other = _convert_other(other) + if other is NotImplemented: + if divmod in (0, 1): + return NotImplemented + return (NotImplemented, NotImplemented) if context is None: context = getcontext() @@ -1292,6 +1308,8 @@ def __rdiv__(self, other, context=None): """Swaps self/other and returns __div__.""" other = _convert_other(other) + if other is NotImplemented: + return other return other.__div__(self, context=context) __rtruediv__ = __rdiv__ @@ -1304,6 +1322,8 @@ def __rdivmod__(self, other, context=None): """Swaps self/other and returns __divmod__.""" other = _convert_other(other) + if other is NotImplemented: + return other return other.__divmod__(self, context=context) def __mod__(self, other, context=None): @@ -1311,6 +1331,8 @@ self % other """ other = _convert_other(other) + if other is NotImplemented: + return other if self._is_special or other._is_special: ans = self._check_nans(other, context) @@ -1325,6 +1347,8 @@ def __rmod__(self, other, context=None): """Swaps self/other and returns __mod__.""" other = _convert_other(other) + if other is NotImplemented: + return other return other.__mod__(self, context=context) def remainder_near(self, other, context=None): @@ -1332,6 +1356,8 @@ Remainder nearest to 0- abs(remainder-near) <= other/2 """ other = _convert_other(other) + if other is NotImplemented: + return other if self._is_special or other._is_special: ans = self._check_nans(other, context) @@ -1411,6 +1437,8 @@ def __rfloordiv__(self, other, context=None): """Swaps self/other and returns __floordiv__.""" other = _convert_other(other) + if other is NotImplemented: + return other return other.__floordiv__(self, context=context) def __float__(self): @@ -1661,6 +1689,8 @@ If modulo is None (default), don't take it mod modulo. """ n = _convert_other(n) + if n is NotImplemented: + return n if context is None: context = getcontext() @@ -1747,6 +1777,8 @@ def __rpow__(self, other, context=None): """Swaps self/other and returns __pow__.""" other = _convert_other(other) + if other is NotImplemented: + return other return other.__pow__(self, context=context) def normalize(self, context=None): @@ -2001,6 +2033,8 @@ NaN (and signals if one is sNaN). Also rounds. """ other = _convert_other(other) + if other is NotImplemented: + return other if self._is_special or other._is_special: # if one operand is a quiet NaN and the other is number, then the @@ -2048,6 +2082,8 @@ NaN (and signals if one is sNaN). Also rounds. """ other = _convert_other(other) + if other is NotImplemented: + return other if self._is_special or other._is_special: # if one operand is a quiet NaN and the other is number, then the @@ -2874,8 +2910,7 @@ return other if isinstance(other, (int, long)): return Decimal(other) - - raise TypeError, "You can interact Decimal only with int, long or Decimal data types." + return NotImplemented _infinity_map = { 'inf' : 1, From rhettinger at users.sourceforge.net Sun Mar 27 12:47:41 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Mar 27 12:47:47 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1276,1.1277 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11467/Misc Modified Files: NEWS Log Message: * Fix decimal's handling of foreign types. Now returns NotImplemented instead of raising a TypeError. Allows other types to successfully implement __radd__() style methods. * Remove future division import from test suite. * Remove test suite's shadowing of __builtin__.dir(). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1276 retrieving revision 1.1277 diff -u -d -r1.1276 -r1.1277 --- NEWS 21 Mar 2005 20:56:35 -0000 1.1276 +++ NEWS 27 Mar 2005 10:47:36 -0000 1.1277 @@ -91,6 +91,11 @@ - distutils.commands.upload was added to support uploading distribution files to PyPI. +- decimal operator and comparison methods now return NotImplemented + instead of raising a TypeError when interacting with other types. This + allows other classes to implement __radd__ style methods and have them + work as expected. + - Bug #1163325: Decimal infinities failed to hash. Attempting to hash a NaN raised an InvalidOperation instead of a TypeError. From rhettinger at users.sourceforge.net Sun Mar 27 12:55:46 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Mar 27 12:55:48 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.40, 1.1193.2.41 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16884/Misc Modified Files: Tag: release24-maint NEWS Log Message: - Fixed decimal operator and comparison methods to return NotImplemented instead of raising a TypeError when interacting with other types. Allows other classes to successfully implement __radd__ style methods. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.40 retrieving revision 1.1193.2.41 diff -u -d -r1.1193.2.40 -r1.1193.2.41 --- NEWS 18 Mar 2005 10:59:04 -0000 1.1193.2.40 +++ NEWS 27 Mar 2005 10:55:26 -0000 1.1193.2.41 @@ -12,6 +12,10 @@ Library ------- +- Fixed decimal operator and comparison methods to return NotImplemented + instead of raising a TypeError when interacting with other types. + Allows other classes to successfully implement __radd__ style methods. + - Bug #1163325: Decimal infinities failed to hash. Attempting to hash a NaN raised an InvalidOperation instead of a TypeError. From rhettinger at users.sourceforge.net Sun Mar 27 12:55:46 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Mar 27 12:55:50 2005 Subject: [Python-checkins] python/dist/src/Lib decimal.py,1.31.2.2,1.31.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16884/Lib Modified Files: Tag: release24-maint decimal.py Log Message: - Fixed decimal operator and comparison methods to return NotImplemented instead of raising a TypeError when interacting with other types. Allows other classes to successfully implement __radd__ style methods. Index: decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/decimal.py,v retrieving revision 1.31.2.2 retrieving revision 1.31.2.3 diff -u -d -r1.31.2.2 -r1.31.2.3 --- decimal.py 15 Mar 2005 23:36:19 -0000 1.31.2.2 +++ decimal.py 27 Mar 2005 10:55:26 -0000 1.31.2.3 @@ -645,6 +645,8 @@ def __cmp__(self, other, context=None): other = _convert_other(other) + if other is NotImplemented: + return other if self._is_special or other._is_special: ans = self._check_nans(other, context) @@ -696,12 +698,12 @@ def __eq__(self, other): if not isinstance(other, (Decimal, int, long)): - return False + return NotImplemented return self.__cmp__(other) == 0 def __ne__(self, other): if not isinstance(other, (Decimal, int, long)): - return True + return NotImplemented return self.__cmp__(other) != 0 def compare(self, other, context=None): @@ -714,6 +716,8 @@ Like __cmp__, but returns Decimal instances. """ other = _convert_other(other) + if other is NotImplemented: + return other #compare(NaN, NaN) = NaN if (self._is_special or other and other._is_special): @@ -919,6 +923,8 @@ -INF + INF (or the reverse) cause InvalidOperation errors. """ other = _convert_other(other) + if other is NotImplemented: + return other if context is None: context = getcontext() @@ -1006,6 +1012,8 @@ def __sub__(self, other, context=None): """Return self + (-other)""" other = _convert_other(other) + if other is NotImplemented: + return other if self._is_special or other._is_special: ans = self._check_nans(other, context=context) @@ -1023,6 +1031,8 @@ def __rsub__(self, other, context=None): """Return other + (-self)""" other = _convert_other(other) + if other is NotImplemented: + return other tmp = Decimal(self) tmp._sign = 1 - tmp._sign @@ -1068,6 +1078,8 @@ (+-) INF * 0 (or its reverse) raise InvalidOperation. """ other = _convert_other(other) + if other is NotImplemented: + return other if context is None: context = getcontext() @@ -1140,6 +1152,10 @@ computing the other value are not raised. """ other = _convert_other(other) + if other is NotImplemented: + if divmod in (0, 1): + return NotImplemented + return (NotImplemented, NotImplemented) if context is None: context = getcontext() @@ -1292,6 +1308,8 @@ def __rdiv__(self, other, context=None): """Swaps self/other and returns __div__.""" other = _convert_other(other) + if other is NotImplemented: + return other return other.__div__(self, context=context) __rtruediv__ = __rdiv__ @@ -1304,6 +1322,8 @@ def __rdivmod__(self, other, context=None): """Swaps self/other and returns __divmod__.""" other = _convert_other(other) + if other is NotImplemented: + return other return other.__divmod__(self, context=context) def __mod__(self, other, context=None): @@ -1311,6 +1331,8 @@ self % other """ other = _convert_other(other) + if other is NotImplemented: + return other if self._is_special or other._is_special: ans = self._check_nans(other, context) @@ -1325,6 +1347,8 @@ def __rmod__(self, other, context=None): """Swaps self/other and returns __mod__.""" other = _convert_other(other) + if other is NotImplemented: + return other return other.__mod__(self, context=context) def remainder_near(self, other, context=None): @@ -1332,6 +1356,8 @@ Remainder nearest to 0- abs(remainder-near) <= other/2 """ other = _convert_other(other) + if other is NotImplemented: + return other if self._is_special or other._is_special: ans = self._check_nans(other, context) @@ -1411,6 +1437,8 @@ def __rfloordiv__(self, other, context=None): """Swaps self/other and returns __floordiv__.""" other = _convert_other(other) + if other is NotImplemented: + return other return other.__floordiv__(self, context=context) def __float__(self): @@ -1661,6 +1689,8 @@ If modulo is None (default), don't take it mod modulo. """ n = _convert_other(n) + if n is NotImplemented: + return n if context is None: context = getcontext() @@ -1747,6 +1777,8 @@ def __rpow__(self, other, context=None): """Swaps self/other and returns __pow__.""" other = _convert_other(other) + if other is NotImplemented: + return other return other.__pow__(self, context=context) def normalize(self, context=None): @@ -2001,6 +2033,8 @@ NaN (and signals if one is sNaN). Also rounds. """ other = _convert_other(other) + if other is NotImplemented: + return other if self._is_special or other._is_special: # if one operand is a quiet NaN and the other is number, then the @@ -2048,6 +2082,8 @@ NaN (and signals if one is sNaN). Also rounds. """ other = _convert_other(other) + if other is NotImplemented: + return other if self._is_special or other._is_special: # if one operand is a quiet NaN and the other is number, then the @@ -2874,8 +2910,7 @@ return other if isinstance(other, (int, long)): return Decimal(other) - - raise TypeError, "You can interact Decimal only with int, long or Decimal data types." + return NotImplemented _infinity_map = { 'inf' : 1, From rhettinger at users.sourceforge.net Sun Mar 27 12:55:46 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Mar 27 12:55:51 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_decimal.py, 1.15.2.2, 1.15.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16884/Lib/test Modified Files: Tag: release24-maint test_decimal.py Log Message: - Fixed decimal operator and comparison methods to return NotImplemented instead of raising a TypeError when interacting with other types. Allows other classes to successfully implement __radd__ style methods. Index: test_decimal.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_decimal.py,v retrieving revision 1.15.2.2 retrieving revision 1.15.2.3 diff -u -d -r1.15.2.2 -r1.15.2.3 --- test_decimal.py 15 Mar 2005 23:36:19 -0000 1.15.2.2 +++ test_decimal.py 27 Mar 2005 10:55:27 -0000 1.15.2.3 @@ -24,8 +24,6 @@ with the corresponding argument. """ -from __future__ import division - import unittest import glob import os, sys @@ -54,9 +52,9 @@ else: file = __file__ testdir = os.path.dirname(file) or os.curdir -dir = testdir + os.sep + TESTDATADIR + os.sep +directory = testdir + os.sep + TESTDATADIR + os.sep -skip_expected = not os.path.isdir(dir) +skip_expected = not os.path.isdir(directory) # Make sure it actually raises errors when not expected and caught in flags # Slower, since it runs some things several times. @@ -109,7 +107,6 @@ Changed for unittest. """ def setUp(self): - global dir self.context = Context() for key in DefaultContext.traps.keys(): DefaultContext.traps[key] = 1 @@ -302,11 +299,11 @@ # Dynamically build custom test definition for each file in the test # directory and add the definitions to the DecimalTest class. This # procedure insures that new files do not get skipped. -for filename in os.listdir(dir): +for filename in os.listdir(directory): if '.decTest' not in filename: continue head, tail = filename.split('.') - tester = lambda self, f=filename: self.eval_file(dir + f) + tester = lambda self, f=filename: self.eval_file(directory + f) setattr(DecimalTest, 'test_' + head, tester) del filename, head, tail, tester @@ -476,6 +473,52 @@ def test_implicit_from_Decimal(self): self.assertEqual(Decimal(5) + Decimal(45), Decimal(50)) + def test_rop(self): + # Allow other classes to be trained to interact with Decimals + class E: + def __divmod__(self, other): + return 'divmod ' + str(other) + def __rdivmod__(self, other): + return str(other) + ' rdivmod' + def __lt__(self, other): + return 'lt ' + str(other) + def __gt__(self, other): + return 'gt ' + str(other) + def __le__(self, other): + return 'le ' + str(other) + def __ge__(self, other): + return 'ge ' + str(other) + def __eq__(self, other): + return 'eq ' + str(other) + def __ne__(self, other): + return 'ne ' + str(other) + + self.assertEqual(divmod(E(), Decimal(10)), 'divmod 10') + self.assertEqual(divmod(Decimal(10), E()), '10 rdivmod') + self.assertEqual(eval('Decimal(10) < E()'), 'gt 10') + self.assertEqual(eval('Decimal(10) > E()'), 'lt 10') + self.assertEqual(eval('Decimal(10) <= E()'), 'ge 10') + self.assertEqual(eval('Decimal(10) >= E()'), 'le 10') + self.assertEqual(eval('Decimal(10) == E()'), 'eq 10') + self.assertEqual(eval('Decimal(10) != E()'), 'ne 10') + + # insert operator methods and then exercise them + for sym, lop, rop in ( + ('+', '__add__', '__radd__'), + ('-', '__sub__', '__rsub__'), + ('*', '__mul__', '__rmul__'), + ('/', '__div__', '__rdiv__'), + ('%', '__mod__', '__rmod__'), + ('//', '__floordiv__', '__rfloordiv__'), + ('**', '__pow__', '__rpow__'), + ): + + setattr(E, lop, lambda self, other: 'str' + lop + str(other)) + setattr(E, rop, lambda self, other: str(other) + rop + 'str') + self.assertEqual(eval('E()' + sym + 'Decimal(10)'), + 'str' + lop + '10') + self.assertEqual(eval('Decimal(10)' + sym + 'E()'), + '10' + rop + 'str') class DecimalArithmeticOperatorsTest(unittest.TestCase): '''Unit tests for all arithmetic operators, binary and unary.''' From rhettinger at users.sourceforge.net Sun Mar 27 22:11:48 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Mar 27 22:11:54 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_itertools.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-serv17250/Lib/test Modified Files: test_itertools.py Log Message: SF patch #1171417: bug fix for islice() in docs Index: test_itertools.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_itertools.py,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- test_itertools.py 11 Mar 2005 22:17:30 -0000 1.38 +++ test_itertools.py 27 Mar 2005 20:11:44 -0000 1.39 @@ -265,6 +265,11 @@ self.assertEqual(list(islice(xrange(10), 2, None)), range(2, 10)) self.assertEqual(list(islice(xrange(10), 1, None, 2)), range(1, 10, 2)) + # Test number of items consumed SF #1171417 + it = iter(range(10)) + self.assertEqual(list(islice(it, 3)), range(3)) + self.assertEqual(list(it), range(3, 10)) + # Test invalid arguments self.assertRaises(TypeError, islice, xrange(10)) self.assertRaises(TypeError, islice, xrange(10), 1, 2, 3, 4) From rhettinger at users.sourceforge.net Sun Mar 27 22:11:48 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Mar 27 22:11:55 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libitertools.tex, 1.34, 1.35 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17250/Doc/lib Modified Files: libitertools.tex Log Message: SF patch #1171417: bug fix for islice() in docs Index: libitertools.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libitertools.tex,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- libitertools.tex 11 Mar 2005 22:17:29 -0000 1.34 +++ libitertools.tex 27 Mar 2005 20:11:43 -0000 1.35 @@ -250,16 +250,14 @@ third line). Equivalent to: \begin{verbatim} - def islice(iterable, *args): + def islice(iterable, *args): s = slice(*args) - next, stop, step = s.start or 0, s.stop, s.step or 1 - for cnt, element in enumerate(iterable): - if cnt < next: - continue - if stop is not None and cnt >= stop: - break - yield element - next += step + it = iter(xrange(s.start or 0, s.stop or sys.maxint, s.step or 1)) + nexti = it.next() + for i, element in enumerate(iterable): + if i == nexti: + yield element + nexti = it.next() \end{verbatim} If \var{start} is \code{None}, then iteration starts at zero. From rhettinger at users.sourceforge.net Sun Mar 27 22:16:51 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Mar 27 22:16:57 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libitertools.tex, 1.32, 1.32.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20488 Modified Files: Tag: release24-maint libitertools.tex Log Message: SF patch #1171417: bug fix for islice() in docs Index: libitertools.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libitertools.tex,v retrieving revision 1.32 retrieving revision 1.32.2.1 diff -u -d -r1.32 -r1.32.2.1 --- libitertools.tex 23 Sep 2004 07:27:39 -0000 1.32 +++ libitertools.tex 27 Mar 2005 20:16:49 -0000 1.32.2.1 @@ -252,14 +252,12 @@ \begin{verbatim} def islice(iterable, *args): s = slice(*args) - next, stop, step = s.start or 0, s.stop, s.step or 1 - for cnt, element in enumerate(iterable): - if cnt < next: - continue - if stop is not None and cnt >= stop: - break - yield element - next += step + it = iter(xrange(s.start or 0, s.stop or sys.maxint, s.step or 1)) + nexti = it.next() + for i, element in enumerate(iterable): + if i == nexti: + yield element + nexti = it.next() \end{verbatim} \end{funcdesc} From rhettinger at users.sourceforge.net Sun Mar 27 22:19:08 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Sun Mar 27 22:19:10 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libitertools.tex, 1.35, 1.36 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21985 Modified Files: libitertools.tex Log Message: Fix whitespace. Index: libitertools.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libitertools.tex,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- libitertools.tex 27 Mar 2005 20:11:43 -0000 1.35 +++ libitertools.tex 27 Mar 2005 20:19:05 -0000 1.36 @@ -250,7 +250,7 @@ third line). Equivalent to: \begin{verbatim} - def islice(iterable, *args): + def islice(iterable, *args): s = slice(*args) it = iter(xrange(s.start or 0, s.stop or sys.maxint, s.step or 1)) nexti = it.next() From tim_one at users.sourceforge.net Mon Mar 28 03:06:07 2005 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Mar 28 03:06:10 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils/command bdist_rpm.py, 1.50, 1.51 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22510/Lib/distutils/command Modified Files: bdist_rpm.py Log Message: Two lines in this file had unbalanced parentheses -- couldn't possibly work (SyntaxErrors at compile time). I slammed in what looked like the obvious fixes, but someone who understands this file should check my work. Index: bdist_rpm.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/bdist_rpm.py,v retrieving revision 1.50 retrieving revision 1.51 diff -u -d -r1.50 -r1.51 --- bdist_rpm.py 24 Mar 2005 07:00:05 -0000 1.50 +++ bdist_rpm.py 28 Mar 2005 01:05:48 -0000 1.51 @@ -361,12 +361,12 @@ assert len(rpms) == 1, \ "unexpected number of RPM files found: %s" % rpms dist_file = ('bdist_rpm', get_python_version(), - self._dist_path(rpms[0]) + self._dist_path(rpms[0])) self.distribution.dist_files.append(dist_file) self.move_file(rpms[0], self.dist_dir) if debuginfo: dist_file = ('bdist_rpm', get_python_version(), - self._dist_path(debuginfo[0]) + self._dist_path(debuginfo[0])) self.move_file(debuginfo[0], self.dist_dir) # run() From tim_one at users.sourceforge.net Mon Mar 28 03:08:05 2005 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Mar 28 03:08:08 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils versionpredicate.py, 1.3, 1.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23805/Lib/distutils Modified Files: versionpredicate.py Log Message: Whitespace normalization. Index: versionpredicate.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/versionpredicate.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- versionpredicate.py 22 Mar 2005 05:43:18 -0000 1.3 +++ versionpredicate.py 28 Mar 2005 01:08:03 -0000 1.4 @@ -101,10 +101,10 @@ versionPredicateStr = versionPredicateStr.strip() if not versionPredicateStr: - raise ValueError("empty package restriction") + raise ValueError("empty package restriction") match = re_validPackage.match(versionPredicateStr) if not match: - raise ValueError("bad package name in %r" % versionPredicateStr) + raise ValueError("bad package name in %r" % versionPredicateStr) self.name, paren = match.groups() paren = paren.strip() if paren: @@ -114,7 +114,7 @@ str = match.groups()[0] self.pred = [splitUp(aPred) for aPred in str.split(",")] if not self.pred: - raise ValueError("empty parenthesized list in %r" + raise ValueError("empty parenthesized list in %r" % versionPredicateStr) else: self.pred = [] From tim_one at users.sourceforge.net Mon Mar 28 03:08:05 2005 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Mar 28 03:08:09 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils/command upload.py, 1.7, 1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23805/Lib/distutils/command Modified Files: upload.py Log Message: Whitespace normalization. Index: upload.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/upload.py,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- upload.py 24 Mar 2005 19:40:57 -0000 1.7 +++ upload.py 28 Mar 2005 01:08:03 -0000 1.8 @@ -133,7 +133,7 @@ schema, netloc, url, params, query, fragments = \ urlparse.urlparse(self.repository) assert not params and not query and not fragments - if schema == 'http': + if schema == 'http': http = httplib.HTTPConnection(netloc) elif schema == 'https': http = httplib.HTTPSConnection(netloc) @@ -145,7 +145,7 @@ try: http.connect() http.putrequest("POST", url) - http.putheader('Content-type', + http.putheader('Content-type', 'multipart/form-data; boundary=%s'%boundary) http.putheader('Content-length', str(len(body))) http.putheader('Authorization', auth) @@ -157,11 +157,10 @@ r = http.getresponse() if r.status == 200: - self.announce('Server response (%s): %s' % (r.status, r.reason), + self.announce('Server response (%s): %s' % (r.status, r.reason), log.INFO) else: - self.announce('Upload failed (%s): %s' % (r.status, r.reason), + self.announce('Upload failed (%s): %s' % (r.status, r.reason), log.ERROR) if self.show_response: print '-'*75, r.read(), '-'*75 - From tim_one at users.sourceforge.net Mon Mar 28 03:08:05 2005 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Mar 28 03:08:11 2005 Subject: [Python-checkins] python/dist/src/Lib UserString.py, 1.24, 1.25 gzip.py, 1.43, 1.44 subprocess.py, 1.19, 1.20 tarfile.py, 1.27, 1.28 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23805/Lib Modified Files: UserString.py gzip.py subprocess.py tarfile.py Log Message: Whitespace normalization. Index: UserString.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/UserString.py,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- UserString.py 18 Feb 2005 13:22:43 -0000 1.24 +++ UserString.py 28 Mar 2005 01:08:02 -0000 1.25 @@ -147,12 +147,12 @@ raise TypeError, "unhashable type (it is mutable)" def __setitem__(self, index, sub): if index < 0: - index += len(self.data) + index += len(self.data) if index < 0 or index >= len(self.data): raise IndexError self.data = self.data[:index] + sub + self.data[index+1:] def __delitem__(self, index): if index < 0: - index += len(self.data) + index += len(self.data) if index < 0 or index >= len(self.data): raise IndexError self.data = self.data[:index] + self.data[index+1:] def __setslice__(self, start, end, sub): Index: gzip.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/gzip.py,v retrieving revision 1.43 retrieving revision 1.44 diff -u -d -r1.43 -r1.44 --- gzip.py 3 Mar 2005 08:35:21 -0000 1.43 +++ gzip.py 28 Mar 2005 01:08:02 -0000 1.44 @@ -333,8 +333,8 @@ def flush(self,zlib_mode=zlib.Z_SYNC_FLUSH): if self.mode == WRITE: - # Ensure the compressor's buffer is flushed - self.fileobj.write(self.compress.flush(zlib_mode)) + # Ensure the compressor's buffer is flushed + self.fileobj.write(self.compress.flush(zlib_mode)) self.fileobj.flush() def fileno(self): Index: subprocess.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/subprocess.py,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- subprocess.py 3 Mar 2005 21:10:23 -0000 1.19 +++ subprocess.py 28 Mar 2005 01:08:02 -0000 1.20 @@ -626,14 +626,14 @@ process to terminate. The optional input argument should be a string to be sent to the child process, or None, if no data should be sent to the child. - + communicate() returns a tuple (stdout, stderr).""" # Optimization: If we are only using one pipe, or no pipe at # all, using select() or threads is unnecessary. if [self.stdin, self.stdout, self.stderr].count(None) >= 2: - stdout = None - stderr = None + stdout = None + stderr = None if self.stdin: if input: self.stdin.write(input) @@ -644,7 +644,7 @@ stderr = self.stderr.read() self.wait() return (stdout, stderr) - + return self._communicate(input) Index: tarfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tarfile.py,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- tarfile.py 5 Mar 2005 12:47:42 -0000 1.27 +++ tarfile.py 28 Mar 2005 01:08:02 -0000 1.28 @@ -665,7 +665,7 @@ if not result: raise StopIteration return result - + #class ExFileObject #------------------ From tim_one at users.sourceforge.net Mon Mar 28 03:08:06 2005 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Mar 28 03:08:12 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils/tests test_dist.py, 1.2, 1.3 test_versionpredicate.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23805/Lib/distutils/tests Modified Files: test_dist.py test_versionpredicate.py Log Message: Whitespace normalization. Index: test_dist.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/tests/test_dist.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- test_dist.py 20 Mar 2005 22:19:47 -0000 1.2 +++ test_dist.py 28 Mar 2005 01:08:03 -0000 1.3 @@ -175,7 +175,7 @@ {"name": "package", "version": "1.0", "obsoletes": ["my.pkg (splat)"]}) - + def format_metadata(self, dist): sio = StringIO.StringIO() dist.metadata.write_pkg_file(sio) Index: test_versionpredicate.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/tests/test_versionpredicate.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- test_versionpredicate.py 20 Mar 2005 22:17:02 -0000 1.1 +++ test_versionpredicate.py 28 Mar 2005 01:08:03 -0000 1.2 @@ -6,4 +6,4 @@ import doctest def test_suite(): - return doctest.DocTestSuite(distutils.versionpredicate) + return doctest.DocTestSuite(distutils.versionpredicate) From tim_one at users.sourceforge.net Mon Mar 28 03:08:06 2005 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Mar 28 03:08:13 2005 Subject: [Python-checkins] python/dist/src/Tools/msi msi.py,1.24,1.25 Message-ID: Update of /cvsroot/python/python/dist/src/Tools/msi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23805/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.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- msi.py 15 Mar 2005 00:39:40 -0000 1.24 +++ msi.py 28 Mar 2005 01:08:04 -0000 1.25 @@ -134,7 +134,7 @@ "24":"{9B81E618-2301-4035-AC77-75D9ABEB7301}", "25":"{2e41b118-38bd-4c1b-a840-6977efd1b911}" } [major+minor] - + # Build the mingw import library, libpythonXY.a # This requires 'nm' and 'dlltool' executables on your PATH From tim_one at users.sourceforge.net Mon Mar 28 03:08:06 2005 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Mon Mar 28 03:08:15 2005 Subject: [Python-checkins] python/dist/src/Lib/test regrtest.py, 1.166, 1.167 test_functional.py, 1.3, 1.4 test_mmap.py, 1.31, 1.32 test_subprocess.py, 1.20, 1.21 test_xdrlib.py, 1.1, 1.2 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23805/Lib/test Modified Files: regrtest.py test_functional.py test_mmap.py test_subprocess.py test_xdrlib.py Log Message: Whitespace normalization. Index: regrtest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v retrieving revision 1.166 retrieving revision 1.167 diff -u -d -r1.166 -r1.167 --- regrtest.py 3 Mar 2005 20:47:37 -0000 1.166 +++ regrtest.py 28 Mar 2005 01:08:03 -0000 1.167 @@ -93,7 +93,7 @@ in the standard library and test suite. This takes a long time. - subprocess Run all tests for the subprocess module. + subprocess Run all tests for the subprocess module. To enable all resources except one, use '-uall,-'. For example, to run all the tests except for the bsddb tests, give the Index: test_functional.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_functional.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- test_functional.py 11 Mar 2005 06:48:49 -0000 1.3 +++ test_functional.py 28 Mar 2005 01:08:04 -0000 1.4 @@ -139,7 +139,7 @@ self.assertEqual(join(data), '0123456789') join = self.thetype(''.join) self.assertEqual(join(data), '0123456789') - + class PartialSubclass(functional.partial): pass Index: test_mmap.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_mmap.py,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- test_mmap.py 3 Mar 2005 11:22:41 -0000 1.31 +++ test_mmap.py 28 Mar 2005 01:08:04 -0000 1.32 @@ -321,7 +321,7 @@ f.close() f = open(TESTFN, "rb+") - mf = mmap.mmap(f.fileno(), 0) + mf = mmap.mmap(f.fileno(), 0) verify(len(mf) == 2**16, "Map size should equal file size.") vereq(mf.read(2**16), 2**16 * "m") mf.close() @@ -329,7 +329,7 @@ finally: os.unlink(TESTFN) - + # test mapping of entire file by passing 0 for map length if hasattr(os, "stat"): print " Ensuring that passing 0 as map length sets map size to current file size." @@ -337,17 +337,17 @@ try: f.write(2**16 * 'm') # Arbitrary character f.close() - + f = open(TESTFN, "rb+") - mf = mmap.mmap(f.fileno(), 0) + mf = mmap.mmap(f.fileno(), 0) verify(len(mf) == 2**16, "Map size should equal file size.") vereq(mf.read(2**16), 2**16 * "m") mf.close() f.close() - + finally: os.unlink(TESTFN) - + print ' Test passed' test_both() Index: test_subprocess.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_subprocess.py,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- test_subprocess.py 5 Mar 2005 06:40:52 -0000 1.20 +++ test_subprocess.py 28 Mar 2005 01:08:04 -0000 1.21 @@ -387,7 +387,7 @@ if test_support.is_resource_enabled("subprocess") and not mswindows: max_handles = 1026 # too much for most UNIX systems else: - max_handles = 65 + max_handles = 65 for i in range(max_handles): p = subprocess.Popen([sys.executable, "-c", "import sys;sys.stdout.write(sys.stdin.read())"], Index: test_xdrlib.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_xdrlib.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- test_xdrlib.py 24 Feb 2005 20:22:11 -0000 1.1 +++ test_xdrlib.py 28 Mar 2005 01:08:04 -0000 1.2 @@ -1,4 +1,3 @@ import xdrlib xdrlib._test() - From gward at users.sourceforge.net Mon Mar 28 04:32:44 2005 From: gward at users.sourceforge.net (gward@users.sourceforge.net) Date: Mon Mar 28 04:32:48 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libossaudiodev.tex, 1.12.4.3, 1.12.4.4 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8794/lib Modified Files: Tag: release24-maint libossaudiodev.tex Log Message: SF #1169212: fix silly typo in explaining AFMT macros: U16 is unsigned and S16 is signed. Duh. Clarify surrounding text a bit and refer to OSS docs. Index: libossaudiodev.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libossaudiodev.tex,v retrieving revision 1.12.4.3 retrieving revision 1.12.4.4 diff -u -d -r1.12.4.3 -r1.12.4.4 --- libossaudiodev.tex 9 Mar 2005 00:55:19 -0000 1.12.4.3 +++ libossaudiodev.tex 28 Mar 2005 02:32:41 -0000 1.12.4.4 @@ -166,7 +166,7 @@ \begin{methoddesc}[audio device]{getfmts}{} Return a bitmask of the audio output formats supported by the -soundcard. On a typical Linux system, these formats are: +soundcard. Some of the formats supported by OSS are: \begin{tableii}{l|l}{constant}{Format}{Description} \lineii{AFMT_MU_LAW} @@ -180,21 +180,22 @@ \lineii{AFMT_U8} {Unsigned, 8-bit audio} \lineii{AFMT_S16_LE} - {Unsigned, 16-bit audio, little-endian byte order (as used by + {Signed, 16-bit audio, little-endian byte order (as used by Intel processors)} \lineii{AFMT_S16_BE} - {Unsigned, 16-bit audio, big-endian byte order (as used by 68k, + {Signed, 16-bit audio, big-endian byte order (as used by 68k, PowerPC, Sparc)} \lineii{AFMT_S8} {Signed, 8 bit audio} \lineii{AFMT_U16_LE} - {Signed, 16-bit little-endian audio} + {Unsigned, 16-bit little-endian audio} \lineii{AFMT_U16_BE} - {Signed, 16-bit big-endian audio} + {Unsigned, 16-bit big-endian audio} \end{tableii} -Most systems support only a subset of these formats. Many devices only -support \constant{AFMT_U8}; the most common format used today is -\constant{AFMT_S16_LE}. +Consult the OSS documentation for a full list of audio formats, and note +that most devices support only a subset of these formats. Some older +devices only support \constant{AFMT_U8}; the most common format used +today is \constant{AFMT_S16_LE}. \end{methoddesc} \begin{methoddesc}[audio device]{setfmt}{format} From gward at users.sourceforge.net Mon Mar 28 04:35:01 2005 From: gward at users.sourceforge.net (gward@users.sourceforge.net) Date: Mon Mar 28 04:35:06 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libossaudiodev.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-serv10031/lib Modified Files: libossaudiodev.tex Log Message: SF #1169212: merge from 2.4 branch: fix silly typo in explaining AFMT macros: U16 is unsigned and S16 is signed. Duh. Clarify surrounding text a bit and refer to OSS docs. Index: libossaudiodev.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libossaudiodev.tex,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- libossaudiodev.tex 7 Mar 2005 01:41:11 -0000 1.14 +++ libossaudiodev.tex 28 Mar 2005 02:34:59 -0000 1.15 @@ -166,7 +166,7 @@ \begin{methoddesc}[audio device]{getfmts}{} Return a bitmask of the audio output formats supported by the -soundcard. On a typical Linux system, these formats are: +soundcard. Some of the formats supported by OSS are: \begin{tableii}{l|l}{constant}{Format}{Description} \lineii{AFMT_MU_LAW} @@ -180,21 +180,22 @@ \lineii{AFMT_U8} {Unsigned, 8-bit audio} \lineii{AFMT_S16_LE} - {Unsigned, 16-bit audio, little-endian byte order (as used by + {Signed, 16-bit audio, little-endian byte order (as used by Intel processors)} \lineii{AFMT_S16_BE} - {Unsigned, 16-bit audio, big-endian byte order (as used by 68k, + {Signed, 16-bit audio, big-endian byte order (as used by 68k, PowerPC, Sparc)} \lineii{AFMT_S8} {Signed, 8 bit audio} \lineii{AFMT_U16_LE} - {Signed, 16-bit little-endian audio} + {Unsigned, 16-bit little-endian audio} \lineii{AFMT_U16_BE} - {Signed, 16-bit big-endian audio} + {Unsigned, 16-bit big-endian audio} \end{tableii} -Most systems support only a subset of these formats. Many devices only -support \constant{AFMT_U8}; the most common format used today is -\constant{AFMT_S16_LE}. +Consult the OSS documentation for a full list of audio formats, and note +that most devices support only a subset of these formats. Some older +devices only support \constant{AFMT_U8}; the most common format used +today is \constant{AFMT_S16_LE}. \end{methoddesc} \begin{methoddesc}[audio device]{setfmt}{format} From gward at users.sourceforge.net Mon Mar 28 04:40:49 2005 From: gward at users.sourceforge.net (gward@users.sourceforge.net) Date: Mon Mar 28 04:40:52 2005 Subject: [Python-checkins] python/dist/src/Modules ossaudiodev.c,1.36,1.37 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12642/Modules Modified Files: ossaudiodev.c Log Message: Conditionally export a few more AFMT_* macros: AFMT_U16_NE, AFMT_S32_LE, AFMT_S32_BE, AFMT_MPEG. Index: ossaudiodev.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/ossaudiodev.c,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- ossaudiodev.c 7 Mar 2005 01:41:09 -0000 1.36 +++ ossaudiodev.c 28 Mar 2005 02:40:46 -0000 1.37 @@ -997,6 +997,18 @@ #ifdef AFMT_S16_NE _EXPORT_INT(m, AFMT_S16_NE); #endif +#ifdef AFMT_U16_NE + _EXPORT_INT(m, AFMT_U16_NE); +#endif +#ifdef AFMT_S32_LE + _EXPORT_INT(m, AFMT_S32_LE); +#endif +#ifdef AFMT_S32_BE + _EXPORT_INT(m, AFMT_S32_BE); +#endif +#ifdef AFMT_MPEG + _EXPORT_INT(m, AFMT_MPEG); +#endif /* Expose the sound mixer device numbers. */ _EXPORT_INT(m, SOUND_MIXER_NRDEVICES); From anthonybaxter at users.sourceforge.net Mon Mar 28 11:04:24 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Mon Mar 28 11:04:26 2005 Subject: [Python-checkins] python/dist/src/PCbuild BUILDno.txt, 1.65.2.2, 1.65.2.3 pythoncore.vcproj, 1.25.2.2, 1.25.2.3 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15912/PCbuild Modified Files: Tag: release24-maint BUILDno.txt pythoncore.vcproj Log Message: 2.4.1 buildno Index: BUILDno.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/BUILDno.txt,v retrieving revision 1.65.2.2 retrieving revision 1.65.2.3 diff -u -d -r1.65.2.2 -r1.65.2.3 --- BUILDno.txt 16 Mar 2005 14:34:23 -0000 1.65.2.2 +++ BUILDno.txt 28 Mar 2005 09:04:20 -0000 1.65.2.3 @@ -33,6 +33,8 @@ Windows Python BUILD numbers ---------------------------- + 65 2.4.1 + 30-Mar-2005 64 2.4.1c2 17-Mar-2005 63 2.4.1c1 Index: pythoncore.vcproj =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/pythoncore.vcproj,v retrieving revision 1.25.2.2 retrieving revision 1.25.2.3 diff -u -d -r1.25.2.2 -r1.25.2.3 --- pythoncore.vcproj 16 Mar 2005 14:34:23 -0000 1.25.2.2 +++ pythoncore.vcproj 28 Mar 2005 09:04:20 -0000 1.25.2.3 @@ -1385,7 +1385,7 @@ Name="VCCLCompilerTool" Optimization="2" AdditionalIncludeDirectories="" - PreprocessorDefinitions="BUILD=64"/> + PreprocessorDefinitions="BUILD=65"/> @@ -1393,7 +1393,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="" - PreprocessorDefinitions="BUILD=64"/> + PreprocessorDefinitions="BUILD=65"/> @@ -1401,7 +1401,7 @@ Name="VCCLCompilerTool" Optimization="2" AdditionalIncludeDirectories="" - PreprocessorDefinitions="BUILD=64"/> + PreprocessorDefinitions="BUILD=65"/> Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31906/Python Modified Files: thread_pthread.h Log Message: Add 0 to _POSIX_SEMAPHORES. Will backport to 2.4. Index: thread_pthread.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_pthread.h,v retrieving revision 2.54 retrieving revision 2.55 diff -u -d -r2.54 -r2.55 --- thread_pthread.h 16 Mar 2005 04:15:07 -0000 2.54 +++ thread_pthread.h 28 Mar 2005 12:34:20 -0000 2.55 @@ -16,7 +16,9 @@ family of functions must indicate this by defining _POSIX_SEMAPHORES. */ #ifdef _POSIX_SEMAPHORES -#if _POSIX_SEMAPHORES == -1 +/* On FreeBSD 4.x, _POSIX_SEMAPHORES is defined empty, so + we need to add 0 to make it work there as well. */ +#if (_POSIX_SEMAPHORES+0) == -1 #define HAVE_BROKEN_POSIX_SEMAPHORES #else #include From loewis at users.sourceforge.net Mon Mar 28 14:36:22 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Mar 28 14:36:27 2005 Subject: [Python-checkins] python/dist/src/Python thread_pthread.h, 2.53.4.1, 2.53.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32187/Python Modified Files: Tag: release24-maint thread_pthread.h Log Message: Add 0 to _POSIX_SEMAPHORES. Index: thread_pthread.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/thread_pthread.h,v retrieving revision 2.53.4.1 retrieving revision 2.53.4.2 diff -u -d -r2.53.4.1 -r2.53.4.2 --- thread_pthread.h 16 Mar 2005 04:13:29 -0000 2.53.4.1 +++ thread_pthread.h 28 Mar 2005 12:36:19 -0000 2.53.4.2 @@ -16,7 +16,9 @@ family of functions must indicate this by defining _POSIX_SEMAPHORES. */ #ifdef _POSIX_SEMAPHORES -#if _POSIX_SEMAPHORES == -1 +/* On FreeBSD 4.x, _POSIX_SEMAPHORES is defined empty, so + we need to add 0 to make it work there as well. */ +#if (_POSIX_SEMAPHORES+0) == -1 #define HAVE_BROKEN_POSIX_SEMAPHORES #else #include From loewis at users.sourceforge.net Mon Mar 28 17:29:31 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Mar 28 17:29:34 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libgc.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-serv24144 Modified Files: libgc.tex Log Message: Mention that DEBUG_LEAK includes DEBUG_SAVEALL. Fixes #1170460. Will backport to 2.4. Index: libgc.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libgc.tex,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- libgc.tex 7 Jan 2005 00:49:17 -0000 1.16 +++ libgc.tex 28 Mar 2005 15:29:28 -0000 1.17 @@ -14,7 +14,9 @@ can disable the collector if you are sure your program does not create reference cycles. Automatic collection can be disabled by calling \code{gc.disable()}. To debug a leaking program call -\code{gc.set_debug(gc.DEBUG_LEAK)}. +\code{gc.set_debug(gc.DEBUG_LEAK)}. Notice that this includes +\code{gc.DEBUG_SAVEALL}, causing garbage-collected objects to be +saved in gc.garbage for inspection. The \module{gc} module provides the following functions: From loewis at users.sourceforge.net Mon Mar 28 17:29:32 2005 From: loewis at users.sourceforge.net (loewis@users.sourceforge.net) Date: Mon Mar 28 17:29:35 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libgc.tex, 1.15.4.1, 1.15.4.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24450 Modified Files: Tag: release24-maint libgc.tex Log Message: Mention that DEBUG_LEAK includes DEBUG_SAVEALL. Fixes #1170460. Index: libgc.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libgc.tex,v retrieving revision 1.15.4.1 retrieving revision 1.15.4.2 diff -u -d -r1.15.4.1 -r1.15.4.2 --- libgc.tex 7 Jan 2005 00:51:02 -0000 1.15.4.1 +++ libgc.tex 28 Mar 2005 15:29:29 -0000 1.15.4.2 @@ -14,7 +14,9 @@ can disable the collector if you are sure your program does not create reference cycles. Automatic collection can be disabled by calling \code{gc.disable()}. To debug a leaking program call -\code{gc.set_debug(gc.DEBUG_LEAK)}. +\code{gc.set_debug(gc.DEBUG_LEAK)}. Notice that this includes +\code{gc.DEBUG_SAVEALL}, causing garbage-collected objects to be +saved in gc.garbage for inspection. The \module{gc} module provides the following functions: From etrepum at users.sourceforge.net Tue Mar 29 01:23:41 2005 From: etrepum at users.sourceforge.net (etrepum@users.sourceforge.net) Date: Tue Mar 29 01:23:50 2005 Subject: [Python-checkins] python/dist/src Makefile.pre.in, 1.148.2.1, 1.148.2.2 configure, 1.462.2.7, 1.462.2.8 configure.in, 1.475.2.7, 1.475.2.8 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1174/dist/src Modified Files: Tag: release24-maint Makefile.pre.in configure configure.in Log Message: patch [1171767] - Darwin 8's headers disable functionality when POSIX is enabled. This prevents the toolbox glue, all of Carbon, and various other non-POSIX features from compiling. The POSIX symbols are still used by default, so turning off the #define doesn't hurt. Additionally, linker flags have changed for Darwin 8, and are different for Darwin 8/gcc4 (default) and Darwin 8/gcc3.3. Approved by Anthony Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.pre.in,v retrieving revision 1.148.2.1 retrieving revision 1.148.2.2 diff -u -d -r1.148.2.1 -r1.148.2.2 --- Makefile.pre.in 19 Jan 2005 06:23:38 -0000 1.148.2.1 +++ Makefile.pre.in 28 Mar 2005 23:23:01 -0000 1.148.2.2 @@ -110,8 +110,8 @@ # 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 +# Options to enable prebinding (for fast startup prior to Mac OS X 10.3) +OTHER_LIBTOOL_OPT=@OTHER_LIBTOOL_OPT@ # Environment to run shared python without installed libraries RUNSHARED= @RUNSHARED@ @@ -371,7 +371,7 @@ $(RESSRCDIR)/English.lproj/InfoPlist.strings $(INSTALL) -d -m $(DIRMODE) $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION) libtool -o $(LDLIBRARY) -dynamic $(OTHER_LIBTOOL_OPT) $(LIBRARY) \ - -framework System @LIBTOOL_CRUFT@ + @LIBTOOL_CRUFT@ $(INSTALL) -d -m $(DIRMODE) \ $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/English.lproj $(INSTALL_DATA) $(RESSRCDIR)/Info.plist \ Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.462.2.7 retrieving revision 1.462.2.8 diff -u -d -r1.462.2.7 -r1.462.2.8 --- configure 14 Mar 2005 21:24:51 -0000 1.462.2.7 +++ configure 28 Mar 2005 23:23:02 -0000 1.462.2.8 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 1.475.2.6 . +# From configure.in Revision: 1.475.2.7 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59 for python 2.4. # @@ -312,7 +312,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 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_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 OTHER_LIBTOOL_OPT 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. @@ -1511,6 +1511,12 @@ define_xopen_source=no fi ;; + # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE + # disables platform specific features beyond repair. + Darwin/8.*) + define_xopen_source=no + ;; + esac if test $define_xopen_source = yes @@ -1545,6 +1551,7 @@ _ACEOF + cat >>confdefs.h <<\_ACEOF #define _POSIX_C_SOURCE 200112L _ACEOF @@ -10196,13 +10203,29 @@ case $ac_sys_system/$ac_sys_release in - Darwin/1.3*) - LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc" + Darwin/[01234567].*) + OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000" + ;; + Darwin/*) + OTHER_LIBTOOL_OPT="" + ;; +esac + + +case $ac_sys_system/$ac_sys_release in + Darwin/[01234567].*) + LIBTOOL_CRUFT="-framework System -lcc_dynamic -arch_only ppc" LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; Darwin/*) - LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc" - LIBTOOL_CRUFT="$LIBTOOL_CRUFT" + gcc_version=`gcc -v 2>&1 | grep version | cut -d\ -f3` + if test ${gcc_version} '<' 4.0 + then + LIBTOOL_CRUFT="-lcc_dynamic" + else + LIBTOOL_CRUFT="" + fi + LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -lSystem -lSystemStubs -arch_only ppc' LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; esac @@ -21048,6 +21071,7 @@ s,@LN@,$LN,;t t s,@OPT@,$OPT,;t t s,@BASECFLAGS@,$BASECFLAGS,;t t +s,@OTHER_LIBTOOL_OPT@,$OTHER_LIBTOOL_OPT,;t t s,@LIBTOOL_CRUFT@,$LIBTOOL_CRUFT,;t t s,@SO@,$SO,;t t s,@LDSHARED@,$LDSHARED,;t t Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.475.2.7 retrieving revision 1.475.2.8 diff -u -d -r1.475.2.7 -r1.475.2.8 --- configure.in 14 Mar 2005 21:24:51 -0000 1.475.2.7 +++ configure.in 28 Mar 2005 23:23:34 -0000 1.475.2.8 @@ -171,6 +171,12 @@ define_xopen_source=no fi ;; + # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE + # disables platform specific features beyond repair. + Darwin/8.*) + define_xopen_source=no + ;; + esac if test $define_xopen_source = yes @@ -194,8 +200,9 @@ # cases for HP-UX, we define it globally. AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1, Define to activate Unix95-and-earlier features) - AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001) + AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001) + fi # @@ -1205,15 +1212,31 @@ esac AC_MSG_RESULT($enable_toolbox_glue) +AC_SUBST(OTHER_LIBTOOL_OPT) +case $ac_sys_system/$ac_sys_release in + Darwin/@<:@01234567@:>@.*) + OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000" + ;; + Darwin/*) + OTHER_LIBTOOL_OPT="" + ;; +esac + AC_SUBST(LIBTOOL_CRUFT) case $ac_sys_system/$ac_sys_release in - Darwin/1.3*) - LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc" + Darwin/@<:@01234567@:>@.*) + LIBTOOL_CRUFT="-framework System -lcc_dynamic -arch_only ppc" LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; Darwin/*) - LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc" - LIBTOOL_CRUFT="$LIBTOOL_CRUFT" + gcc_version=`gcc -v 2>&1 | grep version | cut -d\ -f3` + if test ${gcc_version} '<' 4.0 + then + LIBTOOL_CRUFT="-lcc_dynamic" + else + LIBTOOL_CRUFT="" + fi + LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -lSystem -lSystemStubs -arch_only ppc' LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; esac From etrepum at users.sourceforge.net Tue Mar 29 01:23:49 2005 From: etrepum at users.sourceforge.net (etrepum@users.sourceforge.net) Date: Tue Mar 29 01:23:56 2005 Subject: [Python-checkins] python/dist/src Makefile.pre.in, 1.150, 1.151 configure, 1.470, 1.471 configure.in, 1.483, 1.484 Message-ID: Update of /cvsroot/python/python/dist/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1177/dist/src Modified Files: Makefile.pre.in configure configure.in Log Message: patch [1171735] - Darwin 8's headers disable functionality when POSIX is enabled. This prevents the toolbox glue, all of Carbon, and various other non-POSIX features from compiling. The POSIX symbols are still used by default, so turning off the #define doesn't hurt. Additionally, linker flags have changed for Darwin 8, and are different for Darwin 8/gcc4 (default) and Darwin 8/gcc3.3. Approved by Anthony Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.pre.in,v retrieving revision 1.150 retrieving revision 1.151 diff -u -d -r1.150 -r1.151 --- Makefile.pre.in 19 Jan 2005 06:24:58 -0000 1.150 +++ Makefile.pre.in 28 Mar 2005 23:23:46 -0000 1.151 @@ -113,8 +113,8 @@ # 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 +# Options to enable prebinding (for fast startup prior to Mac OS X 10.3) +OTHER_LIBTOOL_OPT=@OTHER_LIBTOOL_OPT@ # Environment to run shared python without installed libraries RUNSHARED= @RUNSHARED@ @@ -374,7 +374,7 @@ $(RESSRCDIR)/English.lproj/InfoPlist.strings $(INSTALL) -d -m $(DIRMODE) $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION) libtool -o $(LDLIBRARY) -dynamic $(OTHER_LIBTOOL_OPT) $(LIBRARY) \ - -framework System @LIBTOOL_CRUFT@ + @LIBTOOL_CRUFT@ $(INSTALL) -d -m $(DIRMODE) \ $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/English.lproj $(INSTALL_DATA) $(RESSRCDIR)/Info.plist \ Index: configure =================================================================== RCS file: /cvsroot/python/python/dist/src/configure,v retrieving revision 1.470 retrieving revision 1.471 diff -u -d -r1.470 -r1.471 --- configure 14 Mar 2005 21:23:33 -0000 1.470 +++ configure 28 Mar 2005 23:23:46 -0000 1.471 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 1.482 . +# From configure.in Revision: 1.483 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59 for python 2.5. # @@ -312,7 +312,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 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_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 OTHER_LIBTOOL_OPT 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. @@ -1511,6 +1511,12 @@ define_xopen_source=no fi ;; + # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE + # disables platform specific features beyond repair. + Darwin/8.*) + define_xopen_source=no + ;; + esac if test $define_xopen_source = yes @@ -1545,6 +1551,7 @@ _ACEOF + cat >>confdefs.h <<\_ACEOF #define _POSIX_C_SOURCE 200112L _ACEOF @@ -10197,13 +10204,29 @@ case $ac_sys_system/$ac_sys_release in - Darwin/1.3*) - LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc" + Darwin/[01234567].*) + OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000" + ;; + Darwin/*) + OTHER_LIBTOOL_OPT="" + ;; +esac + + +case $ac_sys_system/$ac_sys_release in + Darwin/[01234567].*) + LIBTOOL_CRUFT="-framework System -lcc_dynamic -arch_only ppc" LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; Darwin/*) - LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc" - LIBTOOL_CRUFT="$LIBTOOL_CRUFT" + gcc_version=`gcc -v 2>&1 | grep version | cut -d\ -f3` + if test ${gcc_version} '<' 4.0 + then + LIBTOOL_CRUFT="-lcc_dynamic" + else + LIBTOOL_CRUFT="" + fi + LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -lSystem -lSystemStubs -arch_only ppc' LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; esac @@ -21051,6 +21074,7 @@ s,@LN@,$LN,;t t s,@OPT@,$OPT,;t t s,@BASECFLAGS@,$BASECFLAGS,;t t +s,@OTHER_LIBTOOL_OPT@,$OTHER_LIBTOOL_OPT,;t t s,@LIBTOOL_CRUFT@,$LIBTOOL_CRUFT,;t t s,@SO@,$SO,;t t s,@LDSHARED@,$LDSHARED,;t t Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.483 retrieving revision 1.484 diff -u -d -r1.483 -r1.484 --- configure.in 14 Mar 2005 21:23:31 -0000 1.483 +++ configure.in 28 Mar 2005 23:23:47 -0000 1.484 @@ -171,6 +171,12 @@ define_xopen_source=no fi ;; + # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE + # disables platform specific features beyond repair. + Darwin/8.*) + define_xopen_source=no + ;; + esac if test $define_xopen_source = yes @@ -194,8 +200,9 @@ # cases for HP-UX, we define it globally. AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1, Define to activate Unix95-and-earlier features) - AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001) + AC_DEFINE(_POSIX_C_SOURCE, 200112L, Define to activate features from IEEE Stds 1003.1-2001) + fi # @@ -1205,15 +1212,31 @@ esac AC_MSG_RESULT($enable_toolbox_glue) +AC_SUBST(OTHER_LIBTOOL_OPT) +case $ac_sys_system/$ac_sys_release in + Darwin/@<:@01234567@:>@.*) + OTHER_LIBTOOL_OPT="-prebind -seg1addr 0x10000000" + ;; + Darwin/*) + OTHER_LIBTOOL_OPT="" + ;; +esac + AC_SUBST(LIBTOOL_CRUFT) case $ac_sys_system/$ac_sys_release in - Darwin/1.3*) - LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc" + Darwin/@<:@01234567@:>@.*) + LIBTOOL_CRUFT="-framework System -lcc_dynamic -arch_only ppc" LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; Darwin/*) - LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc" - LIBTOOL_CRUFT="$LIBTOOL_CRUFT" + gcc_version=`gcc -v 2>&1 | grep version | cut -d\ -f3` + if test ${gcc_version} '<' 4.0 + then + LIBTOOL_CRUFT="-lcc_dynamic" + else + LIBTOOL_CRUFT="" + fi + LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -lSystem -lSystemStubs -arch_only ppc' LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';; esac From tim_one at users.sourceforge.net Tue Mar 29 01:50:58 2005 From: tim_one at users.sourceforge.net (tim_one@users.sourceforge.net) Date: Tue Mar 29 01:51:01 2005 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.121,1.122 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17578/Lib Modified Files: doctest.py Log Message: SF patch 1167316: doctest.py fails self-test if run directly. Patch by Ilya Sandler. Bugfix candidate. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.121 retrieving revision 1.122 diff -u -d -r1.121 -r1.122 --- doctest.py 21 Dec 2004 23:46:24 -0000 1.121 +++ doctest.py 28 Mar 2005 23:50:54 -0000 1.122 @@ -2071,24 +2071,24 @@ The old flag is returned so that a runner could restore the old value if it wished to: - >>> old = _unittest_reportflags - >>> set_unittest_reportflags(REPORT_NDIFF | + >>> import doctest + >>> old = doctest._unittest_reportflags + >>> doctest.set_unittest_reportflags(REPORT_NDIFF | ... REPORT_ONLY_FIRST_FAILURE) == old True - >>> import doctest >>> doctest._unittest_reportflags == (REPORT_NDIFF | ... REPORT_ONLY_FIRST_FAILURE) True Only reporting flags can be set: - >>> set_unittest_reportflags(ELLIPSIS) + >>> doctest.set_unittest_reportflags(ELLIPSIS) Traceback (most recent call last): ... ValueError: ('Only reporting flags allowed', 8) - >>> set_unittest_reportflags(old) == (REPORT_NDIFF | + >>> doctest.set_unittest_reportflags(old) == (REPORT_NDIFF | ... REPORT_ONLY_FIRST_FAILURE) True """ From anthonybaxter at users.sourceforge.net Tue Mar 29 14:32:53 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Mar 29 14:32:56 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.41, 1.1193.2.42 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16421/Misc Modified Files: Tag: release24-maint NEWS Log Message: Move exception finalisation later in the shutdown process - this fixes the crash seen in bug #1165761 Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.41 retrieving revision 1.1193.2.42 diff -u -d -r1.1193.2.41 -r1.1193.2.42 --- NEWS 27 Mar 2005 10:55:26 -0000 1.1193.2.41 +++ NEWS 29 Mar 2005 12:32:46 -0000 1.1193.2.42 @@ -4,6 +4,17 @@ (editors: check NEWS.help for information about editing NEWS using ReST.) +What's New in Python 2.4.1 final? +================================= + +*Release date: 30-MAR-2005* + +Core and builtins +----------------- + +- Move exception finalisation later in the shutdown process - this + fixes the crash seen in bug #1165761 + What's New in Python 2.4.1c2? ============================= From anthonybaxter at users.sourceforge.net Tue Mar 29 14:32:54 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Mar 29 14:32:58 2005 Subject: [Python-checkins] python/dist/src/Python pythonrun.c, 2.211, 2.211.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16421/Python Modified Files: Tag: release24-maint pythonrun.c Log Message: Move exception finalisation later in the shutdown process - this fixes the crash seen in bug #1165761 Index: pythonrun.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v retrieving revision 2.211 retrieving revision 2.211.2.1 diff -u -d -r2.211 -r2.211.2.1 --- pythonrun.c 13 Oct 2004 14:48:50 -0000 2.211 +++ pythonrun.c 29 Mar 2005 12:32:50 -0000 2.211.2.1 @@ -392,13 +392,6 @@ _Py_PrintReferences(stderr); #endif /* Py_TRACE_REFS */ - /* Now we decref the exception classes. After this point nothing - can raise an exception. That's okay, because each Fini() method - below has been checked to make sure no exceptions are ever - raised. - */ - _PyExc_Fini(); - /* Cleanup auto-thread-state */ #ifdef WITH_THREAD _PyGILState_Fini(); @@ -407,6 +400,14 @@ /* Clear interpreter state */ PyInterpreterState_Clear(interp); + /* Now we decref the exception classes. After this point nothing + can raise an exception. That's okay, because each Fini() method + below has been checked to make sure no exceptions are ever + raised. + */ + + _PyExc_Fini(); + /* Delete current thread */ PyThreadState_Swap(NULL); PyInterpreterState_Delete(interp); From anthonybaxter at users.sourceforge.net Tue Mar 29 14:33:36 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Mar 29 14:33:38 2005 Subject: [Python-checkins] python/dist/src/Include patchlevel.h, 2.83.2.5, 2.83.2.6 Message-ID: Update of /cvsroot/python/python/dist/src/Include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16943/Include Modified Files: Tag: release24-maint patchlevel.h Log Message: 2.4.1 preparations. Index: patchlevel.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/patchlevel.h,v retrieving revision 2.83.2.5 retrieving revision 2.83.2.6 diff -u -d -r2.83.2.5 -r2.83.2.6 --- patchlevel.h 17 Mar 2005 03:06:56 -0000 2.83.2.5 +++ patchlevel.h 29 Mar 2005 12:33:33 -0000 2.83.2.6 @@ -22,11 +22,11 @@ #define PY_MAJOR_VERSION 2 #define PY_MINOR_VERSION 4 #define PY_MICRO_VERSION 1 -#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_GAMMA -#define PY_RELEASE_SERIAL 2 +#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL +#define PY_RELEASE_SERIAL 0 /* Version as a string */ -#define PY_VERSION "2.4.1c2" +#define PY_VERSION "2.4.1" /* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. Use this for numeric comparisons, e.g. #if PY_VERSION_HEX >= ... */ From anthonybaxter at users.sourceforge.net Tue Mar 29 14:33:36 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Mar 29 14:33:40 2005 Subject: [Python-checkins] python/dist/src/Lib/idlelib NEWS.txt, 1.49.2.5, 1.49.2.6 idlever.py, 1.22.2.3, 1.22.2.4 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16943/Lib/idlelib Modified Files: Tag: release24-maint NEWS.txt idlever.py Log Message: 2.4.1 preparations. Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.49.2.5 retrieving revision 1.49.2.6 diff -u -d -r1.49.2.5 -r1.49.2.6 --- NEWS.txt 16 Mar 2005 14:34:22 -0000 1.49.2.5 +++ NEWS.txt 29 Mar 2005 12:33:34 -0000 1.49.2.6 @@ -1,3 +1,8 @@ +What's New in IDLE 1.1.1? +========================= + +*Release date: 30-MAR-2005* + What's New in IDLE 1.1.1c2? =========================== Index: idlever.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/idlever.py,v retrieving revision 1.22.2.3 retrieving revision 1.22.2.4 diff -u -d -r1.22.2.3 -r1.22.2.4 --- idlever.py 16 Mar 2005 14:34:23 -0000 1.22.2.3 +++ idlever.py 29 Mar 2005 12:33:34 -0000 1.22.2.4 @@ -1 +1 @@ -IDLE_VERSION = "1.1.1c2" +IDLE_VERSION = "1.1.1" From anthonybaxter at users.sourceforge.net Tue Mar 29 14:35:59 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Mar 29 14:36:02 2005 Subject: [Python-checkins] python/dist/src/Lib doctest.py,1.120,1.120.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18010 Modified Files: Tag: release24-maint doctest.py Log Message: backport of 1.122 SF patch 1167316: doctest.py fails self-test if run directly. Index: doctest.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v retrieving revision 1.120 retrieving revision 1.120.2.1 diff -u -d -r1.120 -r1.120.2.1 --- doctest.py 8 Nov 2004 22:31:09 -0000 1.120 +++ doctest.py 29 Mar 2005 12:35:54 -0000 1.120.2.1 @@ -2071,24 +2071,24 @@ The old flag is returned so that a runner could restore the old value if it wished to: - >>> old = _unittest_reportflags - >>> set_unittest_reportflags(REPORT_NDIFF | + >>> import doctest + >>> old = doctest._unittest_reportflags + >>> doctest.set_unittest_reportflags(REPORT_NDIFF | ... REPORT_ONLY_FIRST_FAILURE) == old True - >>> import doctest >>> doctest._unittest_reportflags == (REPORT_NDIFF | ... REPORT_ONLY_FIRST_FAILURE) True Only reporting flags can be set: - >>> set_unittest_reportflags(ELLIPSIS) + >>> doctest.set_unittest_reportflags(ELLIPSIS) Traceback (most recent call last): ... ValueError: ('Only reporting flags allowed', 8) - >>> set_unittest_reportflags(old) == (REPORT_NDIFF | + >>> doctest.set_unittest_reportflags(old) == (REPORT_NDIFF | ... REPORT_ONLY_FIRST_FAILURE) True """ From anthonybaxter at users.sourceforge.net Tue Mar 29 14:38:43 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Mar 29 14:38:46 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.42, 1.1193.2.43 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19851/Misc Modified Files: Tag: release24-maint NEWS Log Message: updates to NEWS Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.42 retrieving revision 1.1193.2.43 diff -u -d -r1.1193.2.42 -r1.1193.2.43 --- NEWS 29 Mar 2005 12:32:46 -0000 1.1193.2.42 +++ NEWS 29 Mar 2005 12:38:37 -0000 1.1193.2.43 @@ -15,6 +15,19 @@ - Move exception finalisation later in the shutdown process - this fixes the crash seen in bug #1165761 +Tests +----- + +- SF patch 1167316: doctest.py fails self-test if run directly. + +Build +----- + +- SF patch 1171767: Darwin 8's headers are anal about POSIX compliance, + and linking has changed (prebinding is now deprecated, and libcc_dynamic + no longer exists). This configure patch makes things right. + + What's New in Python 2.4.1c2? ============================= From anthonybaxter at users.sourceforge.net Tue Mar 29 15:36:19 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Mar 29 15:36:22 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1277,1.1278 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15778/Misc Modified Files: NEWS Log Message: Move exception finalisation later in the shutdown process - this fixes the crash seen in bug #1165761 Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1277 retrieving revision 1.1278 diff -u -d -r1.1277 -r1.1278 --- NEWS 27 Mar 2005 10:47:36 -0000 1.1277 +++ NEWS 29 Mar 2005 13:36:13 -0000 1.1278 @@ -7,9 +7,14 @@ What's New in Python 2.5 alpha 1? ================================= +*Release date: XX-XXX-2006* + Core and builtins ----------------- +- Move exception finalisation later in the shutdown process - this + fixes the crash seen in bug #1165761 + - Added two new builtins, any() and all(). - Defining a class with empty parentheses is now allowed From anthonybaxter at users.sourceforge.net Tue Mar 29 15:36:20 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Mar 29 15:36:25 2005 Subject: [Python-checkins] python/dist/src/Python pythonrun.c,2.212,2.213 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15778/Python Modified Files: pythonrun.c Log Message: Move exception finalisation later in the shutdown process - this fixes the crash seen in bug #1165761 Index: pythonrun.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v retrieving revision 2.212 retrieving revision 2.213 diff -u -d -r2.212 -r2.213 --- pythonrun.c 3 Mar 2005 11:45:45 -0000 2.212 +++ pythonrun.c 29 Mar 2005 13:36:16 -0000 2.213 @@ -392,13 +392,6 @@ _Py_PrintReferences(stderr); #endif /* Py_TRACE_REFS */ - /* Now we decref the exception classes. After this point nothing - can raise an exception. That's okay, because each Fini() method - below has been checked to make sure no exceptions are ever - raised. - */ - _PyExc_Fini(); - /* Cleanup auto-thread-state */ #ifdef WITH_THREAD _PyGILState_Fini(); @@ -407,6 +400,14 @@ /* Clear interpreter state */ PyInterpreterState_Clear(interp); + /* Now we decref the exception classes. After this point nothing + can raise an exception. That's okay, because each Fini() method + below has been checked to make sure no exceptions are ever + raised. + */ + + _PyExc_Fini(); + /* Delete current thread */ PyThreadState_Swap(NULL); PyInterpreterState_Delete(interp); From etrepum at users.sourceforge.net Tue Mar 29 15:48:04 2005 From: etrepum at users.sourceforge.net (etrepum@users.sourceforge.net) Date: Tue Mar 29 15:48:07 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1278,1.1279 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22276 Modified Files: NEWS Log Message: Update NEWS for patch 1171735 (Darwin 8 build fixes) Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1278 retrieving revision 1.1279 diff -u -d -r1.1278 -r1.1279 --- NEWS 29 Mar 2005 13:36:13 -0000 1.1278 +++ NEWS 29 Mar 2005 13:47:59 -0000 1.1279 @@ -245,6 +245,10 @@ Build ----- +- SF patch 1171735: Darwin 8's headers are anal about POSIX compliance, + and linking has changed (prebinding is now deprecated, and libcc_dynamic + no longer exists). This configure patch makes things right. + - Bug #1158607: Build with --disable-unicode again. - spwdmodule.c is built only if either HAVE_GETSPNAM or HAVE_HAVE_GETSPENT is From fdrake at users.sourceforge.net Tue Mar 29 17:57:13 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Mar 29 17:57:16 2005 Subject: [Python-checkins] python/dist/src/Doc/commontex boilerplate.tex, 1.3, 1.3.4.1 license.tex, 1.6.2.1, 1.6.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/commontex In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29997/commontex Modified Files: Tag: release24-maint boilerplate.tex license.tex Log Message: prepare for Python 2.4.1 final Index: boilerplate.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/commontex/boilerplate.tex,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -u -d -r1.3 -r1.3.4.1 --- boilerplate.tex 2 Jan 2004 06:52:06 -0000 1.3 +++ boilerplate.tex 29 Mar 2005 15:57:08 -0000 1.3.4.1 @@ -5,5 +5,5 @@ Email: \email{docs@python.org} } -\date{\today} % XXX update before final release! +\date{30 March 2005} % XXX update before final release! \input{patchlevel} % include Python version information Index: license.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/commontex/license.tex,v retrieving revision 1.6.2.1 retrieving revision 1.6.2.2 diff -u -d -r1.6.2.1 -r1.6.2.2 --- license.tex 8 Feb 2005 06:41:20 -0000 1.6.2.1 +++ license.tex 29 Mar 2005 15:57:11 -0000 1.6.2.2 @@ -47,6 +47,7 @@ \linev{2.3.4}{2.3.3}{2004}{PSF}{yes} \linev{2.3.5}{2.3.4}{2005}{PSF}{yes} \linev{2.4}{2.3}{2004}{PSF}{yes} + \linev{2.4.1}{2.4}{2005}{PSF}{yes} \end{tablev} \note{GPL-compatible doesn't mean that we're distributing From anthonybaxter at users.sourceforge.net Tue Mar 29 18:05:40 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Tue Mar 29 18:05:43 2005 Subject: [Python-checkins] python/dist/src/PCbuild BUILDno.txt,1.66,1.67 Message-ID: Update of /cvsroot/python/python/dist/src/PCbuild In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1511/PCbuild Modified Files: BUILDno.txt Log Message: merge from branch Index: BUILDno.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/PCbuild/BUILDno.txt,v retrieving revision 1.66 retrieving revision 1.67 diff -u -d -r1.66 -r1.67 --- BUILDno.txt 9 Mar 2005 11:51:40 -0000 1.66 +++ BUILDno.txt 29 Mar 2005 16:05:36 -0000 1.67 @@ -33,6 +33,10 @@ Windows Python BUILD numbers ---------------------------- + 65 2.4.1 + 30-Mar-2005 + 64 2.4.1c2 + 17-Mar-2005 63 2.4.1c1 10-Mar-2005 62 2.3.5 From fdrake at users.sourceforge.net Tue Mar 29 18:06:54 2005 From: fdrake at users.sourceforge.net (fdrake@users.sourceforge.net) Date: Tue Mar 29 18:06:56 2005 Subject: [Python-checkins] python/dist/src/Doc/commontex license.tex, 1.7, 1.8 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/commontex In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1990 Modified Files: license.tex Log Message: add 2.4.1 to the release history Index: license.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/commontex/license.tex,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- license.tex 8 Feb 2005 06:42:39 -0000 1.7 +++ license.tex 29 Mar 2005 16:06:51 -0000 1.8 @@ -47,6 +47,7 @@ \linev{2.3.4}{2.3.3}{2004}{PSF}{yes} \linev{2.3.5}{2.3.4}{2005}{PSF}{yes} \linev{2.4}{2.3}{2004}{PSF}{yes} + \linev{2.4.1}{2.4}{2005}{PSF}{yes} \end{tablev} \note{GPL-compatible doesn't mean that we're distributing From anthonybaxter at users.sourceforge.net Wed Mar 30 05:01:53 2005 From: anthonybaxter at users.sourceforge.net (anthonybaxter@users.sourceforge.net) Date: Wed Mar 30 05:01:56 2005 Subject: [Python-checkins] python/dist/src/Lib/idlelib NEWS.txt, 1.49.2.6, 1.49.2.7 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/idlelib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20910/Lib/idlelib Modified Files: Tag: release24-maint NEWS.txt Log Message: Index: NEWS.txt =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v retrieving revision 1.49.2.6 retrieving revision 1.49.2.7 diff -u -d -r1.49.2.6 -r1.49.2.7 --- NEWS.txt 29 Mar 2005 12:33:34 -0000 1.49.2.6 +++ NEWS.txt 30 Mar 2005 03:01:43 -0000 1.49.2.7 @@ -3,6 +3,7 @@ *Release date: 30-MAR-2005* + What's New in IDLE 1.1.1c2? =========================== From mwh at users.sourceforge.net Wed Mar 30 11:38:15 2005 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Wed Mar 30 11:38:18 2005 Subject: [Python-checkins] python/dist/src/Modules readline.c,2.80,2.81 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15932 Modified Files: readline.c Log Message: I don't think it's particularly accurate to say Guido is maintaining this module any more. Index: readline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v retrieving revision 2.80 retrieving revision 2.81 diff -u -d -r2.80 -r2.81 --- readline.c 27 Feb 2005 20:33:25 -0000 2.80 +++ readline.c 30 Mar 2005 09:38:12 -0000 2.81 @@ -1,9 +1,6 @@ /* This module makes GNU readline available to Python. It has ideas * contributed by Lee Busby, LLNL, and William Magro, Cornell Theory * Center. The completer interface was inspired by Lele Gaifax. - * - * More recently, it was largely rewritten by Guido van Rossum who is - * now maintaining it. */ /* Standard definitions */ From mwh at users.sourceforge.net Wed Mar 30 12:09:15 2005 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Wed Mar 30 12:09:18 2005 Subject: [Python-checkins] python/dist/src/Modules readline.c,2.81,2.82 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2142 Modified Files: readline.c Log Message: Be a bit more accurate. Index: readline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v retrieving revision 2.81 retrieving revision 2.82 diff -u -d -r2.81 -r2.82 --- readline.c 30 Mar 2005 09:38:12 -0000 2.81 +++ readline.c 30 Mar 2005 10:09:12 -0000 2.82 @@ -1,6 +1,7 @@ /* This module makes GNU readline available to Python. It has ideas * contributed by Lee Busby, LLNL, and William Magro, Cornell Theory - * Center. The completer interface was inspired by Lele Gaifax. + * Center. The completer interface was inspired by Lele Gaifax. More + * recently, it was largely rewritten by Guido van Rossum. */ /* Standard definitions */ From mwh at users.sourceforge.net Wed Mar 30 13:22:05 2005 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Wed Mar 30 13:22:09 2005 Subject: [Python-checkins] python/dist/src/Modules readline.c,2.82,2.83 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10274 Modified Files: readline.c Log Message: Fixes for [ 1166660 ] The readline module can cause python to segfault It seems to me that the code I'm rewriting here attempted to call any user-supplied hook functions using the thread state of the thread that called the hook-setting function, as opposed to that of the thread that is currently executing. This doesn't work, in general. Fix this by using the PyGILState API (It wouldn't be that hard to define a dummy version of said API when #ifndef WITH_THREAD, would it?). Also, check the conversion to integer of the return value of a hook function for errors (this problem was mentioned in the ipython bug report linked to in the above bug). Index: readline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v retrieving revision 2.82 retrieving revision 2.83 diff -u -d -r2.82 -r2.83 --- readline.c 30 Mar 2005 10:09:12 -0000 2.82 +++ readline.c 30 Mar 2005 11:21:53 -0000 2.83 @@ -159,8 +159,7 @@ /* Generic hook function setter */ static PyObject * -set_hook(const char *funcname, PyObject **hook_var, - PyThreadState **tstate, PyObject *args) +set_hook(const char *funcname, PyObject **hook_var, PyObject *args) { PyObject *function = Py_None; char buf[80]; @@ -170,14 +169,12 @@ if (function == Py_None) { Py_XDECREF(*hook_var); *hook_var = NULL; - *tstate = NULL; } else if (PyCallable_Check(function)) { PyObject *tmp = *hook_var; Py_INCREF(function); *hook_var = function; Py_XDECREF(tmp); - *tstate = PyThreadState_GET(); } else { PyOS_snprintf(buf, sizeof(buf), @@ -194,18 +191,15 @@ /* Exported functions to specify hook functions in Python */ static PyObject *startup_hook = NULL; -static PyThreadState *startup_hook_tstate = NULL; #ifdef HAVE_RL_PRE_INPUT_HOOK static PyObject *pre_input_hook = NULL; -static PyThreadState *pre_input_hook_tstate = NULL; #endif static PyObject * set_startup_hook(PyObject *self, PyObject *args) { - return set_hook("startup_hook", &startup_hook, - &startup_hook_tstate, args); + return set_hook("startup_hook", &startup_hook, args); } PyDoc_STRVAR(doc_set_startup_hook, @@ -222,8 +216,7 @@ static PyObject * set_pre_input_hook(PyObject *self, PyObject *args) { - return set_hook("pre_input_hook", &pre_input_hook, - &pre_input_hook_tstate, args); + return set_hook("pre_input_hook", &pre_input_hook, args); } PyDoc_STRVAR(doc_set_pre_input_hook, @@ -239,7 +232,6 @@ /* Exported function to specify a word completer in Python */ static PyObject *completer = NULL; -static PyThreadState *completer_tstate = NULL; static PyObject *begidx = NULL; static PyObject *endidx = NULL; @@ -403,7 +395,7 @@ static PyObject * set_completer(PyObject *self, PyObject *args) { - return set_hook("completer", &completer, &completer_tstate, args); + return set_hook("completer", &completer, args); } PyDoc_STRVAR(doc_set_completer, @@ -584,28 +576,33 @@ /* C function to call the Python hooks. */ static int -on_hook(PyObject *func, PyThreadState **tstate) +on_hook(PyObject *func) { int result = 0; if (func != NULL) { PyObject *r; - /* Note that readline is called with the interpreter - lock released! */ - PyEval_RestoreThread(*tstate); +#ifdef WITH_THREAD + PyGILState_STATE gilstate = PyGILState_Ensure(); +#endif r = PyObject_CallFunction(func, NULL); if (r == NULL) goto error; if (r == Py_None) result = 0; - else + else { result = PyInt_AsLong(r); + if (result == -1 && PyErr_Occurred()) + goto error; + } Py_DECREF(r); goto done; error: PyErr_Clear(); Py_XDECREF(r); done: - *tstate = PyEval_SaveThread(); +#ifdef WITH_THREAD + PyGILState_Release(gilstate); +#endif } return result; } @@ -613,14 +610,14 @@ static int on_startup_hook(void) { - return on_hook(startup_hook, &startup_hook_tstate); + return on_hook(startup_hook); } #ifdef HAVE_RL_PRE_INPUT_HOOK static int on_pre_input_hook(void) { - return on_hook(pre_input_hook, &pre_input_hook_tstate); + return on_hook(pre_input_hook); } #endif @@ -633,11 +630,9 @@ char *result = NULL; if (completer != NULL) { PyObject *r; - /* Note that readline is called with the interpreter - lock released! */ - PyEval_RestoreThread(completer_tstate); - /* Don't use the default filename completion if we - * have a custom completion function... */ +#ifdef WITH_THREAD + PyGILState_STATE gilstate = PyGILState_Ensure(); +#endif rl_attempted_completion_over = 1; r = PyObject_CallFunction(completer, "si", text, state); if (r == NULL) @@ -657,7 +652,9 @@ PyErr_Clear(); Py_XDECREF(r); done: - completer_tstate = PyEval_SaveThread(); +#ifdef WITH_THREAD + PyGILState_Release(gilstate); +#endif } return result; } From mwh at python.net Wed Mar 30 13:28:16 2005 From: mwh at python.net (Michael Hudson) Date: Wed Mar 30 13:28:18 2005 Subject: [Python-checkins] python/dist/src/Modules readline.c,2.82,2.83 In-Reply-To: (mwh@users.sourceforge.net's message of "Wed, 30 Mar 2005 03:22:05 -0800") References: Message-ID: <2my8c5e5kf.fsf@starship.python.net> mwh@users.sourceforge.net writes: > Update of /cvsroot/python/python/dist/src/Modules > In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10274 > > Modified Files: > readline.c > Log Message: > Fixes for > > [ 1166660 ] The readline module can cause python to segfault > > It seems to me that the code I'm rewriting here attempted to call any > user-supplied hook functions using the thread state of the thread that > called the hook-setting function, as opposed to that of the thread > that is currently executing. This doesn't work, in general. > > Fix this by using the PyGILState API (It wouldn't be that hard to > define a dummy version of said API when #ifndef WITH_THREAD, would > it?). > > Also, check the conversion to integer of the return value of a hook > function for errors (this problem was mentioned in the ipython bug > report linked to in the above bug). Oh, and I forgot to say: this should go into realease24-maint when that opens again. Cheers, mwh -- You're going to have to remember that I still think of Twisted as a big multiplayer game, and all this HTTP stuff is just kind of a grotty way to display room descriptions. -- Glyph Lefkowitz From mwh at users.sourceforge.net Wed Mar 30 18:25:41 2005 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Wed Mar 30 18:25:44 2005 Subject: [Python-checkins] python/dist/src/Doc/lib libfcntl.tex,1.37,1.38 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20170 Modified Files: libfcntl.tex Log Message: Minor wording fix. Index: libfcntl.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfcntl.tex,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- libfcntl.tex 30 Nov 2004 14:31:54 -0000 1.37 +++ libfcntl.tex 30 Mar 2005 16:25:34 -0000 1.38 @@ -66,8 +66,9 @@ If it is false, the buffer's mutability is ignored and behaviour is as for a read-only buffer, except that the 1024 byte limit mentioned - above is avoided -- so long as the buffer you pass is longer than - what the operating system wants to put there, things should work. + above is avoided -- so long as the buffer you pass is as least as + long as what the operating system wants to put there, things should + work. If \var{mutate_flag} is true, then the buffer is (in effect) passed to the underlying \function{ioctl()} system call, the latter's From mwh at users.sourceforge.net Wed Mar 30 18:32:14 2005 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Wed Mar 30 18:32:17 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_new.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-serv23002/Lib/test Modified Files: test_new.py Log Message: Fix for rather inaccurately titled bug [ 1165306 ] Property access with decorator makes interpreter crash Don't allow the creation of unbound methods with NULL im_class, because attempting to call such crashes. Backport candidate. Index: test_new.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_new.py,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- test_new.py 13 Aug 2004 03:57:22 -0000 1.19 +++ test_new.py 30 Mar 2005 16:32:10 -0000 1.20 @@ -47,6 +47,16 @@ verify(c.get_yolks() == 1 and c.get_more_yolks() == 4, 'Broken call of hand-crafted instance method') +im = new.instancemethod(break_yolks, c) +im() +verify(c.get_yolks() == -1) +try: + new.instancemethod(break_yolks, None) +except TypeError: + pass +else: + raise TestFailed, "dangerous instance method creation allowed" + # It's unclear what the semantics should be for a code object compiled at # module scope, but bound and run in a function. In CPython, `c' is global # (by accident?) while in Jython, `c' is local. The intent of the test From mwh at users.sourceforge.net Wed Mar 30 18:32:17 2005 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Wed Mar 30 18:32:19 2005 Subject: [Python-checkins] python/dist/src/Objects classobject.c, 2.176, 2.177 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23002/Objects Modified Files: classobject.c Log Message: Fix for rather inaccurately titled bug [ 1165306 ] Property access with decorator makes interpreter crash Don't allow the creation of unbound methods with NULL im_class, because attempting to call such crashes. Backport candidate. Index: classobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v retrieving revision 2.176 retrieving revision 2.177 diff -u -d -r2.176 -r2.177 --- classobject.c 23 Sep 2004 02:39:36 -0000 2.176 +++ classobject.c 30 Mar 2005 16:32:10 -0000 2.177 @@ -2208,6 +2208,12 @@ } if (self == Py_None) self = NULL; + if (self == NULL && classObj == NULL) { + PyErr_SetString(PyExc_TypeError, + "unbound methods must have non-NULL im_class"); + return NULL; + } + return PyMethod_New(func, self, classObj); } From mwh at users.sourceforge.net Wed Mar 30 18:42:20 2005 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Wed Mar 30 18:42:23 2005 Subject: [Python-checkins] python/dist/src/Python getargs.c,2.104,2.105 Message-ID: Update of /cvsroot/python/python/dist/src/Python In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29451 Modified Files: getargs.c Log Message: I suppose a bug report or even a fix would be a better response, but commit a yelp about a noted flaw the error messages for METH_KEYWORDS functions under some circumstances. Index: getargs.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/getargs.c,v retrieving revision 2.104 retrieving revision 2.105 diff -u -d -r2.104 -r2.105 --- getargs.c 3 Mar 2005 12:26:35 -0000 2.104 +++ getargs.c 30 Mar 2005 16:41:55 -0000 2.105 @@ -1299,7 +1299,8 @@ /* make sure we got an acceptable number of arguments; the message is a little confusing with keywords since keyword arguments which are supplied, but don't match the required arguments - are not included in the "%d given" part of the message */ + are not included in the "%d given" part of the message + XXX and this isn't a bug!? */ if (len < min || max < len) { if (message == NULL) { PyOS_snprintf(msgbuf, sizeof(msgbuf), From rhettinger at users.sourceforge.net Thu Mar 31 06:07:58 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Mar 31 06:08:01 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.43, 1.1193.2.44 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4856/Misc Modified Files: Tag: release24-maint NEWS Log Message: SF bug #1770766: weakref proxy has incorrect __nonzero__ behavior. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.43 retrieving revision 1.1193.2.44 diff -u -d -r1.1193.2.43 -r1.1193.2.44 --- NEWS 29 Mar 2005 12:38:37 -0000 1.1193.2.43 +++ NEWS 31 Mar 2005 04:07:48 -0000 1.1193.2.44 @@ -4,6 +4,15 @@ (editors: check NEWS.help for information about editing NEWS using ReST.) +What's New in Python 2.4.2a +=========================== + +Extension Modules +----------------- + +- weakref proxy has incorrect __nonzero__ behavior. SF bug #1770766. + + What's New in Python 2.4.1 final? ================================= From rhettinger at users.sourceforge.net Thu Mar 31 06:07:59 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Mar 31 06:08:03 2005 Subject: [Python-checkins] python/dist/src/Objects weakrefobject.c, 1.20, 1.20.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4856/Objects Modified Files: Tag: release24-maint weakrefobject.c Log Message: SF bug #1770766: weakref proxy has incorrect __nonzero__ behavior. Index: weakrefobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/weakrefobject.c,v retrieving revision 1.20 retrieving revision 1.20.2.1 diff -u -d -r1.20 -r1.20.2.1 --- weakrefobject.c 30 Oct 2004 23:09:22 -0000 1.20 +++ weakrefobject.c 31 Mar 2005 04:07:55 -0000 1.20.2.1 @@ -505,11 +505,7 @@ PyObject *o = PyWeakref_GET_OBJECT(proxy); if (!proxy_checkref(proxy)) 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); - else - return 1; + return PyObject_IsTrue(o); } static void From rhettinger at users.sourceforge.net Thu Mar 31 06:08:21 2005 From: rhettinger at users.sourceforge.net (rhettinger@users.sourceforge.net) Date: Thu Mar 31 06:08:25 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_weakref.py, 1.42, 1.42.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4856/Lib/test Modified Files: Tag: release24-maint test_weakref.py Log Message: SF bug #1770766: weakref proxy has incorrect __nonzero__ behavior. Index: test_weakref.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_weakref.py,v retrieving revision 1.42 retrieving revision 1.42.4.1 diff -u -d -r1.42 -r1.42.4.1 --- test_weakref.py 8 Jul 2004 01:22:31 -0000 1.42 +++ test_weakref.py 31 Mar 2005 04:07:47 -0000 1.42.4.1 @@ -271,6 +271,12 @@ del f[0] self.assertEqual(f.result, 0) + def test_proxy_bool(self): + # Test clearing of SF bug #1170766 + class List(list): pass + lyst = List() + self.assertEqual(bool(weakref.proxy(lyst)), bool(lyst)) + def test_getweakrefcount(self): o = C() ref1 = weakref.ref(o) From mwh at users.sourceforge.net Thu Mar 31 11:35:50 2005 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Thu Mar 31 11:35:54 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1279,1.1280 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12420 Modified Files: NEWS Log Message: NEWS entries for the bugs I fixed yesterday. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1279 retrieving revision 1.1280 diff -u -d -r1.1279 -r1.1280 --- NEWS 29 Mar 2005 13:47:59 -0000 1.1279 +++ NEWS 31 Mar 2005 09:35:44 -0000 1.1280 @@ -12,6 +12,9 @@ Core and builtins ----------------- +- Bug #1165306: instancemethod_new allowed the creation of a method + with im_class == im_self == NULL, which caused a crash when called. + - Move exception finalisation later in the shutdown process - this fixes the crash seen in bug #1165761 @@ -54,6 +57,9 @@ Extension Modules ----------------- +- Bug #1166660: The readline module could segfault if hook functions + were set in a different thread than that which called readline. + - collections.deque objects now support a remove() method. - operator.itemgetter() and operator.attrgetter() now support retrieving From mwh at users.sourceforge.net Thu Mar 31 12:20:42 2005 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Thu Mar 31 12:20:44 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.44, 1.1193.2.45 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3364/Misc Modified Files: Tag: release24-maint NEWS Log Message: Backport: Fixes for [ 1166660 ] The readline module can cause python to segfault It seems to me that the code I'm rewriting here attempted to call any user-supplied hook functions using the thread state of the thread that called the hook-setting function, as opposed to that of the thread that is currently executing. This doesn't work, in general. Fix this by using the PyGILState API (It wouldn't be that hard to define a dummy version of said API when #ifndef WITH_THREAD, would it?). Also, check the conversion to integer of the return value of a hook function for errors (this problem was mentioned in the ipython bug report linked to in the above bug). Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.44 retrieving revision 1.1193.2.45 diff -u -d -r1.1193.2.44 -r1.1193.2.45 --- NEWS 31 Mar 2005 04:07:48 -0000 1.1193.2.44 +++ NEWS 31 Mar 2005 10:20:34 -0000 1.1193.2.45 @@ -10,6 +10,9 @@ Extension Modules ----------------- +- Bug #1166660: The readline module could segfault if hook functions + were set in a different thread than that which called readline. + - weakref proxy has incorrect __nonzero__ behavior. SF bug #1770766. From mwh at users.sourceforge.net Thu Mar 31 12:21:07 2005 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Thu Mar 31 12:21:11 2005 Subject: [Python-checkins] python/dist/src/Modules readline.c, 2.79.2.1, 2.79.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3364/Modules Modified Files: Tag: release24-maint readline.c Log Message: Backport: Fixes for [ 1166660 ] The readline module can cause python to segfault It seems to me that the code I'm rewriting here attempted to call any user-supplied hook functions using the thread state of the thread that called the hook-setting function, as opposed to that of the thread that is currently executing. This doesn't work, in general. Fix this by using the PyGILState API (It wouldn't be that hard to define a dummy version of said API when #ifndef WITH_THREAD, would it?). Also, check the conversion to integer of the return value of a hook function for errors (this problem was mentioned in the ipython bug report linked to in the above bug). Index: readline.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/readline.c,v retrieving revision 2.79.2.1 retrieving revision 2.79.2.2 diff -u -d -r2.79.2.1 -r2.79.2.2 --- readline.c 27 Feb 2005 20:34:01 -0000 2.79.2.1 +++ readline.c 31 Mar 2005 10:20:33 -0000 2.79.2.2 @@ -161,8 +161,7 @@ /* Generic hook function setter */ static PyObject * -set_hook(const char *funcname, PyObject **hook_var, - PyThreadState **tstate, PyObject *args) +set_hook(const char *funcname, PyObject **hook_var, PyObject *args) { PyObject *function = Py_None; char buf[80]; @@ -172,14 +171,12 @@ if (function == Py_None) { Py_XDECREF(*hook_var); *hook_var = NULL; - *tstate = NULL; } else if (PyCallable_Check(function)) { PyObject *tmp = *hook_var; Py_INCREF(function); *hook_var = function; Py_XDECREF(tmp); - *tstate = PyThreadState_GET(); } else { PyOS_snprintf(buf, sizeof(buf), @@ -196,18 +193,15 @@ /* Exported functions to specify hook functions in Python */ static PyObject *startup_hook = NULL; -static PyThreadState *startup_hook_tstate = NULL; #ifdef HAVE_RL_PRE_INPUT_HOOK static PyObject *pre_input_hook = NULL; -static PyThreadState *pre_input_hook_tstate = NULL; #endif static PyObject * set_startup_hook(PyObject *self, PyObject *args) { - return set_hook("startup_hook", &startup_hook, - &startup_hook_tstate, args); + return set_hook("startup_hook", &startup_hook, args); } PyDoc_STRVAR(doc_set_startup_hook, @@ -224,8 +218,7 @@ static PyObject * set_pre_input_hook(PyObject *self, PyObject *args) { - return set_hook("pre_input_hook", &pre_input_hook, - &pre_input_hook_tstate, args); + return set_hook("pre_input_hook", &pre_input_hook, args); } PyDoc_STRVAR(doc_set_pre_input_hook, @@ -241,7 +234,6 @@ /* Exported function to specify a word completer in Python */ static PyObject *completer = NULL; -static PyThreadState *completer_tstate = NULL; static PyObject *begidx = NULL; static PyObject *endidx = NULL; @@ -405,7 +397,7 @@ static PyObject * set_completer(PyObject *self, PyObject *args) { - return set_hook("completer", &completer, &completer_tstate, args); + return set_hook("completer", &completer, args); } PyDoc_STRVAR(doc_set_completer, @@ -586,28 +578,33 @@ /* C function to call the Python hooks. */ static int -on_hook(PyObject *func, PyThreadState **tstate) +on_hook(PyObject *func) { int result = 0; if (func != NULL) { PyObject *r; - /* Note that readline is called with the interpreter - lock released! */ - PyEval_RestoreThread(*tstate); +#ifdef WITH_THREAD + PyGILState_STATE gilstate = PyGILState_Ensure(); +#endif r = PyObject_CallFunction(func, NULL); if (r == NULL) goto error; if (r == Py_None) result = 0; - else + else { result = PyInt_AsLong(r); + if (result == -1 && PyErr_Occurred()) + goto error; + } Py_DECREF(r); goto done; error: PyErr_Clear(); Py_XDECREF(r); done: - *tstate = PyEval_SaveThread(); +#ifdef WITH_THREAD + PyGILState_Release(gilstate); +#endif } return result; } @@ -615,14 +612,14 @@ static int on_startup_hook(void) { - return on_hook(startup_hook, &startup_hook_tstate); + return on_hook(startup_hook); } #ifdef HAVE_RL_PRE_INPUT_HOOK static int on_pre_input_hook(void) { - return on_hook(pre_input_hook, &pre_input_hook_tstate); + return on_hook(pre_input_hook); } #endif @@ -635,11 +632,9 @@ char *result = NULL; if (completer != NULL) { PyObject *r; - /* Note that readline is called with the interpreter - lock released! */ - PyEval_RestoreThread(completer_tstate); - /* Don't use the default filename completion if we - * have a custom completion function... */ +#ifdef WITH_THREAD + PyGILState_STATE gilstate = PyGILState_Ensure(); +#endif rl_attempted_completion_over = 1; r = PyObject_CallFunction(completer, "si", text, state); if (r == NULL) @@ -659,7 +654,9 @@ PyErr_Clear(); Py_XDECREF(r); done: - completer_tstate = PyEval_SaveThread(); +#ifdef WITH_THREAD + PyGILState_Release(gilstate); +#endif } return result; } From mwh at users.sourceforge.net Thu Mar 31 12:22:45 2005 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Thu Mar 31 12:22:48 2005 Subject: [Python-checkins] python/dist/src/Objects classobject.c, 2.176, 2.176.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5596/Objects Modified Files: Tag: release24-maint classobject.c Log Message: Backport: Fix for rather inaccurately titled bug [ 1165306 ] Property access with decorator makes interpreter crash Don't allow the creation of unbound methods with NULL im_class, because attempting to call such crashes. Backport candidate. Index: classobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v retrieving revision 2.176 retrieving revision 2.176.2.1 diff -u -d -r2.176 -r2.176.2.1 --- classobject.c 23 Sep 2004 02:39:36 -0000 2.176 +++ classobject.c 31 Mar 2005 10:22:42 -0000 2.176.2.1 @@ -2208,6 +2208,12 @@ } if (self == Py_None) self = NULL; + if (self == NULL && classObj == NULL) { + PyErr_SetString(PyExc_TypeError, + "unbound methods must have non-NULL im_class"); + return NULL; + } + return PyMethod_New(func, self, classObj); } From mwh at users.sourceforge.net Thu Mar 31 12:22:46 2005 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Thu Mar 31 12:22:49 2005 Subject: [Python-checkins] python/dist/src/Lib/test test_new.py, 1.19, 1.19.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5596/Lib/test Modified Files: Tag: release24-maint test_new.py Log Message: Backport: Fix for rather inaccurately titled bug [ 1165306 ] Property access with decorator makes interpreter crash Don't allow the creation of unbound methods with NULL im_class, because attempting to call such crashes. Backport candidate. Index: test_new.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_new.py,v retrieving revision 1.19 retrieving revision 1.19.2.1 diff -u -d -r1.19 -r1.19.2.1 --- test_new.py 13 Aug 2004 03:57:22 -0000 1.19 +++ test_new.py 31 Mar 2005 10:22:43 -0000 1.19.2.1 @@ -47,6 +47,16 @@ verify(c.get_yolks() == 1 and c.get_more_yolks() == 4, 'Broken call of hand-crafted instance method') +im = new.instancemethod(break_yolks, c) +im() +verify(c.get_yolks() == -1) +try: + new.instancemethod(break_yolks, None) +except TypeError: + pass +else: + raise TestFailed, "dangerous instance method creation allowed" + # It's unclear what the semantics should be for a code object compiled at # module scope, but bound and run in a function. In CPython, `c' is global # (by accident?) while in Jython, `c' is local. The intent of the test From mwh at users.sourceforge.net Thu Mar 31 12:28:34 2005 From: mwh at users.sourceforge.net (mwh@users.sourceforge.net) Date: Thu Mar 31 12:28:36 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.45, 1.1193.2.46 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8541 Modified Files: Tag: release24-maint NEWS Log Message: I meant to check this in with the last check in (CVS disturbs me sometimes) Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.45 retrieving revision 1.1193.2.46 diff -u -d -r1.1193.2.45 -r1.1193.2.46 --- NEWS 31 Mar 2005 10:20:34 -0000 1.1193.2.45 +++ NEWS 31 Mar 2005 10:28:30 -0000 1.1193.2.46 @@ -7,6 +7,14 @@ What's New in Python 2.4.2a =========================== +*Release date: XX-XXX-2005* + +Core and builtins +----------------- + +- Bug #1165306: instancemethod_new allowed the creation of a method + with im_class == im_self == NULL, which caused a crash when called. + Extension Modules ----------------- From doerwalter at users.sourceforge.net Thu Mar 31 15:57:41 2005 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Thu Mar 31 15:57:44 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils/command register.py, 1.8, 1.9 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27988/Lib/distutils/command Modified Files: register.py Log Message: Since PyPI only accepts UTF-8 encoded data now, make sure that the data is properly encoded and include the encoding in the Content-Type header. Index: register.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/register.py,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- register.py 20 Mar 2005 22:19:47 -0000 1.8 +++ register.py 31 Mar 2005 13:57:38 -0000 1.9 @@ -254,7 +254,7 @@ if type(value) != type([]): value = [value] for value in value: - value = str(value) + value = unicode(value).encode("utf-8") body.write(sep_boundary) body.write('\nContent-Disposition: form-data; name="%s"'%key) body.write("\n\n") @@ -267,7 +267,7 @@ # build the Request headers = { - 'Content-type': 'multipart/form-data; boundary=%s'%boundary, + 'Content-type': 'multipart/form-data; boundary=%s; charset=utf-8'%boundary, 'Content-length': str(len(body)) } req = urllib2.Request(self.repository, body, headers) From doerwalter at users.sourceforge.net Thu Mar 31 15:57:41 2005 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Thu Mar 31 15:57:45 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS,1.1280,1.1281 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27988/Misc Modified Files: NEWS Log Message: Since PyPI only accepts UTF-8 encoded data now, make sure that the data is properly encoded and include the encoding in the Content-Type header. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1280 retrieving revision 1.1281 diff -u -d -r1.1280 -r1.1281 --- NEWS 31 Mar 2005 09:35:44 -0000 1.1280 +++ NEWS 31 Mar 2005 13:57:35 -0000 1.1281 @@ -102,6 +102,9 @@ - distutils.commands.upload was added to support uploading distribution files to PyPI. +- distutils.commands.register now encodes the data as UTF-8 before posting + them to PyPI. + - decimal operator and comparison methods now return NotImplemented instead of raising a TypeError when interacting with other types. This allows other classes to implement __radd__ style methods and have them From doerwalter at users.sourceforge.net Thu Mar 31 16:16:33 2005 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Thu Mar 31 16:16:36 2005 Subject: [Python-checkins] python/dist/src/Misc NEWS, 1.1193.2.46, 1.1193.2.47 Message-ID: Update of /cvsroot/python/python/dist/src/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6022/Misc Modified Files: Tag: release24-maint NEWS Log Message: Backport checkin: Since PyPI only accepts UTF-8 encoded data now, make sure that the data is properly encoded and include the encoding in the Content-Type header. Index: NEWS =================================================================== RCS file: /cvsroot/python/python/dist/src/Misc/NEWS,v retrieving revision 1.1193.2.46 retrieving revision 1.1193.2.47 diff -u -d -r1.1193.2.46 -r1.1193.2.47 --- NEWS 31 Mar 2005 10:28:30 -0000 1.1193.2.46 +++ NEWS 31 Mar 2005 14:16:26 -0000 1.1193.2.47 @@ -23,6 +23,12 @@ - weakref proxy has incorrect __nonzero__ behavior. SF bug #1770766. +Library +------- + +- distutils.commands.register now encodes the data as UTF-8 before posting + them to PyPI. + What's New in Python 2.4.1 final? ================================= From doerwalter at users.sourceforge.net Thu Mar 31 16:16:33 2005 From: doerwalter at users.sourceforge.net (doerwalter@users.sourceforge.net) Date: Thu Mar 31 16:16:37 2005 Subject: [Python-checkins] python/dist/src/Lib/distutils/command register.py, 1.7, 1.7.4.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/distutils/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6022/Lib/distutils/command Modified Files: Tag: release24-maint register.py Log Message: Backport checkin: Since PyPI only accepts UTF-8 encoded data now, make sure that the data is properly encoded and include the encoding in the Content-Type header. Index: register.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/register.py,v retrieving revision 1.7 retrieving revision 1.7.4.1 diff -u -d -r1.7 -r1.7.4.1 --- register.py 18 Jul 2004 06:14:43 -0000 1.7 +++ register.py 31 Mar 2005 14:16:30 -0000 1.7.4.1 @@ -248,7 +248,7 @@ if type(value) != type([]): value = [value] for value in value: - value = str(value) + value = unicode(value).encode("utf-8") body.write(sep_boundary) body.write('\nContent-Disposition: form-data; name="%s"'%key) body.write("\n\n") @@ -261,7 +261,7 @@ # build the Request headers = { - 'Content-type': 'multipart/form-data; boundary=%s'%boundary, + 'Content-type': 'multipart/form-data; boundary=%s; charset=utf-8'%boundary, 'Content-length': str(len(body)) } req = urllib2.Request(self.repository, body, headers) From etrepum at users.sourceforge.net Thu Mar 31 19:38:11 2005 From: etrepum at users.sourceforge.net (etrepum@users.sourceforge.net) Date: Thu Mar 31 19:38:14 2005 Subject: [Python-checkins] python/dist/src/Mac/OSX/Dist/resources postflight, 1.7, 1.7.8.1 Message-ID: Update of /cvsroot/python/python/dist/src/Mac/OSX/Dist/resources In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25906/resources Modified Files: Tag: release24-maint postflight Log Message: (This is only relevant to the MacPython binary release process) Set the Python version to 2.4 in the postflight script used when building Mac OS X installer distributions. Previously it was set to 2.3, so it wouldn't build a working installer. Index: postflight =================================================================== RCS file: /cvsroot/python/python/dist/src/Mac/OSX/Dist/resources/postflight,v retrieving revision 1.7 retrieving revision 1.7.8.1 diff -u -d -r1.7 -r1.7.8.1 --- postflight 23 Jul 2003 10:49:17 -0000 1.7 +++ postflight 31 Mar 2005 17:38:00 -0000 1.7.8.1 @@ -4,7 +4,7 @@ # installed. #---------------------------------------------------------------------- -PYVER=2.3 +PYVER=2.4 PKG=$1 DEST=$2 From vsajip at users.sourceforge.net Thu Mar 31 22:10:49 2005 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Thu Mar 31 22:10:52 2005 Subject: [Python-checkins] python/dist/src/Lib/logging __init__.py, 1.24, 1.24.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/logging In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17920 Modified Files: Tag: release24-maint __init__.py Log Message: Misc. changes Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/logging/__init__.py,v retrieving revision 1.24 retrieving revision 1.24.2.1 diff -u -d -r1.24 -r1.24.2.1 --- __init__.py 21 Oct 2004 21:24:27 -0000 1.24 +++ __init__.py 31 Mar 2005 20:10:38 -0000 1.24.2.1 @@ -1,4 +1,4 @@ -# Copyright 2001-2004 by Vinay Sajip. All Rights Reserved. +# Copyright 2001-2005 by Vinay Sajip. All Rights Reserved. # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose and without fee is hereby granted, @@ -26,7 +26,12 @@ To use, simply 'import logging' and log away! """ -import sys, os, types, time, string, cStringIO +import sys, os, types, time, string, cStringIO, traceback + +try: + import codecs +except ImportError: + codecs = None try: import thread @@ -37,14 +42,14 @@ __author__ = "Vinay Sajip " __status__ = "beta" __version__ = "0.4.9.6" -__date__ = "20 October 2004" +__date__ = "27 March 2005" #--------------------------------------------------------------------------- # Miscellaneous module data #--------------------------------------------------------------------------- # -#_srcfile is used when walking the stack to check when we've got the first +# _srcfile is used when walking the stack to check when we've got the first # caller stack frame. # if string.lower(__file__[-4:]) in ['.pyc', '.pyo']: @@ -53,12 +58,23 @@ _srcfile = __file__ _srcfile = os.path.normcase(_srcfile) +# next bit filched from 1.5.2's inspect.py +def currentframe(): + """Return the frame object for the caller's stack frame.""" + try: + raise 'catch me' + except: + return sys.exc_traceback.tb_frame.f_back + +if hasattr(sys, '_getframe'): currentframe = sys._getframe +# done filching + # _srcfile is only used in conjunction with sys._getframe(). # To provide compatibility with older versions of Python, set _srcfile # to None if _getframe() is not available; this value will prevent # findCaller() from being called. -if not hasattr(sys, "_getframe"): - _srcfile = None +#if not hasattr(sys, "_getframe"): +# _srcfile = None # #_startTime is used as the base when calculating the relative time of events @@ -81,6 +97,7 @@ # loggers are initialized with NOTSET so that they will log all messages, even # at user-defined levels. # + CRITICAL = 50 FATAL = CRITICAL ERROR = 40 @@ -224,8 +241,10 @@ self.relativeCreated = (self.created - _startTime) * 1000 if thread: self.thread = thread.get_ident() + self.threadName = threading.currentThread().getName() else: self.thread = None + self.threadName = None if hasattr(os, 'getpid'): self.process = os.getpid() else: @@ -303,6 +322,7 @@ relative to the time the logging module was loaded (typically at application startup time) %(thread)d Thread ID (if available) + %(threadName)s Thread name (if available) %(process)d Process ID (if available) %(message)s The result of record.getMessage(), computed just as the record is emitted @@ -357,7 +377,6 @@ This default implementation just uses traceback.print_exception() """ - import traceback sio = cStringIO.StringIO() traceback.print_exception(ei[0], ei[1], ei[2], None, sio) s = sio.getvalue() @@ -554,7 +573,7 @@ Acquire a thread lock for serializing access to the underlying I/O. """ if thread: - self.lock = thread.allocate_lock() + self.lock = threading.RLock() else: self.lock = None @@ -663,7 +682,6 @@ The record which was being processed is passed in to this method. """ if raiseExceptions: - import traceback ei = sys.exc_info() traceback.print_exception(ei[0], ei[1], ei[2], None, sys.stderr) del ei @@ -720,11 +738,17 @@ """ A handler class which writes formatted logging records to disk files. """ - def __init__(self, filename, mode="a"): + def __init__(self, filename, mode='a', encoding=None): """ Open the specified file and use it as the stream for logging. """ - StreamHandler.__init__(self, open(filename, mode)) + if codecs is None: + encoding = None + if encoding is None: + stream = open(filename, mode) + else: + stream = codecs.open(filename, mode, encoding) + StreamHandler.__init__(self, stream) #keep the absolute path, otherwise derived classes which use this #may come a cropper when the current directory changes self.baseFilename = os.path.abspath(filename) @@ -1005,16 +1029,16 @@ def findCaller(self): """ Find the stack frame of the caller so that we can note the source - file name and line number. + file name, line number and function name. """ - f = sys._getframe(1) + f = currentframe().f_back while 1: co = f.f_code filename = os.path.normcase(co.co_filename) if filename == _srcfile: f = f.f_back continue - return filename, f.f_lineno + return filename, f.f_lineno, co.co_name def makeRecord(self, name, level, fn, lno, msg, args, exc_info): """ @@ -1029,9 +1053,9 @@ all the handlers of this logger to handle the record. """ if _srcfile: - fn, lno = self.findCaller() + fn, lno, func = self.findCaller() else: - fn, lno = "", 0 + fn, lno, func = "(unknown file)", 0, "(unknown function)" if exc_info: if type(exc_info) != types.TupleType: exc_info = sys.exc_info() @@ -1153,7 +1177,7 @@ filename Specifies that a FileHandler be created, using the specified filename, rather than a StreamHandler. filemode Specifies the mode to open the file, if filename is specified - (if filemode is unspecified, it defaults to "a"). + (if filemode is unspecified, it defaults to 'a'). format Use the specified format string for the handler. datefmt Use the specified date/time format. level Set the root logger level to the specified level. @@ -1170,7 +1194,7 @@ if len(root.handlers) == 0: filename = kwargs.get("filename") if filename: - mode = kwargs.get("filemode", "a") + mode = kwargs.get("filemode", 'a') hdlr = FileHandler(filename, mode) else: stream = kwargs.get("stream") From vsajip at users.sourceforge.net Thu Mar 31 22:11:49 2005 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Thu Mar 31 22:11:51 2005 Subject: [Python-checkins] python/dist/src/Lib/logging config.py, 1.10, 1.10.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/logging In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18372 Modified Files: Tag: release24-maint config.py Log Message: Minor changes to imports Index: config.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/logging/config.py,v retrieving revision 1.10 retrieving revision 1.10.2.1 diff -u -d -r1.10 -r1.10.2.1 --- config.py 24 Sep 2004 11:45:13 -0000 1.10 +++ config.py 31 Mar 2005 20:11:45 -0000 1.10.2.1 @@ -1,4 +1,4 @@ -# Copyright 2001-2004 by Vinay Sajip. All Rights Reserved. +# Copyright 2001-2005 by Vinay Sajip. All Rights Reserved. # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose and without fee is hereby granted, @@ -27,7 +27,13 @@ To use, simply 'import logging' and log away! """ -import sys, logging, logging.handlers, string, thread, threading, socket, struct, os +import sys, logging, logging.handlers, string, socket, struct, os, traceback + +try: + import thread + import threading +except ImportError: + thread = None from SocketServer import ThreadingTCPServer, StreamRequestHandler @@ -189,7 +195,6 @@ for log in existing: root.manager.loggerDict[log].disabled = 1 except: - import traceback ei = sys.exc_info() traceback.print_exception(ei[0], ei[1], ei[2], None, sys.stderr) del ei From vsajip at users.sourceforge.net Thu Mar 31 22:12:58 2005 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Thu Mar 31 22:13:01 2005 Subject: [Python-checkins] python/dist/src/Lib/logging handlers.py, 1.19, 1.19.2.1 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/logging In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19200 Modified Files: Tag: release24-maint handlers.py Log Message: Added optional encoding argument to File based handlers and improved error handling for SysLogHandler Index: handlers.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/logging/handlers.py,v retrieving revision 1.19 retrieving revision 1.19.2.1 diff -u -d -r1.19 -r1.19.2.1 --- handlers.py 3 Oct 2004 19:12:07 -0000 1.19 +++ handlers.py 31 Mar 2005 20:12:55 -0000 1.19.2.1 @@ -1,4 +1,4 @@ -# Copyright 2001-2004 by Vinay Sajip. All Rights Reserved. +# Copyright 2001-2005 by Vinay Sajip. All Rights Reserved. # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose and without fee is hereby granted, @@ -29,6 +29,11 @@ import sys, logging, socket, types, os, string, cPickle, struct, time, glob +try: + import codecs +except ImportError: + codecs = None + # # Some constants... # @@ -45,11 +50,15 @@ Not meant to be instantiated directly. Instead, use RotatingFileHandler or TimedRotatingFileHandler. """ - def __init__(self, filename, mode): + def __init__(self, filename, mode, encoding=None): """ Use the specified filename for streamed logging """ - logging.FileHandler.__init__(self, filename, mode) + if codecs is None: + encoding = None + logging.FileHandler.__init__(self, filename, mode, encoding) + self.mode = mode + self.encoding = encoding def emit(self, record): """ @@ -70,7 +79,7 @@ Handler for logging to a set of files, which switches from one file to the next when the current file reaches a certain size. """ - def __init__(self, filename, mode="a", maxBytes=0, backupCount=0): + def __init__(self, filename, mode='a', maxBytes=0, backupCount=0, encoding=None): """ Open the specified file and use it as the stream for logging. @@ -91,10 +100,9 @@ If maxBytes is zero, rollover never occurs. """ - self.mode = mode if maxBytes > 0: - self.mode = "a" # doesn't make sense otherwise! - BaseRotatingHandler.__init__(self, filename, self.mode) + mode = 'a' # doesn't make sense otherwise! + BaseRotatingHandler.__init__(self, filename, mode, encoding) self.maxBytes = maxBytes self.backupCount = backupCount @@ -118,7 +126,10 @@ os.remove(dfn) os.rename(self.baseFilename, dfn) #print "%s -> %s" % (self.baseFilename, dfn) - self.stream = open(self.baseFilename, "w") + if self.encoding: + self.stream = codecs.open(self.baseFilename, 'w', self.encoding) + else: + self.stream = open(self.baseFilename, 'w') def shouldRollover(self, record): """ @@ -142,8 +153,8 @@ If backupCount is > 0, when rollover is done, no more than backupCount files are kept - the oldest ones are deleted. """ - def __init__(self, filename, when='h', interval=1, backupCount=0): - BaseRotatingHandler.__init__(self, filename, 'a') + def __init__(self, filename, when='h', interval=1, backupCount=0, encoding=None): + BaseRotatingHandler.__init__(self, filename, 'a', encoding) self.when = string.upper(when) self.backupCount = backupCount # Calculate the real rollover interval, which is just the number of @@ -262,7 +273,10 @@ s.sort() os.remove(s[0]) #print "%s -> %s" % (self.baseFilename, dfn) - self.stream = open(self.baseFilename, "w") + if self.encoding: + self.stream = codecs.open(self.baseFilename, 'w', self.encoding) + else: + self.stream = open(self.baseFilename, 'w') self.rolloverAt = int(time.time()) + self.interval class SocketHandler(logging.Handler): @@ -555,14 +569,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 +577,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 +632,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 vsajip at users.sourceforge.net Thu Mar 31 22:16:58 2005 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Thu Mar 31 22:17:02 2005 Subject: [Python-checkins] python/dist/src/Lib/logging __init__.py, 1.26, 1.27 Message-ID: Update of /cvsroot/python/python/dist/src/Lib/logging In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20593 Modified Files: __init__.py Log Message: Added threadName and now using re-entrant lock Index: __init__.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/logging/__init__.py,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- __init__.py 13 Mar 2005 09:54:31 -0000 1.26 +++ __init__.py 31 Mar 2005 20:16:55 -0000 1.27 @@ -42,7 +42,7 @@ __author__ = "Vinay Sajip " __status__ = "beta" __version__ = "0.4.9.6" -__date__ = "12 March 2005" +__date__ = "27 March 2005" #--------------------------------------------------------------------------- # Miscellaneous module data @@ -241,8 +241,10 @@ self.relativeCreated = (self.created - _startTime) * 1000 if thread: self.thread = thread.get_ident() + self.threadName = threading.currentThread().getName() else: self.thread = None + self.threadName = None if hasattr(os, 'getpid'): self.process = os.getpid() else: @@ -320,6 +322,7 @@ relative to the time the logging module was loaded (typically at application startup time) %(thread)d Thread ID (if available) + %(threadName)s Thread name (if available) %(process)d Process ID (if available) %(message)s The result of record.getMessage(), computed just as the record is emitted @@ -570,7 +573,7 @@ Acquire a thread lock for serializing access to the underlying I/O. """ if thread: - self.lock = thread.allocate_lock() + self.lock = threading.RLock() else: self.lock = None From vsajip at users.sourceforge.net Thu Mar 31 22:18:11 2005 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Thu Mar 31 22:18:15 2005 Subject: [Python-checkins] python/dist/src/Doc/lib liblogging.tex,1.35,1.36 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20919 Modified Files: liblogging.tex Log Message: Added threadName to LogRecord Index: liblogging.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liblogging.tex,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- liblogging.tex 18 Feb 2005 11:50:11 -0000 1.35 +++ liblogging.tex 31 Mar 2005 20:18:06 -0000 1.36 @@ -1268,6 +1268,7 @@ \lineii{\%(msecs)d} {Millisecond portion of the time when the \class{LogRecord} was created.} \lineii{\%(thread)d} {Thread ID (if available).} +\lineii{\%(threadName)s} {Thread name (if available).} \lineii{\%(process)d} {Process ID (if available).} \lineii{\%(message)s} {The logged message, computed as \code{msg \% args}.} \end{tableii} From vsajip at users.sourceforge.net Thu Mar 31 22:23:11 2005 From: vsajip at users.sourceforge.net (vsajip@users.sourceforge.net) Date: Thu Mar 31 22:23:14 2005 Subject: [Python-checkins] python/dist/src/Doc/lib liblogging.tex, 1.33.2.1, 1.33.2.2 Message-ID: Update of /cvsroot/python/python/dist/src/Doc/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24216 Modified Files: Tag: release24-maint liblogging.tex Log Message: Corrected SMTPHandler docs and added info about threadName attribute of LogRecord Index: liblogging.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/liblogging.tex,v retrieving revision 1.33.2.1 retrieving revision 1.33.2.2 diff -u -d -r1.33.2.1 -r1.33.2.2 --- liblogging.tex 3 Dec 2004 08:23:36 -0000 1.33.2.1 +++ liblogging.tex 31 Mar 2005 20:23:04 -0000 1.33.2.2 @@ -1133,8 +1133,7 @@ \begin{classdesc}{SMTPHandler}{mailhost, fromaddr, toaddrs, subject} Returns a new instance of the \class{SMTPHandler} class. The instance is initialized with the from and to addresses and subject -line of the email. The \var{toaddrs} should be a list of strings without -domain names (That's what the \var{mailhost} is for). To specify a +line of the email. The \var{toaddrs} should be a list of strings. To specify a non-standard SMTP port, use the (host, port) tuple format for the \var{mailhost} argument. If you use a string, the standard SMTP port is used. @@ -1269,6 +1268,7 @@ \lineii{\%(msecs)d} {Millisecond portion of the time when the \class{LogRecord} was created.} \lineii{\%(thread)d} {Thread ID (if available).} +\lineii{\%(threadName)s} {Thread name (if available).} \lineii{\%(process)d} {Process ID (if available).} \lineii{\%(message)s} {The logged message, computed as \code{msg \% args}.} \end{tableii} From python at rcn.com Thu Mar 31 23:00:19 2005 From: python at rcn.com (Raymond Hettinger) Date: Thu Mar 31 23:05:21 2005 Subject: [Python-checkins] python/dist/src/Lib/logging handlers.py, 1.19, 1.19.2.1 In-Reply-To: Message-ID: <003101c53634$a60b87e0$d2bc958d@oemcomputer> > Tag: release24-maint > handlers.py > Log Message: > Added optional encoding argument to File based handlers and improved error > handling for SysLogHandler Are you sure you want to backport an API change and new feature? Raymond